2 * Routines for the Generic Routing Encapsulation (GRE) protocol
3 * Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include <epan/packet.h>
16 #include <epan/capture_dissectors.h>
17 #include <epan/etypes.h>
18 #include <epan/in_cksum.h>
19 #include <epan/expert.h>
20 #include <epan/ipproto.h>
21 #include <epan/llcsaps.h>
22 #include "packet-gre.h"
23 #include "packet-wccp.h"
25 #include <epan/decode_as.h>
27 #define GRE_IN_UDP_PORT 4754
29 void proto_register_gre(void);
30 void proto_reg_handoff_gre(void);
32 static dissector_handle_t gre_handle
;
33 static capture_dissector_handle_t gre_cap_handle
;
37 * See RFC 1701 "Generic Routing Encapsulation (GRE)", RFC 1702
38 * "Generic Routing Encapsulation over IPv4 networks", RFC 2637
39 * "Point-to-Point Tunneling Protocol (PPTP)", RFC 2784 "Generic
40 * Routing Encapsulation (GRE)", RFC 2890 "Key and Sequence
41 * Number Extensions to GRE", RFC 8086 "GRE-in-UDP Encapsulation",
42 * and draft-ietf-mpls-in-ip-or-gre-07.txt
43 * "Encapsulating MPLS in IP or Generic Routing Encapsulation (GRE)".
47 static int hf_gre_proto
;
48 static int hf_gre_flags_and_version
;
49 static int hf_gre_flags_checksum
;
50 static int hf_gre_flags_routing
;
51 static int hf_gre_flags_key
;
52 static int hf_gre_flags_sequence_number
;
53 static int hf_gre_flags_strict_source_route
;
54 static int hf_gre_flags_recursion_control
;
55 static int hf_gre_flags_ack
;
56 static int hf_gre_flags_reserved_ppp
;
57 static int hf_gre_flags_reserved
;
58 static int hf_gre_flags_version
;
59 static int hf_gre_checksum
;
60 static int hf_gre_checksum_status
;
61 static int hf_gre_offset
;
62 static int hf_gre_key
;
63 static int hf_gre_key_payload_length
;
64 static int hf_gre_key_call_id
;
65 static int hf_gre_sequence_number
;
66 static int hf_gre_ack_number
;
67 static int hf_gre_routing
;
68 static int hf_gre_routing_address_family
;
69 static int hf_gre_routing_sre_length
;
70 static int hf_gre_routing_sre_offset
;
71 static int hf_gre_routing_information
;
73 /* Ref 3GPP2 A.S0012-C v2.0 and A.S0008-A v1.0 */
74 static int hf_gre_3gpp2_attrib
;
75 static int hf_gre_3gpp2_attrib_id
;
76 static int hf_gre_3gpp2_attrib_length
;
77 static int hf_gre_3gpp2_sdi
;
78 static int hf_gre_3gpp2_fci
;
79 static int hf_gre_3gpp2_di
;
80 static int hf_gre_3gpp2_flow_disc
;
81 static int hf_gre_3gpp2_seg
;
83 static int hf_gre_wccp_redirect_header
;
84 static int hf_gre_wccp_dynamic_service
;
85 static int hf_gre_wccp_alternative_bucket_used
;
86 static int hf_gre_wccp_redirect_header_valid
;
87 static int hf_gre_wccp_service_id
;
88 static int hf_gre_wccp_alternative_bucket
;
89 static int hf_gre_wccp_primary_bucket
;
92 static int ett_gre_flags
;
93 static int ett_gre_routing
;
94 static int ett_gre_wccp2_redirect_header
;
95 static int ett_3gpp2_attribs
;
96 static int ett_3gpp2_attr
;
98 static expert_field ei_gre_checksum_incorrect
;
100 static dissector_table_t gre_dissector_table
;
102 static dissector_table_t gre_subdissector_table
;
104 static const value_string gre_version
[] = {
105 { 0, "GRE" }, /* [RFC2784] */
106 { 1, "Enhanced GRE" }, /* [RFC2637] */
109 const value_string gre_typevals
[] = {
110 { GRE_KEEPALIVE
, "Possible GRE keepalive packet" },
111 { ETHERTYPE_PPP
, "PPP" },
112 { ETHERTYPE_IP
, "IP" },
113 { ETHERTYPE_ARP
, "ARP" },
114 { SAP_OSINL5
, "OSI"},
116 { GRE_CISCO_CDP
, "CDP (Cisco)"},
118 { GRE_ERSPAN_88BE
, "ERSPAN"},
119 { GRE_ERSPAN_22EB
, "ERSPAN III"},
120 { GRE_MIKROTIK_EOIP
, "MIKROTIK EoIP"},
121 { GRE_AIROHIVE
, "AIROHIVE AP AP"},
122 { ETHERTYPE_IPX
, "IPX"},
123 { ETHERTYPE_ETHBRIDGE
, "Transparent Ethernet bridging" },
124 { ETHERTYPE_RAW_FR
, "Frame Relay"},
125 { ETHERTYPE_IPv6
, "IPv6" },
126 { ETHERTYPE_MPLS
, "MPLS label switched packet" },
127 { ETHERTYPE_NSH
, "Network Service Header" },
128 { ETHERTYPE_CDMA2000_A10_UBS
,"CDMA2000 A10 Unstructured byte stream" },
129 { ETHERTYPE_3GPP2
, "CDMA2000 A10 3GPP2 Packet" },
130 { ETHERTYPE_CMD
, "CiscoMetaData" },
131 { GRE_GREBONDING
, "Huawei GRE bonding" },
132 { GRE_ARUBA_8200
, "ARUBA WLAN" },
133 { GRE_ARUBA_8210
, "ARUBA WLAN" },
134 { GRE_ARUBA_8220
, "ARUBA WLAN" },
135 { GRE_ARUBA_8230
, "ARUBA WLAN" },
136 { GRE_ARUBA_8240
, "ARUBA WLAN" },
137 { GRE_ARUBA_8250
, "ARUBA WLAN" },
138 { GRE_ARUBA_8260
, "ARUBA WLAN" },
139 { GRE_ARUBA_8270
, "ARUBA WLAN" },
140 { GRE_ARUBA_8280
, "ARUBA WLAN" },
141 { GRE_ARUBA_8290
, "ARUBA WLAN" },
142 { GRE_ARUBA_82A0
, "ARUBA WLAN" },
143 { GRE_ARUBA_82B0
, "ARUBA WLAN" },
144 { GRE_ARUBA_82C0
, "ARUBA WLAN" },
145 { GRE_ARUBA_82D0
, "ARUBA WLAN" },
146 { GRE_ARUBA_82E0
, "ARUBA WLAN" },
147 { GRE_ARUBA_82F0
, "ARUBA WLAN" },
148 { GRE_ARUBA_8300
, "ARUBA WLAN" },
149 { GRE_ARUBA_8310
, "ARUBA WLAN" },
150 { GRE_ARUBA_8320
, "ARUBA WLAN" },
151 { GRE_ARUBA_8330
, "ARUBA WLAN" },
152 { GRE_ARUBA_8340
, "ARUBA WLAN" },
153 { GRE_ARUBA_8350
, "ARUBA WLAN" },
154 { GRE_ARUBA_8360
, "ARUBA WLAN" },
155 { GRE_ARUBA_8370
, "ARUBA WLAN" },
156 { GRE_ARUBA_9000
, "ARUBA WLAN" },
157 { GRE_ARUBA_9100
, "ARUBA WLAN" },
158 { GRE_ARUBA_9110
, "ARUBA WLAN" },
159 { GRE_ARUBA_9120
, "ARUBA WLAN" },
160 { GRE_ARUBA_9130
, "ARUBA WLAN" },
161 { GRE_ARUBA_9140
, "ARUBA WLAN" },
162 { GRE_ARUBA_9150
, "ARUBA WLAN" },
163 { GRE_ARUBA_9160
, "ARUBA WLAN" },
164 { GRE_ARUBA_9170
, "ARUBA WLAN" },
165 { GRE_ARUBA_9180
, "ARUBA WLAN" },
166 { GRE_ARUBA_9190
, "ARUBA WLAN" },
167 { GRE_ARUBA_91A0
, "ARUBA WLAN" },
168 { GRE_ARUBA_91B0
, "ARUBA WLAN" },
169 { GRE_ARUBA_91C0
, "ARUBA WLAN" },
170 { GRE_ARUBA_91D0
, "ARUBA WLAN" },
171 { GRE_ARUBA_91E0
, "ARUBA WLAN" },
172 { GRE_ARUBA_91F0
, "ARUBA WLAN" },
176 #define ID_3GPP2_SDI_FLAG 1
177 #define ID_3GPP2_FLOW_CTRL 2
178 #define ID_3GPP2_FLOW_DISCRIMINATOR 3
179 #define ID_3GPP2_SEG 4
181 static const value_string gre_3gpp2_seg_vals
[] = {
182 { 0x00, "Packet Started" },
183 { 0x01, "Packet continued" },
184 { 0x02, "Packet Ended" },
187 /* 3GPP2 A.S0012-C v2.0
188 * 2.6.1 GRE Attributes
190 static const value_string gre_3gpp2_attrib_id_vals
[] = {
191 { 0x01, "1x SDB/HRPD DOS Indicator" },
192 { 0x02, "Flow Control Indication" },
194 { 0x03, "IP Flow Discriminator" },
195 { 0x04, "Segmentation Indication" },
199 static const true_false_string gre_3gpp2_sdi_val
= {
200 "Packet suitable for 1x SDB or HRPD DOS transmission",
204 static const true_false_string gre_3gpp2_fci_val
= {
209 static const true_false_string gre_3gpp2_di_val
= {
214 static const true_false_string gre_wccp_dynamic_service_val
= {
219 static const true_false_string gre_wccp_alternative_bucket_used_val
= {
220 "Alternative bucket used",
221 "Primary bucket used",
224 static const true_false_string gre_wccp_redirect_header_valid_val
= {
225 "Header is present, but ignore contents",
226 "Header contents are valid",
231 dissect_gre_3gpp2_attribs(tvbuff_t
*tvb
, int offset
, proto_tree
*tree
)
233 bool last_attrib
= false;
234 proto_item
*attr_item
;
235 proto_tree
*attr_tree
;
237 int start_offset
= offset
;
239 proto_item
*ti
= proto_tree_add_item(tree
, hf_gre_3gpp2_attrib
, tvb
, offset
, 0, ENC_NA
);
240 proto_tree
*atree
= proto_item_add_subtree(ti
, ett_3gpp2_attribs
);
242 while(last_attrib
!= true)
244 uint8_t attrib_id
= tvb_get_uint8(tvb
, offset
);
245 uint8_t attrib_length
= tvb_get_uint8(tvb
, offset
+ 1);
247 attr_tree
= proto_tree_add_subtree(atree
, tvb
, offset
, attrib_length
+ 1 + 1, ett_3gpp2_attr
, &attr_item
,
248 val_to_str((attrib_id
&0x7f), gre_3gpp2_attrib_id_vals
, "%u (Unknown)"));
250 proto_tree_add_item(attr_tree
, hf_gre_3gpp2_attrib_id
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
251 proto_tree_add_item(attr_tree
, hf_gre_3gpp2_attrib_length
, tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
254 last_attrib
= (attrib_id
& 0x80)?true:false;
259 case ID_3GPP2_FLOW_DISCRIMINATOR
:
261 value
= tvb_get_uint8(tvb
,offset
);
262 proto_tree_add_item(attr_tree
, hf_gre_3gpp2_flow_disc
, tvb
, offset
, attrib_length
, ENC_NA
);
263 proto_item_append_text(attr_item
," - 0x%x",value
);
266 case ID_3GPP2_SDI_FLAG
:
268 value
= tvb_get_uint8(tvb
,offset
);
269 proto_tree_add_item(attr_tree
, hf_gre_3gpp2_sdi
, tvb
, offset
, attrib_length
, ENC_BIG_ENDIAN
);
270 proto_item_append_text(attr_item
," - %s",
271 (value
& 0x80) ? "Packet suitable for 1x SDB or HRPD DOS transmission" : "Reserved");
277 value
= tvb_get_uint8(tvb
,offset
) >>6;
278 proto_tree_add_item(attr_tree
, hf_gre_3gpp2_seg
, tvb
, offset
, attrib_length
, ENC_BIG_ENDIAN
);
279 proto_item_append_text(attr_item
," - %s",val_to_str(value
, gre_3gpp2_seg_vals
, "0x%02X - Unknown"));
282 case ID_3GPP2_FLOW_CTRL
:
284 value
= tvb_get_uint8(tvb
,offset
);
285 proto_tree_add_item(attr_tree
, hf_gre_3gpp2_fci
, tvb
, offset
, attrib_length
, ENC_BIG_ENDIAN
);
286 proto_item_append_text(attr_item
," - %s",
287 (value
& 0x80) ? "XON" : "XOFF");
288 proto_tree_add_item(attr_tree
, hf_gre_3gpp2_di
, tvb
, offset
, attrib_length
, ENC_BIG_ENDIAN
);
289 proto_item_append_text(attr_item
,"/%s",
290 (value
& 0x40) ? "INDEFINITE" : "TEMPORARY");
295 offset
+= attrib_length
;
297 proto_item_set_len(ti
, offset
- start_offset
);
303 dissect_gre_wccp2_redirect_header(tvbuff_t
*tvb
, int offset
, proto_tree
*tree
)
308 ti
= proto_tree_add_item(tree
, hf_gre_wccp_redirect_header
, tvb
, offset
, 4, ENC_NA
);
309 rh_tree
= proto_item_add_subtree(ti
, ett_gre_wccp2_redirect_header
);
311 proto_tree_add_item(rh_tree
, hf_gre_wccp_dynamic_service
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
313 proto_tree_add_item(rh_tree
, hf_gre_wccp_alternative_bucket_used
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
315 proto_tree_add_item(rh_tree
, hf_gre_wccp_redirect_header_valid
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
317 proto_tree_add_item(rh_tree
, hf_gre_wccp_service_id
, tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
319 proto_tree_add_item(rh_tree
, hf_gre_wccp_alternative_bucket
, tvb
, offset
+2, 1, ENC_BIG_ENDIAN
);
321 proto_tree_add_item(rh_tree
, hf_gre_wccp_primary_bucket
, tvb
, offset
+3, 1, ENC_BIG_ENDIAN
);
325 capture_gre(const unsigned char *pd _U_
, int offset _U_
, int len _U_
, capture_packet_info_t
*cpinfo
, const union wtap_pseudo_header
*pseudo_header _U_
)
327 capture_dissector_increment_count(cpinfo
, proto_gre
);
332 dissect_gre(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
336 gre_hdr_info_t gre_hdr_info
;
339 bool is_wccp2
= false;
340 proto_item
*ti
, *it_flags
;
341 proto_tree
*gre_tree
, *fv_tree
= NULL
;
346 gre_hdr_info
.flags_and_ver
= tvb_get_ntohs(tvb
, offset
);
347 type
= tvb_get_ntohs(tvb
, offset
+ 2);
349 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "GRE");
351 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Encapsulated %s", val_to_str(type
, gre_typevals
, "0x%04X (unknown)"));
356 if (gre_hdr_info
.flags_and_ver
& GRE_VERSION
)
359 case ETHERTYPE_3GPP2
:
360 case ETHERTYPE_CDMA2000_A10_UBS
:
365 /* WCCP2 puts an extra 4 octets into the header, but uses the same
366 encapsulation type; if it looks as if the first octet of the packet
367 isn't the beginning of an IPv4 header, assume it's WCCP2. */
368 if ((tvb_get_uint8(tvb
, offset
+ 2 + 2) & 0xF0) != 0x40) {
374 /* Per README.developer, section 1.2, we must call subdissectors regardless
375 * of whether "tree" is NULL or not. That is done below using
376 * call_dissector(), but since the next_tvb must begin at the correct offset,
377 * it's easier and more readable to always enter this block in order to
378 * compute the correct offset to pass to tvb_new_subset_remaining().
381 ti
= proto_tree_add_protocol_format(tree
, proto_gre
, tvb
, offset
, -1, "Generic Routing Encapsulation (%s)",
382 val_to_str(type
, gre_typevals
, "0x%04X - unknown"));
383 gre_tree
= proto_item_add_subtree(ti
, ett_gre
);
386 it_flags
= proto_tree_add_item(gre_tree
, hf_gre_flags_and_version
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
387 fv_tree
= proto_item_add_subtree(it_flags
, ett_gre_flags
);
389 proto_tree_add_item(fv_tree
, hf_gre_flags_checksum
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
391 proto_tree_add_item(fv_tree
, hf_gre_flags_routing
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
393 proto_tree_add_item(fv_tree
, hf_gre_flags_key
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
395 proto_tree_add_item(fv_tree
, hf_gre_flags_sequence_number
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
397 proto_tree_add_item(fv_tree
, hf_gre_flags_strict_source_route
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
399 proto_tree_add_item(fv_tree
, hf_gre_flags_recursion_control
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
401 /* RFC2637 Section 4.1 : Enhanced GRE Header */
403 proto_tree_add_item(fv_tree
, hf_gre_flags_ack
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
405 proto_tree_add_item(fv_tree
, hf_gre_flags_reserved_ppp
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
408 proto_tree_add_item(fv_tree
, hf_gre_flags_reserved
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
411 proto_tree_add_item(fv_tree
, hf_gre_flags_version
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
415 proto_tree_add_item(gre_tree
, hf_gre_proto
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
418 if (gre_hdr_info
.flags_and_ver
& GRE_CHECKSUM
|| gre_hdr_info
.flags_and_ver
& GRE_ROUTING
) {
419 unsigned length
, reported_length
;
422 /* Checksum check !... */
423 length
= tvb_captured_length(tvb
);
424 reported_length
= tvb_reported_length(tvb
);
425 /* The Checksum Present bit is set, and the packet isn't part of a
426 fragmented datagram and isn't truncated, so we can checksum it. */
427 if ((gre_hdr_info
.flags_and_ver
& GRE_CHECKSUM
) && !pinfo
->fragmented
&& length
>= reported_length
) {
428 SET_CKSUM_VEC_TVB(cksum_vec
[0], tvb
, 0, reported_length
);
429 proto_tree_add_checksum(gre_tree
, tvb
, offset
, hf_gre_checksum
, hf_gre_checksum_status
, &ei_gre_checksum_incorrect
, pinfo
, in_cksum(cksum_vec
, 1),
430 ENC_BIG_ENDIAN
, PROTO_CHECKSUM_VERIFY
|PROTO_CHECKSUM_IN_CKSUM
);
432 proto_tree_add_checksum(gre_tree
, tvb
, offset
, hf_gre_checksum
, hf_gre_checksum_status
, &ei_gre_checksum_incorrect
, pinfo
, 0,
433 ENC_BIG_ENDIAN
, PROTO_CHECKSUM_NO_FLAGS
);
437 proto_tree_add_item(gre_tree
, hf_gre_offset
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
441 if (gre_hdr_info
.flags_and_ver
& GRE_KEY
) {
442 /* RFC2637 Section 4.1 : Enhanced GRE Header */
443 if (is_ppp
&& type
!=ETHERTYPE_CDMA2000_A10_UBS
) {
445 proto_tree_add_item(gre_tree
, hf_gre_key_payload_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
448 proto_tree_add_item(gre_tree
, hf_gre_key_call_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
452 proto_tree_add_item_ret_uint(gre_tree
, hf_gre_key
, tvb
, offset
, 4, ENC_BIG_ENDIAN
, &gre_hdr_info
.key
);
456 if (gre_hdr_info
.flags_and_ver
& GRE_SEQUENCE
) {
458 proto_tree_add_item(gre_tree
, hf_gre_sequence_number
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
461 if (is_ppp
&& (gre_hdr_info
.flags_and_ver
& GRE_ACK
)) {
463 proto_tree_add_item(gre_tree
, hf_gre_ack_number
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
466 if (gre_hdr_info
.flags_and_ver
& GRE_ROUTING
) {
467 proto_item
*it_routing
;
471 it_routing
= proto_tree_add_item(gre_tree
, hf_gre_routing
, tvb
, offset
, -1, ENC_NA
);
472 r_tree
= proto_item_add_subtree(ti
, ett_gre_routing
);
474 sre_af
= tvb_get_ntohs(tvb
, offset
);
475 proto_tree_add_item(r_tree
, hf_gre_routing_address_family
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
478 proto_tree_add_item(r_tree
, hf_gre_routing_sre_offset
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
481 sre_length
= tvb_get_uint8(tvb
, offset
);
482 proto_tree_add_item(r_tree
, hf_gre_routing_sre_length
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
485 proto_item_set_len(it_routing
, 2 + 1 +1 + sre_length
);
486 if (sre_af
== 0 && sre_length
== 0)
489 proto_tree_add_item(r_tree
, hf_gre_routing_information
, tvb
, offset
, sre_length
, ENC_NA
);
490 offset
+= sre_length
;
494 if (type
== GRE_WCCP
&& is_wccp2
) {
495 dissect_gre_wccp2_redirect_header(tvb
, offset
, gre_tree
);
498 if (type
== ETHERTYPE_3GPP2
) {
499 offset
= dissect_gre_3gpp2_attribs(tvb
, offset
, gre_tree
);
502 proto_item_set_len(ti
, offset
);
504 /* If the S bit is not set, this packet might not have a payload, so
505 check whether there's any data left, first.
507 XXX - the S bit isn't in RFC 2784, which deprecates that bit
508 and some other bits in RFC 1701 and says that they should be
509 zero for RFC 2784-compliant GRE; as such, the absence of the
510 S bit doesn't necessarily mean there's no payload. */
511 if (!(gre_hdr_info
.flags_and_ver
& GRE_SEQUENCE
)) {
512 if (tvb_reported_length_remaining(tvb
, offset
) <= 0)
513 return offset
; /* no payload */
515 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
516 pinfo
->flags
.in_gre_pkt
= true;
517 if (!dissector_try_uint_with_data(gre_dissector_table
, type
, next_tvb
, pinfo
, tree
, true, &gre_hdr_info
))
518 if (!dissector_try_payload_with_data(gre_subdissector_table
, next_tvb
, pinfo
, tree
, true, &gre_hdr_info
)) {
519 call_data_dissector(next_tvb
, pinfo
, gre_tree
);
522 return tvb_captured_length(tvb
);
526 gre_prompt(packet_info
*pinfo _U_
, char* result
)
528 snprintf(result
, MAX_DECODE_AS_PROMPT_LEN
, "GRE proto as");
532 proto_register_gre(void)
534 static hf_register_info hf
[] = {
536 { "Protocol Type", "gre.proto",
537 FT_UINT16
, BASE_HEX
, VALS(gre_typevals
), 0x0,
538 "The protocol that is GRE encapsulated", HFILL
}
540 { &hf_gre_flags_and_version
,
541 { "Flags and Version", "gre.flags_and_version",
542 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
543 "The GRE flags are encoded in the first two octets", HFILL
}
545 { &hf_gre_flags_checksum
,
546 { "Checksum Bit", "gre.flags.checksum",
547 FT_BOOLEAN
, 16, TFS(&tfs_yes_no
), GRE_CHECKSUM
,
548 "Indicates if the Checksum field is present", HFILL
}
550 { &hf_gre_flags_routing
,
551 { "Routing Bit", "gre.flags.routing",
552 FT_BOOLEAN
, 16, TFS(&tfs_yes_no
), GRE_ROUTING
,
553 "Indicates if the Routing and Checksum/Offset field are present", HFILL
}
556 { "Key Bit", "gre.flags.key",
557 FT_BOOLEAN
, 16, TFS(&tfs_yes_no
), GRE_KEY
,
558 "Indicates if the Key field is present", HFILL
}
560 { &hf_gre_flags_sequence_number
,
561 { "Sequence Number Bit", "gre.flags.sequence_number",
562 FT_BOOLEAN
, 16, TFS(&tfs_yes_no
), GRE_SEQUENCE
,
563 "Indicates if the Sequence Number field is present", HFILL
}
565 { &hf_gre_flags_strict_source_route
,
566 { "Strict Source Route Bit", "gre.flags.strict_source_route",
567 FT_BOOLEAN
, 16, TFS(&tfs_yes_no
), GRE_STRICTSOURCE
,
570 { &hf_gre_flags_recursion_control
,
571 { "Recursion control", "gre.flags.recursion_control",
572 FT_UINT16
, BASE_DEC
, NULL
, GRE_RECURSION
,
576 { "Acknowledgment", "gre.flags.ack",
577 FT_BOOLEAN
, 16, TFS(&tfs_yes_no
), GRE_ACK
,
578 "Indicates if the packet contains an Acknowledgment Number to be used for acknowledging previously transmitted data", HFILL
}
580 { &hf_gre_flags_reserved
,
581 { "Flags (Reserved)", "gre.flags.reserved",
582 FT_UINT16
, BASE_DEC
, NULL
, GRE_RESERVED
,
585 { &hf_gre_flags_reserved_ppp
,
586 { "Flags (Reserved)", "gre.flags.reserved",
587 FT_UINT16
, BASE_DEC
, NULL
, GRE_RESERVED_PPP
,
590 { &hf_gre_flags_version
,
591 { "Version", "gre.flags.version",
592 FT_UINT16
, BASE_DEC
, VALS(gre_version
), GRE_VERSION
,
596 { "Checksum", "gre.checksum",
597 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
598 "The Checksum field contains the IP (one's complement) checksum of the GRE header and the payload packet", HFILL
}
600 { &hf_gre_checksum_status
,
601 { "Checksum Status", "gre.checksum.status",
602 FT_UINT8
, BASE_NONE
, VALS(proto_checksum_vals
), 0x0,
606 { "Offset", "gre.offset",
607 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
608 "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
}
612 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
613 "The Key field contains a four octet number which was inserted by the encapsulator", HFILL
}
615 { &hf_gre_key_payload_length
,
616 { "Payload Length", "gre.key.payload_length",
617 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
618 "Size of the payload, not including the GRE header", HFILL
}
620 { &hf_gre_key_call_id
,
621 { "Call ID", "gre.key.call_id",
622 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
623 "Contains the Peer's Call ID for the session to which this packet belongs.", HFILL
}
625 { &hf_gre_sequence_number
,
626 { "Sequence Number", "gre.sequence_number",
627 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
628 "The Sequence Number field contains an unsigned 32 bit integer which is inserted by the encapsulator", HFILL
}
630 { &hf_gre_ack_number
,
631 { "Acknowledgment Number", "gre.ack_number",
632 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
633 "Contains the sequence number of the highest numbered GRE packet received by the sending peer for this user session", HFILL
}
636 { "Routing", "gre.routing",
637 FT_NONE
, BASE_NONE
, NULL
, 0x0,
638 "The Routing field is a list of Source Route Entries (SREs)", HFILL
}
640 { &hf_gre_routing_address_family
,
641 { "Address Family", "gre.routing.address_family",
642 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
643 "The Address Family field contains a two octet value which indicates the syntax and semantics of the Routing Information field", HFILL
}
645 { &hf_gre_routing_sre_offset
,
646 { "SRE Offset", "gre.routing.sre_offset",
647 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
648 "The Address Family field contains a two octet value which indicates the syntax and semantics of the Routing Information field", HFILL
}
650 { &hf_gre_routing_sre_length
,
651 { "SRE Length", "gre.routing.src_length",
652 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
653 "The SRE Length field contains the number of octets in the SRE", HFILL
}
655 { &hf_gre_routing_information
,
656 { "Routing Information", "gre.routing.information",
657 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
658 "The Routing Information field contains data which may be used in routing this packet", HFILL
}
660 { &hf_gre_3gpp2_attrib
,
661 { "3GPP2 Attributes", "gre.3gpp2_attrib",
662 FT_NONE
, BASE_NONE
, NULL
, 0x0,
665 { &hf_gre_3gpp2_attrib_id
,
666 { "Type", "gre.3gpp2_attrib_id",
667 FT_UINT8
, BASE_HEX
, VALS(gre_3gpp2_attrib_id_vals
), 0x7f,
670 { &hf_gre_3gpp2_attrib_length
,
671 { "Length", "gre.3gpp2_attrib_length",
672 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
676 { "SDI/DOS", "gre.3gpp2_sdi",
677 FT_BOOLEAN
, 16, TFS(&gre_3gpp2_sdi_val
), 0x8000,
678 "Short Data Indicator(SDI)/Data Over Signaling (DOS)", HFILL
}
681 { "Flow Control Indicator", "gre.3gpp2_fci",
682 FT_BOOLEAN
, 16, TFS(&gre_3gpp2_fci_val
), 0x8000,
686 { "Duration Indicator", "gre.3gpp2_di",
687 FT_BOOLEAN
, 16, TFS(&gre_3gpp2_di_val
), 0x4000,
690 { &hf_gre_3gpp2_flow_disc
,
691 { "Flow ID", "gre.ggp2_flow_disc",
692 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
696 { "Type", "gre.ggp2_3gpp2_seg",
697 FT_UINT16
, BASE_HEX
, VALS(gre_3gpp2_seg_vals
), 0xc000,
701 { &hf_gre_wccp_redirect_header
,
702 { "Redirect Header", "gre.wccp.redirect_header",
703 FT_NONE
, BASE_NONE
, NULL
, 0x0,
706 { &hf_gre_wccp_dynamic_service
,
707 { "Dynamic Service", "gre.wccp.dynamic_service",
708 FT_BOOLEAN
, 8, TFS(&gre_wccp_dynamic_service_val
), 0x01,
711 { &hf_gre_wccp_alternative_bucket_used
,
712 { "Alternative bucket used", "gre.wccp.alternative_bucket_used",
713 FT_BOOLEAN
, 8, TFS(&gre_wccp_alternative_bucket_used_val
), 0x02,
716 { &hf_gre_wccp_redirect_header_valid
,
717 { "WCCP Redirect header is valid", "gre.wccp.redirect_header_valid",
718 FT_BOOLEAN
, 8, TFS(&gre_wccp_redirect_header_valid_val
), 0x04,
721 { &hf_gre_wccp_service_id
,
722 { "Service ID", "gre.wccp.service_id",
723 FT_UINT8
, BASE_DEC
, VALS(service_id_vals
), 0x00,
724 "Service Group identifier", HFILL
}
726 { &hf_gre_wccp_alternative_bucket
,
727 { "Alternative Bucket", "gre.wccp.alternative_bucket",
728 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
729 "Alternative bucket index used to redirect the packet.", HFILL
}
731 { &hf_gre_wccp_primary_bucket
,
732 { "Primary Bucket", "gre.wccp.primary_bucket",
733 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
734 "Primary bucket index used to redirect the packet.", HFILL
}
737 static int *ett
[] = {
741 &ett_gre_wccp2_redirect_header
,
747 static ei_register_info ei
[] = {
748 { &ei_gre_checksum_incorrect
, { "gre.checksum.incorrect", PI_PROTOCOL
, PI_WARN
, "Incorrect GRE Checksum", EXPFILL
}},
751 expert_module_t
* expert_gre
;
753 proto_gre
= proto_register_protocol("Generic Routing Encapsulation",
755 gre_handle
= register_dissector("gre", dissect_gre
, proto_gre
);
756 gre_cap_handle
= register_capture_dissector("gre", capture_gre
, proto_gre
);
757 proto_register_field_array(proto_gre
, hf
, array_length(hf
));
758 proto_register_subtree_array(ett
, array_length(ett
));
759 expert_gre
= expert_register_protocol(proto_gre
);
760 expert_register_field_array(expert_gre
, ei
, array_length(ei
));
767 * https://www.iana.org/assignments/gre-parameters/gre-parameters.xhtml#gre-parameters-1
769 * these are just Ethertypes; should we use "gre.proto" only for
770 * protocols *not* registered as Ethertypes, such as those listed
771 * in the table in "Current List of Protocol Types" in RFC 1701
772 * ("For historical reasons, a number of other values have been
773 * used for some protocols."), and for protocols encapsulated in GRE
774 * differently from the way they're encapsulated over LAN protocols
775 * (for example, Cisco MetaData), and if we don't get a match there,
776 * use the "ethertype" table?
778 * And should we also somehow do something similar for mapping values
779 * to strings, falling back on etype_vals?
781 gre_dissector_table
= register_dissector_table("gre.proto",
782 "GRE protocol type", proto_gre
, FT_UINT16
, BASE_HEX
);
784 gre_subdissector_table
= register_decode_as_next_proto(proto_gre
, "gre.subproto",
785 "GRE protocol type", gre_prompt
);
789 proto_reg_handoff_gre(void)
791 dissector_add_uint("ip.proto", IP_PROTO_GRE
, gre_handle
);
792 dissector_add_uint("udp.port", GRE_IN_UDP_PORT
, gre_handle
);
793 capture_dissector_add_uint("ip.proto", IP_PROTO_GRE
, gre_cap_handle
);
797 * Editor modelines - https://www.wireshark.org/tools/modelines.html
802 * indent-tabs-mode: nil
805 * vi: set shiftwidth=4 tabstop=8 expandtab:
806 * :indentSize=4:tabSize=8:noTabs=true: