line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: STP.pm,v 1.2 2007/01/04 23:30:34 gomor Exp $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::STP; |
5
|
2
|
|
|
2
|
|
25979
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
109
|
|
6
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
125
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
2144
|
use Net::Frame::Layer qw(:consts); |
|
2
|
|
|
|
|
215997
|
|
|
2
|
|
|
|
|
623
|
|
11
|
|
|
|
|
|
|
require Exporter; |
12
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer Exporter); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
15
|
|
|
|
|
|
|
consts => [qw( |
16
|
|
|
|
|
|
|
NF_STP_HDR_LEN |
17
|
|
|
|
|
|
|
NF_STP_PROTOCOL_IDENTIFIER_STP |
18
|
|
|
|
|
|
|
)], |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
21
|
|
|
|
|
|
|
@{$EXPORT_TAGS{consts}}, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
2
|
|
21
|
use constant NF_STP_HDR_LEN => 42; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
130
|
|
25
|
2
|
|
|
2
|
|
10
|
use constant NF_STP_PROTOCOL_IDENTIFIER_STP => 0x0000; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
166
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our @AS = qw( |
28
|
|
|
|
|
|
|
protocolIdentifier |
29
|
|
|
|
|
|
|
protocolVersionIdentifier |
30
|
|
|
|
|
|
|
bpduType |
31
|
|
|
|
|
|
|
bpduFlags |
32
|
|
|
|
|
|
|
rootIdentifier |
33
|
|
|
|
|
|
|
rootPathCost |
34
|
|
|
|
|
|
|
bridgeIdentifier |
35
|
|
|
|
|
|
|
portIdentifier |
36
|
|
|
|
|
|
|
messageAge |
37
|
|
|
|
|
|
|
maxAge |
38
|
|
|
|
|
|
|
helloTime |
39
|
|
|
|
|
|
|
forwardDelay |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
42
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
2
|
|
11
|
use Net::Frame::Layer qw(:subs); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
1659
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub new { |
47
|
|
|
|
|
|
|
shift->SUPER::new( |
48
|
1
|
|
|
1
|
1
|
30
|
protocolIdentifier => NF_STP_PROTOCOL_IDENTIFIER_STP, |
49
|
|
|
|
|
|
|
protocolVersionIdentifier => 0, |
50
|
|
|
|
|
|
|
bpduType => 0x00, |
51
|
|
|
|
|
|
|
bpduFlags => 0x00, |
52
|
|
|
|
|
|
|
rootIdentifier => '1/00:11:22:33:44:55', |
53
|
|
|
|
|
|
|
rootPathCost => 1, |
54
|
|
|
|
|
|
|
bridgeIdentifier => '2/11:22:33:44:55:66', |
55
|
|
|
|
|
|
|
portIdentifier => 0x0001, |
56
|
|
|
|
|
|
|
messageAge => 1, |
57
|
|
|
|
|
|
|
maxAge => 10, |
58
|
|
|
|
|
|
|
helloTime => 1, |
59
|
|
|
|
|
|
|
forwardDelay => 10, |
60
|
|
|
|
|
|
|
@_, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
0
|
1
|
0
|
sub getLength { NF_STP_HDR_LEN } |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub pack { |
67
|
1
|
|
|
1
|
1
|
416
|
my $self = shift; |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
6
|
my ($root, $id1) = split('\s*/\s*', $self->rootIdentifier); |
70
|
1
|
|
|
|
|
37
|
my ($bridge, $id2) = split('\s*/\s*', $self->bridgeIdentifier); |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
17
|
$id1 =~ s/://g; |
73
|
1
|
|
|
|
|
4
|
$id2 =~ s/://g; |
74
|
|
|
|
|
|
|
|
75
|
1
|
50
|
|
|
|
6
|
$self->raw($self->SUPER::pack('nCCCnH12NnH12nvvvv', |
76
|
|
|
|
|
|
|
$self->protocolIdentifier, $self->protocolVersionIdentifier, |
77
|
|
|
|
|
|
|
$self->bpduType, $self->bpduFlags, $root, $id1, $self->rootPathCost, |
78
|
|
|
|
|
|
|
$bridge, $id2, $self->portIdentifier, $self->messageAge, $self->maxAge, |
79
|
|
|
|
|
|
|
$self->helloTime, $self->forwardDelay) |
80
|
|
|
|
|
|
|
) or return undef; |
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
118
|
$self->raw; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub unpack { |
86
|
1
|
|
|
1
|
1
|
12
|
my $self = shift; |
87
|
|
|
|
|
|
|
|
88
|
1
|
50
|
|
|
|
3
|
my ($protocolIdentifier, $protocolVersionIdentifier, $bpduType, $bpduFlags, |
89
|
|
|
|
|
|
|
$root, $identifier1, $rootPathCost, $bridge, $identifier2, |
90
|
|
|
|
|
|
|
$portIdentifier, $messageAge, $maxAge, $helloTime, $forwardDelay, |
91
|
|
|
|
|
|
|
$payload) = $self->SUPER::unpack('nCCCnH12NnH12nvvvv a*', $self->raw) |
92
|
|
|
|
|
|
|
or return undef; |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
37
|
my $id1 = $root.'/'.convertMac($identifier1); |
95
|
1
|
|
|
|
|
14
|
my $id2 = $bridge.'/'.convertMac($identifier2); |
96
|
1
|
|
|
|
|
12
|
$self->rootIdentifier($id1); |
97
|
1
|
|
|
|
|
11
|
$self->bridgeIdentifier($id2); |
98
|
|
|
|
|
|
|
|
99
|
1
|
|
|
|
|
12
|
$self->protocolIdentifier($protocolIdentifier); |
100
|
1
|
|
|
|
|
11
|
$self->protocolVersionIdentifier($protocolVersionIdentifier); |
101
|
1
|
|
|
|
|
11
|
$self->bpduType($bpduType); |
102
|
1
|
|
|
|
|
11
|
$self->bpduFlags($bpduFlags); |
103
|
1
|
|
|
|
|
10
|
$self->rootPathCost($rootPathCost); |
104
|
1
|
|
|
|
|
9
|
$self->portIdentifier($portIdentifier); |
105
|
1
|
|
|
|
|
10
|
$self->messageAge($messageAge); |
106
|
1
|
|
|
|
|
10
|
$self->maxAge($maxAge); |
107
|
1
|
|
|
|
|
10
|
$self->helloTime($helloTime); |
108
|
1
|
|
|
|
|
9
|
$self->forwardDelay($forwardDelay); |
109
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
13
|
$self->payload($payload); |
111
|
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
9
|
$self; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
0
|
1
|
|
sub encapsulate { shift->nextLayer } |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub print { |
118
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
my $l = $self->layer; |
121
|
0
|
|
|
|
|
|
sprintf "$l: protocolIdentifier:0x%04x protocolVersionIdentifier:%d\n". |
122
|
|
|
|
|
|
|
"$l: bpduType:0x%02x bpduFlags:0x%02x\n". |
123
|
|
|
|
|
|
|
"$l: rootIdentifier:%s rootPathCost:%d\n". |
124
|
|
|
|
|
|
|
"$l: bridgeIdentifier:%s portIdentifier:0x%04x\n". |
125
|
|
|
|
|
|
|
"$l: messageAge:%d maxAge:%d helloTime:%d forwardDelay:%d", |
126
|
|
|
|
|
|
|
$self->protocolIdentifier, $self->protocolVersionIdentifier, |
127
|
|
|
|
|
|
|
$self->bpduType, $self->bpduFlags, $self->rootIdentifier, |
128
|
|
|
|
|
|
|
$self->rootPathCost, $self->bridgeIdentifier, |
129
|
|
|
|
|
|
|
$self->portIdentifier, $self->messageAge, $self->maxAge, |
130
|
|
|
|
|
|
|
$self->helloTime, $self->forwardDelay; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
__END__ |