summaryrefslogtreecommitdiffhomepage
path: root/modules/niu
diff options
context:
space:
mode:
Diffstat (limited to 'modules/niu')
-rw-r--r--modules/niu/COPYING.icons48
-rw-r--r--modules/niu/luasrc/controller/niu/wireless.lua7
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/etherwan.lua2
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/lan.lua1
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/lan1.lua3
-rw-r--r--modules/niu/luasrc/model/cbi/niu/wireless/ap.lua43
-rw-r--r--modules/niu/luasrc/model/cbi/niu/wireless/ap1.lua268
-rw-r--r--modules/niu/luasrc/model/cbi/niu/wireless/apdevice.lua51
-rw-r--r--modules/niu/luasrc/view/niu/network.htm2
9 files changed, 421 insertions, 4 deletions
diff --git a/modules/niu/COPYING.icons b/modules/niu/COPYING.icons
new file mode 100644
index 0000000000..c87ac56a2b
--- /dev/null
+++ b/modules/niu/COPYING.icons
@@ -0,0 +1,48 @@
+The Oxygen Icon Theme
+ Copyright (C) 2007 David Vignoni <david@icon-king.com>
+ Copyright (C) 2007 Johann Ollivier Lapeyre <johann@oxygen-icons.org>
+ Copyright (C) 2007 Kenneth Wimer <kwwii@bootsplash.org>
+ Copyright (C) 2007 Nuno Fernades Pinheiro <nf.pinheiro@gmail.com>
+ Copyright (C) 2007 Riccardo Iaconelli <riccardo@oxygen-icons.org>
+ Copyright (C) 2007 David Miller <miller@oxygen-icons.org>
+
+and others
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+Clarification:
+
+ The GNU Lesser General Public License or LGPL is written for
+ software libraries in the first place. We expressly want the LGPL to
+ be valid for this artwork library too.
+
+ KDE Oxygen theme icons is a special kind of software library, it is an
+ artwork library, it's elements can be used in a Graphical User Interface, or
+ GUI.
+
+ Source code, for this library means:
+ - where they exist, SVG;
+ - otherwise, if applicable, the multi-layered formats xcf or psd, or
+ otherwise png.
+
+ The LGPL in some sections obliges you to make the files carry
+ notices. With images this is in some cases impossible or hardly useful.
+
+ With this library a notice is placed at a prominent place in the directory
+ containing the elements. You may follow this practice.
+
+ The exception in section 5 of the GNU Lesser General Public License covers
+ the use of elements of this art library in a GUI.
+
+ kde-artists [at] kde.org
diff --git a/modules/niu/luasrc/controller/niu/wireless.lua b/modules/niu/luasrc/controller/niu/wireless.lua
index f508abad55..4781426292 100644
--- a/modules/niu/luasrc/controller/niu/wireless.lua
+++ b/modules/niu/luasrc/controller/niu/wireless.lua
@@ -16,6 +16,11 @@ local require = require
module "luci.controller.niu.wireless"
function index()
+ if not fs.access("/etc/config/wireless") then
+ return
+ end
+
+
local toniu = {on_success_to={"niu"}}
local e = entry({"niu", "wireless"}, alias("niu"), "Wireless", 20)
@@ -24,5 +29,5 @@ function index()
e.niu_dbicon = "icons32/network-wireless.png"
entry({"niu", "wireless", "ap"},
- cbi("niu/network/ap", toniu), "Configure Private Access Point", 1)
+ cbi("niu/wireless/ap", toniu), "Configure Private Access Point", 1)
end \ No newline at end of file
diff --git a/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua b/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua
index 4f2744b816..c5fda15821 100644
--- a/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua
+++ b/modules/niu/luasrc/model/cbi/niu/network/etherwan.lua
@@ -23,7 +23,7 @@ local has_pppoe = fs.glob("/usr/lib/pppd/*/rp-pppoe.so")()
local has_pppoa = fs.glob("/usr/lib/pppd/*/pppoatm.so")()
-m = Map("network", "Configure Ethernet Adapter")
+m = Map("network", "Configure Ethernet Adapter for Internet Connection")
nw.init(m.uci)
s = m:section(NamedSection, "wan", "interface")
diff --git a/modules/niu/luasrc/model/cbi/niu/network/lan.lua b/modules/niu/luasrc/model/cbi/niu/network/lan.lua
index 6f6237e608..45f2381083 100644
--- a/modules/niu/luasrc/model/cbi/niu/network/lan.lua
+++ b/modules/niu/luasrc/model/cbi/niu/network/lan.lua
@@ -20,6 +20,7 @@ function d.on_done()
cs:save("network")
end
+ cursor:set("network", "lan", "type", "bridge")
cursor:commit("network")
cursor:commit("dhcp")
end
diff --git a/modules/niu/luasrc/model/cbi/niu/network/lan1.lua b/modules/niu/luasrc/model/cbi/niu/network/lan1.lua
index e8069d5b31..7b810b8f44 100644
--- a/modules/niu/luasrc/model/cbi/niu/network/lan1.lua
+++ b/modules/niu/luasrc/model/cbi/niu/network/lan1.lua
@@ -17,7 +17,8 @@ local nw = require "luci.model.network"
local has_ipv6 = nw:has_ipv6()
-m = Map("network", "Local Network")
+m = Map("network", "Configure Local Network", "These settings affect the devices in your local network. "..
+"Usually you do not need to change anything here for your router to work correctly.")
nw.init(m.uci)
diff --git a/modules/niu/luasrc/model/cbi/niu/wireless/ap.lua b/modules/niu/luasrc/model/cbi/niu/wireless/ap.lua
new file mode 100644
index 0000000000..aa6ffbd637
--- /dev/null
+++ b/modules/niu/luasrc/model/cbi/niu/wireless/ap.lua
@@ -0,0 +1,43 @@
+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"})
+ cursor:save("wireless")
+end
+
+local function deviceroute(self)
+ cursor:unload("wireless")
+ local d = cursor:get("wireless", "ap", "device")
+ if d ~= "none" then
+ cursor:delete_all("wireless", "wifi-iface", function(s)
+ return s.device == d and s._niu ~= "1"
+ 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")
+ end
+ cursor:save("wireless")
+end
+
+
+local d = Delegator()
+d.allow_finish = true
+d.allow_back = true
+d.allow_cancel = true
+
+d:add("device", load("niu/wireless/apdevice"))
+d:add("deviceroute", deviceroute)
+
+function d.on_cancel()
+ cursor:revert("wireless")
+end
+
+function d.on_done()
+ cursor:commit("wireless")
+end
+
+return d \ No newline at end of file
diff --git a/modules/niu/luasrc/model/cbi/niu/wireless/ap1.lua b/modules/niu/luasrc/model/cbi/niu/wireless/ap1.lua
new file mode 100644
index 0000000000..f6ce258be2
--- /dev/null
+++ b/modules/niu/luasrc/model/cbi/niu/wireless/ap1.lua
@@ -0,0 +1,268 @@
+--[[
+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 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", "ap", "device")
+local hwtype = cursor:get("wireless", device, "type")
+
+local nsantenna = cursor:get("wireless", device, "antenna")
+
+local iw = nil
+local tx_powers = nil
+local chan = sys.wifi.channels()
+
+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)
+ tx_powers = iw.txpwrlist or { }
+ end
+ end)
+
+m = Map("wireless", "Configure Access Point",
+"The private Access Point is about to be created. You only need to provide "..
+"a network name and a password to finish this step and - if you like - tweak "..
+"some of the advanced settings.")
+
+--- Device Settings ---
+s = m:section(NamedSection, device, "wifi-device", "Device Configuration")
+s.addremove = false
+
+s:tab("general", translate("General Settings"))
+
+ch = s:taboption("general", Value, "channel", translate("Channel"))
+ch:value("auto", translate("automatic"))
+for _, f in ipairs(chan) do
+ ch:value(f.channel, "%i (%.3f GHz)" %{ f.channel, f.mhz })
+end
+
+
+
+s:tab("expert", translate("Expert Settings"))
+if hwtype == "mac80211" then
+ tp = s:taboption("expert",
+ (tx_powers and #tx_powers > 0) and ListValue or Value,
+ "txpower", translate("Transmission Power"), "dBm")
+
+ tp.rmempty = true
+ tp:value("", translate("automatic"))
+ for _, p in ipairs(iw and iw.txpwrlist or {}) do
+ tp:value(p.dbm, "%i dBm (%i mW)" %{ p.dbm, p.mw })
+ end
+elseif hwtype == "atheros" then
+ tp = s:taboption("expert",
+ (#tx_powers > 0) and ListValue or Value,
+ "txpower", translate("Transmission Power"), "dBm")
+
+ tp.rmempty = true
+ tp:value("", translate("automatic"))
+ for _, p in ipairs(iw.txpwrlist) do
+ tp:value(p.dbm, "%i dBm (%i mW)" %{ p.dbm, p.mw })
+ end
+
+ mode = s:taboption("expert", ListValue, "hwmode", translate("Communication Protocol"))
+ mode:value("", translate("automatic"))
+ mode:value("11g", "802.11g")
+ mode:value("11b", "802.11b")
+ mode:value("11bg", "802.11b+g")
+ mode:value("11a", "802.11a")
+ mode:value("11gst", "802.11g + Turbo")
+ mode:value("11ast", "802.11a + Turbo")
+
+ if nsantenna then -- NanoFoo
+ local ant = s:taboption("expert", ListValue, "antenna", translate("Transmitter Antenna"))
+ ant:value("auto")
+ ant:value("vertical")
+ ant:value("horizontal")
+ ant:value("external")
+ ant.default = "auto"
+ end
+elseif hwtype == "broadcom" then
+ tp = s:taboption("expert",
+ (#tx_powers > 0) and ListValue or Value,
+ "txpower", translate("Transmit Power"), "dBm")
+
+ tp.rmempty = true
+ tp:value("", translate("automatic"))
+ for _, p in ipairs(iw.txpwrlist) do
+ tp:value(p.dbm, "%i dBm (%i mW)" %{ p.dbm, p.mw })
+ end
+
+ mp = s:taboption("expert", ListValue, "macfilter", translate("MAC-Address Filter"))
+ mp:value("", translate("disable"))
+ mp:value("allow", translate("Allow listed only"))
+ mp:value("deny", translate("Allow all except listed"))
+ ml = s:taboption("expert", DynamicList, "maclist", translate("MAC-List"))
+ ml:depends({macfilter="allow"})
+ ml:depends({macfilter="deny"})
+
+ s:taboption("expert", Flag, "frameburst", translate("Allow Burst Transmissions"))
+elseif hwtype == "prism2" then
+ s:taboption("expert", Value, "txpower", translate("Transmission Power"), "att units").rmempty = true
+end
+
+
+
+
+s = m:section(NamedSection, "ap", "wifi-iface", "Access Point Details")
+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>)"))
+
+mode = s:taboption("expert", ListValue, "mode", translate("Operating Mode"))
+mode.override_values = true
+mode:value("ap", translate("Access Point"))
+
+encr = s:taboption("expert", ListValue, "encryption", translate("Encryption"))
+
+
+if hwtype == "mac80211" then
+ -- Empty
+elseif hwtype == "atheros" then
+ mode:value("ap-wds", "%s (%s)" % {translate("Access Point"), translate("WDS")})
+ mode:value("wds", translate("Static WDS"))
+
+ function mode.write(self, section, value)
+ if value == "ap-wds" then
+ ListValue.write(self, section, "ap")
+ self.map:set(section, "wds", 1)
+ else
+ ListValue.write(self, section, value)
+ self.map:del(section, "wds")
+ end
+ end
+
+ function mode.cfgvalue(self, section)
+ local mode = ListValue.cfgvalue(self, section)
+ local wds = self.map:get(section, "wds") == "1"
+ return mode == "ap" and wds and "ap-wds" or mode
+ end
+
+ mp = s:taboption("expert", ListValue, "macpolicy", translate("MAC-Address Filter"))
+ mp:value("", translate("disable"))
+ mp:value("deny", translate("Allow listed only"))
+ mp:value("allow", translate("Allow all except listed"))
+ ml = s:taboption("expert", DynamicList, "maclist", translate("MAC-List"))
+ ml:depends({macpolicy="allow"})
+ ml:depends({macpolicy="deny"})
+
+
+ hidden = s:taboption("expert", Flag, "hidden", translate("Hide Access Point"))
+ hidden:depends({mode="ap"})
+ hidden:depends({mode="ap-wds"})
+
+ isolate = s:taboption("expert", Flag, "isolate", translate("Prevent communication between clients"))
+ isolate:depends({mode="ap"})
+
+ s:taboption("expert", Flag, "bursting", translate("Allow Burst Transmissions"))
+elseif hwtype == "broadcom" then
+ mode:value("wds", translate("WDS"))
+
+ hidden = s:taboption("expert", Flag, "hidden", translate("Hide Access Point"))
+ hidden:depends({mode="ap"})
+ hidden:depends({mode="wds"})
+
+ isolate = s:taboption("expert", Flag, "isolate", translate("Prevent communication between clients"))
+ isolate:depends({mode="ap"})
+elseif hwtype == "prism2" then
+ mode:value("wds", translate("WDS"))
+
+ mp = s:taboption("expert", ListValue, "macpolicy", translate("MAC-Address Filter"))
+ mp:value("", translate("disable"))
+ mp:value("deny", translate("Allow listed only"))
+ mp:value("allow", translate("Allow all except listed"))
+
+ ml = s:taboption("expert", DynamicList, "maclist", translate("MAC-List"))
+ ml:depends({macpolicy="allow"})
+ ml:depends({macpolicy="deny"})
+
+ hidden = s:taboption("expert", Flag, "hidden", translate("Hide Access Point"))
+ hidden:depends({mode="ap"})
+ hidden:depends({mode="wds"})
+end
+
+-- Encryption --
+
+
+encr.override_values = true
+encr.override_depends = true
+encr:value("none", "No Encryption")
+encr:value("wep", "WEP", {mode="ap"}, {mode="sta"}, {mode="ap-wds"})
+
+if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
+ local hostapd = fs.access("/usr/sbin/hostapd") or os.getenv("LUCI_SYSROOT")
+
+ if hostapd then
+ --s:taboption("expert", Flag, "_alloweap", "Allow EAP / 802.11i authentication")
+
+ encr:value("psk", "WPA", {mode="ap"}, {mode="ap-wds"})
+ encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="ap-wds"})
+ encr:value("psk-mixed", "WPA + WPA2", {mode="ap"}, {mode="ap-wds"})
+ encr:value("psk2", "WPA2", {mode="ap"}, {mode="ap-wds"})
+ encr:value("wpa2", "WPA2-EAP (802.11i)", {mode="ap"}, {mode="ap-wds"})
+ encr.default = "psk-mixed"
+ end
+elseif hwtype == "broadcom" then
+ encr:value("psk", "WPA")
+ encr:value("psk+psk2", "WPA + WPA2")
+ encr:value("psk2", "WPA2")
+ encr.default = "psk+psk2"
+end
+
+server = s:taboption("general", Value, "server", translate("Radius-Server"))
+server:depends({mode="ap", encryption="wpa"})
+server:depends({mode="ap", encryption="wpa2"})
+server:depends({mode="ap-wds", encryption="wpa"})
+server:depends({mode="ap-wds", encryption="wpa2"})
+server.rmempty = true
+
+port = s:taboption("general", Value, "port", translate("Radius-Port"))
+port:depends({mode="ap", encryption="wpa"})
+port:depends({mode="ap", encryption="wpa2"})
+port:depends({mode="ap-wds", encryption="wpa"})
+port:depends({mode="ap-wds", encryption="wpa2"})
+port.rmempty = true
+
+key = s:taboption("general", Value, "key", translate("Password"))
+key:depends("encryption", "wep")
+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
+
+if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
+ nasid = s:taboption("general", 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
+end
+return m
diff --git a/modules/niu/luasrc/model/cbi/niu/wireless/apdevice.lua b/modules/niu/luasrc/model/cbi/niu/wireless/apdevice.lua
new file mode 100644
index 0000000000..930371e981
--- /dev/null
+++ b/modules/niu/luasrc/model/cbi/niu/wireless/apdevice.lua
@@ -0,0 +1,51 @@
+--[[
+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 iwinfo = require "iwinfo"
+local cursor = require "luci.model.uci".inst
+cursor:unload("wireless")
+
+m = Map("wireless", "Configure Private Access Point")
+s = m:section(NamedSection, "ap", "interface", "Wireless Radio Device",
+"Select the wireless radio device that should be used to run the access"..
+" point. Note that wireless radios will not show up here if you already use"..
+" them for connecting to the Internet and are not capable of being used as"..
+" an access point in parallel.")
+s.anonymous = true
+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
+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/view/niu/network.htm b/modules/niu/luasrc/view/niu/network.htm
index f61e3e1f6e..e49c930657 100644
--- a/modules/niu/luasrc/view/niu/network.htm
+++ b/modules/niu/luasrc/view/niu/network.htm
@@ -35,7 +35,7 @@ uci.inst:foreach("dhcp", "dnsmasq",
)
if leasefn then
- local ln = io.lines(leasefn)
+ local ln = fs.access(leasefn, "r") and io.lines(leasefn)
leasefn = 0
while ln and ln() do
leasefn = leasefn + 1