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