2 Copyright
2008 Steven Barth
<steven@midlink.org
>
3 Copyright
2008 Jo-Philipp Wich
<xm@leipzig.freifunk.net
>
4 Copyright
2011 Manuel Munz
<freifunk at somakoma dot de
>
5 Licensed to the public under the Apache License
2.0.
9 local ipv = luci.model.uci.cursor():get_first(
"olsrd",
"olsrd",
"IpVersion",
"4")
11 function write_conf(conf, file)
12 local fs = require
"nixio.fs"
13 if fs.access(conf) then
14 luci.http.header(
"Content-Disposition",
"attachment; filename="..file)
15 luci.http.prepare_content(
"text/plain")
16 luci.http.write(fs.readfile(conf))
20 conf = luci.http.formvalue()
23 write_conf(
"/etc/config/olsrd",
"olsrd")
28 write_conf(
"/var/etc/olsrd.conf.ipv4",
"olsrd.conf.ipv4")
33 write_conf(
"/var/etc/olsrd.conf.ipv6",
"olsrd.conf.ipv6")
38 write_conf(
"/var/etc/olsrd.conf",
"olsrd.conf")
46 <script type=
"text/javascript" src=
"<%=resource%>/cbi.js"></script>
47 <script type=
"text/javascript">//<![CDATA[
49 XHR.poll(
10, '<%=REQUEST_URI%
>/json', { },
55 document.getElementById('error').innerHTML = '<%:Could not get any data. Make sure the jsoninfo plugin is installed and allows connections from localhost.%
>';
58 document.getElementById('error').innerHTML = '';
60 if (e = document.getElementById('version'))
63 if (info.v4.config.olsrdVersion != undefined) {
64 version = info.v4.config.olsrdVersion
65 date = info.v4.config.olsrdBuildDate
66 } else if (info.v6.config.olsrdVersion != undefined) {
67 version = info.v6.config.olsrdVersion
68 date = info.v6.config.olsrdBuildDate
73 e.innerHTML = version + '
<br />' + date;
75 if (e = document.getElementById('nr_neigh'))
77 if (info.v4.links != undefined) {
78 neigh = neigh + info.v4.links.length
80 if (info.v6.links != undefined) {
81 neigh = neigh + info.v6.links.length
86 if (e = document.getElementById('nr_hna'))
88 if (info.v4.hna != undefined) {
89 hna = hna + info.v4.hna.length
91 if (info.v6.hna != undefined) {
92 hna = hna + info.v6.hna.length
97 if (e = document.getElementById('nr_ifaces'))
99 if (info.v4.interfaces != undefined) {
100 nrint = nrint + info.v4.interfaces.length
102 if (info.v6.interfaces != undefined) {
103 nrint = nrint + info.v6.interfaces.length
108 if (e = document.getElementById('nr_topo'))
112 Array.prototype.contains = function (element) {
113 for (var i =
0; i < this.length; i++) {
114 if (this[i] == element) {
121 if (info.v4.topology != undefined) {
122 topo = topo + info.v4.topology.length;
123 for (var i =
0; i < info.v4.topology.length; i++) {
124 var destip = info.v4.topology[i].destinationIP
125 if (! nodes.contains(destip) ) {
131 if (info.v6.topology != undefined) {
132 topo = topo + info.v6.topology.length
133 for (var i =
0; i < info.v6.topology.length; i++) {
134 var destip = info.v6.topology[i].destinationIP
135 if (! nodes.contains(destip) ) {
143 if (e = document.getElementById('nr_nodes'))
144 e.innerHTML = nodes.length;
146 if (e = document.getElementById('meshfactor'))
147 var meshfactor = topo / nodes.length
148 e.innerHTML = meshfactor.toFixed(
2)
154 <div id=
"error" class=
"error"></div>
156 <h2><a id=
"content" name=
"content">OLSR <%:Overview%
></a></h2>
158 <fieldset class=
"cbi-section">
159 <legend><%:Network%
></legend>
161 <table width=
"100%" cellspacing=
"10">
162 <tr><td width=
"33%"><%:Interfaces%
></td><td>
163 <a href=
"<%=REQUEST_URI%>/interfaces">
164 <span id=
"nr_ifaces">-
<span>
167 <tr><td width=
"33%"><%:Neighbors%
></td><td>
168 <a href=
"<%=REQUEST_URI%>/neighbors">
169 <span id=
"nr_neigh">-
</span>
172 <tr><td width=
"33%"><%:Nodes%
></td><td>
173 <a href=
"<%=REQUEST_URI%>/topology">
174 <span id=
"nr_nodes">-
</span>
177 <tr><td width=
"33%"><%:HNA%
></td><td>
178 <a href=
"<%=REQUEST_URI%>/hna">
179 <span id=
"nr_hna">-
</span>
182 <tr><td width=
"33%"><%:Links total%
></td><td>
183 <a href=
"<%=REQUEST_URI%>/topology">
184 <span id=
"nr_topo">-
</span>
187 <tr><td width=
"33%"><%:Links per node (average)%
></td><td>
188 <span id=
"meshfactor">-
</span>
196 <fieldset class=
"cbi-section">
197 <legend>OLSR <%:Configuration%
></legend>
198 <table width=
"100%" cellspacing=
"10">
199 <tr><td width=
"33%"><%:Version%
></td><td>
200 <span id=
"version">-
<span>
202 <tr><td width=
"33%"><%:Download Config%
></td><td>
203 <a href=
"<%=REQUEST_URI%>?openwrt">OpenWrt
</a>,
204 <% if ipv ==
"6and4" then %
>
205 <a href=
"<%=REQUEST_URI%>?conf_v4">OLSRD IPv4
</a>,
206 <a href=
"<%=REQUEST_URI%>?conf_v6">OLSRD IPv6
</a>
208 <a href=
"<%=REQUEST_URI%>?conf">OLSRD
</a>