NAME
Net::DHCPv6::Packet - DHCPv6 packet base class
VERSION
version 0.001
SYNOPSIS
my $pkt = Net::DHCPv6::Packet->new(
msg_type => $SOLICIT,
transaction_id => 123456,
);
$pkt->add_option($clientid);
my $bytes = $pkt->as_bytes;
my $decoded = Net::DHCPv6::Packet->from_bytes($bytes);
print $decoded->msg_type; # 1
print $decoded->type; # SOLICIT
print $decoded->transaction_id; # 123456
DESCRIPTION
Base class for DHCPv6 packets. Holds a message type, 24-bit transaction ID, and an Net::DHCPv6::OptionList. Concrete message subclasses (e.g. Net::DHCPv6::Message::Solicit) set the msg_type constant.
ALPHA STATUS
ALPHA SOFTWARE. This is an early release. The interface is experimental and subject to change without notice.
CONSTRUCTOR OVERLOAD
When called with a single scalar argument, Packet->new($bytes) delegates to Net::DHCPv6 decode_or_croak:
my $pkt = Net::DHCPv6::Packet->new($wire_bytes);
With key-value arguments, constructs a new packet:
my $pkt = Net::DHCPv6::Packet->new(
msg_type => 1,
transaction_id => 123456,
);
Zero arguments croaks.
METHODS
- msg_type
-
Returns the numeric message type.
- transaction_id
-
Returns the 24-bit transaction ID as an integer.
- options
-
Returns the internal Net::DHCPv6::OptionList.
- add_option($option)
-
Appends an option to the packet.
- get_option($code)
-
Returns the first option with the given code, or
undef. - as_bytes
-
Serializes to wire format: 1-byte msg_type + 3-byte transaction_id (big-endian) + options TLV chain.
- type
-
Returns the message type name string (e.g.
SOLICIT), orundefif unknown. - msg_type_name
-
Alias for "type". Returns the message type name string.
CLASS METHODS
- from_bytes($bytes)
-
Parses a packet from wire bytes. Dispatches to the appropriate concrete subclass via
%MESSAGE_CLASS. Falls back toNet::DHCPv6::Packetfor unknown message types. RELAY-FORW and RELAY-REPLY messages are handled by Net::DHCPv6::Packet::Relay.
RELAY MESSAGES
RELAY-FORW (12) and RELAY-REPLY (13) use a different wire format: hop_count(1) + link_address(16) + peer_address(16) + options. They have no transaction_id. See Net::DHCPv6::Packet::Relay.
SEE ALSO
Net::DHCPv6, Net::DHCPv6::Packet::Relay, Net::DHCPv6::Message::Solicit, Net::DHCPv6::Message::Reply, 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