zengargoyle has asked for the wisdom of the Perl Monks concerning the following question:
Check this out:
#!/usr/usc/perl/5.6.1/bin/perl use strict; use warnings; $|++; my $dev = shift @ARGV; $dev ||= 'qe0'; my $filter_string = 'udp src port 68 and dst port 67'; #my $filter_string = 'udp'; my $snaplen = 1508; my $promisc = 1; my $timeout = 100; my $count = -1; use Net::Pcap; my $err = ''; my $cap_dev; my $filter = ''; my $net = -256; $cap_dev = Net::Pcap::open_live($dev, $snaplen, $promisc, $timeout, \$ +err); die "$err\n" if $err; Net::Pcap::compile($cap_dev, \$filter, $filter_string, 0, -256) and die "compile: $err\n"; Net::Pcap::setfilter($cap_dev, $filter); Net::Pcap::loop($cap_dev, $count, \&callback, 'woot'); Net::Pcap::close($cap_dev); exit 0; sub callback { my ($user_data, $hdr, $pkt) = @_; warn "packet!\n"; my %header = %$hdr; #process_packet(\%header, $pkt); my $len = length $pkt; # warn "$header{len} $header{caplen} $len\n"; } sub process_packet { my ($hdr, $pkt) = @_; my $len = length $pkt; warn "$hdr->{len} $hdr->{caplen} $len\n"; }
This happily prints:
packet! packet! packet! packet!
Unless I uncomment the warn line. Then I get:
packet! 342 342 342 Segmentation Fault (core dumped)
Which seems quite odd. Any ideas what could cause this behavior?
This is perl, v5.6.1 built for sun4-solaris Net::Pcap 0.04 libpcap 0.7.1
Otherwise I use the perl and pcap (tcpdump...) all the time without seeing anything this bizare.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Net::Pcap Solaris and bizare coredumping
by Fletch (Bishop) on Dec 10, 2002 at 15:11 UTC | |
by zengargoyle (Deacon) on Dec 10, 2002 at 21:59 UTC |