@@ -1,5 +1,20 @@
Revision history for Perl extension NetAddr::IP
+4.073 Sat Apr 5 09:32:11 PDT 2014
+ add documentation about FQDN conversion and
+ an option to disable
+
+4.072 Mon Jan 27 11:59:58 PST 2014
+ modify Makefile.PL to bypass missing 'pod2text'
+
+4.071 Mon Sep 30 13:41:03 PDT 2013
+ add method "canon" by request from <tom.jones@bccx.com>
+
+4.070 Thu Sep 12 12:54:22 PDT 2013
+ nth documention error fixed. thanks to Anton tobez@tobez.org
+
+ Lite v1.51, add new6FFFF, RFC4291 compliant ipv4->ipV6 new
+
4.069 Sat May 25 15:10:45 PDT 2013
IN Lite.pm v1.50, add =encoding UTF-8
In Util.pm v1.50
@@ -5,8 +5,8 @@ package NetAddr::IP;
use strict;
#use diagnostics;
use Carp;
-use NetAddr::IP::Lite 1.48 qw(Zero Zeros Ones V4mask V4net);
-use NetAddr::IP::Util 1.49 qw(
+use NetAddr::IP::Lite 1.51 qw(Zero Zeros Ones V4mask V4net);
+use NetAddr::IP::Util 1.50 qw(
sub128
inet_aton
inet_any2n
@@ -37,7 +37,7 @@ require Exporter;
@ISA = qw(Exporter NetAddr::IP::Lite);
-$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.69 $ =~ /\d+/g) };
+$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.73 $ =~ /\d+/g) };
$rfc3021 = 0;
@@ -65,6 +65,7 @@ NetAddr::IP - Manages IPv4 and IPv6 addresses and subnets
:old_storable
:old_nth
:rfc3021
+ :nofqdn
);
NOTE: NetAddr::IP::Util has a full complement of network address
@@ -101,6 +102,8 @@ See L<NetAddr::IP::Util>
FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:: = V4mask();
::FFFF:FFFF = V4net();
+ Will also return an ipV4 or ipV6 representation of a
+ resolvable Fully Qualified Domanin Name (FQDN).
###### DEPRECATED, will be remove in version 5 ############
@@ -614,6 +617,12 @@ Any RFC1884 notation
123456789012 a 'big' bcd number (bigger than perl likes)
and Math::BigInt
+A Fully Qualified Domain Name which returns an ipV4 address or an ipV6
+address, embodied in that order. This previously undocumented feature
+may be disabled with:
+
+ use NetAddr::IP::Lite ':nofqdn';
+
If called with no arguments, 'default' is assumed.
If called with an empty string as the argument, returns 'undef'
@@ -848,6 +857,20 @@ sub short($) {
return _compV6($addr);
}
+=item C<-E<gt>canon()>
+
+Returns the address part in canonical notation as a string. For
+ipV4, this is dotted quad, and is the same as the return value from
+"->addr()". For ipV6 it is as per RFC5952, and is the same as the LOWER CASE value
+returned by "->short()".
+
+=cut
+
+sub canon($) {
+ my $addr = $_[0]->addr;
+ return $_[0]->{isv6} ? lc _compV6($addr) : $addr;
+}
+
=item C<-E<gt>full()>
Returns the address part in FULL notation for
@@ -1322,8 +1345,8 @@ addresses in the network.
new behavior:
NetAddr::IP->new('10/32')->nth(0) == 10.0.0.0/32
NetAddr::IP->new('10.1/32'->nth(0) == 10.0.0.1/32
- NetAddr::IP->new('10/31')->nth(0) == 10.0.0.0/32
- NetAddr::IP->new('10/31')->nth(1) == 10.0.0.1/32
+ NetAddr::IP->new('10/31')->nth(0) == 10.0.0.0/31
+ NetAddr::IP->new('10/31')->nth(1) == 10.0.0.1/31
NetAddr::IP->new('10/30')->nth(0) == 10.0.0.1/30
NetAddr::IP->new('10/30')->nth(1) == 10.0.0.2/30
NetAddr::IP->new('10/30')->nth(2) == undef
@@ -1567,7 +1590,7 @@ so by using it you accept any and all the liability.
=head1 COPYRIGHT
This software is (c) Luis E. Muñoz, 1999 - 2007, and (c) Michael
-Robinton, 2006 - 2012.
+Robinton, 2006 - 2014.
All rights reserved.
@@ -1,5 +1,15 @@
Revision history for Perl extension NetAddr::IP::Lite
+1.53 Sat Apr 5 09:32:11 PDT 2014
+ add documentation about FQDN conversion and
+ an option to disable
+
+1.52 Mon Jan 27 11:59:58 PST 2014
+ modify Makefile.PL to bypass missing 'pod2text'
+
+1.51 Thu Sep 12 12:54:22 PDT 2013
+ add new6FFFF, RFC4291 compliant ipv4->ipV6 new
+
1.50 Sat May 25 15:10:45 PDT 2013
add =encoding UTF-8
@@ -30,9 +30,9 @@ use NetAddr::IP::Util qw(
havegethostbyname2
);
-use vars qw(@ISA @EXPORT_OK $VERSION $Accept_Binary_IP $Old_nth $AUTOLOAD *Zero);
+use vars qw(@ISA @EXPORT_OK $VERSION $Accept_Binary_IP $Old_nth $NoFQDN $AUTOLOAD *Zero);
-$VERSION = do { my @r = (q$Revision: 1.50 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+$VERSION = do { my @r = (q$Revision: 1.53 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
require Exporter;
@@ -67,6 +67,7 @@ NetAddr::IP::Lite - Manages IPv4 and IPv6 addresses and subnets
:old_nth
:upper
:lower
+ :nofqdn
);
my $ip = new NetAddr::IP::Lite '127.0.0.1';
@@ -93,6 +94,9 @@ NetAddr::IP::Lite - Manages IPv4 and IPv6 addresses and subnets
FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:: = V4mask();
::FFFF:FFFF = V4net();
+ Will also return an ipV4 or ipV6 representation of a
+ resolvable Fully Qualified Domanin Name (FQDN).
+
=head1 INSTALLATION
Un-tar the distribution in an appropriate directory and type:
@@ -199,6 +203,7 @@ my $_zero = pack('L4',0,0,0,0);
my $_ones = ~$_zero;
my $_v4mask = pack('L4',0xffffffff,0xffffffff,0xffffffff,0);
my $_v4net = ~ $_v4mask;
+my $_ipv4FFFF = pack('N4',0,0,0xffff,0);
sub Zeros() {
return $_zero;
@@ -508,6 +513,8 @@ sub _new ($$$) {
=item C<-E<gt>new6([$addr, [ $mask]])>
+=item C<-E<gt>new6FFFF([$addr, [ $mask]])>
+
=item C<-E<gt>new_no([$addr, [ $mask]])>
=item C<-E<gt>new_from_aton($netaddr)>
@@ -518,9 +525,14 @@ sub _new ($$$) {
=item C<-E<gt>new_cis6("$addr $mask)>
-The first two methods create a new address with the supplied address in
+The first three methods create a new address with the supplied address in
C<$addr> and an optional netmask C<$mask>, which can be omitted to get
-a /32 or /128 netmask for IPv4 / IPv6 addresses respectively.
+a /32 or /128 netmask for IPv4 / IPv6 addresses respectively.
+
+new6FFFF specifically returns an IPv4 address in IPv6 format according to RFC4291
+
+ new6 ::xxxx:xxxx
+ new6FFFF ::FFFF:xxxx:xxxx
The third method C<new_no> is exclusively for IPv4 addresses and filters
improperly formatted
@@ -616,6 +628,12 @@ Any RFC1884 notation
123456789012 a 'big' bcd number (bigger than perl likes)
and Math::BigInt
+A Fully Qualified Domain Name which returns an ipV4 address or an ipV6
+address, embodied in that order. This previously undocumented feature
+may be disabled with:
+
+ use NetAddr::IP::Lite ':nofqdn';
+
If called with no arguments, 'default' is assumed.
If called with and empty string as the argument, 'undef' is returned;
@@ -703,6 +721,12 @@ sub new6($;$$) {
goto &_xnew;
}
+sub new6FFFF($;$$) {
+ my $ip = _xnew(1,@_);
+ $ip->{addr} |= $_ipv4FFFF;
+ return $ip;
+}
+
sub new_cis($;$$) {
my @in = @_;
if ( $in[1] && $in[1] =~ m!^(.+)\s+(.+)$! ) {
@@ -988,12 +1012,12 @@ sub _xnew($$;$$) {
last;
}
# check for resolvable IPv4 hosts
- elsif ($ip !~ /[^a-zA-Z0-9\.-]/ && ($tmp = gethostbyname(fillIPv4($ip))) && $tmp ne $_v4zero && $tmp ne $_zero ) {
+ elsif (! $NoFQDN && $ip !~ /[^a-zA-Z0-9\.-]/ && ($tmp = gethostbyname(fillIPv4($ip))) && $tmp ne $_v4zero && $tmp ne $_zero ) {
$ip = ipv4to6($tmp);
last;
}
# check for resolvable IPv6 hosts
- elsif ($ip !~ /[^a-zA-Z0-9\.-]/ && havegethostbyname2() && ($tmp = naip_gethostbyname($ip))) {
+ elsif (! $NoFQDN && $ip !~ /[^a-zA-Z0-9\.-]/ && havegethostbyname2() && ($tmp = naip_gethostbyname($ip))) {
$ip = $tmp;
$isV6 = 1;
last;
@@ -1559,6 +1583,11 @@ sub import {
NetAddr::IP::Util::upper();
@_ = grep { $_ ne ':upper' } @_;
}
+ if (grep { $_ eq ':nofqdn' } @_)
+ {
+ $NoFQDN = 1;
+ @_ = grep { $_ ne ':nofqdn' } @_;
+ }
NetAddr::IP::Lite->export_to_level(1, @_);
}
@@ -1572,6 +1601,7 @@ sub import {
:old_nth
:upper
:lower
+ :nofqdn
=head1 AUTHORS
@@ -1586,7 +1616,7 @@ so by using it you accept any and all the liability.
=head1 COPYRIGHT
This software is (c) Luis E. Muñoz, 1999 - 2005
- and (c) Michael Robinton, 2006 - 2012.
+ and (c) Michael Robinton, 2006 - 2014.
All rights reserved.
@@ -19,6 +19,7 @@ t/constants.t
t/contains.t
t/copy.t
t/firstlast.t
+t/ipv4FFFF.t
t/lemasklen.t
t/loops.t
t/lower.t
@@ -28,6 +29,7 @@ t/netaddr.t
t/network.t
t/new-nth.t
t/new-num.t
+t/nofqdn.t
t/numeric.t
t/old-nth.t
t/old-num.t
@@ -25,9 +25,15 @@ sub MY::top_targets {
}
sub MY::post_constants {
- my $post_constants = q|
-MY_POD2TEXT = |. $Config{scriptdirexp} .'/pod2text' .q|
+ my $post_constants = $Config{scriptdirexp} .'/pod2text';
+ if (-e $post_constants) {
+ $post_constants = q|
+MY_POD2TEXT = |. $post_constants .q|
|;
+ } else {
+ $post_constants = q|
+MY_POD2TEXT = echo "perl distro missing 'pod2text' to convert " |;
+ }
}
sub MY::postamble {
@@ -11,6 +11,7 @@ SYNOPSIS
:old_nth
:upper
:lower
+ :nofqdn
);
my $ip = new NetAddr::IP::Lite '127.0.0.1';
@@ -37,6 +38,9 @@ SYNOPSIS
FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:: = V4mask();
::FFFF:FFFF = V4net();
+ Will also return an ipV4 or ipV6 representation of a
+ resolvable Fully Qualified Domanin Name (FQDN).
+
INSTALLATION
Un-tar the distribution in an appropriate directory and type:
@@ -187,14 +191,22 @@ DESCRIPTION
"->new([$addr, [ $mask|IPv6 ]])"
"->new6([$addr, [ $mask]])"
+ "->new6FFFF([$addr, [ $mask]])"
"->new_no([$addr, [ $mask]])"
"->new_from_aton($netaddr)"
new_cis and new_cis6 are DEPRECATED
"->new_cis("$addr $mask)"
"->new_cis6("$addr $mask)"
- The first two methods create a new address with the supplied address
- in "$addr" and an optional netmask "$mask", which can be omitted to
- get a /32 or /128 netmask for IPv4 / IPv6 addresses respectively.
+ The first three methods create a new address with the supplied
+ address in "$addr" and an optional netmask "$mask", which can be
+ omitted to get a /32 or /128 netmask for IPv4 / IPv6 addresses
+ respectively.
+
+ new6FFFF specifically returns an IPv4 address in IPv6 format
+ according to RFC4291
+
+ new6 ::xxxx:xxxx
+ new6FFFF ::FFFF:xxxx:xxxx
The third method "new_no" is exclusively for IPv4 addresses and
filters improperly formatted dot quad strings for leading 0's that
@@ -289,6 +301,12 @@ DESCRIPTION
123456789012 a 'big' bcd number (bigger than perl likes)
and Math::BigInt
+ A Fully Qualified Domain Name which returns an ipV4 address or an
+ ipV6 address, embodied in that order. This previously undocumented
+ feature may be disabled with:
+
+ use NetAddr::IP::Lite ':nofqdn';
+
If called with no arguments, 'default' is assumed.
If called with and empty string as the argument, 'undef' is
@@ -472,6 +490,7 @@ EXPORT_OK
:old_nth
:upper
:lower
+ :nofqdn
AUTHORS
Luis E. Muñoz <luismunoz@cpan.org>, Michael Robinton
@@ -483,7 +502,7 @@ WARRANTY
COPYRIGHT
This software is (c) Luis E. Muñoz, 1999 - 2005
- and (c) Michael Robinton, 2006 - 2012.
+ and (c) Michael Robinton, 2006 - 2014.
All rights reserved.
@@ -1,4 +1,7 @@
+1.51 Mon Jan 27 11:59:58 PST 2014
+ modify Makefile.PL to bypass missing 'pod2text'
+
1.50 Tue Apr 9 12:02:34 PDT 2013
changed Makefile.PL to check for config.h when building for XS
with 'gcc', try building with 'cc', and check again.
@@ -233,9 +233,15 @@ sub MY::top_targets {
}
sub MY::post_constants {
- my $post_constants = q|
-MY_POD2TEXT = |. $Config{scriptdirexp} .'/pod2text' .q|
+ my $post_constants = $Config{scriptdirexp} .'/pod2text';
+ if (-e $post_constants) {
+ $post_constants = q|
+MY_POD2TEXT = |. $post_constants .q|
|;
+ } else {
+ $post_constants = q|
+MY_POD2TEXT = echo "perl distro missing 'pod2text' to convert " |;
+ }
}
sub MY::postamble {
@@ -563,7 +563,7 @@ AUTHOR
Michael Robinton <michael@bizsystems.com>
COPYRIGHT
- Copyright 2003 - 2013, Michael Robinton <michael@bizsystems.com>
+ Copyright 2003 - 2014, Michael Robinton <michael@bizsystems.com>
All rights reserved.
@@ -21,7 +21,7 @@ require Exporter;
@ISA = qw(Exporter DynaLoader);
-$VERSION = do { my @r = (q$Revision: 1.50 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+$VERSION = do { my @r = (q$Revision: 1.51 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
@EXPORT_OK = qw(
inet_aton
@@ -922,7 +922,7 @@ Michael Robinton <michael@bizsystems.com>
=head1 COPYRIGHT
-Copyright 2003 - 2013, Michael Robinton E<lt>michael@bizsystems.comE<gt>
+Copyright 2003 - 2014, Michael Robinton E<lt>michael@bizsystems.comE<gt>
All rights reserved.
@@ -0,0 +1,18 @@
+
+#use diagnostics;
+use NetAddr::IP::Lite;
+
+$| = 1;
+
+print "1..1\n";
+
+my $test = 1;
+sub ok() {
+ print 'ok ',$test++,"\n";
+}
+
+my $ip = new6FFFF NetAddr::IP::Lite('127.0.0.1');
+my $exp = '0:0:0:0:0:FFFF:7F00:1/128';
+print "got: $ip\nexp: $exp\nnot "
+ unless "$ip" eq $exp;
+&ok;
@@ -0,0 +1,29 @@
+
+
+use NetAddr::IP::Lite
+
+$| = 1;
+
+print "1..2\n";
+
+my $test = 1;
+sub ok() {
+ print 'ok ',$test++,"\n";
+}
+
+
+my $ip = new NetAddr::IP::Lite('arin.net');
+if (defined $ip) {
+ print "ok $test # Skipped, resolved $ip\n";
+ $test++;
+} else {
+ print "ok $test # Skipped, resolver not working\n";
+ $test++;
+}
+
+import NetAddr::IP::Lite qw(:nofqdn);
+
+$ip = new NetAddr::IP::Lite('arin.net');
+print "unexpected response with :nofqdn\nnot "
+ if defined $ip;
+&ok;
@@ -8,6 +8,7 @@ MANIFEST.SKIP
Makefile.PL
TODO
docs/rfc1884.txt
+t/canon.t
t/constants.t
t/full.t
t/full6.t
@@ -59,6 +60,7 @@ Lite/t/constants.t
Lite/t/contains.t
Lite/t/copy.t
Lite/t/firstlast.t
+Lite/t/ipv4FFFF.t
Lite/t/lemasklen.t
Lite/t/loops.t
Lite/t/lower.t
@@ -68,6 +70,7 @@ Lite/t/netaddr.t
Lite/t/network.t
Lite/t/new-nth.t
Lite/t/new-num.t
+Lite/t/nofqdn.t
Lite/t/numeric.t
Lite/t/old-nth.t
Lite/t/old-num.t
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: NetAddr-IP
-version: 4.069
+version: 4.073
abstract: Manages IPv4 and IPv6 addresses and subnets
license: ~
author:
@@ -0,0 +1,23 @@
+use Test::More;
+
+my %cases =
+(
+ '127.1' => '127.0.0.1',
+ 'DEAD:BEEF::1' => 'dead:beef::1',
+
+ '1234:5678:90AB:CDEF:0123:4567:890A:BCDE'
+ => '1234:5678:90ab:cdef:123:4567:890a:bcde',
+);
+
+my $tests = keys %cases;
+plan tests => 1 + $tests;
+
+SKIP: {
+ use_ok('NetAddr::IP') or skip "Failed to load NetAddr::IP", $tests;
+ for my $c (sort keys %cases)
+ {
+ my $ip = new NetAddr::IP $c;
+ my $rv = $ip->canon;
+ is($rv, $cases{$c}, "canon($c ) returns $rv");
+ }
+}