X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fniu%2Fluasrc%2Fmodel%2Fcbi%2Fniu%2Fnetwork%2Flan1.lua;h=62795da15c04ec3f6390987539a09dec6191cab0;hp=33bb48c230f6c5a532f1b13be67dc9b5000741ba;hb=5be59e6ae7a496a695c5dd533b0b48bb172ec821;hpb=6122dc723a36ec88e18949d93f3ec50c36eab4b8 diff --git a/modules/niu/luasrc/model/cbi/niu/network/lan1.lua b/modules/niu/luasrc/model/cbi/niu/network/lan1.lua index 33bb48c23..62795da15 100644 --- a/modules/niu/luasrc/model/cbi/niu/network/lan1.lua +++ b/modules/niu/luasrc/model/cbi/niu/network/lan1.lua @@ -13,93 +13,119 @@ You may obtain a copy of the License at $Id$ ]]-- -local nw = require "luci.model.network" - -local has_ipv6 = nw:has_ipv6() - -m = Map("network", translate("m_n_lan")) +local bridge = (arg[1] == "bridgelan") +local niulib = require "luci.niulib" +local fs = require "nixio.fs" +local has_ipv6 = fs.access("/proc/net/ipv6_route") + +m = Map("network", translate("Configure Local Network"), bridge and +translate([[The wireless network will be connected directly to your local network. +Make sure you to assign any address to this device that is in the same subnet +of the other devices in your network but that is not already occupied. +If you have a DHCP-Server in this network you may also choose DHCP for address configuration.]]) +or translate("These settings affect the devices in your local network. ".. +"Usually you do not need to change anything here for this device to work correctly.")) + +s = m:section(NamedSection, "lan", "interface", "Network Settings") +s.addremove = false -nw.init(m.uci) +s:tab("general", translate("General Settings")) +s:tab("expert", translate("Expert Settings")) -s = m:section(NamedSection, "lan", "interface") -s.addremove = false +p = s:taboption("expert", ListValue, "proto", translate("Address Configuration")) +p.default = "static" +p:value("static", translate("Static Configuration")) +p:value("dhcp", "DHCP") -s:tab("general", translate("niu_general", "General Settings")) -ipaddr = s:taboption("general", Value, "ipaddr", translate("ipaddress")) +ipaddr = s:taboption("general", Value, "ipaddr", translate("IPv4-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("IPv4-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("niu_expert", "Expert Settings")) - -mac = s:taboption("expert", Value, "macaddr", translate("macaddress")) +mac = s:taboption("expert", Value, "macaddr", translate("MAC-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("DNS-Server")) dns:depends("peerdns", "") -gw = s:taboption("expert", Value, "gateway", translate("gateway")) -bcast = s:taboption("expert", Value, "bcast", translate("broadcast")) +gw = s:taboption(bridge and "general" or "expert", Value, "gateway", translate("IPv4-Gateway")) +gw:depends("proto", "static") + +bcast = s:taboption("expert", Value, "bcast", translate("IPv4-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("IPv6-Address"), translate("CIDR-Notation: address/prefix")) + ip6addr:depends("proto", "static") + ip6gw = s:taboption("expert", Value, "ip6gw", translate("IPv6-Gateway")) + ip6gw:depends("proto", "static") end +emerg = s:taboption("expert", Value, "_emergv4", translate("Emergency Access Address"), +translate([[In case the DHCP request fails you will still be able to access this device using given IP +by configuring your computer to an address in the same subnet and netmask 255.255.255.0.]])) +emerg:depends("proto", "dhcp") +emerg:value("", translate("disable")) +emerg.default = "169.254.255.169" -stp = s:taboption("expert", Flag, "stp", translate("a_n_i_stp"), - translate("a_n_i_stp1", "Enables the Spanning Tree Protocol on this bridge")) -ifname_multi = s:taboption("expert", MultiValue, "ifname_multi", translate("interface")) -ifname_multi.template = "cbi/network_ifacelist" -ifname_multi.nobridges = true -ifname_multi.widget = "checkbox" +stp = s:taboption("expert", Flag, "stp", translate("Enable STP"), + translate("Enables the Spanning Tree Protocol on this bridge")) -function ifname_multi.cfgvalue(self, s) - return self.map.uci:get("network", s, "ifname") -end - -function ifname_multi.write(self, s, val) - local n = nw:get_network(s) - if n then n:ifname(val) end -end - -for _, d in ipairs(nw:get_interfaces()) do - if not d:is_bridge() then - ifname_multi:value(d:name()) - end +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 -m2 = Map("dhcp", "DHCP") +m2 = Map("dhcp") -s = m2:section(TypedSection, "dhcp", "DHCP-Server") +s = m2:section(TypedSection, "dhcp", "DHCP") s.anonymous = true s.addremove = false s.dynamic = false -s:tab("general", translate("niu_general", "General Settings")) +s:tab("general", translate("General Settings")) s:depends("interface", "lan") -enable = s:taboption("general", ListValue, "ignore", translate("enable"), "") -enable:value(0, translate("enable")) +enable = s:taboption("general", ListValue, "ignore", translate("Automatic address assignment for network devices"), +bridge and +translate("Note: Be careful that you do not accidently two DHCP servers in the same network with overlapping address ranges.") +or "") +enable:value(0, translate("enable"), {["network.lan.proto"] = "static"}) enable:value(1, translate("disable")) -s:tab("expert", translate("niu_expert", "Expert Settings")) -start = s:taboption("expert", Value, "start", translate("m_n_d_firstaddress")) -limit = s:taboption("expert", Value, "limit", translate("m_n_d_numleases"), "") -time = s:taboption("expert", Value, "leasetime") +s:tab("expert", translate("Expert Settings")) +start = s:taboption("expert", Value, "start", translate("First leased address")) +start:depends("ignore", "0") +start.default = "100" + +limit = s:taboption("expert", Value, "limit", translate("Number of leased addresses"), "") +limit:depends("ignore", "0") +limit.default = "150" + +time = s:taboption("expert", Value, "leasetime", translate("Lease Time")) +time:depends("ignore", "0") +time.default = "12h" +local dd = s:taboption("expert", Flag, "dynamicdhcp", translate("Also generate addresses for unknown devices")) +dd.rmempty = false +dd.default = "1" +dd:depends("ignore", "0") -return m, m2 +return m, m2 \ No newline at end of file