- if (buffer = nvram_get(wl_var("ssid"))) {
- if (strlen(buffer) > IW_ESSID_MAX_SIZE) {
- ABORT_ARG_SIZE("Set ESSID", SIOCSIWESSID, IW_ESSID_MAX_SIZE);
- } else {
- char essid[IW_ESSID_MAX_SIZE + 1];
-
- wrq.u.essid.flags = 1;
- strcpy(essid, buffer);
- wrq.u.essid.pointer = (caddr_t) essid;
- wrq.u.essid.length = strlen(essid) + 1;
- IW_SET_EXT_ERR(skfd, ifname, SIOCSIWESSID, &wrq, "Set ESSID");
+ /* 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 && strstr(v, "psk")) {
+ v = nvram_safe_get(wl_var("wpa_psk"));
+
+ if ((strlen(v) >= 8) && (strlen(v) < 63)) {
+ val = 4;
+ bcom_ioctl(skfd, ifname, WLC_SET_WPA_AUTH, &val, sizeof(val));
+
+ bcom_ioctl(skfd, ifname, WLC_GET_AP, &val, sizeof(val));
+ if (!val) {
+ /* Enable in-driver WPA supplicant */
+ wsec_pmk_t pmk;
+
+ pmk.key_len = (unsigned short) strlen(v);
+ pmk.flags = WSEC_PASSPHRASE;
+ strcpy(pmk.key, v);
+ bcom_ioctl(skfd, ifname, WLC_SET_WSEC_PMK, &pmk, sizeof(pmk));
+ bcom_set_int(skfd, ifname, "sup_wpa", 1);
+ }
+ }
+ } else {
+ val = 1;
+ bcom_ioctl(skfd, ifname, WLC_SET_EAP_RESTRICT, &val, sizeof(val));