lib/Net/DHCPv6/Option/VendorClass.pm

filter: Statementstmt 100% 52 / 52 Branchbran 70.0% 7 / 10 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod 100% 4 / 4 totaltotal 90.4% 76 / 84 CC 8 SCAR 10.4
CC
8
Cov
91%
new
5.2
from_bytes_inner
4.0
BEGIN
1.0
CRAP 2.8
« blib/lib/Net/DHCPv6/Option/IAPrefix.pm ↑ Summary blib/lib/Net/DHCPv6/Option/ClientId.pm »
1 #!/usr/bin/false
2 # ABSTRACT: Vendor Class option (code 16) — enterprise-number + opaque data
3 # PODNAME: Net::DHCPv6::Option::VendorClass
4 package Net::DHCPv6::Option::VendorClass;
5 15 $Net::DHCPv6::Option::VendorClass::VERSION = '0.001';
6 15 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 15 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 15 ▶use Net::DHCPv6::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 ▶use Net::DHCPv6::X::Truncated;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use parent 'Net::DHCPv6::Option';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 ▶use Ref::Util qw(is_plain_arrayref);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 15 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub new {
15 9 ▶ my ( $class, %args ) = @_;
Subroutine new: called CC=5 SCAR=16.4
Pod documented
16 9 ▶ croak 'VendorClass requires enterprise_number' unless defined $args{enterprise_number};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"enterprise_number"} 1 8 9
17 8 $args{code} = $OPTION_VENDOR_CLASS;
18 8 ▶ my $data_list = $args{vendor_data} // $args{data} // [];
Condition40%2/5
($args{"vendor_data"} // $args{"data"}) // []
l!l
80
$args{"vendor_data"} // $args{"data"}
l!l&&r!l&&!r
800
MC/DC0%0/2
($args{"vendor_data"} // $args{"data"}) // []
$args{"vendor_data"} $args{"data"}
Truth table33%1/3
A // B
A= $args{"vendor_data"}B= $args{"data"}
ABresult
1X1
011
000
19 8 ▶ $data_list = [$data_list] unless is_plain_arrayref( $data_list );
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_plain_arrayref($data_list) 0 8 8
20 my $encoded =
21 8 pack( 'N', $args{enterprise_number} ) . join( '', map { pack( 'n', CORE::length ) . $_ } @$data_list );
22 8 $args{data} = $encoded;
23 8 my $self = $class->SUPER::new( %args );
24 8 $self->{enterprise_number} = $args{enterprise_number};
25 8 $self->{vendor_data} = $data_list;
26 8 bless $self, $class;
27 }
28  
29 4 ▶sub enterprise_number { shift->{enterprise_number} }
Subroutine enterprise_number: called CC=1 SCAR=0.0
Pod documented
30 3 ▶sub vendor_data { shift->{vendor_data} }
Subroutine vendor_data: called CC=1 SCAR=0.0
Pod documented
31  
32 sub from_bytes_inner {
33 6 ▶ my ( $class, $code, $data ) = @_;
Subroutine from_bytes_inner: called CC=4 SCAR=13.9
Pod documented
34 6 ▶ Net::DHCPv6::X::Truncated->throw( message => 'Truncated VendorClass option' )
Branch: 1 branch
BranchTrueFalseTotal
if length $data < 4 0 6 6
35 if CORE::length( $data ) < 4;
36 6 my $en = unpack( 'N', substr( $data, 0, 4 ) );
37 6 my $rest = substr( $data, 4 );
38 6 my @items;
39 6 my $offset = 0;
40 6 my $len = CORE::length( $rest );
41 6 ▶ while ( $offset + 2 <= $len ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset + 2 <= $len) 7 6 13
42 7 my $ilen = unpack( 'n', substr( $rest, $offset, 2 ) );
43 7 $offset += 2;
44 7 ▶ Net::DHCPv6::X::Truncated->throw( message => 'Truncated VendorClass data item' )
Branch: 1 branch
BranchTrueFalseTotal
if $offset + $ilen > $len 0 7 7
45 if $offset + $ilen > $len;
46 7 push @items, substr( $rest, $offset, $ilen );
47 7 $offset += $ilen;
48 }
49 6 return $class->new( enterprise_number => $en, vendor_data => \@items );
50 }
51  
52 15 $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_VENDOR_CLASS} = __PACKAGE__;
53 15 1;
54  
55 __END__
« blib/lib/Net/DHCPv6/Option/IAPrefix.pm ↑ Summary blib/lib/Net/DHCPv6/Option/ClientId.pm »