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
15 local ipv = luci.model.uci.cursor():get_first(
"olsrd",
"olsrd",
"IpVersion",
"4")
17 function write_conf(conf, file)
18 local fs = require
"luci.fs"
19 if fs.access(conf) then
20 luci.http.header(
"Content-Disposition",
"attachment; filename="..file)
21 luci.http.prepare_content(
"text/plain")
22 luci.http.write(fs.readfile(conf))
26 conf = luci.http.formvalue()
29 write_conf(
"/etc/config/olsrd",
"olsrd")
34 write_conf(
"/var/etc/olsrd.conf.ipv4",
"olsrd.conf.ipv4")
39 write_conf(
"/var/etc/olsrd.conf.ipv6",
"olsrd.conf.ipv6")
44 write_conf(
"/var/etc/olsrd.conf",
"olsrd.conf")
52 <script type=
"text/javascript" src=
"<%=resource%>/cbi.js"></script>
53 <script type=
"text/javascript">//<![CDATA[
55 XHR.poll(
10, '<%=REQUEST_URI%
>/json', { },
61 document.getElementById('error').innerHTML = '<%:Could not get any data. Make sure the jsoninfo plugin is installed and allows connections from localhost.%
>';
64 document.getElementById('error').innerHTML = '';
66 if (e = document.getElementById('version'))
69 if (info.v4.config.olsrdVersion != undefined) {
70 version = info.v4.config.olsrdVersion
71 date = info.v4.config.olsrdBuildDate
72 } else if (info.v6.config.olsrdVersion != undefined) {
73 version = info.v6.config.olsrdVersion
74 date = info.v6.config.olsrdBuildDate
80 e.innerHTML = version + '
<br />' + date;
82 if (e = document.getElementById('nr_neigh'))
84 if (info.v4.links.length != undefined) {
85 neigh = neigh + info.v4.links.length
87 if (info.v6.links.length != undefined) {
88 neigh = neigh + info.v6.links.length
93 if (e = document.getElementById('nr_hna'))
95 if (info.v4.hna.length != undefined) {
96 hna = hna + info.v4.hna.length
98 if (info.v6.hna.length != undefined) {
99 hna = hna + info.v6.hna.length
104 if (e = document.getElementById('nr_ifaces'))
106 if (info.v4.interfaces.length != undefined) {
107 nrint = nrint + info.v4.interfaces.length
109 if (info.v6.interfaces.length != undefined) {
110 nrint = nrint + info.v6.interfaces.length
115 if (e = document.getElementById('nr_topo'))
119 Array.prototype.contains = function (element) {
120 for (var i =
0; i < this.length; i++) {
121 if (this[i] == element) {
128 if (info.v4.topology.length != undefined) {
129 topo = topo + info.v4.topology.length;
130 for (var i =
0; i < info.v4.topology.length; i++) {
131 var destip = info.v4.topology[i].destinationIP
132 if (! nodes.contains(destip) ) {
138 if (info.v6.topology.length != undefined) {
139 topo = topo + info.v6.topology.length
140 for (var i =
0; i < info.v6.topology.length; i++) {
141 var destip = info.v6.topology[i].destinationIP
142 if (! nodes.contains(destip) ) {
150 if (e = document.getElementById('nr_nodes'))
151 e.innerHTML = nodes.length;
153 if (e = document.getElementById('meshfactor'))
154 var meshfactor = topo / nodes.length
155 e.innerHTML = meshfactor.toFixed(
2)
161 <div id=
"error" class=
"error"></div>
163 <h2><a id=
"content" name=
"content">OLSR <%:Overview%
></a></h2>
165 <fieldset class=
"cbi-section">
166 <legend><%:Network%
></legend>
168 <table width=
"100%" cellspacing=
"10">
169 <tr><td width=
"33%"><%:Interfaces%
></td><td>
170 <a href=
"<%=REQUEST_URI%>/interfaces">
171 <span id=
"nr_ifaces">-
<span>
174 <tr><td width=
"33%"><%:Neighbors%
></td><td>
175 <a href=
"<%=REQUEST_URI%>/neighbors">
176 <span id=
"nr_neigh">-
</span>
179 <tr><td width=
"33%"><%:Nodes%
></td><td>
180 <a href=
"<%=REQUEST_URI%>/topology">
181 <span id=
"nr_nodes">-
</span>
184 <tr><td width=
"33%"><%:HNA%
></td><td>
185 <a href=
"<%=REQUEST_URI%>/hna">
186 <span id=
"nr_hna">-
</span>
189 <tr><td width=
"33%"><%:Links total%
></td><td>
190 <a href=
"<%=REQUEST_URI%>/topology">
191 <span id=
"nr_topo">-
</span>
194 <tr><td width=
"33%"><%:Links per node (average)%
></td><td>
195 <span id=
"meshfactor">-
</span>
203 <fieldset class=
"cbi-section">
204 <legend>OLSR <%:Configuration%
></legend>
205 <table width=
"100%" cellspacing=
"10">
206 <tr><td width=
"33%"><%:Version%
></td><td>
207 <span id=
"version">-
<span>
209 <tr><td width=
"33%"><%:Download Config%
></td><td>
210 <a href=
"<%=REQUEST_URI%>?openwrt">OpenWrt
</a>,
211 <% if ipv ==
"6and4" then %
>
212 <a href=
"<%=REQUEST_URI%>?conf_v4">OLSRD IPv4
</a>,
213 <a href=
"<%=REQUEST_URI%>?conf_v6">OLSRD IPv6
</a>
215 <a href=
"<%=REQUEST_URI%>?conf">OLSRD
</a>