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
Paranoid::Network::IPv6(3) User Contributed Perl Documentation Paranoid::Network::IPv6(3)

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

$Id: lib/Paranoid/Network/IPv6.pm, 2.08 2020/12/31 12:10:06 acorliss Exp $

    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;

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

This module exports the following symbols by default:

    ipv6NetConvert ipv6NetPacked ipv6NetIntersect

The following specialized import lists also exist:

    List        Members
    --------------------------------------------------------
    base        @defaults
    constants   MAXIPV6CIDR IPV6REGEX IPV6CIDRRGX IPV6BASE 
                IPV6BRDCST IPV6MASK
    ipv6Sort    ipv6StrSort ipv6PackedSort ipv6NumSort
    all         @base @constants @ipv6Sort

    @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.

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

This function is a wrapper for ipv6NetConvert, but instead of subarrays each element is the packed (opaque) string as returned by inet_pton.

    $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 ipv6NetConvert, but will allow you to test single IPs in integer format as well.

    @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

    @sorted = sort ipv6PackedSort @nets;

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

    @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.

These are only imported if explicitly requested or with the :all tag.

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

Regular expression.

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);

Regular expression.

By default this will extract CIDR notation network addresses:

    @networks = ( $string =~ m#(@{[ IPV6CIDRRGX ]})#si );

This is the ordinal index of the base network address as returned by ipv6NetConvert.

This is the ordinal index of the broadcast address as returned by ipv6NetConvert.

This is the ordinal index of the network mask as returned by ipv6NetConvert.

o
Paranoid
o
Paranoid::Debug
o
Paranoid::Network::Socket

Arthur Corliss (corliss@digitalmages.com)

This software is free software. Similar to Perl, you can redistribute it and/or modify it under the terms of either:

  a)     the GNU General Public License
         <https://www.gnu.org/licenses/gpl-1.0.html> as published by the 
         Free Software Foundation <http://www.fsf.org/>; either version 1
         <https://www.gnu.org/licenses/gpl-1.0.html>, or any later version
         <https://www.gnu.org/licenses/license-list.html#GNUGPL>, or
  b)     the Artistic License 2.0
         <https://opensource.org/licenses/Artistic-2.0>,

subject to the following additional term: No trademark rights to "Paranoid" have been or are conveyed under any of the above licenses. However, "Paranoid" may be used fairly to describe this unmodified software, in good faith, but not as a trademark.

(c) 2005 - 2020, Arthur Corliss (corliss@digitalmages.com) (tm) 2008 - 2020, Paranoid Inc. (www.paranoid.com)

2020-12-31 perl v5.32.1

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

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