Subject: | Net::Packet::Dump fails to bless pcap file as 'IO::File' |
Net-Packet-2.04
perl-5.8.7 for i486-linux-gnu-thread-multi
Linux debian 2.6.12-1-686
I happen to be running in a VMplayer (like VMware) instance, but I think that's unrelated.
Code:
# Instanciate object, will start capturing from network
my $dump = Net::Packet::Dump->new(
filter => 'tcp',
noStore => 1,
);
while (1) {
if (my $frame = $dump->next) {
do_stuff($frame);
}
}
I get an error: Can't bless non-reference value at .../Dump.pm line 250. So I tried perl -d server.pl. The error occurs at this expression:
bless(Net::Packet::netpacket_pcap_fp($self->_pcapd), 'IO::File')
Net::Packet::netpacket_pcap_fp is a reference to a C function:
FILE * netpacket_pcap_fp(pcap_t *pd){
if (pd == NULL) return(0);
else return(pd->sf.rfile);
}
and when I print $self->_pcapd in the debugger, I get
'_pcapd' => pcap_tPtr=SCALAR(0x896dde8)
-> 144211632
which I think is a reference (pointer) to the beginning of the data structure written in C of type struct pcapd, which is defined as follows:
struct pcap_sf {
FILE *rfile;
...
};
...
struct pcap {
...
struct pcap_sf sf;
...
};
So it looks like Net::Packet::Dump is trying to get a FILE* from C and bless it as an 'IO::File'. I've tried many things, even downloading the PeepPoke module so I could inspect that C data structure to be sure that FILE*rfile is not null (and no, it is not null).
Anyway, that's the bug I am working around. Thanks for providing your services voluntarily!