o add indirect array for field indices as the # stats is > 127 and doesn't

fit in a signed char
o change default output to something more useful for sta mode
o futz w/ various field names and widths; need to do full pass over this stuff
This commit is contained in:
Sam Leffler 2008-04-30 19:47:31 +00:00
parent f25bd2b89a
commit 51a5da15a7
4 changed files with 28 additions and 18 deletions

View File

@ -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"

View File

@ -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);

View File

@ -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 *);

View File

@ -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 {