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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
15 #ifndef included_nsh_packet_h
16 #define included_nsh_packet_h
19 * NSH packet format from draft-quinn-sfc-nsh-03.txt
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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29 * Base Header Field Descriptions:
31 * Version: The version field is used to ensure backward compatibility
32 * going forward with future NSH updates.
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).
38 * OAM message specifics and handling details are outside the scope of
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.
47 * All other flag fields are reserved.
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.
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.
58 * The format of the base header is invariant, and not described by MD
61 * Next Protocol: indicates the protocol type of the original packet. A
62 * new IANA registry will be created for protocol type.
64 * This draft defines the following Next Protocol values:
71 typedef CLIB_PACKED(struct {
72 u8 ver_o_c; //TTL: high 4 bit
73 u8 length; //TTL: low 2 bit
76 u32 nsp_nsi; // nsp 24 bits, nsi 8 bits
79 typedef CLIB_PACKED(struct {
80 /* Context headers, always present */
87 typedef CLIB_PACKED(struct {
93 typedef nsh_tlv_header_t nsh_md2_data_t;
95 typedef CLIB_PACKED(struct {
96 nsh_base_header_t nsh_base;
98 nsh_md1_data_t md1_data;
99 nsh_md2_data_t md2_data;
103 #define NSH_VERSION (0<<6)
104 #define NSH_O_BIT (1<<5)
105 #define NSH_C_BIT (1<<4)
107 #define NSH_TTL_H4_MASK 0xF
108 #define NSH_TTL_L2_MASK 0xC0
109 #define NSH_LEN_MASK 0x3F
111 /* Network byte order shift / mask */
112 #define NSH_NSI_MASK 0xFF
113 #define NSH_NSP_MASK (0x00FFFFFF)
114 #define NSH_NSP_SHIFT 8
116 #endif /* included_nsh_packet_h */