summaryrefslogtreecommitdiffhomepage
path: root/module/public-core/src
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-04-21 17:25:01 +0000
committerSteven Barth <steven@midlink.org>2008-04-21 17:25:01 +0000
commitb98c0adcddf66b84dfa7e1ded0d09e17fee82279 (patch)
tree710df73759584ad4fa73445e1bb28d78569e9a0e /module/public-core/src
parentf11c311535ee26684308cff9132d405be66d7d39 (diff)
* Rewrote ffluci.util.split (optimizations)
* Added public pages for OLSR
Diffstat (limited to 'module/public-core/src')
-rw-r--r--module/public-core/src/controller/public/olsr.lua136
-rw-r--r--module/public-core/src/model/menu/00public.lua8
-rw-r--r--module/public-core/src/view/public_olsr/error_olsr.htm6
-rw-r--r--module/public-core/src/view/public_olsr/hna.htm17
-rw-r--r--module/public-core/src/view/public_olsr/index.htm43
-rw-r--r--module/public-core/src/view/public_olsr/mid.htm17
-rw-r--r--module/public-core/src/view/public_olsr/routes.htm36
-rw-r--r--module/public-core/src/view/public_olsr/topology.htm23
8 files changed, 285 insertions, 1 deletions
diff --git a/module/public-core/src/controller/public/olsr.lua b/module/public-core/src/controller/public/olsr.lua
new file mode 100644
index 0000000000..a2ce03eb3b
--- /dev/null
+++ b/module/public-core/src/controller/public/olsr.lua
@@ -0,0 +1,136 @@
+module("ffluci.controller.public.olsr", package.seeall)
+require("ffluci.sys")
+
+function action_index()
+ local data = fetch_txtinfo()
+
+ if not data or not data.Links then
+ ffluci.template.render("public_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)
+
+ ffluci.template.render("public_olsr/index", {links=data.Links})
+end
+
+function action_routes()
+ local data = fetch_txtinfo()
+
+ if not data or not data.Links then
+ ffluci.template.render("public_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)
+
+ ffluci.template.render("public_olsr/routes", {routes=data.Routes})
+end
+
+function action_topology()
+ local data = fetch_txtinfo()
+
+ if not data or not data.Links then
+ ffluci.template.render("public_olsr/error_olsr")
+ return nil
+ end
+
+ local function compare(a, b)
+ return a["Destination IP"] < b["Destination IP"]
+ end
+
+ table.sort(data.Topology, compare)
+
+ ffluci.template.render("public_olsr/topology", {routes=data.Topology})
+end
+
+function action_hna()
+ local data = fetch_txtinfo()
+
+ if not data or not data.Links then
+ ffluci.template.render("public_olsr/error_olsr")
+ return nil
+ end
+
+ local function compare(a, b)
+ return a.Network < b.Network
+ end
+
+ table.sort(data.HNA, compare)
+
+ ffluci.template.render("public_olsr/hna", {routes=data.HNA})
+end
+
+function action_mid()
+ local data = fetch_txtinfo()
+
+ if not data or not data.Links then
+ ffluci.template.render("public_olsr/error_olsr")
+ return nil
+ end
+
+ local function compare(a, b)
+ return a.IP < b.IP
+ end
+
+ table.sort(data.MID, compare)
+
+ ffluci.template.render("public_olsr/mid", {mids=data.MID})
+end
+
+
+-- Internal
+function fetch_txtinfo()
+ local rawdata = ffluci.sys.httpget("http://127.0.0.1:2006")
+
+ if #rawdata == 0 then
+ return nil
+ end
+
+ local data = {}
+
+ local tables = ffluci.util.split(ffluci.util.trim(rawdata), "\n\n")
+
+
+ for i, tbl in ipairs(tables) do
+ local lines = ffluci.util.split(tbl, "\n")
+ local name = table.remove(lines, 1):sub(8)
+ local keys = ffluci.util.split(table.remove(lines, 1), "\t")
+
+ data[name] = {}
+
+ for j, line in ipairs(lines) do
+ local fields = ffluci.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 \ No newline at end of file
diff --git a/module/public-core/src/model/menu/00public.lua b/module/public-core/src/model/menu/00public.lua
index 2e96a5b3c8..3339dd0ff2 100644
--- a/module/public-core/src/model/menu/00public.lua
+++ b/module/public-core/src/model/menu/00public.lua
@@ -4,4 +4,10 @@ act("contact", "Kontakt")
add("public", "status", "Status", 20)
act("routes", "Routingtabelle")
act("internet", "Internetzugang")
-act("iwscan", "WLAN-Scan") \ No newline at end of file
+act("iwscan", "WLAN-Scan")
+
+add("public", "olsr", "OLSR", 30)
+act("routes", "Routen")
+act("topology", "Topologie")
+act("hna", "HNA")
+act("mid", "MID")
diff --git a/module/public-core/src/view/public_olsr/error_olsr.htm b/module/public-core/src/view/public_olsr/error_olsr.htm
new file mode 100644
index 0000000000..25426f50d7
--- /dev/null
+++ b/module/public-core/src/view/public_olsr/error_olsr.htm
@@ -0,0 +1,6 @@
+<%+header%>
+<h1><%:olsr OLSR%></h1>
+<p class="error"><%:olsrerror1 Es konnte keine Verbindung zum OLSR-Daemon hergestellt werden!%></p>
+<p><%:olsrerror2 Um die Statusinformationen abfragen zu können muss der OLSR-Daemon gestartet
+und das Plugin "txtinfo" geladen sein.%></p>
+<%+footer%> \ No newline at end of file
diff --git a/module/public-core/src/view/public_olsr/hna.htm b/module/public-core/src/view/public_olsr/hna.htm
new file mode 100644
index 0000000000..c13369f426
--- /dev/null
+++ b/module/public-core/src/view/public_olsr/hna.htm
@@ -0,0 +1,17 @@
+<%+header%>
+<h1><%:olsrhna OLSR-HNA%></h1>
+<br />
+<table cellspacing="0" cellpadding="6">
+<tr>
+<th><%:destination Ziel%></th>
+<th><%:gateway Gateway%></th>
+</tr>
+<% for k, route in ipairs(routes) do %>
+<tr>
+<td><%=route.Network%>/<%=route.Netmask%></td>
+<td><a href="http://<%=route.Gateway%>"><%=route.Gateway%></a></td>
+</tr>
+<% end %>
+</table>
+<br />
+<%+footer%> \ No newline at end of file
diff --git a/module/public-core/src/view/public_olsr/index.htm b/module/public-core/src/view/public_olsr/index.htm
new file mode 100644
index 0000000000..0633d1f456
--- /dev/null
+++ b/module/public-core/src/view/public_olsr/index.htm
@@ -0,0 +1,43 @@
+<%+header%>
+<h1><%:olsrlinks OLSR-Verbindungen%></h1>
+<p><%:olsrlinks1 Übersicht über aktuell bestehende OLSR-Verbindungen%></p>
+<br />
+<table cellspacing="0" cellpadding="6">
+<tr>
+<th><%:destination Ziel%></th>
+<th><%:local Lokal%></th>
+<th>LQ</th>
+<th>NLQ</th>
+<th>ETX</th>
+</tr>
+<% 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
+%>
+<tr>
+<td><a href="http://<%=link["remote IP"]%>"><%=link["remote IP"]%></a></td>
+<td><%=link["Local IP"]%></td>
+<td><%=link.LinkQuality%></td>
+<td><%=link.NLQ%></td>
+<td style="background-color:<%=color%>"><%=link.ETX%></td>
+</tr>
+<% end %>
+</table>
+<br />
+<h3><%:legend Legende%>:</h3>
+<ul>
+<li><strong>LQ: </strong><%:lq1 Erfolgsquote gesendeter Pakete%></li>
+<li><strong>NLQ: </strong><%:nlq1 Erfolgsquote empfangener Pakete%></li>
+<li><strong>ETX: </strong><%:etx1 Zu erwartende Sendeversuche pro Paket%></li>
+</ul>
+<%+footer%> \ No newline at end of file
diff --git a/module/public-core/src/view/public_olsr/mid.htm b/module/public-core/src/view/public_olsr/mid.htm
new file mode 100644
index 0000000000..6553237ea5
--- /dev/null
+++ b/module/public-core/src/view/public_olsr/mid.htm
@@ -0,0 +1,17 @@
+<%+header%>
+<h1><%:olsrmid OLSR-MID%></h1>
+<br />
+<table cellspacing="0" cellpadding="6">
+<tr>
+<th><%:node Knoten%></th>
+<th><%:aliases Aliasse%></th>
+</tr>
+<% for k, mid in ipairs(mids) do %>
+<tr>
+<td><a href="http://<%=mid.IP%>"><%=mid.IP%></a></td>
+<td><%=mid.Aliases%></td>
+</tr>
+<% end %>
+</table>
+<br />
+<%+footer%> \ No newline at end of file
diff --git a/module/public-core/src/view/public_olsr/routes.htm b/module/public-core/src/view/public_olsr/routes.htm
new file mode 100644
index 0000000000..f3a0fd3366
--- /dev/null
+++ b/module/public-core/src/view/public_olsr/routes.htm
@@ -0,0 +1,36 @@
+<%+header%>
+<h1><%:olsrlinks OLSR-Routen%></h1>
+<br />
+<table cellspacing="0" cellpadding="6">
+<tr>
+<th><%:destination Ziel%></th>
+<th><%:gateway Gateway%></th>
+<th><%:interface Schnittstelle%></th>
+<th><%:metric Metrik%></th>
+<th>ETX</th>
+</tr>
+<% 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
+%>
+<tr>
+<td><%=route.Destination%></td>
+<td><%=route.Gateway%></td>
+<td><%=route.Interface%></td>
+<td><%=route.Metric%></td>
+<td style="background-color:<%=color%>"><%=route.ETX%></td>
+</tr>
+<% end %>
+</table>
+<br />
+<%+footer%> \ No newline at end of file
diff --git a/module/public-core/src/view/public_olsr/topology.htm b/module/public-core/src/view/public_olsr/topology.htm
new file mode 100644
index 0000000000..c622026d48
--- /dev/null
+++ b/module/public-core/src/view/public_olsr/topology.htm
@@ -0,0 +1,23 @@
+<%+header%>
+<h1><%:olsrtopo OLSR-Topologie%></h1>
+<br />
+<table cellspacing="0" cellpadding="6">
+<tr>
+<th><%:destination Ziel%></th>
+<th><%:lasthop Letzter Router%></th>
+<th>LQ</th>
+<th>ILQ</th>
+<th>ETX</th>
+</tr>
+<% 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["Last hop IP"]%>"><%=route["Last hop IP"]%></a></td>
+<td><%=route.LQ%></td>
+<td><%=route.ILQ%></td>
+<td><%=route.ETX%></td>
+</tr>
+<% end %>
+</table>
+<br />
+<%+footer%> \ No newline at end of file