SYNOPSIS

    use Net::IPv6Addr;

    Net::IPv6Addr::ipv6_parse($addr);
    $x = new Net::IPv6Addr("dead:beef:cafe:babe::f0ad");
    print $x->to_string_preferred(), "\n";

DESCRIPTION

\*(C`Net::IPv6Addr\*(C' checks strings for valid IPv6 addresses, as specified in \s-1RFC1884\s0. You throw possible addresses at it, it either accepts them or throws an exception.

If \*(C`Math::Base85\*(C' is installed, then this module is able to process addresses formatted in the style referenced by \s-1RFC1924\s0.

The public interface of this module is rather small.

new

Parameters

A string to be interpreted as an IPv6 address.

Returns

A \*(C`Net::IPv6Addr\*(C' object if successful.

Notes

Throws an exception if the string isn't a valid address.

ipv6_parse

Parameters

A string containing an IPv6 address string. Optionally, it may also include a \*(C`/\*(C' character, and a numeric prefix length, in that order.

-or-

An IPv6 address string. Optionally, a numeric prefix length.

Returns

What you gave it, more or less, if it does parse out correctly.

Notes

Throws an exception on malformed input. This is not an object method or class method; it's just a subroutine.

is_ipv6

Parameters

A string containing an IPv6 address string. Optionally, it may also include a \*(C`/\*(C' character, and a numeric prefix length, in that order.

-or-

An IPv6 address string. Optionally, a numeric prefix length.

Returns

What you gave it, more or less, if it does parse out correctly, otherwise returns undef.

Notes

This is not an object method or class method; it is just a subroutine.

ipv6_chkip

Parameters

An IPv6 address string.

Returns

Something true if it's a valid address; something false otherwise.

to_string_preferred

Parameters

If used as an object method, none; if used as a plain old subroutine, an IPv6 address string in any format.

Returns

The IPv6 address, formatted in the \*(L"preferred\*(R" way (as detailed by \s-1RFC1884\s0).

Notes

Invalid input will generate an exception.

to_string_compressed

Parameters

If used as an object method, none; if used as a plain old subroutine, an IPv6 address string in any format.

Returns

The IPv6 address in \*(L"compresed\*(R" format (as detailed by \s-1RFC1884\s0).

Notes

Invalid input will generate an exception.

to_string_ipv4

Parameters

If used as an object method, none; if used as a plain old subroutine, an IPv6 address string in any format.

Returns

The IPv6 address in IPv4 format (as detailed by \s-1RFC1884\s0).

Notes

Invalid input (such as an address that was not originally IPv4) will generate an exception.

to_string_ipv4_compressed

Parameters

If used as an object method, none; if used as a plain old subroutine, an IPv6 address string in any format.

Returns

The IPv6 address in compressed IPv4 format (as detailed by \s-1RFC1884\s0).

Notes

Invalid input (such as an address that was not originally IPv4) will generate an exception.

to_string_base85

Parameters

If used as an object method, none; if used as a plain old subroutine, an IPv6 address string in any format.

Returns

The IPv6 address in the style detailed by \s-1RFC1924\s0.

Notes

Invalid input will generate an exception.

to_bigint

Parameters

If used as an object method, none; if used as a plain old subroutine, an IPv6 address string in any format.

Returns

The BigInt representation of IPv6 address.

Notes

Invalid input will generate an exception.

to_array

Parameters

If used as an object method, none; if used as a plain old subroutine, an IPv6 address string in any format.

Returns

An array [0..7] of 16 bit hexadecimal numbers.

Notes

Invalid input will generate an exception.

to_intarray

Parameters

If used as an object method, none; if used as a plain old subroutine, an IPv6 address string in any format.

Returns

An array [0..7] of decimal numbers.

Notes

Invalid input will generate an exception.

to_string_ip6_int

Parameters

If used as an object method, none; if used as a plain old subroutine, an IPv6 address string in any format.

Returns

The reverse-address pointer as defined by \s-1RFC1886\s0.

Notes

Invalid input will generate an exception.

in_network_of_size

Parameters

If used as an object method, network size in bits

If used as a plain old subroutine, an IPv6 address string in any format and network size in bits. Network size may be given with / notation.

Returns

Network IPv6Addr of given size.

Notes

Invalid input will generate an exception.

in_network

Parameters

If used as an object method, network and its size in bits

If used as a plain old subroutine, an IPv6 address string in any format network address string and size in bits. Network size may be given with / notation.

Returns

Something true, if address is member of the network, false otherwise.

Notes

Invalid input will generate an exception.

BUGS

probably exist in this module. Please report them.

AUTHOR

Tony Monroe <tmonroe plus perl at nog dot net>.

The module's interface probably looks like it vaguely resembles Net::IPv4Addr by Francis J. Lacoste <francis dot lacoste at iNsu dot \s-1COM\s0>.

Some fixes and subroutines from Jyrki Soini <jyrki dot soini at sonera dot com>.

HISTORY

This was originally written to simplify the task of maintaining \s-1DNS\s0 records after I set myself up with Freenet6. Interesting that there's really only one DNS-related subroutine in here.

RELATED TO Net::IPv6Addr…

\s-1RFC1884\s0, \s-1RFC1886\s0, \s-1RFC1924\s0, perl, Net::IPv4Addr, Math::Base85, Math::BigInt