PaxHeader/Net-DHCPv6-DUID-Parser-1.01000755 777777 777777 00000000214 11477062041 016727 xustar00twright000000 000000 18 gid=1943454482 18 uid=1739053400 20 ctime=1291609121 20 atime=1291609121 24 SCHILY.dev=234881026 22 SCHILY.ino=5755133 18 SCHILY.nlink=9 Net-DHCPv6-DUID-Parser-1.01/000755 €g§ÙX€sÖÃ00000000000 11477062041 016244 5ustar00twright000000 000000 Net-DHCPv6-DUID-Parser-1.01/PaxHeader/Changes000644 777777 777777 00000000214 11477060267 020304 xustar00twright000000 000000 18 gid=1943454482 18 uid=1739053400 20 ctime=1291609121 20 atime=1291609121 24 SCHILY.dev=234881026 22 SCHILY.ino=5754958 18 SCHILY.nlink=2 Net-DHCPv6-DUID-Parser-1.01/Changes000644 €g§ÙX€sÖÃ00000000373 11477060267 017552 0ustar00twright000000 000000 Revision history for Perl extension Net::DHCPv6::DUID::Parser. 1.00 Wed Dec 1 14:56:44 2010 - original version; created by h2xs 1.23 with options -AXc -n Net::DHCPv6::DUID::Parser -v 1.00 1.01 Mon Dec 6 14:33:00 2010 - Updated documentation Net-DHCPv6-DUID-Parser-1.01/PaxHeader/lib000755 777777 777777 00000000214 11477062041 017475 xustar00twright000000 000000 18 gid=1943454482 18 uid=1739053400 20 ctime=1291609121 20 atime=1291609121 24 SCHILY.dev=234881026 22 SCHILY.ino=5755141 18 SCHILY.nlink=3 Net-DHCPv6-DUID-Parser-1.01/lib/000755 €g§ÙX€sÖÃ00000000000 11477062041 017012 5ustar00twright000000 000000 Net-DHCPv6-DUID-Parser-1.01/PaxHeader/Makefile.PL000644 777777 777777 00000000214 11476067605 020765 xustar00twright000000 000000 18 gid=1943454482 18 uid=1739053400 20 ctime=1291609121 20 atime=1291609119 24 SCHILY.dev=234881026 22 SCHILY.ino=5754960 18 SCHILY.nlink=2 Net-DHCPv6-DUID-Parser-1.01/Makefile.PL000644 €g§ÙX€sÖÃ00000001105 11476067605 020225 0ustar00twright000000 000000 use 5.008008; use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'Net::DHCPv6::DUID::Parser', VERSION_FROM => 'lib/Net/DHCPv6/DUID/Parser.pm', # finds $VERSION PREREQ_PM => {}, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'lib/Net/DHCPv6/DUID/Parser.pm', # retrieve abstract from module AUTHOR => 'Tom Wright ') : ()), ); Net-DHCPv6-DUID-Parser-1.01/PaxHeader/MANIFEST000644 777777 777777 00000000214 11476067713 020144 xustar00twright000000 000000 18 gid=1943454482 18 uid=1739053400 20 ctime=1291609121 20 atime=1291609121 24 SCHILY.dev=234881026 22 SCHILY.ino=5755137 18 SCHILY.nlink=1 Net-DHCPv6-DUID-Parser-1.01/MANIFEST000644 €g§ÙX€sÖÃ00000000254 11476067713 017410 0ustar00twright000000 000000 Changes Makefile.PL MANIFEST README t/Net-DHCPv6-DUID-Parser.t lib/Net/DHCPv6/DUID/Parser.pm META.yml Module meta-data (added by MakeMaker) Net-DHCPv6-DUID-Parser-1.01/PaxHeader/META.yml000644 777777 777777 00000000214 11477062041 020252 xustar00twright000000 000000 18 gid=1943454482 18 uid=1739053400 20 ctime=1291609121 20 atime=1291609121 24 SCHILY.dev=234881026 22 SCHILY.ino=5755151 18 SCHILY.nlink=1 Net-DHCPv6-DUID-Parser-1.01/META.yml000644 €g§ÙX€sÖÃ00000000762 11477062041 017522 0ustar00twright000000 000000 --- #YAML:1.0 name: Net-DHCPv6-DUID-Parser version: 1.01 abstract: Parse DHCPv6 Unique Identifiers author: - Tom Wright license: unknown distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 requires: {} no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.48 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Net-DHCPv6-DUID-Parser-1.01/PaxHeader/README000644 777777 777777 00000000214 11475351324 017664 xustar00twright000000 000000 18 gid=1943454482 18 uid=1739053400 20 ctime=1291609121 20 atime=1291608895 24 SCHILY.dev=234881026 22 SCHILY.ino=5754963 18 SCHILY.nlink=2 Net-DHCPv6-DUID-Parser-1.01/README000644 €g§ÙX€sÖÃ00000003517 11475351324 017135 0ustar00twright000000 000000 Net-DHCPv6-DUID-Parser version 1.00 =================================== Net::DHCPv6::DUID::Parser - Object oriented interface to parse RFC3315 compliant DHCPv6 Unique Identifier's (DUID's) INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES None. COPYRIGHT AND LICENCE Copyright 2010 Tom Wright. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY TOM WRIGHT ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TOM WRIGHT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of Tom Wright. Net-DHCPv6-DUID-Parser-1.01/PaxHeader/t000755 777777 777777 00000000214 11477062041 017172 xustar00twright000000 000000 18 gid=1943454482 18 uid=1739053400 20 ctime=1291609121 20 atime=1291609121 24 SCHILY.dev=234881026 22 SCHILY.ino=5755134 18 SCHILY.nlink=3 Net-DHCPv6-DUID-Parser-1.01/t/000755 €g§ÙX€sÖÃ00000000000 11477062041 016507 5ustar00twright000000 000000 Net-DHCPv6-DUID-Parser-1.01/t/PaxHeader/Net-DHCPv6-DUID-Parser.t000644 777777 777777 00000000214 11475347246 023137 xustar00twright000000 000000 18 gid=1943454482 18 uid=1739053400 20 ctime=1291609121 20 atime=1291609121 24 SCHILY.dev=234881026 22 SCHILY.ino=5754965 18 SCHILY.nlink=2 Net-DHCPv6-DUID-Parser-1.01/t/Net-DHCPv6-DUID-Parser.t000644 €g§ÙX€sÖÃ00000007770 11475347246 022415 0ustar00twright000000 000000 # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl Net-DHCPv6-DUID-Parser.t' ######################### use Test::More tests => 46; use strict; BEGIN { use_ok('Net::DHCPv6::DUID::Parser') }; ######################### my $p = new Net::DHCPv6::DUID::Parser; # Check different decoder types isa_ok ($p, 'Net::DHCPv6::DUID::Parser', 'is a Net::DHCPv6::DUID::Parser object'); $p = undef; is ($p, undef, 'object is not defined'); $p = new Net::DHCPv6::DUID::Parser(decode => 'bin', warnings => 1); isa_ok ($p, 'Net::DHCPv6::DUID::Parser', 'is a Net::DHCPv6::DUID::Parser object'); $p = undef; is ($p, undef, 'object is not defined'); $p = new Net::DHCPv6::DUID::Parser(decode => 'hex', warnings => 0); isa_ok ($p, 'Net::DHCPv6::DUID::Parser', 'is a Net::DHCPv6::DUID::Parser object'); # Check all the methods we want are here can_ok ($p, qw/decode type identifier enterprise_number iana_hw_type time local_link_address/); # Test type 1: DUID-LLT is ($p->decode('000100011286F55C0007E90F2FEE'), 1, 'decode 000100011286F55C0007E90F2FEE successful'); cmp_ok ($p->type, '==', 1, 'DUID type is 1'); is ($p->type(format => 'text'), 'DUID-LLT', 'DUID type is DUID-LLT'); is ($p->local_link_address, '0007e90f2fee', 'local link address decoded ok'); is ($p->local_link_address(format => 'ethernet_mac'), '00-07-e9-0f-2f-ee', 'local link address with formatting ok'); cmp_ok ($p->iana_hw_type, '==', '1', 'IANA hardware type is 1'); is ($p->iana_hw_type(format => 'text'), 'Ethernet (10Mb)', 'IANA hardware type is Ethernet (10Mb)'); cmp_ok ($p->time, '==', 310834524, 'time is 310834524 seconds since Midnight, 1 January 2000'); is ($p->enterprise_number, undef, 'Enterprise number is not defined'); is ($p->identifier, undef, 'Identifier is not defined'); # Test type 2: DUID-EN is ($p->decode('0002000000090CC084D303000912'), 1, 'decode 0002000000090CC084D303000912 successful'); cmp_ok ($p->type, '==', 2, 'DUID type is 2'); is ($p->type(format => 'text'), 'DUID-EN', 'DUID type is DUID-EN'); is ($p->local_link_address, undef, 'local link address is not defined'); is ($p->local_link_address(format => 'ethernet_mac'), undef, 'local link address is not defined'); is ($p->iana_hw_type, undef, 'IANA hardware type is not defined'); is ($p->iana_hw_type(format => 'text'), undef, 'IANA hardware type is not defined'); is ($p->time, undef, 'time is not defined'); is ($p->enterprise_number, 9, 'Enterprise number is 9'); is ($p->identifier, '0cc084d303000912', 'Identifier is 0cc084d303000912'); # Test type 3: DUID-LL is ($p->decode('000300010004ED9F7522'), 1, 'decode 000300010004ED9F7522 successful'); cmp_ok ($p->type, '==', 3, 'DUID type is 3'); is ($p->type(format => 'text'), 'DUID-LL', 'DUID type is DUID-LL'); is ($p->local_link_address, '0004ed9f7522', 'local link address decoded ok'); is ($p->local_link_address(format => 'ethernet_mac'), '00-04-ed-9f-75-22', 'local link address with formatting ok'); cmp_ok ($p->iana_hw_type, '==', '1', 'IANA hardware type is 1'); is ($p->iana_hw_type(format => 'text'), 'Ethernet (10Mb)', 'IANA hardware type is Ethernet (10Mb)'); is ($p->time, undef, 'time is not defined'); is ($p->enterprise_number, undef, 'Enterprise number is not defined'); is ($p->identifier, undef, 'Identifier is not defined'); # Test rubbish is ($p->decode('foo'), undef, 'decode foo unsuccessful'); is ($p->type, undef, 'DUID type is undef'); is ($p->local_link_address, undef, 'local link address is not defined'); is ($p->local_link_address(format => 'ethernet_mac'), undef, 'local link address is not defined'); is ($p->iana_hw_type, undef, 'IANA hardware type is not defined'); is ($p->iana_hw_type(format => 'text'), undef, 'IANA hardware type is not defined'); is ($p->time, undef, 'time is not defined'); is ($p->enterprise_number, undef, 'Enterprise number is not defined'); is ($p->identifier, undef, 'Identifier is not defined'); Net-DHCPv6-DUID-Parser-1.01/lib/PaxHeader/Net000755 777777 777777 00000000214 11477062041 020223 xustar00twright000000 000000 18 gid=1943454482 18 uid=1739053400 20 ctime=1291609121 20 atime=1291609121 24 SCHILY.dev=234881026 22 SCHILY.ino=5755142 18 SCHILY.nlink=3 Net-DHCPv6-DUID-Parser-1.01/lib/Net/000755 €g§ÙX€sÖÃ00000000000 11477062041 017540 5ustar00twright000000 000000 Net-DHCPv6-DUID-Parser-1.01/lib/Net/PaxHeader/DHCPv6000755 777777 777777 00000000214 11477062041 021215 xustar00twright000000 000000 18 gid=1943454482 18 uid=1739053400 20 ctime=1291609121 20 atime=1291609121 24 SCHILY.dev=234881026 22 SCHILY.ino=5755143 18 SCHILY.nlink=3 Net-DHCPv6-DUID-Parser-1.01/lib/Net/DHCPv6/000755 €g§ÙX€sÖÃ00000000000 11477062041 020532 5ustar00twright000000 000000 Net-DHCPv6-DUID-Parser-1.01/lib/Net/DHCPv6/PaxHeader/DUID000755 777777 777777 00000000214 11477062041 021742 xustar00twright000000 000000 18 gid=1943454482 18 uid=1739053400 20 ctime=1291609121 20 atime=1291609121 24 SCHILY.dev=234881026 22 SCHILY.ino=5755144 18 SCHILY.nlink=3 Net-DHCPv6-DUID-Parser-1.01/lib/Net/DHCPv6/DUID/000755 €g§ÙX€sÖÃ00000000000 11477062041 021257 5ustar00twright000000 000000 Net-DHCPv6-DUID-Parser-1.01/lib/Net/DHCPv6/DUID/PaxHeader/Parser.pm000644 777777 777777 00000000214 11477061756 023622 xustar00twright000000 000000 18 gid=1943454482 18 uid=1739053400 20 ctime=1291609121 20 atime=1291609119 24 SCHILY.dev=234881026 22 SCHILY.ino=5755077 18 SCHILY.nlink=2 Net-DHCPv6-DUID-Parser-1.01/lib/Net/DHCPv6/DUID/Parser.pm000644 €g§ÙX€sÖÃ00000025515 11477061756 023075 0ustar00twright000000 000000 package Net::DHCPv6::DUID::Parser; # Copyright 2010 Tom Wright. All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are # permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, this list of # conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright notice, this list # of conditions and the following disclaimer in the documentation and/or other materials # provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY TOM WRIGHT ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TOM WRIGHT OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # The views and conclusions contained in the software and documentation are those of the # authors and should not be interpreted as representing official policies, either expressed # or implied, of Tom Wright. our $VERSION = "1.01"; use strict; use warnings; use Carp; =head1 NAME Net::DHCPv6::DUID::Parser - Parse DHCPv6 Unique Identifiers =head1 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' =head1 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. =cut ## Accept the following DUID input formats my %pack_templates = ( 'hex' => 'H*', 'bin' => 'B*', ); ## Decoders registered for each DUID type my %decoders = ( 1 => \&_decode_type_1, 2 => \&_decode_type_2, 3 => \&_decode_type_3, ); ## IETF DUID types my %duid_types = ( 1 => 'DUID-LLT', 2 => 'DUID-EN', 3 => 'DUID-LL', ); ## IANA hardware types my %iana_hw_types = ( 0 => 'Reserved', 1 => 'Ethernet (10Mb)', 2 => 'Experimental Ethernet (3Mb)', 3 => 'Amateur Radio AX.25', 4 => 'Proteon ProNET Token Ring', 5 => 'Chaos', 6 => 'IEEE 802 Networks', 7 => 'ARCNET', 8 => 'Hyperchannel', 9 => 'Lanstar', 10 => 'Autonet Short Address', 11 => 'LocalTalk', 12 => 'LocalNet (IBM PCNet or SYTEK LocalNET)', 13 => 'Ultra link', 14 => 'SMDS', 15 => 'Frame Relay', 16 => 'Asynchronous Transmission Mode (ATM)', 17 => 'HDLC', 18 => 'Fibre Channel', 19 => 'Asynchronous Transmission Mode (ATM)', 20 => 'Serial Line', 21 => 'Asynchronous Transmission Mode (ATM)', 22 => 'MIL-STD-188-220', 23 => 'Metricom', 24 => 'IEEE 1394.1995', 25 => 'MAPOS', 26 => 'Twinaxial', 27 => 'EUI-64', 28 => 'HIPARP', 29 => 'IP and ARP over ISO 7816-3', 30 => 'ARPSec', 31 => 'IPsec tunnel', 32 => 'InfiniBand (TM)', 33 => 'TIA-102 Project 25 Common Air Interface (CAI)', 34 => 'Wiegand Interface', 35 => 'Pure IP', 36 => 'HW_EXP1', 37 => 'HFI', 256 => 'HW_EXP2', ); =head1 USAGE =head2 Methods =head3 Constructor =over 4 =item * 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. =back =cut sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; my $self = { decode => 'hex', warnings => 1, @_, }; my %params = ( 'decode' => 1, warnings => 1 ); foreach (keys %$self) { croak "valid parameters are '". (join "' OR '", keys %params) ."'" unless $params{$_}; } croak "valid attributes for parameter 'decode' are '" . (join "' OR '", keys %pack_templates) ."'" unless $pack_templates{$self->{decode}}; return bless $self, $class; } =head3 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. =over 4 =item * $p->decode($duid) Accepts a single scalar, which should contain the DUID in the format indicated by the constructor. Returns 1 on success. =back =cut sub decode { my ($self, $duid) = @_; $self->{type} = $self->_decode_type($duid); foreach (qw/iana_hw_type local_link_address enterprise_number identifier time/) { $self->{$_} = undef; } if ($decoders{$self->{type}} && $duid_types{$self->{type}}) { ## type 1 if ($self->{type} == 1) { ( $self->{iana_hw_type}, $self->{local_link_address}, $self->{time} ) = &{$decoders{$self->{type}}}($self, $duid); return 1; ## type 2 } elsif ($self->{type} == 2) { ( $self->{enterprise_number}, $self->{identifier} ) = &{$decoders{$self->{type}}}($self, $duid); return 1; ## type 3 } elsif ($self->{type} == 3) { ( $self->{iana_hw_type}, $self->{local_link_address} ) = &{$decoders{$self->{type}}}($self, $duid); return 1; } else { ## should never get here die "ERROR: ".__PACKAGE__."->decoder registered, but not instructed to do anything! ". "don't know how to decode type $self->{type}"; } } else { carp "don't know how to decode type $self->{type}" if ($self->{warnings}); } return undef; } =over 4 =item * $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. =back =cut sub type { my ($self, %opts) = @_; if ($self->{type} && !($duid_types{$self->{type}})) { carp "type $self->{type} is not valid" if ($self->{warnings}); return undef; } elsif ($self->{type} && $opts{format} && $opts{format} eq 'text') { return $duid_types{$self->{type}}; } else { return $self->{type}; } } =over 4 =item * $p->time() Applies to: DUID-LLT. Returns time ticks in seconds since midnight 1st January 2000. =back =cut sub time { my ($self) = @_; carp "time is irrelevant for DUID type $self->{type}" unless ($self->{type} == 1 || !($self->{warnings})); return $self->{time}; } =over 4 =item * $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. =back =cut sub iana_hw_type { my ($self, %opts) = @_; carp "iana_hw_type is irrelevant for DUID type $self->{type}" unless ($self->{type} == 1 || $self->{type} == 3 || !($self->{warnings})); if ($self->{iana_hw_type} && !($iana_hw_types{$self->{iana_hw_type}})) { carp "iana_hw_type $self->{iana_hw_type} is UNKNOWN for DUID type $self->{type}"; return undef; } elsif ($self->{iana_hw_type} && $opts{format} && $opts{format} eq 'text') { return $iana_hw_types{$self->{iana_hw_type}}; } else { return $self->{iana_hw_type}; } } =over 4 =item * $p->enterprise_number() Applies to: DUID-EN. Returns the enterprise number. =back =cut sub enterprise_number { my ($self) = @_; carp "enterprise_number is irrelevant for DUID type $self->{type}" unless ($self->{type} == 2 || !($self->{warnings})); return $self->{enterprise_number}; } =over 4 =item * $p->identifier() Applies to: DUID-EN. Returns the identifier. =back =cut sub identifier { my ($self) = @_; carp "enterprise_number is irrelevant for DUID type $self->{type}" unless ($self->{type} == 2 || !($self->{warnings})); return $self->{identifier}; } =over 4 =item * $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. =back =cut sub local_link_address { my ($self, %opts) = @_; carp "local_link_address is irrelevant for DUID type $self->{type}" unless ($self->{type} == 1 || $self->{type} == 3 || !($self->{warnings})); my %formats = ( ethernet_mac => 1, ); if ($opts{format}) { croak "ERROR: ".__PACKAGE__."->local_link_address' valid options for 'format' are '" . (join "' OR '", keys %formats) . "'" unless ($formats{$opts{format}}); if ($self->{local_link_address} && $opts{format} eq 'ethernet_mac' && $self->iana_hw_type == 1) { my @ethernet_mac = unpack ('(A2)*', $self->{local_link_address}); return join "-", @ethernet_mac; } } else { return $self->{local_link_address}; } return undef; } ## ## PRIVATE METHODS ## ## DUID Based on Link-layer Address Plus Time [DUID-LLT] sub _decode_type_1 { my ($self, $duid) = @_; my ($iana_hw_type, $time, $local_link_address) = unpack ('xx (n) (N) (H*)',pack ($pack_templates{$self->{decode}},$duid)); return ($iana_hw_type, $local_link_address, $time); } ## DUID Assigned by Vendor Based on Enterprise Number [DUID-EN] sub _decode_type_2 { my ($self, $duid) = @_; my ($enterprise_number, $identifier) = unpack ('xx (N) (H*)',pack($pack_templates{$self->{decode}},$duid)); return ($enterprise_number, $identifier); } ## DUID Based on Link-layer Address [DUID-LL] sub _decode_type_3 { my ($self, $duid) = @_; my ($iana_hw_type, $local_link_address) = unpack('xx (n) (H*)',pack ($pack_templates{$self->{decode}},$duid)); return ($iana_hw_type, $local_link_address); } ## Determine only the DUID type sub _decode_type { my ($self, $duid) = @_; return unpack ("n",pack("H*",$duid)); } =head1 CREDITS Mark Smith =head1 SEE ALSO http://tools.ietf.org/html/rfc3315#section-9 =head1 AUTHOR Tom Wright, 2010 =cut 1;