r70969 - in /branches/upstream/libnetaddr-ip-perl/current: Changes IP.pm Lite/Changes Lite/Lite.pm Lite/README Lite/t/v6-num.t MANIFEST META.yml
periapt-guest at users.alioth.debian.org
periapt-guest at users.alioth.debian.org
Wed Mar 9 16:17:14 UTC 2011
Author: periapt-guest
Date: Wed Mar 9 16:17:03 2011
New Revision: 70969
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=70969
Log:
[svn-upgrade] new version libnetaddr-ip-perl (4.041+dfsg)
Added:
branches/upstream/libnetaddr-ip-perl/current/Lite/t/v6-num.t
Modified:
branches/upstream/libnetaddr-ip-perl/current/Changes
branches/upstream/libnetaddr-ip-perl/current/IP.pm
branches/upstream/libnetaddr-ip-perl/current/Lite/Changes
branches/upstream/libnetaddr-ip-perl/current/Lite/Lite.pm
branches/upstream/libnetaddr-ip-perl/current/Lite/README
branches/upstream/libnetaddr-ip-perl/current/MANIFEST
branches/upstream/libnetaddr-ip-perl/current/META.yml
Modified: branches/upstream/libnetaddr-ip-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnetaddr-ip-perl/current/Changes?rev=70969&op=diff
==============================================================================
--- branches/upstream/libnetaddr-ip-perl/current/Changes (original)
+++ branches/upstream/libnetaddr-ip-perl/current/Changes Wed Mar 9 16:17:03 2011
@@ -1,4 +1,10 @@
Revision history for Perl extension NetAddr::IP
+
+4.041 Tue Mar 8 15:18:16 PST 2011
+ Updated Lite.pm v1.26, "sub num" to support usable IP ranges
+ greater than 2**32
+
+ Thanks to Jan Ploski jan at plosquare.com for finding this bug
4.040 Sat Feb 19 10:04:00 PST 2011
correction to use of Util.pm package lexicals
Modified: branches/upstream/libnetaddr-ip-perl/current/IP.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnetaddr-ip-perl/current/IP.pm?rev=70969&op=diff
==============================================================================
--- branches/upstream/libnetaddr-ip-perl/current/IP.pm (original)
+++ branches/upstream/libnetaddr-ip-perl/current/IP.pm Wed Mar 9 16:17:03 2011
@@ -4,7 +4,7 @@
use strict;
#use diagnostics;
-use NetAddr::IP::Lite 1.25 qw(Zero Zeros Ones V4mask V4net);
+use NetAddr::IP::Lite 1.26 qw(Zero Zeros Ones V4mask V4net);
use NetAddr::IP::Util 1.36 qw(
sub128
inet_aton
@@ -34,7 +34,7 @@
@ISA = qw(Exporter NetAddr::IP::Lite);
-$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.40 $ =~ /\d+/g) };
+$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.41 $ =~ /\d+/g) };
=pod
@@ -1237,13 +1237,31 @@
=item C<-E<gt>num()>
Version 4.00 of NetAddr::IP and version 1.00 of NetAddr::IP::Lite
-Returns the number of usable addresses IP addresses within the
-subnet, not counting the broadcast or network address. Previous versions
-returned th number of IP addresses not counting the broadcast address.
+return the number of usable IP addresses within the subnet,
+not counting the broadcast or network address.
+
+Previous versions worked only for ipV4 addresses, returned a
+maximum span of 2**32 and returned the number of IP addresses
+not counting the broadcast address.
+ (one greater than the new behavior)
To use the old behavior for C<-E<gt>nth($index)> and C<-E<gt>num()>:
use NetAddr::IP::Lite qw(:old_nth);
+
+WARNING:
+
+NetAddr::IP will calculate and return a numeric string for network
+ranges as large as 2**128. These values are TEXT strings and perl
+can treat them as integers for numeric calculations.
+
+Perl on 32 bit platforms only handles integer numbers up to 2**32
+and on 64 bit platforms to 2**64.
+
+If you wish to manipulate numeric strings returned by NetAddr::IP
+that are larger than 2**32 or 2**64, respectively, you must load
+additional modules such as Math::BigInt, bignum or some similar
+package to do the integer math.
=item C<-E<gt>re()>
Modified: branches/upstream/libnetaddr-ip-perl/current/Lite/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnetaddr-ip-perl/current/Lite/Changes?rev=70969&op=diff
==============================================================================
--- branches/upstream/libnetaddr-ip-perl/current/Lite/Changes (original)
+++ branches/upstream/libnetaddr-ip-perl/current/Lite/Changes Wed Mar 9 16:17:03 2011
@@ -1,4 +1,9 @@
Revision history for Perl extension NetAddr::IP::Lite
+
+1.26 Tue Mar 8 15:18:16 PST 2011
+ Updated "sub num" to support usable IP ranges greater than 2**32
+
+ Thanks to Jan Ploski jan at plosquare.com for finding this bug
1.25 Sat Feb 19 10:04:00 PST 2011
correction to use of Util.pm package lexicals
Modified: branches/upstream/libnetaddr-ip-perl/current/Lite/Lite.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnetaddr-ip-perl/current/Lite/Lite.pm?rev=70969&op=diff
==============================================================================
--- branches/upstream/libnetaddr-ip-perl/current/Lite/Lite.pm (original)
+++ branches/upstream/libnetaddr-ip-perl/current/Lite/Lite.pm Wed Mar 9 16:17:03 2011
@@ -29,7 +29,7 @@
use vars qw(@ISA @EXPORT_OK $VERSION $Accept_Binary_IP $Old_nth $AUTOLOAD *Zero);
-$VERSION = do { my @r = (q$Revision: 1.25 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+$VERSION = do { my @r = (q$Revision: 1.26 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
require Exporter;
@@ -1210,30 +1210,64 @@
=item C<-E<gt>num()>
Version 4.00 of NetAddr::IP and version 1.00 of NetAddr::IP::Lite
-Returns the number of usable addresses IP addresses within the
-subnet, not counting the broadcast or network address. Previous versions
-returned th number of IP addresses not counting the broadcast address.
+return the number of usable IP addresses within the subnet,
+not counting the broadcast or network address.
+
+Previous versions worked only for ipV4 addresses, returned a
+maximum span of 2**32 and returned the number of IP addresses
+not counting the broadcast address.
+ (one greater than the new behavior)
To use the old behavior for C<-E<gt>nth($index)> and C<-E<gt>num()>:
use NetAddr::IP::Lite qw(:old_nth);
+WARNING:
+
+NetAddr::IP will calculate and return a numeric string for network
+ranges as large as 2**128. These values are TEXT strings and perl
+can treat them as integers for numeric calculations.
+
+Perl on 32 bit platforms only handles integer numbers up to 2**32
+and on 64 bit platforms to 2**64.
+
+If you wish to manipulate numeric strings returned by NetAddr::IP
+that are larger than 2**32 or 2**64, respectively, you must load
+additional modules such as Math::BigInt, bignum or some similar
+package to do the integer math.
+
=cut
sub num ($) {
- my @net = unpack('L3N',$_[0]->{mask} ^ Ones);
if ($Old_nth) {
+ my @net = unpack('L3N',$_[0]->{mask} ^ Ones);
# number of ip's less broadcast
return 0xfffffffe if $net[0] || $net[1] || $net[2]; # 2**32 -1
return $net[3] if $net[3];
} else { # returns 1 for /32 /128, 0 for /31 /127 else n-2 up to 2**32
-# number of usable IP's === number of ip's less broadcast & network addys
- return 0xfffffffd if $net[0] || $net[1] || $net[2]; # 2**32 -2
- return 1 unless $net[3];
- $net[3]--;
+ (undef, my $net) = addconst($_[0]->{mask},1);
+ return 1 unless hasbits($net); # ipV4/32 or ipV6/128
+ $net = $net ^ Ones;
+ return 0 unless hasbits($net); # ipV4/31 or ipV6/127
+ return bin2bcd($net);
}
- return $net[3];
-}
+}
+
+# deprecated
+#sub num ($) {
+# my @net = unpack('L3N',$_[0]->{mask} ^ Ones);
+# if ($Old_nth) {
+## number of ip's less broadcast
+# return 0xfffffffe if $net[0] || $net[1] || $net[2]; # 2**32 -1
+# return $net[3] if $net[3];
+# } else { # returns 1 for /32 /128, 0 for /31 /127 else n-2 up to 2**32
+## number of usable IP's === number of ip's less broadcast & network addys
+# return 0xfffffffd if $net[0] || $net[1] || $net[2]; # 2**32 -2
+# return 1 unless $net[3];
+# $net[3]--;
+# }
+# return $net[3];
+#}
=pod
Modified: branches/upstream/libnetaddr-ip-perl/current/Lite/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnetaddr-ip-perl/current/Lite/README?rev=70969&op=diff
==============================================================================
--- branches/upstream/libnetaddr-ip-perl/current/Lite/README (original)
+++ branches/upstream/libnetaddr-ip-perl/current/Lite/README Wed Mar 9 16:17:03 2011
@@ -409,14 +409,30 @@
"->num()"
Version 4.00 of NetAddr::IP and version 1.00 of NetAddr::IP::Lite
- Returns the number of usable addresses IP addresses within the
- subnet, not counting the broadcast or network address. Previous
- versions returned th number of IP addresses not counting the
- broadcast address.
+ return the number of usable IP addresses within the subnet, not
+ counting the broadcast or network address.
+
+ Previous versions worked only for ipV4 addresses, returned a maximum
+ span of 2**32 and returned the number of IP addresses not counting
+ the broadcast address. (one greater than the new behavior)
To use the old behavior for "->nth($index)" and "->num()":
use NetAddr::IP::Lite qw(:old_nth);
+
+ WARNING:
+
+ NetAddr::IP will calculate and return a numeric string for network
+ ranges as large as 2**128. These values are TEXT strings and perl
+ can treat them as integers for numeric calculations.
+
+ Perl on 32 bit platforms only handles integer numbers up to 2**32
+ and on 64 bit platforms to 2**64.
+
+ If you wish to manipulate numeric strings returned by NetAddr::IP
+ that are larger than 2**32 or 2**64, respectively, you must load
+ additional modules such as Math::BigInt, bignum or some similar
+ package to do the integer math.
EXPORT_OK
Zeros
Added: branches/upstream/libnetaddr-ip-perl/current/Lite/t/v6-num.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnetaddr-ip-perl/current/Lite/t/v6-num.t?rev=70969&op=file
==============================================================================
--- branches/upstream/libnetaddr-ip-perl/current/Lite/t/v6-num.t (added)
+++ branches/upstream/libnetaddr-ip-perl/current/Lite/t/v6-num.t Wed Mar 9 16:17:03 2011
@@ -1,0 +1,55 @@
+use NetAddr::IP::Lite;
+
+my $nets = {
+ 'F0::' => [ 128, '1' ],
+ 'F1::' => [ 127, '0' ],
+ 'F2::' => [ 126, '2' ],
+ 'F3::' => [ 125, '6' ],
+ 'F4::' => [ 124, '14' ],
+ 'F5::' => [ 123, '30' ],
+ 'F6::' => [ 122, '62' ],
+ 'F7::' => [ 100, '268435454' ],
+ 'F8::' => [ 99, '536870910' ],
+ 'F9::' => [ 98, '1073741822' ],
+ 'FA::' => [ 97, '2147483646' ],
+ 'FB::' => [ 96, '4294967294' ],
+ 'FC::' => [ 95, '8589934590' ],
+ 'FD::' => [ 94, '17179869182' ],
+ 'FE::' => [ 93, '34359738366' ],
+ 'FF::' => [ 92, '68719476734' ],
+ 'F10::' => [ 64, '18446744073709551614' ],
+ 'F20::' => [ 32, '79228162514264337593543950334' ],
+ 'F30::' => [ 16, '5192296858534827628530496329220094' ],
+ 'F40::' => [ 8, '1329227995784915872903807060280344574' ],
+ 'F50::' => [ 4, '21267647932558653966460912964485513214' ],
+ 'F60::' => [ 2, '85070591730234615865843651857942052862' ],
+ 'F70::' => [ 1, '170141183460469231731687303715884105726' ],
+ 'F80::' => [ 0, '340282366920938463463374607431768211454' ],
+ '0.0.0.1' => [ 31, '0' ],
+ '0.0.0.2' => [ 30, '2' ],
+ '0.0.0.3' => [ 2, '1073741822' ],
+ '0.0.0.4' => [ 1, '2147483646' ],
+ '0.0.0.5' => [ 0, '4294967294' ],
+ '0.0.0.6' => [ 32, '1' ],
+};
+
+my $new = 1; # flag for old vs new numeric returns
+
+$| = 1;
+
+$test = keys %$nets;
+print "1..", $test, "\n";
+
+$test = 1;
+sub tst {
+ foreach my $a (sort keys %$nets) {
+ my $nc = $nets->{$a}->[1]; # net count
+ my $ip = new NetAddr::IP::Lite($a, $nets->{$a}->[0]);
+ print "/$nets->{$a}->[0] got: $_, exp: $nc\nnot "
+ unless ($_ = $ip->num) eq $nc;
+ print "ok ", $test++, "\n";
+ }
+}
+
+tst();
+
Modified: branches/upstream/libnetaddr-ip-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnetaddr-ip-perl/current/MANIFEST?rev=70969&op=diff
==============================================================================
--- branches/upstream/libnetaddr-ip-perl/current/MANIFEST (original)
+++ branches/upstream/libnetaddr-ip-perl/current/MANIFEST Wed Mar 9 16:17:03 2011
@@ -62,6 +62,7 @@
Lite/t/v6-new_cis6_base.t
Lite/t/v6-new_cis_base.t
Lite/t/v6-new-base.t
+Lite/t/v6-num.t
Lite/t/v6-numeric.t
Lite/t/v6-old-base.t
Lite/t/version.t
Modified: branches/upstream/libnetaddr-ip-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnetaddr-ip-perl/current/META.yml?rev=70969&op=diff
==============================================================================
--- branches/upstream/libnetaddr-ip-perl/current/META.yml (original)
+++ branches/upstream/libnetaddr-ip-perl/current/META.yml Wed Mar 9 16:17:03 2011
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: NetAddr-IP
-version: 4.040
+version: 4.041
abstract: Manages IPv4 and IPv6 addresses and subnets
license: ~
author:
More information about the Pkg-perl-cvs-commits
mailing list