]> git.sur5r.net Git - i3/i3status/commitdiff
Make iface_type() work on FreeBSD
authorGerome Fournier <jef@foutaise.org>
Wed, 7 Feb 2018 10:26:34 +0000 (11:26 +0100)
committerGerome Fournier <jef@foutaise.org>
Wed, 7 Feb 2018 10:26:34 +0000 (11:26 +0100)
src/first_network_device.c

index 3f34cf2ed1bc031221389278f1d9ccca62d22f4e..430f1d5b5418100353e1df6a77e69d3a52da3cc5 100644 (file)
 
 #include "i3status.h"
 
-#ifdef __linux__
-#define LOOPBACK_DEV "lo"
-#else
+#ifdef __OpenBSD__
 #define LOOPBACK_DEV "lo0"
+#else
+#define LOOPBACK_DEV "lo"
 #endif
 
 static bool sysfs_devtype(char *dest, size_t n, const char *ifnam) {
@@ -67,24 +67,7 @@ static bool is_virtual(const char *ifname) {
 }
 
 static net_type_t iface_type(const char *ifname) {
-#ifdef __linux__
-    char devtype[32];
-
-    if (!sysfs_devtype(devtype, sizeof(devtype), ifname))
-        return NET_TYPE_OTHER;
-
-    /* Default to Ethernet when no devtype is available */
-    if (!devtype[0])
-        return NET_TYPE_ETHERNET;
-
-    if (strcmp(devtype, "wlan") == 0)
-        return NET_TYPE_WIRELESS;
-
-    if (strcmp(devtype, "wwan") == 0)
-        return NET_TYPE_OTHER;
-
-    return NET_TYPE_OTHER;
-#elif __OpenBSD__
+#ifdef __OpenBSD__
     /*
      *First determine if the device is a wireless device by trying two ioctl(2)
      * commands against it. If either succeeds we can be sure it's a wireless
@@ -127,7 +110,22 @@ static net_type_t iface_type(const char *ifname) {
         return NET_TYPE_ETHERNET;
     }
 #else
-#error Missing implementation to determine interface type.
+    char devtype[32];
+
+    if (!sysfs_devtype(devtype, sizeof(devtype), ifname))
+        return NET_TYPE_OTHER;
+
+    /* Default to Ethernet when no devtype is available */
+    if (!devtype[0])
+        return NET_TYPE_ETHERNET;
+
+    if (strcmp(devtype, "wlan") == 0)
+        return NET_TYPE_WIRELESS;
+
+    if (strcmp(devtype, "wwan") == 0)
+        return NET_TYPE_OTHER;
+
+    return NET_TYPE_OTHER;
 #endif
 }