1 #ifndef included_vnet_gre_packet_h
2 #define included_vnet_gre_packet_h
7 * Copyright (c) 2012 Cisco and/or its affiliates.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at:
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #define foreach_gre_protocol \
26 _ (0x8847, mpls_unicast) \
32 #define _(n,f) GRE_PROTOCOL_##f = n,
39 /* flags and version */
40 u16 flags_and_version;
41 /* unimplemented at the moment */
42 #define GRE_FLAGS_CHECKSUM (1 << 15)
44 /* deprecated, according to rfc2784 */
45 #define GRE_FLAGS_ROUTING (1 << 14)
46 #define GRE_FLAGS_KEY (1 << 13)
47 #define GRE_FLAGS_SEQUENCE (1 << 12)
48 #define GRE_FLAGS_STRICT_SOURCE_ROUTE (1 << 11)
50 /* version 1 is PPTP which we don't support */
51 #define GRE_SUPPORTED_VERSION 0
52 #define GRE_VERSION_MASK 0x7
54 /* 0x800 for ip4, etc. */
58 /* From draft-foschiano-erspan-03.txt
60 Different frame variants known as "ERSPAN Types" can be
61 distinguished based on the GRE "Protocol Type" field value: Type I
62 and II's value is 0x88BE while Type III's is 0x22EB [ETYPES].
64 GRE header for ERSPAN Type II encapsulation (8 octets [34:41])
66 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
67 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68 |0|0|0|1|0|00000|000000000|00000| Protocol Type for ERSPAN |
69 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
70 | Sequence Number (increments per packet per session) |
71 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
73 Note that in the above GRE header [RFC1701] out of the C, R, K, S,
74 s, Recur, Flags, Version fields only S (bit 03) may be set to 1. The
75 other fields are always set to zero.
77 ERSPAN Type II's frame format also adds a special 8-octet ERSPAN
78 "feature" header on top of the MAC/IPv4/GRE headers to enclose the
81 The ERSPAN Type II feature header is described below:
83 ERSPAN Type II header (8 octets [42:49])
85 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
86 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
87 | Ver | VLAN | COS | En|T| Session ID |
88 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
90 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
92 The various fields of the above header are described in this table:
94 Field Position Length Definition
97 Ver [42:0] 4 ERSPAN Encapsulation version.
98 This indicates the version of
99 the ERSPAN encapsulation
100 specification. Set to 0x1 for
103 VLAN [42:4] 12 Original VLAN of the frame,
104 mirrored from the source.
105 If the En field is set to 11,
106 the value of VLAN is undefined.
108 COS [44:0] 3 Original class of service of the
109 frame, mirrored from the source.
111 En [44:3] 2 The trunk encapsulation type
112 associated with the ERSPAN source
113 port for ingress ERSPAN traffic.
115 The possible values are:
116 00-originally without VLAN tag
117 01-originally ISL encapsulated
118 10-originally 802.1Q encapsulated
119 11-VLAN tag preserved in frame.
121 T [44:5] 1 This bit indicates that the frame
122 copy encapsulated in the ERSPAN
123 packet has been truncated. This
124 occurs if the ERSPAN encapsulated
125 frame exceeds the configured MTU.
127 Session ID [44:6] 10 Identification associated with
128 (ERSPAN ID) each ERSPAN session. Must be
129 unique between the source and the
130 receiver(s). (See section below.)
132 Reserved [46:0] 12 All bits are set to zero
134 Index [47:4] 20 A 20 bit index/port number
135 associated with the ERSPAN
137 direction (ingress/egress). N.B.:
138 This field is platform dependent.
142 typedef CLIB_PACKED (struct {
149 u16 cos_en_t_session;
156 typedef CLIB_PACKED (struct {
159 }) erspan_t2_header_t;
163 /* u64 template for ERSPAN type 2 header with both EN bits set */
164 #define ERSPAN_HDR2 0x1000180000000000ul
166 #endif /* included_vnet_gre_packet_h */
169 * fd.io coding-style-patch-verification: ON
172 * eval: (c-set-style "gnu")