2008-07-07 22:00:56 +00:00
|
|
|
<%#
|
|
|
|
LuCI - Lua Configuration Interface
|
|
|
|
Copyright 2008 Steven Barth <steven@midlink.org>
|
|
|
|
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
|
2011-11-09 18:12:25 +00:00
|
|
|
Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
|
2013-07-02 22:31:04 +00:00
|
|
|
|
2008-07-07 22:00:56 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
-%>
|
2011-01-02 12:09:54 +00:00
|
|
|
|
2011-11-09 18:12:25 +00:00
|
|
|
<%
|
|
|
|
local olsrtools = require "luci.tools.olsr"
|
2011-11-13 12:34:09 +00:00
|
|
|
local i = 1
|
2011-11-09 18:12:25 +00:00
|
|
|
|
|
|
|
if luci.http.formvalue("status") == "1" then
|
|
|
|
local rv = {}
|
|
|
|
for k, link in ipairs(links) do
|
2013-03-16 18:08:13 +00:00
|
|
|
link.linkCost = tonumber(link.linkCost)/1024 or 0
|
|
|
|
if link.linkCost == 4096 then
|
|
|
|
link.linkCost = 0
|
|
|
|
end
|
|
|
|
local color = olsrtools.etx_color(link.linkCost)
|
2011-11-09 18:12:25 +00:00
|
|
|
defaultgw_color = ""
|
|
|
|
if link.defaultgw == 1 then
|
|
|
|
defaultgw_color = "#ffff99"
|
|
|
|
end
|
|
|
|
|
|
|
|
rv[#rv+1] = {
|
2013-03-16 18:08:13 +00:00
|
|
|
rip = link.remoteIP,
|
2013-07-02 22:31:04 +00:00
|
|
|
rmac = link.remoteMAC,
|
2013-03-16 18:08:13 +00:00
|
|
|
hn = link.hostname,
|
|
|
|
lip = link.localIP,
|
2013-07-02 22:31:04 +00:00
|
|
|
lmac = link.localMAC,
|
|
|
|
ifn = link.interface,
|
2013-03-16 18:08:13 +00:00
|
|
|
lq = string.format("%.3f", link.linkQuality),
|
|
|
|
nlq = string.format("%.3f",link.neighborLinkQuality),
|
|
|
|
cost = string.format("%.3f", link.linkCost),
|
2013-07-02 22:31:04 +00:00
|
|
|
snr = string.format("%.3f", link.snr),
|
|
|
|
signal = string.format("%.3f", link.signal),
|
|
|
|
noise = string.format("%.3f", link.noise),
|
2011-11-09 18:12:25 +00:00
|
|
|
color = color,
|
2013-03-16 18:08:13 +00:00
|
|
|
dfgcolor = defaultgw_color,
|
|
|
|
proto = link.proto
|
2011-11-09 18:12:25 +00:00
|
|
|
}
|
2011-01-02 12:09:54 +00:00
|
|
|
end
|
2011-11-09 18:12:25 +00:00
|
|
|
luci.http.prepare_content("application/json")
|
|
|
|
luci.http.write_json(rv)
|
|
|
|
return
|
|
|
|
end
|
2008-05-08 16:14:49 +00:00
|
|
|
%>
|
2011-11-09 18:12:25 +00:00
|
|
|
|
|
|
|
<%+header%>
|
|
|
|
|
|
|
|
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
|
|
|
|
<script type="text/javascript">//<![CDATA[
|
|
|
|
|
|
|
|
XHR.poll(10 , '<%=REQUEST_URI%>', { status: 1 },
|
|
|
|
function(x, info)
|
|
|
|
{
|
|
|
|
var nt = document.getElementById('olsr_neigh_table');
|
|
|
|
if (nt)
|
|
|
|
{
|
|
|
|
var s = '';
|
|
|
|
for (var idx = 0; idx < info.length; idx++)
|
|
|
|
{
|
|
|
|
var neigh = info[idx];
|
|
|
|
|
2013-03-16 18:08:13 +00:00
|
|
|
if (neigh.proto == '6') {
|
|
|
|
s += String.format(
|
|
|
|
'<tr class="cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-%s">' +
|
2013-07-02 22:31:04 +00:00
|
|
|
'<td class="cbi-section-table-titles" style="background-color:%s"><a href="http://[%s]/cgi-bin-status.html">%s/%s</a></td>',
|
|
|
|
neigh.proto, neigh.dfgcolor, neigh.rip, neigh.rip, neigh.rmac
|
2013-03-16 18:08:13 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
s += String.format(
|
|
|
|
'<tr class="cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-%s">' +
|
2013-07-02 22:31:04 +00:00
|
|
|
'<td class="cbi-section-table-titles" style="background-color:%s"><a href="http://%s/cgi-bin-status.html">%s/%s</a></td>',
|
|
|
|
neigh.proto, neigh.dfgcolor, neigh.rip, neigh.rip, neigh.rmac
|
2013-03-16 18:08:13 +00:00
|
|
|
);
|
|
|
|
}
|
2011-11-09 18:12:25 +00:00
|
|
|
if (neigh.hn) {
|
2013-07-02 22:31:04 +00:00
|
|
|
s += String.format(
|
|
|
|
'<td class="cbi-section-table-titles" style="background-color:%s"><a href="http://%s/cgi-bin-status.html">%s</a></td>' +
|
2011-11-09 18:12:25 +00:00
|
|
|
neigh.dfgcolor, neigh.hn, neigh.hn
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
s += String.format(
|
2013-07-02 22:31:04 +00:00
|
|
|
'<td class="cbi-section-table-titles" style="background-color:%s">?</td>',
|
2011-11-09 18:12:25 +00:00
|
|
|
neigh.dfgcolor
|
|
|
|
);
|
|
|
|
}
|
|
|
|
s += String.format(
|
2013-07-02 22:31:04 +00:00
|
|
|
'<td class="cbi-section-table-titles" style="background-color:%s">%s/%s/%s</td>' +
|
|
|
|
'<td class="cbi-section-table-titles" style="background-color:%s">%s</td>' +
|
|
|
|
'<td class="cbi-section-table-titles" style="background-color:%s">%s</td>' +
|
|
|
|
'<td class="cbi-section-table-titles" style="background-color:%s">%s</td>' +
|
|
|
|
'<td class="cbi-section-table-titles" style="background-color:%s" title="Signal: %s Noise: %s">%s</td>' +
|
|
|
|
'</tr>',
|
|
|
|
neigh.dfgcolor, neigh.ifn, neigh.lip, neigh.lmac, neigh.dfgcolor, neigh.lq, neigh.dfgcolor, neigh.nlq, neigh.color, neigh.cost, neigh.color, neigh.signal, neigh.noise, neigh.snr || '?'
|
2011-11-09 18:12:25 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
nt.innerHTML = s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
//]]></script>
|
|
|
|
|
|
|
|
|
|
|
|
<h2><a id="content" name="content"><%:OLSR connections%></a></h2>
|
|
|
|
|
2013-03-16 18:08:13 +00:00
|
|
|
<div id="togglebuttons"></div>
|
|
|
|
|
2011-11-09 18:12:25 +00:00
|
|
|
<fieldset class="cbi-section">
|
|
|
|
<legend><%:Overview of currently established OLSR connections%></legend>
|
|
|
|
|
|
|
|
<table class="cbi-section-table">
|
2011-11-13 12:34:09 +00:00
|
|
|
<thead>
|
|
|
|
<tr class="cbi-section-table-titles">
|
|
|
|
<th class="cbi-section-table-cell"><%:Neighbour IP%></th>
|
|
|
|
<th class="cbi-section-table-cell"><%:Hostname%></th>
|
|
|
|
<th class="cbi-section-table-cell"><%:Local interface IP%></th>
|
|
|
|
<th class="cbi-section-table-cell">LQ</th>
|
|
|
|
<th class="cbi-section-table-cell">NLQ</th>
|
|
|
|
<th class="cbi-section-table-cell">ETX</th>
|
2013-07-02 22:31:04 +00:00
|
|
|
<th class="cbi-section-table-cell">SNR</th>
|
2011-11-13 12:34:09 +00:00
|
|
|
</tr>
|
|
|
|
</thead>
|
2011-11-09 18:12:25 +00:00
|
|
|
|
|
|
|
<tbody id="olsr_neigh_table">
|
|
|
|
<% local i = 1
|
|
|
|
for k, link in ipairs(links) do
|
2013-03-16 18:08:13 +00:00
|
|
|
link.linkCost = tonumber(link.linkCost)/1024 or 0
|
|
|
|
if link.linkCost == 4096 then
|
|
|
|
link.linkCost = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
color = olsrtools.etx_color(link.linkCost)
|
2011-11-09 18:12:25 +00:00
|
|
|
|
|
|
|
defaultgw_color = ""
|
|
|
|
if link.defaultgw == 1 then
|
|
|
|
defaultgw_color = "#ffff99"
|
|
|
|
end
|
|
|
|
%>
|
|
|
|
|
2013-03-16 18:08:13 +00:00
|
|
|
<tr class="cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=link.proto%>">
|
|
|
|
<% if link.proto == "6" then %>
|
2013-07-02 22:31:04 +00:00
|
|
|
<td class="cbi-section-table-titles" style="background-color:<%=defaultgw_color%>"><a href="http://[<%=link.remoteIP%>]/cgi-bin-status.html"><%=link.remoteIP%>/<%=link.remoteMAC%></a></td>
|
2013-03-16 18:08:13 +00:00
|
|
|
<% else %>
|
2013-07-02 22:31:04 +00:00
|
|
|
<td class="cbi-section-table-titles" style="background-color:<%=defaultgw_color%>"><a href="http://<%=link.remoteIP%>/cgi-bin-status.html"><%=link.remoteIP%>/<%=link.remoteMAC%></a></td>
|
2013-03-16 18:08:13 +00:00
|
|
|
<% end %>
|
2013-07-02 22:31:04 +00:00
|
|
|
<td class="cbi-section-table-titles" style="background-color:<%=defaultgw_color%>"><a href="http://<%=link.hostname%>/cgi-bin-status.html"><%=link.hostname%></a></td>
|
|
|
|
<td class="cbi-section-table-titles" style="background-color:<%=defaultgw_color%>"><%=link.interface%>/<%=link.localIP%>/<%=link.localMAC%></td>
|
|
|
|
<td class="cbi-section-table-titles" style="background-color:<%=defaultgw_color%>"><%=string.format("%.3f", link.linkQuality)%></td>
|
|
|
|
<td class="cbi-section-table-titles" style="background-color:<%=defaultgw_color%>"><%=string.format("%.3f", link.neighborLinkQuality)%></td>
|
|
|
|
<td class="cbi-section-table-titles" style="background-color:<%=color%>"><%=string.format("%.3f", link.linkCost)%></td>
|
|
|
|
<td class="cbi-section-table-titles" style="background-color:<%=color%>" title="Signal: <%=string.format("%.3f", link.signal)%> Noise: <%=string.format("%.3f", link.noise)%>"><%=string.format("%.3f", link.snr)%></td>
|
2011-11-09 18:12:25 +00:00
|
|
|
</tr>
|
|
|
|
<%
|
2011-11-13 12:34:09 +00:00
|
|
|
i = ((i % 2) + 1)
|
2011-11-09 18:12:25 +00:00
|
|
|
end %>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2008-05-08 16:14:49 +00:00
|
|
|
<br />
|
2011-11-09 18:12:25 +00:00
|
|
|
|
2013-03-16 18:08:13 +00:00
|
|
|
<%+status-olsr/legend%>
|
2011-11-09 18:12:25 +00:00
|
|
|
</fieldset>
|
2013-03-16 18:08:13 +00:00
|
|
|
<%+status-olsr/common_js%>
|
2008-09-14 20:57:00 +00:00
|
|
|
<%+footer%>
|