ICMPv6/RouterSolicitation.pm

filter: Statementstmt 60.6% 37 / 61 Branchbran 37.5% 3 / 8 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 69.2% 9 / 13 Podpod 100% 6 / 6 totaltotal 57.1% 56 / 98 CC 10 SCAR 14.8
CC
10
Cov
55%
_unpackOptions
12.0
getOptionsLength
6.0
print
6.0
CRAP 4.4
« ICMPv6/NeighborSolicitation.pm ↑ Summary ICMPv6/NeighborAdvertisement.pm »
1 #
2 # Router Solicitation message wrapper, compliant to RFC 4861
3 # pvenegas@infoweapons.com
4 #
5 #
6 # $Id: RouterSolicitation.pm,v bc01789674fd 2019/05/23 05:51:45 gomor $
7 #
8 package Net::Frame::Layer::ICMPv6::RouterSolicitation;
9 3 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶use Net::Frame::Layer qw(:consts :subs);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 our @ISA = qw(Net::Frame::Layer);
13  
14 3 our @AS = qw(
15 reserved
16 );
17 3 our @AA = qw(
18 options
19 );
20 3 __PACKAGE__->cgBuildIndices;
21 3 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
22 3 __PACKAGE__->cgBuildAccessorsArray (\@AA);
23  
24 3 ▶use Net::Frame::Layer::ICMPv6 qw(:consts);
Subroutine BEGIN: called CC=1 SCAR=0.0
25 3 ▶use Bit::Vector;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 3 ▶use Net::Frame::Layer::ICMPv6::Option;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
29 shift->SUPER::new(
30 1 reserved => 0,
31 options => [],
32 @_,
33 );
34 }
35  
36 0 ▶sub getOptionsLength {
Subroutine getOptionsLength: not called CC=2 SCAR=17.9
Pod documented
37 0 my $self = shift;
38 0 my $len = 0;
39 0 $len += $_->getLength for $self->options;
40 0 return $len;
41 }
42  
43 0 ▶sub getLength {
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
44 0 my $self = shift;
45 0 return 4 + $self->getOptionsLength;
46 }
47  
48 1 ▶sub pack {
Subroutine pack: called CC=3 SCAR=11.7
Pod documented
49 1 my $self = shift;
50  
51 1 ▶ my $raw = $self->SUPER::pack('L', $self->reserved)
Branch: 1 branch
BranchTrueFalseTotal
my $raw = $self->SUPER::pack("L", $self->reserved) or return 1 0 1
52 or return;
53  
54 1 for ($self->options) {
55 0 $raw .= $_->pack;
56 }
57  
58 1 return $self->raw($raw);
59 }
60  
61 0 ▶sub _unpackOptions {
Subroutine _unpackOptions: not called CC=3 SCAR=24.8
62 0 my $self = shift;
63 0 my ($payload) = @_;
64
65 0 my @options = ();
66 0 ▶ while (defined($payload) && length($payload)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $payload and length $payload) 0 0 0
Condition0%0/3
defined $payload and length $payload
!ll&&!rl&&r
000
MC/DC0%0/2
defined $payload and length $payload
defined $payload length $payload
Truth table0%0/3
A and B
A= defined $payloadB= length $payload
ABresult
0X0
100
111
67 0 my $opt = Net::Frame::Layer::ICMPv6::Option->new(raw => $payload)->unpack;
68 0 push @options, $opt;
69 0 $payload = $opt->payload;
70 0 $opt->payload(undef);
71 }
72 0 $self->options(\@options);
73 0 return $payload;
74 }
75  
76 1 ▶sub unpack {
Subroutine unpack: called CC=4 SCAR=15.2
Pod documented
77 1 my $self = shift;
78  
79 1 ▶ my ($reserved, $payload) =
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("L a*", $self->raw) or return 1 0 1
80 $self->SUPER::unpack('L a*', $self->raw)
81 or return;
82  
83 1 $self->reserved($reserved);
84 1 $self->payload($payload);
85  
86 1 ▶ if (defined($payload) && length($payload)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $payload and length $payload) 0 1 1
Condition33%1/3
defined $payload and length $payload
!ll&&!rl&&r
010
MC/DC0%0/2
defined $payload and length $payload
defined $payload length $payload
Truth table33%1/3
A and B
A= defined $payloadB= length $payload
ABresult
0X0
100
111
87 0 $payload = $self->_unpackOptions($payload);
88 }
89  
90 1 $self->payload($payload);
91  
92 1 return $self;
93 }
94  
95 0 ▶sub print {
Subroutine print: not called CC=2 SCAR=17.9
Pod documented
96 0 my $self = shift;
97  
98 0 my $l = $self->layer;
99 0 my $buf = sprintf "$l: reserved: 0x%02x",
100 $self->reserved;
101  
102 0 for ($self->options) {
103 0 $buf .= "\n" . $_->print;
104 }
105  
106 0 return $buf;
107 }
108  
109 3 1;
110  
111 __END__
« ICMPv6/NeighborSolicitation.pm ↑ Summary ICMPv6/NeighborAdvertisement.pm »