* luci-0.8: backport luci-app-olsr improvements
This commit is contained in:
parent
a730476b78
commit
e81501aed4
11 changed files with 456 additions and 101 deletions
4
applications/luci-olsr/ipkg/postinst
Executable file
4
applications/luci-olsr/ipkg/postinst
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
[ -n "${IPKG_INSTROOT}" ] || {
|
||||
( . /etc/uci-defaults/luci-olsr ) && rm -f /etc/uci-defaults/luci-olsr
|
||||
}
|
|
@ -1,145 +1,172 @@
|
|||
module("luci.controller.olsr", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.isfile("/etc/config/olsr") then
|
||||
if not luci.fs.isfile("/etc/config/olsrd") then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
require("luci.i18n").loadc("olsr")
|
||||
local i18n = luci.i18n.translate
|
||||
|
||||
|
||||
local page = node("admin", "status", "olsr")
|
||||
page.target = call("action_index")
|
||||
page.title = "OLSR"
|
||||
page.i18n = "olsr"
|
||||
|
||||
|
||||
local page = node("admin", "status", "olsr", "routes")
|
||||
page.target = call("action_routes")
|
||||
page.title = i18n("olsr_routes", "Routen")
|
||||
page.order = 10
|
||||
|
||||
|
||||
local page = node("admin", "status", "olsr", "topology")
|
||||
page.target = call("action_topology")
|
||||
page.title = i18n("olsr_topology", "Topologie")
|
||||
page.order = 20
|
||||
|
||||
|
||||
local page = node("admin", "status", "olsr", "hna")
|
||||
page.target = call("action_hna")
|
||||
page.title = "HNA"
|
||||
page.order = 30
|
||||
|
||||
|
||||
local page = node("admin", "status", "olsr", "mid")
|
||||
page.target = call("action_mid")
|
||||
page.title = "MID"
|
||||
page.order = 50
|
||||
|
||||
entry({"admin", "services", "olsrd"}, cbi("olsr/olsrd"), "OLSR").i18n = "olsr"
|
||||
entry(
|
||||
{"admin", "services", "olsrd"},
|
||||
cbi("olsr/olsrd"), "OLSR"
|
||||
).i18n = "olsr"
|
||||
|
||||
entry(
|
||||
{"admin", "services", "olsrd", "hna"},
|
||||
cbi("olsr/olsrdhna"), "HNA Announcements"
|
||||
).i18n = "olsr"
|
||||
|
||||
oplg = entry(
|
||||
{"admin", "services", "olsrd", "plugins"},
|
||||
cbi("olsr/olsrdplugins"), "Plugins"
|
||||
)
|
||||
oplg.i18n = "olsr"
|
||||
oplg.leaf = 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_index()
|
||||
local data = fetch_txtinfo("links")
|
||||
|
||||
|
||||
if not data or not data.Links then
|
||||
luci.template.render("status-olsr/error_olsr")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
local function compare(a, b)
|
||||
local c = tonumber(a.ETX)
|
||||
local d = tonumber(b.ETX)
|
||||
|
||||
local c = tonumber(a.Cost)
|
||||
local d = tonumber(b.Cost)
|
||||
|
||||
if not c or c == 0 then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
if not d or d == 0 then
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
return c < d
|
||||
end
|
||||
|
||||
|
||||
table.sort(data.Links, compare)
|
||||
|
||||
|
||||
luci.template.render("status-olsr/index", {links=data.Links})
|
||||
end
|
||||
|
||||
function action_routes()
|
||||
local data = fetch_txtinfo("routes")
|
||||
|
||||
|
||||
if not data or not data.Routes then
|
||||
luci.template.render("status-olsr/error_olsr")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
local function compare(a, b)
|
||||
local c = tonumber(a.ETX)
|
||||
local d = tonumber(b.ETX)
|
||||
|
||||
|
||||
if not c or c == 0 then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
if not d or d == 0 then
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
return c < d
|
||||
end
|
||||
|
||||
|
||||
table.sort(data.Routes, compare)
|
||||
|
||||
|
||||
luci.template.render("status-olsr/routes", {routes=data.Routes})
|
||||
end
|
||||
|
||||
function action_topology()
|
||||
local data = fetch_txtinfo("topology")
|
||||
|
||||
|
||||
if not data or not data.Topology then
|
||||
luci.template.render("status-olsr/error_olsr")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
local function compare(a, b)
|
||||
return a["Destination IP"] < b["Destination IP"]
|
||||
return a["Dest. IP"] < b["Dest. IP"]
|
||||
end
|
||||
|
||||
|
||||
table.sort(data.Topology, compare)
|
||||
|
||||
|
||||
luci.template.render("status-olsr/topology", {routes=data.Topology})
|
||||
end
|
||||
|
||||
function action_hna()
|
||||
local data = fetch_txtinfo("hna")
|
||||
|
||||
|
||||
if not data or not data.HNA then
|
||||
luci.template.render("status-olsr/error_olsr")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
local function compare(a, b)
|
||||
return a.Network < b.Network
|
||||
return a.Destination < b.Destination
|
||||
end
|
||||
|
||||
|
||||
table.sort(data.HNA, compare)
|
||||
|
||||
|
||||
luci.template.render("status-olsr/hna", {routes=data.HNA})
|
||||
end
|
||||
|
||||
function action_mid()
|
||||
local data = fetch_txtinfo("mid")
|
||||
|
||||
|
||||
if not data or not data.MID then
|
||||
luci.template.render("status-olsr/error_olsr")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
local function compare(a, b)
|
||||
return a.IP < b.IP
|
||||
return a["IP address"] < b["IP address"]
|
||||
end
|
||||
|
||||
|
||||
table.sort(data.MID, compare)
|
||||
|
||||
|
||||
luci.template.render("status-olsr/mid", {mids=data.MID})
|
||||
end
|
||||
|
||||
|
@ -149,39 +176,39 @@ function fetch_txtinfo(otable)
|
|||
require("luci.sys")
|
||||
otable = otable or ""
|
||||
local rawdata = luci.sys.httpget("http://127.0.0.1:2006/"..otable)
|
||||
|
||||
|
||||
if #rawdata == 0 then
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
local data = {}
|
||||
|
||||
|
||||
local tables = luci.util.split(luci.util.trim(rawdata), "\r?\n\r?\n", nil, true)
|
||||
|
||||
|
||||
|
||||
for i, tbl in ipairs(tables) do
|
||||
local lines = luci.util.split(tbl, "\r?\n", nil, true)
|
||||
local name = table.remove(lines, 1):sub(8)
|
||||
local keys = luci.util.split(table.remove(lines, 1), "\t")
|
||||
local split = #keys - 1
|
||||
|
||||
|
||||
data[name] = {}
|
||||
|
||||
|
||||
for j, line in ipairs(lines) do
|
||||
local fields = luci.util.split(line, "\t", split)
|
||||
data[name][j] = {}
|
||||
for k, key in pairs(keys) do
|
||||
data[name][j][key] = fields[k]
|
||||
data[name][j][key] = fields[k]
|
||||
end
|
||||
|
||||
|
||||
if data[name][j].Linkcost then
|
||||
data[name][j].LinkQuality,
|
||||
data[name][j].NLQ,
|
||||
data[name][j].ETX =
|
||||
data[name][j].Linkcost:match("([%w.]+)/([%w.]+)[%s]+([%w.]+)")
|
||||
data[name][j].Linkcost:match("([%w.]+)/([%w.]+)[%s]+([%w.]+)")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return data
|
||||
end
|
||||
|
|
|
@ -11,68 +11,116 @@ You may obtain a copy of the License at
|
|||
|
||||
$Id$
|
||||
]]--
|
||||
|
||||
require("luci.tools.webadmin")
|
||||
require("luci.fs")
|
||||
|
||||
m = Map("olsr", "OLSR")
|
||||
m = Map("olsrd", "OLSR")
|
||||
|
||||
s = m:section(NamedSection, "general", "olsr")
|
||||
s = m:section(TypedSection, "olsrd", translate("olsr_general"))
|
||||
s.dynamic = true
|
||||
s.anonymous = true
|
||||
|
||||
debug = s:option(ListValue, "DebugLevel")
|
||||
for i=0, 9 do
|
||||
debug:value(i)
|
||||
end
|
||||
debug.optional = true
|
||||
|
||||
ipv = s:option(ListValue, "IpVersion")
|
||||
ipv:value("4", "IPv4")
|
||||
ipv:value("6", "IPv6")
|
||||
|
||||
noint = s:option(Flag, "AllowNoInt")
|
||||
noint.enabled = "yes"
|
||||
noint.disabled = "no"
|
||||
noint.optional = true
|
||||
|
||||
s:option(Value, "Pollrate").optional = true
|
||||
|
||||
tcr = s:option(ListValue, "TcRedundancy")
|
||||
tcr:value("0", translate("olsr_general_tcredundancy_0"))
|
||||
tcr:value("1", translate("olsr_general_tcredundancy_1"))
|
||||
tcr:value("2", translate("olsr_general_tcredundancy_2"))
|
||||
tcr.optional = true
|
||||
|
||||
s:option(Value, "MprCoverage").optional = true
|
||||
|
||||
lql = s:option(ListValue, "LinkQualityLevel")
|
||||
lql:value("0", translate("disable"))
|
||||
lql:value("1", translate("olsr_general_linkqualitylevel_1"))
|
||||
lql:value("2", translate("olsr_general_linkqualitylevel_2"))
|
||||
lql.optional = true
|
||||
|
||||
s:option(Value, "LinkQualityAging").optional = true
|
||||
|
||||
lqa = s:option(ListValue, "LinkQualityAlgorithm")
|
||||
lqa.optional = true
|
||||
lqa:value("etx_fpm", translate("olsr_etx_fpm"))
|
||||
lqa:value("etx_float", translate("olsr_etx_float"))
|
||||
lqa:value("etx_ff", translate("olsr_etx_ff"))
|
||||
lqa.optional = true
|
||||
|
||||
lqfish = s:option(Flag, "LinkQualityFishEye")
|
||||
lqfish.optional = true
|
||||
|
||||
s:option(Value, "LinkQualityWinSize").optional = true
|
||||
|
||||
s:option(Value, "LinkQualityDijkstraLimit").optional = true
|
||||
|
||||
hyst = s:option(Flag, "UseHysteresis")
|
||||
hyst.enabled = "yes"
|
||||
hyst.disabled = "no"
|
||||
hyst.optional = true
|
||||
|
||||
fib = s:option(ListValue, "FIBMetric")
|
||||
fib.optional = true
|
||||
fib:value("flat")
|
||||
fib:value("correct")
|
||||
fib:value("approx")
|
||||
fib.optional = true
|
||||
|
||||
clrscr = s:option(Flag, "ClearScreen")
|
||||
clrscr.enabled = "yes"
|
||||
clrscr.disabled = "no"
|
||||
clrscr.optional = true
|
||||
|
||||
willingness = s:option(ListValue, "Willingness")
|
||||
for i=0,7 do
|
||||
willingness:value(i)
|
||||
end
|
||||
willingness.optional = true
|
||||
|
||||
|
||||
|
||||
i = m:section(TypedSection, "Interface", translate("interfaces"))
|
||||
i.anonymous = true
|
||||
i.addremove = true
|
||||
i.dynamic = true
|
||||
|
||||
network = i:option(ListValue, "Interface", translate("network"))
|
||||
ign = i:option(Flag, "ignore", "Enable")
|
||||
ign.enabled = "0"
|
||||
ign.disabled = "1"
|
||||
|
||||
network = i:option(ListValue, "interface", translate("network"))
|
||||
luci.tools.webadmin.cbi_add_networks(network)
|
||||
|
||||
i:option(Value, "Ip4Broadcast")
|
||||
i:option(Value, "HelloInterval")
|
||||
i:option(Value, "HelloValidityTime")
|
||||
i:option(Value, "TcInterval")
|
||||
i:option(Value, "TcValidityTime")
|
||||
i:option(Value, "MidInterval")
|
||||
i:option(Value, "MidValidityTime")
|
||||
i:option(Value, "HnaInterval")
|
||||
i:option(Value, "HnaValidityTime")
|
||||
i:option(Value, "Ip4Broadcast").optional = true
|
||||
i:option(Value, "HelloInterval").optional = true
|
||||
i:option(Value, "HelloValidityTime").optional = true
|
||||
i:option(Value, "TcInterval").optional = true
|
||||
i:option(Value, "TcValidityTime").optional = true
|
||||
i:option(Value, "MidInterval").optional = true
|
||||
i:option(Value, "MidValidityTime").optional = true
|
||||
i:option(Value, "HnaInterval").optional = true
|
||||
i:option(Value, "HnaValidityTime").optional = true
|
||||
|
||||
adc = i:option(Flag, "AutoDetectChanges")
|
||||
adc.enabled = "yes"
|
||||
adc.disabled = "no"
|
||||
adc.optional = true
|
||||
|
||||
|
||||
p = m:section(TypedSection, "LoadPlugin")
|
||||
p.addremove = true
|
||||
p.dynamic = true
|
||||
|
||||
lib = p:option(ListValue, "Library", translate("library"))
|
||||
lib:value("")
|
||||
for k, v in pairs(luci.fs.dir("/usr/lib")) do
|
||||
if v:sub(1, 6) == "olsrd_" then
|
||||
lib:value(v)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
for i, sect in ipairs({ "Hna4", "Hna6" }) do
|
||||
hna = m:section(TypedSection, sect)
|
||||
hna.addremove = true
|
||||
hna.anonymous = true
|
||||
hna.template = "cbi/tblsection"
|
||||
|
||||
net = hna:option(Value, "NetAddr")
|
||||
msk = hna:option(Value, "Prefix")
|
||||
end
|
||||
|
||||
|
||||
ipc = m:section(NamedSection, "IpcConnect")
|
||||
ipc = m:section(TypedSection, "IpcConnect")
|
||||
conns = ipc:option(Value, "MaxConnections")
|
||||
conns.isInteger = true
|
||||
|
||||
|
|
27
applications/luci-olsr/luasrc/model/cbi/olsr/olsrdhna.lua
Normal file
27
applications/luci-olsr/luasrc/model/cbi/olsr/olsrdhna.lua
Normal file
|
@ -0,0 +1,27 @@
|
|||
--[[
|
||||
LuCI - Lua Configuration Interface
|
||||
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
$Id$
|
||||
]]--
|
||||
|
||||
mh = Map("olsrd", "OLSR - HNA Announcements")
|
||||
|
||||
for i, sect in ipairs({ "Hna4", "Hna6" }) do
|
||||
hna = mh:section(TypedSection, sect)
|
||||
hna.addremove = true
|
||||
hna.anonymous = true
|
||||
hna.template = "cbi/tblsection"
|
||||
|
||||
net = hna:option(Value, "NetAddr")
|
||||
msk = hna:option(Value, "Prefix")
|
||||
end
|
||||
|
||||
return mh
|
242
applications/luci-olsr/luasrc/model/cbi/olsr/olsrdplugins.lua
Normal file
242
applications/luci-olsr/luasrc/model/cbi/olsr/olsrdplugins.lua
Normal file
|
@ -0,0 +1,242 @@
|
|||
--[[
|
||||
LuCI - Lua Configuration Interface
|
||||
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
$Id$
|
||||
]]--
|
||||
|
||||
require("luci.fs")
|
||||
require("luci.ip")
|
||||
|
||||
|
||||
if arg[1] then
|
||||
mp = Map("olsrd", "OLSR - Plugins")
|
||||
|
||||
p = mp:section(TypedSection, "LoadPlugin")
|
||||
p:depends("library", arg[1])
|
||||
p.anonymous = true
|
||||
|
||||
ign = p:option(Flag, "ignore", "Enable")
|
||||
ign.enabled = "0"
|
||||
ign.disabled = "1"
|
||||
function ign.cfgvalue(self, section)
|
||||
return Flag.cfgvalue(self, section) or "0"
|
||||
end
|
||||
|
||||
lib = p:option(DummyValue, "library", translate("library"))
|
||||
lib.default = arg[1]
|
||||
|
||||
local function Range(x,y)
|
||||
local t = {}
|
||||
for i = x, y do t[#t+1] = i end
|
||||
return t
|
||||
end
|
||||
|
||||
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])
|
||||
if cidr then
|
||||
val[i] = cidr:network():string() .. " " .. cidr:mask():string()
|
||||
end
|
||||
end
|
||||
return val
|
||||
end
|
||||
end
|
||||
|
||||
local function IpMask2Cidr(val)
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
local knownPlParams = {
|
||||
["olsrd_bmf.so.1.5.3"] = {
|
||||
{ Value, "BmfInterface", "bmf0" },
|
||||
{ Value, "BmfInterfaceIp", "10.10.10.234/24" },
|
||||
{ Flag, "DoLocalBroadcast", "no" },
|
||||
{ Flag, "CapturePacketsOnOlsrInterfaces", "yes" },
|
||||
{ ListValue, "BmfMechanism", { "UnicastPromiscuous", "Broadcast" } },
|
||||
{ Value, "BroadcastRetransmitCount", "2" },
|
||||
{ Value, "FanOutLimit", "4" },
|
||||
{ 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", IpMask2Cidr, Cidr2IpMask }
|
||||
},
|
||||
|
||||
["olsrd_httpinfo.so.0.1"] = {
|
||||
{ Value, "port", "80" },
|
||||
{ DynamicList, "Host", "163.24.87.3" },
|
||||
{ DynamicList, "Net", "0.0.0.0/0", IpMask2Cidr, Cidr2IpMask }
|
||||
},
|
||||
|
||||
["olsrd_nameservice.so.0.3"] = {
|
||||
{ DynamicList, "name", "my-name.mesh" },
|
||||
{ DynamicList, "hosts", "1.2.3.4 name-for-other-interface.mesh" },
|
||||
{ Value, "suffix", ".olsr" },
|
||||
{ Value, "hosts_file", "/path/to/hosts_file" },
|
||||
{ Value, "add_hosts", "/path/to/file" },
|
||||
{ Value, "dns_server", "141.1.1.1" },
|
||||
{ Value, "resolv_file", "/path/to/resolv.conf" },
|
||||
{ Value, "interval", "120" },
|
||||
{ Value, "timeout", "240" },
|
||||
{ Value, "lat", "12.123" },
|
||||
{ Value, "lon", "12.123" },
|
||||
{ Value, "latlon_file", "/var/run/latlon.js" },
|
||||
{ Value, "latlon_infile", "/var/run/gps.txt" },
|
||||
{ Value, "sighup_pid_file", "/var/run/dnsmasq.pid" },
|
||||
{ Value, "name_change_script", "/usr/local/bin/announce_new_hosts.sh" },
|
||||
{ Value, "services_change_script", "/usr/local/bin/announce_new_services.sh" }
|
||||
},
|
||||
|
||||
["olsrd_quagga.so.0.2.2"] = {
|
||||
{ StaticList, "redistribute", {
|
||||
"system", "kernel", "connect", "static", "rip", "ripng", "ospf",
|
||||
"ospf6", "isis", "bgp", "hsls"
|
||||
} },
|
||||
{ ListValue, "ExportRoutes", { "only", "both" } },
|
||||
{ Flag, "LocalPref", "true" },
|
||||
{ Value, "Distance", Range(0,255) }
|
||||
},
|
||||
|
||||
["olsrd_secure.so.0.5"] = {
|
||||
{ Value, "Keyfile", "/etc/private-olsr.key" }
|
||||
},
|
||||
|
||||
["olsrd_txtinfo.so.0.1"] = {
|
||||
{ Value, "accept", "10.247.200.4" }
|
||||
},
|
||||
|
||||
["olsrd_arprefresh.so.0.1"] = {},
|
||||
["olsrd_dot_draw.so.0.3"] = {},
|
||||
["olsrd_dyn_gw_plain.so.0.4"] = {},
|
||||
["olsrd_pgraph.so.1.1"] = {},
|
||||
["olsrd_tas.so.0.1"] = {}
|
||||
}
|
||||
|
||||
|
||||
-- build plugin options with dependencies
|
||||
if knownPlParams[arg[1]] then
|
||||
for _, option in ipairs(knownPlParams[arg[1]]) do
|
||||
local otype, name, default, uci2cbi, cbi2uci = unpack(option)
|
||||
local values
|
||||
|
||||
if type(default) == "table" then
|
||||
values = default
|
||||
default = default[1]
|
||||
end
|
||||
|
||||
if otype == Flag then
|
||||
local bool = p:option( Flag, name )
|
||||
if default == "yes" or default == "no" then
|
||||
bool.enabled = "yes"
|
||||
bool.disabled = "no"
|
||||
elseif default == "on" or default == "off" then
|
||||
bool.enabled = "on"
|
||||
bool.disabled = "off"
|
||||
elseif default == "1" or default == "0" then
|
||||
bool.enabled = "1"
|
||||
bool.disabled = "0"
|
||||
else
|
||||
bool.enabled = "true"
|
||||
bool.disabled = "false"
|
||||
end
|
||||
bool.optional = true
|
||||
bool.default = default
|
||||
bool:depends({ library = plugin })
|
||||
else
|
||||
local field = p:option( otype, name )
|
||||
if values then
|
||||
for _, value in ipairs(values) do
|
||||
field:value( value )
|
||||
end
|
||||
end
|
||||
if type(uci2cbi) == "function" then
|
||||
function field.cfgvalue(self, section)
|
||||
return uci2cbi(otype.cfgvalue(self, section))
|
||||
end
|
||||
end
|
||||
if type(cbi2uci) == "function" then
|
||||
function field.formvalue(self, section)
|
||||
return cbi2uci(otype.formvalue(self, section))
|
||||
end
|
||||
end
|
||||
field.optional = true
|
||||
field.default = default
|
||||
--field:depends({ library = arg[1] })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return mp
|
||||
|
||||
else
|
||||
|
||||
mpi = Map("olsrd", "OLSR - Plugins")
|
||||
|
||||
local plugins = {}
|
||||
mpi.uci:foreach("olsrd", "LoadPlugin",
|
||||
function(section)
|
||||
if section.library and not plugins[section.library] then
|
||||
plugins[section.library] = true
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
-- create a loadplugin section for each found plugin
|
||||
for k, v in pairs(luci.fs.dir("/usr/lib")) do
|
||||
if v:sub(1, 6) == "olsrd_" then
|
||||
if not plugins[v] then
|
||||
mpi.uci:section(
|
||||
"olsrd", "LoadPlugin", nil,
|
||||
{ library = v, ignore = 1 }
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
t = mpi:section( TypedSection, "LoadPlugin", "Plugins" )
|
||||
t.anonymous = true
|
||||
t.template = "cbi/tblsection"
|
||||
t.override_scheme = true
|
||||
function t.extedit(self, section)
|
||||
local lib = self.map:get(section, "library") or ""
|
||||
return luci.dispatcher.build_url("admin", "services", "olsrd", "plugins") .. "/" .. lib
|
||||
end
|
||||
|
||||
ign = t:option( Flag, "ignore", "Enabled" )
|
||||
ign.enabled = "0"
|
||||
ign.disabled = "1"
|
||||
function ign.cfgvalue(self, section)
|
||||
return Flag.cfgvalue(self, section) or "0"
|
||||
end
|
||||
|
||||
t:option( DummyValue, "library", "Library" )
|
||||
|
||||
return mpi
|
||||
end
|
|
@ -22,7 +22,7 @@ $Id$
|
|||
</tr>
|
||||
<% for k, route in ipairs(routes) do %>
|
||||
<tr>
|
||||
<td><%=route.Network%>/<%=route.Netmask%></td>
|
||||
<td><%=route.Destination%></td>
|
||||
<td><a href="http://<%=route.Gateway%>"><%=route.Gateway%></a></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
|
|
@ -27,23 +27,23 @@ $Id$
|
|||
<% for k, link in ipairs(links) do
|
||||
local color = "#bb3333"
|
||||
|
||||
link.ETX = tonumber(link.ETX) or 0
|
||||
if link.ETX == 0 then
|
||||
link.Cost = tonumber(link.Cost) or 0
|
||||
if link.Cost == 0 then
|
||||
color = "#bb3333"
|
||||
elseif link.ETX < 4 then
|
||||
elseif link.Cost < 4 then
|
||||
color = "#00cc00"
|
||||
elseif link.ETX < 10 then
|
||||
elseif link.Cost < 10 then
|
||||
color = "#ffcb05"
|
||||
elseif link.ETX < 100 then
|
||||
elseif link.Cost < 100 then
|
||||
color = "#ff6600"
|
||||
end
|
||||
%>
|
||||
<tr>
|
||||
<td><a href="http://<%=link["remote IP"]%>"><%=link["remote IP"]%></a></td>
|
||||
<td><a href="http://<%=link["Remote IP"]%>"><%=link["Remote IP"]%></a></td>
|
||||
<td><%=link["Local IP"]%></td>
|
||||
<td><%=link.LinkQuality%></td>
|
||||
<td><%=link.LQ%></td>
|
||||
<td><%=link.NLQ%></td>
|
||||
<td style="background-color:<%=color%>"><%=string.format("%.3f", link.ETX)%></td>
|
||||
<td style="background-color:<%=color%>"><%=string.format("%.3f", link.Cost)%></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
|
|
@ -22,7 +22,7 @@ $Id$
|
|||
</tr>
|
||||
<% for k, mid in ipairs(mids) do %>
|
||||
<tr>
|
||||
<td><a href="http://<%=mid.IP%>"><%=mid.IP%></a></td>
|
||||
<td><a href="http://<%=mid["IP address"]%>"><%=mid["IP address"]%></a></td>
|
||||
<td><%=mid.Aliases%></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
|
|
@ -39,7 +39,7 @@ $Id$
|
|||
%>
|
||||
<tr>
|
||||
<td><%=route.Destination%></td>
|
||||
<td><%=route.Gateway%></td>
|
||||
<td><%=route["Gateway IP"]%></td>
|
||||
<td><%=route.Interface%></td>
|
||||
<td><%=route.Metric%></td>
|
||||
<td style="background-color:<%=color%>"><%=string.format("%.3f", tonumber(route.ETX) or 0)%></td>
|
||||
|
|
|
@ -26,11 +26,11 @@ $Id$
|
|||
<% for k, route in ipairs(routes) do
|
||||
%>
|
||||
<tr>
|
||||
<td><a href="http://<%=route["Destination IP"]%>"><%=route["Destination IP"]%></a></td>
|
||||
<td><a href="http://<%=route["Dest. IP"]%>"><%=route["Dest. IP"]%></a></td>
|
||||
<td><a href="http://<%=route["Last hop IP"]%>"><%=route["Last hop IP"]%></a></td>
|
||||
<td><%=route.LQ%></td>
|
||||
<td><%=route.ILQ%></td>
|
||||
<td><%=string.format("%.3f", tonumber(route.ETX) or 0)%></td>
|
||||
<td><%=route.NLQ%></td>
|
||||
<td><%=string.format("%.3f", tonumber(route.Cost) or 0)%></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
|
7
applications/luci-olsr/root/etc/uci-defaults/luci-olsr
Normal file
7
applications/luci-olsr/root/etc/uci-defaults/luci-olsr
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
uci batch <<-EOF
|
||||
add ucitrack olsrd
|
||||
set ucitrack.@olsrd[-1].init=olsrd
|
||||
commit ucitrack
|
||||
EOF
|
Loading…
Reference in a new issue