2010-12-17 02:14:28 +00:00
< %#
2015-01-16 22:38:38 +00:00
Copyright 2008 Steven Barth < steven @ midlink . org >
2015-01-16 22:46:42 +00:00
Copyright 2008 Jo-Philipp Wich < jow @ openwrt . org >
2015-01-16 22:38:38 +00:00
Copyright 2011 Manuel Munz < freifunk at somakoma dot de >
Licensed to the public under the Apache License 2.0.
2010-12-17 02:14:28 +00:00
-%>
< %
2015-05-30 20:53:11 +00:00
has_ipv4_conf = luci.model.uci.cursor():get_first("olsrd", "olsrd", "IpVersion")
has_ipv6_conf = luci.model.uci.cursor():get_first("olsrd6", "olsrd", "IpVersion")
2010-12-17 02:14:28 +00:00
function write_conf(conf, file)
2015-01-15 13:55:46 +00:00
local fs = require "nixio.fs"
2010-12-17 02:14:28 +00:00
if fs.access(conf) then
luci.http.header("Content-Disposition", "attachment; filename="..file)
luci.http.prepare_content("text/plain")
luci.http.write(fs.readfile(conf))
end
end
conf = luci.http.formvalue()
2015-05-30 20:53:11 +00:00
if conf.openwrt_v4 then
2010-12-17 02:14:28 +00:00
write_conf("/etc/config/olsrd", "olsrd")
return false
end
2015-05-30 20:53:11 +00:00
if conf.openwrt_v6 then
write_conf("/etc/config/olsrd6", "olsrd6")
2010-12-17 02:14:28 +00:00
return false
end
2015-05-30 20:53:11 +00:00
if conf.conf_v4 then
write_conf("/var/etc/olsrd.conf", "olsrd.conf")
2010-12-17 02:14:28 +00:00
return false
end
2015-05-30 20:53:11 +00:00
if conf.conf_v6 then
write_conf("/var/etc/olsrd6.conf", "olsrd6.conf")
2010-12-17 02:14:28 +00:00
return false
end
%>
< %+header%>
2011-11-09 18:12:25 +00:00
< script type = "text/javascript" > / / < ! [ C D A T A [
2013-03-16 18:08:13 +00:00
XHR.poll(10, '< %=REQUEST_URI%>/json', { },
2011-11-09 18:12:25 +00:00
function(x, info)
{
var e;
2013-03-16 18:08:13 +00:00
if (! info) {
document.getElementById('error').innerHTML = '< %:Could not get any data. Make sure the jsoninfo plugin is installed and allows connections from localhost.%>';
return
}
document.getElementById('error').innerHTML = '';
if (e = document.getElementById('version'))
var version;
var date;
if (info.v4.config.olsrdVersion != undefined) {
version = info.v4.config.olsrdVersion
date = info.v4.config.olsrdBuildDate
} else if (info.v6.config.olsrdVersion != undefined) {
version = info.v6.config.olsrdVersion
date = info.v6.config.olsrdBuildDate
} else {
version = 'unknown'
date = 'unknown'
}
e.innerHTML = version + '< br / > ' + date;
if (e = document.getElementById('nr_neigh'))
var neigh = 0;
2013-03-26 10:30:41 +00:00
if (info.v4.links != undefined) {
2013-03-16 18:08:13 +00:00
neigh = neigh + info.v4.links.length
}
2013-03-26 10:30:41 +00:00
if (info.v6.links != undefined) {
2013-03-16 18:08:13 +00:00
neigh = neigh + info.v6.links.length
}
e.innerHTML = neigh;
if (e = document.getElementById('nr_hna'))
var hna = 0;
2013-03-26 10:30:41 +00:00
if (info.v4.hna != undefined) {
2013-03-16 18:08:13 +00:00
hna = hna + info.v4.hna.length
}
2013-03-26 10:30:41 +00:00
if (info.v6.hna != undefined) {
2013-03-16 18:08:13 +00:00
hna = hna + info.v6.hna.length
}
e.innerHTML = hna;
2011-11-09 18:12:25 +00:00
if (e = document.getElementById('nr_ifaces'))
2013-03-16 18:08:13 +00:00
var nrint = 0
2013-03-26 10:30:41 +00:00
if (info.v4.interfaces != undefined) {
2013-03-16 18:08:13 +00:00
nrint = nrint + info.v4.interfaces.length
}
2013-03-26 10:30:41 +00:00
if (info.v6.interfaces != undefined) {
2013-03-16 18:08:13 +00:00
nrint = nrint + info.v6.interfaces.length
}
e.innerHTML = nrint
2011-11-09 18:12:25 +00:00
if (e = document.getElementById('nr_topo'))
2013-03-16 18:08:13 +00:00
var topo = 0;
var nodes = [];
Array.prototype.contains = function (element) {
for (var i = 0; i < this.length ; i + + ) {
if (this[i] == element) {
return true;
}
}
return false;
}
2013-03-26 10:30:41 +00:00
if (info.v4.topology != undefined) {
2013-03-16 18:08:13 +00:00
topo = topo + info.v4.topology.length;
for (var i = 0; i < info.v4.topology.length ; i + + ) {
var destip = info.v4.topology[i].destinationIP
if (! nodes.contains(destip) ) {
nodes.push(destip)
}
}
}
2013-03-26 10:30:41 +00:00
if (info.v6.topology != undefined) {
2013-03-16 18:08:13 +00:00
topo = topo + info.v6.topology.length
for (var i = 0; i < info.v6.topology.length ; i + + ) {
var destip = info.v6.topology[i].destinationIP
if (! nodes.contains(destip) ) {
nodes.push(destip)
}
}
}
e.innerHTML = topo;
if (e = document.getElementById('nr_nodes'))
e.innerHTML = nodes.length;
if (e = document.getElementById('meshfactor'))
var meshfactor = topo / nodes.length
e.innerHTML = meshfactor.toFixed(2)
2011-11-09 18:12:25 +00:00
}
);
//]]>< / script >
2013-03-16 18:08:13 +00:00
< div id = "error" class = "error" > < / div >
2015-10-06 11:29:43 +00:00
< h2 name = "content" > OLSR < %:Overview%>< / h2 >
2010-12-17 02:14:28 +00:00
2013-03-16 18:08:13 +00:00
< fieldset class = "cbi-section" >
< legend > < %:Network%>< / legend >
2018-05-28 12:57:54 +00:00
< div class = "table" width = "100%" cellspacing = "10" >
< div class = "tr" > < div class = "td" width = "33%" > < %:Interfaces%>< / div > < div class = "td" >
2013-03-16 18:08:13 +00:00
< a href = "<%=REQUEST_URI%>/interfaces" >
< span id = "nr_ifaces" > -< span >
< / a >
2018-05-28 12:57:54 +00:00
< / div > < / div >
< div class = "tr" > < div class = "td" width = "33%" > < %:Neighbors%>< / div > < div class = "td" >
2013-03-16 18:08:13 +00:00
< a href = "<%=REQUEST_URI%>/neighbors" >
< span id = "nr_neigh" > -< / span >
< / a >
2018-05-28 12:57:54 +00:00
< / div > < / div >
< div class = "tr" > < div class = "td" width = "33%" > < %:Nodes%>< / div > < div class = "td" >
2013-03-16 18:08:13 +00:00
< a href = "<%=REQUEST_URI%>/topology" >
< span id = "nr_nodes" > -< / span >
< / a >
2018-05-28 12:57:54 +00:00
< / div > < / div >
< div class = "tr" > < div class = "td" width = "33%" > < %:HNA%>< / div > < div class = "td" >
2013-03-16 18:08:13 +00:00
< a href = "<%=REQUEST_URI%>/hna" >
< span id = "nr_hna" > -< / span >
< / a >
2018-05-28 12:57:54 +00:00
< / div > < / div >
< div class = "tr" > < div class = "td" width = "33%" > < %:Links total%>< / div > < div class = "td" >
2013-03-16 18:08:13 +00:00
< a href = "<%=REQUEST_URI%>/topology" >
< span id = "nr_topo" > -< / span >
< / a >
2018-05-28 12:57:54 +00:00
< / div > < / div >
< div class = "tr" > < div class = "td" width = "33%" > < %:Links per node (average)%>< / div > < div class = "td" >
2013-03-16 18:08:13 +00:00
< span id = "meshfactor" > -< / span >
2018-05-28 12:57:54 +00:00
< / div > < / div >
2013-03-16 18:08:13 +00:00
2018-05-28 12:57:54 +00:00
< / div >
2013-03-16 18:08:13 +00:00
< / fieldset >
< fieldset class = "cbi-section" >
< legend > OLSR < %:Configuration%>< / legend >
2018-05-28 12:57:54 +00:00
< div class = "table" width = "100%" cellspacing = "10" >
< div class = "tr" > < div class = "td" width = "33%" > < %:Version%>< / div > < div class = "td" >
2013-03-16 18:08:13 +00:00
< span id = "version" > -< span >
2018-05-28 12:57:54 +00:00
< / div > < / div >
< div class = "tr" > < div class = "td" width = "33%" > < %:Download Config%>< / div > < div class = "td" >
2015-05-30 20:53:11 +00:00
< % if has_ipv4_conf then %>
< a href = "<%=REQUEST_URI%>?openwrt_v4" > OpenWrt (IPv4)< / a > ,
< % end %>
< % if has_ipv6_conf then %>
< a href = "<%=REQUEST_URI%>?openwrt_v6" > OpenWrt (IPv6)< / a > ,
< % end %>
< % if has_ipv4_conf then %>
< a href = "<%=REQUEST_URI%>?conf_v4" > OLSRD (IPv4)< / a > ,
< % end %>
< % if has_ipv6_conf then %>
< a href = "<%=REQUEST_URI%>?conf_v6" > OLSRD (IPv6)< / a >
< % end %>
2018-05-28 12:57:54 +00:00
< / div > < / div >
< / div >
2013-03-16 18:08:13 +00:00
< / fieldset >
2010-12-17 02:14:28 +00:00
< %+footer%>