The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::IPv6Address - Perl extension that provides a variety of use IPv6 address functions

SYNOPSIS

  use Net::IPv6Address;

DESCRIPTION

Net::IPv6Address provide a number of routines that allow for the manipulation and presentation of IPv6 addresses.

new() Create a new Net::IPv6Address object.

my $IPv6Address = new Net::IPv6Address();

new(STRING1, INTEGER) Create a new Net::IPv6Address object.

my $IPv6Address = new Net::IPv6Address("2001:0db8:abcd::1", 64);

STRING1 is an IPv6 address, INTEGER is the length of the prefix

loadDebug(Debug.pm) Accepts a Debug.pm object to facilitate initialization of the debugging

use Debug; use Net:IPv6Address;

my $debug = new Debug; my $IPv6Address = new Net::IPv6Address(); $IPv6Address->loadDebug($debug);

Debug.pm is a copy of valid Debug.pm object

decompressAddress() Processes the address supplied when constructing a Net::IPv6Address object. Returns a STRING representing the fully decompressed and unabbeviated address in an unformatted state, ie no colons just hexidecimal characters.

my $unformattedAddress = $IPv6Address->decompressAddress();

address(STRING) Accepts a STRING representing the IPv6 address that the rest of the module operating on; the address is automatically decompressed. With no arguments this function will return the address that was last set.

my $address = $IPv6Address->address();

$IPv6Address->address("2001:db8:1234::1");

addressLength(INTEGER) Accepts a INTEGER representing the IPv6 prefix length for the supplied address. With no arguments this function will return the prefix length that was last set.

my $length = $IPv6Address->addressLength();

$IPv6Address->addressLength(48);

prefix() This function retrieves the prefix for the supplied address given the prefix length. A string will be returned.

my $IPv6Address = new Net::IPv6Address("2001:0db8:abcd::1", 64); my $prefix = $IPv6Address->prefix();

interface() This function retrieves the interface identifier for the supplied address given the prefix length. A string will be returned.

my $IPv6Address = new Net::IPv6Address("2001:0db8:abcd::1", 64); my $interface = $IPv6Address->interface();

formatAddress() Properly formats the IPv6 address, if the address is compressed or abbreviated it will be uncompressed and unabbreviated then formatted and returned. A string is returned.

my $IPv6Address = new Net::IPv6Address("2001:0db8:abcd::1", 64); my $formattedAddress = $IPv6Address->formatAddress();

hexToBin() Converts a hexidecimal representation of an IPv6 address to its binary form. The binary representation is returned in string format.

my $IPv6Address = new Net::IPv6Address("2001:0db8:abcd::1", 64); my $binaryAddress = $IPv6Address->hexToBin();

binToHex() converts the binary representation of an IPv6 address to it hexidecimal form. The uncompresse and unabbbreviated hexidecimal representation is returned as a string.

my $IPv6Address = new Net::IPv6Address("2001:0db8:abcd::1", 64); my $hexAddress = $IPv6Address->binToHex();

trim() Removes leading whitespace, tabs, spaces, carriage returns, and line feeds. The trimmed data is returned.

my $IPv6Address = new Net::IPv6Address("2001:0db8:abcd::1", 64); my $tString = $IPv6Address->trim(" 2001:0db8:: ");

EXPORT

None by default.

SEE ALSO

N/A

AUTHOR

JJMB, <jjmb@jjmb.com>

COPYRIGHT AND LICENSE

Copyright (C) 2008 by JJMB

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.