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