lib/Net/DHCPv6/Option/IANA.pm

filter: Statementstmt 100% 55 / 55 Branchbran 100% 4 / 4 Conditioncond 57.1% 4 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 16 / 16 Podpod 100% 9 / 9 totaltotal 92.6% 88 / 95 CC 6 SCAR 7.2
CC
6
Cov
95%
new
5.1
from_bytes_inner
2.0
BEGIN
1.0
CRAP 2.1
« lib/Net/DHCPv6/Option/IAAddr.pm ↑ Summary lib/Net/DHCPv6/Option/IAPD.pm »
1 #!/usr/bin/false
2 # ABSTRACT: Identity Association for Non-temporary Addresses option (code 3)
3 # PODNAME: Net::DHCPv6::Option::IANA
4 package Net::DHCPv6::Option::IANA;
5 16 $Net::DHCPv6::Option::IANA::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 15 ▶ my ( $class, %args ) = @_;
Subroutine new: called CC=5 SCAR=16.2
Pod documented
16 15 ▶ croak 'IANA requires iaid' unless defined $args{iaid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"iaid"} 1 14 15
17 14 $args{code} = $OPTION_IA_NA;
18 14 ▶ $args{t1} = $args{t1} // 0;
Condition50%1/2
$args{"t1"} // 0
l!l
140
MC/DC0%0/1
$args{"t1"} // 0
$args{"t1"}
Truth table50%1/2
A
A= $args{"t1"}
Aresult
11
00
19 14 ▶ $args{t2} = $args{t2} // 0;
Condition50%1/2
$args{"t2"} // 0
l!l
140
MC/DC0%0/1
$args{"t2"} // 0
$args{"t2"}
Truth table50%1/2
A
A= $args{"t2"}
Aresult
11
00
20 14 ▶ $args{options} = $args{options} // Net::DHCPv6::OptionList->new;
Condition66%2/3
$args{"options"} // "Net::DHCPv6::OptionList"->new
l!l&&r!l&&!r
1220
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 14 my $data = pack( 'N N N', $args{iaid}, $args{t1}, $args{t2} ) . $args{options}->as_bytes;
22 14 $args{data} = $data;
23 14 my $self = $class->SUPER::new( %args );
24 14 $self->{iaid} = $args{iaid};
25 14 $self->{t1} = $args{t1};
26 14 $self->{t2} = $args{t2};
27 14 $self->{options} = $args{options};
28 14 bless $self, $class;
29 }
30  
31 7 ▶sub iaid { shift->{iaid} }
Subroutine iaid: called CC=1 SCAR=0.0
Pod documented
32 6 ▶sub t1 { shift->{t1} }
Subroutine t1: called CC=1 SCAR=0.0
Pod documented
33 6 ▶sub t2 { shift->{t2} }
Subroutine t2: called CC=1 SCAR=0.0
Pod documented
34 2 ▶sub options { shift->{options} }
Subroutine options: called CC=1 SCAR=0.0
Pod documented
35  
36 sub add_option {
37 2 ▶ my ( $self, $option ) = @_;
Subroutine add_option: called CC=1 SCAR=0.0
Pod documented
38 2 $self->{options}->add_option( $option );
39 }
40  
41 sub get_option {
42 7 ▶ my ( $self, $code ) = @_;
Subroutine get_option: called CC=1 SCAR=0.0
Pod documented
43 7 return $self->{options}->get_option( $code );
44 }
45  
46 sub from_bytes_inner {
47 13 ▶ my ( $class, $code, $data ) = @_;
Subroutine from_bytes_inner: called CC=2 SCAR=6.9
Pod documented
48 13 ▶ Net::DHCPv6::X::Truncated->throw( message => 'Truncated IANA option' )
Branch: 1 branch
BranchTrueFalseTotal
if length $data < 12 1 12 13
49 if CORE::length( $data ) < 12;
50 12 my ( $iaid, $t1, $t2 ) = unpack( 'N N N', substr( $data, 0, 12 ) );
51 12 my $opt_data = substr( $data, 12 );
52 12 my $opts = Net::DHCPv6::OptionList->from_bytes( $opt_data );
53 12 return $class->new( iaid => $iaid, t1 => $t1, t2 => $t2, options => $opts );
54 }
55  
56 sub as_bytes {
57 2 ▶ my $self = shift;
Subroutine as_bytes: called CC=1 SCAR=0.0
Pod documented
58 2 my $data = pack( 'N N N', $self->{iaid}, $self->{t1}, $self->{t2} ) . $self->{options}->as_bytes;
59 2 return pack( 'nn', $self->{code}, CORE::length( $data ) ) . $data;
60 }
61  
62 16 $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_IA_NA} = __PACKAGE__;
63  
64 16 1;
65  
66 __END__
« lib/Net/DHCPv6/Option/IAAddr.pm ↑ Summary lib/Net/DHCPv6/Option/IAPD.pm »