2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
14 m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
16 s = m:section(TypedSection, "interface", translate("interfaces"))
17 function s.filter(self, section)
18 return section ~= "loopback" and
19 (not arg or not arg[1] or arg[1] == section)
22 if not arg or not arg[1] then
25 s:depends("proto", "static")
26 s:depends("proto", "dhcp")
28 p = s:option(ListValue, "proto", translate("protocol"))
29 p:value("static", translate("static"))
30 p:value("dhcp", "DHCP")
33 br = s:option(Flag, "type", translate("a_n_i_bridge"), translate("a_n_i_bridge1"))
37 ifname = s:option(Value, "ifname", translate("interface"))
39 for i,d in ipairs(luci.sys.net.devices()) do
46 ipaddr = s:option(Value, "ipaddr", translate("ipaddress"))
48 ipaddr:depends("proto", "static")
50 nm = s:option(Value, "netmask", translate("netmask"))
52 nm:depends("proto", "static")
53 nm:value("255.255.255.0")
54 nm:value("255.255.0.0")
57 gw = s:option(Value, "gateway", translate("gateway"))
58 gw:depends("proto", "static")
61 bcast = s:option(Value, "bcast", translate("broadcast"))
62 bcast:depends("proto", "static")
65 ip6addr = s:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
66 ip6addr.optional = true
67 ip6addr:depends("proto", "static")
69 ip6gw = s:option(Value, "ip6gw", translate("gateway6"))
70 ip6gw:depends("proto", "static")
73 dns = s:option(Value, "dns", translate("dnsserver"))
74 dns:depends("proto", "static")
77 mtu = s:option(Value, "mtu", "MTU")
81 mac = s:option(Value, "macaddr", translate("macaddress"))
87 s2 = m:section(TypedSection, "alias", translate("aliases"))
90 if arg and arg[1] and luci.model.uci.get("network", arg[1]) then
91 s2:depends("interface", arg[1])
92 s2.defaults.interface = arg[1]
94 parent = s2:option(ListValue, "interface", translate("interface"))
95 luci.model.uci.foreach("network", "interface",
97 if section[".name"] ~= "loopback" then
98 parent:value(section[".name"])
105 s2.defaults.proto = "static"
107 ipaddr = s2:option(Value, "ipaddr", translate("ipaddress"))
108 ipaddr.rmempty = true
110 nm = s2:option(Value, "netmask", translate("netmask"))
112 nm:value("255.255.255.0")
113 nm:value("255.255.0.0")
114 nm:value("255.0.0.0")
116 gw = s2:option(Value, "gateway", translate("gateway"))
119 bcast = s2:option(Value, "bcast", translate("broadcast"))
120 bcast.optional = true
122 ip6addr = s2:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
123 ip6addr.optional = true
125 ip6gw = s2:option(Value, "ip6gw", translate("gateway6"))
126 ip6gw.optional = true
128 dns = s2:option(Value, "dns", translate("dnsserver"))