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