wiconfig.c revision 1.3 1 /*
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul (at) ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Bill Paul.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $Id: wiconfig.c,v 1.3 2000/03/26 08:58:11 itojun Exp $
33 */
34
35 #include <sys/types.h>
36 #include <sys/cdefs.h>
37 #include <sys/param.h>
38 #include <sys/socket.h>
39 #include <sys/ioctl.h>
40 #include <sys/socket.h>
41
42 #include <net/if.h>
43 #ifdef __FreeBSD__
44 #include <net/if_var.h>
45 #include <net/ethernet.h>
46
47 #include <machine/if_wavelan_ieee.h>
48 #else
49 #include <netinet/in.h>
50 #include <netinet/if_ether.h>
51 #ifdef __NetBSD__
52 #include <dev/pcmcia/if_wi_ieee.h>
53 #else
54 #include <dev/pcmcia/if_wavelan_ieee.h>
55 #endif
56 #endif
57
58 #include <stdio.h>
59 #include <string.h>
60 #include <ctype.h>
61 #include <stdlib.h>
62 #include <unistd.h>
63 #include <errno.h>
64 #include <err.h>
65
66 #if !defined(lint)
67 static const char copyright[] = "@(#) Copyright (c) 1997, 1998, 1999\
68 Bill Paul. All rights reserved.";
69 static const char rcsid[] =
70 "@(#) $Id: wiconfig.c,v 1.3 2000/03/26 08:58:11 itojun Exp $";
71 #endif
72
73 static void wi_getval __P((char *, struct wi_req *));
74 static void wi_setval __P((char *, struct wi_req *));
75 static void wi_printstr __P((struct wi_req *));
76 static void wi_setstr __P((char *, int, char *));
77 static void wi_setbytes __P((char *, int, char *, int));
78 static void wi_setword __P((char *, int, int));
79 static void wi_sethex __P((char *, int, char *));
80 static void wi_printwords __P((struct wi_req *));
81 static void wi_printbool __P((struct wi_req *));
82 static void wi_printhex __P((struct wi_req *));
83 static void wi_dumpinfo __P((char *));
84 static void wi_setkeys __P((char *, char *, int));
85 static void wi_printkeys __P((struct wi_req *));
86 static void wi_dumpstats __P((char *));
87 static void usage __P((char *));
88 static int wi_hex2int(char c);
89 static void wi_str2key __P((char *, struct wi_key *));
90 int main __P((int argc, char **argv));
91
92 static void wi_getval(iface, wreq)
93 char *iface;
94 struct wi_req *wreq;
95 {
96 struct ifreq ifr;
97 int s;
98
99 if (iface == NULL)
100 errx(1, "must specify interface name");
101
102 bzero((char *)&ifr, sizeof(ifr));
103
104 strcpy(ifr.ifr_name, iface);
105 ifr.ifr_data = (caddr_t)wreq;
106
107 s = socket(AF_INET, SOCK_DGRAM, 0);
108
109 if (s == -1)
110 err(1, "socket");
111
112 if (ioctl(s, SIOCGWAVELAN, &ifr) == -1)
113 err(1, "SIOCGWAVELAN");
114
115 close(s);
116
117 return;
118 }
119
120 static void wi_setval(iface, wreq)
121 char *iface;
122 struct wi_req *wreq;
123 {
124 struct ifreq ifr;
125 int s;
126
127 bzero((char *)&ifr, sizeof(ifr));
128
129 strcpy(ifr.ifr_name, iface);
130 ifr.ifr_data = (caddr_t)wreq;
131
132 s = socket(AF_INET, SOCK_DGRAM, 0);
133
134 if (s == -1)
135 err(1, "socket");
136
137 if (ioctl(s, SIOCSWAVELAN, &ifr) == -1)
138 err(1, "SIOCSWAVELAN");
139
140 close(s);
141
142 return;
143 }
144
145 void wi_printstr(wreq)
146 struct wi_req *wreq;
147 {
148 char *ptr;
149 int i;
150
151 if (wreq->wi_type == WI_RID_SERIALNO) {
152 ptr = (char *)&wreq->wi_val;
153 for (i = 0; i < (wreq->wi_len - 1) * 2; i++) {
154 if (ptr[i] == '\0')
155 ptr[i] = ' ';
156 }
157 } else {
158 ptr = (char *)&wreq->wi_val[1];
159 for (i = 0; i < wreq->wi_val[0]; i++) {
160 if (ptr[i] == '\0')
161 ptr[i] = ' ';
162 }
163 }
164
165 ptr[i] = '\0';
166 printf("[ %s ]", ptr);
167
168 return;
169 }
170
171 void wi_setstr(iface, code, str)
172 char *iface;
173 int code;
174 char *str;
175 {
176 struct wi_req wreq;
177
178 if (iface == NULL)
179 errx(1, "must specify interface name");
180
181 if (str == NULL)
182 errx(1, "must specify string");
183
184 bzero((char *)&wreq, sizeof(wreq));
185
186 if (strlen(str) > 30)
187 errx(1, "string too long");
188
189 wreq.wi_type = code;
190 wreq.wi_len = 18;
191 wreq.wi_val[0] = strlen(str);
192 bcopy(str, (char *)&wreq.wi_val[1], strlen(str));
193
194 wi_setval(iface, &wreq);
195
196 return;
197 }
198
199 void wi_setbytes(iface, code, bytes, len)
200 char *iface;
201 int code;
202 char *bytes;
203 int len;
204 {
205 struct wi_req wreq;
206
207 if (iface == NULL)
208 errx(1, "must specify interface name");
209
210 bzero((char *)&wreq, sizeof(wreq));
211
212 wreq.wi_type = code;
213 wreq.wi_len = (len / 2) + 1;
214 bcopy(bytes, (char *)&wreq.wi_val[0], len);
215
216 wi_setval(iface, &wreq);
217
218 return;
219 }
220
221 void wi_setword(iface, code, word)
222 char *iface;
223 int code;
224 int word;
225 {
226 struct wi_req wreq;
227
228 if (iface == NULL)
229 errx(1, "must specify interface name");
230
231 bzero((char *)&wreq, sizeof(wreq));
232
233 wreq.wi_type = code;
234 wreq.wi_len = 2;
235 wreq.wi_val[0] = word;
236
237 wi_setval(iface, &wreq);
238
239 return;
240 }
241
242 void wi_sethex(iface, code, str)
243 char *iface;
244 int code;
245 char *str;
246 {
247 struct ether_addr *addr;
248
249 if (iface == NULL)
250 errx(1, "must specify interface name");
251 if (str == NULL)
252 errx(1, "must specify address");
253
254 addr = ether_aton(str);
255
256 if (addr == NULL)
257 errx(1, "badly formatted address");
258
259 wi_setbytes(iface, code, (char *)addr, ETHER_ADDR_LEN);
260
261 return;
262 }
263
264 static int
265 wi_hex2int(char c)
266 {
267 if (c >= '0' && c <= '9')
268 return (c - '0');
269 if (c >= 'A' && c <= 'F')
270 return (c - 'A' + 10);
271 if (c >= 'a' && c <= 'f')
272 return (c - 'a' + 10);
273
274 return (0);
275 }
276
277 static void wi_str2key(s, k)
278 char *s;
279 struct wi_key *k;
280 {
281 int n, i;
282 char *p;
283
284 /* Is this a hex string? */
285 if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) {
286 /* Yes, convert to int. */
287 n = 0;
288 p = (char *)&k->wi_keydat[0];
289 for (i = 2; i < strlen(s); i+= 2) {
290 *p++ = (wi_hex2int(s[i]) << 4) + wi_hex2int(s[i + 1]);
291 n++;
292 }
293 k->wi_keylen = n;
294 } else {
295 /* No, just copy it in. */
296 bcopy(s, k->wi_keydat, strlen(s));
297 k->wi_keylen = strlen(s);
298 }
299
300 return;
301 }
302
303 static void wi_setkeys(iface, key, idx)
304 char *iface;
305 char *key;
306 int idx;
307 {
308 struct wi_req wreq;
309 struct wi_ltv_keys *keys;
310 struct wi_key *k;
311
312 if (iface == NULL)
313 errx(1, "must specify interface name");
314
315 bzero((char *)&wreq, sizeof(wreq));
316 wreq.wi_len = WI_MAX_DATALEN;
317 wreq.wi_type = WI_RID_WEP_AVAIL;
318
319 wi_getval(iface, &wreq);
320 if (wreq.wi_val[0] == 0)
321 err(1, "no WEP option available on this card");
322
323 bzero((char *)&wreq, sizeof(wreq));
324 wreq.wi_len = WI_MAX_DATALEN;
325 wreq.wi_type = WI_RID_DEFLT_CRYPT_KEYS;
326
327 wi_getval(iface, &wreq);
328 keys = (struct wi_ltv_keys *)&wreq;
329
330 if (key[0] == '0' && (key[1] == 'x' || key[1] == 'X')) {
331 if (strlen(key) > 30)
332 err(1, "encryption key must be no "
333 "more than 28 hex digits long");
334 } else {
335 if (strlen(key) > 14)
336 err(1, "encryption key must be no "
337 "more than 14 characters long");
338 }
339
340 if (idx > 3)
341 err(1, "only 4 encryption keys available");
342
343 k = &keys->wi_keys[idx];
344 wi_str2key(key, k);
345
346 wreq.wi_len = (sizeof(struct wi_ltv_keys) / 2) + 1;
347 wreq.wi_type = WI_RID_DEFLT_CRYPT_KEYS;
348 wi_setval(iface, &wreq);
349
350 return;
351 }
352
353 static void wi_printkeys(wreq)
354 struct wi_req *wreq;
355 {
356 int i, j, bn;
357 struct wi_key *k;
358 struct wi_ltv_keys *keys;
359 char *ptr;
360
361 keys = (struct wi_ltv_keys *)wreq;
362
363 for (i = 0, bn = 0; i < 4; i++, bn = 0) {
364 k = &keys->wi_keys[i];
365 ptr = (char *)k->wi_keydat;
366 for (j = 0; j < k->wi_keylen; j++) {
367 if (!isprint(ptr[j])) {
368 bn = 1;
369 break;
370 }
371 }
372
373 if (bn) {
374 printf("[ 0x");
375 for (j = 0; j < k->wi_keylen; j++)
376 printf("%02x", ((unsigned char *) ptr)[j]);
377 printf(" ]");
378 } else {
379 ptr[j] = '\0';
380 printf("[ %s ]", ptr);
381 }
382 }
383
384 return;
385 };
386
387 void wi_printwords(wreq)
388 struct wi_req *wreq;
389 {
390 int i;
391
392 printf("[ ");
393 for (i = 0; i < wreq->wi_len - 1; i++)
394 printf("%d ", wreq->wi_val[i]);
395 printf("]");
396
397 return;
398 }
399
400 void wi_printbool(wreq)
401 struct wi_req *wreq;
402 {
403 if (wreq->wi_val[0])
404 printf("[ On ]");
405 else
406 printf("[ Off ]");
407
408 return;
409 }
410
411 void wi_printhex(wreq)
412 struct wi_req *wreq;
413 {
414 int i;
415 unsigned char *c;
416
417 c = (unsigned char *)&wreq->wi_val;
418
419 printf("[ ");
420 for (i = 0; i < (wreq->wi_len - 1) * 2; i++) {
421 printf("%02x", c[i]);
422 if (i < ((wreq->wi_len - 1) * 2) - 1)
423 printf(":");
424 }
425
426 printf(" ]");
427 return;
428 }
429
430 #define WI_STRING 0x01
431 #define WI_BOOL 0x02
432 #define WI_WORDS 0x03
433 #define WI_HEXBYTES 0x04
434 #define WI_KEYSTRUCT 0x05
435
436 struct wi_table {
437 int wi_code;
438 int wi_type;
439 char *wi_str;
440 };
441
442 static struct wi_table wi_table[] = {
443 { WI_RID_SERIALNO, WI_STRING, "NIC serial number:\t\t\t" },
444 { WI_RID_NODENAME, WI_STRING, "Station name:\t\t\t\t" },
445 { WI_RID_OWN_SSID, WI_STRING, "SSID for IBSS creation:\t\t\t" },
446 { WI_RID_CURRENT_SSID, WI_STRING, "Current netname (SSID):\t\t\t" },
447 { WI_RID_DESIRED_SSID, WI_STRING, "Desired netname (SSID):\t\t\t" },
448 { WI_RID_CURRENT_BSSID, WI_HEXBYTES, "Current BSSID:\t\t\t\t" },
449 { WI_RID_CHANNEL_LIST, WI_WORDS, "Channel list:\t\t\t\t" },
450 { WI_RID_OWN_CHNL, WI_WORDS, "IBSS channel:\t\t\t\t" },
451 { WI_RID_CURRENT_CHAN, WI_WORDS, "Current channel:\t\t\t" },
452 { WI_RID_COMMS_QUALITY, WI_WORDS, "Comms quality/signal/noise:\t\t" },
453 { WI_RID_PROMISC, WI_BOOL, "Promiscuous mode:\t\t\t" },
454 { WI_RID_PORTTYPE, WI_WORDS, "Port type (1=BSS, 3=ad-hoc):\t\t"},
455 { WI_RID_MAC_NODE, WI_HEXBYTES, "MAC address:\t\t\t\t"},
456 { WI_RID_TX_RATE, WI_WORDS, "TX rate (selection):\t\t\t"},
457 { WI_RID_CUR_TX_RATE, WI_WORDS, "TX rate (actual speed):\t\t\t"},
458 { WI_RID_RTS_THRESH, WI_WORDS, "RTS/CTS handshake threshold:\t\t"},
459 { WI_RID_CREATE_IBSS, WI_BOOL, "Create IBSS:\t\t\t\t" },
460 { WI_RID_SYSTEM_SCALE, WI_WORDS, "Access point density:\t\t\t" },
461 { WI_RID_PM_ENABLED, WI_WORDS, "Power Mgmt (1=on, 0=off):\t\t" },
462 { WI_RID_MAX_SLEEP, WI_WORDS, "Max sleep time:\t\t\t\t" },
463 { 0, NULL }
464 };
465
466 static struct wi_table wi_crypt_table[] = {
467 { WI_RID_ENCRYPTION, WI_BOOL, "WEP encryption:\t\t\t\t" },
468 { WI_RID_TX_CRYPT_KEY, WI_WORDS, "TX encryption key:\t\t\t" },
469 { WI_RID_DEFLT_CRYPT_KEYS, WI_KEYSTRUCT, "Encryption keys:\t\t\t" },
470 { 0, NULL }
471 };
472
473 static void wi_dumpinfo(iface)
474 char *iface;
475 {
476 struct wi_req wreq;
477 int i, has_wep;
478 struct wi_table *w;
479
480 bzero((char *)&wreq, sizeof(wreq));
481
482 wreq.wi_len = WI_MAX_DATALEN;
483 wreq.wi_type = WI_RID_WEP_AVAIL;
484
485 wi_getval(iface, &wreq);
486 has_wep = wreq.wi_val[0];
487
488 w = wi_table;
489
490 for (i = 0; w[i].wi_type; i++) {
491 bzero((char *)&wreq, sizeof(wreq));
492
493 wreq.wi_len = WI_MAX_DATALEN;
494 wreq.wi_type = w[i].wi_code;
495
496 wi_getval(iface, &wreq);
497 printf("%s", w[i].wi_str);
498 switch (w[i].wi_type) {
499 case WI_STRING:
500 wi_printstr(&wreq);
501 break;
502 case WI_WORDS:
503 wi_printwords(&wreq);
504 break;
505 case WI_BOOL:
506 wi_printbool(&wreq);
507 break;
508 case WI_HEXBYTES:
509 wi_printhex(&wreq);
510 break;
511 default:
512 break;
513 }
514 printf("\n");
515 }
516
517 if (has_wep) {
518 w = wi_crypt_table;
519 for (i = 0; w[i].wi_type; i++) {
520 bzero((char *)&wreq, sizeof(wreq));
521
522 wreq.wi_len = WI_MAX_DATALEN;
523 wreq.wi_type = w[i].wi_code;
524
525 wi_getval(iface, &wreq);
526 printf("%s", w[i].wi_str);
527 switch (w[i].wi_type) {
528 case WI_STRING:
529 wi_printstr(&wreq);
530 break;
531 case WI_WORDS:
532 if (wreq.wi_type == WI_RID_TX_CRYPT_KEY)
533 wreq.wi_val[0]++;
534 wi_printwords(&wreq);
535 break;
536 case WI_BOOL:
537 wi_printbool(&wreq);
538 break;
539 case WI_HEXBYTES:
540 wi_printhex(&wreq);
541 break;
542 case WI_KEYSTRUCT:
543 wi_printkeys(&wreq);
544 break;
545 default:
546 break;
547 }
548 printf("\n");
549 }
550 }
551
552 return;
553 }
554
555 static void wi_dumpstats(iface)
556 char *iface;
557 {
558 struct wi_req wreq;
559 struct wi_counters *c;
560
561 if (iface == NULL)
562 errx(1, "must specify interface name");
563
564 bzero((char *)&wreq, sizeof(wreq));
565 wreq.wi_len = WI_MAX_DATALEN;
566 wreq.wi_type = WI_RID_IFACE_STATS;
567
568 wi_getval(iface, &wreq);
569
570 c = (struct wi_counters *)&wreq.wi_val;
571
572 printf("Transmitted unicast frames:\t\t%d\n",
573 c->wi_tx_unicast_frames);
574 printf("Transmitted multicast frames:\t\t%d\n",
575 c->wi_tx_multicast_frames);
576 printf("Transmitted fragments:\t\t\t%d\n",
577 c->wi_tx_fragments);
578 printf("Transmitted unicast octets:\t\t%d\n",
579 c->wi_tx_unicast_octets);
580 printf("Transmitted multicast octets:\t\t%d\n",
581 c->wi_tx_multicast_octets);
582 printf("Single transmit retries:\t\t%d\n",
583 c->wi_tx_single_retries);
584 printf("Multiple transmit retries:\t\t%d\n",
585 c->wi_tx_multi_retries);
586 printf("Transmit retry limit exceeded:\t\t%d\n",
587 c->wi_tx_retry_limit);
588 printf("Transmit discards:\t\t\t%d\n",
589 c->wi_tx_discards);
590 printf("Transmit discards due to wrong SA:\t%d\n",
591 c->wi_tx_discards_wrong_sa);
592 printf("Received unicast frames:\t\t%d\n",
593 c->wi_rx_unicast_frames);
594 printf("Received multicast frames:\t\t%d\n",
595 c->wi_rx_multicast_frames);
596 printf("Received fragments:\t\t\t%d\n",
597 c->wi_rx_fragments);
598 printf("Received unicast octets:\t\t%d\n",
599 c->wi_rx_unicast_octets);
600 printf("Received multicast octets:\t\t%d\n",
601 c->wi_rx_multicast_octets);
602 printf("Receive FCS errors:\t\t\t%d\n",
603 c->wi_rx_fcs_errors);
604 printf("Receive discards due to no buffer:\t%d\n",
605 c->wi_rx_discards_nobuf);
606 printf("Can't decrypt WEP frame:\t\t%d\n",
607 c->wi_rx_WEP_cant_decrypt);
608 printf("Received message fragments:\t\t%d\n",
609 c->wi_rx_msg_in_msg_frags);
610 printf("Received message bad fragments:\t\t%d\n",
611 c->wi_rx_msg_in_bad_msg_frags);
612
613 return;
614 }
615
616 static void usage(p)
617 char *p;
618 {
619 fprintf(stderr,
620 "usage: wiconfig interface "
621 "[-o] [-t tx rate] [-n network name] [-s station name]\n"
622 " [-e 0|1] [-k key [-v 1|2|3|4]] [-T 1|2|3|4]\n"
623 " [-c 0|1] [-q SSID] [-p port type] [-a access point density]\n"
624 " [-m MAC address] [-d max data length] [-r RTS threshold]\n"
625 " [-f frequency] [-P 0|1] [-S max sleep duration]\n");
626 exit(1);
627 }
628
629 int main(argc, argv)
630 int argc;
631 char *argv[];
632 {
633 int ch;
634 char *iface = NULL;
635 char *p = argv[0];
636 char *key = NULL;
637 int modifier = 0;
638
639 if (argc > 1 && argv[1][0] != '-') {
640 iface = argv[1];
641 memcpy(&argv[1], &argv[2], argc * sizeof(char *));
642 argc--;
643 }
644
645 while ((ch = getopt(argc, argv,
646 "hoc:d:f:p:r:q:t:n:s:i:m:P:S:T:e:k:v:")) != -1) {
647 switch (ch) {
648 case 'o':
649 wi_dumpstats(iface);
650 exit(0);
651 break;
652 case 'i':
653 if (iface == NULL)
654 iface = optarg;
655 break;
656 case 'c':
657 wi_setword(iface, WI_RID_CREATE_IBSS, atoi(optarg));
658 exit(0);
659 break;
660 case 'd':
661 wi_setword(iface, WI_RID_MAX_DATALEN, atoi(optarg));
662 exit(0);
663 break;
664 case 'f':
665 wi_setword(iface, WI_RID_OWN_CHNL, atoi(optarg));
666 exit(0);
667 break;
668 case 'p':
669 wi_setword(iface, WI_RID_PORTTYPE, atoi(optarg));
670 exit(0);
671 break;
672 case 'r':
673 wi_setword(iface, WI_RID_RTS_THRESH, atoi(optarg));
674 exit(0);
675 break;
676 case 't':
677 wi_setword(iface, WI_RID_TX_RATE, atoi(optarg));
678 exit(0);
679 break;
680 case 'n':
681 wi_setstr(iface, WI_RID_DESIRED_SSID, optarg);
682 exit(0);
683 break;
684 case 's':
685 wi_setstr(iface, WI_RID_NODENAME, optarg);
686 exit(0);
687 break;
688 case 'm':
689 wi_sethex(iface, WI_RID_MAC_NODE, optarg);
690 exit(0);
691 break;
692 case 'q':
693 wi_setstr(iface, WI_RID_OWN_SSID, optarg);
694 exit(0);
695 break;
696 case 'S':
697 wi_setword(iface, WI_RID_MAX_SLEEP, atoi(optarg));
698 exit(0);
699 break;
700 case 'P':
701 wi_setword(iface, WI_RID_PM_ENABLED, atoi(optarg));
702 exit(0);
703 break;
704 case 'T':
705 wi_setword(iface, WI_RID_TX_CRYPT_KEY,
706 atoi(optarg) - 1);
707 exit(0);
708 break;
709 case 'k':
710 key = optarg;
711 break;
712 case 'e':
713 wi_setword(iface, WI_RID_ENCRYPTION, atoi(optarg));
714 exit(0);
715 break;
716 case 'v':
717 modifier = atoi(optarg);
718 modifier--;
719 break;
720 case 'h':
721 default:
722 usage(p);
723 break;
724 }
725 }
726
727 if (iface == NULL)
728 usage(p);
729
730 if (key != NULL)
731 wi_setkeys(iface, key, modifier);
732
733 wi_dumpinfo(iface);
734
735 exit(0);
736 }
737