diff --git a/Changes b/Changes index 3a56c70..40f85b3 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,31 @@ Revision history for Perl extension NetAddr::IP +4.036 Tue Nov 16 16:28:37 PST 2010 + In Util.pm v1.35, naip_gethostbyname modified to return undef + instead of 0 (zero) on failure + + thanks to Terry Cassidy enaudishaylee@tc17.com for the bug report + + In Util.pm v1.35, move sub's ipv6_n2d and ipv6_n2x to non-autosplit + portion of module to eliminate warnings during autosplit of "our" + variables + + thanks to Nicholas Bamber + Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=517361 + + In Lite.pm v1.22, update new6 to properly classify short ipv4 notation + i.e. 127/8 with test for ":" rather than match for \d.\d.\d.\d + + thanks to Steve Huff (SHUFF) * shuff@cpan.org for + spotting that bug. + + In Lite.pm v1.22, update t/v4-new.t for deprecated array syntax in + perl 5.13 + was: qw(...stuff...) + is: (qw(...stuff...)) + + thanks to Todd Rinaldo for reporting this + 4.035 Thu Oct 28 14:26:19 PDT 2010 fix bug in Lite v1.21 where new6 improperly assigns the mask value for and ipv4 address in 32 bit space instead of 128 bit space diff --git a/IP.pm b/IP.pm index 7b5743e..cd16be3 100644 --- a/IP.pm +++ b/IP.pm @@ -5,7 +5,7 @@ use strict; #use diagnostics; use NetAddr::IP::Lite 1.21 qw(Zero Zeros Ones V4mask V4net); -use NetAddr::IP::Util 1.34 qw( +use NetAddr::IP::Util 1.35 qw( sub128 inet_aton inet_any2n @@ -34,7 +34,7 @@ @ISA = qw(Exporter NetAddr::IP::Lite); -$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.35 $ =~ /\d+/g) }; +$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.36 $ =~ /\d+/g) }; =pod @@ -60,7 +60,7 @@ ); NOTE: NetAddr::IP::Util has a full complement of network address - utilites to convert back and forth between binary and text. + utilities to convert back and forth between binary and text. inet_aton, inet_ntoa, ipv6_aton, ipv6_n2x, ipv6_n2d inet_any2d, inet_n2dx, inet_n2ad, inetanyto6, ipv6to4 @@ -490,7 +490,7 @@ The last two methods B and B differ from B and B only in that they except the common Cisco address notation for -address/mask pairs with a B as a seperator instead of a slash (/) +address/mask pairs with a B as a separator instead of a slash (/) i.e. ->new_cis('1.2.3.0 24') or diff --git a/Lite/Changes b/Lite/Changes index c55cde7..aa549bf 100644 --- a/Lite/Changes +++ b/Lite/Changes @@ -1,5 +1,18 @@ Revision history for Perl extension NetAddr::IP::Lite +1.22 Tue Nov 16 16:28:37 PST 2010 + update new6 to properly classify short ipv4 notation + i.e. 127/8 with test for ":" rather than match for \d.\d.\d.\d + + thanks to Steve Huff (SHUFF) * shuff@cpan.org for + spotting that bug. + + update t/v4-new.t for deprecated array syntax in perl 5.13 + was: qw(...stuff...) + is: (qw(...stuff...)) + + thanks to Todd Rinaldo for reporting this + 1.21 Thu Oct 28 14:26:19 PDT 2010 fix bug where new6 improperly assigns the mask value for and ipv4 address in 32 bit space instead of 128 bit space diff --git a/Lite/Lite.pm b/Lite/Lite.pm index ba7d744..ab59516 100644 --- a/Lite/Lite.pm +++ b/Lite/Lite.pm @@ -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.21 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.22 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; require Exporter; @@ -500,7 +500,7 @@ The last two methods B and B differ from B and B only in that they except the common Cisco address notation for -address/mask pairs with a B as a seperator instead of a slash (/) +address/mask pairs with a B as a separator instead of a slash (/) i.e. ->new_cis('1.2.3.0 24') or @@ -740,7 +740,7 @@ if ($mval == 128) { # cidr 128 $mask = Ones; } - elsif ($ip =~ /^\d+\.\d+\.\d+\.\d+$/) { # corner case of ipV4 with new6 + elsif (index($ip,':') < 0) { # corner case of ipV4 with new6 $mask = shiftleft(Ones,32 -$mval); } elsif ($mask < 128) { # small cidr diff --git a/Lite/README b/Lite/README index b0e655a..3a2956c 100644 --- a/Lite/README +++ b/Lite/README @@ -182,7 +182,7 @@ The last two methods new_cis and new_cis6 differ from new and new6 only in that they except the common Cisco address notation for - address/mask pairs with a space as a seperator instead of a slash + address/mask pairs with a space as a separator instead of a slash (/) i.e. ->new_cis('1.2.3.0 24') diff --git a/Lite/Util/Changes b/Lite/Util/Changes index b809134..a83e2a4 100644 --- a/Lite/Util/Changes +++ b/Lite/Util/Changes @@ -1,5 +1,17 @@ Revision history for Perl extension NetAddr::IP::Util +1.35 Tue Nov 16 16:28:37 PST 2010 + naip_gethostbyname modified to return undef instead of + 0 (zero) on failure + + thanks to Terry Cassidy enaudishaylee@tc17.com for the bug report + + move sub's ipv6_n2d and ipv6_n2x to non-autosplit portion + of module to eliminate warnings during autosplit of "our" variables + + thanks to Nicholas Bamber + Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=517361 + 1.34 Wed Sep 29 10:32:50 PDT 2010 Conditionalize import of AF_INET6 in Util.pm NetAddr::IP::UtilPolluted diff --git a/Lite/Util/Util.pm b/Lite/Util/Util.pm index d0c6b8d..9262667 100644 --- a/Lite/Util/Util.pm +++ b/Lite/Util/Util.pm @@ -13,7 +13,7 @@ @ISA = qw(Exporter DynaLoader); -$VERSION = do { my @r = (q$Revision: 1.34 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.35 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; @EXPORT_OK = qw( inet_aton @@ -115,12 +115,29 @@ # allow user to choose upper or lower case -our $n2x_format = "%X:%X:%X:%X:%X:%X:%X:%X"; -our $n2d_format = "%X:%X:%X:%X:%X:%X:%D.%D.%D.%D"; +my $n2x_format = "%X:%X:%X:%X:%X:%X:%X:%X"; +my $n2d_format = "%X:%X:%X:%X:%X:%X:%D.%D.%D.%D"; sub upper { $n2x_format = uc($n2x_format); $n2d_format = uc($n2d_format); } sub lower { $n2x_format = lc($n2x_format); $n2d_format = lc($n2d_format); } +sub ipv6_n2x { + die "Bad arg length for 'ipv6_n2x', length is ". length($_[0]) ." should be 16" + unless length($_[0]) == 16; + return sprintf($n2x_format,unpack("n8",$_[0])); +} + +sub ipv6_n2d { + die "Bad arg length for 'ipv6_n2x', length is ". length($_[0]) ." should be 16" + unless length($_[0]) == 16; + my @hex = (unpack("n8",$_[0])); + $hex[9] = $hex[7] & 0xff; + $hex[8] = $hex[7] >> 8; + $hex[7] = $hex[6] & 0xff; + $hex[6] >>= 8; + return sprintf($n2d_format,@hex); +} + # if Socket lib is broken in some way, check for overange values # my $overange = yinet_aton('256.1') ? 1:0; @@ -160,7 +177,7 @@ sub _end_gethostbyname { my $tip = $_[0]; - return 0 unless $tip && $tip ne $_v4zero && $tip ne $_zero; + return undef unless $tip && $tip ne $_v4zero && $tip ne $_zero; my $len = length($tip); if ($len == 4) { return Util::ipv4to6($tip); @@ -168,7 +185,7 @@ elsif ($len == 16) { return $tip; } - return 0; + return undef; } unless (eval { require Socket6 }) { @@ -388,14 +405,6 @@ input: 128 bit RDATA string returns: x:x:x:x:x:x:x:x -=cut - -sub ipv6_n2x { - die "Bad arg length for 'ipv6_n2x', length is ". length($_[0]) ." should be 16" - unless length($_[0]) == 16; - return sprintf($n2x_format,unpack("n8",$_[0])); -} - =item * $dec_text = ipv6_n2d($ipv6addr); Takes an IPv6 RDATA string and returns a mixed hex - decimal IPv6 address @@ -405,19 +414,6 @@ input: 128 bit RDATA string returns: x:x:x:x:x:x:d.d.d.d -=cut - -sub ipv6_n2d { - die "Bad arg length for 'ipv6_n2x', length is ". length($_[0]) ." should be 16" - unless length($_[0]) == 16; - my @hex = (unpack("n8",$_[0])); - $hex[9] = $hex[7] & 0xff; - $hex[8] = $hex[7] >> 8; - $hex[7] = $hex[6] & 0xff; - $hex[6] >>= 8; - return sprintf($n2d_format,@hex); -} - =item * $ipv6naddr = inet_any2n($dotquad or $ipv6_text); This function converts a text IPv4 or IPv6 address in text format in any diff --git a/Lite/t/v4-new.t b/Lite/t/v4-new.t index 263098b..dd952b9 100644 --- a/Lite/t/v4-new.t +++ b/Lite/t/v4-new.t @@ -42,12 +42,12 @@ plan tests => (4 * scalar @a * scalar @m) + 4; -foreach my $invalid qw( +foreach my $invalid (qw( 256.1.1.1 256.256.1.1 256.256.256.1 256.256.256.256 -) { +)) { ok (! defined NetAddr::IP::Lite->new($invalid), "Invalid IP $invalid returns undef"); } diff --git a/META.yml b/META.yml index fea4406..2855caf 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- #YAML:1.0 name: NetAddr-IP -version: 4.035 +version: 4.036 abstract: Manages IPv4 and IPv6 addresses and subnets license: ~ author: