mirror of https://github.com/aredn/aredn.git
Merge branch 'MeshBugfix' into release-3.15.1.0
This commit is contained in:
commit
d7926c111c
|
@ -87,6 +87,8 @@ foreach(`echo /all | nc 127.0.0.1 2006 2>$tmperr`)
|
||||||
}
|
}
|
||||||
elsif($table eq "MID")
|
elsif($table eq "MID")
|
||||||
{
|
{
|
||||||
|
($ip, $junk) = split /\s+/, $_;
|
||||||
|
foreach $aip ( split /;/, $junk ) { $ipalias{$aip} = $ip }
|
||||||
}
|
}
|
||||||
elsif($table eq "Routes")
|
elsif($table eq "Routes")
|
||||||
{
|
{
|
||||||
|
@ -111,20 +113,14 @@ foreach(`cat /etc/hosts`)
|
||||||
chomp;
|
chomp;
|
||||||
($ip, $name, $tactical) = split /\s+/, $_;
|
($ip, $name, $tactical) = split /\s+/, $_;
|
||||||
next if $name =~ /^(localhost|localnode|localap|dtdlink\..*)$/;
|
next if $name =~ /^(localhost|localnode|localap|dtdlink\..*)$/;
|
||||||
|
if ( $name !~ /\.local\.mesh$/ ) { $name="${name}.local.mesh"; }
|
||||||
if($ip eq $my_ip)
|
if($ip eq $my_ip)
|
||||||
{
|
{
|
||||||
$tactical = "" unless $tactical;
|
$tactical = "" unless $tactical;
|
||||||
$localhosts{$ip}{tactical} = $tactical;
|
$localhosts{$ip}{tactical} = $tactical;
|
||||||
$localhosts{$ip}{name} = $name;
|
$localhosts{$ip}{name} = $name;
|
||||||
}
|
}
|
||||||
else
|
else { push @{$localhosts{$my_ip}{hosts}}, $name; }
|
||||||
{
|
|
||||||
if ( $name !~ /\./ )
|
|
||||||
{
|
|
||||||
$name="${name}.local.mesh";
|
|
||||||
}
|
|
||||||
push @{$localhosts{$my_ip}{hosts}}, $name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# load the olsr hosts file
|
# load the olsr hosts file
|
||||||
|
@ -135,35 +131,37 @@ foreach(`cat /var/run/hosts_olsr 2>/dev/null`)
|
||||||
($ip, $name, $junk, $originator, $mid, $midnum) = split /\s+/, $_;
|
($ip, $name, $junk, $originator, $mid, $midnum) = split /\s+/, $_;
|
||||||
next unless $originator;
|
next unless $originator;
|
||||||
next if $originator eq "myself";
|
next if $originator eq "myself";
|
||||||
if ( $name =~ /^dtdlink\..*$/ )
|
|
||||||
|
if ( $name !~ /\.local\.mesh$/ ) { $name="${name}.local.mesh"; }
|
||||||
|
|
||||||
|
if ( $ip eq $originator )
|
||||||
{
|
{
|
||||||
$hosts{$ip}{name} = $name;
|
if($hosts{$ip}{name}) { $hosts{$ip}{tactical} = $name }
|
||||||
$hosts{$ip}{hide} = 1;
|
else
|
||||||
next;
|
{
|
||||||
|
$hosts{$ip}{name} = $name;
|
||||||
|
if ( $routes{$ip} ) { $hosts{$ip}{etx} = $routes{$ip}{etx} ; }
|
||||||
|
else { $hosts{$ip}{etx} = "99.000"; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
elsif ( $name =~ /^dtdlink\..*$/ )
|
||||||
if(defined $mid and $midnum =~ /^\#(\d+)/)
|
{
|
||||||
{
|
|
||||||
if ( !exists $hosts{$ip}{name} )
|
|
||||||
{
|
|
||||||
$hosts{$ip}{name} = $name;
|
$hosts{$ip}{name} = $name;
|
||||||
|
if ( $routes{$ip} ) { $hosts{$ip}{etx} = $routes{$ip}{etx} ; }
|
||||||
|
else { $hosts{$ip}{etx} = "99.000"; }
|
||||||
|
$dtd{$originator} = 1 ;
|
||||||
}
|
}
|
||||||
$hosts{$ip}{hide} = 1;
|
elsif ( $name =~ /^mid\d+\..*$/ )
|
||||||
$hosts{$originator}{mid} = $1;
|
{
|
||||||
}
|
$midcount{$originator} = $midcount{$originator} ? $midcount{$originator}+1: 1 ;
|
||||||
elsif($ip eq $originator)
|
if (! $hosts{$ip}{name} )
|
||||||
{
|
{
|
||||||
if($hosts{$ip}{name}) { $hosts{$ip}{tactical} = $name }
|
if ( $routes{$ip} ) { $hosts{$ip}{etx} = $routes{$ip}{etx} ; }
|
||||||
else { $hosts{$ip}{name} = $name }
|
else { $hosts{$ip}{etx} = "99.000"; }
|
||||||
}
|
$hosts{$ip}{name} = $name;
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
if ( $name !~ /\./ )
|
else { push @{$hosts{$originator}{hosts}}, $name; }
|
||||||
{
|
|
||||||
$name="${name}.local.mesh";
|
|
||||||
}
|
|
||||||
push @{$hosts{$originator}{hosts}}, $name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# load the olsr services file
|
# load the olsr services file
|
||||||
|
@ -178,10 +176,7 @@ foreach(`cat /var/run/services_olsr 2>/dev/null`)
|
||||||
($name, $originator) = split /\#/, $name;
|
($name, $originator) = split /\#/, $name;
|
||||||
$name =~ s/\s+$//;
|
$name =~ s/\s+$//;
|
||||||
|
|
||||||
if ( $host !~ /\./ )
|
if ( $host !~ /\./ ) { $host="${host}.local.mesh"; }
|
||||||
{
|
|
||||||
$host="${host}.local.mesh";
|
|
||||||
}
|
|
||||||
|
|
||||||
#$host = $originator eq " my own service" ? $node : $hosts{$originator}{name};
|
#$host = $originator eq " my own service" ? $node : $hosts{$originator}{name};
|
||||||
|
|
||||||
|
@ -279,7 +274,7 @@ if(keys %localhosts)
|
||||||
|
|
||||||
foreach $ip (keys %localhosts)
|
foreach $ip (keys %localhosts)
|
||||||
{
|
{
|
||||||
$host = $localhosts{$ip}{name} . ".local.mesh";
|
$host = $localhosts{$ip}{name};
|
||||||
$tactical = $localhosts{$ip}{tactical} ? " / " . $localhosts{$ip}{tactical} : "";
|
$tactical = $localhosts{$ip}{tactical} ? " / " . $localhosts{$ip}{tactical} : "";
|
||||||
$rows{$host} = sprintf "<tr><td valign=top><nobr>%s</nobr></td><td colspan=3> </td><td>\n", $host . $tactical;
|
$rows{$host} = sprintf "<tr><td valign=top><nobr>%s</nobr></td><td colspan=3> </td><td>\n", $host . $tactical;
|
||||||
foreach(sort keys %{$services{$host}})
|
foreach(sort keys %{$services{$host}})
|
||||||
|
@ -316,40 +311,35 @@ print "<tr><th align=left><nobr>Remote Nodes</nobr></th><th> </th><th
|
||||||
print "<tr><td colspan=5><hr></td></tr>\n";
|
print "<tr><td colspan=5><hr></td></tr>\n";
|
||||||
|
|
||||||
%rows = ();
|
%rows = ();
|
||||||
|
%sortrows = ();
|
||||||
foreach $ip (keys %hosts)
|
foreach $ip (keys %hosts)
|
||||||
{
|
{
|
||||||
next if $links{$ip};
|
next if $links{$ip};
|
||||||
next if exists $hosts{$ip}{hide};
|
next if $ipalias{$ip};
|
||||||
|
|
||||||
|
$isNeig=0;
|
||||||
|
foreach $aip (keys %ipalias)
|
||||||
|
{
|
||||||
|
if ($ipalias{$aip} eq $ip ) { if ($links{$aip} ) { $isNeig=1; last;} }
|
||||||
|
}
|
||||||
|
next if $isNeig;
|
||||||
|
|
||||||
$host = $hosts{$ip}{name};
|
$host = $hosts{$ip}{name};
|
||||||
$tactical = $hosts{$ip}{tactical} ? " / " . $hosts{$ip}{tactical} : "";
|
$tactical = $hosts{$ip}{tactical} ? " / " . $hosts{$ip}{tactical} : "";
|
||||||
$etx = "unknown";
|
$etx = sprintf "%.2f", $hosts{$ip}{etx};
|
||||||
|
next if ($etx > 50 );
|
||||||
|
|
||||||
if ( $host !~ /\./ )
|
|
||||||
{
|
|
||||||
$host="${host}.local.mesh";
|
|
||||||
}
|
|
||||||
|
|
||||||
if($routes{$ip}) # get the etx directly
|
|
||||||
{
|
|
||||||
$etx = sprintf "%.2f", $routes{$ip}{etx};
|
|
||||||
}
|
|
||||||
else # find the subnet it belongs to
|
|
||||||
{
|
|
||||||
foreach $net (keys %routes)
|
|
||||||
{
|
|
||||||
next unless (ip2decimal($ip) & $routes{$net}{mask}) == $routes{$net}{value};
|
|
||||||
$etx = sprintf "%.2f", $routes{$net}{etx};
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
next if $etx eq "unknown";
|
|
||||||
$rows{$host} = sprintf "<tr><td valign=top><nobr><a href='http://%s:8080/'>%s</a>", $host, $host . $tactical;
|
$rows{$host} = sprintf "<tr><td valign=top><nobr><a href='http://%s:8080/'>%s</a>", $host, $host . $tactical;
|
||||||
if($midnum = $hosts{$ip}{mid}) # show mid interfaces
|
|
||||||
{
|
undef $nodeiface;
|
||||||
$midnum = ($midnum > 1) ? "*$midnum" : "";
|
if ( $dtd{$ip} )
|
||||||
$rows{$host} .= " <small>(mid$midnum)</small>";
|
{
|
||||||
|
$nodeiface = "dtd";
|
||||||
|
if ( $midcount{$ip} ) { $midcount{$ip} -= 1; } # extra mid entry matching and with dtdlink in hosts_olsrd
|
||||||
}
|
}
|
||||||
|
if ( $midcount{$ip} ) { $nodeiface = $nodeiface ? "dtd," . "tun*$midcount{$ip}" : "tun*$midcount{$ip}" ; }
|
||||||
|
if ( $nodeiface ) { $rows{$host} .= " <small>($nodeiface)</small>"; }
|
||||||
|
|
||||||
$rows{$host} .= sprintf "</nobr></td><td></td><td align=right valign=top>%s</td><td></td><td>\n", $etx;
|
$rows{$host} .= sprintf "</nobr></td><td></td><td align=right valign=top>%s</td><td></td><td>\n", $etx;
|
||||||
foreach(sort keys %{$services{$host}})
|
foreach(sort keys %{$services{$host}})
|
||||||
{
|
{
|
||||||
|
@ -368,11 +358,12 @@ foreach $ip (keys %hosts)
|
||||||
}
|
}
|
||||||
$rows{$host} .= "</td></tr>\n";
|
$rows{$host} .= "</td></tr>\n";
|
||||||
}
|
}
|
||||||
|
$sortrows{$ip}=$host;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(keys %rows)
|
if(keys %rows)
|
||||||
{
|
{
|
||||||
foreach(sort keys %rows) { print $rows{$_} }
|
foreach(sort { $hosts{$a}{etx} <=> $hosts{$b}{etx} } keys %sortrows) { print $rows{$sortrows{$_}} }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -382,7 +373,6 @@ else
|
||||||
|
|
||||||
print "</table></td><td width=20> </td><td valign=top><table>\n";
|
print "</table></td><td width=20> </td><td valign=top><table>\n";
|
||||||
|
|
||||||
|
|
||||||
# show current neighbors
|
# show current neighbors
|
||||||
|
|
||||||
print "<tr><th align=left><nobr>Current Neighbors</nobr></th><th> </th><th>LQ</th><th>NLQ</th><th> </th><th align=left>Services</th></tr>\n";
|
print "<tr><th align=left><nobr>Current Neighbors</nobr></th><th> </th><th>LQ</th><th>NLQ</th><th> </th><th align=left>Services</th></tr>\n";
|
||||||
|
@ -394,32 +384,37 @@ if(keys %links)
|
||||||
|
|
||||||
foreach $ip (keys %links)
|
foreach $ip (keys %links)
|
||||||
{
|
{
|
||||||
$host = $hosts{$ip}{name} ? $hosts{$ip}{name} : $ip;
|
$ipmain = exists $ipalias{$ip} ? $ipalias{$ip} : $ip ;
|
||||||
$tactical = $hosts{$ip}{tactical} ? " / " . $hosts{$ip}{tactical} : "";
|
$host = $hosts{$ipmain}{name} ? $hosts{$ipmain}{name} : $ipmain;
|
||||||
|
$tactical = $hosts{$ipmain}{tactical} ? " / " . $hosts{$ipmain}{tactical} : "";
|
||||||
if ( $host !~ /\./ )
|
|
||||||
{
|
|
||||||
$host="${host}.local.mesh";
|
|
||||||
}
|
|
||||||
|
|
||||||
$rows{$host} = sprintf "<tr><td valign=top><nobr><a href='http://%s:8080/'>%s</a>", $host, $host . $tactical;
|
$rows{$host} = sprintf "<tr><td valign=top><nobr><a href='http://%s:8080/'>%s</a>", $host, $host . $tactical;
|
||||||
|
|
||||||
if($midnum = $hosts{$ip}{mid}) # show mid interfaces
|
if ( $ipmain ne $ip ) # indicate if dtd or tunnel interface to neighbor
|
||||||
{
|
{
|
||||||
$midnum = ($midnum > 1) ? "*$midnum" : "";
|
if ( $hosts{$ip}{name} =~ /^dtdlink\..*$/ ){ $linktype="dtd" ; }
|
||||||
$rows{$host} .= " <small>(mid$midnum)</small>";
|
elsif ( $hosts{$ip}{name} =~ /^mid\d+\..*$/ ) { $linktype="tun" ; }
|
||||||
|
else { $linktype="?" ; }
|
||||||
|
|
||||||
|
$rows{$host} .= " <small>($linktype)</small>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows{$host} .= sprintf ("</nobr></td><td></td><td align=right valign=top>%.0f%%</td><td align=right valign=top>%.0f%%</td><td></td><td>\n", 100*$links{$ip}{lq}, 100*$links{$ip}{nlq});
|
$rows{$host} .= sprintf ("</nobr></td><td></td><td align=right valign=top>%.0f%%</td><td align=right valign=top>%.0f%%</td><td></td><td>\n", 100*$links{$ip}{lq}, 100*$links{$ip}{nlq});
|
||||||
foreach(sort keys %{$services{$host}}) { $rows{$host} .= "<nobr>" . $services{$host}{$_} . "</nobr><br>\n" }
|
|
||||||
$rows{$host} .= "</td></tr>\n";
|
if ( ! exists $neighservices{$host} )
|
||||||
|
{
|
||||||
# add advertised dmz hosts
|
foreach(sort keys %{$services{$host}}) { $rows{$host} .= "<nobr>" . $services{$host}{$_} . "</nobr><br>\n" }
|
||||||
foreach $dmzhost (@{$hosts{$ip}{hosts}})
|
|
||||||
{
|
|
||||||
$rows{$host} .= "<tr><td valign=top><nobr> <img src='/dot.png'>$dmzhost</nobr></td><td colspan=3></td><td>\n";
|
|
||||||
foreach(sort keys %{$services{$dmzhost}}) { $rows{$host} .= $services{$dmzhost}{$_} . "<br>\n" }
|
|
||||||
$rows{$host} .= "</td></tr>\n";
|
$rows{$host} .= "</td></tr>\n";
|
||||||
|
|
||||||
|
# add advertised dmz hosts
|
||||||
|
foreach $dmzhost (@{$hosts{$ipmain}{hosts}})
|
||||||
|
{
|
||||||
|
$rows{$host} .= "<tr><td valign=top><nobr> <img src='/dot.png'>$dmzhost</nobr></td><td colspan=3></td><td>\n";
|
||||||
|
foreach(sort keys %{$services{$dmzhost}}) { $rows{$host} .= $services{$dmzhost}{$_} . "<br>\n" }
|
||||||
|
$rows{$host} .= "</td></tr>\n";
|
||||||
|
}
|
||||||
|
$neighservices{$host}=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,7 +485,8 @@ if($debug)
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\nhosts\n";
|
print "\nhosts\n";
|
||||||
foreach $ip (sort keys %hosts)
|
#foreach $ip (sort keys %hosts)
|
||||||
|
foreach $ip (sort { $hosts{$a}{etx} <=> $hosts{$b}{etx} } keys %hosts)
|
||||||
{
|
{
|
||||||
$hosts{$ip}{name} = "" unless $hosts{$ip}{name};
|
$hosts{$ip}{name} = "" unless $hosts{$ip}{name};
|
||||||
printf "%s %s", $ip, $hosts{$ip}{name};
|
printf "%s %s", $ip, $hosts{$ip}{name};
|
||||||
|
@ -498,6 +494,7 @@ if($debug)
|
||||||
foreach(@{$hosts{$ip}{hosts}}) { print ":$_" }
|
foreach(@{$hosts{$ip}{hosts}}) { print ":$_" }
|
||||||
printf(" %d", $hosts{$ip}{mid}) if $hosts{$ip}{mid};
|
printf(" %d", $hosts{$ip}{mid}) if $hosts{$ip}{mid};
|
||||||
print "\n";
|
print "\n";
|
||||||
|
print "ETX=$hosts{$ip}{etx}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\nlinks\n";
|
print "\nlinks\n";
|
||||||
|
|
Loading…
Reference in New Issue