#  This software was derived from SATAN 1.1.1 by Dan Farmer and Wietse Venema
#  (http://www.porcupine.org/satan).
#

#  This code update is provided by the Advanced Research Corporation (r) to
#  further the utility of the SARA Report Writer.  We request that the
#  developers do not modify or reverse engineer this code for
#  their own gain.
#
#  Developed and distributed by the Advanced Research Corporation.
#
# Report subnets
#

# generate the tables for looking subnets/hosts in:
&make_subnet_info();
$_subnets = keys %all_subnets;

sub sort_ip {
    local($aip,$bip);
    for $ip (split(/\./,$a)) { $aip = $aip * 256 + $ip; }
    for $ip (split(/\./,$b)) { $bip = $bip * 256 + $ip; }
    return $aip <=> $bip;
}

print <<EOF;
<HTML>
<HEAD>
<title> Host Tables - By Database Summary  </title>
<LINK REV="made" HREF="mailto:satan\@fish.com">
<LINK REV="made" HREF="mailto:sara\@arc.com">
</HEAD>
<H2>Security Auditor's Research Assistant (SARA) Report Writer</H2>
<a href="$HTML_ROOT/$system.html"> Back to the $SYSTEM start page </a> |
<a href="$HTML_SERVER/reporting/analysis.pl"> Back to $SYSTEM Reporting and Analysis </a><HR>
<P>
EOF
#
#Clear Chart variables
#
$black_bar=0;
$green_bar=0;
$red_bar=0;
$yellow_bar=0;
$brown_bar=0;
$start_report=1;
$report="chart";
for $_net (sort sort_ip keys %all_subnets) 
{
@_hosts = split(/\s/, $all_subnets{$_net});
do "$html_root/reporting/reportwriter/report_host_summary.pl";
    }
$total_bar = $green_bar + $black_bar + $red_bar + $yellow_bar + $brown_bar;
$green_per = int(((500 * $green_bar) / $total_bar) +.5);
$black_per = int(((500 * $black_bar) / $total_bar) +.5);
$red_per =   int(((500 * $red_bar) / $total_bar) +.5);
$red_per =   int(((500 * $red_bar) / $total_bar) +.5);
$yellow_per= int(((500 * $yellow_bar) / $total_bar) +.5);
$brown_per = int(((500 * $brown_bar) / $total_bar) +.5);
print <<EOF;
<UL><UL><UL>
<TABLE BORDER=0><TR><TD width="50">Green</TD><TD width="$green_per" BGCOLOR="Green">&nbsp;</TD><TD>$green_bar</TD></TR></TABLE>
<TABLE BORDER=0><TR><TD width="50">None</TD><TD width=$black_per" BGCOLOR="#808080">&nbsp;</TD><TD>$black_bar</TD></TR></TABLE>
<TABLE BORDER=0><TR><TD width="50">Red</TD><TD width="$red_per" BGCOLOR="RED">
&nbsp;</TD><TD>$red_bar</TD></TR></TABLE>
<TABLE BORDER=0><TR><TD width="50">Yellow</TD><TD width="$yellow_per" BGCOLOR="YELLOW">&nbsp;</TD><TD>$yellow_bar</TD></TR></TABLE>
<TABLE BORDER=0><TR><TD width="50">Brown</TD><TD width="$brown_per" BGCOLOR="#800000">&nbsp;</TD><TD>$brown_bar</TD></TR></TABLE>
<P>
<B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Figure 1  Host Summary by Color</B>
</UL></UL></UL>
<P>
<HR>
EOF
$start_report=1;
$report="table";
for $_net (sort sort_ip keys %all_subnets)
{
@_hosts = split(/\s/, $all_subnets{$_net});
do "$html_root/reporting/reportwriter/report_host_summary.pl";
    }

print <<EOF;
</TABLE></CENTER>
</ul>
</UL></UL>
</BODY>
</HTML>
EOF
