Changeset 7892

Show
Ignore:
Timestamp:
11/07/11 07:31:43 (19 months ago)
Author:
jow
Message:

luci-0.10: merge r7891

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • luci/branches/luci-0.10/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua

    r7810 r7892  
    578578encr:depends({mode="mesh"}) 
    579579 
     580cipher = s:taboption("encryption", ListValue, "cipher", translate("Cipher")) 
     581cipher.rmempty = false 
     582cipher:depends({encryption="wpa"}) 
     583cipher:depends({encryption="wpa2"}) 
     584cipher:depends({encryption="psk"}) 
     585cipher:depends({encryption="psk2"}) 
     586cipher:depends({encryption="wpa-mixed"}) 
     587cipher:depends({encryption="psk-mixed"}) 
     588cipher:value("auto", translate("auto")) 
     589cipher:value("ccmp", translate("Force CCMP (AES)")) 
     590cipher:value("tkip", translate("Force TKIP")) 
     591cipher:value("tkip+ccmp", translate("Force TKIP and CCMP (AES)")) 
     592 
     593function encr.cfgvalue(self, section) 
     594    local v = tostring(ListValue.cfgvalue(self, section)) 
     595    if v == "wep" then 
     596        return "wep-open" 
     597    elseif v and v:match("%+") then 
     598        return (v:gsub("%+.+$", "")) 
     599    end 
     600    return v 
     601end 
     602 
    580603function encr.write(self, section, value) 
     604    local e = tostring(encr:formvalue(section)) 
     605    local c = tostring(cipher:formvalue(section)) 
    581606    if value == "wpa" or value == "wpa2"  then 
    582607        self.map.uci:delete("wireless", section, "key") 
    583608    end 
    584     self.map.uci:set("wireless", section, "encryption", value) 
     609    if e and (c == "tkip" or c == "ccmp" or c == "tkip+ccmp") then 
     610        e = e .. "+" .. c 
     611    end 
     612    self.map:set(section, "encryption", e) 
     613end 
     614 
     615function cipher.cfgvalue(self, section) 
     616    local v = tostring(ListValue.cfgvalue(encr, section)) 
     617    if v and v:match("%+") then 
     618        v = v:gsub("^[^%+]+%+", "") 
     619        if v == "aes" then v = "ccmp" 
     620        elseif v == "tkip+aes" then v = "tkip+ccmp" 
     621        elseif v == "aes+tkip" then v = "tkip+ccmp" 
     622        elseif v == "ccmp+tkip" then v = "tkip+ccmp" 
     623        end 
     624    end 
     625    return v 
     626end 
     627 
     628function cipher.write(self, section) 
     629    return encr:write(section) 
    585630end 
    586631