summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-07-17 03:11:53 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-07-17 03:11:53 +0000
commit5d20095f2ea76fe4a137473b5027adb54c562036 (patch)
tree4df5238e864397457b8d9d26a1f2b2cdd920754e /lib
parent37be0adfd3a8c7700da400b1233879928b7830b0 (diff)
downloadperl-5d20095f2ea76fe4a137473b5027adb54c562036.tar.gz
Upgrade to Net::Ping 2.20.
p4raw-id: //depot/perl@17584
Diffstat (limited to 'lib')
-rw-r--r--lib/Net/Ping.pm84
-rw-r--r--lib/Net/Ping/Changes14
-rw-r--r--lib/Net/Ping/README69
-rw-r--r--lib/Net/Ping/t/200_ping_tcp.t4
4 files changed, 129 insertions, 42 deletions
diff --git a/lib/Net/Ping.pm b/lib/Net/Ping.pm
index babe2b0b53..815bb75843 100644
--- a/lib/Net/Ping.pm
+++ b/lib/Net/Ping.pm
@@ -1,13 +1,13 @@
package Net::Ping;
-# $Id: Ping.pm,v 1.1 2002/06/04 00:41:52 rob Exp $
+# $Id: Ping.pm,v 1.6 2002/06/19 15:23:48 rob Exp $
require 5.002;
require Exporter;
use strict;
use vars qw(@ISA @EXPORT $VERSION
- $def_timeout $def_proto $max_datasize $pingstring $hires $udp_source_verify);
+ $def_timeout $def_proto $max_datasize $pingstring $hires $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.19";
+$VERSION = "2.20";
# Constants
@@ -25,7 +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
+$source_verify = 1; # Default is to verify source endpoint
if ($^O =~ /Win32/i) {
# Hack to avoid this Win32 spewage:
@@ -171,8 +171,8 @@ sub bind
sub source_verify
{
my $self = shift;
- $udp_source_verify = 1 unless defined
- ($udp_source_verify = ((defined $self) && (ref $self)) ? shift() : $self);
+ $source_verify = 1 unless defined
+ ($source_verify = ((defined $self) && (ref $self)) ? shift() : $self);
}
# Description: allows the module to use milliseconds as returned by
@@ -321,7 +321,7 @@ sub ping_icmp
substr($recv_msg, length($recv_msg) - $len_msg,
$len_msg));
if (($from_type == ICMP_ECHOREPLY) &&
- ($from_ip eq $ip) &&
+ (!$source_verify || $from_ip eq $ip) &&
($from_pid == $self->{"pid"}) && # Does the packet check out?
($from_seq == $self->{"seq"}))
{
@@ -650,7 +650,7 @@ 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 (!$udp_source_verify ||
+ if (!$source_verify ||
(($from_ip eq $ip) && # Does the packet check out?
($from_port == $self->{"port_num"}) &&
($from_msg eq $msg)))
@@ -685,7 +685,7 @@ __END__
Net::Ping - check a remote host for reachability
-$Id: Ping.pm,v 1.1 2002/06/04 00:41:52 rob Exp $
+$Id: Ping.pm,v 1.6 2002/06/19 15:23:48 rob Exp $
=head1 SYNOPSIS
@@ -791,12 +791,27 @@ 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->ping($host [, $timeout]);
+
+Ping the remote host and wait for a response. $host can be either the
+hostname or the IP number of the remote host. The optional timeout
+must be greater than 0 seconds and defaults to whatever was specified
+when the ping object was created. Returns a success flag. If the
+hostname cannot be found or there is a problem with the IP number, the
+success flag returned will be undef. Otherwise, the success flag will
+be 1 if the host is reachable and 0 if it is not. For most practical
+purposes, undef and 0 and can be treated as the same case. In array
+context, the elapsed time is also returned. The elapsed time value will
+be a float, as retuned by the Time::HiRes::time() function, if hires()
+has been previously called, otherwise it is returned as an integer.
+
=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 only affects udp and icmp protocol pings.
This is enabled by default.
@@ -821,20 +836,6 @@ then bind() must be called at most once per object, and (if it is
called at all) must be called before the first call to ping() for that
object.
-=item $p->ping($host [, $timeout]);
-
-Ping the remote host and wait for a response. $host can be either the
-hostname or the IP number of the remote host. The optional timeout
-must be greater than 0 seconds and defaults to whatever was specified
-when the ping object was created. Returns a success flag. If the
-hostname cannot be found or there is a problem with the IP number, the
-success flag returned will be undef. Otherwise, the success flag will
-be 1 if the host is reachable and 0 if it is not. For most practical
-purposes, undef and 0 and can be treated as the same case. In array
-context, the elapsed time is also returned. The elapsed time value will
-be a float, as retuned by the Time::HiRes::time() function, if hires()
-has been previously called, otherwise it is returned as an integer.
-
=item $p->open($host);
When you are using the stream protocol, this call pre-opens the
@@ -900,6 +901,43 @@ routines to pack and unpack ICMP packets. It would be better for a
separate module to be written which understands all of the different
kinds of ICMP packets.
+=head1 INSTALL
+
+The latest source tree is available via cvs:
+
+ cvs -z3 -q -d :pserver:anonymous@cvs.roobik.com.:/usr/local/cvsroot/freeware co Net-Ping
+ cd Net-Ping
+
+The tarball can be created as follows:
+
+ perl Makefile.PL ; make ; make dist
+
+The latest Net::Ping release can be found at CPAN:
+
+ $CPAN/modules/by-module/Net/
+
+1) Extract the tarball
+
+ gtar -zxvf Net-Ping-xxxx.tar.gz
+ cd Net-Ping-xxxx
+
+2) Build:
+
+ make realclean
+ perl Makefile.PL
+ make
+ make test
+
+3) Install
+
+ make install
+
+Or install it RPM Style:
+
+ rpm -ta SOURCES/Net-Ping-xxxx.tar.gz
+
+ rpm -ih RPMS/noarch/perl-Net-Ping-xxxx.rpm
+
=head1 AUTHORS
Current maintainer:
diff --git a/lib/Net/Ping/Changes b/lib/Net/Ping/Changes
index 6677b527e0..d8dad1625b 100644
--- a/lib/Net/Ping/Changes
+++ b/lib/Net/Ping/Changes
@@ -1,12 +1,24 @@
CHANGES
-------
+2.20 Jun 20 10:00 2002
+ - Perl 5.8.0 compatibility stuff.
+ Spot by dcd@tc.fluke.com (David Dyck).
+ And patch by jhi@iki.fi (Jarkko Hietaniemi).
+ - Move INSTALL doc into perldoc.
+ - Allow source_verify method to work
+ for icmp protocol as well as udp.
+ Spot by taner@taner.net (Taner Halicioglu)
+
2.19 Jun 03 19:00 2002
- - Add $p->udp_source_verify method to skip source
+ - Add $p->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.
+ Spot by dcd@tc.fluke.com (David Dyck)
- Moved files to more standard locations.
+ - Less common martian used for ping test
+ to reduce conflicts
2.18 May 06 12:00 2002
- More RPM spec generalizations.
diff --git a/lib/Net/Ping/README b/lib/Net/Ping/README
index b3665cec6e..2dc4b95280 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.1 2002/06/04 00:41:52 rob Exp $
+ $Id: Ping.pm,v 1.6 2002/06/19 15:23:48 rob Exp $
SYNOPSIS
use Net::Ping;
@@ -102,11 +102,26 @@ DESCRIPTION
otherwise. The maximum number of data bytes that can be specified is
1024.
+ $p->ping($host [, $timeout]);
+ Ping the remote host and wait for a response. $host can be either
+ the hostname or the IP number of the remote host. The optional
+ timeout must be greater than 0 seconds and defaults to whatever was
+ specified when the ping object was created. Returns a success flag.
+ If the hostname cannot be found or there is a problem with the IP
+ number, the success flag returned will be undef. Otherwise, the
+ success flag will be 1 if the host is reachable and 0 if it is not.
+ For most practical purposes, undef and 0 and can be treated as the
+ same case. In array context, the elapsed time is also returned. The
+ elapsed time value will be a float, as retuned by the
+ Time::HiRes::time() function, if hires() has been previously called,
+ otherwise it is returned as an integer.
+
$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.
+ original destination endpoint was sent to. This only affects udp and
+ icmp protocol pings.
This is enabled by default.
@@ -129,20 +144,6 @@ DESCRIPTION
called at all) must be called before the first call to ping() for
that object.
- $p->ping($host [, $timeout]);
- Ping the remote host and wait for a response. $host can be either
- the hostname or the IP number of the remote host. The optional
- timeout must be greater than 0 seconds and defaults to whatever was
- specified when the ping object was created. Returns a success flag.
- If the hostname cannot be found or there is a problem with the IP
- number, the success flag returned will be undef. Otherwise, the
- success flag will be 1 if the host is reachable and 0 if it is not.
- For most practical purposes, undef and 0 and can be treated as the
- same case. In array context, the elapsed time is also returned. The
- elapsed time value will be a float, as retuned by the
- Time::HiRes::time() function, if hires() has been previously called,
- otherwise it is returned as an integer.
-
$p->open($host);
When you are using the stream protocol, this call pre-opens the tcp
socket. It's only necessary to do this if you want to provide a
@@ -200,6 +201,42 @@ NOTES
module to be written which understands all of the different kinds of
ICMP packets.
+INSTALL
+ The latest source tree is available via cvs:
+
+ cvs -z3 -q -d :pserver:anonymous@cvs.roobik.com.:/usr/local/cvsroot/freeware co Net-Ping
+ cd Net-Ping
+
+ The tarball can be created as follows:
+
+ perl Makefile.PL ; make ; make dist
+
+ The latest Net::Ping release can be found at CPAN:
+
+ $CPAN/modules/by-module/Net/
+
+ 1) Extract the tarball
+
+ gtar -zxvf Net-Ping-xxxx.tar.gz
+ cd Net-Ping-xxxx
+
+ 2) Build:
+
+ make realclean
+ perl Makefile.PL
+ make
+ make test
+
+ 3) Install
+
+ make install
+
+ Or install it RPM Style:
+
+ rpm -ta SOURCES/Net-Ping-xxxx.tar.gz
+
+ rpm -ih RPMS/noarch/perl-Net-Ping-xxxx.rpm
+
AUTHORS
Current maintainer:
bbb@cpan.org (Rob Brown)
diff --git a/lib/Net/Ping/t/200_ping_tcp.t b/lib/Net/Ping/t/200_ping_tcp.t
index c417fcb91c..591c25166f 100644
--- a/lib/Net/Ping/t/200_ping_tcp.t
+++ b/lib/Net/Ping/t/200_ping_tcp.t
@@ -51,8 +51,8 @@ ok ($p -> {port_num} = (getservbyname("http", "tcp") || 80));
# Test localhost on the web port
ok $p -> ping("localhost");
-# Hopefully this is not a routeable host
-ok !$p -> ping("10.12.14.16");
+# Hopefully this is never a routeable host
+ok !$p -> ping("172.29.249.249");
# Test a few remote servers
# Hopefully they are up when the tests are run.