blib/lib/Net/Frame/Layer/STP.pm

filter: Statementstmt 91.8% 56 / 61 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 76.9% 10 / 13 Podpod 100% 6 / 6 totaltotal 88.1% 74 / 84 CC 3 SCAR 3.8
CC
3
Cov
89%
pack
2.0
unpack
2.0
getLength
2.0
CRAP 1.5
↑ Summary
1 #
2 # $Id: STP.pm 8 2015-01-14 06:55:14Z gomor $
3 #
4 package Net::Frame::Layer::STP;
5 3 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 our $VERSION = '1.02';
8  
9 3 ▶use Net::Frame::Layer qw(:consts);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 our @ISA = qw(Net::Frame::Layer Exporter);
12  
13 3 our %EXPORT_TAGS = (
14 consts => [qw(
15 NF_STP_HDR_LEN
16 NF_STP_PROTOCOL_IDENTIFIER_STP
17 )],
18 );
19 our @EXPORT_OK = (
20 3 @{$EXPORT_TAGS{consts}},
21 );
22  
23 3 ▶use constant NF_STP_HDR_LEN => 42;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 3 ▶use constant NF_STP_PROTOCOL_IDENTIFIER_STP => 0x0000;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 3 our @AS = qw(
27 protocolIdentifier
28 protocolVersionIdentifier
29 bpduType
30 bpduFlags
31 rootIdentifier
32 rootPathCost
33 bridgeIdentifier
34 portIdentifier
35 messageAge
36 maxAge
37 helloTime
38 forwardDelay
39 );
40 3 __PACKAGE__->cgBuildIndices;
41 3 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
42  
43 3 ▶use Net::Frame::Layer qw(:subs);
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
46 shift->SUPER::new(
47 1 protocolIdentifier => NF_STP_PROTOCOL_IDENTIFIER_STP,
48 protocolVersionIdentifier => 0,
49 bpduType => 0x00,
50 bpduFlags => 0x00,
51 rootIdentifier => '1/00:11:22:33:44:55',
52 rootPathCost => 1,
53 bridgeIdentifier => '2/11:22:33:44:55:66',
54 portIdentifier => 0x0001,
55 messageAge => 1,
56 maxAge => 10,
57 helloTime => 1,
58 forwardDelay => 10,
59 @_,
60 );
61 }
62  
63 0 ▶sub getLength { NF_STP_HDR_LEN }
Subroutine getLength: not called CC=1 SCAR=6.9
Pod documented
64  
65 1 ▶sub pack {
Subroutine pack: called CC=2 SCAR=7.0
Pod documented
66 1 my $self = shift;
67  
68 1 my ($root, $id1) = split('\s*/\s*', $self->rootIdentifier);
69 1 my ($bridge, $id2) = split('\s*/\s*', $self->bridgeIdentifier);
70  
71 1 $id1 =~ s/://g;
72 1 $id2 =~ s/://g;
73  
74 1 ▶ $self->raw($self->SUPER::pack('nCCCnH12NnH12nvvvv',
Branch: 1 branch
BranchTrueFalseTotal
$self->raw($self->SUPER::pack("nCCCnH12NnH12nvvvv", $self->protocolIdentifier, $self->protocolVersionIdentifier, $self->bpduType, $self->bpduFlags, $root, $id1, $self->rootPathCost, $bridge, $id2, $self->portIdentifier, $self->messageAge, $self->maxAge, $self->helloTime, $self->forwardDelay)) or return undef 1 0 1
75 $self->protocolIdentifier, $self->protocolVersionIdentifier,
76 $self->bpduType, $self->bpduFlags, $root, $id1, $self->rootPathCost,
77 $bridge, $id2, $self->portIdentifier, $self->messageAge, $self->maxAge,
78 $self->helloTime, $self->forwardDelay)
79 ) or return undef;
80  
81 1 $self->raw;
82 }
83  
84 1 ▶sub unpack {
Subroutine unpack: called CC=2 SCAR=6.9
Pod documented
85 1 my $self = shift;
86  
87 1 ▶ my ($protocolIdentifier, $protocolVersionIdentifier, $bpduType, $bpduFlags,
Branch: 1 branch
BranchTrueFalseTotal
() = $self->SUPER::unpack("nCCCnH12NnH12nvvvv a*", $self->raw) or return undef 1 0 1
88 $root, $identifier1, $rootPathCost, $bridge, $identifier2,
89 $portIdentifier, $messageAge, $maxAge, $helloTime, $forwardDelay,
90 $payload) = $self->SUPER::unpack('nCCCnH12NnH12nvvvv a*', $self->raw)
91 or return undef;
92  
93 1 my $id1 = $root.'/'.convertMac($identifier1);
94 1 my $id2 = $bridge.'/'.convertMac($identifier2);
95 1 $self->rootIdentifier($id1);
96 1 $self->bridgeIdentifier($id2);
97  
98 1 $self->protocolIdentifier($protocolIdentifier);
99 1 $self->protocolVersionIdentifier($protocolVersionIdentifier);
100 1 $self->bpduType($bpduType);
101 1 $self->bpduFlags($bpduFlags);
102 1 $self->rootPathCost($rootPathCost);
103 1 $self->portIdentifier($portIdentifier);
104 1 $self->messageAge($messageAge);
105 1 $self->maxAge($maxAge);
106 1 $self->helloTime($helloTime);
107 1 $self->forwardDelay($forwardDelay);
108  
109 1 $self->payload($payload);
110  
111 1 $self;
112 }
113  
114 0 ▶sub encapsulate { shift->nextLayer }
Subroutine encapsulate: not called CC=1 SCAR=6.9
Pod documented
115  
116 0 ▶sub print {
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
117 0 my $self = shift;
118  
119 0 my $l = $self->layer;
120 0 sprintf "$l: protocolIdentifier:0x%04x protocolVersionIdentifier:%d\n".
121 "$l: bpduType:0x%02x bpduFlags:0x%02x\n".
122 "$l: rootIdentifier:%s rootPathCost:%d\n".
123 "$l: bridgeIdentifier:%s portIdentifier:0x%04x\n".
124 "$l: messageAge:%d maxAge:%d helloTime:%d forwardDelay:%d",
125 $self->protocolIdentifier, $self->protocolVersionIdentifier,
126 $self->bpduType, $self->bpduFlags, $self->rootIdentifier,
127 $self->rootPathCost, $self->bridgeIdentifier,
128 $self->portIdentifier, $self->messageAge, $self->maxAge,
129 $self->helloTime, $self->forwardDelay;
130 }
131  
132 3 1;
133  
134 __END__
↑ Summary