1 -- Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
5 local utl = require "luci.util"
7 m = Map("radvd", translatef("Radvd - Prefix"),
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."))
12 m.redirect = luci.dispatcher.build_url("admin/network/radvd")
14 if m.uci:get("radvd", sid) ~= "prefix" then
15 luci.http.redirect(m.redirect)
20 s = m:section(NamedSection, sid, "interface", translate("Prefix Configuration"))
23 s:tab("general", translate("General"))
24 s:tab("advanced", translate("Advanced"))
31 o = s:taboption("general", Flag, "ignore", translate("Enable"))
34 function o.cfgvalue(...)
35 local v = Flag.cfgvalue(...)
36 return v == "1" and "0" or "1"
39 function o.write(self, section, value)
40 Flag.write(self, section, value == "1" and "0" or "1")
44 o = s:taboption("general", Value, "interface", translate("Interface"),
45 translate("Specifies the logical interface name this section belongs to"))
47 o.template = "cbi/network_netlist"
51 function o.formvalue(...)
52 return Value.formvalue(...) or "-"
55 function o.validate(self, value)
57 return nil, translate("Interface required")
62 function o.write(self, section, value)
63 m.uci:set("radvd", section, "ignore", 0)
64 m.uci:set("radvd", section, "interface", value)
68 o = s:taboption("general", DynamicList, "prefix", translate("Prefixes"),
69 translate("Advertised IPv6 prefixes. If empty, the current interface prefix is used"))
72 o.datatype = "ip6addr"
73 o.placeholder = translate("default")
74 function o.cfgvalue(self, section)
76 local v = m.uci:get_list("radvd", section, "prefix")
77 for v in utl.imatch(v) do
84 o = s:taboption("general", Flag, "AdvOnLink", translate("On-link determination"),
85 translate("Indicates that this prefix can be used for on-link determination (RFC4861)"))
91 o = s:taboption("general", Flag, "AdvAutonomous", translate("Autonomous"),
92 translate("Indicates that this prefix can be used for autonomous address configuration (RFC4862)"))
102 o = s:taboption("advanced", Flag, "AdvRouterAddr", translate("Advertise router address"),
103 translate("Indicates that the address of interface is sent instead of network prefix, as is required by Mobile IPv6"))
106 o = s:taboption("advanced", Value, "AdvValidLifetime", translate("Valid lifetime"),
107 translate("Advertises the length of time in seconds that the prefix is valid for the purpose of on-link determination."))
109 o.datatype = 'or(uinteger,"infinity")'
110 o.placeholder = 86400
113 o = s:taboption("advanced", Value, "AdvPreferredLifetime", translate("Preferred lifetime"),
114 translate("Advertises the length of time in seconds that addresses generated from the prefix via stateless address autoconfiguration remain preferred."))
116 o.datatype = 'or(uinteger,"infinity")'
117 o.placeholder = 14400
120 o = s:taboption("advanced", Value, "Base6to4Interface", translate("6to4 interface"),
121 translate("Specifies a logical interface name to derive a 6to4 prefix from. The interfaces public IPv4 address is combined with 2002::/3 and the value of the prefix option"))
123 o.template = "cbi/network_netlist"