LLTD/Discover.pm

filter: Statementstmt 64.1% 34 / 53 Branchbran 30.0% 3 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 63.6% 7 / 11 Podpod 100% 7 / 7 totaltotal 60.4% 52 / 86 CC 11 SCAR 16.9
CC
11
Cov
58%
unpack
9.4
getStationListLength
6.0
pack
6.0
CRAP 5.4
↑ Summary LLTD/Emit.pm »
1 #
2 # $Id: Discover.pm 12 2015-01-14 06:29:59Z gomor $
3 #
4 package Net::Frame::Layer::LLTD::Discover;
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);
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 numberOfStations
14 );
15 10 our @AA = qw(
16 stationList
17 );
18 10 __PACKAGE__->cgBuildIndices;
19 10 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
20 10 __PACKAGE__->cgBuildAccessorsArray (\@AA);
21  
22 10 ▶use Net::Frame::Layer qw(:subs);
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
25 shift->SUPER::new(
26 2 generationNumber => 0,
27 numberOfStations => 0,
28 stationList => [],
29 @_,
30 );
31 }
32  
33 0 ▶sub getStationListLength {
Subroutine getStationListLength: not called CC=2 SCAR=17.9
Pod documented
34 0 my $self = shift;
35 0 my $len = 0;
36 0 for ($self->stationList) {
37 0 $len += 6;
38 }
39 0 $len;
40 }
41  
42 0 ▶sub getLength { 4 + shift->getStationListLength }
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
43  
44 1 ▶sub pack {
Subroutine pack: called CC=4 SCAR=17.9
Pod documented
45 1 my $self = shift;
46  
47 1 ▶ my $raw = $self->SUPER::pack('nn',
Branch: 1 branch
BranchTrueFalseTotal
my $raw = $self->SUPER::pack("nn", $self->generationNumber, $self->numberOfStations) or return undef 1 0 1
48 $self->generationNumber,
49 $self->numberOfStations,
50 ) or return undef;
51  
52 1 for ($self->stationList) {
53 0 s/://g;
54 0 ▶ $raw .= $self->SUPER::pack('H12', $_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$raw .= $self->SUPER::pack("H12", $_) or return undef 0 0 0
55 }
56  
57 1 $self->raw($raw);
58 }
59  
60 2 ▶sub unpack {
Subroutine unpack: called CC=6 SCAR=22.4
Pod documented
61 2 my $self = shift;
62  
63 2 ▶ my ($generationNumber, $numberOfStations, $tail) =
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("nn a*", $self->raw) or return undef 2 0 2
64 $self->SUPER::unpack('nn a*', $self->raw)
65 or return undef;
66  
67 2 $self->generationNumber($generationNumber);
68 2 $self->numberOfStations($numberOfStations);
69  
70 2 my @stationList = ();
71 2 ▶ if ($self->numberOfStations && $self->numberOfStations > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->numberOfStations and $self->numberOfStations > 0) 0 2 2
Condition33%1/3
$self->numberOfStations and $self->numberOfStations > 0
!ll&&!rl&&r
200
MC/DC0%0/2
$self->numberOfStations and $self->numberOfStations > 0
$self->numberOfStations $self->numberOfStations > 0
Truth table33%1/3
A and B
A= $self->numberOfStationsB= $self->numberOfStations > 0
ABresult
0X0
100
111
72 0 for (1..$self->numberOfStations) {
73 0 my $mac;
74 0 ▶ ($mac, $tail) = $self->SUPER::unpack('H12 a*', $tail)
Branch: 1 branch
BranchTrueFalseTotal
($mac, $tail) = $self->SUPER::unpack("H12 a*", $tail) or return undef 0 0 0
75 or return undef;
76 0 push @stationList, convertMac($mac);
77 }
78 }
79  
80 2 $self->stationList(\@stationList);
81 2 $self->payload($tail);
82  
83 2 $self;
84 }
85  
86 0 ▶sub encapsulate { shift->nextLayer }
Subroutine encapsulate: not called CC=1 SCAR=6.9
Pod documented
87  
88 0 ▶sub print {
Subroutine print: not called CC=2 SCAR=17.9
Pod documented
89 0 my $self = shift;
90  
91 0 my $l = $self->layer;
92 0 my $buf .= sprintf "$l: generationNumber:%d numberOfStations:%d",
93 $self->generationNumber,
94 $self->numberOfStations;
95  
96 0 for my $s ($self->stationList) {
97 0 $buf .= sprintf "\n$l: station: %s", $s;
98 }
99  
100 0 $buf;
101 }
102  
103 10 1;
104  
105 __END__
↑ Summary LLTD/Emit.pm »