NAME

Net::DHCPv6::OptionList - Shared container for a collection of DHCPv6 options

VERSION

version 0.001

SYNOPSIS

my $ol = Net::DHCPv6::OptionList->new;
$ol->add_option($clientid);
$ol->add_option($oro);

my $opt    = $ol->get_option(1);        # first ClientId
my $opts   = $ol->options;              # arrayref in insertion order
my $bytes  = $ol->as_bytes;             # TLV chain

my $parsed = Net::DHCPv6::OptionList->from_bytes($bytes);

DESCRIPTION

Stores options in insertion order for deterministic serialization while providing O(1) lookup by option code. Used by Net::DHCPv6::Packet, Net::DHCPv6::Option::IANA, Net::DHCPv6::Option::IAPD, and Net::DHCPv6::Option::IAAddr.

ALPHA STATUS

ALPHA SOFTWARE. This is an early release. The interface is experimental and subject to change without notice.

METHODS

new

Returns an empty option list.

add_option($option)

Appends an option. Multiple options with the same code are allowed.

get_option($code)

Returns the first option with the given code, or undef.

remove_option($code)

Removes all options with the given code.

options

Returns an arrayref of all options in insertion order, or undef if empty.

as_bytes

Serializes all options as a TLV chain.

from_bytes($bytes)

Class method. Parses a TLV chain from wire bytes. Uses %OPTION_CLASS to dispatch to concrete option subclasses. Falls back to Option::Generic for unknown codes or parse failures.

try_from_bytes($bytes)

Class method. Like from_bytes but returns ($option_list, $error). On truncation mid-option, $option_list contains whatever options were fully parsed before the truncation, and $error is an error string. On success, $error is undef. Never throws.

DISPATCH TABLE

%OPTION_CLASS maps numeric option codes to package names. Each concrete option class registers itself at compile time. For example:

$Net::DHCPv6::OptionList::OPTION_CLASS{1} = 'Net::DHCPv6::Option::ClientId';

SEE ALSO

Net::DHCPv6::Option, concrete option classes under Net::DHCPv6::Option

AUTHOR

Dean Hamstead <dean@fragfest.com.au>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2026 by Dean Hamstead.

This is free software, licensed under:

The MIT (X11) License