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