0620f227b9f8e5efc33bf1c018eaadbb0eb908db
[vpp.git] / vnet / vnet / nsh-gre / nsh_gre_packet.h
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef included_vnet_nsh_gre_packet_h
16 #define included_vnet_nsh_gre_packet_h
17
18 /*
19  * NSH_GRE packet format from draft-quinn-sfc-nsh-03.txt
20  *
21  * NSH Base Header
22  *  0                   1                   2                   3
23  *  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
24  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25  *  |Ver|O|C|R|R|R|R|R|R|   Length  |    MD Type    | Next Protocol |
26  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27  * 
28  * 
29  * Base Header Field Descriptions:
30  * 
31  * Version: The version field is used to ensure backward compatibility
32  * going forward with future NSH updates.
33  * 
34  * O bit: Indicates that this packet is an operations and management
35  * (OAM) packet.  SFF and SFs nodes MUST examine the payload and take
36  * appropriate action (e.g. return status information).
37  * 
38  * OAM message specifics and handling details are outside the scope of
39  * this document.
40  * 
41  * C bit: Indicates that a critical metadata TLV is present (see section
42  * 7).  This bit acts as an indication for hardware implementers to
43  * decide how to handle the presence of a critical TLV without
44  * necessarily needing to parse all TLVs present.  The C bit MUST be set
45  * to 1 if one or more critical TLVs are present.
46  * 
47  * All other flag fields are reserved.
48  * 
49  * Length: total length, in 4 byte words, of the NSH header, including
50  * optional variable TLVs.  Length must be equal or greater than 6.
51  * 
52  * MD Type: indicates the format of NSH beyond the base header and the
53  * type of metadata being carried.  This typing is used to describe the
54  * use for the metadata.  A new registry will be requested from IANA for
55  * the MD Type.  NSH defines one type, type = 0x1 which indicates that
56  * the format of the header is as per this draft.
57  * 
58  * The format of the base header is invariant, and not described by MD
59  * Type.
60  * 
61  * Next Protocol: indicates the protocol type of the original packet.  A
62  * new IANA registry will be created for protocol type.
63  * 
64  * This draft defines the following Next Protocol values:
65  * 
66  * 0x1 : IPv4
67  * 0x2 : IPv6
68  * 0x3 : Ethernet
69  */
70
71 typedef CLIB_PACKED(struct {
72   u8 ver_o_c;
73   u8 length;
74   u8 md_type;
75   u8 next_protocol;
76   u32 spi_si;
77   /* Context headers, always present */
78   u32 c1; u32 c2; u32 c3; u32 c4;
79
80   /* Optional variable length metadata */
81   u32 tlvs[0];
82 }) nsh_header_t;
83
84 #define NSH_GRE_VERSION (0<<6)
85 #define NSH_GRE_O_BIT (1<<5)
86 #define NSH_GRE_C_BIT (1<<4)
87
88 /* Network byte order shift / mask */
89 #define NSH_GRE_SINDEX_MASK 0xFF
90 #define NSH_GRE_SPI_MASK (0x00FFFFFF)
91 #define NSH_GRE_SPI_SHIFT 8
92
93 #endif /* included_vnet_nsh_gre_packet_h */