2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13 * redistribution must be conditioned upon including a substantially
14 * similar Disclaimer requirement for further binary redistribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
33 * Simple Atheros-specific tool to inspect and monitor network traffic
36 * athstats [-i interface] [-bz] [-l] [-o fmtstring] [interval]
38 * (default interface is ath0). If interval is specified a rolling output
39 * a la netstat -i is displayed every interval seconds. The format of
40 * the rolling display can be controlled a la ps. The -l option will
41 * print a list of all possible statistics for use with the -o option.
44 #include <sys/param.h>
60 "input,output,altrate,short,long,xretry,crcerr,crypt,phyerr,rssi,rate"
63 "avgbrssi,avgrssi,avgtxrssi,NI,SI,step,owsd,cwst,NI+,NI-,SI+,SI-,OFDM,CCK,LISTEN"
66 "input,output,bexmit,tdmau,tdmadj,crcerr,phyerr,phytor,rssi,noise,rate"
69 "bstuck,bmiss,bexmit,beacons,bmisscount,reset,ofdm,cck,input,output"
74 getfmt(const char *tag)
77 for (i = 0; i < nitems(tags); i++)
78 if (strcasecmp(tags[i].tag, tag) == 0)
86 catchalarm(int signo __unused)
92 main(int argc, char *argv[])
94 struct athstatfoo *wf;
98 ifname = getenv("ATH");
100 ifname = ATH_DEFAULT;
101 wf = athstats_new(ifname, getfmt("default"));
102 while ((c = getopt(argc, argv, "bi:lo:z")) != -1) {
108 wf->setifname(wf, optarg);
111 wf->print_fields(wf, stdout);
114 wf->setfmt(wf, getfmt(optarg));
120 errx(-1, "usage: %s [-a] [-i ifname] [-l] [-o fmt] [-z] [interval]\n", argv[0]);
128 u_long interval = strtoul(argv[0], NULL, 0);
133 signal(SIGALRM, catchalarm);
138 wf->print_header(wf, stdout);
143 wf->print_current(wf, stdout);
147 wf->print_total(wf, stdout);
150 omask = sigblock(sigmask(SIGALRM));
157 if (line == 21) /* XXX tty line count */
164 wf->print_verbose(wf, stdout);