2 * Routines for the Generic Routing Encapsulation (GRE) protocol
3 * Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <epan/packet.h>
30 #include <epan/etypes.h>
31 #include <epan/in_cksum.h>
32 #include <epan/expert.h>
33 #include <epan/greproto.h>
34 #include <epan/ipproto.h>
35 #include <epan/llcsaps.h>
36 #include "packet-gre.h"
37 #include "packet-wccp.h"
40 * See RFC 1701 "Generic Routing Encapsulation (GRE)", RFC 1702
41 * "Generic Routing Encapsulation over IPv4 networks", RFC 2637
42 * "Point-to-Point Tunneling Protocol (PPTP)", RFC 2784 "Generic
43 * Routing Encapsulation (GRE)", RFC 2890 "Key and Sequence
44 * Number Extensions to GRE" and draft-ietf-mpls-in-ip-or-gre-07.txt
45 * "Encapsulating MPLS in IP or Generic Routing Encapsulation (GRE)".
48 static int proto_gre
= -1;
49 static int hf_gre_proto
= -1;
50 static int hf_gre_flags_and_version
= -1;
51 static int hf_gre_flags_checksum
= -1;
52 static int hf_gre_flags_routing
= -1;
53 static int hf_gre_flags_key
= -1;
54 static int hf_gre_flags_sequence_number
= -1;
55 static int hf_gre_flags_strict_source_route
= -1;
56 static int hf_gre_flags_recursion_control
= -1;
57 static int hf_gre_flags_ack
= -1;
58 static int hf_gre_flags_reserved_ppp
= -1;
59 static int hf_gre_flags_reserved
= -1;
60 static int hf_gre_flags_version
= -1;
61 static int hf_gre_checksum
= -1;
62 static int hf_gre_offset
= -1;
63 static int hf_gre_key
= -1;
64 static int hf_gre_key_payload_length
= -1;
65 static int hf_gre_key_call_id
= -1;
66 static int hf_gre_sequence_number
= -1;
67 static int hf_gre_ack_number
= -1;
68 static int hf_gre_routing
= -1;
69 static int hf_gre_routing_address_family
= -1;
70 static int hf_gre_routing_sre_length
= -1;
71 static int hf_gre_routing_sre_offset
= -1;
72 static int hf_gre_routing_information
= -1;
74 /* Ref 3GPP2 A.S0012-C v2.0 and A.S0008-A v1.0 */
75 static int hf_gre_3ggp2_attrib
= -1;
76 static int hf_gre_3ggp2_attrib_id
= -1;
77 static int hf_gre_3ggp2_attrib_length
= -1;
78 static int hf_gre_3ggp2_sdi
= -1;
79 static int hf_gre_3ggp2_fci
= -1;
80 static int hf_gre_3ggp2_di
= -1;
81 static int hf_gre_3ggp2_flow_disc
= -1;
82 static int hf_gre_3ggp2_seg
= -1;
84 static int hf_gre_wccp_redirect_header
= -1;
85 static int hf_gre_wccp_dynamic_service
= -1;
86 static int hf_gre_wccp_alternative_bucket_used
= -1;
87 static int hf_gre_wccp_redirect_header_valid
= -1;
88 static int hf_gre_wccp_service_id
= -1;
89 static int hf_gre_wccp_alternative_bucket
= -1;
90 static int hf_gre_wccp_primary_bucket
= -1;
92 static gint ett_gre
= -1;
93 static gint ett_gre_flags
= -1;
94 static gint ett_gre_routing
= -1;
95 static gint ett_gre_wccp2_redirect_header
= -1;
96 static gint ett_3gpp2_attribs
= -1;
97 static gint ett_3gpp2_attr
= -1;
99 static expert_field ei_gre_checksum_incorrect
= EI_INIT
;
101 static dissector_table_t gre_dissector_table
;
102 static dissector_handle_t data_handle
;
104 /* bit positions for flags in header */
105 #define GRE_CHECKSUM 0x8000
106 #define GRE_ROUTING 0x4000
107 #define GRE_KEY 0x2000
108 #define GRE_SEQUENCE 0x1000
109 #define GRE_STRICTSOURCE 0x0800
110 #define GRE_RECURSION 0x0700
111 #define GRE_ACK 0x0080 /* only in special PPTPized GRE header */
112 #define GRE_RESERVED_PPP 0x0078 /* only in special PPTPized GRE header */
113 #define GRE_RESERVED 0x00F8
114 #define GRE_VERSION 0x0007
117 const value_string gre_version
[] = {
118 { 0, "GRE" }, /* [RFC2784] */
119 { 1, "Enhanced GRE" }, /* [RFC2637] */
122 const value_string gre_typevals
[] = {
123 { GRE_KEEPALIVE
, "Possible GRE keepalive packet" },
124 { ETHERTYPE_PPP
, "PPP" },
125 { ETHERTYPE_IP
, "IP" },
126 { SAP_OSINL5
, "OSI"},
129 { GRE_ERSPAN_88BE
, "ERSPAN"},
130 { GRE_ERSPAN_22EB
, "ERSPAN"},
131 { ETHERTYPE_IPX
, "IPX"},
132 { ETHERTYPE_ETHBRIDGE
, "Transparent Ethernet bridging" },
133 { ETHERTYPE_RAW_FR
, "Frame Relay"},
134 { ETHERTYPE_IPv6
, "IPv6" },
135 { ETHERTYPE_MPLS
, "MPLS label switched packet" },
136 { ETHERTYPE_CDMA2000_A10_UBS
,"CDMA2000 A10 Unstructured byte stream" },
137 { ETHERTYPE_3GPP2
, "CDMA2000 A10 3GPP2 Packet" },
138 { GRE_ARUBA_8200
, "ARUBA WLAN" },
139 { GRE_ARUBA_8210
, "ARUBA WLAN" },
140 { GRE_ARUBA_8220
, "ARUBA WLAN" },
141 { GRE_ARUBA_8230
, "ARUBA WLAN" },
142 { GRE_ARUBA_8240
, "ARUBA WLAN" },
143 { GRE_ARUBA_8250
, "ARUBA WLAN" },
144 { GRE_ARUBA_8260
, "ARUBA WLAN" },
145 { GRE_ARUBA_8270
, "ARUBA WLAN" },
146 { GRE_ARUBA_8280
, "ARUBA WLAN" },
147 { GRE_ARUBA_8290
, "ARUBA WLAN" },
148 { GRE_ARUBA_82A0
, "ARUBA WLAN" },
149 { GRE_ARUBA_82B0
, "ARUBA WLAN" },
150 { GRE_ARUBA_82C0
, "ARUBA WLAN" },
151 { GRE_ARUBA_82D0
, "ARUBA WLAN" },
152 { GRE_ARUBA_82E0
, "ARUBA WLAN" },
153 { GRE_ARUBA_82F0
, "ARUBA WLAN" },
154 { GRE_ARUBA_8300
, "ARUBA WLAN" },
155 { GRE_ARUBA_8310
, "ARUBA WLAN" },
156 { GRE_ARUBA_8320
, "ARUBA WLAN" },
157 { GRE_ARUBA_8330
, "ARUBA WLAN" },
158 { GRE_ARUBA_8340
, "ARUBA WLAN" },
159 { GRE_ARUBA_8350
, "ARUBA WLAN" },
160 { GRE_ARUBA_8360
, "ARUBA WLAN" },
161 { GRE_ARUBA_8370
, "ARUBA WLAN" },
162 { GRE_ARUBA_9000
, "ARUBA WLAN" },
166 #define ID_3GPP2_SDI_FLAG 1
167 #define ID_3GPP2_FLOW_CTRL 2
168 #define ID_3GPP2_FLOW_DISCRIMINATOR 3
169 #define ID_3GPP2_SEG 4
171 static const value_string gre_3ggp2_seg_vals
[] = {
172 { 0x00, "Packet Started" },
173 { 0x01, "Packet continued" },
174 { 0x02, "Packet Ended" },
177 /* 3GPP2 A.S0012-C v2.0
178 * 2.6.1 GRE Attributes
180 static const value_string gre_3ggp2_attrib_id_vals
[] = {
181 { 0x01, "1x SDB/HRPD DOS Indicator" },
182 { 0x02, "Flow Control Indication" },
184 { 0x03, "IP Flow Discriminator" },
185 { 0x04, "Segmentation Indication" },
189 static const true_false_string gre_3ggp2_sdi_val
= {
190 "Packet suitable for 1x SDB or HRPD DOS transmission",
194 static const true_false_string gre_3ggp2_fci_val
= {
199 static const true_false_string gre_3ggp2_di_val
= {
204 static const true_false_string gre_wccp_dynamic_service_val
= {
209 static const true_false_string gre_wccp_alternative_bucket_used_val
= {
210 "Alternative bucket used",
211 "Primary bucket used",
214 static const true_false_string gre_wccp_redirect_header_valid_val
= {
215 "Header is present, but ignore contents",
216 "Header contents are valid",
221 dissect_gre_3gpp2_attribs(tvbuff_t
*tvb
, int offset
, proto_tree
*tree
)
223 gboolean last_attrib
= FALSE
;
224 proto_item
*attr_item
;
225 proto_tree
*attr_tree
;
227 int start_offset
= offset
;
229 proto_item
*ti
= proto_tree_add_item(tree
, hf_gre_3ggp2_attrib
, tvb
, offset
, 0, ENC_NA
);
230 proto_tree
*atree
= proto_item_add_subtree(ti
, ett_3gpp2_attribs
);
232 while(last_attrib
!= TRUE
)
234 guint8 attrib_id
= tvb_get_guint8(tvb
, offset
);
235 guint8 attrib_length
= tvb_get_guint8(tvb
, offset
+ 1);
237 attr_item
= proto_tree_add_text(atree
, tvb
, offset
, attrib_length
+ 1 + 1, "%s",
238 val_to_str((attrib_id
&0x7f), gre_3ggp2_attrib_id_vals
, "%u (Unknown)"));
239 attr_tree
= proto_item_add_subtree(attr_item
, ett_3gpp2_attr
);
241 proto_tree_add_item(attr_tree
, hf_gre_3ggp2_attrib_id
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
242 proto_tree_add_item(attr_tree
, hf_gre_3ggp2_attrib_length
, tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
245 last_attrib
= (attrib_id
& 0x80)?TRUE
:FALSE
;
250 case ID_3GPP2_FLOW_DISCRIMINATOR
:
252 value
= tvb_get_guint8(tvb
,offset
);
253 proto_tree_add_item(attr_tree
, hf_gre_3ggp2_flow_disc
, tvb
, offset
, attrib_length
, ENC_NA
);
254 proto_item_append_text(attr_item
," - 0x%x",value
);
257 case ID_3GPP2_SDI_FLAG
:
259 value
= tvb_get_guint8(tvb
,offset
);
260 proto_tree_add_item(attr_tree
, hf_gre_3ggp2_sdi
, tvb
, offset
, attrib_length
, ENC_BIG_ENDIAN
);
261 proto_item_append_text(attr_item
," - %s",
262 (value
& 0x80) ? "Packet suitable for 1x SDB or HRPD DOS transmission" : "Reserved");
268 value
= tvb_get_guint8(tvb
,offset
) >>6;
269 proto_tree_add_item(attr_tree
, hf_gre_3ggp2_seg
, tvb
, offset
, attrib_length
, ENC_BIG_ENDIAN
);
270 proto_item_append_text(attr_item
," - %s",val_to_str(value
, gre_3ggp2_seg_vals
, "0x%02X - Unknown"));
273 case ID_3GPP2_FLOW_CTRL
:
275 value
= tvb_get_guint8(tvb
,offset
);
276 proto_tree_add_item(attr_tree
, hf_gre_3ggp2_fci
, tvb
, offset
, attrib_length
, ENC_BIG_ENDIAN
);
277 proto_item_append_text(attr_item
," - %s",
278 (value
& 0x80) ? "XON" : "XOFF");
279 proto_tree_add_item(attr_tree
, hf_gre_3ggp2_di
, tvb
, offset
, attrib_length
, ENC_BIG_ENDIAN
);
280 proto_item_append_text(attr_item
,"/%s",
281 (value
& 0x40) ? "INDEFINITE" : "TEMPORARY");
286 offset
+= attrib_length
;
288 proto_item_set_len(ti
, offset
- start_offset
);
294 dissect_gre_wccp2_redirect_header(tvbuff_t
*tvb
, int offset
, proto_tree
*tree
)
299 ti
= proto_tree_add_item(tree
, hf_gre_wccp_redirect_header
, tvb
, offset
, 4, ENC_NA
);
300 rh_tree
= proto_item_add_subtree(ti
, ett_gre_wccp2_redirect_header
);
302 proto_tree_add_item(rh_tree
, hf_gre_wccp_dynamic_service
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
304 proto_tree_add_item(rh_tree
, hf_gre_wccp_alternative_bucket_used
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
306 proto_tree_add_item(rh_tree
, hf_gre_wccp_redirect_header_valid
, tvb
, offset
, 1, FALSE
);
308 proto_tree_add_item(rh_tree
, hf_gre_wccp_service_id
, tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
310 proto_tree_add_item(rh_tree
, hf_gre_wccp_alternative_bucket
, tvb
, offset
+2, 1, ENC_BIG_ENDIAN
);
312 proto_tree_add_item(rh_tree
, hf_gre_wccp_primary_bucket
, tvb
, offset
+3, 1, ENC_BIG_ENDIAN
);
316 dissect_gre(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
320 guint16 flags_and_ver
;
322 gboolean is_ppp
= FALSE
;
323 gboolean is_wccp2
= FALSE
;
324 proto_item
*ti
, *it_flags
;
325 proto_tree
*gre_tree
, *fv_tree
= NULL
;
330 flags_and_ver
= tvb_get_ntohs(tvb
, offset
);
331 type
= tvb_get_ntohs(tvb
, offset
+ 2);
333 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "GRE");
335 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Encapsulated %s", val_to_str(type
, gre_typevals
, "0x%04X (unknown)"));
340 if (flags_and_ver
& GRE_ACK
)
343 case ETHERTYPE_3GPP2
:
344 case ETHERTYPE_CDMA2000_A10_UBS
:
349 /* WCCP2 puts an extra 4 octets into the header, but uses the same
350 encapsulation type; if it looks as if the first octet of the packet
351 isn't the beginning of an IPv4 header, assume it's WCCP2. */
352 if ((tvb_get_guint8(tvb
, offset
+ 2 + 2) & 0xF0) != 0x40) {
358 /* Per README.developer, section 1.2, we must call subdissectors regardless
359 * of whether "tree" is NULL or not. That is done below using
360 * call_dissector(), but since the next_tvb must begin at the correct offset,
361 * it's easier and more readable to always enter this block in order to
362 * compute the correct offset to pass to tvb_new_subset_remaining().
365 ti
= proto_tree_add_protocol_format(tree
, proto_gre
, tvb
, offset
, -1, "Generic Routing Encapsulation (%s)",
366 val_to_str(type
, gre_typevals
, "0x%04X - unknown"));
367 gre_tree
= proto_item_add_subtree(ti
, ett_gre
);
370 it_flags
= proto_tree_add_item(gre_tree
, hf_gre_flags_and_version
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
371 fv_tree
= proto_item_add_subtree(it_flags
, ett_gre_flags
);
373 proto_tree_add_item(fv_tree
, hf_gre_flags_checksum
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
375 proto_tree_add_item(fv_tree
, hf_gre_flags_routing
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
377 proto_tree_add_item(fv_tree
, hf_gre_flags_key
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
379 proto_tree_add_item(fv_tree
, hf_gre_flags_sequence_number
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
381 proto_tree_add_item(fv_tree
, hf_gre_flags_strict_source_route
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
383 proto_tree_add_item(fv_tree
, hf_gre_flags_recursion_control
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
385 /* RFC2637 Section 4.1 : Enhanced GRE Header */
387 proto_tree_add_item(fv_tree
, hf_gre_flags_ack
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
389 proto_tree_add_item(fv_tree
, hf_gre_flags_reserved_ppp
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
392 proto_tree_add_item(fv_tree
, hf_gre_flags_reserved
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
395 proto_tree_add_item(fv_tree
, hf_gre_flags_version
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
399 proto_tree_add_item(gre_tree
, hf_gre_proto
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
402 if (flags_and_ver
& GRE_CHECKSUM
|| flags_and_ver
& GRE_ROUTING
) {
403 guint length
, reported_length
;
404 proto_item
*it_checksum
;
406 guint16 cksum
, computed_cksum
;
408 it_checksum
= proto_tree_add_item(gre_tree
, hf_gre_checksum
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
409 /* Checksum check !... */
410 cksum
= tvb_get_ntohs(tvb
, offset
);
411 length
= tvb_length(tvb
);
412 reported_length
= tvb_reported_length(tvb
);
413 /* The Checksum Present bit is set, and the packet isn't part of a
414 fragmented datagram and isn't truncated, so we can checksum it. */
415 if ((flags_and_ver
& GRE_CHECKSUM
) && !pinfo
->fragmented
&& length
>= reported_length
) {
416 cksum_vec
[0].ptr
= tvb_get_ptr(tvb
, 0, reported_length
);
417 cksum_vec
[0].len
= reported_length
;
418 computed_cksum
= in_cksum(cksum_vec
, 1);
419 if (computed_cksum
== 0) {
420 proto_item_append_text(it_checksum
," [correct]");
422 proto_item_append_text(it_checksum
," [incorrect, should be 0x%04x]",in_cksum_shouldbe(cksum
, computed_cksum
));
423 expert_add_info(pinfo
, it_checksum
, &ei_gre_checksum_incorrect
);
430 proto_tree_add_item(gre_tree
, hf_gre_offset
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
434 if (flags_and_ver
& GRE_KEY
) {
435 /* RFC2637 Section 4.1 : Enhanced GRE Header */
436 if (is_ppp
&& type
!=ETHERTYPE_CDMA2000_A10_UBS
) {
438 proto_tree_add_item(gre_tree
, hf_gre_key_payload_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
441 proto_tree_add_item(gre_tree
, hf_gre_key_call_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
445 proto_tree_add_item(gre_tree
, hf_gre_key
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
449 if (flags_and_ver
& GRE_SEQUENCE
) {
451 proto_tree_add_item(gre_tree
, hf_gre_sequence_number
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
454 if (is_ppp
&& (flags_and_ver
& GRE_ACK
)) {
456 proto_tree_add_item(gre_tree
, hf_gre_ack_number
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
459 if (flags_and_ver
& GRE_ROUTING
) {
460 proto_item
*it_routing
;
464 it_routing
= proto_tree_add_item(gre_tree
, hf_gre_routing
, tvb
, offset
, -1, ENC_NA
);
465 r_tree
= proto_item_add_subtree(ti
, ett_gre_routing
);
467 sre_af
= tvb_get_ntohs(tvb
, offset
);
468 proto_tree_add_item(r_tree
, hf_gre_routing_address_family
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
471 proto_tree_add_item(r_tree
, hf_gre_routing_sre_offset
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
474 sre_length
= tvb_get_guint8(tvb
, offset
);
475 proto_tree_add_item(r_tree
, hf_gre_routing_sre_length
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
478 proto_item_set_len(it_routing
, 2 + 1 +1 + sre_length
);
479 if (sre_af
== 0 && sre_length
== 0)
482 proto_tree_add_item(r_tree
, hf_gre_routing_information
, tvb
, offset
, sre_length
, ENC_NA
);
483 offset
+= sre_length
;
487 if (type
== GRE_WCCP
&& is_wccp2
) {
488 dissect_gre_wccp2_redirect_header(tvb
, offset
, gre_tree
);
491 if (type
== ETHERTYPE_3GPP2
) {
492 offset
= dissect_gre_3gpp2_attribs(tvb
, offset
, gre_tree
);
495 proto_item_set_len(ti
, offset
);
497 /* If the S bit is not set, this packet might not have a payload, so
498 check whether there's any data left, first.
500 XXX - the S bit isn't in RFC 2784, which deprecates that bit
501 and some other bits in RFC 1701 and says that they should be
502 zero for RFC 2784-compliant GRE; as such, the absence of the
503 S bit doesn't necessarily mean there's no payload. */
504 if (!(flags_and_ver
& GRE_SEQUENCE
)) {
505 if (tvb_reported_length_remaining(tvb
, offset
) <= 0)
506 return; /* no payload */
508 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
509 pinfo
->flags
.in_gre_pkt
= TRUE
;
510 if (!dissector_try_uint(gre_dissector_table
, type
, next_tvb
, pinfo
, tree
))
511 call_dissector(data_handle
,next_tvb
, pinfo
, gre_tree
);
517 proto_register_gre(void)
519 static hf_register_info hf
[] = {
521 { "Protocol Type", "gre.proto",
522 FT_UINT16
, BASE_HEX
, VALS(gre_typevals
), 0x0,
523 "The protocol that is GRE encapsulated", HFILL
}
525 { &hf_gre_flags_and_version
,
526 { "Flags and Version", "gre.flags_and_version",
527 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
528 "The GRE flags are encoded in the first two octets", HFILL
}
530 { &hf_gre_flags_checksum
,
531 { "Checksum Bit", "gre.flags.checksum",
532 FT_BOOLEAN
, 16, TFS(&tfs_yes_no
), GRE_CHECKSUM
,
533 "Indicates if the Checksum field is present", HFILL
}
535 { &hf_gre_flags_routing
,
536 { "Routing Bit", "gre.flags.routing",
537 FT_BOOLEAN
, 16, TFS(&tfs_yes_no
), GRE_ROUTING
,
538 "Indicates if the Routing and Checksum/Offset field are present", HFILL
}
541 { "Key Bit", "gre.flags.key",
542 FT_BOOLEAN
, 16, TFS(&tfs_yes_no
), GRE_KEY
,
543 "Indicates if the Key field is present", HFILL
}
545 { &hf_gre_flags_sequence_number
,
546 { "Sequence Number Bit", "gre.flags.sequence_number",
547 FT_BOOLEAN
, 16, TFS(&tfs_yes_no
), GRE_SEQUENCE
,
548 "Indicates if the Sequence Number field is present", HFILL
}
550 { &hf_gre_flags_strict_source_route
,
551 { "Strict Source Route Bit", "gre.flags.strict_source_route",
552 FT_BOOLEAN
, 16, TFS(&tfs_yes_no
), GRE_STRICTSOURCE
,
555 { &hf_gre_flags_recursion_control
,
556 { "Recursion control", "gre.flags.recursion_control",
557 FT_UINT16
, BASE_DEC
, NULL
, GRE_RECURSION
,
561 { "Acknowledgment", "gre.flags.ack",
562 FT_BOOLEAN
, 16, TFS(&tfs_yes_no
), GRE_ACK
,
563 "Indicates if the packet packet contains Acknowledgment Number to be used for acknowledging previously transmitted data", HFILL
}
565 { &hf_gre_flags_reserved
,
566 { "Flags (Reserved)", "gre.flags.reserved",
567 FT_UINT16
, BASE_DEC
, NULL
, GRE_RESERVED
,
570 { &hf_gre_flags_reserved_ppp
,
571 { "Flags (Reserved)", "gre.flags.reserved",
572 FT_UINT16
, BASE_DEC
, NULL
, GRE_RESERVED_PPP
,
575 { &hf_gre_flags_version
,
576 { "Version", "gre.flags.version",
577 FT_UINT16
, BASE_DEC
, VALS(gre_version
), GRE_VERSION
,
581 { "Checksum", "gre.checksum",
582 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
583 "The Checksum field contains the IP (one's complement) checksum of the GRE header and the payload packet", HFILL
}
586 { "Offset", "gre.offset",
587 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
588 "The offset field indicates the octet offset from the start of the Routing field to the first octet of the active Source Route Entry to be examined", HFILL
}
592 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
593 "The Key field contains a four octet number which was inserted by the encapsulator", HFILL
}
595 { &hf_gre_key_payload_length
,
596 { "Payload Length", "gre.key.payload_length",
597 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
598 "Size of the payload, not including the GRE header", HFILL
}
600 { &hf_gre_key_call_id
,
601 { "Call ID", "gre.key.call_id",
602 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
603 "Contains the Peer's Call ID for the session to which this packet belongs.", HFILL
}
605 { &hf_gre_sequence_number
,
606 { "Sequence Number", "gre.sequence_number",
607 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
608 "The Sequence Number field contains an unsigned 32 bit integer which is inserted by the encapsulator", HFILL
}
610 { &hf_gre_ack_number
,
611 { "Acknowledgment Number", "gre.ack_number",
612 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
613 "Contains the sequence number of the highest numbered GRE packet received by the sending peer for this user session", HFILL
}
616 { "Routing", "gre.routing",
617 FT_NONE
, BASE_NONE
, NULL
, 0x0,
618 "The Routing field is a list of Source Route Entries (SREs)", HFILL
}
620 { &hf_gre_routing_address_family
,
621 { "Address Family", "gre.routing.address_family",
622 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
623 "The Address Family field contains a two octet value which indicates the syntax and semantics of the Routing Information field", HFILL
}
625 { &hf_gre_routing_sre_offset
,
626 { "SRE Offset", "gre.routing.sre_offset",
627 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
628 "The Address Family field contains a two octet value which indicates the syntax and semantics of the Routing Information field", HFILL
}
630 { &hf_gre_routing_sre_length
,
631 { "SRE Length", "gre.routing.src_length",
632 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
633 "The SRE Length field contains the number of octets in the SRE", HFILL
}
635 { &hf_gre_routing_information
,
636 { "Routing Information", "gre.routing.information",
637 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
638 "The Routing Information field contains data which may be used in routing this packet", HFILL
}
640 { &hf_gre_3ggp2_attrib
,
641 { "3GGP2 Attributes", "gre.ggp2_attrib",
642 FT_NONE
, BASE_NONE
, NULL
, 0x0,
645 { &hf_gre_3ggp2_attrib_id
,
646 { "Type", "gre.ggp2_attrib_id",
647 FT_UINT8
, BASE_HEX
, VALS(gre_3ggp2_attrib_id_vals
), 0x7f,
650 { &hf_gre_3ggp2_attrib_length
,
651 { "Length", "gre.ggp2_attrib_length",
652 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
656 { "SDI/DOS", "gre.3ggp2_sdi",
657 FT_BOOLEAN
, 16, TFS(&gre_3ggp2_sdi_val
), 0x8000,
658 "Short Data Indicator(SDI)/Data Over Signaling (DOS)", HFILL
}
661 { "Flow Control Indicator", "gre.3ggp2_fci",
662 FT_BOOLEAN
, 16, TFS(&gre_3ggp2_fci_val
), 0x8000,
666 { "Duration Indicator", "gre.3ggp2_di",
667 FT_BOOLEAN
, 16, TFS(&gre_3ggp2_di_val
), 0x4000,
670 { &hf_gre_3ggp2_flow_disc
,
671 { "Flow ID", "gre.ggp2_flow_disc",
672 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
676 { "Type", "gre.ggp2_3ggp2_seg",
677 FT_UINT16
, BASE_HEX
, VALS(gre_3ggp2_seg_vals
), 0xc000,
681 { &hf_gre_wccp_redirect_header
,
682 { "Redirect Header", "gre.wccp.redirect_header",
683 FT_NONE
, BASE_NONE
, NULL
, 0x0,
686 { &hf_gre_wccp_dynamic_service
,
687 { "Dynamic Service", "gre.wccp.dynamic_service",
688 FT_BOOLEAN
, 8, TFS(&gre_wccp_dynamic_service_val
), 0x01,
691 { &hf_gre_wccp_alternative_bucket_used
,
692 { "Alternative bucket used", "gre.wccp.alternative_bucket_used",
693 FT_BOOLEAN
, 8, TFS(&gre_wccp_alternative_bucket_used_val
), 0x02,
696 { &hf_gre_wccp_redirect_header_valid
,
697 { "WCCP Redirect header is valid", "gre.wccp.redirect_header_valid",
698 FT_BOOLEAN
, 8, TFS(&gre_wccp_redirect_header_valid_val
), 0x04,
701 { &hf_gre_wccp_service_id
,
702 { "Service ID", "gre.wccp.service_id",
703 FT_UINT8
, BASE_DEC
, VALS(service_id_vals
), 0x00,
704 "Service Group identifier", HFILL
}
706 { &hf_gre_wccp_alternative_bucket
,
707 { "Alternative Bucket", "gre.wccp.alternative_bucket",
708 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
709 "Alternative bucket index used to redirect the packet.", HFILL
}
711 { &hf_gre_wccp_primary_bucket
,
712 { "Primary Bucket", "gre.wccp.primary_bucket",
713 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
714 "Primary bucket index used to redirect the packet.", HFILL
}
717 static gint
*ett
[] = {
721 &ett_gre_wccp2_redirect_header
,
727 static ei_register_info ei
[] = {
728 { &ei_gre_checksum_incorrect
, { "gre.checksum.incorrect", PI_PROTOCOL
, PI_WARN
, "Incorrect GRE Checksum", EXPFILL
}},
731 expert_module_t
* expert_gre
;
733 proto_gre
= proto_register_protocol("Generic Routing Encapsulation",
735 proto_register_field_array(proto_gre
, hf
, array_length(hf
));
736 proto_register_subtree_array(ett
, array_length(ett
));
737 expert_gre
= expert_register_protocol(proto_gre
);
738 expert_register_field_array(expert_gre
, ei
, array_length(ei
));
740 /* subdissector code */
741 gre_dissector_table
= register_dissector_table("gre.proto",
742 "GRE protocol type", FT_UINT16
, BASE_HEX
);
746 proto_reg_handoff_gre(void)
748 dissector_handle_t gre_handle
;
750 gre_handle
= create_dissector_handle(dissect_gre
, proto_gre
);
751 dissector_add_uint("ip.proto", IP_PROTO_GRE
, gre_handle
);
752 data_handle
= find_dissector("data");