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"))
18 s = m:section(TypedSection, "interface", translate("interfaces"))
19 function s.create(self, section)
20 local stat = TypedSection.create(self, section)
22 arg = {section or stat}
27 function s.filter(self, section)
28 return section ~= "loopback" and
29 (not arg or not arg[1] or arg[1] == section)
32 if not arg or not arg[1] then
35 s:depends("proto", "static")
36 s:depends("proto", "dhcp")
38 p = s:option(ListValue, "proto", translate("protocol"))
39 p:value("static", translate("static"))
40 p:value("dhcp", "DHCP")
43 br = s:option(Flag, "type", translate("a_n_i_bridge"), translate("a_n_i_bridge1"))
47 ifname = s:option(Value, "ifname", translate("interface"))
49 for i,d in ipairs(luci.sys.net.devices()) do
56 ipaddr = s:option(Value, "ipaddr", translate("ipaddress"))
58 ipaddr:depends("proto", "static")
60 nm = s:option(Value, "netmask", translate("netmask"))
62 nm:depends("proto", "static")
63 nm:value("255.255.255.0")
64 nm:value("255.255.0.0")
67 gw = s:option(Value, "gateway", translate("gateway"))
68 gw:depends("proto", "static")
71 bcast = s:option(Value, "bcast", translate("broadcast"))
72 bcast:depends("proto", "static")
75 ip6addr = s:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
76 ip6addr.optional = true
77 ip6addr:depends("proto", "static")
79 ip6gw = s:option(Value, "ip6gw", translate("gateway6"))
80 ip6gw:depends("proto", "static")
83 dns = s:option(Value, "dns", translate("dnsserver"))
84 dns:depends("proto", "static")
87 mtu = s:option(Value, "mtu", "MTU")
91 mac = s:option(Value, "macaddr", translate("macaddress"))
97 s2 = m:section(TypedSection, "alias", translate("aliases"))
100 if arg and arg[1] then
101 s2:depends("interface", arg[1])
102 s2.defaults.interface = arg[1]
104 parent = s2:option(ListValue, "interface", translate("interface"))
105 luci.model.uci.foreach("network", "interface",
107 if section[".name"] ~= "loopback" then
108 parent:value(section[".name"])
115 s2.defaults.proto = "static"
117 ipaddr = s2:option(Value, "ipaddr", translate("ipaddress"))
118 ipaddr.rmempty = true
120 nm = s2:option(Value, "netmask", translate("netmask"))
122 nm:value("255.255.255.0")
123 nm:value("255.255.0.0")
124 nm:value("255.0.0.0")
126 gw = s2:option(Value, "gateway", translate("gateway"))
129 bcast = s2:option(Value, "bcast", translate("broadcast"))
130 bcast.optional = true
132 ip6addr = s2:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
133 ip6addr.optional = true
135 ip6gw = s2:option(Value, "ip6gw", translate("gateway6"))
136 ip6gw.optional = true
138 dns = s2:option(Value, "dns", translate("dnsserver"))