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 back = s:option(DummyValue, "_overview", translate("overview"))
24 back.titleref = luci.dispatcher.build_url("admin", "network", "network")
26 p = s:option(ListValue, "proto", translate("protocol"))
27 p:value("static", translate("static"))
28 p:value("dhcp", "DHCP")
29 p:value("pppoe", "PPPoE")
30 p:value("pptp", "PPTP")
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
45 local zones = luci.tools.webadmin.network_get_zones(arg[1])
50 fwzone = s:option(Value, "_fwzone",
51 translate("network_interface_fwzone"),
52 translate("network_interface_fwzone_desc"))
54 fwzone:value("", "- " .. translate("none") .. " -")
56 m.uci:load("firewall")
57 m.uci:foreach("firewall", "zone",
59 fwzone:value(section.name)
63 function fwzone.write(self, section, value)
64 local zone = luci.tools.webadmin.firewall_find_zone(value)
68 stat = m.uci:section("firewall", "zone", nil, {
73 local net = m.uci:get("firewall", zone, "network")
74 net = (net or value) .. " " .. section
75 stat = m.uci:set("firewall", zone, "network", net)
79 self.render = function() end
83 fwzone = s:option(DummyValue, "_fwzone", translate("zone"))
84 fwzone.value = table.concat(zones, ", ")
86 fwzone.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "zones")
87 m.uci:unload("firewall")
90 ipaddr = s:option(Value, "ipaddr", translate("ipaddress"))
92 ipaddr:depends("proto", "static")
94 nm = s:option(Value, "netmask", translate("netmask"))
96 nm:depends("proto", "static")
97 nm:value("255.255.255.0")
98 nm:value("255.255.0.0")
101 gw = s:option(Value, "gateway", translate("gateway"))
102 gw:depends("proto", "static")
105 bcast = s:option(Value, "bcast", translate("broadcast"))
106 bcast:depends("proto", "static")
107 bcast.optional = true
109 ip6addr = s:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
110 ip6addr.optional = true
111 ip6addr:depends("proto", "static")
113 ip6gw = s:option(Value, "ip6gw", translate("gateway6"))
114 ip6gw:depends("proto", "static")
115 ip6gw.optional = true
117 dns = s:option(Value, "dns", translate("dnsserver"))
118 dns:depends("proto", "static")
121 mtu = s:option(Value, "mtu", "MTU")
125 mac = s:option(Value, "macaddr", translate("macaddress"))
129 srv = s:option(Value, "server", translate("network_interface_server"))
130 srv:depends("proto", "pptp")
133 user = s:option(Value, "username", translate("username"))
135 user:depends("proto", "pptp")
136 user:depends("proto", "pppoe")
138 pass = s:option(Value, "password", translate("password"))
140 pass:depends("proto", "pptp")
141 pass:depends("proto", "pppoe")
143 ka = s:option(Value, "keepalive",
144 translate("network_interface_keepalive"),
145 translate("network_interface_keepalive_desc")
148 ka:depends("proto", "pptp")
149 ka:depends("proto", "pppoe")
151 demand = s:option(Value, "demand",
152 translate("network_interface_demand"),
153 translate("network_interface_demand_desc")
155 demand.rmempty = true
156 demand:depends("proto", "pptp")
157 demand:depends("proto", "pppoe")
162 s2 = m:section(TypedSection, "alias", translate("aliases"))
165 s2:depends("interface", arg[1])
166 s2.defaults.interface = arg[1]
169 s2.defaults.proto = "static"
171 ipaddr = s2:option(Value, "ipaddr", translate("ipaddress"))
172 ipaddr.rmempty = true
174 nm = s2:option(Value, "netmask", translate("netmask"))
176 nm:value("255.255.255.0")
177 nm:value("255.255.0.0")
178 nm:value("255.0.0.0")
180 gw = s2:option(Value, "gateway", translate("gateway"))
183 bcast = s2:option(Value, "bcast", translate("broadcast"))
184 bcast.optional = true
186 ip6addr = s2:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
187 ip6addr.optional = true
189 ip6gw = s2:option(Value, "ip6gw", translate("gateway6"))
190 ip6gw.optional = true
192 dns = s2:option(Value, "dns", translate("dnsserver"))