2013-11-14 23:11:16 -07:00
|
|
|
#!/usr/bin/perl
|
2015-01-18 12:36:49 -07:00
|
|
|
=for commnet
|
|
|
|
|
2015-03-09 17:39:04 -06:00
|
|
|
Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
|
2015-01-18 12:36:49 -07:00
|
|
|
Copyright (C) 2015 Conrad Lara
|
|
|
|
See Contributors file for additional contributors
|
|
|
|
|
|
|
|
Copyright (c) 2013 David Rivenburg et al. BroadBand-HamNet
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation version 3 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-03-09 17:39:04 -06:00
|
|
|
Additional Terms:
|
|
|
|
|
|
|
|
Additional use restrictions exist on the AREDN(TM) trademark and logo.
|
|
|
|
See AREDNLicense.txt for more info.
|
|
|
|
|
|
|
|
Attributions to the AREDN Project must be retained in the source code.
|
|
|
|
If importing this code into a new or existing project attribution
|
|
|
|
to the AREDN project must be added to the source code.
|
|
|
|
|
|
|
|
You must not misrepresent the origin of the material conained within.
|
|
|
|
|
|
|
|
Modified versions must be modified to attribute to the original source
|
|
|
|
and be marked in reasonable ways as differentiate it from the original
|
|
|
|
version.
|
|
|
|
|
2015-01-18 12:36:49 -07:00
|
|
|
=cut
|
2013-11-14 23:11:16 -07:00
|
|
|
|
|
|
|
$debug = 0;
|
|
|
|
|
2013-12-02 13:04:54 -07:00
|
|
|
BEGIN {push @INC, '/www/cgi-bin'};
|
2013-11-14 23:11:16 -07:00
|
|
|
use perlfunc;
|
|
|
|
|
|
|
|
# collect some variables
|
2015-12-21 19:26:45 -07:00
|
|
|
$node = nvram_get("node");
|
2013-11-14 23:11:16 -07:00
|
|
|
$node = "NOCALL" if $node eq "";
|
|
|
|
$tactical = nvram_get("tactical");
|
|
|
|
$config = nvram_get("config");
|
|
|
|
$config = "not set" if $config eq "" or not -d "/etc/config.$config";
|
2015-03-25 00:25:18 -06:00
|
|
|
($my_ip) = get_ip4_network(get_interface("wifi"));
|
2013-11-14 23:11:16 -07:00
|
|
|
|
2015-12-21 19:26:45 -07:00
|
|
|
chomp ($chanbw = `cat /sys/kernel/debug/ieee80211/phy0/ath9k/chanbw`);
|
|
|
|
if ($chanbw eq "0x00000005") {$chanbw = 4;}
|
|
|
|
elsif ($chanbw eq "0x0000000a") {$chanbw = 2;}
|
|
|
|
else {$chanbw = 1;}
|
|
|
|
|
2013-11-14 23:11:16 -07:00
|
|
|
read_postdata();
|
|
|
|
|
|
|
|
system "mkdir -p /tmp/web";
|
|
|
|
system "touch /tmp/web/automesh" if $parms{auto};
|
|
|
|
system "rm -f /tmp/web/automesh" if $parms{stop};
|
|
|
|
|
|
|
|
# parse the txtinfo output
|
|
|
|
|
|
|
|
$table = "none";
|
|
|
|
chomp($tmperr = `mktemp /tmp/web/nc.XXXXXX`);
|
|
|
|
|
|
|
|
foreach(`echo /all | nc 127.0.0.1 2006 2>$tmperr`)
|
|
|
|
{
|
|
|
|
if(/^Table: (\w+)/)
|
|
|
|
{
|
|
|
|
$table = $1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
next if /^\s*$/ or /^\D/;
|
|
|
|
|
|
|
|
if($table eq "Links")
|
|
|
|
{
|
2015-05-04 10:39:52 -06:00
|
|
|
($junk, $ip, $junk, $lq, $nlq) = split /\s+/, $_;
|
|
|
|
$links{$ip}{lq} = $lq;
|
|
|
|
$links{$ip}{nlq} = $nlq;
|
2015-12-21 19:26:45 -07:00
|
|
|
|
2016-01-01 17:08:02 -07:00
|
|
|
$mac = `grep $ip /proc/net/arp | grep wlan0 | grep -v "00:00:00:00:00:00" | head -1`;
|
2015-12-21 19:26:45 -07:00
|
|
|
$mac =~ s/^.*(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w).*$/$1/;
|
|
|
|
chomp $mac;
|
|
|
|
|
|
|
|
if (! $mac or ! -e "/sys/kernel/debug/ieee80211/phy0/netdev:wlan0/stations/$mac" )
|
|
|
|
{
|
2016-01-01 17:08:02 -07:00
|
|
|
$mbps = "";
|
2015-12-21 19:26:45 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#802.11n
|
|
|
|
$mbps = `egrep 'HT(4|2)0\\\/\(L|S\)GI[ \t]+(A|T)' /sys/kernel/debug/ieee80211/phy0/netdev\:wlan0/stations/$mac/rc_stats`;
|
2016-01-01 17:08:02 -07:00
|
|
|
if ($mbps) { $mbps =~ s/HT(4|2)0\/(L|S)GI[[ \tTtPABCD]+MCS[0-9]+[ \t]*([0-9\.]+).*$/$3/ ; }
|
2015-12-21 19:26:45 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
#802.11a/g
|
2016-01-01 17:08:02 -07:00
|
|
|
$mbps = `egrep \"^A[BCDP \t]+[0-9\.]+\" /sys/kernel/debug/ieee80211/phy0/netdev\:wlan0/stations/$mac/rc_stats`;
|
|
|
|
if ($mbps) { $mbps =~ s/^A[ \tBCDP]+[0-9\.]+[ \t]+([0-9\.]+).*$/$1/ ; }
|
2015-12-21 19:26:45 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
#802.11b
|
|
|
|
$mbps = `egrep \"CCK\/LP[ \t]*T\" /sys/kernel/debug/ieee80211/phy0/netdev\:wlan0/stations/$mac/rc_stats`;
|
2016-01-01 17:08:02 -07:00
|
|
|
if ($mbps) { $mbps =~ s/CCK\/LP[ \tTtP]+[0-9\.]+M[ \t]*([0-9\.]+).*$/$1/ ; }
|
|
|
|
else { $mbps = ""; }
|
2015-12-21 19:26:45 -07:00
|
|
|
}
|
|
|
|
}
|
2016-01-01 17:08:02 -07:00
|
|
|
if ( ! $mbps eq "" )
|
|
|
|
{
|
|
|
|
$mbps /= $chanbw;
|
|
|
|
$links{$ip}{mbps} = sprintf "%.1f",$mbps;
|
|
|
|
}
|
|
|
|
else { $links{$ip}{mbps} = ""; }
|
2015-12-21 19:26:45 -07:00
|
|
|
}
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|
|
|
|
elsif($table eq "Neighbors")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
elsif($table eq "Topology")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
elsif($table eq "HNA")
|
|
|
|
{
|
2015-05-25 10:25:38 -06:00
|
|
|
($iproute, $ip) = split /\s+/, $_;
|
|
|
|
($net, $cidr) = split /\//, $iproute;
|
|
|
|
if ( $net eq "0.0.0.0" ) { $wangateway{$ip} = 1; }
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|
|
|
|
elsif($table eq "MID")
|
|
|
|
{
|
2015-05-24 23:43:26 -06:00
|
|
|
($ip, $junk) = split /\s+/, $_;
|
|
|
|
foreach $aip ( split /;/, $junk ) { $ipalias{$aip} = $ip }
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|
|
|
|
elsif($table eq "Routes")
|
|
|
|
{
|
|
|
|
($ip, $junk, $junk, $etx) = split /\s+/, $_;
|
|
|
|
($net, $cidr) = split /\//, $ip;
|
|
|
|
$routes{$net}{cidr} = $cidr;
|
|
|
|
$routes{$net}{etx} = $etx;
|
|
|
|
$routes{$net}{value} = ip2decimal($net);
|
|
|
|
$routes{$net}{mask} = 0xffffffff - ((1 << (32 - $cidr)) - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# stat and -s do not work in microperl
|
|
|
|
@parts = split /\s+/, `ls -l $tmperr`;
|
|
|
|
$txtinfo_err = $parts[4];
|
|
|
|
unlink $tmperr;
|
|
|
|
|
|
|
|
# load the local hosts file
|
|
|
|
foreach(`cat /etc/hosts`)
|
|
|
|
{
|
|
|
|
next unless /^10[.]/;
|
|
|
|
chomp;
|
|
|
|
($ip, $name, $tactical) = split /\s+/, $_;
|
2014-06-23 20:42:20 -06:00
|
|
|
next if $name =~ /^(localhost|localnode|localap|dtdlink\..*)$/;
|
2015-07-02 00:10:13 -06:00
|
|
|
if ( $name !~ /\./ ) { $name="${name}.local.mesh"; }
|
2013-11-14 23:11:16 -07:00
|
|
|
if($ip eq $my_ip)
|
|
|
|
{
|
|
|
|
$tactical = "" unless $tactical;
|
|
|
|
$localhosts{$ip}{tactical} = $tactical;
|
|
|
|
$localhosts{$ip}{name} = $name;
|
|
|
|
}
|
2015-05-24 23:43:26 -06:00
|
|
|
else { push @{$localhosts{$my_ip}{hosts}}, $name; }
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# load the olsr hosts file
|
|
|
|
foreach(`cat /var/run/hosts_olsr 2>/dev/null`)
|
|
|
|
{
|
|
|
|
next unless /^\d/;
|
|
|
|
chomp;
|
|
|
|
($ip, $name, $junk, $originator, $mid, $midnum) = split /\s+/, $_;
|
|
|
|
next unless $originator;
|
|
|
|
next if $originator eq "myself";
|
2015-05-24 23:43:26 -06:00
|
|
|
|
2015-07-02 00:10:13 -06:00
|
|
|
if (( $name !~ /\./ ) || ( $name =~ /^mid\.[^\.]*$/ )) { $name="${name}.local.mesh"; }
|
2015-05-24 23:43:26 -06:00
|
|
|
|
|
|
|
if ( $ip eq $originator )
|
2014-06-23 20:42:20 -06:00
|
|
|
{
|
2015-05-24 23:43:26 -06:00
|
|
|
if($hosts{$ip}{name}) { $hosts{$ip}{tactical} = $name }
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$hosts{$ip}{name} = $name;
|
|
|
|
if ( $routes{$ip} ) { $hosts{$ip}{etx} = $routes{$ip}{etx} ; }
|
|
|
|
else { $hosts{$ip}{etx} = "99.000"; }
|
|
|
|
}
|
2014-06-23 20:42:20 -06:00
|
|
|
}
|
2015-05-24 23:43:26 -06:00
|
|
|
elsif ( $name =~ /^dtdlink\..*$/ )
|
|
|
|
{
|
2014-06-23 20:42:20 -06:00
|
|
|
$hosts{$ip}{name} = $name;
|
2015-05-24 23:43:26 -06:00
|
|
|
if ( $routes{$ip} ) { $hosts{$ip}{etx} = $routes{$ip}{etx} ; }
|
|
|
|
else { $hosts{$ip}{etx} = "99.000"; }
|
|
|
|
$dtd{$originator} = 1 ;
|
2014-06-23 20:42:20 -06:00
|
|
|
}
|
2015-05-24 23:43:26 -06:00
|
|
|
elsif ( $name =~ /^mid\d+\..*$/ )
|
|
|
|
{
|
|
|
|
$midcount{$originator} = $midcount{$originator} ? $midcount{$originator}+1: 1 ;
|
|
|
|
if (! $hosts{$ip}{name} )
|
|
|
|
{
|
|
|
|
if ( $routes{$ip} ) { $hosts{$ip}{etx} = $routes{$ip}{etx} ; }
|
|
|
|
else { $hosts{$ip}{etx} = "99.000"; }
|
|
|
|
$hosts{$ip}{name} = $name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { push @{$hosts{$originator}{hosts}}, $name; }
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# load the olsr services file
|
|
|
|
foreach(`cat /var/run/services_olsr 2>/dev/null`)
|
|
|
|
{
|
|
|
|
next unless /^\w/;
|
|
|
|
chomp;
|
|
|
|
($url, $junk, $name) = split /\|/, $_;
|
|
|
|
next unless defined $name;
|
2015-01-23 19:25:25 -07:00
|
|
|
($protocol, $host, $port, $path) = $url =~ /^(\w+):\/\/([\w\-\.]+):(\d+)\/(.*)/;
|
|
|
|
next unless defined $path;
|
2013-11-14 23:11:16 -07:00
|
|
|
($name, $originator) = split /\#/, $name;
|
|
|
|
$name =~ s/\s+$//;
|
2015-01-23 19:25:25 -07:00
|
|
|
|
2015-05-24 23:43:26 -06:00
|
|
|
if ( $host !~ /\./ ) { $host="${host}.local.mesh"; }
|
2015-01-23 19:25:25 -07:00
|
|
|
|
2013-11-14 23:11:16 -07:00
|
|
|
# attempt to work around olsr never forgetting defunct services
|
|
|
|
# assume that the first entry in the file by this name is the most recent, ignore the rest
|
|
|
|
next if $services{$host}{$name};
|
|
|
|
|
2015-07-30 11:33:18 -06:00
|
|
|
$services{$host}{$name} = $port ? "<a href='${protocol}://${host}:${port}/${path}' target='_blank'>$name</a>" : $name;
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# load the node history
|
|
|
|
foreach(`cat /tmp/node.history 2>/dev/null`)
|
|
|
|
{
|
|
|
|
chomp;
|
|
|
|
($ip, $age, $host) = split / /, $_;
|
|
|
|
next unless $age;
|
|
|
|
$host = "" unless $host;
|
|
|
|
$host =~ s|/| / |;
|
|
|
|
$history{$ip}{age} = $age;
|
|
|
|
$history{$ip}{host} = $host;
|
|
|
|
}
|
|
|
|
|
|
|
|
#delete $hosts{"127.0.0.1"};
|
|
|
|
|
|
|
|
|
|
|
|
# generate the page
|
|
|
|
http_header();
|
|
|
|
html_header("$node mesh status", 0);
|
|
|
|
print "<meta http-equiv='refresh' content='10;url=/cgi-bin/mesh'>\n" if -f "/tmp/web/automesh";
|
|
|
|
print "</head>\n";
|
|
|
|
print "<body><form method=post action=/cgi-bin/mesh enctype='multipart/form-data'>\n";
|
|
|
|
print "<input type=hidden name=reload value=1>\n";
|
|
|
|
print "<center>\n";
|
|
|
|
|
2013-12-11 23:54:27 -07:00
|
|
|
alert_banner();
|
|
|
|
|
2013-11-14 23:11:16 -07:00
|
|
|
# page header
|
|
|
|
print "<h1>$node mesh status</h1><hr><nobr>";
|
|
|
|
|
|
|
|
# nav buttons
|
|
|
|
if(-f "/tmp/web/automesh")
|
|
|
|
{
|
|
|
|
print "<input type=submit name=stop value=Stop title='Abort continuous status'>\n";
|
|
|
|
}
|
|
|
|
elsif($config eq "mesh")
|
|
|
|
{
|
|
|
|
print "<input type=submit name=refresh value=Refresh title='Refresh this page'>\n";
|
|
|
|
print " \n";
|
|
|
|
print "<input type=submit name=auto value=Auto title='Automatic page refresh'>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print "  ";
|
|
|
|
print "<button type=button onClick='window.location=\"status\"' title='Return to the status page'>Quit</button>\n";
|
|
|
|
|
|
|
|
if($config ne "mesh")
|
|
|
|
{
|
|
|
|
print "<br><br><b>This page is available only when the router is acting as a Mesh Node.</b>\n";
|
2015-03-09 20:28:59 -06:00
|
|
|
print "</center></form>";
|
|
|
|
page_footer();
|
|
|
|
print "</body></html>\n";
|
2013-11-14 23:11:16 -07:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
elsif($txtinfo_err)
|
|
|
|
{
|
|
|
|
print "<br><br><b>Whoops! OLSR is not running, try again later.</b>\n";
|
2015-03-09 20:28:59 -06:00
|
|
|
print "</center></form>";
|
|
|
|
page_footer();
|
|
|
|
print "</body></html>\n";
|
2013-11-14 23:11:16 -07:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
print "</nobr><br><br>\n";
|
|
|
|
|
|
|
|
unless(keys %localhosts or keys %links)
|
|
|
|
{
|
|
|
|
print "No other nodes are available.\n";
|
2015-03-09 20:28:59 -06:00
|
|
|
print "</center></form>";
|
|
|
|
page_footer();
|
|
|
|
print "</body></html\n";
|
2013-11-14 23:11:16 -07:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print "<table><tr><td valign=top><table>\n";
|
|
|
|
|
|
|
|
|
|
|
|
# show local hosts
|
|
|
|
|
|
|
|
print "<tr><th colspan=4 align=left><nobr>Local Hosts</nobr></th><th align=left>Services</th></tr>\n";
|
|
|
|
print "<tr><td colspan=5><hr></td></tr>\n";
|
|
|
|
|
|
|
|
if(keys %localhosts)
|
|
|
|
{
|
|
|
|
%rows = ();
|
|
|
|
|
|
|
|
foreach $ip (keys %localhosts)
|
|
|
|
{
|
2015-05-24 23:43:26 -06:00
|
|
|
$host = $localhosts{$ip}{name};
|
2013-11-14 23:11:16 -07:00
|
|
|
$tactical = $localhosts{$ip}{tactical} ? " / " . $localhosts{$ip}{tactical} : "";
|
2015-05-25 10:25:38 -06:00
|
|
|
$rows{$host} = sprintf "<tr><td valign=top><nobr>%s</nobr>", $host . $tactical;
|
|
|
|
|
2015-05-25 11:46:15 -06:00
|
|
|
if ( $wangateway{$ip} ) { $nodeiface = "wan" ; }
|
|
|
|
if ( $nodeiface ) { $rows{$host} .= " <small>($nodeiface)</small>"; }
|
2015-05-25 10:25:38 -06:00
|
|
|
|
|
|
|
$rows{$host} .= "</td><td colspan=3> </td><td>\n" ;
|
|
|
|
|
2013-11-14 23:11:16 -07:00
|
|
|
foreach(sort keys %{$services{$host}})
|
|
|
|
{
|
|
|
|
$rows{$host} .= "<nobr>" . $services{$host}{$_} . "</nobr><br>\n";
|
|
|
|
}
|
|
|
|
$rows{$host} .= "</td></tr>\n";
|
|
|
|
|
|
|
|
# add locally advertised dmz hosts
|
|
|
|
foreach $dmzhost (@{$localhosts{$ip}{hosts}})
|
|
|
|
{
|
|
|
|
$rows{$host} .= "<tr><td valign=top><nobr> <img src='/dot.png'>$dmzhost</nobr></td>";
|
|
|
|
$rows{$host} .= "<td colspan=3></td><td>\n";
|
|
|
|
foreach(sort keys %{$services{$dmzhost}})
|
|
|
|
{
|
|
|
|
$rows{$host} .= "<nobr>" . $services{$dmzhost}{$_} . "</nobr><br>\n";
|
|
|
|
}
|
|
|
|
$rows{$host} .= "</td></tr>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach(sort keys %rows) { print $rows{$_} }
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print "<tr><td>none</td></tr>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# show remote nodes
|
|
|
|
|
|
|
|
print "<tr><td> </td></tr>\n";
|
|
|
|
print "<tr><th align=left><nobr>Remote Nodes</nobr></th><th> </th><th>ETX</th><th> </th><th align=left>Services</th></tr>\n";
|
|
|
|
print "<tr><td colspan=5><hr></td></tr>\n";
|
|
|
|
|
|
|
|
%rows = ();
|
2015-05-24 23:43:26 -06:00
|
|
|
%sortrows = ();
|
2013-11-14 23:11:16 -07:00
|
|
|
foreach $ip (keys %hosts)
|
|
|
|
{
|
|
|
|
next if $links{$ip};
|
2015-05-24 23:43:26 -06:00
|
|
|
next if $ipalias{$ip};
|
2013-11-14 23:11:16 -07:00
|
|
|
|
2015-05-24 23:43:26 -06:00
|
|
|
$isNeig=0;
|
|
|
|
foreach $aip (keys %ipalias)
|
|
|
|
{
|
|
|
|
if ($ipalias{$aip} eq $ip ) { if ($links{$aip} ) { $isNeig=1; last;} }
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|
2015-05-24 23:43:26 -06:00
|
|
|
next if $isNeig;
|
|
|
|
|
|
|
|
$host = $hosts{$ip}{name};
|
|
|
|
$tactical = $hosts{$ip}{tactical} ? " / " . $hosts{$ip}{tactical} : "";
|
|
|
|
$etx = sprintf "%.2f", $hosts{$ip}{etx};
|
|
|
|
next if ($etx > 50 );
|
2013-11-14 23:11:16 -07:00
|
|
|
|
|
|
|
$rows{$host} = sprintf "<tr><td valign=top><nobr><a href='http://%s:8080/'>%s</a>", $host, $host . $tactical;
|
2015-05-24 23:43:26 -06:00
|
|
|
|
|
|
|
undef $nodeiface;
|
2015-07-02 00:21:51 -06:00
|
|
|
#if ( $dtd{$ip} )
|
|
|
|
#{
|
|
|
|
#$nodeiface = "dtd";
|
|
|
|
#if ( $midcount{$ip} ) { $midcount{$ip} -= 1; } # extra mid entry matching and with dtdlink in hosts_olsrd
|
|
|
|
#}
|
|
|
|
#if ( $hosts{$ip}{tactical} ) { $midcount{$ip} -= 1; } # extra mid entry if tactical name defined
|
|
|
|
#if ( $midcount{$ip} ) { $nodeiface = $nodeiface ? "dtd," . "tun*$midcount{$ip}" : "tun*$midcount{$ip}" ; }
|
2015-05-25 10:25:38 -06:00
|
|
|
if ( $wangateway{$ip} ) { $nodeiface = $nodeiface ? $nodeiface . ",wan" : "wan" ; }
|
|
|
|
|
2015-05-24 23:43:26 -06:00
|
|
|
if ( $nodeiface ) { $rows{$host} .= " <small>($nodeiface)</small>"; }
|
|
|
|
|
2013-11-14 23:11:16 -07:00
|
|
|
$rows{$host} .= sprintf "</nobr></td><td></td><td align=right valign=top>%s</td><td></td><td>\n", $etx;
|
|
|
|
foreach(sort keys %{$services{$host}})
|
|
|
|
{
|
|
|
|
$rows{$host} .= "<nobr>" . $services{$host}{$_} . "</nobr><br>\n";
|
|
|
|
}
|
|
|
|
$rows{$host} .= "</td></tr>\n";
|
|
|
|
|
|
|
|
# add advertised dmz hosts
|
|
|
|
foreach $dmzhost (@{$hosts{$ip}{hosts}})
|
|
|
|
{
|
|
|
|
$rows{$host} .= "<tr><td valign=top><nobr> <img src='/dot.png'>$dmzhost</nobr></td>";
|
|
|
|
$rows{$host} .= "<td colspan=3></td><td>\n";
|
|
|
|
foreach(sort keys %{$services{$dmzhost}})
|
|
|
|
{
|
|
|
|
$rows{$host} .= "<nobr>" . $services{$dmzhost}{$_} . "</nobr><br>\n";
|
|
|
|
}
|
|
|
|
$rows{$host} .= "</td></tr>\n";
|
|
|
|
}
|
2015-05-24 23:43:26 -06:00
|
|
|
$sortrows{$ip}=$host;
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if(keys %rows)
|
|
|
|
{
|
2015-05-24 23:43:26 -06:00
|
|
|
foreach(sort { $hosts{$a}{etx} <=> $hosts{$b}{etx} } keys %sortrows) { print $rows{$sortrows{$_}} }
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print "<tr><td>none</td></tr>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print "</table></td><td width=20> </td><td valign=top><table>\n";
|
|
|
|
|
|
|
|
# show current neighbors
|
|
|
|
|
2015-12-21 19:26:45 -07:00
|
|
|
print "<tr><th align=left><nobr>Current Neighbors</nobr></th><th> </th><th>LQ</th><th>NLQ</th><th>TxMbps</th><th> </th><th align=left>Services</th></tr>\n";
|
|
|
|
print "<tr><td colspan=7><hr></td></tr>\n";
|
2013-11-14 23:11:16 -07:00
|
|
|
|
|
|
|
if(keys %links)
|
|
|
|
{
|
|
|
|
%rows = ();
|
|
|
|
|
|
|
|
foreach $ip (keys %links)
|
|
|
|
{
|
2015-05-24 23:43:26 -06:00
|
|
|
$ipmain = exists $ipalias{$ip} ? $ipalias{$ip} : $ip ;
|
|
|
|
$host = $hosts{$ipmain}{name} ? $hosts{$ipmain}{name} : $ipmain;
|
|
|
|
$tactical = $hosts{$ipmain}{tactical} ? " / " . $hosts{$ipmain}{tactical} : "";
|
2015-05-25 11:46:15 -06:00
|
|
|
if ( $rows{$host} ) { $host .= " " ; } # avoid collision 2 links to same host {rf, dtd}
|
2015-01-23 19:25:25 -07:00
|
|
|
|
2015-06-15 00:06:32 -06:00
|
|
|
$no_space_host=$host;
|
|
|
|
$no_space_host =~ s/\s+$//;
|
|
|
|
$rows{$host} = sprintf "<tr><td valign=top><nobr><a href='http://%s:8080/'>%s</a>", $no_space_host, $no_space_host . $tactical;
|
2015-01-23 19:25:25 -07:00
|
|
|
|
2015-05-25 10:25:38 -06:00
|
|
|
undef $nodeiface;
|
2015-05-24 23:43:26 -06:00
|
|
|
if ( $ipmain ne $ip ) # indicate if dtd or tunnel interface to neighbor
|
2013-11-14 23:11:16 -07:00
|
|
|
{
|
2015-05-25 10:25:38 -06:00
|
|
|
if ( $hosts{$ip}{name} =~ /^dtdlink\..*$/ ){ $nodeiface="dtd" ; }
|
2015-07-02 00:21:51 -06:00
|
|
|
#elsif ( $hosts{$ip}{name} =~ /^mid\d+\..*$/ ) { $nodeiface="tun" ; }
|
|
|
|
#else { $nodeiface="?" ; }
|
2015-05-24 23:43:26 -06:00
|
|
|
}
|
2013-11-14 23:11:16 -07:00
|
|
|
|
2015-05-25 11:46:15 -06:00
|
|
|
if ( $wangateway{$ip} or $wangateway{$ipmain} ) { $nodeiface = $nodeiface ? $nodeiface . ",wan" : "wan" ; }
|
2015-05-25 10:25:38 -06:00
|
|
|
if ( $nodeiface ) { $rows{$host} .= " <small>($nodeiface)</small>"; }
|
|
|
|
|
2015-12-21 19:26:45 -07:00
|
|
|
$rows{$host} .= sprintf ("</nobr></td><td></td><td align=right valign=top>%.0f%%</td><td align=right valign=top>%.0f%%</td><td align=right valign=top>%s</td><td></td><td>\n", 100*$links{$ip}{lq}, 100*$links{$ip}{nlq},$links{$ip}{mbps});
|
2015-05-24 23:43:26 -06:00
|
|
|
|
|
|
|
if ( ! exists $neighservices{$host} )
|
|
|
|
{
|
|
|
|
foreach(sort keys %{$services{$host}}) { $rows{$host} .= "<nobr>" . $services{$host}{$_} . "</nobr><br>\n" }
|
|
|
|
|
2013-11-14 23:11:16 -07:00
|
|
|
$rows{$host} .= "</td></tr>\n";
|
2015-05-24 23:43:26 -06:00
|
|
|
|
|
|
|
# add advertised dmz hosts
|
|
|
|
foreach $dmzhost (@{$hosts{$ipmain}{hosts}})
|
|
|
|
{
|
2015-12-21 19:26:45 -07:00
|
|
|
$rows{$host} .= "<tr><td valign=top><nobr> <img src='/dot.png'>$dmzhost</nobr></td><td colspan=5></td><td>\n";
|
2015-05-24 23:43:26 -06:00
|
|
|
foreach(sort keys %{$services{$dmzhost}}) { $rows{$host} .= $services{$dmzhost}{$_} . "<br>\n" }
|
|
|
|
$rows{$host} .= "</td></tr>\n";
|
|
|
|
}
|
|
|
|
$neighservices{$host}=1;
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach(sort keys %rows) { print $rows{$_} }
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print "<tr><td>none</td></tr>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# show previous neighbors
|
|
|
|
|
|
|
|
print "<tr><td> </td></tr>\n";
|
2015-12-21 19:26:45 -07:00
|
|
|
print "<tr><th colspan=6 align=left><nobr>Previous Neighbors</nobr></th><th align=left>When</th></tr>\n";
|
|
|
|
print "<tr><td colspan=7><hr></td></tr>\n";
|
2013-11-14 23:11:16 -07:00
|
|
|
%rows = ();
|
|
|
|
($uptime) = `cat /proc/uptime` =~ /^(\d+)/;
|
|
|
|
|
|
|
|
foreach $ip (keys %history)
|
|
|
|
{
|
|
|
|
next if $links{$ip};
|
2015-05-25 11:46:15 -06:00
|
|
|
next if $links{$ipalias{$ip}};
|
2013-11-14 23:11:16 -07:00
|
|
|
$age = sprintf "%010d", $uptime - $history{$ip}{age};
|
|
|
|
$host = $history{$ip}{host} ? $history{$ip}{host} : $ip;
|
2015-05-25 11:46:15 -06:00
|
|
|
$host =~ s/^mid\d+\.// ;
|
|
|
|
$host =~ s/^dtdlink\.// ;
|
2015-12-21 19:26:45 -07:00
|
|
|
$rows{$age} .= sprintf "<tr><td colspan=6><nobr>%s</nobr>", $host;
|
2013-11-14 23:11:16 -07:00
|
|
|
foreach(@{$hosts{$ip}{hosts}}) { $rows{$age} .= "<br><nobr><img src='/dot.png'>$_</nobr>" }
|
|
|
|
$rows{$age} .= "</td><td valign=top><nobr>";
|
|
|
|
if($age < 3600)
|
|
|
|
{
|
|
|
|
$val = int($age/60);
|
|
|
|
$rows{$age} .= $val == 1 ? "1 minute ago" : "$val minutes ago";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$val = sprintf "%.1f", $age/3660;
|
|
|
|
$rows{$age} .= $val eq "1.0" ? "1 hour ago" : "$val hours ago";
|
|
|
|
}
|
|
|
|
$rows{$age} .= "</nobr></td></tr>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(keys %rows)
|
|
|
|
{
|
|
|
|
foreach(sort keys %rows) { print $rows{$_} }
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print "<tr><td>none</td></tr>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print "</table></td></tr></table>\n";
|
|
|
|
|
|
|
|
|
|
|
|
# end
|
|
|
|
print "</center>\n";
|
|
|
|
print "</form>\n";
|
|
|
|
|
|
|
|
if($debug)
|
|
|
|
{
|
|
|
|
print "<pre>\n";
|
|
|
|
print "localhosts\n";
|
|
|
|
foreach $ip (sort keys %localhosts)
|
|
|
|
{
|
|
|
|
printf "%s %s", $ip, $localhosts{$ip}{name};
|
|
|
|
printf "/%s", $localhosts{$ip}{tactical} if $localhosts{$ip}{tactical};
|
|
|
|
foreach(@{$localhosts{$ip}{hosts}}) { print ":$_" }
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print "\nhosts\n";
|
2015-05-25 10:25:38 -06:00
|
|
|
foreach $ip (sort keys %hosts)
|
2013-11-14 23:11:16 -07:00
|
|
|
{
|
|
|
|
$hosts{$ip}{name} = "" unless $hosts{$ip}{name};
|
|
|
|
printf "%s %s", $ip, $hosts{$ip}{name};
|
|
|
|
printf "/%s", $hosts{$ip}{tactical} if $hosts{$ip}{tactical};
|
|
|
|
foreach(@{$hosts{$ip}{hosts}}) { print ":$_" }
|
|
|
|
printf(" %d", $hosts{$ip}{mid}) if $hosts{$ip}{mid};
|
|
|
|
}
|
|
|
|
|
|
|
|
print "\nlinks\n";
|
|
|
|
foreach(sort keys %links)
|
|
|
|
{
|
|
|
|
print "$_\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print "</pre>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
show_debug_info();
|
|
|
|
show_parse_errors();
|
|
|
|
|
2015-03-09 20:28:59 -06:00
|
|
|
page_footer();
|
2013-11-14 23:11:16 -07:00
|
|
|
print "</body>\n";
|
|
|
|
print "</html>\n";
|
|
|
|
|