#### 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 "$title |
\n";
print HTMLFILE "| Updated on $LONGDATE |
\n";
print HTMLFILE "| |
\n";
print HTMLFILE "
\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 "| $img_src | $tree[0]
\n";
for ($i = 1; $i < @tree; $i++) {
print HTMLFILE " | $tree[$i]
\n";
}
print HTMLFILE "
\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:
- U raises a warning that a route entry is Unstable;\n
- O raises a warning that there are Odd route entries
(invalid or unaggregated prefixes).
\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