2 * wlc - Broadcom Wireless Driver Control Utility
4 * Copyright (C) 2006 Felix Fietkau <nbd@nbd.name>
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_get(interface, iov, val, sizeof(int));
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_get(interface, iov, vif, val, sizeof(int));
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_get(interface, "afterburner", val, sizeof(int));
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 int wlc_cap(wlc_param param, void *data, void *value)
396 char *iov = *((char **) data);
399 return wl_iovar_get(interface, iov, value, BUFSIZE);
404 static int wlc_bssmax(wlc_param param, void *data, void *value)
406 int *val = (int *) value;
407 char *iov = *((char **) data);
411 ret = wl_iovar_get(interface, iov, wlbuf, BUFSIZE);
413 if (strstr(wlbuf, "mbss4"))
415 else if (strstr(wlbuf, "mbss16"))
425 static inline int cw2ecw(int cw)
428 for (cw++, i = 0; cw; i++) cw >>=1;
432 static int wlc_wme_ac(wlc_param param, void *data, void *value)
434 char *type = *((char **) data);
435 char *settings = (char *) value;
436 char cmd[100], *p, *val;
437 edcf_acparam_t params[AC_COUNT];
443 if ((param & PARAM_MODE) != SET)
446 memset(params, 0, sizeof(params));
447 ret = wl_iovar_get(interface, type, params, sizeof(params));
448 memset(buf, 0, BUFSIZE);
450 buf += strlen(buf) + 1;
452 foreach(cmd, settings, p) {
453 val = strchr(cmd, '=');
455 if (strcmp(cmd, "be") == 0)
457 else if (strcmp(cmd, "bk") == 0)
459 else if (strcmp(cmd, "vi") == 0)
461 else if (strcmp(cmd, "vo") == 0)
467 params[cur].ACI = (params[cur].ACI & (0x3 << 5)) | (cur << 5);
471 intval = strtoul(val, NULL, 10);
472 if (strcmp(cmd, "cwmin") == 0)
473 params[cur].ECW = (params[cur].ECW & ~(0xf)) | cw2ecw(intval);
474 else if (strcmp(cmd, "ecwmin") == 0)
475 params[cur].ECW = (params[cur].ECW & ~(0xf)) | (intval & 0xf);
476 else if (strcmp(cmd, "cwmax") == 0)
477 params[cur].ECW = (params[cur].ECW & ~(0xf << 4)) | (cw2ecw(intval) << 4);
478 else if (strcmp(cmd, "ecwmax") == 0)
479 params[cur].ECW = (params[cur].ECW & ~(0xf << 4)) | ((intval & 0xf) << 4);
480 else if (strcmp(cmd, "aifsn") == 0)
481 params[cur].ACI = (params[cur].ACI & ~(0xf)) | (intval & 0xf);
482 else if (strcmp(cmd, "txop") == 0)
483 params[cur].TXOP = intval >> 5;
484 else if (strcmp(cmd, "force") == 0)
485 params[cur].ACI = (params[cur].ACI & ~(1 << 4)) | ((intval) ? (1 << 4) : 0);
488 memcpy(buf, ¶ms[cur], sizeof(edcf_acparam_t));
489 wl_ioctl(interface, WLC_SET_VAR, wlbuf, BUFSIZE);
495 static int wlc_ifname(wlc_param param, void *data, void *value)
497 char *val = (char *) value;
501 if (strlen(val) < 16)
502 strcpy(interface, val);
506 strcpy(val, interface);
512 static int wlc_wdsmac(wlc_param param, void *data, void *value)
514 unsigned char mac[6];
517 ret = wl_ioctl(interface, WLC_WDS_GET_REMOTE_HWADDR, &mac, 6);
519 my_ether_ntoa(mac, value);
524 static int wlc_pmk(wlc_param param, void *data, void *value)
527 char *str = (char *) value;
530 /* driver doesn't support GET */
532 if ((param & PARAM_MODE) == SET) {
533 strncpy(pmk.key, str, WSEC_MAX_PSK_LEN);
534 pmk.key_len = strlen(str);
536 if (pmk.key_len > WSEC_MAX_PSK_LEN)
537 pmk.key_len = WSEC_MAX_PSK_LEN;
539 pmk.flags = WSEC_PASSPHRASE;
541 ret = wl_ioctl(interface, WLC_SET_WSEC_PMK, &pmk, sizeof(pmk));
547 static const struct wlc_call wlc_calls[] = {
550 .param = STRING|NOARG,
551 .handler = wlc_string,
553 .desc = "Version of this program"
560 .desc = "wlc debug level"
566 .data.ptr = &fromstdin,
567 .desc = "Accept input from stdin"
572 .handler = wlc_ifname,
573 .desc = "interface to send commands to"
578 .handler = wlc_ioctl,
580 .desc = "Bring the interface up"
585 .handler = wlc_ioctl,
586 .data.num = WLC_DOWN,
587 .desc = "Bring the interface down"
592 .handler = wlc_radio,
593 .desc = "Radio enabled flag"
598 .handler = wlc_ioctl,
599 .data.num = ((WLC_GET_AP << 16) | WLC_SET_AP),
600 .desc = "Access Point mode"
605 .handler = wlc_iovar,
607 .desc = "Multi-ssid mode"
612 .handler = wlc_iovar,
614 .desc = "AP+STA mode"
619 .handler = wlc_ioctl,
620 .data.num = ((WLC_GET_INFRA << 16) | WLC_SET_INFRA),
621 .desc = "Infrastructure mode"
626 .handler = wlc_ioctl,
627 .data.num = ((WLC_GET_WET << 16) | WLC_SET_WET),
628 .desc = "Wireless repeater mode",
631 .name = "statimeout",
633 .handler = wlc_iovar,
634 .data.str = "sta_retry_time",
635 .desc = "STA connection timeout"
640 .handler = wlc_ioctl,
641 .data.num = ((WLC_GET_COUNTRY << 16) | WLC_SET_COUNTRY),
642 .desc = "Country code"
647 .handler = wlc_ioctl,
648 .data.num = ((WLC_GET_CHANNEL << 16) | WLC_SET_CHANNEL),
654 .handler = wlc_bssiovar,
655 .data.str = "vlan_mode",
656 .desc = "Parse 802.1Q tags",
663 .desc = "Current vif index"
668 .handler = wlc_vif_enabled,
669 .desc = "vif enabled flag"
675 .desc = "Interface ESSID"
680 .handler = wlc_bssiovar,
681 .data.str = "closednet",
682 .desc = "Hidden ESSID flag"
687 .handler = wlc_bssiovar,
689 .desc = "Security mode flags"
694 .handler = wlc_wsec_key,
695 .desc = "Set/Remove WEP keys"
700 .handler = wlc_ioctl,
701 .data.num = ((WLC_GET_AUTH << 16) | WLC_SET_AUTH),
702 .desc = "WEP authentication type. 0 = OpenSystem, 1 = SharedKey"
705 .name = "wsec_restrict",
707 .handler = wlc_bssiovar,
708 .data.str = "wsec_restrict",
709 .desc = "Drop unencrypted traffic"
712 .name = "eap_restrict",
714 .handler = wlc_bssiovar,
715 .data.str = "eap_restrict",
716 .desc = "Only allow 802.1X traffic until 802.1X authorized"
721 .handler = wlc_bssiovar,
722 .data.str = "wpa_auth",
723 .desc = "WPA authentication modes"
726 .name = "ap_isolate",
728 .handler = wlc_bssiovar,
729 .data.str = "ap_isolate",
730 .desc = "Isolate connected clients"
733 .name = "supplicant",
735 .handler = wlc_iovar,
736 .data.str = "sup_wpa",
737 .desc = "Built-in WPA supplicant"
740 .name = "passphrase",
743 .desc = "Passphrase for built-in WPA supplicant",
748 .handler = wlc_iovar,
749 .data.str = "maxassoc",
750 .desc = "Max. number of associated clients",
755 .handler = wlc_iovar,
757 .desc = "WME enabled"
762 .handler = wlc_wme_ac,
763 .data.str = "wme_ac_ap",
764 .desc = "Set WME AC options for AP mode",
767 .name = "wme_ac_sta",
769 .handler = wlc_wme_ac,
770 .data.str = "wme_ac_sta",
771 .desc = "Set WME AC options for STA mode",
776 .handler = wlc_iovar,
777 .data.str = "wme_noack",
778 .desc = "WME ACK disable request",
783 .handler = wlc_ioctl,
784 .data.num = ((WLC_GET_REGULATORY << 16) | WLC_SET_REGULATORY),
785 .desc = "Enable/disable 802.11d regulatory management",
790 .handler = wlc_ioctl,
791 .data.num = ((WLC_GET_SPECT_MANAGMENT << 16) | WLC_SET_SPECT_MANAGMENT),
792 .desc = "Enable/disable 802.11h spectrum management",
795 .name = "fragthresh",
797 .handler = wlc_iovar,
798 .data.str = "fragthresh",
799 .desc = "Fragmentation threshold",
804 .handler = wlc_iovar,
805 .data.str = "rtsthresh",
806 .desc = "RTS threshold"
811 .handler = wlc_iovar,
812 .data.str = "acktiming",
818 .handler = wlc_ioctl,
819 .data.num = ((WLC_GET_ANTDIV << 16) | WLC_SET_ANTDIV),
820 .desc = "Rx antenna selection"
825 .handler = wlc_ioctl,
826 .data.num = ((WLC_GET_TXANT << 16) | WLC_SET_TXANT),
827 .desc = "Tx antenna selection"
832 .handler = wlc_ioctl,
833 .data.num = ((WLC_GET_DTIMPRD << 16) | WLC_SET_DTIMPRD),
834 .desc = "DTIM period",
839 .handler = wlc_ioctl,
840 .data.num = ((WLC_GET_BCNPRD << 16) | WLC_SET_BCNPRD),
841 .desc = "Beacon interval"
844 .name = "frameburst",
846 .handler = wlc_ioctl,
847 .data.num = ((WLC_GET_FAKEFRAG << 16) | WLC_SET_FAKEFRAG),
848 .desc = "Framebursting"
853 .handler = wlc_ioctl,
854 .data.num = ((WLC_GET_MONITOR << 16) | WLC_SET_MONITOR),
855 .desc = "Monitor mode"
858 .name = "passive_scan",
860 .handler = wlc_ioctl,
861 .data.num = ((WLC_GET_PASSIVE_SCAN << 16) | WLC_SET_PASSIVE_SCAN),
862 .desc = "Passive scan mode"
867 .handler = wlc_ioctl,
868 .data.num = ((WLC_GET_MACMODE << 16) | WLC_SET_MACMODE),
869 .desc = "MAC filter mode (0:disabled, 1:deny, 2:allow)"
874 .data.num = ((WLC_GET_MACLIST << 16) | WLC_SET_MACLIST),
875 .handler = wlc_maclist,
876 .desc = "MAC filter list"
881 .handler = wlc_ioctl,
882 .data.num = ((WLC_GET_LAZYWDS << 16) | WLC_SET_LAZYWDS),
883 .desc = "Automatic WDS"
888 .data.num = ((WLC_GET_WDSLIST << 16) | WLC_SET_WDSLIST),
889 .handler = wlc_maclist,
890 .desc = "WDS connection list"
893 .name = "wdstimeout",
895 .handler = wlc_iovar,
896 .data.str = "wdstimeout",
897 .desc = "WDS link detection timeout"
901 .param = STRING|NOARG,
902 .handler = wlc_wdsmac,
903 .desc = "MAC of the remote WDS endpoint (only with wds0.* interfaces)"
906 .name = "afterburner",
908 .handler = wlc_afterburner,
909 .desc = "Broadcom Afterburner"
912 .name = "ibss_merge",
914 .handler = wlc_iovar,
915 .data.str = "ibss_coalesce_allowed",
916 .desc = "Allow IBSS merges"
921 .handler = wlc_ioctl,
922 .data.num = ((WLC_GET_BSSID << 16) | WLC_SET_BSSID),
926 .name = "cur_etheraddr",
928 .handler = wlc_iovar,
929 .data.str = "cur_etheraddr",
930 .desc = "Current MAC Address"
933 .name = "default_bssid",
935 .handler = wlc_iovar,
936 .data.str = "perm_etheraddr",
937 .desc = "Default BSSID (read-only)"
942 .data.num = (WLC_GET_ASSOCLIST << 16),
943 .handler = wlc_maclist,
944 .desc = "MACs of associated stations"
949 .data.num = ((WLC_GET_GMODE << 16) | WLC_SET_GMODE),
950 .handler = wlc_ioctl,
956 .data.num = (WLC_GET_PHYTYPE << 16),
957 .handler = wlc_ioctl,
958 .desc = "PHY Type (read-only)"
963 .handler = wlc_iovar,
970 .handler = wlc_iovar,
972 .desc = "N Mode required"
977 .handler = wlc_iovar,
978 .data.str = "chanspec",
979 .desc = "Channel Spec (See bcmwifi.h)"
984 .data.num = ((WLC_GET_BAND << 16) | WLC_SET_BAND),
985 .handler = wlc_ioctl,
986 .desc = "Band (0=auto, 1=5Ghz, 2=2.4GHz)"
990 .param = STRING|NOARG,
993 .desc = "Capabilities"
998 .handler = wlc_bssmax,
1000 .desc = "Number of VIF's supported"
1005 .handler = wlc_iovar,
1006 .data.str = "leddc",
1007 .desc = "LED Duty Cycle"
1011 #define wlc_calls_size (sizeof(wlc_calls) / sizeof(struct wlc_call))
1013 static void usage(char *cmd)
1016 fprintf(stderr, "Usage: %s <command> [<argument> ...]\n"
1018 "Available commands:\n", cmd);
1019 for (i = 0; i < wlc_calls_size; i++) {
1020 fprintf(stderr, "\t%-16s\t%s\n", wlc_calls[i].name ?: "", wlc_calls[i].desc ?: "");
1022 fprintf(stderr, "\n");
1026 static int do_command(const struct wlc_call *cmd, char *arg)
1028 static char buf[BUFSIZE];
1033 void *ptr = (void *) buf;
1036 fprintf(stderr, "do_command %-16s\t'%s'\n", cmd->name, arg);
1039 if ((arg == NULL) && ((cmd->param & PARAM_TYPE) != NONE)) {
1041 ret = cmd->handler(cmd->param | GET, (void *) &cmd->data, (void *) buf);
1043 switch(cmd->param & PARAM_TYPE) {
1045 intval = *((int *) buf);
1048 format = "0x%08x\n";
1049 else if (intval > 255)
1050 format = "0x%04x\n";
1054 fprintf(stdout, format, intval);
1057 fprintf(stdout, "%s\n", buf);
1060 my_ether_ntoa(buf, buf + 6);
1061 fprintf(stdout, "%s\n", buf + 6);
1067 switch(cmd->param & PARAM_TYPE) {
1069 intval = strtoul(arg, &end, 0);
1070 if (end && !(*end)) {
1071 memcpy(buf, &intval, sizeof(intval));
1073 fprintf(stderr, "%s: Invalid argument\n", cmd->name);
1078 strncpy(buf, arg, BUFSIZE);
1079 buf[BUFSIZE - 1] = 0;
1082 ptr = ether_aton(arg);
1084 fprintf(stderr, "%s: Invalid mac address '%s'\n", cmd->name, arg);
1090 ret = cmd->handler(cmd->param | SET, (void *) &cmd->data, ptr);
1093 if ((debug > 0) && (ret != 0))
1094 fprintf(stderr, "Command '%s %s' failed: %d\n", (set == 1 ? "set" : "get"), cmd->name, ret);
1099 static struct wlc_call *find_cmd(char *name)
1101 int found = 0, i = 0;
1103 while (!found && (i < wlc_calls_size)) {
1104 if (strcmp(name, wlc_calls[i].name) == 0)
1110 return (struct wlc_call *) (found ? &wlc_calls[i] : NULL);
1113 int main(int argc, char **argv)
1115 static char buf[BUFSIZE];
1117 char *cmd = argv[0];
1118 struct wlc_call *call;
1124 for(interface[2] = '0'; (interface[2] < '3') && (wl_probe(interface) != 0); interface[2]++);
1125 if (interface[2] == '3') {
1126 fprintf(stderr, "No Broadcom wl interface found!\n");
1132 while ((argc > 0) && (argv[0] != NULL)) {
1133 if ((call = find_cmd(argv[0])) == NULL) {
1134 fprintf(stderr, "Invalid command: %s\n\n", argv[0]);
1137 if ((argc > 1) && (!(call->param & NOARG))) {
1138 ret = do_command(call, argv[1]);
1142 ret = do_command(call, NULL);
1148 while (fromstdin && !feof(stdin)) {
1150 fgets(buf, BUFSIZE - 1, stdin);
1155 if ((s = strchr(buf, '\r')) != NULL)
1157 if ((s = strchr(buf, '\n')) != NULL)
1167 if ((s2 = strchr(s, ' ')) != NULL)
1170 while (s2 && isspace(*s2))
1173 if ((call = find_cmd(s)) == NULL) {
1174 fprintf(stderr, "Invalid command: %s\n", s);
1177 ret = do_command(call, ((call->param & NOARG) ? NULL : s2));