From: Jarkko Hietaniemi Date: Mon, 10 Jun 2002 02:12:09 +0000 (+0000) Subject: Upgrade to Net::Ping 2.19. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=15d96390cdc9f50119594a52390acfbf47d4f693;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Net::Ping 2.19. p4raw-id: //depot/perl@17155 --- diff --git a/MANIFEST b/MANIFEST index 8ed35fb..29b2e9d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1306,7 +1306,7 @@ lib/Net/netent.t See if Net::netent works lib/Net/Netrc.pm libnet lib/Net/NNTP.pm libnet lib/Net/Ping.pm Hello, anybody home? -lib/Net/Ping/CHANGES Net::Ping +lib/Net/Ping/Changes Net::Ping lib/Net/Ping/README Net::Ping lib/Net/Ping/t/100_load.t Ping Net::Ping lib/Net/Ping/t/110_icmp_inst.t Ping Net::Ping diff --git a/lib/Net/Ping.pm b/lib/Net/Ping.pm index 04cddc1..babe2b0 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 similarity index 91% rename from lib/Net/Ping/CHANGES rename to lib/Net/Ping/Changes index 0ac95cf..6677b52 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 e55e847..b3665ce 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