NIU:
[project/luci.git] / modules / niu / luasrc / model / cbi / niu / network / lan1.lua
index 727526b..e4005bb 100644 (file)
@@ -13,94 +13,107 @@ You may obtain a copy of the License at
 $Id$
 ]]--
 
-local nw = require "luci.model.network"
-local fw = require "luci.model.firewall"
+local niulib = require "luci.niulib"
+local fs = require "nixio.fs"
+local has_ipv6 = fs.access("/proc/net/ipv6_route")
 
-local has_ipv6 = nw:has_ipv6()
+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.")
 
-m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
-m:chain("firewall")
-
-nw.init(m.uci)
-fw.init(m.uci)
-
-s = m:section(NamedSection, "lan", "interface")
+s = m:section(NamedSection, "lan", "interface", "Network Settings")
 s.addremove = false
 
-s:tab("general", translate("niu_general", "General Settings"))
+s:tab("general", translate("General Settings"))
 
-ipaddr = s:taboption("general", Value, "ipaddr", translate("ipaddress"))
+ipaddr = s:taboption("general", Value, "ipaddr", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
+ipaddr.default = "192.168.0.1"
+ipaddr:depends("proto", "static")
 
-nm = s:taboption("general", Value, "netmask", translate("netmask"))
+nm = s:taboption("general", Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"))
+nm.default = "255.255.255.0"
 nm:value("255.255.255.0")
 nm:value("255.255.0.0")
 nm:value("255.0.0.0")
+nm:depends("proto", "static")
+
 
 
+s:tab("expert", translate("Expert Settings"))
 
-s:tab("expert", translate("niu_expert", "Expert Settings"))
+p = s:taboption("expert", ListValue, "proto", translate("Connection Protocol"))
+p.default = "static"
+p:value("dhcp", "DHCP")
+p:value("static", translate("Static Ethernet"))
 
-mac = s:taboption("expert", Value, "macaddr", translate("macaddress"))
+mac = s:taboption("expert", Value, "macaddr", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
 
 mtu = s:taboption("expert", Value, "mtu", "MTU")
 mtu.isinteger = true
 
-dns = s:taboption("expert", Value, "dns", translate("dnsserver"))
+dns = s:taboption("expert", Value, "dns", translate("<abbr title=\"Domain Name System\">DNS</abbr>-Server"))
 dns:depends("peerdns", "")
 
 
-gw = s:taboption("expert", Value, "gateway", translate("gateway"))
-bcast = s:taboption("expert", Value, "bcast", translate("broadcast"))
+gw = s:taboption("expert", Value, "gateway", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Gateway"))
+gw:depends("proto", "static")
+
+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("ip6address"), translate("cidr6"))
-       ip6gw = s:taboption("expert", Value, "ip6gw", translate("gateway6"))
+       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
 
+emerg = s:taboption("expert", Value, "_emergv4", translate("Emergency Access Address"))
+emerg:depends("proto", "dhcp")
+emerg.default = "169.254.255.169"
 
-br = s:taboption("expert", Flag, "type", translate("a_n_i_bridge"), translate("a_n_i_bridge1"))
-br.enabled = "bridge"
-br.rmempty = true
-
-stp = s:taboption("expert", Flag, "stp", translate("a_n_i_stp"),
-       translate("a_n_i_stp1", "Enables the Spanning Tree Protocol on this bridge"))
-stp:depends("type", "1")
-stp.rmempty = true
 
-ifname_single = s:taboption("expert", Value, "ifname_single", translate("interface"))
-ifname_single.template = "cbi/network_ifacelist"
-ifname_single.widget = "radio"
-ifname_single.nobridges = true
-ifname_single.rmempty = true
-ifname_single:depends("type", "")
+stp = s:taboption("expert", Flag, "stp", translate("Enable <abbr title=\"Spanning Tree Protocol\">STP</abbr>"),
+       translate("Enables the Spanning Tree Protocol on this bridge"))
 
-function ifname_single.cfgvalue(self, s)
-       return self.map.uci:get("network", s, "ifname")
+ifname_multi = s:taboption("expert", MultiValue, "ifname", translate("Interface"))
+ifname_multi.widget = "checkbox"
+for _, eth in ipairs(niulib.eth_get_available("lan")) do
+       ifname_multi:value(eth, translate("Ethernet-Adapter (%s)") % eth)
 end
 
-function ifname_single.write(self, s, val)
-       local n = nw:get_network(s)
-       if n then n:ifname(val) end
-end
 
 
-ifname_multi = s:taboption("expert", MultiValue, "ifname_multi", translate("interface"))
-ifname_multi.template = "cbi/network_ifacelist"
-ifname_multi.nobridges = true
-ifname_multi.widget = "checkbox"
-ifname_multi:depends("type", "1")
-ifname_multi.cfgvalue = ifname_single.cfgvalue
-ifname_multi.write = ifname_single.write
-
-for _, d in ipairs(nw:get_interfaces()) do
-       if not d:is_bridge() then
-               ifname_single:value(d:name())
-               ifname_multi:value(d:name())
-       end
-end
+m2 = Map("dhcp")
+
+s = m2:section(TypedSection, "dhcp", "DHCP")
+s.anonymous = true
+s.addremove = false
+s.dynamic = false
+
+s:tab("general", translate("General Settings"))
+
+s:depends("interface", "lan")
+
+enable = s:taboption("general", ListValue, "ignore", "Automatic address assignment for network devices", "")
+enable:value(0, translate("enable"), {["network.lan.proto"] = "static"})
+enable:value(1, translate("disable"))
+
+
+s:tab("expert", translate("Expert Settings"))
+start = s:taboption("expert", Value, "start", translate("First leased address"))
+start:depends("ignore", "0")
+
+limit = s:taboption("expert", Value, "limit", translate("Number of leased addresses"), "")
+limit:depends("ignore", "0")
 
+time = s:taboption("expert", Value, "leasetime", "Lease Time")
+time:depends("ignore", "0")
 
+local dd = s:taboption("expert", Flag, "dynamicdhcp", "Also generate addresses for unknown devices")
+dd.rmempty = false
+dd.default = "1"
+dd:depends("ignore", "0")
 
 
-return m
+return m, m2