lib/Net/DHCPv6/Option/IAPrefix.pm

filter: Statementstmt 91.6% 55 / 60 Branchbran 50.0% 2 / 4 Conditioncond 55.5% 5 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 82.3% 14 / 17 Podpod 100% 10 / 10 totaltotal 81.9% 86 / 105 CC 7 SCAR 9.5
CC
7
Cov
85%
new
6.2
from_bytes_inner
2.0
options
2.0
CRAP 2.6
« lib/Net/DHCPv6/Option/Auth.pm ↑ Summary lib/Net/DHCPv6/Option.pm »
1 #!/usr/bin/false
2 # ABSTRACT: IA Prefix option (code 26) — prefix delegation sub-option
3 # PODNAME: Net::DHCPv6::Option::IAPrefix
4 package Net::DHCPv6::Option::IAPrefix;
5 15 $Net::DHCPv6::Option::IAPrefix::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::OptionList;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use Net::DHCPv6::X::Truncated;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 ▶use parent 'Net::DHCPv6::Option';
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 22 ▶ my ( $class, %args ) = @_;
Subroutine new: called CC=6 SCAR=18.3
Pod documented
16 22 ▶ croak 'IAPrefix requires address' unless $args{address};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"address"} 0 22 22
17 22 $args{code} = $OPTION_IAPREFIX;
18 22 ▶ $args{preferred_lifetime} = $args{preferred_lifetime} // 0;
Condition50%1/2
$args{"preferred_lifetime"} // 0
l!l
220
MC/DC0%0/1
$args{"preferred_lifetime"} // 0
$args{"preferred_lifetime"}
Truth table50%1/2
A
A= $args{"preferred_lifetime"}
Aresult
11
00
19 22 ▶ $args{valid_lifetime} = $args{valid_lifetime} // 0;
Condition50%1/2
$args{"valid_lifetime"} // 0
l!l
220
MC/DC0%0/1
$args{"valid_lifetime"} // 0
$args{"valid_lifetime"}
Truth table50%1/2
A
A= $args{"valid_lifetime"}
Aresult
11
00
20 22 ▶ $args{prefix_length} = $args{prefix_length} // 0;
Condition50%1/2
$args{"prefix_length"} // 0
l!l
220
MC/DC0%0/1
$args{"prefix_length"} // 0
$args{"prefix_length"}
Truth table50%1/2
A
A= $args{"prefix_length"}
Aresult
11
00
21 22 ▶ $args{options} = $args{options} // Net::DHCPv6::OptionList->new;
Condition66%2/3
$args{"options"} // "Net::DHCPv6::OptionList"->new
l!l&&r!l&&!r
2110
MC/DC0%0/2
$args{"options"} // "Net::DHCPv6::OptionList"->new
$args{"options"} "Net::DHCPv6::OptionList"->new
Truth table66%2/3
A // B
A= $args{"options"}B= "Net::DHCPv6::OptionList"->new
ABresult
1X1
011
000
22 my $data =
23 pack( 'N N', $args{preferred_lifetime}, $args{valid_lifetime} )
24 . pack( 'C', $args{prefix_length} )
25 . $args{address}
26 22 . $args{options}->as_bytes;
27 22 $args{data} = $data;
28 22 my $self = $class->SUPER::new( %args );
29 22 $self->{address} = $args{address};
30 22 $self->{preferred_lifetime} = $args{preferred_lifetime};
31 22 $self->{valid_lifetime} = $args{valid_lifetime};
32 22 $self->{prefix_length} = $args{prefix_length};
33 22 $self->{options} = $args{options};
34 22 bless $self, $class;
35 }
36  
37 5 ▶sub address { shift->{address} }
Subroutine address: called CC=1 SCAR=0.0
Pod documented
38 12 ▶sub preferred_lifetime { shift->{preferred_lifetime} }
Subroutine preferred_lifetime: called CC=1 SCAR=0.0
Pod documented
39 12 ▶sub valid_lifetime { shift->{valid_lifetime} }
Subroutine valid_lifetime: called CC=1 SCAR=0.0
Pod documented
40 9 ▶sub prefix_length { shift->{prefix_length} }
Subroutine prefix_length: called CC=1 SCAR=0.0
Pod documented
41 0 ▶sub options { shift->{options} }
Subroutine options: not called CC=1 SCAR=6.9
Pod documented
42  
43 sub add_option {
44 0 ▶ my ( $self, $option ) = @_;
Subroutine add_option: not called CC=1 SCAR=6.9
Pod documented
45 0 $self->{options}->add_option( $option );
46 }
47  
48 sub get_option {
49 0 ▶ my ( $self, $code ) = @_;
Subroutine get_option: not called CC=1 SCAR=6.9
Pod documented
50 0 return $self->{options}->get_option( $code );
51 }
52  
53 sub from_bytes_inner {
54 21 ▶ my ( $class, $code, $data ) = @_;
Subroutine from_bytes_inner: called CC=2 SCAR=7.0
Pod documented
55 21 ▶ Net::DHCPv6::X::Truncated->throw( message => 'Truncated IAPrefix option' )
Branch: 1 branch
BranchTrueFalseTotal
if length $data < 25 0 21 21
56 if CORE::length( $data ) < 25;
57 21 my ( $pl, $vl ) = unpack( 'N N', substr( $data, 0, 8 ) );
58 21 my $plen = unpack( 'C', substr( $data, 8, 1 ) );
59 21 my $addr = substr( $data, 9, 16 );
60 21 my $opt_data = substr( $data, 25 );
61 21 my $opts = Net::DHCPv6::OptionList->from_bytes( $opt_data );
62 21 return $class->new(
63 address => $addr,
64 preferred_lifetime => $pl,
65 valid_lifetime => $vl,
66 prefix_length => $plen,
67 options => $opts,
68 );
69 }
70  
71 sub as_bytes {
72 22 ▶ my $self = shift;
Subroutine as_bytes: called CC=1 SCAR=0.0
Pod documented
73 my $data =
74 pack( 'N N', $self->{preferred_lifetime}, $self->{valid_lifetime} )
75 . pack( 'C', $self->{prefix_length} )
76 . $self->{address}
77 22 . $self->{options}->as_bytes;
78 22 return pack( 'nn', $self->{code}, CORE::length( $data ) ) . $data;
79 }
80  
81 15 $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_IAPREFIX} = __PACKAGE__;
82  
83 15 1;
84  
85 __END__
« lib/Net/DHCPv6/Option/Auth.pm ↑ Summary lib/Net/DHCPv6/Option.pm »