1 /* $NetBSD: wiconfig.c,v 1.41 2008/07/21 13:37:00 lukem Exp $ */
3 * Copyright (c) 1997, 1998, 1999
4 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Bill Paul.
17 * 4. Neither the name of the author nor the names of any co-contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
33 * From: Id: wicontrol.c,v 1.6 1999/05/22 16:12:49 wpaul Exp $
36 #include <sys/types.h>
37 #include <sys/cdefs.h>
38 #include <sys/param.h>
39 #include <sys/socket.h>
40 #include <sys/ioctl.h>
44 #include <net/if_var.h>
45 #include <net/ethernet.h>
47 #include <machine/if_wavelan_ieee.h>
49 #include <netinet/in.h>
50 #include <netinet/if_ether.h>
52 #include <net80211/ieee80211.h>
53 #include <net80211/ieee80211_ioctl.h>
54 #include <dev/ic/wi_ieee.h>
56 #include <dev/pcmcia/if_wavelan_ieee.h>
69 __COPYRIGHT("@(#) Copyright (c) 1997, 1998, 1999\
70 Bill Paul. All rights reserved.");
71 __RCSID("$NetBSD: wiconfig.c,v 1.41 2008/07/21 13:37:00 lukem Exp $");
78 #define WI_STRING 0x01
81 #define WI_HEXBYTES 0x04
82 #define WI_KEYSTRUCT 0x05
84 #define WI_VENDOR 0x07
85 const char *wi_label
; /* label used to print info */
86 int wi_opt
; /* option character to set this */
91 /* already define in wireg.h XXX */
92 #define WI_APRATE_0 0x00 /* NONE */
93 #define WI_APRATE_1 0x0A /* 1 Mbps */
94 #define WI_APRATE_2 0x14 /* 2 Mbps */
95 #define WI_APRATE_5 0x37 /* 5.5 Mbps */
96 #define WI_APRATE_11 0x6E /* 11 Mbps */
98 #ifdef WI_RID_SCAN_APS
99 static void wi_apscan
__P((char *));
100 static int get_if_flags
__P((int, const char *));
101 static int set_if_flags
__P((int, const char *, int));
103 static int wi_getval
__P((char *, struct wi_req
*));
104 static void wi_setval
__P((char *, struct wi_req
*));
105 static void wi_printstr
__P((struct wi_req
*));
106 static void wi_setstr
__P((char *, int, char *));
107 static void wi_setbytes
__P((char *, int, char *, int));
108 static void wi_setword
__P((char *, int, int));
109 static void wi_sethex
__P((char *, int, char *));
110 static void wi_printwords
__P((struct wi_req
*));
111 static void wi_printbool
__P((struct wi_req
*));
112 static void wi_printhex
__P((struct wi_req
*));
113 static void wi_printbits
__P((struct wi_req
*));
114 static void wi_checkwifi
__P((char *));
115 static void wi_dumpinfo
__P((char *));
116 static void wi_printkeys
__P((struct wi_req
*));
117 static void wi_printvendor
__P((struct wi_req
*));
118 static void wi_dumpstats
__P((char *));
119 static void usage
__P((void));
120 static struct wi_table
*
121 wi_optlookup
__P((struct wi_table
*, int));
122 int main
__P((int argc
, char **argv
));
124 #ifdef WI_RID_SCAN_APS
125 static int get_if_flags(s
, name
)
132 strncpy(ifreq
.ifr_name
, name
, sizeof(ifreq
.ifr_name
));
133 if (ioctl(s
, SIOCGIFFLAGS
, (caddr_t
)&ifreq
) == -1)
134 err(1, "SIOCGIFFLAGS");
135 flags
= ifreq
.ifr_flags
;
140 static int set_if_flags(s
, name
, flags
)
147 ifreq
.ifr_flags
= flags
;
148 strncpy(ifreq
.ifr_name
, name
, sizeof(ifreq
.ifr_name
));
149 if (ioctl(s
, SIOCSIFFLAGS
, (caddr_t
)&ifreq
) == -1)
150 err(1, "SIOCSIFFLAGS");
155 static void wi_apscan(iface
)
168 errx(1, "must specify interface name");
170 s
= socket(AF_INET
, SOCK_DGRAM
, 0);
173 flags
= get_if_flags(s
, iface
);
174 if ((flags
& IFF_UP
) == 0)
175 flags
= set_if_flags(s
, iface
, flags
| IFF_UP
);
177 memset((char *)&wreq
, 0, sizeof(wreq
));
179 wreq
.wi_type
= WI_RID_SCAN_APS
;
181 /* note chan. 1 is the least significant bit */
182 wreq
.wi_val
[0] = htole16(0x3fff); /* 1 bit per channel, 1-14 */
183 wreq
.wi_val
[1] = htole16(0xf); /* tx rate */
185 /* write the request */
186 wi_setval(iface
, &wreq
);
188 /* now poll for a result */
189 memset((char *)&wreq
, 0, sizeof(wreq
));
191 wreq
.wi_type
= WI_RID_READ_APS
;
192 wreq
.wi_len
= WI_MAX_DATALEN
;
194 /* we have to do this ourself as opposed to
195 * using getval, because we cannot bail if
198 memset((char *)&ifr
, 0, sizeof(ifr
));
199 strncpy(ifr
.ifr_name
, iface
, sizeof(ifr
.ifr_name
));
200 ifr
.ifr_data
= (caddr_t
)&wreq
;
202 printf("scanning ...");
204 while (ioctl(s
, SIOCGWAVELAN
, &ifr
) == -1) {
207 printf("."); fflush(stdout
);
215 set_if_flags(s
, iface
, flags
);
220 naps
= *(int *)wreq
.wi_val
;
223 printf("\nAP Information\n");
225 printf("\nNo APs available\n");
227 w
= (struct wi_apinfo
*)(((char *)&wreq
.wi_val
) + sizeof(int));
228 for ( i
= 0; i
< naps
; i
++, w
++) {
229 printf("ap[%d]:\n", i
);
231 static const char *scanm
[] = {
233 "Firmware initiated",
234 "Inquiry request from host"
236 printf("\tScanReason:\t\t\t[ %s ]\n",
237 scanm
[w
->scanreason
- 1]);
239 printf("\tnetname (SSID):\t\t\t[ ");
240 for (j
= 0; j
< w
->namelen
; j
++) {
241 printf("%c", w
->name
[j
]);
244 printf("\tBSSID:\t\t\t\t[ %02x:%02x:%02x:%02x:%02x:%02x ]\n",
245 w
->bssid
[0]&0xff, w
->bssid
[1]&0xff,
246 w
->bssid
[2]&0xff, w
->bssid
[3]&0xff,
247 w
->bssid
[4]&0xff, w
->bssid
[5]&0xff);
248 printf("\tChannel:\t\t\t[ %d ]\n", w
->channel
);
249 printf("\tQuality/Signal/Noise [signal]:\t[ %d / %d / %d ]\n"
250 "\t [dBm]:\t[ %d / %d / %d ]\n",
251 w
->quality
, w
->signal
, w
->noise
,
252 w
->quality
, w
->signal
- 149, w
->noise
- 149);
253 printf("\tBSS Beacon Interval [msec]:\t[ %d ]\n", w
->interval
);
254 printf("\tCapinfo:\t\t\t[ ");
255 if (w
->capinfo
& IEEE80211_CAPINFO_ESS
)
257 if (w
->capinfo
& IEEE80211_CAPINFO_PRIVACY
)
279 if (rate
) printf("\tDataRate [Mbps]:\t\t[ %d ]\n", rate
);
282 set_if_flags(s
, iface
, flags
);
287 static int wi_getval(iface
, wreq
)
295 bzero((char *)&ifr
, sizeof(ifr
));
297 strncpy(ifr
.ifr_name
, iface
, sizeof(ifr
.ifr_name
));
298 ifr
.ifr_data
= (caddr_t
)wreq
;
300 s
= socket(AF_INET
, SOCK_DGRAM
, 0);
305 if (ioctl(s
, SIOCGWAVELAN
, &ifr
) == -1) {
306 warn("SIOCGWAVELAN(wreq %04x)", wreq
->wi_type
);
315 static void wi_setval(iface
, wreq
)
322 bzero((char *)&ifr
, sizeof(ifr
));
324 strncpy(ifr
.ifr_name
, iface
, sizeof(ifr
.ifr_name
));
325 ifr
.ifr_data
= (caddr_t
)wreq
;
327 s
= socket(AF_INET
, SOCK_DGRAM
, 0);
332 if (ioctl(s
, SIOCSWAVELAN
, &ifr
) == -1)
333 err(1, "SIOCSWAVELAN");
340 void wi_printstr(wreq
)
346 if (wreq
->wi_type
== WI_RID_SERIALNO
) {
347 ptr
= (char *)&wreq
->wi_val
;
348 for (i
= 0; i
< (wreq
->wi_len
- 1) * 2; i
++) {
353 int len
= le16toh(wreq
->wi_val
[0]);
355 ptr
= (char *)&wreq
->wi_val
[1];
356 for (i
= 0; i
< len
; i
++) {
363 printf("[ %s ]", ptr
);
368 void wi_setstr(iface
, code
, str
)
375 bzero((char *)&wreq
, sizeof(wreq
));
377 if (strlen(str
) > 30)
378 errx(1, "string too long");
382 wreq
.wi_val
[0] = htole16(strlen(str
));
383 bcopy(str
, (char *)&wreq
.wi_val
[1], strlen(str
));
385 wi_setval(iface
, &wreq
);
390 void wi_setbytes(iface
, code
, bytes
, len
)
398 bzero((char *)&wreq
, sizeof(wreq
));
401 wreq
.wi_len
= (len
/ 2) + 1;
402 bcopy(bytes
, (char *)&wreq
.wi_val
[0], len
);
404 wi_setval(iface
, &wreq
);
409 void wi_setword(iface
, code
, word
)
416 bzero((char *)&wreq
, sizeof(wreq
));
420 wreq
.wi_val
[0] = htole16(word
);
422 wi_setval(iface
, &wreq
);
427 void wi_sethex(iface
, code
, str
)
432 struct ether_addr
*addr
;
434 addr
= ether_aton(str
);
436 errx(1, "badly formatted address");
438 wi_setbytes(iface
, code
, (char *)addr
, ETHER_ADDR_LEN
);
443 static void wi_printkeys(wreq
)
448 struct wi_ltv_keys
*keys
;
451 keys
= (struct wi_ltv_keys
*)wreq
;
453 for (i
= 0, bn
= 0; i
< 4; i
++, bn
= 0) {
454 k
= &keys
->wi_keys
[i
];
455 ptr
= (char *)k
->wi_keydat
;
456 for (j
= 0; j
< le16toh(k
->wi_keylen
); j
++) {
457 if (!isprint((unsigned char) ptr
[j
])) {
465 for (j
= 0; j
< le16toh(k
->wi_keylen
); j
++)
466 printf("%02x", ((unsigned char *) ptr
)[j
]);
470 printf("[ %s ]", ptr
);
477 void wi_printvendor(wreq
)
485 #define WI_RID_STA_IDENTITY_LUCENT 0x1
486 #define WI_RID_STA_IDENTITY_PRISMII 0x2
487 #define WI_RID_STA_IDENTITY_SAMSUNG 0x3
488 #define WI_RID_STA_IDENTITY_DLINK 0x6
490 const char *vendor
= "Unknown";
492 if (wreq
->wi_len
< 4)
495 switch (le16toh(wreq
->wi_val
[1])) {
496 case WI_RID_STA_IDENTITY_LUCENT
:
499 case WI_RID_STA_IDENTITY_PRISMII
:
500 vendor
= "generic PRISM II";
502 case WI_RID_STA_IDENTITY_SAMSUNG
:
505 case WI_RID_STA_IDENTITY_DLINK
:
509 printf("[ %s ID: %d version: %d.%d ]", vendor
, le16toh(wreq
->wi_val
[0]),
510 le16toh(wreq
->wi_val
[2]), le16toh(wreq
->wi_val
[3]));
514 void wi_printwords(wreq
)
520 for (i
= 0; i
< wreq
->wi_len
- 1; i
++)
521 printf("%d ", le16toh(wreq
->wi_val
[i
]));
527 void wi_printbool(wreq
)
530 if (le16toh(wreq
->wi_val
[0]))
538 void wi_printhex(wreq
)
544 c
= (unsigned char *)&wreq
->wi_val
;
547 for (i
= 0; i
< (wreq
->wi_len
- 1) * 2; i
++) {
548 printf("%02x", c
[i
]);
549 if (i
< ((wreq
->wi_len
- 1) * 2) - 1)
557 void wi_printbits(wreq
)
561 int bits
= le16toh(wreq
->wi_val
[0]);
564 for (i
= 0; i
< 16; i
++) {
574 static struct wi_table wi_table
[] = {
575 { WI_RID_SERIALNO
, WI_STRING
, "NIC serial number:\t\t\t", 0, 0, 0 },
576 { WI_RID_NODENAME
, WI_STRING
, "Station name:\t\t\t\t",
577 's', "station name", 0, },
578 { WI_RID_OWN_SSID
, WI_STRING
, "SSID for IBSS creation:\t\t\t", 0, 0, 0 },
579 { WI_RID_CURRENT_SSID
, WI_STRING
, "Current netname (SSID):\t\t\t", 0, 0, 0 },
580 { WI_RID_DESIRED_SSID
, WI_STRING
, "Desired netname (SSID):\t\t\t", 0, 0, 0 },
581 { WI_RID_CURRENT_BSSID
, WI_HEXBYTES
, "Current BSSID:\t\t\t\t", 0, 0, 0 },
582 { WI_RID_CHANNEL_LIST
, WI_BITS
, "Channel list:\t\t\t\t", 0, 0, 0 },
583 { WI_RID_OWN_CHNL
, WI_WORDS
, "IBSS channel:\t\t\t\t", 0, 0, 0 },
584 { WI_RID_CURRENT_CHAN
, WI_WORDS
, "Current channel:\t\t\t", 0, 0, 0 },
585 { WI_RID_COMMS_QUALITY
, WI_WORDS
, "Comms quality/signal/noise:\t\t", 0, 0, 0 },
586 { WI_RID_PROMISC
, WI_BOOL
, "Promiscuous mode:\t\t\t", 0, 0, 0 },
587 { WI_RID_PORTTYPE
, WI_WORDS
, "Port type:\t\t\t\t", 0, 0, 0 },
588 { WI_RID_MAC_NODE
, WI_HEXBYTES
, "MAC address:\t\t\t\t",
589 'm', "MAC address", 0, },
590 { WI_RID_TX_RATE
, WI_WORDS
, "TX rate (selection):\t\t\t", 0, 0, 0 },
591 { WI_RID_CUR_TX_RATE
, WI_WORDS
, "TX rate (actual speed):\t\t\t", 0, 0, 0 },
592 { WI_RID_CUR_BEACON_INT
, WI_WORDS
, "Beacon Interval (current) [msec]:\t", 0, 0, 0 },
593 { WI_RID_MAX_DATALEN
, WI_WORDS
, "Maximum data length:\t\t\t",
594 'd', "maximum data length", 0 },
595 { WI_RID_RTS_THRESH
, WI_WORDS
, "RTS/CTS handshake threshold:\t\t",
596 'r', "RTS threshold", 0 },
597 { WI_RID_FRAG_THRESH
, WI_WORDS
, "fragmentation threshold:\t\t",
598 'g', "fragmentation threshold", 0, },
599 { WI_RID_DBM_ADJUST
, WI_WORDS
, "RSSI -> dBm adjustment:\t\t\t", 0, 0, 0 },
600 { WI_RID_CREATE_IBSS
, WI_BOOL
, "Create IBSS:\t\t\t\t", 0, 0, 0 },
601 { WI_RID_MICROWAVE_OVEN
, WI_WORDS
, "Microwave oven robustness:\t\t",
602 'M', "microwave oven robustness enabled", 0 },
603 { WI_RID_ROAMING_MODE
, WI_WORDS
, "Roaming mode(1:firm,3:disable):\t\t",
604 'R', "roaming mode", 0 },
605 { WI_RID_SYSTEM_SCALE
, WI_WORDS
, "Access point density:\t\t\t",
606 'a', "system scale", 0 },
607 { WI_RID_PM_ENABLED
, WI_WORDS
, "Power Mgmt (1=on, 0=off):\t\t", 0, 0, 0 },
608 { WI_RID_MAX_SLEEP
, WI_WORDS
, "Max sleep time (msec):\t\t\t", 0, 0, 0 },
609 { WI_RID_STA_IDENTITY
, WI_VENDOR
, "Vendor info:\t\t\t\t", 0, 0, 0 },
610 { 0, WI_NONE
, 0, 0, 0, 0 }
613 static struct wi_table wi_crypt_table
[] = {
614 { WI_RID_ENCRYPTION
, WI_BOOL
, "WEP encryption:\t\t\t\t", 0, 0, 0 },
615 { WI_RID_CNFAUTHMODE
, WI_WORDS
, "Authentication type \n(1=OpenSys, 2=Shared Key):\t\t",
616 'A', "authentication type", 0 },
617 { WI_RID_TX_CRYPT_KEY
, WI_WORDS
, "TX encryption key:\t\t\t", 0, 0, 0 },
618 { WI_RID_DEFLT_CRYPT_KEYS
, WI_KEYSTRUCT
, "Encryption keys:\t\t\t", 0, 0, 0 },
619 { 0, WI_NONE
, 0, 0, 0, 0 }
622 static struct wi_table
*wi_tables
[] = {
628 static struct wi_table
*
629 wi_optlookup(table
, opt
)
630 struct wi_table
*table
;
635 for (wt
= table
; wt
->wi_type
!= 0; wt
++)
636 if (wt
->wi_opt
== opt
)
641 static void wi_checkwifi(iface
)
645 struct ieee80211_nwid nwid
;
648 bzero((char *)&ifr
, sizeof(ifr
));
650 strncpy(ifr
.ifr_name
, iface
, sizeof(ifr
.ifr_name
));
651 ifr
.ifr_data
= (void *)&nwid
;
653 s
= socket(AF_INET
, SOCK_DGRAM
, 0);
658 /* Choice of ioctl inspired by ifconfig/ieee80211.c */
659 if (ioctl(s
, SIOCG80211NWID
, &ifr
) == -1)
660 err(1, "SIOCG80211NWID");
665 static void wi_dumpinfo(iface
)
672 bzero((char *)&wreq
, sizeof(wreq
));
674 wreq
.wi_len
= WI_MAX_DATALEN
;
675 wreq
.wi_type
= WI_RID_WEP_AVAIL
;
677 wi_getval(iface
, &wreq
);
678 has_wep
= le16toh(wreq
.wi_val
[0]);
682 for (i
= 0; w
[i
].wi_code
!= WI_NONE
; i
++) {
683 bzero((char *)&wreq
, sizeof(wreq
));
685 wreq
.wi_len
= WI_MAX_DATALEN
;
686 wreq
.wi_type
= w
[i
].wi_type
;
688 printf("%s", w
[i
].wi_label
);
689 if (wi_getval(iface
, &wreq
)) {
690 printf("[ Unknown ]\n");
693 switch (w
[i
].wi_code
) {
698 wi_printwords(&wreq
);
710 wi_printvendor(&wreq
);
720 for (i
= 0; w
[i
].wi_code
!= WI_NONE
; i
++) {
721 bzero((char *)&wreq
, sizeof(wreq
));
723 wreq
.wi_len
= WI_MAX_DATALEN
;
724 wreq
.wi_type
= w
[i
].wi_type
;
726 wi_getval(iface
, &wreq
);
727 printf("%s", w
[i
].wi_label
);
728 switch (w
[i
].wi_code
) {
733 if (wreq
.wi_type
== WI_RID_TX_CRYPT_KEY
)
735 htole16(le16toh(wreq
.wi_val
[0]) + 1);
736 wi_printwords(&wreq
);
757 static void wi_dumpstats(iface
)
761 struct wi_counters
*c
;
763 bzero((char *)&wreq
, sizeof(wreq
));
764 wreq
.wi_len
= WI_MAX_DATALEN
;
765 wreq
.wi_type
= WI_RID_IFACE_STATS
;
767 wi_getval(iface
, &wreq
);
769 c
= (struct wi_counters
*)&wreq
.wi_val
;
771 /* XXX native byte order */
772 printf("Transmitted unicast frames:\t\t%d\n",
773 c
->wi_tx_unicast_frames
);
774 printf("Transmitted multicast frames:\t\t%d\n",
775 c
->wi_tx_multicast_frames
);
776 printf("Transmitted fragments:\t\t\t%d\n",
778 printf("Transmitted unicast octets:\t\t%d\n",
779 c
->wi_tx_unicast_octets
);
780 printf("Transmitted multicast octets:\t\t%d\n",
781 c
->wi_tx_multicast_octets
);
782 printf("Single transmit retries:\t\t%d\n",
783 c
->wi_tx_single_retries
);
784 printf("Multiple transmit retries:\t\t%d\n",
785 c
->wi_tx_multi_retries
);
786 printf("Transmit retry limit exceeded:\t\t%d\n",
787 c
->wi_tx_retry_limit
);
788 printf("Transmit discards:\t\t\t%d\n",
790 printf("Transmit discards due to wrong SA:\t%d\n",
791 c
->wi_tx_discards_wrong_sa
);
792 printf("Received unicast frames:\t\t%d\n",
793 c
->wi_rx_unicast_frames
);
794 printf("Received multicast frames:\t\t%d\n",
795 c
->wi_rx_multicast_frames
);
796 printf("Received fragments:\t\t\t%d\n",
798 printf("Received unicast octets:\t\t%d\n",
799 c
->wi_rx_unicast_octets
);
800 printf("Received multicast octets:\t\t%d\n",
801 c
->wi_rx_multicast_octets
);
802 printf("Receive FCS errors:\t\t\t%d\n",
803 c
->wi_rx_fcs_errors
);
804 printf("Receive discards due to no buffer:\t%d\n",
805 c
->wi_rx_discards_nobuf
);
806 printf("Can't decrypt WEP frame:\t\t%d\n",
807 c
->wi_rx_WEP_cant_decrypt
);
808 printf("Received message fragments:\t\t%d\n",
809 c
->wi_rx_msg_in_msg_frags
);
810 printf("Received message bad fragments:\t\t%d\n",
811 c
->wi_rx_msg_in_bad_msg_frags
);
821 "usage: %s interface [-Dho] [-A 1|2] [-a access point density]\n"
822 " [-d max data length] [-g fragmentation threshold] [-M 0|1]\n"
823 " [-m MAC address] [-R 1|3] [-r RTS threshold] [-s station name]\n"
833 struct wi_table
*wt
, **table
;
835 int ch
, dumpinfo
, dumpstats
, apscan
;
837 #define SET_OPERAND(opr, desc) do { \
841 warnx("%s is already specified to %s", \
850 if (argc
> 1 && argv
[1][0] != '-') {
855 while ((ch
= getopt(argc
, argv
,
856 "a:d:g:hi:m:or:s:A:M:R:D")) != -1) {
860 * Lookup generic options and remember operand if found.
862 wt
= NULL
; /* XXXGCC -Wuninitialized */
863 for (table
= wi_tables
; *table
!= NULL
; table
++)
864 if ((wt
= wi_optlookup(*table
, ch
)) != NULL
) {
865 SET_OPERAND(wt
->wi_optval
, wt
->wi_desc
);
870 * Handle special options.
877 SET_OPERAND(iface
, "interface");
892 /* Check interface is wireless. Will not return on error */
895 for (table
= wi_tables
; *table
!= NULL
; table
++)
896 for (wt
= *table
; wt
->wi_code
!= WI_NONE
; wt
++)
897 if (wt
->wi_optval
!= NULL
) {
898 switch (wt
->wi_code
) {
901 wi_setword(iface
, wt
->wi_type
,
902 atoi(wt
->wi_optval
));
905 wi_setstr(iface
, wt
->wi_type
,
909 wi_sethex(iface
, wt
->wi_type
,
921 #ifdef WI_RID_SCAN_APS
924 errx(1, "AP scan mode is not available.");