diff --git a/Changes b/Changes index 357a5b5..b9823d5 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,11 @@ Revision history for Perl extension NetAddr::IP +4.053 Wed Oct 26 08:52:34 PDT 2011 + In Lite.pm v1.36 + fix bug #71925. A a sub-varient of #62521 that showed up only for + short notation for IPv4. i.e. 127/n, 127.0/n, 127.0.0/n but + not 127.0.0.0/n + 4.052 Tue Oct 25 16:18:38 PDT 2011 add test in Lite.pm v1.35 for api-version of Math::BigInt to support versions earlier than 1.70, circa Dec 2003. diff --git a/IP.pm b/IP.pm index ae3a8bf..a42d33b 100644 --- a/IP.pm +++ b/IP.pm @@ -4,8 +4,8 @@ use strict; #use diagnostics; -use NetAddr::IP::Lite 1.32 qw(Zero Zeros Ones V4mask V4net); -use NetAddr::IP::Util 1.41 qw( +use NetAddr::IP::Lite 1.36 qw(Zero Zeros Ones V4mask V4net); +use NetAddr::IP::Util 1.43 qw( sub128 inet_aton inet_any2n @@ -35,7 +35,7 @@ @ISA = qw(Exporter NetAddr::IP::Lite); -$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.52 $ =~ /\d+/g) }; +$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.53 $ =~ /\d+/g) }; =pod diff --git a/Lite/Changes b/Lite/Changes index 148b232..88ba6ca 100644 --- a/Lite/Changes +++ b/Lite/Changes @@ -1,5 +1,10 @@ Revision history for Perl extension NetAddr::IP::Lite +1.36 Wed Oct 26 08:52:34 PDT 2011 + fix bug #71925. A a sub-varient of #62521 that showed up only for + short notation for IPv4. i.e. 127/n, 127.0/n, 127.0.0/n but + not 127.0.0.0/n + 1.35 Tue Oct 25 16:18:38 PDT 2011 add test for api-version of Math::BigInt to support versions earlier than 1.70, circa Dec 2003. diff --git a/Lite/Lite.pm b/Lite/Lite.pm index 2ba073e..2897f38 100644 --- a/Lite/Lite.pm +++ b/Lite/Lite.pm @@ -32,7 +32,7 @@ use vars qw(@ISA @EXPORT_OK $VERSION $Accept_Binary_IP $Old_nth $AUTOLOAD *Zero); -$VERSION = do { my @r = (q$Revision: 1.35 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.36 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; require Exporter; @@ -792,8 +792,7 @@ # check these conditions and set isV6 as appropriate # my $try; - $isV6 = 1 # unconditionally - if # check big bcd and IPv6 rfc1884 + $isV6 = 1 if # check big bcd and IPv6 rfc1884 ( $ip !~ /\D/ && # ip is all decimal (length($ip) > 3 || $ip > 255) && # exclude a single digit in the range of zero to 255, could be funny IPv4 ($try = bcd2bin($ip)) && ! isIPv4($try)) || # precedence so $try is not corrupted @@ -810,7 +809,20 @@ my $isCIDR = length($mask) < 4 && $mask < 129; if ($isV6) { if ($isCIDR) { - if ($ip =~ /^\d+\.\d+\.\d+\.\d+$/) { # corner condition of IPv4 with isV6 + my($dq1,$dq2,$dq3,$dq4); + if ($ip =~ /^(\d+)(?:|\.(\d+)(?:|\.(\d+)(?:|\.(\d+))))$/ && + do {$dq1 = $1; + $dq2 = $2 || 0; + $dq3 = $3 || 0; + $dq4 = $4 || 0; + 1; + } && + $dq1 >= 0 && $dq1 < 256 && + $dq2 >= 0 && $dq2 < 256 && + $dq3 >= 0 && $dq3 < 256 && + $dq4 >= 0 && $dq4 < 256 + ) { # corner condition of IPv4 with isV6 + $ip = join('.',$dq1,$dq2,$dq3,$dq4); $try = ipv4to6(inet_aton($ip)); if ($mask < 32) { $mask = shiftleft(Ones,32 -$mask); @@ -1191,10 +1203,10 @@ } else { require NetAddr::IP::Calc; $biloaded = \&NetAddr::IP::Calc::_new; - $biapi = 1; + $biapi = 99; } } - +print "BIAPI=$biapi\n"; my $biarray = $biapi ? $biloaded->(undef,$_[0]) : $biloaded->(undef,\$_[0]); # versions before 1.70 expect a reference diff --git a/Lite/t/bigint.t b/Lite/t/bigint.t index c07701c..ae4e702 100644 --- a/Lite/t/bigint.t +++ b/Lite/t/bigint.t @@ -8,11 +8,11 @@ use Data::Dumper; BEGIN { - unless ( eval { require Math::BigInt }) { - print "ok 1 # skip all tests, Math::BigInt not found!\n"; + unless ( eval { require Math::BigInt::Calc }) { + print "1..1\n"; + print "ok 1 # skip all tests, Math::BigInt::Calc not found!\n"; exit; } - import Math::BigInt @Math::BigInt::EXPORTS; } # good test results go here diff --git a/Lite/t/bug62521.t b/Lite/t/bug62521.t index c28825b..0fdfc06 100644 --- a/Lite/t/bug62521.t +++ b/Lite/t/bug62521.t @@ -1,5 +1,5 @@ -BEGIN { $| = 1; print "1..2\n"; } +BEGIN { $| = 1; print "1..3\n"; } END {print "not ok 1\n" unless $loaded;} $loaded = 1; @@ -21,3 +21,8 @@ print "exp $exp\ngot ", $ip, "\nnot " unless $ip eq $exp; &ok; + +$ip = new6 NetAddr::IP::Lite('127/8'); +print "exp $exp\ngot ", $ip, "\nnot " + unless $ip eq $exp; +&ok; diff --git a/MANIFEST b/MANIFEST index 53634d5..6f5c5c0 100644 --- a/MANIFEST +++ b/MANIFEST @@ -6,7 +6,6 @@ MANIFEST.SKIP META.yml Module meta-data (added by MakeMaker) Makefile.PL -README TODO docs/rfc1884.txt t/constants.t diff --git a/Makefile.PL b/Makefile.PL index 76baad9..cb0d83c 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -40,43 +40,6 @@ sleep $view if $view; } -eval q{ use Test::Pod; - $check0 = 1; }; - -unless ($check0) -{ - print <broadcast; - $ip ++) - { - print "$ip\n"; - } - -This will print out something like... - -10.0.0.1/28 -10.0.0.2/28 -10.0.0.3/28 -10.0.0.4/28 -10.0.0.5/28 -(and so on...) - -...which is quite useful for generating config files and the -such. This works even for huge ranges of IP addresses. - -This module can be installed without compiling any XS code, although -some parts are available as XS for speed. It has been extensively -tested in a variety of platforms. An extensive test suite is provided -with the module to verify correct results. - -The lastest version of this module should be preferred. You can obtain -it on the nearest CPAN mirror. Please find a mirror near you to help -spread the load. - -Version 4 works with earlier versions of perl at least back to 5.00503 -however overloaded iterative arrays and binary bit strings 0b101010101 -are not supported in versions of perl prior to 5.6.0. - -To use the old behavior for ->nth($index) and ->num(): - - use NetAddr::IP::Lite qw(:old_nth); - - old behavior: - NetAddr::IP->new('10/32')->nth(0) == undef - NetAddr::IP->new('10/32')->nth(1) == undef - NetAddr::IP->new('10/31')->nth(0) == undef - NetAddr::IP->new('10/31')->nth(1) == 10.0.0.1/31 - NetAddr::IP->new('10/30')->nth(0) == undef - NetAddr::IP->new('10/30')->nth(1) == 10.0.0.1/30 - NetAddr::IP->new('10/30')->nth(2) == 10.0.0.2/30 - NetAddr::IP->new('10/30')->nth(3) == 10.0.0.3/30 - -Note that in each case, the broadcast address is represented in the -output set and that the 'zero'th index is alway undef. - - 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) == undef - NetAddr::IP->new('10/31')->nth(1) == undef - 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 - -Note that a /32 net always has 1 usable address while a /31 has none -since it has a network and broadcast address, but no host -addresses. The first index (0) returns the address immediately -following the network address. - -To install, follow the standard CPAN recipe of: - -$ perl Makefile.PL -$ make -$ make test - -If all tests pass, then do - -$ make install - -NetAddr::IP depends on NetAddr::IP::Util which utilizes perl_xs. If -you do not have a C compiler on your system or you would prefer the -slower PURE PERL version for some obtuse reason then build as follows: - -$ perl Makefile.PL -noxs -$ make -$ make test - -$ make install - -Tests related to address compaction could be too resource-intensive in -some environments. If this is your case, you can skip those tests by -setting an environment variable before make'ing test. In a bash-like -shell, you could use the following example: - -$ LIGHTERIPTESTS=yes; export LIGHTERIPTESTS -$ make test - -The module's documentation can be accessed through POD. After -installing the module, you can do - -$ perldoc NetAddr::IP -$ perldoc NetAddr::IP::Lite -$ perldoc NetAddr::IP::Util -$ perldoc NetAddr::IP::UtilPP - -to access the documentation. There is also a tutorial in HTML at the -following URIs - - http://mipagina.cantv.net/lem/perl/iptut.htm - http://mipagina.cantv.net/lem/perl/ipperf.htm - -If you want to thank me for this module, please go look at those -tutorials and if you see banners there, click on a few :) - -Bug reports are welcome. Please do not forget to tell me what -version/platform are you running this code on. Providing a small piece -of code that shows the bug helps me a lot in sorting it out and -possibly in writting more tests for the distribution. - -Also, this code is intended to be strict and -w safe, so please report -cases where warnings are generated so that I can fix them. - -Report your bugs to me (luismunoz@cpan.org) or through the CPAN RT -interface at http://rt.cpan.org/. - -DO YOU WANT TO THANK ME? - -If you consider this a valuable contribution, there is a web page -where you can express your gratitude. Please see - - http://mipagina.cantv.net/lem/thanks-en.html (English) - http://mipagina.cantv.net/lem/thanks-es.html (Spanish) - -SECURITY CONSIDERATIONS - -I have no control on the machanisms involved in the storage or -transport of this distribution. This means that I cannot guarantee -that the distribution you have in your hands is indeed, the same -distribution I packed and uploaded. - -Starting with v3.14_1, along the distribution file, you should have a -file with the extension ".asc". This contains a GPG "detached -signature" that makes it impossible for anybody to alter this -distribution. If security is of any concern to you, by all means -verify the signature of this file and contact the author if any -discrepancy is detected. - -You can find more information about this at the following URL - - http://mipagina.cantv.net/lem/gpg/ - -This information includes the correct keys, fingerprints, etc.Note -that this README file should also be signed. - -Additionally, I am also using Module::Signature to ease with the -signature verification. Module::Signature can automatically retrieve -the PGP keys from public keyservers, as well as verifying each -individual file. - -LICENSE AND WARRANTY - -This software is (c) Luis E. Mu�oz and Michael A. Robinton. It can be -used under the terms of the perl artistic license provided that proper -credit for the work of the authors is preserved in the form of this -copyright notice and license for this module. - -No warranty of any kind is expressed or implied. This code might make -your computer go up in a puff of black smoke. - ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.2.1 (Darwin) - -iD8DBQFE4KXRQyDWGRI/hhARAqjSAJ4/MnV9e01zLfrIJ1CtfwfaJiKUDwCePdhb -djsPkRD3CRKuxz5d+9oX9zc= -=srrF ------END PGP SIGNATURE-----