4 * Jean II - HPLB 97->99 - HPL 99->00
6 * Main code for "iwconfig". This is the generic tool for most
8 * You need to link this code against "iwlib.c" and "-lm".
10 * This file is released under the GPL license.
11 * Copyright (c) 1997-2002 Jean Tourrilhes <jt@hpl.hp.com>
14 #include "iwlib.h" /* Header */
16 /************************** DOCUMENTATION **************************/
21 * The initial implementation of iwpriv was using the SIOCDEVPRIVATE
22 * ioctl range (up to 16 ioctls - driver specific). However, this was
23 * causing some compatibility problems with other usages of those
24 * ioctls, and those ioctls are supposed to be removed.
25 * Therefore, I created a new ioctl range, at SIOCIWFIRSTPRIV. Those
26 * ioctls are specific to Wireless Extensions, so you don't have to
27 * worry about collisions with other usages. On the other hand, in the
28 * new range, the SET convention is enforced (see below).
29 * The differences are : SIOCDEVPRIVATE SIOCIWFIRSTPRIV
30 * o availability : <= 2.5.X WE > 11 (>= 2.4.13)
32 * o SET convention optional enforced
37 * Wireless Extension 13 introduce a new driver API. Wireless
38 * Extensions requests can be handled via a iw_handler table instead
39 * of through the regular ioctl handler.
40 * The new driver API can be handled only with the new ioctl range
41 * and enforce the GET convention (see below).
42 * The differences are : old API new API
43 * o handler do_ioctl() struct iw_handler_def
44 * o SIOCIWFIRSTPRIV WE > 11 yes
45 * o SIOCDEVPRIVATE yes no
46 * o GET convention optional enforced
47 * Note that the new API before Wireless Extension 15 contains bugs
48 * with regards to handling sub-ioctls and addr/float data types.
50 * SET/GET CONVENTION :
52 * The regular Wireless Extensions use a SET/GET convention, where
53 * the low order bit identify a SET (0) or a GET (1) request.
54 * The new ioctl range enforce the SET convention : SET request will
55 * be available to root only and can't return any arguments. If you don't
56 * like that, just use every other two ioctl.
57 * The new driver API enforce the GET convention : GET request won't
58 * be able to accept any arguments (except if its fits within (union
59 * iwreq_data)). If you don't like that, just use the old API (aka the
61 * In any case, it's a good idea to not have ioctl with both SET
62 * and GET arguments. If the GET arguments doesn't fit within
63 * (union iwreq_data) and SET do, or vice versa, the current code in iwpriv
64 * won't work. One exception is if both SET and GET arguments fit within
65 * (union iwreq_data), this case should be handled safely in a GET
70 * Wireless Extension 15 introduce sub-ioctls. For some applications,
71 * 32 ioctl is not enough, and this simple mechanism allow to increase
72 * the number of ioctls by adding a sub-ioctl index to some of the ioctl
73 * (so basically a two level addressing).
74 * One might argue that at the point, some other mechanisms might be
75 * better, like using a real filesystem abstraction (/proc, driverfs, ...),
76 * but sub-ioctls are simple enough to not have much drawbacks (which means
77 * that it's a quick and dirty hack ;-).
79 * There is two slightly different variation of the sub-ioctl scheme :
80 * If the payload fit within (union iwreq_data), the first int (4 bytes)
81 * is reserved as the sub-ioctl number and the regular payload shifted by
83 * If the ioctl use (struct iw_point), the sub-ioctl number is in the
84 * flags member of the structure.
85 * Then, in your handler you would just extract the sub-ioctl number
86 * and do the appropriate processing.
88 * Sub-ioctls are declared normally in the private definition table,
89 * with cmd (first arg) beeing the sub-ioctl number. Then, you need to
90 * declare the real ioctl which will process the sub-ioctls with the
91 * SAME ARGUMENTS and a NULL NAME.
92 * It could look like, for example :
93 * --------------------------------------------
94 // --- Raw access to sub-ioctl handlers ---
95 { 0x8BE0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "set_paramN" },
96 { 0x8BE1, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
97 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_paramN" },
98 // --- sub-ioctls handlers ---
99 { 0x8BE0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
100 { 0x8BE1, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
101 // --- sub-ioctls definitions ---
102 { 1, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_param1" },
103 { 1, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_param1" },
104 { 2, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_param2" },
105 { 2, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_param2" },
106 * --------------------------------------------
107 * And iwpriv should do the rest for you ;-)
109 * Note that version of iwpriv up to v24 (included) expect at most
110 * 16 ioctls definitions and will likely crash when given more.
111 * There is no fix that I can see, apart from recommending an upgrade
112 * of Wireless Tools. Wireless Extensions 15 will check this condition, so
113 * another workaround is restricting those extra definitions to WE-15.
115 * Another problem is that new API before Wireless Extension 15
116 * will get it wrong when passing fixed arguments of 12-15 bytes. It will
117 * try to get them inline instead of by pointer. You can fool the new API
118 * to do the right thing using fake ioctl definitions (but remember that
119 * you will get more likely to hit the limit of 16 ioctl definitions).
120 * For safety, use the ioctl handler before v15.
122 * NEW DATA TYPES (ADDR/FLOAT) :
123 * ---------------------------
124 * Wireless Tools 25 introduce two new data types, addr and float,
125 * corresponding to struct sockaddr and struct iwfreq.
126 * Those types are properly handled with Wireless Extensions 15.
127 * However, the new API before v15 won't handle them properly.
129 * The first problem is that the new API won't know their size, so
130 * won't copy them. This can be workaround with a fake ioctl definition.
131 * The second problem is that a fixed single addr won't be inlined
132 * in struct iwreq and will be passed as a pointer. This is due to an
133 * off-by-one error, where all fixed data of 16 bytes is considered too
134 * big to fit in struct iwreq.
136 * For those reasons, I would recommend to use the ioctl handler
137 * before v15 when manipulating those data.
141 * Token index is very similar to sub-ioctl. It allow the user
142 * to specify an integer index in front of a bunch of other arguments
143 * (addresses, strings, ...).
144 * Token index works only with data passed as pointer, and is
145 * otherwise ignored. If your data would fit within struct iwreq, you
146 * need to declare the command *without* IW_PRIV_SIZE_FIXED to force
147 * this to happen (and check arg number yourself).
148 * --------------------------------------------
149 // --- Commands that would fit in struct iwreq ---
150 { 0x8BE0, IW_PRIV_TYPE_ADDR | 1, 0, "set_param_with_token" },
151 // --- No problem here ---
152 { 0x8BE1, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 2, 0, "again" },
153 * --------------------------------------------
154 * The token index feature is pretty transparent, the token index
155 * will just be in the flags member of (struct iw_point). Default value
156 * (if the user doesn't specify it) will be 0. Token index itself will
157 * work with any version of Wireless Extensions.
158 * Token index is not compatible with sub-ioctl (both use the same
159 * field of struct iw_point). However, token index can be use to offer
160 * raw access to the sub-ioctl handlers (if it uses struct iw_point) :
161 * --------------------------------------------
162 // --- sub-ioctls handler ---
163 { 0x8BE0, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "" },
164 // --- sub-ioctls definitions ---
165 { 0, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "setaddr" },
166 { 1, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "deladdr" },
167 // --- raw access with token index (+ iwreq workaround) ---
168 { 0x8BE0, IW_PRIV_TYPE_ADDR | 1, 0, "rawaddr" },
169 * --------------------------------------------
174 /**************************** CONSTANTS ****************************/
176 static const char * argtype[] = {
177 " ", "byte ", "char ", "", "int ", "float", "addr " };
179 #define IW_MAX_PRIV_DEF 128
181 /* Backward compatibility */
182 #ifndef IW_PRIV_TYPE_ADDR
183 #define IW_PRIV_TYPE_ADDR 0x6000
184 #endif /* IW_PRIV_TYPE_ADDR */
186 /************************* MISC SUBROUTINES **************************/
188 /*------------------------------------------------------------------*/
195 fprintf(stderr, "Usage: iwpriv interface [private-command [private-arguments]]\n");
196 fprintf(stderr, " interface [roam {on|off}]\n");
197 fprintf(stderr, " interface [port {ad-hoc|managed|N}]\n");
200 /************************* SETTING ROUTINES **************************/
202 /*------------------------------------------------------------------*/
204 * Execute a private command on the interface
207 set_private_cmd(int skfd, /* Socket */
208 char * args[], /* Command line args */
209 int count, /* Args count */
210 char * ifname, /* Dev name */
211 char * cmdname, /* Command name */
212 iwprivargs * priv, /* Private ioctl description */
213 int priv_num) /* Number of descriptions */
216 u_char buffer[4096]; /* Only that big in v25 and later */
217 int i = 0; /* Start with first command arg */
218 int k; /* Index in private description table */
220 int subcmd = 0; /* sub-ioctl index */
221 int offset = 0; /* Space for sub-ioctl index */
223 /* Check if we have a token index.
224 * Do it know so that sub-ioctl takes precendence, and so that we
225 * don't have to bother with it later on... */
226 if((count > 1) && (sscanf(args[0], "[%d]", &temp) == 1))
233 /* Search the correct ioctl */
235 while((++k < priv_num) && strcmp(priv[k].name, cmdname));
237 /* If not found... */
240 fprintf(stderr, "Invalid command : %s\n", cmdname);
244 /* Watch out for sub-ioctls ! */
245 if(priv[k].cmd < SIOCDEVPRIVATE)
249 /* Find the matching *real* ioctl */
250 while((++j < priv_num) && ((priv[j].name[0] != '\0') ||
251 (priv[j].set_args != priv[k].set_args) ||
252 (priv[j].get_args != priv[k].get_args)));
254 /* If not found... */
257 fprintf(stderr, "Invalid private ioctl definition for : %s\n",
262 /* Save sub-ioctl number */
263 subcmd = priv[k].cmd;
264 /* Reserve one int (simplify alignement issues) */
265 offset = sizeof(__u32);
266 /* Use real ioctl definition from now on */
269 printf("<mapping sub-ioctl %s to cmd 0x%X-%d>\n", cmdname,
270 priv[k].cmd, subcmd);
273 /* If we have to set some data */
274 if((priv[k].set_args & IW_PRIV_TYPE_MASK) &&
275 (priv[k].set_args & IW_PRIV_SIZE_MASK))
277 switch(priv[k].set_args & IW_PRIV_TYPE_MASK)
279 case IW_PRIV_TYPE_BYTE:
280 /* Number of args to fetch */
281 wrq.u.data.length = count;
282 if(wrq.u.data.length > (priv[k].set_args & IW_PRIV_SIZE_MASK))
283 wrq.u.data.length = priv[k].set_args & IW_PRIV_SIZE_MASK;
286 for(; i < wrq.u.data.length; i++) {
287 sscanf(args[i], "%d", &temp);
288 buffer[i] = (char) temp;
292 case IW_PRIV_TYPE_INT:
293 /* Number of args to fetch */
294 wrq.u.data.length = count;
295 if(wrq.u.data.length > (priv[k].set_args & IW_PRIV_SIZE_MASK))
296 wrq.u.data.length = priv[k].set_args & IW_PRIV_SIZE_MASK;
299 for(; i < wrq.u.data.length; i++) {
300 sscanf(args[i], "%d", &temp);
301 ((__s32 *) buffer)[i] = (__s32) temp;
305 case IW_PRIV_TYPE_CHAR:
308 /* Size of the string to fetch */
309 wrq.u.data.length = strlen(args[i]) + 1;
310 if(wrq.u.data.length > (priv[k].set_args & IW_PRIV_SIZE_MASK))
311 wrq.u.data.length = priv[k].set_args & IW_PRIV_SIZE_MASK;
314 memcpy(buffer, args[i], wrq.u.data.length);
315 buffer[sizeof(buffer) - 1] = '\0';
320 wrq.u.data.length = 1;
325 case IW_PRIV_TYPE_FLOAT:
326 /* Number of args to fetch */
327 wrq.u.data.length = count;
328 if(wrq.u.data.length > (priv[k].set_args & IW_PRIV_SIZE_MASK))
329 wrq.u.data.length = priv[k].set_args & IW_PRIV_SIZE_MASK;
332 for(; i < wrq.u.data.length; i++) {
334 if(sscanf(args[i], "%lg", &(freq)) != 1)
336 printf("Invalid float [%s]...\n", args[i]);
339 if(index(args[i], 'G')) freq *= GIGA;
340 if(index(args[i], 'M')) freq *= MEGA;
341 if(index(args[i], 'k')) freq *= KILO;
342 sscanf(args[i], "%d", &temp);
343 iw_float2freq(freq, ((struct iw_freq *) buffer) + i);
347 case IW_PRIV_TYPE_ADDR:
348 /* Number of args to fetch */
349 wrq.u.data.length = count;
350 if(wrq.u.data.length > (priv[k].set_args & IW_PRIV_SIZE_MASK))
351 wrq.u.data.length = priv[k].set_args & IW_PRIV_SIZE_MASK;
354 for(; i < wrq.u.data.length; i++) {
355 if(iw_in_addr(skfd, ifname, args[i],
356 ((struct sockaddr *) buffer) + i) < 0)
358 printf("Invalid address [%s]...\n", args[i]);
365 fprintf(stderr, "Not yet implemented...\n");
369 if((priv[k].set_args & IW_PRIV_SIZE_FIXED) &&
370 (wrq.u.data.length != (priv[k].set_args & IW_PRIV_SIZE_MASK)))
372 printf("The command %s need exactly %d argument...\n",
373 cmdname, priv[k].set_args & IW_PRIV_SIZE_MASK);
376 } /* if args to set */
379 wrq.u.data.length = 0L;
382 strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
384 /* Those two tests are important. They define how the driver
385 * will have to handle the data */
386 if((priv[k].set_args & IW_PRIV_SIZE_FIXED) &&
387 ((iw_get_priv_size(priv[k].set_args) + offset) <= IFNAMSIZ))
389 /* First case : all SET args fit within wrq */
392 memcpy(wrq.u.name + offset, buffer, IFNAMSIZ - offset);
396 if((priv[k].set_args == 0) &&
397 (priv[k].get_args & IW_PRIV_SIZE_FIXED) &&
398 (iw_get_priv_size(priv[k].get_args) <= IFNAMSIZ))
400 /* Second case : no SET args, GET args fit within wrq */
406 /* Thirst case : args won't fit in wrq, or variable number of args */
407 wrq.u.data.pointer = (caddr_t) buffer;
408 wrq.u.data.flags = subcmd;
412 /* Perform the private ioctl */
413 if(ioctl(skfd, priv[k].cmd, &wrq) < 0)
415 fprintf(stderr, "Interface doesn't accept private ioctl...\n");
416 fprintf(stderr, "%s (%X): %s\n", cmdname, priv[k].cmd, strerror(errno));
420 /* If we have to get some data */
421 if((priv[k].get_args & IW_PRIV_TYPE_MASK) &&
422 (priv[k].get_args & IW_PRIV_SIZE_MASK))
425 int n = 0; /* number of args */
427 printf("%-8.8s %s:", ifname, cmdname);
429 /* Check where is the returned data */
430 if((priv[k].get_args & IW_PRIV_SIZE_FIXED) &&
431 (iw_get_priv_size(priv[k].get_args) <= IFNAMSIZ))
433 memcpy(buffer, wrq.u.name, IFNAMSIZ);
434 n = priv[k].get_args & IW_PRIV_SIZE_MASK;
437 n = wrq.u.data.length;
439 switch(priv[k].get_args & IW_PRIV_TYPE_MASK)
441 case IW_PRIV_TYPE_BYTE:
443 for(j = 0; j < n; j++)
444 printf("%d ", buffer[j]);
448 case IW_PRIV_TYPE_INT:
450 for(j = 0; j < n; j++)
451 printf("%d ", ((__s32 *) buffer)[j]);
455 case IW_PRIV_TYPE_CHAR:
457 buffer[wrq.u.data.length - 1] = '\0';
458 printf("%s\n", buffer);
461 case IW_PRIV_TYPE_FLOAT:
465 for(j = 0; j < n; j++)
467 freq = iw_freq2float(((struct iw_freq *) buffer) + j);
469 printf("%gG ", freq / GIGA);
472 printf("%gM ", freq / MEGA);
474 printf("%gk ", freq / KILO);
480 case IW_PRIV_TYPE_ADDR:
483 struct sockaddr * hwa;
485 for(j = 0; j < n; j++)
487 hwa = ((struct sockaddr *) buffer) + j;
490 (int) strlen(cmdname), " ");
491 printf("%s\n", iw_pr_ether(scratch, hwa->sa_data));
497 fprintf(stderr, "Not yet implemented...\n");
500 } /* if args to set */
505 /*------------------------------------------------------------------*/
507 * Execute a private command on the interface
510 set_private(int skfd, /* Socket */
511 char * args[], /* Command line args */
512 int count, /* Args count */
513 char * ifname) /* Dev name */
515 iwprivargs priv[IW_MAX_PRIV_DEF];
516 int number; /* Max of private ioctl */
518 /* Read the private ioctls */
519 number = iw_get_priv_info(skfd, ifname, priv, IW_MAX_PRIV_DEF);
524 /* Could skip this message ? */
525 fprintf(stderr, "%-8.8s no private ioctls.\n\n",
530 return(set_private_cmd(skfd, args + 1, count - 1, ifname, args[0],
534 /************************ CATALOG FUNCTIONS ************************/
536 /*------------------------------------------------------------------*/
538 * Print on the screen in a neat fashion all the info we have collected
542 print_priv_info(int skfd,
548 iwprivargs priv[IW_MAX_PRIV_DEF];
551 /* Avoid "Unused parameter" warning */
552 args = args; count = count;
554 /* Read the private ioctls */
555 n = iw_get_priv_info(skfd, ifname, priv, IW_MAX_PRIV_DEF);
560 /* Could skip this message ? */
561 fprintf(stderr, "%-8.8s no private ioctls.\n\n",
566 printf("%-8.8s Available private ioctl :\n", ifname);
568 for(k = 0; k < n; k++)
569 if(priv[k].name[0] != '\0')
570 printf(" %-16.16s (%.4X) : set %3d %s & get %3d %s\n",
571 priv[k].name, priv[k].cmd,
572 priv[k].set_args & IW_PRIV_SIZE_MASK,
573 argtype[(priv[k].set_args & IW_PRIV_TYPE_MASK) >> 12],
574 priv[k].get_args & IW_PRIV_SIZE_MASK,
575 argtype[(priv[k].get_args & IW_PRIV_TYPE_MASK) >> 12]);
581 /*------------------------------------------------------------------*/
583 * Print on the screen in a neat fashion all the info we have collected
587 print_priv_all(int skfd,
593 iwprivargs priv[IW_MAX_PRIV_DEF];
596 /* Avoid "Unused parameter" warning */
597 args = args; count = count;
599 /* Read the private ioctls */
600 n = iw_get_priv_info(skfd, ifname, priv, IW_MAX_PRIV_DEF);
605 /* Could skip this message ? */
606 fprintf(stderr, "%-8.8s no private ioctls.\n\n",
611 printf("%-8.8s Available read-only private ioctl :\n", ifname);
613 for(k = 0; k < n; k++)
614 /* We call all ioctl that don't have a null name, don't require
615 * args and return some (avoid triggering "reset" commands) */
616 if((priv[k].name[0] != '\0') && (priv[k].set_args == 0) &&
617 (priv[k].get_args != 0))
618 set_private_cmd(skfd, NULL, 0, ifname, priv[k].name,
624 printf("struct ifreq = %d ; struct iwreq = %d ; IFNAMSIZ = %d\n",
625 sizeof(struct ifreq), sizeof(struct iwreq), IFNAMSIZ);
626 printf("struct iw_freq = %d ; struct sockaddr = %d\n",
627 sizeof(struct iw_freq), sizeof(struct sockaddr));
632 /********************** PRIVATE IOCTLS MANIPS ***********************/
634 * Convenient access to some private ioctls of some devices
637 /*------------------------------------------------------------------*/
639 * Set roaming mode on and off
640 * Found in wavelan_cs driver
643 set_roaming(int skfd, /* Socket */
644 char * args[], /* Command line args */
645 int count, /* Args count */
646 char * ifname) /* Dev name */
650 int i = 0; /* Start with first arg */
652 iwprivargs priv[IW_MAX_PRIV_DEF];
654 char RoamState; /* buffer to hold new roam state */
655 char ChangeRoamState=0; /* whether or not we are going to
656 change roam states */
658 /* Read the private ioctls */
659 number = iw_get_priv_info(skfd, ifname, priv, IW_MAX_PRIV_DEF);
664 /* Could skip this message ? */
665 fprintf(stderr, "%-8.8s no private ioctls.\n\n",
676 if(!strcasecmp(args[i], "on"))
678 printf("%-8.8s enable roaming\n", ifname);
681 fprintf(stderr, "This device doesn't support roaming\n");
688 if(!strcasecmp(args[i], "off"))
691 printf("%-8.8s disable roaming\n", ifname);
694 fprintf(stderr, "This device doesn't support roaming\n");
709 while((++k < number) && strcmp(priv[k].name, "setroam"));
712 fprintf(stderr, "This device doesn't support roaming\n");
715 strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
719 memcpy(wrq.u.name, &buffer, IFNAMSIZ);
721 if(ioctl(skfd, priv[k].cmd, &wrq) < 0)
723 fprintf(stderr, "Roaming support is broken.\n");
731 /*------------------------------------------------------------------*/
733 * Get and set the port type
734 * Found in wavelan2_cs and wvlan_cs drivers
737 port_type(int skfd, /* Socket */
738 char * args[], /* Command line args */
739 int count, /* Args count */
740 char * ifname) /* Dev name */
743 int i = 0; /* Start with first arg */
745 iwprivargs priv[IW_MAX_PRIV_DEF];
748 char * modes[] = { "invalid", "managed (BSS)", "reserved", "ad-hoc" };
750 /* Read the private ioctls */
751 number = iw_get_priv_info(skfd, ifname, priv, IW_MAX_PRIV_DEF);
756 /* Could skip this message ? */
757 fprintf(stderr, "%-8.8s no private ioctls.\n\n", ifname);
764 /* So, we just want to see the current value... */
766 while((++k < number) && strcmp(priv[k].name, "gport_type") &&
767 strcmp(priv[k].name, "get_port"));
770 fprintf(stderr, "This device doesn't support getting port type\n");
773 strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
776 if(ioctl(skfd, priv[k].cmd, &wrq) < 0)
778 fprintf(stderr, "Port type support is broken.\n");
784 printf("%-8.8s Current port mode is %s <port type is %d>.\n\n",
785 ifname, modes[(int) ptype], ptype);
799 while((k < 4) && strncasecmp(args[i], modes[k], 2))
804 /* ...or as an integer */
805 if(sscanf(args[i], "%d", (int *) &ptype) != 1)
812 while((++k < number) && strcmp(priv[k].name, "sport_type") &&
813 strcmp(priv[k].name, "set_port"));
816 fprintf(stderr, "This device doesn't support setting port type\n");
819 strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
821 *(wrq.u.name) = ptype;
823 if(ioctl(skfd, priv[k].cmd, &wrq) < 0)
825 fprintf(stderr, "Invalid port type (or setting not allowed)\n");
832 /******************************* MAIN ********************************/
834 /*------------------------------------------------------------------*/
842 int skfd; /* generic raw socket desc. */
845 /* Create a channel to the NET kernel. */
846 if((skfd = iw_sockets_open()) < 0)
852 /* No argument : show the list of all device + info */
854 iw_enum_devices(skfd, &print_priv_info, NULL, 0);
856 /* Special cases take one... */
858 if((!strncmp(argv[1], "-a", 2)) || (!strcmp(argv[1], "--all")))
859 iw_enum_devices(skfd, &print_priv_all, NULL, 0);
862 if((!strncmp(argv[1], "-h", 2)) || (!strcmp(argv[1], "--help")))
866 if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))
867 goterr = iw_print_version_info("iwpriv");
869 /* The device name must be the first argument */
870 /* Name only : show for that device only */
872 print_priv_info(skfd, argv[1], NULL, 0);
874 /* Special cases take two... */
876 if((!strncmp(argv[2], "-a", 2)) ||
877 (!strcmp(argv[2], "--all")))
878 print_priv_all(skfd, argv[1], NULL, 0);
881 if(!strncmp(argv[2], "roam", 4))
882 goterr = set_roaming(skfd, argv + 3, argc - 3, argv[1]);
885 if(!strncmp(argv[2], "port", 4))
886 goterr = port_type(skfd, argv + 3, argc - 3, argv[1]);
889 /* Otherwise, it's a private ioctl */
890 goterr = set_private(skfd, argv + 2, argc - 2, argv[1]);
892 /* Close the socket. */