LLTD/Hello.pm

filter: Statementstmt 63.7% 37 / 58 Branchbran 37.5% 3 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 63.6% 7 / 11 Podpod 100% 7 / 7 totaltotal 61.8% 55 / 89 CC 9 SCAR 13.3
CC
9
Cov
59%
getTlvListLength
6.0
getLength
6.0
print
6.0
CRAP 3.8
« LLTD/QueryResp.pm ↑ Summary LLTD.pm »
1 #
2 # $Id: Hello.pm 12 2015-01-14 06:29:59Z gomor $
3 #
4 package Net::Frame::Layer::LLTD::Hello;
5 10 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 ▶use Net::Frame::Layer qw(:consts :subs);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 require Exporter;
9 10 our @ISA = qw(Net::Frame::Layer Exporter);
10  
11 10 our @AS = qw(
12 generationNumber
13 currentMapperAddress
14 apparentMapperAddress
15 );
16 10 our @AA = qw(
17 tlvList
18 );
19 10 __PACKAGE__->cgBuildIndices;
20 10 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
21 10 __PACKAGE__->cgBuildAccessorsArray (\@AA);
22  
23 10 ▶use Net::Frame::Layer::LLTD::Tlv;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
26 shift->SUPER::new(
27 1 generationNumber => 0,
28 currentMapperAddress => 'ff:ff:ff:ff:ff:ff',
29 apparentMapperAddress => 'ff:ff:ff:ff:ff:ff',
30 tlvList => [],
31 @_,
32 );
33 }
34  
35 0 ▶sub getTlvListLength {
Subroutine getTlvListLength: not called CC=2 SCAR=17.9
Pod documented
36 0 my $self = shift;
37 0 my $len = 0;
38 0 for ($self->tlvList) {
39 0 $len += $_->getLength;
40 }
41 0 $len;
42 }
43  
44 0 ▶sub getLength {
Subroutine getLength: not called CC=2 SCAR=17.9
Pod documented
45 0 my $self = shift;
46 0 my $len = 14;
47 0 ▶ $len += $self->getTlvListLength if $self->tlvList;
Branch: 1 branch
BranchTrueFalseTotal
if $self->tlvList 0 0 0
48 0 $len;
49 }
50  
51 1 ▶sub pack {
Subroutine pack: called CC=3 SCAR=11.3
Pod documented
52 1 my $self = shift;
53  
54 1 (my $mac1 = $self->currentMapperAddress) =~ s/://g;
55 1 (my $mac2 = $self->apparentMapperAddress) =~ s/://g;
56  
57 1 ▶ my $raw = $self->SUPER::pack('nH12H12',
Branch: 1 branch
BranchTrueFalseTotal
my $raw = $self->SUPER::pack("nH12H12", $self->generationNumber, $mac1, $mac2) or return undef 1 0 1
58 $self->generationNumber,
59 $mac1,
60 $mac2,
61 ) or return undef;
62  
63 1 for ($self->tlvList) {
64 0 $raw .= $_->pack;
65 }
66  
67 1 $self->raw($raw);
68 }
69  
70 1 ▶sub unpack {
Subroutine unpack: called CC=4 SCAR=15.9
Pod documented
71 1 my $self = shift;
72  
73 1 ▶ my ($generationNumber, $mac1, $mac2, $payload) =
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("nH12H12 a*", $self->raw) or return undef 1 0 1
74 $self->SUPER::unpack('nH12H12 a*', $self->raw)
75 or return undef;
76  
77 1 $self->generationNumber($generationNumber);
78 1 $self->currentMapperAddress(convertMac($mac1));
79 1 $self->apparentMapperAddress(convertMac($mac2));
80  
81 1 my @tlvList = ();
82 1 ▶ while ($payload && length($payload) > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($payload and length $payload > 2) 0 1 1
Condition33%1/3
$payload and length $payload > 2
!ll&&!rl&&r
100
MC/DC0%0/2
$payload and length $payload > 2
$payload length $payload > 2
Truth table33%1/3
A and B
A= $payloadB= length $payload > 2
ABresult
0X0
100
111
83 0 my $tlv = Net::Frame::Layer::LLTD::Tlv->new(raw => $payload);
84 0 $tlv->unpack;
85 0 push @tlvList, $tlv;
86 0 $payload = $tlv->payload;
87 }
88  
89 1 $self->tlvList(\@tlvList);
90 1 $self->payload($payload);
91  
92 1 $self;
93 }
94  
95 0 ▶sub encapsulate { shift->nextLayer }
Subroutine encapsulate: not called CC=1 SCAR=6.9
Pod documented
96  
97 0 ▶sub print {
Subroutine print: not called CC=2 SCAR=17.9
Pod documented
98 0 my $self = shift;
99  
100 0 my $l = $self->layer;
101 0 my $buf = sprintf
102 "$l: generationNumber:%d\n".
103 "$l: currentMapperAddress: %s\n".
104 "$l: apparentMapperAddress: %s",
105 $self->generationNumber,
106 $self->currentMapperAddress,
107 $self->apparentMapperAddress;
108  
109 0 for ($self->tlvList) {
110 0 $buf .= "\n".$_->print;
111 }
112  
113 0 $buf;
114 }
115  
116 10 1;
117  
118 __END__
« LLTD/QueryResp.pm ↑ Summary LLTD.pm »