lathspell has asked for the wisdom of the Perl Monks concerning the following question:

Hello

Can somebody give me a hint how to filter out specific packets using PCAP filter? My below attempt calls the callback function even or ICMP pings, printing: "ip protocol=1".

I'm using Net::RawIP 0.21 and Perl 5.8.8 on a Debian Linux system with kernel 2.6.23.

bye,

-christian-
> #!/usr/bin/perl -W > use Net::RawIP; > use Data::Dumper; > > sub pcap_recv_callback { > $recv_rawip = new Net::RawIP({'udp' => {}}); > $recv_rawip->bset($_[2], 14); > printf("ip protocol=%d\n", $recv_rawip->get({'ip' => ['protocol' +]})); > } > > my $rawip = new Net::RawIP(); > my $pcap = $rawip->pcapinit('lo', 'dst port 68', 1500, 300); > > my @temp; > loop($pcap, 1, \&pcap_recv_callback, \@temp);

Replies are listed 'Best First'.
Re: PCAP filter does not work
by Khen1950fx (Canon) on Dec 29, 2007 at 06:30 UTC
      Thanks, using Net::Pcap it works!