FD.io VPP  v19.04.4-rc0-5-ge88582fac
Vector Packet Processing
nsh_packet.h
Go to the documentation of this file.
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_nsh_packet_h
16 #define included_nsh_packet_h
17 
18 /*
19  * NSH 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| TTL | 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; //TTL: high 4 bit
73  u8 length; //TTL: low 2 bit
74  u8 md_type;
75  u8 next_protocol;
76  u32 nsp_nsi; // nsp 24 bits, nsi 8 bits
77 }) nsh_base_header_t;
78 
79 typedef CLIB_PACKED(struct {
80  /* Context headers, always present */
81  u32 c1;
82  u32 c2;
83  u32 c3;
84  u32 c4;
85 }) nsh_md1_data_t;
86 
87 typedef CLIB_PACKED(struct {
88  u16 class;
89  u8 type;
90  u8 length;
91 }) nsh_tlv_header_t;
92 
93 typedef nsh_tlv_header_t nsh_md2_data_t;
94 
95 typedef CLIB_PACKED(struct {
96  nsh_base_header_t nsh_base;
97  union {
98  nsh_md1_data_t md1_data;
99  nsh_md2_data_t md2_data;
100  } md;
101 }) nsh_header_t;
102 
103 #define NSH_VERSION (0<<6)
104 #define NSH_O_BIT (1<<5)
105 #define NSH_C_BIT (1<<4)
106 
107 #define NSH_TTL_H4_MASK 0xF
108 #define NSH_TTL_L2_MASK 0xC0
109 #define NSH_LEN_MASK 0x3F
110 
111 /* Network byte order shift / mask */
112 #define NSH_NSI_MASK 0xFF
113 #define NSH_NSP_MASK (0x00FFFFFF)
114 #define NSH_NSP_SHIFT 8
115 
116 #endif /* included_nsh_packet_h */
unsigned char u8
Definition: types.h:56
typedef CLIB_PACKED(struct { u8 ver_o_c;u8 length;u8 md_type;u8 next_protocol;u32 nsp_nsi;}) nsh_base_header_t
unsigned int u32
Definition: types.h:88
unsigned short u16
Definition: types.h:57
nsh_tlv_header_t nsh_md2_data_t
Definition: nsh_packet.h:93