.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.13)
.\"
.\" 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
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'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 turned on, 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.
.ie \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.el \{\
. de IX
..
.\}
.\" ========================================================================
.\"
.IX Title "IP 3"
.TH IP 3 "2012-11-28" "perl v5.10.1" "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 \s-1IP\s0 objects, which can
be single \s-1IP\s0 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 \s-1IP\s0 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 \fInew()\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 \s-1IP\s0. Otherwise, it
tries to guess what the version is (see \fB\f(BI_is_ipv4()\fB\fR and \fB\f(BI_is_ipv6()\fB\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 \s-1IP\s0 address in an existing \s-1IP\s0 object. This method has the same
functionality as the \fInew()\fR method, except that it reuses an existing object to
store the new \s-1IP\s0.
.PP
\&\f(CW\*(C`$ip\->set(\*(Aq130.23.1/24\*(Aq,4);\*(C'\fR
.PP
Like \fInew()\fR, \fIset()\fR takes two arguments \- a string used to build an \s-1IP\s0 address,
prefix, or range, and optionally, the \s-1IP\s0 version of the considered address.
.PP
It returns an \s-1IP\s0 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 \fB\f(BIError()\fB\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 \fB\f(CB$ERRNO\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 \s-1IP\s0 address (or first \s-1IP\s0 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 \s-1IP\s0 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 \s-1IP\s0 object (4 or 6).
.PP
\&\f(CW\*(C`print ($ip\->version());\*(C'\fR
.SS "size"
.IX Subsection "size"
Return the number of \s-1IP\s0 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 \s-1IP\s0 object (IP/Prefix or First \- Last)
.PP
\&\f(CW\*(C`print ($ip\->print());\*(C'\fR
.SS "intip"
.IX Subsection "intip"
Convert the \s-1IP\s0 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 \s-1IP\s0 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 \s-1IP\s0 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 \s-1IP\s0 Type \- this describes the type of an \s-1IP\s0 (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 \s-1IP\s0 for a given \s-1IP\s0 address (in.addr. format).
.PP
\&\f(CW\*(C`print ($ip\->reserve_ip());\*(C'\fR
.SS "last_ip"
.IX Subsection "last_ip"
Return the last \s-1IP\s0 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 \s-1IP\s0 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 \s-1IP\s0 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 \s-1IP\s0 objects. The function takes an operation
and an \s-1IP\s0 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 \s-1IP\s0 objects. The value returned is an \s-1IP\s0 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 \s-1IP\s0 object is returned.
.PP
\&\f(CW\*(C`my $total = $ip\->aggregate($ip2);\*(C'\fR
.SS "overlaps"
.IX Subsection "overlaps"
Check if two \s-1IP\s0 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 \s-1IP\s0 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 \s-1IP\s0 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 \s-1OO\s0 methods,
most of these return undef on failure. In order to access error codes
and strings, instead of using \f(CW$ip\fR\->\fIerror()\fR and \f(CW$ip\fR\->\fIerrno()\fR, use the
global functions \f(CW\*(C`Error()\*(C'\fR and \f(CW\*(C`Errno()\*(C'\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 \s-1OO\s0 interface, as if the \fInew()\fR function
fails, we cannot call \f(CW$ip\fR\->\fIerror()\fR and so we have to use \fIError()\fR.
.PP
warn \fIError()\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 \s-1IP\s0 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 \s-1IP\s0 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 \s-1IP\s0 version of an \s-1IP\s0 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 \s-1IP\s0 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 \s-1IP\s0 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 \s-1IP\s0 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 \s-1IP\s0 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 \s-1IP\s0 and prefix length.
If it was passed a simple \s-1IP\s0, 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 \s-1IP\s0 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 \s-1IP\s0 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 \s-1RFC\s0 5735 and \s-1RFC\s0 6598
.PP
Address Block Present Use Reference
\&\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
0.0.0.0/8 \*(L"This\*(R" Network \s-1RFC\s0 1122 \s-1PRIVATE\s0
10.0.0.0/8 Private-Use Networks \s-1RFC\s0 1918 \s-1PRIVATE\s0
100.64.0.0/10 \s-1CGN\s0 Shared Address Space \s-1RFC\s0 6598 \s-1SHARED\s0
127.0.0.0/8 Loopback \s-1RFC\s0 1122 \s-1LOOPBACK\s0
169.254.0.0/16 Link Local \s-1RFC\s0 3927 LINK-LOCAL
172.16.0.0/12 Private-Use Networks \s-1RFC\s0 1918 \s-1PRIVATE\s0
192.0.0.0/24 \s-1IETF\s0 Protocol Assignments \s-1RFC\s0 5736 \s-1RESERVED\s0
192.0.2.0/24 \s-1TEST\-NET\-1\s0 \s-1RFC\s0 5737 TEST-NET
192.88.99.0/24 6to4 Relay Anycast \s-1RFC\s0 3068 6TO4\-RELAY
192.168.0.0/16 Private-Use Networks \s-1RFC\s0 1918 \s-1PRIVATE\s0
198.18.0.0/15 Network Interconnect
Device Benchmark Testing \s-1RFC\s0 2544 \s-1RESERVED\s0
198.51.100.0/24 \s-1TEST\-NET\-2\s0 \s-1RFC\s0 5737 TEST-NET
203.0.113.0/24 \s-1TEST\-NET\-3\s0 \s-1RFC\s0 5737 TEST-NET
224.0.0.0/4 Multicast \s-1RFC\s0 3171 \s-1MULTICAST\s0
240.0.0.0/4 Reserved for Future Use \s-1RFC\s0 1112 \s-1RESERVED\s0
255.255.255.255/32 Limited Broadcast \s-1RFC\s0 919 \s-1BROADCAST\s0
\s-1RFC\s0 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 <\s-1IANA\s0 Internet Protocol Version 6 Address Space> and <\s-1IANA\s0 IPv6 Special Purpose Address Registry>
.PP
Prefix Allocation Reference
\&\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
0000::/8 Reserved by \s-1IETF\s0 [\s-1RFC4291\s0] \s-1RESERVED\s0
0100::/8 Reserved by \s-1IETF\s0 [\s-1RFC4291\s0] \s-1RESERVED\s0
0200::/7 Reserved by \s-1IETF\s0 [\s-1RFC4048\s0] \s-1RESERVED\s0
0400::/6 Reserved by \s-1IETF\s0 [\s-1RFC4291\s0] \s-1RESERVED\s0
0800::/5 Reserved by \s-1IETF\s0 [\s-1RFC4291\s0] \s-1RESERVED\s0
1000::/4 Reserved by \s-1IETF\s0 [\s-1RFC4291\s0] \s-1RESERVED\s0
2000::/3 Global Unicast [\s-1RFC4291\s0] GLOBAL-UNICAST
4000::/3 Reserved by \s-1IETF\s0 [\s-1RFC4291\s0] \s-1RESERVED\s0
6000::/3 Reserved by \s-1IETF\s0 [\s-1RFC4291\s0] \s-1RESERVED\s0
8000::/3 Reserved by \s-1IETF\s0 [\s-1RFC4291\s0] \s-1RESERVED\s0
A000::/3 Reserved by \s-1IETF\s0 [\s-1RFC4291\s0] \s-1RESERVED\s0
C000::/3 Reserved by \s-1IETF\s0 [\s-1RFC4291\s0] \s-1RESERVED\s0
E000::/4 Reserved by \s-1IETF\s0 [\s-1RFC4291\s0] \s-1RESERVED\s0
F000::/5 Reserved by \s-1IETF\s0 [\s-1RFC4291\s0] \s-1RESERVED\s0
F800::/6 Reserved by \s-1IETF\s0 [\s-1RFC4291\s0] \s-1RESERVED\s0
\&\s-1FC00::/7\s0 Unique Local Unicast [\s-1RFC4193\s0] UNIQUE-LOCAL-UNICAST
\&\s-1FE00::/9\s0 Reserved by \s-1IETF\s0 [\s-1RFC4291\s0] \s-1RESERVED\s0
\&\s-1FE80::/10\s0 Link Local Unicast [\s-1RFC4291\s0] LINK-LOCAL-UNICAST
\&\s-1FEC0::/10\s0 Reserved by \s-1IETF\s0 [\s-1RFC3879\s0] \s-1RESERVED\s0
\&\s-1FF00::/8\s0 Multicast [\s-1RFC4291\s0] \s-1MULTICAST\s0
.PP
Prefix Assignment Reference
\&\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
::1/128 Loopback Address [\s-1RFC4291\s0] \s-1UNSPECIFIED\s0
::/128 Unspecified Address [\s-1RFC4291\s0] \s-1LOOPBACK\s0
::FFFF:0:0/96 IPv4\-mapped Address [\s-1RFC4291\s0] \s-1IPV4MAP\s0
0100::/64 Discard-Only Prefix [\s-1RFC6666\s0] \s-1DISCARD\s0
2001:0000::/32 \s-1TEREDO\s0 [\s-1RFC4380\s0] \s-1TEREDO\s0
2001:0002::/48 \s-1BMWG\s0 [\s-1RFC5180\s0] \s-1BMWG\s0
2001:db8::/32 Documentation Prefix [\s-1RFC3849\s0] \s-1DOCUMENTATION\s0
2001:10::/28 \s-1ORCHID\s0 [\s-1RFC4843\s0] \s-1ORCHID\s0
2002::/16 6to4 [\s-1RFC3056\s0] 6TO4
\&\s-1FC00::/7\s0 Unique-Local [\s-1RFC4193\s0] UNIQUE-LOCAL-UNICAST
\&\s-1FE80::/10\s0 Linked-Scoped Unicast [\s-1RFC4291\s0] LINK-LOCAL-UNICAST
\&\s-1FF00::/8\s0 Multicast [\s-1RFC4291\s0] \s-1MULTICAST\s0
.SS "ip_iptype"
.IX Subsection "ip_iptype"
Return the type of an \s-1IP\s0 (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 \s-1IP\s0 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 \s-1IP\s0 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 <manuel.valente@gmail.com>.
.PP
Original IPv4 code by Monica Cortes Sack <mcortes@ripe.net>.
.PP
Original IPv6 code by Lee Wilmot <lee@ripe.net>.
.SH "BASED ON"
.IX Header "BASED ON"
ipv4pack.pm, iplib.pm, iplibncc.pm.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fIperl\fR\|(1), IP::Authority
.SH "POD ERRORS"
.IX Header "POD ERRORS"
Hey! \fBThe above document had some coding errors, which are explained below:\fR
.IP "Around line 2007:" 4
.IX Item "Around line 2007:"
Invalid =encoding syntax: \s-1ALREADYDONE\s0 =head1 \s-1NAME\s0
Copyright 2K16 - 2K18 Indonesian Hacker Rulez