summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-radvd/luasrc/model/cbi/radvd.lua
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-01-29 03:27:37 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-01-29 03:27:37 +0000
commita707d2cb84459d8f92eebadec86eeefb16c0548e (patch)
tree2890b55c1c7c2420211d232bec113a472ac4e57c /applications/luci-radvd/luasrc/model/cbi/radvd.lua
parentc2b107ed46571a1494d74d4c1af3bb22b8b2f821 (diff)
applications/luci-radvd: sync with OpenWrt trunk changes
Diffstat (limited to 'applications/luci-radvd/luasrc/model/cbi/radvd.lua')
-rw-r--r--applications/luci-radvd/luasrc/model/cbi/radvd.lua118
1 files changed, 99 insertions, 19 deletions
diff --git a/applications/luci-radvd/luasrc/model/cbi/radvd.lua b/applications/luci-radvd/luasrc/model/cbi/radvd.lua
index 18df46b19..5ee196942 100644
--- a/applications/luci-radvd/luasrc/model/cbi/radvd.lua
+++ b/applications/luci-radvd/luasrc/model/cbi/radvd.lua
@@ -18,6 +18,7 @@ m = Map("radvd", translate("Radvd"),
"as described in RFC 4861."))
local nm = require "luci.model.network".init(m.uci)
+local ut = require "luci.util"
--
@@ -69,9 +70,10 @@ o.template = "cbi/network_netinfo"
o.width = "10%"
o = s:option(DummyValue, "UnicastOnly", translate("Multicast"))
-function o.cfgvalue(...)
- local v = Value.cfgvalue(...)
- return v == "1" and translate("no") or translate("yes")
+function o.cfgvalue(self, section)
+ local v = Value.cfgvalue(self, section)
+ local v2 = m.uci:get("radvd", section, "client")
+ return (v == "1" or (v2 and #v2 > 0)) and translate("no") or translate("yes")
end
o = s:option(DummyValue, "AdvSendAdvert", translate("Advertising"))
@@ -133,7 +135,9 @@ o.width = "10%"
o = s2:option(DummyValue, "prefix", translate("Prefix"))
o.width = "60%"
function o.cfgvalue(self, section)
- local v = Value.cfgvalue(self, section)
+ local v = m.uci:get_list("radvd", section, "prefix")
+ local l = { }
+
if not v then
local net = nm:get_network(m.uci:get("radvd", section, "interface"))
if net then
@@ -149,12 +153,20 @@ function o.cfgvalue(self, section)
end
end
end
- else
+ end
+
+ for v in ut.imatch(v) do
v = luci.ip.IPv6(v)
- v = v and v:string()
+ if v then
+ l[#l+1] = v:string()
+ end
+ end
+
+ if #l == 0 then
+ l[1] = "?"
end
- return v or "?"
+ return table.concat(l, ", ")
end
o = s2:option(DummyValue, "AdvAutonomous", translate("Autonomous"))
@@ -210,12 +222,22 @@ o.width = "10%"
o = s3:option(DummyValue, "prefix", translate("Prefix"))
o.width = "60%"
function o.cfgvalue(self, section)
- local v = Value.cfgvalue(self, section)
+ local v = m.uci:get_list("radvd", section, "prefix")
+ local l = { }
if v then
- v = luci.ip.IPv6(v)
- v = v and v:string()
+ for v in ut.imatch(v) do
+ v = luci.ip.IPv6(v)
+ if v then
+ l[#l+1] = v:string()
+ end
+ end
end
- return v or "?"
+
+ if #l == 0 then
+ l[1] = "?"
+ end
+
+ return table.concat(l, ", ")
end
o = s3:option(DummyValue, "AdvRouteLifetime", translate("Lifetime"))
@@ -265,7 +287,8 @@ o.width = "10%"
o = s4:option(DummyValue, "addr", translate("Address"))
o.width = "60%"
function o.cfgvalue(self, section)
- local v = Value.cfgvalue(self, section)
+ local v = m.uci:get_list("radvd", section, "addr")
+ local l = { }
if not v then
local net = nm:get_network(m.uci:get("radvd", section, "interface"))
if net then
@@ -281,21 +304,78 @@ function o.cfgvalue(self, section)
end
end
end
- else
+ end
+
+ for v in ut.imatch(v) do
v = luci.ip.IPv6(v)
- v = v and v:network(128):string()
+ if v then
+ l[#l+1] = v:network(128):string()
+ end
+ end
+
+ if #l == 0 then
+ l[1] = "?"
end
- return v or "?"
+ return table.concat(l, ", ")
end
-o = s4:option(DummyValue, "AdvRDNSSOpen", translate("Open"))
+o = s4:option(DummyValue, "AdvRDNSSLifetime", translate("Lifetime"))
function o.cfgvalue(self, section)
- local v = Value.cfgvalue(self, section)
- return v == "1" and translate("yes") or translate("no")
+ local v = Value.cfgvalue(self, section) or "1200"
+ return translate(v)
end
-o = s4:option(DummyValue, "AdvRDNSSLifetime", translate("Lifetime"))
+
+--
+-- DNSSL
+--
+
+s4 = m:section(TypedSection, "dnssl", translate("DNSSL"))
+s4.template = "cbi/tblsection"
+s4.extedit = luci.dispatcher.build_url("admin/network/radvd/dnssl/%s")
+s4.addremove = true
+s4.anonymous = true
+
+function s.create(...)
+ local id = TypedSection.create(...)
+ luci.http.redirect(s4.extedit % id)
+end
+
+
+o = s4:option(Flag, "ignore", translate("Enable"))
+o.rmempty = false
+o.width = "30px"
+function o.cfgvalue(...)
+ local v = Flag.cfgvalue(...)
+ return v == "1" and "0" or "1"
+end
+function o.write(self, section, value)
+ Flag.write(self, section, value == "1" and "0" or "1")
+end
+
+o = s4:option(DummyValue, "interface", translate("Interface"))
+o.template = "cbi/network_netinfo"
+o.width = "10%"
+
+o = s4:option(DummyValue, "suffix", translate("Suffix"))
+o.width = "60%"
+function o.cfgvalue(self, section)
+ local v = m.uci:get_list("radvd", section, "suffix")
+ local l = { }
+
+ for v in ut.imatch(v) do
+ l[#l+1] = v
+ end
+
+ if #l == 0 then
+ l[1] = "?"
+ end
+
+ return table.concat(l, ", ")
+end
+
+o = s4:option(DummyValue, "AdvDNSSLLifetime", translate("Lifetime"))
function o.cfgvalue(self, section)
local v = Value.cfgvalue(self, section) or "1200"
return translate(v)