#### ASpath-tree v.4.2 - Released on Thu APR 17 2003, h.16:58:12 #### File: lib/bgp-tree.pl Last modified on Fri APR 11 2003, h.23:56:04 # Routine to create the current tree table (input: type of tree -whole (0), bb (1), otherIANA (2)-, # output: array containing HTML formatted table cells) sub create_output_table { my ($tree_type) = @_; my @sim = ("", "", "", "", "", ""); my @asn_1 = (); my @asn_2 = (); my @bar = (); my @cell = (); my @f_table = (); my ($key, $filename, $flag_tmp, $flag, $num_as, $i, $j, $ncol, $n, $asn_toprint); my @keys = (); my $history_reldir = substr($HISTORYHTMLDIR, length($HTMLDIR_LOCAL) + 1, length($HISTORYHTMLDIR) - length($HTMLDIR_LOCAL)); # Set and sort ASpaths array for $tree_type if ($tree_type != 0) { foreach $key (keys(%TREE_ROWS)) { $TREE_ROWS{$key} =~ /(\S+)\s+(\S+)\s+(\S+)/; $flag_tmp = $1; $num_as = $2; if ($flag_tmp =~ /$tree_type/) { push(@keys, $key); if ($ncol < $num_as) {$ncol = $num_as} } } } else { @keys = (keys(%TREE_ROWS)); $ncol = length($keys[0])/5; } @keys = sort(@keys); $ncol--; $n = $ncol*2+1; unless (@keys) {return(())}; for ($j = $#keys; $j >= 0; $j--) { @asn_1 = &convert_asn($keys[$j]); if ($j > 0) {@asn_2 = &convert_asn($keys[$j-1])} else {@asn_2 = ()} $n = $ncol*2+1; for ($i = $ncol; $i >= 0; $i--) { if (!defined($asn_1[$i])) {$n = $n-2} elsif (join("", @asn_1[(0)..($i)]) ne join("", @asn_2[(0)..($i)])) { $asn_toprint = substr($ASNAME{$asn_1[$i]}, 0, 11); $asn_toprint =~ s/-/\ \;/g; if ($i eq $#asn_1) { $colspan = $ncol*2 - $n + 1; if ($colspan > 0) {$cell[$n+1] = ""} $TREE_ROWS{$keys[$j]} =~ /(\S+)\s+(\S+)\s+(\S+)/; $flag_tmp = $1; $filename = $3; $flag = ''; if ($tree_type == 0) {$asn_toprint = "$asn_toprint"} elsif ($tree_type == 1) {$asn_toprint ="$asn_toprint"} elsif ($tree_type == 3) {$asn_toprint = "$asn_toprint"} if (($tree_type == 0) && ($flag_tmp =~ /[025]/)) {$flag .= "O"} if ($flag_tmp =~ /[u]/) {$flag .= "U"} if ($flag) {$asn_toprint .= " !$flag!"} else {$asn_toprint .= ""} $cell[$n--] = $asn_toprint; } else { $cell[$n--] = "$asn_toprint"; } if (join("", @asn_1[(0)..($i-1)]) eq join("", @asn_2[(0)..($i-1)])) { if (!defined($asn_2[$i])) { if ($bar[$i]) { $cell[$n--] = "".$sim[0].""; $bar[$i] = ""; } else {$cell[$n--] = "".$sim[2].""} } else { if ($bar[$i]) {$cell[$n--] = "".$sim[4].""} else { $cell[$n--] = "".$sim[3].""; $bar[$i] = 1; } } } elsif ($bar[$i]) { $cell[$n--] = "".$sim[0].""; $bar[$i] = ""; } else {$cell[$n--] = "".$sim[2].""} } elsif (!defined($asn_2[$i+1])) { $cell[$n--] = "".$sim[3].""; if ($bar[$i]) {$cell[$n--] = "".$sim[1].""} else {$cell[$n--] = "".$sim[5].""} } else { $cell[$n--] = "".$sim[5].""; if ($bar[$i]) {$cell[$n--] = "".$sim[1].""} else {$cell[$n--] = "".$sim[5].""} } } #end for columns $f_table[$j] = join("", @cell); @cell = (); } #end for rows return(@f_table); } # Routine to generate HTML files for current tree tables sub create_html_tree { my ($tree_type, $time_change) = @_; my ($output_file, $title, $img_src, $lastchange); my $i = 0; my @tree = (); my $history_reldir = substr($HISTORYHTMLDIR, length($HTMLDIR_LOCAL) + 1, length($HISTORYHTMLDIR) - length($HTMLDIR_LOCAL)); my $printable_date = &convert_date($time_change); if ($tree_type == 0) { # complete $output_file = $OUTPUTCOMPLETE; $title = "The whole IPv6 BGP table"; } elsif ($tree_type == 1) { # backbone $output_file = $OUTPUTBB; $title = "IPv6 BGP table: the backbone"; } elsif ($tree_type == 3) { # otherIANA $output_file = $OUTPUTIANA; $title = "IPv6 BGP table: "2001" routes"; } open(HTMLFILE,">".$output_file); print HTMLFILE &header($title, 1); print HTMLFILE "\n"; if ($SITEPICTURE) { print HTMLFILE "\n"; } print HTMLFILE "\n"; print HTMLFILE "\n"; print HTMLFILE "\n"; print HTMLFILE "
$title
Updated on $LONGDATE
 
\n"; print HTMLFILE "

\n"; print HTMLFILE "\n"; if ($ROOTPICTURE) {$img_src = ""} else {$img_src = $SITENAME} if (-e $DETAILFILE) {$img_src = "".$img_src.""} $img_src .= " "; @tree = &create_output_table($tree_type); print HTMLFILE "$tree[0]\n"; for ($i = 1; $i < @tree; $i++) { print HTMLFILE "$tree[$i]\n"; } print HTMLFILE "
$img_src
\n


\n"; # The whole IPv6 BGP table if ($tree_type == 0) { if ($time_change) { if ($CHANGESFLAG && -e $OUTPUTCOMPLETECHANGES) {$lastchange = "Last change"} else {$lastchange = "Last change"} print HTMLFILE " $lastchange on the tree detected on $printable_date

\n"; } print HTMLFILE " The IPv6 BGP routing tree is obtained elaborating the AS path information of the IPv6 BGP routing table. A link to detailed routing information is available at the end of each branch of the tree.
Warnings (!) are raised for odd and unstable routes: \n "; } # The 6bone backbone IPv6 BGP table elsif ($tree_type == 1) { if ($time_change) { if ($CHANGESFLAG && -e $OUTPUTBBCHANGES) {$lastchange = "Last change"} else {$lastchange = "Last change"} print HTMLFILE " $lastchange on the tree detected on $printable_date
\n"; } if (@NRPTLAS) { $i = 0; print HTMLFILE "We are not receiving any routing information for "; print HTMLFILE "the following pTLAs:
\n\n"; for (sort(@NRPTLAS)) { print HTMLFILE "$_"; if ($i < (@NRPTLAS-1)) {print HTMLFILE ", "} $i++; } print HTMLFILE "\n
\n\n"; } print HTMLFILE " The IPv6 BGP routing tree for the 6bone backbone is obtained elaborating the AS path information of the IPv6 BGP routing table.
A link to detailed routing information is available at the end of each branch of the tree.
Warnings (!U!) are raised for unstable routes.\n "; } # The other IANA IPv6 BGP table elsif ($tree_type == 3) { if ($time_change) { if ($CHANGESFLAG && -e $OUTPUTIANACHANGES) {$lastchange = "Last change"} else {$lastchange = "Last change"} print HTMLFILE " $lastchange on the tree detected on $printable_date

\n"; } print HTMLFILE " The IPv6 BGP routing tree for the "2001" routes (route entries containing prefixes assigned by the RIRs within the 2001::/16 address space and prefix length in range [29,35]) is obtained elaborating the AS path information of the IPv6 BGP routing table.
A link to detailed routing information is available at the end of each branch of the tree.
Warnings (!U!) are raised for unstable routes.\n "; } print HTMLFILE "
\n".&footer."
\n\n\n"; close(HTMLFILE); $output_file =~ m!([^/]*)$!; &log_it(" $1 created", 1); return(0); } # Routine to create a html detail file sub create_html_detailfile { my ($filename, $aspath, $vector_index, $hints_index, $prepend) = @_; my @vector = @$vector_index; my %hints = %$hints_index; my @item = (); my ($ncol, $line, $key, $prefix, $origin_as, $owner, $xtla_site, $timestring, $timecolor, $updates); my ($detailslink, $status, $fal_whois, $prepended_as, $as_number); my $history_reldir = substr($HISTORYHTMLDIR, length($HTMLDIR_LOCAL) + 1, length($HISTORYHTMLDIR) - length($HTMLDIR_LOCAL)); open(HTMLDETAILS,">".$filename); print HTMLDETAILS &header("Routing entry detail: $LONGDATE", 0); print HTMLDETAILS "AS Path:
\n"; print HTMLDETAILS "$aspath

\n"; print HTMLDETAILS "Advertised prefixes:
\n"; print HTMLDETAILS "

\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; if (defined($prepend)) { print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; $ncol = 15; } else {$ncol = 13} print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; foreach $line (@vector) { @item = split(/\s+/, $line); $prefix = $item[0]; if ($item[1] eq '?' || $item[1] eq '?') {$owner = '?'} else { if (&includedprefix($prefix,"3ffe::/16")) {$flag_whois = 0} else {$flag_whois = 1} $owner = &format_owner($item[1],$flag_whois); } $timestring = &convert_sincelastchange_time($item[2]); $timestring =~ s/\s/\ \;/g; if (int($item[2]/60) <= $WARNINGTIME) {$timecolor = "\"#FF0000\""} else {$timecolor = "\"#000000\""} $updates = $item[3]; if ($item[4] ne 'n/a') {$detailslink = "view"} else {$detailslink = $item[4]} if ($item[5] eq '?' || $item[5] eq '?') {$xtla_site = '?'} else {$xtla_site = &format_owner($item[5],$flag_whois)} $origin_as = &format_originAS($item[6]); if (substr($ROUTE_FLAGS{$prefix}, 4, 1) eq '?') {$origin_as .= ' [incomplete]'} elsif (substr($ROUTE_FLAGS{$prefix}, 4, 1) eq 'i') {$origin_as .= ' [IGP]'} elsif (substr($ROUTE_FLAGS{$prefix}, 4, 1) eq 'e') {$origin_as .= ' [EGP]'} print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; if ($ncol == 15) { print HTMLDETAILS "\n\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; print HTMLDETAILS "\n"; } print HTMLDETAILS "
 Status  Destination prefix  Origin  Prepended AS 
(times)
 Assigned to  xTLA owner Time (updates)
 since last change 
 Details
".substr($ROUTE_FLAGS{$prefix}, 0, 2)." $prefix  $origin_as "; @item = grep(/\S+/,(split(/\s+/, $$prepend{$prefix}))); foreach my $element (@item) { $element =~ /(\d+)\#(\d+)/; $prepended_as = &format_originAS($1); print HTMLDETAILS "$prepended_as\ ($2)"; unless ($element eq $item[$#item]) {print HTMLDETAILS ",\ "} } } print HTMLDETAILS " $owner  $xtla_site  $timestring ($updates)  $detailslink
\n

\n"; print HTMLDETAILS "Status Codes:
\n"; print HTMLDETAILS "$STATUSCODES

\n"; if (%hints) { print HTMLDETAILS "Hints:
\n"; print HTMLDETAILS "\n"; foreach $key (keys(%hints)) { $as_number = &format_originAS($key); print HTMLDETAILS "$as_number: $hints{$key}
\n"; } print HTMLDETAILS "
\n"; } print HTMLDETAILS "


\n ".&footer." \n\n\n"; close(HTMLDETAILS); return(1); } (1); #### ASpath-tree v.4.2 - Released on Thu APR 17 2003, h.16:58:12 #### File: lib/bgp-tree.pl Last modified on Fri APR 11 2003, h.23:56:04