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.
58 "input,output,altrate,short,long,xretry,crcerr,crypt,phyerr,rssi,rate"
61 "avgbrssi,avgrssi,avgtxrssi,NI,SI,step,owsd,cwst,NI+,NI-,SI+,SI-,OFDM,CCK,LISTEN"
64 "input,output,bexmit,tdmau,tdmadj,crcerr,phyerr,phytor,rssi,noise,rate"
69 getfmt(const char *tag)
71 #define N(a) (sizeof(a)/sizeof(a[0]))
73 for (i = 0; i < N(tags); i++)
74 if (strcasecmp(tags[i].tag, tag) == 0)
83 catchalarm(int signo __unused)
89 main(int argc, char *argv[])
91 struct athstatfoo *wf;
95 ifname = getenv("ATH");
98 wf = athstats_new(ifname, getfmt("default"));
99 while ((c = getopt(argc, argv, "bi:lo:z")) != -1) {
105 wf->setifname(wf, optarg);
108 wf->print_fields(wf, stdout);
111 wf->setfmt(wf, getfmt(optarg));
117 errx(-1, "usage: %s [-a] [-i ifname] [-l] [-o fmt] [-z] [interval]\n", argv[0]);
125 u_long interval = strtoul(argv[0], NULL, 0);
130 signal(SIGALRM, catchalarm);
135 wf->print_header(wf, stdout);
140 wf->print_current(wf, stdout);
144 wf->print_total(wf, stdout);
147 omask = sigblock(sigmask(SIGALRM));
154 if (line == 21) /* XXX tty line count */
161 wf->print_verbose(wf, stdout);