diff --git a/tools/tools/net80211/wlanstats/main.c b/tools/tools/net80211/wlanstats/main.c index d7519044b11f..6c5e9f4bf2a3 100644 --- a/tools/tools/net80211/wlanstats/main.c +++ b/tools/tools/net80211/wlanstats/main.c @@ -49,7 +49,7 @@ #include "wlanstats.h" #define S_DEFAULT \ - "input,output,rx_ucast,rx_mcast,tx_ucast,tx_mcast,rssi,rate" + "input,rx_mgmt,output,rx_badkeyid,scan_active,scan_bg,bmiss,rssi,noise,rate" #define S_AMPDU \ "input,output,ampdu_reorder,ampdu_oor,rx_dup,ampdu_flush,ampdu_move,ampdu_drop,ampdu_bar,ampdu_baroow,ampdu_barmove,rssi,rate" diff --git a/tools/tools/net80211/wlanstats/statfoo.c b/tools/tools/net80211/wlanstats/statfoo.c index 9963ea0495c7..1ede5de84b77 100644 --- a/tools/tools/net80211/wlanstats/statfoo.c +++ b/tools/tools/net80211/wlanstats/statfoo.c @@ -40,9 +40,9 @@ statfoo_setfmt(struct statfoo *sf, const char *fmt0) #define N(a) (sizeof(a)/sizeof(a[0])) char fmt[4096]; char *fp, *tok; - int i, j; + int i, j, field; - j = 0; + j = field = 0; strlcpy(fmt, fmt0, sizeof(fmt)); for (fp = fmt; (tok = strsep(&fp, ", ")) != NULL;) { for (i = 0; i < sf->nstats; i++) @@ -58,9 +58,15 @@ statfoo_setfmt(struct statfoo *sf, const char *fmt0) "stopped at %s\n", sf->name, tok); break; } + if (field > 127) { + fprintf(stderr, "%s: too many fields; " + "stopped at %s\n", sf->name, tok); + break; + } if (j != 0) sf->fmts[j++] = ' '; - sf->fmts[j++] = 0x80 | i; + sf->fmts[j++] = 0x80 | field; + sf->fields[field++] = i; } sf->fmts[j] = '\0'; #undef N @@ -92,7 +98,8 @@ statfoo_print_header(struct statfoo *sf, FILE *fd) for (cp = sf->fmts; *cp != '\0'; cp++) { if (*cp & 0x80) { - const struct fmt *f = &sf->stats[*cp &~ 0x80]; + int six = sf->fields[*cp &~ 0x80]; + const struct fmt *f = &sf->stats[six]; fprintf(fd, "%*s", f->width, f->label); } else putc(*cp, fd); @@ -108,8 +115,9 @@ statfoo_print_current(struct statfoo *sf, FILE *fd) for (cp = sf->fmts; *cp != '\0'; cp++) { if (*cp & 0x80) { - const struct fmt *f = &sf->stats[*cp &~ 0x80]; - if (sf->get_curstat(sf, *cp &~ 0x80, buf, sizeof(buf))) + int six = sf->fields[*cp &~ 0x80]; + const struct fmt *f = &sf->stats[six]; + if (sf->get_curstat(sf, six, buf, sizeof(buf))) fprintf(fd, "%*s", f->width, buf); } else putc(*cp, fd); @@ -125,8 +133,9 @@ statfoo_print_total(struct statfoo *sf, FILE *fd) for (cp = sf->fmts; *cp != '\0'; cp++) { if (*cp & 0x80) { - const struct fmt *f = &sf->stats[*cp &~ 0x80]; - if (sf->get_totstat(sf, *cp &~ 0x80, buf, sizeof(buf))) + int six = sf->fields[*cp &~ 0x80]; + const struct fmt *f = &sf->stats[six]; + if (sf->get_totstat(sf, six, buf, sizeof(buf))) fprintf(fd, "%*s", f->width, buf); } else putc(*cp, fd); diff --git a/tools/tools/net80211/wlanstats/statfoo.h b/tools/tools/net80211/wlanstats/statfoo.h index df7eb7acdcdd..2501d21d2924 100644 --- a/tools/tools/net80211/wlanstats/statfoo.h +++ b/tools/tools/net80211/wlanstats/statfoo.h @@ -79,6 +79,7 @@ struct statfoo { const char *name; /* statistics name, e.g. wlanstats */ const struct fmt *stats; /* statistics in class */ int nstats; /* number of stats */ + int fields[128]; /* index of field referenced in fmts */ unsigned char fmts[4096]; /* private: compiled stats to display */ STATFOO_DECL_METHODS(struct statfoo *); diff --git a/tools/tools/net80211/wlanstats/wlanstats.c b/tools/tools/net80211/wlanstats/wlanstats.c index 8eb867f68bb0..a48e11da40f8 100644 --- a/tools/tools/net80211/wlanstats/wlanstats.c +++ b/tools/tools/net80211/wlanstats/wlanstats.c @@ -157,7 +157,7 @@ static const struct fmt wlanstats[] = { { 5, "rx_unauth", "unauth", "rx discard 'cuz port unauthorized" }, #define S_RX_BADKEYID AFTER(S_RX_UNAUTH) - { 5, "rx_badkeyid", "badkeyid", "rx w/ incorrect keyid" }, + { 5, "rx_badkeyid", "rxkid", "rx w/ incorrect keyid" }, #define S_RX_CCMPREPLAY AFTER(S_RX_BADKEYID) { 5, "rx_ccmpreplay", "ccmpreplay", "rx seq# violation (CCMP)" }, #define S_RX_CCMPFORMAT AFTER(S_RX_CCMPREPLAY) @@ -195,11 +195,11 @@ static const struct fmt wlanstats[] = { #define S_TX_FRAGS AFTER(S_TX_FRAGFRAMES) { 5, "tx_frags", "frags", "tx frags generated" }, #define S_SCAN_ACTIVE AFTER(S_TX_FRAGS) - { 5, "scan_active", "scan_active", "active scans started" }, + { 5, "scan_active", "ascan", "active scans started" }, #define S_SCAN_PASSIVE AFTER(S_SCAN_ACTIVE) - { 5, "scan_passive", "scan_passive", "passive scans started" }, + { 5, "scan_passive", "pscan", "passive scans started" }, #define S_SCAN_BG AFTER(S_SCAN_PASSIVE) - { 5, "scan_bg", "scan_bg", "background scans started" }, + { 5, "scan_bg", "bgscn", "background scans started" }, #define S_NODE_TIMEOUT AFTER(S_SCAN_BG) { 5, "node_timeout", "node_timeout", "nodes timed out for inactivity" }, #define S_CRYPTO_NOMEM AFTER(S_NODE_TIMEOUT) @@ -259,7 +259,7 @@ static const struct fmt wlanstats[] = { #define S_RX_BADBINTVAL AFTER(S_FF_ENCAPFAIL) { 5, "rx_badbintval", "rx_badbintval","rx frame with bogus beacon interval" }, #define S_RX_MGMT AFTER(S_RX_BADBINTVAL) - { 5, "rx_mgmt", "rx_mgmt", "rx management frames" }, + { 8, "rx_mgmt", "mgmt", "rx management frames" }, #define S_RX_DEMICFAIL AFTER(S_RX_MGMT) { 5, "rx_demicfail", "rx_demicfail", "rx demic failed" }, #define S_RX_DEFRAG AFTER(S_RX_DEMICFAIL) @@ -335,13 +335,13 @@ static const struct fmt wlanstats[] = { #define S_TX_MCAST AFTER(S_TX_UCAST) { 8, "tx_mcast", "tx_mcast", "multicast data frames sent" }, #define S_RATE AFTER(S_TX_MCAST) - { 4, "rate", "rate", "current transmit rate" }, + { 5, "rate", "rate", "current transmit rate" }, #define S_RSSI AFTER(S_RATE) - { 4, "rssi", "rssi", "current rssi" }, + { 5, "rssi", "rssi", "current rssi" }, #define S_NOISE AFTER(S_RSSI) - { 4, "noise", "noise", "current noise floor (dBm)" }, + { 5, "noise", "noise", "current noise floor (dBm)" }, #define S_SIGNAL AFTER(S_NOISE) - { 4, "signal", "sig", "current signal (dBm)" }, + { 5, "signal", "sig", "current signal (dBm)" }, }; struct wlanstatfoo_p {