Fixed last commit
[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 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
6
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
10
11         http://www.apache.org/licenses/LICENSE-2.0
12
13 $Id$
14 ]]--
15 arg[1] = arg[1] or ""
16 m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
17
18 s = m:section(NamedSection, arg[1], "interface")
19 s.addremove = true
20
21 p = s:option(ListValue, "proto", translate("protocol"))
22 p:value("static", translate("static"))
23 p:value("dhcp", "DHCP")
24 p:value("pppoe", "PPPoE")
25 p:value("pptp", "PPTP")
26 p.default = "static"
27
28 br = s:option(Flag, "type", translate("a_n_i_bridge"), translate("a_n_i_bridge1"))
29 br.enabled = "bridge"
30 br.rmempty = true
31
32 ifname = s:option(Value, "ifname", translate("interface"))
33 ifname.rmempty = true
34 for i,d in ipairs(luci.sys.net.devices()) do
35         if d ~= "lo" then
36                 ifname:value(d)
37         end
38 end
39
40
41 ipaddr = s:option(Value, "ipaddr", translate("ipaddress"))
42 ipaddr.rmempty = true
43 ipaddr:depends("proto", "static")
44
45 nm = s:option(Value, "netmask", translate("netmask"))
46 nm.rmempty = true
47 nm:depends("proto", "static")
48 nm:value("255.255.255.0")
49 nm:value("255.255.0.0")
50 nm:value("255.0.0.0")
51
52 gw = s:option(Value, "gateway", translate("gateway"))
53 gw:depends("proto", "static")
54 gw.rmempty = true
55
56 bcast = s:option(Value, "bcast", translate("broadcast"))
57 bcast:depends("proto", "static")
58 bcast.optional = true
59
60 ip6addr = s:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
61 ip6addr.optional = true
62 ip6addr:depends("proto", "static")
63
64 ip6gw = s:option(Value, "ip6gw", translate("gateway6"))
65 ip6gw:depends("proto", "static")
66 ip6gw.optional = 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 user = s:option(Value, "username", translate("username"))
80 user.rmempty = true
81 user:depends("proto", "pptp")
82 user:depends("proto", "ppoe")
83
84 pass = s:option(Value, "password", translate("password"))
85 pass.rmempty = true
86 pass:depends("proto", "pptp")
87 pass:depends("proto", "ppoe")
88
89 ka = s:option(Value, "keepalive")
90 ka.rmempty = true
91 ka:depends("proto", "pptp")
92 ka:depends("proto", "ppoe")
93
94 demand = s:option(Value, "demand")
95 demand.rmempty = true
96 demand:depends("proto", "pptp")
97 demand:depends("proto", "ppoe")
98
99 srv = s:option(Value, "server")
100 srv:depends("proto", "pptp")
101 srv.rmempty = true
102
103
104
105
106 s2 = m:section(TypedSection, "alias", translate("aliases"))
107 s2.addremove = true
108
109 s2:depends("interface", arg[1])
110 s2.defaults.interface = arg[1]
111
112
113 s2.defaults.proto = "static"
114
115 ipaddr = s2:option(Value, "ipaddr", translate("ipaddress"))
116 ipaddr.rmempty = true
117
118 nm = s2:option(Value, "netmask", translate("netmask"))
119 nm.rmempty = true
120 nm:value("255.255.255.0")
121 nm:value("255.255.0.0")
122 nm:value("255.0.0.0")
123
124 gw = s2:option(Value, "gateway", translate("gateway"))
125 gw.rmempty = true
126
127 bcast = s2:option(Value, "bcast", translate("broadcast"))
128 bcast.optional = true
129
130 ip6addr = s2:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
131 ip6addr.optional = true
132
133 ip6gw = s2:option(Value, "ip6gw", translate("gateway6"))
134 ip6gw.optional = true
135
136 dns = s2:option(Value, "dns", translate("dnsserver"))
137 dns.optional = true
138
139 return m