X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fprint_wireless_info.c;h=9ab9c2f38786f8132d448f69ba7b3f4cb96155d2;hb=0eeded8bc013857a5e8a2efbc20002a22502897e;hp=b5e7ba26e9d6a9ecc63fc8c1fd2d25707b8f0baf;hpb=794151cfe76f80fb2c7eebb8d3fbbce8fc5ccb09;p=i3%2Fi3status diff --git a/src/print_wireless_info.c b/src/print_wireless_info.c index b5e7ba2..9ab9c2f 100644 --- a/src/print_wireless_info.c +++ b/src/print_wireless_info.c @@ -25,6 +25,19 @@ #define IW_ESSID_MAX_SIZE IEEE80211_NWID_LEN #endif +#ifdef __DragonFly__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define IW_ESSID_MAX_SIZE IEEE80211_NWID_LEN +#endif + #ifdef __OpenBSD__ #include #include @@ -170,7 +183,7 @@ static int get_wireless_info(const char *interface, wireless_info_t *info) { 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; @@ -305,6 +318,15 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface, 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; + } else { + START_COLOR("color_good"); + } + if (get_wireless_info(interface, &info)) { walk = format_up; if (info.flags & WIRELESS_INFO_FLAG_HAS_QUALITY) @@ -366,9 +388,8 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface, } 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 @@ -383,6 +404,7 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface, #endif } +out: END_COLOR; OUTPUT_FULL_TEXT(buffer); }