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

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 60 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: Vendor-specific Information option (code 17) — enterprise + sub-options
3 # PODNAME: Net::DHCPv6::Option::VendorOpts
4 package Net::DHCPv6::Option::VendorOpts;
5 $Net::DHCPv6::Option::VendorOpts::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 Ref::Util qw(is_plain_arrayref);
12 use namespace::clean;
13  
14 sub new {
15 my ( $class, %args ) = @_;
16 croak 'VendorOpts requires enterprise_number' unless defined $args{enterprise_number};
17 $args{code} = $OPTION_VENDOR_OPTS;
18 my $sub_data = $args{sub_options} // '';
19 $sub_data = join( '', map { $_->as_bytes } @$sub_data ) if is_plain_arrayref( $sub_data );
20 $args{data} = pack( 'N', $args{enterprise_number} ) . $sub_data;
21 my $self = $class->SUPER::new( %args );
22 $self->{enterprise_number} = $args{enterprise_number};
23 bless $self, $class;
24 }
25  
26 sub enterprise_number { shift->{enterprise_number} }
27  
28 sub from_bytes_inner {
29 my ( $class, $code, $data ) = @_;
30 Net::DHCPv6::X::Truncated->throw( message => 'Truncated VendorOpts option' )
31 if CORE::length( $data ) < 4;
32 my $en = unpack( 'N', substr( $data, 0, 4 ) );
33 return $class->new( enterprise_number => $en, sub_options => substr( $data, 4 ) );
34 }
35  
36 $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_VENDOR_OPTS} = __PACKAGE__;
37 1;
38  
39 __END__