Import of LUISMUNOZ/NetAddr-IP-3.32 from CPAN.
gitpan-cpan-distribution: NetAddr-IP
gitpan-cpan-version:      3.32
gitpan-cpan-path:         LUISMUNOZ/NetAddr-IP-3.32.tar.gz
gitpan-cpan-author:       LUISMUNOZ
gitpan-cpan-maturity:     released
1 parent e377f39 commit d2d3dec77abdee813cdada320eb3b82a6586cc10
@Luis Muñoz Luis Muñoz authored on 1 May 2006
Gitpan committed on 21 Oct 2014
Showing 6 changed files
View
53
IP.pm
#!/usr/bin/perl -w
 
# $Id: IP.pm,v 3.28 2005/09/28 23:56:52 lem Exp $
# $Id: IP.pm,v 3.32 2006/05/01 17:11:18 lem Exp $
 
package NetAddr::IP;
 
=pod
our @EXPORT_OK = qw(Compact Coalesce);
 
our @ISA = qw(Exporter);
 
our $VERSION = do { sprintf " %d.%03d", (q$Revision: 3.28 $ =~ /\d+/g) };
our $VERSION = do { sprintf "%d.%02d", (q$Revision: 3.32 $ =~ /\d+/g) };
 
# Set to true, to enable recognizing of 4-octet binary notation IP
# addresses. Thanks to Steve Snodgrass for reporting. This can be done
# at the time of use-ing the module. See docs for details.
for (0 .. 2)
{
return if vec($mask, $_, 8) < vec($mask, $_ + 1, 8);
}
}
elsif ($Accept_Binary_IP
and !$present and length($ip) == 4) {
my @o = unpack("C4", $ip);
 
vec($addr, $_, 8) = $o[$_] for 0 .. 3;
vec($mask, 0, 32) = 0xFFFFFFFF;
}
elsif (lc $ip eq 'default' or lc $ip eq 'any') {
vec($addr, 0, 32) = 0x0;
}
elsif (lc $ip eq 'broadcast') {
vec($addr, 0, 32) = _ones 32;
}
elsif (lc $ip eq 'loopback') {
vec($addr, 0, 8) = 127;
vec($addr, 3, 8) = 1;
}
elsif (($a = gethostbyname($ip)) and defined($a)
and ($a ne pack("C4", 0, 0, 0, 0))) {
if ($a and inet_ntoa($a) =~ m!^(\d+)\.(\d+)\.(\d+)\.(\d+)$!) {
vec($addr, 1, 8) = $2;
vec($addr, 2, 8) = $3;
vec($addr, 3, 8) = $4;
}
}
elsif ($Accept_Binary_IP
and !$present and length($ip) == 4) {
my @o = unpack("C4", $ip);
 
vec($addr, $_, 8) = $o[$_] for 0 .. 3;
vec($mask, 0, 32) = 0xFFFFFFFF;
}
elsif (lc $ip eq 'default' or lc $ip eq 'any') {
vec($addr, 0, 32) = 0x0;
}
elsif (lc $ip eq 'broadcast') {
vec($addr, 0, 32) = _ones 32;
}
elsif (lc $ip eq 'loopback') {
vec($addr, 0, 8) = 127;
vec($addr, 3, 8) = 1;
}
else {
# croak "Cannot obtain an IP address out of $ip";
return;
 
 
=head1 HISTORY
 
$Id: IP.pm,v 3.28 2005/09/28 23:56:52 lem Exp $
$Id: IP.pm,v 3.32 2006/05/01 17:11:18 lem Exp $
 
=over
 
=item 0.01
 
=back
 
$Log: IP.pm,v $
Revision 3.32 2006/05/01 17:11:18 lem
Force update as upload failed
 
Revision 3.31 2006/05/01 16:47:15 lem
Fixed CPAN #16754, version contained a space
 
Revision 3.30 2006/05/01 15:31:19 lem
Moved DNS resolution to the last spot in the chain, before special
keywords, as suggested by Kevin Brintnall - Thanks!
 
Revision 3.29 2005/10/05 18:01:30 lem
Change version digits back to previous levels
 
Revision 3.28 2005/09/28 23:56:52 lem
Each revision will now add the CVS log to the docs automatically.
 
 
View
2
■■■
META.yml
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: NetAddr-IP
version: 3.028
version: 3.32
version_from: IP.pm
installdirs: site
requires:
Math::BigInt: 0
View
README
View
SIGNATURE
View
TODO
View
t/00-load.t