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
79 e.innerHTML = version + '
<br />' + date;
81 if (e = document.getElementById('nr_neigh'))
83 if (info.v4.links != undefined) {
84 neigh = neigh + info.v4.links.length
86 if (info.v6.links != undefined) {
87 neigh = neigh + info.v6.links.length
92 if (e = document.getElementById('nr_hna'))
94 if (info.v4.hna != undefined) {
95 hna = hna + info.v4.hna.length
97 if (info.v6.hna != undefined) {
98 hna = hna + info.v6.hna.length
103 if (e = document.getElementById('nr_ifaces'))
105 if (info.v4.interfaces != undefined) {
106 nrint = nrint + info.v4.interfaces.length
108 if (info.v6.interfaces != undefined) {
109 nrint = nrint + info.v6.interfaces.length
114 if (e = document.getElementById('nr_topo'))
118 Array.prototype.contains = function (element) {
119 for (var i =
0; i < this.length; i++) {
120 if (this[i] == element) {
127 if (info.v4.topology != undefined) {
128 topo = topo + info.v4.topology.length;
129 for (var i =
0; i < info.v4.topology.length; i++) {
130 var destip = info.v4.topology[i].destinationIP
131 if (! nodes.contains(destip) ) {
137 if (info.v6.topology != undefined) {
138 topo = topo + info.v6.topology.length
139 for (var i =
0; i < info.v6.topology.length; i++) {
140 var destip = info.v6.topology[i].destinationIP
141 if (! nodes.contains(destip) ) {
149 if (e = document.getElementById('nr_nodes'))
150 e.innerHTML = nodes.length;
152 if (e = document.getElementById('meshfactor'))
153 var meshfactor = topo / nodes.length
154 e.innerHTML = meshfactor.toFixed(
2)
160 <div id=
"error" class=
"error"></div>
162 <h2><a id=
"content" name=
"content">OLSR <%:Overview%
></a></h2>
164 <fieldset class=
"cbi-section">
165 <legend><%:Network%
></legend>
167 <table width=
"100%" cellspacing=
"10">
168 <tr><td width=
"33%"><%:Interfaces%
></td><td>
169 <a href=
"<%=REQUEST_URI%>/interfaces">
170 <span id=
"nr_ifaces">-
<span>
173 <tr><td width=
"33%"><%:Neighbors%
></td><td>
174 <a href=
"<%=REQUEST_URI%>/neighbors">
175 <span id=
"nr_neigh">-
</span>
178 <tr><td width=
"33%"><%:Nodes%
></td><td>
179 <a href=
"<%=REQUEST_URI%>/topology">
180 <span id=
"nr_nodes">-
</span>
183 <tr><td width=
"33%"><%:HNA%
></td><td>
184 <a href=
"<%=REQUEST_URI%>/hna">
185 <span id=
"nr_hna">-
</span>
188 <tr><td width=
"33%"><%:Links total%
></td><td>
189 <a href=
"<%=REQUEST_URI%>/topology">
190 <span id=
"nr_topo">-
</span>
193 <tr><td width=
"33%"><%:Links per node (average)%
></td><td>
194 <span id=
"meshfactor">-
</span>
202 <fieldset class=
"cbi-section">
203 <legend>OLSR <%:Configuration%
></legend>
204 <table width=
"100%" cellspacing=
"10">
205 <tr><td width=
"33%"><%:Version%
></td><td>
206 <span id=
"version">-
<span>
208 <tr><td width=
"33%"><%:Download Config%
></td><td>
209 <a href=
"<%=REQUEST_URI%>?openwrt">OpenWrt
</a>,
210 <% if ipv ==
"6and4" then %
>
211 <a href=
"<%=REQUEST_URI%>?conf_v4">OLSRD IPv4
</a>,
212 <a href=
"<%=REQUEST_URI%>?conf_v6">OLSRD IPv6
</a>
214 <a href=
"<%=REQUEST_URI%>?conf">OLSRD
</a>