When using the send subroutine in this module and connecting to an IP
address that the "ping" tool on the command line reports as "Network is
unreachable" the code always ends with this message:-
sendto() at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Net/RawIP.pm line
630.
There does not seem to be any way to catch this error and prevent the
code from ending. I would consider this a bug that there is no way to
detect errors in this call and handle them, as the code always causes
the script to end.
Sample script that causes the issue on the network I am using:-
#!/usr/bin/perl -w
use strict;
use Net::RawIP qw(:pcap);
my $srcIP = "10.24.240.130";
my $dstIP = "172.31.252.26";
my $b = new Net::RawIP ({icmp =>{}});
$b->set({ip => {saddr => $srcIP, daddr => $dstIP}, icmp => {type => 8,
id => $$} });
$b->set({icmp => {data => "............aaaaaaaaaa..".timem()}});
$b->send(0,1);
Using perl version 5.8.8 on CentOS 5.4
The bug appears to be the croak statements in util.c:-
void
pkt_send (int fd, unsigned char * sock,u_char *pkt,int size)
{
if (sendto (fd, (const void *)pkt,size, 0, (const struct sockaddr *)
sock, sizeof (struct sockaddr)) < 0)
{
close (fd);
croak("sendto()");
}
}
Commenting out the croak in the code above and re-compiling works around
the problem.