MLD/Query.pm

filter: Statementstmt 84.6% 55 / 65 Branchbran 41.6% 5 / 12 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 90.9% 10 / 11 Podpod 100% 7 / 7 totaltotal 74.2% 78 / 105 CC 13 SCAR 13.0
CC
13
Cov
73%
unpack
6.8
getLength
6.0
encapsulate
3.3
CRAP 3.7
« MLD/Report/Record.pm ↑ Summary MLD/Report.pm »
1 #
2 # $Id: Query.pm 49 2009-05-31 13:15:34Z VinsWorldcom $
3 #
4 package Net::Frame::Layer::ICMPv6::MLD::Query;
5 5 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use Net::Frame::Layer qw(:consts :subs);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 our @ISA = qw(Net::Frame::Layer);
9  
10 5 our @AS = qw(
11 resv
12 sFlag
13 qrv
14 qqic
15 numSources
16 );
17 5 our @AA = qw(
18 sourceAddress
19 );
20 5 __PACKAGE__->cgBuildIndices;
21 5 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
22 5 __PACKAGE__->cgBuildAccessorsArray(\@AA);
23  
24 #no strict 'vars';
25  
26 5 ▶use Bit::Vector;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
29 shift->SUPER::new(
30 2 resv => 0,
31 sFlag => 0,
32 qrv => 2,
33 qqic => 125,
34 numSources => 0,
35 sourceAddress => [],
36 @_,
37 );
38 }
39  
40 0 ▶sub getLength {
Subroutine getLength: not called CC=2 SCAR=17.9
Pod documented
41 0 my $self = shift;
42 0 my $len = 4;
43 0 $len += 16 for $self->sourceAddress;
44 0 return $len;
45 }
46  
47 1 ▶sub pack {
Subroutine pack: called CC=3 SCAR=11.2
Pod documented
48 1 my $self = shift;
49  
50 1 my $resv = Bit::Vector->new_Dec(4, $self->resv);
51 1 my $sFlag = Bit::Vector->new_Dec(1, $self->sFlag);
52 1 my $qrv = Bit::Vector->new_Dec(3, $self->qrv);
53 1 my $bvlist = $resv->Concat_List($sFlag, $qrv);
54  
55 1 ▶ my $raw = $self->SUPER::pack('CCn',
Branch: 1 branch
BranchTrueFalseTotal
my $raw = $self->SUPER::pack("CCn", $bvlist->to_Dec, $self->qqic, $self->numSources) or return 1 0 1
56 $bvlist->to_Dec,
57 $self->qqic,
58 $self->numSources
59 ) or return;
60  
61 1 for ($self->sourceAddress) {
62 0 $raw .= inet6Aton($_);
63 }
64  
65 1 return $self->raw($raw);
66 }
67  
68 1 ▶sub unpack {
Subroutine unpack: called CC=5 SCAR=19.2
Pod documented
69 1 my $self = shift;
70  
71 1 ▶ my ($bv, $qqic, $numSources, $payload) =
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("CCn a*", $self->raw) or return 1 0 1
72 $self->SUPER::unpack('CCn a*', $self->raw)
73 or return;
74  
75 1 my $bvlist = Bit::Vector->new_Dec(8, $bv);
76 1 $self->resv ($bvlist->Chunk_Read(4, 4));
77 1 $self->sFlag ($bvlist->Chunk_Read(1, 3));
78 1 $self->qrv ($bvlist->Chunk_Read(3, 0));
79  
80 1 $self->qqic($qqic);
81 1 $self->numSources($numSources);
82  
83 1 my @sourceAddress = ();
84 1 for my $num (0..$numSources-1) {
85 0 ▶ if (defined($payload) && (length($payload) >= 16)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $payload and length $payload >= 16) 0 0 0
Condition0%0/3
defined $payload and length $payload >= 16
!ll&&!rl&&r
000
MC/DC0%0/2
defined $payload and length $payload >= 16
defined $payload length $payload >= 16
Truth table0%0/3
A and B
A= defined $payloadB= length $payload >= 16
ABresult
0X0
100
111
86 0 my $addr = unpack 'a16', $payload;
87 0 push @sourceAddress, inet6Ntoa($addr);
88 0 $payload = substr $payload, 16;
89 }
90 }
91 1 $self->sourceAddress(\@sourceAddress);
92  
93 1 $self->payload($payload);
94  
95 1 return $self;
96 }
97  
98 1 ▶sub encapsulate {
Subroutine encapsulate: called CC=3 SCAR=12.0
Pod documented
99 1 my $self = shift;
100  
101 1 ▶ return $self->nextLayer if $self->nextLayer;
Branch: 1 branch
BranchTrueFalseTotal
if $self->nextLayer 0 1 1
102  
103 1 ▶ if ($self->payload) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->payload) 0 1 1
104 0 return 'ICMPv6::MLD::Query';
105 }
106  
107 1 NF_LAYER_NONE;
108 }
109  
110 1 ▶sub computeLengths {
Subroutine computeLengths: called CC=3 SCAR=12.0
Pod documented
111 1 my $self = shift;
112  
113 # Calculate numSources from sourceAddress array items
114 1 ▶ if (scalar($self->sourceAddress) && ($self->numSources == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar $self->sourceAddress and $self->numSources == 0) 1 0 1
Condition33%1/3
scalar $self->sourceAddress and $self->numSources == 0
!ll&&!rl&&r
001
MC/DC0%0/2
scalar $self->sourceAddress and $self->numSources == 0
scalar $self->sourceAddress $self->numSources == 0
Truth table33%1/3
A and B
A= scalar $self->sourceAddressB= $self->numSources == 0
ABresult
0X0
100
111
115 1 $self->numSources(scalar($self->sourceAddress))
116 }
117  
118 1 return 1;
119 }
120  
121 3 ▶sub print {
Subroutine print: called CC=2 SCAR=6.9
Pod documented
122 3 my $self = shift;
123  
124 3 my $l = $self->layer;
125 3 my $buf = sprintf
126 "$l: resv:%d sFlag:%d qrv:%d qqic:%d numSources:%d",
127 $self->resv, $self->sFlag, $self->qrv, $self->qqic, $self->numSources;
128  
129 3 for ($self->sourceAddress) {
130 2 $buf .= sprintf
131 "\n$l: sourceAddress:%s",
132 $_
133 }
134  
135 3 return $buf;
136 }
137  
138 5 1;
139  
140 __END__
« MLD/Report/Record.pm ↑ Summary MLD/Report.pm »