diff --git a/Changes b/Changes index a435409..c9da454 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,11 @@ Revision history for Perl extension NetAddr::IP +4.045 Thu Oct 6 18:23:04 PDT 2011 + updated NetAddr::IP::Util 1.37 + addid isAnyIPv4, isNewIPv4, inet_4map6 + revised naip_gethostbyname + to conform to Perl's gethostbyname output + 4.044 Wed May 18 14:47:34 PDT 2011 added missing support for ->compactref(\@list) which is described in the documentation but not implemented. diff --git a/IP.pm b/IP.pm index 8839464..42a65a8 100644 --- a/IP.pm +++ b/IP.pm @@ -5,7 +5,7 @@ use strict; #use diagnostics; use NetAddr::IP::Lite 1.28 qw(Zero Zeros Ones V4mask V4net); -use NetAddr::IP::Util 1.36 qw( +use NetAddr::IP::Util 1.37 qw( sub128 inet_aton inet_any2n @@ -34,7 +34,7 @@ @ISA = qw(Exporter NetAddr::IP::Lite); -$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.44 $ =~ /\d+/g) }; +$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.45 $ =~ /\d+/g) }; =pod diff --git a/Lite/MANIFEST b/Lite/MANIFEST new file mode 100644 index 0000000..c90a453 --- /dev/null +++ b/Lite/MANIFEST @@ -0,0 +1,111 @@ +MANIFEST +MANIFEST.SKIP +Changes +Lite.pm +Makefile.PL +META.yml +README +bug2742981.pl +t/addr.t +t/aton.t +t/bigints.t +t/bits.t +t/broadcast.t +t/bug62521.t +t/cidr.t +t/constants.t +t/contains.t +t/copy.t +t/firstlast.t +t/lemasklen.t +t/loops.t +t/lower.t +t/mask.t +t/masklen.t +t/netaddr.t +t/network.t +t/new-nth.t +t/new-num.t +t/numeric.t +t/old-nth.t +t/old-num.t +t/over-qq.t +t/over_comp.t +t/over_copy.t +t/over_equal.t +t/over_math.t +t/overminus.t +t/pathological.t +t/range.t +t/relops.t +t/v4-aton.t +t/v4-badnm.t +t/v4-base.t +t/v4-basem.t +t/v4-cidr.t +t/v4-cnew.t +t/v4-contains.t +t/v4-last.t +t/v4-new-first.t +t/v4-new_from_aton.t +t/v4-new.t +t/v4_new_cis.t +t/v4-no_octal.t +t/v4-num.t +t/v4-numeric.t +t/v4-old-first.t +t/v4-range.t +t/v4-snew.t +t/v4-wnew.t +t/v6-cnew.t +t/v6-contains.t +t/v6-inc.t +t/v6-new_cis6_base.t +t/v6-new_cis_base.t +t/v6-new-base.t +t/v6-num.t +t/v6-numeric.t +t/v6-old-base.t +t/version.t +t/within.t +Util/MANIFEST +Util/MANIFEST.SKIP +Util/Changes +Util/configure +Util/configure.ac +Util/config.h.in +Util/GPL +Util/lib/NetAddr/IP/UtilPP.pm +Util/tlib/NetAddr/IP/Util_IS.pm +Util/localconf.h +Util/Makefile.PL +Util/README +Util/t/4to6.t +Util/t/add128.t +Util/t/addconst.t +Util/t/anyto6.t +Util/t/badd.t +Util/t/bcd2bin.t +Util/t/bcdn2bin.t +Util/t/bin.t +Util/t/comp128.t +Util/t/croak.t +Util/t/hasbits.t +Util/t/inet_4map6.t +Util/t/inet_n2ad.t +Util/t/inet_n2dx.t +Util/t/ipv4_inet.t +Util/t/ipv6_any2n.t +Util/t/ipv6func.t +Util/t/ipv6to4.t +Util/t/isIPv4.t +Util/t/leftshift.t +Util/t/mode.t +Util/t/notcontiguous.t +Util/t/simple_pack.t +Util/t/sub128.t +Util/typemap +Util/Util.pm +Util/Util.xs +Util/xs_include/inet_aton.c +Util/xs_include/miniSocket.inc diff --git a/Lite/MANIFEST.SKIP b/Lite/MANIFEST.SKIP new file mode 100644 index 0000000..3dd2a78 --- /dev/null +++ b/Lite/MANIFEST.SKIP @@ -0,0 +1,31 @@ +^Build$ +^_build/ +^blib/ +^blibdirs +Makefile$ +Makefile\.[a-z]+$ +pm_to_blib +CVS/.* +\.cvs +,v$ +^tmp/ +\.old$ +\.bak$ +\.tmp$ +\.xsc$ +~$ +^# +\.shar$ +\.tar$ +\.tgz$ +\.tar\.gz$ +\.zip$ +_uu$ +Util_IS\.pm$ +Util\.(bs|[co])$ +localStuff\.h$ +config\.log$ +config\.h$ +config\.status +localperl\.h + diff --git a/Lite/Util/Changes b/Lite/Util/Changes index 68ff6ac..ddba191 100644 --- a/Lite/Util/Changes +++ b/Lite/Util/Changes @@ -1,5 +1,10 @@ Revision history for Perl extension NetAddr::IP::Util +1.37 Thu Oct 6 18:23:04 PDT 2011 + addid isAnyIPv4, isNewIPv4, inet_4map6 + revised naip_gethostbyname + to conform to Perl's gethostbyname output + 1.36 Sat Feb 19 10:04:00 PST 2011 correction to use of package lexicals diff --git a/Lite/Util/MANIFEST b/Lite/Util/MANIFEST new file mode 100644 index 0000000..870e4f5 --- /dev/null +++ b/Lite/Util/MANIFEST @@ -0,0 +1,42 @@ +Changes +configure +configure.ac +config.h.in +GPL +lib/NetAddr/IP/UtilPP.pm +localconf.h +Makefile.PL +README +t/4to6.t +t/add128.t +t/addconst.t +t/anyto6.t +t/badd.t +t/bcd2bin.t +t/bcdn2bin.t +t/bin.t +t/comp128.t +t/croak.t +t/hasbits.t +t/inet_4map6.t +t/inet_n2ad.t +t/inet_n2dx.t +t/ipv4_inet.t +t/ipv6_any2n.t +t/ipv6func.t +t/ipv6to4.t +t/isIPv4.t +t/leftshift.t +t/mode.t +t/notcontiguous.t +t/simple_pack.t +t/sub128.t +typemap +Util.pm +Util.xs +xs_include/inet_aton.c +xs_include/miniSocket.inc +Makefile.PL +MANIFEST This list of files +MANIFEST.SKIP +README diff --git a/Lite/Util/MANIFEST.SKIP b/Lite/Util/MANIFEST.SKIP new file mode 100644 index 0000000..61daf92 --- /dev/null +++ b/Lite/Util/MANIFEST.SKIP @@ -0,0 +1,31 @@ +^Build$ +^_build/ +^blib/ +^blibdirs +Makefile$ +Makefile\.[a-z]+$ +pm_to_blib +CVS/.* +\.cvs +,v$ +^tmp/ +\.old$ +\.bak$ +\.tmp$ +\.xsc$ +~$ +^# +\.shar$ +\.tar$ +\.tgz$ +\.tar\.gz$ +\.zip$ +_uu$ +Util\.(bs|[co])$ +localStuff\.h$ +config\.log$ +config\.h$ +config\.status +localperl\.h +tlib/NetAddr/IP/Util_IS.pm +Util_IS.pm diff --git a/Lite/Util/README b/Lite/Util/README index b3ebb63..ab29f48 100644 --- a/Lite/Util/README +++ b/Lite/Util/README @@ -11,8 +11,11 @@ inet_any2n hasbits isIPv4 + isNewIPv4 + isAnyIPv4 inet_n2dx inet_n2ad + inet_4map6 ipv4to6 mask4to6 ipanyto6 @@ -33,19 +36,19 @@ :inet => inet_aton, inet_ntoa, ipv6_aton, ipv6_n2x, ipv6_n2d, inet_any2n, - inet_n2dx, inet_n2ad, ipv4to6, - mask4to6, ipanyto6, maskanyto6, - ipv6to4, naip_gethostbyname + inet_n2dx, inet_n2ad, inet_4map6, + ipv4to6, mask4to6, ipanyto6, + maskanyto6, ipv6to4, naip_gethostbyname :ipv4 => inet_aton, inet_ntoa :ipv6 => ipv6_aton, ipv6_n2x, ipv6_n2d, inet_any2n, inet_n2dx, inet_n2ad - ipv4to6, mask4to6, ipanyto6, + inet_4map6, ipv4to6, mask4to6, ipanyto6, maskanyto6, ipv6to4, naip_gethostbyname - :math => hasbits, isIPv4, addconst, - add128, sub128, notcontiguous, + :math => hasbits, isIPv4, isNewIPv4, isAnyIPv4, + addconst, add128, sub128, notcontiguous, bin2bcd, bcd2bin, shiftleft $dotquad = inet_ntoa($netaddr); @@ -54,8 +57,11 @@ $hex_text = ipv6_n2x($ipv6naddr); $dec_text = ipv6_n2d($ipv6naddr); $ipv6naddr = inet_any2n($dotquad or $ipv6_text); + $ipv6naddr = inet_4map6($netaddr or $ipv6naddr); $rv = hasbits($bits128); $rv = isIPv4($bits128); + $rv = isNewIPv4($bits128); + $rv = isAnyIPv4($bits128); $dotquad or $hex_text = inet_n2dx($ipv6naddr); $dotquad or $dec_text = inet_n2ad($ipv6naddr); $ipv6naddr = ipv4to6($netaddr); @@ -179,10 +185,40 @@ input: 128 bit IPv6 string returns: true if any bits are present + * $ipv6naddr = inet_4map6($netaddr or $ipv6naddr + This function returns an ipV6 network address with the first 80 bits + set to zero and the next 16 bits set to one, while the last 32 bits + are filled with the ipV4 address. + + input: ipV4 netaddr + or ipV6 netaddr + returns: ipV6 netaddr + + returns: undef on error + + An ipV6 network address must be in one of the two compatible ipV4 + mapped address spaces. i.e. + + ::ffff::d.d.d.d or ::d.d.d.d + * $rv = isIPv4($bits128); This function returns true if there are no on bits present in the IPv6 portion of the 128 bit string and false otherwise. + i.e. the address must be of the form - ::d.d.d.d + + Note: this is an old and deprecated ipV4 compatible ipV6 address + + * $rv = isNewIPv4($bits128); + This function return true if the IPv6 128 bit string is of the form + + ::ffff::d.d.d.d + + * $rv = isAnyIPv4($bits128); + This function return true if the IPv6 bit string is of the form + + ::d.d.d.d or ::ffff::d.d.d.d + * $dotquad or $hex_text = inet_n2dx($ipv6naddr); This function does the right thing and returns the text for either a dot-quad IPv4 or a hex notation IPv6 address. @@ -306,6 +342,11 @@ * ($name,$aliases,$addrtype,$length,@addrs)=naip_gethostbyname(NAME); Replacement for Perl's gethostbyname if Socket6 is available + This function ALWAYS returns an IPv6 address, even on IPv4 only + systems. IPv4 addresses are mapped into IPv6 space in the form: + + ::FFFF:FFFF:d.d.d.d + * NetAddr::IP::Util::lower(); Return IPv6 strings in lowercase. @@ -411,8 +452,11 @@ inet_any2n hasbits isIPv4 + isNewIPv4 + isAnyIPv4 inet_n2dx inet_n2ad + inet_4map6 ipv4to6 mask4to6 ipanyto6 diff --git a/Lite/Util/Util.pm b/Lite/Util/Util.pm index d908236..352915e 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.36 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.37 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; @EXPORT_OK = qw( inet_aton @@ -24,8 +24,11 @@ inet_any2n hasbits isIPv4 + isNewIPv4 + isAnyIPv4 inet_n2dx inet_n2ad + inet_4map6 shiftleft addconst add128 @@ -58,6 +61,7 @@ inet_any2n inet_n2dx inet_n2ad + inet_4map6 ipv4to6 mask4to6 ipanyto6 @@ -69,6 +73,8 @@ shiftleft hasbits isIPv4 + isNewIPv4 + isAnyIPv4 addconst add128 sub128 @@ -87,6 +93,7 @@ inet_any2n inet_n2dx inet_n2ad + inet_4map6 ipv4to6 mask4to6 ipanyto6 @@ -159,7 +166,14 @@ sub DESTROY {}; +my $_newV4compat = pack('L4',0,0,0xffffffff,0); + my $mygethostbyname; +my $_Sock6ok = 1; # for testing gethostbyname + +sub _forceNoSock6() { + $_Sock6ok = 0; +} package NetAddr::IP::UtilPolluted; @@ -168,6 +182,7 @@ use strict; use Socket; +use NetAddr::IP::Util qw(ipv6_n2x ipv4to6); sub DESTROY {}; @@ -178,36 +193,49 @@ my $_zero = pack('L4',0,0,0,0); sub _end_gethostbyname { - my $tip = $_[0]; - return undef unless $tip && $tip ne $_v4zero && $tip ne $_zero; - my $len = length($tip); - if ($len == 4) { - return Util::ipv4to6($tip); +# my ($name,$aliases,$addrtype,$length,@addrs) = @_; + my @rv = @_; +# first ip address = rv[4] + my $tip = $rv[4]; + unless ($tip && $tip ne $_v4zero && $tip ne $_zero) { + @rv = (); } - elsif ($len == 16) { - return $tip; +# length = rv[3] + elsif ($rv[3] && $rv[3] == 4) { + foreach (4..$#rv) { + $rv[$_] = ipv4to6(inet_4map6($rv[$_])); + } + $rv[3] = 16; # unconditionally set length to 16 } - return undef; + elsif ($rv[3] == 16) { + ; # is ok + } else { + @rv = (); + } + return wantarray ? @rv : $rv[4]; } -unless (eval { require Socket6 }) { +unless ($_Sock6ok && eval { require Socket6 }) { $mygethostbyname = sub { - my $tip = gethostbyname($_[0]); - return &_end_gethostbyname($tip); + my @tip = gethostbyname($_[0]); + return &_end_gethostbyname(@tip); }; } else { import Socket6 qw( gethostbyname2 ); import Socket6 qw( AF_INET6 ) - unless eval { &AF_INET6 }; - my $tip; + unless eval { &AF_INET6 }; + $mygethostbyname = sub { - unless ($tip = gethostbyname2($_[0],&AF_INET6)) { - $tip = gethostbyname($_[0]); - } - return &_end_gethostbyname($tip); + my @tip; + unless (@tip = gethostbyname2($_[0],&AF_INET6)) { + @tip = gethostbyname($_[0]); + } + return &_end_gethostbyname(@tip); }; } +#package NetAddr::IP::Util; + package NetAddr::IP::Util; sub naip_gethostbyname { @@ -216,7 +244,36 @@ return &$mygethostbyname($_[0]); } +sub isNewIPv4 { +print "NOT DEFINE\n" unless defined $_[0]; + my $naddr = $_[0] ^ $_newV4compat; + return isIPv4($naddr); +} + +sub isAnyIPv4 { + my $naddr = $_[0]; + my $rv = isIPv4($_[0]); + return $rv if $rv; + return isNewIPv4($naddr); +} + +sub inet_4map6 { + my $naddr = shift; + if (length($naddr) == 4) { + $naddr = ipv4to6($naddr); + } + elsif (length($naddr) == 16) { + ; # is OK + return undef unless isAnyIPv4($naddr); + } else { + return undef; + } + $naddr |= $_newV4compat; + return $naddr; +} + 1; + __END__ =head1 NAME @@ -234,8 +291,11 @@ inet_any2n hasbits isIPv4 + isNewIPv4 + isAnyIPv4 inet_n2dx inet_n2ad + inet_4map6 ipv4to6 mask4to6 ipanyto6 @@ -256,19 +316,19 @@ :inet => inet_aton, inet_ntoa, ipv6_aton, ipv6_n2x, ipv6_n2d, inet_any2n, - inet_n2dx, inet_n2ad, ipv4to6, - mask4to6, ipanyto6, maskanyto6, - ipv6to4, naip_gethostbyname + inet_n2dx, inet_n2ad, inet_4map6, + ipv4to6, mask4to6, ipanyto6, + maskanyto6, ipv6to4, naip_gethostbyname :ipv4 => inet_aton, inet_ntoa :ipv6 => ipv6_aton, ipv6_n2x, ipv6_n2d, inet_any2n, inet_n2dx, inet_n2ad - ipv4to6, mask4to6, ipanyto6, + inet_4map6, ipv4to6, mask4to6, ipanyto6, maskanyto6, ipv6to4, naip_gethostbyname - :math => hasbits, isIPv4, addconst, - add128, sub128, notcontiguous, + :math => hasbits, isIPv4, isNewIPv4, isAnyIPv4, + addconst, add128, sub128, notcontiguous, bin2bcd, bcd2bin, shiftleft $dotquad = inet_ntoa($netaddr); @@ -277,8 +337,11 @@ $hex_text = ipv6_n2x($ipv6naddr); $dec_text = ipv6_n2d($ipv6naddr); $ipv6naddr = inet_any2n($dotquad or $ipv6_text); + $ipv6naddr = inet_4map6($netaddr or $ipv6naddr); $rv = hasbits($bits128); $rv = isIPv4($bits128); + $rv = isNewIPv4($bits128); + $rv = isAnyIPv4($bits128); $dotquad or $hex_text = inet_n2dx($ipv6naddr); $dotquad or $dec_text = inet_n2ad($ipv6naddr); $ipv6naddr = ipv4to6($netaddr); @@ -456,11 +519,44 @@ input: 128 bit IPv6 string returns: true if any bits are present +=item * $ipv6naddr = inet_4map6($netaddr or $ipv6naddr + +This function returns an ipV6 network address with the first 80 bits +set to zero and the next 16 bits set to one, while the last 32 bits +are filled with the ipV4 address. + + input: ipV4 netaddr + or ipV6 netaddr + returns: ipV6 netaddr + + returns: undef on error + +An ipV6 network address must be in one of the two compatible ipV4 +mapped address spaces. i.e. + + ::ffff::d.d.d.d or ::d.d.d.d + =item * $rv = isIPv4($bits128); This function returns true if there are no on bits present in the IPv6 portion of the 128 bit string and false otherwise. + i.e. the address must be of the form - ::d.d.d.d + +Note: this is an old and deprecated ipV4 compatible ipV6 address + +=item * $rv = isNewIPv4($bits128); + +This function return true if the IPv6 128 bit string is of the form + + ::ffff::d.d.d.d + +=item * $rv = isAnyIPv4($bits128); + +This function return true if the IPv6 bit string is of the form + + ::d.d.d.d or ::ffff::d.d.d.d + =item * $dotquad or $hex_text = inet_n2dx($ipv6naddr); This function B and returns the text for either a @@ -664,6 +760,11 @@ Replacement for Perl's gethostbyname if Socket6 is available +This function ALWAYS returns an IPv6 address, even on IPv4 only systems. +IPv4 addresses are mapped into IPv6 space in the form: + + ::FFFF:FFFF:d.d.d.d + =item * NetAddr::IP::Util::lower(); Return IPv6 strings in lowercase. @@ -777,8 +878,11 @@ inet_any2n hasbits isIPv4 + isNewIPv4 + isAnyIPv4 inet_n2dx inet_n2ad + inet_4map6 ipv4to6 mask4to6 ipanyto6 diff --git a/Lite/Util/t/inet_4map6.t b/Lite/Util/t/inet_4map6.t new file mode 100644 index 0000000..550ff00 --- /dev/null +++ b/Lite/Util/t/inet_4map6.t @@ -0,0 +1,70 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) +$| = 1; +END {print "1..1\nnot ok 1\n" unless $test;} + +#use diagnostics; +use NetAddr::IP::Util qw( + ipv6_n2d + inet_aton + ipv6_aton + inet_4map6 +); + +$test = 1; + +sub ok { + print "ok $test\n"; + ++$test; +} + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): +print "1..6\n"; + +my @stuff = qw( + 192.168.1.1 + 1.2.3.4 + ::3.4.5.6 + ::FFFF:FFFF:4.5.6.7 + ::1:5.4.3.2 + ::FEFF:FFFF:4.3.2.1 +); + + my $p4 = '0:0:0:0:FFFF:FFFF:'; + my $p6 = '0:0:0:0:'; + + foreach(0..$#stuff) { + my $pass = 1; + my $result; + my $bstr; + $pass = 0 if $_ > 3; + if ($stuff[$_] =~ /\:/) { + $bstr = ipv6_aton($stuff[$_]); + my $prefix = ($stuff[$_] =~ /^\:\:F/) + ? $p6 : $p4; + ($result = $stuff[$_]) =~ s/\:\:/$prefix/; + } + else { + $bstr = inet_aton($stuff[$_]); + $result = $p4 . $stuff[$_]; + } + my $rv = inet_4map6($bstr); + if ($pass && ! $rv) { + print "failed to return valid address\nnot "; + } + elsif ($pass) { + $rv = ipv6_n2d($rv); + print "got: $rv, exp: $result\nnot " unless $rv eq $result; + } + else { + print 'unknown return ', ipv6_n2d($rv), "\nnot " if $rv; + } + &ok; + } + diff --git a/Lite/Util/t/isIPv4.t b/Lite/Util/t/isIPv4.t index dce3a5d..c1a6f5c 100644 --- a/Lite/Util/t/isIPv4.t +++ b/Lite/Util/t/isIPv4.t @@ -5,13 +5,15 @@ # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) -BEGIN { $| = 1; print "1..106\n"; } +BEGIN { $| = 1; print "1..421\n"; } END {print "not ok 1\n" unless $loaded;} use NetAddr::IP::Util qw( ipv6_aton ipv6_n2x isIPv4 + isNewIPv4 + isAnyIPv4 ); $loaded = 1; @@ -138,6 +140,8 @@ ::1 ); +# check isIPv4 + foreach (@num) { my $bstr = ipv6_aton($_); my $rv = isIPv4($bstr); @@ -146,3 +150,37 @@ unless $rv eq $exp; &ok; } + +# check isAnyIPv4 +foreach (@num) { + my $bstr = ipv6_aton($_); + my $rv = isAnyIPv4($bstr); + my $exp = ($_ =~ /\d::$/) ? 0:1; + print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot " + unless $rv eq $exp; + &ok; +} + +my $compat = ipv6_aton('::FFFF:FFFF:0:0'); + +# check isAnyIPv4 with compatible high bits +foreach (@num) { + my $bstr = ipv6_aton($_); + $bstr ^= $compat; + my $rv = isAnyIPv4($bstr); + my $exp = ($_ =~ /\d::$/) ? 0:1; + print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot " + unless $rv eq $exp; + &ok; +} + +# check isNewIPv4 with compatible high bits +foreach (@num) { + my $bstr = ipv6_aton($_); + $bstr ^= $compat; + my $rv = isNewIPv4($bstr); + my $exp = ($_ =~ /\d::$/) ? 0:1; + print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot " + unless $rv eq $exp; + &ok; +} diff --git a/Lite/bug2742981.pl b/Lite/bug2742981.pl new file mode 100755 index 0000000..fa420b8 --- /dev/null +++ b/Lite/bug2742981.pl @@ -0,0 +1,96 @@ +#!/usr/bin/perl +use Math::BigInt; +use NetAddr::IP::Util qw( + bcd2bin + ipv6_n2x +); + +my $data = q| + got: '340282366920938963520000944000010176000' +# expected: '340282366920938463463374607431768211455' + +# Failed test 'cafe:cafe::/64 Scalar numeric ok' +# at t/v6-numeric.t line 57. +# got: '269827015721314205120005577600083392000' +# expected: '269827015721314068804783158349174669312' + +# Failed test 'cafe:cafe::/64 Array numeric ok for network' +# at t/v6-numeric.t line 58. +# got: '269827015721314205120005577600083392000' +# expected: '269827015721314068804783158349174669312' + +# Failed test 'cafe:cafe::/64 Array numeric ok for mask' +# at t/v6-numeric.t line 59. +# got: '340282366920938963520000944000010176000' +# expected: '340282366920938463444927863358058659840' + +# Failed test 'cafe:cafe::1/64 Scalar numeric ok' +# at t/v6-numeric.t line 57. +# got: '269827015721314205120005577600083392000' +# expected: '269827015721314068804783158349174669313' + +# Failed test 'cafe:cafe::1/64 Array numeric ok for network' +# at t/v6-numeric.t line 58. +# got: '269827015721314205120005577600083392000' +# expected: '269827015721314068804783158349174669313' + +# Failed test 'cafe:cafe::1/64 Array numeric ok for mask' +# at t/v6-numeric.t line 59. +# got: '340282366920938963520000944000010176000' +# expected: '340282366920938463444927863358058659840' + +# Failed test 'dead:beef::/100 Scalar numeric ok' +# at t/v6-numeric.t line 57. +# got: '295990755014136299520006003200014752000' +# expected: '295990755014133383690938178081940045824' + +# Failed test 'dead:beef::/100 Array numeric ok for network' +# at t/v6-numeric.t line 58. +# got: '295990755014136299520006003200014752000' +# expected: '295990755014133383690938178081940045824' + +# Failed test 'dead:beef::/100 Array numeric ok for mask' +# at t/v6-numeric.t line 59. +# got: '340282366920938963520000944000010176000' +# expected: '340282366920938463463374607431499776000' + +# Failed test 'dead:beef::1/100 Scalar numeric ok' +# at t/v6-numeric.t line 57. +# got: '295990755014136299520006003200014752000' +# expected: '295990755014133383690938178081940045825' + +# Failed test 'dead:beef::1/100 Array numeric ok for network' +# at t/v6-numeric.t line 58. +# got: '295990755014136299520006003200014752000' +# expected: '295990755014133383690938178081940045825' + +# Failed test 'dead:beef::1/100 Array numeric ok for mask' +# at t/v6-numeric.t line 59. +# got: '340282366920938963520000944000010176000' +# expected: '340282366920938463463374607431499776000' +|; + +my @trial = split("\n",$data); +my @data; +foreach(@trial) { + if ($_ =~ /(?:got|expected)\:\s+\'(\d+)/) { + push @data,$1; + } +} + +#for(my $i=0;$i <= $#data;$i +=2) { +# print $data[$i]," -\n"; +# print $data[$i +1]," =\n"; +# my $x = Math::BigInt->new($data[$i]); +# my $y = Math::BigInt->new($data[$i +1]); +# $x->bsub($y); +# print $x,"\n\n"; +#} + +for(my $i=0;$i <= $#data;$i +=2) { + my $x = ipv6_n2x(bcd2bin($data[$i])); + print $data[$i],"\t=> $x\n"; + my $y = ipv6_n2x(bcd2bin($data[$i +1])); + print $data[$i +1],"\t=> $y\n"; +} + diff --git a/MANIFEST b/MANIFEST index a244f47..bb3f3f6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -139,4 +139,10 @@ t/v6-splitplan.t t/wildcard.t TODO +Lite/bug2742981.pl +Lite/MANIFEST +Lite/MANIFEST.SKIP +Lite/Util/MANIFEST +Lite/Util/MANIFEST.SKIP +Lite/Util/t/inet_4map6.t META.yml Module meta-data (added by MakeMaker) diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 9c60227..88bb381 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -28,3 +28,4 @@ config\.h$ config\.status localperl\.h +Lite/bug2742981.pl diff --git a/META.yml b/META.yml index 4af6471..759906e 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- #YAML:1.0 name: NetAddr-IP -version: 4.044 +version: 4.045 abstract: Manages IPv4 and IPv6 addresses and subnets license: ~ author: