diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2002-06-10 02:12:09 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-06-10 02:12:09 +0000 |
commit | 8f4bea27aa19b9083580f535cb24c9515c9aefbe (patch) | |
tree | 354fa1935b736b1c5afcf463bdd12cc194608c2f /lib/Net | |
parent | 270fe7e1c9e0c4a8d76aa80e57390c48c57811a9 (diff) | |
download | perl-8f4bea27aa19b9083580f535cb24c9515c9aefbe.tar.gz |
Upgrade to Net::Ping 2.19.
p4raw-id: //depot/perl@17155
Diffstat (limited to 'lib/Net')
-rw-r--r-- | lib/Net/Ping.pm | 38 | ||||
-rw-r--r-- | lib/Net/Ping/Changes (renamed from lib/Net/Ping/CHANGES) | 7 | ||||
-rw-r--r-- | lib/Net/Ping/README | 12 |
3 files changed, 49 insertions, 8 deletions
diff --git a/lib/Net/Ping.pm b/lib/Net/Ping.pm index 04cddc14d7..babe2b0b53 100644 --- a/lib/Net/Ping.pm +++ b/lib/Net/Ping.pm @@ -1,13 +1,13 @@ package Net::Ping; -# $Id: Ping.pm,v 1.34 2002/05/06 17:37:54 rob Exp $ +# $Id: Ping.pm,v 1.1 2002/06/04 00:41:52 rob Exp $ require 5.002; require Exporter; use strict; use vars qw(@ISA @EXPORT $VERSION - $def_timeout $def_proto $max_datasize $pingstring $hires); + $def_timeout $def_proto $max_datasize $pingstring $hires $udp_source_verify); use FileHandle; use Socket qw( SOCK_DGRAM SOCK_STREAM SOCK_RAW PF_INET inet_aton inet_ntoa sockaddr_in ); @@ -16,7 +16,7 @@ use POSIX qw(ECONNREFUSED); @ISA = qw(Exporter); @EXPORT = qw(pingecho); -$VERSION = "2.18"; +$VERSION = "2.19"; # Constants @@ -25,6 +25,7 @@ $def_proto = "tcp"; # Default protocol to use for pinging $max_datasize = 1024; # Maximum data bytes in a packet # The data we exchange with the server for the stream protocol $pingstring = "pingschwingping!\n"; +$udp_source_verify = 1; # Default is to verify source endpoint if ($^O =~ /Win32/i) { # Hack to avoid this Win32 spewage: @@ -163,6 +164,17 @@ sub bind } +# Description: Allow UDP source endpoint comparision to be +# skipped for those remote interfaces that do +# not response from the same endpoint. + +sub source_verify +{ + my $self = shift; + $udp_source_verify = 1 unless defined + ($udp_source_verify = ((defined $self) && (ref $self)) ? shift() : $self); +} + # Description: allows the module to use milliseconds as returned by # the Time::HiRes module @@ -638,9 +650,10 @@ sub ping_udp $from_saddr = recv($self->{"fh"}, $from_msg, 1500, UDP_FLAGS) or last; # For example an unreachable host will make recv() fail. ($from_port, $from_ip) = sockaddr_in($from_saddr); - if (($from_ip eq $ip) && # Does the packet check out? - ($from_port == $self->{"port_num"}) && - ($from_msg eq $msg)) + if (!$udp_source_verify || + (($from_ip eq $ip) && # Does the packet check out? + ($from_port == $self->{"port_num"}) && + ($from_msg eq $msg))) { $ret = 1; # It's a winner $done = 1; @@ -672,7 +685,7 @@ __END__ Net::Ping - check a remote host for reachability -$Id: Ping.pm,v 1.34 2002/05/06 17:37:54 rob Exp $ +$Id: Ping.pm,v 1.1 2002/06/04 00:41:52 rob Exp $ =head1 SYNOPSIS @@ -778,11 +791,22 @@ default) number of data bytes is 1 if the protocol is "udp" and 0 otherwise. The maximum number of data bytes that can be specified is 1024. +=item $p->source_verify( { 0 | 1 } ); + +Allows source endpoint verification to be enabled or disabled. +This is useful for those remote destinations with multiples +interfaces where the response may not originate from the same +endpoint that the original destination endpoint was sent to. + +This is enabled by default. + =item $p->hires( { 0 | 1 } ); Causes this module to use Time::HiRes module, allowing milliseconds to be returned by subsequent calls to ping(). +This is disabled by default. + =item $p->bind($local_addr); Sets the source address from which pings will be sent. This must be diff --git a/lib/Net/Ping/CHANGES b/lib/Net/Ping/Changes index 0ac95cf4cc..6677b527e0 100644 --- a/lib/Net/Ping/CHANGES +++ b/lib/Net/Ping/Changes @@ -1,6 +1,13 @@ CHANGES ------- +2.19 Jun 03 19:00 2002 + - Add $p->udp_source_verify method to skip source + endpoint verification of udp protocol pings for + those remote destinations with multiple interfaces + that may have the "reverse telnet" bug. + - Moved files to more standard locations. + 2.18 May 06 12:00 2002 - More RPM spec generalizations. diff --git a/lib/Net/Ping/README b/lib/Net/Ping/README index e55e847aa8..b3665cec6e 100644 --- a/lib/Net/Ping/README +++ b/lib/Net/Ping/README @@ -1,7 +1,7 @@ NAME Net::Ping - check a remote host for reachability - $Id: Ping.pm,v 1.34 2002/05/06 17:37:54 rob Exp $ + $Id: Ping.pm,v 1.1 2002/06/04 00:41:52 rob Exp $ SYNOPSIS use Net::Ping; @@ -102,10 +102,20 @@ DESCRIPTION otherwise. The maximum number of data bytes that can be specified is 1024. + $p->source_verify( { 0 | 1 } ); + Allows source endpoint verification to be enabled or disabled. This + is useful for those remote destinations with multiples interfaces + where the response may not originate from the same endpoint that the + original destination endpoint was sent to. + + This is enabled by default. + $p->hires( { 0 | 1 } ); Causes this module to use Time::HiRes module, allowing milliseconds to be returned by subsequent calls to ping(). + This is disabled by default. + $p->bind($local_addr); Sets the source address from which pings will be sent. This must be the address of one of the interfaces on the local host. $local_addr |