* luci/app-olsr: fix olsrplugins page
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 13 Sep 2008 05:17:20 +0000 (05:17 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 13 Sep 2008 05:17:20 +0000 (05:17 +0000)
applications/luci-olsr/luasrc/model/cbi/olsr/olsrd.lua
applications/luci-olsr/luasrc/model/cbi/olsr/olsrdplugins.lua

index 7e134cc6d5a637f8ebe19b9e03aaa8af307ac783..1ea3d9762b88640dd103a6b61a48196d77381b7c 100644 (file)
@@ -120,7 +120,7 @@ adc.disabled = "no"
 adc.optional = true
 
 
-ipc = m:section(NamedSection, "IpcConnect")
+ipc = m:section(TypedSection, "IpcConnect")
 conns = ipc:option(Value, "MaxConnections")
 conns.isInteger = true
 
index 83ed74ac9091ce754279cc92005dc3d8caf358c2..236276d472081ea5f605632656d65cdd05f39374 100644 (file)
@@ -25,6 +25,7 @@ p.anonymous = true
 ign = p:option(Flag, "ignore")
 ign.enabled  = "1"
 ign.disabled = "0"
+ign.optional = true
 
 lib = p:option(ListValue, "library", translate("library"))
 lib:value("")
@@ -41,19 +42,34 @@ local function Range(x,y)
 end
 
 local function Cidr2IpMask(val)
-       local cidr = luci.ip.IPv4(val) or luci.ip.IPv6(val)
-       if not cidr then return val else return cidr end
+       if val then
+               for i = 1, #val do
+                       local cidr = luci.ip.IPv4(val[i]) or luci.ip.IPv6(val[i])
+                       if cidr then
+                               val[i] = cidr:network():string() .. " " .. cidr:mask():string()
+                       end
+               end
+               return val
+       end
 end
 
 local function IpMask2Cidr(val)
-       local ip, mask = val:gmatch("([^%s+])%s+([^%s+])")
-       local cidr
-       if ip and mask and ip:match(":") then
-               cidr = luci.ip.IPv6(ip, mask)
-       elseif ip and mask then
-               cidr = luci.ip.IPv4(ip, mask)
+       if val then
+               for i = 1, #val do
+                       local ip, mask = val[i]:gmatch("([^%s+])%s+([^%s+])")()
+                       local cidr
+                       if ip and mask and ip:match(":") then
+                               cidr = luci.ip.IPv6(ip, mask)
+                       elseif ip and mask then
+                               cidr = luci.ip.IPv4(ip, mask)
+                       end
+
+                       if cidr then
+                               val[i] = cidr:string()
+                       end
+               end
+               return val
        end
-       if not cidr then return val else return cidr end
 end
 
 
@@ -66,19 +82,19 @@ local knownPlParams = {
                { ListValue,    "BmfMechanism",                 { "UnicastPromiscuous", "Broadcast" } },
                { Value,                "BroadcastRetransmitCount",     "2" },
                { Value,                "FanOutLimit",                  "4" },
-               { DynamicList,  "NonOlsrIf",                    "eth1" },
+               { DynamicList,  "NonOlsrIf",                    "eth1" }
        },
 
        ["olsrd_dyn_gw.so.0.4"] = {
                { Value,                "Interval",                             "40" },
                { DynamicList,  "Ping",                                 "141.1.1.1" },
-               { DynamicList,  "HNA",                                  "192.168.80.0/24", Cidr2IpMask, IpMask2Cidr }
+               { DynamicList,  "HNA",                                  "192.168.80.0/24", IpMask2Cidr, Cidr2IpMask }
        },
 
        ["olsrd_httpinfo.so.0.1"] = {
                { Value,                "port",                                 "80" },
                { DynamicList,  "Host",                                 "163.24.87.3" },
-               { DynamicList,  "Net",                                  "0.0.0.0/0", Cidr2IpMask, IpMask2Cidr },
+               { DynamicList,  "Net",                                  "0.0.0.0/0", IpMask2Cidr, Cidr2IpMask }
        },
 
        ["olsrd_nameservice.so.0.2"] = {
@@ -165,6 +181,9 @@ for plugin, options in pairs(knownPlParams) do
                                        return cbi2uci(otype.formvalue(self, section))
                                end
                        end
+                       if otype == DynamicList then
+                               field:value( default )
+                       end
                        field.default = default
                        field:depends({ library = plugin })
                end