#define IW_ESSID_MAX_SIZE IEEE80211_NWID_LEN
#endif
+#ifdef __DragonFly__
+#include <sys/param.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <ifaddrs.h>
+#include <net/if.h>
+#include <net/if_media.h>
+#include <netproto/802_11/ieee80211.h>
+#include <netproto/802_11/ieee80211_ioctl.h>
+#include <unistd.h>
+#define IW_ESSID_MAX_SIZE IEEE80211_NWID_LEN
+#endif
+
#ifdef __OpenBSD__
#include <sys/ioctl.h>
#include <sys/socket.h>
info->essid[IW_ESSID_MAX_SIZE] = '\0';
}
+ /* If the function iw_get_stats does not return proper stats, the
+ wifi is considered as down.
+ Since ad-hoc network does not have theses stats, we need to return
+ here for this mode. */
+ if (wcfg.mode == 1) {
+ close(skfd);
+ return 1;
+ }
+
/* Wireless quality is a relative value in a driver-specific range.
Signal and noise level can be either relative or absolute values
in dBm. Furthermore, noise and quality can be expressed directly
close(skfd);
return 1;
#endif
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__)
int s, len, inwid;
uint8_t buf[24 * 1024], *cp;
struct ieee80211req na;
INSTANCE(interface);
+ const char *ip_address = get_ip_addr(interface);
+ if (ip_address == NULL) {
+ START_COLOR("color_bad");
+ outwalk += sprintf(outwalk, "%s", format_down);
+ goto out;
+ }
+
if (get_wireless_info(interface, &info)) {
walk = format_up;
if (info.flags & WIRELESS_INFO_FLAG_HAS_QUALITY)
START_COLOR((info.quality < info.quality_average ? "color_degraded" : "color_good"));
- }
- else {
+ else
+ START_COLOR("color_good");
+ } else {
walk = format_down;
START_COLOR("color_bad");
}
}
if (BEGINS_WITH(walk+1, "ip")) {
- const char *ip_address = get_ip_addr(interface);
- outwalk += sprintf(outwalk, "%s", (ip_address ? ip_address : "no IP"));
- walk += strlen("ip");
+ outwalk += sprintf(outwalk, "%s", ip_address);
+ walk += strlen("ip");
}
#ifdef LINUX
#endif
}
+out:
END_COLOR;
OUTPUT_FULL_TEXT(buffer);
}