diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tools/ath/80211stats.c | 129 | ||||
-rw-r--r-- | tools/tools/ath/Makefile | 4 |
2 files changed, 132 insertions, 1 deletions
diff --git a/tools/tools/ath/80211stats.c b/tools/tools/ath/80211stats.c new file mode 100644 index 0000000..05653ab --- /dev/null +++ b/tools/tools/ath/80211stats.c @@ -0,0 +1,129 @@ +/*- + * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + * redistribution must be conditioned upon including a substantially + * similar Disclaimer requirement for further binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGES. + * + * $FreeBSD$ + */ + +/* + * athstats [-i interface] + * (default interface is ath0). + */ +#include <sys/types.h> +#include <sys/file.h> +#include <sys/sockio.h> +#include <sys/socket.h> +#include <net/if.h> +#include <net/if_media.h> +#include <net/if_var.h> + +#include <stdio.h> +#include <signal.h> + +#include "../../../sys/net80211/ieee80211_ioctl.h" + +static void +printstats(FILE *fd, const struct ieee80211_stats *stats) +{ +#define N(a) (sizeof(a) / sizeof(a[0])) +#define STAT(x,fmt) \ + if (stats->is_##x) fprintf(fd, "%u " fmt "\n", stats->is_##x) + STAT(rx_badversion, "rx frame with bad version"); + STAT(rx_tooshort, "rx frame too short"); + STAT(rx_wrongbss, "rx from wrong bssid"); + STAT(rx_dup, "rx discard 'cuz dup"); + STAT(rx_wrongdir, "rx w/ wrong direction"); + STAT(rx_mcastecho, "rx discard 'cuz mcast echo"); + STAT(rx_notassoc, "rx discard 'cuz sta !assoc"); + STAT(rx_nowep, "rx w/ wep but wep !config"); + STAT(rx_wepfail, "rx wep processing failed"); + STAT(rx_decap, "rx decapsulation failed"); + STAT(rx_mgtdiscard, "rx discard mgt frames"); + STAT(rx_ctl, "rx discard ctrl frames"); + STAT(rx_rstoobig, "rx rate set truncated"); + STAT(rx_elem_missing, "rx required element missing"); + STAT(rx_elem_toobig, "rx element too big"); + STAT(rx_elem_toosmall, "rx element too small"); + STAT(rx_elem_unknown, "rx element unknown"); + STAT(rx_badchan, "rx frame w/ invalid chan"); + STAT(rx_chanmismatch, "rx frame chan mismatch"); + STAT(rx_nodealloc, "nodes allocated (rx)"); + STAT(rx_ssidmismatch, "rx frame ssid mismatch"); + STAT(rx_auth_unsupported,"rx w/ unsupported auth alg"); + STAT(rx_auth_fail, "rx sta auth failure"); + STAT(rx_assoc_bss, "rx assoc from wrong bssid"); + STAT(rx_assoc_notauth, "rx assoc w/o auth"); + STAT(rx_assoc_capmismatch,"rx assoc w/ cap mismatch"); + STAT(rx_assoc_norate, "rx assoc w/ no rate match"); + STAT(rx_deauth, "rx deauthentication"); + STAT(rx_disassoc, "rx disassociation"); + STAT(rx_badsubtype, "rx frame w/ unknown subtype"); + STAT(rx_nombuf, "rx failed for lack of mbuf"); + STAT(rx_decryptcrc, "rx decrypt failed on crc"); + STAT(rx_ahdemo_mgt, + "rx discard mgmt frame received in ahdoc demo mode"); + STAT(rx_bad_auth, "rx bad authentication request"); + STAT(tx_nombuf, "tx failed for lack of mbuf"); + STAT(tx_nonode, "tx failed for no node"); + STAT(tx_unknownmgt, "tx of unknown mgt frame"); + STAT(scan_active, "active scans started"); + STAT(scan_passive, "passive scans started"); + STAT(node_timeout, "nodes timed out inactivity"); + STAT(crypto_nomem, "malloc failure of rc4 context"); +#undef STAT +#undef N +} + +int +main(int argc, char *argv[]) +{ + int s; + struct ifreq ifr; + struct ieee80211_stats stats; + + s = socket(AF_INET, SOCK_DGRAM, 0); + if (s < 0) + err(1, "socket"); + if (argc > 1) { + strncpy(ifr.ifr_name, argv[1], sizeof (ifr.ifr_name)); + argc -= 1, argv += 1; + } else + strncpy(ifr.ifr_name, "ath0", sizeof (ifr.ifr_name)); + + ifr.ifr_data = (caddr_t) &stats; + if (ioctl(s, SIOCG80211STATS, &ifr) < 0) + err(1, ifr.ifr_name); + printstats(stdout, &stats); + return 0; +} diff --git a/tools/tools/ath/Makefile b/tools/tools/ath/Makefile index 35cc2d3..3104965 100644 --- a/tools/tools/ath/Makefile +++ b/tools/tools/ath/Makefile @@ -25,11 +25,13 @@ # SUCH DAMAGE. # -ALL= athstats +ALL= athstats 80211stats all: ${ALL} athstats: athstats.c ${CC} -o athstats athstats.c -lkvm +80211stats: 80211stats.c + ${CC} -o 80211stats 80211stats.c clean: rm -f ${ALL} core a.out |