2 LuCI - Lua Configuration Interface
4 Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
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
10 http://www.apache.org/licenses/LICENSE-2.0
15 m = Map("radvd", translate("Radvd"),
16 translate("Radvd is a router advertisement daemon for IPv6. " ..
17 "It listens to router solicitations and sends router advertisements " ..
18 "as described in RFC 4861."))
20 local nm = require "luci.model.network".init(m.uci)
21 local ut = require "luci.util"
28 s = m:section(TypedSection, "interface", translate("Interfaces"))
29 s.template = "cbi/tblsection"
30 s.extedit = luci.dispatcher.build_url("admin/network/radvd/interface/%s")
34 function s.create(...)
35 local id = TypedSection.create(...)
36 luci.http.redirect(s.extedit % id)
39 function s.remove(self, section)
40 if m.uci:get("radvd", section) == "interface" then
41 local iface = m.uci:get("radvd", section, "interface")
43 m.uci:delete_all("radvd", "prefix",
44 function(s) return s.interface == iface end)
46 m.uci:delete_all("radvd", "route",
47 function(s) return s.interface == iface end)
49 m.uci:delete_all("radvd", "rdnss",
50 function(s) return s.interface == iface end)
54 return TypedSection.remove(self, section)
57 o = s:option(Flag, "ignore", translate("Enable"))
60 function o.cfgvalue(...)
61 local v = Flag.cfgvalue(...)
62 return v == "1" and "0" or "1"
64 function o.write(self, section, value)
65 Flag.write(self, section, value == "1" and "0" or "1")
68 o = s:option(DummyValue, "interface", translate("Interface"))
69 o.template = "cbi/network_netinfo"
72 o = s:option(DummyValue, "UnicastOnly", translate("Multicast"))
73 function o.cfgvalue(self, section)
74 local v = Value.cfgvalue(self, section)
75 local v2 = m.uci:get("radvd", section, "client")
76 return (v == "1" or (v2 and #v2 > 0)) and translate("no") or translate("yes")
79 o = s:option(DummyValue, "AdvSendAdvert", translate("Advertising"))
80 function o.cfgvalue(...)
81 local v = Value.cfgvalue(...)
82 return v == "1" and translate("yes") or translate("no")
85 o = s:option(DummyValue, "MaxRtrAdvInterval", translate("Max. interval"))
86 function o.cfgvalue(...)
87 local v = Value.cfgvalue(...) or "600"
91 o = s:option(DummyValue, "AdvHomeAgentFlag", translate("Mobile IPv6"))
92 function o.cfgvalue(...)
93 local v = Value.cfgvalue(...)
94 return v == "1" and translate("yes") or translate("no")
97 o = s:option(DummyValue, "AdvDefaultPreference", translate("Preference"))
98 function o.cfgvalue(...)
99 local v = Value.cfgvalue(...) or "medium"
108 s2 = m:section(TypedSection, "prefix", translate("Prefixes"))
109 s2.template = "cbi/tblsection"
110 s2.extedit = luci.dispatcher.build_url("admin/network/radvd/prefix/%s")
114 function s2.create(...)
115 local id = TypedSection.create(...)
116 luci.http.redirect(s2.extedit % id)
120 o = s2:option(Flag, "ignore", translate("Enable"))
123 function o.cfgvalue(...)
124 local v = Flag.cfgvalue(...)
125 return v == "1" and "0" or "1"
127 function o.write(self, section, value)
128 Flag.write(self, section, value == "1" and "0" or "1")
131 o = s2:option(DummyValue, "interface", translate("Interface"))
132 o.template = "cbi/network_netinfo"
135 o = s2:option(DummyValue, "prefix", translate("Prefix"))
137 function o.cfgvalue(self, section)
138 local v = m.uci:get_list("radvd", section, "prefix")
142 local net = nm:get_network(m.uci:get("radvd", section, "interface"))
144 local ifc = nm:get_interface(net:ifname())
147 for _, adr in ipairs(ifc:ip6addrs()) do
148 if not adr:is6linklocal() then
157 for v in ut.imatch(v) do
168 return table.concat(l, ", ")
171 o = s2:option(DummyValue, "AdvAutonomous", translate("Autonomous"))
172 function o.cfgvalue(...)
173 local v = Value.cfgvalue(...)
174 return v == "1" and translate("yes") or translate("no")
177 o = s2:option(DummyValue, "AdvOnLink", translate("On-link"))
178 function o.cfgvalue(...)
179 local v = Value.cfgvalue(...)
180 return v == "1" and translate("yes") or translate("no")
183 o = s2:option(DummyValue, "AdvValidLifetime", translate("Validity time"))
184 function o.cfgvalue(...)
185 local v = Value.cfgvalue(...) or "86400"
194 s3 = m:section(TypedSection, "route", translate("Routes"))
195 s3.template = "cbi/tblsection"
196 s3.extedit = luci.dispatcher.build_url("admin/network/radvd/route/%s")
200 function s3.create(...)
201 local id = TypedSection.create(...)
202 luci.http.redirect(s3.extedit % id)
206 o = s3:option(Flag, "ignore", translate("Enable"))
209 function o.cfgvalue(...)
210 local v = Flag.cfgvalue(...)
211 return v == "1" and "0" or "1"
213 function o.write(self, section, value)
214 Flag.write(self, section, value == "1" and "0" or "1")
217 o = s3:option(DummyValue, "interface", translate("Interface"))
218 o.template = "cbi/network_netinfo"
221 o = s3:option(DummyValue, "prefix", translate("Prefix"))
223 function o.cfgvalue(self, section)
224 local v = m.uci:get_list("radvd", section, "prefix")
227 for v in ut.imatch(v) do
239 return table.concat(l, ", ")
242 o = s3:option(DummyValue, "AdvRouteLifetime", translate("Lifetime"))
243 function o.cfgvalue(self, section)
244 local v = Value.cfgvalue(self, section) or "1800"
248 o = s3:option(DummyValue, "AdvRoutePreference", translate("Preference"))
249 function o.cfgvalue(self, section)
250 local v = Value.cfgvalue(self, section) or "medium"
259 s4 = m:section(TypedSection, "rdnss", translate("RDNSS"))
260 s4.template = "cbi/tblsection"
261 s4.extedit = luci.dispatcher.build_url("admin/network/radvd/rdnss/%s")
265 function s4.create(...)
266 local id = TypedSection.create(...)
267 luci.http.redirect(s4.extedit % id)
271 o = s4:option(Flag, "ignore", translate("Enable"))
274 function o.cfgvalue(...)
275 local v = Flag.cfgvalue(...)
276 return v == "1" and "0" or "1"
278 function o.write(self, section, value)
279 Flag.write(self, section, value == "1" and "0" or "1")
282 o = s4:option(DummyValue, "interface", translate("Interface"))
283 o.template = "cbi/network_netinfo"
286 o = s4:option(DummyValue, "addr", translate("Address"))
288 function o.cfgvalue(self, section)
289 local v = m.uci:get_list("radvd", section, "addr")
292 local net = nm:get_network(m.uci:get("radvd", section, "interface"))
294 local ifc = nm:get_interface(net:ifname())
297 for _, adr in ipairs(ifc:ip6addrs()) do
298 if not adr:is6linklocal() then
299 v = adr:network(128):string()
307 for v in ut.imatch(v) do
310 l[#l+1] = v:network(128):string()
318 return table.concat(l, ", ")
321 o = s4:option(DummyValue, "AdvRDNSSLifetime", translate("Lifetime"))
322 function o.cfgvalue(self, section)
323 local v = Value.cfgvalue(self, section) or "1200"
332 s5 = m:section(TypedSection, "dnssl", translate("DNSSL"))
333 s5.template = "cbi/tblsection"
334 s5.extedit = luci.dispatcher.build_url("admin/network/radvd/dnssl/%s")
338 function s5.create(...)
339 local id = TypedSection.create(...)
340 luci.http.redirect(s5.extedit % id)
344 o = s5:option(Flag, "ignore", translate("Enable"))
347 function o.cfgvalue(...)
348 local v = Flag.cfgvalue(...)
349 return v == "1" and "0" or "1"
351 function o.write(self, section, value)
352 Flag.write(self, section, value == "1" and "0" or "1")
355 o = s5:option(DummyValue, "interface", translate("Interface"))
356 o.template = "cbi/network_netinfo"
359 o = s5:option(DummyValue, "suffix", translate("Suffix"))
361 function o.cfgvalue(self, section)
362 local v = m.uci:get_list("radvd", section, "suffix")
365 for v in ut.imatch(v) do
373 return table.concat(l, ", ")
376 o = s5:option(DummyValue, "AdvDNSSLLifetime", translate("Lifetime"))
377 function o.cfgvalue(self, section)
378 local v = Value.cfgvalue(self, section) or "1200"