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

Fsdb::Support::IPv6 - ipv6-parsing helpers

SYNOPSIS

use Fsdb::Support::IPv6;

ipv6_zeroize

$ipv6_zeroized = Fsdb::Support::IPv6::ipv6_zeroize('1:0002:3:4::');
# result is 1:2:3:4:0:0:0:0

Normalize an IPv6 address so it has all hextets present, with no leading zeros.

Also treats strings of hex digits without colons as IPv6 prefixes.

ipv6_fullhex

$ipv6_fullhex = Fsdb::Support::IPv6::ipv6_full('1:0002:3:4::');
# result is 0001000200030004000000000000000

Rewrite an IPv6 address as a full, 128-bit, base-16 number.

ipv6_normalize

$ipv6_normal = Fsdb::Support::IPv6::ipv6_normalize('1:0002::7:0:00:8');
# result is 1:2::7:0:0:8

Convert an IPv6 address to IETF normal form. The input maybe has some fields 0 or leading zero, or :: in a non-standard place. Normalize it to remove leading zeros and replace the leftmost, longest run of zeros with ::.

Also treats strings of hex digits without colons as IPv6 prefixes.

ip_fullhex_to_normal

$ip_normal = Fsdb::Support::IPv6::ip_fullhex_to_normal('20010db8000300040005000600070008');
# result is 2001:db8:3:4:5:6:7:8

$ip_normal = Fsdb::Support::IPv6::ip_fullhex_to_normal('c0000201');
# result is 192.0.2.1

Convert an IPv6 address to IETF normal form. The input maybe has some fields 0 or leading zero, or :: in a non-standard place. Normalize it to remove leading zeros and replace the leftmost, longest run of zeros with ::.

Also treats strings of hex digits without colons as IPv6 prefixes.

_test_zero_fill

Internal testing.

_test_zero_remove

Internal testing.

_test_fullhex

Internal testing.

_test_fullhex_to_normal

Internal testing.

_test_both

Internal testing.

_test_ipv6

Internal testing.