make -o handling like athstats
This commit is contained in:
parent
a54c6fc878
commit
ab28e51677
@ -48,10 +48,30 @@
|
|||||||
|
|
||||||
#include "wlanstats.h"
|
#include "wlanstats.h"
|
||||||
|
|
||||||
#define S_DEFAULT \
|
static struct {
|
||||||
"input,rx_mgmt,output,rx_badkeyid,scan_active,scan_bg,bmiss,rssi,noise,rate"
|
const char *tag;
|
||||||
#define S_AMPDU \
|
const char *fmt;
|
||||||
"input,output,ampdu_reorder,ampdu_oor,rx_dup,ampdu_flush,ampdu_move,ampdu_drop,ampdu_bar,ampdu_baroow,ampdu_barmove,rssi,rate"
|
} 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;
|
static int signalled;
|
||||||
|
|
||||||
@ -138,10 +158,14 @@ main(int argc, char *argv[])
|
|||||||
struct wlanstatfoo *wf;
|
struct wlanstatfoo *wf;
|
||||||
struct ether_addr *ea;
|
struct ether_addr *ea;
|
||||||
const uint8_t *mac = NULL;
|
const uint8_t *mac = NULL;
|
||||||
|
const char *ifname;
|
||||||
int allnodes = 0;
|
int allnodes = 0;
|
||||||
int c, mode;
|
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) {
|
while ((c = getopt(argc, argv, "ai:lm:o:")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'a':
|
case 'a':
|
||||||
@ -160,10 +184,7 @@ main(int argc, char *argv[])
|
|||||||
mac = ea->octet;
|
mac = ea->octet;
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
if (strcasecmp(optarg, "ampdu") == 0)
|
wf->setfmt(wf, getfmt(optarg));
|
||||||
wf->setfmt(wf, S_AMPDU);
|
|
||||||
else
|
|
||||||
wf->setfmt(wf, optarg);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
errx(-1, "usage: %s [-a] [-i ifname] [-l] [-o fmt] [interval]\n", argv[0]);
|
errx(-1, "usage: %s [-a] [-i ifname] [-l] [-o fmt] [interval]\n", argv[0]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user