ONE-11: Fix bugs in LISP API
[vpp.git] / vnet / vnet / nsh-vxlan-gpe / vxlan_gpe_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_vxlan_gpe_packet_h
16 #define included_vxlan_gpe_packet_h
17
18 /*
19  *   From draft-quinn-vxlan-gpe-03.txt
20  *
21  *    0                   1                   2                   3
22  *    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
23  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
24  *   |R|R|R|R|I|P|R|O|Ver|   Reserved                |Next Protocol  |
25  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
26  *   |                VXLAN Network Identifier (VNI) |   Reserved    |
27  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
28  *
29  *   I Bit: Flag bit 4 indicates that the VNI is valid. 
30  *
31  *   P Bit:  Flag bit 5 is defined as the Next Protocol bit.  The P bit
32  *      MUST be set to 1 to indicate the presence of the 8 bit next
33  *      protocol field.
34  *
35  *   O Bit: Flag bit 7 is defined as the O bit. When the O bit is set to 1, 
36  *
37  *      the packet is an OAM packet and OAM processing MUST occur.  The OAM
38  *      protocol details are out of scope for this document.  As with the
39  *      P-bit, bit 7 is currently a reserved flag in VXLAN.
40  *
41  *   VXLAN-gpe bits 8 and 9 are defined as version bits.  These bits are
42  *   reserved in VXLAN.  The version field is used to ensure backward
43  *   compatibility going forward with future VXLAN-gpe updates.
44  *
45  *   The initial version for VXLAN-gpe is 0.
46  *
47  *   This draft defines the following Next Protocol values:
48  *
49  *      0x1 : IPv4
50  *      0x2 : IPv6
51  *      0x3 : Ethernet
52  *      0x4 : Network Service Header [NSH]
53  */
54
55 typedef struct {
56   u8 flags;
57   u8 ver_res;
58   u8 res;
59   u8 next_protocol;
60   u32 vni_res;
61 } vxlan_gpe_header_t;
62
63 #define VXLAN_GPE_FLAGS_I 0x08
64 #define VXLAN_GPE_FLAGS_P 0x04
65 #define VXLAN_GPE_FLAGS_O 0x01
66
67 #define VXLAN_GPE_VERSION 0x0
68
69 #define VXLAN_NEXT_PROTOCOL_IP4 0x1
70 #define VXLAN_NEXT_PROTOCOL_IP6 0x2
71 #define VXLAN_NEXT_PROTOCOL_ETHERNET 0x3
72 #define VXLAN_NEXT_PROTOCOL_NSH 0x4
73
74 #endif /* included_vxlan_gpe_packet_h */