aboutsummaryrefslogtreecommitdiffstats
path: root/scan_scr.c
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2016-01-30 17:08:40 +0000
committerJonathan McCrohan <jmccrohan@gmail.com>2016-01-30 17:08:40 +0000
commit947da597663e60b0a214d96bfcadc0cd042a49ff (patch)
treef4d3df7b9f3e41ee4beed2e049d9b52031404b8e /scan_scr.c
parentcec92f1a82b9f29ec16a4c03c37487c7cb019acf (diff)
parent0b0aac6ce21bcb38d7e03dc2b3ff419861476a24 (diff)
downloadwavemon-947da597663e60b0a214d96bfcadc0cd042a49ff.tar.gz
Merge tag 'upstream/0.8.0'
Upstream version 0.8.0
Diffstat (limited to 'scan_scr.c')
-rw-r--r--scan_scr.c78
1 files changed, 51 insertions, 27 deletions
diff --git a/scan_scr.c b/scan_scr.c
index 611a32f..6373b6a 100644
--- a/scan_scr.c
+++ b/scan_scr.c
@@ -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;