Changeset View
Changeset View
Standalone View
Standalone View
head/tools/tools/ath/athaggrstats/main.c
Show All 36 Lines | |||||
* athaggrstats [-i interface] [-bz] [-l] [-o fmtstring] [interval] | * athaggrstats [-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 "athaggrstats.h" | #include "athaggrstats.h" | ||||
static struct { | static struct { | ||||
const char *tag; | const char *tag; | ||||
const char *fmt; | const char *fmt; | ||||
} tags[] = { | } tags[] = { | ||||
{ "default", | { "default", | ||||
"singlepkt,nonbawpkt,aggrpkt,bawclosedpkt,lhsinglepkt,schednopkt,rtsaggrlimit" | "singlepkt,nonbawpkt,aggrpkt,bawclosedpkt,lhsinglepkt,schednopkt,rtsaggrlimit" | ||||
}, | }, | ||||
}; | }; | ||||
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 |