From 932280107232706c4605e475a6d969f0adf2e22d Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Fri, 6 Jun 2008 15:50:21 +0000 Subject: * Separated OLSR pages into separate application pack * Minor bugfixes and enhancements --- applications/luci-olsr/luasrc/controller/olsr.lua | 165 +++++++++++++++++++++ .../luci-olsr/luasrc/model/cbi/olsr/olsrd.lua | 90 +++++++++++ .../luasrc/view/status-olsr/error_olsr.htm | 6 + .../luci-olsr/luasrc/view/status-olsr/hna.htm | 17 +++ .../luci-olsr/luasrc/view/status-olsr/index.htm | 43 ++++++ .../luci-olsr/luasrc/view/status-olsr/mid.htm | 17 +++ .../luci-olsr/luasrc/view/status-olsr/routes.htm | 36 +++++ .../luci-olsr/luasrc/view/status-olsr/topology.htm | 23 +++ 8 files changed, 397 insertions(+) create mode 100644 applications/luci-olsr/luasrc/controller/olsr.lua create mode 100644 applications/luci-olsr/luasrc/model/cbi/olsr/olsrd.lua create mode 100644 applications/luci-olsr/luasrc/view/status-olsr/error_olsr.htm create mode 100644 applications/luci-olsr/luasrc/view/status-olsr/hna.htm create mode 100644 applications/luci-olsr/luasrc/view/status-olsr/index.htm create mode 100644 applications/luci-olsr/luasrc/view/status-olsr/mid.htm create mode 100644 applications/luci-olsr/luasrc/view/status-olsr/routes.htm create mode 100644 applications/luci-olsr/luasrc/view/status-olsr/topology.htm (limited to 'applications/luci-olsr/luasrc') diff --git a/applications/luci-olsr/luasrc/controller/olsr.lua b/applications/luci-olsr/luasrc/controller/olsr.lua new file mode 100644 index 000000000..0482a8fe7 --- /dev/null +++ b/applications/luci-olsr/luasrc/controller/olsr.lua @@ -0,0 +1,165 @@ +module("luci.controller.olsr", package.seeall) + +function index() + local page = node("admin", "status", "olsr") + page.target = call("action_index") + page.title = "OLSR" + + local page = node("admin", "status", "olsr", "routes") + page.target = call("action_routes") + page.title = "Routen" + page.order = 10 + + local page = node("admin", "status", "olsr", "topology") + page.target = call("action_topology") + page.title = "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.lua"), "OLSRd") +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) + if tonumber(a.ETX) == 0 then + return false + end + + if tonumber(b.ETX) == 0 then + return true + end + + return tonumber(a.ETX) < tonumber(b.ETX) + 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) + if tonumber(a.ETX) == 0 then + return false + end + + if tonumber(b.ETX) == 0 then + return true + end + + return tonumber(a.ETX) < tonumber(b.ETX) + 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"] + 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 + 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 + end + + table.sort(data.MID, compare) + + luci.template.render("status-olsr/mid", {mids=data.MID}) +end + + +-- Internal +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), "\n\n") + + + for i, tbl in ipairs(tables) do + local lines = luci.util.split(tbl, "\n") + local name = table.remove(lines, 1):sub(8) + local keys = luci.util.split(table.remove(lines, 1), "\t") + + data[name] = {} + + for j, line in ipairs(lines) do + local fields = luci.util.split(line, "\t") + data[name][j] = {} + for k, key in pairs(keys) do + data[name][j][key] = fields[k] + end + end + end + + return data +end diff --git a/applications/luci-olsr/luasrc/model/cbi/olsr/olsrd.lua b/applications/luci-olsr/luasrc/model/cbi/olsr/olsrd.lua new file mode 100644 index 000000000..3e3c68dff --- /dev/null +++ b/applications/luci-olsr/luasrc/model/cbi/olsr/olsrd.lua @@ -0,0 +1,90 @@ +-- ToDo: Autodetect things, Translate, Add descriptions +require("luci.fs") + +m = Map("olsr", "OLSR", [[OLSR ist ein flexibles Routingprotokoll, +dass den Aufbau von mobilen Ad-Hoc Netzen unterstützt.]]) + +s = m:section(NamedSection, "general", "olsr", "Allgemeine Einstellungen") + +debug = s:option(ListValue, "DebugLevel", "Debugmodus") +for i=0, 9 do + debug:value(i) +end + +ipv = s:option(ListValue, "IpVersion", "Internet Protokoll") +ipv:value("4", "IPv4") +ipv:value("6", "IPv6") + +noint = s:option(Flag, "AllowNoInt", "Start ohne Netzwerk") +noint.enabled = "yes" +noint.disabled = "no" + +s:option(Value, "Pollrate", "Abfragerate (Pollrate)", "s") + +tcr = s:option(ListValue, "TcRedundancy", "TC-Redundanz") +tcr:value("0", "MPR-Selektoren") +tcr:value("1", "MPR-Selektoren und MPR") +tcr:value("2", "Alle Nachbarn") + +s:option(Value, "MprCoverage", "MPR-Erfassung") + +lql = s:option(ListValue, "LinkQualityLevel", "VQ-Level") +lql:value("0", "deaktiviert") +lql:value("1", "MPR-Auswahl") +lql:value("2", "MPR-Auswahl und Routing") + +lqfish = s:option(Flag, "LinkQualityFishEye", "VQ-Fisheye") + +s:option(Value, "LinkQualityWinSize", "VQ-Fenstergröße") + +s:option(Value, "LinkQualityDijkstraLimit", "VQ-Dijkstralimit") + +hyst = s:option(Flag, "UseHysteresis", "Hysterese aktivieren") +hyst.enabled = "yes" +hyst.disabled = "no" + + +i = m:section(TypedSection, "Interface", "Schnittstellen") +i.anonymous = true +i.addremove = true +i.dynamic = true + +network = i:option(ListValue, "Interface", "Netzwerkschnittstellen") +network:value("") +luci.model.uci.foreach("network", "interface", + function (section) + if section[".name"] ~= "loopback" then + network:value(section[".name"]) + end + end) + +i:option(Value, "HelloInterval", "Hello-Intervall") + +i:option(Value, "HelloValidityTime", "Hello-Gültigkeit") + +i:option(Value, "TcInterval", "TC-Intervall") + +i:option(Value, "TcValidityTime", "TC-Gültigkeit") + +i:option(Value, "MidInterval", "MID-Intervall") + +i:option(Value, "MidValidityTime", "MID-Gültigkeit") + +i:option(Value, "HnaInterval", "HNA-Intervall") + +i:option(Value, "HnaValidityTime", "HNA-Gültigkeit") + + +p = m:section(TypedSection, "LoadPlugin", "Plugins") +p.addremove = true +p.dynamic = true + +lib = p:option(ListValue, "Library", "Bibliothek") +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 + +return m \ No newline at end of file diff --git a/applications/luci-olsr/luasrc/view/status-olsr/error_olsr.htm b/applications/luci-olsr/luasrc/view/status-olsr/error_olsr.htm new file mode 100644 index 000000000..25426f50d --- /dev/null +++ b/applications/luci-olsr/luasrc/view/status-olsr/error_olsr.htm @@ -0,0 +1,6 @@ +<%+header%> +

<%:olsr OLSR%>

+

<%:olsrerror1 Es konnte keine Verbindung zum OLSR-Daemon hergestellt werden!%>

+

<%:olsrerror2 Um die Statusinformationen abfragen zu können muss der OLSR-Daemon gestartet +und das Plugin "txtinfo" geladen sein.%>

+<%+footer%> \ No newline at end of file diff --git a/applications/luci-olsr/luasrc/view/status-olsr/hna.htm b/applications/luci-olsr/luasrc/view/status-olsr/hna.htm new file mode 100644 index 000000000..c13369f42 --- /dev/null +++ b/applications/luci-olsr/luasrc/view/status-olsr/hna.htm @@ -0,0 +1,17 @@ +<%+header%> +

<%:olsrhna OLSR-HNA%>

+
+ + + + + +<% for k, route in ipairs(routes) do %> + + + + +<% end %> +
<%:destination Ziel%><%:gateway Gateway%>
<%=route.Network%>/<%=route.Netmask%><%=route.Gateway%>
+
+<%+footer%> \ No newline at end of file diff --git a/applications/luci-olsr/luasrc/view/status-olsr/index.htm b/applications/luci-olsr/luasrc/view/status-olsr/index.htm new file mode 100644 index 000000000..0633d1f45 --- /dev/null +++ b/applications/luci-olsr/luasrc/view/status-olsr/index.htm @@ -0,0 +1,43 @@ +<%+header%> +

<%:olsrlinks OLSR-Verbindungen%>

+

<%:olsrlinks1 Übersicht über aktuell bestehende OLSR-Verbindungen%>

+
+ + + + + + + + +<% for k, link in ipairs(links) do + local color = "#bb3333" + + link.ETX = tonumber(link.ETX) + if link.ETX == 0 then + color = "#bb3333" + elseif link.ETX < 4 then + color = "#00cc00" + elseif link.ETX < 10 then + color = "#ffcb05" + elseif link.ETX < 100 then + color = "#ff6600" + end +%> + + + + + + + +<% end %> +
<%:destination Ziel%><%:local Lokal%>LQNLQETX
"><%=link["remote IP"]%><%=link["Local IP"]%><%=link.LinkQuality%><%=link.NLQ%><%=link.ETX%>
+
+

<%:legend Legende%>:

+ +<%+footer%> \ No newline at end of file diff --git a/applications/luci-olsr/luasrc/view/status-olsr/mid.htm b/applications/luci-olsr/luasrc/view/status-olsr/mid.htm new file mode 100644 index 000000000..6553237ea --- /dev/null +++ b/applications/luci-olsr/luasrc/view/status-olsr/mid.htm @@ -0,0 +1,17 @@ +<%+header%> +

<%:olsrmid OLSR-MID%>

+
+ + + + + +<% for k, mid in ipairs(mids) do %> + + + + +<% end %> +
<%:node Knoten%><%:aliases Aliasse%>
<%=mid.IP%><%=mid.Aliases%>
+
+<%+footer%> \ No newline at end of file diff --git a/applications/luci-olsr/luasrc/view/status-olsr/routes.htm b/applications/luci-olsr/luasrc/view/status-olsr/routes.htm new file mode 100644 index 000000000..f3a0fd336 --- /dev/null +++ b/applications/luci-olsr/luasrc/view/status-olsr/routes.htm @@ -0,0 +1,36 @@ +<%+header%> +

<%:olsrlinks OLSR-Routen%>

+
+ + + + + + + + +<% for k, route in ipairs(routes) do + local color = "#bb3333" + + route.ETX = tonumber(route.ETX) + if route.ETX == 0 then + color = "#bb3333" + elseif route.ETX < 4 then + color = "#00cc00" + elseif route.ETX < 10 then + color = "#ffcb05" + elseif route.ETX < 100 then + color = "#ff6600" + end +%> + + + + + + + +<% end %> +
<%:destination Ziel%><%:gateway Gateway%><%:interface Schnittstelle%><%:metric Metrik%>ETX
<%=route.Destination%><%=route.Gateway%><%=route.Interface%><%=route.Metric%><%=route.ETX%>
+
+<%+footer%> \ No newline at end of file diff --git a/applications/luci-olsr/luasrc/view/status-olsr/topology.htm b/applications/luci-olsr/luasrc/view/status-olsr/topology.htm new file mode 100644 index 000000000..c622026d4 --- /dev/null +++ b/applications/luci-olsr/luasrc/view/status-olsr/topology.htm @@ -0,0 +1,23 @@ +<%+header%> +

<%:olsrtopo OLSR-Topologie%>

+
+ + + + + + + + +<% for k, route in ipairs(routes) do %> + + + + + + + +<% end %> +
<%:destination Ziel%><%:lasthop Letzter Router%>LQILQETX
"><%=route["Destination IP"]%>"><%=route["Last hop IP"]%><%=route.LQ%><%=route.ILQ%><%=route.ETX%>
+
+<%+footer%> \ No newline at end of file -- cgit v1.2.3