Changeset View
Changeset View
Standalone View
Standalone View
head/tools/tools/ath/athstats/main.c
Show All 35 Lines | |||||
* athstats [-i interface] [-bz] [-l] [-o fmtstring] [interval] | * athstats [-i interface] [-bz] [-l] [-o fmtstring] [interval] | ||||
* | * | ||||
* (default interface is ath0). If interval is specified a rolling output | * (default interface is ath0). If interval is specified a rolling output | ||||
* a la netstat -i is displayed every interval seconds. The format of | * a la netstat -i is displayed every interval seconds. The format of | ||||
* the rolling display can be controlled a la ps. The -l option will | * the rolling display can be controlled a la ps. The -l option will | ||||
* print a list of all possible statistics for use with the -o option. | * print a list of all possible statistics for use with the -o option. | ||||
*/ | */ | ||||
#include <sys/param.h> | |||||
#include <err.h> | |||||
#include <signal.h> | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <signal.h> | |||||
#include <unistd.h> | |||||
#include <string.h> | #include <string.h> | ||||
#include <err.h> | #include <unistd.h> | ||||
#include "athstats.h" | #include "athstats.h" | ||||
static struct { | static struct { | ||||
const char *tag; | const char *tag; | ||||
const char *fmt; | const char *fmt; | ||||
} tags[] = { | } tags[] = { | ||||
{ "default", | { "default", | ||||
"input,output,altrate,short,long,xretry,crcerr,crypt,phyerr,rssi,rate" | "input,output,altrate,short,long,xretry,crcerr,crypt,phyerr,rssi,rate" | ||||
}, | }, | ||||
{ "ani", | { "ani", | ||||
"avgbrssi,avgrssi,avgtxrssi,NI,SI,step,owsd,cwst,NI+,NI-,SI+,SI-,OFDM,CCK,LISTEN" | "avgbrssi,avgrssi,avgtxrssi,NI,SI,step,owsd,cwst,NI+,NI-,SI+,SI-,OFDM,CCK,LISTEN" | ||||
}, | }, | ||||
{ "tdma", | { "tdma", | ||||
"input,output,bexmit,tdmau,tdmadj,crcerr,phyerr,phytor,rssi,noise,rate" | "input,output,bexmit,tdmau,tdmadj,crcerr,phyerr,phytor,rssi,noise,rate" | ||||
}, | }, | ||||
}; | }; | ||||
static const char * | static const char * | ||||
getfmt(const char *tag) | getfmt(const char *tag) | ||||
{ | { | ||||
#define N(a) (sizeof(a)/sizeof(a[0])) | |||||
int i; | int i; | ||||
for (i = 0; i < N(tags); i++) | for (i = 0; i < nitems(tags); i++) | ||||
if (strcasecmp(tags[i].tag, tag) == 0) | if (strcasecmp(tags[i].tag, tag) == 0) | ||||
return tags[i].fmt; | return tags[i].fmt; | ||||
return tag; | return tag; | ||||
#undef N | |||||
} | } | ||||
static int signalled; | static int signalled; | ||||
static void | static void | ||||
catchalarm(int signo __unused) | catchalarm(int signo __unused) | ||||
{ | { | ||||
signalled = 1; | signalled = 1; | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |