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 has_ipv4_conf = luci.model.uci.cursor():get_first("olsrd", "olsrd", "IpVersion")
11 has_ipv6_conf = luci.model.uci.cursor():get_first("olsrd6", "olsrd", "IpVersion")
13 function write_conf(conf, file)
14 local fs = require "nixio.fs"
15 if fs.access(conf) then
16 luci.http.header("Content-Disposition", "attachment; filename="..file)
17 luci.http.prepare_content("text/plain")
18 luci.http.write(fs.readfile(conf))
22 conf = luci.http.formvalue()
24 if conf.openwrt_v4 then
25 write_conf("/etc/config/olsrd", "olsrd")
29 if conf.openwrt_v6 then
30 write_conf("/etc/config/olsrd6", "olsrd6")
35 write_conf("/var/etc/olsrd.conf", "olsrd.conf")
40 write_conf("/var/etc/olsrd6.conf", "olsrd6.conf")
48 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
49 <script type="text/javascript">//<![CDATA[
51 XHR.poll(10, '<%=REQUEST_URI%>/json', { },
57 document.getElementById('error').innerHTML = '<%:Could not get any data. Make sure the jsoninfo plugin is installed and allows connections from localhost.%>';
60 document.getElementById('error').innerHTML = '';
62 if (e = document.getElementById('version'))
65 if (info.v4.config.olsrdVersion != undefined) {
66 version = info.v4.config.olsrdVersion
67 date = info.v4.config.olsrdBuildDate
68 } else if (info.v6.config.olsrdVersion != undefined) {
69 version = info.v6.config.olsrdVersion
70 date = info.v6.config.olsrdBuildDate
75 e.innerHTML = version + '<br />' + date;
77 if (e = document.getElementById('nr_neigh'))
79 if (info.v4.links != undefined) {
80 neigh = neigh + info.v4.links.length
82 if (info.v6.links != undefined) {
83 neigh = neigh + info.v6.links.length
88 if (e = document.getElementById('nr_hna'))
90 if (info.v4.hna != undefined) {
91 hna = hna + info.v4.hna.length
93 if (info.v6.hna != undefined) {
94 hna = hna + info.v6.hna.length
99 if (e = document.getElementById('nr_ifaces'))
101 if (info.v4.interfaces != undefined) {
102 nrint = nrint + info.v4.interfaces.length
104 if (info.v6.interfaces != undefined) {
105 nrint = nrint + info.v6.interfaces.length
110 if (e = document.getElementById('nr_topo'))
114 Array.prototype.contains = function (element) {
115 for (var i = 0; i < this.length; i++) {
116 if (this[i] == element) {
123 if (info.v4.topology != undefined) {
124 topo = topo + info.v4.topology.length;
125 for (var i = 0; i < info.v4.topology.length; i++) {
126 var destip = info.v4.topology[i].destinationIP
127 if (! nodes.contains(destip) ) {
133 if (info.v6.topology != undefined) {
134 topo = topo + info.v6.topology.length
135 for (var i = 0; i < info.v6.topology.length; i++) {
136 var destip = info.v6.topology[i].destinationIP
137 if (! nodes.contains(destip) ) {
145 if (e = document.getElementById('nr_nodes'))
146 e.innerHTML = nodes.length;
148 if (e = document.getElementById('meshfactor'))
149 var meshfactor = topo / nodes.length
150 e.innerHTML = meshfactor.toFixed(2)
156 <div id="error" class="error"></div>
158 <h2><a id="content" name="content">OLSR <%:Overview%></a></h2>
160 <fieldset class="cbi-section">
161 <legend><%:Network%></legend>
163 <table width="100%" cellspacing="10">
164 <tr><td width="33%"><%:Interfaces%></td><td>
165 <a href="<%=REQUEST_URI%>/interfaces">
166 <span id="nr_ifaces">-<span>
169 <tr><td width="33%"><%:Neighbors%></td><td>
170 <a href="<%=REQUEST_URI%>/neighbors">
171 <span id="nr_neigh">-</span>
174 <tr><td width="33%"><%:Nodes%></td><td>
175 <a href="<%=REQUEST_URI%>/topology">
176 <span id="nr_nodes">-</span>
179 <tr><td width="33%"><%:HNA%></td><td>
180 <a href="<%=REQUEST_URI%>/hna">
181 <span id="nr_hna">-</span>
184 <tr><td width="33%"><%:Links total%></td><td>
185 <a href="<%=REQUEST_URI%>/topology">
186 <span id="nr_topo">-</span>
189 <tr><td width="33%"><%:Links per node (average)%></td><td>
190 <span id="meshfactor">-</span>
198 <fieldset class="cbi-section">
199 <legend>OLSR <%:Configuration%></legend>
200 <table width="100%" cellspacing="10">
201 <tr><td width="33%"><%:Version%></td><td>
202 <span id="version">-<span>
204 <tr><td width="33%"><%:Download Config%></td><td>
205 <% if has_ipv4_conf then %>
206 <a href="<%=REQUEST_URI%>?openwrt_v4">OpenWrt (IPv4)</a>,
208 <% if has_ipv6_conf then %>
209 <a href="<%=REQUEST_URI%>?openwrt_v6">OpenWrt (IPv6)</a>,
211 <% if has_ipv4_conf then %>
212 <a href="<%=REQUEST_URI%>?conf_v4">OLSRD (IPv4)</a>,
214 <% if has_ipv6_conf then %>
215 <a href="<%=REQUEST_URI%>?conf_v6">OLSRD (IPv6)</a>