aboutsummaryrefslogtreecommitdiffstats
path: root/info_scr.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--info_scr.c75
1 files changed, 9 insertions, 66 deletions
diff --git a/info_scr.c b/info_scr.c
index 55a3bbc..86095fa 100644
--- a/info_scr.c
+++ b/info_scr.c
@@ -53,6 +53,7 @@ static void *sampling_loop(void *arg)
void sampling_init(void)
{
+ pthread_mutex_init(&linkstat.mutex, NULL);
linkstat.run = true;
pthread_create(&sampling_thread, NULL, sampling_loop, NULL);
}
@@ -61,6 +62,7 @@ void sampling_stop(void)
{
linkstat.run = false;
pthread_join(sampling_thread, NULL);
+ pthread_mutex_destroy(&linkstat.mutex);
}
static void display_levels(void)
@@ -78,7 +80,6 @@ static void display_levels(void)
bool noise_data_valid;
int sig_qual = -1, sig_qual_max, sig_level;
-
noise_data_valid = iw_nl80211_have_survey_data(&linkstat.data);
sig_level = linkstat.data.signal_avg ?: linkstat.data.signal;
@@ -103,12 +104,6 @@ static void display_levels(void)
sig_qual_max = 70;
}
- if (sig_qual == -1 && !sig_level && !noise_data_valid) {
- wattron(w_levels, A_BOLD);
- waddstr_center(w_levels, (WH_LEVEL + 1)/2, "NO INTERFACE DATA");
- goto done_levels;
- }
-
line = 1;
/* Noise data is rare. Use the space for spreading out. */
@@ -173,7 +168,6 @@ static void display_levels(void)
waddstr_b(w_levels, tmp);
}
-done_levels:
wrefresh(w_levels);
}
@@ -211,7 +205,8 @@ static void display_stats(void)
if (linkstat.data.rx_drop_misc) {
waddstr(w_stats, ", drop: ");
- sprintf(tmp, "%'llu", (unsigned long long)linkstat.data.rx_drop_misc);
+ sprintf(tmp, "%'llu (%.1f%%)", (unsigned long long)linkstat.data.rx_drop_misc,
+ (1e2 * linkstat.data.rx_drop_misc)/linkstat.data.rx_packets);
waddstr_b(w_stats, tmp);
}
@@ -237,7 +232,8 @@ static void display_stats(void)
if (linkstat.data.tx_retries) {
waddstr(w_stats, ", retries: ");
- sprintf(tmp, "%'u", linkstat.data.tx_retries);
+ sprintf(tmp, "%'u (%.1f%%)", linkstat.data.tx_retries,
+ (1e2 * linkstat.data.tx_retries)/linkstat.data.tx_packets);
waddstr_b(w_stats, tmp);
}
@@ -257,10 +253,9 @@ static void display_info(WINDOW *w_if, WINDOW *w_info)
struct iw_nl80211_ifstat ifs;
struct iw_nl80211_reg ir;
char tmp[0x100];
- int i;
iw_getinf_range(conf_ifname(), &range);
- dyn_info_get(&info, conf_ifname(), &range);
+ dyn_info_get(&info, conf_ifname());
iw_nl80211_getifstat(&ifs);
iw_nl80211_getreg(&ir);
@@ -530,63 +525,11 @@ static void display_info(WINDOW *w_if, WINDOW *w_info)
}
wclrtoborder(w_info);
+ /* FIXME: re-enable encryption information (issue #8)
wmove(w_info, 7, 1);
waddstr(w_info, "encryption: ");
- if (info.keys) {
- int cnt = dyn_info_active_keys(&info);
-
- if (cnt == 0) {
- waddstr_b(w_info, "off (no key set)");
- } else if (info.active_key) {
- i = info.active_key - 1;
- waddstr_b(w_info, curtail(format_key(info.keys + i),
- "..", MAXXLEN/2));
-
- if (info.keys[i].flags & IW_ENCODE_RESTRICTED)
- waddstr(w_info, ", restricted");
- if (info.keys[i].flags & IW_ENCODE_OPEN)
- waddstr(w_info, ", open");
-
- /* First key = default */
- if (cnt > 1 || info.active_key != 1) {
- sprintf(tmp, " [%d]", info.active_key);
- waddstr_b(w_info, tmp);
- }
- if (cnt > 1) {
- sprintf(tmp, " (%d other key%s)", cnt - 1,
- cnt == 2 ? "" : "s");
- waddstr(w_info, tmp);
- }
- } else if (dyn_info_wep_keys(&info) == cnt) {
- waddstr_b(w_info, "off ");
- sprintf(tmp, "(%d disabled WEP key%s)", cnt,
- cnt == 1 ? "" : "s");
- waddstr(w_info, tmp);
- } else {
- uint8_t j = 0, k = 0;
-
- do if (info.keys[j].size &&
- !(info.keys[j].flags & IW_ENCODE_DISABLED))
- info.keys[k++].size = info.keys[j].size;
- while (k < cnt && ++j < info.nkeys);
-
- if (cnt == 1)
- j = sprintf(tmp, "1 key (index #%u), ", j + 1);
- else
- j = sprintf(tmp, "%d keys with ", k);
- for (i = 0; i < k; i++)
- j += sprintf(tmp + j, "%s%d", i ? "/" : "",
- info.keys[i].size * 8);
- sprintf(tmp + j, " bits");
- waddstr_b(w_info, tmp);
- }
- } else if (has_net_admin_capability()) {
- waddstr(w_info, "no information available");
- } else {
- waddstr(w_info, "n/a (requires CAP_NET_ADMIN permissions)");
- }
+ */
- dyn_info_cleanup(&info);
wclrtoborder(w_info);
wrefresh(w_info);
}