.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" 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" '' . 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 "Paranoid::Network::IPv6 3pm" .TH Paranoid::Network::IPv6 3pm "2018-11-09" "perl v5.28.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 .SH "NAME" Paranoid::Network::IPv6 \- IPv6\-related functions .SH "VERSION" .IX Header "VERSION" \&\f(CW$Id:\fR lib/Paranoid/Network/IPv6.pm, 2.06 2018/08/05 01:21:48 acorliss Exp $ .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Paranoid::Network::IPv6; \& \& @net = ipv6NetConvert($netAddr); \& $rv = ipv6NetIntersect($net1, $net2); .Ve .PP or .PP .Vb 1 \& use Paranoid::Network::IPv6 qw(:all); \& \& print "Valid IP address\en" if $netAddr =~ /^@{[ IPV6REGEX ]}$/; \& \& @net = ipv6NetConvert($netAddr); \& $broadcast = $net[IPV6BRDCST]; \& \& use Paranoid::Network::IPv6 qw(:ipv6Sort); \& \& @nets = sort ipv6StrSort @nets; \& @nets = sort ipv6PackedSort @nets; \& @nets = sort ipv6NumSort @nets; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module contains a few convenience functions for working with IPv6 addresses. .PP By default only \fBipv6NetConvert\fR, \fBipv6NetPacked\fR, and \&\fBipv4NetIntersect\fR are imported. Other symbol sets are: .PP .Vb 6 \& Name Description \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& all all functions/constants \& base default exported functions \& constants constants \& ipv6Sort sort functions .Ve .SH "SUBROUTINES/METHODS" .IX Header "SUBROUTINES/METHODS" .SS "ipv6NetConvert" .IX Subsection "ipv6NetConvert" .Vb 1 \& @net = ipv6NetConvert($netAddr); .Ve .PP This function takes an IPv4 network address in string format and converts it into and array of arrays. The arrays will contain the base network address, the broadcast address, and the netmask, each split into native 32bit integer format chunks. Each sub array is essentially what you would get from: .PP .Vb 1 \& @chunks = unpack \*(AqNNNN\*(Aq, inet_pton(AF_INET6, \*(Aq::1\*(Aq); .Ve .PP using '::1' as the sample IPv6 address. .PP The network address must have the netmask in \s-1CIDR\s0 format. In the case of a single \s-1IP\s0 address, the array with only have one subarray, that of the \s-1IP\s0 itself, split into 32bit integers. .PP Passing any argument to this function that is not a string representation of an \s-1IP\s0 address (including undef values) will cause this function to return an empty array. .SS "ipv6NetPacked" .IX Subsection "ipv6NetPacked" .Vb 1 \& @net = ipv6NetPacked(\*(Aqfe80::/64\*(Aq); .Ve .PP This function is a wrapper for \fBipv6NetConvert\fR, but instead of subarrays each element is the packed (opaque) string as returned by \fBinet_pton\fR. .SS "ipv6NetIntersect" .IX Subsection "ipv6NetIntersect" .Vb 1 \& $rv = ipv6NetIntersect($net1, $net2); .Ve .PP This function tests whether an \s-1IP\s0 or subnet intersects with another \s-1IP\s0 or subnet. The return value is essentially boolean, but the true value can vary to indicate which is a subset of the other: .PP .Vb 3 \& \-1: destination range encompasses target range \& 0: both ranges do not intersect at all \& 1: target range encompasses destination range .Ve .PP The function handles the same string formats as \fBipv6NetConvert\fR, but will allow you to test single IPs in integer format as well. .SS "ipv6StrSort" .IX Subsection "ipv6StrSort" .Vb 1 \& @sorted = sort ipv6StrSort @nets; .Ve .PP This function allows IPv6 addresses and networks to be passed in string format. Networks can be in \s-1CIDR\s0 format. Sorts in ascending order. :w .SS "ipv6PackedSort" .IX Subsection "ipv6PackedSort" .Vb 1 \& @sorted = sort ipv6PackedSort @nets; .Ve .PP This function sorts addresses that are in packed format, such as returned by inet_pton. Sorts in ascending order. .SS "ipv6NumSort" .IX Subsection "ipv6NumSort" .Vb 1 \& @sorted = sort ipv6NumSort @nets; .Ve .PP This function sorts addresses that are in unpacked, native integer format, such as one gets from: .PP .Vb 1 \& @ip = unpack \*(AqNNNN\*(Aq, inet_pton(AF_INET6, $ipAddr); .Ve .PP Sorts in ascending order. List of addresses should be a list of lists. .SH "CONSTANTS" .IX Header "CONSTANTS" These are only imported if explicitly requested or with the \fB:all\fR tag. .SS "\s-1MAXIPV6CIDR\s0" .IX Subsection "MAXIPV6CIDR" Simply put: 128. This is the largest \s-1CIDR\s0 notation supported in IPv6. .SS "\s-1IPV6REGEX\s0" .IX Subsection "IPV6REGEX" Regular expression. .PP You can use this for validating \s-1IP\s0 addresses as such: .PP .Vb 1 \& $ip =~ m#^@{[ IPV6REGEX ]}$#; .Ve .PP or to extract potential IPs from extraneous text: .PP .Vb 1 \& @ips = ( $string =~ m#(@{[ IPV6REGEX ]})#g); .Ve .SS "\s-1IPV6CIDRRGX\s0" .IX Subsection "IPV6CIDRRGX" Regular expression. .PP By default this will extract \s-1CIDR\s0 notation network addresses: .PP .Vb 1 \& @networks = ( $string =~ m#(@{[ IPV6CIDRRGX ]})#si ); .Ve .SS "\s-1IPV6BASE\s0" .IX Subsection "IPV6BASE" This is the ordinal index of the base network address as returned by \&\fBipv6NetConvert\fR. .SS "\s-1IPV6BRDCST\s0" .IX Subsection "IPV6BRDCST" This is the ordinal index of the broadcast address as returned by \&\fBipv6NetConvert\fR. .SS "\s-1IPV6MASK\s0" .IX Subsection "IPV6MASK" This is the ordinal index of the network mask as returned by \&\fBipv6NetConvert\fR. .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" .IP "o" 4 .IX Item "o" Paranoid .IP "o" 4 .IX Item "o" Paranoid::Debug .IP "o" 4 .IX Item "o" Paranoid::Network::Socket .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" .SH "AUTHOR" .IX Header "AUTHOR" Arthur Corliss (corliss@digitalmages.com) .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information. .PP (c) 2005 \- 2017, Arthur Corliss (corliss@digitalmages.com)