aboutsummaryrefslogtreecommitdiffstats
path: root/scan_scr.c
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2012-05-06 21:13:09 +0100
committerJonathan McCrohan <jmccrohan@gmail.com>2012-05-06 21:13:09 +0100
commit3645c236e9720deb696e7aebc33cd9a6d8cbbdc6 (patch)
tree4d5f0add375be9eb1b913e5d437b811db8921aad /scan_scr.c
parent89de95a89953c20349a8c7c4684eba45feb34bf5 (diff)
downloadwavemon-3645c236e9720deb696e7aebc33cd9a6d8cbbdc6.tar.gz
Imported Upstream version 0.7.5upstream/0.7.5
Diffstat (limited to '')
-rw-r--r--scan_scr.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/scan_scr.c b/scan_scr.c
index e125f22..02cb8db 100644
--- a/scan_scr.c
+++ b/scan_scr.c
@@ -20,6 +20,7 @@
#include "iw_if.h"
#define START_LINE 2 /* where to begin the screen */
+#define NUMTOP 5 /* maximum number of 'top' statistics entries */
/* GLOBALS */
static WINDOW *w_aplst;
@@ -48,7 +49,6 @@ static char *fmt_scan_result(struct scan_result *cur, struct iw_range *iw_range,
else
len += snprintf(buf + len, buflen - len, "? dBm");
-
if (cur->freq < 1e3)
len += snprintf(buf + len, buflen - len, ", Chan %2.0f",
cur->freq);
@@ -77,8 +77,11 @@ static void display_aplist(WINDOW *w_aplst)
char s[IW_ESSID_MAX_SIZE << 3];
int max_essid_len = 0;
int i, line = START_LINE;
+ int total = 0, open = 0, tg = 0, fg = 0;
struct iw_range range;
struct scan_result *head, *cur;
+ struct cnt *stats;
+ int max_cnt = NUMTOP;
int skfd = socket(AF_INET, SOCK_DGRAM, 0);
if (skfd < 0)
@@ -126,10 +129,17 @@ static void display_aplist(WINDOW *w_aplst)
if (!head)
waddstr_center(w_aplst, WAV_HEIGHT/2 - 1, s);
- for (cur = head; cur; cur = cur->next) {
+ for (cur = head; cur; cur = cur->next, total++) {
if (str_is_ascii(cur->essid))
max_essid_len = clamp(strlen(cur->essid),
max_essid_len, IW_ESSID_MAX_SIZE);
+ open += ! cur->has_key;
+ if (cur->freq < 1e3)
+ ; /* cur->freq is channel number */
+ else if (cur->freq < 5e9)
+ tg++;
+ else
+ fg++;
}
/* Truncate overly long access point lists to match screen height */
@@ -161,8 +171,49 @@ static void display_aplist(WINDOW *w_aplst)
waddstr(w_aplst, " ");
waddstr(w_aplst, s);
}
- free_scan_result(head);
+
+ /* Summary statistics at the bottom. */
+ if (total < NUMTOP)
+ goto done;
+
+ wmove(w_aplst, MAXYLEN, 1);
+ wadd_attr_str(w_aplst, A_REVERSE, "total:");
+ sprintf(s, " %d", total);
+ waddstr(w_aplst, s);
+
+ if (total + START_LINE > line) {
+ sprintf(s, " (%d not shown)", total + START_LINE - line);
+ waddstr(w_aplst, s);
+ }
+ if (open) {
+ sprintf(s, ", %d open", open);
+ waddstr(w_aplst, s);
+ }
+ if (tg && fg) {
+ waddch(w_aplst, ' ');
+ wadd_attr_str(w_aplst, A_REVERSE, "5/2GHz:");
+ sprintf(s, " %d/%d", fg, tg);
+ waddstr(w_aplst, s);
+ }
+
+ stats = channel_stats(head, &range, &max_cnt);
+ if (stats) {
+ waddch(w_aplst, ' ');
+ if (conf.scan_sort_order == SO_CHAN_REV)
+ sprintf(s, "bottom-%d:", max_cnt);
+ else
+ sprintf(s, "top-%d:", max_cnt);
+ wadd_attr_str(w_aplst, A_REVERSE, s);
+
+ for (i = 0; i < max_cnt; i++) {
+ sprintf(s, "%s CH-%d(%d)", i ? "," : "",
+ stats[i].val, stats[i].count);
+ waddstr(w_aplst, s);
+ }
+ }
+ free(stats);
done:
+ free_scan_result(head);
close(skfd);
wrefresh(w_aplst);
}