2 * wlc - Broadcom Wireless Driver Control Utility
4 * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 #include <sys/types.h>
29 #include <proto/802.11.h>
33 #define PTABLE_MAGIC 0xbadc0ded
38 #define PTABLE_END 0xffffffff
41 * Copy each token in wordlist delimited by space into word
42 * Taken from Broadcom shutils.h
44 #define foreach(word, wordlist, next) \
45 for (next = &wordlist[strspn(wordlist, " ")], \
46 strncpy(word, next, sizeof(word)), \
47 word[strcspn(word, " ")] = '\0', \
48 word[sizeof(word) - 1] = '\0', \
49 next = strchr(next, ' '); \
51 next = next ? &next[strspn(next, " ")] : "", \
52 strncpy(word, next, sizeof(word)), \
53 word[strcspn(word, " ")] = '\0', \
54 word[sizeof(word) - 1] = '\0', \
55 next = strchr(next, ' '))
57 static char wlbuf
[8192];
58 static char interface
[16] = "wl0";
59 static unsigned long kmem_offset
= 0;
60 static int vif
= 0, debug
= 1, fromstdin
= 0;
72 PARAM_OPTIONS
= 0x0f0,
84 int (*handler
)(wlc_param param
, void *data
, void *value
);
93 /* can't use the system include because of the stupid broadcom header files */
94 extern struct ether_addr
*ether_aton(const char *asc
);
95 static inline int my_ether_ntoa(unsigned char *ea
, char *buf
)
97 return sprintf(buf
, "%02x:%02x:%02x:%02x:%02x:%02x",
98 ea
[0], ea
[1], ea
[2], ea
[3], ea
[4], ea
[5]);
101 static int wlc_ioctl(wlc_param param
, void *data
, void *value
)
103 unsigned int *var
= ((unsigned int *) data
);
104 unsigned int ioc
= *var
;
107 return wl_ioctl(interface
, ioc
, NULL
, 0);
109 switch(param
& PARAM_TYPE
) {
111 return wl_ioctl(interface
, ((param
& SET
) ? (ioc
) : (ioc
>> 16)) & 0xffff, value
, 6);
113 return wl_ioctl(interface
, ((param
& SET
) ? (ioc
) : (ioc
>> 16)) & 0xffff, value
, sizeof(int));
115 return wl_ioctl(interface
, ((param
& SET
) ? (ioc
) : (ioc
>> 16)) & 0xffff, value
, BUFSIZE
);
120 static int wlc_iovar(wlc_param param
, void *data
, void *value
)
122 int *val
= (int *) value
;
123 char *iov
= *((char **) data
);
127 switch(param
& PARAM_TYPE
) {
129 ret
= wl_iovar_setint(interface
, iov
, *val
);
132 ret
= wl_iovar_set(interface
, iov
, value
, 6);
137 switch(param
& PARAM_TYPE
) {
139 ret
= wl_iovar_getint(interface
, iov
, val
);
142 ret
= wl_iovar_get(interface
, iov
, value
, 6);
150 static int wlc_bssiovar(wlc_param param
, void *data
, void *value
)
152 int *val
= (int *) value
;
153 char *iov
= *((char **) data
);
157 switch(param
& PARAM_TYPE
) {
159 ret
= wl_bssiovar_setint(interface
, iov
, vif
, *val
);
163 switch(param
& PARAM_TYPE
) {
165 ret
= wl_bssiovar_getint(interface
, iov
, vif
, val
);
172 static int wlc_vif_enabled(wlc_param param
, void *data
, void *value
)
174 int *val
= (int *) value
;
178 sprintf((char *) buf
, "bss");
181 buf
[2] = (*val
? 1 : 0);
182 ret
= wl_ioctl(interface
, WLC_SET_VAR
, buf
, sizeof(buf
));
183 } else if (param
& GET
) {
184 ret
= wl_ioctl(interface
, WLC_GET_VAR
, buf
, sizeof(buf
));
191 static int wlc_ssid(wlc_param param
, void *data
, void *value
)
193 int ret
= -1, ret2
= -1;
194 char *dest
= (char *) value
;
197 if ((param
& PARAM_MODE
) == GET
) {
198 ret
= wl_bssiovar_get(interface
, "ssid", vif
, &ssid
, sizeof(ssid
));
201 /* if we can't get the ssid through the bssiovar, try WLC_GET_SSID */
202 ret
= wl_ioctl(interface
, WLC_GET_SSID
, &ssid
, sizeof(ssid
));
205 memcpy(dest
, ssid
.SSID
, ssid
.SSID_len
);
206 dest
[ssid
.SSID_len
] = 0;
208 } else if ((param
& PARAM_MODE
) == SET
) {
209 strncpy(ssid
.SSID
, value
, 32);
210 ssid
.SSID_len
= strlen(value
);
212 if (ssid
.SSID_len
> 32)
216 /* for the main interface, also try the WLC_SET_SSID call */
217 ret2
= wl_ioctl(interface
, WLC_SET_SSID
, &ssid
, sizeof(ssid
));
220 ret
= wl_bssiovar_set(interface
, "ssid", vif
, &ssid
, sizeof(ssid
));
221 ret
= (!ret2
? 0 : ret
);
227 static int wlc_int(wlc_param param
, void *data
, void *value
)
229 int *var
= *((int **) data
);
230 int *val
= (int *) value
;
232 if ((param
& PARAM_MODE
) == SET
) {
234 } else if ((param
& PARAM_MODE
) == GET
) {
241 static int wlc_flag(wlc_param param
, void *data
, void *value
)
243 int *var
= *((int **) data
);
250 static int wlc_string(wlc_param param
, void *data
, void *value
)
252 char *var
= *((char **) data
);
254 if ((param
& PARAM_MODE
) == GET
) {
261 static int wlc_afterburner(wlc_param param
, void *data
, void *value
)
263 int *val
= (int *) value
;
266 if ((param
& PARAM_MODE
) == GET
) {
267 ret
= wl_iovar_getint(interface
, "afterburner", val
);
269 wl_iovar_setint(interface
, "wlfeatureflag", (*val
? 3 : 0));
270 ret
= wl_iovar_setint(interface
, "afterburner", (*val
? 1 : 0));
271 wl_iovar_setint(interface
, "afterburner_override", *val
);
277 static int wlc_maclist(wlc_param param
, void *data
, void *value
)
279 unsigned int *var
= ((unsigned int *) data
);
280 unsigned int ioc
= *var
;
281 int limit
= (sizeof(wlbuf
) - 4) / sizeof(struct ether_addr
);
282 struct maclist
*list
= (struct maclist
*) wlbuf
;
283 char *str
= (char *) value
;
285 struct ether_addr
*addr
;
289 if ((param
& PARAM_MODE
) == GET
) {
291 ret
= wl_ioctl(interface
, (ioc
>> 16) & 0xffff, wlbuf
, sizeof(wlbuf
));
294 while (list
->count
) {
295 str
+= sprintf(str
, "%s", ((((char *) value
) == str
) ? "" : " "));
296 str
+= my_ether_ntoa((unsigned char *) &list
->ea
[list
->count
-- - 1], str
);
301 while (*str
&& isspace(*str
))
308 if (wl_ioctl(interface
, (ioc
>> 16) & 0xffff, wlbuf
, sizeof(wlbuf
)) == 0)
311 while (*str
&& isspace(*str
))
316 memset(wlbuf
, 0, sizeof(wlbuf
));
318 foreach(astr
, str
, p
) {
319 if (list
->count
>= limit
)
322 if ((addr
= ether_aton(astr
)) != NULL
)
323 memcpy(&list
->ea
[list
->count
++], addr
, sizeof(struct ether_addr
));
326 return wl_ioctl(interface
, ioc
& 0xffff, wlbuf
, sizeof(wlbuf
));
330 static int wlc_radio(wlc_param param
, void *data
, void *value
)
332 int *val
= (int *) value
;
335 if ((param
& PARAM_MODE
) == GET
) {
336 ret
= wl_ioctl(interface
, WLC_GET_RADIO
, val
, sizeof(int));
337 *val
= ((*val
& 1) ? 0 : 1);
339 *val
= (1 << 16) | (*val
? 0 : 1);
340 ret
= wl_ioctl(interface
, WLC_SET_RADIO
, val
, sizeof(int));
346 static int wlc_wsec_key(wlc_param param
, void *null
, void *value
)
348 wl_wsec_key_t wsec_key
;
349 unsigned char *index
= value
;
352 unsigned char hex
[3];
354 if ((param
& PARAM_MODE
) != SET
)
357 memset(&wsec_key
, 0, sizeof(wsec_key
));
358 if (index
[0] == '=') {
359 wsec_key
.flags
= WL_PRIMARY_KEY
;
363 if ((index
[0] < '1') || (index
[0] > '4') || (index
[1] != ','))
367 if (strncmp(key
, "d:", 2) == 0) { /* delete key */
368 } else if (strncmp(key
, "s:", 2) == 0) { /* ascii key */
370 wsec_key
.len
= strlen(key
);
372 if ((wsec_key
.len
!= 5) && (wsec_key
.len
!= 13))
375 strcpy(wsec_key
.data
, key
);
376 } else { /* hex key */
377 wsec_key
.len
= strlen(key
);
378 if ((wsec_key
.len
!= 10) && (wsec_key
.len
!= 26))
382 data
= wsec_key
.data
;
387 *(data
++) = (unsigned char) strtoul(hex
, NULL
, 16);
391 return wl_bssiovar_set(interface
, "wsec_key", vif
, &wsec_key
, sizeof(wsec_key
));
394 static inline int cw2ecw(int cw
)
397 for (cw
++, i
= 0; cw
; i
++) cw
>>=1;
401 static int wlc_wme_ac(wlc_param param
, void *data
, void *value
)
403 char *type
= *((char **) data
);
404 char *settings
= (char *) value
;
405 char cmd
[100], *p
, *val
;
406 edcf_acparam_t params
[AC_COUNT
];
412 if ((param
& PARAM_MODE
) != SET
)
415 memset(params
, 0, sizeof(params
));
416 ret
= wl_iovar_get(interface
, type
, params
, sizeof(params
));
417 memset(buf
, 0, BUFSIZE
);
419 buf
+= strlen(buf
) + 1;
421 foreach(cmd
, settings
, p
) {
422 val
= strchr(cmd
, '=');
424 if (strcmp(cmd
, "be") == 0)
426 else if (strcmp(cmd
, "bk") == 0)
428 else if (strcmp(cmd
, "vi") == 0)
430 else if (strcmp(cmd
, "vo") == 0)
436 params
[cur
].ACI
= (params
[cur
].ACI
& (0x3 << 5)) | (cur
<< 5);
440 intval
= strtoul(val
, NULL
, 10);
441 if (strcmp(cmd
, "cwmin") == 0)
442 params
[cur
].ECW
= (params
[cur
].ECW
& ~(0xf)) | cw2ecw(intval
);
443 else if (strcmp(cmd
, "ecwmin") == 0)
444 params
[cur
].ECW
= (params
[cur
].ECW
& ~(0xf)) | (intval
& 0xf);
445 else if (strcmp(cmd
, "cwmax") == 0)
446 params
[cur
].ECW
= (params
[cur
].ECW
& ~(0xf << 4)) | (cw2ecw(intval
) << 4);
447 else if (strcmp(cmd
, "ecwmax") == 0)
448 params
[cur
].ECW
= (params
[cur
].ECW
& ~(0xf << 4)) | ((intval
& 0xf) << 4);
449 else if (strcmp(cmd
, "aifsn") == 0)
450 params
[cur
].ACI
= (params
[cur
].ACI
& ~(0xf)) | (intval
& 0xf);
451 else if (strcmp(cmd
, "txop") == 0)
452 params
[cur
].TXOP
= intval
>> 5;
453 else if (strcmp(cmd
, "force") == 0)
454 params
[cur
].ACI
= (params
[cur
].ACI
& ~(1 << 4)) | ((intval
) ? (1 << 4) : 0);
457 memcpy(buf
, ¶ms
[cur
], sizeof(edcf_acparam_t
));
458 wl_ioctl(interface
, WLC_SET_VAR
, wlbuf
, BUFSIZE
);
464 static int wlc_ifname(wlc_param param
, void *data
, void *value
)
466 char *val
= (char *) value
;
470 if (strlen(val
) < 16)
471 strcpy(interface
, val
);
475 strcpy(val
, interface
);
481 static int wlc_wdsmac(wlc_param param
, void *data
, void *value
)
483 unsigned char mac
[6];
486 ret
= wl_ioctl(interface
, WLC_WDS_GET_REMOTE_HWADDR
, &mac
, 6);
488 my_ether_ntoa(mac
, value
);
493 static int wlc_pmk(wlc_param param
, void *data
, void *value
)
496 char *str
= (char *) value
;
499 /* driver doesn't support GET */
501 if ((param
& PARAM_MODE
) == SET
) {
502 strncpy(pmk
.key
, value
, WSEC_MAX_PSK_LEN
);
503 pmk
.key_len
= strlen(value
);
505 if (pmk
.key_len
> WSEC_MAX_PSK_LEN
)
506 pmk
.key_len
= WSEC_MAX_PSK_LEN
;
508 pmk
.flags
= WSEC_PASSPHRASE
;
510 ret
= wl_ioctl(interface
, WLC_SET_WSEC_PMK
, &pmk
, sizeof(pmk
));
516 static const struct wlc_call wlc_calls
[] = {
519 .param
= STRING
|NOARG
,
520 .handler
= wlc_string
,
522 .desc
= "Version of this program"
529 .desc
= "wlc debug level"
535 .data
.ptr
= &fromstdin
,
536 .desc
= "Accept input from stdin"
541 .handler
= wlc_ifname
,
542 .desc
= "interface to send commands to"
547 .handler
= wlc_ioctl
,
549 .desc
= "Bring the interface up"
554 .handler
= wlc_ioctl
,
555 .data
.num
= WLC_DOWN
,
556 .desc
= "Bring the interface down"
561 .handler
= wlc_radio
,
562 .desc
= "Radio enabled flag"
567 .handler
= wlc_ioctl
,
568 .data
.num
= ((WLC_GET_AP
<< 16) | WLC_SET_AP
),
569 .desc
= "Access Point mode"
574 .handler
= wlc_iovar
,
576 .desc
= "Multi-ssid mode"
581 .handler
= wlc_iovar
,
583 .desc
= "AP+STA mode"
588 .handler
= wlc_ioctl
,
589 .data
.num
= ((WLC_GET_INFRA
<< 16) | WLC_SET_INFRA
),
590 .desc
= "Infrastructure mode"
595 .handler
= wlc_ioctl
,
596 .data
.num
= ((WLC_GET_WET
<< 16) | WLC_SET_WET
),
597 .desc
= "Wireless repeater mode",
600 .name
= "statimeout",
602 .handler
= wlc_iovar
,
603 .data
.str
= "sta_retry_time",
604 .desc
= "STA connection timeout"
609 .handler
= wlc_ioctl
,
610 .data
.num
= ((WLC_GET_COUNTRY
<< 16) | WLC_SET_COUNTRY
),
611 .desc
= "Country code"
616 .handler
= wlc_ioctl
,
617 .data
.num
= ((WLC_GET_CHANNEL
<< 16) | WLC_SET_CHANNEL
),
623 .handler
= wlc_bssiovar
,
624 .data
.str
= "vlan_mode",
625 .desc
= "Parse 802.1Q tags",
632 .desc
= "Current vif index"
637 .handler
= wlc_vif_enabled
,
638 .desc
= "vif enabled flag"
644 .desc
= "Interface ESSID"
649 .handler
= wlc_bssiovar
,
650 .data
.str
= "closednet",
651 .desc
= "Hidden ESSID flag"
656 .handler
= wlc_bssiovar
,
658 .desc
= "Security mode flags"
663 .handler
= wlc_wsec_key
,
664 .desc
= "Set/Remove WEP keys"
667 .name
= "wsec_restrict",
669 .handler
= wlc_bssiovar
,
670 .data
.str
= "wsec_restrict",
671 .desc
= "Drop unencrypted traffic"
674 .name
= "eap_restrict",
676 .handler
= wlc_bssiovar
,
677 .data
.str
= "eap_restrict",
678 .desc
= "Only allow 802.1X traffic until 802.1X authorized"
683 .handler
= wlc_bssiovar
,
684 .data
.str
= "wpa_auth",
685 .desc
= "WPA authentication modes"
688 .name
= "ap_isolate",
690 .handler
= wlc_bssiovar
,
691 .data
.str
= "ap_isolate",
692 .desc
= "Isolate connected clients"
695 .name
= "supplicant",
697 .handler
= wlc_iovar
,
698 .data
.str
= "sup_wpa",
699 .desc
= "Built-in WPA supplicant"
702 .name
= "passphrase",
705 .desc
= "Passphrase for built-in WPA supplicant",
710 .handler
= wlc_iovar
,
711 .data
.str
= "maxassoc",
712 .desc
= "Max. number of associated clients",
717 .handler
= wlc_iovar
,
719 .desc
= "WME enabled"
724 .handler
= wlc_wme_ac
,
725 .data
.str
= "wme_ac_ap",
726 .desc
= "Set WME AC options for AP mode",
729 .name
= "wme_ac_sta",
731 .handler
= wlc_wme_ac
,
732 .data
.str
= "wme_ac_sta",
733 .desc
= "Set WME AC options for STA mode",
738 .handler
= wlc_iovar
,
739 .data
.str
= "wme_noack",
740 .desc
= "WME ACK disable request",
745 .handler
= wlc_ioctl
,
746 .data
.num
= ((WLC_GET_REGULATORY
<< 16) | WLC_SET_REGULATORY
),
747 .desc
= "Enable/disable 802.11d regulatory management",
752 .handler
= wlc_ioctl
,
753 .data
.num
= ((WLC_GET_SPECT_MANAGMENT
<< 16) | WLC_SET_SPECT_MANAGMENT
),
754 .desc
= "Enable/disable 802.11h spectrum management",
757 .name
= "fragthresh",
759 .handler
= wlc_iovar
,
760 .data
.str
= "fragthresh",
761 .desc
= "Fragmentation threshold",
766 .handler
= wlc_iovar
,
767 .data
.str
= "rtsthresh",
768 .desc
= "RTS threshold"
773 .handler
= wlc_iovar
,
774 .data
.str
= "acktiming",
780 .handler
= wlc_ioctl
,
781 .data
.num
= ((WLC_GET_ANTDIV
<< 16) | WLC_SET_ANTDIV
),
782 .desc
= "Rx antenna selection"
787 .handler
= wlc_ioctl
,
788 .data
.num
= ((WLC_GET_TXANT
<< 16) | WLC_SET_TXANT
),
789 .desc
= "Tx antenna selection"
794 .handler
= wlc_ioctl
,
795 .data
.num
= ((WLC_GET_DTIMPRD
<< 16) | WLC_SET_DTIMPRD
),
796 .desc
= "DTIM period",
801 .handler
= wlc_ioctl
,
802 .data
.num
= ((WLC_GET_BCNPRD
<< 16) | WLC_SET_BCNPRD
),
803 .desc
= "Beacon interval"
806 .name
= "frameburst",
808 .handler
= wlc_ioctl
,
809 .data
.num
= ((WLC_GET_FAKEFRAG
<< 16) | WLC_SET_FAKEFRAG
),
810 .desc
= "Framebursting"
815 .handler
= wlc_ioctl
,
816 .data
.num
= ((WLC_GET_MONITOR
<< 16) | WLC_SET_MONITOR
),
817 .desc
= "Monitor mode"
822 .handler
= wlc_ioctl
,
823 .data
.num
= ((WLC_GET_PASSIVE
<< 16) | WLC_SET_PASSIVE
),
824 .desc
= "Passive mode"
829 .handler
= wlc_ioctl
,
830 .data
.num
= ((WLC_GET_MACMODE
<< 16) | WLC_SET_MACMODE
),
831 .desc
= "MAC filter mode (0:disabled, 1:deny, 2:allow)"
836 .data
.num
= ((WLC_GET_MACLIST
<< 16) | WLC_SET_MACLIST
),
837 .handler
= wlc_maclist
,
838 .desc
= "MAC filter list"
843 .handler
= wlc_ioctl
,
844 .data
.num
= ((WLC_GET_LAZYWDS
<< 16) | WLC_SET_LAZYWDS
),
845 .desc
= "Automatic WDS"
850 .data
.num
= ((WLC_GET_WDSLIST
<< 16) | WLC_SET_WDSLIST
),
851 .handler
= wlc_maclist
,
852 .desc
= "WDS connection list"
855 .name
= "wdstimeout",
857 .handler
= wlc_iovar
,
858 .data
.str
= "wdstimeout",
859 .desc
= "WDS link detection timeout"
863 .param
= STRING
|NOARG
,
864 .handler
= wlc_wdsmac
,
865 .desc
= "MAC of the remote WDS endpoint (only with wds0.* interfaces)"
868 .name
= "afterburner",
870 .handler
= wlc_afterburner
,
871 .desc
= "Broadcom Afterburner"
876 .handler
= wlc_iovar
,
877 .data
.str
= "IBSS_join_once",
878 .desc
= "Prevent unwanted IBSS merges"
883 .handler
= wlc_iovar
,
884 .data
.str
= "cur_etheraddr",
888 .name
= "default_bssid",
890 .handler
= wlc_iovar
,
891 .data
.str
= "perm_etheraddr",
892 .desc
= "Default BSSID (read-only)"
895 .name
= "allow_mode",
897 .data
.num
= ((WLC_GET_ALLOW_MODE
<< 16) | WLC_SET_ALLOW_MODE
),
898 .handler
= wlc_ioctl
,
899 .desc
= "STA/IBSS assoc mode"
904 .data
.num
= ((WLC_GET_DESIRED_BSSID
<< 16) | WLC_SET_DESIRED_BSSID
),
905 .handler
= wlc_ioctl
,
906 .desc
= "Desired BSSID"
909 #define wlc_calls_size (sizeof(wlc_calls) / sizeof(struct wlc_call))
911 static void usage(char *cmd
)
914 fprintf(stderr
, "Usage: %s <command> [<argument> ...]\n"
916 "Available commands:\n", cmd
);
917 for (i
= 0; i
< wlc_calls_size
; i
++) {
918 fprintf(stderr
, "\t%-16s\t%s\n", wlc_calls
[i
].name
?: "", wlc_calls
[i
].desc
?: "");
920 fprintf(stderr
, "\n");
924 static int do_command(const struct wlc_call
*cmd
, char *arg
)
926 static char buf
[BUFSIZE
];
931 void *ptr
= (void *) buf
;
934 fprintf(stderr
, "do_command %-16s\t'%s'\n", cmd
->name
, arg
);
937 if ((arg
== NULL
) && ((cmd
->param
& PARAM_TYPE
) != NONE
)) {
939 ret
= cmd
->handler(cmd
->param
| GET
, (void *) &cmd
->data
, (void *) buf
);
941 switch(cmd
->param
& PARAM_TYPE
) {
943 intval
= *((int *) buf
);
947 else if (intval
> 255)
952 fprintf(stdout
, format
, intval
);
955 fprintf(stdout
, "%s\n", buf
);
958 my_ether_ntoa(buf
, buf
+ 6);
959 fprintf(stdout
, "%s\n", buf
+ 6);
965 switch(cmd
->param
& PARAM_TYPE
) {
967 intval
= strtoul(arg
, &end
, 10);
968 if (end
&& !(*end
)) {
969 memcpy(buf
, &intval
, sizeof(intval
));
971 fprintf(stderr
, "%s: Invalid argument\n", cmd
->name
);
976 strncpy(buf
, arg
, BUFSIZE
);
977 buf
[BUFSIZE
- 1] = 0;
980 ptr
= ether_aton(arg
);
982 fprintf(stderr
, "%s: Invalid mac address '%s'\n", cmd
->name
, arg
);
988 ret
= cmd
->handler(cmd
->param
| SET
, (void *) &cmd
->data
, ptr
);
991 if ((debug
> 0) && (ret
!= 0))
992 fprintf(stderr
, "Command '%s %s' failed: %d\n", (set
== 1 ? "set" : "get"), cmd
->name
, ret
);
997 static struct wlc_call
*find_cmd(char *name
)
999 int found
= 0, i
= 0;
1001 while (!found
&& (i
< wlc_calls_size
)) {
1002 if (strcmp(name
, wlc_calls
[i
].name
) == 0)
1008 return (struct wlc_call
*) (found
? &wlc_calls
[i
] : NULL
);
1011 int main(int argc
, char **argv
)
1013 static char buf
[BUFSIZE
];
1015 char *cmd
= argv
[0];
1016 struct wlc_call
*call
;
1022 for(interface
[2] = '0'; (interface
[2] < '3') && (wl_probe(interface
) != 0); interface
[2]++);
1023 if (interface
[2] == '3') {
1024 fprintf(stderr
, "No Broadcom wl interface found!\n");
1030 while ((argc
> 0) && (argv
[0] != NULL
)) {
1031 if ((call
= find_cmd(argv
[0])) == NULL
) {
1032 fprintf(stderr
, "Invalid command: %s\n\n", argv
[0]);
1035 if ((argc
> 1) && (!(call
->param
& NOARG
))) {
1036 ret
= do_command(call
, argv
[1]);
1040 ret
= do_command(call
, NULL
);
1046 while (fromstdin
&& !feof(stdin
)) {
1048 fgets(buf
, BUFSIZE
- 1, stdin
);
1053 if ((s
= strchr(buf
, '\r')) != NULL
)
1055 if ((s
= strchr(buf
, '\n')) != NULL
)
1065 if ((s2
= strchr(buf
, ' ')) != NULL
)
1068 while (s2
&& isspace(*s2
))
1071 if ((call
= find_cmd(buf
)) == NULL
) {
1072 fprintf(stderr
, "Invalid command: %s\n", buf
);
1075 ret
= do_command(call
, ((call
->param
& NOARG
) ? NULL
: s2
));