text# $tmpfile = "tmp.html"; open(HOUT,"> $tmpfile"); print HOUT "\n"; print HOUT "
textif ($dontformat) { if (/^>>>>/) { print HOUT ""; $dontformat = 0; } else { # if protocol info, strip level info if (/^\[\d+\](.*)/) { print HOUT $1 . "\n"; } else { print HOUT $_ . "\n"; } } } elsif (/^<<<) { print HOUT "
";
$dontformat = 1; # don't format after this line
}
elsif (s/^###\s+(.+)###/$1/) {
# if starts with "###", it is a heading
print HOUT "" . $_ . "
\n";
# special handling after "Protocol"
if (/^Protocol/) {
print HOUT "
\n";
print HOUT "";
}
# special handling after "Packet Size Distribution"
if (/^Packet Size Distribution/) {
print HOUT "
\n";
print HOUT "detailed numbers
\n";
}
}
elsif (/([^:]+):(.*)/) {
# if ":" exists, use bold typeface
print HOUT "" . $1 . ":" . $2 . "
\n";
# find Id field
if (/^Id:\s*(\w+)/) {
$id = $1;
$outfile = $id . ".html";
}
}
else {
# just output the original line
print HOUT $_ . "
\n";
}
}
# if there is a dumpfile, create a link
$dumpfile = "";
if (-r $id . ".dump.gz") {
$dumpfile = $id . ".dump.gz";
}
elsif (-r $id . ".dump") {
$dumpfile = $id . ".dump";
}
if ($dumpfile) {
($dc, $dc, $dc, $dc, $dc, $dc, $dc, $size) = stat $dumpfile;
$sizestr = sprintf "%.2f", $size / 1024 / 1024;
# create anonymous ftp url
# the path starts at "/pub/" for anon ftp
chop($hostname = `hostname`);
chop($cwd = `pwd`);
if ($cwd =~ /.*(\/pub\/.*)/) {
$cwd = $1;
}
$url = "ftp://" . $hostname . $cwd . "/" . $dumpfile;
print HOUT "tcpdump file: $dumpfile ($sizestr MB)
\n";
}
print HOUT <
EOF
close(HOUT);
rename $tmpfile, $outfile;
exit 0;