LISP GPE: initial CP commit and DP improvements
[vpp.git] / vnet / vnet / lisp-gpe / lisp_gpe_packet.h
1 /*
2  * Copyright (c) 2016 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
16 #ifndef included_lisp_gpe_packet_h
17 #define included_lisp_gpe_packet_h
18
19 /*
20  *   From draft-lewis-lisp-gpe-02.txt
21  *
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  * |N|L|E|V|I|P|R|O|Ver|      Reserved             | Next Protocol |
26  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27  * |                 Instance ID/Locator-Status-Bits               |
28  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29  *
30  *   N: The N-bit is the nonce-present bit.  When this bit is set to 1,
31  *     the low-order 24 bits of the first 32 bits of the LISP header
32  *     contain a Nonce.  See Section 6.3.1 for details.  Both N- and
33  *     V-bits MUST NOT be set in the same packet.  If they are, a
34  *     decapsulating ETR MUST treat the 'Nonce/Map-Version' field as
35  *     having a Nonce value present.
36  *
37  *  L: The L-bit is the 'Locator-Status-Bits' field enabled bit.  When
38  *     this bit is set to 1, the Locator-Status-Bits in the second
39  *     32 bits of the LISP header are in use.
40  *
41  *  E: The E-bit is the echo-nonce-request bit.  This bit MUST be ignored
42  *     and has no meaning when the N-bit is set to 0.  When the N-bit is
43  *     set to 1 and this bit is set to 1, an ITR is requesting that the
44  *     nonce value in the 'Nonce' field be echoed back in LISP-
45  *     encapsulated packets when the ITR is also an ETR.  See
46  *     Section 6.3.1 for details.
47  *
48  *  V: The V-bit is the Map-Version present bit.  When this bit is set to
49  *     1, the N-bit MUST be 0.  Refer to Section 6.6.3 for more details.
50  *
51  *  I: The I-bit is the Instance ID bit.  See Section 5.5 for more
52  *     details.  When this bit is set to 1, the 'Locator-Status-Bits'
53  *     field is reduced to 8 bits and the high-order 24 bits are used as
54  *     an Instance ID.  If the L-bit is set to 0, then the low-order
55  *     8 bits are transmitted as zero and ignored on receipt.
56  *
57  * P Bit:  Flag bit 5 is defined as the Next Protocol bit.  The P bit
58  *    MUST be set to 1 to indicate the presence of the 8 bit next
59  *    protocol field.
60  *
61  *    P = 0 indicates that the payload MUST conform to LISP as defined
62  *    in [RFC6830].
63  *
64  *    Flag bit 5 was chosen as the P bit because this flag bit is
65  *    currently unallocated in LISP [RFC6830].
66  *
67  *  O: Flag bit 7 is defined as the O bit.  When the O bit is set to 1, the
68  *  packet is an OAM packet and OAM processing MUST occur.  The OAM
69  *  protocol details are out of scope for this document.  As with the
70  *  P-bit, bit 7 is currently a reserved flag in [RFC6830].
71  *
72  * Next Protocol Field:  The lower 8 bits of the first word are used to
73  *    carry a next protocol.  This next protocol field contains the
74  *    protocol of the encapsulated payload packet.
75  *
76  *    LISP [RFC6830] uses the lower 16 bits of the first word for either
77  *    a nonce, an echo-nonce ([RFC6830]) or to support map-versioning
78  *    ([RFC6834]).  These are all optional capabilities that are
79  *    indicated by setting the N, E, and the V bit respectively.
80  *
81  *    To maintain the desired data plane compatibility, when the P bit
82  *    is set, the N, E, and V bits MUST be set to zero.
83  *
84  * A new protocol registry will be requested from IANA for the Next
85  * Protocol field.  This draft defines the following Next Protocol
86  * values:
87  *
88  *    0x1 : IPv4
89  *    0x2 : IPv6
90  *    0x3 : Ethernet
91  *    0x4: Network Service Header
92  */
93  
94 typedef struct {
95   u8 flags;
96   u8 ver_res;
97   u8 res;
98   u8 next_protocol;
99   u32 iid;
100 } lisp_gpe_header_t;
101
102 #define foreach_lisp_gpe_flag_bit               \
103 _(N, 0x80)                                      \
104 _(L, 0x40)                                      \
105 _(E, 0x20)                                      \
106 _(V, 0x10)                                      \
107 _(I, 0x08)                                      \
108 _(P, 0x04)                                      \
109 _(O, 0x01)
110
111 typedef enum {
112 #define _(n,v) LISP_GPE_FLAGS_##n = v,
113 foreach_lisp_gpe_flag_bit
114 #undef _
115 } vnet_lisp_gpe_flag_bit_t;
116
117 #define LISP_GPE_VERSION 0x0
118
119 #define LISP_GPE_NEXT_PROTOCOL_IP4 0x1
120 #define LISP_GPE_NEXT_PROTOCOL_IP6 0x2
121 #define LISP_GPE_NEXT_PROTOCOL_ETHERNET 0x3
122 #define LISP_GPE_NEXT_PROTOCOL_NSH 0x4
123
124 typedef enum
125 {
126   LISP_GPE_NEXT_PROTO_IP4 = 1,
127   LISP_GPE_NEXT_PROTO_IP6,
128   LISP_GPE_NEXT_PROTO_ETHERNET,
129   LISP_GPE_NEXT_PROTO_NSH,
130   LISP_GPE_NEXT_PROTOS
131 } lisp_gpe_next_protocol_e;
132
133 #endif /* included_lisp_gpe_packet_h */