LISP: don't show PITR generated mapping in dump call
[vpp.git] / src / vnet / lisp-cp / lisp_api.c
1 /*
2  *------------------------------------------------------------------
3  * lisp_api.c - lisp api
4  *
5  * Copyright (c) 2016 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19
20 #include <vnet/vnet.h>
21 #include <vlibmemory/api.h>
22
23 #include <vnet/interface.h>
24 #include <vnet/api_errno.h>
25 #include <vnet/lisp-cp/control.h>
26 #include <vnet/lisp-gpe/lisp_gpe.h>
27
28 #include <vnet/vnet_msg_enum.h>
29
30 #define vl_api_remote_locator_t_endian vl_noop_handler
31 #define vl_api_remote_locator_t_print vl_noop_handler
32 #define vl_api_local_locator_t_endian vl_noop_handler
33 #define vl_api_local_locator_t_print vl_noop_handler
34
35 #define vl_api_lisp_add_del_locator_set_t_endian vl_noop_handler
36 #define vl_api_lisp_add_del_locator_set_t_print vl_noop_handler
37 #define vl_api_lisp_add_del_remote_mapping_t_endian vl_noop_handler
38 #define vl_api_lisp_add_del_remote_mapping_t_print vl_noop_handler
39
40 #define vl_typedefs             /* define message structures */
41 #include <vnet/vnet_all_api_h.h>
42 #undef vl_typedefs
43
44 #define vl_endianfun            /* define message structures */
45 #include <vnet/vnet_all_api_h.h>
46 #undef vl_endianfun
47
48 /* instantiate all the print functions we know about */
49 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
50 #define vl_printfun
51 #include <vnet/vnet_all_api_h.h>
52 #undef vl_printfun
53
54 #include <vlibapi/api_helper_macros.h>
55
56 #define foreach_vpe_api_msg                             \
57 _(LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set)                   \
58 _(LISP_ADD_DEL_LOCATOR, lisp_add_del_locator)                           \
59 _(LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid)                       \
60 _(LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver)                 \
61 _(LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server)                     \
62 _(LISP_ENABLE_DISABLE, lisp_enable_disable)                             \
63 _(LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable)       \
64 _(LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable)   \
65 _(LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping)             \
66 _(LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency)                       \
67 _(LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set)                 \
68 _(LISP_MAP_REQUEST_MODE, lisp_map_request_mode)                         \
69 _(LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map)               \
70 _(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump)                         \
71 _(LISP_LOCATOR_DUMP, lisp_locator_dump)                                 \
72 _(LISP_EID_TABLE_DUMP, lisp_eid_table_dump)                             \
73 _(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump)                       \
74 _(LISP_MAP_SERVER_DUMP, lisp_map_server_dump)                           \
75 _(LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump)                     \
76 _(LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump)                     \
77 _(LISP_ADJACENCIES_GET, lisp_adjacencies_get)                           \
78 _(SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state)               \
79 _(SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state)           \
80 _(SHOW_LISP_STATUS, show_lisp_status)                                   \
81 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS,                                   \
82   lisp_add_del_map_request_itr_rlocs)                                   \
83 _(LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs)       \
84 _(SHOW_LISP_PITR, show_lisp_pitr)                                       \
85 _(SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode)               \
86 _(LISP_USE_PETR, lisp_use_petr)                                         \
87 _(SHOW_LISP_USE_PETR, show_lisp_use_petr)                               \
88
89 static locator_t *
90 unformat_lisp_locs (vl_api_remote_locator_t * rmt_locs, u32 rloc_num)
91 {
92   u32 i;
93   locator_t *locs = 0, loc;
94   vl_api_remote_locator_t *r;
95
96   for (i = 0; i < rloc_num; i++)
97     {
98       /* remote locators */
99       r = &rmt_locs[i];
100       memset (&loc, 0, sizeof (loc));
101       gid_address_ip_set (&loc.address, &r->addr, r->is_ip4 ? IP4 : IP6);
102
103       loc.priority = r->priority;
104       loc.weight = r->weight;
105
106       vec_add1 (locs, loc);
107     }
108   return locs;
109 }
110
111 static void
112 vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t *
113                                            mp)
114 {
115   vl_api_lisp_add_del_locator_set_reply_t *rmp;
116   int rv = 0;
117   vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
118   locator_t locator;
119   vl_api_local_locator_t *ls_loc;
120   u32 ls_index = ~0, locator_num;
121   u8 *locator_name = NULL;
122   int i;
123
124   memset (a, 0, sizeof (a[0]));
125
126   locator_name = format (0, "%s", mp->locator_set_name);
127
128   a->name = locator_name;
129   a->is_add = mp->is_add;
130   a->local = 1;
131   locator_num = clib_net_to_host_u32 (mp->locator_num);
132
133   memset (&locator, 0, sizeof (locator));
134   for (i = 0; i < locator_num; i++)
135     {
136       ls_loc = &mp->locators[i];
137       VALIDATE_SW_IF_INDEX (ls_loc);
138
139       locator.sw_if_index = htonl (ls_loc->sw_if_index);
140       locator.priority = ls_loc->priority;
141       locator.weight = ls_loc->weight;
142       locator.local = 1;
143       vec_add1 (a->locators, locator);
144     }
145
146   rv = vnet_lisp_add_del_locator_set (a, &ls_index);
147
148   BAD_SW_IF_INDEX_LABEL;
149
150   vec_free (locator_name);
151   vec_free (a->locators);
152
153   /* *INDENT-OFF* */
154   REPLY_MACRO2 (VL_API_LISP_ADD_DEL_LOCATOR_SET_REPLY,
155   ({
156     rmp->ls_index = clib_host_to_net_u32 (ls_index);
157   }));
158   /* *INDENT-ON* */
159 }
160
161 static void
162 vl_api_lisp_add_del_locator_t_handler (vl_api_lisp_add_del_locator_t * mp)
163 {
164   vl_api_lisp_add_del_locator_reply_t *rmp;
165   int rv = 0;
166   locator_t locator, *locators = NULL;
167   vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
168   u32 ls_index = ~0;
169   u8 *locator_name = NULL;
170
171   memset (&locator, 0, sizeof (locator));
172   memset (a, 0, sizeof (a[0]));
173
174   locator.sw_if_index = ntohl (mp->sw_if_index);
175   locator.priority = mp->priority;
176   locator.weight = mp->weight;
177   locator.local = 1;
178   vec_add1 (locators, locator);
179
180   locator_name = format (0, "%s", mp->locator_set_name);
181
182   a->name = locator_name;
183   a->locators = locators;
184   a->is_add = mp->is_add;
185   a->local = 1;
186
187   rv = vnet_lisp_add_del_locator (a, NULL, &ls_index);
188
189   vec_free (locators);
190   vec_free (locator_name);
191
192   REPLY_MACRO (VL_API_LISP_ADD_DEL_LOCATOR_REPLY);
193 }
194
195 static int
196 unformat_lisp_eid_api (gid_address_t * dst, u32 vni, u8 type, void *src,
197                        u8 len)
198 {
199   switch (type)
200     {
201     case 0:                     /* ipv4 */
202       gid_address_type (dst) = GID_ADDR_IP_PREFIX;
203       gid_address_ip_set (dst, src, IP4);
204       gid_address_ippref_len (dst) = len;
205       ip_prefix_normalize (&gid_address_ippref (dst));
206       break;
207     case 1:                     /* ipv6 */
208       gid_address_type (dst) = GID_ADDR_IP_PREFIX;
209       gid_address_ip_set (dst, src, IP6);
210       gid_address_ippref_len (dst) = len;
211       ip_prefix_normalize (&gid_address_ippref (dst));
212       break;
213     case 2:                     /* l2 mac */
214       gid_address_type (dst) = GID_ADDR_MAC;
215       clib_memcpy (&gid_address_mac (dst), src, 6);
216       break;
217     default:
218       /* unknown type */
219       return VNET_API_ERROR_INVALID_VALUE;
220     }
221
222   gid_address_vni (dst) = vni;
223
224   return 0;
225 }
226
227 static void
228 vl_api_lisp_add_del_local_eid_t_handler (vl_api_lisp_add_del_local_eid_t * mp)
229 {
230   vl_api_lisp_add_del_local_eid_reply_t *rmp;
231   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
232   int rv = 0;
233   gid_address_t _eid, *eid = &_eid;
234   uword *p = NULL;
235   u32 locator_set_index = ~0, map_index = ~0;
236   vnet_lisp_add_del_mapping_args_t _a, *a = &_a;
237   u8 *name = NULL, *key = NULL;
238   memset (a, 0, sizeof (a[0]));
239   memset (eid, 0, sizeof (eid[0]));
240
241   rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
242                               mp->eid_type, mp->eid, mp->prefix_len);
243   if (rv)
244     goto out;
245
246   name = format (0, "%s", mp->locator_set_name);
247   p = hash_get_mem (lcm->locator_set_index_by_name, name);
248   if (!p)
249     {
250       rv = VNET_API_ERROR_INVALID_VALUE;
251       goto out;
252     }
253   locator_set_index = p[0];
254
255   if (*mp->key)
256     key = format (0, "%s", mp->key);
257
258   /* XXX treat batch configuration */
259   a->is_add = mp->is_add;
260   gid_address_copy (&a->eid, eid);
261   a->locator_set_index = locator_set_index;
262   a->local = 1;
263   a->key = key;
264   a->key_id = clib_net_to_host_u16 (mp->key_id);
265
266   rv = vnet_lisp_add_del_local_mapping (a, &map_index);
267
268 out:
269   vec_free (name);
270   vec_free (key);
271   gid_address_free (&a->eid);
272
273   REPLY_MACRO (VL_API_LISP_ADD_DEL_LOCAL_EID_REPLY);
274 }
275
276 static void
277   vl_api_lisp_eid_table_add_del_map_t_handler
278   (vl_api_lisp_eid_table_add_del_map_t * mp)
279 {
280   vl_api_lisp_eid_table_add_del_map_reply_t *rmp;
281   int rv = 0;
282   rv = vnet_lisp_eid_table_map (clib_net_to_host_u32 (mp->vni),
283                                 clib_net_to_host_u32 (mp->dp_table),
284                                 mp->is_l2, mp->is_add);
285 REPLY_MACRO (VL_API_LISP_EID_TABLE_ADD_DEL_MAP_REPLY)}
286
287 static void
288 vl_api_lisp_add_del_map_server_t_handler (vl_api_lisp_add_del_map_server_t
289                                           * mp)
290 {
291   vl_api_lisp_add_del_map_server_reply_t *rmp;
292   int rv = 0;
293   ip_address_t addr;
294
295   memset (&addr, 0, sizeof (addr));
296
297   ip_address_set (&addr, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
298   rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
299
300   REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_SERVER_REPLY);
301 }
302
303 static void
304 vl_api_lisp_add_del_map_resolver_t_handler (vl_api_lisp_add_del_map_resolver_t
305                                             * mp)
306 {
307   vl_api_lisp_add_del_map_resolver_reply_t *rmp;
308   int rv = 0;
309   vnet_lisp_add_del_map_resolver_args_t _a, *a = &_a;
310
311   memset (a, 0, sizeof (a[0]));
312
313   a->is_add = mp->is_add;
314   ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
315
316   rv = vnet_lisp_add_del_map_resolver (a);
317
318   REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_RESOLVER_REPLY);
319 }
320
321 static void
322   vl_api_lisp_map_register_enable_disable_t_handler
323   (vl_api_lisp_map_register_enable_disable_t * mp)
324 {
325   vl_api_lisp_map_register_enable_disable_reply_t *rmp;
326   int rv = 0;
327
328   vnet_lisp_map_register_enable_disable (mp->is_enabled);
329   REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
330 }
331
332 static void
333   vl_api_lisp_rloc_probe_enable_disable_t_handler
334   (vl_api_lisp_rloc_probe_enable_disable_t * mp)
335 {
336   vl_api_lisp_rloc_probe_enable_disable_reply_t *rmp;
337   int rv = 0;
338
339   vnet_lisp_rloc_probe_enable_disable (mp->is_enabled);
340   REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
341 }
342
343 static void
344 vl_api_lisp_enable_disable_t_handler (vl_api_lisp_enable_disable_t * mp)
345 {
346   vl_api_lisp_enable_disable_reply_t *rmp;
347   int rv = 0;
348
349   vnet_lisp_enable_disable (mp->is_en);
350   REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
351 }
352
353 static void
354   vl_api_show_lisp_map_request_mode_t_handler
355   (vl_api_show_lisp_map_request_mode_t * mp)
356 {
357   int rv = 0;
358   vl_api_show_lisp_map_request_mode_reply_t *rmp;
359
360   /* *INDENT-OFF* */
361   REPLY_MACRO2(VL_API_SHOW_LISP_MAP_REQUEST_MODE_REPLY,
362   ({
363     rmp->mode = vnet_lisp_get_map_request_mode ();
364   }));
365   /* *INDENT-ON* */
366 }
367
368 static void
369 vl_api_lisp_map_request_mode_t_handler (vl_api_lisp_map_request_mode_t * mp)
370 {
371   vl_api_lisp_map_request_mode_reply_t *rmp;
372   int rv = 0;
373
374   rv = vnet_lisp_set_map_request_mode (mp->mode);
375
376   REPLY_MACRO (VL_API_LISP_MAP_REQUEST_MODE_REPLY);
377 }
378
379 static void
380 vl_api_lisp_pitr_set_locator_set_t_handler (vl_api_lisp_pitr_set_locator_set_t
381                                             * mp)
382 {
383   vl_api_lisp_pitr_set_locator_set_reply_t *rmp;
384   int rv = 0;
385   u8 *ls_name = 0;
386
387   ls_name = format (0, "%s", mp->ls_name);
388   rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
389   vec_free (ls_name);
390
391   REPLY_MACRO (VL_API_LISP_PITR_SET_LOCATOR_SET_REPLY);
392 }
393
394 static void
395 vl_api_lisp_use_petr_t_handler (vl_api_lisp_use_petr_t * mp)
396 {
397   vl_api_lisp_use_petr_reply_t *rmp;
398   int rv = 0;
399   ip_address_t addr;
400
401   ip_address_set (&addr, &mp->address, mp->is_ip4 ? IP4 : IP6);
402   rv = vnet_lisp_use_petr (&addr, mp->is_add);
403
404   REPLY_MACRO (VL_API_LISP_USE_PETR_REPLY);
405 }
406
407 static void
408 vl_api_show_lisp_use_petr_t_handler (vl_api_show_lisp_use_petr_t * mp)
409 {
410   unix_shared_memory_queue_t *q = NULL;
411   vl_api_show_lisp_use_petr_reply_t *rmp = NULL;
412   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
413   mapping_t *m;
414   locator_set_t *ls = 0;
415   int rv = 0;
416   locator_t *loc = 0;
417   u8 status = 0;
418   gid_address_t addr;
419
420   q = vl_api_client_index_to_input_queue (mp->client_index);
421   if (q == 0)
422     {
423       return;
424     }
425
426   memset (&addr, 0, sizeof (addr));
427   status = lcm->flags & LISP_FLAG_USE_PETR;
428   if (status)
429     {
430       m = pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index);
431       if (~0 != m->locator_set_index)
432         {
433           ls =
434             pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
435           loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
436           gid_address_copy (&addr, &loc->address);
437         }
438     }
439
440   /* *INDENT-OFF* */
441   REPLY_MACRO2 (VL_API_SHOW_LISP_USE_PETR_REPLY,
442   {
443       rmp->status = status;
444       gid_address_put (rmp->address, &addr);
445       rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4);
446   });
447   /* *INDENT-ON* */
448 }
449
450 static void
451   vl_api_lisp_add_del_map_request_itr_rlocs_t_handler
452   (vl_api_lisp_add_del_map_request_itr_rlocs_t * mp)
453 {
454   vl_api_lisp_add_del_map_request_itr_rlocs_reply_t *rmp;
455   int rv = 0;
456   u8 *locator_set_name = NULL;
457   vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
458
459   locator_set_name = format (0, "%s", mp->locator_set_name);
460
461   a->is_add = mp->is_add;
462   a->locator_set_name = locator_set_name;
463
464   rv = vnet_lisp_add_del_mreq_itr_rlocs (a);
465
466   vec_free (locator_set_name);
467
468   REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
469 }
470
471 static void
472   vl_api_lisp_add_del_remote_mapping_t_handler
473   (vl_api_lisp_add_del_remote_mapping_t * mp)
474 {
475   locator_t *rlocs = 0;
476   vl_api_lisp_add_del_remote_mapping_reply_t *rmp;
477   int rv = 0;
478   gid_address_t _eid, *eid = &_eid;
479   u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num);
480
481   memset (eid, 0, sizeof (eid[0]));
482
483   rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
484                               mp->eid_type, mp->eid, mp->eid_len);
485   if (rv)
486     goto send_reply;
487
488   rlocs = unformat_lisp_locs (mp->rlocs, rloc_num);
489
490   if (!mp->is_add)
491     {
492       vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
493       gid_address_copy (&a->reid, eid);
494       a->is_add = 0;
495       rv = vnet_lisp_add_del_adjacency (a);
496       if (rv)
497         {
498           goto out;
499         }
500     }
501
502   /* NOTE: for now this works as a static remote mapping, i.e.,
503    * not authoritative and ttl infinite. */
504   rv = vnet_lisp_add_del_mapping (eid, rlocs, mp->action, 0, ~0,
505                                   mp->is_add, 1 /* is_static */ , 0);
506
507   if (mp->del_all)
508     vnet_lisp_clear_all_remote_adjacencies ();
509
510 out:
511   vec_free (rlocs);
512 send_reply:
513   REPLY_MACRO (VL_API_LISP_ADD_DEL_REMOTE_MAPPING_REPLY);
514 }
515
516 static void
517 vl_api_lisp_add_del_adjacency_t_handler (vl_api_lisp_add_del_adjacency_t * mp)
518 {
519   vl_api_lisp_add_del_adjacency_reply_t *rmp;
520   vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
521
522   int rv = 0;
523   memset (a, 0, sizeof (a[0]));
524
525   rv = unformat_lisp_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni),
526                               mp->eid_type, mp->leid, mp->leid_len);
527   rv |= unformat_lisp_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni),
528                                mp->eid_type, mp->reid, mp->reid_len);
529
530   if (rv)
531     goto send_reply;
532
533   a->is_add = mp->is_add;
534   rv = vnet_lisp_add_del_adjacency (a);
535
536 send_reply:
537   REPLY_MACRO (VL_API_LISP_ADD_DEL_ADJACENCY_REPLY);
538 }
539
540 static void
541 send_lisp_locator_details (lisp_cp_main_t * lcm,
542                            locator_t * loc,
543                            unix_shared_memory_queue_t * q, u32 context)
544 {
545   vl_api_lisp_locator_details_t *rmp;
546
547   rmp = vl_msg_api_alloc (sizeof (*rmp));
548   memset (rmp, 0, sizeof (*rmp));
549   rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_DETAILS);
550   rmp->context = context;
551
552   rmp->local = loc->local;
553   if (loc->local)
554     {
555       rmp->sw_if_index = ntohl (loc->sw_if_index);
556     }
557   else
558     {
559       rmp->is_ipv6 = gid_address_ip_version (&loc->address);
560       ip_address_copy_addr (rmp->ip_address, &gid_address_ip (&loc->address));
561     }
562   rmp->priority = loc->priority;
563   rmp->weight = loc->weight;
564
565   vl_msg_api_send_shmem (q, (u8 *) & rmp);
566 }
567
568 static void
569 vl_api_lisp_locator_dump_t_handler (vl_api_lisp_locator_dump_t * mp)
570 {
571   u8 *ls_name = 0;
572   unix_shared_memory_queue_t *q = 0;
573   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
574   locator_set_t *lsit = 0;
575   locator_t *loc = 0;
576   u32 ls_index = ~0, *locit = 0;
577   uword *p = 0;
578
579   q = vl_api_client_index_to_input_queue (mp->client_index);
580   if (q == 0)
581     {
582       return;
583     }
584
585   if (mp->is_index_set)
586     ls_index = htonl (mp->ls_index);
587   else
588     {
589       /* make sure we get a proper C-string */
590       mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
591       ls_name = format (0, "%s", mp->ls_name);
592       p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
593       if (!p)
594         goto out;
595       ls_index = p[0];
596     }
597
598   if (pool_is_free_index (lcm->locator_set_pool, ls_index))
599     return;
600
601   lsit = pool_elt_at_index (lcm->locator_set_pool, ls_index);
602
603   vec_foreach (locit, lsit->locator_indices)
604   {
605     loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
606     send_lisp_locator_details (lcm, loc, q, mp->context);
607   };
608 out:
609   vec_free (ls_name);
610 }
611
612 static void
613 send_lisp_locator_set_details (lisp_cp_main_t * lcm,
614                                locator_set_t * lsit,
615                                unix_shared_memory_queue_t * q,
616                                u32 context, u32 ls_index)
617 {
618   vl_api_lisp_locator_set_details_t *rmp;
619   u8 *str = 0;
620
621   rmp = vl_msg_api_alloc (sizeof (*rmp));
622   memset (rmp, 0, sizeof (*rmp));
623   rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_SET_DETAILS);
624   rmp->context = context;
625
626   rmp->ls_index = htonl (ls_index);
627   if (lsit->local)
628     {
629       ASSERT (lsit->name != NULL);
630       strncpy ((char *) rmp->ls_name, (char *) lsit->name,
631                vec_len (lsit->name));
632     }
633   else
634     {
635       str = format (0, "<remote-%d>", ls_index);
636       strncpy ((char *) rmp->ls_name, (char *) str, vec_len (str));
637       vec_free (str);
638     }
639
640   vl_msg_api_send_shmem (q, (u8 *) & rmp);
641 }
642
643 static void
644 vl_api_lisp_locator_set_dump_t_handler (vl_api_lisp_locator_set_dump_t * mp)
645 {
646   unix_shared_memory_queue_t *q = NULL;
647   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
648   locator_set_t *lsit = NULL;
649   u8 filter;
650
651   q = vl_api_client_index_to_input_queue (mp->client_index);
652   if (q == 0)
653     {
654       return;
655     }
656
657   filter = mp->filter;
658   /* *INDENT-OFF* */
659   pool_foreach (lsit, lcm->locator_set_pool,
660   ({
661     if (filter && !((1 == filter && lsit->local) ||
662                     (2 == filter && !lsit->local)))
663       {
664         continue;
665       }
666     send_lisp_locator_set_details (lcm, lsit, q, mp->context,
667                                    lsit - lcm->locator_set_pool);
668   }));
669   /* *INDENT-ON* */
670 }
671
672 static void
673 lisp_fid_put_api (u8 * dst, fid_address_t * src, u8 * prefix_length)
674 {
675   ASSERT (prefix_length);
676   ip_prefix_t *ippref = &fid_addr_ippref (src);
677
678   switch (fid_addr_type (src))
679     {
680     case FID_ADDR_IP_PREF:
681       if (ip_prefix_version (ippref) == IP4)
682         clib_memcpy (dst, &ip_prefix_v4 (ippref), 4);
683       else
684         clib_memcpy (dst, &ip_prefix_v6 (ippref), 16);
685       prefix_length[0] = ip_prefix_len (ippref);
686       break;
687
688     case FID_ADDR_MAC:
689       prefix_length[0] = 0;
690       clib_memcpy (dst, fid_addr_mac (src), 6);
691       break;
692
693     default:
694       clib_warning ("Unknown FID type %d!", fid_addr_type (src));
695       break;
696     }
697 }
698
699 static u8
700 fid_type_to_api_type (fid_address_t * fid)
701 {
702   ip_prefix_t *ippref;
703
704   switch (fid_addr_type (fid))
705     {
706     case FID_ADDR_IP_PREF:
707       ippref = &fid_addr_ippref (fid);
708       if (ip_prefix_version (ippref) == IP4)
709         return 0;
710       else if (ip_prefix_version (ippref) == IP6)
711         return 1;
712       else
713         return ~0;
714
715     case FID_ADDR_MAC:
716       return 2;
717     case FID_ADDR_NSH:
718       return 3;
719     }
720
721   return ~0;
722 }
723
724 static void
725 send_lisp_eid_table_details (mapping_t * mapit,
726                              unix_shared_memory_queue_t * q,
727                              u32 context, u8 filter)
728 {
729   fid_address_t *fid;
730   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
731   locator_set_t *ls = 0;
732   vl_api_lisp_eid_table_details_t *rmp = NULL;
733   gid_address_t *gid = NULL;
734   u8 *mac = 0;
735   ip_prefix_t *ip_prefix = NULL;
736
737   switch (filter)
738     {
739     case 0:                     /* all mappings */
740       break;
741
742     case 1:                     /* local only */
743       if (!mapit->local)
744         return;
745       break;
746     case 2:                     /* remote only */
747       if (mapit->local)
748         return;
749       break;
750     default:
751       clib_warning ("Filter error, unknown filter: %d", filter);
752       return;
753     }
754
755   /* don't send PITR generated mapping */
756   if (mapit->pitr_set)
757     return;
758
759   gid = &mapit->eid;
760   ip_prefix = &gid_address_ippref (gid);
761   mac = gid_address_mac (gid);
762
763   rmp = vl_msg_api_alloc (sizeof (*rmp));
764   memset (rmp, 0, sizeof (*rmp));
765   rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_DETAILS);
766
767   ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index);
768   if (vec_len (ls->locator_indices) == 0)
769     rmp->locator_set_index = ~0;
770   else
771     rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index);
772
773   rmp->is_local = mapit->local;
774   rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
775   rmp->action = mapit->action;
776   rmp->authoritative = mapit->authoritative;
777
778   switch (gid_address_type (gid))
779     {
780     case GID_ADDR_SRC_DST:
781       rmp->is_src_dst = 1;
782       fid = &gid_address_sd_src (gid);
783       rmp->eid_type = fid_type_to_api_type (fid);
784       lisp_fid_put_api (rmp->seid, &gid_address_sd_src (gid),
785                         &rmp->seid_prefix_len);
786       lisp_fid_put_api (rmp->eid, &gid_address_sd_dst (gid),
787                         &rmp->eid_prefix_len);
788       break;
789     case GID_ADDR_IP_PREFIX:
790       rmp->eid_prefix_len = ip_prefix_len (ip_prefix);
791       if (ip_prefix_version (ip_prefix) == IP4)
792         {
793           rmp->eid_type = 0;    /* ipv4 type */
794           clib_memcpy (rmp->eid, &ip_prefix_v4 (ip_prefix),
795                        sizeof (ip_prefix_v4 (ip_prefix)));
796         }
797       else
798         {
799           rmp->eid_type = 1;    /* ipv6 type */
800           clib_memcpy (rmp->eid, &ip_prefix_v6 (ip_prefix),
801                        sizeof (ip_prefix_v6 (ip_prefix)));
802         }
803       break;
804     case GID_ADDR_MAC:
805       rmp->eid_type = 2;        /* l2 mac type */
806       clib_memcpy (rmp->eid, mac, 6);
807       break;
808     default:
809       ASSERT (0);
810     }
811   rmp->context = context;
812   rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
813   rmp->key_id = clib_host_to_net_u16 (mapit->key_id);
814   memcpy (rmp->key, mapit->key, vec_len (mapit->key));
815   vl_msg_api_send_shmem (q, (u8 *) & rmp);
816 }
817
818 static void
819 vl_api_lisp_eid_table_dump_t_handler (vl_api_lisp_eid_table_dump_t * mp)
820 {
821   u32 mi;
822   unix_shared_memory_queue_t *q = NULL;
823   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
824   mapping_t *mapit = NULL;
825   gid_address_t _eid, *eid = &_eid;
826
827   q = vl_api_client_index_to_input_queue (mp->client_index);
828   if (q == 0)
829     {
830       return;
831     }
832
833   if (mp->eid_set)
834     {
835       memset (eid, 0, sizeof (*eid));
836
837       unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
838                              mp->eid_type, mp->eid, mp->prefix_length);
839
840       mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
841       if ((u32) ~ 0 == mi)
842         return;
843
844       mapit = pool_elt_at_index (lcm->mapping_pool, mi);
845       send_lisp_eid_table_details (mapit, q, mp->context,
846                                    0 /* ignore filter */ );
847     }
848   else
849     {
850       /* *INDENT-OFF* */
851       pool_foreach (mapit, lcm->mapping_pool,
852       ({
853         send_lisp_eid_table_details(mapit, q, mp->context,
854                                     mp->filter);
855       }));
856       /* *INDENT-ON* */
857     }
858 }
859
860 static void
861 send_lisp_map_server_details (ip_address_t * ip,
862                               unix_shared_memory_queue_t * q, u32 context)
863 {
864   vl_api_lisp_map_server_details_t *rmp = NULL;
865
866   rmp = vl_msg_api_alloc (sizeof (*rmp));
867   memset (rmp, 0, sizeof (*rmp));
868   rmp->_vl_msg_id = ntohs (VL_API_LISP_MAP_SERVER_DETAILS);
869
870   switch (ip_addr_version (ip))
871     {
872     case IP4:
873       rmp->is_ipv6 = 0;
874       clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
875                    sizeof (ip_addr_v4 (ip)));
876       break;
877
878     case IP6:
879       rmp->is_ipv6 = 1;
880       clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
881                    sizeof (ip_addr_v6 (ip)));
882       break;
883
884     default:
885       ASSERT (0);
886     }
887   rmp->context = context;
888
889   vl_msg_api_send_shmem (q, (u8 *) & rmp);
890 }
891
892 static void
893 vl_api_lisp_map_server_dump_t_handler (vl_api_lisp_map_server_dump_t * mp)
894 {
895   unix_shared_memory_queue_t *q = NULL;
896   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
897   lisp_msmr_t *mr;
898
899   q = vl_api_client_index_to_input_queue (mp->client_index);
900   if (q == 0)
901     {
902       return;
903     }
904
905   vec_foreach (mr, lcm->map_servers)
906   {
907     send_lisp_map_server_details (&mr->address, q, mp->context);
908   }
909 }
910
911 static void
912 send_lisp_map_resolver_details (ip_address_t * ip,
913                                 unix_shared_memory_queue_t * q, u32 context)
914 {
915   vl_api_lisp_map_resolver_details_t *rmp = NULL;
916
917   rmp = vl_msg_api_alloc (sizeof (*rmp));
918   memset (rmp, 0, sizeof (*rmp));
919   rmp->_vl_msg_id = ntohs (VL_API_LISP_MAP_RESOLVER_DETAILS);
920
921   switch (ip_addr_version (ip))
922     {
923     case IP4:
924       rmp->is_ipv6 = 0;
925       clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
926                    sizeof (ip_addr_v4 (ip)));
927       break;
928
929     case IP6:
930       rmp->is_ipv6 = 1;
931       clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
932                    sizeof (ip_addr_v6 (ip)));
933       break;
934
935     default:
936       ASSERT (0);
937     }
938   rmp->context = context;
939
940   vl_msg_api_send_shmem (q, (u8 *) & rmp);
941 }
942
943 static void
944 vl_api_lisp_map_resolver_dump_t_handler (vl_api_lisp_map_resolver_dump_t * mp)
945 {
946   unix_shared_memory_queue_t *q = NULL;
947   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
948   lisp_msmr_t *mr;
949
950   q = vl_api_client_index_to_input_queue (mp->client_index);
951   if (q == 0)
952     {
953       return;
954     }
955
956   vec_foreach (mr, lcm->map_resolvers)
957   {
958     send_lisp_map_resolver_details (&mr->address, q, mp->context);
959   }
960 }
961
962 static void
963 send_eid_table_map_pair (hash_pair_t * p,
964                          unix_shared_memory_queue_t * q, u32 context)
965 {
966   vl_api_lisp_eid_table_map_details_t *rmp = NULL;
967
968   rmp = vl_msg_api_alloc (sizeof (*rmp));
969   memset (rmp, 0, sizeof (*rmp));
970   rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_MAP_DETAILS);
971
972   rmp->vni = clib_host_to_net_u32 (p->key);
973   rmp->dp_table = clib_host_to_net_u32 (p->value[0]);
974   rmp->context = context;
975   vl_msg_api_send_shmem (q, (u8 *) & rmp);
976 }
977
978 static void
979 vl_api_lisp_eid_table_map_dump_t_handler (vl_api_lisp_eid_table_map_dump_t *
980                                           mp)
981 {
982   unix_shared_memory_queue_t *q = NULL;
983   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
984   hash_pair_t *p;
985   uword *vni_table = 0;
986
987   q = vl_api_client_index_to_input_queue (mp->client_index);
988   if (q == 0)
989     {
990       return;
991     }
992
993   if (mp->is_l2)
994     {
995       vni_table = lcm->bd_id_by_vni;
996     }
997   else
998     {
999       vni_table = lcm->table_id_by_vni;
1000     }
1001
1002   /* *INDENT-OFF* */
1003   hash_foreach_pair (p, vni_table,
1004   ({
1005     send_eid_table_map_pair (p, q, mp->context);
1006   }));
1007   /* *INDENT-ON* */
1008 }
1009
1010 static void
1011 send_eid_table_vni (u32 vni, unix_shared_memory_queue_t * q, u32 context)
1012 {
1013   vl_api_lisp_eid_table_vni_details_t *rmp = 0;
1014
1015   rmp = vl_msg_api_alloc (sizeof (*rmp));
1016   memset (rmp, 0, sizeof (*rmp));
1017   rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_VNI_DETAILS);
1018   rmp->context = context;
1019   rmp->vni = clib_host_to_net_u32 (vni);
1020   vl_msg_api_send_shmem (q, (u8 *) & rmp);
1021 }
1022
1023 static void
1024 lisp_adjacency_copy (vl_api_lisp_adjacency_t * dst, lisp_adjacency_t * adjs)
1025 {
1026   lisp_adjacency_t *adj;
1027   vl_api_lisp_adjacency_t a;
1028   u32 i, n = vec_len (adjs);
1029
1030   for (i = 0; i < n; i++)
1031     {
1032       adj = vec_elt_at_index (adjs, i);
1033       memset (&a, 0, sizeof (a));
1034
1035       switch (gid_address_type (&adj->reid))
1036         {
1037         case GID_ADDR_IP_PREFIX:
1038           a.reid_prefix_len = gid_address_ippref_len (&adj->reid);
1039           a.leid_prefix_len = gid_address_ippref_len (&adj->leid);
1040           if (gid_address_ip_version (&adj->reid) == IP4)
1041             {
1042               a.eid_type = 0;   /* ipv4 type */
1043               clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 4);
1044               clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 4);
1045             }
1046           else
1047             {
1048               a.eid_type = 1;   /* ipv6 type */
1049               clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 16);
1050               clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 16);
1051             }
1052           break;
1053         case GID_ADDR_MAC:
1054           a.eid_type = 2;       /* l2 mac type */
1055           mac_copy (a.reid, gid_address_mac (&adj->reid));
1056           mac_copy (a.leid, gid_address_mac (&adj->leid));
1057           break;
1058         default:
1059           ASSERT (0);
1060         }
1061       dst[i] = a;
1062     }
1063 }
1064
1065 static void
1066   vl_api_show_lisp_rloc_probe_state_t_handler
1067   (vl_api_show_lisp_rloc_probe_state_t * mp)
1068 {
1069   vl_api_show_lisp_rloc_probe_state_reply_t *rmp = 0;
1070   int rv = 0;
1071
1072   /* *INDENT-OFF* */
1073   REPLY_MACRO2 (VL_API_SHOW_LISP_RLOC_PROBE_STATE_REPLY,
1074   {
1075     rmp->is_enabled = vnet_lisp_rloc_probe_state_get ();
1076   });
1077   /* *INDENT-ON* */
1078 }
1079
1080 static void
1081   vl_api_show_lisp_map_register_state_t_handler
1082   (vl_api_show_lisp_map_register_state_t * mp)
1083 {
1084   vl_api_show_lisp_map_register_state_reply_t *rmp = 0;
1085   int rv = 0;
1086
1087   /* *INDENT-OFF* */
1088   REPLY_MACRO2 (VL_API_SHOW_LISP_MAP_REGISTER_STATE_REPLY,
1089   {
1090     rmp->is_enabled = vnet_lisp_map_register_state_get ();
1091   });
1092   /* *INDENT-ON* */
1093 }
1094
1095 static void
1096 vl_api_lisp_adjacencies_get_t_handler (vl_api_lisp_adjacencies_get_t * mp)
1097 {
1098   vl_api_lisp_adjacencies_get_reply_t *rmp = 0;
1099   lisp_adjacency_t *adjs = 0;
1100   int rv = 0;
1101   u32 size = ~0;
1102   u32 vni = clib_net_to_host_u32 (mp->vni);
1103
1104   adjs = vnet_lisp_adjacencies_get_by_vni (vni);
1105   size = vec_len (adjs) * sizeof (vl_api_lisp_adjacency_t);
1106
1107   /* *INDENT-OFF* */
1108   REPLY_MACRO4 (VL_API_LISP_ADJACENCIES_GET_REPLY, size,
1109   {
1110     rmp->count = clib_host_to_net_u32 (vec_len (adjs));
1111     lisp_adjacency_copy (rmp->adjacencies, adjs);
1112   });
1113   /* *INDENT-ON* */
1114
1115   vec_free (adjs);
1116 }
1117
1118 static void
1119 vl_api_lisp_eid_table_vni_dump_t_handler (vl_api_lisp_eid_table_vni_dump_t *
1120                                           mp)
1121 {
1122   hash_pair_t *p;
1123   u32 *vnis = 0;
1124   unix_shared_memory_queue_t *q = 0;
1125   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1126
1127   q = vl_api_client_index_to_input_queue (mp->client_index);
1128   if (q == 0)
1129     {
1130       return;
1131     }
1132
1133   /* *INDENT-OFF* */
1134   hash_foreach_pair (p, lcm->table_id_by_vni,
1135   ({
1136     hash_set (vnis, p->key, 0);
1137   }));
1138
1139   hash_foreach_pair (p, lcm->bd_id_by_vni,
1140   ({
1141     hash_set (vnis, p->key, 0);
1142   }));
1143
1144   hash_foreach_pair (p, vnis,
1145   ({
1146     send_eid_table_vni (p->key, q, mp->context);
1147   }));
1148   /* *INDENT-ON* */
1149
1150   hash_free (vnis);
1151 }
1152
1153 static void
1154 vl_api_show_lisp_status_t_handler (vl_api_show_lisp_status_t * mp)
1155 {
1156   unix_shared_memory_queue_t *q = NULL;
1157   vl_api_show_lisp_status_reply_t *rmp = NULL;
1158   int rv = 0;
1159
1160   q = vl_api_client_index_to_input_queue (mp->client_index);
1161   if (q == 0)
1162     {
1163       return;
1164     }
1165
1166   /* *INDENT-OFF* */
1167   REPLY_MACRO2(VL_API_SHOW_LISP_STATUS_REPLY,
1168   ({
1169     rmp->gpe_status = vnet_lisp_gpe_enable_disable_status ();
1170     rmp->feature_status = vnet_lisp_enable_disable_status ();
1171   }));
1172   /* *INDENT-ON* */
1173 }
1174
1175 static void
1176   vl_api_lisp_get_map_request_itr_rlocs_t_handler
1177   (vl_api_lisp_get_map_request_itr_rlocs_t * mp)
1178 {
1179   unix_shared_memory_queue_t *q = NULL;
1180   vl_api_lisp_get_map_request_itr_rlocs_reply_t *rmp = NULL;
1181   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1182   locator_set_t *loc_set = 0;
1183   u8 *tmp_str = 0;
1184   int rv = 0;
1185
1186   q = vl_api_client_index_to_input_queue (mp->client_index);
1187   if (q == 0)
1188     {
1189       return;
1190     }
1191
1192   if (~0 == lcm->mreq_itr_rlocs)
1193     {
1194       tmp_str = format (0, " ");
1195     }
1196   else
1197     {
1198       loc_set =
1199         pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
1200       tmp_str = format (0, "%s", loc_set->name);
1201     }
1202
1203   /* *INDENT-OFF* */
1204   REPLY_MACRO2(VL_API_LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY,
1205   ({
1206     strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1207             ARRAY_LEN(rmp->locator_set_name) - 1);
1208   }));
1209   /* *INDENT-ON* */
1210
1211   vec_free (tmp_str);
1212 }
1213
1214 static void
1215 vl_api_show_lisp_pitr_t_handler (vl_api_show_lisp_pitr_t * mp)
1216 {
1217   unix_shared_memory_queue_t *q = NULL;
1218   vl_api_show_lisp_pitr_reply_t *rmp = NULL;
1219   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1220   mapping_t *m;
1221   locator_set_t *ls = 0;
1222   u8 *tmp_str = 0;
1223   int rv = 0;
1224
1225   q = vl_api_client_index_to_input_queue (mp->client_index);
1226   if (q == 0)
1227     {
1228       return;
1229     }
1230
1231   if (!lcm->lisp_pitr)
1232     {
1233       tmp_str = format (0, "N/A");
1234     }
1235   else
1236     {
1237       m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index);
1238       if (~0 != m->locator_set_index)
1239         {
1240           ls =
1241             pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1242           tmp_str = format (0, "%s", ls->name);
1243         }
1244       else
1245         {
1246           tmp_str = format (0, "N/A");
1247         }
1248     }
1249   vec_add1 (tmp_str, 0);
1250
1251   /* *INDENT-OFF* */
1252   REPLY_MACRO2(VL_API_SHOW_LISP_PITR_REPLY,
1253   ({
1254     rmp->status = lcm->lisp_pitr;
1255     strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1256             ARRAY_LEN(rmp->locator_set_name) - 1);
1257   }));
1258   /* *INDENT-ON* */
1259 }
1260
1261 /*
1262  * lisp_api_hookup
1263  * Add vpe's API message handlers to the table.
1264  * vlib has alread mapped shared memory and
1265  * added the client registration handlers.
1266  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1267  */
1268 #define vl_msg_name_crc_list
1269 #include <vnet/vnet_all_api_h.h>
1270 #undef vl_msg_name_crc_list
1271
1272 static void
1273 setup_message_id_table (api_main_t * am)
1274 {
1275 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1276   foreach_vl_msg_name_crc_lisp;
1277 #undef _
1278 }
1279
1280 static clib_error_t *
1281 lisp_api_hookup (vlib_main_t * vm)
1282 {
1283   api_main_t *am = &api_main;
1284
1285 #define _(N,n)                                                  \
1286     vl_msg_api_set_handlers(VL_API_##N, #n,                     \
1287                            vl_api_##n##_t_handler,              \
1288                            vl_noop_handler,                     \
1289                            vl_api_##n##_t_endian,               \
1290                            vl_api_##n##_t_print,                \
1291                            sizeof(vl_api_##n##_t), 1);
1292   foreach_vpe_api_msg;
1293 #undef _
1294
1295   /*
1296    * Set up the (msg_name, crc, message-id) table
1297    */
1298   setup_message_id_table (am);
1299
1300   return 0;
1301 }
1302
1303 VLIB_API_INIT_FUNCTION (lisp_api_hookup);
1304
1305 /*
1306  * fd.io coding-style-patch-verification: ON
1307  *
1308  * Local Variables:
1309  * eval: (c-set-style "gnu")
1310  * End:
1311  */