line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: 8021Q.pm 7 2010-06-03 12:35:18Z gomor $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::8021Q; |
5
|
2
|
|
|
2
|
|
40815
|
use strict; use warnings; |
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
|
|
88
|
|
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
112
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
3106
|
use Net::Frame::Layer qw(:consts); |
|
2
|
|
|
|
|
287360
|
|
|
2
|
|
|
|
|
1148
|
|
10
|
2
|
|
|
2
|
|
27
|
use Exporter; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
3756
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer Exporter); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
14
|
|
|
|
|
|
|
consts => [qw( |
15
|
|
|
|
|
|
|
NF_8021Q_HDR_LEN |
16
|
|
|
|
|
|
|
NF_8021Q_TYPE_IPv4 |
17
|
|
|
|
|
|
|
NF_8021Q_TYPE_X25 |
18
|
|
|
|
|
|
|
NF_8021Q_TYPE_ARP |
19
|
|
|
|
|
|
|
NF_8021Q_TYPE_CGMP |
20
|
|
|
|
|
|
|
NF_8021Q_TYPE_80211 |
21
|
|
|
|
|
|
|
NF_8021Q_TYPE_PPPIPCP |
22
|
|
|
|
|
|
|
NF_8021Q_TYPE_RARP |
23
|
|
|
|
|
|
|
NF_8021Q_TYPE_DDP |
24
|
|
|
|
|
|
|
NF_8021Q_TYPE_AARP |
25
|
|
|
|
|
|
|
NF_8021Q_TYPE_PPPCCP |
26
|
|
|
|
|
|
|
NF_8021Q_TYPE_WCP |
27
|
|
|
|
|
|
|
NF_8021Q_TYPE_8021Q |
28
|
|
|
|
|
|
|
NF_8021Q_TYPE_IPX |
29
|
|
|
|
|
|
|
NF_8021Q_TYPE_STP |
30
|
|
|
|
|
|
|
NF_8021Q_TYPE_IPv6 |
31
|
|
|
|
|
|
|
NF_8021Q_TYPE_WLCCP |
32
|
|
|
|
|
|
|
NF_8021Q_TYPE_MPLS |
33
|
|
|
|
|
|
|
NF_8021Q_TYPE_PPPoED |
34
|
|
|
|
|
|
|
NF_8021Q_TYPE_PPPoES |
35
|
|
|
|
|
|
|
NF_8021Q_TYPE_8021X |
36
|
|
|
|
|
|
|
NF_8021Q_TYPE_AoE |
37
|
|
|
|
|
|
|
NF_8021Q_TYPE_80211I |
38
|
|
|
|
|
|
|
NF_8021Q_TYPE_LLDP |
39
|
|
|
|
|
|
|
NF_8021Q_TYPE_LLTD |
40
|
|
|
|
|
|
|
NF_8021Q_TYPE_LOOP |
41
|
|
|
|
|
|
|
NF_8021Q_TYPE_VLAN |
42
|
|
|
|
|
|
|
NF_8021Q_TYPE_PPPPAP |
43
|
|
|
|
|
|
|
NF_8021Q_TYPE_PPPCHAP |
44
|
|
|
|
|
|
|
)], |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
47
|
|
|
|
|
|
|
@{$EXPORT_TAGS{consts}}, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
2
|
|
|
2
|
|
2209
|
use constant NF_8021Q_HDR_LEN => 4; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
248
|
|
51
|
2
|
|
|
2
|
|
14
|
use constant NF_8021Q_TYPE_IPv4 => 0x0800; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
583
|
|
52
|
2
|
|
|
2
|
|
13
|
use constant NF_8021Q_TYPE_X25 => 0x0805; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
86
|
|
53
|
2
|
|
|
2
|
|
12
|
use constant NF_8021Q_TYPE_ARP => 0x0806; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
552
|
|
54
|
2
|
|
|
2
|
|
13
|
use constant NF_8021Q_TYPE_CGMP => 0x2001; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
96
|
|
55
|
2
|
|
|
2
|
|
20
|
use constant NF_8021Q_TYPE_80211 => 0x2452; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
120
|
|
56
|
2
|
|
|
2
|
|
10
|
use constant NF_8021Q_TYPE_PPPIPCP => 0x8021; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
72
|
|
57
|
2
|
|
|
2
|
|
10
|
use constant NF_8021Q_TYPE_RARP => 0x8035; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
95
|
|
58
|
2
|
|
|
2
|
|
9
|
use constant NF_8021Q_TYPE_DDP => 0x809b; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
750
|
|
59
|
2
|
|
|
2
|
|
25
|
use constant NF_8021Q_TYPE_AARP => 0x80f3; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
151
|
|
60
|
2
|
|
|
2
|
|
11
|
use constant NF_8021Q_TYPE_PPPCCP => 0x80fd; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
77
|
|
61
|
2
|
|
|
2
|
|
8
|
use constant NF_8021Q_TYPE_WCP => 0x80ff; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
90
|
|
62
|
2
|
|
|
2
|
|
10
|
use constant NF_8021Q_TYPE_8021Q => 0x8100; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
78
|
|
63
|
2
|
|
|
2
|
|
9
|
use constant NF_8021Q_TYPE_IPX => 0x8137; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
531
|
|
64
|
2
|
|
|
2
|
|
15
|
use constant NF_8021Q_TYPE_STP => 0x8181; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
663
|
|
65
|
2
|
|
|
2
|
|
26
|
use constant NF_8021Q_TYPE_IPv6 => 0x86dd; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
107
|
|
66
|
2
|
|
|
2
|
|
11
|
use constant NF_8021Q_TYPE_WLCCP => 0x872d; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
195
|
|
67
|
2
|
|
|
2
|
|
13
|
use constant NF_8021Q_TYPE_MPLS => 0x8847; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
107
|
|
68
|
2
|
|
|
2
|
|
12
|
use constant NF_8021Q_TYPE_PPPoED => 0x8863; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
267
|
|
69
|
2
|
|
|
2
|
|
11
|
use constant NF_8021Q_TYPE_PPPoES => 0x8864; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
260
|
|
70
|
2
|
|
|
2
|
|
11
|
use constant NF_8021Q_TYPE_8021X => 0x888e; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
89
|
|
71
|
2
|
|
|
2
|
|
11
|
use constant NF_8021Q_TYPE_AoE => 0x88a2; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
87
|
|
72
|
2
|
|
|
2
|
|
11
|
use constant NF_8021Q_TYPE_80211I => 0x88c7; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
106
|
|
73
|
2
|
|
|
2
|
|
10
|
use constant NF_8021Q_TYPE_LLDP => 0x88cc; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
90
|
|
74
|
2
|
|
|
2
|
|
9
|
use constant NF_8021Q_TYPE_LLTD => 0x88d9; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
678
|
|
75
|
2
|
|
|
2
|
|
13
|
use constant NF_8021Q_TYPE_LOOP => 0x9000; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
99
|
|
76
|
2
|
|
|
2
|
|
10
|
use constant NF_8021Q_TYPE_VLAN => 0x9100; |
|
2
|
|
|
|
|
25
|
|
|
2
|
|
|
|
|
80
|
|
77
|
2
|
|
|
2
|
|
9
|
use constant NF_8021Q_TYPE_PPPPAP => 0xc023; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
72
|
|
78
|
2
|
|
|
2
|
|
9
|
use constant NF_8021Q_TYPE_PPPCHAP => 0xc223; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
204
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
our @AS = qw( |
81
|
|
|
|
|
|
|
priority |
82
|
|
|
|
|
|
|
cfi |
83
|
|
|
|
|
|
|
id |
84
|
|
|
|
|
|
|
type |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
87
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
88
|
|
|
|
|
|
|
|
89
|
2
|
|
|
2
|
|
11
|
no strict 'vars'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
13371
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
require Bit::Vector; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub new { |
94
|
|
|
|
|
|
|
shift->SUPER::new( |
95
|
1
|
|
|
1
|
1
|
33
|
priority => 0, |
96
|
|
|
|
|
|
|
cfi => 0, |
97
|
|
|
|
|
|
|
id => 0, |
98
|
|
|
|
|
|
|
type => NF_8021Q_TYPE_IPv4, |
99
|
|
|
|
|
|
|
@_, |
100
|
|
|
|
|
|
|
); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
0
|
1
|
0
|
sub getLength { NF_8021Q_HDR_LEN } |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub pack { |
106
|
1
|
|
|
1
|
1
|
559
|
my $self = shift; |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
49
|
my $v3 = Bit::Vector->new_Dec( 3, $self->[$__priority]); |
109
|
1
|
|
|
|
|
9
|
my $v1 = Bit::Vector->new_Dec( 1, $self->[$__cfi]); |
110
|
1
|
|
|
|
|
6
|
my $v12 = Bit::Vector->new_Dec(12, $self->[$__id]); |
111
|
1
|
|
|
|
|
15
|
my $v16 = $v3->Concat_List($v1, $v12); |
112
|
|
|
|
|
|
|
|
113
|
1
|
50
|
|
|
|
18
|
$self->[$__raw] = $self->SUPER::pack('nn', |
114
|
|
|
|
|
|
|
$v16->to_Dec, |
115
|
|
|
|
|
|
|
$self->[$__type], |
116
|
|
|
|
|
|
|
) or return undef; |
117
|
|
|
|
|
|
|
|
118
|
1
|
|
|
|
|
30
|
$self->[$__raw]; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub unpack { |
122
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
123
|
|
|
|
|
|
|
|
124
|
1
|
50
|
|
|
|
10
|
my ($pCfiId, $type, $payload) = |
125
|
|
|
|
|
|
|
$self->SUPER::unpack('nn a*', $self->[$__raw]) |
126
|
|
|
|
|
|
|
or return undef; |
127
|
|
|
|
|
|
|
|
128
|
1
|
|
|
|
|
24
|
my $v16 = Bit::Vector->new_Dec(16, $pCfiId); |
129
|
|
|
|
|
|
|
|
130
|
1
|
|
|
|
|
99
|
$self->[$__priority] = $v16->Chunk_Read( 3, 13); |
131
|
1
|
|
|
|
|
7
|
$self->[$__cfi] = $v16->Chunk_Read( 1, 12); |
132
|
1
|
|
|
|
|
6
|
$self->[$__id] = $v16->Chunk_Read(12, 0); |
133
|
1
|
|
|
|
|
2
|
$self->[$__type] = $type; |
134
|
1
|
|
|
|
|
3
|
$self->[$__payload] = $payload; |
135
|
|
|
|
|
|
|
|
136
|
1
|
|
|
|
|
7
|
$self; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub encapsulate { |
140
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
141
|
|
|
|
|
|
|
|
142
|
0
|
0
|
|
|
|
|
return $self->[$__nextLayer] if $self->[$__nextLayer]; |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
my $types = { |
145
|
|
|
|
|
|
|
NF_8021Q_TYPE_IPv4() => 'IPv4', |
146
|
|
|
|
|
|
|
NF_8021Q_TYPE_X25() => 'X25', |
147
|
|
|
|
|
|
|
NF_8021Q_TYPE_ARP() => 'ARP', |
148
|
|
|
|
|
|
|
NF_8021Q_TYPE_CGMP() => 'CGMP', |
149
|
|
|
|
|
|
|
NF_8021Q_TYPE_80211() => '80211', |
150
|
|
|
|
|
|
|
NF_8021Q_TYPE_PPPIPCP() => 'PPPIPCP', |
151
|
|
|
|
|
|
|
NF_8021Q_TYPE_RARP() => 'RARP', |
152
|
|
|
|
|
|
|
NF_8021Q_TYPE_DDP() => 'DDP', |
153
|
|
|
|
|
|
|
NF_8021Q_TYPE_AARP() => 'AARP', |
154
|
|
|
|
|
|
|
NF_8021Q_TYPE_PPPCCP() => 'PPPCCP', |
155
|
|
|
|
|
|
|
NF_8021Q_TYPE_WCP() => 'WCP', |
156
|
|
|
|
|
|
|
NF_8021Q_TYPE_8021Q() => '8021Q', |
157
|
|
|
|
|
|
|
NF_8021Q_TYPE_IPX() => 'IPX', |
158
|
|
|
|
|
|
|
NF_8021Q_TYPE_STP() => 'STP', |
159
|
|
|
|
|
|
|
NF_8021Q_TYPE_IPv6() => 'IPv6', |
160
|
|
|
|
|
|
|
NF_8021Q_TYPE_WLCCP() => 'WLCCP', |
161
|
|
|
|
|
|
|
NF_8021Q_TYPE_MPLS() => 'MPLS', |
162
|
|
|
|
|
|
|
NF_8021Q_TYPE_PPPoED() => 'PPPoED', |
163
|
|
|
|
|
|
|
NF_8021Q_TYPE_PPPoES() => 'PPPoES', |
164
|
|
|
|
|
|
|
NF_8021Q_TYPE_8021X() => '8021X', |
165
|
|
|
|
|
|
|
NF_8021Q_TYPE_AoE() => 'AoE', |
166
|
|
|
|
|
|
|
NF_8021Q_TYPE_80211I() => '80211I', |
167
|
|
|
|
|
|
|
NF_8021Q_TYPE_LLDP() => 'LLDP', |
168
|
|
|
|
|
|
|
NF_8021Q_TYPE_LLTD() => 'LLTD', |
169
|
|
|
|
|
|
|
NF_8021Q_TYPE_LOOP() => 'LOOP', |
170
|
|
|
|
|
|
|
NF_8021Q_TYPE_VLAN() => 'VLAN', |
171
|
|
|
|
|
|
|
NF_8021Q_TYPE_PPPPAP() => 'PPPPAP', |
172
|
|
|
|
|
|
|
NF_8021Q_TYPE_PPPCHAP() => 'PPPCHAP', |
173
|
|
|
|
|
|
|
}; |
174
|
|
|
|
|
|
|
|
175
|
0
|
0
|
0
|
|
|
|
if ($self->[$__type] <= 1500 && $self->[$__payload]) { |
176
|
0
|
|
|
|
|
|
my $payload = CORE::unpack('H*', $self->[$__payload]); |
177
|
0
|
0
|
|
|
|
|
if ($payload =~ /^aaaa/) { |
178
|
0
|
|
|
|
|
|
return 'LLC'; |
179
|
|
|
|
|
|
|
} |
180
|
0
|
|
|
|
|
|
return NF_LAYER_UNKNOWN; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
0
|
0
|
|
|
|
|
$types->{$self->type} || NF_LAYER_UNKNOWN; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub print { |
187
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
188
|
|
|
|
|
|
|
|
189
|
0
|
|
|
|
|
|
my $l = $self->layer; |
190
|
0
|
|
|
|
|
|
sprintf "$l: priority:0x%01x cfi:0x%01x id:%d type:0x%02x", |
191
|
|
|
|
|
|
|
$self->[$__priority], $self->[$__cfi], $self->[$__id], $self->[$__type]; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
1; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
__END__ |