line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: 8021Q.pm 10 2015-01-20 18:42:55Z gomor $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::8021Q; |
5
|
2
|
|
|
2
|
|
11467
|
use strict; use warnings; |
|
2
|
|
|
2
|
|
3
|
|
|
2
|
|
|
|
|
72
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
101
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.03'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1219
|
use Net::Frame::Layer qw(:consts); |
|
2
|
|
|
|
|
136002
|
|
|
2
|
|
|
|
|
391
|
|
10
|
2
|
|
|
2
|
|
18
|
use Exporter; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
238
|
|
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
|
|
9
|
use constant NF_8021Q_HDR_LEN => 4; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
94
|
|
51
|
2
|
|
|
2
|
|
6
|
use constant NF_8021Q_TYPE_IPv4 => 0x0800; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
62
|
|
52
|
2
|
|
|
2
|
|
8
|
use constant NF_8021Q_TYPE_X25 => 0x0805; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
63
|
|
53
|
2
|
|
|
2
|
|
7
|
use constant NF_8021Q_TYPE_ARP => 0x0806; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
60
|
|
54
|
2
|
|
|
2
|
|
7
|
use constant NF_8021Q_TYPE_CGMP => 0x2001; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
58
|
|
55
|
2
|
|
|
2
|
|
14
|
use constant NF_8021Q_TYPE_80211 => 0x2452; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
69
|
|
56
|
2
|
|
|
2
|
|
7
|
use constant NF_8021Q_TYPE_PPPIPCP => 0x8021; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
60
|
|
57
|
2
|
|
|
2
|
|
7
|
use constant NF_8021Q_TYPE_RARP => 0x8035; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
71
|
|
58
|
2
|
|
|
2
|
|
7
|
use constant NF_8021Q_TYPE_DDP => 0x809b; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
88
|
|
59
|
2
|
|
|
2
|
|
16
|
use constant NF_8021Q_TYPE_AARP => 0x80f3; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
82
|
|
60
|
2
|
|
|
2
|
|
13
|
use constant NF_8021Q_TYPE_PPPCCP => 0x80fd; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
79
|
|
61
|
2
|
|
|
2
|
|
8
|
use constant NF_8021Q_TYPE_WCP => 0x80ff; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
71
|
|
62
|
2
|
|
|
2
|
|
6
|
use constant NF_8021Q_TYPE_8021Q => 0x8100; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
62
|
|
63
|
2
|
|
|
2
|
|
10
|
use constant NF_8021Q_TYPE_IPX => 0x8137; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
66
|
|
64
|
2
|
|
|
2
|
|
7
|
use constant NF_8021Q_TYPE_STP => 0x8181; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
72
|
|
65
|
2
|
|
|
2
|
|
9
|
use constant NF_8021Q_TYPE_IPv6 => 0x86dd; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
106
|
|
66
|
2
|
|
|
2
|
|
8
|
use constant NF_8021Q_TYPE_WLCCP => 0x872d; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
83
|
|
67
|
2
|
|
|
2
|
|
11
|
use constant NF_8021Q_TYPE_MPLS => 0x8847; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
76
|
|
68
|
2
|
|
|
2
|
|
7
|
use constant NF_8021Q_TYPE_PPPoED => 0x8863; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
69
|
|
69
|
2
|
|
|
2
|
|
6
|
use constant NF_8021Q_TYPE_PPPoES => 0x8864; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
67
|
|
70
|
2
|
|
|
2
|
|
7
|
use constant NF_8021Q_TYPE_8021X => 0x888e; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
65
|
|
71
|
2
|
|
|
2
|
|
6
|
use constant NF_8021Q_TYPE_AoE => 0x88a2; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
63
|
|
72
|
2
|
|
|
2
|
|
8
|
use constant NF_8021Q_TYPE_80211I => 0x88c7; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
64
|
|
73
|
2
|
|
|
2
|
|
7
|
use constant NF_8021Q_TYPE_LLDP => 0x88cc; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
71
|
|
74
|
2
|
|
|
2
|
|
7
|
use constant NF_8021Q_TYPE_LLTD => 0x88d9; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
68
|
|
75
|
2
|
|
|
2
|
|
7
|
use constant NF_8021Q_TYPE_LOOP => 0x9000; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
64
|
|
76
|
2
|
|
|
2
|
|
7
|
use constant NF_8021Q_TYPE_VLAN => 0x9100; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
67
|
|
77
|
2
|
|
|
2
|
|
6
|
use constant NF_8021Q_TYPE_PPPPAP => 0xc023; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
63
|
|
78
|
2
|
|
|
2
|
|
6
|
use constant NF_8021Q_TYPE_PPPCHAP => 0xc223; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
137
|
|
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
|
|
8
|
no strict 'vars'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
1764
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
require Bit::Vector; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub new { |
94
|
|
|
|
|
|
|
shift->SUPER::new( |
95
|
1
|
|
|
1
|
1
|
21
|
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
|
207
|
my $self = shift; |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
28
|
my $v3 = Bit::Vector->new_Dec( 3, $self->[$__priority]); |
109
|
1
|
|
|
|
|
4
|
my $v1 = Bit::Vector->new_Dec( 1, $self->[$__cfi]); |
110
|
1
|
|
|
|
|
5
|
my $v12 = Bit::Vector->new_Dec(12, $self->[$__id]); |
111
|
1
|
|
|
|
|
6
|
my $v16 = $v3->Concat_List($v1, $v12); |
112
|
|
|
|
|
|
|
|
113
|
1
|
50
|
|
|
|
12
|
$self->[$__raw] = $self->SUPER::pack('nn', |
114
|
|
|
|
|
|
|
$v16->to_Dec, |
115
|
|
|
|
|
|
|
$self->[$__type], |
116
|
|
|
|
|
|
|
) or return undef; |
117
|
|
|
|
|
|
|
|
118
|
1
|
|
|
|
|
23
|
$self->[$__raw]; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub unpack { |
122
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
123
|
|
|
|
|
|
|
|
124
|
1
|
50
|
|
|
|
6
|
my ($pCfiId, $type, $payload) = |
125
|
|
|
|
|
|
|
$self->SUPER::unpack('nn a*', $self->[$__raw]) |
126
|
|
|
|
|
|
|
or return undef; |
127
|
|
|
|
|
|
|
|
128
|
1
|
|
|
|
|
19
|
my $v16 = Bit::Vector->new_Dec(16, $pCfiId); |
129
|
|
|
|
|
|
|
|
130
|
1
|
|
|
|
|
8
|
$self->[$__priority] = $v16->Chunk_Read( 3, 13); |
131
|
1
|
|
|
|
|
3
|
$self->[$__cfi] = $v16->Chunk_Read( 1, 12); |
132
|
1
|
|
|
|
|
4
|
$self->[$__id] = $v16->Chunk_Read(12, 0); |
133
|
1
|
|
|
|
|
2
|
$self->[$__type] = $type; |
134
|
1
|
|
|
|
|
2
|
$self->[$__payload] = $payload; |
135
|
|
|
|
|
|
|
|
136
|
1
|
|
|
|
|
3
|
$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__ |