diff options
author | Jonathan McCrohan <jmccrohan@gmail.com> | 2016-01-30 17:08:40 +0000 |
---|---|---|
committer | Jonathan McCrohan <jmccrohan@gmail.com> | 2016-01-30 17:08:40 +0000 |
commit | 0b0aac6ce21bcb38d7e03dc2b3ff419861476a24 (patch) | |
tree | caa65d08ef64dfd060a749ccc690efd7bcc2a7b3 /scan_scr.c | |
parent | d7ca0c3e555ef0b5250873ddce48ccf2326b017a (diff) | |
download | wavemon-0b0aac6ce21bcb38d7e03dc2b3ff419861476a24.tar.gz |
Imported Upstream version 0.8.0upstream/0.8.0
Diffstat (limited to '')
-rw-r--r-- | scan_scr.c | 78 |
1 files changed, 51 insertions, 27 deletions
@@ -36,37 +36,56 @@ static void fmt_scan_entry(struct scan_entry *cur, char buf[], size_t buflen) { size_t len = 0; - if (!(cur->qual.updated & (IW_QUAL_QUAL_INVALID|IW_QUAL_LEVEL_INVALID))) - len += snprintf(buf + len, buflen - len, "%3.0f%%, %.0f dBm", - 1E2 * cur->qual.qual / sr.range.max_qual.qual, - cur->dbm.signal); - else if (!(cur->qual.updated & IW_QUAL_QUAL_INVALID)) + if (cur->bss_signal) { + float sig_qual, sig_qual_max; + + if (cur->bss_signal_qual) { + /* BSS_SIGNAL_UNSPEC is scaled 0..100 */ + sig_qual = cur->bss_signal_qual; + sig_qual_max = 100; + } else { + if (cur->bss_signal < -110) + sig_qual = 0; + else if (cur->bss_signal > -40) + sig_qual = 70; + else + sig_qual = cur->bss_signal + 110; + sig_qual_max = 70; + } + len += snprintf(buf + len, buflen - len, "%3.0f%%, %d dBm", + (1E2 * sig_qual)/ sig_qual_max, cur->bss_signal); + } else if (cur->bss_signal_qual) { len += snprintf(buf + len, buflen - len, "%2d/%d", - cur->qual.qual, sr.range.max_qual.qual); - else if (!(cur->qual.updated & IW_QUAL_LEVEL_INVALID)) - len += snprintf(buf + len, buflen - len, "%.0f dBm", - cur->dbm.signal); - else + cur->bss_signal_qual, 100); + } else { len += snprintf(buf + len, buflen - len, "? dBm"); + } - if (cur->freq < 1e3) - len += snprintf(buf + len, buflen - len, ", Chan %2.0f", - cur->freq); - else if (cur->chan >= 0) - len += snprintf(buf + len, buflen - len, ", %s %3d, %g MHz", - cur->freq < 5e9 ? "ch" : "CH", - cur->chan, cur->freq / 1e6); + if (cur->chan >= 0) + len += snprintf(buf + len, buflen - len, ", %s %3d, %d MHz", + cur->freq < 5e6 ? "ch" : "CH", + cur->chan, cur->freq); else len += snprintf(buf + len, buflen - len, ", %g GHz", - cur->freq / 1e9); - - /* Access Points are marked by CP_SCAN_CRYPT/CP_SCAN_UNENC already */ - if (cur->mode != IW_MODE_MASTER) - len += snprintf(buf + len, buflen - len, " %s", - iw_opmode(cur->mode)); - if (cur->flags) - len += snprintf(buf + len, buflen - len, ", %s", - format_enc_capab(cur->flags, "/")); + cur->freq / 1e3); + + if (cur->bss_capa & WLAN_CAPABILITY_ESS) { + if (cur->bss_sta_count || cur->bss_chan_usage > 2) { + if (cur->bss_sta_count) + len += snprintf(buf + len, buflen - len, " %u sta", cur->bss_sta_count); + if (cur->bss_chan_usage > 2) /* 1% is 2.55 */ + len += snprintf(buf + len, buflen - len, "%s %.0f%% chan", + cur->bss_sta_count? "," : "", (1e2 * cur->bss_chan_usage)/2.55e2); + } else { + len += snprintf(buf + len, buflen - len, " ESS"); + } + if (cur->bss_capa & WLAN_CAPABILITY_RADIO_MEASURE) + len += snprintf(buf + len, buflen - len, ", Radio Measure"); + if (cur->bss_capa & WLAN_CAPABILITY_SPECTRUM_MGMT) + len += snprintf(buf + len, buflen - len, ", Spectrum Mgmt"); + } else if (cur->bss_capa & WLAN_CAPABILITY_IBSS) { + len += snprintf(buf + len, buflen - len, " IBSS"); + } } static void display_aplist(WINDOW *w_aplst) @@ -75,6 +94,7 @@ static void display_aplist(WINDOW *w_aplst) const char *sort_type[] = { [SO_CHAN] = "Chan", [SO_SIGNAL] = "Sig", + [SO_MAC] = "Mac", [SO_ESSID] = "Essid", [SO_OPEN] = "Open", [SO_CHAN_SIG] = "Ch/Sg", @@ -100,8 +120,9 @@ static void display_aplist(WINDOW *w_aplst) for (cur = sr.head; cur && line < MAXYLEN; line++, cur = cur->next) { col = CP_SCAN_NON_AP; - if (cur->mode == IW_MODE_MASTER) + if (!WLAN_CAPABILITY_IS_STA_BSS(cur->bss_capa) && (cur->bss_capa & WLAN_CAPABILITY_ESS)) { col = cur->has_key ? CP_SCAN_CRYPT : CP_SCAN_UNENC; + } wmove(w_aplst, line, 1); if (!*cur->essid) { @@ -209,6 +230,9 @@ int scr_aplst_loop(WINDOW *w_menu) case 'e': /* ESSID */ conf.scan_sort_order = SO_ESSID; return -1; + case 'm': /* MAC address */ + conf.scan_sort_order = SO_MAC; + return -1; case 'o': /* open (descending is default) */ conf.scan_sort_order = SO_OPEN; conf.scan_sort_asc = false; |