lib/Net/DHCPv6/Option/PdExclude.pm

filter: Statementstmt 100% 54 / 54 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 14 / 14 Podpod 100% 6 / 6 totaltotal 97.5% 80 / 82 CC 5 SCAR 5.2
CC
5
Cov
97%
from_bytes_inner
3.1
new
3.0
BEGIN
1.0
CRAP 1.7
« lib/Net/DHCPv6/Option/RelayMsg.pm ↑ Summary lib/Net/DHCPv6/Option/InterfaceId.pm »
1 #!/bin/false
2 # ABSTRACT: PD Exclude option (code 67) -- prefix to exclude from IA_PD
3 # PODNAME: Net::DHCPv6::Option::PdExclude
4 15 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package Net::DHCPv6::Option::PdExclude;
7 15 $Net::DHCPv6::Option::PdExclude::VERSION = '0.002';
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;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 ▶use Net::DHCPv6::X::Truncated;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 15 ▶use Net::DHCPv6::X::BadOption;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 15 ▶use parent 'Net::DHCPv6::Option';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 15 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 15 my $BYTE_ALIGN_MASK = 7; ## no critic (ValuesAndExpressions::ProhibitMagicNumbers)
17 15 my $BYTE_SHIFT = 3; ## no critic (ValuesAndExpressions::ProhibitMagicNumbers)
18  
19 sub new {
20 9 ▶ my ( $class, %args ) = @_;
Subroutine new: called CC=3 SCAR=11.0
Pod documented
21 9 ▶ croak 'PdExclude requires prefix_length' unless defined $args{prefix_length};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"prefix_length"} 1 8 9
22 8 my $addr = $class->_pick_addr( \%args, 'address' );
23 8 ▶ croak 'PdExclude requires address' unless defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 1 7 8
24 7 my $addr_len = ( $args{prefix_length} + $BYTE_ALIGN_MASK ) >> $BYTE_SHIFT;
25 7 $addr = substr( $addr, 0, $addr_len );
26 7 $args{code} = $OPTION_PD_EXCLUDE;
27 7 $args{data} = pack( 'C', $args{prefix_length} ) . $addr;
28 7 my $self = $class->SUPER::new( %args );
29 7 $self->{prefix_length} = $args{prefix_length};
30 7 $self->{address} = $addr;
31 7 return bless $self, $class;
32 }
33  
34 6 ▶sub prefix_length { return shift->{prefix_length} }
Subroutine prefix_length: called CC=1 SCAR=0.0
Pod documented
35 5 ▶sub address_raw { return shift->{address} }
Subroutine address_raw: called CC=1 SCAR=0.0
Pod documented
36 4 ▶sub address { return shift->{address} }
Subroutine address: called CC=1 SCAR=0.0
Pod documented
37  
38 sub from_bytes_inner {
39 3 ▶ my ( $class, $code, $payload ) = @_;
Subroutine from_bytes_inner: called CC=3 SCAR=11.2
Pod documented
40 3 ▶ Net::DHCPv6::X::Truncated->throw( message => 'Truncated PdExclude option' )
Branch: 1 branch
BranchTrueFalseTotal
if length $payload < 1 0 3 3
41 if CORE::length( $payload ) < 1;
42 3 my $plen = unpack( 'C', substr( $payload, 0, 1 ) );
43 3 my $addr_len = ( $plen + $BYTE_ALIGN_MASK ) >> $BYTE_SHIFT;
44 3 ▶ Net::DHCPv6::X::Truncated->throw( message => 'Truncated PdExclude address' )
Branch: 1 branch
BranchTrueFalseTotal
if 1 + $addr_len > length $payload 0 3 3
45 if 1 + $addr_len > CORE::length( $payload );
46 3 my $addr = substr( $payload, 1, $addr_len );
47 3 return $class->new( prefix_length => $plen, address_raw => $addr );
48 }
49  
50 sub as_bytes {
51 2 ▶ my $self = shift;
Subroutine as_bytes: called CC=1 SCAR=0.0
Pod documented
52 2 my $payload = pack( 'C', $self->{prefix_length} ) . $self->{address};
53 2 return pack( 'nn', $self->{code}, CORE::length( $payload ) ) . $payload;
54 }
55  
56 15 $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_PD_EXCLUDE} = __PACKAGE__;
57 15 1;
58  
59 __END__
« lib/Net/DHCPv6/Option/RelayMsg.pm ↑ Summary lib/Net/DHCPv6/Option/InterfaceId.pm »