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