applications/luci-radvd: sync with OpenWrt trunk changes
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 29 Jan 2011 03:27:37 +0000 (03:27 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 29 Jan 2011 03:27:37 +0000 (03:27 +0000)
applications/luci-radvd/luasrc/controller/radvd.lua
applications/luci-radvd/luasrc/model/cbi/radvd.lua
applications/luci-radvd/luasrc/model/cbi/radvd/interface.lua
applications/luci-radvd/luasrc/model/cbi/radvd/prefix.lua
applications/luci-radvd/luasrc/model/cbi/radvd/rdnss.lua
applications/luci-radvd/luasrc/model/cbi/radvd/route.lua

index 1b403a8..6ed1176 100644 (file)
@@ -24,4 +24,5 @@ function index()
        entry({"admin", "network", "radvd", "prefix"}, cbi("radvd/prefix"), nil).leaf = true
        entry({"admin", "network", "radvd", "route"}, cbi("radvd/route"), nil).leaf = true
        entry({"admin", "network", "radvd", "rdnss"}, cbi("radvd/rdnss"), nil).leaf = true
+       entry({"admin", "network", "radvd", "dnssl"}, cbi("radvd/dnssl"), nil).leaf = true
 end
index 18df46b..5ee1969 100644 (file)
@@ -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)
index ae8e062..519664c 100644 (file)
@@ -13,6 +13,7 @@ $Id$
 ]]--
 
 local sid = arg[1]
+local utl = require "luci.util"
 
 m = Map("radvd", translatef("Radvd - Interface %q", "?"),
        translate("Radvd is a router advertisement daemon for IPv6. " ..
@@ -84,6 +85,22 @@ function o.write(self, section, value)
 end
 
 
+o = s:taboption("general", DynamicList, "client", translate("Clients"),
+       translate("Restrict communication to specified clients, leave empty to use multicast"))
+
+o.rmempty     = true
+o.datatype    = "ip6addr"
+o.placeholder = "any"
+function o.cfgvalue(...)
+       local v = Value.cfgvalue(...)
+       local l = { }
+       for v in utl.imatch(v) do
+               l[#l+1] = v
+       end
+       return l
+end
+
+
 o = s:taboption("general", Flag, "AdvSendAdvert", translate("Enable advertisements"),
        translate("Enables router advertisements and solicitations"))
 
index d3567cb..6151910 100644 (file)
@@ -13,6 +13,7 @@ $Id$
 ]]--
 
 local sid = arg[1]
+local utl = require "luci.util"
 
 m = Map("radvd", translatef("Radvd - Prefix"),
        translate("Radvd is a router advertisement daemon for IPv6. " ..
@@ -75,11 +76,20 @@ function o.write(self, section, value)
 end
 
 
-o = s:taboption("general", Value, "prefix", translate("Prefix"),
-       translate("Advertised IPv6 prefix. If empty, the current interface prefix is used"))
+o = s:taboption("general", DynamicList, "prefix", translate("Prefixes"),
+       translate("Advertised IPv6 prefixes. If empty, the current interface prefix is used"))
 
-o.optional = true
-o.datatype = "ip6addr"
+o.optional    = true
+o.datatype    = "ip6addr"
+o.placeholder = translate("default")
+function o.cfgvalue(self, section)
+       local l = { }
+       local v = m.uci:get_list("radvd", section, "prefix")
+       for v in utl.imatch(v) do
+               l[#l+1] = v
+       end
+       return l
+end
 
 
 o = s:taboption("general", Flag, "AdvOnLink", translate("On-link determination"),
index 91cf25c..5313bbe 100644 (file)
@@ -13,6 +13,7 @@ $Id$
 ]]--
 
 local sid = arg[1]
+local utl = require "luci.util"
 
 m = Map("radvd", translatef("Radvd - RDNSS"),
        translate("Radvd is a router advertisement daemon for IPv6. " ..
@@ -72,16 +73,21 @@ function o.write(self, section, value)
 end
 
 
-o = s:option(Value, "addr", translate("Address"),
+o = s:option(DynamicList, "addr", translate("Addresses"),
        translate("Advertised IPv6 RDNSS. If empty, the current IPv6 address of the interface is used"))
 
-o.optional = false
-o.rmempty  = true
-o.datatype = "ip6addr"
-
-
-o = s:option(Flag, "AdvRDNSSOpen", translate("Open"),
-       translate("Indicates whether that RDNSS continues to be available to hosts even if they moved to a different subnet "))
+o.optional    = false
+o.rmempty     = true
+o.datatype    = "ip6addr"
+o.placeholder = translate("default")
+function o.cfgvalue(self, section)
+       local l = { }
+       local v = m.uci:get_list("radvd", section, "prefix")
+       for v in utl.imatch(v) do
+               l[#l+1] = v
+       end
+       return l
+end
 
 
 o = s:option(Value, "AdvRDNSSLifetime", translate("Lifetime"),
index 6e84d0f..37fac57 100644 (file)
@@ -13,6 +13,7 @@ $Id$
 ]]--
 
 local sid = arg[1]
+local utl = require "luci.util"
 
 m = Map("radvd", translatef("Radvd - Route"),
        translate("Radvd is a router advertisement daemon for IPv6. " ..
@@ -72,11 +73,20 @@ function o.write(self, section, value)
 end
 
 
-o = s:option(Value, "prefix", translate("Prefix"),
-       translate("Advertised IPv6 prefix"))
+o = s:option(DynamicList, "prefix", translate("Prefixes"),
+       translate("Advertised IPv6 prefixes"))
 
-o.rmempty = false
-o.datatype = "ip6addr"
+o.rmempty     = false
+o.datatype    = "ip6addr"
+o.placeholder = translate("default")
+function o.cfgvalue(self, section)
+       local l = { }
+       local v = m.uci:get_list("radvd", section, "prefix")
+       for v in utl.imatch(v) do
+               l[#l+1] = v
+       end
+       return l
+end
 
 
 o = s:option(Value, "AdvRouteLifetime", translate("Lifetime"),