2 *------------------------------------------------------------------
3 * lisp_api.c - lisp api
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:
10 * http://www.apache.org/licenses/LICENSE-2.0
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 *------------------------------------------------------------------
20 #include <vnet/vnet.h>
21 #include <vlibmemory/api.h>
23 #include <vnet/interface.h>
24 #include <vnet/api_errno.h>
25 #include <lisp/lisp-cp/control.h>
26 #include <lisp/lisp-gpe/lisp_gpe.h>
27 #include <vnet/ip/ip_types_api.h>
28 #include <vnet/ethernet/ethernet_types_api.h>
29 #include <lisp/lisp-cp/lisp_types_api.h>
31 /* define message IDs */
32 #include <vnet/format_fns.h>
33 #include <lisp/lisp-cp/lisp.api_enum.h>
34 #include <lisp/lisp-cp/lisp.api_types.h>
37 * Base message ID fot the plugin
39 static u32 lisp_base_msg_id;
40 #define REPLY_MSG_ID_BASE lisp_base_msg_id
42 #include <vlibapi/api_helper_macros.h>
45 unformat_lisp_locs (vl_api_remote_locator_t * rmt_locs, u32 rloc_num)
48 locator_t *locs = 0, loc;
49 vl_api_remote_locator_t *r;
51 for (i = 0; i < rloc_num; i++)
55 clib_memset (&loc, 0, sizeof (loc));
56 ip_address_decode2 (&r->ip_address, &loc.address.ippref.addr);
57 loc.address.ippref.len =
58 ip_address_max_len (loc.address.ippref.addr.version);
60 loc.priority = r->priority;
61 loc.weight = r->weight;
69 vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t *
72 vl_api_lisp_add_del_locator_set_reply_t *rmp;
74 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
76 vl_api_local_locator_t *ls_loc;
77 u32 ls_index = ~0, locator_num;
78 u8 *locator_name = NULL;
81 clib_memset (a, 0, sizeof (a[0]));
83 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
84 locator_name = format (0, "%s", mp->locator_set_name);
85 vec_terminate_c_string (locator_name);
87 a->name = locator_name;
88 a->is_add = mp->is_add;
90 locator_num = clib_net_to_host_u32 (mp->locator_num);
92 clib_memset (&locator, 0, sizeof (locator));
93 for (i = 0; i < locator_num; i++)
95 ls_loc = &mp->locators[i];
96 VALIDATE_SW_IF_INDEX (ls_loc);
98 locator.sw_if_index = htonl (ls_loc->sw_if_index);
99 locator.priority = ls_loc->priority;
100 locator.weight = ls_loc->weight;
102 vec_add1 (a->locators, locator);
105 rv = vnet_lisp_add_del_locator_set (a, &ls_index);
107 BAD_SW_IF_INDEX_LABEL;
109 vec_free (locator_name);
110 vec_free (a->locators);
113 REPLY_MACRO2 (VL_API_LISP_ADD_DEL_LOCATOR_SET_REPLY,
115 rmp->ls_index = clib_host_to_net_u32 (ls_index);
121 vl_api_lisp_add_del_locator_t_handler (vl_api_lisp_add_del_locator_t * mp)
123 vl_api_lisp_add_del_locator_reply_t *rmp;
125 locator_t locator, *locators = NULL;
126 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
128 u8 *locator_name = NULL;
130 clib_memset (&locator, 0, sizeof (locator));
131 clib_memset (a, 0, sizeof (a[0]));
133 locator.sw_if_index = ntohl (mp->sw_if_index);
134 locator.priority = mp->priority;
135 locator.weight = mp->weight;
137 vec_add1 (locators, locator);
139 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
140 locator_name = format (0, "%s", mp->locator_set_name);
141 vec_terminate_c_string (locator_name);
143 a->name = locator_name;
144 a->locators = locators;
145 a->is_add = mp->is_add;
148 rv = vnet_lisp_add_del_locator (a, NULL, &ls_index);
151 vec_free (locator_name);
153 REPLY_MACRO (VL_API_LISP_ADD_DEL_LOCATOR_REPLY);
157 vl_api_lisp_add_del_local_eid_t_handler (vl_api_lisp_add_del_local_eid_t * mp)
159 vl_api_lisp_add_del_local_eid_reply_t *rmp;
160 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
162 gid_address_t _gid, *gid = &_gid;
164 u32 locator_set_index = ~0, map_index = ~0;
165 vnet_lisp_add_del_mapping_args_t _a, *a = &_a;
166 u8 *name = NULL, *key = NULL;
167 clib_memset (a, 0, sizeof (a[0]));
168 clib_memset (gid, 0, sizeof (gid[0]));
170 rv = unformat_lisp_eid_api (gid, mp->vni, &mp->eid);
174 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
175 name = format (0, "%s", mp->locator_set_name);
176 vec_terminate_c_string (name);
177 p = hash_get_mem (lcm->locator_set_index_by_name, name);
180 rv = VNET_API_ERROR_INVALID_VALUE;
183 locator_set_index = p[0];
186 key = format (0, "%s", mp->key.key);
188 /* XXX treat batch configuration */
189 a->is_add = mp->is_add;
190 gid_address_copy (&a->eid, gid);
191 a->locator_set_index = locator_set_index;
194 a->key_id = clib_net_to_host_u16 (mp->key.id);
196 rv = vnet_lisp_add_del_local_mapping (a, &map_index);
201 gid_address_free (&a->eid);
203 REPLY_MACRO (VL_API_LISP_ADD_DEL_LOCAL_EID_REPLY);
207 vl_api_lisp_eid_table_add_del_map_t_handler
208 (vl_api_lisp_eid_table_add_del_map_t * mp)
210 vl_api_lisp_eid_table_add_del_map_reply_t *rmp;
212 rv = vnet_lisp_eid_table_map (clib_net_to_host_u32 (mp->vni),
213 clib_net_to_host_u32 (mp->dp_table),
214 mp->is_l2, mp->is_add);
215 REPLY_MACRO (VL_API_LISP_EID_TABLE_ADD_DEL_MAP_REPLY)}
218 vl_api_lisp_add_del_map_server_t_handler (vl_api_lisp_add_del_map_server_t
221 vl_api_lisp_add_del_map_server_reply_t *rmp;
225 clib_memset (&addr, 0, sizeof (addr));
227 ip_address_decode2 (&mp->ip_address, &addr);
228 rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
230 REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_SERVER_REPLY);
234 vl_api_lisp_add_del_map_resolver_t_handler (vl_api_lisp_add_del_map_resolver_t
237 vl_api_lisp_add_del_map_resolver_reply_t *rmp;
239 vnet_lisp_add_del_map_resolver_args_t _a, *a = &_a;
241 clib_memset (a, 0, sizeof (a[0]));
243 a->is_add = mp->is_add;
244 ip_address_decode2 (&mp->ip_address, &a->address);
246 rv = vnet_lisp_add_del_map_resolver (a);
248 REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_RESOLVER_REPLY);
252 vl_api_lisp_map_register_enable_disable_t_handler
253 (vl_api_lisp_map_register_enable_disable_t * mp)
255 vl_api_lisp_map_register_enable_disable_reply_t *rmp;
258 vnet_lisp_map_register_enable_disable (mp->is_enable);
259 REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
263 vl_api_lisp_rloc_probe_enable_disable_t_handler
264 (vl_api_lisp_rloc_probe_enable_disable_t * mp)
266 vl_api_lisp_rloc_probe_enable_disable_reply_t *rmp;
269 vnet_lisp_rloc_probe_enable_disable (mp->is_enable);
270 REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
274 vl_api_lisp_enable_disable_t_handler (vl_api_lisp_enable_disable_t * mp)
276 vl_api_lisp_enable_disable_reply_t *rmp;
279 vnet_lisp_enable_disable (mp->is_enable);
280 REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
284 vl_api_show_lisp_map_request_mode_t_handler
285 (vl_api_show_lisp_map_request_mode_t * mp)
288 vl_api_show_lisp_map_request_mode_reply_t *rmp;
291 REPLY_MACRO2(VL_API_SHOW_LISP_MAP_REQUEST_MODE_REPLY,
293 rmp->is_src_dst = vnet_lisp_get_map_request_mode ();
299 vl_api_lisp_map_request_mode_t_handler (vl_api_lisp_map_request_mode_t * mp)
301 vl_api_lisp_map_request_mode_reply_t *rmp;
304 rv = vnet_lisp_set_map_request_mode (mp->is_src_dst);
306 REPLY_MACRO (VL_API_LISP_MAP_REQUEST_MODE_REPLY);
310 vl_api_lisp_pitr_set_locator_set_t_handler (vl_api_lisp_pitr_set_locator_set_t
313 vl_api_lisp_pitr_set_locator_set_reply_t *rmp;
317 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
318 ls_name = format (0, "%s", mp->ls_name);
319 vec_terminate_c_string (ls_name);
320 rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
323 REPLY_MACRO (VL_API_LISP_PITR_SET_LOCATOR_SET_REPLY);
327 vl_api_lisp_use_petr_t_handler (vl_api_lisp_use_petr_t * mp)
329 vl_api_lisp_use_petr_reply_t *rmp;
333 ip_address_decode2 (&mp->ip_address, &addr);
334 rv = vnet_lisp_use_petr (&addr, mp->is_add);
336 REPLY_MACRO (VL_API_LISP_USE_PETR_REPLY);
340 vl_api_show_lisp_use_petr_t_handler (vl_api_show_lisp_use_petr_t * mp)
342 vl_api_show_lisp_use_petr_reply_t *rmp = NULL;
343 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
345 locator_set_t *ls = 0;
351 clib_memset (&addr, 0, sizeof (addr));
352 status = lcm->flags & LISP_FLAG_USE_PETR;
355 m = pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index);
356 if (~0 != m->locator_set_index)
359 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
360 loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
361 gid_address_copy (&addr, &loc->address);
366 REPLY_MACRO2 (VL_API_SHOW_LISP_USE_PETR_REPLY,
368 rmp->is_petr_enable = status;
369 ip_address_encode2 (&gid_address_ip (&addr), &rmp->ip_address);
375 vl_api_lisp_add_del_map_request_itr_rlocs_t_handler
376 (vl_api_lisp_add_del_map_request_itr_rlocs_t * mp)
378 vl_api_lisp_add_del_map_request_itr_rlocs_reply_t *rmp;
380 u8 *locator_set_name = NULL;
381 vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
383 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
384 locator_set_name = format (0, "%s", mp->locator_set_name);
385 vec_terminate_c_string (locator_set_name);
387 a->is_add = mp->is_add;
388 a->locator_set_name = locator_set_name;
390 rv = vnet_lisp_add_del_mreq_itr_rlocs (a);
392 vec_free (locator_set_name);
394 REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
398 vl_api_lisp_add_del_remote_mapping_t_handler
399 (vl_api_lisp_add_del_remote_mapping_t * mp)
401 locator_t *rlocs = 0;
402 vl_api_lisp_add_del_remote_mapping_reply_t *rmp;
404 gid_address_t _eid, *eid = &_eid;
405 u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num);
407 clib_memset (eid, 0, sizeof (eid[0]));
409 rv = unformat_lisp_eid_api (eid, mp->vni, &mp->deid);
413 rlocs = unformat_lisp_locs (mp->rlocs, rloc_num);
417 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
418 clib_memset (a, 0, sizeof (*a));
419 gid_address_copy (&a->reid, eid);
421 rv = vnet_lisp_add_del_adjacency (a);
428 /* NOTE: for now this works as a static remote mapping, i.e.,
429 * not authoritative and ttl infinite. */
432 vnet_lisp_add_del_mapping_args_t _m_args, *m_args = &_m_args;
433 clib_memset (m_args, 0, sizeof (m_args[0]));
434 gid_address_copy (&m_args->eid, eid);
435 m_args->action = mp->action;
436 m_args->is_static = 1;
438 m_args->authoritative = 0;
439 rv = vnet_lisp_add_mapping (m_args, rlocs, NULL, NULL);
443 rv = vnet_lisp_del_mapping (eid, NULL);
447 vnet_lisp_clear_all_remote_adjacencies ();
452 REPLY_MACRO (VL_API_LISP_ADD_DEL_REMOTE_MAPPING_REPLY);
456 vl_api_lisp_add_del_adjacency_t_handler (vl_api_lisp_add_del_adjacency_t * mp)
458 vl_api_lisp_add_del_adjacency_reply_t *rmp;
459 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
462 clib_memset (a, 0, sizeof (a[0]));
464 rv = unformat_lisp_eid_api (&a->leid, mp->vni, &mp->leid);
465 rv = unformat_lisp_eid_api (&a->reid, mp->vni, &mp->reid);
470 a->is_add = mp->is_add;
471 rv = vnet_lisp_add_del_adjacency (a);
474 REPLY_MACRO (VL_API_LISP_ADD_DEL_ADJACENCY_REPLY);
478 send_lisp_locator_details (lisp_cp_main_t * lcm,
479 locator_t * loc, vl_api_registration_t * reg,
482 vl_api_lisp_locator_details_t *rmp;
484 rmp = vl_msg_api_alloc (sizeof (*rmp));
485 clib_memset (rmp, 0, sizeof (*rmp));
486 rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_DETAILS + REPLY_MSG_ID_BASE);
487 rmp->context = context;
489 rmp->local = loc->local;
492 rmp->sw_if_index = ntohl (loc->sw_if_index);
496 ip_address_encode2 (&gid_address_ip (&loc->address), &rmp->ip_address);
498 rmp->priority = loc->priority;
499 rmp->weight = loc->weight;
501 vl_api_send_msg (reg, (u8 *) rmp);
505 vl_api_lisp_locator_dump_t_handler (vl_api_lisp_locator_dump_t * mp)
508 vl_api_registration_t *reg = 0;
509 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
510 locator_set_t *lsit = 0;
512 u32 ls_index = ~0, *locit = 0;
515 reg = vl_api_client_index_to_registration (mp->client_index);
519 if (mp->is_index_set)
520 ls_index = htonl (mp->ls_index);
523 /* make sure we get a proper C-string */
524 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
525 ls_name = format (0, "%s", mp->ls_name);
526 vec_terminate_c_string (ls_name);
527 p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
533 if (pool_is_free_index (lcm->locator_set_pool, ls_index))
536 lsit = pool_elt_at_index (lcm->locator_set_pool, ls_index);
538 vec_foreach (locit, lsit->locator_indices)
540 loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
541 send_lisp_locator_details (lcm, loc, reg, mp->context);
548 send_lisp_locator_set_details (lisp_cp_main_t * lcm,
549 locator_set_t * lsit,
550 vl_api_registration_t * reg, u32 context,
553 vl_api_lisp_locator_set_details_t *rmp;
556 rmp = vl_msg_api_alloc (sizeof (*rmp));
557 clib_memset (rmp, 0, sizeof (*rmp));
559 ntohs (VL_API_LISP_LOCATOR_SET_DETAILS + REPLY_MSG_ID_BASE);
560 rmp->context = context;
562 rmp->ls_index = htonl (ls_index);
565 ASSERT (lsit->name != NULL);
566 strncpy ((char *) rmp->ls_name, (char *) lsit->name,
567 vec_len (lsit->name));
571 str = format (0, "<remote-%d>", ls_index);
572 strncpy ((char *) rmp->ls_name, (char *) str, vec_len (str));
576 vl_api_send_msg (reg, (u8 *) rmp);
580 vl_api_lisp_locator_set_dump_t_handler (vl_api_lisp_locator_set_dump_t * mp)
582 vl_api_registration_t *reg;
583 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
584 locator_set_t *lsit = NULL;
587 reg = vl_api_client_index_to_registration (mp->client_index);
593 pool_foreach (lsit, lcm->locator_set_pool,
595 if (filter && !((1 == filter && lsit->local) ||
596 (2 == filter && !lsit->local)))
600 send_lisp_locator_set_details (lcm, lsit, reg, mp->context,
601 lsit - lcm->locator_set_pool);
607 send_lisp_eid_table_details (mapping_t * mapit,
608 vl_api_registration_t * reg, u32 context,
611 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
612 locator_set_t *ls = 0;
613 vl_api_lisp_eid_table_details_t *rmp = NULL;
614 gid_address_t *gid = NULL;
618 case 0: /* all mappings */
621 case 1: /* local only */
625 case 2: /* remote only */
630 clib_warning ("Filter error, unknown filter: %d", filter);
634 /* don't send PITR generated mapping */
640 rmp = vl_msg_api_alloc (sizeof (*rmp));
641 clib_memset (rmp, 0, sizeof (*rmp));
642 rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_DETAILS + REPLY_MSG_ID_BASE);
644 ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index);
645 if (vec_len (ls->locator_indices) == 0)
646 rmp->locator_set_index = ~0;
648 rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index);
650 rmp->is_local = mapit->local;
651 rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
652 rmp->action = mapit->action;
653 rmp->authoritative = mapit->authoritative;
654 switch (gid_address_type (gid))
656 case GID_ADDR_SRC_DST:
657 lisp_fid_put_api (&rmp->seid, &gid_address_sd_src (gid));
658 lisp_fid_put_api (&rmp->deid, &gid_address_sd_dst (gid));
661 case GID_ADDR_IP_PREFIX:
662 lisp_gid_put_api (&rmp->seid, gid);
665 lisp_gid_put_api (&rmp->seid, gid);
670 rmp->context = context;
671 rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
672 rmp->key.id = clib_host_to_net_u16 (mapit->key_id);
673 memcpy (rmp->key.key, mapit->key, vec_len (mapit->key));
674 vl_api_send_msg (reg, (u8 *) rmp);
678 vl_api_lisp_eid_table_dump_t_handler (vl_api_lisp_eid_table_dump_t * mp)
681 vl_api_registration_t *reg;
682 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
683 mapping_t *mapit = NULL;
684 gid_address_t _eid, *eid = &_eid;
686 reg = vl_api_client_index_to_registration (mp->client_index);
692 clib_memset (eid, 0, sizeof (*eid));
694 unformat_lisp_eid_api (eid, mp->vni, &mp->eid);
696 mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
700 mapit = pool_elt_at_index (lcm->mapping_pool, mi);
701 send_lisp_eid_table_details (mapit, reg, mp->context,
702 0 /* ignore filter */ );
707 pool_foreach (mapit, lcm->mapping_pool,
709 send_lisp_eid_table_details(mapit, reg, mp->context,
717 send_lisp_map_server_details (ip_address_t * ip, vl_api_registration_t * reg,
720 vl_api_lisp_map_server_details_t *rmp = NULL;
722 rmp = vl_msg_api_alloc (sizeof (*rmp));
723 clib_memset (rmp, 0, sizeof (*rmp));
725 ntohs (VL_API_LISP_MAP_SERVER_DETAILS + REPLY_MSG_ID_BASE);
727 ip_address_encode2 (ip, &rmp->ip_address);
728 rmp->context = context;
730 vl_api_send_msg (reg, (u8 *) rmp);
734 vl_api_lisp_map_server_dump_t_handler (vl_api_lisp_map_server_dump_t * mp)
736 vl_api_registration_t *reg;
737 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
740 reg = vl_api_client_index_to_registration (mp->client_index);
744 vec_foreach (mr, lcm->map_servers)
746 send_lisp_map_server_details (&mr->address, reg, mp->context);
751 send_lisp_map_resolver_details (ip_address_t * ip,
752 vl_api_registration_t * reg, u32 context)
754 vl_api_lisp_map_resolver_details_t *rmp = NULL;
756 rmp = vl_msg_api_alloc (sizeof (*rmp));
757 clib_memset (rmp, 0, sizeof (*rmp));
759 ntohs (VL_API_LISP_MAP_RESOLVER_DETAILS + REPLY_MSG_ID_BASE);
761 ip_address_encode2 (ip, &rmp->ip_address);
762 rmp->context = context;
764 vl_api_send_msg (reg, (u8 *) rmp);
768 vl_api_lisp_map_resolver_dump_t_handler (vl_api_lisp_map_resolver_dump_t * mp)
770 vl_api_registration_t *reg;
771 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
774 reg = vl_api_client_index_to_registration (mp->client_index);
778 vec_foreach (mr, lcm->map_resolvers)
780 send_lisp_map_resolver_details (&mr->address, reg, mp->context);
785 send_eid_table_map_pair (hash_pair_t * p, vl_api_registration_t * reg,
788 vl_api_lisp_eid_table_map_details_t *rmp = NULL;
790 rmp = vl_msg_api_alloc (sizeof (*rmp));
791 clib_memset (rmp, 0, sizeof (*rmp));
793 ntohs (VL_API_LISP_EID_TABLE_MAP_DETAILS + REPLY_MSG_ID_BASE);
795 rmp->vni = clib_host_to_net_u32 (p->key);
796 rmp->dp_table = clib_host_to_net_u32 (p->value[0]);
797 rmp->context = context;
798 vl_api_send_msg (reg, (u8 *) rmp);
802 vl_api_lisp_eid_table_map_dump_t_handler (vl_api_lisp_eid_table_map_dump_t *
805 vl_api_registration_t *reg;
806 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
808 uword *vni_table = 0;
810 reg = vl_api_client_index_to_registration (mp->client_index);
816 vni_table = lcm->bd_id_by_vni;
820 vni_table = lcm->table_id_by_vni;
824 hash_foreach_pair (p, vni_table,
826 send_eid_table_map_pair (p, reg, mp->context);
832 send_eid_table_vni (u32 vni, vl_api_registration_t * reg, u32 context)
834 vl_api_lisp_eid_table_vni_details_t *rmp = 0;
836 rmp = vl_msg_api_alloc (sizeof (*rmp));
837 clib_memset (rmp, 0, sizeof (*rmp));
839 ntohs (VL_API_LISP_EID_TABLE_VNI_DETAILS + REPLY_MSG_ID_BASE);
840 rmp->context = context;
841 rmp->vni = clib_host_to_net_u32 (vni);
842 vl_api_send_msg (reg, (u8 *) rmp);
846 lisp_adjacency_copy (vl_api_lisp_adjacency_t * dst, lisp_adjacency_t * adjs)
848 lisp_adjacency_t *adj;
849 vl_api_lisp_adjacency_t a;
850 u32 i, n = vec_len (adjs);
852 for (i = 0; i < n; i++)
854 adj = vec_elt_at_index (adjs, i);
855 clib_memset (&a, 0, sizeof (a));
857 lisp_gid_put_api (&a.reid, &adj->reid);
858 lisp_gid_put_api (&a.leid, &adj->leid);
865 vl_api_show_lisp_rloc_probe_state_t_handler
866 (vl_api_show_lisp_rloc_probe_state_t * mp)
868 vl_api_show_lisp_rloc_probe_state_reply_t *rmp = 0;
872 REPLY_MACRO2 (VL_API_SHOW_LISP_RLOC_PROBE_STATE_REPLY,
874 rmp->is_enabled = vnet_lisp_rloc_probe_state_get ();
880 vl_api_show_lisp_map_register_state_t_handler
881 (vl_api_show_lisp_map_register_state_t * mp)
883 vl_api_show_lisp_map_register_state_reply_t *rmp = 0;
887 REPLY_MACRO2 (VL_API_SHOW_LISP_MAP_REGISTER_STATE_REPLY,
889 rmp->is_enabled = vnet_lisp_map_register_state_get ();
895 vl_api_lisp_adjacencies_get_t_handler (vl_api_lisp_adjacencies_get_t * mp)
897 vl_api_lisp_adjacencies_get_reply_t *rmp = 0;
898 lisp_adjacency_t *adjs = 0;
901 u32 vni = clib_net_to_host_u32 (mp->vni);
903 adjs = vnet_lisp_adjacencies_get_by_vni (vni);
904 size = vec_len (adjs) * sizeof (vl_api_lisp_adjacency_t);
907 REPLY_MACRO4 (VL_API_LISP_ADJACENCIES_GET_REPLY, size,
909 rmp->count = clib_host_to_net_u32 (vec_len (adjs));
910 lisp_adjacency_copy (rmp->adjacencies, adjs);
918 vl_api_lisp_eid_table_vni_dump_t_handler (vl_api_lisp_eid_table_vni_dump_t *
923 vl_api_registration_t *reg = 0;
924 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
926 reg = vl_api_client_index_to_registration (mp->client_index);
931 hash_foreach_pair (p, lcm->table_id_by_vni,
933 hash_set (vnis, p->key, 0);
936 hash_foreach_pair (p, lcm->bd_id_by_vni,
938 hash_set (vnis, p->key, 0);
941 hash_foreach_pair (p, vnis,
943 send_eid_table_vni (p->key, reg, mp->context);
951 vl_api_show_lisp_status_t_handler (vl_api_show_lisp_status_t * mp)
953 vl_api_show_lisp_status_reply_t *rmp = NULL;
957 REPLY_MACRO2(VL_API_SHOW_LISP_STATUS_REPLY,
959 rmp->is_gpe_enabled = vnet_lisp_gpe_enable_disable_status ();
960 rmp->is_lisp_enabled = vnet_lisp_enable_disable_status ();
966 vl_api_lisp_get_map_request_itr_rlocs_t_handler
967 (vl_api_lisp_get_map_request_itr_rlocs_t * mp)
969 vl_api_lisp_get_map_request_itr_rlocs_reply_t *rmp = NULL;
970 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
971 locator_set_t *loc_set = 0;
975 if (~0 == lcm->mreq_itr_rlocs)
977 tmp_str = format (0, " ");
982 pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
983 tmp_str = format (0, "%s", loc_set->name);
987 REPLY_MACRO2(VL_API_LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY,
989 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
990 ARRAY_LEN(rmp->locator_set_name) - 1);
998 vl_api_show_lisp_pitr_t_handler (vl_api_show_lisp_pitr_t * mp)
1000 vl_api_show_lisp_pitr_reply_t *rmp = NULL;
1001 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1003 locator_set_t *ls = 0;
1007 u8 is_enabled = (lcm->flags & LISP_FLAG_PITR_MODE)
1008 && lcm->pitr_map_index != ~0;
1012 tmp_str = format (0, "N/A");
1016 m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index);
1017 if (~0 != m->locator_set_index)
1020 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1021 tmp_str = format (0, "%s", ls->name);
1025 tmp_str = format (0, "N/A");
1028 vec_add1 (tmp_str, 0);
1031 REPLY_MACRO2(VL_API_SHOW_LISP_PITR_REPLY,
1033 rmp->is_enabled = lcm->flags & LISP_FLAG_PITR_MODE;
1034 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1035 ARRAY_LEN(rmp->locator_set_name) - 1);
1042 * Add vpe's API message handlers to the table.
1043 * vlib has already mapped shared memory and
1044 * added the client registration handlers.
1045 * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1047 #include <lisp/lisp-cp/lisp.api.c>
1049 static clib_error_t *
1050 lisp_api_hookup (vlib_main_t * vm)
1053 * Set up the (msg_name, crc, message-id) table
1055 lisp_base_msg_id = setup_message_id_table ();
1060 VLIB_API_INIT_FUNCTION (lisp_api_hookup);
1063 * fd.io coding-style-patch-verification: ON
1066 * eval: (c-set-style "gnu")