9065636836e77a536d02decb85bfaaadaf8d9a0d
[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
17 m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
18
19 s = m:section(NamedSection, arg[1], "interface", translate("interfaces"))
20 s.addremove = true
21
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")
27 p.default = "static"
28
29 br = s:option(Flag, "type", translate("a_n_i_bridge"), translate("a_n_i_bridge1"))
30 br.enabled = "bridge"
31 br.rmempty = true
32
33 ifname = s:option(Value, "ifname", translate("interface"))
34 ifname.rmempty = true
35 for i,d in ipairs(luci.sys.net.devices()) do
36         if d ~= "lo" then
37                 ifname:value(d)
38         end
39 end
40
41
42 ipaddr = s:option(Value, "ipaddr", translate("ipaddress"))
43 ipaddr.rmempty = true
44 ipaddr:depends("proto", "static")
45
46 nm = s:option(Value, "netmask", translate("netmask"))
47 nm.rmempty = true
48 nm:depends("proto", "static")
49 nm:value("255.255.255.0")
50 nm:value("255.255.0.0")
51 nm:value("255.0.0.0")
52
53 gw = s:option(Value, "gateway", translate("gateway"))
54 gw:depends("proto", "static")
55 gw.rmempty = true
56
57 bcast = s:option(Value, "bcast", translate("broadcast"))
58 bcast:depends("proto", "static")
59 bcast.optional = true
60
61 ip6addr = s:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
62 ip6addr.optional = true
63 ip6addr:depends("proto", "static")
64
65 ip6gw = s:option(Value, "ip6gw", translate("gateway6"))
66 ip6gw:depends("proto", "static")
67 ip6gw.optional = true
68
69 dns = s:option(Value, "dns", translate("dnsserver"))
70 dns:depends("proto", "static")
71 dns.optional = true
72
73 mtu = s:option(Value, "mtu", "MTU")
74 mtu.optional = true
75 mtu.isinteger = true
76
77 mac = s:option(Value, "macaddr", translate("macaddress"))
78 mac.optional = true
79
80 user = s:option(Value, "username", translate("username"))
81 user.rmempty = true
82 user:depends("proto", "pptp")
83 user:depends("proto", "ppoe")
84
85 pass = s:option(Value, "password", translate("password"))
86 pass.rmempty = true
87 pass:depends("proto", "pptp")
88 pass:depends("proto", "ppoe")
89
90 ka = s:option(Value, "keepalive")
91 ka.rmempty = true
92 ka:depends("proto", "pptp")
93 ka:depends("proto", "ppoe")
94
95 demand = s:option(Value, "demand")
96 demand.rmempty = true
97 demand:depends("proto", "pptp")
98 demand:depends("proto", "ppoe")
99
100 srv = s:option(Value, "server")
101 srv:depends("proto", "pptp")
102 srv.rmempty = true
103
104
105
106
107 s2 = m:section(TypedSection, "alias", translate("aliases"))
108 s2.addremove = true
109
110 s2:depends("interface", arg[1])
111 s2.defaults.interface = arg[1]
112
113
114 s2.defaults.proto = "static"
115
116 ipaddr = s2:option(Value, "ipaddr", translate("ipaddress"))
117 ipaddr.rmempty = true
118
119 nm = s2:option(Value, "netmask", translate("netmask"))
120 nm.rmempty = true
121 nm:value("255.255.255.0")
122 nm:value("255.255.0.0")
123 nm:value("255.0.0.0")
124
125 gw = s2:option(Value, "gateway", translate("gateway"))
126 gw.rmempty = true
127
128 bcast = s2:option(Value, "bcast", translate("broadcast"))
129 bcast.optional = true
130
131 ip6addr = s2:option(Value, "ip6addr", translate("ip6address"), translate("cidr6"))
132 ip6addr.optional = true
133
134 ip6gw = s2:option(Value, "ip6gw", translate("gateway6"))
135 ip6gw.optional = true
136
137 dns = s2:option(Value, "dns", translate("dnsserver"))
138 dns.optional = true
139
140 return m