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 pfx = s2:option(DummyValue, "prefix", translate("Prefix"))
137 function pfx.cfgvalue(self, section)
138 local v = m.uci:get_list("radvd", section, self.option)
141 if not v or #v == 0 or (#v == 1 and #v[1] == 0) then
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 o.cfgvalue = pfx.cfgvalue
225 o = s3:option(DummyValue, "AdvRouteLifetime", translate("Lifetime"))
226 function o.cfgvalue(self, section)
227 local v = Value.cfgvalue(self, section) or "1800"
231 o = s3:option(DummyValue, "AdvRoutePreference", translate("Preference"))
232 function o.cfgvalue(self, section)
233 local v = Value.cfgvalue(self, section) or "medium"
242 s4 = m:section(TypedSection, "rdnss", translate("RDNSS"))
243 s4.template = "cbi/tblsection"
244 s4.extedit = luci.dispatcher.build_url("admin/network/radvd/rdnss/%s")
248 function s4.create(...)
249 local id = TypedSection.create(...)
250 luci.http.redirect(s4.extedit % id)
254 o = s4:option(Flag, "ignore", translate("Enable"))
257 function o.cfgvalue(...)
258 local v = Flag.cfgvalue(...)
259 return v == "1" and "0" or "1"
261 function o.write(self, section, value)
262 Flag.write(self, section, value == "1" and "0" or "1")
265 o = s4:option(DummyValue, "interface", translate("Interface"))
266 o.template = "cbi/network_netinfo"
269 o = s4:option(DummyValue, "addr", translate("Address"))
271 o.cfgvalue = pfx.cfgvalue
273 o = s4:option(DummyValue, "AdvRDNSSLifetime", translate("Lifetime"))
274 function o.cfgvalue(self, section)
275 local v = Value.cfgvalue(self, section) or "1200"
284 s5 = m:section(TypedSection, "dnssl", translate("DNSSL"))
285 s5.template = "cbi/tblsection"
286 s5.extedit = luci.dispatcher.build_url("admin/network/radvd/dnssl/%s")
290 function s5.create(...)
291 local id = TypedSection.create(...)
292 luci.http.redirect(s5.extedit % id)
296 o = s5:option(Flag, "ignore", translate("Enable"))
299 function o.cfgvalue(...)
300 local v = Flag.cfgvalue(...)
301 return v == "1" and "0" or "1"
303 function o.write(self, section, value)
304 Flag.write(self, section, value == "1" and "0" or "1")
307 o = s5:option(DummyValue, "interface", translate("Interface"))
308 o.template = "cbi/network_netinfo"
311 o = s5:option(DummyValue, "suffix", translate("Suffix"))
313 function o.cfgvalue(self, section)
314 local v = m.uci:get_list("radvd", section, "suffix")
317 for v in ut.imatch(v) do
325 return table.concat(l, ", ")
328 o = s5:option(DummyValue, "AdvDNSSLLifetime", translate("Lifetime"))
329 function o.cfgvalue(self, section)
330 local v = Value.cfgvalue(self, section) or "1200"