rendered paste body local $SIG{ALRM} = sub { die "timeout\n"; };
alarm 3;
eval {
# call the sniffing loop, with the following code as an anonymous callback..
loop $pcap, $packet_count, sub {
if ($self->debug >3) {
print "Listener GOT a packet...\n";
}
my $time = timem();
$p->bset( substr( $_[2], 14 ) );
$self->dest( substr( $_[2], 0, 6) );
$self->src( substr( $_[2], 6, 6) );
my @g = $p->get( {ip => [qw(ttl saddr daddr)], udp => [qw(data)]} );
$self->decode( $g[3] );
$svrip = $self->server_ip;
$done = 1;
# Display Detailed packet information
if ( $self->debug > 3) {
my $x = $self->options();
my %options = %$x;
my $op53 = $options{'53'};
print "CHILD - RCVD:\n";
printf
"CHILD - xid %lx:\n %lu\tttl=%u saddr=%s daddr=%s\n\t\tsrc=%s dest=%s op=%d\n",
$self->xid, $xid, $g[0], ip2dot( $g[1] ), ip2dot( $g[2] ),
net2mac( $self->src ), net2mac( $self->dest ), $op53;
print "CHILD - (".$self->reply . " from " .$self->server_ip.")\n";
} # End if debug 3
my $svr_hwa = net2mac( $self->src );
# Push what we've found onto the previous data
push(@server_results,net2mac($self->src));
if ( $self->debug > 4 ) {
print Dumper @server_results;
} # End if debug 4
}, \@f; # End of anony sub passed to loop..
}; # End EVAL
alarm 0;
if ( $@ ) {
if ( $@ =~ /timeout/ ) {
if ( $self->debug > 1 ) {
print "CHILD - TIMEOUT\n";
}
return @server_results;
}
else {
print "UNKNOWN ERROR\n";
die;