Changes of Revision 2
[-] | Added | perl-Net-IPv4Addr.spec |
x 1
2 +Name: perl-Net-IPv4Addr 3 +Version: 0.10 4 +Release: 1 5 +License: GPL 6 +Group: Development/Libraries/Perl 7 +Summary: Perl module Net::IPv4Addr 8 +URL: http://search.cpan.org/~luismunoz/ 9 +Source0: Net-IPv4Addr-%{version}.tar.gz 10 +BuildRoot: %{_tmppath}/%{name}-%{version}-build 11 +BuildRequires: glibc-devel libgcc gcc gcc-c++ perl 12 + 13 +%if 0%{?fedora_version} >= 7 14 +BuildRequires: perl-ExtUtils-MakeMaker 15 +%endif 16 + 17 +%description 18 +Perl extension for manipulating IPv4 addresses. 19 + 20 +%prep 21 +%setup -q -n Net-IPv4Addr-%{version} 22 + 23 +%build 24 +CFLAGS="%{optflags}" %{__perl} Makefile.PL INSTALLDIRS="vendor" PREFIX="%{_prefix}" 25 +%{__make} %{?_smp_mflags} OPTIMIZE="%{optflags}" 26 + 27 +%install 28 +%__make DESTDIR=%{buildroot} install 29 + 30 +### Clean up buildroot 31 +%{__rm} -rf %{buildroot}%{perl_archlib} \ 32 + %{buildroot}%{perl_vendorarch}/auto/*{,/*{,/*}}/.packlist 33 + 34 +%clean 35 +rm -rf $RPM_BUILD_ROOT/* 36 +rm -rf $RPM_BUILD_DIR/%{name}* 37 + 38 + 39 +%files 40 +%defattr(-,root,root) 41 +%doc README 42 +%dir %{perl_vendorlib}/Net 43 +%{perl_vendorlib}/Net/IPv4Addr.pm 44 +%{_mandir}/man3/Net::IPv4Addr.3pm* 45 +%{_bindir}/ipv4calc 46 +%dir %{perl_vendorlib}/auto/Net 47 +%dir %{perl_vendorlib}/auto/Net/IPv4Addr 48 +%{perl_vendorlib}/auto/Net/IPv4Addr/autosplit.ix 49 +%{_mandir}/man1/ipv4calc.1* 50 + 51 +%changelog 52 +* Sun May 31 2009 Carsten Schoene <cs@linux-administrator.com> - 0.1100 53 +- initial build. 54 |
||
[+] | Deleted | perl-Net-IPv6Addr.spec ^ |
@@ -1,56 +0,0 @@ -Name: perl-Net-IPv6Addr -Version: 0.2 -Release: 1 -License: GPL -Group: Development/Libraries/Perl -Summary: Perl module Net::IPv6Addr -URL: http://search.cpan.org/~luismunoz/ -Source0: Net-IPv6Addr-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: glibc-devel libgcc gcc gcc-c++ perl -#BuildRequires: perl(Net::IPv4Addr) -#BuildRequires: perl(Math::Base85) - -%if 0%{?fedora_version} >= 7 -BuildRequires: perl-ExtUtils-MakeMaker -%endif - -%description -Net::IPv6Addr provides functions for parsing IPv6 addresses in all -formats described by RFC1884. If Math::Base85 is installed, formats -described in RFC1924 are also valid. It will generate "IP6.INT." -strings (as described in RFC1886) if you are inclined to play with -DNS records. - -This module needs Net::IPv4Addr to function properly. - - -%prep -%setup -q -n Net-IPv6Addr-%{version} - -%build -CFLAGS="%{optflags}" %{__perl} Makefile.PL INSTALLDIRS="vendor" PREFIX="%{_prefix}" -%{__make} %{?_smp_mflags} OPTIMIZE="%{optflags}" - -%install -%__make DESTDIR=%{buildroot} install - -### Clean up buildroot -%{__rm} -rf %{buildroot}%{perl_archlib} \ - %{buildroot}%{perl_vendorarch}/auto/*{,/*{,/*}}/.packlist - -%clean -rm -rf $RPM_BUILD_ROOT/* -rm -rf $RPM_BUILD_DIR/%{name}* - - -%files -%defattr(-,root,root) -%doc README -%dir %{perl_vendorlib}/Net -%{perl_vendorlib}/Net/IPv6Addr.pm -%{_mandir}/man3/Net::IPv6Addr.3pm* - -%changelog -* Sun May 31 2009 Carsten Schoene <cs@linux-administrator.com> - 0.2 -- initial build. | ||
[+] | Changed | Net-IPv4Addr-0.10.tar.gz/ChangeLog ^ |
@@ -1,15 +1,90 @@ -2002-05-03 Tony Monroe <tmonroe+perl@nog.net> (0.2) +2000-08-01 Francis J. Lacoste <francis.lacoste@iNsu.COM> - * Many patches from Jyrki Soini <jyrki.soini@sonera.com>, - fixing bugs and adding features! + * Tag: IPV4ADDR_0_10 -2001-07-20 Tony Monroe <tmonroe+perl@nog.net> (0.1) + * IPv4Addr.spec: Updated for version 0.10. + Updated spec file to use new macros. - * Based on Net::IPv4Addr version 0.10. - Author: Francis J. Lacoste <francis.lacoste@iNsu.COM> + * IPv4Addr.pm (ipv4_network): Bad network for 0.0.0.0/0. + (ipv4_broadcast): Bad broadcast for 0.0.0.0/0. + (ipv4_in_network): 0.0.0.0/0 was included in any nets. + (VERSION): Updated version number to 0.10. - * Passes all basic tests. + * NEWS: News for 0.10. - * Takes any input or output format described by RFC1884 or RFC1924. + * README: Updated version number to 0.10. + + * test.pl: Added test for ipv4_in_network( anything, 0.0.0.0/0). + + * debian/rules: Merged changes from Bernd +. + * debian/changelog: Merged changes from Bernd. + + * debian/control: Merged changes from Bernd. + + * IPv4Addr.pm: Copyright mods. + +2000-07-27 Francis J. Lacoste <francis.lacoste@iNsu.COM> + + * IPv4Addr (%EXPORT_TAGS): ipv4_chkip was exported + under the wrong name. + +2000-05-03 Francis J. Lacoste <francis.lacoste@iNsu.COM> + * Tag: IPV4ADDR_0_09 + + * test.pl: Added test for different class networks. + + * IPv4Addr.pm (ipv4_in_network) Fixed bug where + comparison between network that differ + by more than an octet failed. + (version) Incremented version number + to 0.09. + +1999-12-15 Francis J. Lacoste <francis.lacoste@iNsu.COM> + + * Tag: IPV4ADDR_0_08 + + * IPv4Addr.pm: Moved require statement inside BEGIN to + fix problems with ipv4calc. + + Incremented version number to 0.08. + +1999-10-19 Francis J. Lacoste <francis.lacoste@iNsu.COM> + + TAG: IPV4ADDR_0_07 + + * debian/: Added debian packaging by Bernd Eckenfels + <ecki@lina.inka.de> + + TAG: IPV4ADDR_0_06 + + * IPv4Addr.pm: Renamed module to Net::IPv4Addr. + +1999-09-15 Francis J. Lacoste <francis.lacoste@iNsu.COM> + + * IPv4Addr.pm: Corrected errors in the documentation. + + TAG: IPV4ADDR_0_05. + +1999-08-15 Francis J. Lacoste <francis.lacoste@iNsu.COM> + + * IPv4Addr.pm (ipv4_in_netwrok): Fixed broken logic + of ipv4_in_network. It didn't handle + correctly network which weren't of + the same size. + + TAG: IPV4ADDR_0_04. + +1999-07-05 Francis J. Lacoste <francis.lacoste@iNsu.COM> + + * IPv4Addr.pm (ipv4_in_network): Added check for universal + broadcast address (255.255.255.255) and + no address (0.0.0.0). + + TAG: IPV4ADDR_0_03. + +1999-05-27 Francis J. Lacoste <francis.lacoste@iNsu.COM> + + * IPv4Addr.pm: (ipv4_parse) removed some undefined warnings. + Updated version to 0.02. - * Automatically generates those pesky IP6.INT. strings (RFC1886). | ||
[+] | Added | Net-IPv4Addr-0.10.tar.gz/IPv4Addr.pm ^ |
@@ -0,0 +1,385 @@ +# IPv4Addr.pm - Perl module to manipulate IPv4 addresses. +# +# Author: Francis J. Lacoste <francis.lacoste@iNsu.COM> +# +# Copyright (C) 1999, 2000 iNsu Innovations Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms as perl itself. +# + +package Net::IPv4Addr; + +use strict; +use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); + +BEGIN { + require Exporter; + require AutoLoader; + + @ISA = qw(Exporter AutoLoader); + + @EXPORT = qw(); + + %EXPORT_TAGS = ( + all => [qw{ ipv4_parse ipv4_chkip + ipv4_network ipv4_broadcast + ipv4_cidr2msk ipv4_msk2cidr + ipv4_in_network ipv4_dflt_netmask + } ], + ); + + @EXPORT_OK = qw(); + + Exporter::export_ok_tags('all'); + + $VERSION = '0.10'; +} + +# Preloaded methods go here. +use Carp; + +# Functions to manipulate IPV4 address +my $ip_rgx = "\\d+\\.\\d+\\.\\d+\\.\\d+"; + +# Given an IPv4 address in host, ip/netmask or cidr format +# returns a ip / cidr pair. +sub ipv4_parse($;$) { + my ($ip,$msk); + # Called with 2 args, assume first is IP address + if ( defined $_[1] ) { + $ip = $_[0]; + $msk= $_[1]; + } else { + ($ip) = $_[0] =~ /($ip_rgx)/o; + ($msk) = $_[0] =~ m!/(.+)!o; + } + + # Remove white spaces + $ip = ipv4_chkip( $ip ) or + croak __PACKAGE__, ": invalid IPv4 address: ", $ip, "\n"; + $msk =~ s/\s//g if defined $msk; + + # Check Netmask to see if it is a CIDR or Network + if (defined $msk ) { + if ($msk =~ /^\d{1,2}$/) { + # Check cidr + croak __PACKAGE__, ": invalid cidr: ", $msk, "\n" + if $msk < 0 or $msk > 32; + } elsif ($msk =~ /^$ip_rgx$/o ) { + $msk = ipv4_msk2cidr($msk); + } else { + croak __PACKAGE__, ": invalid netmask specification: ", $msk, "\n"; + } + } else { + # Host + return $ip; + } + wantarray ? ($ip,$msk) : "$ip/$msk"; +} + +sub ipv4_dflt_netmask($) { + my ($ip) = ipv4_parse($_[0]); + + my ($b1) = split /\./, $ip; + + return "255.0.0.0" if $b1 <= 127; + return "255.255.0.0" if $b1 <= 191; + return "255.255.255.0"; +} + +# Check form a valid IPv4 address. +sub ipv4_chkip($) { + my ($ip) = $_[0] =~ /($ip_rgx)/o; + + return undef unless $ip; + + # Check that bytes are in range + for (split /\./, $ip ) { + return undef if $_ < 0 or $_ > 255; + } + return $ip; +} + +# Transform a netmask in a CIDR mask length +sub ipv4_msk2cidr($) { + my $msk = ipv4_chkip( $_[0] ) + or croak __PACKAGE__, ": invalid netmask: ", $_[0], "\n"; + + my @bytes = split /\./, $msk; + + my $cidr = 0; + for (@bytes) { + my $bits = unpack( "B*", pack( "C", $_ ) ); + $cidr += $bits =~ tr /1/1/; + } + return $cidr; +} + +# Transform a CIDR mask length in a netmask +sub ipv4_cidr2msk($) { + my $cidr = shift; + croak __PACKAGE__, ": invalid cidr: ", $cidr, "\n" + if $cidr < 0 or $cidr > 32; + + my $bits = "1" x $cidr . "0" x (32 - $cidr); + + return join ".", (unpack 'CCCC', pack("B*", $bits )); +} + +# Return the network address of +# an IPv4 address +sub ipv4_network($;$) { + my ($ip,$cidr) = ipv4_parse( $_[0], $_[1] ); + + # If only an host is given, use the default netmask + unless (defined $cidr) { + $cidr = ipv4_msk2cidr( ipv4_dflt_netmask($ip) ); + } + my $u32 = unpack "N", pack "CCCC", split /\./, $ip; + my $bits = "1" x $cidr . "0" x (32 - $cidr ); + + my $msk = unpack "N", pack "B*", $bits; + + my $net = join ".", unpack "CCCC", pack "N", $u32 & $msk; + + wantarray ? ( $net, $cidr) : "$net/$cidr"; +} + +sub ipv4_broadcast($;$) { + my ($ip,$cidr) = ipv4_parse( $_[0], $_[1] ); + + # If only an host is given, use the default netmask + unless (defined $cidr) { + $cidr = ipv4_msk2cidr( ipv4_dflt_netmask($ip) ); + } + + my $u32 = unpack "N", pack "CCCC", split /\./, $ip; + my $bits = "1" x $cidr . "0" x (32 - $cidr ); + + my $msk = unpack "N", pack "B*", $bits; + + my $broadcast = join ".", unpack "CCCC", pack "N", $u32 | ~$msk; + + $broadcast; +} + +sub ipv4_in_network($$;$$) { + my ($ip1,$cidr1,$ip2,$cidr2); + if ( @_ >= 3) { + ($ip1,$cidr1) = ipv4_parse( $_[0], $_[1] ); + ($ip2,$cidr2) = ipv4_parse( $_[2], $_[3] ); + } else { + ($ip1,$cidr1) = ipv4_parse( $_[0]); + ($ip2,$cidr2) = ipv4_parse( $_[1]); + } + + # Check for magic addresses. + return 1 if ($ip1 eq "255.255.255.255" or $ip1 eq "0.0.0.0") + and !defined $cidr1; + return 1 if ($ip2 eq "255.255.255.255" or $ip2 eq "0.0.0.0") + and !defined $cidr2; + + # Case where first argument is really an host + return $ip1 eq $ip2 unless (defined $cidr1); + + # Case where second argument is an host + if ( not defined $cidr2) { + return ipv4_network( $ip1, $cidr1) eq ipv4_network( $ip2, $cidr1 ); + } elsif ( $cidr2 >= $cidr1 ) { + # Network 2 is smaller or equal than network 1 + return ipv4_network( $ip1, $cidr1 ) eq ipv4_network( $ip2, $cidr1 ); + } else { + # Network 2 is bigger, so can't be wholly contained. + return 0; + } +} +# Autoload methods go after =cut, and are processed by the autosplit program. + +1; +__END__ +# Below is the stub of documentation for your module. You better edit it! +=pod + +=head1 NAME + +Net::IPv4Addr - Perl extension for manipulating IPv4 addresses. + +=head1 SYNOPSIS + + use Net::IPv4Addr qw( :all ); + + my ($ip,$cidr) = ipv4_parse( "127.0.0.1/24" ); + my ($ip,$cidr) = ipv4_parse( "192.168.100.10 / 255.255.255.0" ); + + my ($net,$msk) = ipv4_network( "192.168.100.30" ); + + my $broadcast = ipv4_broadcast( "192.168.100.30/26" ); + + if ( ipv4_in_network( "192.168.100.0", $her_ip ) ) { + print "Welcome !"; + } + + etc. + +=head1 DESCRIPTION + +Net::IPv4Addr provides functions for parsing IPv4 addresses both +in traditional address/netmask format and in the new CIDR format. +There are also methods for calculating the network and broadcast +address and also to see check if a given address is in a specific +network. + +=head1 ADDRESSES + +All of Net::IPv4Addr functions accepts addresses in many +format. The parsing is very liberal. + +All these addresses would be accepted: + + 127.0.0.1 + 192.168.001.010/24 + 192.168.10.10/255.255.255.0 + 192.168.30.10 / 21 + 10.0.0.0 / 255.0.0.0 + 255.255.0.0 + +Those wouldn't though: + + 272.135.234.0 + 192.168/16 + +Most functions accepts the address and netmask or masklength in the +same scalar value or as separate values. That is either + + my($ip,$masklength) = ipv4_parse($cidr_str); + my($ip,$masklength) = ipv4_parse($ip_str,$msk_str); + +=head1 USING + +No functions are exported by default. Either use the C<:all> tag +to import them all or explicitly import those you need. + +=head1 FUNCTIONS + +=over + +=item ipv4_parse + + my ($ip,$msklen) = ipv4_parse($cidr_str); + my $cidr = ipv4_parse($ip_str,$msk_str); + my ($ip) = ipv4_parse($ip_str,$msk_str); + +Parse an IPv4 address and in scalar context the address in CIDR +format and in an array context the address and the mask length. + +If the parameters doesn't contains a netmask or a mask length, +in scalar context only the IPv4 address is returned and in an +array context the mask length is undefined. + +If the function cannot parse its input, it croaks. Trap it using +C<eval> if don't like that. + +=item ipv4_network + + my $cidr = ipv4_network($ip_str); + my $cidr = ipv4_network($cidr_str); + my ($net,$msk) = ipv4_network( $net_str, $msk_str); + +In scalar context, this function returns the network in CIDR format in +which the address is. In array context, it returns the network address and +its mask length as a two elements array. If the input is an host without +a netmask of mask length, the default netmask is assumed. + +Again, the function croak if the input is invalid. + +=item ipv4_broadcast + + my ($broadcast) = ipv4_broadcast($ip_str); + my $broadcast = ipv4_broadcast($ip_str,$msk_str); + +This function returns the broadcast address. If the input doesn't +contains a netmask or mask length, the default netmask is assumed. + +This function croaks if the input is invalid. + +=item ipv4_network + + my $cidr = ipv4_network($net_str); + my $cidr = ipv4_network($cidr_sstr); + my ($net,$msk) = ipv4_network( $ip_str, $mask_str); + +In scalar context, this function returns the network in CIDR format in +which the address is. In array context, it returns the network address and +its mask length as a two elements array. If the input is an host without +a netmask or mask length, the default netmask is assumed. + +Again, the function croak if the input is invalid. + +=item ipv4_in_network + + print "Yes" if ipv4_in_network( $cidr_str1, $cidr_str2); + print "Yes" if ipv4_in_network( $ip_str1, $mask_str1, $cidr_str2 ); + print "Yes" if ipv4_in_network( $ip1, $mask1, $ip2, $msk2 ); + +This function checks if the second network is contained in +the first one and it implements the following semantics : + + If net1 or net2 is a magic address (0.0.0.0 or 255.255.255.255) + than this function returns true. + + If net1 is an host, net2 will be in the same net only if + it is the same host. + + If net2 is an host, it will be contained in net1 only if + it is part of net1. + + If net2 is only part of net1 if it is entirely contained in + net1. + +Trap bad input with C<eval> or else. + +=item ipv4_checkip + + if ($ip = ipv4_checkip($str) ) { + # Do something + } + +Return the IPv4 address in the string or undef if the input +doesn't contains a valid IPv4 address. + +=item ipv4_cidr2msk + + my $netmask = ipv4_cidr2msk( $cidr ); + +Returns the netmask corresponding to the mask length given in input. +As usual, croaks if it doesn't like your input (in this case a number +between 0 and 32). + +=item ipv4_msk2cidr + + my $masklen = ipv4_msk2cidr( $msk ); + +Returns the mask length of the netmask in input. As usual, croaks if it +doesn't like your input. + +=back + +=head1 AUTHOR + +Francis J. Lacoste <francis.lacoste@iNsu.COM> + +=head1 COPYRIGHT + +Copyright (c) 1999, 2000 iNsu Innovations Inc. +All rights reserved. + +This program is free software; you can redistribute it and/or modify +it under the terms as perl itself. + +=head1 SEE ALSO + +perl(1) ipv4calc(1). + +=cut + | ||
[+] | Added | Net-IPv4Addr-0.10.tar.gz/IPv4Addr.spec ^ |
@@ -0,0 +1,90 @@ +Summary: Perl modules to manipulates Ipv4 addresses. +Name: Net-IPv4Addr +Version: 0.10 +Release: 1i +Source: http://iNDev.iNsu.COM/sources/%{name}-%{version}.tar.gz +Copyright: GPL or Artistic License +Group: Development/Libraries +Prefix: /usr +URL: http://iNDev.iNsu.COM/IPv4Addr/ +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root +BuildArchitectures: noarch +Obsoletes: Network-IPv4Addr + +%description +Net::IPv4Addr provides methods for parsing IPv4 +addresses both in traditional address/netmask format and +in the new CIDR format. There are also methods for +calculating the network and broadcast address and also to +see check if a given address is in a specific network. + +%prep +%setup -q +%fix_perl_path + +%build +perl Makefile.PL +make OPTIMIZE="$RPM_OPT_FLAGS" +make test + +%install +rm -fr $RPM_BUILD_ROOT +%perl_make_install + +BuildDirList > %pkg_file_list +BuildFileList >> %pkg_file_list + +%clean +rm -fr $RPM_BUILD_ROOT + +%files -f %{name}-file-list +%defattr(-,root,root) +%doc README ChangeLog + +%changelog +* Tue Aug 01 2000 Francis J. Lacoste <francis.lacoste@iNsu.COM> + [0.10-1i] +- Updated to version 0.10. +- Updated spec file to use new macros. + +* Wed May 03 2000 Francis J. Lacoste <francis.lacoste@iNsu.COM> + [0.09-1i] +- Updated to version 0.09. +- Updated automatic file list generation. +- Changed group. + +* Wed Dec 15 1999 Francis J. Lacoste <francis.lacoste@iNsu.COM> + [0.08-1i] +- Updated to version 0.08. +- Added perl(Net::IPv4Addr) to list of Provides. +- Fixed Source URL. + +* Tue Oct 19 1999 Francis J. Lacoste <francis.lacoste@iNsu.COM> + [0.07-1i] +- Updated to version 0.07 + +* Tue Oct 19 1999 Francis J. Lacoste <francis.lacoste@iNsu.COM> + [0.06-1i] +- Updated to version 0.06. +- Renamed package to Net-IPv4Addr. + +* Wed Sep 15 1999 Francis J. Lacoste <francis.lacoste@iNsu.COM> + [0.05-1i] +- Updated to version 0.05. + +* Sun Aug 15 1999 Francis J. Lacoste <francis.lacoste@iNsu.COM> + [0.04-1i] +- Updated to version 0.04. + +* Mon Jul 05 1999 Francis J. Lacoste <francis.lacoste@iNsu.COM> + [0.03-1i] +- Updated to version 0.03. + +* Sat May 15 1999 Francis J. Lacoste <francis@iNsu.COM> + [0.02-2i] +- Updated to version 0.02. + +* Sat May 15 1999 Francis J. Lacoste <francis@iNsu.COM> + [0.01-1i] +- First RPM release. + | ||
[+] | Changed | Net-IPv4Addr-0.10.tar.gz/MANIFEST ^ |
@@ -1,17 +1,15 @@ +NEWS +README ChangeLog -IPv6Addr.pm +IPv4Addr.pm MANIFEST Makefile.PL -README -t/base85.t -t/chkip.t -t/compressed.t -t/ipv4.t -t/ipv4comp.t -t/new.t -t/parse.t -t/preferred.t -t/string.t -rfc1886.txt -rfc1924.txt -rfc2373.txt +test.pl +IPv4Addr.spec +ipv4calc +debian/changelog +debian/control +debian/copyright +debian/dirs +debian/docs +debian/rules | ||
[+] | Changed | Net-IPv4Addr-0.10.tar.gz/Makefile.PL ^ |
@@ -2,10 +2,7 @@ # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( - 'NAME' => 'Net::IPv6Addr', - 'VERSION_FROM' => 'IPv6Addr.pm', # finds $VERSION - 'PREREQ_PM' => { - 'Net::IPv4Addr' => 0, - 'Math::Base85' => 0 - }, + 'NAME' => 'Net::IPv4Addr', + 'VERSION_FROM' => 'IPv4Addr.pm', # finds $VERSION + 'EXE_FILES' => [ ipv4calc ], ); | ||
[+] | Added | Net-IPv4Addr-0.10.tar.gz/NEWS ^ |
@@ -0,0 +1,28 @@ +Net::IPv4Addr NEWS -- History of User-Visible Changes. May 03 2000 + +* Changes in IPv4Addr 0.10 + + - Fixed important errors which occurs when using + a /0 CIDR. Thanks to Bernd Eckenfels from Debian + for the fix. + + - Fixed : ipv4_in_network( anything, 0.0.0.0/0) was + returning true. Thanks to Bernd Eckenfels from Debian + for the fix. + + - ipv4_chkip wasn't exported with the all tag. + +* Changes in IPv4Addr 0.09 + + - Fixed an important bug in ipv4_in_network which caused + comparison between networks that where in different class + to fail. + +* Changes in IPv4Addr 0.07 + + - Debian packaging done by Bernd Eckenfels <ecki@lina.inka.de>. + +* Change in IPv4Addr 0.06 + + - Module was renamed to Net::IPv4Addr to better fit into CPAN hierarchy. + | ||
[+] | Changed | Net-IPv4Addr-0.10.tar.gz/README ^ |
@@ -1,35 +1,41 @@ -========================= -Net::IPv6Addr Version 0.1 -========================= +Net::IPv4Addr +================= -Net::IPv6Addr provides functions for parsing IPv6 addresses in all -formats described by RFC1884. If Math::Base85 is installed, formats -described in RFC1924 are also valid. It will generate "IP6.INT." -strings (as described in RFC1886) if you are inclined to play with -DNS records. +Version: 0.10 -This module needs Net::IPv4Addr to function properly. +Description +----------- -The usual installation instructions apply: +Net::IPv4Addr provides functions for parsing IPv4 addresses both +in traditional address/netmask format and in the new CIDR format. +There are also methods for calculating the network and broadcast +address and also to see check if a given address is in a specific +network. - /path/to/perl Makefile.PL +Installing +---------- + +The usual: + + perl Makefile.PL make - make test make install +Documentation +------------- + Documentation is included in pod format. -Please send bug reports and suggestions to the author at -<tmonroe plus perl at nog dot net>. +Bugs +---- + +Send bug reports and suggestions to bugs@iNsu.COM. + +Copyright +--------- ---------------------- -Copyright and License ---------------------- - -This distribution (with the exception of included RFC's) is copyright -(c) 2001-2002 Tony Monroe. All rights reserved. This software is -distributed under the same license terms as Perl itself. This -software comes with NO WARRANTIES WHATSOEVER, express, implied, or -otherwise. +Copyright (c) 1999,2000 iNsu Innovations Inc . +All rights reserved. -$Id: README,v 1.5 2002/08/06 21:35:26 tony Exp $ +This package is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. | ||
[+] | Added | Net-IPv4Addr-0.10.tar.gz/debian ^ |
+(directory) | ||
[+] | Added | Net-IPv4Addr-0.10.tar.gz/debian/changelog ^ |
@@ -0,0 +1,37 @@ +libnetwork-ipv4addr-perl (0.09-2) frozen unstable; urgency=high + + * fixed bug #66073 and fixed bug #66080 + * changed maintainer email address to @debian.org + * fixed section and standards version + + -- Bernd Eckenfels <ecki@debian.org> Sat, 22 Jul 2000 07:02:12 +0200 + + +libnetwork-ipv4addr-perl (0.09-1) frozen unstable; urgency=high + + * in this version #63482 is not visible anymore (fixed i guess) + * fixed security bug (#63529) + + -- Bernd Eckenfels <ecki@debian.org> Thu, 4 May 2000 05:50:32 +0200 + +libnetwork-ipv4addr-perl (0.07-2) unstable; urgency=low + + * fixed bug with 5.005 pl3 (Bug#49609:) thanks to Bitkoenig! + + -- Bernd Eckenfels <ecki@debian.org> Tue, 9 Nov 1999 03:05:41 +0100 + +libnetwork-ipv4addr-perl (0.07-1) unstable; urgency=low + + * new version, including a full working debian/ subdir, thanks Francis + + -- Bernd Eckenfels <ecki@debian.org> Sat, 23 Oct 1999 20:19:13 +0200 + +libnetwork-ipv4addr-perl (0.05-1) unstable; urgency=low + + * Initial Release. + + -- Bernd Eckenfels <ecki@debian.org> Sat, 25 Sep 1999 01:26:34 +0200 + +Local variables: +mode: debian-changelog +End: | ||
[+] | Added | Net-IPv4Addr-0.10.tar.gz/debian/control ^ |
@@ -0,0 +1,12 @@ +Source: libnetwork-ipv4addr-perl +Section: interpreters +Priority: optional +Maintainer: Bernd Eckenfels <ecki@debian.org> +Standards-Version: 3.0.1 + +Package: libnetwork-ipv4addr-perl +Architecture: all +Depends: ${perl:Depends} +Description: The Net::IPv4Addr perl module API and ipv4calc script + ipv4calc can be used to calculate netmask, broadcast and netaddress of + an IPv4 (Internet) address. | ||
[+] | Added | Net-IPv4Addr-0.10.tar.gz/debian/copyright ^ |
@@ -0,0 +1,14 @@ +This package was debianized by Bernd Eckenfels <ecki@lina.inka.de> on +Sat, 25 Sep 1999 01:26:34 +0200. + +It was downloaded from http://iNDev.iNsu.COM/IPv4Addr/ + +Upstream Author(s): Francis J. Lacoste <francis.lacoste@iNsu.COM> + +Copyright: + +Copyright (c) 1999 Francis J. Lacoste and iNsu Innovations Inc . +All rights reserved. + +This package is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. | ||
[+] | Added | Net-IPv4Addr-0.10.tar.gz/debian/dirs ^ |
@@ -0,0 +1,4 @@ +usr/bin +usr/lib/perl5/Net/ +usr/share/man/man1 +usr/share/man/man3 | ||
[+] | Added | Net-IPv4Addr-0.10.tar.gz/debian/docs ^ |
@@ -0,0 +1,4 @@ +README +NEWS +IPv4Addr.spec + | ||
[+] | Added | Net-IPv4Addr-0.10.tar.gz/debian/rules ^ |
@@ -0,0 +1,85 @@ +#!/usr/bin/make -f +#-*- makefile -*- +# Made with the aid of dh_make, by Craig Small +# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. +# Some lines taken from debmake, by Christoph Lameter. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# This is the debhelper compatability version to use. +export DH_COMPAT=1 + +ifndef PERL +PERL = /usr/bin/perl +endif + +TMP =`pwd`/debian/tmp +#archlib =`$(PERL) -MConfig -e 'print $$Config{installarchlib}'` +#config =INSTALLDIRS=perl INSTALLMAN1DIR=$(TMP)/usr/share/man/man1 INSTALLMAN3DIR=$(TMP)/usr/share/man/man3 INSTALLPRIVLIB=$(TMP)/usr/lib/perl5 INSTALLARCHLIB=$(TMP)$(archlib) + +build: build-stamp +build-stamp: + dh_testdir + # Add here commands to compile the package. + $(PERL) Makefile.PL + $(MAKE) + touch build-stamp + +clean: + dh_testdir + rm -f build-stamp install-stamp + # Add here commands to clean up after the build process. + -$(MAKE) clean + -rm -rf blib/ Makefile.old Makefile + dh_clean + +install: install-stamp +install-stamp: build-stamp + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + install -m 755 blib/script/ipv4calc debian/tmp/usr/bin + install -m 644 blib/lib/Net/IPv4Addr.pm debian/tmp/usr/lib/perl5/Net/IPv4Addr.pm + touch install-stamp + +# Build architecture-independent files here. +binary-indep: build install +# dh_testversion + dh_testdir + dh_testroot + dh_installdocs + dh_installexamples +# dh_installmenu +# dh_installemacsen +# dh_installpam + dh_installinit + dh_installcron + dh_installmanpages +# dh_installinfo +# dh_undocumented + dh_installchangelogs ChangeLog + dh_link + dh_strip + dh_compress + dh_fixperms + # You may want to make some executables suid here. + dh_suidregister +# dh_makeshlibs + dh_installdeb + dh_perl + dh_shlibdeps + dh_gencontrol + dh_md5sums + dpkg --build debian/tmp .. + +# Build architecture-dependent files here. +binary-arch: build install +# We have nothing to do by default. + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install | ||
[+] | Added | Net-IPv4Addr-0.10.tar.gz/ipv4calc ^ |
@@ -0,0 +1,89 @@ +#!/usr/bin/perl + +use strict; +use Net::IPv4Addr qw (:all); +use Getopt::Long; + +my %opts = (); + +sub usage() { + die <<EOU; +usage: ipv4calc [--network | --broadcast | --netmask | + --cidr | --address ] addr +EOU +} + +GetOptions( \%opts, "network", "broadcast", "netmask", "cidr", "address") + or usage; + +my $str = shift; +$str or usage; + +my ($ip,$cidr) = ipv4_parse($str); +my ($network,$msk) = ipv4_network($ip,$cidr); +my ($broadcast) = ipv4_broadcast($ip,$cidr); + +if ( $opts{network}) { + print $network,"\n"; +} elsif ($opts{broadcast}) { + print $broadcast,"\n"; +} elsif ( $opts{netmask} ) { + print ipv4_cidr2msk( $msk ), "\n"; +} elsif ( $opts{address} ) { + print $ip, "\n"; +} elsif ( $opts{cidr} ) { + print $msk, "\n"; +} else { + print <<EOF; +Host: $ip +Network: $network/$msk +Broadcast: $broadcast +EOF +} + +1; + +__END__ +# Below is the stub of documentation for your module. You better edit it! +=pod + +=head1 NAME + + ipv4calc - Calculates IPv4 elements from an address. + +=head1 SYNOPSIS + + ipv4calc [ --network | --broadcast | --netmask | + --address | --cidr ] addr + +=head1 DESCRIPTION + +If an option is specified B<ipv4calc> calculates the requested element +from the address and prints it on stdout. + +If multiple options are specified, only the first one is printed. + +If no options are specified, the program prints the host part of the +address, the network and the broadcast address as deduced from the +given address. + +If address doesn't contains a netmask or mask length, the default +one is assumed. + +=head1 AUTHOR + +Francis J. Lacoste <francis.lacoste@iNsu.COM> + +=head1 COPYRIGHT + +Copyright (c) 1999,2000 iNsu Innovations Inc. +All rights reserved. + +This program is free software; you can redistribute it and/or modify +it under the terms as perl itself. + +=head1 SEE ALSO + +Network::IPv4Addr(3). + +=cut | ||
[+] | Added | Net-IPv4Addr-0.10.tar.gz/test.pl ^ |
@@ -0,0 +1,68 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +use strict; +use Test; + +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { plan tests => 37 } +use Net::IPv4Addr qw(/^ipv4/); + + +# ipv4_parse +ok( scalar ipv4_parse( "127.0.0.1" ), "127.0.0.1" ); +ok( scalar ipv4_parse( "192.168.100.1 / 24" ), "192.168.100.1/24" ); +ok( scalar ipv4_parse( "130.10.2.10", "255.255.255.0"), "130.10.2.10/24"); +ok( scalar ipv4_parse( "130.10.2.10", "255.255.255.240"), "130.10.2.10/28"); +ok( scalar ipv4_parse( "130.10.2.10/28"), "130.10.2.10/28"); + +# ipv4_dftl_netmask +ok( ipv4_dflt_netmask( "127.0.0.1" ), "255.0.0.0" ); +ok( ipv4_dflt_netmask( "172.0.0.01" ), "255.255.0.0" ); +ok( ipv4_dflt_netmask( "198.0.0.20" ), "255.255.255.0" ); + +# ipv4_network +ok( scalar ipv4_network( "127.0.0.1"), "127.0.0.0/8" ); +ok( scalar ipv4_network( "192.168.100.10" ), "192.168.100.0/24" ); +ok( scalar ipv4_network( "192.168.100.100/255.255.255.192"), "192.168.100.64/26" ); + +# ipv4_broadcast +ok( ipv4_broadcast( "127.0.0.1"), "127.255.255.255" ); +ok( ipv4_broadcast( "192.168.100.10/24" ), "192.168.100.255" ); +ok( ipv4_broadcast( "192.168.100.100/255.255.255.192"), "192.168.100.127" ); + +# ipv4_in_network +ok( ipv4_in_network( "127.0.0.1", "127.0.0.1" ) ); +ok( not ipv4_in_network( "127.0.0.0/8", "192.168.30.1" )); +ok( not ipv4_in_network( "192.168.100.10", "192.168.100.30")); +ok( ipv4_in_network( "192.168.100.10/24", "192.168.100.255")); +ok( ipv4_in_network( "192.168.100.0/24", "192.168.100.0")); +ok( not ipv4_in_network( "192.16.100.63/26", "192.168.100.65")); +ok( ipv4_in_network( "192.168.100.0/24", "0.0.0.0" ) ); +ok( ipv4_in_network( "192.168.100.0/24", "255.255.255.255" ) ); +ok( ipv4_in_network( "0.0.0.0", "192.168.1.1" ) ); +ok( ipv4_in_network( "255.255.255.255", "192.176.1.8" ) ); +ok( ipv4_in_network( "192.168.199.0/30", "192.168.199.1" ) ); +ok( ipv4_in_network( "212.117.64.0/19", "212.117.65.42/28" ) ); +ok( !ipv4_in_network( "21.10.0.4/24", "0.0.0.0/0" ) ); + +# ipv4_cidr2msk +ok( ipv4_cidr2msk( 24 ), "255.255.255.0" ); +ok( ipv4_cidr2msk( 16 ), "255.255.0.0" ); +ok( ipv4_cidr2msk( 8 ), "255.0.0.0" ); +ok( ipv4_cidr2msk( 26 ), "255.255.255.192" ); +ok( ipv4_cidr2msk( 0 ), "0.0.0.0" ); +ok( ipv4_cidr2msk( 32 ), "255.255.255.255" ); + +# ipv4_msk2cidr +ok( ipv4_msk2cidr( "255.255.255.0" ), 24); +ok( ipv4_msk2cidr( "255.255.0.0" ), 16 ); +ok( ipv4_msk2cidr( "255.0.0.0" ), 8 ); +ok( ipv4_msk2cidr( "255.255.255.192" ), 26 ); +ok( ipv4_msk2cidr( "0.0.0.0" ), 0 ); +ok( ipv4_msk2cidr( "255.255.255.255" ), 32 ); + + + | ||
[+] | Deleted | Net-IPv6Addr-0.2.tar.gz/IPv6Addr.pm ^ |
@@ -1,836 +0,0 @@ -package Net::IPv6Addr; - -use strict; -use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - -use Carp; -use Net::IPv4Addr; - -BEGIN { - eval { - require Math::BigInt; - require Math::Base85; - }; -} - -=pod - -=head1 NAME - -Net::IPv6Addr -- check validity of IPv6 addresses - -=head1 SYNOPSIS - - use Net::IPv6Addr; - - Net::IPv6Addr::ipv6_parse($addr); - $x = new Net::IPv6Addr("dead:beef:cafe:babe::f0ad"); - print $x->to_string_preferred(), "\n"; - -=head1 DESCRIPTION - -C<Net::IPv6Addr> checks strings for valid IPv6 addresses, as -specified in RFC1884. You throw possible addresses at it, it -either accepts them or throws an exception. - -If C<Math::Base85> is installed, then this module is able to process -addresses formatted in the style referenced by RFC1924. - -The public interface of this module is rather small. - -=cut - -@ISA = qw(Exporter); - -@EXPORT = qw(); -@EXPORT_OK = qw(); - -$VERSION = '0.2'; - -# We get these formats from rfc1884: -# -# preferred form: x:x:x:x:x:x:x:x -# -# zero-compressed form: the infamous double-colon. -# Too many pattern matches to describe in this margin. -# -# mixed IPv4/IPv6 format: x:x:x:x:x:x:d.d.d.d -# -# mixed IPv4/IPv6 with compression: ::d.d.d.d or ::FFFF:d.d.d.d -# -# And we get these from rfc1924: -# -# base-85-encoded: [0-9A-Za-z!#$%&()*+-;<=>?@^_`{|}~]{20} -# - -my %ipv6_patterns = ( - 'preferred' => [ - qr/^(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}$/i, - \&ipv6_parse_preferred, - ], - 'compressed' => [ ## No, this isn't pretty. - qr/^[a-f0-9]{0,4}::$/i, - qr/^:(?::[a-f0-9]{1,4}){1,6}$/i, - qr/^(?:[a-f0-9]{1,4}:){1,6}:$/i, - qr/^(?:[a-f0-9]{1,4}:)(?::[a-f0-9]{1,4}){1,6}$/i, - qr/^(?:[a-f0-9]{1,4}:){2}(?::[a-f0-9]{1,4}){1,5}$/i, - qr/^(?:[a-f0-9]{1,4}:){3}(?::[a-f0-9]{1,4}){1,4}$/i, - qr/^(?:[a-f0-9]{1,4}:){4}(?::[a-f0-9]{1,4}){1,3}$/i, - qr/^(?:[a-f0-9]{1,4}:){5}(?::[a-f0-9]{1,4}){1,2}$/i, - qr/^(?:[a-f0-9]{1,4}:){6}(?::[a-f0-9]{1,4})$/i, - \&ipv6_parse_compressed, - ], - 'ipv4' => [ - qr/^(?:0:){5}ffff:(?:\d{1,3}\.){3}\d{1,3}$/i, - qr/^(?:0:){6}(?:\d{1,3}\.){3}\d{1,3}$/, - \&ipv6_parse_ipv4, - ], - 'ipv4 compressed' => [ - qr/^::(?:ffff:)?(?:\d{1,3}\.){3}\d{1,3}$/i, - \&ipv6_parse_ipv4_compressed, - ], -); - -# base-85 -if (defined $Math::Base85::base85_digits) { - my $digits; - ($digits = $Math::Base85::base85_digits) =~ s/-//; - my $x = "[" . $digits . "-]"; - my $n = "{20}"; - $ipv6_patterns{'base85'} = [ - qr/$x$n/, - \&ipv6_parse_base85, - ]; -} - -=pod - -=head1 new - -=head2 Parameters - -A string to be interpreted as an IPv6 address. - -=head2 Returns - -A C<Net::IPv6Addr> object if successful. - -=head2 Notes - -Throws an exception if the string isn't a valid address. - -=cut - -sub new -{ - my $proto = shift; - my $class = ref($proto) || $proto; - my $maybe_ip = shift; - my $parser = ipv6_chkip($maybe_ip); - if (ref $parser ne 'CODE') { - croak __PACKAGE__, "::new -- invalid IPv6 address $maybe_ip"; - } - my @hexadecets = $parser->($maybe_ip); - my $self = \@hexadecets; - bless $self, $class; - return $self; -} - -=pod - -=head1 ipv6_parse - -=head2 Parameters - -A string containing an IPv6 address string. Optionally, it may -also include a C</> character, and a numeric prefix length, in that -order. - - -or- - -An IPv6 address string. Optionally, a numeric prefix length. - -=head2 Returns - -What you gave it, more or less, if it does parse out correctly. - -=head2 Notes - -Throws an exception on malformed input. This is not an object -method or class method; it's just a subroutine. - -=cut - -sub ipv6_parse -{ - my ($ip, $pfx); - if (@_ == 2) { - ($ip, $pfx) = @_; - } else { - ($ip, $pfx) = split(m!/!, $_[0]) - } - - unless (ipv6_chkip($ip)) { - croak __PACKAGE__, "::ipv6_parse -- invalid IPv6 address $ip\n"; - } - - $pfx =~ s/\s+//g if defined($pfx); - - if (defined $pfx) { - if ($pfx =~ /^\d+$/) { - if (($pfx < 0) || ($pfx > 128)) { - croak __PACKAGE__, "::ipv6_parse -- invalid prefix length $pfx\n"; - } - } else { - croak __PACKAGE__, "::ipv6_parse -- non-numeric prefix length $pfx\n"; - } - } else { - return $ip; - } - wantarray ? ($ip, $pfx) : "$ip/$pfx"; -} - -=pod - -=head1 is_ipv6 - -=head2 Parameters - -A string containing an IPv6 address string. Optionally, it may -also include a C</> character, and a numeric prefix length, in that -order. - - -or- - -An IPv6 address string. Optionally, a numeric prefix length. - -=head2 Returns - -What you gave it, more or less, if it does parse out correctly, -otherwise returns undef. -=head2 Notes - -This is not an object method or class method; it is just a subroutine. - -=cut - -sub is_ipv6 -{ - my ($ip, $pfx); - if (@_ == 2) { - ($ip, $pfx) = @_; - } else { - ($ip, $pfx) = split(m!/!, $_[0]) - } - - unless (ipv6_chkip($ip)) { - return undef; - } - - if (defined $pfx) { - $pfx =~ s/s+//g; - if ($pfx =~ /^\d+$/) { - if (($pfx < 0) || ($pfx > 128)) { - return undef; - } - } else { - return undef; - } - } else { - return $ip; - } - wantarray ? ($ip, $pfx) : "$ip/$pfx"; -} - -=pod - -=head1 ipv6_chkip - -=head2 Parameters - -An IPv6 address string. - -=head2 Returns - -Something true if it's a valid address; something false otherwise. - -=cut - -sub ipv6_chkip -{ - my $ip = shift; - my ($pattern, $parser); - my @patlist; - - $parser = undef; - -TYPE: - for my $k (keys %ipv6_patterns) { - @patlist = @{$ipv6_patterns{$k}}; -PATTERN: - for my $pattern (@patlist) { - last PATTERN if (ref($pattern) eq 'CODE'); - if ($ip =~ $pattern) { - $parser = $patlist[-1]; - last TYPE; - } - } - } - return $parser; -} - -sub ipv6_parse_preferred -{ - my $ip = shift; - my @patterns = @{$ipv6_patterns{'preferred'}}; - for my $p (@patterns) { - if (ref($p) eq 'CODE') { - croak __PACKAGE__, "::ipv6_parse_preferred -- invalid address"; - } - last if ($ip =~ $p); - } - my @pieces = split(/:/, $ip); - splice(@pieces, 8); - return map { hex } @pieces; -} - -sub ipv6_parse_compressed -{ - my $ip = shift; - my @patterns = @{$ipv6_patterns{'compressed'}}; - for my $p (@patterns) { - if (ref($p) eq 'CODE') { - croak __PACKAGE__, "::ipv6_parse_compressed -- invalid address"; - } - last if ($ip =~ $p); - } - my $colons; - $colons = ($ip =~ tr/:/:/); - my $expanded = ':' x (9 - $colons); - $ip =~ s/::/$expanded/; - my @pieces = split(/:/, $ip, 8); - return map { hex } @pieces; -} - -sub ipv6_parse_ipv4 -{ - my $ip = shift; - my @patterns = @{$ipv6_patterns{'ipv4'}}; - for my $p (@patterns) { - if (ref($p) eq 'CODE') { - croak __PACKAGE__, "::ipv6_parse_ipv4 -- invalid address"; - } - last if ($ip =~ $p); - } - my @result; - my $v4addr; - my @v6pcs = split(/:/, $ip); - $v4addr = $v6pcs[-1]; - splice(@v6pcs, 6); - push @result, map { hex } @v6pcs; - Net::IPv4Addr::ipv4_parse($v4addr); - my @v4pcs = split(/\./, $v4addr); - push @result, unpack("n", pack("CC", @v4pcs[0,1])); - push @result, unpack("n", pack("CC", @v4pcs[2,3])); - return @result; -} - -sub ipv6_parse_ipv4_compressed -{ - my $ip = shift; - my @patterns = @{$ipv6_patterns{'ipv4 compressed'}}; - for my $p (@patterns) { - if (ref($p) eq 'CODE') { - croak __PACKAGE__, "::ipv6_parse_ipv4_compressed -- invalid address"; - } - last if ($ip =~ $p); - } - my @result; - my $v4addr; - my $colons; - $colons = ($ip =~ tr/:/:/); - my $expanded = ':' x (8 - $colons); - $ip =~ s/::/$expanded/; - my @v6pcs = split(/:/, $ip, 7); - $v4addr = $v6pcs[-1]; - splice(@v6pcs, 6); - push @result, map { hex } @v6pcs; - Net::IPv4Addr::ipv4_parse($v4addr); - my @v4pcs = split(/\./, $v4addr); - splice(@v4pcs, 4); - push @result, unpack("n", pack("CC", @v4pcs[0,1])); - push @result, unpack("n", pack("CC", @v4pcs[2,3])); - return @result; -} - -sub ipv6_parse_base85 -{ - croak __PACKAGE__, "::ipv6_parse_base85 -- Math::Base85 not loaded" unless defined $Math::Base85::base85_digits; - my $ip = shift; - my $r; - my @patterns = @{$ipv6_patterns{'base85'}}; - for my $p (@patterns) { - if (ref($p) eq 'CODE') { - croak __PACKAGE__, "::ipv6_parse_base85 -- invalid address"; - } - last if ($ip =~ $p); - } - my $bigint = Math::Base85::from_base85($ip); - my @result; - while ($bigint > 0) { - $r = $bigint & 0xffff; - unshift @result, sprintf("%d", $r); - $bigint = $bigint >> 16; - } - foreach $r ($#result+1..7) { - $result[$r] = 0; - } - return @result; -} - -=pod - -=head1 to_string_preferred - -=head2 Parameters - -If used as an object method, none; if used as a plain old subroutine, -an IPv6 address string in any format. - -=head2 Returns - -The IPv6 address, formatted in the "preferred" way (as detailed by -RFC1884). - -=head2 Notes - -Invalid input will generate an exception. - -=cut - -sub to_string_preferred -{ - my $self = shift; - if (ref $self eq __PACKAGE__) { - return join(":", map { sprintf("%x", $_) } @$self); - } - return Net::IPv6Addr->new($self)->to_string_preferred(); -} - -=pod - -=head1 to_string_compressed - -=head2 Parameters - -If used as an object method, none; if used as a plain old subroutine, -an IPv6 address string in any format. - -=head2 Returns - -The IPv6 address in "compresed" format (as detailed by RFC1884). - -=head2 Notes - -Invalid input will generate an exception. - -=cut - -sub to_string_compressed -{ - my $self = shift; - if (ref $self ne __PACKAGE__) { - return Net::IPv6Addr->new($self)->to_string_compressed(); - } - my $expanded = join(":", map { sprintf("%x", $_) } @$self); - $expanded =~ s/^0:/:/; - $expanded =~ s/:0/:/g; - if ($expanded =~ s/:::::::/_/ or - $expanded =~ s/::::::/_/ or - $expanded =~ s/:::::/_/ or - $expanded =~ s/::::/_/ or - $expanded =~ s/:::/_/ or - $expanded =~ s/::/_/ - ) { - $expanded =~ s/:(?=:)/:0/g; - $expanded =~ s/^:(?=[0-9a-f])/0:/; - $expanded =~ s/([0-9a-f]):$/$1:0/; - $expanded =~ s/_/::/; - } - return $expanded; -} - -=pod - -=head1 to_string_ipv4 - -=head2 Parameters - -If used as an object method, none; if used as a plain old subroutine, -an IPv6 address string in any format. - -=head2 Returns - -The IPv6 address in IPv4 format (as detailed by RFC1884). - -=head2 Notes - -Invalid input (such as an address that was not originally IPv4) -will generate an exception. - -=cut - -sub to_string_ipv4 -{ - my $self = shift; - if (ref $self ne __PACKAGE__) { - return Net::IPv6Addr->new($self)->to_string_ipv4(); - } - if ($self->[0] | $self->[1] | $self->[2] | $self->[3] | $self->[4]) { - croak __PACKAGE__, "::to_string_ipv4 -- not originally an IPv4 address"; - } - if (($self->[5] != 0xffff) && $self->[5]) { - croak __PACKAGE__, "::to_string_ipv4 -- not originally an IPv4 address"; - } - my $v6part = join(':', map { sprintf("%x", $_) } @$self[0..5]); - my $v4part = join('.', $self->[6] >> 8, $self->[6] & 0xff, $self->[7] >> 8, $self->[7] & 0xff); - return "$v6part:$v4part"; -} - -=pod - -=head1 to_string_ipv4_compressed - -=head2 Parameters - -If used as an object method, none; if used as a plain old subroutine, -an IPv6 address string in any format. - -=head2 Returns - -The IPv6 address in compressed IPv4 format (as detailed by RFC1884). - -=head2 Notes - -Invalid input (such as an address that was not originally IPv4) -will generate an exception. - -=cut - -sub to_string_ipv4_compressed -{ - my $self = shift; - if (ref $self ne __PACKAGE__) { - return Net::IPv6Addr->new($self)->to_string_ipv4_compressed(); - } - if ($self->[0] | $self->[1] | $self->[2] | $self->[3] | $self->[4]) { - croak __PACKAGE__, "::to_string_ipv4 -- not originally an IPv4 address"; - } - if (($self->[5] != 0xffff) && $self->[5]) { - croak __PACKAGE__, "::to_string_ipv4 -- not originally an IPv4 address"; - } - my $v6part; - if ($self->[5]) { - $v6part = sprintf("::%x", $self->[5]); - } else { - $v6part = ":"; - } - my $v4part = join('.', $self->[6] >> 8, $self->[6] & 0xff, $self->[7] >> 8, $self->[7] & 0xff); - return "$v6part:$v4part"; -} - - -=pod - -=head1 to_string_base85 - -=head2 Parameters - -If used as an object method, none; if used as a plain old subroutine, -an IPv6 address string in any format. - -=head2 Returns - -The IPv6 address in the style detailed by RFC1924. - -=head2 Notes - -Invalid input will generate an exception. - -=cut - -sub to_string_base85 -{ - croak __PACKAGE__, "::to_string_base85 -- Math::Base85 not loaded" unless defined $Math::Base85::base85_digits; - my $self = shift; - if (ref $self ne __PACKAGE__) { - return Net::IPv6Addr->new($self)->to_string_base85(); - } - my $bigint = new Math::BigInt("0"); - for my $i (@{$self}[0..6]) { - $bigint = $bigint + $i; - $bigint = $bigint << 16; - } - $bigint = $bigint + $self->[7]; - return Math::Base85::to_base85($bigint); -} - -=pod - -=head1 to_bigint - -=head2 Parameters - -If used as an object method, none; if used as a plain old subroutine, -an IPv6 address string in any format. - -=head2 Returns - -The BigInt representation of IPv6 address. - -=head2 Notes - -Invalid input will generate an exception. - -=cut - -sub to_bigint -{ - croak __PACKAGE__, "::to_bigint -- Math::BigInt not loaded" unless defined &Math::BigInt::new; - my $self = shift; - if (ref $self ne __PACKAGE__) { - return Net::IPv6Addr->new($self)->to_bigint(); - } - my $bigint = new Math::BigInt("0"); - for my $i (@{$self}[0..6]) { - $bigint = $bigint + $i; - $bigint = $bigint << 16; - } - $bigint = $bigint + $self->[7]; - $bigint =~ s/\+//; - return $bigint; -} - -=pod - -=head1 to_array - -=head2 Parameters - -If used as an object method, none; if used as a plain old subroutine, -an IPv6 address string in any format. - -=head2 Returns - -An array [0..7] of 16 bit hexadecimal numbers. - -=head2 Notes - -Invalid input will generate an exception. - -=cut - -sub to_array -{ - my $self = shift; - if (ref $self ne __PACKAGE__) { - return Net::IPv6Addr->new($self)->to_array(); - } - return map {sprintf "%04x", $_} @$self; -} -=pod - -=head1 to_intarray - -=head2 Parameters - -If used as an object method, none; if used as a plain old subroutine, -an IPv6 address string in any format. - -=head2 Returns - -An array [0..7] of decimal numbers. - -=head2 Notes - -Invalid input will generate an exception. - -=cut - -sub to_intarray -{ - my $self = shift; - if (ref $self ne __PACKAGE__) { - return Net::IPv6Addr->new($self)->to_intarray(); - } - return @$self; -} - -=pod - -=head1 to_string_ip6_int - -=head2 Parameters - -If used as an object method, none; if used as a plain old subroutine, -an IPv6 address string in any format. - -=head2 Returns - -The reverse-address pointer as defined by RFC1886. - -=head2 Notes - -Invalid input will generate an exception. - -=cut - -sub to_string_ip6_int -{ - my $self = shift; - if (ref $self ne __PACKAGE__) { - return Net::IPv6Addr->new($self)->to_string_ip6_int(); - } - my $hexdigits = sprintf("%04x" x 8, @$self); - my @nibbles = ('INT', 'IP6', split(//, $hexdigits)); - my $ptr = join('.', reverse @nibbles); - return $ptr . "."; -} - - -=pod - -=head1 in_network_of_size - -=head2 Parameters - -If used as an object method, network size in bits - -If used as a plain old subroutine, an IPv6 address string in any format -and network size in bits. Network size may be given with / notation. - -=head2 Returns - -Network IPv6Addr of given size. - -=head2 Notes - -Invalid input will generate an exception. - -=cut - -sub in_network_of_size -{ - my $self = shift; - if (ref $self ne __PACKAGE__) { - if ($self =~ m!(.+)/(.+)!) { - unshift @_, $2; - return Net::IPv6Addr->new($1)->in_network_of_size(@_)->to_string_preferred; - } - return Net::IPv6Addr->new($self)->in_network_of_size(@_)->to_string_preferred; - } - my $netsize = shift; - if (!defined $netsize) { - croak __PACKAGE__, "::in_network_of_size -- not network size given"; - } - $netsize =~ s!/!!; - if ($netsize !~ /^\d+$/ or $netsize < 0 or $netsize > 128) { - croak __PACKAGE__, "::in_network_of_size -- not valid network size $netsize"; - } - my @parts = @$self; - my $i = $netsize / 16; - unless ($i == 8) { # netsize was 128 bits; the whole address - my $j = $netsize % 16; - $parts[$i] &= unpack("C4",pack("B16", '1' x $j . '0000000000000000')); - foreach $j (++$i..$#parts) { - $parts[$j] = 0; - } - } - return Net::IPv6Addr->new(join(':', @parts)); -} - -=pod - -=head1 in_network - -=head2 Parameters - -If used as an object method, network and its size in bits - -If used as a plain old subroutine, an IPv6 address string in any format -network address string and size in bits. -Network size may be given with / notation. - -=head2 Returns - -Something true, if address is member of the network, false otherwise. - -=head2 Notes - -Invalid input will generate an exception. - -=cut - -sub in_network -{ - my $self = shift; - if (ref $self ne __PACKAGE__) { - return Net::IPv6Addr->new($self)->in_network(@_); - } - my ($net,$netsize) = (@_); - if ($net =~ m!/!) { - $net =~ s!(.*)/(.*)!$1!; - $netsize = $2; - } - unless (defined $netsize) { - croak __PACKAGE__, "::in_network -- not enough parameters"; - } - $netsize =~ s!/!!; - if ($netsize !~ /^\d+$/ or $netsize < 0 or $netsize > 128) { - croak __PACKAGE__, "::in_network -- not valid network size $netsize"; - } - my @s = $self->in_network_of_size($netsize)->to_intarray; - $net = Net::IPv6Addr->new($net) unless (ref $net); - my @n = $net->in_network_of_size($netsize)->to_intarray; - my $i = int($netsize / 16); - $i++; - $i = $#s if ($i > $#s); - for (0..$i) { - return 0 unless ($s[$_] == $n[$_]); - } - return 1; -} - - -1; -__END__ - -=pod - -=head1 BUGS - -probably exist in this module. Please report them. - -=head1 AUTHOR - -Tony Monroe E<lt>tmonroe plus perl at nog dot netE<gt>. - -The module's interface probably looks like it vaguely resembles -Net::IPv4Addr by Francis J. Lacoste E<lt>francis dot lacoste at -iNsu dot COME<gt>. - -Some fixes and subroutines from Jyrki Soini E<lt>jyrki dot soini -at sonera dot comE<gt>. - -=head1 HISTORY - -This was originally written to simplify the task of maintaining -DNS records after I set myself up with Freenet6. Interesting that -there's really only one DNS-related subroutine in here. - -=head1 SEE ALSO - -RFC1884, RFC1886, RFC1924, L<perl>, L<Net::IPv4Addr>, L<Math::Base85>, -L<Math::BigInt> - -=cut | ||
[+] | Deleted | Net-IPv6Addr-0.2.tar.gz/rfc1886.txt ^ |
@@ -1,268 +0,0 @@ - - - - - - -Network Working Group S. Thomson -Request for Comments: 1886 Bellcore -Category: Standards Track C. Huitema - INRIA - December 1995 - - - DNS Extensions to support IP version 6 - - -Status of this Memo - - This document specifies an Internet standards track protocol for the - Internet community, and requests discussion and suggestions for - improvements. Please refer to the current edition of the "Internet - Official Protocol Standards" (STD 1) for the standardization state - and status of this protocol. Distribution of this memo is unlimited. - - -Abstract - - This document defines the changes that need to be made to the Domain - Name System to support hosts running IP version 6 (IPv6). The - changes include a new resource record type to store an IPv6 address, - a new domain to support lookups based on an IPv6 address, and updated - definitions of existing query types that return Internet addresses as - part of additional section processing. The extensions are designed - to be compatible with existing applications and, in particular, DNS - implementations themselves. - - - - - - - - - - - - - - - - - - - -Thompson & Huitema Standards Track [Page 1] - -RFC 1886 IPv6 DNS Extensions December 1995 - - -1. INTRODUCTION - - Current support for the storage of Internet addresses in the Domain - Name System (DNS)[1,2] cannot easily be extended to support IPv6 - addresses[3] since applications assume that address queries return - 32-bit IPv4 addresses only. - - To support the storage of IPv6 addresses we define the following - extensions: - - o A new resource record type is defined to map a domain name to an - IPv6 address. - - o A new domain is defined to support lookups based on address. - - o Existing queries that perform additional section processing to - locate IPv4 addresses are redefined to perform additional - section processing on both IPv4 and IPv6 addresses. - - The changes are designed to be compatible with existing software. The - existing support for IPv4 addresses is retained. Transition issues - related to the co-existence of both IPv4 and IPv6 addresses in DNS - are discussed in [4]. - - -2. NEW RESOURCE RECORD DEFINITION AND DOMAIN - - A new record type is defined to store a host's IPv6 address. A host - that has more than one IPv6 address must have more than one such - record. - - -2.1 AAAA record type - - The AAAA resource record type is a new record specific to the - Internet class that stores a single IPv6 address. - - The value of the type is 28 (decimal). - - -2.2 AAAA data format - - A 128 bit IPv6 address is encoded in the data portion of an AAAA - resource record in network byte order (high-order byte first). - - - - -Thompson & Huitema Standards Track [Page 2] - -RFC 1886 IPv6 DNS Extensions December 1995 - - -2.3 AAAA query - - An AAAA query for a specified domain name in the Internet class - returns all associated AAAA resource records in the answer section of - a response. - - A type AAAA query does not perform additional section processing. - - -2.4 Textual format of AAAA records - - The textual representation of the data portion of the AAAA resource - record used in a master database file is the textual representation - of a IPv6 address as defined in [3]. - - -2.5 IP6.INT Domain - - A special domain is defined to look up a record given an address. The - intent of this domain is to provide a way of mapping an IPv6 address - to a host name, although it may be used for other purposes as well. - The domain is rooted at IP6.INT. - - An IPv6 address is represented as a name in the IP6.INT domain by a - sequence of nibbles separated by dots with the suffix ".IP6.INT". The - sequence of nibbles is encoded in reverse order, i.e. the low-order - nibble is encoded first, followed by the next low-order nibble and so - on. Each nibble is represented by a hexadecimal digit. For example, - the inverse lookup domain name corresponding to the address - - 4321:0:1:2:3:4:567:89ab - - would be - -b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.IP6.INT. - - - -3. MODIFICATIONS TO EXISTING QUERY TYPES - - All existing query types that perform type A additional section - processing, i.e. name server (NS), mail exchange (MX) and mailbox - (MB) query types, must be redefined to perform both type A and type - AAAA additional section processing. These new definitions mean that a - name server must add any relevant IPv4 addresses and any relevant - - - -Thompson & Huitema Standards Track [Page 3] - -RFC 1886 IPv6 DNS Extensions December 1995 - - - IPv6 addresses available locally to the additional section of a - response when processing any one of the above queries. - - -4. SECURITY CONSIDERATIONS - - Security issues are not discussed in this memo. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Thompson & Huitema Standards Track [Page 4] - -RFC 1886 IPv6 DNS Extensions December 1995 - - -5. REFERENCES - - - [1] Mockapetris, P., "Domain Names - Concepts and Facilities", STD - 13, RFC 1034, USC/Information Sciences Institute, November 1987. - - [2] Mockapetris, P., "Domain Names - Implementation and Specifica- - tion", STD 13, RFC 1035, USC/Information Sciences Institute, - November 1987. - - [3] Hinden, R., and S. Deering, Editors, "IP Version 6 Addressing - Architecture", RFC 1884, Ipsilon Networks, Xerox PARC, December - 1995. - - - [4] Gilligan, R., and E. Nordmark, "Transition Mechanisms for IPv6 - Hosts and Routers", Work in Progress. - - -Authors' Addresses - - Susan Thomson - Bellcore - MRE 2P343 - 445 South Street - Morristown, NJ 07960 - U.S.A. - - Phone: +1 201-829-4514 - EMail: set@thumper.bellcore.com - - - Christian Huitema - INRIA, Sophia-Antipolis - 2004 Route des Lucioles - BP 109 - F-06561 Valbonne Cedex - France - - Phone: +33 93 65 77 15 - EMail: Christian.Huitema@MIRSA.INRIA.FR - - - - - - - -Thompson & Huitema Standards Track [Page 5] - | ||
[+] | Deleted | Net-IPv6Addr-0.2.tar.gz/rfc1924.txt ^ |
@@ -1,339 +0,0 @@ - - - - - - -Network Working Group R. Elz -Request for Comments: 1924 University of Melbourne -Category: Informational 1 April 1996 - - - A Compact Representation of IPv6 Addresses - -Status of this Memo - - This memo provides information for the Internet community. This memo - does not specify an Internet standard of any kind. Distribution of - this memo is unlimited. - -1. Abstract - - IPv6 addresses, being 128 bits long, need 32 characters to write in - the general case, if standard hex representation, is used, plus more - for any punctuation inserted (typically about another 7 characters, - or 39 characters total). This document specifies a more compact - representation of IPv6 addresses, which permits encoding in a mere 20 - bytes. - -2. Introduction - - It is always necessary to be able to write in characters the form of - an address, though in actual use it is always carried in binary. For - IP version 4 (IP Classic) the well known dotted quad format is used. - That is, 10.1.0.23 is one such address. Each decimal integer - represents a one octet of the 4 octet address, and consequently has a - value between 0 and 255 (inclusive). The written length of the - address varies between 7 and 15 bytes. - - For IPv6 however, addresses are 16 octets long [IPv6], if the old - standard form were to be used, addresses would be anywhere between 31 - and 63 bytes, which is, of course, untenable. - - Because of that, IPv6 had chosen to represent addresses using hex - digits, and use only half as many punctuation characters, which will - mean addresses of between 15 and 39 bytes, which is still quite long. - Further, in an attempt to save more bytes, a special format was - invented, in which a single run of zero octets can be dropped, the - two adjacent punctuation characters indicate this has happened, the - number of missing zeroes can be deduced from the fixed size of the - address. - - In most cases, using genuine IPv6 addresses, one may expect the - address as written to tend toward the upper limit of 39 octets, as - long strings of zeroes are likely to be rare, and most of the other - - - -Elz Informational [Page 1] - -RFC 1924 A Compact Representation of IPv6 Addresses 1 April 1996 - - - groups of 4 hex digits are likely to be longer than a single non-zero - digit (just as MAC addresses typically have digits spread throughout - their length). - - This document specifies a new encoding, which can always represent - any IPv6 address in 20 octets. While longer than the shortest - possible representation of an IPv6 address, this is barely longer - than half the longest representation, and will typically be shorter - than the representation of most IPv6 addresses. - -3. Current formats - - [AddrSpec] specifies that the preferred text representation of IPv6 - addresses is in one of three conventional forms. - - The preferred form is x:x:x:x:x:x:x:x, where the 'x's are the - hexadecimal values of the eight 16-bit pieces of the address. - - Examples: - - FEDC:BA98:7654:3210:FEDC:BA98:7654:3210 (39 characters) - - 1080:0:0:0:8:800:200C:417A (25 characters) - - The second, or zero suppressed, form allows "::" to indicate multiple - groups of suppressed zeroes, hence: - - 1080:0:0:0:8:800:200C:417A - - may be represented as - - 1080::8:800:200C:417A - - a saving of just 5 characters from this typical address form, and - still leaving 21 characters. - - In other cases the saving is more dramatic, in the extreme case, the - address: - - 0:0:0:0:0:0:0:0 - - that is, the unspecified address, can be written as - - :: - - This is just 2 characters, which is a considerable saving. However - such cases will rarely be encountered. - - - - -Elz Informational [Page 2] - -RFC 1924 A Compact Representation of IPv6 Addresses 1 April 1996 - - - The third possible form mixes the new IPv6 form with the old IPv4 - form, and is intended mostly for transition, when IPv4 addresses are - embedded into IPv6 addresses. These can be considerably longer than - the longest normal IPv6 representation, and will eventually be phased - out. Consequently they will not be considered further here. - -4. The New Encoding Format - - The new standard way of writing IPv6 addresses is to treat them as a - 128 bit integer, encode that in base 85 notation, then encode that - using 85 ASCII characters. - -4.1. Why 85? - - 2^128 is 340282366920938463463374607431768211456. 85^20 is - 387595310845143558731231784820556640625, and thus in 20 digits of - base 85 representation all possible 2^128 IPv6 addresses can clearly - be encoded. - - 84^20 is 305904398238499908683087849324518834176, clearly not - sufficient, 21 characters would be needed to encode using base 84, - this wastage of notational space cannot be tolerated. - - On the other hand, 94^19 is just - 30862366077815087592879016454695419904, also insufficient to encode - all 2^128 different IPv6 addresses, so 20 characters would be needed - even with base 94 encoding. As there are just 94 ASCII characters - (excluding control characters, space, and del) base 94 is the largest - reasonable value that can be used. Even if space were allowed, base - 95 would still require 20 characters. - - Thus, any value between 85 and 94 inclusive could reasonably be - chosen. Selecting 85 allows the use of the smallest possible subset - of the ASCII characters, enabling more characters to be retained for - other uses, eg, to delimit the address. - -4.2. The Character Set - - The character set to encode the 85 base85 digits, is defined to be, - in ascending order: - - '0'..'9', 'A'..'Z', 'a'..'z', '!', '#', '$', '%', '&', '(', - ')', '*', '+', '-', ';', '<', '=', '>', '?', '@', '^', '_', - '`', '{', '|', '}', and '~'. - - This set has been chosen with considerable care. From the 94 - printable ASCII characters, the following nine were omitted: - - - - -Elz Informational [Page 3] - -RFC 1924 A Compact Representation of IPv6 Addresses 1 April 1996 - - - '"' and "'", which allow the representation of IPv6 addresses to - be quoted in other environments where some of the characters in - the chosen character set may, unquoted, have other meanings. - - ',' to allow lists of IPv6 addresses to conveniently be written, - and '.' to allow an IPv6 address to end a sentence without - requiring it to be quoted. - - '/' so IPv6 addresses can be written in standard CIDR - address/length notation, and ':' because that causes problems when - used in mail headers and URLs. - - '[' and ']', so those can be used to delimit IPv6 addresses when - represented as text strings, as they often are for IPv4, - - And last, '\', because it is often difficult to represent in a way - where it does not appear to be a quote character, including in the - source of this document. - -5. Converting an IPv6 address to base 85. - - The conversion process is a simple one of division, taking the - remainders at each step, and dividing the quotient again, then - reading up the page, as is done for any other base conversion. - - For example, consider the address shown above - - 1080:0:0:0:8:800:200C:417A - - In decimal, considered as a 128 bit number, that is - 21932261930451111902915077091070067066. - - As we divide that successively by 85 the following remainders emerge: - 51, 34, 65, 57, 58, 0, 75, 53, 37, 4, 19, 61, 31, 63, 12, 66, 46, 70, - 68, 4. - - Thus in base85 the address is: - - 4-68-70-46-66-12-63-31-61-19-4-37-53-75-0-58-57-65-34-51. - - Then, when encoded as specified above, this becomes: - - 4)+k&C#VzJ4br>0wv%Yp - - This procedure is trivially reversed to produce the binary form of - the address from textually encoded format. - - - - - -Elz Informational [Page 4] - -RFC 1924 A Compact Representation of IPv6 Addresses 1 April 1996 - - -6. Additional Benefit - - Apart from generally reducing the length of an IPv6 address when - encode in a textual format, this scheme also has the benefit of - returning IPv6 addresses to a fixed length representation, leading - zeroes are never omitted, thus removing the ugly and awkward variable - length representation that has previously been recommended. - -7. Implementation Issues - - Many current processors do not find 128 bit integer arithmetic, as - required for this technique, a trivial operation. This is not - considered a serious drawback in the representation, but a flaw of - the processor designs. - - It may be expected that future processors will address this defect, - quite possibly before any significant IPv6 deployment has been - accomplished. - -8. Security Considerations - - By encoding addresses in this form, it is less likely that a casual - observer will be able to immediately detect the binary form of the - address, and thus will find it harder to make immediate use of the - address. As IPv6 addresses are not intended to be learned by humans, - one reason for which being that they are expected to alter in - comparatively short timespan, by human perception, the somewhat - challenging nature of the addresses is seen as a feature. - - Further, the appearance of the address, as if it may be random - gibberish in a compressed file, makes it much harder to detect by a - packet sniffer programmed to look for bypassing addresses. - - - - - - - - - - - - - - - - - - - -Elz Informational [Page 5] - -RFC 1924 A Compact Representation of IPv6 Addresses 1 April 1996 - - -9. References - - [IPv6] Internet Protocol, Version 6 (IPv6) Specification, - S. Deering, R. Hinden, RFC 1883, January 4, 1996. - - [AddrSpec] IP Version 6 Addressing Architecture, - R. Hinden, S. Deering, RFC 1884, January 4, 1996. - -10. Author's Address - - Robert Elz - Computer Science - University of Melbourne - Parkville, Victoria, 3052 - Australia - - EMail: kre@munnari.OZ.AU - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Elz Informational [Page 6] - | ||
[+] | Deleted | Net-IPv6Addr-0.2.tar.gz/rfc2373.txt ^ |
@@ -1,1459 +0,0 @@ - - - - - - -Network Working Group R. Hinden -Request for Comments: 2373 Nokia -Obsoletes: 1884 S. Deering -Category: Standards Track Cisco Systems - July 1998 - - IP Version 6 Addressing Architecture - -Status of this Memo - - This document specifies an Internet standards track protocol for the - Internet community, and requests discussion and suggestions for - improvements. Please refer to the current edition of the "Internet - Official Protocol Standards" (STD 1) for the standardization state - and status of this protocol. Distribution of this memo is unlimited. - -Copyright Notice - - Copyright (C) The Internet Society (1998). All Rights Reserved. - -Abstract - - This specification defines the addressing architecture of the IP - Version 6 protocol [IPV6]. The document includes the IPv6 addressing - model, text representations of IPv6 addresses, definition of IPv6 - unicast addresses, anycast addresses, and multicast addresses, and an - IPv6 node's required addresses. - -Table of Contents - - 1. Introduction.................................................2 - 2. IPv6 Addressing..............................................2 - 2.1 Addressing Model.........................................3 - 2.2 Text Representation of Addresses.........................3 - 2.3 Text Representation of Address Prefixes..................5 - 2.4 Address Type Representation..............................6 - 2.5 Unicast Addresses........................................7 - 2.5.1 Interface Identifiers................................8 - 2.5.2 The Unspecified Address..............................9 - 2.5.3 The Loopback Address.................................9 - 2.5.4 IPv6 Addresses with Embedded IPv4 Addresses.........10 - 2.5.5 NSAP Addresses......................................10 - 2.5.6 IPX Addresses.......................................10 - 2.5.7 Aggregatable Global Unicast Addresses...............11 - 2.5.8 Local-use IPv6 Unicast Addresses....................11 - 2.6 Anycast Addresses.......................................12 - 2.6.1 Required Anycast Address............................13 - 2.7 Multicast Addresses.....................................14 - - - -Hinden & Deering Standards Track [Page 1] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - - 2.7.1 Pre-Defined Multicast Addresses.....................15 - 2.7.2 Assignment of New IPv6 Multicast Addresses..........17 - 2.8 A Node's Required Addresses.............................17 - 3. Security Considerations.....................................18 - APPENDIX A: Creating EUI-64 based Interface Identifiers........19 - APPENDIX B: ABNF Description of Text Representations...........22 - APPENDIX C: CHANGES FROM RFC-1884..............................23 - REFERENCES.....................................................24 - AUTHORS' ADDRESSES.............................................25 - FULL COPYRIGHT STATEMENT.......................................26 - - -1.0 INTRODUCTION - - This specification defines the addressing architecture of the IP - Version 6 protocol. It includes a detailed description of the - currently defined address formats for IPv6 [IPV6]. - - The authors would like to acknowledge the contributions of Paul - Francis, Scott Bradner, Jim Bound, Brian Carpenter, Matt Crawford, - Deborah Estrin, Roger Fajman, Bob Fink, Peter Ford, Bob Gilligan, - Dimitry Haskin, Tom Harsch, Christian Huitema, Tony Li, Greg - Minshall, Thomas Narten, Erik Nordmark, Yakov Rekhter, Bill Simpson, - and Sue Thomson. - - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", - "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this - document are to be interpreted as described in [RFC 2119]. - -2.0 IPv6 ADDRESSING - - IPv6 addresses are 128-bit identifiers for interfaces and sets of - interfaces. There are three types of addresses: - - Unicast: An identifier for a single interface. A packet sent to - a unicast address is delivered to the interface - identified by that address. - - Anycast: An identifier for a set of interfaces (typically - belonging to different nodes). A packet sent to an - anycast address is delivered to one of the interfaces - identified by that address (the "nearest" one, according - to the routing protocols' measure of distance). - - Multicast: An identifier for a set of interfaces (typically - belonging to different nodes). A packet sent to a - multicast address is delivered to all interfaces - identified by that address. - - - -Hinden & Deering Standards Track [Page 2] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - - There are no broadcast addresses in IPv6, their function being - superseded by multicast addresses. - - In this document, fields in addresses are given a specific name, for - example "subscriber". When this name is used with the term "ID" for - identifier after the name (e.g., "subscriber ID"), it refers to the - contents of the named field. When it is used with the term "prefix" - (e.g. "subscriber prefix") it refers to all of the address up to and - including this field. - - In IPv6, all zeros and all ones are legal values for any field, - unless specifically excluded. Specifically, prefixes may contain - zero-valued fields or end in zeros. - -2.1 Addressing Model - - IPv6 addresses of all types are assigned to interfaces, not nodes. - An IPv6 unicast address refers to a single interface. Since each - interface belongs to a single node, any of that node's interfaces' - unicast addresses may be used as an identifier for the node. - - All interfaces are required to have at least one link-local unicast - address (see section 2.8 for additional required addresses). A - single interface may also be assigned multiple IPv6 addresses of any - type (unicast, anycast, and multicast) or scope. Unicast addresses - with scope greater than link-scope are not needed for interfaces that - are not used as the origin or destination of any IPv6 packets to or - from non-neighbors. This is sometimes convenient for point-to-point - interfaces. There is one exception to this addressing model: - - An unicast address or a set of unicast addresses may be assigned to - multiple physical interfaces if the implementation treats the - multiple physical interfaces as one interface when presenting it to - the internet layer. This is useful for load-sharing over multiple - physical interfaces. - - Currently IPv6 continues the IPv4 model that a subnet prefix is - associated with one link. Multiple subnet prefixes may be assigned - to the same link. - -2.2 Text Representation of Addresses - - There are three conventional forms for representing IPv6 addresses as - text strings: - - 1. The preferred form is x:x:x:x:x:x:x:x, where the 'x's are the - hexadecimal values of the eight 16-bit pieces of the address. - Examples: - - - -Hinden & Deering Standards Track [Page 3] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - - FEDC:BA98:7654:3210:FEDC:BA98:7654:3210 - - 1080:0:0:0:8:800:200C:417A - - Note that it is not necessary to write the leading zeros in an - individual field, but there must be at least one numeral in every - field (except for the case described in 2.). - - 2. Due to some methods of allocating certain styles of IPv6 - addresses, it will be common for addresses to contain long strings - of zero bits. In order to make writing addresses containing zero - bits easier a special syntax is available to compress the zeros. - The use of "::" indicates multiple groups of 16-bits of zeros. - The "::" can only appear once in an address. The "::" can also be - used to compress the leading and/or trailing zeros in an address. - - For example the following addresses: - - 1080:0:0:0:8:800:200C:417A a unicast address - FF01:0:0:0:0:0:0:101 a multicast address - 0:0:0:0:0:0:0:1 the loopback address - 0:0:0:0:0:0:0:0 the unspecified addresses - - may be represented as: - - 1080::8:800:200C:417A a unicast address - FF01::101 a multicast address - ::1 the loopback address - :: the unspecified addresses - - 3. An alternative form that is sometimes more convenient when dealing - with a mixed environment of IPv4 and IPv6 nodes is - x:x:x:x:x:x:d.d.d.d, where the 'x's are the hexadecimal values of - the six high-order 16-bit pieces of the address, and the 'd's are - the decimal values of the four low-order 8-bit pieces of the - address (standard IPv4 representation). Examples: - - 0:0:0:0:0:0:13.1.68.3 - - 0:0:0:0:0:FFFF:129.144.52.38 - - or in compressed form: - - ::13.1.68.3 - - ::FFFF:129.144.52.38 - - - - - -Hinden & Deering Standards Track [Page 4] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - -2.3 Text Representation of Address Prefixes - - The text representation of IPv6 address prefixes is similar to the - way IPv4 addresses prefixes are written in CIDR notation. An IPv6 - address prefix is represented by the notation: - - ipv6-address/prefix-length - - where - - ipv6-address is an IPv6 address in any of the notations listed - in section 2.2. - - prefix-length is a decimal value specifying how many of the - leftmost contiguous bits of the address comprise - the prefix. - - For example, the following are legal representations of the 60-bit - prefix 12AB00000000CD3 (hexadecimal): - - 12AB:0000:0000:CD30:0000:0000:0000:0000/60 - 12AB::CD30:0:0:0:0/60 - 12AB:0:0:CD30::/60 - - The following are NOT legal representations of the above prefix: - - 12AB:0:0:CD3/60 may drop leading zeros, but not trailing zeros, - within any 16-bit chunk of the address - - 12AB::CD30/60 address to left of "/" expands to - 12AB:0000:0000:0000:0000:000:0000:CD30 - - 12AB::CD3/60 address to left of "/" expands to - 12AB:0000:0000:0000:0000:000:0000:0CD3 - - When writing both a node address and a prefix of that node address - (e.g., the node's subnet prefix), the two can combined as follows: - - the node address 12AB:0:0:CD30:123:4567:89AB:CDEF - and its subnet number 12AB:0:0:CD30::/60 - - can be abbreviated as 12AB:0:0:CD30:123:4567:89AB:CDEF/60 - - - - - - - - - -Hinden & Deering Standards Track [Page 5] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - -2.4 Address Type Representation - - The specific type of an IPv6 address is indicated by the leading bits - in the address. The variable-length field comprising these leading - bits is called the Format Prefix (FP). The initial allocation of - these prefixes is as follows: - - Allocation Prefix Fraction of - (binary) Address Space - ----------------------------------- -------- ------------- - Reserved 0000 0000 1/256 - Unassigned 0000 0001 1/256 - - Reserved for NSAP Allocation 0000 001 1/128 - Reserved for IPX Allocation 0000 010 1/128 - - Unassigned 0000 011 1/128 - Unassigned 0000 1 1/32 - Unassigned 0001 1/16 - - Aggregatable Global Unicast Addresses 001 1/8 - Unassigned 010 1/8 - Unassigned 011 1/8 - Unassigned 100 1/8 - Unassigned 101 1/8 - Unassigned 110 1/8 - - Unassigned 1110 1/16 - Unassigned 1111 0 1/32 - Unassigned 1111 10 1/64 - Unassigned 1111 110 1/128 - Unassigned 1111 1110 0 1/512 - - Link-Local Unicast Addresses 1111 1110 10 1/1024 - Site-Local Unicast Addresses 1111 1110 11 1/1024 - - Multicast Addresses 1111 1111 1/256 - - Notes: - - (1) The "unspecified address" (see section 2.5.2), the loopback - address (see section 2.5.3), and the IPv6 Addresses with - Embedded IPv4 Addresses (see section 2.5.4), are assigned out - of the 0000 0000 format prefix space. - - - - - - - -Hinden & Deering Standards Track [Page 6] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - - (2) The format prefixes 001 through 111, except for Multicast - Addresses (1111 1111), are all required to have to have 64-bit - interface identifiers in EUI-64 format. See section 2.5.1 for - definitions. - - This allocation supports the direct allocation of aggregation - addresses, local use addresses, and multicast addresses. Space is - reserved for NSAP addresses and IPX addresses. The remainder of the - address space is unassigned for future use. This can be used for - expansion of existing use (e.g., additional aggregatable addresses, - etc.) or new uses (e.g., separate locators and identifiers). Fifteen - percent of the address space is initially allocated. The remaining - 85% is reserved for future use. - - Unicast addresses are distinguished from multicast addresses by the - value of the high-order octet of the addresses: a value of FF - (11111111) identifies an address as a multicast address; any other - value identifies an address as a unicast address. Anycast addresses - are taken from the unicast address space, and are not syntactically - distinguishable from unicast addresses. - -2.5 Unicast Addresses - - IPv6 unicast addresses are aggregatable with contiguous bit-wise - masks similar to IPv4 addresses under Class-less Interdomain Routing - [CIDR]. - - There are several forms of unicast address assignment in IPv6, - including the global aggregatable global unicast address, the NSAP - address, the IPX hierarchical address, the site-local address, the - link-local address, and the IPv4-capable host address. Additional - address types can be defined in the future. - - IPv6 nodes may have considerable or little knowledge of the internal - structure of the IPv6 address, depending on the role the node plays - (for instance, host versus router). At a minimum, a node may - consider that unicast addresses (including its own) have no internal - structure: - - | 128 bits | - +-----------------------------------------------------------------+ - | node address | - +-----------------------------------------------------------------+ - - A slightly sophisticated host (but still rather simple) may - additionally be aware of subnet prefix(es) for the link(s) it is - attached to, where different addresses may have different values for - n: - - - -Hinden & Deering Standards Track [Page 7] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - - | n bits | 128-n bits | - +------------------------------------------------+----------------+ - | subnet prefix | interface ID | - +------------------------------------------------+----------------+ - - Still more sophisticated hosts may be aware of other hierarchical - boundaries in the unicast address. Though a very simple router may - have no knowledge of the internal structure of IPv6 unicast - addresses, routers will more generally have knowledge of one or more - of the hierarchical boundaries for the operation of routing - protocols. The known boundaries will differ from router to router, - depending on what positions the router holds in the routing - hierarchy. - -2.5.1 Interface Identifiers - - Interface identifiers in IPv6 unicast addresses are used to identify - interfaces on a link. They are required to be unique on that link. - They may also be unique over a broader scope. In many cases an - interface's identifier will be the same as that interface's link- - layer address. The same interface identifier may be used on multiple - interfaces on a single node. - - Note that the use of the same interface identifier on multiple - interfaces of a single node does not affect the interface - identifier's global uniqueness or each IPv6 addresses global - uniqueness created using that interface identifier. - - In a number of the format prefixes (see section 2.4) Interface IDs - are required to be 64 bits long and to be constructed in IEEE EUI-64 - format [EUI64]. EUI-64 based Interface identifiers may have global - scope when a global token is available (e.g., IEEE 48bit MAC) or may - have local scope where a global token is not available (e.g., serial - links, tunnel end-points, etc.). It is required that the "u" bit - (universal/local bit in IEEE EUI-64 terminology) be inverted when - forming the interface identifier from the EUI-64. The "u" bit is set - to one (1) to indicate global scope, and it is set to zero (0) to - indicate local scope. The first three octets in binary of an EUI-64 - identifier are as follows: - - 0 0 0 1 1 2 - |0 7 8 5 6 3| - +----+----+----+----+----+----+ - |cccc|ccug|cccc|cccc|cccc|cccc| - +----+----+----+----+----+----+ - - - - - - -Hinden & Deering Standards Track [Page 8] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - - written in Internet standard bit-order , where "u" is the - universal/local bit, "g" is the individual/group bit, and "c" are the - bits of the company_id. Appendix A: "Creating EUI-64 based Interface - Identifiers" provides examples on the creation of different EUI-64 - based interface identifiers. - - The motivation for inverting the "u" bit when forming the interface - identifier is to make it easy for system administrators to hand - configure local scope identifiers when hardware tokens are not - available. This is expected to be case for serial links, tunnel end- - points, etc. The alternative would have been for these to be of the - form 0200:0:0:1, 0200:0:0:2, etc., instead of the much simpler ::1, - ::2, etc. - - The use of the universal/local bit in the IEEE EUI-64 identifier is - to allow development of future technology that can take advantage of - interface identifiers with global scope. - - The details of forming interface identifiers are defined in the - appropriate "IPv6 over <link>" specification such as "IPv6 over - Ethernet" [ETHER], "IPv6 over FDDI" [FDDI], etc. - -2.5.2 The Unspecified Address - - The address 0:0:0:0:0:0:0:0 is called the unspecified address. It - must never be assigned to any node. It indicates the absence of an - address. One example of its use is in the Source Address field of - any IPv6 packets sent by an initializing host before it has learned - its own address. - - The unspecified address must not be used as the destination address - of IPv6 packets or in IPv6 Routing Headers. - -2.5.3 The Loopback Address - - The unicast address 0:0:0:0:0:0:0:1 is called the loopback address. - It may be used by a node to send an IPv6 packet to itself. It may - never be assigned to any physical interface. It may be thought of as - being associated with a virtual interface (e.g., the loopback - interface). - - The loopback address must not be used as the source address in IPv6 - packets that are sent outside of a single node. An IPv6 packet with - a destination address of loopback must never be sent outside of a - single node and must never be forwarded by an IPv6 router. - - - - - - -Hinden & Deering Standards Track [Page 9] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - -2.5.4 IPv6 Addresses with Embedded IPv4 Addresses - - The IPv6 transition mechanisms [TRAN] include a technique for hosts - and routers to dynamically tunnel IPv6 packets over IPv4 routing - infrastructure. IPv6 nodes that utilize this technique are assigned - special IPv6 unicast addresses that carry an IPv4 address in the low- - order 32-bits. This type of address is termed an "IPv4-compatible - IPv6 address" and has the format: - - | 80 bits | 16 | 32 bits | - +--------------------------------------+--------------------------+ - |0000..............................0000|0000| IPv4 address | - +--------------------------------------+----+---------------------+ - - A second type of IPv6 address which holds an embedded IPv4 address is - also defined. This address is used to represent the addresses of - IPv4-only nodes (those that *do not* support IPv6) as IPv6 addresses. - This type of address is termed an "IPv4-mapped IPv6 address" and has - the format: - - | 80 bits | 16 | 32 bits | - +--------------------------------------+--------------------------+ - |0000..............................0000|FFFF| IPv4 address | - +--------------------------------------+----+---------------------+ - -2.5.5 NSAP Addresses - - This mapping of NSAP address into IPv6 addresses is defined in - [NSAP]. This document recommends that network implementors who have - planned or deployed an OSI NSAP addressing plan, and who wish to - deploy or transition to IPv6, should redesign a native IPv6 - addressing plan to meet their needs. However, it also defines a set - of mechanisms for the support of OSI NSAP addressing in an IPv6 - network. These mechanisms are the ones that must be used if such - support is required. This document also defines a mapping of IPv6 - addresses within the OSI address format, should this be required. - -2.5.6 IPX Addresses - - This mapping of IPX address into IPv6 addresses is as follows: - - | 7 | 121 bits | - +-------+---------------------------------------------------------+ - |0000010| to be defined | - +-------+---------------------------------------------------------+ - - The draft definition, motivation, and usage are under study. - - - - -Hinden & Deering Standards Track [Page 10] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - -2.5.7 Aggregatable Global Unicast Addresses - - The global aggregatable global unicast address is defined in [AGGR]. - This address format is designed to support both the current provider - based aggregation and a new type of aggregation called exchanges. - The combination will allow efficient routing aggregation for both - sites which connect directly to providers and who connect to - exchanges. Sites will have the choice to connect to either type of - aggregation point. - - The IPv6 aggregatable global unicast address format is as follows: - - | 3| 13 | 8 | 24 | 16 | 64 bits | - +--+-----+---+--------+--------+--------------------------------+ - |FP| TLA |RES| NLA | SLA | Interface ID | - | | ID | | ID | ID | | - +--+-----+---+--------+--------+--------------------------------+ - - Where - - 001 Format Prefix (3 bit) for Aggregatable Global - Unicast Addresses - TLA ID Top-Level Aggregation Identifier - RES Reserved for future use - NLA ID Next-Level Aggregation Identifier - SLA ID Site-Level Aggregation Identifier - INTERFACE ID Interface Identifier - - The contents, field sizes, and assignment rules are defined in - [AGGR]. - -2.5.8 Local-Use IPv6 Unicast Addresses - - There are two types of local-use unicast addresses defined. These - are Link-Local and Site-Local. The Link-Local is for use on a single - link and the Site-Local is for use in a single site. Link-Local - addresses have the following format: - - | 10 | - | bits | 54 bits | 64 bits | - +----------+-------------------------+----------------------------+ - |1111111010| 0 | interface ID | - +----------+-------------------------+----------------------------+ - - Link-Local addresses are designed to be used for addressing on a - single link for purposes such as auto-address configuration, neighbor - discovery, or when no routers are present. - - - - -Hinden & Deering Standards Track [Page 11] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - - Routers must not forward any packets with link-local source or - destination addresses to other links. - - Site-Local addresses have the following format: - - | 10 | - | bits | 38 bits | 16 bits | 64 bits | - +----------+-------------+-----------+----------------------------+ - |1111111011| 0 | subnet ID | interface ID | - +----------+-------------+-----------+----------------------------+ - - Site-Local addresses are designed to be used for addressing inside of - a site without the need for a global prefix. - - Routers must not forward any packets with site-local source or - destination addresses outside of the site. - -2.6 Anycast Addresses - - An IPv6 anycast address is an address that is assigned to more than - one interface (typically belonging to different nodes), with the - property that a packet sent to an anycast address is routed to the - "nearest" interface having that address, according to the routing - protocols' measure of distance. - - Anycast addresses are allocated from the unicast address space, using - any of the defined unicast address formats. Thus, anycast addresses - are syntactically indistinguishable from unicast addresses. When a - unicast address is assigned to more than one interface, thus turning - it into an anycast address, the nodes to which the address is - assigned must be explicitly configured to know that it is an anycast - address. - - For any assigned anycast address, there is a longest address prefix P - that identifies the topological region in which all interfaces - belonging to that anycast address reside. Within the region - identified by P, each member of the anycast set must be advertised as - a separate entry in the routing system (commonly referred to as a - "host route"); outside the region identified by P, the anycast - address may be aggregated into the routing advertisement for prefix - P. - - Note that in, the worst case, the prefix P of an anycast set may be - the null prefix, i.e., the members of the set may have no topological - locality. In that case, the anycast address must be advertised as a - separate routing entry throughout the entire internet, which presents - - - - - -Hinden & Deering Standards Track [Page 12] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - - a severe scaling limit on how many such "global" anycast sets may be - supported. Therefore, it is expected that support for global anycast - sets may be unavailable or very restricted. - - One expected use of anycast addresses is to identify the set of - routers belonging to an organization providing internet service. - Such addresses could be used as intermediate addresses in an IPv6 - Routing header, to cause a packet to be delivered via a particular - aggregation or sequence of aggregations. Some other possible uses - are to identify the set of routers attached to a particular subnet, - or the set of routers providing entry into a particular routing - domain. - - There is little experience with widespread, arbitrary use of internet - anycast addresses, and some known complications and hazards when - using them in their full generality [ANYCST]. Until more experience - has been gained and solutions agreed upon for those problems, the - following restrictions are imposed on IPv6 anycast addresses: - - o An anycast address must not be used as the source address of an - IPv6 packet. - - o An anycast address must not be assigned to an IPv6 host, that - is, it may be assigned to an IPv6 router only. - -2.6.1 Required Anycast Address - - The Subnet-Router anycast address is predefined. Its format is as - follows: - - | n bits | 128-n bits | - +------------------------------------------------+----------------+ - | subnet prefix | 00000000000000 | - +------------------------------------------------+----------------+ - - The "subnet prefix" in an anycast address is the prefix which - identifies a specific link. This anycast address is syntactically - the same as a unicast address for an interface on the link with the - interface identifier set to zero. - - Packets sent to the Subnet-Router anycast address will be delivered - to one router on the subnet. All routers are required to support the - Subnet-Router anycast addresses for the subnets which they have - interfaces. - - - - - - - -Hinden & Deering Standards Track [Page 13] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - - The subnet-router anycast address is intended to be used for - applications where a node needs to communicate with one of a set of - routers on a remote subnet. For example when a mobile host needs to - communicate with one of the mobile agents on its "home" subnet. - -2.7 Multicast Addresses - - An IPv6 multicast address is an identifier for a group of nodes. A - node may belong to any number of multicast groups. Multicast - addresses have the following format: - - | 8 | 4 | 4 | 112 bits | - +------ -+----+----+---------------------------------------------+ - |11111111|flgs|scop| group ID | - +--------+----+----+---------------------------------------------+ - - 11111111 at the start of the address identifies the address as - being a multicast address. - - +-+-+-+-+ - flgs is a set of 4 flags: |0|0|0|T| - +-+-+-+-+ - - The high-order 3 flags are reserved, and must be initialized to - 0. - - T = 0 indicates a permanently-assigned ("well-known") multicast - address, assigned by the global internet numbering authority. - - T = 1 indicates a non-permanently-assigned ("transient") - multicast address. - - scop is a 4-bit multicast scope value used to limit the scope of - the multicast group. The values are: - - 0 reserved - 1 node-local scope - 2 link-local scope - 3 (unassigned) - 4 (unassigned) - 5 site-local scope - 6 (unassigned) - 7 (unassigned) - 8 organization-local scope - 9 (unassigned) - A (unassigned) - B (unassigned) - C (unassigned) - - - -Hinden & Deering Standards Track [Page 14] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - - D (unassigned) - E global scope - F reserved - - group ID identifies the multicast group, either permanent or - transient, within the given scope. - - The "meaning" of a permanently-assigned multicast address is - independent of the scope value. For example, if the "NTP servers - group" is assigned a permanent multicast address with a group ID of - 101 (hex), then: - - FF01:0:0:0:0:0:0:101 means all NTP servers on the same node as the - sender. - - FF02:0:0:0:0:0:0:101 means all NTP servers on the same link as the - sender. - - FF05:0:0:0:0:0:0:101 means all NTP servers at the same site as the - sender. - - FF0E:0:0:0:0:0:0:101 means all NTP servers in the internet. - - Non-permanently-assigned multicast addresses are meaningful only - within a given scope. For example, a group identified by the non- - permanent, site-local multicast address FF15:0:0:0:0:0:0:101 at one - site bears no relationship to a group using the same address at a - different site, nor to a non-permanent group using the same group ID - with different scope, nor to a permanent group with the same group - ID. - - Multicast addresses must not be used as source addresses in IPv6 - packets or appear in any routing header. - -2.7.1 Pre-Defined Multicast Addresses - - The following well-known multicast addresses are pre-defined: - - Reserved Multicast Addresses: FF00:0:0:0:0:0:0:0 - FF01:0:0:0:0:0:0:0 - FF02:0:0:0:0:0:0:0 - FF03:0:0:0:0:0:0:0 - FF04:0:0:0:0:0:0:0 - FF05:0:0:0:0:0:0:0 - FF06:0:0:0:0:0:0:0 - FF07:0:0:0:0:0:0:0 - FF08:0:0:0:0:0:0:0 - FF09:0:0:0:0:0:0:0 - - - -Hinden & Deering Standards Track [Page 15] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - - FF0A:0:0:0:0:0:0:0 - FF0B:0:0:0:0:0:0:0 - FF0C:0:0:0:0:0:0:0 - FF0D:0:0:0:0:0:0:0 - FF0E:0:0:0:0:0:0:0 - FF0F:0:0:0:0:0:0:0 - - The above multicast addresses are reserved and shall never be - assigned to any multicast group. - - All Nodes Addresses: FF01:0:0:0:0:0:0:1 - FF02:0:0:0:0:0:0:1 - - The above multicast addresses identify the group of all IPv6 nodes, - within scope 1 (node-local) or 2 (link-local). - - All Routers Addresses: FF01:0:0:0:0:0:0:2 - FF02:0:0:0:0:0:0:2 - FF05:0:0:0:0:0:0:2 - - The above multicast addresses identify the group of all IPv6 routers, - within scope 1 (node-local), 2 (link-local), or 5 (site-local). - - Solicited-Node Address: FF02:0:0:0:0:1:FFXX:XXXX - - The above multicast address is computed as a function of a node's - unicast and anycast addresses. The solicited-node multicast address - is formed by taking the low-order 24 bits of the address (unicast or - anycast) and appending those bits to the prefix - FF02:0:0:0:0:1:FF00::/104 resulting in a multicast address in the - range - - FF02:0:0:0:0:1:FF00:0000 - - to - - FF02:0:0:0:0:1:FFFF:FFFF - - For example, the solicited node multicast address corresponding to - the IPv6 address 4037::01:800:200E:8C6C is FF02::1:FF0E:8C6C. IPv6 - addresses that differ only in the high-order bits, e.g. due to - multiple high-order prefixes associated with different aggregations, - will map to the same solicited-node address thereby reducing the - number of multicast addresses a node must join. - - A node is required to compute and join the associated Solicited-Node - multicast addresses for every unicast and anycast address it is - assigned. - - - -Hinden & Deering Standards Track [Page 16] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - -2.7.2 Assignment of New IPv6 Multicast Addresses - - The current approach [ETHER] to map IPv6 multicast addresses into - IEEE 802 MAC addresses takes the low order 32 bits of the IPv6 - multicast address and uses it to create a MAC address. Note that - Token Ring networks are handled differently. This is defined in - [TOKEN]. Group ID's less than or equal to 32 bits will generate - unique MAC addresses. Due to this new IPv6 multicast addresses - should be assigned so that the group identifier is always in the low - order 32 bits as shown in the following: - - | 8 | 4 | 4 | 80 bits | 32 bits | - +------ -+----+----+---------------------------+-----------------+ - |11111111|flgs|scop| reserved must be zero | group ID | - +--------+----+----+---------------------------+-----------------+ - - While this limits the number of permanent IPv6 multicast groups to - 2^32 this is unlikely to be a limitation in the future. If it - becomes necessary to exceed this limit in the future multicast will - still work but the processing will be sightly slower. - - Additional IPv6 multicast addresses are defined and registered by the - IANA [MASGN]. - -2.8 A Node's Required Addresses - - A host is required to recognize the following addresses as - identifying itself: - - o Its Link-Local Address for each interface - o Assigned Unicast Addresses - o Loopback Address - o All-Nodes Multicast Addresses - o Solicited-Node Multicast Address for each of its assigned - unicast and anycast addresses - o Multicast Addresses of all other groups to which the host - belongs. - - A router is required to recognize all addresses that a host is - required to recognize, plus the following addresses as identifying - itself: - - o The Subnet-Router anycast addresses for the interfaces it is - configured to act as a router on. - o All other Anycast addresses with which the router has been - configured. - o All-Routers Multicast Addresses - - - - -Hinden & Deering Standards Track [Page 17] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - - o Multicast Addresses of all other groups to which the router - belongs. - - The only address prefixes which should be predefined in an - implementation are the: - - o Unspecified Address - o Loopback Address - o Multicast Prefix (FF) - o Local-Use Prefixes (Link-Local and Site-Local) - o Pre-Defined Multicast Addresses - o IPv4-Compatible Prefixes - - Implementations should assume all other addresses are unicast unless - specifically configured (e.g., anycast addresses). - -3. Security Considerations - - IPv6 addressing documents do not have any direct impact on Internet - infrastructure security. Authentication of IPv6 packets is defined - in [AUTH]. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Hinden & Deering Standards Track [Page 18] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - -APPENDIX A : Creating EUI-64 based Interface Identifiers --------------------------------------------------------- - - Depending on the characteristics of a specific link or node there are - a number of approaches for creating EUI-64 based interface - identifiers. This appendix describes some of these approaches. - -Links or Nodes with EUI-64 Identifiers - - The only change needed to transform an EUI-64 identifier to an - interface identifier is to invert the "u" (universal/local) bit. For - example, a globally unique EUI-64 identifier of the form: - - |0 1|1 3|3 4|4 6| - |0 5|6 1|2 7|8 3| - +----------------+----------------+----------------+----------------+ - |cccccc0gcccccccc|ccccccccmmmmmmmm|mmmmmmmmmmmmmmmm|mmmmmmmmmmmmmmmm| - +----------------+----------------+----------------+----------------+ - - where "c" are the bits of the assigned company_id, "0" is the value - of the universal/local bit to indicate global scope, "g" is - individual/group bit, and "m" are the bits of the manufacturer- - selected extension identifier. The IPv6 interface identifier would - be of the form: - - |0 1|1 3|3 4|4 6| - |0 5|6 1|2 7|8 3| - +----------------+----------------+----------------+----------------+ - |cccccc1gcccccccc|ccccccccmmmmmmmm|mmmmmmmmmmmmmmmm|mmmmmmmmmmmmmmmm| - +----------------+----------------+----------------+----------------+ - - The only change is inverting the value of the universal/local bit. - -Links or Nodes with IEEE 802 48 bit MAC's - - [EUI64] defines a method to create a EUI-64 identifier from an IEEE - 48bit MAC identifier. This is to insert two octets, with hexadecimal - values of 0xFF and 0xFE, in the middle of the 48 bit MAC (between the - company_id and vendor supplied id). For example the 48 bit MAC with - global scope: - - |0 1|1 3|3 4| - |0 5|6 1|2 7| - +----------------+----------------+----------------+ - |cccccc0gcccccccc|ccccccccmmmmmmmm|mmmmmmmmmmmmmmmm| - +----------------+----------------+----------------+ - - - - - -Hinden & Deering Standards Track [Page 19] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - - where "c" are the bits of the assigned company_id, "0" is the value - of the universal/local bit to indicate global scope, "g" is - individual/group bit, and "m" are the bits of the manufacturer- - selected extension identifier. The interface identifier would be of - the form: - - |0 1|1 3|3 4|4 6| - |0 5|6 1|2 7|8 3| - +----------------+----------------+----------------+----------------+ - |cccccc1gcccccccc|cccccccc11111111|11111110mmmmmmmm|mmmmmmmmmmmmmmmm| - +----------------+----------------+----------------+----------------+ - - When IEEE 802 48bit MAC addresses are available (on an interface or a - node), an implementation should use them to create interface - identifiers due to their availability and uniqueness properties. - -Links with Non-Global Identifiers - - There are a number of types of links that, while multi-access, do not - have globally unique link identifiers. Examples include LocalTalk - and Arcnet. The method to create an EUI-64 formatted identifier is - to take the link identifier (e.g., the LocalTalk 8 bit node - identifier) and zero fill it to the left. For example a LocalTalk 8 - bit node identifier of hexadecimal value 0x4F results in the - following interface identifier: - - |0 1|1 3|3 4|4 6| - |0 5|6 1|2 7|8 3| - +----------------+----------------+----------------+----------------+ - |0000000000000000|0000000000000000|0000000000000000|0000000001001111| - +----------------+----------------+----------------+----------------+ - - Note that this results in the universal/local bit set to "0" to - indicate local scope. - -Links without Identifiers - - There are a number of links that do not have any type of built-in - identifier. The most common of these are serial links and configured - tunnels. Interface identifiers must be chosen that are unique for - the link. - - When no built-in identifier is available on a link the preferred - approach is to use a global interface identifier from another - interface or one which is assigned to the node itself. To use this - approach no other interface connecting the same node to the same link - may use the same identifier. - - - - -Hinden & Deering Standards Track [Page 20] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - - If there is no global interface identifier available for use on the - link the implementation needs to create a local scope interface - identifier. The only requirement is that it be unique on the link. - There are many possible approaches to select a link-unique interface - identifier. They include: - - Manual Configuration - Generated Random Number - Node Serial Number (or other node-specific token) - - The link-unique interface identifier should be generated in a manner - that it does not change after a reboot of a node or if interfaces are - added or deleted from the node. - - The selection of the appropriate algorithm is link and implementation - dependent. The details on forming interface identifiers are defined - in the appropriate "IPv6 over <link>" specification. It is strongly - recommended that a collision detection algorithm be implemented as - part of any automatic algorithm. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Hinden & Deering Standards Track [Page 21] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - -APPENDIX B: ABNF Description of Text Representations ----------------------------------------------------- - - This appendix defines the text representation of IPv6 addresses and - prefixes in Augmented BNF [ABNF] for reference purposes. - - IPv6address = hexpart [ ":" IPv4address ] - IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT - - IPv6prefix = hexpart "/" 1*2DIGIT - - hexpart = hexseq | hexseq "::" [ hexseq ] | "::" [ hexseq ] - hexseq = hex4 *( ":" hex4) - hex4 = 1*4HEXDIG - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Hinden & Deering Standards Track [Page 22] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - -APPENDIX C: CHANGES FROM RFC-1884 ---------------------------------- - - The following changes were made from RFC-1884 "IP Version 6 - Addressing Architecture": - - - Added an appendix providing a ABNF description of text - representations. - - Clarification that link unique identifiers not change after - reboot or other interface reconfigurations. - - Clarification of Address Model based on comments. - - Changed aggregation format terminology to be consistent with - aggregation draft. - - Added text to allow interface identifier to be used on more than - one interface on same node. - - Added rules for defining new multicast addresses. - - Added appendix describing procedures for creating EUI-64 based - interface ID's. - - Added notation for defining IPv6 prefixes. - - Changed solicited node multicast definition to use a longer - prefix. - - Added site scope all routers multicast address. - - Defined Aggregatable Global Unicast Addresses to use "001" Format - Prefix. - - Changed "010" (Provider-Based Unicast) and "100" (Reserved for - Geographic) Format Prefixes to Unassigned. - - Added section on Interface ID definition for unicast addresses. - Requires use of EUI-64 in range of format prefixes and rules for - setting global/local scope bit in EUI-64. - - Updated NSAP text to reflect working in RFC1888. - - Removed protocol specific IPv6 multicast addresses (e.g., DHCP) - and referenced the IANA definitions. - - Removed section "Unicast Address Example". Had become OBE. - - Added new and updated references. - - Minor text clarifications and improvements. - - - - - - - - - - - - - - - - -Hinden & Deering Standards Track [Page 23] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - -REFERENCES - - [ABNF] Crocker, D., and P. Overell, "Augmented BNF for - Syntax Specifications: ABNF", RFC 2234, November 1997. - - [AGGR] Hinden, R., O'Dell, M., and S. Deering, "An - Aggregatable Global Unicast Address Format", RFC 2374, July - 1998. - - [AUTH] Atkinson, R., "IP Authentication Header", RFC 1826, August - 1995. - - [ANYCST] Partridge, C., Mendez, T., and W. Milliken, "Host - Anycasting Service", RFC 1546, November 1993. - - [CIDR] Fuller, V., Li, T., Yu, J., and K. Varadhan, "Classless - Inter-Domain Routing (CIDR): An Address Assignment and - Aggregation Strategy", RFC 1519, September 1993. - - [ETHER] Crawford, M., "Transmission of IPv6 Pacekts over Ethernet - Networks", Work in Progress. - - [EUI64] IEEE, "Guidelines for 64-bit Global Identifier (EUI-64) - Registration Authority", - http://standards.ieee.org/db/oui/tutorials/EUI64.html, - March 1997. - - [FDDI] Crawford, M., "Transmission of IPv6 Packets over FDDI - Networks", Work in Progress. - - [IPV6] Deering, S., and R. Hinden, Editors, "Internet Protocol, - Version 6 (IPv6) Specification", RFC 1883, December 1995. - - [MASGN] Hinden, R., and S. Deering, "IPv6 Multicast Address - Assignments", RFC 2375, July 1998. - - [NSAP] Bound, J., Carpenter, B., Harrington, D., Houldsworth, J., - and A. Lloyd, "OSI NSAPs and IPv6", RFC 1888, August 1996. - - [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate - Requirement Levels", BCP 14, RFC 2119, March 1997. - - [TOKEN] Thomas, S., "Transmission of IPv6 Packets over Token Ring - Networks", Work in Progress. - - [TRAN] Gilligan, R., and E. Nordmark, "Transition Mechanisms for - IPv6 Hosts and Routers", RFC 1993, April 1996. - - - - -Hinden & Deering Standards Track [Page 24] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - -AUTHORS' ADDRESSES - - Robert M. Hinden - Nokia - 232 Java Drive - Sunnyvale, CA 94089 - USA - - Phone: +1 408 990-2004 - Fax: +1 408 743-5677 - EMail: hinden@iprg.nokia.com - - - Stephen E. Deering - Cisco Systems, Inc. - 170 West Tasman Drive - San Jose, CA 95134-1706 - USA - - Phone: +1 408 527-8213 - Fax: +1 408 527-8254 - EMail: deering@cisco.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Hinden & Deering Standards Track [Page 25] - -RFC 2373 IPv6 Addressing Architecture July 1998 - - -Full Copyright Statement - - Copyright (C) The Internet Society (1998). All Rights Reserved. - - This document and translations of it may be copied and furnished to - others, and derivative works that comment on or otherwise explain it - or assist in its implementation may be prepared, copied, published - and distributed, in whole or in part, without restriction of any - kind, provided that the above copyright notice and this paragraph are - included on all such copies and derivative works. However, this - document itself may not be modified in any way, such as by removing - the copyright notice or references to the Internet Society or other - Internet organizations, except as needed for the purpose of - developing Internet standards in which case the procedures for - copyrights defined in the Internet Standards process must be - followed, or as required to translate it into languages other than - English. - - The limited permissions granted above are perpetual and will not be - revoked by the Internet Society or its successors or assigns. - - This document and the information contained herein is provided on an - "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING - TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION - HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF - MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - - - - - - - - - - - - - - - - - - - - - - - - -Hinden & Deering Standards Track [Page 26] - | ||
[+] | Deleted | Net-IPv6Addr-0.2.tar.gz/t ^ |
-(directory) | ||
[+] | Deleted | Net-IPv6Addr-0.2.tar.gz/t/base85.t ^ |
@@ -1,68 +0,0 @@ -use strict; -use Test; -BEGIN { - eval { require Math::Base85; }; - if ($@) { - print "1..0 # Math::Base85 is not installed\n"; - exit 0; - } -} -BEGIN { plan test => 29; } - -use Net::IPv6Addr; -ok(1); - -# Test ipv6_parse_base85 with garbage. - -eval { Net::IPv6Addr::ipv6_parse_base85("\n"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_base85 with a bad character. -eval { Net::IPv6Addr::ipv6_parse_base85("abcdefghi klmnopqrst"); }; -ok($@); -ok($@, qr/invalid address/); - - -# Test ipv6_parse_base85 with a bad length. -eval { Net::IPv6Addr::ipv6_parse_base85("abcdefghijklmnopqrs"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_base85 with good stuff. -# Example stolen from rfc1924.txt -my @pieces = Net::IPv6Addr::ipv6_parse_base85("4)+k&C#VzJ4br>0wv%Yp"); -ok($pieces[0], 0x1080); -ok($pieces[1], 0); -ok($pieces[2], 0); -ok($pieces[3], 0); -ok($pieces[4], 0x8); -ok($pieces[5], 0x800); -ok($pieces[6], 0x200C); -ok($pieces[7], 0x417A); - -my $x; -# Test new with bad base85 digits. -eval { $x = new Net::IPv6Addr("0123456789ABCDEF GHI"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with bad base85 length. -eval { $x = new Net::IPv6Addr("0123456789ABCDEFGHI"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with good base85. -$x = new Net::IPv6Addr("4)+k&C#VzJ4br>0wv%Yp"); -ok(ref $x, 'Net::IPv6Addr'); -ok($x->[0], 0x1080); -ok($x->[1], 0); -ok($x->[2], 0); -ok($x->[3], 0); -ok($x->[4], 8); -ok($x->[5], 0x800); -ok($x->[6], 0x200C); -ok($x->[7], 0x417A); - -# Test to_string_base85. -ok($x->to_string_base85(), "4)+k&C#VzJ4br>0wv%Yp"); | ||
[+] | Deleted | Net-IPv6Addr-0.2.tar.gz/t/chkip.t ^ |
@@ -1,139 +0,0 @@ -use strict; -use Test; -BEGIN { plan tests => 34; } - -use Net::IPv6Addr; -ok(1); - -my $x; -# Test ipv6_chkip with garbage. -$x = Net::IPv6Addr::ipv6_chkip("Obvious Garbage"); -ok(not defined $x); - -# Test ipv6_chkip with preferred style, too many : -$x = Net::IPv6Addr::ipv6_chkip("0:1:2:3:4:5:6:7:8"); -ok(not defined $x); - -# Test ipv6_chkip with preferred style, not enough : -$x = Net::IPv6Addr::ipv6_chkip("0:1:2:3:4:5:6"); -ok(not defined $x); - -# Test ipv6_chkip with preferred style, bad digits. -$x = Net::IPv6Addr::ipv6_chkip("0:1:2:3:4:5:6:x"); -ok(not defined $x); - -# Test ipv6_chkip with preferred style, adjacent : -$x = Net::IPv6Addr::ipv6_chkip("0:1:2:3:4:5:6::7"); -ok(not defined $x); - -# Test ipv6_chkip with preferred style, too many digits. -$x = Net::IPv6Addr::ipv6_chkip("0:1:2:3:4:5:6:789abcdef"); -ok(not defined $x); - -# Test ipv6_chkip with preferred style. -$x = Net::IPv6Addr::ipv6_chkip("0:1:2:3:4:5:6:789a"); -ok(ref $x, 'CODE'); - -# Test ipv6_chkip with compressed style, bad digits. -$x = Net::IPv6Addr::ipv6_chkip("0:1:2:3::x"); -ok(not defined $x); - -# Test ipv6_chkip with compressed style, too many adjacent : -$x = Net::IPv6Addr::ipv6_chkip("0:1:2:::3"); -ok(not defined $x); - -# Test ipv6_chkip with compressed style, too many digits. -$x = Net::IPv6Addr::ipv6_chkip("0:1:2:3::abcde"); -ok(not defined $x); - -# Test ipv6_chkip with compressed style, too many : -$x = Net::IPv6Addr::ipv6_chkip("0:1:2:3:4:5:6:7:8"); -ok(not defined $x); - -# Test ipv6_chkip with compressed style, not enough : -$x = Net::IPv6Addr::ipv6_chkip("0:1"); -ok(not defined $x); - -# Test ipv6_chkip with compressed style. -$x = Net::IPv6Addr::ipv6_chkip("0:1:2:3::f"); -ok(ref $x, 'CODE'); - -# Test ipv6_chkip with ipv4 style, bad ipv6 digits. -$x = Net::IPv6Addr::ipv6_chkip("0:0:0:0:0:x:10.0.0.1"); -ok(not defined $x); - -# Test ipv6_chkip with ipv4 style, bad ipv4 digits. -$x = Net::IPv6Addr::ipv6_chkip("0:0:0:0:0:0:10.0.0.x"); -ok(not defined $x); - -# Test ipv6_chkip with ipv4 style, adjacent : -$x = Net::IPv6Addr::ipv6_chkip("0:0:0:0:0::0:10.0.0.1"); -ok(not defined $x); - -# Test ipv6_chkip with ipv4 style, too many ipv6 digits. -$x = Net::IPv6Addr::ipv6_chkip("0:0:0:0:0:00000:10.0.0.1"); -ok(not defined $x); - -# Test ipv6_chkip with ipv4 style, too many : -$x = Net::IPv6Addr::ipv6_chkip("0:0:0:0:0:0:0:10.0.0.1"); -ok(not defined $x); - -# Test ipv6_chkip with ipv4 style, not enough : -$x = Net::IPv6Addr::ipv6_chkip("0:0:0:0:0:10.0.0.1"); -ok(not defined $x); - -# Test ipv6_chkip with ipv4 style, too many . -$x = Net::IPv6Addr::ipv6_chkip("0:0:0:0:0:0:10.0.0.0.1"); -ok(not defined $x); - -# Test ipv6_chkip with ipv4 style, not enough . -$x = Net::IPv6Addr::ipv6_chkip("0:0:0:0:0:0:10.0.1"); -ok(not defined $x); - -# Test ipv6_chkip with ipv4 style, adjacent . -$x = Net::IPv6Addr::ipv6_chkip("0:0:0:0:0:0:10..0.0.1"); -ok(not defined $x); - -# Test ipv6_chkip with ipv4 style. -$x = Net::IPv6Addr::ipv6_chkip("0:0:0:0:0:0:10.0.0.1"); -ok(ref $x, 'CODE'); - -# Test ipv6_chkip with compressed ipv4 style, bad ipv6 digits. -$x = Net::IPv6Addr::ipv6_chkip("::fffx:192.168.0.1"); -ok(not defined $x); - -# Test ipv6_chkip with compressed ipv4 style, bad ipv4 digits. -$x = Net::IPv6Addr::ipv6_chkip("::ffff:192.168.0.x"); -ok(not defined $x); - -# Test ipv6_chkip with compressed ipv4 style, too many adjacent : -$x = Net::IPv6Addr::ipv6_chkip(":::ffff:192.168.0.1"); -ok(not defined $x); - -# Test ipv6_chkip with compressed ipv4 style, too many ipv6 digits. -$x = Net::IPv6Addr::ipv6_chkip("::fffff:192.168.0.1"); -ok(not defined $x); - -# Test ipv6_chkip with compressed ipv4 style, too many ipv4 digits. -$x = Net::IPv6Addr::ipv6_chkip("::ffff:1923.168.0.1"); -ok(not defined $x); - -# Test ipv6_chkip with compressed ipv4 style, not enough : -$x = Net::IPv6Addr::ipv6_chkip(":ffff:192.168.0.1"); -ok(not defined $x); - -# Test ipv6_chkip with compressed ipv4 style, too many . -$x = Net::IPv6Addr::ipv6_chkip("::ffff:192.168.0.1.2"); -ok(not defined $x); - -# Test ipv6_chkip with compressed ipv4 style, not enough . -$x = Net::IPv6Addr::ipv6_chkip("::ffff:192.168.0"); -ok(not defined $x); - -# Test ipv6_chkip with compressed ipv4 style, adjacent . -$x = Net::IPv6Addr::ipv6_chkip("::ffff:192.168..0.1"); -ok(not defined $x); - -# Test ipv6_chkip with compressed ipv4 style. -$x = Net::IPv6Addr::ipv6_chkip("::ffff:192.168.0.1"); -ok(ref $x, 'CODE'); | ||
[+] | Deleted | Net-IPv6Addr-0.2.tar.gz/t/compressed.t ^ |
@@ -1,44 +0,0 @@ -use strict; -use Test; -BEGIN { plan test => 19; } - -use Net::IPv6Addr; -ok(1); - -my @x; - -# Test ipv6_parse_compressed, bad digits. -eval { @x = Net::IPv6Addr::ipv6_parse_compressed("::x"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_compressed, too many adjacent : -eval { @x = Net::IPv6Addr::ipv6_parse_compressed(":::1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_compressed, too many digits. -eval { @x = Net::IPv6Addr::ipv6_parse_compressed("::11111"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_compressed, too many : -eval { @x = Net::IPv6Addr::ipv6_parse_compressed("0:1:2:3:4:5:6::7"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_compressed, not enough : -eval { @x = Net::IPv6Addr::ipv6_parse_compressed(":1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_compressed, with good stuff. -@x = Net::IPv6Addr::ipv6_parse_compressed("::1"); -ok($x[0], 0); -ok($x[1], 0); -ok($x[2], 0); -ok($x[3], 0); -ok($x[4], 0); -ok($x[5], 0); -ok($x[6], 0); -ok($x[7], 1); | ||
[+] | Deleted | Net-IPv6Addr-0.2.tar.gz/t/ipv4.t ^ |
@@ -1,74 +0,0 @@ -use strict; -use Test; -BEGIN { plan test => 31; } - -use Net::IPv6Addr; -ok(1); - -my @x; - -# Test ipv6_parse_ipv4, garbage. -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4("absolute and utter garbage"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4, bad ipv6 digits. -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4("x:0:0:0:0:0:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4, bad ipv4 digits. -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4("0:0:0:0:0:0:x.0.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4, adjacent : -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4("0:0:0:0:0::0:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4, too many ipv6 digits. -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4("00000:0:0:0:0:0:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4, too many ipv4 digits. -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4("0:0:0:0:0:0:10.0.0.1000"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4, too many : -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4("0:0:0:0:0:0:0:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4, not enough : -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4("0:0:0:0:0:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4, too many . -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4("0:0:0:0:0:0:10.0.0.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4, not enough . -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4("0:0:0:0:0:0:10.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4, adjacent . -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4("0:0:0:0:0:0:10.0.0..1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4, good stuff. -@x = Net::IPv6Addr::ipv6_parse_ipv4("0:0:0:0:0:0:10.0.0.1"); -ok($x[0], 0); -ok($x[1], 0); -ok($x[2], 0); -ok($x[3], 0); -ok($x[4], 0); -ok($x[5], 0); -ok($x[6], 0xa00); -ok($x[7], 1); | ||
[+] | Deleted | Net-IPv6Addr-0.2.tar.gz/t/ipv4comp.t ^ |
@@ -1,84 +0,0 @@ -use strict; -use Test; -BEGIN { plan test => 39; } - -use Net::IPv6Addr; -ok(1); - -my @x; - -# Test ipv6_parse_ipv4_compressed, with garbage. -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4_compressed("life, in a nutshell"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4_compressed, bad ipv6 digits. -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4_compressed("::fffe:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4_compressed, bad ipv4 digits. -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4_compressed("::ffff:10.0.0.x"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4_compressed, too many adjacent : -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4_compressed(":::ffff:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4_compressed, too many ipv6 digits. -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4_compressed("::fffff:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4_compressed, too many ipv4 digits. -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4_compressed("::ffff:10.0.0.9999"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4_compressed, too many : -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4_compressed("::0:ffff:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4_compressed, not enough : -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4_compressed(":ffff:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4_compressed, too many . -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4_compressed("::ffff:10.0.0.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4_compressed, not enough . -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4_compressed("::ffff:10.0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4_compressed, adjacent . -eval { @x = Net::IPv6Addr::ipv6_parse_ipv4_compressed("::ffff:10.0..0.1"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_ipv4_compressed, with good stuff. -@x = Net::IPv6Addr::ipv6_parse_ipv4_compressed("::ffff:10.0.0.1"); -ok($x[0], 0); -ok($x[1], 0); -ok($x[2], 0); -ok($x[3], 0); -ok($x[4], 0); -ok($x[5], 0xffff); -ok($x[6], 0xa00); -ok($x[7], 1); - -@x = Net::IPv6Addr::ipv6_parse_ipv4_compressed("::10.0.0.1"); -ok($x[0], 0); -ok($x[1], 0); -ok($x[2], 0); -ok($x[3], 0); -ok($x[4], 0); -ok($x[5], 0); -ok($x[6], 0xa00); -ok($x[7], 1); | ||
[+] | Deleted | Net-IPv6Addr-0.2.tar.gz/t/new.t ^ |
@@ -1,169 +0,0 @@ -use strict; -use Test; -BEGIN { plan test => 63; } - -use Net::IPv6Addr; -ok(1); - -my $x; - -# Test new with garbage. -eval { $x = new Net::IPv6Addr("Obvious Garbage"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with preferred style, too many : -eval { $x = new Net::IPv6Addr("0:1:2:3:4:5:6:7:8"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with preferred style, not enough : -eval { $x = new Net::IPv6Addr("0:1:2:3:4:5:6"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with preferred style, bad digits. -eval { $x = new Net::IPv6Addr("0:1:2:3:4:5:6:x"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with preferred style, adjacent : -eval { $x = new Net::IPv6Addr("0:1:2:3:4:5:6::7"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with preferred style, too many digits. -eval { $x = new Net::IPv6Addr("0:1:2:3:4:5:6:789abcdef"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with preferred style. -$x = new Net::IPv6Addr("0:1:2:3:4:5:6:789a"); -ok(ref $x, 'Net::IPv6Addr'); - -# Test new with compressed style, bad digits. -eval { $x = new Net::IPv6Addr("0:1:2:3::x"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with compressed style, too many adjacent : -eval { $x = new Net::IPv6Addr("0:1:2:::3"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with compressed style, too many digits. -eval { $x = new Net::IPv6Addr("0:1:2:3::abcde"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with compressed style, too many : -eval { $x = new Net::IPv6Addr("0:1:2:3:4:5:6:7:8"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with compressed style, not enough : -eval { $x = new Net::IPv6Addr("0:1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with compressed style. -$x = new Net::IPv6Addr("0:1:2:3::f"); -ok(ref $x, 'Net::IPv6Addr'); - -# Test new with ipv4 style, bad ipv6 digits. -eval { $x = new Net::IPv6Addr("0:0:0:0:0:x:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with ipv4 style, bad ipv4 digits. -eval { $x = new Net::IPv6Addr("0:0:0:0:0:0:10.0.0.x"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with ipv4 style, adjacent : -eval { $x = new Net::IPv6Addr("0:0:0:0:0::0:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with ipv4 style, too many ipv6 digits. -eval { $x = new Net::IPv6Addr("0:0:0:0:0:00000:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with ipv4 style, too many : -eval { $x = new Net::IPv6Addr("0:0:0:0:0:0:0:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with ipv4 style, not enough : -eval { $x = new Net::IPv6Addr("0:0:0:0:0:10.0.0.1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with ipv4 style, too many . -eval { $x = new Net::IPv6Addr("0:0:0:0:0:0:10.0.0.0.1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with ipv4 style, not enough . -eval { $x = new Net::IPv6Addr("0:0:0:0:0:0:10.0.1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with ipv4 style, adjacent . -eval { $x = new Net::IPv6Addr("0:0:0:0:0:0:10..0.0.1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with ipv4 style. -$x = new Net::IPv6Addr("0:0:0:0:0:0:10.0.0.1"); -ok(ref $x, 'Net::IPv6Addr'); - -# Test new with compressed ipv4 style, bad ipv6 digits. -eval { $x = new Net::IPv6Addr("::fffx:192.168.0.1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with compressed ipv4 style, bad ipv4 digits. -eval { $x = new Net::IPv6Addr("::ffff:192.168.0.x"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with compressed ipv4 style, too many adjacent : -eval { $x = new Net::IPv6Addr(":::ffff:192.168.0.1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with compressed ipv4 style, too many ipv6 digits. -eval { $x = new Net::IPv6Addr("::fffff:192.168.0.1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with compressed ipv4 style, too many ipv4 digits. -eval { $x = new Net::IPv6Addr("::ffff:1923.168.0.1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with compressed ipv4 style, not enough : -eval { $x = new Net::IPv6Addr(":ffff:192.168.0.1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with compressed ipv4 style, too many . -eval { $x = new Net::IPv6Addr("::ffff:192.168.0.1.2"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with compressed ipv4 style, not enough . -eval { $x = new Net::IPv6Addr("::ffff:192.168.0"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with compressed ipv4 style, adjacent . -eval { $x = new Net::IPv6Addr("::ffff:192.168..0.1"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -# Test new with compressed ipv4 style. -$x = new Net::IPv6Addr("::ffff:192.168.0.1"); -ok(ref $x, 'Net::IPv6Addr'); | ||
[+] | Deleted | Net-IPv6Addr-0.2.tar.gz/t/parse.t ^ |
@@ -1,28 +0,0 @@ -use strict; -use Test; -BEGIN { plan tests => 12; } -use Net::IPv6Addr; -ok(1); - -# Yeah, so I was listening to it when I wrote the test. -eval { Net::IPv6Addr::ipv6_parse("sunshine of your love"); }; -ok($@); -ok($@, qr/invalid IPv6 address/); - -eval { Net::IPv6Addr::ipv6_parse("::/x"); }; -ok($@); -ok($@, qr/non-numeric prefix length/); - -eval { Net::IPv6Addr::ipv6_parse("::/-19325"); }; -ok($@); -ok($@, qr/non-numeric prefix length/); - -eval { Net::IPv6Addr::ipv6_parse("::/65389"); }; -ok($@); -ok($@, qr/invalid prefix length/); - -ok(scalar(Net::IPv6Addr::ipv6_parse("a:b:c:d:0:1:2:3")), "a:b:c:d:0:1:2:3"); - -my ($x, $y) = Net::IPv6Addr::ipv6_parse("a::/24"); -ok($x, "a::"); -ok($y, 24); | ||
[+] | Deleted | Net-IPv6Addr-0.2.tar.gz/t/preferred.t ^ |
@@ -1,52 +0,0 @@ -use strict; -use Test; -BEGIN { plan test => 25; } - -use Net::IPv6Addr; -ok(1); - -my @x; - -# Test ipv6_parse_preferred, garbage input. -eval { @x = Net::IPv6Addr::ipv6_parse_preferred("nathan jones"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_preferred, too many : -eval { @x = Net::IPv6Addr::ipv6_parse_preferred("0:1:2:3:4:5:6:7:8"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_preferred, not enough : -eval { @x = Net::IPv6Addr::ipv6_parse_preferred("0:1:2:3:4:5:6"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_preferred, bad digits. -eval { @x = Net::IPv6Addr::ipv6_parse_preferred("0:1:2:3:4:5:6:x"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_preferred, adjacent : -eval { @x = Net::IPv6Addr::ipv6_parse_preferred("0:1:2:3:4:5:6::7"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_preferred, too many digits. -eval { @x = Net::IPv6Addr::ipv6_parse_preferred("0:1:2:3:4:5:6:789ab"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_preferred, : on boundary. -eval { @x = Net::IPv6Addr::ipv6_parse_preferred(":0:1:2:3:4:5:6"); }; -ok($@); -ok($@, qr/invalid address/); - -eval { @x = Net::IPv6Addr::ipv6_parse_preferred("0:1:2:3:4:5:6:"); }; -ok($@); -ok($@, qr/invalid address/); - -# Test ipv6_parse_preferred, with good stuff. - -@x = Net::IPv6Addr::ipv6_parse_preferred("0:1:2:3:4:5:6:7"); -for my $i (0..7) { ok($x[$i], $i); } | ||
[+] | Deleted | Net-IPv6Addr-0.2.tar.gz/t/string.t ^ |
@@ -1,56 +0,0 @@ -use strict; -use Test; -BEGIN { plan test => 35; } - -use Net::IPv6Addr; -ok(1); - -my $w = new Net::IPv6Addr("ab:cd:ef:01:23:45:67:89"); -ok($w->to_string_preferred(), "ab:cd:ef:1:23:45:67:89"); -ok($w->to_string_compressed(), "ab:cd:ef:1:23:45:67:89"); -eval { $w->to_string_ipv4(); }; -ok($@); -ok($@, qr/not originally an IPv4 address/); -eval { $w->to_string_ipv4_compressed(); }; -ok($@); -ok($@, qr/not originally an IPv4 address/); -ok($w->to_string_ip6_int(), "9.8.0.0.7.6.0.0.5.4.0.0.3.2.0.0.1.0.0.0.f.e.0.0.d.c.0.0.b.a.0.0.IP6.INT."); - -my $x = new Net::IPv6Addr("::"); -ok($x->to_string_preferred(), "0:0:0:0:0:0:0:0"); -ok($x->to_string_compressed(), "::"); -ok($x->to_string_ipv4(), "0:0:0:0:0:0:0.0.0.0"); -ok($x->to_string_ipv4_compressed(), "::0.0.0.0"); -ok($x->to_string_ip6_int(), "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT."); - -my $y = new Net::IPv6Addr("::1"); -ok($y->to_string_preferred(), "0:0:0:0:0:0:0:1"); -ok($y->to_string_compressed(), "::1"); -ok($y->to_string_ipv4(), "0:0:0:0:0:0:0.0.0.1"); -ok($y->to_string_ipv4_compressed(), "::0.0.0.1"); -ok($y->to_string_ip6_int(), "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT."); - -my $z = new Net::IPv6Addr("abcd:ef12::3456:789a"); -ok($z->to_string_preferred(), "abcd:ef12:0:0:0:0:3456:789a"); -ok($z->to_string_compressed(), "abcd:ef12::3456:789a"); -eval { $w->to_string_ipv4(); }; -ok($@); -ok($@, qr/not originally an IPv4 address/); -eval { $w->to_string_ipv4_compressed(); }; -ok($@); -ok($@, qr/not originally an IPv4 address/); -ok($z->to_string_ip6_int(), "a.9.8.7.6.5.4.3.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.1.f.e.d.c.b.a.IP6.INT."); - -my $p = new Net::IPv6Addr("::ffff:10.0.0.1"); -ok($p->to_string_preferred(), "0:0:0:0:0:ffff:a00:1"); -ok($p->to_string_compressed(), "::ffff:a00:1"); -ok($p->to_string_ipv4(), "0:0:0:0:0:ffff:10.0.0.1"); -ok($p->to_string_ipv4_compressed(), "::ffff:10.0.0.1"); -ok($p->to_string_ip6_int(), "1.0.0.0.0.0.a.0.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT."); - -my $q = new Net::IPv6Addr("0:0:0:0:0:0:10.0.0.1"); -ok($q->to_string_preferred(), "0:0:0:0:0:0:a00:1"); -ok($q->to_string_compressed(), "::a00:1"); -ok($q->to_string_ipv4(), "0:0:0:0:0:0:10.0.0.1"); -ok($q->to_string_ipv4_compressed(), "::10.0.0.1"); -ok($q->to_string_ip6_int(), "1.0.0.0.0.0.a.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT."); |