ec67f308aec566ed945728fd66c9950fa9603cdc
[project/luci.git] / applications / luci-app-radvd / luasrc / model / cbi / radvd / dnssl.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: rdnss.lua 6715 2011-01-13 20:03:40Z jow $
13 ]]--
14
15 local sid = arg[1]
16 local utl = require "luci.util"
17
18 m = Map("radvd", translatef("Radvd - DNSSL"),
19         translate("Radvd is a router advertisement daemon for IPv6. " ..
20                 "It listens to router solicitations and sends router advertisements " ..
21                 "as described in RFC 4861."))
22
23 m.redirect = luci.dispatcher.build_url("admin/network/radvd")
24
25 if m.uci:get("radvd", sid) ~= "dnssl" then
26         luci.http.redirect(m.redirect)
27         return
28 end
29
30
31 s = m:section(NamedSection, sid, "interface", translate("DNSSL Configuration"))
32 s.addremove = false
33
34
35 --
36 -- General
37 --
38
39 o = s:option(Flag, "ignore", translate("Enable"))
40 o.rmempty = false
41
42 function o.cfgvalue(...)
43         local v = Flag.cfgvalue(...)
44         return v == "1" and "0" or "1"
45 end
46
47 function o.write(self, section, value)
48         Flag.write(self, section, value == "1" and "0" or "1")
49 end
50
51
52 o = s:option(Value, "interface", translate("Interface"),
53         translate("Specifies the logical interface name this section belongs to"))
54
55 o.template = "cbi/network_netlist"
56 o.nocreate = true
57 o.optional = false
58
59 function o.formvalue(...)
60         return Value.formvalue(...) or "-"
61 end
62
63 function o.validate(self, value)
64         if value == "-" then
65                 return nil, translate("Interface required")
66         end
67         return value
68 end
69
70 function o.write(self, section, value)
71         m.uci:set("radvd", section, "ignore", 0)
72         m.uci:set("radvd", section, "interface", value)
73 end
74
75
76 o = s:option(DynamicList, "suffix", translate("Suffix"),
77         translate("Advertised Domain Suffixes"))
78
79 o.optional    = false
80 o.rmempty     = false
81 o.datatype    = "hostname"
82 function o.cfgvalue(self, section)
83         local l = { }
84         local v = m.uci:get_list("radvd", section, "suffix")
85         for v in utl.imatch(v) do
86                 l[#l+1] = v
87         end
88         return l
89 end
90
91
92 o = s:option(Value, "AdvDNSSLLifetime", translate("Lifetime"),
93         translate("Specifies the maximum duration how long the DNSSL entries are used for name resolution."))
94
95 o.datatype = 'or(uinteger,"infinity")'
96 o.placeholder = 1200
97
98
99 return m