2 *------------------------------------------------------------------
3 * one_api.c - Overlay Network Engine API
5 * Copyright (c) 2016-2017 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>
28 #include <vnet/ip/ip_types_api.h>
29 #include <vnet/ethernet/ethernet_types_api.h>
31 /* define message IDs */
32 #include <vnet/format_fns.h>
33 #include <lisp/lisp-cp/one.api_enum.h>
34 #include <lisp/lisp-cp/one.api_types.h>
37 * Base message ID fot the plugin
39 static u32 one_base_msg_id;
40 #define REPLY_MSG_ID_BASE one_base_msg_id
42 #include <vlibapi/api_helper_macros.h>
44 #define REPLY_DETAILS(t, body) \
46 vl_api_registration_t * reg; \
47 reg = vl_api_client_index_to_registration (mp->client_index); \
51 rmp = vl_msg_api_alloc (sizeof (*rmp)); \
52 rmp->_vl_msg_id = ntohs((t)); \
53 rmp->context = mp->context; \
54 do {body;} while (0); \
55 vl_api_send_msg (reg, (u8 *)&rmp); \
58 #define foreach_vpe_api_msg \
59 _(ONE_ADD_DEL_LOCATOR_SET, one_add_del_locator_set) \
60 _(ONE_ADD_DEL_LOCATOR, one_add_del_locator) \
61 _(ONE_ADD_DEL_LOCAL_EID, one_add_del_local_eid) \
62 _(ONE_ADD_DEL_MAP_RESOLVER, one_add_del_map_resolver) \
63 _(ONE_ADD_DEL_MAP_SERVER, one_add_del_map_server) \
64 _(ONE_ENABLE_DISABLE, one_enable_disable) \
65 _(ONE_RLOC_PROBE_ENABLE_DISABLE, one_rloc_probe_enable_disable) \
66 _(ONE_MAP_REGISTER_ENABLE_DISABLE, one_map_register_enable_disable) \
67 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD, \
68 one_map_register_fallback_threshold) \
69 _(ONE_ADD_DEL_REMOTE_MAPPING, one_add_del_remote_mapping) \
70 _(ONE_ADD_DEL_ADJACENCY, one_add_del_adjacency) \
71 _(ONE_PITR_SET_LOCATOR_SET, one_pitr_set_locator_set) \
72 _(ONE_NSH_SET_LOCATOR_SET, one_nsh_set_locator_set) \
73 _(ONE_MAP_REQUEST_MODE, one_map_request_mode) \
74 _(ONE_EID_TABLE_ADD_DEL_MAP, one_eid_table_add_del_map) \
75 _(ONE_LOCATOR_SET_DUMP, one_locator_set_dump) \
76 _(ONE_LOCATOR_DUMP, one_locator_dump) \
77 _(ONE_EID_TABLE_DUMP, one_eid_table_dump) \
78 _(ONE_MAP_RESOLVER_DUMP, one_map_resolver_dump) \
79 _(ONE_MAP_SERVER_DUMP, one_map_server_dump) \
80 _(ONE_EID_TABLE_MAP_DUMP, one_eid_table_map_dump) \
81 _(ONE_EID_TABLE_VNI_DUMP, one_eid_table_vni_dump) \
82 _(ONE_ADJACENCIES_GET, one_adjacencies_get) \
83 _(ONE_MAP_REGISTER_SET_TTL, one_map_register_set_ttl) \
84 _(SHOW_ONE_NSH_MAPPING, show_one_nsh_mapping) \
85 _(SHOW_ONE_RLOC_PROBE_STATE, show_one_rloc_probe_state) \
86 _(SHOW_ONE_MAP_REGISTER_STATE, show_one_map_register_state) \
87 _(SHOW_ONE_MAP_REGISTER_TTL, show_one_map_register_ttl) \
88 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, \
89 show_one_map_register_fallback_threshold) \
90 _(SHOW_ONE_STATUS, show_one_status) \
91 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \
92 one_add_del_map_request_itr_rlocs) \
93 _(ONE_GET_MAP_REQUEST_ITR_RLOCS, one_get_map_request_itr_rlocs) \
94 _(SHOW_ONE_PITR, show_one_pitr) \
95 _(SHOW_ONE_MAP_REQUEST_MODE, show_one_map_request_mode) \
96 _(ONE_USE_PETR, one_use_petr) \
97 _(SHOW_ONE_USE_PETR, show_one_use_petr) \
98 _(SHOW_ONE_STATS_ENABLE_DISABLE, show_one_stats_enable_disable) \
99 _(ONE_STATS_ENABLE_DISABLE, one_stats_enable_disable) \
100 _(ONE_STATS_DUMP, one_stats_dump) \
101 _(ONE_STATS_FLUSH, one_stats_flush) \
102 _(ONE_L2_ARP_BD_GET, one_l2_arp_bd_get) \
103 _(ONE_L2_ARP_ENTRIES_GET, one_l2_arp_entries_get) \
104 _(ONE_ADD_DEL_L2_ARP_ENTRY, one_add_del_l2_arp_entry) \
105 _(ONE_ADD_DEL_NDP_ENTRY, one_add_del_ndp_entry) \
106 _(ONE_NDP_BD_GET, one_ndp_bd_get) \
107 _(ONE_NDP_ENTRIES_GET, one_ndp_entries_get) \
108 _(ONE_SET_TRANSPORT_PROTOCOL, one_set_transport_protocol) \
109 _(ONE_GET_TRANSPORT_PROTOCOL, one_get_transport_protocol) \
110 _(ONE_ENABLE_DISABLE_XTR_MODE, one_enable_disable_xtr_mode) \
111 _(ONE_SHOW_XTR_MODE, one_show_xtr_mode) \
112 _(ONE_ENABLE_DISABLE_PITR_MODE, one_enable_disable_pitr_mode) \
113 _(ONE_SHOW_PITR_MODE, one_show_pitr_mode) \
114 _(ONE_ENABLE_DISABLE_PETR_MODE, one_enable_disable_petr_mode) \
115 _(ONE_SHOW_PETR_MODE, one_show_petr_mode) \
119 unformat_one_locs (vl_api_remote_locator_t * rmt_locs, u32 rloc_num)
122 locator_t *locs = 0, loc;
123 vl_api_remote_locator_t *r;
125 for (i = 0; i < rloc_num; i++)
127 /* remote locators */
129 clib_memset (&loc, 0, sizeof (loc));
130 ip_address_decode2 (&r->ip_address, &loc.address.ippref.addr);
131 loc.address.ippref.len =
132 ip_address_max_len (loc.address.ippref.addr.version);
134 loc.priority = r->priority;
135 loc.weight = r->weight;
137 vec_add1 (locs, loc);
143 vl_api_one_map_register_set_ttl_t_handler (vl_api_one_map_register_set_ttl_t *
146 vl_api_one_map_register_set_ttl_reply_t *rmp;
149 mp->ttl = clib_net_to_host_u32 (mp->ttl);
150 rv = vnet_lisp_map_register_set_ttl (mp->ttl);
152 REPLY_MACRO (VL_API_ONE_MAP_REGISTER_SET_TTL_REPLY);
156 vl_api_show_one_map_register_ttl_t_handler
157 (vl_api_show_one_map_register_ttl_t * mp)
159 vl_api_show_one_map_register_ttl_reply_t *rmp;
162 u32 ttl = vnet_lisp_map_register_get_ttl ();
163 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_TTL_REPLY,
165 rmp->ttl = clib_host_to_net_u32 (ttl);
170 vl_api_one_add_del_locator_set_t_handler (vl_api_one_add_del_locator_set_t *
173 vl_api_one_add_del_locator_set_reply_t *rmp;
175 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
177 vl_api_local_locator_t *ls_loc;
178 u32 ls_index = ~0, locator_num;
179 u8 *locator_name = NULL;
182 clib_memset (a, 0, sizeof (a[0]));
184 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
185 locator_name = format (0, "%s", mp->locator_set_name);
186 vec_terminate_c_string (locator_name);
188 a->name = locator_name;
189 a->is_add = mp->is_add;
191 locator_num = clib_net_to_host_u32 (mp->locator_num);
193 clib_memset (&locator, 0, sizeof (locator));
194 for (i = 0; i < locator_num; i++)
196 ls_loc = &mp->locators[i];
197 VALIDATE_SW_IF_INDEX (ls_loc);
199 locator.sw_if_index = htonl (ls_loc->sw_if_index);
200 locator.priority = ls_loc->priority;
201 locator.weight = ls_loc->weight;
203 vec_add1 (a->locators, locator);
206 rv = vnet_lisp_add_del_locator_set (a, &ls_index);
208 BAD_SW_IF_INDEX_LABEL;
210 vec_free (locator_name);
211 vec_free (a->locators);
213 REPLY_MACRO2 (VL_API_ONE_ADD_DEL_LOCATOR_SET_REPLY,
215 rmp->ls_index = clib_host_to_net_u32 (ls_index);
220 vl_api_one_add_del_locator_t_handler (vl_api_one_add_del_locator_t * mp)
222 vl_api_one_add_del_locator_reply_t *rmp;
224 locator_t locator, *locators = NULL;
225 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
227 u8 *locator_name = NULL;
229 clib_memset (&locator, 0, sizeof (locator));
230 clib_memset (a, 0, sizeof (a[0]));
232 locator.sw_if_index = ntohl (mp->sw_if_index);
233 locator.priority = mp->priority;
234 locator.weight = mp->weight;
236 vec_add1 (locators, locator);
238 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
239 locator_name = format (0, "%s", mp->locator_set_name);
240 vec_terminate_c_string (locator_name);
242 a->name = locator_name;
243 a->locators = locators;
244 a->is_add = mp->is_add;
247 rv = vnet_lisp_add_del_locator (a, NULL, &ls_index);
250 vec_free (locator_name);
252 REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCATOR_REPLY);
259 } __attribute__ ((__packed__)) lisp_nsh_api_t;
262 unformat_one_eid_api (gid_address_t * dst, u32 vni, vl_api_eid_t * eid)
268 case EID_TYPE_API_PREFIX:
269 ip_prefix_decode (&eid->address.prefix, &prefix);
270 gid_address_type (dst) = GID_ADDR_IP_PREFIX;
271 if (prefix.fp_proto == FIB_PROTOCOL_IP4)
272 gid_address_ip_set (dst, &prefix.fp_addr.ip4, AF_IP4);
273 if (prefix.fp_proto == FIB_PROTOCOL_IP6)
274 gid_address_ip_set (dst, &prefix.fp_addr.ip6, AF_IP6);
275 gid_address_ippref_len (dst) = prefix.fp_len;
276 ip_prefix_normalize (&gid_address_ippref (dst));
278 case EID_TYPE_API_MAC:
279 gid_address_type (dst) = GID_ADDR_MAC;
280 mac_address_decode (eid->address.mac,
281 (mac_address_t *) & gid_address_mac (dst));
283 case EID_TYPE_API_NSH:
284 gid_address_type (dst) = GID_ADDR_NSH;
285 gid_address_nsh_spi (dst) = clib_net_to_host_u32 (eid->address.nsh.spi);
286 gid_address_nsh_si (dst) = eid->address.nsh.si;
290 return VNET_API_ERROR_INVALID_VALUE;
293 gid_address_vni (dst) = vni;
299 fid_to_api_eid (fid_address_t * fid, vl_api_eid_t * eid)
301 fib_prefix_t fib_prefix;
304 switch (fid_addr_type (fid))
306 case FID_ADDR_IP_PREF:
307 eid_type = EID_TYPE_API_PREFIX;
308 ip_prefix_to_fib_prefix (&fid_addr_ippref (fid), &fib_prefix);
309 ip_prefix_encode (&fib_prefix, &eid->address.prefix);
312 eid_type = EID_TYPE_API_MAC;
313 mac_address_encode ((mac_address_t *) fid_addr_mac (fid),
321 eid->type = eid_type;
325 vl_api_one_add_del_local_eid_t_handler (vl_api_one_add_del_local_eid_t * mp)
327 vl_api_one_add_del_local_eid_reply_t *rmp;
328 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
330 gid_address_t _eid, *eid = &_eid;
332 u32 locator_set_index = ~0, map_index = ~0;
333 vnet_lisp_add_del_mapping_args_t _a, *a = &_a;
334 u8 *name = NULL, *key = NULL;
335 clib_memset (a, 0, sizeof (a[0]));
336 clib_memset (eid, 0, sizeof (eid[0]));
338 rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->eid);
342 if (gid_address_type (eid) == GID_ADDR_NSH)
344 rv = VNET_API_ERROR_INVALID_VALUE;
348 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
349 name = format (0, "%s", mp->locator_set_name);
350 vec_terminate_c_string (name);
351 p = hash_get_mem (lcm->locator_set_index_by_name, name);
354 rv = VNET_API_ERROR_INVALID_VALUE;
357 locator_set_index = p[0];
359 if (mp->key.id != KEY_ID_API_HMAC_NO_KEY)
360 key = format (0, "%s", mp->key.key);
362 /* XXX treat batch configuration */
363 a->is_add = mp->is_add;
364 gid_address_copy (&a->eid, eid);
365 a->locator_set_index = locator_set_index;
368 a->key_id = mp->key.id;
370 rv = vnet_lisp_add_del_local_mapping (a, &map_index);
375 gid_address_free (&a->eid);
377 REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCAL_EID_REPLY);
381 vl_api_one_eid_table_add_del_map_t_handler
382 (vl_api_one_eid_table_add_del_map_t * mp)
384 vl_api_one_eid_table_add_del_map_reply_t *rmp;
386 rv = vnet_lisp_eid_table_map (clib_net_to_host_u32 (mp->vni),
387 clib_net_to_host_u32 (mp->dp_table),
388 mp->is_l2, mp->is_add);
389 REPLY_MACRO (VL_API_ONE_EID_TABLE_ADD_DEL_MAP_REPLY)}
392 vl_api_one_add_del_map_server_t_handler (vl_api_one_add_del_map_server_t * mp)
394 vl_api_one_add_del_map_server_reply_t *rmp;
398 clib_memset (&addr, 0, sizeof (addr));
400 ip_address_decode2 (&mp->ip_address, &addr);
402 rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
404 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_SERVER_REPLY);
408 vl_api_one_add_del_map_resolver_t_handler (vl_api_one_add_del_map_resolver_t
411 vl_api_one_add_del_map_resolver_reply_t *rmp;
413 vnet_lisp_add_del_map_resolver_args_t _a, *a = &_a;
415 clib_memset (a, 0, sizeof (a[0]));
417 ip_address_decode2 (&mp->ip_address, &a->address);
419 a->is_add = mp->is_add;
421 rv = vnet_lisp_add_del_map_resolver (a);
423 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_RESOLVER_REPLY);
427 vl_api_one_map_register_enable_disable_t_handler
428 (vl_api_one_map_register_enable_disable_t * mp)
430 vl_api_one_map_register_enable_disable_reply_t *rmp;
433 vnet_lisp_map_register_enable_disable (mp->is_enable);
434 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
438 vl_api_one_rloc_probe_enable_disable_t_handler
439 (vl_api_one_rloc_probe_enable_disable_t * mp)
441 vl_api_one_rloc_probe_enable_disable_reply_t *rmp;
444 vnet_lisp_rloc_probe_enable_disable (mp->is_enable);
445 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
449 vl_api_one_enable_disable_t_handler (vl_api_one_enable_disable_t * mp)
451 vl_api_one_enable_disable_reply_t *rmp;
454 vnet_lisp_enable_disable (mp->is_enable);
455 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
459 vl_api_show_one_map_request_mode_t_handler
460 (vl_api_show_one_map_request_mode_t * mp)
463 vl_api_show_one_map_request_mode_reply_t *rmp;
465 REPLY_MACRO2(VL_API_SHOW_ONE_MAP_REQUEST_MODE_REPLY,
467 rmp->mode = vnet_lisp_get_map_request_mode ();
472 vl_api_one_map_request_mode_t_handler (vl_api_one_map_request_mode_t * mp)
474 vl_api_one_map_request_mode_reply_t *rmp;
477 rv = vnet_lisp_set_map_request_mode (mp->mode);
479 REPLY_MACRO (VL_API_ONE_MAP_REQUEST_MODE_REPLY);
483 vl_api_one_nsh_set_locator_set_t_handler (vl_api_one_nsh_set_locator_set_t
486 vl_api_one_nsh_set_locator_set_reply_t *rmp;
490 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
491 ls_name = format (0, "%s", mp->ls_name);
492 vec_terminate_c_string (ls_name);
493 rv = vnet_lisp_nsh_set_locator_set (ls_name, mp->is_add);
496 REPLY_MACRO (VL_API_ONE_PITR_SET_LOCATOR_SET_REPLY);
500 vl_api_one_pitr_set_locator_set_t_handler (vl_api_one_pitr_set_locator_set_t
503 vl_api_one_pitr_set_locator_set_reply_t *rmp;
507 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
508 ls_name = format (0, "%s", mp->ls_name);
509 vec_terminate_c_string (ls_name);
510 rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
513 REPLY_MACRO (VL_API_ONE_PITR_SET_LOCATOR_SET_REPLY);
517 vl_api_one_use_petr_t_handler (vl_api_one_use_petr_t * mp)
519 vl_api_one_use_petr_reply_t *rmp;
523 ip_address_decode2 (&mp->ip_address, &addr);
525 rv = vnet_lisp_use_petr (&addr, mp->is_add);
527 REPLY_MACRO (VL_API_ONE_USE_PETR_REPLY);
531 vl_api_show_one_use_petr_t_handler (vl_api_show_one_use_petr_t * mp)
533 vl_api_show_one_use_petr_reply_t *rmp = NULL;
534 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
536 locator_set_t *ls = 0;
542 clib_memset (&addr, 0, sizeof (addr));
543 status = lcm->flags & LISP_FLAG_USE_PETR;
546 m = pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index);
547 if (~0 != m->locator_set_index)
550 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
551 loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
552 gid_address_copy (&addr, &loc->address);
556 REPLY_MACRO2 (VL_API_SHOW_ONE_USE_PETR_REPLY,
558 rmp->status = status;
559 ip_address_t *ip = &gid_address_ip (&addr);
561 ip_address_encode2 (ip, &rmp->ip_address);
566 vl_api_one_add_del_map_request_itr_rlocs_t_handler
567 (vl_api_one_add_del_map_request_itr_rlocs_t * mp)
569 vl_api_one_add_del_map_request_itr_rlocs_reply_t *rmp;
571 u8 *locator_set_name = NULL;
572 vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
574 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
575 locator_set_name = format (0, "%s", mp->locator_set_name);
576 vec_terminate_c_string (locator_set_name);
578 a->is_add = mp->is_add;
579 a->locator_set_name = locator_set_name;
581 rv = vnet_lisp_add_del_mreq_itr_rlocs (a);
583 vec_free (locator_set_name);
585 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
589 vl_api_one_add_del_remote_mapping_t_handler
590 (vl_api_one_add_del_remote_mapping_t * mp)
592 locator_t *rlocs = 0;
593 vl_api_one_add_del_remote_mapping_reply_t *rmp;
595 gid_address_t _eid, *eid = &_eid;
596 u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num);
598 clib_memset (eid, 0, sizeof (eid[0]));
600 rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->deid);
604 rlocs = unformat_one_locs (mp->rlocs, rloc_num);
608 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
609 clib_memset (a, 0, sizeof (a[0]));
610 gid_address_copy (&a->reid, eid);
612 rv = vnet_lisp_add_del_adjacency (a);
619 /* NOTE: for now this works as a static remote mapping, i.e.,
620 * not authoritative and ttl infinite. */
623 vnet_lisp_add_del_mapping_args_t _m_args, *m_args = &_m_args;
624 clib_memset (m_args, 0, sizeof (m_args[0]));
625 gid_address_copy (&m_args->eid, eid);
626 m_args->action = mp->action;
627 m_args->is_static = 1;
629 m_args->authoritative = 0;
630 rv = vnet_lisp_add_mapping (m_args, rlocs, NULL, NULL);
633 rv = vnet_lisp_del_mapping (eid, NULL);
636 vnet_lisp_clear_all_remote_adjacencies ();
641 REPLY_MACRO (VL_API_ONE_ADD_DEL_REMOTE_MAPPING_REPLY);
645 vl_api_one_add_del_adjacency_t_handler (vl_api_one_add_del_adjacency_t * mp)
647 vl_api_one_add_del_adjacency_reply_t *rmp;
648 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
651 clib_memset (a, 0, sizeof (a[0]));
654 unformat_one_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni),
657 unformat_one_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni),
663 a->is_add = mp->is_add;
664 rv = vnet_lisp_add_del_adjacency (a);
667 REPLY_MACRO (VL_API_ONE_ADD_DEL_ADJACENCY_REPLY);
671 send_one_locator_details (lisp_cp_main_t * lcm,
672 locator_t * loc, vl_api_registration_t * reg,
675 vl_api_one_locator_details_t *rmp;
677 rmp = vl_msg_api_alloc (sizeof (*rmp));
678 clib_memset (rmp, 0, sizeof (*rmp));
679 rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_DETAILS);
680 rmp->context = context;
682 rmp->local = loc->local;
685 rmp->sw_if_index = ntohl (loc->sw_if_index);
689 ip_address_encode2 (&loc->address.ippref.addr, &rmp->ip_address);
691 rmp->priority = loc->priority;
692 rmp->weight = loc->weight;
694 vl_api_send_msg (reg, (u8 *) rmp);
698 vl_api_one_locator_dump_t_handler (vl_api_one_locator_dump_t * mp)
701 vl_api_registration_t *reg;
702 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
703 locator_set_t *lsit = 0;
705 u32 ls_index = ~0, *locit = 0;
708 reg = vl_api_client_index_to_registration (mp->client_index);
712 if (mp->is_index_set)
713 ls_index = htonl (mp->ls_index);
716 /* make sure we get a proper C-string */
717 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
718 ls_name = format (0, "%s", mp->ls_name);
719 vec_terminate_c_string (ls_name);
720 p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
726 if (pool_is_free_index (lcm->locator_set_pool, ls_index))
729 lsit = pool_elt_at_index (lcm->locator_set_pool, ls_index);
731 vec_foreach (locit, lsit->locator_indices)
733 loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
734 send_one_locator_details (lcm, loc, reg, mp->context);
741 send_one_locator_set_details (lisp_cp_main_t * lcm,
742 locator_set_t * lsit,
743 vl_api_registration_t * reg, u32 context,
746 vl_api_one_locator_set_details_t *rmp;
749 rmp = vl_msg_api_alloc (sizeof (*rmp));
750 clib_memset (rmp, 0, sizeof (*rmp));
751 rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_SET_DETAILS);
752 rmp->context = context;
754 rmp->ls_index = htonl (ls_index);
757 ASSERT (lsit->name != NULL);
758 strncpy ((char *) rmp->ls_name, (char *) lsit->name,
759 vec_len (lsit->name));
763 str = format (0, "<remote-%d>", ls_index);
764 strncpy ((char *) rmp->ls_name, (char *) str, vec_len (str));
768 vl_api_send_msg (reg, (u8 *) rmp);
772 vl_api_one_locator_set_dump_t_handler (vl_api_one_locator_set_dump_t * mp)
774 vl_api_registration_t *reg;
775 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
776 locator_set_t *lsit = NULL;
779 reg = vl_api_client_index_to_registration (mp->client_index);
784 pool_foreach (lsit, lcm->locator_set_pool)
786 if (filter && !((1 == filter && lsit->local) ||
787 (2 == filter && !lsit->local)))
791 send_one_locator_set_details (lcm, lsit, reg, mp->context,
792 lsit - lcm->locator_set_pool);
797 send_one_eid_table_details (mapping_t * mapit,
798 vl_api_registration_t * reg, u32 context,
801 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
802 locator_set_t *ls = 0;
803 vl_api_one_eid_table_details_t *rmp = NULL;
804 gid_address_t *gid = NULL;
806 fib_prefix_t fib_prefix;
808 if (mapit->pitr_set || mapit->nsh_set)
813 case ONE_FILTER_API_ALL: /* all mappings */
816 case ONE_FILTER_API_LOCAL: /* local only */
820 case ONE_FILTER_API_REMOTE: /* remote only */
825 clib_warning ("Filter error, unknown filter: %d", filter);
831 rmp = vl_msg_api_alloc (sizeof (*rmp));
832 clib_memset (rmp, 0, sizeof (*rmp));
833 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_DETAILS);
835 ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index);
836 if (vec_len (ls->locator_indices) == 0)
837 rmp->locator_set_index = ~0;
839 rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index);
841 rmp->is_local = mapit->local;
842 rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
843 rmp->action = mapit->action;
844 rmp->authoritative = mapit->authoritative;
846 switch (gid_address_type (gid))
848 case GID_ADDR_SRC_DST:
849 fid_to_api_eid (&gid_address_sd_src (gid), &rmp->seid);
850 fid_to_api_eid (&gid_address_sd_dst (gid), &rmp->deid);
852 case GID_ADDR_IP_PREFIX:
853 eid_type = EID_TYPE_API_PREFIX;
854 rmp->seid.type = eid_type;
855 ip_prefix_to_fib_prefix (&gid_address_ippref (gid), &fib_prefix);
856 ip_prefix_encode (&fib_prefix, &rmp->seid.address.prefix);
859 eid_type = EID_TYPE_API_MAC;
860 rmp->seid.type = eid_type;
861 mac_address_encode ((mac_address_t *) gid_address_mac (gid),
862 rmp->seid.address.mac);
865 eid_type = EID_TYPE_API_NSH;
866 rmp->seid.type = eid_type;
867 rmp->seid.address.nsh.spi =
868 clib_host_to_net_u32 (gid_address_nsh_spi (gid));
869 rmp->seid.address.nsh.si = gid_address_nsh_si (gid);
876 rmp->context = context;
877 rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
878 rmp->key.id = mapit->key_id;
879 memcpy (rmp->key.key, mapit->key, vec_len (mapit->key));
880 vl_api_send_msg (reg, (u8 *) rmp);
884 vl_api_one_eid_table_dump_t_handler (vl_api_one_eid_table_dump_t * mp)
887 vl_api_registration_t *reg;
888 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
889 mapping_t *mapit = NULL;
890 gid_address_t _eid, *eid = &_eid;
892 reg = vl_api_client_index_to_registration (mp->client_index);
898 clib_memset (eid, 0, sizeof (*eid));
900 unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->eid);
902 mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
906 mapit = pool_elt_at_index (lcm->mapping_pool, mi);
907 send_one_eid_table_details (mapit, reg, mp->context,
908 0 /* ignore filter */ );
912 pool_foreach (mapit, lcm->mapping_pool)
914 send_one_eid_table_details(mapit, reg, mp->context,
921 send_one_map_server_details (ip_address_t * ip, vl_api_registration_t * reg,
924 vl_api_one_map_server_details_t *rmp = NULL;
926 rmp = vl_msg_api_alloc (sizeof (*rmp));
927 clib_memset (rmp, 0, sizeof (*rmp));
928 rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_SERVER_DETAILS);
931 ip_address_encode2 (ip, &rmp->ip_address);
933 rmp->context = context;
935 vl_api_send_msg (reg, (u8 *) rmp);
939 vl_api_one_map_server_dump_t_handler (vl_api_one_map_server_dump_t * mp)
941 vl_api_registration_t *reg;
942 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
945 reg = vl_api_client_index_to_registration (mp->client_index);
949 vec_foreach (mr, lcm->map_servers)
951 send_one_map_server_details (&mr->address, reg, mp->context);
956 send_one_map_resolver_details (ip_address_t * ip,
957 vl_api_registration_t * reg, u32 context)
959 vl_api_one_map_resolver_details_t *rmp = NULL;
961 rmp = vl_msg_api_alloc (sizeof (*rmp));
962 clib_memset (rmp, 0, sizeof (*rmp));
963 rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_RESOLVER_DETAILS);
965 ip_address_encode2 (ip, &rmp->ip_address);
966 rmp->context = context;
968 vl_api_send_msg (reg, (u8 *) rmp);
972 vl_api_one_map_resolver_dump_t_handler (vl_api_one_map_resolver_dump_t * mp)
974 vl_api_registration_t *reg;
975 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
978 reg = vl_api_client_index_to_registration (mp->client_index);
982 vec_foreach (mr, lcm->map_resolvers)
984 send_one_map_resolver_details (&mr->address, reg, mp->context);
989 send_eid_table_map_pair (hash_pair_t * p, vl_api_registration_t * reg,
992 vl_api_one_eid_table_map_details_t *rmp = NULL;
994 rmp = vl_msg_api_alloc (sizeof (*rmp));
995 clib_memset (rmp, 0, sizeof (*rmp));
996 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_MAP_DETAILS);
998 rmp->vni = clib_host_to_net_u32 (p->key);
999 rmp->dp_table = clib_host_to_net_u32 (p->value[0]);
1000 rmp->context = context;
1001 vl_api_send_msg (reg, (u8 *) rmp);
1005 vl_api_one_eid_table_map_dump_t_handler (vl_api_one_eid_table_map_dump_t * mp)
1007 vl_api_registration_t *reg;
1008 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1010 uword *vni_table = 0;
1012 reg = vl_api_client_index_to_registration (mp->client_index);
1018 vni_table = lcm->bd_id_by_vni;
1022 vni_table = lcm->table_id_by_vni;
1025 hash_foreach_pair (p, vni_table,
1027 send_eid_table_map_pair (p, reg, mp->context);
1032 send_eid_table_vni (u32 vni, vl_api_registration_t * reg, u32 context)
1034 vl_api_one_eid_table_vni_details_t *rmp = 0;
1036 rmp = vl_msg_api_alloc (sizeof (*rmp));
1037 clib_memset (rmp, 0, sizeof (*rmp));
1038 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_VNI_DETAILS);
1039 rmp->context = context;
1040 rmp->vni = clib_host_to_net_u32 (vni);
1041 vl_api_send_msg (reg, (u8 *) rmp);
1045 one_adjacency_copy (vl_api_one_adjacency_t * dst, lisp_adjacency_t * adjs)
1047 lisp_adjacency_t *adj;
1048 vl_api_one_adjacency_t a;
1049 u32 i, n = vec_len (adjs);
1050 fib_prefix_t rfib_prefix, lfib_prefix;
1053 for (i = 0; i < n; i++)
1055 adj = vec_elt_at_index (adjs, i);
1056 clib_memset (&a, 0, sizeof (a));
1058 switch (gid_address_type (&adj->reid))
1060 case GID_ADDR_IP_PREFIX:
1061 eid_type = EID_TYPE_API_PREFIX;
1062 ip_prefix_to_fib_prefix (&gid_address_ippref (&adj->reid),
1064 ip_prefix_to_fib_prefix (&gid_address_ippref (&adj->leid),
1066 ip_prefix_encode (&rfib_prefix, &a.reid.address.prefix);
1067 ip_prefix_encode (&lfib_prefix, &a.leid.address.prefix);
1070 eid_type = EID_TYPE_API_PREFIX;
1071 mac_address_encode ((mac_address_t *) gid_address_mac (&adj->reid),
1072 a.reid.address.mac);
1073 mac_address_encode ((mac_address_t *) gid_address_mac (&adj->leid),
1074 a.leid.address.mac);
1077 eid_type = EID_TYPE_API_PREFIX;
1078 a.reid.address.nsh.spi =
1079 clib_host_to_net_u32 (gid_address_nsh_spi (&adj->reid));
1080 a.reid.address.nsh.si = gid_address_nsh_si (&adj->reid);
1081 a.leid.address.nsh.spi =
1082 clib_host_to_net_u32 (gid_address_nsh_spi (&adj->leid));
1083 a.leid.address.nsh.si = gid_address_nsh_si (&adj->leid);
1088 a.reid.type = eid_type;
1089 a.leid.type = eid_type;
1095 vl_api_show_one_rloc_probe_state_t_handler
1096 (vl_api_show_one_rloc_probe_state_t * mp)
1098 vl_api_show_one_rloc_probe_state_reply_t *rmp = 0;
1101 REPLY_MACRO2 (VL_API_SHOW_ONE_RLOC_PROBE_STATE_REPLY,
1103 rmp->is_enable = vnet_lisp_rloc_probe_state_get ();
1108 vl_api_show_one_map_register_state_t_handler
1109 (vl_api_show_one_map_register_state_t * mp)
1111 vl_api_show_one_map_register_state_reply_t *rmp = 0;
1114 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_STATE_REPLY,
1116 rmp->is_enable = vnet_lisp_map_register_state_get ();
1121 vl_api_one_adjacencies_get_t_handler (vl_api_one_adjacencies_get_t * mp)
1123 vl_api_one_adjacencies_get_reply_t *rmp = 0;
1124 lisp_adjacency_t *adjs = 0;
1127 u32 vni = clib_net_to_host_u32 (mp->vni);
1129 adjs = vnet_lisp_adjacencies_get_by_vni (vni);
1130 size = vec_len (adjs) * sizeof (vl_api_one_adjacency_t);
1132 REPLY_MACRO4 (VL_API_ONE_ADJACENCIES_GET_REPLY, size,
1134 rmp->count = clib_host_to_net_u32 (vec_len (adjs));
1135 one_adjacency_copy (rmp->adjacencies, adjs);
1142 vl_api_one_eid_table_vni_dump_t_handler (vl_api_one_eid_table_vni_dump_t * mp)
1146 vl_api_registration_t *reg;
1147 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1149 reg = vl_api_client_index_to_registration (mp->client_index);
1153 hash_foreach_pair (p, lcm->table_id_by_vni,
1155 hash_set (vnis, p->key, 0);
1158 hash_foreach_pair (p, lcm->bd_id_by_vni,
1160 hash_set (vnis, p->key, 0);
1163 hash_foreach_pair (p, vnis,
1165 send_eid_table_vni (p->key, reg, mp->context);
1172 vl_api_show_one_status_t_handler (vl_api_show_one_status_t * mp)
1174 vl_api_show_one_status_reply_t *rmp = NULL;
1177 REPLY_MACRO2(VL_API_SHOW_ONE_STATUS_REPLY,
1179 rmp->gpe_status = vnet_lisp_gpe_enable_disable_status ();
1180 rmp->feature_status = vnet_lisp_enable_disable_status ();
1185 vl_api_one_get_map_request_itr_rlocs_t_handler
1186 (vl_api_one_get_map_request_itr_rlocs_t * mp)
1188 vl_api_one_get_map_request_itr_rlocs_reply_t *rmp = NULL;
1189 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1190 locator_set_t *loc_set = 0;
1194 if (~0 == lcm->mreq_itr_rlocs)
1196 tmp_str = format (0, " ");
1201 pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
1202 tmp_str = format (0, "%s", loc_set->name);
1205 REPLY_MACRO2(VL_API_ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY,
1207 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1208 ARRAY_LEN(rmp->locator_set_name) - 1);
1215 vl_api_show_one_nsh_mapping_t_handler (vl_api_show_one_nsh_mapping_t * mp)
1217 vl_api_show_one_nsh_mapping_reply_t *rmp = NULL;
1218 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1220 locator_set_t *ls = 0;
1225 if (lcm->nsh_map_index == (u32) ~ 0)
1227 tmp_str = format (0, "N/A");
1231 m = pool_elt_at_index (lcm->mapping_pool, lcm->nsh_map_index);
1232 if (~0 != m->locator_set_index)
1235 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1236 tmp_str = format (0, "%s", ls->name);
1241 tmp_str = format (0, "N/A");
1244 vec_add1 (tmp_str, 0);
1246 REPLY_MACRO2(VL_API_SHOW_ONE_NSH_MAPPING_REPLY,
1248 rmp->is_set = is_set;
1249 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1250 ARRAY_LEN(rmp->locator_set_name) - 1);
1255 vl_api_show_one_pitr_t_handler (vl_api_show_one_pitr_t * mp)
1257 vl_api_show_one_pitr_reply_t *rmp = NULL;
1258 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1260 locator_set_t *ls = 0;
1264 u8 is_enable = (lcm->flags & LISP_FLAG_PITR_MODE)
1265 && lcm->pitr_map_index != ~0;
1269 tmp_str = format (0, "N/A");
1273 m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index);
1274 if (~0 != m->locator_set_index)
1277 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1278 tmp_str = format (0, "%s", ls->name);
1282 tmp_str = format (0, "N/A");
1285 vec_add1 (tmp_str, 0);
1287 REPLY_MACRO2(VL_API_SHOW_ONE_PITR_REPLY,
1289 rmp->status = lcm->flags & LISP_FLAG_PITR_MODE;
1290 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1291 ARRAY_LEN(rmp->locator_set_name) - 1);
1296 vl_api_show_one_stats_enable_disable_t_handler
1297 (vl_api_show_one_stats_enable_disable_t * mp)
1299 vl_api_show_one_stats_enable_disable_reply_t *rmp = NULL;
1300 vnet_api_error_t rv = 0;
1302 REPLY_MACRO2 (VL_API_SHOW_ONE_STATS_ENABLE_DISABLE_REPLY,
1304 rmp->is_enable = vnet_lisp_stats_enable_disable_state ();
1309 vl_api_one_stats_enable_disable_t_handler
1310 (vl_api_one_stats_enable_disable_t * mp)
1312 vl_api_one_enable_disable_reply_t *rmp = NULL;
1314 vnet_api_error_t rv = vnet_lisp_stats_enable_disable (mp->is_enable);
1315 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
1319 vl_api_one_stats_flush_t_handler (vl_api_one_stats_flush_t * mp)
1321 vl_api_one_stats_flush_reply_t *rmp;
1324 rv = vnet_lisp_flush_stats ();
1325 REPLY_MACRO (VL_API_ONE_STATS_FLUSH_REPLY);
1329 vl_api_one_stats_dump_t_handler (vl_api_one_stats_dump_t * mp)
1331 vl_api_one_stats_details_t *rmp;
1332 lisp_api_stats_t *stats, *stat;
1334 stats = vnet_lisp_get_stats ();
1335 vec_foreach (stat, stats)
1337 REPLY_DETAILS (VL_API_ONE_STATS_DETAILS,
1339 fid_to_api_eid (&stat->deid, &rmp->deid);
1340 fid_to_api_eid (&stat->seid, &rmp->seid);
1341 rmp->vni = clib_host_to_net_u32 (stat->vni);
1343 ip_address_encode2 (&stat->rmt_rloc, &rmp->rloc);
1344 ip_address_encode2 (&stat->loc_rloc, &rmp->lloc);
1346 rmp->pkt_count = clib_host_to_net_u32 (stat->counters.packets);
1347 rmp->bytes = clib_host_to_net_u32 (stat->counters.bytes);
1353 vl_api_one_add_del_l2_arp_entry_t_handler
1354 (vl_api_one_add_del_l2_arp_entry_t * mp)
1356 vl_api_one_add_del_l2_arp_entry_reply_t *rmp;
1358 gid_address_t _arp, *arp = &_arp;
1361 clib_memset (arp, 0, sizeof (*arp));
1363 gid_address_type (arp) = GID_ADDR_ARP;
1364 gid_address_arp_bd (arp) = clib_net_to_host_u32 (mp->bd);
1366 ip4_address_decode (mp->entry.ip4, &ip4);
1367 ip_address_set (&gid_address_arp_ndp_ip (arp), &ip4, AF_IP4);
1368 mac_address_decode (mp->entry.mac, &mac);
1370 rv = vnet_lisp_add_del_l2_arp_ndp_entry (arp, mac.bytes, mp->is_add);
1372 REPLY_MACRO (VL_API_ONE_ADD_DEL_L2_ARP_ENTRY_REPLY);
1376 vl_api_one_add_del_ndp_entry_t_handler (vl_api_one_add_del_ndp_entry_t * mp)
1378 vl_api_one_add_del_ndp_entry_reply_t *rmp;
1380 gid_address_t _g, *g = &_g;
1383 clib_memset (g, 0, sizeof (*g));
1385 gid_address_type (g) = GID_ADDR_NDP;
1386 gid_address_ndp_bd (g) = clib_net_to_host_u32 (mp->bd);
1388 ip6_address_decode (mp->entry.ip6, &ip6);
1389 ip_address_set (&gid_address_arp_ndp_ip (g), &ip6, AF_IP6);
1390 mac_address_decode (mp->entry.mac, &mac);
1392 rv = vnet_lisp_add_del_l2_arp_ndp_entry (g, mac.bytes, mp->is_add);
1394 REPLY_MACRO (VL_API_ONE_ADD_DEL_NDP_ENTRY_REPLY);
1398 vl_api_one_ndp_bd_get_t_handler (vl_api_one_ndp_bd_get_t * mp)
1400 vl_api_one_ndp_bd_get_reply_t *rmp;
1405 u32 *bds = vnet_lisp_ndp_bds_get ();
1406 u32 size = hash_elts (bds) * sizeof (u32);
1408 REPLY_MACRO4 (VL_API_ONE_NDP_BD_GET_REPLY, size,
1410 rmp->count = clib_host_to_net_u32 (hash_elts (bds));
1411 hash_foreach_pair (p, bds,
1413 rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
1421 vl_api_one_l2_arp_bd_get_t_handler (vl_api_one_l2_arp_bd_get_t * mp)
1423 vl_api_one_l2_arp_bd_get_reply_t *rmp;
1428 u32 *bds = vnet_lisp_l2_arp_bds_get ();
1429 u32 size = hash_elts (bds) * sizeof (u32);
1431 REPLY_MACRO4 (VL_API_ONE_L2_ARP_BD_GET_REPLY, size,
1433 rmp->count = clib_host_to_net_u32 (hash_elts (bds));
1434 hash_foreach_pair (p, bds,
1436 rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
1444 vl_api_one_l2_arp_entries_get_t_handler (vl_api_one_l2_arp_entries_get_t * mp)
1446 vl_api_one_l2_arp_entries_get_reply_t *rmp;
1447 lisp_api_l2_arp_entry_t *entries = 0, *e;
1451 u32 bd = clib_net_to_host_u32 (mp->bd);
1453 entries = vnet_lisp_l2_arp_entries_get_by_bd (bd);
1454 u32 size = vec_len (entries) * sizeof (vl_api_one_l2_arp_entry_t);
1456 REPLY_MACRO4 (VL_API_ONE_L2_ARP_ENTRIES_GET_REPLY, size,
1458 rmp->count = clib_host_to_net_u32 (vec_len (entries));
1459 vec_foreach (e, entries)
1461 mac_address_encode ((mac_address_t *) e->mac, rmp->entries[i].mac);
1462 ip4_address_encode ((ip4_address_t *) &e->ip4, rmp->entries[i].ip4);
1471 vl_api_one_map_register_fallback_threshold_t_handler
1472 (vl_api_one_map_register_fallback_threshold_t * mp)
1474 vl_api_one_map_register_fallback_threshold_reply_t *rmp;
1477 mp->value = clib_net_to_host_u32 (mp->value);
1478 rv = vnet_lisp_map_register_fallback_threshold_set (mp->value);
1479 REPLY_MACRO (VL_API_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY);
1483 vl_api_show_one_map_register_fallback_threshold_t_handler
1484 (vl_api_show_one_map_register_fallback_threshold_t * mp)
1486 vl_api_show_one_map_register_fallback_threshold_reply_t *rmp;
1489 u32 value = vnet_lisp_map_register_fallback_threshold_get ();
1491 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY,
1493 rmp->value = clib_host_to_net_u32 (value);
1498 vl_api_one_set_transport_protocol_t_handler
1499 (vl_api_one_set_transport_protocol_t * mp)
1501 vl_api_one_set_transport_protocol_reply_t *rmp;
1504 rv = vnet_lisp_set_transport_protocol (mp->protocol);
1506 REPLY_MACRO (VL_API_ONE_SET_TRANSPORT_PROTOCOL_REPLY);
1510 vl_api_one_get_transport_protocol_t_handler
1511 (vl_api_one_get_transport_protocol_t * mp)
1513 vl_api_one_get_transport_protocol_reply_t *rmp;
1515 u8 proto = (u8) vnet_lisp_get_transport_protocol ();
1517 REPLY_MACRO2 (VL_API_ONE_GET_TRANSPORT_PROTOCOL_REPLY,
1519 rmp->protocol = proto;
1524 vl_api_one_ndp_entries_get_t_handler (vl_api_one_ndp_entries_get_t * mp)
1526 vl_api_one_ndp_entries_get_reply_t *rmp = 0;
1527 lisp_api_ndp_entry_t *entries = 0, *e;
1531 u32 bd = clib_net_to_host_u32 (mp->bd);
1533 entries = vnet_lisp_ndp_entries_get_by_bd (bd);
1534 u32 size = vec_len (entries) * sizeof (vl_api_one_ndp_entry_t);
1536 REPLY_MACRO4 (VL_API_ONE_NDP_ENTRIES_GET_REPLY, size,
1538 rmp->count = clib_host_to_net_u32 (vec_len (entries));
1539 vec_foreach (e, entries)
1541 mac_address_encode ((mac_address_t *) e->mac, rmp->entries[i].mac);
1542 ip6_address_encode ((ip6_address_t *) &e->ip6, rmp->entries[i].ip6);
1551 vl_api_one_enable_disable_xtr_mode_t_handler
1552 (vl_api_one_enable_disable_xtr_mode_t * mp)
1554 vl_api_one_enable_disable_xtr_mode_reply_t *rmp = 0;
1555 int rv = vnet_lisp_enable_disable_xtr_mode (mp->is_enable);
1557 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_XTR_MODE_REPLY);
1561 vl_api_one_show_xtr_mode_t_handler (vl_api_one_show_xtr_mode_t * mp)
1563 vl_api_one_show_xtr_mode_reply_t *rmp = 0;
1566 REPLY_MACRO2 (VL_API_ONE_SHOW_XTR_MODE_REPLY,
1568 rmp->is_enable = vnet_lisp_get_xtr_mode ();
1573 vl_api_one_enable_disable_pitr_mode_t_handler
1574 (vl_api_one_enable_disable_pitr_mode_t * mp)
1576 vl_api_one_enable_disable_pitr_mode_reply_t *rmp = 0;
1577 int rv = vnet_lisp_enable_disable_pitr_mode (mp->is_enable);
1579 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_PITR_MODE_REPLY);
1583 vl_api_one_show_pitr_mode_t_handler (vl_api_one_show_pitr_mode_t * mp)
1585 vl_api_one_show_pitr_mode_reply_t *rmp = 0;
1588 REPLY_MACRO2 (VL_API_ONE_SHOW_PITR_MODE_REPLY,
1590 rmp->is_enable = vnet_lisp_get_pitr_mode ();
1595 vl_api_one_enable_disable_petr_mode_t_handler
1596 (vl_api_one_enable_disable_petr_mode_t * mp)
1598 vl_api_one_enable_disable_petr_mode_reply_t *rmp = 0;
1599 int rv = vnet_lisp_enable_disable_petr_mode (mp->is_enable);
1601 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_PETR_MODE_REPLY);
1605 vl_api_one_show_petr_mode_t_handler (vl_api_one_show_petr_mode_t * mp)
1607 vl_api_one_show_petr_mode_reply_t *rmp = 0;
1610 REPLY_MACRO2 (VL_API_ONE_SHOW_PETR_MODE_REPLY,
1612 rmp->is_enable = vnet_lisp_get_petr_mode ();
1618 * Add vpe's API message handlers to the table.
1619 * vlib has already mapped shared memory and
1620 * added the client registration handlers.
1621 * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1623 #include <lisp/lisp-cp/one.api.c>
1625 static clib_error_t *
1626 one_api_hookup (vlib_main_t * vm)
1628 one_base_msg_id = setup_message_id_table ();
1633 VLIB_API_INIT_FUNCTION (one_api_hookup);
1635 #include <vlib/unix/plugin.h>
1636 #include <vpp/app/version.h>
1638 VLIB_PLUGIN_REGISTER () = {
1639 .version = VPP_BUILD_VER,
1640 .description = "Locator ID Separation Protocol (LISP)",
1644 * fd.io coding-style-patch-verification: ON
1647 * eval: (c-set-style "gnu")