Net::D...:Parser(3pm)
π NAME π
Net::DHCPv6::DUID::Parser β bestie, this is the module that parses DHCPv6 Unique Identifiers (DUIDs). It's giving "object oriented Perl" and we're obsessed. β¨
(Also, real talk, the page header says it's Net::D...:Parser(3pm) and it lives in the User Contributed Perl Documentation section, so you know it's community-made with love.)
π¦ SYNOPSIS π¦
use Net::DHCPv6::DUID::Parser;
my $p = new Net::DHCPv6::DUID::Parser;
# Decode an example DUID
$p->decode('000300010004ED9F7622');
# Print the type
print "TYPE: ".$p->type(format => 'text')."\n";
### prints 'TYPE: DUID-LL'
if ($p->type == 1 || $p->type == 3) {
# Format this like a MAC address if the link type was Ethernet
if ($p->iana_hw_type == 1) {
print "MAC ADDRESS: ".$p->local_link_address(format => 'ethernet_mac')."\n";
} else {
print "LOCAL LINK ADDRESS: ".$p->local_link_address."\n";
}
}
### prints 'MAC ADDRESS: 00-04-ed-9f-76-22'
no cap, that's the whole vibe right there. π«Ά
πΈ DESCRIPTION πΈ
An object oriented interface to parse RFC3315 compliant DHCPv6 Unique Identifiers (DUIDs). Periodt. π
So the tea is: this module was written for the purpose of splitting the DUID into its constituent parts, and it got shared here for convenience. It does some textual conversions that may save you some time. It's the little helper that could. π
π USAGE π
β¨ Methods β¨
Constructor π«
Net::DHCPv6::DUID::Parser->new(..)
my $p = new Net::DHCPv6::DUID::Parser (decode => 'hex');
The constructor class method accepts two parameters, bestie, listen up:
The decode parameter tells the parser the format of the DUID you're intending to parse using the decode object method. Valid attributes are hex and bin. The default value is hex. Defaults are lowkey iconic.
The warnings parameter can be set to 0 to disable output to STDERR. The default value is 1. So if you want your terminal to stop yelling at you, now you know. π
Object Methods π§
Heads up, real talk: each method returns undef if it encounters a failure, or if a requested DUID component wasn't relevant to the decoded DUID type. Not me being honest about the undefs. π
Warnings are emitted by default, unless turned off in the object constructor.
$p->decode($duid)β accepts a single scalar, which should contain the DUID in the format indicated by the constructor. Returns1on success. slay.$p->type(..)β applies to: DUID-LL, DUID-LLT and DUID-EN. Returns the DUID type. Specify"format => 'text'"to return the textual representation of the DUID type. The default return value is numeric.$p->time()β applies to: DUID-LLT. Returns time ticks in seconds since midnight 1st January 2000. yes it's got its own little epoch, we don't make the rules. β°$p->iana_hw_type(..)β applies to: DUID-LL and DUID-LLT. Returns the IANA hardware type orundefif this parameter is irrelevant. Specify"format => 'text'"for a textual representation of this value. The default return value is numeric.$p->enterprise_number()β applies to: DUID-EN. Returns the enterprise number. corporate era. π’$p->identifier()β applies to: DUID-EN. Returns the identifier.$p->local_link_address(..)β applies to: DUID-LL and DUID-LLT. Returns the local link address. Specify"format => 'ethernet_mac'"for a pretty representation of this value. The formatting will only apply if the IANA hardware type is1β i.e, if it's Ethernet. otherwise it stays raw, and that's that. π€·
π CREDITS π
Mark Smith
(the originator, the blueprint, the moment. we love a credit section. π)
π SEE ALSO π
http://tools.ietf.org/html/rfc3315#section-9
go read the RFC bestie, section 9 specifically, iykyk. πβ¨
π AUTHOR π
Tom Wright, 2010
ok so that's the whole page!! every flag, every method, every default, all present and accounted for, no skips. π―
and for the cute sign-off: this lil beauty is part of perl v5.36.0, dated 2022-10-22, and it's filed under the Net::D...:Parser(3pm) page in the User Contributed Perl Documentation. mwah. ππ
π¦
π¦ where this page comes from
- ubuntu noble: libnet-dhcpv6-duid-parser-perl 1.01-4 Β· BSD-2-Clause
- ubuntu resolute: libnet-dhcpv6-duid-parser-perl 1.01-4 Β· BSD-2-Clause
- ubuntu stonking: libnet-dhcpv6-duid-parser-perl 1.01-4 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms