2 Copyright 2008 Steven Barth <steven@midlink.org>
3 Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
4 Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
5 Licensed to the public under the Apache License 2.0.
10 local olsrtools = require "luci.tools.olsr"
13 if luci.http.formvalue("status") == "1" then
15 for k, route in ipairs(routes) do
16 local ETX = string.format("%.3f", tonumber(route.rtpMetricCost)/1024 or 0)
18 hostname = route.hostname,
19 dest = route.destination,
20 genmask = route.genmask,
22 interface = route.networkInterface,
23 metric = route.metric,
25 color = olsrtools.etx_color(tonumber(ETX))
28 luci.http.prepare_content("application/json")
29 luci.http.write_json(rv)
37 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
38 <script type="text/javascript">//<![CDATA[
40 XHR.poll(20, '<%=REQUEST_URI%>', { status: 1 },
44 var rt = document.getElementById('olsrd_routes');
48 for (var idx = 0; idx < info.length; idx++)
50 var route = info[idx];
53 '<tr class="cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-%s">' +
54 '<td class="cbi-section-table-cell">%s/%s</td>' +
55 '<td class="cbi-section-table-cell">' +
56 '<a href="http://%s/cgi-bin-status.html">%s</a>',
57 route.proto, route.dest, route.genmask, route.gw, route.gw
61 if (hna.proto == '6') {
63 ' / <a href="http://[%s]/cgi-bin-status.html">%s</a>',
64 route.hostname, route.hostname || '?'
68 ' / <a href="http://%s/cgi-bin-status.html">%s</a>',
69 route.hostname, route.hostname || '?'
76 '<td class="cbi-section-table-cell">%s</td>' +
77 '<td class="cbi-section-table-cell">%s</td>' +
78 '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
80 route.interface, route.metric, route.color, route.etx || '?'
92 <h2><a id="content" name="content"><%:Known OLSR routes%></a></h2>
94 <div id="togglebuttons"></div>
96 <fieldset class="cbi-section">
97 <legend><%:Overview of currently known routes to other OLSR nodes%></legend>
99 <table class="cbi-section-table">
101 <tr class="cbi-section-table-titles">
102 <th class="cbi-section-table-cell"><%:Announced network%></th>
103 <th class="cbi-section-table-cell"><%:OLSR gateway%></th>
104 <th class="cbi-section-table-cell"><%:Interface%></th>
105 <th class="cbi-section-table-cell"><%:Metric%></th>
106 <th class="cbi-section-table-cell">ETX</th>
110 <tbody id="olsrd_routes">
112 <% for k, route in ipairs(routes) do
113 ETX = tonumber(route.rtpMetricCost)/1024 or '0'
114 color = olsrtools.etx_color(ETX)
117 <tr class="cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=route.proto%>">
118 <td class="cbi-section-table-cell"><%=route.destination%>/<%=route.genmask%></td>
119 <td class="cbi-section-table-cell">
120 <% if route.proto == '6' then %>
121 <a href="http://[<%=route.gateway%>]/cgi-bin-status.html"><%=route.gateway%></a>
123 <a href="http://<%=route.gateway%>/cgi-bin-status.html"><%=route.gateway%></a>
125 <% if route.hostname then %>
126 / <a href="http://<%=route.Hostname%>/cgi-bin-status.html"><%=route.hostname%></a>
129 <td class="cbi-section-table-cell"><%=route.networkInterface%></td>
130 <td class="cbi-section-table-cell"><%=route.metric%></td>
131 <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=string.format("%.3f", ETX)%></td>
139 <%+status-olsr/legend%>
141 <%+status-olsr/common_js%>