2 LuCI - Lua Configuration Interface
3 Copyright
2008 Steven Barth
<steven@midlink.org
>
4 Copyright
2008 Jo-Philipp Wich
<xm@leipzig.freifunk.net
>
5 Copyright
2011 Manuel Munz
<freifunk at somakoma dot de
>
7 Licensed under the Apache License, Version
2.0 (the
"License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-
2.0
16 local olsrtools = require
"luci.tools.olsr"
19 if luci.http.formvalue(
"status") ==
"1" then
21 for k, link in ipairs(links) do
22 link.Cost = tonumber(link.Cost) or
0
23 local color = olsrtools.etx_color(link.Cost)
25 if link.defaultgw ==
1 then
26 defaultgw_color =
"#ffff99"
30 rip = link[
"Remote IP"],
31 hn = link[
"Hostname"],
32 lip = link[
"Local IP"],
33 dev = link[
"Local Device"],
36 cost = string.format(
"%.3f", link.Cost),
38 dfgcolor = defaultgw_color
41 luci.http.prepare_content(
"application/json")
42 luci.http.write_json(rv)
49 <script type=
"text/javascript" src=
"<%=resource%>/cbi.js"></script>
50 <script type=
"text/javascript">//<![CDATA[
52 XHR.poll(
10 , '<%=REQUEST_URI%
>', { status:
1 },
55 var nt = document.getElementById('olsr_neigh_table');
59 for (var idx =
0; idx < info.length; idx++)
61 var neigh = info[idx];
64 '
<tr class=
"cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+'">' +
65 '
<td class=
"cbi-section-table-cell" style=
"background-color:%s"><a href=
"http://%s/cgi-bin-status.html">%s
</a></td>',
66 neigh.dfgcolor, neigh.rip, neigh.rip
70 '
<td class=
"cbi-section-table-cell" style=
"background-color:%s"><a href=
"http://%s/cgi-bin-status.html">%s
</a></td>',
71 neigh.dfgcolor, neigh.hn, neigh.hn
76 '
<td class=
"cbi-section-table-cell" style=
"background-color:%s">?
</td>',
81 '
<td class=
"cbi-section-table-cell" style=
"background-color:%s">%s
</td>' +
82 '
<td class=
"cbi-section-table-cell" style=
"background-color:%s">%s
</td>' +
83 '
<td class=
"cbi-section-table-cell" style=
"background-color:%s">%s
</td>' +
84 '
<td class=
"cbi-section-table-cell" style=
"background-color:%s">%s
</td>' +
85 '
<td class=
"cbi-section-table-cell" style=
"background-color:%s">%s
</td>' +
88 neigh.dfgcolor, neigh.lip, neigh.dfgcolor, neigh.dev, neigh.dfgcolor, neigh.lq, neigh.dfgcolor, neigh.nlq, neigh.color, neigh.cost || '?'
99 <h2><a id=
"content" name=
"content"><%:OLSR connections%
></a></h2>
101 <fieldset class=
"cbi-section">
102 <legend><%:Overview of currently established OLSR connections%
></legend>
104 <table class=
"cbi-section-table">
106 <tr class=
"cbi-section-table-titles">
107 <th class=
"cbi-section-table-cell"><%:Neighbour IP%
></th>
108 <th class=
"cbi-section-table-cell"><%:Hostname%
></th>
109 <th class=
"cbi-section-table-cell"><%:Local interface IP%
></th>
110 <th class=
"cbi-section-table-cell"><%:Device%
></th>
111 <th class=
"cbi-section-table-cell">LQ
</th>
112 <th class=
"cbi-section-table-cell">NLQ
</th>
113 <th class=
"cbi-section-table-cell">ETX
</th>
117 <tbody id=
"olsr_neigh_table">
119 for k, link in ipairs(links) do
120 link.Cost = tonumber(link.Cost) or
0
121 color = olsrtools.etx_color(link.Cost)
124 if link.defaultgw ==
1 then
125 defaultgw_color =
"#ffff99"
129 <tr class=
"cbi-section-table-row cbi-rowstyle-<%=i%>">
130 <td class=
"cbi-section-table-cell" style=
"background-color:<%=defaultgw_color%>"><a href=
"http://<%=link["Remote IP
"]%>/cgi-bin-status.html"><%=link[
"Remote IP"]%
></a></td>
131 <td class=
"cbi-section-table-cell" style=
"background-color:<%=defaultgw_color%>"><a href=
"http://<%=link["Hostname
"]%>/cgi-bin-status.html"><%=link[
"Hostname"]%
></a></td>
132 <td class=
"cbi-section-table-cell" style=
"background-color:<%=defaultgw_color%>"><%=link[
"Local IP"]%
></td>
133 <td class=
"cbi-section-table-cell" style=
"background-color:<%=defaultgw_color%>"><%=link[
"Local Device"]%
></td>
134 <td class=
"cbi-section-table-cell" style=
"background-color:<%=defaultgw_color%>"><%=link.LQ%
></td>
135 <td class=
"cbi-section-table-cell" style=
"background-color:<%=defaultgw_color%>"><%=link.NLQ%
></td>
136 <td class=
"cbi-section-table-cell" style=
"background-color:<%=color%>"><%=string.format(
"%.3f", link.Cost)%
></td>
145 <h3><%:Legend%
>:
</h3>
147 <li><strong>LQ:
</strong><%:Success rate of packages received from the neighbour%
></li>
148 <li><strong>NLQ:
</strong><%:Success rate of packages sent to the neighbour%
></li>
149 <li><strong>ETX:
</strong><%:Expected retransmission count%
></li>