diff --git a/Changes b/Changes index de32554..ce2a711 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,15 @@ Revision history for Perl extension NetAddr::IP +4.020 Tue Dec 9 16:25:46 PST 2008 + cleaned up various typo's with good patch from + Rob Riepel + thanks Rob. + + revised UtilPP v1.7 to work around perl 5.8.4 + failures with certain @_ operations of goto &sub... + see perl bug [ 23429]. Unfortunately, perl-5.8.4 is + the distribution of choice for many solaris boxes + 4.019 Sat Nov 29 15:15:30 PST 2008 in Lite/Util, add pure perl testing to XS build @@ -31,7 +41,7 @@ string of build headers. added what is hopefully thread safe operation via - serializaton. Must be invoked by "--with-threads" + serialization. Must be invoked by "--with-threads" in Lite v1.12 corrected missing Zeros subroutine @@ -50,22 +60,22 @@ libraries against the perl build for consistency 4.015 Sun Nov 2 10:10:38 PST 2008 - in Util v1.23 add missing headers in configure and localconf.h + in Util v1.23 add missing headers in configure and localconf.h for Solaris inet_xton thanks to Karl Bunch for spotting the bug. 4.014 Sat Nov 1 15:13:48 PST 2008 - in Lite.pm v1.11, add test for characters not allowed by - rfc952 before the call to gethostbyname in sub new() for those + in Lite.pm v1.11, add test for characters not allowed by + rfc952 before the call to gethostbyname in sub new() for those people that insist on using deprecated functionality :aton and OS's that fail to notice calls to gethostbyname with binary arguments. 4.013 Wed Oct 22 15:04:49 PDT 2008 - In Lite.pm v1.10, add new no octal method for + In Lite.pm v1.10, add new no octal method for improperly formatted ipV4 addresses - In Util.pm v1.22, eliminated dependance on PL_sawampersand + In Util.pm v1.22, eliminated dependence on PL_sawampersand thanks to Mark Martinec for spotting this and submitting a patch. @@ -93,11 +103,11 @@ 4.009 Tue Sep 2 19:09:57 PDT 2008 In NetAddr::IP::Lite v1.07, in the off chance that NetAddr::IP::Lite objects are created - and the caller later loads NetAddr::IP and expects to use - those objects, let the AUTOLOAD routine find and redirect - NetAddr::IP::Lite method and subroutine calles to NetAddr::IP. + and the caller later loads NetAddr::IP and expects to use + those objects, let the AUTOLOAD routine find and redirect + NetAddr::IP::Lite method and subroutine calls to NetAddr::IP. - updated Lite/t/v4-wnew.t so that non-existent + updated Lite/t/v4-wnew.t so that non-existent domains are "really" not there 4.008 Sat Jun 7 14:01:55 PDT 2008 @@ -105,21 +115,21 @@ add related documentation Inherited methods from Lite.pm updated as follows: - - comparisons of the form <, >, <=, >= + + comparisons of the form <, >, <=, >= 10.0.0.0/24 {operator} 10.0.0.0/16 - return now return the comparision of the cidr value - when the address portion is equal. + return now return the comparison of the cidr value + when the address portion is equal. NOTE: this comparison returns the comparison of the NUMERIC value of the CIDR. This produces the counter intuitive result that /24 > /16. There is logic to this, really! For proper operation of commands like "Compact" and "Coalesce", lists of netaddr objects must sort in ascending order. However, this conflicts with the requirement for larger netblocks to sort - FIRST so as to include smaller ones. This logic extends to + FIRST so as to include smaller ones. This logic extends to any requirement for a sort of netaddr objects. It should be - further noted that the mixing of netaddr objects with varying - IP addresses and CIDR allocations can lead to unexpected + further noted that the mixing of netaddr objects with varying + IP addresses and CIDR allocations can lead to unexpected results since the comparisons done first on the IP portion and then on the CIDR portion. The documentation has been updated appropriately. @@ -154,7 +164,7 @@ update Lite.pm to v1.02 $isV6 global converted to a lexical variable within sub "_xnew" $Class global removed and replaced by calls to UNIVERSAL::isa - Thanks to julian@mehnle.net for spotting problems related to + Thanks to julian@mehnle.net for spotting problems related to using the Lite.pm with mod_perl 4.001 Thu Jul 6 14:09:01 PDT 2006 @@ -164,7 +174,7 @@ return the address value ()[1] 4.000 Mon Jun 19 21:51:10 PDT 2006 - initial release of version 4.000 which includes + initial release of version 4.000 which includes full support of ipV6 addresses and drops the requirement for Math::BigInt and will run on older versions of Perl at least back to 5.005_03 diff --git a/IP.pm b/IP.pm index 26ff7f1..dc17da9 100644 --- a/IP.pm +++ b/IP.pm @@ -34,7 +34,7 @@ @ISA = qw(Exporter NetAddr::IP::Lite); -$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.19 $ =~ /\d+/g) }; +$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.20 $ =~ /\d+/g) }; =pod @@ -82,7 +82,7 @@ ###### DEPRECATED, will be remove in version 5 ############ - * To accept addresses in the format as returned by + * To accept addresses in the format as returned by inet_aton, invoke the module as: use NetAddr::IP qw(:aton); @@ -92,7 +92,7 @@ * To enable usage of legacy data files containing NetAddr::IP objects stored using the L module. - use NetAddr::IP qw(:old_storable); + use NetAddr::IP qw(:old_storable); * To compact many smaller subnets (see: C<$me-Ecompact($addr1,$addr2,...)> @@ -153,7 +153,7 @@ =head1 DESCRIPTION This module provides an object-oriented abstraction on top of IP -addresses or IP subnets, that allows for easy manipulations. +addresses or IP subnets, that allows for easy manipulations. Version 4.xx of NetAdder::IP will will work older versions of Perl and does B use Math::BigInt as in previous versions. @@ -173,8 +173,8 @@ use overload - '@{}' => sub { - return [ $_[0]->hostenum ]; + '@{}' => sub { + return [ $_[0]->hostenum ]; }; =pod @@ -208,7 +208,7 @@ comparison with arbitrary strings as well as NetAddr::IP objects. The following example: - if (NetAddr::IP->new('127.0.0.1','255.0.0.0') eq '127.0.0.1/8') + if (NetAddr::IP->new('127.0.0.1','255.0.0.0') eq '127.0.0.1/8') { print "Yes\n"; } Will print out "Yes". @@ -228,10 +228,10 @@ /24 > /16 -Comparision should not be done on netaddr objects with different CIDR as +Comparison should not be done on netaddr objects with different CIDR as this may produce indeterminate - unexpected results, rather the determination of which netblock is larger or smaller should be -done by comparing +done by comparing $ip1->masklen <=> $ip2->masklen @@ -250,12 +250,12 @@ outputs 10.0.0.0/24. -Returns the the unchanged object when the conastant is missing or out of +Returns the the unchanged object when the constant is missing or out of range. 2147483647 <= constant >= -2147483648 -=item B)> +=item B)> The complement of the addition of a constant. @@ -264,7 +264,7 @@ Returns the difference between the address parts of two NetAddr::IP::Lite objects address parts as a 32 bit signed number. -Returns B if the difference is out of range. +Returns B if the difference is out of range. (See range restrictions on Addition above) @@ -310,17 +310,17 @@ if (grep { $_ eq ':old_storable' } @_) { @_ = grep { $_ ne ':old_storable' } @_; } else { - *{STORABLE_freeze} = sub + *{STORABLE_freeze} = sub { my $self = shift; return $self->cidr(); # use stringification }; - *{STORABLE_thaw} = sub + *{STORABLE_thaw} = sub { my $self = shift; my $cloning = shift; # Not used my $serial = shift; - + my $ip = new NetAddr::IP $serial; $self->{addr} = $ip->{addr}; $self->{mask} = $ip->{mask}; @@ -363,12 +363,16 @@ sub splitref { unshift @_, 0; # mark as no reverse - goto &_splitref; +# perl 5.8.4 fails with this operation. see perl bug [ 23429] +# goto &_splitref; + &_splitref; } sub rsplitref { unshift @_, 1; # mark as reversed - goto &_splitref; +# perl 5.8.4 fails with this operation. see perl bug [ 23429] +# goto &_splitref; + &_splitref; } sub split { @@ -439,7 +443,7 @@ broken. The third method C is exclusively for IPv4 addresses and filters -improperly formated +improperly formatted dot quad strings for leading 0's that would normally be interpreted as octal format by NetAddr per the specifications for inet_aton. @@ -460,7 +464,7 @@ the mask in CIDR notation. B notation is understood, with the limitation that the range -speficied by the prefix must match with a valid subnet. +specified by the prefix must match with a valid subnet. Addresses in the same format returned by C or C can also be understood, although no mask can be @@ -508,14 +512,14 @@ =item C<-Ebroadcast()> -Returns a new object refering to the broadcast address of a given +Returns a new object referring to the broadcast address of a given subnet. The broadcast address has all ones in all the bit positions where the netmask has zero bits. This is normally used to address all the hosts in a given subnet. =item C<-Enetwork()> -Returns a new object refering to the network address of a given +Returns a new object referring to the network address of a given subnet. A network address has all zero bits where the bits of the netmask are zero. Normally this is used to refer to a subnet. @@ -555,8 +559,8 @@ =item C<-Eaton()> Returns the address part of the NetAddr::IP object in the same format -as the C or C function respectively. If the object -was created using ->new6($ip), the address returned will always be in ipV6 +as the C or C function respectively. If the object +was created using ->new6($ip), the address returned will always be in ipV6 format, even for addresses in ipV4 address space. =item C<-Erange()> @@ -639,9 +643,9 @@ =item C<-Eshort()> -Returns the address part in a short or compact notation. +Returns the address part in a short or compact notation. - (ie, 127.0.0.1 becomes 127.1). + (ie, 127.0.0.1 becomes 127.1). Works with both, V4 and V6. @@ -730,7 +734,7 @@ =item C<-Efull()> -Returns the address part in FULL notation for +Returns the address part in FULL notation for ipV4 and ipV6 respectively. i.e. for ipV4 @@ -774,7 +778,7 @@ =item C<$me-Ewithin($other)> The complement of C<-Econtains()>. Returns true when C<$me> is -completely con tained within C<$other>. +completely contained within C<$other>. Note that C<$me> and C<$other> must be C objects. @@ -785,18 +789,18 @@ unchanged. Note that C<$bits> must be longer than the original mask in order for it to be splittable. -ERROR conditions: +ERROR conditions: - ->splitref will DIE with the message 'netlimit exceeded' + ->splitref will DIE with the message 'netlimit exceeded' if the number of return objects exceeds 'netlimit'. See function 'netlimit' above (default 2**16 or 65536 nets). - ->splitref returns undef when C or the (bits list) + ->splitref returns undef when C or the (bits list) will not fit within the original object. - ->splitref returns undef if a supplied ipV4, ipV6, or NetAddr - mask in inappropriately formated, - + ->splitref returns undef if a supplied ipV4, ipV6, or NetAddr + mask in inappropriately formatted, + B may be a CIDR mask, a dot quad or ipV6 string or a NetAddr::IP object. If C is missing, the object is split for into all available addresses within the ipV4 or ipV6 object ( auto-mask of CIDR 32, 128 respectively ). @@ -829,7 +833,7 @@ =item C<-Ersplitref($bits,[optional $bits1,$bits2,...])> C<-Ersplitref> is the same as C<-Esplitref> above except that the split plan is -applided to the original object in reverse order. +applied to the original object in reverse order. i.e. my $ip = new NetAddr::IP('192.168.0.0'); my @objects = $ip->split(28, 29, 28, 29, 26); @@ -849,13 +853,13 @@ =item C<-Esplit($bits,[optional $bits1,$bits2,...])> Similar to C<-Esplitref> above but returns the list rather than a list -reference. You may not want to use this if a large numnber of objects is +reference. You may not want to use this if a large number of objects is expected. =item C<-Ersplit($bits,[optional $bits1,$bits2,...])> Similar to C<-Ersplitref> above but returns the list rather than a list -reference. You may not want to use this if a large numnber of objects is +reference. You may not want to use this if a large number of objects is expected. =cut @@ -908,7 +912,7 @@ # normalization can use add/subtract to accomplish normalization # # keys of %nets are the masks used by this split -# values of %nets are the normalized weighting for +# values of %nets are the normalized weighting for # calculating when the split is "full" or complete # %masks values contain the actual masks for each split subnet # @bits contains the masks in the order the user actually wants them @@ -980,9 +984,9 @@ Returns the list of hosts within a subnet. -ERROR conditions: +ERROR conditions: - ->hostenum will DIE with the message 'netlimit exceeded' + ->hostenum will DIE with the message 'netlimit exceeded' if the number of return objects exceeds 'netlimit'. See function 'netlimit' above (default 2**16 or 65536 nets). @@ -1003,10 +1007,10 @@ =item C<@compacted_object_list = Compact(@object_list)> Given a list of objects (including C<$me>), this method will compact -all the addresses and subnets into the largest (ie, least specific) +all the addresses and subnets into the largest (ie, least specific) subnets possible that contain exactly all of the given objects. -Note that in versions prior to 3.02, if fed with the same IP subnets +Note that in versions prior to 3.02, if fed with the same IP subnets multiple times, these subnets would be returned. From 3.02 on, a more "correct" approach has been adopted and only one address would be returned. @@ -1118,7 +1122,7 @@ my @ret = (); # Add to @ret any arguments with netmasks longer than our argument - for my $c (sort { $a->masklen <=> $b->masklen } + for my $c (sort { $a->masklen <=> $b->masklen } grep { $_->masklen <= $masklen } @_) { next if grep { $_->contains($c) } @ret; @@ -1126,8 +1130,8 @@ } # Now add to @ret all the subnets with more than $number hits - for my $c (map { new NetAddr::IP $_ } - grep { $ret{$_} >= $number } + for my $c (map { new NetAddr::IP $_ } + grep { $ret{$_} >= $number } keys %ret) { next if grep { $_->contains($c) } @ret; @@ -1156,8 +1160,8 @@ (for example, when the network is too small for C<$index> hosts), C is returned. -Version 4.00 of NetAddr::IP and version 1.00 of NetAddr::IP::Lite implements -C<-Enth($index)> and C<-Enum()> exactly as the documentation states. +Version 4.00 of NetAddr::IP and version 1.00 of NetAddr::IP::Lite implements +C<-Enth($index)> and C<-Enum()> exactly as the documentation states. Previous versions behaved slightly differently and not in a consistent manner. See the README file for details. @@ -1186,11 +1190,11 @@ sub re ($) { - goto &re6 unless isIPv4($_[0]->{addr}); + return &re6 unless isIPv4($_[0]->{addr}); my $self = shift->network; # Insure a "zero" host part my ($addr, $mlen) = ($self->addr, $self->masklen); my @o = split('\.', $addr, 4); - + my $octet= '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'; my @r = @o; my $d; @@ -1204,7 +1208,7 @@ { if ($mlen > 24) { - $d = 2 ** (32 - $mlen) - 1; + $d = 2 ** (32 - $mlen) - 1; $r[3] = '(?:' . join('|', ($o[3]..$o[3] + $d)) . ')'; } else @@ -1212,7 +1216,7 @@ $r[3] = $octet; if ($mlen > 16) { - $d = 2 ** (24 - $mlen) - 1; + $d = 2 ** (24 - $mlen) - 1; $r[2] = '(?:' . join('|', ($o[2]..$o[2] + $d)) . ')'; } else @@ -1220,7 +1224,7 @@ $r[2] = $octet; if ($mlen > 8) { - $d = 2 ** (16 - $mlen) - 1; + $d = 2 ** (16 - $mlen) - 1; $r[1] = '(?:' . join('|', ($o[1]..$o[1] + $d)) . ')'; } else @@ -1307,11 +1311,11 @@ do { my $grp = join('',splice(@dig,0,4)); if ($grp =~ /^(0+)/) { - my $l = length($1); + my $l = length($1); if ($l == 4) { $grp = '0{1,4}'; } else { - $grp =~ s/^${1}/0\{0,$l\}/; + $grp =~ s/^${1}/0\{0,$l\}/; } } if ($grp =~ /(x+)$/) { @@ -1353,620 +1357,21 @@ V4net netlimit +=head1 NOTES / BUGS ... FEATURES + +NetAddr::IP only runs in Pure Perl mode on Windows boxes because I don't +have the resources or know how to get the "configure" stuff working in the +Windows environment. Volunteers WELCOME to port the "C" portion of this +module to Windows. + =head1 HISTORY -$Id: IP.pm,v 4.8 2008/06/07 20:43:38 luisemunoz Exp $ - -=over - -=item 0.01 - -=over - - -=item * - -original version; Basic testing and release to CPAN as -version 0.01. This is considered beta software. - -=back - - -=item 0.02 - -=over - - -=item * - -Multiple changes to fix endiannes issues. This code is now -moderately tested on Wintel and Sun/Solaris boxes. - -=back - - -=item 0.03 - -=over - - -=item * - -Added -Efirst and -Elast methods. Version changed to 0.03. - -=back - - -=item 1.00 - -=over - - -=item * - -Implemented -Enew_subnet. Version changed to 1.00. - -=item * - -less croak()ing when improper input is fed to the module. A -more consistent 'undef' is returned now instead to allow the -user to better handle the error. - -=back - - -=item 1.10 - -=over - - -=item * - -As per Marnix A. Van Ammers [mav6@ns02.comp.pge.com] -suggestion, changed the syntax of the loop in host_enum to -be the same of the enum method. - -=item * - -Fixed the MS-DOS ^M at the end-of-line problem. This should -make the module easier to use for *nix users. - -=back - - -=item 1.20 - -=over - - -=item * - -Implemented -Ecompact and -Eexpand methods. - -=item * - -Applying for official name - -=back - - -=item 1.21 - -=over - - -=item * - -Added -Eaddr_number and -Emask_bits. Currently we return -normal numbers (not BigInts). Please test this in your -platform and report any problems! - -=back - - -=item 2.00 - -=over - - -=item * - -Released under the new *official* name of NetAddr::IP - -=back - - -=item 2.10 - -=over - - -=item * - -Added support for -Enew($min, $max, $bits) form - -=item * - -Added -Eto_numeric. This helps serializing objects - -=back - - -=item 2.20 - -=over - - -=item * - -Chris Dowling reported that the sort method introduced in -v1.20 for -Eexpand and -Ecompact doesn't always return a -number under perl versions < 5.6.0. His fix was applied and -redistributed. Thanks Chris! - -=item * - -This module is hopefully released with no CR-LF issues! - -=item * - -Fixed a warning about uninitialized values during make test - -=back - - -=item 2.21 - -=over - - -=item * - -Dennis Boylan pointed out a bug under Linux and perhaps -other platforms as well causing the error "Sort subroutine -didn't return single value at -/usr/lib/perl5/site_perl/5.6.0/NetAddr/IP.pm line 299, EE -line 2." or similar. This was fixed. - -=back - - -=item 2.22 - -=over - - -=item * - -Some changes suggested by Jeroen Ruigrok and Anton Berezin -were included. Thanks guys! - -=back - - -=item 2.23 - -=over - - -=item * - -Bug fix for /XXX.XXX.XXX.XXX netmasks under v5.6.1 suggested -by Tim Wuyts. Thanks! - -=item * - -Tested the module under MACHTYPE=hppa1.0-hp-hpux11.00. It is -now konwn to work under Linux (Intel/AMD), Digital Unix -(Alpha), Solaris (Sun), HP-UX11 (HP-PA-RISC), Windows -9x/NT/2K (using ActiveState on Intel). - -=back - - -=item 2.24 - -=over - - -=item * - -A spurious warning when expand()ing with C<-w> under certain -circumstances was removed. This involved using /31s, /32s -and the same netmask as the input. Thanks to Elie Rosenblum -for pointing it out. - -=item * - -Slight change in license terms to ease redistribution as a -Debian package. - -=back - - -=item 3.00 - -This is a major rewrite, supposed to fix a number of issues pointed -out in earlier versions. - -The goals for this version include getting rid of BigInts, speeding up -and also cleaning up the code, which is written in a modular enough -way so as to allow IPv6 functionality in the future, taking benefit -from most of the methods. - -Note that no effort has been made to remain backwards compatible with -earlier versions. In particular, certain semantics of the earlier -versions have been removed in favor of faster performance. - -This version was tested under Win98/2K (ActiveState 5.6.0/5.6.1), -HP-UX11 on PA-RISC (5.6.0), RedHat Linux 6.2 (5.6.0), Digital Unix on -Alpha (5.6.0), Solaris on Sparc (5.6.0) and possibly others. - -=item 3.01 - -=over - -=item * - -Added C<-Enumeric()>. - -=item * - -C<-Enew()> called with no parameters creates a B -NetAddr::IP object. - -=back - -=item 3.02 - -=over - -=item * - -Fxed C<-Ecompact()> for cases of equal subnets or -mutually-contained IP addresses as pointed out by Peter Wirdemo. Note -that now only distinct IP addresses will be returned by this method. - -=item * - -Fixed the docs as suggested by Thomas Linden. - -=item * - -Introduced overloading to ease certain common operations. - -=item * - - Fixed compatibility issue with C<-Enum()> on 64-bit processors. - -=back - -=item 3.03 - -=over - -=item * - -Added more comparison operators. - -=item * - -As per Peter Wirdemo's suggestion, added C<-Ewildcard()> for -producing subnets in wildcard format. - -=item * - -Added C<++> and C<+> to provide for efficient iteration operations -over all the hosts of a subnet without C<-Eexpand()>ing it. - -=back - -=item 3.04 - -=over - -=item * - -Got rid of C when invalid input was fed to C<-Enew()>. - -=item * - -As suggested by Andrew Gaskill, added support for prefix -notation. Thanks for the code of the initial C<-Eprefix()> -function. - -=back - -=item 3.05 - -=over - -=item * - -Added support for range notation, where base and broadcast addresses -are given as arguments to C<-Enew()>. - -=back - -=item 3.06 - -=over - -=item * - -Andrew Ruthven pointed out a bug related to proper interpretation of -"compact" CIDR blocks. This was fixed. Thanks! - -=back - -=item 3.07 - -=over - -=item * - -Sami Pohto pointed out a bug with C<-Elast()>. This was fixed. - -=item * - -A small bug related to parsing of 'localhost' was fixed. - -=back - -=item 3.08 - -=over - -=item * - -By popular request, C<-Enew()> now checks the sanity of the netmasks -it receives. If the netmask is invalid, C will be returned. - -=back - -=item 3.09 - -=over - -=item * - -Fixed typo that invalidated otherwise correct masks. This bug appeared in 3.08. - -=back - -=item 3.10 - -=over - -=item * - -Fixed relops. Semantics where adjusted to remove the netmask from the -comparison. (ie, it does not make sense to say that 10.0.0.0/24 is > -10.0.0.0/16 or viceversa). - -=back - -=item 3.11 - -=over - -=item * - -Thanks to David D. Zuhn for contributing the C<-Enth()> method. - -=item * - -tutorial.htm now included in the distribution. I hope this helps some -people to better understand what kind of stuff can be done with this -module. - -=item * - -C<'any'> can be used as a synonim of C<'default'>. Also, C<'host'> is -now a valid (/32) netmask. - -=back - -=item 3.12 - -=over - -=item * - -Added CVS control files, though this is of no relevance to the community. - -=item * - -Thanks to Steve Snodgrass for pointing out a bug in the processing of -the special names such as default, any, etc. A fix was produced and -adequate tests were added to the code. - -=item * - -First steps towards "regexp free" parsing. - -=item * - -Documentation revisited and reorganized within the file, so that it -helps document the code. - -=item * - -Added C<-Eaton()> and support for this format in -C<-Enew()>. This makes the code helpful to interface with -old-style socket code. - -=back - -=item 3.13 - -=over - -=item * - -Fixes a warning related to 'wrapping', introduced in 3.12 in -C/C for the new support for C<-Eaton()>. - -=back - -=item 3.14 - -=over - -=item * - -C in Solaris seems to behave a bit different -from other OSes. Reversed change in 3.13 and added code around this -difference. - -=back - -=item 3.14_1 - -This is an interim release just to incorporate the v6 patches -contributed. No extensive testing has been done with this support -yet. More tests are needed. - -=over - -=item * - -Preliminary support for IPv6 contributed by Kadlecsik Jozsi -Ekadlec at sunserv.kfki.huE. Thanks a lot! - -=item * - -IP.pm and other files are enconded in ISO-8859-1 (Latin1) so that I -can spell my name properly. - -=item * - -Tested under Perl 5.8.0, no surprises found. - -=back - -=item 3.14_2 - -Minor development release. - -=over - -=item * - -Added C<-Eversion> and C<-Ebits>, including testing. - -=item * - -C can now be exported if the user so requests. - -=item * - -Fixed a bug when octets in a dotted quad were > 256 (ie, were not -octets). Thanks to Anton Berezin for pointing this out. - -=back - -=item 3.14_3 - -Fixed a bug pointed out by Brent Imhoff related to the implicit -comparison that happens within C. The netmask was being -ignored in the comparison (ie, 10/8 was considered the same as -10.0/16). Since some people have requested that 10.0/16 was considered -larger than 10/8, I added this change, which makes the bug go -away. This will be the last '_' release, pending new bugs. - -Regarding the comparison of subnets, I'm still open to debate so as to -wether 10.0/16 > 10/8. Certainly 255.255.0.0 > 255.0.0.0, but 2 ** 24 -are more hosts than 2 ** 16. I think we might use gt & friends for -this semantic and make everyone happy, but I won't do anything else -here without (significant) feedback. - -=item 3.14_4 - -As noted by Michael, 127/8 should be 127.0.0.0/8 and not -0.0.0.128/8. Also, improved docs on the usage of contains() and -friends. - -=item 3.15 - -Finally. Added POD tests (and fixed minor doc bug in IP.pm). As -reported by Anand Vijay, negative numbers are assumed to be signed -ints and converted accordingly to a v4 address. split() and nth() now -work with IPv6 addresses (Thanks to Venkata Pingali for -reporting). Tests were added for v6 base functionality and -splitting. Also tests for bitwise aritmethic with long integers has -been added. I'm afraid Math::BigInt is now required. - -Note that IPv6 might not be as solid as I would like. Be careful... - -=item 3.16 - -Fixed a couple of (minor) bugs in shipped tests in the last -version. Also, fixed a small pod typo that caused code to show up in -the documentation. - -=item 3.17 - -Fixed IP.pm so that all test could pass in Solaris machines. Thanks to -all who reported this. - -=item 3.18 - -Fixed some bugs pointed out by David Lloyd, having to do with the -module packaging and version requirements. Thanks David! - -=item 3.19 - -Fixed a bug pointed out by Andrew D. Clark, regarding proper parsing -of IP ranges with non-contiguous masks. Thanks Andrew! - -=item 3.20 - -Suggestion by Reuland Olivier gave birth to C, which provides -for a compact representation of the IP address. Rewrote C<_compact> to -find the longest sequence of zeros to compact. Reuland also pointed -out a flaw in contains() and within(), which was fixed. Thanks -Reuland! - -Fixed rt bug #5478 in t/00-load.t. - -=item 3.21 - -Fixed minor v-string problem pointed out by Steve Snodgrass (Thanks -Steve!). NetAddr::IP can now collaborate with Storable to serialize -itself. - -=item 3.22 - -Fixed bug rt.cpan.org #7070 reported by Grover Browning (auto-inc/dec -on v6 fails). Thanks Grover. Ruben van Staveren pointed out a bug in -v6 canonicalization, as well as providing a patch that was -applied. Thanks Ruben. - -=item 3.23 - -Included support for Module::Signature. Added -Ere() as -contributed by Laurent Facq (Thanks Laurent!). Added Coalesce() as -suggested by Perullo. - -=item 3.24 - -Version bump. Transfer of 3.23 to CPAN ended up in a truncated file -being uploaded. - -=item 3.25 - -Some IP specs resembling range notations but not depicting actual CIDR -ranges, were being erroneously recognized. Thanks to Steve Snodgrass -for reporting a bug with parsing IP addresses in 4-octet binary -format. Added optional Pod::Coverage tests. compact_addr has been -commented out, after a long time as deprecated. Improved speed of --Enew() for the case of a single host IPv4 address, which seems to -be the most common one. +=over 4 =item 4.00 -Dependence on Math::BigInt removed, works with earlier versions of Perl. +Dependence on Math::BigInt in earlier version is removed in this release +4.00. NetAddr::IP now works with earlier versions of Perl. The module was partitioned into three logical pieces as follows: Util.pm Math and logic operation on bit strings and number @@ -1974,17 +1379,17 @@ between various number formats. Implemented in C_XS for speed and PURE PERL of transportability. -Lite.pm Operations, simple conversions and comparisons of +Lite.pm Operations, simple conversions and comparisons of IP addresses, notations and formats. -IP.pm Complex operations and conversions of IP address +IP.pm Complex operations and conversions of IP address notation, nets, subnets, and ranges. The internal representation of addresses was changed to 128 bit binary strings as returned by inet_pton (ipv6_aton in this module). Both -ipV4 and ipV6 notations can be freely mixed and matched. +ipV4 and ipV6 notations can be freely mixed and matched. -Additional methods added to force operations into ipV6 space even when +Additional methods added to force operations into ipV6 space even when ipV4 notation is used. =item 4.05 @@ -1996,12 +1401,12 @@ Inherited methods from Lite.pm updated as follows: - comparisons of the form <, >, <=, >= + comparisons of the form <, >, <=, >= 10.0.0.0/24 {operator} 10.0.0.0/16 - return now return the comparision of the cidr value - when the address portion is equal. + return now return the comparison of the cidr value + when the address portion is equal. Thanks to Peter DeVries for spotting this bug. ... and leading us to discover that this next fix is required @@ -2058,9 +1463,19 @@ removed --with-threads, PTHREADS support, and all the mutex locking - unlocking - updated Util.xs to be fully re-entrant and thus + updated Util.xs to be fully re-entrant and thus fully thread safe. +=item 4.020 + + Fixed core dump due to bug in perl 5.8.4 handling of + @_ in goto &sub operations. Unfortunately this version + of perl is standard on Solaris -- it should be upgraded! + + Included missing code to parse BCD numbers as argument + to sub new(bcdnum). Thanks to Carlos Vicente cvicente@cpan.org + for reporting this bug. + =back =head1 AUTHORS diff --git a/Lite/Changes b/Lite/Changes index 5fdaede..766d28e 100644 --- a/Lite/Changes +++ b/Lite/Changes @@ -1,5 +1,16 @@ Revision history for Perl extension NetAddr::IP::Lite +1.13 Tue Dec 9 16:00:35 PST 2008 + added missing regexp to classify arguments as BCD numbers, + apparently this has been missing from NetAddr::IP::Lite + since the first release. + Thanks to Carlos Vicente cvicente@cpan.org for reporting this bug. + + revised UtilPP v1.7 to work around perl 5.8.4 + failures with certain @_ operations of goto &sub... + see perl bug [ 23429]. Unfortunately, perl-5.8.4 is + the distribution of choice for many solaris boxes + 1.12 Sun Nov 23 19:32:59 PST 2008 repaired missing sub Zeros @@ -10,8 +21,8 @@ for the initial code and inspiration for this enhancement 1.11 Sat Nov 1 15:13:48 PST 2008 - add test for characters not allowed by rfc952 before - the call to gethostbyname in sub new() for those people + add test for characters not allowed by rfc952 before + the call to gethostbyname in sub new() for those people that insist on using deprecated functionality :aton and OS's that fail to notice calls to gethostbyname with binary arguments @@ -19,8 +30,8 @@ 1.10 Wed Oct 22 14:54:12 PDT 2008 add new no octal method for improperly formatted ipV4 addresses - In Util.pm v1.22, eliminated dependance on PL_sawampersand - thanks to Mark Martinec + In Util.pm v1.22, eliminated dependence on PL_sawampersand + thanks to Mark Martinec for spotting this and submitting a patch. In Util.pm v1.22, force -noxs mode for Win32 @@ -29,41 +40,41 @@ 1.09 Thu Oct 16 19:35:33 PDT 2008 again... clear build bug for Win32 in Util.pm v 1.21 - + 1.08 Sat Sep 27 12:27:28 PDT 2008 in Util v0.19 updated test for ENDIANess in siteconf - + add test in inet_aton to detect overange IP dot quad values missed by some broken Socket implementations i.e. 256.1.1.1 1.07 Tue Sep 2 19:09:57 PDT 2008 in the off chance that NetAddr::IP::Lite objects are created - and the caller later loads NetAddr::IP and expects to use - those objects, let the AUTOLOAD routine find and redirect - NetAddr::IP::Lite method and subroutine calles to NetAddr::IP. + and the caller later loads NetAddr::IP and expects to use + those objects, let the AUTOLOAD routine find and redirect + NetAddr::IP::Lite method and subroutine calls to NetAddr::IP. - updated t/v4-wnew.t so that non-existent + updated t/v4-wnew.t so that non-existent domains are "really" not there 1.06 Sat Jun 7 12:57:18 PDT 2008 add method "new_from_aton" and related documentation - comparisons of the form <, >, <=, >= + comparisons of the form <, >, <=, >= 10.0.0.0/24 {operator} 10.0.0.0/16 - return now return the comparision of the cidr value - when the address portion is equal. + return now return the comparison of the cidr value + when the address portion is equal. NOTE: this comparison returns the comparison of the NUMERIC value of the CIDR. This produces the counter intuitive result that /24 > /16. There is logic to this, really! For proper operation of commands like "Compact" and "Coalesce", lists of netaddr objects must sort in ascending order. However, this conflicts with the requirement for larger netblocks to sort - FIRST so as to include smaller ones. This logic extends to + FIRST so as to include smaller ones. This logic extends to any requirement for a sort of netaddr objects. It should be - further noted that the mixing of netaddr objects with varying - IP addresses and CIDR allocations can lead to unexpected + further noted that the mixing of netaddr objects with varying + IP addresses and CIDR allocations can lead to unexpected results since the comparisons done first on the IP portion and then on the CIDR portion. The documentation has been updated appropriately. @@ -78,7 +89,7 @@ 1.02 Fri Aug 4 14:14:16 PDT 2006 $isV6 global converted to a lexical variable within sub "_xnew" $Class global removed and replaced by calls to UNIVERSAL::isa - Thanks to julian@mehnle.net for spotting problems related to + Thanks to julian@mehnle.net for spotting problems related to using the Lite.pm with mod_perl 1.01 Thu Jul 6 10:46:48 PDT 2006 @@ -95,8 +106,8 @@ 0.12 Sun Jun 25 16:13:00 PDT 2006 imported missing 'bcd2bin' - fixed Util->new() issues with long digit strings - ->new('::fffff') and non hex digits ->new('::foo'). + fixed Util->new() issues with long digit strings + ->new('::fffff') and non hex digits ->new('::foo'). Thanks to Radoslaw Zielinski for spotting these 3 bugs @@ -106,7 +117,7 @@ add $self->{isv6} flag for hint to ipV6 status - corrected bug in sub num that miscalcluated the number + corrected bug in sub num that miscalculated the number of IP's in a net for /31 /32 0.10 Tue Jun 13 14:07:46 PDT 2006 @@ -125,7 +136,7 @@ update Util/Makefile.PM to check for link libraries that ExtUtils::MakeMaker does not find properly - remove 'use warnings' from Lite.pm for backwards + remove 'use warnings' from Lite.pm for backwards compatibility with older perl versions 0.08 Tue Jun 6 08:33:11 PDT 2006 @@ -149,7 +160,7 @@ left Util/Makefile.pl out of the top level distro 0.03 Fri Apr 28 17:26:51 PDT 2006 - oops! left prerequsite Util 0.08 in the Makefile + oops! left prerequisite Util 0.08 in the Makefile when it is include in this distro 0.02 Fri Apr 28 16:11:00 PDT 2006 diff --git a/Lite/Lite.pm b/Lite/Lite.pm index ebbc3df..943d555 100644 --- a/Lite/Lite.pm +++ b/Lite/Lite.pm @@ -27,7 +27,7 @@ ); use vars qw(@ISA @EXPORT_OK $VERSION $Accept_Binary_IP $Old_nth $AUTOLOAD *Zero); -$VERSION = do { my @r = (q$Revision: 1.12 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.13 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; require Exporter; @@ -113,10 +113,10 @@ =cut -# in the off chance that NetAddr::IP::Lite objects are created -# and the caller later loads NetAddr::IP and expects to use -# those objects, let the AUTOLOAD routine find and redirect -# NetAddr::IP::Lite method and subroutine calles to NetAddr::IP. +# in the off chance that NetAddr::IP::Lite objects are created +# and the caller later loads NetAddr::IP and expects to use +# those objects, let the AUTOLOAD routine find and redirect +# NetAddr::IP::Lite method and subroutine calls to NetAddr::IP. # my $parent = 'NetAddr::IP'; @@ -159,7 +159,7 @@ =cut # these really should be packed in Network Long order but since they are -# symetrical, that extra internal processing can be skipped +# symmetrical, that extra internal processing can be skipped my $_v4zero = pack('L',0); my $_zero = pack('L4',0,0,0,0); @@ -199,13 +199,13 @@ '""' => sub { $_[0]->cidr(); }, - 'eq' => sub { + 'eq' => sub { my $a = (UNIVERSAL::isa($_[0],__PACKAGE__)) ? $_[0]->cidr : $_[0]; my $b = (UNIVERSAL::isa($_[1],__PACKAGE__)) ? $_[1]->cidr : $_[1]; $a eq $b; }, - '==' => sub { + '==' => sub { return 0 unless UNIVERSAL::isa($_[0],__PACKAGE__) && UNIVERSAL::isa($_[1],__PACKAGE__); $_[0]->cidr eq $_[1]->cidr; }, @@ -279,7 +279,7 @@ my $ip = new6 NetAddr::IP::Lite '192.168.1.123'; print "$ip\n"; -Will print the string +Will print the string =item B @@ -287,7 +287,7 @@ comparison with arbitrary strings as well as NetAddr::IP::Lite objects. The following example: - if (NetAddr::IP::Lite->new('127.0.0.1','255.0.0.0') eq '127.0.0.1/8') + if (NetAddr::IP::Lite->new('127.0.0.1','255.0.0.0') eq '127.0.0.1/8') { print "Yes\n"; } Will print out "Yes". @@ -307,7 +307,7 @@ /24 > /16 -Comparision should not be done on netaddr objects with different CIDR as +Comparison should not be done on netaddr objects with different CIDR as this may produce indeterminate - unexpected results, rather the determination of which netblock is larger or smaller should be done by comparing @@ -329,7 +329,7 @@ outputs 10.0.0.0/24. -Returns the the unchanged object when the conastant is missing or out of range. +Returns the the unchanged object when the constant is missing or out of range. 2147483647 <= constant >= -2147483648 @@ -345,7 +345,7 @@ my $a = $ip->{addr}; my $m = $ip->{mask}; - + my $lo = $a & ~$m; my $hi = $a & $m; @@ -354,7 +354,7 @@ return _new($ip,$new,$m); } -=item B)> +=item B)> The complement of the addition of a constant. @@ -402,7 +402,7 @@ my $m = $ip->{mask}; my $lo = $a & ~ $m; - my $hi = $a & $m; + my $hi = $a & $m; $ip->{addr} = ((addconst($lo,1))[1] & ~ $m) | $hi; return $ip; @@ -422,7 +422,7 @@ my $m = $ip->{mask}; my $lo = $a & ~$m; - my $hi = $a & $m; + my $hi = $a & $m; $ip->{addr} = ((addconst($lo,-1))[1] & ~$m) | $hi; return $ip; @@ -473,10 +473,10 @@ The first two 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. The third method C is exclusively for IPv4 addresses and filters -improperly formated +improperly formatted dot quad strings for leading 0's that would normally be interpreted as octal format by NetAddr per the specifications for inet_aton. @@ -501,7 +501,7 @@ the mask in CIDR notation. B notation is understood, with the limitation that the range -speficied by the prefix must match with a valid subnet. +specified by the prefix must match with a valid subnet. Addresses in the same format returned by C or C can also be understood, although no mask can be @@ -528,7 +528,7 @@ n.n.n.n/m.m.m.m loopback, localhost, broadcast, any, default x.x.x.x/host - 0xABCDEF, 0b111111000101011110, (a bcd number) + 0xABCDEF, 0b111111000101011110, (or a bcd number) a netaddr as returned by 'inet_aton' @@ -621,7 +621,7 @@ return bless $self, $class; } -sub new6($;$$) { +sub new6($;$$) { unshift @_, 1; goto &_xnew; } @@ -739,6 +739,10 @@ elsif ($ip =~ /^(\d+)$/ && $hasmask && $1 >= 0 and $1 < 256) { # pure numeric $ip = sprintf("%d.0.0.0",$1); } + elsif ($ip =~ /^\d+$/ && !$hasmask) { # a big integer + $ip = bcd2bin($ip); + last; + } elsif ($ip =~ /^0[xb]\d+$/ && $hasmask && (($tmp = eval "$ip") || 1) && $tmp >= 0 && $tmp < 256) { @@ -839,7 +843,7 @@ } # end while (1) return undef if notcontiguous($mask); # invalid if not contiguous - + my $self = { addr => $ip, mask => $mask, @@ -850,7 +854,7 @@ =item C<-Ebroadcast()> -Returns a new object refering to the broadcast address of a given +Returns a new object referring to the broadcast address of a given subnet. The broadcast address has all ones in all the bit positions where the netmask has zero bits. This is normally used to address all the hosts in a given subnet. @@ -865,7 +869,7 @@ =item C<-Enetwork()> -Returns a new object refering to the network address of a given +Returns a new object referring to the network address of a given subnet. A network address has all zero bits where the bits of the netmask are zero. Normally this is used to refer to a subnet. @@ -1071,8 +1075,8 @@ (for example, when the network is too small for C<$index> hosts), C is returned. -Version 4.00 of NetAddr::IP and version 1.00 of NetAddr::IP::Lite implements -C<-Enth($index)> and C<-Enum()> exactly as the documentation states. +Version 4.00 of NetAddr::IP and version 1.00 of NetAddr::IP::Lite implements +C<-Enth($index)> and C<-Enum()> exactly as the documentation states. Previous versions behaved slightly differently and not in a consistent manner. @@ -1083,9 +1087,9 @@ 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(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(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 @@ -1096,7 +1100,7 @@ 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(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 @@ -1184,11 +1188,11 @@ =head1 LICENSE - This software is (c) Luis E. Mu�oz, 1999 - 2005 + This software is (c) Luis E. Mu�oz, 1999 - 2005 and (c) Michael Robinton, 2006 - 2008. -It can be used under the terms of the perl artistic license provided that -proper credit for the work of the author is preserved in the form of this +It can be used under the terms of the perl artistic license provided that +proper credit for the work of the author is preserved in the form of this copyright notice and license for this module. =head1 SEE ALSO diff --git a/Lite/Makefile.PL b/Lite/Makefile.PL index 5614482..3fce927 100644 --- a/Lite/Makefile.PL +++ b/Lite/Makefile.PL @@ -26,9 +26,9 @@ sub MY::post_constants { my $post_constants = q| -MY_POD2TEXT = |. $Config{scriptdirexp} .'/pod2text' .q| +MY_POD2TEXT = |. $Config{scriptdirexp} .'/pod2text' .q| |; -} +} sub MY::postamble { package MY; diff --git a/Lite/README b/Lite/README index b291cde..cb348b4 100644 --- a/Lite/README +++ b/Lite/README @@ -95,7 +95,7 @@ comparison with arbitrary strings as well as NetAddr::IP::Lite objects. The following example: - if (NetAddr::IP::Lite->new('127.0.0.1','255.0.0.0') eq '127.0.0.1/8') + if (NetAddr::IP::Lite->new('127.0.0.1','255.0.0.0') eq '127.0.0.1/8') { print "Yes\n"; } Will print out "Yes". @@ -116,10 +116,10 @@ /24 > /16 - Comparision should not be done on netaddr objects with different - CIDR as this may produce indeterminate - unexpected results, rather - the determination of which netblock is larger or smaller should be - done by comparing + Comparison should not be done on netaddr objects with different CIDR + as this may produce indeterminate - unexpected results, rather the + determination of which netblock is larger or smaller should be done + by comparing $ip1->masklen <=> $ip2->masklen @@ -138,12 +138,12 @@ outputs 10.0.0.0/24. - Returns the the unchanged object when the conastant is missing or - out of range. + Returns the the unchanged object when the constant is missing or out + of range. 2147483647 <= constant >= -2147483648 - Substraction of a constant ("+") + Subtraction of a constant ("-") The complement of the addition of a constant. Difference ("-") @@ -173,7 +173,7 @@ get a /32 or /128 netmask for IPv4 / IPv6 addresses respectively. The third method "new_no" is exclusively for IPv4 addresses and - filters improperly formated dot quad strings for leading 0's that + filters improperly formatted dot quad strings for leading 0's that would normally be interpreted as octal format by NetAddr per the specifications for inet_aton. @@ -198,7 +198,7 @@ contain the mask in CIDR notation. prefix notation is understood, with the limitation that the range - speficied by the prefix must match with a valid subnet. + specified by the prefix must match with a valid subnet. Addresses in the same format returned by "inet_aton" or "gethostbyname" can also be understood, although no mask can be @@ -225,7 +225,7 @@ n.n.n.n/m.m.m.m loopback, localhost, broadcast, any, default x.x.x.x/host - 0xABCDEF, 0b111111000101011110, (a bcd number) + 0xABCDEF, 0b111111000101011110, (or a bcd number) a netaddr as returned by 'inet_aton' Any RFC1884 notation @@ -247,13 +247,13 @@ If called with no arguments, 'default' is assumed. "->broadcast()" - Returns a new object refering to the broadcast address of a given + Returns a new object referring to the broadcast address of a given subnet. The broadcast address has all ones in all the bit positions where the netmask has zero bits. This is normally used to address all the hosts in a given subnet. "->network()" - Returns a new object refering to the network address of a given + Returns a new object referring to the network address of a given subnet. A network address has all zero bits where the bits of the netmask are zero. Normally this is used to refer to a subnet. @@ -343,9 +343,9 @@ 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(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(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 @@ -356,7 +356,7 @@ 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(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 @@ -395,7 +395,7 @@ by using it you accept any and all the liability. LICENSE - This software is (c) Luis E. Mu�oz, 1999 - 2005 + This software is (c) Luis E. Mu�oz, 1999 - 2005 and (c) Michael Robinton, 2006 - 2008. It can be used under the terms of the perl artistic license provided diff --git a/Lite/Util/Changes b/Lite/Util/Changes index c0f178e..da8702c 100644 --- a/Lite/Util/Changes +++ b/Lite/Util/Changes @@ -1,5 +1,11 @@ Revision history for Perl extension NetAddr::IP::Util +1.27 Tue Dec 9 12:00:08 PST 2008 + revised UtilPP v1.7 to work around perl 5.8.4 + failures with certain @_ operations of goto &sub... + see perl bug [ 23429]. Unfortunately, perl-5.8.4 is + the distribution of choice for many solaris boxes + 1.26 Fri Nov 28 23:19:01 PST 2008 revised XS code to be full re-entrant... thread safe. removed all traces of mutex locks @@ -11,10 +17,10 @@ add threads reporting to Util.xs and UtilPP added what is hopefully thread safe operation via - serializaton. Must be invoked by "--with-threads" + serialization. Must be invoked by "--with-threads" 1.24 Wed Nov 5 18:13:20 PST 2008 - Clean up Makefile.PL to check actual required link + Clean up Makefile.PL to check actual required link libraries against the perl build for consistency 1.23 Sun Nov 2 10:10:38 PST 2008 @@ -22,8 +28,8 @@ thanks to Karl Bunch for spotting the bug. 1.22 Wed Oct 22 14:54:12 PDT 2008 - eliminated dependance on PL_sawampersand - thanks to Mark Martinec + eliminated dependence on PL_sawampersand + thanks to Mark Martinec for spotting this and submitting a patch. force -noxs mode for Win32 @@ -56,13 +62,13 @@ 0.16 Sun Jun 25 16:13:00 PDT 2006 fixed ->new() issues with long digit strings ->new('::fffff') - and non hex digits ->new('::foo'). + and non hex digits ->new('::foo'). Thanks to Radoslaw Zielinski for spotting those bugs 0.15 Tue Jun 13 14:42:34 PDT 2006 - UtilPP.pm v0.07 & Util.xs 'shiftleft' so that the orignal - agrument is returned when the shift count is '0' or missing + UtilPP.pm v0.07 & Util.xs 'shiftleft' so that the original + argument is returned when the shift count is '0' or missing 0.14 Tue Jun 6 08:37:01 PDT 2006 add logic to check LIBS => [-lfiles] @@ -108,17 +114,17 @@ add ipv4to6, mask4to6 to Util.pm and UtilPP.pm v0.03 0.05 Sat Apr 15 15:48:17 PDT 2006 - Fixed some typo's in Makefile.PL that + Fixed some typo's in Makefile.PL that failed to update README during build 0.04 Wed Apr 12 15:43:33 PDT 2006 - add Util_IS.pm to guarantee that the XS lib is not + add Util_IS.pm to guarantee that the XS lib is not loaded if a previous incarnation of the same version has previously been installed on the system and the module is built with -noxs 0.03 Tue Apr 4 21:55:35 PDT 2006 - udate minisocket to perl-5.9.3, add header + update minisocket to perl-5.9.3, add header file for backwards compatibility add function 'notcontiguous' to return cidr size @@ -127,7 +133,7 @@ 0.02 Fri Mar 31 12:44:15 PST 2006 added test for illegal characters to ipv6_aton - added UtilPP for Pure Perl functionality for the + added UtilPP for Pure Perl functionality for the WinTel folks that don't have gcc on their systems 0.01 Tue Mar 28 16:42:44 PST 2006 diff --git a/Lite/Util/GPL b/Lite/Util/GPL index 60549be..2ba72d5 100644 --- a/Lite/Util/GPL +++ b/Lite/Util/GPL @@ -55,7 +55,7 @@ The precise terms and conditions for copying, distribution and modification follow. - + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION @@ -110,7 +110,7 @@ License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) - + These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in @@ -168,7 +168,7 @@ access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - + 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is @@ -225,7 +225,7 @@ This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - + 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License @@ -278,7 +278,7 @@ POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS - + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest diff --git a/Lite/Util/Makefile.PL b/Lite/Util/Makefile.PL index e44e90f..a726adc 100644 --- a/Lite/Util/Makefile.PL +++ b/Lite/Util/Makefile.PL @@ -10,7 +10,7 @@ my $pwd = getcwd(); -unlink 'Makefile'; # remove Makefile to stabalize CC test +unlink 'Makefile'; # remove Makefile to stabilize CC test # # get any command line arguments @@ -24,7 +24,7 @@ }, ); -if ($^O eq 'MSWin32') { +if ($^O eq 'MSWin32') { $useXS = 0; # force NOXS mode for windows } @@ -52,7 +52,7 @@ # Check if we have a C compiler unless (defined $useXS) { - if (test_cc()) { + if (test_cc()) { print "You have a working compiler.\n"; $useXS = 1; # $makeparms{'MYEXTLIB'} = 'netdns$(LIB_EXT)', @@ -63,7 +63,7 @@ I cannot determine if you have a C compiler. I will install the perl-only implementation. - + You can force installation of the XS version with: perl Makefile.PL --xs @@ -79,7 +79,7 @@ # turn the XS bits on. delete $makeparms{'XS'}; delete $makeparms{'C'}; - + unless (-e './config.h') { system('./configure'); } @@ -182,7 +182,7 @@ # Scalar-List-Utils distribution. # print "Testing if you have a C compiler and the needed header files....\n"; - + unless (open(F, ">compile.c")) { warn "Cannot write compile.c, skipping test compilation and installing pure Perl version.\n"; return; @@ -191,11 +191,11 @@ print F <<'EOF'; int main() { return 0; } EOF - + close(F) or return; my $rv = system("$Config{'ccname'} compile.c -o compile$Config{obj_ext}"); - + foreach my $file (glob('compile*')) { unlink($file) || warn "Could not delete $file: $!\n"; } @@ -241,9 +241,9 @@ sub MY::post_constants { my $post_constants = q| -MY_POD2TEXT = |. $Config{scriptdirexp} .'/pod2text' .q| +MY_POD2TEXT = |. $Config{scriptdirexp} .'/pod2text' .q| |; -} +} sub MY::postamble { package MY; diff --git a/Lite/Util/README b/Lite/Util/README index 850c27e..5240290 100644 --- a/Lite/Util/README +++ b/Lite/Util/README @@ -31,7 +31,7 @@ use NetAddr::IP::Util qw(:all :inet :ipv4 :ipv6 :math) :inet => inet_aton, inet_ntoa, ipv6_aton, - ipv6_n2x, ipv6_n2d, inet_any2n, + ipv6_n2x, ipv6_n2d, inet_any2n, inet_n2dx, inet_n2ad, ipv4to6, mask4to6, ipanyto6, maskanyto6, ipv6to4 @@ -234,7 +234,7 @@ number of shifts [optional] returns: bits X n shifts - NOTE: a single shift is performed + NOTE: a single shift is performed if $n is not specified * addconst($ipv6naddr,$signed_32con); @@ -260,7 +260,7 @@ 128 bit string var2 returns: scalar carry array (carry, result) - + Note: The carry from this operation is the result of adding the one's complement of ARG2 +1 to the ARG1. It is logically NOT borrow. @@ -367,8 +367,8 @@ ? 1 : 0; } - # add a constant, wrapping at netblock boundries - # to subtract the constant, negate it before calling + # add a constant, wrapping at netblock boundaries + # to subtract the constant, negate it before calling # 'addwrap' since 'addconst' will extend the sign bits # sub addwrap { @@ -386,8 +386,8 @@ }; # bless $newip as appropriate return $newip; - } - + } + EXPORT_OK inet_aton inet_ntoa @@ -416,7 +416,7 @@ AUTHOR Michael Robinton -ACKNOWLEDGEMENTS +ACKNOWLEDGMENTS The following functions are used in whole or in part as include files to Util.xs. The copyright is include in the file. diff --git a/Lite/Util/Util.pm b/Lite/Util/Util.pm index 08b6e1f..6c70f04 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.26 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.27 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; @EXPORT_OK = qw( inet_aton @@ -167,7 +167,7 @@ use NetAddr::IP::Util qw(:all :inet :ipv4 :ipv6 :math) :inet => inet_aton, inet_ntoa, ipv6_aton, - ipv6_n2x, ipv6_n2d, inet_any2n, + ipv6_n2x, ipv6_n2d, inet_any2n, inet_n2dx, inet_n2ad, ipv4to6, mask4to6, ipanyto6, maskanyto6, ipv6to4 @@ -252,7 +252,7 @@ =over 4 -=item * $dotquad = inet_ntoa($netaddr); +=item * $dotquad = inet_ntoa($netaddr); Convert a packed IPv4 network address to a dot-quad IP address. @@ -285,7 +285,7 @@ $ipv6 = sprintf("%s%X%02X:%X%02X",$1,$2,$3,$4,$5); # convert to pure hex } my $c; - return undef if + return undef if $ipv6 =~ /[^:0-9a-fA-F]/ || # non-hex character (($c = $ipv6) =~ s/::/x/ && $c =~ /(?:x|:):/) || # double :: ::? $ipv6 =~ /[0-9a-fA-F]{5,}/; # more than 4 digits @@ -463,7 +463,7 @@ =item * $netaddr = ipv6to4($pv6naddr); -Truncate the upper 96 bits of a 128 bit address and return the lower +Truncate the upper 96 bits of a 128 bit address and return the lower 32 bits. Returns an IPv4 address as returned by inet_aton. input: 128 bit network address @@ -475,7 +475,7 @@ number of shifts [optional] returns: bits X n shifts - NOTE: a single shift is performed + NOTE: a single shift is performed if $n is not specified =item * addconst($ipv6naddr,$signed_32con); @@ -504,10 +504,10 @@ 128 bit string var2 returns: scalar carry array (carry, result) - + Note: The carry from this operation is the result of adding the one's complement of ARG2 +1 to the ARG1. It is logically -B. +B. i.e. if ARG1 >= ARG2 then carry = 1 or if ARG1 < ARG2 then carry = 0 @@ -566,7 +566,7 @@ #This function is not exported. # # input: string of packed decimal digits -# returns: hexdecimal digits +# returns: hexadecimal digits # #Similar to unpack("H*", $bcd); # @@ -661,8 +661,8 @@ ? 1 : 0; } - # add a constant, wrapping at netblock boundries - # to subtract the constant, negate it before calling + # add a constant, wrapping at netblock boundaries + # to subtract the constant, negate it before calling # 'addwrap' since 'addconst' will extend the sign bits # sub addwrap { @@ -680,8 +680,8 @@ }; # bless $newip as appropriate return $newip; - } - + } + =head1 EXPORT_OK inet_aton @@ -712,7 +712,7 @@ Michael Robinton -=head1 ACKNOWLEDGEMENTS +=head1 ACKNOWLEDGMENTS The following functions are used in whole or in part as include files to Util.xs. The copyright is include in the file. @@ -736,7 +736,7 @@ the author is preserved in the form of this copyright notice and license for this module. -No warranty of any kind is expressed or implied, by using it +No warranty of any kind is expressed or implied, by using it you accept any and all the liability. diff --git a/Lite/Util/Util.xs b/Lite/Util/Util.xs index f6b758a..ad53030 100644 --- a/Lite/Util/Util.xs +++ b/Lite/Util/Util.xs @@ -65,8 +65,6 @@ u_int32_t bcd[5]; /* 20 bytes, 40 digits */ } BCD; -BCD xn; - #define zero ('0' & 0x7f) void @@ -268,7 +266,7 @@ /* multiply 128 bit number by 10, add bcd digit to result */ -void +void _128x10plusbcd(n128 * ap128, n128 * tp128, char digit) { register u_int32_t * ap = ap128->u, * tp = tp128->u; @@ -363,7 +361,7 @@ u_int32_t word; unsigned char binmsk = 0; int c = 0,i, j, p; - + memset (n->bcd, 0, 20); for (p=0;p<128;p++) { /* bit pointer */ @@ -379,7 +377,7 @@ if (carry | bcd8) { /* if something to do */ add3 = 3; msk8 = 8; - + for (j=0;j<8;j++) { /* prep bcd digits for X2 */ tmp = bcd8 + add3; if (tmp & msk8) @@ -621,7 +619,7 @@ XSRETURN(1); #* -#* the second argument 'len' is the number of bcd digits for +#* the second argument 'len' is the number of bcd digits for #* the bcdn2bin conversion. Pack looses track of the number #* digits so this is needed to do the "right thing". #* NOTE: that simple_pack always returns 40 digits diff --git a/Lite/Util/configure.ac b/Lite/Util/configure.ac index 9a45de3..72862c4 100644 --- a/Lite/Util/configure.ac +++ b/Lite/Util/configure.ac @@ -11,7 +11,7 @@ # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST -AC_TYPE_INT32_T +AC_TYPE_INT32_T AC_TYPE_UINT16_T AC_TYPE_UINT32_T AC_TYPE_UINT8_T diff --git a/Lite/Util/lib/NetAddr/IP/UtilPP.pm b/Lite/Util/lib/NetAddr/IP/UtilPP.pm index 2626092..ef8c958 100644 --- a/Lite/Util/lib/NetAddr/IP/UtilPP.pm +++ b/Lite/Util/lib/NetAddr/IP/UtilPP.pm @@ -12,7 +12,7 @@ @ISA = qw(Exporter); -$VERSION = do { my @r = (q$Revision: 1.6 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.7 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; @EXPORT_OK = qw( hasbits @@ -163,10 +163,10 @@ # sub _128x2 { my $inp = shift; - $$inp[0] = ($$inp[0] << 1 & 0xffffffff) + (($$inp[1] & 0x80000000) ? 1:0); - $$inp[1] = ($$inp[1] << 1 & 0xffffffff) + (($$inp[2] & 0x80000000) ? 1:0); - $$inp[2] = ($$inp[2] << 1 & 0xffffffff) + (($$inp[3] & 0x80000000) ? 1:0); - $$inp[3] = $$inp[3] << 1 & 0xffffffff; + $$inp[0] = ($$inp[0] << 1 & 0xffffffff) + (($$inp[1] & 0x80000000) ? 1:0); + $$inp[1] = ($$inp[1] << 1 & 0xffffffff) + (($$inp[2] & 0x80000000) ? 1:0); + $$inp[2] = ($$inp[2] << 1 & 0xffffffff) + (($$inp[3] & 0x80000000) ? 1:0); + $$inp[3] = $$inp[3] << 1 & 0xffffffff; } # multiply x 10 @@ -257,7 +257,9 @@ my $sign = ($const < 0) ? 0xffffffff : 0; my $b128 = pack('N4',$sign,$sign,$sign,$const); @_ = ($a128,$b128,0); - goto &slowadd128; +# perl 5.8.4 fails with this operation. see perl bug [ 23429] +# goto &slowadd128; + slowadd128(@_); } =item * add128($ipv6naddr1,$ipv6naddr2); @@ -278,7 +280,9 @@ _deadlen(length($b128)) if length($b128) != 16; @_ = ($a128,$b128,0); - goto &slowadd128; +# perl 5.8.4 fails with this operation. see perl bug [ 23429] +# goto &slowadd128; + slowadd128(@_); } =item * sub128($ipv6naddr1,$ipv6naddr2); @@ -289,10 +293,10 @@ 128 bit string var2 returns: scalar carry array (carry, result) - + Note: The carry from this operation is the result of adding the one's complement of ARG2 +1 to the ARG1. It is logically -B. +B. i.e. if ARG1 >= ARG2 then carry = 1 or if ARG1 < ARG2 then carry = 0 @@ -307,7 +311,9 @@ my $a128 = $_[0]; my $b128 = ~$_[1]; @_ = ($a128,$b128,1); - goto &slowadd128; +# perl 5.8.4 fails with this operation. see perl bug [ 23429] +# goto &slowadd128; + slowadd128(@_); } =item * ($spurious,$cidr) = notcontiguous($mask128); @@ -339,7 +345,7 @@ $ua[1] |= 0x80000000 if $ua[0] & 1; $ua[0] >>= 1; } - + my $spurious = $ua[0] | $ua[1] | $ua[2] | $ua[3]; return $spurious unless wantarray; return ($spurious,$count); @@ -361,7 +367,7 @@ return pack('L3a4',0,0,0,$_[0]); } -=item * $ipv6naddr = mask4to6($netaddr); +=item * $ipv6naddr = mask4to6($netaddr); Convert an ipv4 netowrk address into an ipv6 network mask. @@ -421,7 +427,7 @@ =item * $netaddr = ipv6to4($pv6naddr); -Truncate the upper 96 bits of a 128 bit address and return the lower +Truncate the upper 96 bits of a 128 bit address and return the lower 32 bits. Returns an IPv4 address as returned by inet_aton. input: 128 bit network address @@ -464,7 +470,9 @@ sub bcd2bin { &_bcdcheck; - goto &_bcd2bin; +# perl 5.8.4 fails with this operation. see perl bug [ 23429] +# goto &_bcd2bin; + &_bcd2bin; } =pod @@ -480,7 +488,7 @@ #module testing purposes because it is used internally in the B routine. The #function is very fast, but calling if from perl directly is very slow. It is almost #33% faster to use B than to do a 1's comp with perl and then call -#B. In the PurePerl version, it is a call to +#B. In the PurePerl version, it is a call to # # sub {return ~ $_[0]}; # @@ -507,7 +515,9 @@ sub bin2bcdn { _deadlen(length($_[0])) if length($_[0]) != 16; - goto &_bin2bcdn; +# perl 5.8.4 fails with this operation. see perl bug [ 23429] +# goto &_bin2bcdn; + &_bin2bcdn; } sub _bin2bcdn { @@ -676,12 +686,12 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (except as noted otherwise in individuals sub modules) published by -the Free Software Foundation; either version 2 of the License, or +the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License diff --git a/Lite/Util/t/badd.t b/Lite/Util/t/badd.t index 9f2f291..f13a473 100644 --- a/Lite/Util/t/badd.t +++ b/Lite/Util/t/badd.t @@ -19,7 +19,7 @@ ++$test; } -my @addr = +my @addr = qw( :: 0:0:0:0:0:0:0:0 ::: undef foo undef diff --git a/Lite/Util/t/bin.t b/Lite/Util/t/bin.t index b0cccb7..49c3a60 100644 --- a/Lite/Util/t/bin.t +++ b/Lite/Util/t/bin.t @@ -43,7 +43,7 @@ my($ar,$i) = @_; return sprintf("%.0f",$ar->[$i +1]); } - + sub numstr { my($ar,$i) = @_; return $ar->[$i+1]; diff --git a/Lite/Util/t/notcontiguous.t b/Lite/Util/t/notcontiguous.t index e8d8032..0724d85 100644 --- a/Lite/Util/t/notcontiguous.t +++ b/Lite/Util/t/notcontiguous.t @@ -53,7 +53,7 @@ eFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:0 112 1 FFFF:FeFF:FFFF:FFFF:FFFF:FFFF:FFF0:0 108 1 F000:: 4 0 - A000:: 3 1 + A000:: 3 1 ); for (my $i=0;$i < @num;$i+=3) { diff --git a/Lite/Util/xs_include/miniSocket.inc b/Lite/Util/xs_include/miniSocket.inc index 079cf82..d6a8674 100644 --- a/Lite/Util/xs_include/miniSocket.inc +++ b/Lite/Util/xs_include/miniSocket.inc @@ -1,8 +1,8 @@ - # This file is excerpeted from perl-5.8.0/ext/Socket/Socket.xs and + # This file is excerpted from perl-5.8.0/ext/Socket/Socket.xs and # modified slightly so that it compiles on older versions of perl/gcc # - # 3/28/06 verson 1.78 of Socket.xs, included in perl 5.9.3 + # 3/28/06 version 1.78 of Socket.xs, included in perl 5.9.3 # is 100% compatible with this version # # Copyright 2003 - 2006, Michael Robinton scalar @num; + +#diag ("\ntesting SCALARS\n\n"); + +for(my $i = 0;$i <= $#num;$i += 2) { + my $n = $num[$i +1]; + my $ip = new NetAddr::IP::Lite($n); + ok($ip eq $num[$i],"$n\t=> got: $ip\texp: ". $num[$i]); +} + +#diag ("\ntesting Math::BigInt's\n\n"); + +for(my $i = 0;$i <= $#num;$i += 2) { + my $n = new Math::BigInt($num[$i +1]); + my $ip = new NetAddr::IP::Lite($num[$i +1]); + ok($ip eq $num[$i],"$n\t=> got: $ip\texp: ". $num[$i]); +} + + + + +# simulate the use of Math::BigInt + +package Math::BigInt; +use strict; + +use overload +'""' => sub { $_[0]->_str(); }; + +sub BASE_LEN () { 7 }; + +sub _str { # adapted from Math::BigInt::Calc::_str + # (ref to BINT) return num_str + # Convert number from internal base 100000 format to string format. + # internal format is always normalized (no leading zeros, "-0" => "+0") + my $ar = $_[0]->{value}; + + my $l = scalar @$ar; # number of parts + my $ret = ""; + # handle first one different to strip leading zeros from it (there are no + # leading zero parts in internal representation) + $l --; $ret .= int($ar->[$l]); $l--; + # Interestingly, the pre-padd method uses more time + # the old grep variant takes longer (14 vs. 10 sec) + my $z = '0' x (BASE_LEN -1); + while ($l >= 0) + { + $ret .= substr($z.$ar->[$l],- BASE_LEN); # fastest way I could think of + $l--; + } + $ret; +} + +sub new { # adapted from Math::BigInt::new + my ($class,$wanted) = @_; + my $self = bless {}, $class; + + die "oops, not a good Math::BigInt number" + unless ((!ref $wanted) && ($wanted =~ /^([+-]?)[1-9][0-9]*\z/)); + $self->{sign} = $1 || '+'; + + if ($wanted =~ /^[+-]/) { +# remove sign without touching wanted to make it work with constants + my $t = $wanted; $t =~ s/^[+-]//; + $self->{value} = _new($t); + } + else { + $self->{value} = _new($wanted); + } + return $self; +} + +sub _new { # adapted from Math::BigInt::Calc::_new + my $wanted = $_[0]; + # (ref to string) return ref to num_array + # Convert a number from string format (without sign) to internal base + # 1ex format. Assumes normalized value as input. + my $il = length($wanted)-1; + + # < BASE_LEN due len-1 above + return [ int($wanted) ] if $il < BASE_LEN; # shortcut for short numbers + + my $base_len = BASE_LEN; + # this leaves '00000' instead of int 0 and will be corrected after any op + [ reverse(unpack("a" . ($il % BASE_LEN +1) + . ("a$base_len" x ($il / BASE_LEN)), $wanted)) ]; +} diff --git a/Lite/t/contains.t b/Lite/t/contains.t index 8668244..c192658 100644 --- a/Lite/t/contains.t +++ b/Lite/t/contains.t @@ -27,7 +27,7 @@ FF::87 1 FF::88 0 ); - + for (my $i=0;$i<@try;$i+=2) { my $ip = NetAddr::IP::Lite->new($try[$i]); my $rv = ($try[$i] =~ /:/) diff --git a/Lite/t/copy.t b/Lite/t/copy.t index 34ba8d5..a21fdf2 100644 --- a/Lite/t/copy.t +++ b/Lite/t/copy.t @@ -26,7 +26,7 @@ unless $txto eq $ip24; &ok; -## test 2 +## test 2 print "copy... got: $txtc, exp: $ip24\nnot " unless $txtc eq $ip24; &ok; @@ -45,7 +45,7 @@ unless $txto eq $ip24; &ok; -## test 4 +## test 4 print "copy... got: $txtc, exp: $ip28\nnot " unless $txtc eq $ip28; &ok; diff --git a/Lite/t/lemasklen.t b/Lite/t/lemasklen.t index fc7d2db..b79e558 100644 --- a/Lite/t/lemasklen.t +++ b/Lite/t/lemasklen.t @@ -4,7 +4,7 @@ $| = 1; -print '1..', scalar @masks, "\n"; +print '1..', scalar @masks, "\n"; my $count = 1; diff --git a/Lite/t/loops.t b/Lite/t/loops.t index 55696a5..8f90ade 100644 --- a/Lite/t/loops.t +++ b/Lite/t/loops.t @@ -15,7 +15,7 @@ my $o = $ip->addr; $o =~ s/^.+\.(\d+)$/$1/; - + if ($o == $count) { print "ok $count\n"; } diff --git a/Lite/t/mask.t b/Lite/t/mask.t index f99c811..2709383 100644 --- a/Lite/t/mask.t +++ b/Lite/t/mask.t @@ -36,7 +36,7 @@ unless $mask eq $exp && ! ref $mask; &ok; -## test mask dot quad +## test mask dot quad $exp = '255.255.255.0'; $mask = $dqip->mask; print "got: $mask, exp: $exp\nnot " diff --git a/Lite/t/netaddr.t b/Lite/t/netaddr.t index 4ee8c6b..9eec7db 100644 --- a/Lite/t/netaddr.t +++ b/Lite/t/netaddr.t @@ -46,7 +46,7 @@ sub list2NetAddr { my($inref,$outref) = @_; - return undef + return undef unless ref $inref eq 'ARRAY' && ref $outref eq 'ARRAY'; unless ($SKIP_NetAddrIP) { @@ -91,7 +91,7 @@ =cut -sub matchNetAddr { +sub matchNetAddr { my($ip,$naref) = @_; return 0 unless $ip && $ip =~ /\d+\.\d+\.\d+\.\d+/; $ip =~ s/\s//g; @@ -105,7 +105,7 @@ } else { return 1 if $ip->within($beg); } - } + } return 0; } @@ -122,7 +122,7 @@ # # A multi-formated array of IP address that will never be tarpitted. # -# WARNING: if you are using a private network, then you should include the +# WARNING: if you are using a private network, then you should include the # address description for the net/subnets that you are using or you might # find your DMZ or internal mail servers blocked since many DNSBLS list the # private network addresses as BLACKLISTED @@ -179,7 +179,7 @@ ## test 6-35 bracket NA objects # -my @chkary = # 5 x 6 tests +my @chkary = # 5 x 6 tests # out left in left middle in right out right qw( 11.22.33.43 11.22.33.44 11.22.33.44 11.22.33.44 11.22.33.45 22.33.44.54 22.33.44.55 22.33.44.60 22.33.44.65 22.33.44.66 diff --git a/Lite/t/new-nth.t b/Lite/t/new-nth.t index 04db308..1595dca 100644 --- a/Lite/t/new-nth.t +++ b/Lite/t/new-nth.t @@ -23,7 +23,7 @@ print '1..', (@try/2) +2, "\n"; $test = 1; - + for (my $i=0;$i<@try;$i+=2) { my $rv = $ip4->nth($try[$i]); $rv = defined $rv diff --git a/Lite/t/numeric.t b/Lite/t/numeric.t index 6e7759d..2ac72f4 100644 --- a/Lite/t/numeric.t +++ b/Lite/t/numeric.t @@ -23,7 +23,7 @@ print "got: $sclr\nexp: $tval[$i+1]\nnot " unless $sclr .'x' eq $tval[$i+1] .'x'; &ok; - + ## test array return my($addr,$mask) = $nip->numeric; print "got: $addr\nexp: $tval[$i+1]\nnot " diff --git a/Lite/t/old-nth.t b/Lite/t/old-nth.t index ed20b14..b63cf75 100644 --- a/Lite/t/old-nth.t +++ b/Lite/t/old-nth.t @@ -24,7 +24,7 @@ 7 1.2.3.15 8 undef ); - + for (my $i=0;$i<@try;$i+=2) { my $rv = $ip4->nth($try[$i]); $rv = defined $rv diff --git a/Lite/t/over_copy.t b/Lite/t/over_copy.t index 1c4bc88..7b9aba6 100644 --- a/Lite/t/over_copy.t +++ b/Lite/t/over_copy.t @@ -26,7 +26,7 @@ unless $txto eq $ip24; &ok; -## test 2 +## test 2 print "copy... got: $txtc, exp: $ip24\nnot " unless $txtc eq $ip24; &ok; @@ -46,7 +46,7 @@ unless $txto eq $ip28; &ok; -## test 4 +## test 4 print "copy... got: $txtc, exp: $ip28\nnot " unless $txtc eq $ip28; &ok; diff --git a/Lite/t/v4-aton.t b/Lite/t/v4-aton.t index 6673399..3ffe37b 100644 --- a/Lite/t/v4-aton.t +++ b/Lite/t/v4-aton.t @@ -35,13 +35,13 @@ skip "Failed to load NetAddr::IP::Lite", 17 unless use_ok('NetAddr::IP::Lite'); - ok(! defined NetAddr::IP::Lite->new("\1\1\1\1"), + ok(! defined NetAddr::IP::Lite->new("\1\1\1\1"), "binary unrecognized by default ". ($x ? $x->addr :'')); # This mimicks the actual use with :aton NetAddr::IP::Lite::import(':aton'); - ok(defined ($x = NetAddr::IP::Lite->new("\1\1\1\1")), + ok(defined ($x = NetAddr::IP::Lite->new("\1\1\1\1")), "...but can be recognized ". $x->addr); ok(!defined ($x = NetAddr::IP::Lite->new('bad rfc-952 characters')), @@ -53,7 +53,7 @@ ok(defined NetAddr::IP::Lite->new(l_inet_aton($_->[1])), "->new aton($_->[1])") for @addr; - is(NetAddr::IP::Lite->new(l_inet_aton($_->[1]))->addr, $_->[1], + is(NetAddr::IP::Lite->new(l_inet_aton($_->[1]))->addr, $_->[1], "->new aton($_->[1])") for @addr; }; diff --git a/Lite/t/v4-badnm.t b/Lite/t/v4-badnm.t index 3a5dc55..4d6b264 100644 --- a/Lite/t/v4-badnm.t +++ b/Lite/t/v4-badnm.t @@ -33,10 +33,10 @@ my $count = 1; -ok(! defined NetAddr::IP::Lite->new($_), "new $_ should fail") +ok(! defined NetAddr::IP::Lite->new($_), "new $_ should fail") for @badnets; -ok(defined NetAddr::IP::Lite->new($_), "new $_ should work") +ok(defined NetAddr::IP::Lite->new($_), "new $_ should work") for @goodnets; diff --git a/Lite/t/v4-basem.t b/Lite/t/v4-basem.t index 516f50d..461a371 100644 --- a/Lite/t/v4-basem.t +++ b/Lite/t/v4-basem.t @@ -13,11 +13,11 @@ for my $a (keys %$nets) { my $ip = new NetAddr::IP::Lite $a, $nets->{$a}->[0]; - print '', (($ip->broadcast->addr ne $nets->{$a}->[1] ? - 'not ' : ''), + print '', (($ip->broadcast->addr ne $nets->{$a}->[1] ? + 'not ' : ''), "ok ", $count++, "\n"); - print '', (($ip->network->addr ne $nets->{$a}->[2] ? - 'not ' : ''), + print '', (($ip->network->addr ne $nets->{$a}->[2] ? + 'not ' : ''), "ok ", $count++, "\n"); } diff --git a/Lite/t/v4-contains.t b/Lite/t/v4-contains.t index 8c877ea..62234b7 100644 --- a/Lite/t/v4-contains.t +++ b/Lite/t/v4-contains.t @@ -1,7 +1,7 @@ use NetAddr::IP::Lite; my @yes_pairs = ( - [ [ '127.0.0.0', '255.0.0.0' ], + [ [ '127.0.0.0', '255.0.0.0' ], [ '127.0.0.1', '255.255.255.255'] ], [ [ '10.0.0.0', '255.255.255.0' ], [ '10.0.0.128', '255.255.255.128' ] ], diff --git a/Lite/t/v4-new-first.t b/Lite/t/v4-new-first.t index fc0ecfd..31d1a57 100644 --- a/Lite/t/v4-new-first.t +++ b/Lite/t/v4-new-first.t @@ -14,16 +14,16 @@ for my $a (keys %$nets) { my $ip = new NetAddr::IP::Lite $a, $nets->{$a}->[0]; - print '', (($ip->first->addr ne $nets->{$a}->[1] ? - 'not ' : ''), + print '', (($ip->first->addr ne $nets->{$a}->[1] ? + 'not ' : ''), "ok ", $count++, "\n"); - print '', (($ip->last->addr ne $nets->{$a}->[2] ? - 'not ' : ''), + print '', (($ip->last->addr ne $nets->{$a}->[2] ? + 'not ' : ''), "ok ", $count++, "\n"); my $new = $ip->nth(10); - print '', (((defined $new ? $new->addr : 'undef') ne $nets->{$a}->[3] ? - 'not ' : ''), + print '', (((defined $new ? $new->addr : 'undef') ne $nets->{$a}->[3] ? + 'not ' : ''), "ok ", $count++, "\n"); } diff --git a/Lite/t/v4-numeric.t b/Lite/t/v4-numeric.t index fb900f2..a2bf009 100644 --- a/Lite/t/v4-numeric.t +++ b/Lite/t/v4-numeric.t @@ -24,13 +24,13 @@ print '', ($nip and $nip->cidr eq $ip->cidr) ? '' : 'not ', 'ok ', $count ++, "\n"; - print '', (($addr != $nets->{$a}->[0] ? 'not ' : ''), + print '', (($addr != $nets->{$a}->[0] ? 'not ' : ''), "ok ", $count++, "\n"); - print '', (($mask != $nets->{$a}->[1] ? 'not ' : ''), + print '', (($mask != $nets->{$a}->[1] ? 'not ' : ''), "ok ", $count++, "\n"); - + } diff --git a/Lite/t/v4-old-first.t b/Lite/t/v4-old-first.t index 1ad05a2..89fef7f 100644 --- a/Lite/t/v4-old-first.t +++ b/Lite/t/v4-old-first.t @@ -14,16 +14,16 @@ for my $a (keys %$nets) { my $ip = new NetAddr::IP::Lite $a, $nets->{$a}->[0]; - print '', (($ip->first->addr ne $nets->{$a}->[1] ? - 'not ' : ''), + print '', (($ip->first->addr ne $nets->{$a}->[1] ? + 'not ' : ''), "ok ", $count++, "\n"); - print '', (($ip->last->addr ne $nets->{$a}->[2] ? - 'not ' : ''), + print '', (($ip->last->addr ne $nets->{$a}->[2] ? + 'not ' : ''), "ok ", $count++, "\n"); my $new = $ip->nth(10); - print '', (((defined $new ? $new->addr : 'undef') ne $nets->{$a}->[3] ? - 'not ' : ''), + print '', (((defined $new ? $new->addr : 'undef') ne $nets->{$a}->[3] ? + 'not ' : ''), "ok ", $count++, "\n"); } diff --git a/Lite/t/v4-wnew.t b/Lite/t/v4-wnew.t index d5a17e5..69e4f77 100644 --- a/Lite/t/v4-wnew.t +++ b/Lite/t/v4-wnew.t @@ -9,7 +9,7 @@ diag < $tests; -ok(NetAddr::IP::Lite->new('::')->contains(NetAddr::IP::Lite->new('::')), +ok(NetAddr::IP::Lite->new('::')->contains(NetAddr::IP::Lite->new('::')), ":: contains itself"); for my $p (@yes_pairs) diff --git a/Lite/t/v6-inc.t b/Lite/t/v6-inc.t index fa51fe8..3a4bdcd 100644 --- a/Lite/t/v6-inc.t +++ b/Lite/t/v6-inc.t @@ -3,8 +3,8 @@ # Test ++ in IPv6 addresses (Bug rt.cpan.org #7070 by a guest) -@ip = (NetAddr::IP::Lite->new('2001:468:ff:fffe::2/64'), - NetAddr::IP::Lite->new('2001:468:ff:fffe::2/64'), +@ip = (NetAddr::IP::Lite->new('2001:468:ff:fffe::2/64'), + NetAddr::IP::Lite->new('2001:468:ff:fffe::2/64'), NetAddr::IP::Lite->new('2001:468:ff:fffe::2/64')); $ip[1] ++; diff --git a/Lite/t/v6-new-base.t b/Lite/t/v6-new-base.t index 9a26065..9d83fe3 100644 --- a/Lite/t/v6-new-base.t +++ b/Lite/t/v6-new-base.t @@ -3,7 +3,7 @@ sub mypass() {1} sub myfail() {0} -@addr = +@addr = ( ['::', 3, '0:0:0:0:0:0:0:0/128',myfail], ['::1', 3, '0:0:0:0:0:0:0:1/128',myfail], @@ -26,7 +26,7 @@ ['2001:620:0:4::/64', 0, '2001:620:0:4:0:0:0:1/64',mypass], ['3FFE:2000:0:4::/64', 0, '3FFE:2000:0:4:0:0:0:1/64',mypass], ['2001:620:600::1', 0, '2001:620:600:0:0:0:0:1/128',mypass], - ['2001:620:600:0:1::1', 0,'2001:620:600:0:1:0:0:1/128',mypass], + ['2001:620:600:0:1::1', 0,'2001:620:600:0:1:0:0:1/128',mypass], ); use NetAddr::IP::Lite; diff --git a/Lite/t/v6-numeric.t b/Lite/t/v6-numeric.t index c9eddfb..4d68e74 100644 --- a/Lite/t/v6-numeric.t +++ b/Lite/t/v6-numeric.t @@ -5,16 +5,16 @@ ( [ '::/0', '0', '0' ], [ '::/128', '0', '340282366920938463463374607431768211455' ], - [ 'cafe:cafe::/64', - '269827015721314068804783158349174669312', + [ 'cafe:cafe::/64', + '269827015721314068804783158349174669312', '340282366920938463444927863358058659840' ], - [ 'cafe:cafe::1/64', - '269827015721314068804783158349174669313', + [ 'cafe:cafe::1/64', + '269827015721314068804783158349174669313', '340282366920938463444927863358058659840' ], - [ 'dead:beef::/100', + [ 'dead:beef::/100', '295990755014133383690938178081940045824', '340282366920938463463374607431499776000' ], - [ 'dead:beef::1/100', + [ 'dead:beef::1/100', '295990755014133383690938178081940045825', '340282366920938463463374607431499776000' ], ); @@ -68,11 +68,11 @@ for my $l (0 .. $i - 1) { next if $l >= $i; - unless (ok($ip_scale[$i]->numeric > $ip_scale[$l]->numeric, + unless (ok($ip_scale[$i]->numeric > $ip_scale[$l]->numeric, "[$i, $l] $scale[$i] > $scale[$l]")) { - diag "assertion [$i]: " . $ip_scale[$i]->numeric . - " > " . $ip_scale[$l]->numeric; + diag "assertion [$i]: " . $ip_scale[$i]->numeric . + " > " . $ip_scale[$l]->numeric; } } @@ -81,11 +81,11 @@ for my $l ($i + 1 .. $#ip_scale) { next if $l <= $i; - unless (ok($ip_scale[$i]->numeric < $ip_scale[$l]->numeric, + unless (ok($ip_scale[$i]->numeric < $ip_scale[$l]->numeric, "[$i, $l] $scale[$i] < $scale[$l]")) { - diag "assertion [$i]: " . $ip_scale[$i]->numeric . - " < " . $ip_scale[$l]->numeric; + diag "assertion [$i]: " . $ip_scale[$i]->numeric . + " < " . $ip_scale[$l]->numeric; } } } diff --git a/Lite/t/v6-old-base.t b/Lite/t/v6-old-base.t index 0bbf088..05d3934 100644 --- a/Lite/t/v6-old-base.t +++ b/Lite/t/v6-old-base.t @@ -3,7 +3,7 @@ sub mypass() {1} sub myfail() {0} -@addr = +@addr = ( ['::', 3, '0:0:0:0:0:0:0:0/128',myfail], ['::1', 3, '0:0:0:0:0:0:0:1/128',myfail], @@ -26,7 +26,7 @@ ['2001:620:0:4::/64', 1, '2001:620:0:4:0:0:0:1/64',mypass], ['3FFE:2000:0:4::/64', 1, '3FFE:2000:0:4:0:0:0:1/64',mypass], ['2001:620:600::1', 1, '2001:620:600:0:0:0:0:1/128',myfail], - ['2001:620:600:0:1::1', 1,'2001:620:600:0:1:0:0:1/128',myfail], + ['2001:620:600:0:1::1', 1,'2001:620:600:0:1:0:0:1/128',myfail], ); use NetAddr::IP::Lite qw(:old_nth); diff --git a/Lite/t/within.t b/Lite/t/within.t index 3654871..5093e1f 100644 --- a/Lite/t/within.t +++ b/Lite/t/within.t @@ -27,7 +27,7 @@ FF::87 1 FF::88 0 ); - + for (my $i=0;$i<@try;$i+=2) { my $ip = NetAddr::IP::Lite->new($try[$i]); my $rv = ($try[$i] =~ /:/) diff --git a/MANIFEST b/MANIFEST index 9ae7209..d54cc6d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -8,6 +8,7 @@ Lite/README Lite/t/addr.t Lite/t/aton.t +Lite/t/bigints.t Lite/t/bits.t Lite/t/broadcast.t Lite/t/cidr.t diff --git a/META.yml b/META.yml index f3d25c8..b43cbbf 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- #YAML:1.0 name: NetAddr-IP -version: 4.019 +version: 4.020 abstract: Manages IPv4 and IPv6 addresses and subnets license: ~ author: diff --git a/Makefile.PL b/Makefile.PL index 29f1362..98b4d12 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -9,11 +9,28 @@ # set number of seconds to view my $view = $then +86400 < $now ? 5:0; +my $pv = sprintf "%vd", $^V; +unless (0 && $pv lt '5.8.0' || $pv gt '5.8.5') { + print +qq( +################################################################# +######################### WARNING ############################### +# # +# YOUR VERSION OF PERL = $pv HAS SERIOUS BUGS # +# # +# Early versions of perl 5.8.x contain bugs that cause certain # +# \@_ operations to fail. Please upgrade to at least perl 5.8.6 # +# # +################################################################# +); + sleep $view if $view; +} + unless (grep { m/-noxs/ } @ARGV) { print q{ This build requires a C compiler by default except on Windows where the Pure Perl version is mandatory. The Pure Perl -version does not require compilation of XS code can be used +version does not require compilation of XS code can be used by invoking this as: perl Makefile.PL -noxs @@ -79,7 +96,7 @@ this all means, most likely you're safe to go along. Versions before 3.25 recognized by default IP addresses as returned by -inet_aton. This is no longer the default. To enable this behaviour +inet_aton. This is no longer the default. To enable this behavior again, the module must be use()d as use NetAddr::IP ':aton'; @@ -95,7 +112,7 @@ sleep $view if $view; my %makeparms = ( -# (MM->can('signature_target') ? (SIGN => 1) : ()), +# (MM->can('signature_target') ? (SIGN => 1) : ()), 'NAME' => 'NetAddr::IP', 'VERSION_FROM' => 'IP.pm', # finds $VERSION 'PREREQ_PM' => { diff --git a/README b/README index 99cb0de..314d7cb 100644 --- a/README +++ b/README @@ -13,7 +13,7 @@ address is within a subnet, comparing, looping, splitting subnets into longer prefixes, compacting addresses to the shortest prefixes, etc. -The general idea, is that you should be able to do +The general idea, is that you should be able to do use NetAddr::IP; @@ -34,7 +34,7 @@ for (my $ip = new NetAddr::IP '10.0.0.1/28'; $ip < $ip->broadcast; - $ip ++) + $ip ++) { print "$ip\n"; } @@ -60,7 +60,7 @@ 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 +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. @@ -71,9 +71,9 @@ 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(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(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 @@ -84,7 +84,7 @@ 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(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 @@ -189,7 +189,7 @@ 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 +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 diff --git a/t/full.t b/t/full.t index d3011e7..a703671 100644 --- a/t/full.t +++ b/t/full.t @@ -2,7 +2,7 @@ # $Id: short.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ -my %cases = +my %cases = ( '127.1' => '0000:0000:0000:0000:0000:0000:127.0.0.1', '123.23.4.210' => '0000:0000:0000:0000:0000:0000:123.23.4.210', diff --git a/t/full6.t b/t/full6.t index 3934731..e2a1be1 100644 --- a/t/full6.t +++ b/t/full6.t @@ -2,7 +2,7 @@ # $Id: short.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ -my %cases = +my %cases = ( '127.1' => '0000:0000:0000:0000:0000:0000:7f00:0001', '123.23.4.210' => '0000:0000:0000:0000:0000:0000:7b17:04d2', diff --git a/t/masklen.t b/t/masklen.t index 0791021..5457380 100644 --- a/t/masklen.t +++ b/t/masklen.t @@ -6,7 +6,7 @@ $| = 1; -print '1..', scalar @masks, "\n"; +print '1..', scalar @masks, "\n"; my $count = 1; diff --git a/t/over-arr.t b/t/over-arr.t index 5dd962e..386d320 100644 --- a/t/over-arr.t +++ b/t/over-arr.t @@ -1,7 +1,7 @@ use NetAddr::IP; use Test::More; -my @addr = ( [ '10.0.0.0/24', '10.0.0.1/32' ], +my @addr = ( [ '10.0.0.0/24', '10.0.0.1/32' ], [ '192.168.0.0/24', '192.168.0.1/32' ], [ '127.0.0.1/32', '127.0.0.1/32' ] ); diff --git a/t/v4-re.t b/t/v4-re.t index 1ee1862..e97c11a 100644 --- a/t/v4-re.t +++ b/t/v4-re.t @@ -25,7 +25,7 @@ diag "Compilation of the resulting regular expression failed: $@" unless ok(!$@, "Compilation of the resulting regular expression"); - for (my $ip = $a->network; + for (my $ip = $a->network; $ip < $a->broadcast && $a->masklen != 32; $ip ++) { diff --git a/t/v4-split-list.t b/t/v4-split-list.t index 75d865c..ac7660a 100644 --- a/t/v4-split-list.t +++ b/t/v4-split-list.t @@ -6,7 +6,7 @@ '10.0.0.10' => [ '255.255.252.0', 24, [ '10.0.0.0', '10.0.1.0', - '10.0.2.0', '10.0.3.0' + '10.0.2.0', '10.0.3.0' ]], '10.0.0.1' => [ '255.255.255.254', 32, [ diff --git a/t/v4-sprefix.t b/t/v4-sprefix.t index b130aeb..718e511 100644 --- a/t/v4-sprefix.t +++ b/t/v4-sprefix.t @@ -16,7 +16,7 @@ for my $a (@addr) { my $ip = new NetAddr::IP $a->[0]; - + if ($ip->cidr eq $a->[1]) { print "ok $count\n"; } diff --git a/t/v4-xprefix.t b/t/v4-xprefix.t index 6978ace..3fce3cb 100644 --- a/t/v4-xprefix.t +++ b/t/v4-xprefix.t @@ -19,7 +19,7 @@ my $ip = new NetAddr::IP $a->[0]; # print "$a->[0] is ", $ip->prefix, "\n"; - + if ($ip->prefix eq $a->[1]) { print "ok $count\n"; } diff --git a/t/v6-re.t b/t/v6-re.t index d175bf7..aed48b4 100644 --- a/t/v6-re.t +++ b/t/v6-re.t @@ -50,7 +50,7 @@ diag "Compilation of the resulting regular expression failed: $@" unless ok(!$@, "Compilation of the resulting regular expression"); - for (my $ip = $a->network; + for (my $ip = $a->network; $ip < $a->broadcast && $a->masklen != 128; $ip ++) { diff --git a/t/v6-split-bulk.t b/t/v6-split-bulk.t index 49dad4f..3e59375 100644 --- a/t/v6-split-bulk.t +++ b/t/v6-split-bulk.t @@ -3,7 +3,7 @@ # $Id: v6-split-bulk.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ -my @addr = ( +my @addr = ( [ 'dead:beef::1', 126, 127, 2 ], [ 'dead:beef::1', 127, 127, 1 ], [ 'dead:beef::1', 127, 128, 2 ],