GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  PARANOID::NETWORK::IPV6 (3)

.ds Aq ’

NAME

Paranoid::Network::IPv6 - IPv6-related functions

CONTENTS

VERSION

$Id: IPv6.pm,v 0.3 2012/09/24 23:20:22 acorliss Exp $

SYNOPSIS



    use Paranoid::Network::IPv6;

    @net = ipv6NetConvert($netAddr);
    $rv = ipv6NetIntersect($net1, $net2);



or



    use Paranoid::Network::IPv6 qw(:all);

    print "Valid IP address\n" 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;



DESCRIPTION

This module contains a few convenience functions for working with IPv6 addresses.

By default only <B>ipv6NetConvertB>, <B>ipv6NetPackedB>, and <B>ipv4NetIntersectB> are imported. Other symbol sets are:



    Name        Description
    ---------------------------------------------
    all         all functions/constants
    base        default exported functions
    constants   constants
    ipv6Sort    sort functions



SUBROUTINES/METHODS

    ipv6NetConvert



    @net = ipv6NetConvert($netAddr);



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:



    @chunks = unpack NNNN, inet_pton(AF_INET6, ::1);



using ’::1’ as the sample IPv6 address.

The network address must have the netmask in CIDR format. In the case of a single IP address, the array with only have one subarray, that of the IP itself, split into 32bit integers.

Passing any argument to this function that is not a string representation of an IP address (including undef values) will cause this function to return an empty array.

    ipv6NetPacked



    @net = ipv6NetPacked(fe80::/64);



This function is a wrapper for <B>ipv6NetConvertB>, but instead of subarrays each element is the packed (opaque) string as returned by <B>inet_ptonB>.

    ipv6NetIntersect



    $rv = ipv6NetIntersect($net1, $net2);



This function tests whether an IP or subnet intersects with another IP or subnet. The return value is essentially boolean, but the true value can vary to indicate which is a subset of the other:



    -1: destination range encompasses target range
     0: both ranges do not intersect at all
     1: target range encompasses destination range



The function handles the same string formats as <B>ipv6NetConvertB>, but will allow you to test single IPs in integer format as well.

    ipv6StrSort



    @sorted = sort ipv6StrSort @nets;



This function allows IPv6 addresses and networks to be passed in string format. Networks can be in CIDR format. Sorts in ascending order. :w

    ipv6PackedSort



    @sorted = sort ipv6PackedSort @nets;



This function sorts addresses that are in packed format, such as returned by inet_pton. Sorts in ascending order.

    ipv6NumSort



    @sorted = sort ipv6NumSort @nets;



This function sorts addresses that are in unpacked, native integer format, such as one gets from:



    @ip = unpack NNNN, inet_pton(AF_INET6, $ipAddr);



Sorts in ascending order. List of addresses should be a list of lists.

CONSTANTS

These are only imported if explicity requested or with the <B>:allB> tag.

    MAXIPV6CIDR

Simply put: 128. This is the largest CIDR notation supported in IPv6.

    IPV6REGEX

Regular expression:



                            qr/
                            :(?::[abcdef\d]{1,4}){1,7}                 |
                            [abcdef\d]{1,4}(?:::?[abcdef\d]{1,4}){1,7} |
                            (?:[abcdef\d]{1,4}:){1,7}:
                            /smix;



You can use this for validating IP addresses as such:



    $ip =~ m#^@{[ IPV6REGEX ]}$#;



or to extract potential IPs from extraneous text:



    (@ips) = ( $string =~ m#(@{[ IPV6REGEX ]})#g);



    IPV6CIDRRGX

Regular expression:



    qr#(@{[ IPV6REGEX ]})(?:/(\d+))?#sm



By default this will extract an IP or CIDR notation network address:



    ($net, $mask) = ( $ip =~ m#^@{[ IPV6CIDRRGX ]}$# );



In the case of a simple IP address <B>B>$mask<B>B> will be undefined.

    IPV6BASE

This is the ordinal index of the base network address as returned by <B>ipv6NetConvertB>.

    IPV6BRDCST

This is the ordinal index of the broadcast address as returned by <B>ipv6NetConvertB>.

    IPV6MASK

This is the ordinal index of the network mask as returned by <B>ipv6NetConvertB>.

DEPENDENCIES

o Paranoid
o Paranoid::Network::Socket

BUGS AND LIMITATIONS

AUTHOR

Arthur Corliss (corliss@digitalmages.com)

LICENSE AND COPYRIGHT

This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information.

(c) 2012, Arthur Corliss (corliss@digitalmages.com)

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 PARANOID::NETWORK::IPV6 (3) 2012-09-24

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.