summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-01-10 23:23:32 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-01-10 23:23:32 +0000
commit8feae0cba8454cba3b122d5351f2e2f336905134 (patch)
treefb7c5f01919bd8c247d31478649026c653dc91ce /modules
parent84c6b17d78c5cfab8977b4037b717cadde99b4de (diff)
modules/admin-full: rework wep/wpa key handling
Diffstat (limited to 'modules')
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua77
1 files changed, 64 insertions, 13 deletions
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
index 87f7d8ef0..0cfc02176 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
@@ -593,19 +593,70 @@ port:depends({mode="ap-wds", encryption="wpa"})
port:depends({mode="ap-wds", encryption="wpa2"})
port.rmempty = true
-key = s:taboption("encryption", Value, "key", translate("Key"))
-key:depends("encryption", "wep-open")
-key:depends("encryption", "wep-shared")
-key:depends("encryption", "psk")
-key:depends("encryption", "psk2")
-key:depends("encryption", "psk+psk2")
-key:depends("encryption", "psk-mixed")
-key:depends({mode="ap", encryption="wpa"})
-key:depends({mode="ap", encryption="wpa2"})
-key:depends({mode="ap-wds", encryption="wpa"})
-key:depends({mode="ap-wds", encryption="wpa2"})
-key.rmempty = true
-key.password = true
+wpakey = s:taboption("encryption", Value, "_wpa_key", translate("Key"))
+wpakey:depends("encryption", "psk")
+wpakey:depends("encryption", "psk2")
+wpakey:depends("encryption", "psk+psk2")
+wpakey:depends("encryption", "psk-mixed")
+wpakey:depends({mode="ap", encryption="wpa"})
+wpakey:depends({mode="ap", encryption="wpa2"})
+wpakey:depends({mode="ap-wds", encryption="wpa"})
+wpakey:depends({mode="ap-wds", encryption="wpa2"})
+wpakey.datatype = "wpakey"
+wpakey.rmempty = true
+wpakey.password = true
+
+wpakey.cfgvalue = function(self, section, value)
+ local key = m.uci:get("wireless", section, "key")
+ if key == "1" or key == "2" or key == "3" or key == "4" then
+ return nil
+ end
+ 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"))