FD.io VPP  v19.04-6-g6f05f72
Vector Packet Processing
packet.h
Go to the documentation of this file.
1 #ifndef included_vnet_gre_packet_h
2 #define included_vnet_gre_packet_h
3 
4 /*
5  * GRE packet format
6  *
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:
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  */
20 
21 #define foreach_gre_protocol \
22 _ (0x0800, ip4) \
23 _ (0x86DD, ip6) \
24 _ (0x6558, teb) \
25 _ (0x0806, arp) \
26 _ (0x8847, mpls_unicast) \
27 _ (0x88BE, erspan) \
28 _ (0x894F, nsh)
29 
30 typedef enum
31 {
32 #define _(n,f) GRE_PROTOCOL_##f = n,
34 #undef _
36 
37 typedef struct
38 {
39  /* flags and version */
41  /* unimplemented at the moment */
42 #define GRE_FLAGS_CHECKSUM (1 << 15)
43 
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)
49 
50  /* version 1 is PPTP which we don't support */
51 #define GRE_SUPPORTED_VERSION 0
52 #define GRE_VERSION_MASK 0x7
53 
54  /* 0x800 for ip4, etc. */
56 } gre_header_t;
57 
58 /* From draft-foschiano-erspan-03.txt
59 
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].
63 
64  GRE header for ERSPAN Type II encapsulation (8 octets [34:41])
65  0 1 2 3
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  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
72 
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.
76 
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
79  raw mirrored frames.
80 
81  The ERSPAN Type II feature header is described below:
82 
83  ERSPAN Type II header (8 octets [42:49])
84  0 1 2 3
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  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
89  | Reserved | Index |
90  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
91 
92  The various fields of the above header are described in this table:
93 
94  Field Position Length Definition
95  [octet:bit] (bits)
96 
97  Ver [42:0] 4 ERSPAN Encapsulation version.
98  This indicates the version of
99  the ERSPAN encapsulation
100  specification. Set to 0x1 for
101  Type II.
102 
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.
107 
108  COS [44:0] 3 Original class of service of the
109  frame, mirrored from the source.
110 
111  En [44:3] 2 The trunk encapsulation type
112  associated with the ERSPAN source
113  port for ingress ERSPAN traffic.
114 
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.
120 
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.
126 
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.)
131 
132  Reserved [46:0] 12 All bits are set to zero
133 
134  Index [47:4] 20 A 20 bit index/port number
135  associated with the ERSPAN
136  traffic's port and
137  direction (ingress/egress). N.B.:
138  This field is platform dependent.
139 */
140 
141 /* *INDENT-OFF* */
142 typedef CLIB_PACKED (struct {
143  u32 seq_num;
144  union
145  {
146  struct
147  {
148  u16 ver_vlan;
149  u16 cos_en_t_session;
150  u32 res_index;
151  } t2;
152  u64 t2_u64;
153  };
154 }) erspan_t2_t;
155 
156 typedef CLIB_PACKED (struct {
157  gre_header_t gre;
158  erspan_t2_t erspan;
159 }) erspan_t2_header_t;
160 
161 /* *INDENT-ON* */
162 
163 /* u64 template for ERSPAN type 2 header with both EN bits set */
164 #define ERSPAN_HDR2 0x1000180000000000ul
165 
166 #endif /* included_vnet_gre_packet_h */
167 
168 /*
169  * fd.io coding-style-patch-verification: ON
170  *
171  * Local Variables:
172  * eval: (c-set-style "gnu")
173  * End:
174  */
#define foreach_gre_protocol
Definition: packet.h:21
unsigned long u64
Definition: types.h:89
unsigned int u32
Definition: types.h:88
unsigned short u16
Definition: types.h:57
u16 flags_and_version
Definition: packet.h:40
u16 protocol
Definition: packet.h:55
typedef CLIB_PACKED(struct{u8 b_dst_address[6];u8 b_src_address[6];u16 b_type;u16 priority_dei_id;u16 i_type;u32 priority_dei_uca_res_sid;}) ethernet_pbb_header_packed_t
gre_protocol_t
Definition: packet.h:30