summaryrefslogtreecommitdiffhomepage
path: root/modules/niu/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/niu/luasrc')
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/assign1.lua2
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/etherwan.lua4
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/lan.lua3
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/wan.lua23
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/wandevice.lua19
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/wlanwan.lua254
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/wlanwanscan.lua12
-rw-r--r--modules/niu/luasrc/model/cbi/niu/traffic/routes1.lua2
-rw-r--r--modules/niu/luasrc/model/cbi/niu/wireless/ap.lua6
-rw-r--r--modules/niu/luasrc/model/cbi/niu/wireless/ap1.lua2
-rw-r--r--modules/niu/luasrc/model/cbi/niu/wireless/apdevice.lua25
-rw-r--r--modules/niu/luasrc/niulib.lua65
-rw-r--r--modules/niu/luasrc/view/niu/network/wlanwanscan.htm7
13 files changed, 376 insertions, 48 deletions
diff --git a/modules/niu/luasrc/model/cbi/niu/network/assign1.lua b/modules/niu/luasrc/model/cbi/niu/network/assign1.lua
index fdd0dc00b..0fee331e1 100644
--- a/modules/niu/luasrc/model/cbi/niu/network/assign1.lua
+++ b/modules/niu/luasrc/model/cbi/niu/network/assign1.lua
@@ -46,7 +46,7 @@ local function date_format(secs)
end
end
-m2 = Map("dhcp", "Display and Customize Address Assignment")
+m2 = Map("dhcp", "Manage Address Assignment")
local leasefn, leasefp, leases
uci:foreach("dhcp", "dnsmasq",
diff --git a/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua b/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua
index c5fda1582..f57b7f316 100644
--- a/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua
+++ b/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua
@@ -14,9 +14,8 @@ $Id$
]]--
local fs = require "nixio.fs"
-local nw = require "luci.model.network"
-local has_ipv6 = nw:has_ipv6()
+local has_ipv6 = fs.access("/proc/net/ipv6_route")
local has_pptp = fs.access("/usr/sbin/pptp")
local has_pppd = fs.access("/usr/sbin/pppd")
local has_pppoe = fs.glob("/usr/lib/pppd/*/rp-pppoe.so")()
@@ -24,7 +23,6 @@ local has_pppoa = fs.glob("/usr/lib/pppd/*/pppoatm.so")()
m = Map("network", "Configure Ethernet Adapter for Internet Connection")
-nw.init(m.uci)
s = m:section(NamedSection, "wan", "interface")
s.addremove = false
diff --git a/modules/niu/luasrc/model/cbi/niu/network/lan.lua b/modules/niu/luasrc/model/cbi/niu/network/lan.lua
index 45f238108..feb213c6e 100644
--- a/modules/niu/luasrc/model/cbi/niu/network/lan.lua
+++ b/modules/niu/luasrc/model/cbi/niu/network/lan.lua
@@ -5,8 +5,7 @@ d.allow_finish = true
d.allow_back = true
d.allow_cancel = true
-d:add("lan1", load("niu/network/lan1"))
-d:set("warnip", {Template("niu/network/warn_ip_change")})
+d:add("lan1", "niu/network/lan1")
function d.on_cancel()
cursor:revert("network")
diff --git a/modules/niu/luasrc/model/cbi/niu/network/wan.lua b/modules/niu/luasrc/model/cbi/niu/network/wan.lua
index b7351ff19..1724c4a8e 100644
--- a/modules/niu/luasrc/model/cbi/niu/network/wan.lua
+++ b/modules/niu/luasrc/model/cbi/niu/network/wan.lua
@@ -5,6 +5,12 @@ if not cursor:get("network", "wan") then
cursor:save("network")
end
+if not cursor:get("wireless", "client") then
+ cursor:section("wireless", "wifi-iface", "client",
+ {device = "_", doth = "1", _niu = "1", mode = "sta"})
+ cursor:save("wireless")
+end
+
local function deviceroute(self)
cursor:unload("network")
local wd = cursor:get("network", "wan", "_wandev") or ""
@@ -22,11 +28,18 @@ local function deviceroute(self)
end
if wd:find("wlan:") == 1 then
-
+ local widev = wd:sub(6)
+ if cursor:get("wireless", "client", "device") ~= widev then
+ cursor:delete("wireless", "client", "network")
+ cursor:set("wireless", "client", "device", widev)
+ end
+ self:set_route("wlanwan1", "wlanwan2")
else
- cursor:delete_all("wireless", "wifi-iface", {network = "wan"})
+ cursor:delete("wireless", "client", "device")
+ cursor:delete("wireless", "client", "network")
end
+
cursor:save("wireless")
cursor:save("network")
end
@@ -37,9 +50,11 @@ d.allow_finish = true
d.allow_back = true
d.allow_cancel = true
-d:add("device", load("niu/network/wandevice"))
+d:add("device", "niu/network/wandevice")
d:add("deviceroute", deviceroute)
-d:set("etherwan", load("niu/network/etherwan"))
+d:set("etherwan", "niu/network/etherwan")
+d:set("wlanwan1", "niu/network/wlanwanscan")
+d:set("wlanwan2", "niu/network/wlanwan")
function d.on_cancel()
cursor:revert("network")
diff --git a/modules/niu/luasrc/model/cbi/niu/network/wandevice.lua b/modules/niu/luasrc/model/cbi/niu/network/wandevice.lua
index db7d90254..9287ba8d0 100644
--- a/modules/niu/luasrc/model/cbi/niu/network/wandevice.lua
+++ b/modules/niu/luasrc/model/cbi/niu/network/wandevice.lua
@@ -12,9 +12,7 @@ You may obtain a copy of the License at
$Id$
]]--
-local cursor = require "luci.model.uci".inst_state
-local nw = require "luci.model.network"
-nw.init(cursor)
+local niulib = require "luci.niulib"
m = Map("network", "Configure Internet Connection")
s = m:section(NamedSection, "wan", "interface", "Internet Connection Device")
@@ -23,16 +21,15 @@ s.addremove = false
l = s:option(ListValue, "_wandev", "Internet Connection via")
-for _, iface in ipairs(nw.get_interfaces()) do
- if iface:name():find("eth") == 1 then
- local net = iface:get_network()
- if not net or net:name() == "wan" or os.getenv("LUCI_SYSROOT") then
- l:value("ethernet:%s" % iface:name(),
- "Cable / DSL / Ethernet Adapter (%s)" % iface:name())
- end
- end
+for _, ifc in ipairs(niulib.eth_get_available("wan")) do
+ l:value("ethernet:%s" % ifc, "Cable / DSL / Ethernet-Adapter (%s)" % ifc)
end
+for _, wifi in ipairs(niulib.wifi_get_available("client")) do
+ l:value("wlan:%s" % wifi, "WLAN-Adapter (%s)" % wifi)
+end
+
+
l:value("none", "No Internet Connection")
return m
diff --git a/modules/niu/luasrc/model/cbi/niu/network/wlanwan.lua b/modules/niu/luasrc/model/cbi/niu/network/wlanwan.lua
new file mode 100644
index 000000000..dc8bfbdfb
--- /dev/null
+++ b/modules/niu/luasrc/model/cbi/niu/network/wlanwan.lua
@@ -0,0 +1,254 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2009 Steven Barth <steven@midlink.org>
+Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+]]--
+
+local fs = require "nixio.fs"
+local uci = require "luci.model.uci"
+local nixio = require "nixio"
+local iwinfo = require "iwinfo"
+
+local cursor = uci.inst
+local state = uci.inst_state
+cursor:unload("wireless")
+state:unload("wireless")
+
+local has_ipv6 = fs.access("/proc/net/ipv6_route")
+local device = cursor:get("wireless", "client", "device")
+local hwtype = cursor:get("wireless", device, "type")
+
+
+-- Bring up interface and scan --
+
+if not state:get("wireless", "client", "network") then
+ local olduci = uci.cursor(nil, "")
+ local oldcl = olduci:get_all("wireless", "client")
+ olduci:unload("wireless")
+
+ local newuci = uci.cursor()
+ local newcl = newuci:get_all("wireless", "client")
+ newcl.network = "wan"
+
+ local proc = nixio.fork()
+ if proc == 0 then
+ newuci:delete("wireless", "client", "ssid")
+ newuci:commit("wireless")
+ nixio.exec("/sbin/wifi", "up", device)
+ os.exit(1)
+ end
+ nixio.wait(proc)
+
+ newuci:delete("wireless", "client")
+ newuci:section("wireless", "wifi-iface", "client", oldcl)
+ newuci:commit("wireless")
+ newuci:tset("wireless", "client", newcl)
+ newuci:save("wireless")
+ newuci:unload("wireless")
+
+ state:unload("wireless")
+end
+
+local ifname = state:get("wireless", "client", "ifname") or "wlan0dummy"
+local iwlib = iwinfo.type(ifname) and iwinfo[iwinfo.type(ifname)]
+local suggest = {}
+local encrdep = {
+ none = {{["!default"] = 1}},
+ wep = {{["!default"] = 1}},
+ psk = {{["!default"] = 1}},
+ psk2 = {{["!default"] = 1}},
+ wpa = {{["!default"] = 1}},
+ wpa2 = {{["!default"] = 1}}
+}
+
+if iwlib then
+ suggest = iwlib.scanlist(ifname)
+end
+
+
+
+-- Form definition --
+
+m2 = Map("wireless", "Configure WLAN-Adapter for Internet Connection")
+
+s = m2:section(NamedSection, "client", "wifi-iface", "Wireless Settings")
+s.addremove = false
+
+s:tab("general", translate("General Settings"))
+s:tab("expert", translate("Expert Settings"))
+
+local ssid = s:taboption("general", Value, "ssid", translate("Network Name (<abbr title=\"Extended Service Set Identifier\">ESSID</abbr>)"))
+ssid.rmempty = false
+
+for _, v in ipairs(suggest) do
+ if v.mode == "Master" then
+ ssid:value(v.ssid)
+
+ if not v.wep then
+ encrdep.wep[#encrdep.wep+1] = {ssid = v.ssid, ["!reverse"] = 1}
+ end
+ if v.wpa ~= 1 or (v.wpa == 1 and v.auth_suites[1] ~= "802.1x") then
+ encrdep.wpa[#encrdep.wpa+1] = {ssid = v.ssid, ["!reverse"] = 1}
+ end
+ if v.wpa ~= 1 or (v.wpa == 1 and v.auth_suites[1] ~= "PSK") then
+ encrdep.psk[#encrdep.psk+1] = {ssid = v.ssid, ["!reverse"] = 1}
+ end
+ if not v.wpa or v.wpa < 2 or (v.wpa >= 2 and v.auth_suites[1] ~= "802.1x") then
+ encrdep.wpa2[#encrdep.wpa2+1] = {ssid = v.ssid, ["!reverse"] = 1}
+ end
+ if not v.wpa or v.wpa < 2 or (v.wpa >= 2 and v.auth_suites[1] ~= "PSK") then
+ encrdep.psk2[#encrdep.psk2+1] = {ssid = v.ssid, ["!reverse"] = 1}
+ end
+ if v.wpa or v.wep then
+ encrdep.none[#encrdep.none+1] = {ssid = v.ssid, ["!reverse"] = 1}
+ end
+ end
+end
+
+encr = s:taboption("general", ListValue, "encryption", translate("Encryption"))
+
+
+if hwtype == "mac80211" then
+ s:taboption("expert", Flag, "powersave", "Enable Powersaving")
+elseif hwtype == "atheros" then
+ s:taboption("expert", Flag, "bursting", translate("Allow Burst Transmissions"))
+end
+
+
+
+-- Encryption --
+
+encr.override_values = true
+encr.override_depends = true
+encr:value("none", "No Encryption", unpack(encrdep.none))
+encr:value("wep", "WEP", unpack(encrdep.wep))
+
+if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
+ local supplicant = fs.access("/usr/sbin/wpa_supplicant") or os.getenv("LUCI_SYSROOT")
+ if supplicant then
+ encr:value("psk", "WPA", unpack(encrdep.psk))
+ encr:value("wpa", "WPA-EAP", unpack(encrdep.wpa))
+ encr:value("psk2", "WPA2", unpack(encrdep.psk2))
+ encr:value("wpa2", "WPA2-EAP (802.11i)", unpack(encrdep.wpa2))
+ end
+elseif hwtype == "broadcom" then
+ encr:value("psk", "WPA", unpack(encrdep.psk))
+ encr:value("psk2", "WPA2", unpack(encrdep.psk2))
+end
+
+key = s:taboption("general", Value, "key", translate("Password"))
+key:depends("encryption", "wep")
+key:depends("encryption", "psk")
+key:depends("encryption", "psk2")
+key.rmempty = true
+key.password = true
+
+if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
+ eaptype = s:taboption("general", ListValue, "eap_type", translate("EAP-Method"))
+ eaptype:value("TLS")
+ eaptype:value("TTLS")
+ eaptype:value("PEAP")
+ eaptype:depends({encryption="wpa"})
+ eaptype:depends({encryption="wpa2"})
+
+ cacert = s:taboption("general", FileUpload, "ca_cert", translate("Path to CA-Certificate"))
+ cacert:depends({encryption="wpa"})
+ cacert:depends({encryption="wpa2"})
+
+ privkey = s:taboption("general", FileUpload, "priv_key", translate("Path to Private Key"))
+ privkey:depends({eap_type="TLS", encryption="wpa2"})
+ privkey:depends({eap_type="TLS", encryption="wpa"})
+
+ privkeypwd = s:taboption("general", Value, "priv_key_pwd", translate("Password of Private Key"))
+ privkeypwd:depends({eap_type="TLS", encryption="wpa2"})
+ privkeypwd:depends({eap_type="TLS", encryption="wpa"})
+
+
+ auth = s:taboption("general", Value, "auth", translate("Authentication"))
+ auth:value("PAP")
+ auth:value("CHAP")
+ auth:value("MSCHAP")
+ auth:value("MSCHAPV2")
+ auth:depends({eap_type="PEAP", encryption="wpa2"})
+ auth:depends({eap_type="PEAP", encryption="wpa"})
+ auth:depends({eap_type="TTLS", encryption="wpa2"})
+ auth:depends({eap_type="TTLS", encryption="wpa"})
+
+
+ identity = s:taboption("general", Value, "identity", translate("Identity"))
+ identity:depends({eap_type="PEAP", encryption="wpa2"})
+ identity:depends({eap_type="PEAP", encryption="wpa"})
+ identity:depends({eap_type="TTLS", encryption="wpa2"})
+ identity:depends({eap_type="TTLS", encryption="wpa"})
+
+ password = s:taboption("general", Value, "password", translate("Password"))
+ password:depends({eap_type="PEAP", encryption="wpa2"})
+ password:depends({eap_type="PEAP", encryption="wpa"})
+ password:depends({eap_type="TTLS", encryption="wpa2"})
+ password:depends({eap_type="TTLS", encryption="wpa"})
+end
+
+
+
+
+
+m = Map("network")
+
+s = m:section(NamedSection, "wan", "interface", translate("Address Settings"))
+s.addremove = false
+
+s:tab("general", translate("General Settings"))
+s:tab("expert", translate("Expert Settings"))
+
+p = s:taboption("general", ListValue, "proto", "Connection Type")
+p.override_scheme = true
+p.default = "dhcp"
+p:value("dhcp", "Automatic Configuration (DHCP)")
+p:value("static", "Static Configuration")
+
+
+
+ipaddr = s:taboption("general", Value, "ipaddr", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
+ipaddr.rmempty = true
+ipaddr:depends("proto", "static")
+
+nm = s:taboption("general", Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"))
+nm.rmempty = true
+nm:depends("proto", "static")
+nm:value("255.255.255.0")
+nm:value("255.255.0.0")
+nm:value("255.0.0.0")
+
+gw = s:taboption("general", Value, "gateway", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Gateway"))
+gw:depends("proto", "static")
+gw.rmempty = true
+
+bcast = s:taboption("expert", Value, "bcast", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Broadcast"))
+bcast:depends("proto", "static")
+
+if has_ipv6 then
+ ip6addr = s:taboption("expert", Value, "ip6addr", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Address"), translate("<abbr title=\"Classless Inter-Domain Routing\">CIDR</abbr>-Notation: address/prefix"))
+ ip6addr:depends("proto", "static")
+
+ ip6gw = s:taboption("expert", Value, "ip6gw", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Gateway"))
+ ip6gw:depends("proto", "static")
+end
+
+dns = s:taboption("expert", Value, "dns", translate("<abbr title=\"Domain Name System\">DNS</abbr>-Server"))
+dns:depends("peerdns", "")
+
+mtu = s:taboption("expert", Value, "mtu", "MTU")
+mtu.isinteger = true
+
+mac = s:taboption("expert", Value, "macaddr", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
+
+return m2, m
diff --git a/modules/niu/luasrc/model/cbi/niu/network/wlanwanscan.lua b/modules/niu/luasrc/model/cbi/niu/network/wlanwanscan.lua
new file mode 100644
index 000000000..4035ff415
--- /dev/null
+++ b/modules/niu/luasrc/model/cbi/niu/network/wlanwanscan.lua
@@ -0,0 +1,12 @@
+local t = Template("niu/network/wlanwanscan")
+function t.parse(self, ...)
+ local state = Template.parse(self, ...)
+ if Map.formvalue({readinput = true}, "cbi.delg.back") then
+ return FORM_SKIP
+ end
+ if state == FORM_NODATA then
+ self.delegator.disallow_pageactions = true
+ end
+ return state
+end
+return t \ No newline at end of file
diff --git a/modules/niu/luasrc/model/cbi/niu/traffic/routes1.lua b/modules/niu/luasrc/model/cbi/niu/traffic/routes1.lua
index 094831e72..f09cf076c 100644
--- a/modules/niu/luasrc/model/cbi/niu/traffic/routes1.lua
+++ b/modules/niu/luasrc/model/cbi/niu/traffic/routes1.lua
@@ -12,7 +12,7 @@ You may obtain a copy of the License at
$Id$
]]--
-m = Map("network", translate("Display and Customize Routing"),
+m = Map("network", translate("Manage Traffic Routing"),
translate("With additional static routes you allow computers on your network to reach unannounced remote hosts or networks."))
local routes6 = luci.sys.net.routes6()
diff --git a/modules/niu/luasrc/model/cbi/niu/wireless/ap.lua b/modules/niu/luasrc/model/cbi/niu/wireless/ap.lua
index 54f510dc9..08cc565e2 100644
--- a/modules/niu/luasrc/model/cbi/niu/wireless/ap.lua
+++ b/modules/niu/luasrc/model/cbi/niu/wireless/ap.lua
@@ -2,7 +2,7 @@ local cursor = require "luci.model.uci".cursor()
if not cursor:get("wireless", "ap") then
cursor:section("wireless", "wifi-iface", "ap",
- {device = "_", doth = "1", wmm = "1", _niu = "1", mode = "ap"})
+ {device = "_", doth = "1", _niu = "1", mode = "ap"})
cursor:save("wireless")
end
@@ -15,7 +15,6 @@ local function deviceroute(self)
end)
cursor:set("wireless", d, "disabled", 0)
cursor:set("wireless", "ap", "network", "lan")
- self:set("ap1", load("niu/wireless/ap1"))
self:set_route("ap1")
else
cursor:delete("wireless", "ap", "network")
@@ -29,8 +28,9 @@ d.allow_finish = true
d.allow_back = true
d.allow_cancel = true
-d:add("device", load("niu/wireless/apdevice"))
+d:add("device", "niu/wireless/apdevice")
d:add("deviceroute", deviceroute)
+d:set("ap1", "niu/wireless/ap1")
function d.on_cancel()
cursor:revert("wireless")
diff --git a/modules/niu/luasrc/model/cbi/niu/wireless/ap1.lua b/modules/niu/luasrc/model/cbi/niu/wireless/ap1.lua
index df36eefd8..8df31e82d 100644
--- a/modules/niu/luasrc/model/cbi/niu/wireless/ap1.lua
+++ b/modules/niu/luasrc/model/cbi/niu/wireless/ap1.lua
@@ -234,7 +234,7 @@ encr.default = "wep" -- Early default
encr.override_values = true
encr.override_depends = true
encr:value("none", "No Encryption")
-encr:value("wep", "WEP", {mode="ap"}, {mode="sta"})
+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")
diff --git a/modules/niu/luasrc/model/cbi/niu/wireless/apdevice.lua b/modules/niu/luasrc/model/cbi/niu/wireless/apdevice.lua
index 930371e98..b9e0fa517 100644
--- a/modules/niu/luasrc/model/cbi/niu/wireless/apdevice.lua
+++ b/modules/niu/luasrc/model/cbi/niu/wireless/apdevice.lua
@@ -11,10 +11,7 @@ You may obtain a copy of the License at
$Id$
]]--
-
-local iwinfo = require "iwinfo"
-local cursor = require "luci.model.uci".inst
-cursor:unload("wireless")
+local niulib = require "luci.niulib"
m = Map("wireless", "Configure Private Access Point")
s = m:section(NamedSection, "ap", "interface", "Wireless Radio Device",
@@ -27,25 +24,9 @@ s.addremove = false
l = s:option(ListValue, "device", "Device providing Access Point")
-local used = {}
-cursor:foreach("wireless", "wifi-iface", function(s)
- if s[".name"] ~= "ap" and s._niu == 1 then
- used[s.device] = 1
- end
-end)
-
-for k in pairs(used) do
- local t = iwinfo.type(k)
- if t and iwinfo[t] then
- used[k] = (iwinfo[t].mbssid_support() < 1)
- end
+for _, wifi in ipairs(niulib.wifi_get_available("ap")) do
+ l:value(wifi, "WLAN-Adapter (%s)" % wifi)
end
-
-cursor:foreach("wireless", "wifi-device", function(s)
- if not used[s[".name"]] then
- l:value(s[".name"], "Radio %s" % s[".name"])
- end
-end)
l:value("none", "Disable Private Access Point")
return m
diff --git a/modules/niu/luasrc/niulib.lua b/modules/niu/luasrc/niulib.lua
new file mode 100644
index 000000000..2a4635553
--- /dev/null
+++ b/modules/niu/luasrc/niulib.lua
@@ -0,0 +1,65 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2009 Steven Barth <steven@midlink.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+]]--
+
+local ipairs, pairs, require = ipairs, pairs, require
+local os = require "os"
+
+local cursor = require "luci.model.uci".inst
+
+
+module "luci.niulib"
+
+function eth_get_available(except)
+ local nw = require "luci.model.network"
+ nw.init(cursor)
+
+ local ifs = {}
+ for _, iface in ipairs(nw.get_interfaces()) do
+ if iface:name():find("eth") == 1 then
+ local net = iface:get_network()
+ if not net or net:name() == except or os.getenv("LUCI_SYSROOT") then
+ ifs[#ifs+1] = iface:name()
+ end
+ end
+ end
+ return ifs
+end
+
+function wifi_get_available(except)
+ cursor:unload("wireless")
+
+ local iwinfo = require "iwinfo"
+ local used = {}
+ cursor:foreach("wireless", "wifi-iface", function(s)
+ if s[".name"] ~= except and s._niu == 1 then
+ used[s.device] = 1
+ end
+ end)
+
+ for k in pairs(used) do
+ local t = iwinfo.type(k)
+ if t and iwinfo[t] then
+ used[k] = (iwinfo[t].mbssid_support() < 1)
+ end
+ end
+
+ local wifis = {}
+ cursor:foreach("wireless", "wifi-device", function(s)
+ if not used[s[".name"]] then
+ wifis[#wifis+1] = s[".name"]
+ end
+ end)
+ return wifis
+end
+
diff --git a/modules/niu/luasrc/view/niu/network/wlanwanscan.htm b/modules/niu/luasrc/view/niu/network/wlanwanscan.htm
new file mode 100644
index 000000000..f02b32ff5
--- /dev/null
+++ b/modules/niu/luasrc/view/niu/network/wlanwanscan.htm
@@ -0,0 +1,7 @@
+<div style="margin: auto">
+<h2>Scanning for wireless networks in range</h2>
+<div>This may take a few seconds. Please wait...</div>
+</div>
+<script type="text/javascript">
+setTimeout(function() { document.forms.cbi.submit(); }, 100);
+</script> \ No newline at end of file