diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-04-01 20:43:09 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-04-01 20:43:09 +0000 |
commit | 1f66d416fde867e9d94a323c8dcc59cf7474dca5 (patch) | |
tree | d71b44e2601df47225c7c06243f0c93efad16908 /sbin | |
parent | 246c86203a49af3f344ad123f32dc598d4a9a29e (diff) |
Also accept "adhoc" (or "ad-hoc"), "bss", and "hostap" instead of
numbers for -p option.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/wicontrol/wicontrol.8 | 8 | ||||
-rw-r--r-- | sbin/wicontrol/wicontrol.c | 39 |
2 files changed, 36 insertions, 11 deletions
diff --git a/sbin/wicontrol/wicontrol.8 b/sbin/wicontrol/wicontrol.8 index 0e90a4d5d59..ebd3440dd15 100644 --- a/sbin/wicontrol/wicontrol.8 +++ b/sbin/wicontrol/wicontrol.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: wicontrol.8,v 1.28 2002/04/01 07:00:34 deraadt Exp $ +.\" $OpenBSD: wicontrol.8,v 1.29 2002/04/01 20:43:08 millert Exp $ .\" .\" Copyright (c) 1997, 1998, 1999 .\" Bill Paul <wpaul@ctr.columbia.edu> All rights reserved. @@ -199,6 +199,12 @@ for a specified interface. The legal values for .Ar port type are 1 (BSS mode), 3 (ad-hoc mode) and 6 (hostap mode). +The symbolic values +.Dq bss , +.Dq adhoc +and +.Dq hostap +may also be used instead of numeric values. In ad-hoc mode, the station can communicate directly with any other stations within direct radio range (provided that they are also operating in ad-hoc mode). diff --git a/sbin/wicontrol/wicontrol.c b/sbin/wicontrol/wicontrol.c index a8ca4a9b875..13f7f8766cb 100644 --- a/sbin/wicontrol/wicontrol.c +++ b/sbin/wicontrol/wicontrol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wicontrol.c,v 1.28 2002/04/01 19:50:44 millert Exp $ */ +/* $OpenBSD: wicontrol.c,v 1.29 2002/04/01 20:43:08 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -69,7 +69,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997, 1998, 1999\ Bill Paul. All rights reserved."; static const char rcsid[] = - "@(#) $OpenBSD: wicontrol.c,v 1.28 2002/04/01 19:50:44 millert Exp $"; + "@(#) $OpenBSD: wicontrol.c,v 1.29 2002/04/01 20:43:08 millert Exp $"; #endif void wi_getval(char *, struct wi_req *); @@ -89,7 +89,8 @@ void wi_printcardid(struct wi_req *, int); void wi_dumpstats(char *); void wi_dumpstations(char *); void usage(void); -void printb(char *s, unsigned short v, char *bits); +void printb(char *, unsigned short, char *); +char *portid(char *); void wi_getval(iface, wreq) @@ -778,7 +779,10 @@ main(argc, argv) "a:c:d:e:f:hi:k:lm:n:op:q:r:s:t:v:A:M:S:P:R:T:")) != -1) { for (p = 0; ch && wi_opt[p].key; p++) if (ch == wi_opt[p].key) { - wi_opt[p].optarg = optarg; + if (ch == 'p' && !isdigit(*optarg)) + wi_opt[p].optarg = portid(optarg); + else + wi_opt[p].optarg = optarg; if (ch == 'T') /* key 1-4/0-3 kludge */ (*optarg)--; dumpinfo = ch = 0; @@ -786,13 +790,13 @@ main(argc, argv) switch(ch) { case 0: break; - case 'o': - dumpstats ++; - break; case 'i': if (!ifspecified) iface = optarg; break; + case 'o': + dumpstats++; + break; case 'l': dumpstations++; break; @@ -814,9 +818,6 @@ main(argc, argv) } } - if (iface == NULL) - usage(); - for (p = 0; wi_opt[p].key; p++) if (wi_opt[p].optarg != NULL) wi_opt[p].function(iface, wi_opt[p].wi_code, @@ -868,3 +869,21 @@ printb(s, v, bits) putchar('>'); } } + +char * +portid(char *name) +{ + char *id; + + if (strcasecmp(name, "bss") == 0) + id = "1"; + else if (strcasecmp(name, "adhoc") == 0 || + strcasecmp(name, "ad-hoc") == 0) + id = "3"; + else if (strcasecmp(name, "hostap") == 0) + id = "6"; + else + errx(1, "unknown port type %s", name); + + return(id); +} |