-foreach my $line (@active) {
- my $protocol='';
- my $expires='';
- my $status='';
- my $orgsip='';
- my $orgdip='';
- my $orgsp='';
- my $orgdp='';
- my $exsip='';
- my $exdip='';
- my $exsp='';
- my $exdp='';
- my $marked='';
- my $use='';
-
- chomp($line);
- my @temp = split(' ',$line);
-
- if ($temp[0] eq 'icmp') {
- $protocol = $temp[0];
- $status = $Lang::tr{'all'};
- $orgsip = substr $temp[3], 4;
- $orgdip = substr $temp[4], 4;
- $marked = $temp[8] eq '[UNREPLIED]' ? '[UNREPLIED]' : ' ';
- }
- if ($temp[0] eq 'udp') {
- $protocol = $temp[0];
- $status = $Lang::tr{'all'};
- $orgsip = substr $temp[3], 4;
- $orgdip = substr $temp[4], 4;
- $marked = $temp[7] eq '[UNREPLIED]' ? '[UNREPLIED]' : defined ($temp[12]) ? $temp[11] : ' ';
- }
- if ($temp[0] eq 'tcp') {
- $protocol = $temp[0];
- $status = $temp[3];
- $orgsip = substr $temp[4], 4;
- $orgdip = substr $temp[5], 4;
- $marked = $temp[8] eq '[UNREPLIED]' ? '[UNREPLIED]' : defined ($temp[13]) ? $temp[12] : ' ';
- }
-
- # filter the line if we found a known proto
- next if( !(
- (($cgiparams{'SEE_PROTO'} eq $Lang::tr{'all'}) || ($protocol eq $cgiparams{'SEE_PROTO'} ))
- && (($cgiparams{'SEE_STATE'} eq $Lang::tr{'all'}) || ($status eq $cgiparams{'SEE_STATE'} ))
- && (($cgiparams{'SEE_MARK'} eq $Lang::tr{'all'}) || ($marked eq $cgiparams{'SEE_MARK'} ))
- && (($cgiparams{'SEE_SRC'} eq "*.*.*.*") || ($orgsip eq $cgiparams{'SEE_SRC'} ))
- && (($cgiparams{'SEE_DEST'} eq "*.*.*.*") || ($orgdip eq $cgiparams{'SEE_DEST'} ))
- ));
-
- if ($temp[0] eq 'icmp') {
- my $offset = 0;
- $protocol = $temp[0] . " (" . $temp[1] . ")";
- $expires = $temp[2];
- $status = ' ';
- if ($temp[8] eq '[UNREPLIED]' ) {
- $offset = +1;
- }
- $orgsip = substr $temp[3], 4;
- $orgdip = substr $temp[4], 4;
- $orgsp = &General::GetIcmpDescription(substr( $temp[5], 5)) . "/" . substr( $temp[6], 5);;
- $orgdp = 'id=' . substr( $temp[7], 3);
- $exsip = substr $temp[8 + $offset], 4;
- $exdip = substr $temp[9 + $offset], 4;
- $exsp = &General::GetIcmpDescription(substr( $temp[10 + $offset], 5)). "/" . substr( $temp[11 + $offset], 5);
- $exdp = 'id=' . substr( $temp[11 + $offset], 5);
- $marked = $temp[8] eq '[UNREPLIED]' ? '[UNREPLIED]' : ' ';
- $use = substr( $temp[13 + $offset], 4 );
- }
- if ($temp[0] eq 'udp') {
- my $offset = 0;
- $marked = '';
- $protocol = $temp[0] . " (" . $temp[1] . ")";
- $expires = $temp[2];
- $status = ' ';
- $orgsip = substr $temp[3], 4;
- $orgdip = substr $temp[4], 4;
- $orgsp = substr $temp[5], 6;
- $orgdp = substr $temp[6], 6;
- if ($temp[7] eq '[UNREPLIED]') {
- $offset = 1;
- $marked = $temp[7];
- $use = substr $temp[12], 4;
- } else {
- if ((substr $temp[11], 0, 3) eq 'use' ) {
- $marked = '';
- $use = substr $temp[11], 4;
- } else {
- $marked = $temp[11];
- $use = substr $temp[12], 4;
- }
- }
- $exsip = substr $temp[7 + $offset], 4;
- $exdip = substr $temp[8 + $offset], 4;
- $exsp = substr $temp[9 + $offset], 6;
- $exdp = substr $temp[10 + $offset], 6;
- }
- if ($temp[0] eq 'tcp') {
- my $offset = 0;
- $protocol = $temp[0] . " (" . $temp[1] . ")";
- $expires = $temp[2];
- $status = $temp[3];
- $orgsip = substr $temp[4], 4;
- $orgdip = substr $temp[5], 4;
- $orgsp = substr $temp[6], 6;
- $orgdp = substr $temp[7], 6;
- if ($temp[8] eq '[UNREPLIED]') {
- $marked = $temp[8];
- $offset = 1;
- } else {
- $marked = $temp[12];
- }
- $exsip = substr $temp[8 + $offset], 4;
- $exdip = substr $temp[9 + $offset], 4;
- $exsp = substr $temp[10 + $offset], 6;
- $exdp = substr $temp[11 + $offset], 6;
- $use = substr $temp[13], 4;
- }
- if ($temp[0] eq 'unknown') {
- my $offset = 0;
- $protocol = "??? (" . $temp[1] . ")";
- $protocol = "esp (" . $temp[1] . ")" if ($temp[1] == 50);
- $protocol = "ah (" . $temp[1] . ")" if ($temp[1] == 51);
- $expires = $temp[2];
- $status = ' ';
- $orgsip = substr $temp[3], 4;
- $orgdip = substr $temp[4], 4;
- $orgsp = ' ';
- $orgdp = ' ';
- $exsip = substr $temp[5], 4;
- $exdip = substr $temp[6], 4;
- $exsp = ' ';
- $exdp = ' ';
- $marked = ' ';
- $use = ' ';
- }
- if ($temp[0] eq 'gre') {
- my $offset = 0;
- $protocol = $temp[0] . " (" . $temp[1] . ")";
- $expires = $temp[2];
- $orgsip = substr $temp[5], 4;
- $orgdip = substr $temp[6], 4;
- $orgsp = ' ';
- $orgdp = ' ';
- $exsip = substr $temp[11], 4;
- $exdip = substr $temp[12], 4;
- $exsp = ' ';
- $exdp = ' ';
- $marked = $temp[17];
- $use = $temp[18];
- }
- # Only from this point, lines have the same known format/field
- # The floating fields [UNREPLIED] [ASSURED] etc are ok.
-
- # Store the line in a hash array for sorting
- if ( $protocol ) { # line is decoded ?
- my @record = ( 'index', $index++,
- 'protocol', $protocol,
- 'expires', $expires,
- 'status', $status,
- 'orgsip', $orgsip,
- 'orgdip', $orgdip,
- 'orgsp', $orgsp,
- 'orgdp', $orgdp,
- 'exsip', $exsip,
- 'exdip', $exdip,
- 'exsp', $exsp,
- 'exdp', $exdp,
- 'marked', $marked,
- 'use', $use);
- my $record = {}; # create a reference to empty hash
- %{$record} = @record; # populate that hash with @record
- $entries{$record->{index}} = $record; # add this to a hash of hashes
- } else { # it was not a known line
- $unknownlines .= "<tr bgcolor='${Header::table1colour}'>";
- $unknownlines .= "<td colspan='9'> unknown:$line></td></tr>";
- }
-}
-
-# Build listbox objects
-my $menu_proto = &make_select ('SEE_PROTO', $cgiparams{'SEE_PROTO'}, @list_proto);
-my $menu_state = &make_select ('SEE_STATE', $cgiparams{'SEE_STATE'}, @list_state);
-my $menu_src = &make_select ('SEE_SRC', $cgiparams{'SEE_SRC'}, &get_known_ips('orgsip'));
-my $menu_dest = &make_select ('SEE_DEST', $cgiparams{'SEE_DEST'}, &get_known_ips('orgdip'));
-my $menu_mark = &make_select ('SEE_MARK', $cgiparams{'SEE_MARK'}, @list_mark);
-my $menu_sort = &make_select ('SEE_SORT', $cgiparams{'SEE_SORT'}, @list_sort);
-