2 LuCI - Lua Configuration Interface
4 Copyright 2009 Steven Barth <steven@midlink.org>
5 Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
16 local nw = require "luci.model.network"
17 local fw = require "luci.model.firewall"
19 local has_ipv6 = nw:has_ipv6()
21 m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
27 s = m:section(NamedSection, "lan", "interface")
30 s:tab("general", translate("niu_general", "General Settings"))
32 ipaddr = s:taboption("general", Value, "ipaddr", translate("ipaddress"))
34 nm = s:taboption("general", Value, "netmask", translate("netmask"))
35 nm:value("255.255.255.0")
36 nm:value("255.255.0.0")
41 s:tab("expert", translate("niu_expert", "Expert Settings"))
43 mac = s:taboption("expert", Value, "macaddr", translate("macaddress"))
45 mtu = s:taboption("expert", Value, "mtu", "MTU")
48 dns = s:taboption("expert", Value, "dns", translate("dnsserver"))
49 dns:depends("peerdns", "")
52 gw = s:taboption("expert", Value, "gateway", translate("gateway"))
53 bcast = s:taboption("expert", Value, "bcast", translate("broadcast"))
57 ip6addr = s:taboption("expert", Value, "ip6addr", translate("ip6address"), translate("cidr6"))
58 ip6gw = s:taboption("expert", Value, "ip6gw", translate("gateway6"))
62 br = s:taboption("expert", Flag, "type", translate("a_n_i_bridge"), translate("a_n_i_bridge1"))
66 stp = s:taboption("expert", Flag, "stp", translate("a_n_i_stp"),
67 translate("a_n_i_stp1", "Enables the Spanning Tree Protocol on this bridge"))
68 stp:depends("type", "1")
71 ifname_single = s:taboption("expert", Value, "ifname_single", translate("interface"))
72 ifname_single.template = "cbi/network_ifacelist"
73 ifname_single.widget = "radio"
74 ifname_single.nobridges = true
75 ifname_single.rmempty = true
76 ifname_single:depends("type", "")
78 function ifname_single.cfgvalue(self, s)
79 return self.map.uci:get("network", s, "ifname")
82 function ifname_single.write(self, s, val)
83 local n = nw:get_network(s)
84 if n then n:ifname(val) end
88 ifname_multi = s:taboption("expert", MultiValue, "ifname_multi", translate("interface"))
89 ifname_multi.template = "cbi/network_ifacelist"
90 ifname_multi.nobridges = true
91 ifname_multi.widget = "checkbox"
92 ifname_multi:depends("type", "1")
93 ifname_multi.cfgvalue = ifname_single.cfgvalue
94 ifname_multi.write = ifname_single.write
96 for _, d in ipairs(nw:get_interfaces()) do
97 if not d:is_bridge() then
98 ifname_single:value(d:name())
99 ifname_multi:value(d:name())