Globally reduce copyright headers
[project/luci.git] / applications / luci-app-radvd / luasrc / model / cbi / radvd / dnssl.lua
1 -- Copyright 2010 Jo-Philipp Wich <xm@subsignal.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 - DNSSL"),
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) ~= "dnssl" then
15 luci.http.redirect(m.redirect)
16 return
17 end
18
19
20 s = m:section(NamedSection, sid, "interface", translate("DNSSL Configuration"))
21 s.addremove = false
22
23
24 --
25 -- General
26 --
27
28 o = s:option(Flag, "ignore", translate("Enable"))
29 o.rmempty = false
30
31 function o.cfgvalue(...)
32 local v = Flag.cfgvalue(...)
33 return v == "1" and "0" or "1"
34 end
35
36 function o.write(self, section, value)
37 Flag.write(self, section, value == "1" and "0" or "1")
38 end
39
40
41 o = s:option(Value, "interface", translate("Interface"),
42 translate("Specifies the logical interface name this section belongs to"))
43
44 o.template = "cbi/network_netlist"
45 o.nocreate = true
46 o.optional = false
47
48 function o.formvalue(...)
49 return Value.formvalue(...) or "-"
50 end
51
52 function o.validate(self, value)
53 if value == "-" then
54 return nil, translate("Interface required")
55 end
56 return value
57 end
58
59 function o.write(self, section, value)
60 m.uci:set("radvd", section, "ignore", 0)
61 m.uci:set("radvd", section, "interface", value)
62 end
63
64
65 o = s:option(DynamicList, "suffix", translate("Suffix"),
66 translate("Advertised Domain Suffixes"))
67
68 o.optional = false
69 o.rmempty = false
70 o.datatype = "hostname"
71 function o.cfgvalue(self, section)
72 local l = { }
73 local v = m.uci:get_list("radvd", section, "suffix")
74 for v in utl.imatch(v) do
75 l[#l+1] = v
76 end
77 return l
78 end
79
80
81 o = s:option(Value, "AdvDNSSLLifetime", translate("Lifetime"),
82 translate("Specifies the maximum duration how long the DNSSL entries are used for name resolution."))
83
84 o.datatype = 'or(uinteger,"infinity")'
85 o.placeholder = 1200
86
87
88 return m