diff --git a/Changes b/Changes index 09c9b52..8528cf4 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,10 @@ Revision history for Perl extension NetAddr::IP +4.070 Thu Sep 12 12:54:22 PDT 2013 + nth documention error fixed. thanks to Anton tobez@tobez.org + + Lite v1.51, add new6FFFF, RFC4291 compliant ipv4->ipV6 new + 4.069 Sat May 25 15:10:45 PDT 2013 IN Lite.pm v1.50, add =encoding UTF-8 In Util.pm v1.50 diff --git a/IP.pm b/IP.pm index 574af23..6ba1863 100644 --- a/IP.pm +++ b/IP.pm @@ -5,8 +5,8 @@ use strict; #use diagnostics; use Carp; -use NetAddr::IP::Lite 1.48 qw(Zero Zeros Ones V4mask V4net); -use NetAddr::IP::Util 1.49 qw( +use NetAddr::IP::Lite 1.51 qw(Zero Zeros Ones V4mask V4net); +use NetAddr::IP::Util 1.50 qw( sub128 inet_aton inet_any2n @@ -37,7 +37,7 @@ @ISA = qw(Exporter NetAddr::IP::Lite); -$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.69 $ =~ /\d+/g) }; +$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.70 $ =~ /\d+/g) }; $rfc3021 = 0; @@ -1322,8 +1322,8 @@ 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) == 10.0.0.0/32 - NetAddr::IP->new('10/31')->nth(1) == 10.0.0.1/32 + NetAddr::IP->new('10/31')->nth(0) == 10.0.0.0/31 + NetAddr::IP->new('10/31')->nth(1) == 10.0.0.1/31 NetAddr::IP->new('10/30')->nth(0) == 10.0.0.1/30 NetAddr::IP->new('10/30')->nth(1) == 10.0.0.2/30 NetAddr::IP->new('10/30')->nth(2) == undef diff --git a/Lite/Changes b/Lite/Changes index 666ecd9..d4206fb 100644 --- a/Lite/Changes +++ b/Lite/Changes @@ -1,5 +1,8 @@ Revision history for Perl extension NetAddr::IP::Lite +1.51 Thu Sep 12 12:54:22 PDT 2013 + add new6FFFF, RFC4291 compliant ipv4->ipV6 new + 1.50 Sat May 25 15:10:45 PDT 2013 add =encoding UTF-8 diff --git a/Lite/Lite.pm b/Lite/Lite.pm index fcdefda..a01e67b 100644 --- a/Lite/Lite.pm +++ b/Lite/Lite.pm @@ -32,7 +32,7 @@ use vars qw(@ISA @EXPORT_OK $VERSION $Accept_Binary_IP $Old_nth $AUTOLOAD *Zero); -$VERSION = do { my @r = (q$Revision: 1.50 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.51 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; require Exporter; @@ -199,6 +199,7 @@ my $_ones = ~$_zero; my $_v4mask = pack('L4',0xffffffff,0xffffffff,0xffffffff,0); my $_v4net = ~ $_v4mask; +my $_ipv4FFFF = pack('N4',0,0,0xffff,0); sub Zeros() { return $_zero; @@ -508,6 +509,8 @@ =item C<-Enew6([$addr, [ $mask]])> +=item C<-Enew6FFFF([$addr, [ $mask]])> + =item C<-Enew_no([$addr, [ $mask]])> =item C<-Enew_from_aton($netaddr)> @@ -518,9 +521,14 @@ =item C<-Enew_cis6("$addr $mask)> -The first two methods create a new address with the supplied address in +The first three 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. + +new6FFFF specifically returns an IPv4 address in IPv6 format according to RFC4291 + + new6 ::xxxx:xxxx + new6FFFF ::FFFF:xxxx:xxxx The third method C is exclusively for IPv4 addresses and filters improperly formatted @@ -703,6 +711,12 @@ goto &_xnew; } +sub new6FFFF($;$$) { + my $ip = _xnew(1,@_); + $ip->{addr} |= $_ipv4FFFF; + return $ip; +} + sub new_cis($;$$) { my @in = @_; if ( $in[1] && $in[1] =~ m!^(.+)\s+(.+)$! ) { diff --git a/Lite/MANIFEST b/Lite/MANIFEST index 3970664..b6f2fdd 100644 --- a/Lite/MANIFEST +++ b/Lite/MANIFEST @@ -19,6 +19,7 @@ t/contains.t t/copy.t t/firstlast.t +t/ipv4FFFF.t t/lemasklen.t t/loops.t t/lower.t diff --git a/Lite/README b/Lite/README index f3d55e5..1cad531 100644 --- a/Lite/README +++ b/Lite/README @@ -187,14 +187,22 @@ "->new([$addr, [ $mask|IPv6 ]])" "->new6([$addr, [ $mask]])" + "->new6FFFF([$addr, [ $mask]])" "->new_no([$addr, [ $mask]])" "->new_from_aton($netaddr)" new_cis and new_cis6 are DEPRECATED "->new_cis("$addr $mask)" "->new_cis6("$addr $mask)" - The first two methods create a new address with the supplied address - in "$addr" and an optional netmask "$mask", which can be omitted to - get a /32 or /128 netmask for IPv4 / IPv6 addresses respectively. + The first three methods create a new address with the supplied + address in "$addr" and an optional netmask "$mask", which can be + omitted to get a /32 or /128 netmask for IPv4 / IPv6 addresses + respectively. + + new6FFFF specifically returns an IPv4 address in IPv6 format + according to RFC4291 + + new6 ::xxxx:xxxx + new6FFFF ::FFFF:xxxx:xxxx The third method "new_no" is exclusively for IPv4 addresses and filters improperly formatted dot quad strings for leading 0's that diff --git a/Lite/t/ipv4FFFF.t b/Lite/t/ipv4FFFF.t new file mode 100644 index 0000000..bbea1a0 --- /dev/null +++ b/Lite/t/ipv4FFFF.t @@ -0,0 +1,18 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..1\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $ip = new6FFFF NetAddr::IP::Lite('127.0.0.1'); +my $exp = '0:0:0:0:0:FFFF:7F00:1/128'; +print "got: $ip\nexp: $exp\nnot " + unless "$ip" eq $exp; +&ok; diff --git a/MANIFEST b/MANIFEST index 8865865..2e72d4b 100644 --- a/MANIFEST +++ b/MANIFEST @@ -59,6 +59,7 @@ Lite/t/contains.t Lite/t/copy.t Lite/t/firstlast.t +Lite/t/ipv4FFFF.t Lite/t/lemasklen.t Lite/t/loops.t Lite/t/lower.t diff --git a/META.yml b/META.yml index f5ec1aa..f1ec3e3 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- #YAML:1.0 name: NetAddr-IP -version: 4.069 +version: 4.070 abstract: Manages IPv4 and IPv6 addresses and subnets license: ~ author: