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, route in ipairs(routes) do
22 local ETX = string.format("%.3f", tonumber(route.rtpMetricCost)/1024 or 0)
24 hostname = route.hostname,
25 dest = route.destination,
26 genmask = route.genmask,
28 interface = route.networkInterface,
29 metric = route.metric,
31 color = olsrtools.etx_color(tonumber(ETX))
34 luci.http.prepare_content("application/json")
35 luci.http.write_json(rv)
43 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
44 <script type="text/javascript">//<![CDATA[
46 XHR.poll(20, '<%=REQUEST_URI%>', { status: 1 },
50 var rt = document.getElementById('olsrd_routes');
54 for (var idx = 0; idx < info.length; idx++)
56 var route = info[idx];
59 '<tr class="cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-%s">' +
60 '<td class="cbi-section-table-cell">%s/%s</td>' +
61 '<td class="cbi-section-table-cell">' +
62 '<a href="http://%s/cgi-bin-status.html">%s</a>',
63 route.proto, route.dest, route.genmask, route.gw, route.gw
67 if (hna.proto == '6') {
69 ' / <a href="http://[%s]/cgi-bin-status.html">%s</a>',
70 route.hostname, route.hostname || '?'
74 ' / <a href="http://%s/cgi-bin-status.html">%s</a>',
75 route.hostname, route.hostname || '?'
82 '<td class="cbi-section-table-cell">%s</td>' +
83 '<td class="cbi-section-table-cell">%s</td>' +
84 '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
86 route.interface, route.metric, route.color, route.etx || '?'
98 <h2><a id="content" name="content"><%:Known OLSR routes%></a></h2>
100 <div id="togglebuttons"></div>
102 <fieldset class="cbi-section">
103 <legend><%:Overview of currently known routes to other OLSR nodes%></legend>
105 <table class="cbi-section-table">
107 <tr class="cbi-section-table-titles">
108 <th class="cbi-section-table-cell"><%:Announced network%></th>
109 <th class="cbi-section-table-cell"><%:OLSR gateway%></th>
110 <th class="cbi-section-table-cell"><%:Interface%></th>
111 <th class="cbi-section-table-cell"><%:Metric%></th>
112 <th class="cbi-section-table-cell">ETX</th>
116 <tbody id="olsrd_routes">
118 <% for k, route in ipairs(routes) do
119 ETX = tonumber(route.rtpMetricCost)/1024 or '0'
120 color = olsrtools.etx_color(ETX)
123 <tr class="cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=route.proto%>">
124 <td class="cbi-section-table-cell"><%=route.destination%>/<%=route.genmask%></td>
125 <td class="cbi-section-table-cell">
126 <% if route.proto == '6' then %>
127 <a href="http://[<%=route.gateway%>]/cgi-bin-status.html"><%=route.gateway%></a>
129 <a href="http://<%=route.gateway%>/cgi-bin-status.html"><%=route.gateway%></a>
131 <% if route.hostname then %>
132 / <a href="http://<%=route.Hostname%>/cgi-bin-status.html"><%=route.hostname%></a>
135 <td class="cbi-section-table-cell"><%=route.networkInterface%></td>
136 <td class="cbi-section-table-cell"><%=route.metric%></td>
137 <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=string.format("%.3f", ETX)%></td>
145 <%+status-olsr/legend%>
147 <%+status-olsr/common_js%>