diff options
author | imp <imp@FreeBSD.org> | 2002-06-24 06:09:54 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2002-06-24 06:09:54 +0000 |
commit | dd9b9a1d118960ca9f2ffc50b054eaab13efebf7 (patch) | |
tree | 475c639097989ac7ea6afbb78d544b2b186e8973 /usr.sbin/wicontrol/wicontrol.c | |
parent | 57b695126f126c8ac6b0e85af1df53a952371809 (diff) | |
download | FreeBSD-src-dd9b9a1d118960ca9f2ffc50b054eaab13efebf7.zip FreeBSD-src-dd9b9a1d118960ca9f2ffc50b054eaab13efebf7.tar.gz |
Document -L and -l.
Change -l -> -L to match OpenBSD (since we haven't MFC'd it yet).
-l will now list stations that are associated with a hostap (preliminary)
MFC After: 2 weeks
Diffstat (limited to 'usr.sbin/wicontrol/wicontrol.c')
-rw-r--r-- | usr.sbin/wicontrol/wicontrol.c | 87 |
1 files changed, 84 insertions, 3 deletions
diff --git a/usr.sbin/wicontrol/wicontrol.c b/usr.sbin/wicontrol/wicontrol.c index 99db559..ac86b15 100644 --- a/usr.sbin/wicontrol/wicontrol.c +++ b/usr.sbin/wicontrol/wicontrol.c @@ -49,6 +49,7 @@ static const char rcsid[] = #include <net/ethernet.h> #include <dev/wi/if_wavelan_ieee.h> +#include <dev/wi/wi_hostap.h> #include <stdio.h> #include <string.h> @@ -83,6 +84,41 @@ static void usage(const char *); int listaps; +/* + * Print a value a la the %b format of the kernel's printf + * (ripped screaming from ifconfig/ifconfig.c) + */ +void +printb(s, v, bits) + char *s; + char *bits; + unsigned short v; +{ + int i, any = 0; + char c; + + if (bits && *bits == 8) + printf("%s=%o", s, v); + else + printf("%s=%x", s, v); + bits++; + if (bits) { + putchar('<'); + while ((i = *bits++)) { + if (v & (1 << (i-1))) { + if (any) + putchar(','); + any = 1; + for (; (c = *bits) > 32; bits++) + putchar(c); + } else + for (; *bits > 32; bits++) + ; + } + putchar('>'); + } +} + static void wi_getval(const char *iface, struct wi_req *wreq) { @@ -724,6 +760,47 @@ usage(const char *p) exit(1); } +static void +wi_dumpstations(const char *iface) +{ + struct hostap_getall reqall; + struct hostap_sta stas[WIHAP_MAX_STATIONS]; + struct ifreq ifr; + int i, s; + + bzero(&ifr, sizeof(ifr)); + strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); + ifr.ifr_data = (caddr_t) & reqall; + bzero(&reqall, sizeof(reqall)); + reqall.size = sizeof(stas); + reqall.addr = stas; + bzero(&stas, sizeof(stas)); + + s = socket(AF_INET, SOCK_DGRAM, 0); + if (s == -1) + err(1, "socket"); + + if (ioctl(s, SIOCHOSTAP_GETALL, &ifr) < 0) + err(1, "SIOCHOSTAP_GETALL"); + + printf("%d station%s:\n", reqall.nstations, reqall.nstations>1?"s":""); + for (i = 0; i < reqall.nstations; i++) { + struct hostap_sta *info = &stas[i]; + + printf("%02x:%02x:%02x:%02x:%02x:%02x asid=%04x", + info->addr[0], info->addr[1], info->addr[2], + info->addr[3], info->addr[4], info->addr[5], + info->asid - 0xc001); + printb(", flags", info->flags, HOSTAP_FLAGS_BITS); + printb(", caps", info->capinfo, IEEE80211_CAPINFO_BITS); + printb(", rates", info->rates, WI_RATES_BITS); + if (info->sig_info) + printf(", sig=%d/%d", + info->sig_info >> 8, info->sig_info & 0xff); + putchar('\n'); + } +} + #ifdef WICACHE static void wi_zerocache(const char *iface) @@ -814,15 +891,15 @@ main(int argc, char *argv[]) opterr = 1; while((ch = getopt(argc, argv, - "a:hoc:d:e:f:i:k:lp:r:q:t:n:s:m:v:F:P:S:T:ZC")) != -1) { + "a:hoc:d:e:f:i:k:lp:r:q:t:n:s:m:v:F:LP:S:T:ZC")) != -1) { switch(ch) { case 'Z': #ifdef WICACHE wi_zerocache(iface); - exit(0); #else printf("WICACHE not available\n"); #endif + exit(0); break; case 'C': #ifdef WICACHE @@ -859,9 +936,13 @@ main(int argc, char *argv[]) case 'k': key = optarg; break; - case 'l': + case 'L': listaps = 1; break; + case 'l': + wi_dumpstations(iface); + exit(0); + break; case 'p': wi_setword(iface, WI_RID_PORTTYPE, atoi(optarg)); exit(0); |