#### ASpath-tree v.4.2 - Released on Thu APR 17 2003, h.16:58:12
#### File: lib/odd-as.pl Last modified on Fri MAR 14 2003, h.15:42:35

# Routine to create a detail page for odd AS numbers

sub create_oddasn_pages {
	my ($filename, $ipriv, $ireserv) = @_;

	&odd_asn_details($filename, 'private', $ipriv);
	&odd_asn_details($filename, 'reserved', $ireserv);
	return(0);
}

sub odd_asn_details {
	my ($filename, $flag, $ihash) = @_;
	my ($title, $key, $aspath, $maxlen, $numcol, $asname, $name);
	my $separator = '-';
	my @ass = ();

	$filename =~ /(.*)\/{1}(.*)\.{1}.*$/;
	my $path = $1;
	my $link = $2;

	if ($flag eq 'private') {$title = "private AS numbers"}
	elsif ($flag eq 'reserved') {
		$title = "reserved AS numbers";
		$filename = $path.'/'.$link.'1.html';
	}

	open(HTMLFILE,">".$filename);

	print HTMLFILE &header("Detected $title", 0);

	print HTMLFILE "<TABLE>\n<TR>";
	if ($SITEPICTURE) {
		print HTMLFILE "<TD VALIGN=top><IMG SRC=\"$ICONS/$SITEPICTURE\" BORDER=0></TD>\n";
	}
	else {print HTMLFILE "<TD></TD>\n"}
	print HTMLFILE "<TD VALIGN=bottom CLASS=a32b>&nbsp;Detected $title</TD></TR>\n";
	print HTMLFILE "<TR><TD ALIGN=center VALIGN=top COLSPAN=2 CLASS=n10b>Updated on $LONGDATE</TD></TR>\n";
	print HTMLFILE "</TABLE>\n<P>\n";

	if (keys(%$ihash)) {
		foreach $key (keys(%$ihash)) {
			foreach $aspath (@{$$ihash{$key}}) {
				@ass = &convert_asn($aspath);
				if ($maxlen < @ass) {$maxlen = @ass}
			}
		}
		$numcol = ($maxlen-5)*2;
		print HTMLFILE "<CENTER><TABLE CELLPADDING=5 BORDER=1>\n";
		print HTMLFILE "<TR BGCOLOR=\"$MAINCOLOR\"><TD ALIGN=center CLASS=w12b>$title</TD>\n";
		print HTMLFILE "<TD CLASS=w12b>AS Paths</TD></TR>\n";
		foreach $key (sort(keys(%$ihash))) {
			$name = '';
			if (defined($ASNAME{$key}) && $ASNAME{$key} !~ /^AS\d+$/) {
				if ($ASNAME{$key} =~ /\-/) {$name = "<NOBR>"}
				$name = "(<A HREF=\"$WHOISLINK?$ASNAME{$key}\">$ASNAME{$key}</A>)";
			}
			else {$name = ''}
			print HTMLFILE "<TR><TD VALIGN=top CLASS=n10>"."AS"."$key $name</TD>\n";
			print HTMLFILE "<TD VALIGN=bottom><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>\n";
			foreach $aspath (@{$$ihash{$key}}) {
				@ass = &convert_asn($aspath);
				print HTMLFILE "<TR>\n";
				for ($i = 0; $i < $#ass; $i++) {
					$asname = &format_asname($ass[$i]);
					if ($ass[$i] eq $key) {$asname = '<SPAN CLASS=n10b>'.$asname.'</SPAN>'}
					print HTMLFILE "<TD VALIGN=bottom CLASS=n10>$asname</TD>";
					print HTMLFILE "<TD VALIGN=bottom CLASS=n10>$separator</TD>\n";
				}
				$asname = &format_asname($ass[$#ass]);
				if ($ass[$#ass] eq $key) {$asname = '<SPAN CLASS=n10b>'.$asname.'</SPAN>'}
				print HTMLFILE "<TD VALIGN=bottom CLASS=n10>$asname</TD>\n";
				if ($#ass < $maxlen) {
					$leftcol = $numcol - ($#ass - 4)*2 + 1;
					print HTMLFILE "<TD COLSPAN=$leftcol CLASS=n10>&nbsp;</TD>\n";
				}
				print HTMLFILE "\n</TR>\n";
			}
			print HTMLFILE "</TABLE></TD></TR>\n";
		}
		print HTMLFILE "</TABLE></CENTER>\n<P><HR>\n";
	}
	else {print HTMLFILE "<SPAN CLASS=n12>There are no $title in the routing table.</SPAN><P><HR>\n"}

	print HTMLFILE "<SPAN CLASS=n10><A HREF=\"./$INDEXPAGE\">Back to routing information page</A>\n";

	print HTMLFILE "
	<HR>\n".&footer."
	</SPAN>\n</BODY>\n</HTML>\n";

	close(HTMLFILE);
	return(0);
}

(1);
#### ASpath-tree v.4.2 - Released on Thu APR 17 2003, h.16:58:12
#### File: lib/odd-as.pl Last modified on Fri MAR 14 2003, h.15:42:35
