Date: Thu, 5 Feb 2009 22:17:11 +0000 (UTC) From: Sam Leffler <sam@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r188206 - head/tools/tools/net80211/wlanstats Message-ID: <200902052217.n15MHBxL040943@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sam Date: Thu Feb 5 22:17:10 2009 New Revision: 188206 URL: http://svn.freebsd.org/changeset/base/188206 Log: make -o handling like athstats Modified: head/tools/tools/net80211/wlanstats/main.c Modified: head/tools/tools/net80211/wlanstats/main.c ============================================================================== --- head/tools/tools/net80211/wlanstats/main.c Thu Feb 5 22:16:09 2009 (r188205) +++ head/tools/tools/net80211/wlanstats/main.c Thu Feb 5 22:17:10 2009 (r188206) @@ -48,10 +48,30 @@ #include "wlanstats.h" -#define S_DEFAULT \ - "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" +static struct { + const char *tag; + const char *fmt; +} tags[] = { + { "default", + "input,rx_mgmt,output,rx_badkeyid,scan_active,scan_bg,bmiss,rssi,noise,rate" + }, + { "ampdu", + "input,output,ampdu_reorder,ampdu_oor,rx_dup,ampdu_flush,ampdu_move," + "ampdu_drop,ampdu_bar,ampdu_baroow,ampdu_barmove,rssi,rate" + }, +}; + +static const char * +getfmt(const char *tag) +{ +#define N(a) (sizeof(a)/sizeof(a[0])) + int i; + for (i = 0; i < N(tags); i++) + if (strcasecmp(tags[i].tag, tag) == 0) + return tags[i].fmt; + return tag; +#undef N +} static int signalled; @@ -138,10 +158,14 @@ main(int argc, char *argv[]) struct wlanstatfoo *wf; struct ether_addr *ea; const uint8_t *mac = NULL; + const char *ifname; int allnodes = 0; int c, mode; - wf = wlanstats_new("wlan0", S_DEFAULT); + ifname = getenv("WLAN"); + if (ifname == NULL) + ifname = "wlan0"; + wf = wlanstats_new(ifname, getfmt("default")); while ((c = getopt(argc, argv, "ai:lm:o:")) != -1) { switch (c) { case 'a': @@ -160,10 +184,7 @@ main(int argc, char *argv[]) mac = ea->octet; break; case 'o': - if (strcasecmp(optarg, "ampdu") == 0) - wf->setfmt(wf, S_AMPDU); - else - wf->setfmt(wf, optarg); + wf->setfmt(wf, getfmt(optarg)); break; default: errx(-1, "usage: %s [-a] [-i ifname] [-l] [-o fmt] [interval]\n", argv[0]);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902052217.n15MHBxL040943>