d52f37b6011bb20560a372eec04a230ec41bd22a
[vpp.git] / vnet / vnet / lisp-cp / lisp_cp_messages.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 VNET_LISP_GPE_LISP_CP_MESSAGES_H_
17 #define VNET_LISP_GPE_LISP_CP_MESSAGES_H_
18
19 #include <vnet/vnet.h>
20
21 #define MAX_IP_PKT_LEN 4096
22 #define MAX_IP_HDR_LEN 40       /* without options or IPv6 hdr extensions */
23 #define UDP_HDR_LEN 8
24 #define LISP_DATA_HDR_LEN 8
25 #define LISP_ECM_HDR_LEN 4
26 #define MAX_LISP_MSG_ENCAP_LEN  2*(MAX_IP_HDR_LEN + UDP_HDR_LEN)+ LISP_ECM_HDR_LEN
27 #define MAX_LISP_PKT_ENCAP_LEN  MAX_IP_HDR_LEN + UDP_HDR_LEN + LISP_DATA_HDR_LEN
28
29 #define LISP_CONTROL_PORT 4342
30
31 /*
32  * EID RECORD FIELD
33  */
34
35 /*
36  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37  *    / |   Reserved    | EID mask-len  |        EID-prefix-AFI         |
38  *  Rec +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39  *    \ |                       EID-prefix  ...                         |
40  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41  */
42
43
44 typedef struct _eid_prefix_record_hdr
45 {
46   u8 reserved;
47   u8 eid_prefix_length;
48 } __attribute__ ((__packed__)) eid_record_hdr_t;
49
50 void eid_rec_hdr_init (eid_record_hdr_t * ptr);
51
52 #define EID_REC_CAST(h_) ((eid_record_hdr_t *)(h_))
53 #define EID_REC_MLEN(h_) EID_REC_CAST((h_))->eid_prefix_length
54 #define EID_REC_ADDR(h) (u8 *)(h) + sizeof(eid_record_hdr_t)
55
56 /* LISP Types */
57 typedef enum
58 {
59   NOT_LISP_MSG,
60   LISP_MAP_REQUEST = 1,
61   LISP_MAP_REPLY,
62   LISP_MAP_REGISTER,
63   LISP_MAP_NOTIFY,
64   LISP_INFO_NAT = 7,
65   LISP_ENCAP_CONTROL_TYPE = 8,
66   LISP_MSG_TYPES
67 } lisp_msg_type_e;
68
69 /*
70  * ENCAPSULATED CONTROL MESSAGE
71  */
72
73 /*
74  *     0                   1                   2                   3
75  *     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
76  *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77  *   / |                       IPv4 or IPv6 Header                     |
78  * OH  |                      (uses RLOC addresses)                    |
79  *   \ |                                                               |
80  *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
81  *   / |       Source Port = xxxx      |       Dest Port = 4342        |
82  * UDP +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
83  *   \ |           UDP Length          |        UDP Checksum           |
84  *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
85  * LH  |Type=8 |S|                  Reserved                           |
86  *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
87  *   / |                       IPv4 or IPv6 Header                     |
88  * IH  |                  (uses RLOC or EID addresses)                 |
89  *   \ |                                                               |
90  *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
91  *   / |       Source Port = xxxx      |       Dest Port = yyyy        |
92  * UDP +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
93  *   \ |           UDP Length          |        UDP Checksum           |
94  *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95  * LCM |                      LISP Control Message                     |
96  *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
97  */
98
99
100 /*
101  * Encapsulated control message header. This is followed by the IP
102  * header of the encapsulated LISP control message.
103  *
104  *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
105  *    |Type=8 |S|                 Reserved                            |
106  *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
107  */
108
109 typedef struct
110 {
111 #if CLIB_ARCH_IS_LITTLE_ENDIAN
112   u8 reserved:3;
113   u8 s_bit:1;
114   u8 type:4;
115 #else
116   u8 type:4;
117   u8 s_bit:1;
118   u8 reserved:3;
119 #endif
120   u8 reserved2[3];
121 } ecm_hdr_t;
122
123 char *ecm_hdr_to_char (ecm_hdr_t * h);
124
125 #define ECM_TYPE(h_) ((ecm_hdr_t *)(h_))->type
126
127 /*
128  * MAP-REQUEST MESSAGE
129  */
130
131 /*
132  * Map-Request Message Format
133  *
134  *       0                   1                   2                   3
135  *       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
136  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
137  *      |Type=1 |A|M|P|S|p|s|    Reserved     |   IRC   | Record Count  |
138  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
139  *      |                         Nonce . . .                           |
140  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
141  *      |                         . . . Nonce                           |
142  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
143  *      |         Source-EID-AFI        |   Source EID Address  ...     |
144  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
145  *      |         ITR-RLOC-AFI 1        |    ITR-RLOC Address 1  ...    |
146  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
147  *      |                              ...                              |
148  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
149  *      |         ITR-RLOC-AFI n        |    ITR-RLOC Address n  ...    |
150  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
151  *    / |   Reserved    | EID mask-len  |        EID-prefix-AFI         |
152  *  Rec +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
153  *    \ |                       EID-prefix  ...                         |
154  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
155  *      |                   Map-Reply Record  ...                       |
156  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
157  *      |                     Mapping Protocol Data                     |
158  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
159  */
160
161
162 /*
163  * Fixed size portion of the map request. Variable size source EID
164  * address, originating ITR RLOC AFIs and addresses and then map
165  * request records follow.
166  */
167 typedef struct
168 {
169 #if CLIB_ARCH_IS_LITTLE_ENDIAN
170   u8 solicit_map_request:1;
171   u8 rloc_probe:1;
172   u8 map_data_present:1;
173   u8 authoritative:1;
174   u8 type:4;
175 #else
176   u8 type:4;
177   u8 authoritative:1;
178   u8 map_data_present:1;
179   u8 rloc_probe:1;
180   u8 solicit_map_request:1;
181 #endif
182 #if CLIB_ARCH_IS_LITTLE_ENDIAN
183   u8 reserved1:6;
184   u8 smr_invoked:1;
185   u8 pitr:1;
186 #else
187   u8 pitr:1;
188   u8 smr_invoked:1;
189   u8 reserved1:6;
190 #endif
191 #if CLIB_ARCH_IS_LITTLE_ENDIAN
192   u8 additional_itr_rloc_count:5;
193   u8 reserved2:3;
194 #else
195   u8 reserved2:3;
196   u8 additional_itr_rloc_count:5;
197 #endif
198   u8 record_count;
199   u64 nonce;
200 } __attribute__ ((__packed__)) map_request_hdr_t;
201
202 void map_request_hdr_init (void *ptr);
203 char *map_request_hdr_to_char (map_request_hdr_t * h);
204
205 #define MREQ_TYPE(h_) (h_)->type
206 #define MREQ_HDR_CAST(h_) ((map_request_hdr_t *)(h_))
207 #define MREQ_REC_COUNT(h_) (MREQ_HDR_CAST(h_))->record_count
208 #define MREQ_RLOC_PROBE(h_) (MREQ_HDR_CAST(h_))->rloc_probe
209 #define MREQ_ITR_RLOC_COUNT(h_) (MREQ_HDR_CAST(h_))->additional_itr_rloc_count
210 #define MREQ_NONCE(h_) (MREQ_HDR_CAST(h_))->nonce
211 #define MREQ_SMR(h_) (MREQ_HDR_CAST(h_))->solicit_map_request
212 #define MREQ_SMR_INVOKED(h_) (MREQ_HDR_CAST(h_))->smr_invoked
213
214 /*
215  * MAP-REPLY MESSAGE
216  */
217
218  /*
219   * Map-Reply Message Format
220   *
221   *       0                   1                   2                   3
222   *       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
223   *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
224   *      |Type=2 |P|E|S|         Reserved                | Record Count  |
225   *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
226   *      |                         Nonce . . .                           |
227   *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
228   *      |                         . . . Nonce                           |
229   *  +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
230   *  |   |                          Record  TTL                          |
231   *  |   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
232   *  R   | Locator Count | EID mask-len  | ACT |A|      Reserved         |
233   *  e   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
234   *  c   | Rsvd  |  Map-Version Number   |            EID-AFI            |
235   *  o   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
236   *  r   |                          EID-prefix                           |
237   *  d   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
238   *  |  /|    Priority   |    Weight     |  M Priority   |   M Weight    |
239   *  | L +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
240   *  | o |        Unused Flags     |L|p|R|           Loc-AFI             |
241   *  | c +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
242   *  |  \|                            Locator                            |
243   *  +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
244   *      |                     Mapping Protocol Data                     |
245   *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
246   */
247
248  /*
249   * Fixed size portion of the map reply.
250   */
251 typedef struct
252 {
253 #if CLIB_ARCH_IS_LITTLE_ENDIAN
254   u8 reserved1:1;
255   u8 security:1;
256   u8 echo_nonce:1;
257   u8 rloc_probe:1;
258   u8 type:4;
259 #else
260   u8 type:4;
261   u8 rloc_probe:1;
262   u8 echo_nonce:1;
263   u8 security:1;
264   u8 reserved1:1;
265 #endif
266   u8 reserved2;
267   u8 reserved3;
268   u8 record_count;
269   u64 nonce;
270 } __attribute__ ((__packed__)) map_reply_hdr_t;
271
272 void map_reply_hdr_init (void *ptr);
273 char *map_reply_hdr_to_char (map_reply_hdr_t * h);
274
275 #define MREP_HDR_CAST(h_) ((map_reply_hdr_t *)(h_))
276 #define MREP_REC_COUNT(h_) MREP_HDR_CAST(h_)->record_count
277 #define MREP_RLOC_PROBE(h_) MREP_HDR_CAST(h_)->rloc_probe
278 #define MREP_NONCE(h_) MREP_HDR_CAST(h_)->nonce
279
280
281 always_inline lisp_msg_type_e
282 lisp_msg_type (void *b)
283 {
284   ecm_hdr_t *hdr = b;
285   if (!hdr)
286     {
287       return (NOT_LISP_MSG);
288     }
289   return (hdr->type);
290 }
291
292 always_inline void
293 increment_record_count (void *b)
294 {
295   switch (lisp_msg_type (b))
296     {
297     case LISP_MAP_REQUEST:
298       MREQ_REC_COUNT (b) += 1;
299       break;
300     case LISP_MAP_REPLY:
301       MREP_REC_COUNT (b) += 1;
302       break;
303     default:
304       return;
305     }
306 }
307
308
309 /*
310  * LOCATOR FIELD
311  *
312  *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
313  *    /|    Priority   |    Weight     |  M Priority   |   M Weight    |
314  *   L +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
315  *   o |        Unused Flags     |L|p|R|           Loc-AFI             |
316  *   c +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
317  *    \|                            Locator                            |
318  *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
319  *
320  * Fixed portion of the mapping record locator. Variable length
321  * locator address follows.
322  */
323 typedef struct _locator_hdr
324 {
325   u8 priority;
326   u8 weight;
327   u8 mpriority;
328   u8 mweight;
329   u8 unused1;
330 #ifdef CLIB_ARCH_IS_LITTLE_ENDIAN
331   u8 reachable:1;
332   u8 probed:1;
333   u8 local:1;
334   u8 unused2:5;
335 #else
336   u8 unused2:5;
337   u8 local:1;
338   u8 probed:1;
339   u8 reachable:1;
340 #endif
341 } __attribute__ ((__packed__)) locator_hdr_t;
342
343 #define LOC_CAST(h_) ((locator_hdr_t *)(h_))
344 #define LOC_PROBED(h_) LOC_CAST(h_)->probed
345 #define LOC_PRIORITY(h_) LOC_CAST(h_)->priority
346 #define LOC_WEIGHT(h_) LOC_CAST(h_)->weight
347 #define LOC_MPRIORITY(h_) LOC_CAST(h_)->mpriority
348 #define LOC_MWEIGHT(h_) LOC_CAST(h_)->mweight
349 #define LOC_REACHABLE(h_) LOC_CAST(h_)->reachable
350 #define LOC_LOCAL(h_) LOC_CAST(h_)->local
351 #define LOC_ADDR(h_) ((u8 *)(h_)  + sizeof(locator_hdr_t))
352
353 /*
354  * MAPPING RECORD
355  *
356  * Mapping record used in all LISP control messages.
357  *
358  *  +--->  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
359  *  |      |                          Record  TTL                          |
360  *  |      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
361  *  R      | Locator Count | EID mask-len  | ACT |A|       Reserved        |
362  *  e      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
363  *  c      | Rsvd  |  Map-Version Number   |            EID-AFI            |
364  *  o      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
365  *  r      |                          EID-prefix                           |
366  *  d      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
367  *  |     /|    Priority   |    Weight     |  M Priority   |   M Weight    |
368  *  |    / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
369  *  |  Loc |         Unused Flags    |L|p|R|           Loc-AFI             |
370  *  |    \ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
371  *  |     \|                             Locator                           |
372  *  +--->  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
373  */
374
375 /*
376  * Fixed portion of the mapping record. EID prefix address and
377  * locators follow.
378  */
379
380 typedef struct _mapping_record_hdr_t
381 {
382   u32 ttl;
383   u8 locator_count;
384   u8 eid_prefix_length;
385 #ifdef CLIB_ARCH_IS_LITTLE_ENDIAN
386   u8 reserved1:4;
387   u8 authoritative:1;
388   u8 action:3;
389 #else
390   u8 action:3;
391   u8 authoritative:1;
392   u8 reserved1:4;
393 #endif
394   u8 reserved2;
395 #ifdef CLIB_ARCH_IS_LITTLE_ENDIAN
396   u8 version_hi:4;
397   u8 reserved3:4;
398 #else
399   u8 reserved3:4;
400   u8 version_hi:4;
401 #endif
402   u8 version_low;
403 } __attribute__ ((__packed__)) mapping_record_hdr_t;
404
405 void mapping_record_init_hdr (mapping_record_hdr_t * h);
406
407 #define MAP_REC_EID_PLEN(h) ((mapping_record_hdr_t *)(h))->eid_prefix_length
408 #define MAP_REC_LOC_COUNT(h) ((mapping_record_hdr_t *)(h))->locator_count
409 #define MAP_REC_ACTION(h) ((mapping_record_hdr_t *)(h))->action
410 #define MAP_REC_AUTH(h) ((mapping_record_hdr_t *)(h))->authoritative
411 #define MAP_REC_TTL(h) ((mapping_record_hdr_t *)(h))->ttl
412 #define MAP_REC_EID(h) (u8 *)(h)+sizeof(mapping_record_hdr_t)
413 #define MAP_REC_VERSION(h) (h)->version_hi << 8 | (h)->version_low
414
415 typedef enum
416 {
417   LISP_NO_ACTION,
418   LISP_FORWARD_NATIVE,
419   LISP_SEND_MAP_REQUEST,
420   LISP_DROP
421 } lisp_action_e;
422
423 typedef enum lisp_authoritative
424 {
425   A_NO_AUTHORITATIVE = 0,
426   A_AUTHORITATIVE
427 } lisp_authoritative_e;
428
429 /*
430  * LISP Canonical Address Format Encodings
431  *
432  *   0                   1                   2                   3
433  *   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
434  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
435  *  |           AFI = 16387         |     Rsvd1     |     Flags     |
436  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
437  *  |    Type       |     Rsvd2     |            Length             |
438  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
439  */
440
441 typedef struct _lcaf_hdr_t
442 {
443   u8 reserved1;
444   u8 flags;
445   u8 type;
446   u8 reserved2;
447   u16 len;
448 } __attribute__ ((__packed__)) lcaf_hdr_t;
449
450 #define LCAF_TYPE(h) ((lcaf_hdr_t *)(h))->type
451 #define LCAF_LENGTH(h) ((lcaf_hdr_t *)(h))->len
452 #define LCAF_RES2(h) ((lcaf_hdr_t *)(h))->reserved2
453 #define LCAF_FLAGS(h) ((lcaf_hdr_t *)(h))->flags
454 #define LCAF_PAYLOAD(h) (u8 *)(h)+sizeof(lcaf_hdr_t)
455
456 /*
457  * Source/Dest Key Canonical Address Format:
458  *
459  *   0                   1                   2                   3
460  *   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
461  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
462  *   |            Reserved           |   Source-ML   |    Dest-ML    |
463  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
464  */
465 typedef struct _lcaf_src_dst_hdr_t
466 {
467   u16 reserved;
468   u8 src_mask_len;
469   u8 dst_mask_len;
470 } __attribute__ ((__packed__)) lcaf_src_dst_hdr_t;
471
472 #define LCAF_SD_SRC_ML(_h) (_h)->src_mask_len
473 #define LCAF_SD_DST_ML(_h) (_h)->dst_mask_len
474
475 #endif /* VNET_LISP_GPE_LISP_CP_MESSAGES_H_ */
476
477 /*
478  * fd.io coding-style-patch-verification: ON
479  *
480  * Local Variables:
481  * eval: (c-set-style "gnu")
482  * End:
483  */