+ return key
+end
+
+wpakey.write = function(self, section, value)
+ self.map.uci:set("wireless", section, "key", value)
+ self.map.uci:delete("wireless", section, "key1")
+end
+
+
+wepslot = s:taboption("encryption", ListValue, "_wep_key", translate("Used Key Slot"))
+wepslot:depends("encryption", "wep-open")
+wepslot:depends("encryption", "wep-shared")
+wepslot:value("1", translatef("Key #%d", 1))
+wepslot:value("2", translatef("Key #%d", 2))
+wepslot:value("3", translatef("Key #%d", 3))
+wepslot:value("4", translatef("Key #%d", 4))
+
+wepslot.cfgvalue = function(self, section)
+ local slot = tonumber(m.uci:get("wireless", section, "key"))
+ if not slot or slot < 1 or slot > 4 then
+ return 1
+ end
+ return slot
+end
+
+wepslot.write = function(self, section, value)
+ self.map.uci:set("wireless", section, "key", value)
+end
+
+local slot
+for slot=1,4 do
+ wepkey = s:taboption("encryption", Value, "key" .. slot, translatef("Key #%d", slot))
+ wepkey:depends("encryption", "wep-open")
+ wepkey:depends("encryption", "wep-shared")
+ wepkey.datatype = "wepkey"
+ wepkey.rmempty = true
+ wepkey.password = true
+
+ function wepkey.write(self, section, value)
+ if value and (#value == 5 or #value == 13) then
+ value = "s:" .. value
+ end
+ return Value.write(self, section, value)
+ end
+end
+
+
+if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
+ nasid = s:taboption("encryption", Value, "nasid", translate("NAS ID"))
+ nasid:depends({mode="ap", encryption="wpa"})
+ nasid:depends({mode="ap", encryption="wpa2"})
+ nasid:depends({mode="ap-wds", encryption="wpa"})
+ nasid:depends({mode="ap-wds", encryption="wpa2"})
+ nasid.rmempty = true
+
+ eaptype = s:taboption("encryption", ListValue, "eap_type", translate("EAP-Method"))
+ eaptype:value("tls", "TLS")
+ eaptype:value("ttls", "TTLS")
+ eaptype:value("peap", "PEAP")
+ eaptype:depends({mode="sta", encryption="wpa"})
+ eaptype:depends({mode="sta", encryption="wpa2"})
+ eaptype:depends({mode="sta-wds", encryption="wpa"})
+ eaptype:depends({mode="sta-wds", encryption="wpa2"})
+
+ cacert = s:taboption("encryption", FileUpload, "ca_cert", translate("Path to CA-Certificate"))
+ cacert:depends({mode="sta", encryption="wpa"})
+ cacert:depends({mode="sta", encryption="wpa2"})
+ cacert:depends({mode="sta-wds", encryption="wpa"})
+ cacert:depends({mode="sta-wds", encryption="wpa2"})
+
+ clientcert = s:taboption("encryption", FileUpload, "client_cert", translate("Path to Client-Certificate"))
+ clientcert:depends({mode="sta", encryption="wpa"})
+ clientcert:depends({mode="sta", encryption="wpa2"})
+ clientcert:depends({mode="sta-wds", encryption="wpa"})
+ clientcert:depends({mode="sta-wds", encryption="wpa2"})
+
+ privkey = s:taboption("encryption", FileUpload, "priv_key", translate("Path to Private Key"))
+ privkey:depends({mode="sta", eap_type="tls", encryption="wpa2"})
+ privkey:depends({mode="sta", eap_type="tls", encryption="wpa"})
+ privkey:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
+ privkey:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
+
+ privkeypwd = s:taboption("encryption", Value, "priv_key_pwd", translate("Password of Private Key"))
+ privkeypwd:depends({mode="sta", eap_type="tls", encryption="wpa2"})
+ privkeypwd:depends({mode="sta", eap_type="tls", encryption="wpa"})
+ privkeypwd:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
+ privkeypwd:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
+
+
+ auth = s:taboption("encryption", Value, "auth", translate("Authentication"))
+ auth:value("PAP")
+ auth:value("CHAP")
+ auth:value("MSCHAP")
+ auth:value("MSCHAPV2")
+ auth:depends({mode="sta", eap_type="peap", encryption="wpa2"})
+ auth:depends({mode="sta", eap_type="peap", encryption="wpa"})
+ auth:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
+ auth:depends({mode="sta", eap_type="ttls", encryption="wpa"})
+ auth:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
+ auth:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
+ auth:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
+ auth:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
+
+
+ identity = s:taboption("encryption", Value, "identity", translate("Identity"))
+ identity:depends({mode="sta", eap_type="peap", encryption="wpa2"})
+ identity:depends({mode="sta", eap_type="peap", encryption="wpa"})
+ identity:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
+ identity:depends({mode="sta", eap_type="ttls", encryption="wpa"})
+ identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
+ identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
+ identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
+ identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
+
+ password = s:taboption("encryption", Value, "password", translate("Password"))
+ password:depends({mode="sta", eap_type="peap", encryption="wpa2"})
+ password:depends({mode="sta", eap_type="peap", encryption="wpa"})
+ password:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
+ password:depends({mode="sta", eap_type="ttls", encryption="wpa"})
+ password:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
+ password:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
+ password:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
+ password:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})