Sophie

Sophie

distrib > Mandriva > 2006.0 > i586 > by-pkgid > 17ef4e87ae8e300b78e4e2c62e3b9fb1 > files > 47

perl-Net-Packet-2.04-1mdk.i586.rpm

#!/usr/bin/perl

#
# $Id: read-pcap.pl,v 1.1.2.2 2005/05/22 19:09:31 gomor Exp $
#

use strict;
use warnings;

use Getopt::Std;

my %opts;
getopts('f:F:', \%opts);

die "Usage: read-pcap.pl -f file [-F filter]\n"
   unless $opts{f};

use Net::Pkt;

my $dump = Net::Packet::Dump->new(
   unlinkOnDestroy => 0,
   file            => $opts{f},
   filter          => $opts{F} || "",
   callStart       => 0,
   noStore         => 1,
);

while ($_ = $dump->next) {
   print $_->l2->print, "\n" if $_->l2;
   print $_->l3->print, "\n" if $_->l3;
   print $_->l4->print, "\n" if $_->l4;
   print $_->l7->print, "\n" if $_->l7;
}

$dump->stop;