diff options
author | Gisle Aas <gisle@aas.no> | 2005-06-03 02:17:44 -0700 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-06-03 21:07:03 +0000 |
commit | 46b9c7d8ea33b68703894b17914aea032e1c7b83 (patch) | |
tree | 24f5902205af5adbe92ee51b7a4bf46e347f3b3f /lib | |
parent | 84bda14a8c85ec8b0c8842a9a3367471372735ce (diff) | |
download | perl-46b9c7d8ea33b68703894b17914aea032e1c7b83.tar.gz |
Re: [PATCH] Improved ICMP_UNREACHABLE handling in Net::Ping
Message-ID: <lry89rfm8n.fsf_-_@caliper.activestate.com>
p4raw-id: //depot/perl@24699
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Net/Ping.pm | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/Net/Ping.pm b/lib/Net/Ping.pm index 05fd69d492..e989261933 100644 --- a/lib/Net/Ping.pm +++ b/lib/Net/Ping.pm @@ -16,7 +16,7 @@ use Carp; @ISA = qw(Exporter); @EXPORT = qw(pingecho); -$VERSION = "2.31_01"; +$VERSION = "2.31_02"; sub SOL_IP { 0; }; sub IP_TOS { 1; }; @@ -395,12 +395,13 @@ sub ping_external { return Net::Ping::External::ping(ip => $ip, timeout => $timeout); } -use constant ICMP_ECHOREPLY => 0; # ICMP packet types -use constant ICMP_ECHO => 8; -use constant ICMP_STRUCT => "C2 n3 A"; # Structure of a minimal ICMP packet -use constant SUBCODE => 0; # No ICMP subcode for ECHO and ECHOREPLY -use constant ICMP_FLAGS => 0; # No special flags for send or recv -use constant ICMP_PORT => 0; # No port with ICMP +use constant ICMP_ECHOREPLY => 0; # ICMP packet types +use constant ICMP_UNREACHABLE => 3; # ICMP packet types +use constant ICMP_ECHO => 8; +use constant ICMP_STRUCT => "C2 n3 A"; # Structure of a minimal ICMP packet +use constant SUBCODE => 0; # No ICMP subcode for ECHO and ECHOREPLY +use constant ICMP_FLAGS => 0; # No special flags for send or recv +use constant ICMP_PORT => 0; # No port with ICMP sub ping_icmp { @@ -478,10 +479,12 @@ sub ping_icmp $self->{"from_subcode"} = $from_subcode; if (($from_pid == $self->{"pid"}) && # Does the packet check out? ($from_seq == $self->{"seq"})) { - if ($from_type == ICMP_ECHOREPLY){ + if ($from_type == ICMP_ECHOREPLY) { $ret = 1; + $done = 1; + } elsif ($from_type == ICMP_UNREACHABLE) { + $done = 1; } - $done = 1; } } else { # Oops, timed out $done = 1; |