| 1 | #!/bin/false | ||||||||||
| 2 | # ABSTRACT: Remote ID option (code 37) -- enterprise-number + opaque data | ||||||||||
| 3 | # PODNAME: Net::DHCPv6::Option::RemoteId | ||||||||||
| 4 | 15 | ▶ | use strictures 2; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | package Net::DHCPv6::Option::RemoteId; | ||||||||||
| 7 | 15 | $Net::DHCPv6::Option::RemoteId::VERSION = '0.003'; | |||||||||
| 8 | 15 | ▶ | use Net::DHCPv6::OptionList (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 15 | ▶ | use Carp qw( croak ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 15 | ▶ | use Net::DHCPv6::Constants qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | $OPTION_REMOTE_ID | ||||||||||
| 12 | 15 | ); | |||||||||
| 13 | 15 | ▶ | use Net::DHCPv6::X::Truncated (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 15 | ▶ | use parent 'Net::DHCPv6::Option'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 15 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 15 | my $ENT_NUM_LEN = 4; ## no critic (ValuesAndExpressions::ProhibitMagicNumbers) | |||||||||
| 17 | |||||||||||
| 18 | 4 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 19 | 4 | my ( $class, %args ) = @_; | |||||||||
| 20 | 4 | ▶ | croak 'RemoteId requires enterprise_number' unless defined $args{enterprise_number}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 3 | ▶ | croak 'RemoteId requires remote_data' unless defined $args{remote_data}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 2 | $args{code} = $OPTION_REMOTE_ID; | |||||||||
| 23 | 2 | $args{data} = pack( 'N', $args{enterprise_number} ) . $args{remote_data}; | |||||||||
| 24 | 2 | my $self = $class->SUPER::new( %args ); | |||||||||
| 25 | 2 | $self->{enterprise_number} = $args{enterprise_number}; | |||||||||
| 26 | 2 | $self->{remote_data} = $args{remote_data}; | |||||||||
| 27 | 2 | return bless $self, $class; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 2 | ▶ | sub enterprise_number { return shift->{enterprise_number} } | ||||||||
|
Subroutine
enterprise_number: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 31 | 2 | ▶ | sub remote_data { return shift->{remote_data} } | ||||||||
|
Subroutine
remote_data: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 32 | |||||||||||
| 33 | 1 | ▶ | sub from_bytes_inner { | ||||||||
|
Subroutine
from_bytes_inner: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 34 | 1 | my ( $class, $code, $payload ) = @_; | |||||||||
| 35 | 1 | ▶ | Net::DHCPv6::X::Truncated->throw( message => 'Truncated RemoteId option' ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | if CORE::length( $payload ) < $ENT_NUM_LEN; | ||||||||||
| 37 | 1 | my $en = unpack( 'N', substr( $payload, 0, $ENT_NUM_LEN ) ); | |||||||||
| 38 | 1 | my $rest = substr( $payload, $ENT_NUM_LEN ); | |||||||||
| 39 | 1 | return $class->new( enterprise_number => $en, remote_data => $rest ); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 15 | $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_REMOTE_ID} = __PACKAGE__; | |||||||||
| 43 | 15 | 1; | |||||||||
| 44 | |||||||||||
| 45 | __END__ | ||||||||||