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 m.uci:load("firewall")
53 m.uci:foreach("firewall", "zone",
55 fwzone:value(section.name)
59 function fwzone.write(self, section, value)
60 local zone = luci.tools.webadmin.firewall_find_zone(value)
64 stat = m.uci:section("firewall", "zone", nil, {
69 local net = m.uci:get("firewall", zone, "network")
70 net = (net or value) .. " " .. section
71 stat = m.uci:set("firewall", zone, "network", net)
75 self.render = function() end
79 fwzone = s:option(DummyValue, "_fwzone", translate("zone"))
80 fwzone.value = table.concat(zones, ", ")
82 fwzone.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "zones")
83 m.uci:unload("firewall")
86 ipaddr = s:option(Value, "ipaddr", translate("ipaddress"))
88 ipaddr:depends("proto", "static")
90 nm = s:option(Value, "netmask", translate("netmask"))
92 nm:depends("proto", "static")
93 nm:value("255.255.255.0")
94 nm:value("255.255.0.0")
97 gw = s:option(Value, "gateway", translate("gateway"))
98 gw:depends("proto", "static")
101 bcast = s:option(Value, "bcast", translate("broadcast"))
102 bcast:depends("proto", "static")
103 bcast.optional = true
105 ip6addr = s:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
106 ip6addr.optional = true
107 ip6addr:depends("proto", "static")
109 ip6gw = s:option(Value, "ip6gw", translate("gateway6"))
110 ip6gw:depends("proto", "static")
111 ip6gw.optional = true
113 dns = s:option(Value, "dns", translate("dnsserver"))
114 dns:depends("proto", "static")
117 mtu = s:option(Value, "mtu", "MTU")
121 mac = s:option(Value, "macaddr", translate("macaddress"))
125 srv = s:option(Value, "server", translate("network_interface_server"))
126 srv:depends("proto", "pptp")
129 user = s:option(Value, "username", translate("username"))
131 user:depends("proto", "pptp")
132 user:depends("proto", "pppoe")
134 pass = s:option(Value, "password", translate("password"))
136 pass:depends("proto", "pptp")
137 pass:depends("proto", "pppoe")
139 ka = s:option(Value, "keepalive",
140 translate("network_interface_keepalive"),
141 translate("network_interface_keepalive_desc")
144 ka:depends("proto", "pptp")
145 ka:depends("proto", "pppoe")
147 demand = s:option(Value, "demand",
148 translate("network_interface_demand"),
149 translate("network_interface_demand_desc")
151 demand.rmempty = true
152 demand:depends("proto", "pptp")
153 demand:depends("proto", "pppoe")
158 s2 = m:section(TypedSection, "alias", translate("aliases"))
161 s2:depends("interface", arg[1])
162 s2.defaults.interface = arg[1]
165 s2.defaults.proto = "static"
167 ipaddr = s2:option(Value, "ipaddr", translate("ipaddress"))
168 ipaddr.rmempty = true
170 nm = s2:option(Value, "netmask", translate("netmask"))
172 nm:value("255.255.255.0")
173 nm:value("255.255.0.0")
174 nm:value("255.0.0.0")
176 gw = s2:option(Value, "gateway", translate("gateway"))
179 bcast = s2:option(Value, "bcast", translate("broadcast"))
180 bcast.optional = true
182 ip6addr = s2:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
183 ip6addr.optional = true
185 ip6gw = s2:option(Value, "ip6gw", translate("gateway6"))
186 ip6gw.optional = true
188 dns = s2:option(Value, "dns", translate("dnsserver"))