libs/cbi: Added magic ;-)
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / ifaces.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14 m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
15
16 s = m:section(TypedSection, "interface", "")
17 function s.filter(section)
18         return section ~= "loopback" and (not arg or #arg == 0 or
19          luci.util.contains(arg, section))
20 end
21
22 if not arg or #arg == 0 then
23         s.addremove = true
24 end
25 s:depends("proto", "static")
26 s:depends("proto", "dhcp")
27
28 p = s:option(ListValue, "proto", translate("protocol"))
29 p:value("static", translate("static"))
30 p:value("dhcp", "DHCP")
31 p.default = "static"
32
33 br = s:option(Flag, "type", translate("a_n_i_bridge"), translate("a_n_i_bridge1"))
34 br.enabled = "bridge"
35 br.rmempty = true
36
37 ifname = s:option(Value, "ifname", translate("interface"))
38 ifname.rmempty = true
39 for i,d in ipairs(luci.sys.net.devices()) do
40         if d ~= "lo" then
41                 ifname:value(d)
42         end
43 end
44
45 ipaddr = s:option(Value, "ipaddr", translate("ipaddress"))
46 ipaddr.rmempty = true
47 ipaddr:depends("proto", "static")
48
49 nm = s:option(Value, "netmask", translate("netmask"))
50 nm.rmempty = true
51 nm:depends("proto", "static")
52 nm:value("255.255.255.0")
53 nm:value("255.255.0.0")
54 nm:value("255.0.0.0")
55
56 gw = s:option(Value, "gateway", translate("gateway"))
57 gw:depends("proto", "static")
58 gw.rmempty = true
59
60 ip6addr = s:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
61 ip6addr.rmempty = true
62 ip6addr:depends("proto", "static")
63
64 ip6gw = s:option(Value, "ip6gw", translate("gateway6"))
65 ip6gw:depends("proto", "static")
66 ip6gw.rmempty = true
67
68 dns = s:option(Value, "dns", translate("dnsserver"))
69 dns:depends("proto", "static")
70 dns.optional = true
71
72 mtu = s:option(Value, "mtu", "MTU")
73 mtu.optional = true
74 mtu.isinteger = true
75
76 mac = s:option(Value, "macaddr", translate("macaddress"))
77 mac.optional = true
78
79 return m