X-Git-Url: http://git.rohieb.name/openwrt.git/blobdiff_plain/0509a46f271cda237881a7ed244e9b14760c4654..d5951b0eb46d2a9f476ed8cb51b9c8af2c11eb8a:/package/wificonf/wificonf.c diff --git a/package/wificonf/wificonf.c b/package/wificonf/wificonf.c index 44ca8a40d..4a5f2fc6c 100644 --- a/package/wificonf/wificonf.c +++ b/package/wificonf/wificonf.c @@ -146,6 +146,8 @@ int bcom_set_int(int skfd, char *ifname, char *var, int val) void setup_bcom(int skfd, char *ifname) { int val = 0; + char buf[8192]; + char wbuf[80]; char *v; if (bcom_ioctl(skfd, ifname, WLC_GET_MAGIC, &val, sizeof(val)) < 0) @@ -153,20 +155,22 @@ void setup_bcom(int skfd, char *ifname) bcom_ioctl(skfd, ifname, WLC_DOWN, NULL, 0); - /* Set up WPA */ - if (nvram_match(wl_var("crypto"), "tkip")) - val = TKIP_ENABLED; - else if (nvram_match(wl_var("crypto"), "aes")) - val = AES_ENABLED; - else if (nvram_match(wl_var("crypto"), "tkip+aes")) - val = TKIP_ENABLED | AES_ENABLED; - else - val = 0; - bcom_ioctl(skfd, ifname, WLC_SET_WSEC, &val, sizeof(val)); - - if (val && nvram_get(wl_var("wpa_psk"))) { - val = 1; - bcom_ioctl(skfd, ifname, WLC_SET_EAP_RESTRICT, &val, sizeof(val)); + if (!nvram_enabled(wl_var("wep"))) { + /* Set up WPA */ + if (nvram_match(wl_var("crypto"), "tkip")) + val = TKIP_ENABLED; + else if (nvram_match(wl_var("crypto"), "aes")) + val = AES_ENABLED; + else if (nvram_match(wl_var("crypto"), "tkip+aes")) + val = TKIP_ENABLED | AES_ENABLED; + else + val = 0; + bcom_ioctl(skfd, ifname, WLC_SET_WSEC, &val, sizeof(val)); + + if (val && nvram_get(wl_var("wpa_psk"))) { + val = 1; + bcom_ioctl(skfd, ifname, WLC_SET_EAP_RESTRICT, &val, sizeof(val)); + } } /* Set up afterburner */ @@ -178,20 +182,37 @@ void setup_bcom(int skfd, char *ifname) bcom_set_val(skfd, ifname, "afterburner_override", &val, sizeof(val)); /* Set other options */ - val = atoi(nvram_safe_get(wl_var("lazywds"))); - bcom_ioctl(skfd, ifname, WLC_SET_LAZYWDS, &val, sizeof(val)); - val = atoi(nvram_safe_get(wl_var("frag"))); - bcom_ioctl(skfd, ifname, WLC_SET_FRAG, &val, sizeof(val)); - val = atoi(nvram_safe_get(wl_var("dtim"))); - bcom_ioctl(skfd, ifname, WLC_SET_DTIMPRD, &val, sizeof(val)); - val = atoi(nvram_safe_get(wl_var("bcn"))); - bcom_ioctl(skfd, ifname, WLC_SET_BCNPRD, &val, sizeof(val)); - val = atoi(nvram_safe_get(wl_var("rts"))); - bcom_ioctl(skfd, ifname, WLC_SET_RTS, &val, sizeof(val)); - val = atoi(nvram_safe_get(wl_var("antdiv"))); - bcom_ioctl(skfd, ifname, WLC_SET_ANTDIV, &val, sizeof(val)); - val = atoi(nvram_safe_get(wl_var("txant"))); - bcom_ioctl(skfd, ifname, WLC_SET_TXANT, &val, sizeof(val)); + if (v = nvram_get(wl_var("lazywds"))) { + val = atoi(v); + bcom_ioctl(skfd, ifname, WLC_SET_LAZYWDS, &val, sizeof(val)); + } + if (v = nvram_get(wl_var("frag"))) { + val = atoi(v); + bcom_ioctl(skfd, ifname, WLC_SET_FRAG, &val, sizeof(val)); + } + if (v = nvram_get(wl_var("dtim"))) { + val = atoi(v); + bcom_ioctl(skfd, ifname, WLC_SET_DTIMPRD, &val, sizeof(val)); + } + if (v = nvram_get(wl_var("bcn"))) { + val = atoi(v); + bcom_ioctl(skfd, ifname, WLC_SET_BCNPRD, &val, sizeof(val)); + } + if (v = nvram_get(wl_var("rts"))) { + val = atoi(v); + bcom_ioctl(skfd, ifname, WLC_SET_RTS, &val, sizeof(val)); + } + if (v = nvram_get(wl_var("antdiv"))) { + val = atoi(v); + bcom_ioctl(skfd, ifname, WLC_SET_ANTDIV, &val, sizeof(val)); + } + if (v = nvram_get(wl_var("txant"))) { + val = atoi(v); + bcom_ioctl(skfd, ifname, WLC_SET_TXANT, &val, sizeof(val)); + } + + val = nvram_enabled(wl_var("closed")); + bcom_ioctl(skfd, ifname, WLC_SET_CLOSED, &val, sizeof(val)); val = nvram_enabled(wl_var("ap_isolate")); bcom_set_int(skfd, ifname, "ap_isolate", val); @@ -208,7 +229,6 @@ void setup_bcom(int skfd, char *ifname) val = WLC_MACMODE_DISABLED; if ((val != WLC_MACMODE_DISABLED) && (v = nvram_get(wl_var("maclist")))) { - char buf[8192]; struct maclist *mac_list; struct ether_addr *addr; char *next; @@ -217,19 +237,32 @@ void setup_bcom(int skfd, char *ifname) mac_list = (struct maclist *) buf; addr = mac_list->ea; - v = malloc(80); - foreach(v, nvram_safe_get(wl_var("maclist")), next) { - if (ether_atoe(v, addr->ether_addr_octet)) { + foreach(wbuf, v, next) { + if (ether_atoe(wbuf, addr->ether_addr_octet)) { mac_list->count++; addr++; } } - free(v); bcom_ioctl(skfd, ifname, WLC_SET_MACLIST, buf, sizeof(buf)); } else { val = WLC_MACMODE_DISABLED; } bcom_ioctl(skfd, ifname, WLC_SET_MACMODE, &val, sizeof(val)); + + if (v = nvram_get(wl_var("wds"))) { + struct maclist *wdslist = (struct maclist *) buf; + struct ether_addr *addr = wdslist->ea; + char *next; + + memset(buf, 0, 8192); + foreach(wbuf, v, next) { + if (ether_atoe(wbuf, addr->ether_addr_octet)) { + wdslist->count++; + addr++; + } + } + bcom_ioctl(skfd, ifname, WLC_SET_WDSLIST, buf, sizeof(buf)); + } /* Set up G mode */ bcom_ioctl(skfd, ifname, WLC_GET_PHYTYPE, &val, sizeof(val)); @@ -337,24 +370,21 @@ void setup_wext(int skfd, char *ifname) if (channel > 0) { wrq.u.freq.flags = IW_FREQ_FIXED; wrq.u.freq.m = channel; + IW_SET_EXT_ERR(skfd, ifname, SIOCSIWFREQ, &wrq, "Set Frequency"); } - IW_SET_EXT_ERR(skfd, ifname, SIOCSIWFREQ, &wrq, "Set Frequency"); /* Set operation mode */ int ap = 0, infra = 0, wet = 0; - ap = (nvram_match(wl_var("mode"), "ap") || nvram_match(wl_var("mode"), "wds")); - infra = nvram_enabled(wl_var("infra")); + ap = !nvram_match(wl_var("mode"), "sta"); + infra = !nvram_disabled(wl_var("infra")); wet = nvram_enabled(wl_var("wet")); wrq.u.mode = (!infra ? IW_MODE_ADHOC : (ap ? IW_MODE_MASTER : (wet ? IW_MODE_REPEAT : IW_MODE_INFRA))); IW_SET_EXT_ERR(skfd, ifname, SIOCSIWMODE, &wrq, "Set Mode"); /* Disable radio if wlX_radio is set and not enabled */ - if (nvram_disabled(wl_var("radio"))) - wrq.u.txpower.disabled = 1; - else - wrq.u.txpower.disabled = 0; + wrq.u.txpower.disabled = nvram_disabled(wl_var("radio")); wrq.u.txpower.value = -1; wrq.u.txpower.fixed = 1;