line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: GRE.pm 21 2009-05-31 14:56:35Z gomor $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::GRE; |
5
|
2
|
|
|
2
|
|
15836
|
use strict; use warnings; |
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
|
|
93
|
|
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
107
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.04'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1927
|
use Net::Frame::Layer qw(:consts); |
|
2
|
|
|
|
|
258829
|
|
|
2
|
|
|
|
|
713
|
|
10
|
2
|
|
|
2
|
|
28
|
use Exporter; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
291
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer Exporter); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
14
|
|
|
|
|
|
|
consts => [qw( |
15
|
|
|
|
|
|
|
NF_GRE_HDR_LEN |
16
|
|
|
|
|
|
|
NF_GRE_TYPE_IPv4 |
17
|
|
|
|
|
|
|
NF_GRE_TYPE_X25 |
18
|
|
|
|
|
|
|
NF_GRE_TYPE_ARP |
19
|
|
|
|
|
|
|
NF_GRE_TYPE_CGMP |
20
|
|
|
|
|
|
|
NF_GRE_TYPE_80211 |
21
|
|
|
|
|
|
|
NF_GRE_TYPE_PPPIPCP |
22
|
|
|
|
|
|
|
NF_GRE_TYPE_RARP |
23
|
|
|
|
|
|
|
NF_GRE_TYPE_DDP |
24
|
|
|
|
|
|
|
NF_GRE_TYPE_AARP |
25
|
|
|
|
|
|
|
NF_GRE_TYPE_PPPCCP |
26
|
|
|
|
|
|
|
NF_GRE_TYPE_WCP |
27
|
|
|
|
|
|
|
NF_GRE_TYPE_8021Q |
28
|
|
|
|
|
|
|
NF_GRE_TYPE_IPX |
29
|
|
|
|
|
|
|
NF_GRE_TYPE_STP |
30
|
|
|
|
|
|
|
NF_GRE_TYPE_IPv6 |
31
|
|
|
|
|
|
|
NF_GRE_TYPE_WLCCP |
32
|
|
|
|
|
|
|
NF_GRE_TYPE_MPLS |
33
|
|
|
|
|
|
|
NF_GRE_TYPE_PPPoED |
34
|
|
|
|
|
|
|
NF_GRE_TYPE_PPPoES |
35
|
|
|
|
|
|
|
NF_GRE_TYPE_8021X |
36
|
|
|
|
|
|
|
NF_GRE_TYPE_AoE |
37
|
|
|
|
|
|
|
NF_GRE_TYPE_80211I |
38
|
|
|
|
|
|
|
NF_GRE_TYPE_LLDP |
39
|
|
|
|
|
|
|
NF_GRE_TYPE_LLTD |
40
|
|
|
|
|
|
|
NF_GRE_TYPE_LOOP |
41
|
|
|
|
|
|
|
NF_GRE_TYPE_VLAN |
42
|
|
|
|
|
|
|
NF_GRE_TYPE_PPPPAP |
43
|
|
|
|
|
|
|
NF_GRE_TYPE_PPPCHAP |
44
|
|
|
|
|
|
|
)], |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
47
|
|
|
|
|
|
|
@{$EXPORT_TAGS{consts}}, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
2
|
|
|
2
|
|
13
|
use constant NF_GRE_HDR_LEN => 4; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
174
|
|
51
|
2
|
|
|
2
|
|
11
|
use constant NF_GRE_TYPE_IPv4 => 0x0800; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
126
|
|
52
|
2
|
|
|
2
|
|
10
|
use constant NF_GRE_TYPE_X25 => 0x0805; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
301
|
|
53
|
2
|
|
|
2
|
|
13
|
use constant NF_GRE_TYPE_ARP => 0x0806; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
92
|
|
54
|
2
|
|
|
2
|
|
11
|
use constant NF_GRE_TYPE_CGMP => 0x2001; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
93
|
|
55
|
2
|
|
|
2
|
|
19
|
use constant NF_GRE_TYPE_80211 => 0x2452; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
101
|
|
56
|
2
|
|
|
2
|
|
11
|
use constant NF_GRE_TYPE_PPPIPCP => 0x8021; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
88
|
|
57
|
2
|
|
|
2
|
|
10
|
use constant NF_GRE_TYPE_RARP => 0x8035; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
111
|
|
58
|
2
|
|
|
2
|
|
12
|
use constant NF_GRE_TYPE_DDP => 0x809b; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
105
|
|
59
|
2
|
|
|
2
|
|
23
|
use constant NF_GRE_TYPE_AARP => 0x80f3; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
102
|
|
60
|
2
|
|
|
2
|
|
10
|
use constant NF_GRE_TYPE_PPPCCP => 0x80fd; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
92
|
|
61
|
2
|
|
|
2
|
|
12
|
use constant NF_GRE_TYPE_WCP => 0x80ff; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
100
|
|
62
|
2
|
|
|
2
|
|
10
|
use constant NF_GRE_TYPE_8021Q => 0x8100; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
86
|
|
63
|
2
|
|
|
2
|
|
11
|
use constant NF_GRE_TYPE_IPX => 0x8137; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
105
|
|
64
|
2
|
|
|
2
|
|
12
|
use constant NF_GRE_TYPE_STP => 0x8181; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
82
|
|
65
|
2
|
|
|
2
|
|
18
|
use constant NF_GRE_TYPE_IPv6 => 0x86dd; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
106
|
|
66
|
2
|
|
|
2
|
|
11
|
use constant NF_GRE_TYPE_WLCCP => 0x872d; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
182
|
|
67
|
2
|
|
|
2
|
|
13
|
use constant NF_GRE_TYPE_MPLS => 0x8847; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
105
|
|
68
|
2
|
|
|
2
|
|
12
|
use constant NF_GRE_TYPE_PPPoED => 0x8863; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
92
|
|
69
|
2
|
|
|
2
|
|
10
|
use constant NF_GRE_TYPE_PPPoES => 0x8864; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
98
|
|
70
|
2
|
|
|
2
|
|
11
|
use constant NF_GRE_TYPE_8021X => 0x888e; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
280
|
|
71
|
2
|
|
|
2
|
|
11
|
use constant NF_GRE_TYPE_AoE => 0x88a2; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
101
|
|
72
|
2
|
|
|
2
|
|
12
|
use constant NF_GRE_TYPE_80211I => 0x88c7; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
103
|
|
73
|
2
|
|
|
2
|
|
11
|
use constant NF_GRE_TYPE_LLDP => 0x88cc; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
106
|
|
74
|
2
|
|
|
2
|
|
10
|
use constant NF_GRE_TYPE_LLTD => 0x88d9; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
115
|
|
75
|
2
|
|
|
2
|
|
10
|
use constant NF_GRE_TYPE_LOOP => 0x9000; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
89
|
|
76
|
2
|
|
|
2
|
|
11
|
use constant NF_GRE_TYPE_VLAN => 0x9100; |
|
2
|
|
|
|
|
22
|
|
|
2
|
|
|
|
|
88
|
|
77
|
2
|
|
|
2
|
|
12
|
use constant NF_GRE_TYPE_PPPPAP => 0xc023; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
103
|
|
78
|
2
|
|
|
2
|
|
13
|
use constant NF_GRE_TYPE_PPPCHAP => 0xc223; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
380
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
our @AS = qw( |
81
|
|
|
|
|
|
|
flags |
82
|
|
|
|
|
|
|
protocol |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
85
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
86
|
|
|
|
|
|
|
|
87
|
2
|
|
|
2
|
|
12
|
no strict 'vars'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1746
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub new { |
90
|
|
|
|
|
|
|
shift->SUPER::new( |
91
|
1
|
|
|
1
|
1
|
26
|
flags => 0, |
92
|
|
|
|
|
|
|
protocol => NF_GRE_TYPE_IPv4, |
93
|
|
|
|
|
|
|
@_, |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
0
|
1
|
0
|
sub getLength { NF_GRE_HDR_LEN } |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub pack { |
100
|
1
|
|
|
1
|
1
|
263
|
my $self = shift; |
101
|
|
|
|
|
|
|
|
102
|
1
|
50
|
|
|
|
20
|
$self->[$__raw] = $self->SUPER::pack('nn', |
103
|
|
|
|
|
|
|
$self->[$__flags], |
104
|
|
|
|
|
|
|
$self->[$__protocol], |
105
|
|
|
|
|
|
|
) or return undef; |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
19
|
$self->[$__raw]; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub unpack { |
111
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
112
|
|
|
|
|
|
|
|
113
|
1
|
50
|
|
|
|
10
|
my ($flags, $protocol, $payload) = |
114
|
|
|
|
|
|
|
$self->SUPER::unpack('nn a*', $self->[$__raw]) |
115
|
|
|
|
|
|
|
or return undef; |
116
|
|
|
|
|
|
|
|
117
|
1
|
|
|
|
|
19
|
$self->[$__flags] = $flags; |
118
|
1
|
|
|
|
|
2
|
$self->[$__protocol] = $protocol; |
119
|
1
|
|
|
|
|
3
|
$self->[$__payload] = $payload; |
120
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
3
|
$self; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub encapsulate { |
125
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
126
|
|
|
|
|
|
|
|
127
|
0
|
0
|
|
|
|
|
return $self->[$__nextLayer] if $self->[$__nextLayer]; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
my $types = { |
130
|
|
|
|
|
|
|
NF_GRE_TYPE_IPv4() => 'IPv4', |
131
|
|
|
|
|
|
|
NF_GRE_TYPE_X25() => 'X25', |
132
|
|
|
|
|
|
|
NF_GRE_TYPE_ARP() => 'ARP', |
133
|
|
|
|
|
|
|
NF_GRE_TYPE_CGMP() => 'CGMP', |
134
|
|
|
|
|
|
|
NF_GRE_TYPE_80211() => '80211', |
135
|
|
|
|
|
|
|
NF_GRE_TYPE_PPPIPCP() => 'PPPIPCP', |
136
|
|
|
|
|
|
|
NF_GRE_TYPE_RARP() => 'RARP', |
137
|
|
|
|
|
|
|
NF_GRE_TYPE_DDP () => 'DDP', |
138
|
|
|
|
|
|
|
NF_GRE_TYPE_AARP() => 'AARP', |
139
|
|
|
|
|
|
|
NF_GRE_TYPE_PPPCCP() => 'PPPCCP', |
140
|
|
|
|
|
|
|
NF_GRE_TYPE_WCP() => 'WCP', |
141
|
|
|
|
|
|
|
NF_GRE_TYPE_8021Q() => '8021Q', |
142
|
|
|
|
|
|
|
NF_GRE_TYPE_IPX() => 'IPX', |
143
|
|
|
|
|
|
|
NF_GRE_TYPE_STP() => 'STP', |
144
|
|
|
|
|
|
|
NF_GRE_TYPE_IPv6() => 'IPv6', |
145
|
|
|
|
|
|
|
NF_GRE_TYPE_WLCCP() => 'WLCCP', |
146
|
|
|
|
|
|
|
NF_GRE_TYPE_MPLS() => 'MPLS', |
147
|
|
|
|
|
|
|
NF_GRE_TYPE_PPPoED() => 'PPPoED', |
148
|
|
|
|
|
|
|
NF_GRE_TYPE_PPPoES() => 'PPPoES', |
149
|
|
|
|
|
|
|
NF_GRE_TYPE_8021X() => '8021X', |
150
|
|
|
|
|
|
|
NF_GRE_TYPE_AoE() => 'AoE', |
151
|
|
|
|
|
|
|
NF_GRE_TYPE_80211I() => '80211I', |
152
|
|
|
|
|
|
|
NF_GRE_TYPE_LLDP() => 'LLDP', |
153
|
|
|
|
|
|
|
NF_GRE_TYPE_LLTD() => 'LLTD', |
154
|
|
|
|
|
|
|
NF_GRE_TYPE_LOOP() => 'LOOP', |
155
|
|
|
|
|
|
|
NF_GRE_TYPE_VLAN() => 'VLAN', |
156
|
|
|
|
|
|
|
NF_GRE_TYPE_PPPPAP() => 'PPPPAP', |
157
|
|
|
|
|
|
|
NF_GRE_TYPE_PPPCHAP() => 'PPPCHAP', |
158
|
|
|
|
|
|
|
}; |
159
|
|
|
|
|
|
|
|
160
|
0
|
0
|
|
|
|
|
$types->{$self->[$__protocol]} || NF_LAYER_UNKNOWN; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub print { |
164
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
my $l = $self->layer; |
167
|
0
|
|
|
|
|
|
sprintf "$l: flags:0x%04x protocol:0x%04x", |
168
|
|
|
|
|
|
|
$self->[$__flags], $self->[$__protocol]; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
1; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
__END__ |