X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/de1bb6ef97ddd71db237578bd5f7ed8c5a61fb82..2f20008d73b76b05007ed54fe813a564ae6c3c98:/package/iwinfo/src/iwinfo_cli.c diff --git a/package/iwinfo/src/iwinfo_cli.c b/package/iwinfo/src/iwinfo_cli.c index d5be084bd..dc8ed8b14 100644 --- a/package/iwinfo/src/iwinfo_cli.c +++ b/package/iwinfo/src/iwinfo_cli.c @@ -275,6 +275,34 @@ static char * format_hwmodes(int modes) return buf; } +static char * format_assocrate(struct iwinfo_rate_entry *r) +{ + static char buf[40]; + char *p = buf; + int l = sizeof(buf); + + if (r->rate <= 0) + { + snprintf(buf, sizeof(buf), "unknown"); + } + else + { + p += snprintf(p, l, "%s", format_rate(r->rate)); + l = sizeof(buf) - (p - buf); + + if (r->mcs >= 0) + { + p += snprintf(p, l, ", MCS %d, %dMHz", r->mcs, 20 + r->is_40mhz*20); + l = sizeof(buf) - (p - buf); + + if (r->is_short_gi) + p += snprintf(p, l, ", short GI"); + } + } + + return buf; +} + static const char * print_type(const struct iwinfo_ops *iw, const char *ifname) { @@ -391,9 +419,14 @@ static char * print_frequency(const struct iwinfo_ops *iw, const char *ifname) static char * print_txpower(const struct iwinfo_ops *iw, const char *ifname) { - int pwr; + int pwr, off; + if (iw->txpower_offset(ifname, &off)) + off = 0; + if (iw->txpower(ifname, &pwr)) pwr = -1; + else + pwr += off; return format_txpower(pwr); } @@ -553,7 +586,7 @@ static void print_scanlist(const struct iwinfo_ops *iw, const char *ifname) static void print_txpwrlist(const struct iwinfo_ops *iw, const char *ifname) { - int len, pwr, i; + int len, pwr, off, i; char buf[IWINFO_BUFSIZE]; struct iwinfo_txpwrlist_entry *e; @@ -566,14 +599,17 @@ static void print_txpwrlist(const struct iwinfo_ops *iw, const char *ifname) if (iw->txpower(ifname, &pwr)) pwr = -1; + if (iw->txpower_offset(ifname, &off)) + off = 0; + for (i = 0; i < len; i += sizeof(struct iwinfo_txpwrlist_entry)) { e = (struct iwinfo_txpwrlist_entry *) &buf[i]; printf("%s%3d dBm (%4d mW)\n", (pwr == e->dbm) ? "*" : " ", - e->dbm, - e->mw); + e->dbm + off, + iwinfo_dbm2mw(e->dbm + off)); } } @@ -627,11 +663,22 @@ static void print_assoclist(const struct iwinfo_ops *iw, const char *ifname) { e = (struct iwinfo_assoclist_entry *) &buf[i]; - printf("%s %s / %s (SNR %d)\n", + printf("%s %s / %s (SNR %d) %d ms ago\n", format_bssid(e->mac), format_signal(e->signal), format_noise(e->noise), - (e->signal - e->noise)); + (e->signal - e->noise), + e->inactive); + + printf(" RX: %-38s %8d Pkts.\n", + format_assocrate(&e->rx_rate), + e->rx_packets + ); + + printf(" TX: %-38s %8d Pkts.\n\n", + format_assocrate(&e->tx_rate), + e->tx_packets + ); } }