summaryrefslogtreecommitdiffstats
path: root/tools/tools
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2009-02-13 05:45:23 +0000
committersam <sam@FreeBSD.org>2009-02-13 05:45:23 +0000
commitf0b2ccddbf5a975ff9ec24514c7c5190157107c4 (patch)
tree02b3dcfa9290e1fe80bce61cda3ef5298540dff4 /tools/tools
parent6a08d937057508530a3fe32a0eed96764a432b7e (diff)
downloadFreeBSD-src-f0b2ccddbf5a975ff9ec24514c7c5190157107c4.zip
FreeBSD-src-f0b2ccddbf5a975ff9ec24514c7c5190157107c4.tar.gz
add -z option to zero driver statistics (but note we don't yet zero
stats obtained from the hal)
Diffstat (limited to 'tools/tools')
-rw-r--r--tools/tools/ath/athstats/athstats.c10
-rw-r--r--tools/tools/ath/athstats/athstats.h2
-rw-r--r--tools/tools/ath/athstats/main.c9
3 files changed, 18 insertions, 3 deletions
diff --git a/tools/tools/ath/athstats/athstats.c b/tools/tools/ath/athstats/athstats.c
index 0bb05a4..be729c1 100644
--- a/tools/tools/ath/athstats/athstats.c
+++ b/tools/tools/ath/athstats/athstats.c
@@ -436,6 +436,15 @@ ath_setifname(struct athstatfoo *wf0, const char *ifname)
#endif
}
+static void
+ath_zerostats(struct athstatfoo *wf0)
+{
+ struct athstatfoo_p *wf = (struct athstatfoo_p *) wf0;
+
+ if (ioctl(wf->s, SIOCZATHSTATS, &wf->ifr) < 0)
+ err(-1, wf->ifr.ifr_name);
+}
+
static void
ath_collect(struct athstatfoo_p *wf, struct _athstats *stats)
{
@@ -997,6 +1006,7 @@ athstats_new(const char *ifname, const char *fmtstring)
#if 0
wf->base.setstamac = wlan_setstamac;
#endif
+ wf->base.zerostats = ath_zerostats;
wf->s = socket(AF_INET, SOCK_DGRAM, 0);
if (wf->s < 0)
err(1, "socket");
diff --git a/tools/tools/ath/athstats/athstats.h b/tools/tools/ath/athstats/athstats.h
index 4ebfa74..cfd44ca 100644
--- a/tools/tools/ath/athstats/athstats.h
+++ b/tools/tools/ath/athstats/athstats.h
@@ -46,6 +46,8 @@ struct athstatfoo {
void (*setifname)(struct athstatfoo *, const char *ifname);
/* set the mac address of the associated station/ap */
void (*setstamac)(struct athstatfoo *, const uint8_t mac[]);
+ /* zero in-kernel statistics */
+ void (*zerostats)(struct athstatfoo *);
};
struct athstatfoo *athstats_new(const char *ifname, const char *fmtstring);
diff --git a/tools/tools/ath/athstats/main.c b/tools/tools/ath/athstats/main.c
index 518b149..acb8467 100644
--- a/tools/tools/ath/athstats/main.c
+++ b/tools/tools/ath/athstats/main.c
@@ -33,7 +33,7 @@
* Simple Atheros-specific tool to inspect and monitor network traffic
* statistics.
*
- * athstats [-i interface] [-l] [-o fmtstring] [interval]
+ * athstats [-i interface] [-z] [-l] [-o fmtstring] [interval]
*
* (default interface is ath0). If interval is specified a rolling output
* a la netstat -i is displayed every interval seconds. The format of
@@ -95,7 +95,7 @@ main(int argc, char *argv[])
if (ifname == NULL)
ifname = "ath0";
wf = athstats_new(ifname, getfmt("default"));
- while ((c = getopt(argc, argv, "i:lo:")) != -1) {
+ while ((c = getopt(argc, argv, "i:lo:z")) != -1) {
switch (c) {
case 'i':
wf->setifname(wf, optarg);
@@ -106,8 +106,11 @@ main(int argc, char *argv[])
case 'o':
wf->setfmt(wf, getfmt(optarg));
break;
+ case 'z':
+ wf->zerostats(wf);
+ break;
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] [-z] [interval]\n", argv[0]);
/*NOTREACHED*/
}
}
OpenPOWER on IntegriCloud