line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: GRE.pm 23 2015-01-20 18:48:56Z gomor $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::GRE; |
5
|
2
|
|
|
2
|
|
9643
|
use strict; use warnings; |
|
2
|
|
|
2
|
|
5
|
|
|
2
|
|
|
|
|
75
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
98
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.05'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1331
|
use Net::Frame::Layer qw(:consts); |
|
2
|
|
|
|
|
113516
|
|
|
2
|
|
|
|
|
412
|
|
10
|
2
|
|
|
2
|
|
17
|
use Exporter; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
253
|
|
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
|
|
11
|
use constant NF_GRE_HDR_LEN => 4; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
105
|
|
51
|
2
|
|
|
2
|
|
10
|
use constant NF_GRE_TYPE_IPv4 => 0x0800; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
82
|
|
52
|
2
|
|
|
2
|
|
8
|
use constant NF_GRE_TYPE_X25 => 0x0805; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
84
|
|
53
|
2
|
|
|
2
|
|
10
|
use constant NF_GRE_TYPE_ARP => 0x0806; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
81
|
|
54
|
2
|
|
|
2
|
|
9
|
use constant NF_GRE_TYPE_CGMP => 0x2001; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
100
|
|
55
|
2
|
|
|
2
|
|
18
|
use constant NF_GRE_TYPE_80211 => 0x2452; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
93
|
|
56
|
2
|
|
|
2
|
|
9
|
use constant NF_GRE_TYPE_PPPIPCP => 0x8021; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
87
|
|
57
|
2
|
|
|
2
|
|
9
|
use constant NF_GRE_TYPE_RARP => 0x8035; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
94
|
|
58
|
2
|
|
|
2
|
|
10
|
use constant NF_GRE_TYPE_DDP => 0x809b; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
103
|
|
59
|
2
|
|
|
2
|
|
16
|
use constant NF_GRE_TYPE_AARP => 0x80f3; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
87
|
|
60
|
2
|
|
|
2
|
|
14
|
use constant NF_GRE_TYPE_PPPCCP => 0x80fd; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
90
|
|
61
|
2
|
|
|
2
|
|
9
|
use constant NF_GRE_TYPE_WCP => 0x80ff; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
128
|
|
62
|
2
|
|
|
2
|
|
11
|
use constant NF_GRE_TYPE_8021Q => 0x8100; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
93
|
|
63
|
2
|
|
|
2
|
|
10
|
use constant NF_GRE_TYPE_IPX => 0x8137; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
87
|
|
64
|
2
|
|
|
2
|
|
10
|
use constant NF_GRE_TYPE_STP => 0x8181; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
87
|
|
65
|
2
|
|
|
2
|
|
9
|
use constant NF_GRE_TYPE_IPv6 => 0x86dd; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
99
|
|
66
|
2
|
|
|
2
|
|
9
|
use constant NF_GRE_TYPE_WLCCP => 0x872d; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
85
|
|
67
|
2
|
|
|
2
|
|
15
|
use constant NF_GRE_TYPE_MPLS => 0x8847; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
96
|
|
68
|
2
|
|
|
2
|
|
14
|
use constant NF_GRE_TYPE_PPPoED => 0x8863; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
80
|
|
69
|
2
|
|
|
2
|
|
8
|
use constant NF_GRE_TYPE_PPPoES => 0x8864; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
89
|
|
70
|
2
|
|
|
2
|
|
10
|
use constant NF_GRE_TYPE_8021X => 0x888e; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
85
|
|
71
|
2
|
|
|
2
|
|
9
|
use constant NF_GRE_TYPE_AoE => 0x88a2; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
84
|
|
72
|
2
|
|
|
2
|
|
9
|
use constant NF_GRE_TYPE_80211I => 0x88c7; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
91
|
|
73
|
2
|
|
|
2
|
|
9
|
use constant NF_GRE_TYPE_LLDP => 0x88cc; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
91
|
|
74
|
2
|
|
|
2
|
|
9
|
use constant NF_GRE_TYPE_LLTD => 0x88d9; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
89
|
|
75
|
2
|
|
|
2
|
|
9
|
use constant NF_GRE_TYPE_LOOP => 0x9000; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
88
|
|
76
|
2
|
|
|
2
|
|
8
|
use constant NF_GRE_TYPE_VLAN => 0x9100; |
|
2
|
|
|
|
|
18
|
|
|
2
|
|
|
|
|
90
|
|
77
|
2
|
|
|
2
|
|
9
|
use constant NF_GRE_TYPE_PPPPAP => 0xc023; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
83
|
|
78
|
2
|
|
|
2
|
|
10
|
use constant NF_GRE_TYPE_PPPCHAP => 0xc223; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
185
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
our @AS = qw( |
81
|
|
|
|
|
|
|
flags |
82
|
|
|
|
|
|
|
protocol |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
85
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
86
|
|
|
|
|
|
|
|
87
|
2
|
|
|
2
|
|
11
|
no strict 'vars'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1132
|
|
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
|
215
|
my $self = shift; |
101
|
|
|
|
|
|
|
|
102
|
1
|
50
|
|
|
|
14
|
$self->[$__raw] = $self->SUPER::pack('nn', |
103
|
|
|
|
|
|
|
$self->[$__flags], |
104
|
|
|
|
|
|
|
$self->[$__protocol], |
105
|
|
|
|
|
|
|
) or return undef; |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
17
|
$self->[$__raw]; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub unpack { |
111
|
1
|
|
|
1
|
1
|
4
|
my $self = shift; |
112
|
|
|
|
|
|
|
|
113
|
1
|
50
|
|
|
|
6
|
my ($flags, $protocol, $payload) = |
114
|
|
|
|
|
|
|
$self->SUPER::unpack('nn a*', $self->[$__raw]) |
115
|
|
|
|
|
|
|
or return undef; |
116
|
|
|
|
|
|
|
|
117
|
1
|
|
|
|
|
17
|
$self->[$__flags] = $flags; |
118
|
1
|
|
|
|
|
3
|
$self->[$__protocol] = $protocol; |
119
|
1
|
|
|
|
|
2
|
$self->[$__payload] = $payload; |
120
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
2
|
$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__ |