convert luci.fs users to nixio.fs api
[project/luci.git] / applications / luci-olsr / luasrc / model / cbi / olsr / olsrdplugins.lua
index 6a498a5..f81a4a4 100644 (file)
@@ -2,6 +2,7 @@
 LuCI - Lua Configuration Interface
 
 Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
@@ -12,9 +13,8 @@ You may obtain a copy of the License at
 $Id$
 ]]--
 
-require("luci.fs")
-require("luci.ip")
-
+local ip = require "luci.ip"
+local fs = require "nixio.fs"
 
 if arg[1] then
        mp = Map("olsrd", translate("olsrd_plugins", "OLSR - Plugins"))
@@ -26,6 +26,7 @@ if arg[1] then
        ign = p:option(Flag, "ignore", "Enable")
        ign.enabled  = "0"
        ign.disabled = "1"
+       ign.rmempty  = false
        function ign.cfgvalue(self, section)
                return Flag.cfgvalue(self, section) or "0"
        end
@@ -42,7 +43,7 @@ if arg[1] then
        local function Cidr2IpMask(val)
                if val then
                        for i = 1, #val do
-                               local cidr = luci.ip.IPv4(val[i]) or luci.ip.IPv6(val[i])
+                               local cidr = ip.IPv4(val[i]) or ip.IPv6(val[i])
                                if cidr then
                                        val[i] = cidr:network():string() .. " " .. cidr:mask():string()
                                end
@@ -54,12 +55,12 @@ if arg[1] then
        local function IpMask2Cidr(val)
                if val then
                        for i = 1, #val do
-                               local ip, mask = val[i]:gmatch("([^%s+])%s+([^%s+])")()
+                               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)
+                                       cidr = ip.IPv6(ip, mask)
                                elseif ip and mask then
-                                       cidr = luci.ip.IPv4(ip, mask)
+                                       cidr = ip.IPv4(ip, mask)
                                end
 
                                if cidr then
@@ -80,7 +81,7 @@ if arg[1] then
                        { ListValue,    "BmfMechanism",                 { "UnicastPromiscuous", "Broadcast" } },
                        { Value,                "BroadcastRetransmitCount",     "2" },
                        { Value,                "FanOutLimit",                  "4" },
-                       { DynamicList,  "NonOlsrIf",                    "eth1" }
+                       { DynamicList,  "NonOlsrIf",                    "br-lan" }
                },
 
                ["olsrd_dyn_gw.so.0.4"] = {
@@ -132,6 +133,15 @@ if arg[1] then
                        { Value,                "accept",                               "10.247.200.4" }
                },
 
+               ["olsrd_watchdog.so.0.1"] = {
+                       { Value,                "file",                                 "/var/run/olsrd.watchdog" },
+                       { Value,                "interval",                             "30" }
+               },
+
+               ["olsrd_mdns.so.1.0.0"] = {
+                       { DynamicList,  "NonOlsrIf",                    "br-lan" }
+               },
+
                ["olsrd_arprefresh.so.0.1"]             = {},
                ["olsrd_dot_draw.so.0.3"]               = {},
                ["olsrd_dyn_gw_plain.so.0.4"]   = {},
@@ -209,7 +219,7 @@ else
        )
 
        -- create a loadplugin section for each found plugin
-       for k, v in pairs(luci.fs.dir("/usr/lib")) do
+       for v in fs.dir("/usr/lib") do
                if v:sub(1, 6) == "olsrd_" then
                        if not plugins[v] then
                                mpi.uci:section(
@@ -230,8 +240,9 @@ else
        end
 
        ign = t:option( Flag, "ignore", "Enabled" )
-       ign.enabled = "0"
+       ign.enabled  = "0"
        ign.disabled = "1"
+       ign.rmempty  = false
        function ign.cfgvalue(self, section)
                return Flag.cfgvalue(self, section) or "0"
        end