2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
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
15 require("luci.tools.webadmin")
17 m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
19 s = m:section(NamedSection, arg[1], "interface")
22 p = s:option(ListValue, "proto", translate("protocol"))
23 p:value("static", translate("static"))
24 p:value("dhcp", "DHCP")
25 p:value("pppoe", "PPPoE")
26 p:value("pptp", "PPTP")
29 br = s:option(Flag, "type", translate("a_n_i_bridge"), translate("a_n_i_bridge1"))
33 ifname = s:option(Value, "ifname", translate("interface"))
35 for i,d in ipairs(luci.sys.net.devices()) do
41 local zones = luci.tools.webadmin.network_get_zones(arg[1])
46 fwzone = s:option(Value, "_fwzone",
47 translate("network_interface_fwzone"),
48 translate("network_interface_fwzone_desc"))
50 fwzone:value("", "- " .. translate("none") .. " -")
52 luci.model.uci.foreach("firewall", "zone",
54 fwzone:value(section.name)
58 function fwzone.write(self, section, value)
59 local zone = luci.tools.webadmin.firewall_find_zone(value)
63 stat = luci.model.uci.section("firewall", "zone", nil, {
68 local net = luci.model.uci.get("firewall", zone, "network")
69 net = (net or value) .. " " .. section
70 stat = luci.model.uci.set("firewall", zone, "network", net)
74 self.render = function() end
78 fwzone = s:option(DummyValue, "_fwzone", translate("zone"))
79 fwzone.value = table.concat(zones, ", ")
81 fwzone.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "zones")
84 ipaddr = s:option(Value, "ipaddr", translate("ipaddress"))
86 ipaddr:depends("proto", "static")
88 nm = s:option(Value, "netmask", translate("netmask"))
90 nm:depends("proto", "static")
91 nm:value("255.255.255.0")
92 nm:value("255.255.0.0")
95 gw = s:option(Value, "gateway", translate("gateway"))
96 gw:depends("proto", "static")
99 bcast = s:option(Value, "bcast", translate("broadcast"))
100 bcast:depends("proto", "static")
101 bcast.optional = true
103 ip6addr = s:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
104 ip6addr.optional = true
105 ip6addr:depends("proto", "static")
107 ip6gw = s:option(Value, "ip6gw", translate("gateway6"))
108 ip6gw:depends("proto", "static")
109 ip6gw.optional = true
111 dns = s:option(Value, "dns", translate("dnsserver"))
112 dns:depends("proto", "static")
115 mtu = s:option(Value, "mtu", "MTU")
119 mac = s:option(Value, "macaddr", translate("macaddress"))
123 srv = s:option(Value, "server", translate("network_interface_server"))
124 srv:depends("proto", "pptp")
127 user = s:option(Value, "username", translate("username"))
129 user:depends("proto", "pptp")
130 user:depends("proto", "pppoe")
132 pass = s:option(Value, "password", translate("password"))
134 pass:depends("proto", "pptp")
135 pass:depends("proto", "pppoe")
137 ka = s:option(Value, "keepalive",
138 translate("network_interface_keepalive"),
139 translate("network_interface_keepalive_desc")
142 ka:depends("proto", "pptp")
143 ka:depends("proto", "pppoe")
145 demand = s:option(Value, "demand",
146 translate("network_interface_demand"),
147 translate("network_interface_demand_desc")
149 demand.rmempty = true
150 demand:depends("proto", "pptp")
151 demand:depends("proto", "pppoe")
156 s2 = m:section(TypedSection, "alias", translate("aliases"))
159 s2:depends("interface", arg[1])
160 s2.defaults.interface = arg[1]
163 s2.defaults.proto = "static"
165 ipaddr = s2:option(Value, "ipaddr", translate("ipaddress"))
166 ipaddr.rmempty = true
168 nm = s2:option(Value, "netmask", translate("netmask"))
170 nm:value("255.255.255.0")
171 nm:value("255.255.0.0")
172 nm:value("255.0.0.0")
174 gw = s2:option(Value, "gateway", translate("gateway"))
177 bcast = s2:option(Value, "bcast", translate("broadcast"))
178 bcast.optional = true
180 ip6addr = s2:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
181 ip6addr.optional = true
183 ip6gw = s2:option(Value, "ip6gw", translate("gateway6"))
184 ip6gw.optional = true
186 dns = s2:option(Value, "dns", translate("dnsserver"))