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