summaryrefslogtreecommitdiff
path: root/src/first_network_device.c
diff options
context:
space:
mode:
authorIngo Bürk <admin@airblader.de>2018-03-27 09:27:43 +0200
committerGitHub <noreply@github.com>2018-03-27 09:27:43 +0200
commit5abed8241987a1cb77a4e8e6856f4c7efad3ef0b (patch)
tree7a370fcf9448ef002710110959d41bdc2acbcfce /src/first_network_device.c
parent279e2fccf4c3bf48edd6a0ac68778ec235831599 (diff)
parent4345fa9d9715a912c55828565783311e3fab4f0f (diff)
Merge pull request #264 from foutaise/master
Make iface_type() work on FreeBSD
Diffstat (limited to 'src/first_network_device.c')
-rw-r--r--src/first_network_device.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/first_network_device.c b/src/first_network_device.c
index 1ed50a2..b930f53 100644
--- a/src/first_network_device.c
+++ b/src/first_network_device.c
@@ -14,10 +14,10 @@
#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,22 +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;
-#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
@@ -124,6 +109,23 @@ static net_type_t iface_type(const char *ifname) {
close(s);
return NET_TYPE_ETHERNET;
}
+#else
+ 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
return NET_TYPE_OTHER;
}