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")
31 p:value("3g", "UMTS/3G")
32 p:value("pptp", "PPTP")
35 br = s:option(Flag, "type", translate("a_n_i_bridge"), translate("a_n_i_bridge1"))
39 ifname = s:option(Value, "ifname", translate("interface"))
41 for i,d in ipairs(luci.sys.net.devices()) do
47 local zones = luci.tools.webadmin.network_get_zones(arg[1])
52 fwzone = s:option(Value, "_fwzone",
53 translate("network_interface_fwzone"),
54 translate("network_interface_fwzone_desc"))
56 fwzone:value("", "- " .. translate("none") .. " -")
58 m.uci:load("firewall")
59 m.uci:foreach("firewall", "zone",
61 fwzone:value(section.name)
65 function fwzone.write(self, section, value)
66 local zone = luci.tools.webadmin.firewall_find_zone(value)
70 stat = m.uci:section("firewall", "zone", nil, {
75 local net = m.uci:get("firewall", zone, "network")
76 net = (net or value) .. " " .. section
77 stat = m.uci:set("firewall", zone, "network", net)
81 self.render = function() end
85 fwzone = s:option(DummyValue, "_fwzone", translate("zone"))
86 fwzone.value = table.concat(zones, ", ")
88 fwzone.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "zones")
89 m.uci:unload("firewall")
92 ipaddr = s:option(Value, "ipaddr", translate("ipaddress"))
94 ipaddr:depends("proto", "static")
96 nm = s:option(Value, "netmask", translate("netmask"))
98 nm:depends("proto", "static")
99 nm:value("255.255.255.0")
100 nm:value("255.255.0.0")
101 nm:value("255.0.0.0")
103 gw = s:option(Value, "gateway", translate("gateway"))
104 gw:depends("proto", "static")
107 bcast = s:option(Value, "bcast", translate("broadcast"))
108 bcast:depends("proto", "static")
109 bcast.optional = true
111 ip6addr = s:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
112 ip6addr.optional = true
113 ip6addr:depends("proto", "static")
115 ip6gw = s:option(Value, "ip6gw", translate("gateway6"))
116 ip6gw:depends("proto", "static")
117 ip6gw.optional = true
119 dns = s:option(Value, "dns", translate("dnsserver"))
122 mtu = s:option(Value, "mtu", "MTU")
126 mac = s:option(Value, "macaddr", translate("macaddress"))
130 srv = s:option(Value, "server", translate("network_interface_server"))
131 srv:depends("proto", "pptp")
134 service = s:option(ListValue, "service", translate("network_interface_service"))
135 service:value("umts", "UMTS/GPRS")
136 service:value("cdma", "CDMA")
137 service:value("evdo", "EV-DO")
138 service:depends("proto", "3g")
140 apn = s:option(Value, "apn", translate("network_interface_apn"))
141 apn:depends("proto", "3g")
143 pincode = s:option(Value, "pincode",
144 translate("network_interface_pincode"),
145 translate("network_interface_pincode_desc")
147 pincode:depends("proto", "3g")
149 user = s:option(Value, "username", translate("username"))
151 user:depends("proto", "pptp")
152 user:depends("proto", "pppoe")
153 user:depends("proto", "ppp")
154 user:depends("proto", "3g")
156 pass = s:option(Value, "password", translate("password"))
158 pass:depends("proto", "pptp")
159 pass:depends("proto", "pppoe")
160 pass:depends("proto", "ppp")
161 pass:depends("proto", "3g")
163 ka = s:option(Value, "keepalive",
164 translate("network_interface_keepalive"),
165 translate("network_interface_keepalive_desc")
168 ka:depends("proto", "pptp")
169 ka:depends("proto", "pppoe")
170 ka:depends("proto", "ppp")
171 ka:depends("proto", "3g")
173 demand = s:option(Value, "demand",
174 translate("network_interface_demand"),
175 translate("network_interface_demand_desc")
177 demand.optional = true
178 demand:depends("proto", "pptp")
179 demand:depends("proto", "pppoe")
180 demand:depends("proto", "ppp")
181 demand:depends("proto", "3g")
183 device = s:option(Value, "device",
184 translate("network_interface_device"),
185 translate("network_interface_device_desc")
187 device:depends("proto", "ppp")
188 device:depends("proto", "3g")
190 defaultroute = s:option(Flag, "defaultroute",
191 translate("network_interface_defaultroute"),
192 translate("network_interface_defaultroute_desc")
194 defaultroute:depends("proto", "ppp")
195 defaultroute:depends("proto", "3g")
197 peerdns = s:option(Flag, "peerdns",
198 translate("network_interface_peerdns"),
199 translate("network_interface_peerdns_desc")
201 peerdns:depends("proto", "ppp")
203 ipv6 = s:option(Flag, "ipv6", translate("network_interface_ipv6") )
204 ipv6:depends("proto", "ppp")
205 --ipv6:depends("proto", "3g")
207 connect = s:option(Value, "connect",
208 translate("network_interface_connect"),
209 translate("network_interface_connect_desc")
211 connect.optional = true
212 connect:depends("proto", "ppp")
213 connect:depends("proto", "3g")
215 disconnect = s:option(Value, "disconnect",
216 translate("network_interface_disconnect"),
217 translate("network_interface_disconnect_desc")
219 disconnect.optional = true
220 disconnect:depends("proto", "ppp")
221 disconnect:depends("proto", "3g")
223 pppd_options = s:option(Value, "pppd_options",
224 translate("network_interface_pppd_options"),
225 translate("network_interface_pppd_options_desc")
227 pppd_options.optional = true
228 pppd_options:depends("proto", "ppp")
229 pppd_options:depends("proto", "3g")
231 maxwait = s:option(Value, "maxwait",
232 translate("network_interface_maxwait"),
233 translate("network_interface_maxwait_desc")
235 maxwait.optional = true
236 maxwait:depends("proto", "3g")
239 s2 = m:section(TypedSection, "alias", translate("aliases"))
242 s2:depends("interface", arg[1])
243 s2.defaults.interface = arg[1]
246 s2.defaults.proto = "static"
248 ipaddr = s2:option(Value, "ipaddr", translate("ipaddress"))
249 ipaddr.rmempty = true
251 nm = s2:option(Value, "netmask", translate("netmask"))
253 nm:value("255.255.255.0")
254 nm:value("255.255.0.0")
255 nm:value("255.0.0.0")
257 gw = s2:option(Value, "gateway", translate("gateway"))
260 bcast = s2:option(Value, "bcast", translate("broadcast"))
261 bcast.optional = true
263 ip6addr = s2:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
264 ip6addr.optional = true
266 ip6gw = s2:option(Value, "ip6gw", translate("gateway6"))
267 ip6gw.optional = true
269 dns = s2:option(Value, "dns", translate("dnsserver"))