71 lines
1.9 KiB
Plaintext
71 lines
1.9 KiB
Plaintext
$OpenBSD: patch-src_info_c,v 1.4 2012/04/03 15:10:40 jasper Exp $
|
|
|
|
https://bugzilla.gnome.org/show_bug.cgi?id=652713
|
|
|
|
--- src/info.c.orig Tue Jan 3 10:10:16 2012
|
|
+++ src/info.c Tue Jan 3 10:50:22 2012
|
|
@@ -20,6 +20,12 @@
|
|
#include <gtk/gtk.h>
|
|
#include <glib/gi18n.h>
|
|
#include <glib/gprintf.h>
|
|
+#if defined (__FreeBSD__) || defined (__OpenBSD__)
|
|
+#include <sys/types.h>
|
|
+#include <string.h>
|
|
+#include <errno.h>
|
|
+#include <unistd.h>
|
|
+#endif
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
# include <config.h>
|
|
@@ -37,6 +43,9 @@
|
|
#include <sys/ioctl.h>
|
|
#include <stdlib.h>
|
|
#include <net/if.h>
|
|
+#if defined (__FreeBSD__) || defined (__OpenBSD__)
|
|
+#include <net/if_media.h>
|
|
+#endif
|
|
|
|
#include <glibtop.h>
|
|
#include <glibtop/netlist.h>
|
|
@@ -131,9 +140,39 @@ info_get_interface_from_dev_name (const gchar *dev_nam
|
|
{
|
|
gint i;
|
|
gchar *path;
|
|
+ gchar *dev_type = NULL;
|
|
|
|
+#if defined (__FreeBSD__) || defined (__OpenBSD__)
|
|
+ int s;
|
|
+ struct ifmediareq ifmr;
|
|
+
|
|
+ if ((s = socket (AF_INET, SOCK_DGRAM, 0)) > -1) {
|
|
+
|
|
+ (void) memset (&ifmr, 0, sizeof (ifmr));
|
|
+ (void) strncpy (ifmr.ifm_name, dev_name, sizeof (ifmr.ifm_name));
|
|
+
|
|
+ if (ioctl (s, SIOCGIFMEDIA, (caddr_t) &ifmr) > -1) {
|
|
+ switch (IFM_TYPE (ifmr.ifm_active)) {
|
|
+ case IFM_ETHER:
|
|
+ dev_type = "eth";
|
|
+ break;
|
|
+ case IFM_IEEE80211:
|
|
+ dev_type = "wlan";
|
|
+ break;
|
|
+ default:
|
|
+ dev_type = "other_type";
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ close (s);
|
|
+ }
|
|
+#endif /* defined (__FreeBSD__) || defined (__OpenBSD__) */
|
|
+
|
|
+ if (!dev_type)
|
|
+ dev_type = (gchar *) dev_name;
|
|
+
|
|
for (i = 0; info_iface_desc[i].name; i++)
|
|
- if (strstr (dev_name, info_iface_desc[i].prefix) == dev_name) {
|
|
+ if (strstr (dev_type, info_iface_desc[i].prefix) == dev_type) {
|
|
(*iface) = g_strdup_printf ("%s (%s)", _(info_iface_desc[i].name), dev_name);
|
|
if (info_iface_desc[i].pixbuf == NULL) {
|
|
path = g_build_filename (PIXMAPS_DIR, info_iface_desc[i].icon, NULL);
|