blib/lib/Net/DHCPv6/Option/RemoteId.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 57 CC 4 SCAR 15.9
CC
4
Cov
0%
new
12.0
from_bytes_inner
6.0
enterprise_number
2.0
CRAP 4.9
1 #!/usr/bin/false
2 # ABSTRACT: Remote ID option (code 37) — enterprise-number + opaque data
3 # PODNAME: Net::DHCPv6::Option::RemoteId
4 package Net::DHCPv6::Option::RemoteId;
5 $Net::DHCPv6::Option::RemoteId::VERSION = '0.001';
6 use strictures 2;
7 use Carp qw(croak);
8 use Net::DHCPv6::Constants;
9 use Net::DHCPv6::X::Truncated;
10 use parent 'Net::DHCPv6::Option';
11 use namespace::clean;
12  
13 sub new {
14 my ( $class, %args ) = @_;
15 croak 'RemoteId requires enterprise_number' unless defined $args{enterprise_number};
16 croak 'RemoteId requires remote_data' unless defined $args{remote_data};
17 $args{code} = $OPTION_REMOTE_ID;
18 $args{data} = pack( 'N', $args{enterprise_number} ) . $args{remote_data};
19 my $self = $class->SUPER::new( %args );
20 $self->{enterprise_number} = $args{enterprise_number};
21 $self->{remote_data} = $args{remote_data};
22 bless $self, $class;
23 }
24  
25 sub enterprise_number { shift->{enterprise_number} }
26 sub remote_data { shift->{remote_data} }
27  
28 sub from_bytes_inner {
29 my ( $class, $code, $data ) = @_;
30 Net::DHCPv6::X::Truncated->throw( message => 'Truncated RemoteId option' )
31 if CORE::length( $data ) < 4;
32 my $en = unpack( 'N', substr( $data, 0, 4 ) );
33 my $rest = substr( $data, 4 );
34 return $class->new( enterprise_number => $en, remote_data => $rest );
35 }
36  
37 $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_REMOTE_ID} = __PACKAGE__;
38 1;
39  
40 __END__