NAME

Net::CIDR::Lookup::IPv6

DESCRIPTION

This is the IPv6 version of Net::CIDR::Lookup. It generally provides the same methods, with the distinction that the add_num/add_num_range methods that accept an IPv4 address as an integer have been split in two to accommodate different representations for an IPv6 address:

  • add_vec/add_vec_range accepts a 128-bit Bit::Vector object for an address

  • add_str/add_str_range takes a packed string as returned by Socket::unpack_sockaddr_in6

For all other methods, see Net::CIDR::Lookup.

This module requires an IPv6-enabled Socket. As there is no way to ask for this using ExtUtils::MakeMaker, do make sure you have it.

VERSION HISTORY

See Net::CIDR::Lookup::IPv6::Changes

METHODS

add

Arguments: $cidr, $value

Return Value: none; dies on error

Adds VALUE to the tree under the key CIDR. CIDR must be a string containing an IPv6 address followed by a slash and a number of network bits. Bits to the right of this mask will be ignored.

add_range

Arguments: $range, $value

Return Value: none; dies on error

Adds VALUE to the tree for each address included in RANGE which must be a hyphenated range of IPv6 addresses and with the first address being numerically smaller the second. This range will be split up into as many CIDR blocks as necessary (algorithm adapted from a script by Dr. Liviu Daia).

add_vec

Arguments: $address, $bits, $value

Return Value: none; dies on error

Like add() but accepts an address as a Bit::Vector object and the network bits as a separate integer instead of all in one string.

add_str

Arguments: $address, $bits, $value

Return Value: none; dies on error

Like add_vec() but accepts an address as a packed string as returned by Socket::unpack_sockaddr_in6.

add_vec_range

Arguments: $start, $end, $value

Return Value: none; dies on error

Like add_range() but accepts addresses as separate Bit::Vector objects instead of a range string.

add_str_range

Arguments: $start, $end, $value

Return Value: true for successful completion; dies on error

Like add_vec_range() but accepts addresses as packed strings as returned by Socket::unpack_sockaddr_in6.

lookup

Arguments: $address

Return Value: value assoiated with this address or undef

Looks up an IPv6 address specified as a string and returns the value associated with the network containing it. So far there is no way to tell which network that is though.

lookup_vec

Arguments: $address

Return Value: value assoiated with this address or undef

Like lookup() but accepts the address as a Bit::Vector object.

lookup_str

Arguments: $address

Return Value: value assoiated with this address or undef

Like lookup() but accepts the address as a packed string as returned by Socket::unpack_sockaddr_in6.

to_hash

Arguments: none

Return Value: $hashref

Returns a hash representation of the tree with keys being CIDR-style network addresses.

walk

Arguments: $coderef to call for each tree entry. Callback arguments are:

$address

The network address as a Bit::Vector object. The callback must not change this object's contents, use $addr->Clone if in doubt!

$bits

The current CIDR block's number of network bits

$value

The value associated with this block

Return Value: nothing useful

BUGS

  • The IPv6 version hasn't seen any real-world testing and the unit tests are still rather scarce, so there will probably be more bugs than listed here.

  • I didn't need deletions yet and deleting parts of a CIDR block is a bit more complicated than anything this class does so far, so it's not implemented.

  • Storing an undef value does not work and yields an error. This would be relatively easy to fix at the cost of some memory so that's more a design decision.

  • A consequence of the same design is also that a /0 block can't be formed. Although it doesn't make much sense, this might happen if your input is that weird.

AUTHORS, COPYRIGHTS & LICENSE

Matthias Bethke <matthias@towiski.de>

Licensed unter the Artistic License 2.0

SEE ALSO

This module's methods are based even more loosely on Net::CIDR::Lite than those of Net::CIDR::Lookup.