NAME
Net::DHCPv6 - DHCPv6 packet decoder/encoder
VERSION
version 0.001
SYNOPSIS
use Net::DHCPv6;
my $bytes = ...; # wire bytes from socket
my $packet = Net::DHCPv6->decode_or_croak($bytes);
print $packet->type; # SOLICIT
print $packet->msg_type; # 1
print $packet->transaction_id;
my $cid = $packet->get_option(1);
print $cid->duid->duid_type;
# Tolerant parsing
if (my $pkt = Net::DHCPv6->decode_or_null($bytes)) {
...
}
# Inspect-mode parsing
my ($pkt, $err) = Net::DHCPv6->decode_with_error($bytes);
if ($err) { warn $err->message; }
DESCRIPTION
Top-level module for the Net::DHCPv6 library. Provides three entry points for decoding DHCPv6 wire bytes with different error-handling behaviours. Also loads all sub-modules so a single use Net::DHCPv6 makes all classes available.
ALPHA STATUS
ALPHA SOFTWARE. This is an early release. The interface is experimental and subject to change without notice.
DECODER METHODS
- decode_or_croak($bytes)
-
Strict parsing. Returns a Net::DHCPv6::Packet object on success. Croaks (throws an exception) on any parse failure, including truncated data.
- decode_or_null($bytes)
-
Tolerant parsing. Returns a Net::DHCPv6::Packet object on success,
undefon failure. Never throws. - decode_with_error($bytes)
-
Inspect-mode parsing. Returns
($packet, $error)where$packetis a Net::DHCPv6::Packet orundef, and$erroris an error string orundef. Never throws.
DUID STREAMING HELPERS
These methods parse raw DUID bytes without requiring a full packet or option wrapper.
- decode_duid_with_error($bytes)
-
Returns
($duid, $error). On truncation,$duidcontains whatever fields could be decoded (partial decode).$erroris a string orundef. Never throws. - decode_duid_or_null($bytes)
-
Returns a Net::DHCPv6::DUID on success or partial decode,
undefif the buffer is too short for even the 2-byte type header. Never throws. - decode_duid_or_croak($bytes)
-
Returns a Net::DHCPv6::DUID on success, croaks on any truncation.
OPTION-LIST STREAMING HELPERS
These methods parse raw option TLV chains without requiring a packet wrapper — useful for relay messages or extracting options from sub-option payloads.
- decode_options_with_error($bytes)
-
Returns
($option_list, $error). On truncation,$option_listcontains whatever options were fully parsed before the error.$erroris a string orundef. Never throws. - decode_options_or_null($bytes)
-
Returns a Net::DHCPv6::OptionList on success or partial decode, an empty Net::DHCPv6::OptionList on empty input. Never throws.
- decode_options_or_croak($bytes)
-
Returns a Net::DHCPv6::OptionList on success, croaks on any truncation or trailing garbage.
PACKET SUGAR
my $pkt = Net::DHCPv6::Packet->new($bytes);
Packet->new($bytes) delegates to decode_or_croak when given a single scalar argument.
SEE ALSO
Net::DHCPv6::Packet, Net::DHCPv6::Constants, Net::DHCPv6::DUID, Net::DHCPv6::OptionList
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