diff --git a/files/www/cgi-bin/mesh b/files/www/cgi-bin/mesh index 41ab0b92..7c9c76c9 100755 --- a/files/www/cgi-bin/mesh +++ b/files/www/cgi-bin/mesh @@ -84,6 +84,9 @@ foreach(`echo /all | nc 127.0.0.1 2006 2>$tmperr`) } elsif($table eq "HNA") { + ($iproute, $ip) = split /\s+/, $_; + ($net, $cidr) = split /\//, $iproute; + if ( $net eq "0.0.0.0" ) { $wangateway{$ip} = 1; } } elsif($table eq "MID") { @@ -276,7 +279,13 @@ if(keys %localhosts) { $host = $localhosts{$ip}{name}; $tactical = $localhosts{$ip}{tactical} ? " / " . $localhosts{$ip}{tactical} : ""; - $rows{$host} = sprintf "%s \n", $host . $tactical; + $rows{$host} = sprintf "%s", $host . $tactical; + + if ( $wangateway{$ip} ) { $nodeiface = "wan" ; } + if ( $nodeiface ) { $rows{$host} .= "   ($nodeiface)"; } + + $rows{$host} .= " \n" ; + foreach(sort keys %{$services{$host}}) { $rows{$host} .= "" . $services{$host}{$_} . "
\n"; @@ -338,6 +347,8 @@ foreach $ip (keys %hosts) 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 ( $wangateway{$ip} ) { $nodeiface = $nodeiface ? $nodeiface . ",wan" : "wan" ; } + if ( $nodeiface ) { $rows{$host} .= "   ($nodeiface)"; } $rows{$host} .= sprintf "%s\n", $etx; @@ -387,18 +398,21 @@ if(keys %links) $ipmain = exists $ipalias{$ip} ? $ipalias{$ip} : $ip ; $host = $hosts{$ipmain}{name} ? $hosts{$ipmain}{name} : $ipmain; $tactical = $hosts{$ipmain}{tactical} ? " / " . $hosts{$ipmain}{tactical} : ""; + if ( $rows{$host} ) { $host .= " " ; } # avoid collision 2 links to same host {rf, dtd} $rows{$host} = sprintf "%s", $host, $host . $tactical; + undef $nodeiface; if ( $ipmain ne $ip ) # indicate if dtd or tunnel interface to neighbor { - if ( $hosts{$ip}{name} =~ /^dtdlink\..*$/ ){ $linktype="dtd" ; } - elsif ( $hosts{$ip}{name} =~ /^mid\d+\..*$/ ) { $linktype="tun" ; } - else { $linktype="?" ; } - - $rows{$host} .= "   ($linktype)"; + if ( $hosts{$ip}{name} =~ /^dtdlink\..*$/ ){ $nodeiface="dtd" ; } + elsif ( $hosts{$ip}{name} =~ /^mid\d+\..*$/ ) { $nodeiface="tun" ; } + else { $nodeiface="?" ; } } + if ( $wangateway{$ip} or $wangateway{$ipmain} ) { $nodeiface = $nodeiface ? $nodeiface . ",wan" : "wan" ; } + if ( $nodeiface ) { $rows{$host} .= "   ($nodeiface)"; } + $rows{$host} .= sprintf ("%.0f%%%.0f%%\n", 100*$links{$ip}{lq}, 100*$links{$ip}{nlq}); if ( ! exists $neighservices{$host} ) @@ -437,8 +451,11 @@ print "
\n"; foreach $ip (keys %history) { next if $links{$ip}; + next if $links{$ipalias{$ip}}; $age = sprintf "%010d", $uptime - $history{$ip}{age}; $host = $history{$ip}{host} ? $history{$ip}{host} : $ip; + $host =~ s/^mid\d+\.// ; + $host =~ s/^dtdlink\.// ; $rows{$age} .= sprintf "%s", $host; foreach(@{$hosts{$ip}{hosts}}) { $rows{$age} .= "
$_" } $rows{$age} .= ""; @@ -485,16 +502,13 @@ if($debug) } print "\nhosts\n"; - #foreach $ip (sort keys %hosts) - foreach $ip (sort { $hosts{$a}{etx} <=> $hosts{$b}{etx} } keys %hosts) + foreach $ip (sort keys %hosts) { $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 "\n"; - print "ETX=$hosts{$ip}{etx}\n"; } print "\nlinks\n";