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"
18 if luci.http.formvalue(
"status") ==
"1" then
22 for k, link in ipairs(links) do
23 link.Cost = tonumber(link.Cost) or
0
24 local color = olsrtools.etx_color(link.Cost)
26 if link.defaultgw ==
1 then
27 defaultgw_color =
"#ffff99"
31 rip = link[
"Remote IP"],
32 hn = link[
"Hostname"],
33 lip = link[
"Local IP"],
34 dev = link[
"Local Device"],
37 cost = string.format(
"%.3f", link.Cost),
40 dfgcolor = defaultgw_color
42 if i ==
1 then i =
0 elseif i ==
0 then i =
1 end
44 luci.http.prepare_content(
"application/json")
45 luci.http.write_json(rv)
52 <script type=
"text/javascript" src=
"<%=resource%>/cbi.js"></script>
53 <script type=
"text/javascript">//<![CDATA[
55 XHR.poll(
10 , '<%=REQUEST_URI%
>', { status:
1 },
58 var nt = document.getElementById('olsr_neigh_table');
62 for (var idx =
0; idx < info.length; idx++)
64 var neigh = info[idx];
67 '
<tr class=
"cbi-section-table-row cbi-rowstyle-%s">' +
68 '
<td class=
"cbi-section-table-cell" style=
"background-color:%s"><a href=
"http://%s/cgi-bin-status.html">%s
</a></td>',
69 neigh.rs, neigh.dfgcolor, neigh.rip, neigh.rip
73 '
<td class=
"cbi-section-table-cell" style=
"background-color:%s"><a href=
"http://%s/cgi-bin-status.html">%s
</a></td>',
74 neigh.dfgcolor, neigh.hn, neigh.hn
79 '
<td class=
"cbi-section-table-cell" style=
"background-color:%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>' +
86 '
<td class=
"cbi-section-table-cell" style=
"background-color:%s">%s
</td>' +
87 '
<td class=
"cbi-section-table-cell" style=
"background-color:%s">%s
</td>' +
88 '
<td class=
"cbi-section-table-cell" style=
"background-color:%s">%s
</td>' +
91 neigh.dfgcolor, neigh.lip, neigh.dfgcolor, neigh.dev, neigh.dfgcolor, neigh.lq, neigh.dfgcolor, neigh.nlq, neigh.color, neigh.cost || '?'
102 <h2><a id=
"content" name=
"content"><%:OLSR connections%
></a></h2>
104 <fieldset class=
"cbi-section">
105 <legend><%:Overview of currently established OLSR connections%
></legend>
107 <table class=
"cbi-section-table">
108 <tr class=
"cbi-section-table-titles">
109 <th class=
"cbi-section-table-cell"><%:Neighbour IP%
></th>
110 <th class=
"cbi-section-table-cell"><%:Hostname%
></th>
111 <th class=
"cbi-section-table-cell"><%:Local interface IP%
></th>
112 <th class=
"cbi-section-table-cell"><%:Device%
></th>
113 <th class=
"cbi-section-table-cell">LQ
</th>
114 <th class=
"cbi-section-table-cell">NLQ
</th>
115 <th class=
"cbi-section-table-cell">ETX
</th>
119 <tbody id=
"olsr_neigh_table">
121 for k, link in ipairs(links) do
122 link.Cost = tonumber(link.Cost) or
0
123 color = olsrtools.etx_color(link.Cost)
126 if link.defaultgw ==
1 then
127 defaultgw_color =
"#ffff99"
131 <tr class=
"cbi-section-table-row cbi-rowstyle-<%=i%>">
132 <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>
133 <td class=
"cbi-section-table-cell" style=
"background-color:<%=defaultgw_color%>"><a href=
"http://<%=link["Hostname
"]%>/cgi-bin-status.html"><%=link[
"Hostname"]%
></a></td>
134 <td class=
"cbi-section-table-cell" style=
"background-color:<%=defaultgw_color%>"><%=link[
"Local IP"]%
></td>
135 <td class=
"cbi-section-table-cell" style=
"background-color:<%=defaultgw_color%>"><%=link[
"Local Device"]%
></td>
136 <td class=
"cbi-section-table-cell" style=
"background-color:<%=defaultgw_color%>"><%=link.LQ%
></td>
137 <td class=
"cbi-section-table-cell" style=
"background-color:<%=defaultgw_color%>"><%=link.NLQ%
></td>
138 <td class=
"cbi-section-table-cell" style=
"background-color:<%=color%>"><%=string.format(
"%.3f", link.Cost)%
></td>
141 if i ==
1 then i =
0 elseif i ==
0 then i =
1 end
147 <h3><%:Legend%
>:
</h3>
149 <li><strong>LQ:
</strong><%:Success rate of packages received from the neighbour%
></li>
150 <li><strong>NLQ:
</strong><%:Success rate of packages sent to the neighbour%
></li>
151 <li><strong>ETX:
</strong><%:Expected retransmission count%
></li>