treewide: replace nbd@openwrt.org with nbd@nbd.name
[openwrt/staging/yousong.git] / package / kernel / broadcom-wl / src / wlc.c
index 253809c9a34da7bd753c8050d0ceb6b35568af9c..46ccf94bffd1e0de5e5715b7d264b13f8f4c6f1f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * wlc - Broadcom Wireless Driver Control Utility
  *
- * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2006 Felix Fietkau <nbd@nbd.name>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -391,6 +391,37 @@ static int wlc_wsec_key(wlc_param param, void *null, void *value)
        return wl_bssiovar_set(interface, "wsec_key", vif, &wsec_key, sizeof(wsec_key));
 }
 
+static int wlc_cap(wlc_param param, void *data, void *value)
+{
+       char *iov = *((char **) data);
+
+       if (param & GET)
+               return wl_iovar_get(interface, iov, value, BUFSIZE);
+
+       return -1;
+}
+
+static int wlc_bssmax(wlc_param param, void *data, void *value)
+{
+       int *val = (int *) value;
+       char *iov = *((char **) data);
+       int ret = -1;
+
+       if (param & GET) {
+               ret = wl_iovar_get(interface, iov, wlbuf, BUFSIZE);
+               if (!ret) {
+                       if (strstr(wlbuf, "mbss4"))
+                               *val = 4;
+                       else if (strstr(wlbuf, "mbss16"))
+                               *val = 16;
+                       else
+                               *val = 1;
+               }
+       }
+
+       return ret;
+}
+
 static inline int cw2ecw(int cw)
 {
        int i;  
@@ -499,8 +530,8 @@ static int wlc_pmk(wlc_param param, void *data, void *value)
        /* driver doesn't support GET */
 
        if ((param & PARAM_MODE) == SET) {
-               strncpy(pmk.key, value, WSEC_MAX_PSK_LEN);
-               pmk.key_len = strlen(value);
+               strncpy(pmk.key, str, WSEC_MAX_PSK_LEN);
+               pmk.key_len = strlen(str);
 
                if (pmk.key_len > WSEC_MAX_PSK_LEN)
                        pmk.key_len = WSEC_MAX_PSK_LEN;
@@ -891,6 +922,13 @@ static const struct wlc_call wlc_calls[] = {
                .data.num = ((WLC_GET_BSSID << 16) | WLC_SET_BSSID),
                .desc = "BSSID"
        },
+       {
+               .name = "cur_etheraddr",
+               .param = MAC,
+               .handler = wlc_iovar,
+               .data.str = "cur_etheraddr",
+               .desc = "Current MAC Address"
+       },
        {
                .name = "default_bssid",
                .param = MAC,
@@ -912,6 +950,63 @@ static const struct wlc_call wlc_calls[] = {
                .handler = wlc_ioctl,
                .desc = "G Mode"
        },
+       {
+               .name = "phytype",
+               .param = INT,
+               .data.num = (WLC_GET_PHYTYPE << 16),
+               .handler = wlc_ioctl,
+               .desc = "PHY Type (read-only)"
+       },
+       {
+               .name = "nmode",
+               .param = INT,
+               .handler = wlc_iovar,
+               .data.str = "nmode",
+               .desc = "N Mode"
+       },
+       {
+               .name = "nreqd",
+               .param = INT,
+               .handler = wlc_iovar,
+               .data.str = "nreqd",
+               .desc = "N Mode required"
+       },
+       {
+               .name = "chanspec",
+               .param = INT,
+               .handler = wlc_iovar,
+               .data.str = "chanspec",
+               .desc = "Channel Spec (See bcmwifi.h)"
+       },
+       {
+               .name = "band",
+               .param = INT,
+               .data.num = ((WLC_GET_BAND << 16) | WLC_SET_BAND),
+               .handler = wlc_ioctl,
+               .desc = "Band (0=auto, 1=5Ghz, 2=2.4GHz)"
+       },
+       {
+               .name = "cap",
+               .param = STRING|NOARG,
+               .handler = wlc_cap,
+               .data.str = "cap",
+               .desc = "Capabilities"
+       },
+       {
+               .name = "bssmax",
+               .param = INT|NOARG,
+               .handler = wlc_bssmax,
+               .data.str = "cap",
+               .desc = "Number of VIF's supported"
+       },
+       {
+               .name = "leddc",
+               .param = INT,
+               .handler = wlc_iovar,
+               .data.str = "leddc",
+               .desc = "LED Duty Cycle"
+       },
+       
 };
 #define wlc_calls_size (sizeof(wlc_calls) / sizeof(struct wlc_call))
 
@@ -971,7 +1066,7 @@ static int do_command(const struct wlc_call *cmd, char *arg)
                set = 1;
                switch(cmd->param & PARAM_TYPE) {
                        case INT:
-                               intval = strtoul(arg, &end, 10);
+                               intval = strtoul(arg, &end, 0);
                                if (end && !(*end)) {
                                        memcpy(buf, &intval, sizeof(intval));
                                } else {
@@ -1069,14 +1164,14 @@ int main(int argc, char **argv)
                if (!*s)
                        continue;
        
-               if ((s2 = strchr(buf, ' ')) != NULL)
+               if ((s2 = strchr(s, ' ')) != NULL)
                        *(s2++) = 0;
                
                while (s2 && isspace(*s2))
                        s2++;
                
-               if ((call = find_cmd(buf)) == NULL) {
-                       fprintf(stderr, "Invalid command: %s\n", buf);
+               if ((call = find_cmd(s)) == NULL) {
+                       fprintf(stderr, "Invalid command: %s\n", s);
                        ret = -1;
                } else
                        ret = do_command(call, ((call->param & NOARG) ? NULL : s2));