diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-09-11 09:32:02 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-09-11 09:32:02 +0000 |
commit | af96568d82852ae80adb25afa8c0f172586b3b10 (patch) | |
tree | 94e71eb028588fccea4d5ac40ea6e2b98a98c08d /lib/Net | |
parent | 1c7564925f172c80f4f5e495ffe3564f3687bb91 (diff) | |
download | perl-af96568d82852ae80adb25afa8c0f172586b3b10.tar.gz |
Upgrade to Net::Ping 2.33, with help from Jerry Hedden
p4raw-id: //depot/perl@31845
Diffstat (limited to 'lib/Net')
-rw-r--r-- | lib/Net/Ping.pm | 24 | ||||
-rw-r--r-- | lib/Net/Ping/Changes | 15 |
2 files changed, 36 insertions, 3 deletions
diff --git a/lib/Net/Ping.pm b/lib/Net/Ping.pm index fcb127f0c5..64464bb53d 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.32"; +$VERSION = "2.33"; sub SOL_IP { 0; }; sub IP_TOS { 1; }; @@ -481,6 +481,7 @@ sub ping_icmp $self->{"from_type"} = $from_type; $self->{"from_subcode"} = $from_subcode; if (($from_pid == $self->{"pid"}) && # Does the packet check out? + (! $source_verify || (inet_ntoa($from_ip) eq inet_ntoa($ip))) && ($from_seq == $self->{"seq"})) { if ($from_type == ICMP_ECHOREPLY) { $ret = 1; @@ -1369,6 +1370,15 @@ sub close } } +sub port_number { + my $self = shift; + if(@_) { + $self->{port_num} = shift @_; + $self->service_check(1); + } + return $self->{port_num}; +} + 1; __END__ @@ -1398,7 +1408,7 @@ Net::Ping - check a remote host for reachability $p = Net::Ping->new("tcp", 2); # Try connecting to the www port instead of the echo port - $p->{port_num} = getservbyname("http", "tcp"); + $p->port_number(getservbyname("http", "tcp")); while ($stop_time > time()) { print "$host not reachable ", scalar(localtime()), "\n" @@ -1409,7 +1419,7 @@ Net::Ping - check a remote host for reachability # Like tcp protocol, but with many hosts $p = Net::Ping->new("syn"); - $p->{port_num} = getservbyname("http", "tcp"); + $p->port_number(getservbyname("http", "tcp")); foreach $host (@host_array) { $p->ping($host); } @@ -1631,6 +1641,14 @@ connection is also closed by "undef $p". The network connection is automatically closed if the ping object goes out of scope (e.g. $p is local to a subroutine and you leave the subroutine). +=item $p->port_number([$port_number]) + +When called with a port number, the port number used to ping is set to +$port_number rather than using the echo port. It also has the effect +of calling C<$p-E<gt>service_check(1)> causing a ping to return a successful +response only if that specific port is accessible. This function returns +the value of the port that C<ping()> will connect to. + =item pingecho($host [, $timeout]); To provide backward compatibility with the previous version of diff --git a/lib/Net/Ping/Changes b/lib/Net/Ping/Changes index c4885be968..b0e711abfe 100644 --- a/lib/Net/Ping/Changes +++ b/lib/Net/Ping/Changes @@ -1,6 +1,21 @@ CHANGES ------- +2.33 Jul 31 20:15 2007 + - add new method port_number() rather than asking users to + twiddle with the internals of Net::Ping to probe a specific + port. This should resolve a few bugs where the documentation + was lacking. + - apply patch from bergonz at labs.it. This patch resolves + several problems logged regarding using Net::Ping in a multi- + threaded program. Thanks so much! + <http://rt.cpan.org/Ticket/Display.html?id=17408> + +2.32 Jul 30 21:30 2007 + - new co-maintainer Steve Peters + - integrate assorted bleadperl fixes from the past four years + <http://rt.cpan.org/Public/Bug/Display.html?id=28348> + 2.31 Jun 28 14:00 2003 - Win32 Compatibility fixes. Patch by mhx-perl@gmx.net (Marcus Holland-Moritz) |