lib/Net/DHCPv6/Packet/Relay.pm

filter: Statementstmt 100% 43 / 43 Branchbran 50.0% 6 / 12 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 12 / 12 Podpod 100% 6 / 6 totaltotal 79.5% 70 / 88 CC 10 SCAR 14.4
CC
10
Cov
81%
new
8.8
from_bytes
4.3
BEGIN
1.0
CRAP 4.2
« Build ↑ Summary blib/lib/Net/DHCPv6/Option/BootfileUrl.pm »
1 #!/usr/bin/false
2 # ABSTRACT: Base class for DHCPv6 relay messages (RelayForw/RelayReply)
3 # PODNAME: Net::DHCPv6::Packet::Relay
4 package Net::DHCPv6::Packet::Relay;
5 29 $Net::DHCPv6::Packet::Relay::VERSION = '0.001';
6 29 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 29 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 29 ▶use Net::DHCPv6::OptionList;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 29 ▶use Net::DHCPv6::X::BadMessage;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 29 ▶use parent 'Net::DHCPv6::Packet';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 29 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub new {
14 2 ▶ my ( $class, %args ) = @_;
Subroutine new: called CC=7 SCAR=21.8
Pod documented
15 2 ▶ croak 'Relay->new: hop_count is required' unless defined $args{hop_count};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"hop_count"} 0 2 2
16 2 ▶ croak 'Relay->new: link_address is required' unless defined $args{link_address};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"link_address"} 0 2 2
17 2 ▶ croak 'Relay->new: peer_address is required' unless defined $args{peer_address};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"peer_address"} 0 2 2
18 2 ▶ croak 'Relay->new: link_address must be 16 bytes' unless CORE::length( $args{link_address} ) == 16;
Branch: 1 branch
BranchTrueFalseTotal
unless length $args{"link_address"} == 16 0 2 2
19 2 ▶ croak 'Relay->new: peer_address must be 16 bytes' unless CORE::length( $args{peer_address} ) == 16;
Branch: 1 branch
BranchTrueFalseTotal
unless length $args{"peer_address"} == 16 0 2 2
20  
21 2 ▶ $args{options} = $args{options} // Net::DHCPv6::OptionList->new;
Condition33%1/3
$args{"options"} // "Net::DHCPv6::OptionList"->new
l!l&&r!l&&!r
020
MC/DC0%0/2
$args{"options"} // "Net::DHCPv6::OptionList"->new
$args{"options"} "Net::DHCPv6::OptionList"->new
Truth table33%1/3
A // B
A= $args{"options"}B= "Net::DHCPv6::OptionList"->new
ABresult
1X1
011
000
22  
23 return bless {
24 msg_type => $args{msg_type},
25 hop_count => $args{hop_count},
26 link_address => $args{link_address},
27 peer_address => $args{peer_address},
28 options => $args{options},
29 2 }, $class;
30 }
31  
32 4 ▶sub hop_count { shift->{hop_count} }
Subroutine hop_count: called CC=1 SCAR=0.0
Pod documented
33 4 ▶sub link_address { shift->{link_address} }
Subroutine link_address: called CC=1 SCAR=0.0
Pod documented
34 4 ▶sub peer_address { shift->{peer_address} }
Subroutine peer_address: called CC=1 SCAR=0.0
Pod documented
35  
36 sub from_bytes {
37 3 ▶ my ( $class, $bytes ) = @_;
Subroutine from_bytes: called CC=4 SCAR=14.7
Pod documented
38 3 ▶ Net::DHCPv6::X::BadMessage->throw( message => 'Empty relay data' )
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bytes and length $bytes >= 34 0 3 3
Condition33%1/3
defined $bytes and length $bytes >= 34
!ll&&!rl&&r
003
MC/DC0%0/2
defined $bytes and length $bytes >= 34
defined $bytes length $bytes >= 34
Truth table33%1/3
A and B
A= defined $bytesB= length $bytes >= 34
ABresult
0X0
100
111
39 unless defined $bytes && CORE::length( $bytes ) >= 34;
40  
41 3 my $msg_type = unpack( 'C', substr( $bytes, 0, 1 ) );
42 3 my $hop_count = unpack( 'C', substr( $bytes, 1, 1 ) );
43 3 my $link_addr = substr( $bytes, 2, 16 );
44 3 my $peer_addr = substr( $bytes, 18, 16 );
45 3 my $opts_bytes = substr( $bytes, 34 );
46 3 my $opts = Net::DHCPv6::OptionList->from_bytes( $opts_bytes );
47  
48 3 ▶ my $subclass = $Net::DHCPv6::Packet::MESSAGE_CLASS{$msg_type} || $class;
Condition33%1/3
$Net::DHCPv6::Packet::MESSAGE_CLASS{$msg_type} || $class
l!l&&r!l&&!r
300
MC/DC0%0/2
$Net::DHCPv6::Packet::MESSAGE_CLASS{$msg_type} || $class
$Net::DHCPv6::Packet::MESSAGE_CLASS{$msg_type} $class
Truth table33%1/3
A || B
A= $Net::DHCPv6::Packet::MESSAGE_CLASS{$msg_type}B= $class
ABresult
1X1
011
000
49 3 return bless {
50 msg_type => $msg_type,
51 hop_count => $hop_count,
52 link_address => $link_addr,
53 peer_address => $peer_addr,
54 options => $opts,
55 }, $subclass;
56 }
57  
58 sub as_bytes {
59 2 ▶ my $self = shift;
Subroutine as_bytes: called CC=1 SCAR=0.0
Pod documented
60 return
61 pack( 'C C a16 a16', $self->{msg_type}, $self->{hop_count}, $self->{link_address}, $self->{peer_address} )
62 2 . $self->{options}->as_bytes;
63 }
64  
65 29 1;
66  
67 __END__
« Build ↑ Summary blib/lib/Net/DHCPv6/Option/BootfileUrl.pm »