build: split into luci and luci-addons packages
[project/luci.git] / modules / niu / luasrc / model / cbi / niu / wireless / ap1.lua
index ccca18c..3ecbf5f 100644 (file)
@@ -16,13 +16,13 @@ $Id$
 local iface = "ap"
 local ap = true
 
-
 local fs = require "nixio.fs"
 local sys = require "luci.sys"
 local cursor = require "luci.model.uci".inst
 local state = require "luci.model.uci".inst_state
 cursor:unload("wireless")
 
+
 local device = cursor:get("wireless", iface, "device")
 local hwtype = cursor:get("wireless", device, "type")
 
@@ -30,13 +30,13 @@ local nsantenna = cursor:get("wireless", device, "antenna")
 
 local iw = nil
 local tx_powers = {}
-local chan = sys.wifi.channels()
+local chan = {}
 
 state:foreach("wireless", "wifi-iface",
        function(s)
                if s.device == device and not iw then
                        iw = sys.wifi.getiwinfo(s.ifname or s.device)
-                       chan = sys.wifi.channels(s.ifname or s.device)
+                       chan = iw and iw.freqlist or { }
                        tx_powers = iw.txpwrlist or { }
                end
        end)
@@ -175,7 +175,9 @@ s.addremove = false
 s:tab("general", translate("General Settings"))
 s:tab("expert", translate("Expert Settings"))
 
-s:taboption("general", Value, "ssid", translate("Network Name (<abbr title=\"Extended Service Set Identifier\">ESSID</abbr>)"))
+
+
+local ssid = s:taboption("general", Value, "ssid", translate("Network Name (<abbr title=\"Extended Service Set Identifier\">ESSID</abbr>)"))
 
 mode = s:taboption("expert", ListValue, "mode", translate("Operating Mode"))
 mode.override_values = true
@@ -185,8 +187,12 @@ encr = s:taboption("expert", ListValue, "encryption", translate("Encryption"))
 
 
 if hwtype == "mac80211" then
-       s:taboption("expert", Flag, "wds", "Allow Bridging and Repeating (WDS)")
-       s:taboption("expert", Flag, "powersave", "Enable Powersaving")
+       mode:value("mesh", translate("Mesh (802.11s)"))
+       local meshid = s:taboption("expert", Value, "mesh_id", translate("Mesh ID"))
+       meshid:depends("mode", "mesh")
+
+       s:taboption("expert", Flag, "wds", translate("Enable Bridging and Repeating (WDS)")):depends("mode", "ap")
+       s:taboption("expert", Flag, "powersave", translate("Enable Powersaving")):depends("mode", "ap")
 elseif hwtype == "atheros" then
        -- mode:value("wds", translate("Static WDS"))
        
@@ -198,7 +204,7 @@ elseif hwtype == "atheros" then
        ml:depends({macpolicy="allow"})
        ml:depends({macpolicy="deny"})
 
-       s:taboption("expert", Flag, "wds", "Allow Bridging and Repeating (WDS)")
+       s:taboption("expert", Flag, "wds", translate("Enable Bridging and Repeating (WDS)"))
                
        if ap then                              
                hidden = s:taboption("expert", Flag, "hidden", translate("Hide Access Point"))
@@ -212,8 +218,6 @@ elseif hwtype == "atheros" then
        s:taboption("expert", Flag, "bursting", translate("Allow Burst Transmissions"))
 elseif hwtype == "broadcom" then
        if ap then
-               mode:value("wds", translate("WDS"))
-
                hidden = s:taboption("expert", Flag, "hidden", translate("Hide Access Point"))
                hidden:depends({mode="ap"})
                hidden:depends({mode="wds"})
@@ -222,10 +226,6 @@ elseif hwtype == "broadcom" then
                isolate:depends({mode="ap"})
        end
 elseif hwtype == "prism2" then
-       if ap then
-               mode:value("wds", translate("WDS"))
-       end
-
        mp = s:taboption("expert", ListValue, "macpolicy", translate("MAC-Address Filter"))
        mp:value("", translate("disable"))
        mp:value("deny", translate("Allow listed only"))
@@ -252,16 +252,26 @@ encr:value("wep", "WEP", {mode="ap"})
 
 if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
        local hostapd = fs.access("/usr/sbin/hostapd") or os.getenv("LUCI_SYSROOT")
+       local supplicant = fs.access("/usr/sbin/wpa_supplicant") or os.getenv("LUCI_SYSROOT")
 
-       if hostapd then
-               --s:taboption("expert", Flag, "_alloweap", "Allow EAP / 802.11i authentication")
-               
+       if hostapd and not supplicant then              
                encr:value("psk", "WPA", {mode="ap"})
                encr:value("wpa", "WPA-EAP", {mode="ap"})
                encr:value("psk-mixed", "WPA + WPA2", {mode="ap"})
                encr:value("psk2", "WPA2", {mode="ap"})
                encr:value("wpa2", "WPA2-EAP (802.11i)", {mode="ap"})
                encr.default = "psk-mixed"
+       elseif not hostapd and supplicant then
+               encr:value("psk", "WPA", {mode="mesh"})
+               encr:value("psk2", "WPA2", {mode="mesh"})
+               encr.default = "psk2"
+       elseif hostapd and supplicant then
+               encr:value("psk", "WPA", {mode="ap"}, {mode="mesh"})
+               encr:value("wpa", "WPA-EAP", {mode="ap"})
+               encr:value("psk-mixed", "WPA + WPA2", {mode="ap"})
+               encr:value("psk2", "WPA2", {mode="ap"}, {mode="mesh"})
+               encr:value("wpa2", "WPA2-EAP (802.11i)", {mode="ap"})
+               encr.default = "psk-mixed"              
        end
 elseif hwtype == "broadcom" then
        encr:value("psk", "WPA")