applications/luci-radvd: sync with OpenWrt trunk changes
[project/luci.git] / applications / luci-radvd / luasrc / model / cbi / radvd / interface.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2010 Jo-Philipp Wich <xm@subsignal.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
15 local sid = arg[1]
16 local utl = require "luci.util"
17
18 m = Map("radvd", translatef("Radvd - Interface %q", "?"),
19         translate("Radvd is a router advertisement daemon for IPv6. " ..
20                 "It listens to router solicitations and sends router advertisements " ..
21                 "as described in RFC 4861."))
22
23 m.redirect = luci.dispatcher.build_url("admin/network/radvd")
24
25 if m.uci:get("radvd", sid) ~= "interface" then
26         luci.http.redirect(m.redirect)
27         return
28 end
29
30 m.uci:foreach("radvd", "interface",
31         function(s)
32                 if s['.name'] == sid and s.interface then
33                         m.title = translatef("Radvd - Interface %q", s.interface)
34                         return false
35                 end
36         end)
37
38
39 s = m:section(NamedSection, sid, "interface", translate("Interface Configuration"))
40 s.addremove = false
41
42 s:tab("general", translate("General"))
43 s:tab("timing",  translate("Timing"))
44 s:tab("mobile",  translate("Mobile IPv6"))
45
46
47 --
48 -- General
49 --
50
51 o = s:taboption("general", Flag, "ignore", translate("Enable"))
52 o.rmempty = false
53
54 function o.cfgvalue(...)
55         local v = Flag.cfgvalue(...)
56         return v == "1" and "0" or "1"
57 end
58
59 function o.write(self, section, value)
60         Flag.write(self, section, value == "1" and "0" or "1")
61 end
62
63
64 o = s:taboption("general", Value, "interface", translate("Interface"),
65         translate("Specifies the logical interface name this section belongs to"))
66
67 o.template = "cbi/network_netlist"
68 o.nocreate = true
69 o.optional = false
70
71 function o.formvalue(...)
72         return Value.formvalue(...) or "-"
73 end
74
75 function o.validate(self, value)
76         if value == "-" then
77                 return nil, translate("Interface required")
78         end
79         return value
80 end
81
82 function o.write(self, section, value)
83         m.uci:set("radvd", section, "ignore", 0)
84         m.uci:set("radvd", section, "interface", value)
85 end
86
87
88 o = s:taboption("general", DynamicList, "client", translate("Clients"),
89         translate("Restrict communication to specified clients, leave empty to use multicast"))
90
91 o.rmempty     = true
92 o.datatype    = "ip6addr"
93 o.placeholder = "any"
94 function o.cfgvalue(...)
95         local v = Value.cfgvalue(...)
96         local l = { }
97         for v in utl.imatch(v) do
98                 l[#l+1] = v
99         end
100         return l
101 end
102
103
104 o = s:taboption("general", Flag, "AdvSendAdvert", translate("Enable advertisements"),
105         translate("Enables router advertisements and solicitations"))
106
107 o.rmempty = false
108 function o.write(self, section, value)
109         if value == "1" then
110                 m.uci:set("radvd", section, "ignore", 0)
111                 m.uci:set("radvd", section, "IgnoreIfMissing", 1)
112         end
113
114         m.uci:set("radvd", section, "AdvSendAdvert", value)
115 end
116
117
118 o = s:taboption("general", Flag, "UnicastOnly", translate("Unicast only"),
119         translate("Indicates that the underlying link is not broadcast capable, prevents unsolicited advertisements from being sent"))
120
121 o:depends("AdvSendAdvert", "1")
122
123
124 o = s:taboption("general", Flag, "AdvManagedFlag", translate("Managed flag"),
125         translate("Enables the additional stateful administered autoconfiguration protocol (RFC2462)"))
126
127 o:depends("AdvSendAdvert", "1")
128
129
130 o = s:taboption("general", Flag, "AdvOtherConfigFlag", translate("Configuration flag"),
131         translate("Enables the autoconfiguration of additional, non address information (RFC2462)"))
132
133 o:depends("AdvSendAdvert", "1")
134
135
136 o = s:taboption("general", Flag, "AdvSourceLLAddress", translate("Source link-layer address"),
137         translate("Includes the link-layer address of the outgoing interface in the RA"))
138
139 o.rmempty = false
140 o.default = "1"
141 o:depends("AdvSendAdvert", "1")
142
143
144 o = s:taboption("general", Value, "AdvLinkMTU", translate("Link MTU"),
145         translate("Advertises the given link MTU in the RA if specified. 0 disables MTU advertisements"))
146
147 o.datatype = "uinteger"
148 o.placeholder = 0
149 o:depends("AdvSendAdvert", "1")
150
151
152 o = s:taboption("general", Value, "AdvCurHopLimit", translate("Current hop limit"),
153         translate("Advertises the default Hop Count value for outgoing unicast packets in the RA. 0 disables hopcount advertisements"))
154
155 o.datatype = "uinteger"
156 o.optional = false
157 o.placeholder = 64
158 o:depends("AdvSendAdvert", "1")
159
160
161 o = s:taboption("general", ListValue, "AdvDefaultPreference", translate("Default preference"),
162         translate("Advertises the default router preference"))
163
164 o.optional = false
165 o.default = "medium"
166 o:value("low",    translate("low"))
167 o:value("medium", translate("medium"))
168 o:value("high",   translate("high"))
169 o:depends("AdvSendAdvert", "1")
170
171
172 --
173 -- Timing
174 --
175
176 o = s:taboption("timing", Value, "MinRtrAdvInterval", translate("Minimum advertisement interval"),
177         translate("The minimum time allowed between sending unsolicited multicast router advertisements from the interface, in seconds"))
178
179 o.datatype = "uinteger"
180 o.optional = false
181 o.placeholder = 198
182 o:depends("AdvSendAdvert", "1")
183
184
185 o = s:taboption("timing", Value, "MaxRtrAdvInterval", translate("Maximum advertisement interval"),
186         translate("The maximum time allowed between sending unsolicited multicast router advertisements from the interface, in seconds"))
187
188 o.datatype = "uinteger"
189 o.optional = false
190 o.placeholder = 600
191 o:depends("AdvSendAdvert", "1")
192
193
194 o = s:taboption("timing", Value, "MinDelayBetweenRAs", translate("Minimum advertisement delay"),
195         translate("The minimum time allowed between sending multicast router advertisements from the interface, in seconds"))
196
197 o.datatype = "uinteger"
198 o.optional = false
199 o.placeholder = 3
200 o:depends("AdvSendAdvert", "1")
201
202
203 o = s:taboption("timing", Value, "AdvReachableTime", translate("Reachable time"),
204         translate("Advertises assumed reachability time in milliseconds of neighbours in the RA if specified. 0 disables reachability advertisements"))
205
206 o.datatype = "uinteger"
207 o.optional = false
208 o.placeholder = 0
209 o:depends("AdvSendAdvert", "1")
210
211
212 o = s:taboption("timing", Value, "AdvRetransTimer", translate("Retransmit timer"),
213         translate("Advertises wait time in milliseconds between Neighbor Solicitation messages in the RA if specified. 0 disables retransmit advertisements"))
214
215 o.datatype = "uinteger"
216 o.optional = false
217 o.placeholder = 0
218 o:depends("AdvSendAdvert", "1")
219
220
221 o = s:taboption("timing", Value, "AdvDefaultLifetime", translate("Default lifetime"),
222         translate("Advertises the lifetime of the default router in seconds. 0 indicates that the node is no default router"))
223
224 o.datatype = "uinteger"
225 o.optional = false
226 o.placeholder = 1800
227 o:depends("AdvSendAdvert", "1")
228
229
230 --
231 -- Mobile
232 --
233
234 o = s:taboption("mobile", Flag, "AdvHomeAgentFlag", translate("Advertise Home Agent flag"),
235         translate("Advertises Mobile IPv6 Home Agent capability (RFC3775)"))
236
237 o:depends("AdvSendAdvert", "1")
238
239
240 o = s:taboption("mobile", Flag, "AdvIntervalOpt", translate("Mobile IPv6 interval option"),
241         translate("Include Mobile IPv6 Advertisement Interval option to RA"))
242
243 o:depends({AdvHomeAgentFlag = "1", AdvSendAdvert = "1"})
244
245
246 o = s:taboption("mobile", Flag, "AdvHomeAgentInfo", translate("Home Agent information"),
247         translate("Include Home Agent Information in the RA"))
248
249 o:depends({AdvHomeAgentFlag = "1", AdvSendAdvert = "1"})
250
251
252 o = s:taboption("mobile", Flag, "AdvMobRtrSupportFlag", translate("Mobile IPv6 router registration"),
253         translate("Advertises Mobile Router registration capability (NEMO Basic)"))
254
255 o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"})
256
257
258 o = s:taboption("mobile", Value, "HomeAgentLifetime", translate("Home Agent lifetime"),
259         translate("Advertises the time in seconds the router is offering Mobile IPv6 Home Agent services"))
260
261 o.datatype = "uinteger"
262 o.optional = false
263 o.placeholder = 1800
264 o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"})
265
266
267 o = s:taboption("mobile", Value, "HomeAgentPreference", translate("Home Agent preference"),
268         translate("The preference for the Home Agent sending this RA"))
269
270 o.datatype = "uinteger"
271 o.optional = false
272 o.placeholder = 0
273 o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"})
274
275
276 return m