.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "IP 3" .TH IP 3 2024-09-01 "perl v5.40.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh Net::IP \- Perl extension for manipulating IPv4/IPv6 addresses .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Net::IP; \& \& my $ip = new Net::IP (\*(Aq193.0.1/24\*(Aq) or die (Net::IP::Error()); \& print ("IP : ".$ip\->ip()."\en"); \& print ("Sho : ".$ip\->short()."\en"); \& print ("Bin : ".$ip\->binip()."\en"); \& print ("Int : ".$ip\->intip()."\en"); \& print ("Mask: ".$ip\->mask()."\en"); \& print ("Last: ".$ip\->last_ip()."\en"); \& print ("Len : ".$ip\->prefixlen()."\en"); \& print ("Size: ".$ip\->size()."\en"); \& print ("Type: ".$ip\->iptype()."\en"); \& print ("Rev: ".$ip\->reverse_ip()."\en"); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This module provides functions to deal with \fBIPv4/IPv6\fR addresses. The module can be used as a class, allowing the user to instantiate IP objects, which can be single IP addresses, prefixes, or ranges of addresses. There is also a procedural way of accessing most of the functions. Most subroutines can take either \fBIPv4\fR or \fBIPv6\fR addresses transparently. .SH "OBJECT-ORIENTED INTERFACE" .IX Header "OBJECT-ORIENTED INTERFACE" .SS "Object Creation" .IX Subsection "Object Creation" A Net::IP object can be created from a single IP address: .PP .Vb 1 \& $ip = new Net::IP (\*(Aq193.0.1.46\*(Aq) || die ... .Ve .PP Or from a Classless Prefix (a /24 prefix is equivalent to a C class): .PP .Vb 1 \& $ip = new Net::IP (\*(Aq195.114.80/24\*(Aq) || die ... .Ve .PP Or from a range of addresses: .PP .Vb 1 \& $ip = new Net::IP (\*(Aq20.34.101.207 \- 201.3.9.99\*(Aq) || die ... .Ve .PP Or from a address plus a number: .PP .Vb 1 \& $ip = new Net::IP (\*(Aq20.34.10.0 + 255\*(Aq) || die ... .Ve .PP The \fBnew()\fR function accepts IPv4 and IPv6 addresses: .PP .Vb 1 \& $ip = new Net::IP (\*(Aqdead:beef::/32\*(Aq) || die ... .Ve .PP Optionnaly, the function can be passed the version of the IP. Otherwise, it tries to guess what the version is (see \fB_is_ipv4()\fR and \fB_is_ipv6()\fR). .PP .Vb 1 \& $ip = new Net::IP (\*(Aq195/8\*(Aq,4); # Class A .Ve .SH "OBJECT METHODS" .IX Header "OBJECT METHODS" Most of these methods are front-ends for the real functions, which use a procedural interface. Most functions return undef on failure, and a true value on success. A detailed description of the procedural interface is provided below. .SS set .IX Subsection "set" Set an IP address in an existing IP object. This method has the same functionality as the \fBnew()\fR method, except that it reuses an existing object to store the new IP. .PP \&\f(CW\*(C`$ip\->set(\*(Aq130.23.1/24\*(Aq,4);\*(C'\fR .PP Like \fBnew()\fR, \fBset()\fR takes two arguments \- a string used to build an IP address, prefix, or range, and optionally, the IP version of the considered address. .PP It returns an IP object on success, and undef on failure. .SS error .IX Subsection "error" Return the current object error string. The error string is set whenever one of the methods produces an error. Also, a global, class-wide \fBError()\fR function is avaliable. .PP \&\f(CW\*(C`warn ($ip\->error());\*(C'\fR .SS errno .IX Subsection "errno" Return the current object error number. The error number is set whenever one of the methods produces an error. Also, a global \fR\f(CB$ERRNO\fR\fB\fR variable is set when an error is produced. .PP \&\f(CW\*(C`warn ($ip\->errno());\*(C'\fR .SS ip .IX Subsection "ip" Return the IP address (or first IP of the prefix or range) in quad format, as a string. .PP \&\f(CW\*(C`print ($ip\->ip());\*(C'\fR .SS binip .IX Subsection "binip" Return the IP address as a binary string of 0s and 1s. .PP \&\f(CW\*(C`print ($ip\->binip());\*(C'\fR .SS prefixlen .IX Subsection "prefixlen" Return the length in bits of the current prefix. .PP \&\f(CW\*(C`print ($ip\->prefixlen());\*(C'\fR .SS version .IX Subsection "version" Return the version of the current IP object (4 or 6). .PP \&\f(CW\*(C`print ($ip\->version());\*(C'\fR .SS size .IX Subsection "size" Return the number of IP addresses in the current prefix or range. Use of this function requires Math::BigInt. .PP \&\f(CW\*(C`print ($ip\->size());\*(C'\fR .SS binmask .IX Subsection "binmask" Return the binary mask of the current prefix, if applicable. .PP \&\f(CW\*(C`print ($ip\->binmask());\*(C'\fR .SS mask .IX Subsection "mask" Return the mask in quad format of the current prefix. .PP \&\f(CW\*(C`print ($ip\->mask());\*(C'\fR .SS prefix .IX Subsection "prefix" Return the full prefix (ip+prefix length) in quad (standard) format. .PP \&\f(CW\*(C`print ($ip\->prefix());\*(C'\fR .SS print .IX Subsection "print" Print the IP object (IP/Prefix or First \- Last) .PP \&\f(CW\*(C`print ($ip\->print());\*(C'\fR .SS intip .IX Subsection "intip" Convert the IP in integer format and return it as a Math::BigInt object. .PP \&\f(CW\*(C`print ($ip\->intip());\*(C'\fR .SS hexip .IX Subsection "hexip" Return the IP in hex format .PP \&\f(CW\*(C`print ($ip\->hexip());\*(C'\fR .SS hexmask .IX Subsection "hexmask" Return the mask in hex format .PP \&\f(CW\*(C`print ($ip\->hexmask());\*(C'\fR .SS short .IX Subsection "short" Return the IP in short format: IPv4 addresses: 194.5/16 IPv6 addresses: ab32:f000:: .PP \&\f(CW\*(C`print ($ip\->short());\*(C'\fR .SS iptype .IX Subsection "iptype" Return the IP Type \- this describes the type of an IP (Public, Private, Reserved, etc.) See procedural interface ip_iptype for more details. .PP \&\f(CW\*(C`print ($ip\->iptype());\*(C'\fR .SS reverse_ip .IX Subsection "reverse_ip" Return the reverse IP for a given IP address (in.addr. format). .PP \&\f(CW\*(C`print ($ip\->reserve_ip());\*(C'\fR .SS last_ip .IX Subsection "last_ip" Return the last IP of a prefix/range in quad format. .PP \&\f(CW\*(C`print ($ip\->last_ip());\*(C'\fR .SS last_bin .IX Subsection "last_bin" Return the last IP of a prefix/range in binary format. .PP \&\f(CW\*(C`print ($ip\->last_bin());\*(C'\fR .SS last_int .IX Subsection "last_int" Return the last IP of a prefix/range in integer format. .PP \&\f(CW\*(C`print ($ip\->last_int());\*(C'\fR .SS find_prefixes .IX Subsection "find_prefixes" This function finds all the prefixes that can be found between the two addresses of a range. The function returns a list of prefixes. .PP \&\f(CW\*(C`@list = $ip\->find_prefixes($other_ip));\*(C'\fR .SS bincomp .IX Subsection "bincomp" Binary comparaison of two IP objects. The function takes an operation and an IP object as arguments. It returns a boolean value. .PP The operation can be one of: lt: less than (smaller than) le: smaller or equal to gt: greater than ge: greater or equal to .PP \&\f(CW\*(C`if ($ip\->bincomp(\*(Aqlt\*(Aq,$ip2) {...}\*(C'\fR .SS binadd .IX Subsection "binadd" Binary addition of two IP objects. The value returned is an IP object. .PP \&\f(CW\*(C`my $sum = $ip\->binadd($ip2);\*(C'\fR .SS aggregate .IX Subsection "aggregate" Aggregate 2 IPs \- Append one range/prefix of IPs to another. The last address of the first range must be the one immediately preceding the first address of the second range. A new IP object is returned. .PP \&\f(CW\*(C`my $total = $ip\->aggregate($ip2);\*(C'\fR .SS overlaps .IX Subsection "overlaps" Check if two IP ranges/prefixes overlap each other. The value returned by the function should be one of: \f(CW$IP_PARTIAL_OVERLAP\fR (ranges overlap) \f(CW$IP_NO_OVERLAP\fR (no overlap) \f(CW$IP_A_IN_B_OVERLAP\fR (range2 contains range1) \f(CW$IP_B_IN_A_OVERLAP\fR (range1 contains range2) \f(CW$IP_IDENTICAL\fR (ranges are identical) undef (problem) .PP \&\f(CW\*(C`if ($ip\->overlaps($ip2)==$IP_A_IN_B_OVERLAP) {...};\*(C'\fR .SS looping .IX Subsection "looping" The \f(CW\*(C`+\*(C'\fR operator is overloaded in order to allow looping though a whole range of IP addresses: .PP .Vb 5 \& my $ip = new Net::IP (\*(Aq195.45.6.7 \- 195.45.6.19\*(Aq) || die; \& # Loop \& do { \& print $ip\->ip(), "\en"; \& } while (++$ip); .Ve .PP The ++ operator returns undef when the last address of the range is reached. .SS auth .IX Subsection "auth" Return IP authority information from the IP::Authority module .PP \&\f(CW\*(C`$auth = ip\-\*(C'\fRauth ();> .PP Note: IPv4 only .SH "PROCEDURAL INTERFACE" .IX Header "PROCEDURAL INTERFACE" These functions do the real work in the module. Like the OO methods, most of these return undef on failure. In order to access error codes and strings, instead of using \f(CW$ip\fR\->\fBerror()\fR and \f(CW$ip\fR\->\fBerrno()\fR, use the global functions \f(CWError()\fR and \f(CWErrno()\fR. .PP The functions of the procedural interface are not exported by default. In order to import these functions, you need to modify the use statement for the module: .PP \&\f(CW\*(C`use Net::IP qw(:PROC);\*(C'\fR .SS Error .IX Subsection "Error" Returns the error string corresponding to the last error generated in the module. This is also useful for the OO interface, as if the \fBnew()\fR function fails, we cannot call \f(CW$ip\fR\->\fBerror()\fR and so we have to use \fBError()\fR. .PP warn \fBError()\fR; .SS Errno .IX Subsection "Errno" Returns a numeric error code corresponding to the error string returned by Error. .SS ip_iptobin .IX Subsection "ip_iptobin" Transform an IP address into a bit string. .PP .Vb 2 \& Params : IP address, IP version \& Returns : binary IP string on success, undef otherwise .Ve .PP \&\f(CW\*(C`$binip = ip_iptobin ($ip,6);\*(C'\fR .SS ip_bintoip .IX Subsection "ip_bintoip" Transform a bit string into an IP address .PP .Vb 2 \& Params : binary IP, IP version \& Returns : IP address on success, undef otherwise .Ve .PP \&\f(CW\*(C`$ip = ip_bintoip ($binip,6);\*(C'\fR .SS ip_bintoint .IX Subsection "ip_bintoint" Transform a bit string into a BigInt. .PP .Vb 2 \& Params : binary IP \& Returns : BigInt .Ve .PP \&\f(CW\*(C`$bigint = new Math::BigInt (ip_bintoint($binip));\*(C'\fR .SS ip_inttobin .IX Subsection "ip_inttobin" Transform a BigInt into a bit string. \&\fIWarning\fR: sets warnings (\f(CW\*(C`\-w\*(C'\fR) off. This is necessary because Math::BigInt is not compliant. .PP .Vb 2 \& Params : BigInt, IP version \& Returns : binary IP .Ve .PP \&\f(CW\*(C`$binip = ip_inttobin ($bigint);\*(C'\fR .SS ip_get_version .IX Subsection "ip_get_version" Try to guess the IP version of an IP address. .PP .Vb 2 \& Params : IP address \& Returns : 4, 6, undef(unable to determine) .Ve .PP \&\f(CW\*(C`$version = ip_get_version ($ip)\*(C'\fR .SS ip_is_ipv4 .IX Subsection "ip_is_ipv4" Check if an IP address is of type 4. .PP .Vb 2 \& Params : IP address \& Returns : 1 (yes) or 0 (no) .Ve .PP \&\f(CW\*(C`ip_is_ipv4($ip) and print "$ip is IPv4";\*(C'\fR .SS ip_is_ipv6 .IX Subsection "ip_is_ipv6" Check if an IP address is of type 6. .PP .Vb 2 \& Params : IP address \& Returns : 1 (yes) or 0 (no) .Ve .PP \&\f(CW\*(C`ip_is_ipv6($ip) and print "$ip is IPv6";\*(C'\fR .SS ip_expand_address .IX Subsection "ip_expand_address" Expand an IP address from compact notation. .PP .Vb 2 \& Params : IP address, IP version \& Returns : expanded IP address or undef on failure .Ve .PP \&\f(CW\*(C`$ip = ip_expand_address ($ip,4);\*(C'\fR .SS ip_get_mask .IX Subsection "ip_get_mask" Get IP mask from prefix length. .PP .Vb 2 \& Params : Prefix length, IP version \& Returns : Binary Mask .Ve .PP \&\f(CW\*(C`$mask = ip_get_mask ($len,6);\*(C'\fR .SS ip_last_address_bin .IX Subsection "ip_last_address_bin" Return the last binary address of a prefix. .PP .Vb 2 \& Params : First binary IP, prefix length, IP version \& Returns : Binary IP .Ve .PP \&\f(CW\*(C`$lastbin = ip_last_address_bin ($ip,$len,6);\*(C'\fR .SS ip_splitprefix .IX Subsection "ip_splitprefix" Split a prefix into IP and prefix length. If it was passed a simple IP, it just returns it. .PP .Vb 2 \& Params : Prefix \& Returns : IP, optionnaly length of prefix .Ve .PP \&\f(CW\*(C`($ip,$len) = ip_splitprefix ($prefix)\*(C'\fR .SS ip_prefix_to_range .IX Subsection "ip_prefix_to_range" Get a range of IPs from a prefix. .PP .Vb 2 \& Params : Prefix, IP version \& Returns : First IP, last IP .Ve .PP \&\f(CW\*(C`($ip1,$ip2) = ip_prefix_to_range ($prefix,6);\*(C'\fR .SS ip_bincomp .IX Subsection "ip_bincomp" Compare binary Ips with <, >, <=, >=. Operators are lt(<), le(<=), gt(>), and ge(>=) .PP .Vb 2 \& Params : First binary IP, operator, Last binary IP \& Returns : 1 (yes), 0 (no), or undef (problem) .Ve .PP \&\f(CW\*(C`ip_bincomp ($ip1,\*(Aqlt\*(Aq,$ip2) == 1 or do {}\*(C'\fR .SS ip_binadd .IX Subsection "ip_binadd" Add two binary IPs. .PP .Vb 2 \& Params : First binary IP, Last binary IP \& Returns : Binary sum or undef (problem) .Ve .PP \&\f(CW\*(C`$binip = ip_binadd ($bin1,$bin2);\*(C'\fR .SS ip_get_prefix_length .IX Subsection "ip_get_prefix_length" Get the prefix length for a given range of 2 IPs. .PP .Vb 2 \& Params : First binary IP, Last binary IP \& Returns : Length of prefix or undef (problem) .Ve .PP \&\f(CW\*(C`$len = ip_get_prefix_length ($ip1,$ip2);\*(C'\fR .SS ip_range_to_prefix .IX Subsection "ip_range_to_prefix" Return all prefixes between two IPs. .PP .Vb 2 \& Params : First IP (binary format), Last IP (binary format), IP version \& Returns : List of Prefixes or undef (problem) .Ve .PP The prefixes returned have the form q.q.q.q/nn. .PP \&\f(CW\*(C`@prefix = ip_range_to_prefix ($ip1,$ip2,6);\*(C'\fR .SS ip_compress_v4_prefix .IX Subsection "ip_compress_v4_prefix" Compress an IPv4 Prefix. .PP .Vb 2 \& Params : IP, Prefix length \& Returns : Compressed Prefix .Ve .PP \&\f(CW\*(C`$ip = ip_compress_v4_prefix ($ip, $len);\*(C'\fR .SS ip_compress_address .IX Subsection "ip_compress_address" Compress an IPv6 address. Just returns the IP if it is an IPv4. .PP .Vb 2 \& Params : IP, IP version \& Returns : Compressed IP or undef (problem) .Ve .PP \&\f(CW\*(C`$ip = ip_compress_adress ($ip, $version);\*(C'\fR .SS ip_is_overlap .IX Subsection "ip_is_overlap" Check if two ranges of IPs overlap. .PP .Vb 7 \& Params : Four binary IPs (begin of range 1,end1,begin2,end2), IP version \& $IP_PARTIAL_OVERLAP (ranges overlap) \& $IP_NO_OVERLAP (no overlap) \& $IP_A_IN_B_OVERLAP (range2 contains range1) \& $IP_B_IN_A_OVERLAP (range1 contains range2) \& $IP_IDENTICAL (ranges are identical) \& undef (problem) .Ve .PP \&\f(CW\*(C`(ip_is_overlap($rb1,$re1,$rb2,$re2,4) eq $IP_A_IN_B_OVERLAP) and do {};\*(C'\fR .SS ip_get_embedded_ipv4 .IX Subsection "ip_get_embedded_ipv4" Get an IPv4 embedded in an IPv6 address .PP .Vb 2 \& Params : IPv6 \& Returns : IPv4 string or undef (not found) .Ve .PP \&\f(CW\*(C`$ip4 = ip_get_embedded($ip6);\*(C'\fR .SS ip_check_mask .IX Subsection "ip_check_mask" Check the validity of a binary IP mask .PP .Vb 2 \& Params : Mask \& Returns : 1 or undef (invalid) .Ve .PP \&\f(CW\*(C`ip_check_mask($binmask) or do {};\*(C'\fR .PP Checks if mask has only 1s followed by 0s. .SS ip_aggregate .IX Subsection "ip_aggregate" Aggregate 2 ranges of binary IPs .PP .Vb 2 \& Params : 1st range (1st IP, Last IP), last range (1st IP, last IP), IP version \& Returns : prefix or undef (invalid) .Ve .PP \&\f(CW\*(C`$prefix = ip_aggregate ($bip1,$eip1,$bip2,$eip2) || die ...\*(C'\fR .SS ip_iptypev4 .IX Subsection "ip_iptypev4" Return the type of an IPv4 address. .PP .Vb 2 \& Params: binary IP \& Returns: type as of the following table or undef (invalid ip) .Ve .PP See RFC 5735 and RFC 6598 .PP Address\ Block\ \ \ \ \ \ \ Present\ Use\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Reference \&\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- 0.0.0.0/8\ \ \ \ \ \ \ \ \ \ \ "This"\ Network\ \ \ \ \ \ \ \ \ \ \ \ \ RFC\ 1122\ PRIVATE 10.0.0.0/8\ \ \ \ \ \ \ \ \ \ Private-Use\ Networks\ \ \ \ \ \ \ RFC\ 1918\ PRIVATE 100.64.0.0/10\ \ \ \ \ \ \ CGN\ Shared\ Address\ Space\ \ \ RFC\ 6598\ SHARED 127.0.0.0/8\ \ \ \ \ \ \ \ \ Loopback\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ RFC\ 1122\ LOOPBACK 169.254.0.0/16\ \ \ \ \ \ Link\ Local\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ RFC\ 3927\ LINK-LOCAL 172.16.0.0/12\ \ \ \ \ \ \ Private-Use\ Networks\ \ \ \ \ \ \ RFC\ 1918\ PRIVATE 192.0.0.0/24\ \ \ \ \ \ \ \ IETF\ Protocol\ Assignments\ \ RFC\ 5736\ RESERVED 192.0.2.0/24\ \ \ \ \ \ \ \ TEST\-NET\-1\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ RFC\ 5737\ TEST-NET 192.88.99.0/24\ \ \ \ \ \ 6to4\ Relay\ Anycast\ \ \ \ \ \ \ \ \ RFC\ 3068\ 6TO4\-RELAY 192.168.0.0/16\ \ \ \ \ \ Private-Use\ Networks\ \ \ \ \ \ \ RFC\ 1918\ PRIVATE 198.18.0.0/15\ \ \ \ \ \ \ Network\ Interconnect \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Device\ Benchmark\ Testing\ \ \ RFC\ 2544\ RESERVED 198.51.100.0/24\ \ \ \ \ TEST\-NET\-2\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ RFC\ 5737\ TEST-NET 203.0.113.0/24\ \ \ \ \ \ TEST\-NET\-3\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ RFC\ 5737\ TEST-NET 224.0.0.0/4\ \ \ \ \ \ \ \ \ Multicast\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ RFC\ 3171\ MULTICAST 240.0.0.0/4\ \ \ \ \ \ \ \ \ Reserved\ for\ Future\ Use\ \ \ \ RFC\ 1112\ RESERVED 255.255.255.255/32\ \ Limited\ Broadcast\ \ \ \ \ \ \ \ \ \ RFC\ 919\ \ BROADCAST \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ RFC\ 922 .SS ip_iptypev6 .IX Subsection "ip_iptypev6" Return the type of an IPv6 address. .PP .Vb 2 \& Params: binary ip \& Returns: type as of the following table or undef (invalid) .Ve .PP See IANA Internet Protocol Version 6 Address Space and IANA IPv6 Special Purpose Address Registry .PP Prefix\ \ \ \ \ \ Allocation\ \ \ \ \ \ \ \ \ \ \ Reference \&\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- 0000::/8\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4291]\ RESERVED 0100::/8\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4291]\ RESERVED 0200::/7\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4048]\ RESERVED 0400::/6\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4291]\ RESERVED 0800::/5\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4291]\ RESERVED 1000::/4\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4291]\ RESERVED 2000::/3\ \ \ \ Global\ Unicast\ \ \ \ \ \ \ [RFC4291]\ GLOBAL-UNICAST 4000::/3\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4291]\ RESERVED 6000::/3\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4291]\ RESERVED 8000::/3\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4291]\ RESERVED A000::/3\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4291]\ RESERVED C000::/3\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4291]\ RESERVED E000::/4\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4291]\ RESERVED F000::/5\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4291]\ RESERVED F800::/6\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4291]\ RESERVED FC00::/7\ \ \ \ Unique\ Local\ Unicast\ [RFC4193]\ UNIQUE-LOCAL-UNICAST FE00::/9\ \ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC4291]\ RESERVED FE80::/10\ \ \ Link\ Local\ Unicast\ \ \ [RFC4291]\ LINK-LOCAL-UNICAST FEC0::/10\ \ \ Reserved\ by\ IETF\ \ \ \ \ [RFC3879]\ RESERVED FF00::/8\ \ \ \ Multicast\ \ \ \ \ \ \ \ \ \ \ \ [RFC4291]\ MULTICAST .PP Prefix\ \ \ \ \ \ \ \ \ \ Assignment\ \ \ \ \ \ \ \ \ \ \ \ Reference \&\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- ::1/128\ \ \ \ \ \ \ \ \ Loopback\ Address\ \ \ \ \ \ [RFC4291]\ UNSPECIFIED ::/128\ \ \ \ \ \ \ \ \ \ Unspecified\ Address\ \ \ [RFC4291]\ LOOPBACK ::FFFF:0:0/96\ \ \ IPv4\-mapped\ Address\ \ \ [RFC4291]\ IPV4MAP 0100::/64\ \ \ \ \ \ \ Discard-Only\ Prefix\ \ \ [RFC6666]\ DISCARD 2001:0000::/32\ \ TEREDO\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ [RFC4380]\ TEREDO 2001:0002::/48\ \ BMWG\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ [RFC5180]\ BMWG 2001:db8::/32\ \ \ Documentation\ Prefix\ \ [RFC3849]\ DOCUMENTATION 2001:10::/28\ \ \ \ ORCHID\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ [RFC4843]\ ORCHID 2002::/16\ \ \ \ \ \ \ 6to4\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ [RFC3056]\ 6TO4 FC00::/7\ \ \ \ \ \ \ \ Unique-Local\ \ \ \ \ \ \ \ \ \ [RFC4193]\ UNIQUE-LOCAL-UNICAST FE80::/10\ \ \ \ \ \ \ Linked-Scoped\ Unicast\ [RFC4291]\ LINK-LOCAL-UNICAST FF00::/8\ \ \ \ \ \ \ \ Multicast\ \ \ \ \ \ \ \ \ \ \ \ \ [RFC4291]\ MULTICAST .SS ip_iptype .IX Subsection "ip_iptype" Return the type of an IP (Public, Private, Reserved) .PP .Vb 2 \& Params : Binary IP to test, IP version (defaults to 6) \& Returns : type (see ip_iptypev4 and ip_iptypev6 for details) or undef (invalid) .Ve .PP \&\f(CW\*(C`$type = ip_iptype ($ip);\*(C'\fR .SS ip_check_prefix .IX Subsection "ip_check_prefix" Check the validity of a prefix .PP .Vb 2 \& Params : binary IP, length of prefix, IP version \& Returns : 1 or undef (invalid) .Ve .PP Checks if the variant part of a prefix only has 0s, and the length is correct. .PP \&\f(CW\*(C`ip_check_prefix ($ip,$len,$ipv) or do {};\*(C'\fR .SS ip_reverse .IX Subsection "ip_reverse" Get a reverse name from a prefix .PP .Vb 2 \& Params : IP, length of prefix, IP version \& Returns : Reverse name or undef (error) .Ve .PP \&\f(CW\*(C`$reverse = ip_reverse ($ip);\*(C'\fR .SS ip_normalize .IX Subsection "ip_normalize" Normalize data to a range/prefix of IP addresses .PP .Vb 2 \& Params : Data String (Single IP, Range, Prefix) \& Returns : ip1, ip2 (if range/prefix) or undef (error) .Ve .PP \&\f(CW\*(C`($ip1,$ip2) = ip_normalize ($data);\*(C'\fR .SS ip_auth .IX Subsection "ip_auth" Return IP authority information from the IP::Authority module .PP .Vb 2 \& Params : IP, version \& Returns : Auth info (RI for RIPE, AR for ARIN, etc) .Ve .PP \&\f(CW\*(C`$auth = ip_auth ($ip,4);\*(C'\fR .PP Note: IPv4 only .SH BUGS .IX Header "BUGS" The Math::BigInt library is needed for functions that use integers. These are ip_inttobin, ip_bintoint, and the size method. In a next version, Math::BigInt will become optionnal. .SH AUTHORS .IX Header "AUTHORS" Manuel Valente . .PP Original IPv4 code by Monica Cortes Sack . .PP Original IPv6 code by Lee Wilmot . .SH "BASED ON" .IX Header "BASED ON" ipv4pack.pm, iplib.pm, iplibncc.pm. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBperl\fR\|(1), IP::Authority