Scroll to navigation

Net::DHCPv6::DUID::Parser(3pm) User Contributed Perl Documentation Net::DHCPv6::DUID::Parser(3pm)

NAME

Net::DHCPv6::DUID::Parser - Parse DHCPv6 Unique Identifiers

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'

DESCRIPTION

Object oriented interface to parse RFC3315 compliant DHCPv6 Unique Identifiers (DUIDs)

This module was written for the purpose of splitting the DUID into its constituent parts, and shared here for convenience. It does some textual conversions that may save you some time.

USAGE

Methods

Constructor

Net::DHCPv6::DUID::Parser->new(..)

  my $p = new Net::DHCPv6::DUID::Parser (decode => 'hex');
    

The constructor class method accepts two parameters.

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'.

The 'warnings' parameter can be set to 0 to disable output to STDERR. The default value is 1.

Object Methods

Each method returns undef if it encounters a failure, or if a requested DUID component wasn't relevant to the decoded DUID type.

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.

    Returns 1 on success.

  • $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.

  • $p->iana_hw_type(..)

    Applies to: DUID-LL and DUID-LLT.

    Returns the IANA hardware type or undef if 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.

  • $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 is '1' - i.e, if it's Ethernet.

CREDITS

Mark Smith

SEE ALSO

http://tools.ietf.org/html/rfc3315#section-9

AUTHOR

Tom Wright, 2010

2022-10-22 perl v5.34.0