add SubmittingPatches document to docs/
[openwrt.git] / package / broadcom-wl / src / wlc / wlc.c
index 99237c0..f5db9a7 100644 (file)
@@ -92,7 +92,11 @@ struct wlc_call {
 
 /* can't use the system include because of the stupid broadcom header files */
 extern struct ether_addr *ether_aton(const char *asc);
-extern char *ether_ntoa(const struct ether_addr *addr);
+static inline int my_ether_ntoa(unsigned char *ea, char *buf)
+{
+       return sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
+               ea[0], ea[1], ea[2], ea[3], ea[4], ea[5]);
+}
 
 /*
  * find the starting point of wl.o in memory
@@ -128,7 +132,7 @@ static int ptable_init(void)
        if (ptable[0] == PTABLE_MAGIC)
                return 0;
        
-       glob("/lib/modules/2.4.*/wl.o", 0, NULL, &globbuf);
+       glob("/lib/modules/2.4.*/wl.o.patch", 0, NULL, &globbuf);
        
        if (globbuf.gl_pathv[0] == NULL)
                return -1;
@@ -139,13 +143,8 @@ static int ptable_init(void)
        if (fstat(fd, &statbuf) < 0)
                goto failed;
 
-       if (statbuf.st_size <= 512)
-               goto failed;
-       
-       if (lseek(fd, statbuf.st_size - 512, SEEK_SET) < 0) {
-               perror("lseek");
+       if (statbuf.st_size < 512)
                goto failed;
-       }
 
        if (read(fd, ptable, 512) < 512)
                goto failed;
@@ -481,8 +480,10 @@ static int wlc_maclist(wlc_param param, void *data, void *value)
                ret = wl_ioctl(interface, (ioc >> 16) & 0xffff, wlbuf, sizeof(wlbuf));
                
                if (!ret) 
-                       while (list->count)
-                               str += sprintf(str, "%s%s", ((((char *) value) == str) ? "" : " "), ether_ntoa(&list->ea[list->count-- - 1]));
+                       while (list->count) {
+                               str += sprintf(str, "%s", ((((char *) value) == str) ? "" : " "));
+                               str += my_ether_ntoa((unsigned char *) &list->ea[list->count-- - 1], str);
+                       }
                
                return ret;
        } else {
@@ -649,6 +650,58 @@ static int wlc_wme_ac(wlc_param param, void *data, void *value)
        return ret;
 }
 
+static int wlc_ifname(wlc_param param, void *data, void *value)
+{
+       char *val = (char *) value;
+       int ret = 0;
+       
+       if (param & SET) {
+               if (strlen(val) < 16)
+                       strcpy(interface, val);
+               else ret = -1;
+       }
+       if (param & GET) {
+               strcpy(val, interface);
+       }
+
+       return ret;
+}
+
+static int wlc_wdsmac(wlc_param param, void *data, void *value)
+{
+       unsigned char mac[6];
+       int ret = 0;
+       
+       ret = wl_ioctl(interface, WLC_WDS_GET_REMOTE_HWADDR, &mac, 6);
+       if (ret == 0)
+               my_ether_ntoa(mac, value);
+
+       return ret;
+}
+
+static int wlc_pmk(wlc_param param, void *data, void *value)
+{
+       int ret = -1;
+       char *str = (char *) value;
+       wsec_pmk_t pmk;
+       
+       /* driver doesn't support GET */
+
+       if ((param & PARAM_MODE) == SET) {
+               strncpy(pmk.key, value, WSEC_MAX_PSK_LEN);
+               pmk.key_len = strlen(value);
+
+               if (pmk.key_len > WSEC_MAX_PSK_LEN)
+                       pmk.key_len = WSEC_MAX_PSK_LEN;
+
+               pmk.flags = WSEC_PASSPHRASE;
+
+               ret = wl_ioctl(interface, WLC_SET_WSEC_PMK, &pmk, sizeof(pmk));
+       }
+       
+       return ret;
+}
+
 static const struct wlc_call wlc_calls[] = {
        {
                .name = "version",
@@ -671,6 +724,12 @@ static const struct wlc_call wlc_calls[] = {
                .data.ptr = &fromstdin,
                .desc = "Accept input from stdin"
        },
+       {
+               .name = "ifname",
+               .param = STRING,
+               .handler = wlc_ifname,
+               .desc = "interface to send commands to"
+       },
        {
                .name = "up",
                .param = NOARG,
@@ -747,6 +806,13 @@ static const struct wlc_call wlc_calls[] = {
                .data.num = ((WLC_GET_CHANNEL << 16) | WLC_SET_CHANNEL),
                .desc = "Channel",
        },
+       {
+               .name = "vlan_mode",
+               .param = INT,
+               .handler = wlc_bssiovar,
+               .data.str = "vlan_mode",
+               .desc = "Parse 802.1Q tags",
+       },
        {
                .name = "vif",
                .param = INT,
@@ -821,6 +887,12 @@ static const struct wlc_call wlc_calls[] = {
                .data.str = "sup_wpa",
                .desc = "Built-in WPA supplicant"
        },
+       {
+               .name = "passphrase",
+               .param = STRING,
+               .handler = wlc_pmk,
+               .desc = "Passphrase for built-in WPA supplicant",
+       },
        {
                .name = "maxassoc",
                .param = INT,
@@ -856,6 +928,20 @@ static const struct wlc_call wlc_calls[] = {
                .data.str = "wme_noack",
                .desc = "WME ACK disable request",
        },
+       {
+               .name = "802.11d",
+               .param = INT,
+               .handler = wlc_ioctl,
+               .data.num = ((WLC_GET_REGULATORY << 16) | WLC_SET_REGULATORY),
+               .desc = "Enable/disable 802.11d regulatory management",
+       },
+       {
+               .name = "802.11h",
+               .param = INT,
+               .handler = wlc_ioctl,
+               .data.num = ((WLC_GET_SPECT_MANAGMENT << 16) | WLC_SET_SPECT_MANAGMENT),
+               .desc = "Enable/disable 802.11h spectrum management",
+       },
        {
                .name = "fragthresh",
                .param = INT,
@@ -954,6 +1040,12 @@ static const struct wlc_call wlc_calls[] = {
                .data.str = "wdstimeout",
                .desc = "WDS link detection timeout"
        },
+       {
+               .name = "wdsmac",
+               .param = STRING|NOARG,
+               .handler = wlc_wdsmac,
+               .desc = "MAC of the remote WDS endpoint (only with wds0.* interfaces)"
+       },
        {
                .name = "afterburner",
                .param = INT,
This page took 0.026569 seconds and 4 git commands to generate.