summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-olsr/luasrc/controller
diff options
context:
space:
mode:
authorPatrick Grimm <patrick@lunatiki.de>2014-07-30 19:11:04 +0000
committerPatrick Grimm <patrick@lunatiki.de>2014-07-30 19:11:04 +0000
commit2332a0692c7c9f1bcbc1d48fe20192ceaed6b6e4 (patch)
treeaf4fb0f9095e8f1826998c29fd5e41e50abecb1a /applications/luci-olsr/luasrc/controller
parent33d88f9b54efe40ddecbef0d594ec90662efdc36 (diff)
luci-olsr split IPv6/4 configuration in 2 sections
Diffstat (limited to 'applications/luci-olsr/luasrc/controller')
-rw-r--r--applications/luci-olsr/luasrc/controller/olsr.lua61
-rw-r--r--applications/luci-olsr/luasrc/controller/olsr4.lua47
-rw-r--r--applications/luci-olsr/luasrc/controller/olsr6.lua47
3 files changed, 106 insertions, 49 deletions
diff --git a/applications/luci-olsr/luasrc/controller/olsr.lua b/applications/luci-olsr/luasrc/controller/olsr.lua
index 44849dfcce..b5698eecba 100644
--- a/applications/luci-olsr/luasrc/controller/olsr.lua
+++ b/applications/luci-olsr/luasrc/controller/olsr.lua
@@ -1,7 +1,14 @@
module("luci.controller.olsr", package.seeall)
function index()
- if not nixio.fs.access("/etc/config/olsrd") then
+ local ipv4,ipv6
+ if nixio.fs.access("/etc/config/olsrd") then
+ ipv4 = 1
+ end
+ if nixio.fs.access("/etc/config/olsrd6") then
+ ipv6 = 1
+ end
+ if not ipv4 and not ipv6 then
return
end
@@ -60,46 +67,11 @@ function index()
page.title = _("Interfaces")
page.order = 70
- local ol = entry(
- {"admin", "services", "olsrd"},
- cbi("olsr/olsrd"), "OLSR"
- )
- ol.subindex = true
-
- entry(
- {"admin", "services", "olsrd", "iface"},
- cbi("olsr/olsrdiface")
- ).leaf = true
-
- entry(
- {"admin", "services", "olsrd", "hna"},
- cbi("olsr/olsrdhna"), _("HNA Announcements")
- )
-
- oplg = entry(
- {"admin", "services", "olsrd", "plugins"},
- cbi("olsr/olsrdplugins"), _("Plugins")
- )
-
odsp = entry(
{"admin", "services", "olsrd", "display"},
cbi("olsr/olsrddisplay"), _("Display")
)
- oplg.leaf = true
- oplg.subindex = true
-
- local uci = require("luci.model.uci").cursor()
- uci:foreach("olsrd", "LoadPlugin",
- function (section)
- local lib = section.library
- entry(
- {"admin", "services", "olsrd", "plugins", lib },
- cbi("olsr/olsrdplugins"),
- nil --'Plugin "%s"' % lib:gsub("^olsrd_",""):gsub("%.so.+$","")
- )
- end
- )
end
function action_json()
@@ -109,13 +81,8 @@ function action_json()
local jsonreq4
local jsonreq6
- local IpVersion = uci:get_first("olsrd", "olsrd","IpVersion")
- if IpVersion == "4" or IpVersion == "6and4" then
- jsonreq4 = utl.exec("echo /status | nc 127.0.0.1 9090")
- end
- if IpVersion == "6" or IpVersion == "6and4" then
- jsonreq6 = utl.exec("echo /status | nc ::1 9090")
- end
+ jsonreq4 = utl.exec("echo /status | nc 127.0.0.1 9090")
+ jsonreq6 = utl.exec("echo /status | nc ::1 9090")
http.prepare_content("application/json")
if not jsonreq4 or jsonreq4 == "" then
jsonreq4 = "{}"
@@ -394,12 +361,8 @@ function fetch_jsoninfo(otable)
local IpVersion = uci:get_first("olsrd", "olsrd","IpVersion")
local jsonreq4 = ""
local jsonreq6 = ""
- if IpVersion == "4" or IpVersion == "6and4" then
- jsonreq4 = utl.exec("echo /" .. otable .. " | nc 127.0.0.1 9090")
- end
- if IpVersion == "6" or IpVersion == "6and4" then
- jsonreq6 = utl.exec("echo /" .. otable .. " | nc ::1 9090")
- end
+ jsonreq4 = utl.exec("echo /" .. otable .. " | nc 127.0.0.1 9090")
+ jsonreq6 = utl.exec("echo /" .. otable .. " | nc ::1 9090")
local jsondata4 = {}
local jsondata6 = {}
local data4 = {}
diff --git a/applications/luci-olsr/luasrc/controller/olsr4.lua b/applications/luci-olsr/luasrc/controller/olsr4.lua
new file mode 100644
index 0000000000..31a3101bc2
--- /dev/null
+++ b/applications/luci-olsr/luasrc/controller/olsr4.lua
@@ -0,0 +1,47 @@
+module("luci.controller.olsr4", package.seeall)
+
+function index()
+ if not nixio.fs.access("/etc/config/olsrd") then
+ return
+ end
+
+ require("luci.model.uci")
+ local uci = luci.model.uci.cursor_state()
+
+ local ol = entry(
+ {"admin", "services", "olsrd"},
+ cbi("olsr/olsrd"), "OLSR IPv4"
+ )
+ ol.subindex = true
+
+ entry(
+ {"admin", "services", "olsrd", "iface"},
+ cbi("olsr/olsrdiface")
+ ).leaf = true
+
+ entry(
+ {"admin", "services", "olsrd", "hna"},
+ cbi("olsr/olsrdhna"), _("HNA Announcements")
+ )
+
+ oplg = entry(
+ {"admin", "services", "olsrd", "plugins"},
+ cbi("olsr/olsrdplugins"), _("Plugins")
+ )
+
+ oplg.leaf = true
+ oplg.subindex = true
+
+ local uci = require("luci.model.uci").cursor()
+ uci:foreach("olsrd", "LoadPlugin",
+ function (section)
+ local lib = section.library
+ entry(
+ {"admin", "services", "olsrd", "plugins", lib },
+ cbi("olsr/olsrdplugins"),
+ nil --'Plugin "%s"' % lib:gsub("^olsrd_",""):gsub("%.so.+$","")
+ )
+ end
+ )
+end
+
diff --git a/applications/luci-olsr/luasrc/controller/olsr6.lua b/applications/luci-olsr/luasrc/controller/olsr6.lua
new file mode 100644
index 0000000000..9fbaa0427b
--- /dev/null
+++ b/applications/luci-olsr/luasrc/controller/olsr6.lua
@@ -0,0 +1,47 @@
+module("luci.controller.olsr6", package.seeall)
+
+function index()
+ if not nixio.fs.access("/etc/config/olsrd6") then
+ return
+ end
+
+ require("luci.model.uci")
+ local uci = luci.model.uci.cursor_state()
+
+ local ol = entry(
+ {"admin", "services", "olsrd6"},
+ cbi("olsr/olsrd6"), "OLSR IPv6"
+ )
+ ol.subindex = true
+
+ entry(
+ {"admin", "services", "olsrd6", "iface"},
+ cbi("olsr/olsrdiface6")
+ ).leaf = true
+
+ entry(
+ {"admin", "services", "olsrd6", "hna"},
+ cbi("olsr/olsrdhna6"), _("HNA6 Announcements")
+ )
+
+ oplg = entry(
+ {"admin", "services", "olsrd6", "plugins"},
+ cbi("olsr/olsrdplugins6"), _("Plugins")
+ )
+
+ oplg.leaf = true
+ oplg.subindex = true
+
+ local uci = require("luci.model.uci").cursor()
+ uci:foreach("olsrd6", "LoadPlugin",
+ function (section)
+ local lib = section.library
+ entry(
+ {"admin", "services", "olsrd6", "plugins", lib },
+ cbi("olsr/olsrdplugins6"),
+ nil --'Plugin "%s"' % lib:gsub("^olsrd_",""):gsub("%.so.+$","")
+ )
+ end
+ )
+end
+