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])
42 if zones and #zones == 0 then
45 fwzone = s:option(Value, "_fwzone",
46 translate("network_interface_fwzone"),
47 translate("network_interface_fwzone_desc"))
49 fwzone:value("", "- " .. translate("none") .. " -")
51 luci.model.uci.foreach("firewall", "zone",
53 fwzone:value(section.name)
57 function fwzone.write(self, section, value)
58 local zone = luci.tools.webadmin.firewall_find_zone(value)
62 stat = luci.model.uci.section("firewall", "zone", nil, {
67 local net = luci.model.uci.get("firewall", zone, "network")
68 net = (net or value) .. " " .. section
69 stat = luci.model.uci.set("firewall", zone, "network", net)
73 self.render = function() end
78 ipaddr = s:option(Value, "ipaddr", translate("ipaddress"))
80 ipaddr:depends("proto", "static")
82 nm = s:option(Value, "netmask", translate("netmask"))
84 nm:depends("proto", "static")
85 nm:value("255.255.255.0")
86 nm:value("255.255.0.0")
89 gw = s:option(Value, "gateway", translate("gateway"))
90 gw:depends("proto", "static")
93 bcast = s:option(Value, "bcast", translate("broadcast"))
94 bcast:depends("proto", "static")
97 ip6addr = s:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
98 ip6addr.optional = true
99 ip6addr:depends("proto", "static")
101 ip6gw = s:option(Value, "ip6gw", translate("gateway6"))
102 ip6gw:depends("proto", "static")
103 ip6gw.optional = true
105 dns = s:option(Value, "dns", translate("dnsserver"))
106 dns:depends("proto", "static")
109 mtu = s:option(Value, "mtu", "MTU")
113 mac = s:option(Value, "macaddr", translate("macaddress"))
117 srv = s:option(Value, "server", translate("network_interface_server"))
118 srv:depends("proto", "pptp")
121 user = s:option(Value, "username", translate("username"))
123 user:depends("proto", "pptp")
124 user:depends("proto", "pppoe")
126 pass = s:option(Value, "password", translate("password"))
128 pass:depends("proto", "pptp")
129 pass:depends("proto", "pppoe")
131 ka = s:option(Value, "keepalive",
132 translate("network_interface_keepalive"),
133 translate("network_interface_keepalive_desc")
136 ka:depends("proto", "pptp")
137 ka:depends("proto", "pppoe")
139 demand = s:option(Value, "demand",
140 translate("network_interface_demand"),
141 translate("network_interface_demand_desc")
143 demand.rmempty = true
144 demand:depends("proto", "pptp")
145 demand:depends("proto", "pppoe")
150 s2 = m:section(TypedSection, "alias", translate("aliases"))
153 s2:depends("interface", arg[1])
154 s2.defaults.interface = arg[1]
157 s2.defaults.proto = "static"
159 ipaddr = s2:option(Value, "ipaddr", translate("ipaddress"))
160 ipaddr.rmempty = true
162 nm = s2:option(Value, "netmask", translate("netmask"))
164 nm:value("255.255.255.0")
165 nm:value("255.255.0.0")
166 nm:value("255.0.0.0")
168 gw = s2:option(Value, "gateway", translate("gateway"))
171 bcast = s2:option(Value, "bcast", translate("broadcast"))
172 bcast.optional = true
174 ip6addr = s2:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
175 ip6addr.optional = true
177 ip6gw = s2:option(Value, "ip6gw", translate("gateway6"))
178 ip6gw.optional = true
180 dns = s2:option(Value, "dns", translate("dnsserver"))