lib/Net/DHCPv6/Option/IAAddr.pm

filter: Statementstmt 91.0% 51 / 56 Branchbran 100% 4 / 4 Conditioncond 57.1% 4 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 81.2% 13 / 16 Podpod 100% 9 / 9 totaltotal 84.3% 81 / 96 CC 6 SCAR 7.9
CC
6
Cov
88%
new
5.1
options
2.0
add_option
2.0
CRAP 2.2
« lib/Net/DHCPv6/Option/SipServerA.pm ↑ Summary lib/Net/DHCPv6/Option/IANA.pm »
1 #!/usr/bin/false
2 # ABSTRACT: IA Address option (code 5) — address + lifetimes + sub-options
3 # PODNAME: Net::DHCPv6::Option::IAAddr
4 package Net::DHCPv6::Option::IAAddr;
5 16 $Net::DHCPv6::Option::IAAddr::VERSION = '0.001';
6 16 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 16 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 16 ▶use Net::DHCPv6::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 16 ▶use Net::DHCPv6::OptionList;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 16 ▶use Net::DHCPv6::X::Truncated;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 16 ▶use parent 'Net::DHCPv6::Option';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 16 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub new {
15 18 ▶ my ( $class, %args ) = @_;
Subroutine new: called CC=5 SCAR=16.2
Pod documented
16 18 ▶ croak 'IAAddr requires address' unless $args{address};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"address"} 1 17 18
17 17 $args{code} = $OPTION_IAADDR;
18 17 ▶ $args{preferred_lifetime} = $args{preferred_lifetime} // 0;
Condition50%1/2
$args{"preferred_lifetime"} // 0
l!l
170
MC/DC0%0/1
$args{"preferred_lifetime"} // 0
$args{"preferred_lifetime"}
Truth table50%1/2
A
A= $args{"preferred_lifetime"}
Aresult
11
00
19 17 ▶ $args{valid_lifetime} = $args{valid_lifetime} // 0;
Condition50%1/2
$args{"valid_lifetime"} // 0
l!l
170
MC/DC0%0/1
$args{"valid_lifetime"} // 0
$args{"valid_lifetime"}
Truth table50%1/2
A
A= $args{"valid_lifetime"}
Aresult
11
00
20 17 ▶ $args{options} = $args{options} // Net::DHCPv6::OptionList->new;
Condition66%2/3
$args{"options"} // "Net::DHCPv6::OptionList"->new
l!l&&r!l&&!r
1520
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
21 my $data =
22 17 $args{address} . pack( 'N N', $args{preferred_lifetime}, $args{valid_lifetime} ) . $args{options}->as_bytes;
23 17 $args{data} = $data;
24 17 my $self = $class->SUPER::new( %args );
25 17 $self->{address} = $args{address};
26 17 $self->{preferred_lifetime} = $args{preferred_lifetime};
27 17 $self->{valid_lifetime} = $args{valid_lifetime};
28 17 $self->{options} = $args{options};
29 17 bless $self, $class;
30 }
31  
32 6 ▶sub address { shift->{address} }
Subroutine address: called CC=1 SCAR=0.0
Pod documented
33 10 ▶sub preferred_lifetime { shift->{preferred_lifetime} }
Subroutine preferred_lifetime: called CC=1 SCAR=0.0
Pod documented
34 9 ▶sub valid_lifetime { shift->{valid_lifetime} }
Subroutine valid_lifetime: called CC=1 SCAR=0.0
Pod documented
35 0 ▶sub options { shift->{options} }
Subroutine options: not called CC=1 SCAR=6.9
Pod documented
36  
37 sub add_option {
38 0 ▶ my ( $self, $option ) = @_;
Subroutine add_option: not called CC=1 SCAR=6.9
Pod documented
39 0 $self->{options}->add_option( $option );
40 }
41  
42 sub get_option {
43 0 ▶ my ( $self, $code ) = @_;
Subroutine get_option: not called CC=1 SCAR=6.9
Pod documented
44 0 return $self->{options}->get_option( $code );
45 }
46  
47 sub from_bytes_inner {
48 16 ▶ my ( $class, $code, $data ) = @_;
Subroutine from_bytes_inner: called CC=2 SCAR=6.9
Pod documented
49 16 ▶ Net::DHCPv6::X::Truncated->throw( message => 'Truncated IAAddr option' )
Branch: 1 branch
BranchTrueFalseTotal
if length $data < 24 1 15 16
50 if CORE::length( $data ) < 24;
51 15 my $addr = substr( $data, 0, 16 );
52 15 my ( $pl, $vl ) = unpack( 'N N', substr( $data, 16, 8 ) );
53 15 my $opt_data = substr( $data, 24 );
54 15 my $opts = Net::DHCPv6::OptionList->from_bytes( $opt_data );
55 15 return $class->new(
56 address => $addr,
57 preferred_lifetime => $pl,
58 valid_lifetime => $vl,
59 options => $opts,
60 );
61 }
62  
63 sub as_bytes {
64 16 ▶ my $self = shift;
Subroutine as_bytes: called CC=1 SCAR=0.0
Pod documented
65 my $data =
66 $self->{address}
67 . pack( 'N N', $self->{preferred_lifetime}, $self->{valid_lifetime} )
68 16 . $self->{options}->as_bytes;
69 16 return pack( 'nn', $self->{code}, CORE::length( $data ) ) . $data;
70 }
71  
72 16 $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_IAADDR} = __PACKAGE__;
73  
74 16 1;
75  
76 __END__
« lib/Net/DHCPv6/Option/SipServerA.pm ↑ Summary lib/Net/DHCPv6/Option/IANA.pm »