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