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 rv = vl_msg_api_pd_handler (mp, rv); \
48 reg = vl_api_client_index_to_registration (mp->client_index); \
52 rmp = vl_msg_api_alloc (sizeof (*rmp)); \
53 rmp->_vl_msg_id = ntohs((t)); \
54 rmp->context = mp->context; \
55 do {body;} while (0); \
56 vl_api_send_msg (reg, (u8 *)&rmp); \
59 #define foreach_vpe_api_msg \
60 _(ONE_ADD_DEL_LOCATOR_SET, one_add_del_locator_set) \
61 _(ONE_ADD_DEL_LOCATOR, one_add_del_locator) \
62 _(ONE_ADD_DEL_LOCAL_EID, one_add_del_local_eid) \
63 _(ONE_ADD_DEL_MAP_RESOLVER, one_add_del_map_resolver) \
64 _(ONE_ADD_DEL_MAP_SERVER, one_add_del_map_server) \
65 _(ONE_ENABLE_DISABLE, one_enable_disable) \
66 _(ONE_RLOC_PROBE_ENABLE_DISABLE, one_rloc_probe_enable_disable) \
67 _(ONE_MAP_REGISTER_ENABLE_DISABLE, one_map_register_enable_disable) \
68 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD, \
69 one_map_register_fallback_threshold) \
70 _(ONE_ADD_DEL_REMOTE_MAPPING, one_add_del_remote_mapping) \
71 _(ONE_ADD_DEL_ADJACENCY, one_add_del_adjacency) \
72 _(ONE_PITR_SET_LOCATOR_SET, one_pitr_set_locator_set) \
73 _(ONE_NSH_SET_LOCATOR_SET, one_nsh_set_locator_set) \
74 _(ONE_MAP_REQUEST_MODE, one_map_request_mode) \
75 _(ONE_EID_TABLE_ADD_DEL_MAP, one_eid_table_add_del_map) \
76 _(ONE_LOCATOR_SET_DUMP, one_locator_set_dump) \
77 _(ONE_LOCATOR_DUMP, one_locator_dump) \
78 _(ONE_EID_TABLE_DUMP, one_eid_table_dump) \
79 _(ONE_MAP_RESOLVER_DUMP, one_map_resolver_dump) \
80 _(ONE_MAP_SERVER_DUMP, one_map_server_dump) \
81 _(ONE_EID_TABLE_MAP_DUMP, one_eid_table_map_dump) \
82 _(ONE_EID_TABLE_VNI_DUMP, one_eid_table_vni_dump) \
83 _(ONE_ADJACENCIES_GET, one_adjacencies_get) \
84 _(ONE_MAP_REGISTER_SET_TTL, one_map_register_set_ttl) \
85 _(SHOW_ONE_NSH_MAPPING, show_one_nsh_mapping) \
86 _(SHOW_ONE_RLOC_PROBE_STATE, show_one_rloc_probe_state) \
87 _(SHOW_ONE_MAP_REGISTER_STATE, show_one_map_register_state) \
88 _(SHOW_ONE_MAP_REGISTER_TTL, show_one_map_register_ttl) \
89 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, \
90 show_one_map_register_fallback_threshold) \
91 _(SHOW_ONE_STATUS, show_one_status) \
92 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \
93 one_add_del_map_request_itr_rlocs) \
94 _(ONE_GET_MAP_REQUEST_ITR_RLOCS, one_get_map_request_itr_rlocs) \
95 _(SHOW_ONE_PITR, show_one_pitr) \
96 _(SHOW_ONE_MAP_REQUEST_MODE, show_one_map_request_mode) \
97 _(ONE_USE_PETR, one_use_petr) \
98 _(SHOW_ONE_USE_PETR, show_one_use_petr) \
99 _(SHOW_ONE_STATS_ENABLE_DISABLE, show_one_stats_enable_disable) \
100 _(ONE_STATS_ENABLE_DISABLE, one_stats_enable_disable) \
101 _(ONE_STATS_DUMP, one_stats_dump) \
102 _(ONE_STATS_FLUSH, one_stats_flush) \
103 _(ONE_L2_ARP_BD_GET, one_l2_arp_bd_get) \
104 _(ONE_L2_ARP_ENTRIES_GET, one_l2_arp_entries_get) \
105 _(ONE_ADD_DEL_L2_ARP_ENTRY, one_add_del_l2_arp_entry) \
106 _(ONE_ADD_DEL_NDP_ENTRY, one_add_del_ndp_entry) \
107 _(ONE_NDP_BD_GET, one_ndp_bd_get) \
108 _(ONE_NDP_ENTRIES_GET, one_ndp_entries_get) \
109 _(ONE_SET_TRANSPORT_PROTOCOL, one_set_transport_protocol) \
110 _(ONE_GET_TRANSPORT_PROTOCOL, one_get_transport_protocol) \
111 _(ONE_ENABLE_DISABLE_XTR_MODE, one_enable_disable_xtr_mode) \
112 _(ONE_SHOW_XTR_MODE, one_show_xtr_mode) \
113 _(ONE_ENABLE_DISABLE_PITR_MODE, one_enable_disable_pitr_mode) \
114 _(ONE_SHOW_PITR_MODE, one_show_pitr_mode) \
115 _(ONE_ENABLE_DISABLE_PETR_MODE, one_enable_disable_petr_mode) \
116 _(ONE_SHOW_PETR_MODE, one_show_petr_mode) \
120 unformat_one_locs (vl_api_remote_locator_t * rmt_locs, u32 rloc_num)
123 locator_t *locs = 0, loc;
124 vl_api_remote_locator_t *r;
126 for (i = 0; i < rloc_num; i++)
128 /* remote locators */
130 clib_memset (&loc, 0, sizeof (loc));
131 ip_address_decode2 (&r->ip_address, &loc.address.ippref.addr);
132 loc.address.ippref.len =
133 ip_address_max_len (loc.address.ippref.addr.version);
135 loc.priority = r->priority;
136 loc.weight = r->weight;
138 vec_add1 (locs, loc);
144 vl_api_one_map_register_set_ttl_t_handler (vl_api_one_map_register_set_ttl_t *
147 vl_api_one_map_register_set_ttl_reply_t *rmp;
150 mp->ttl = clib_net_to_host_u32 (mp->ttl);
151 rv = vnet_lisp_map_register_set_ttl (mp->ttl);
153 REPLY_MACRO (VL_API_ONE_MAP_REGISTER_SET_TTL_REPLY);
157 vl_api_show_one_map_register_ttl_t_handler
158 (vl_api_show_one_map_register_ttl_t * mp)
160 vl_api_show_one_map_register_ttl_reply_t *rmp;
163 u32 ttl = vnet_lisp_map_register_get_ttl ();
165 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_TTL_REPLY,
167 rmp->ttl = clib_host_to_net_u32 (ttl);
173 vl_api_one_add_del_locator_set_t_handler (vl_api_one_add_del_locator_set_t *
176 vl_api_one_add_del_locator_set_reply_t *rmp;
178 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
180 vl_api_local_locator_t *ls_loc;
181 u32 ls_index = ~0, locator_num;
182 u8 *locator_name = NULL;
185 clib_memset (a, 0, sizeof (a[0]));
187 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
188 locator_name = format (0, "%s", mp->locator_set_name);
189 vec_terminate_c_string (locator_name);
191 a->name = locator_name;
192 a->is_add = mp->is_add;
194 locator_num = clib_net_to_host_u32 (mp->locator_num);
196 clib_memset (&locator, 0, sizeof (locator));
197 for (i = 0; i < locator_num; i++)
199 ls_loc = &mp->locators[i];
200 VALIDATE_SW_IF_INDEX (ls_loc);
202 locator.sw_if_index = htonl (ls_loc->sw_if_index);
203 locator.priority = ls_loc->priority;
204 locator.weight = ls_loc->weight;
206 vec_add1 (a->locators, locator);
209 rv = vnet_lisp_add_del_locator_set (a, &ls_index);
211 BAD_SW_IF_INDEX_LABEL;
213 vec_free (locator_name);
214 vec_free (a->locators);
217 REPLY_MACRO2 (VL_API_ONE_ADD_DEL_LOCATOR_SET_REPLY,
219 rmp->ls_index = clib_host_to_net_u32 (ls_index);
225 vl_api_one_add_del_locator_t_handler (vl_api_one_add_del_locator_t * mp)
227 vl_api_one_add_del_locator_reply_t *rmp;
229 locator_t locator, *locators = NULL;
230 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
232 u8 *locator_name = NULL;
234 clib_memset (&locator, 0, sizeof (locator));
235 clib_memset (a, 0, sizeof (a[0]));
237 locator.sw_if_index = ntohl (mp->sw_if_index);
238 locator.priority = mp->priority;
239 locator.weight = mp->weight;
241 vec_add1 (locators, locator);
243 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
244 locator_name = format (0, "%s", mp->locator_set_name);
245 vec_terminate_c_string (locator_name);
247 a->name = locator_name;
248 a->locators = locators;
249 a->is_add = mp->is_add;
252 rv = vnet_lisp_add_del_locator (a, NULL, &ls_index);
255 vec_free (locator_name);
257 REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCATOR_REPLY);
264 } __attribute__ ((__packed__)) lisp_nsh_api_t;
267 unformat_one_eid_api (gid_address_t * dst, u32 vni, vl_api_eid_t * eid)
273 case EID_TYPE_API_PREFIX:
274 ip_prefix_decode (&eid->address.prefix, &prefix);
275 gid_address_type (dst) = GID_ADDR_IP_PREFIX;
276 if (prefix.fp_proto == FIB_PROTOCOL_IP4)
277 gid_address_ip_set (dst, &prefix.fp_addr.ip4, AF_IP4);
278 if (prefix.fp_proto == FIB_PROTOCOL_IP6)
279 gid_address_ip_set (dst, &prefix.fp_addr.ip6, AF_IP6);
280 gid_address_ippref_len (dst) = prefix.fp_len;
281 ip_prefix_normalize (&gid_address_ippref (dst));
283 case EID_TYPE_API_MAC:
284 gid_address_type (dst) = GID_ADDR_MAC;
285 mac_address_decode (eid->address.mac,
286 (mac_address_t *) & gid_address_mac (dst));
288 case EID_TYPE_API_NSH:
289 gid_address_type (dst) = GID_ADDR_NSH;
290 gid_address_nsh_spi (dst) = clib_net_to_host_u32 (eid->address.nsh.spi);
291 gid_address_nsh_si (dst) = eid->address.nsh.si;
295 return VNET_API_ERROR_INVALID_VALUE;
298 gid_address_vni (dst) = vni;
304 fid_to_api_eid (fid_address_t * fid, vl_api_eid_t * eid)
306 fib_prefix_t fib_prefix;
309 switch (fid_addr_type (fid))
311 case FID_ADDR_IP_PREF:
312 eid_type = EID_TYPE_API_PREFIX;
313 ip_prefix_to_fib_prefix (&fid_addr_ippref (fid), &fib_prefix);
314 ip_prefix_encode (&fib_prefix, &eid->address.prefix);
317 eid_type = EID_TYPE_API_MAC;
318 mac_address_encode ((mac_address_t *) fid_addr_mac (fid),
326 eid->type = eid_type;
330 vl_api_one_add_del_local_eid_t_handler (vl_api_one_add_del_local_eid_t * mp)
332 vl_api_one_add_del_local_eid_reply_t *rmp;
333 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
335 gid_address_t _eid, *eid = &_eid;
337 u32 locator_set_index = ~0, map_index = ~0;
338 vnet_lisp_add_del_mapping_args_t _a, *a = &_a;
339 u8 *name = NULL, *key = NULL;
340 clib_memset (a, 0, sizeof (a[0]));
341 clib_memset (eid, 0, sizeof (eid[0]));
343 rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->eid);
347 if (gid_address_type (eid) == GID_ADDR_NSH)
349 rv = VNET_API_ERROR_INVALID_VALUE;
353 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
354 name = format (0, "%s", mp->locator_set_name);
355 vec_terminate_c_string (name);
356 p = hash_get_mem (lcm->locator_set_index_by_name, name);
359 rv = VNET_API_ERROR_INVALID_VALUE;
362 locator_set_index = p[0];
364 if (mp->key.id != KEY_ID_API_HMAC_NO_KEY)
365 key = format (0, "%s", mp->key.key);
367 /* XXX treat batch configuration */
368 a->is_add = mp->is_add;
369 gid_address_copy (&a->eid, eid);
370 a->locator_set_index = locator_set_index;
373 a->key_id = mp->key.id;
375 rv = vnet_lisp_add_del_local_mapping (a, &map_index);
380 gid_address_free (&a->eid);
382 REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCAL_EID_REPLY);
386 vl_api_one_eid_table_add_del_map_t_handler
387 (vl_api_one_eid_table_add_del_map_t * mp)
389 vl_api_one_eid_table_add_del_map_reply_t *rmp;
391 rv = vnet_lisp_eid_table_map (clib_net_to_host_u32 (mp->vni),
392 clib_net_to_host_u32 (mp->dp_table),
393 mp->is_l2, mp->is_add);
394 REPLY_MACRO (VL_API_ONE_EID_TABLE_ADD_DEL_MAP_REPLY)}
397 vl_api_one_add_del_map_server_t_handler (vl_api_one_add_del_map_server_t * mp)
399 vl_api_one_add_del_map_server_reply_t *rmp;
403 clib_memset (&addr, 0, sizeof (addr));
405 ip_address_decode2 (&mp->ip_address, &addr);
407 rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
409 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_SERVER_REPLY);
413 vl_api_one_add_del_map_resolver_t_handler (vl_api_one_add_del_map_resolver_t
416 vl_api_one_add_del_map_resolver_reply_t *rmp;
418 vnet_lisp_add_del_map_resolver_args_t _a, *a = &_a;
420 clib_memset (a, 0, sizeof (a[0]));
422 ip_address_decode2 (&mp->ip_address, &a->address);
424 a->is_add = mp->is_add;
426 rv = vnet_lisp_add_del_map_resolver (a);
428 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_RESOLVER_REPLY);
432 vl_api_one_map_register_enable_disable_t_handler
433 (vl_api_one_map_register_enable_disable_t * mp)
435 vl_api_one_map_register_enable_disable_reply_t *rmp;
438 vnet_lisp_map_register_enable_disable (mp->is_enable);
439 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
443 vl_api_one_rloc_probe_enable_disable_t_handler
444 (vl_api_one_rloc_probe_enable_disable_t * mp)
446 vl_api_one_rloc_probe_enable_disable_reply_t *rmp;
449 vnet_lisp_rloc_probe_enable_disable (mp->is_enable);
450 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
454 vl_api_one_enable_disable_t_handler (vl_api_one_enable_disable_t * mp)
456 vl_api_one_enable_disable_reply_t *rmp;
459 vnet_lisp_enable_disable (mp->is_enable);
460 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
464 vl_api_show_one_map_request_mode_t_handler
465 (vl_api_show_one_map_request_mode_t * mp)
468 vl_api_show_one_map_request_mode_reply_t *rmp;
471 REPLY_MACRO2(VL_API_SHOW_ONE_MAP_REQUEST_MODE_REPLY,
473 rmp->mode = vnet_lisp_get_map_request_mode ();
479 vl_api_one_map_request_mode_t_handler (vl_api_one_map_request_mode_t * mp)
481 vl_api_one_map_request_mode_reply_t *rmp;
484 rv = vnet_lisp_set_map_request_mode (mp->mode);
486 REPLY_MACRO (VL_API_ONE_MAP_REQUEST_MODE_REPLY);
490 vl_api_one_nsh_set_locator_set_t_handler (vl_api_one_nsh_set_locator_set_t
493 vl_api_one_nsh_set_locator_set_reply_t *rmp;
497 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
498 ls_name = format (0, "%s", mp->ls_name);
499 vec_terminate_c_string (ls_name);
500 rv = vnet_lisp_nsh_set_locator_set (ls_name, mp->is_add);
503 REPLY_MACRO (VL_API_ONE_PITR_SET_LOCATOR_SET_REPLY);
507 vl_api_one_pitr_set_locator_set_t_handler (vl_api_one_pitr_set_locator_set_t
510 vl_api_one_pitr_set_locator_set_reply_t *rmp;
514 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
515 ls_name = format (0, "%s", mp->ls_name);
516 vec_terminate_c_string (ls_name);
517 rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
520 REPLY_MACRO (VL_API_ONE_PITR_SET_LOCATOR_SET_REPLY);
524 vl_api_one_use_petr_t_handler (vl_api_one_use_petr_t * mp)
526 vl_api_one_use_petr_reply_t *rmp;
530 ip_address_decode2 (&mp->ip_address, &addr);
532 rv = vnet_lisp_use_petr (&addr, mp->is_add);
534 REPLY_MACRO (VL_API_ONE_USE_PETR_REPLY);
538 vl_api_show_one_use_petr_t_handler (vl_api_show_one_use_petr_t * mp)
540 vl_api_show_one_use_petr_reply_t *rmp = NULL;
541 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
543 locator_set_t *ls = 0;
549 clib_memset (&addr, 0, sizeof (addr));
550 status = lcm->flags & LISP_FLAG_USE_PETR;
553 m = pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index);
554 if (~0 != m->locator_set_index)
557 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
558 loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
559 gid_address_copy (&addr, &loc->address);
564 REPLY_MACRO2 (VL_API_SHOW_ONE_USE_PETR_REPLY,
566 rmp->status = status;
567 ip_address_t *ip = &gid_address_ip (&addr);
569 ip_address_encode2 (ip, &rmp->ip_address);
575 vl_api_one_add_del_map_request_itr_rlocs_t_handler
576 (vl_api_one_add_del_map_request_itr_rlocs_t * mp)
578 vl_api_one_add_del_map_request_itr_rlocs_reply_t *rmp;
580 u8 *locator_set_name = NULL;
581 vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
583 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
584 locator_set_name = format (0, "%s", mp->locator_set_name);
585 vec_terminate_c_string (locator_set_name);
587 a->is_add = mp->is_add;
588 a->locator_set_name = locator_set_name;
590 rv = vnet_lisp_add_del_mreq_itr_rlocs (a);
592 vec_free (locator_set_name);
594 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
598 vl_api_one_add_del_remote_mapping_t_handler
599 (vl_api_one_add_del_remote_mapping_t * mp)
601 locator_t *rlocs = 0;
602 vl_api_one_add_del_remote_mapping_reply_t *rmp;
604 gid_address_t _eid, *eid = &_eid;
605 u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num);
607 clib_memset (eid, 0, sizeof (eid[0]));
609 rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->deid);
613 rlocs = unformat_one_locs (mp->rlocs, rloc_num);
617 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
618 clib_memset (a, 0, sizeof (a[0]));
619 gid_address_copy (&a->reid, eid);
621 rv = vnet_lisp_add_del_adjacency (a);
628 /* NOTE: for now this works as a static remote mapping, i.e.,
629 * not authoritative and ttl infinite. */
632 vnet_lisp_add_del_mapping_args_t _m_args, *m_args = &_m_args;
633 clib_memset (m_args, 0, sizeof (m_args[0]));
634 gid_address_copy (&m_args->eid, eid);
635 m_args->action = mp->action;
636 m_args->is_static = 1;
638 m_args->authoritative = 0;
639 rv = vnet_lisp_add_mapping (m_args, rlocs, NULL, NULL);
642 rv = vnet_lisp_del_mapping (eid, NULL);
645 vnet_lisp_clear_all_remote_adjacencies ();
650 REPLY_MACRO (VL_API_ONE_ADD_DEL_REMOTE_MAPPING_REPLY);
654 vl_api_one_add_del_adjacency_t_handler (vl_api_one_add_del_adjacency_t * mp)
656 vl_api_one_add_del_adjacency_reply_t *rmp;
657 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
660 clib_memset (a, 0, sizeof (a[0]));
663 unformat_one_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni),
666 unformat_one_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni),
672 a->is_add = mp->is_add;
673 rv = vnet_lisp_add_del_adjacency (a);
676 REPLY_MACRO (VL_API_ONE_ADD_DEL_ADJACENCY_REPLY);
680 send_one_locator_details (lisp_cp_main_t * lcm,
681 locator_t * loc, vl_api_registration_t * reg,
684 vl_api_one_locator_details_t *rmp;
686 rmp = vl_msg_api_alloc (sizeof (*rmp));
687 clib_memset (rmp, 0, sizeof (*rmp));
688 rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_DETAILS);
689 rmp->context = context;
691 rmp->local = loc->local;
694 rmp->sw_if_index = ntohl (loc->sw_if_index);
698 ip_address_encode2 (&loc->address.ippref.addr, &rmp->ip_address);
700 rmp->priority = loc->priority;
701 rmp->weight = loc->weight;
703 vl_api_send_msg (reg, (u8 *) rmp);
707 vl_api_one_locator_dump_t_handler (vl_api_one_locator_dump_t * mp)
710 vl_api_registration_t *reg;
711 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
712 locator_set_t *lsit = 0;
714 u32 ls_index = ~0, *locit = 0;
717 reg = vl_api_client_index_to_registration (mp->client_index);
721 if (mp->is_index_set)
722 ls_index = htonl (mp->ls_index);
725 /* make sure we get a proper C-string */
726 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
727 ls_name = format (0, "%s", mp->ls_name);
728 vec_terminate_c_string (ls_name);
729 p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
735 if (pool_is_free_index (lcm->locator_set_pool, ls_index))
738 lsit = pool_elt_at_index (lcm->locator_set_pool, ls_index);
740 vec_foreach (locit, lsit->locator_indices)
742 loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
743 send_one_locator_details (lcm, loc, reg, mp->context);
750 send_one_locator_set_details (lisp_cp_main_t * lcm,
751 locator_set_t * lsit,
752 vl_api_registration_t * reg, u32 context,
755 vl_api_one_locator_set_details_t *rmp;
758 rmp = vl_msg_api_alloc (sizeof (*rmp));
759 clib_memset (rmp, 0, sizeof (*rmp));
760 rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_SET_DETAILS);
761 rmp->context = context;
763 rmp->ls_index = htonl (ls_index);
766 ASSERT (lsit->name != NULL);
767 strncpy ((char *) rmp->ls_name, (char *) lsit->name,
768 vec_len (lsit->name));
772 str = format (0, "<remote-%d>", ls_index);
773 strncpy ((char *) rmp->ls_name, (char *) str, vec_len (str));
777 vl_api_send_msg (reg, (u8 *) rmp);
781 vl_api_one_locator_set_dump_t_handler (vl_api_one_locator_set_dump_t * mp)
783 vl_api_registration_t *reg;
784 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
785 locator_set_t *lsit = NULL;
788 reg = vl_api_client_index_to_registration (mp->client_index);
794 pool_foreach (lsit, lcm->locator_set_pool,
796 if (filter && !((1 == filter && lsit->local) ||
797 (2 == filter && !lsit->local)))
801 send_one_locator_set_details (lcm, lsit, reg, mp->context,
802 lsit - lcm->locator_set_pool);
808 send_one_eid_table_details (mapping_t * mapit,
809 vl_api_registration_t * reg, u32 context,
812 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
813 locator_set_t *ls = 0;
814 vl_api_one_eid_table_details_t *rmp = NULL;
815 gid_address_t *gid = NULL;
817 fib_prefix_t fib_prefix;
819 if (mapit->pitr_set || mapit->nsh_set)
824 case ONE_FILTER_API_ALL: /* all mappings */
827 case ONE_FILTER_API_LOCAL: /* local only */
831 case ONE_FILTER_API_REMOTE: /* remote only */
836 clib_warning ("Filter error, unknown filter: %d", filter);
842 rmp = vl_msg_api_alloc (sizeof (*rmp));
843 clib_memset (rmp, 0, sizeof (*rmp));
844 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_DETAILS);
846 ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index);
847 if (vec_len (ls->locator_indices) == 0)
848 rmp->locator_set_index = ~0;
850 rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index);
852 rmp->is_local = mapit->local;
853 rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
854 rmp->action = mapit->action;
855 rmp->authoritative = mapit->authoritative;
857 switch (gid_address_type (gid))
859 case GID_ADDR_SRC_DST:
860 fid_to_api_eid (&gid_address_sd_src (gid), &rmp->seid);
861 fid_to_api_eid (&gid_address_sd_dst (gid), &rmp->deid);
863 case GID_ADDR_IP_PREFIX:
864 eid_type = EID_TYPE_API_PREFIX;
865 rmp->seid.type = eid_type;
866 ip_prefix_to_fib_prefix (&gid_address_ippref (gid), &fib_prefix);
867 ip_prefix_encode (&fib_prefix, &rmp->seid.address.prefix);
870 eid_type = EID_TYPE_API_MAC;
871 rmp->seid.type = eid_type;
872 mac_address_encode ((mac_address_t *) gid_address_mac (gid),
873 rmp->seid.address.mac);
876 eid_type = EID_TYPE_API_NSH;
877 rmp->seid.type = eid_type;
878 rmp->seid.address.nsh.spi =
879 clib_host_to_net_u32 (gid_address_nsh_spi (gid));
880 rmp->seid.address.nsh.si = gid_address_nsh_si (gid);
887 rmp->context = context;
888 rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
889 rmp->key.id = mapit->key_id;
890 memcpy (rmp->key.key, mapit->key, vec_len (mapit->key));
891 vl_api_send_msg (reg, (u8 *) rmp);
895 vl_api_one_eid_table_dump_t_handler (vl_api_one_eid_table_dump_t * mp)
898 vl_api_registration_t *reg;
899 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
900 mapping_t *mapit = NULL;
901 gid_address_t _eid, *eid = &_eid;
903 reg = vl_api_client_index_to_registration (mp->client_index);
909 clib_memset (eid, 0, sizeof (*eid));
911 unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->eid);
913 mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
917 mapit = pool_elt_at_index (lcm->mapping_pool, mi);
918 send_one_eid_table_details (mapit, reg, mp->context,
919 0 /* ignore filter */ );
924 pool_foreach (mapit, lcm->mapping_pool,
926 send_one_eid_table_details(mapit, reg, mp->context,
934 send_one_map_server_details (ip_address_t * ip, vl_api_registration_t * reg,
937 vl_api_one_map_server_details_t *rmp = NULL;
939 rmp = vl_msg_api_alloc (sizeof (*rmp));
940 clib_memset (rmp, 0, sizeof (*rmp));
941 rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_SERVER_DETAILS);
944 ip_address_encode2 (ip, &rmp->ip_address);
946 rmp->context = context;
948 vl_api_send_msg (reg, (u8 *) rmp);
952 vl_api_one_map_server_dump_t_handler (vl_api_one_map_server_dump_t * mp)
954 vl_api_registration_t *reg;
955 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
958 reg = vl_api_client_index_to_registration (mp->client_index);
962 vec_foreach (mr, lcm->map_servers)
964 send_one_map_server_details (&mr->address, reg, mp->context);
969 send_one_map_resolver_details (ip_address_t * ip,
970 vl_api_registration_t * reg, u32 context)
972 vl_api_one_map_resolver_details_t *rmp = NULL;
974 rmp = vl_msg_api_alloc (sizeof (*rmp));
975 clib_memset (rmp, 0, sizeof (*rmp));
976 rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_RESOLVER_DETAILS);
978 ip_address_encode2 (ip, &rmp->ip_address);
979 rmp->context = context;
981 vl_api_send_msg (reg, (u8 *) rmp);
985 vl_api_one_map_resolver_dump_t_handler (vl_api_one_map_resolver_dump_t * mp)
987 vl_api_registration_t *reg;
988 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
991 reg = vl_api_client_index_to_registration (mp->client_index);
995 vec_foreach (mr, lcm->map_resolvers)
997 send_one_map_resolver_details (&mr->address, reg, mp->context);
1002 send_eid_table_map_pair (hash_pair_t * p, vl_api_registration_t * reg,
1005 vl_api_one_eid_table_map_details_t *rmp = NULL;
1007 rmp = vl_msg_api_alloc (sizeof (*rmp));
1008 clib_memset (rmp, 0, sizeof (*rmp));
1009 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_MAP_DETAILS);
1011 rmp->vni = clib_host_to_net_u32 (p->key);
1012 rmp->dp_table = clib_host_to_net_u32 (p->value[0]);
1013 rmp->context = context;
1014 vl_api_send_msg (reg, (u8 *) rmp);
1018 vl_api_one_eid_table_map_dump_t_handler (vl_api_one_eid_table_map_dump_t * mp)
1020 vl_api_registration_t *reg;
1021 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1023 uword *vni_table = 0;
1025 reg = vl_api_client_index_to_registration (mp->client_index);
1031 vni_table = lcm->bd_id_by_vni;
1035 vni_table = lcm->table_id_by_vni;
1039 hash_foreach_pair (p, vni_table,
1041 send_eid_table_map_pair (p, reg, mp->context);
1047 send_eid_table_vni (u32 vni, vl_api_registration_t * reg, u32 context)
1049 vl_api_one_eid_table_vni_details_t *rmp = 0;
1051 rmp = vl_msg_api_alloc (sizeof (*rmp));
1052 clib_memset (rmp, 0, sizeof (*rmp));
1053 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_VNI_DETAILS);
1054 rmp->context = context;
1055 rmp->vni = clib_host_to_net_u32 (vni);
1056 vl_api_send_msg (reg, (u8 *) rmp);
1060 one_adjacency_copy (vl_api_one_adjacency_t * dst, lisp_adjacency_t * adjs)
1062 lisp_adjacency_t *adj;
1063 vl_api_one_adjacency_t a;
1064 u32 i, n = vec_len (adjs);
1065 fib_prefix_t rfib_prefix, lfib_prefix;
1068 for (i = 0; i < n; i++)
1070 adj = vec_elt_at_index (adjs, i);
1071 clib_memset (&a, 0, sizeof (a));
1073 switch (gid_address_type (&adj->reid))
1075 case GID_ADDR_IP_PREFIX:
1076 eid_type = EID_TYPE_API_PREFIX;
1077 ip_prefix_to_fib_prefix (&gid_address_ippref (&adj->reid),
1079 ip_prefix_to_fib_prefix (&gid_address_ippref (&adj->leid),
1081 ip_prefix_encode (&rfib_prefix, &a.reid.address.prefix);
1082 ip_prefix_encode (&lfib_prefix, &a.leid.address.prefix);
1085 eid_type = EID_TYPE_API_PREFIX;
1086 mac_address_encode ((mac_address_t *) gid_address_mac (&adj->reid),
1087 a.reid.address.mac);
1088 mac_address_encode ((mac_address_t *) gid_address_mac (&adj->leid),
1089 a.leid.address.mac);
1092 eid_type = EID_TYPE_API_PREFIX;
1093 a.reid.address.nsh.spi =
1094 clib_host_to_net_u32 (gid_address_nsh_spi (&adj->reid));
1095 a.reid.address.nsh.si = gid_address_nsh_si (&adj->reid);
1096 a.leid.address.nsh.spi =
1097 clib_host_to_net_u32 (gid_address_nsh_spi (&adj->leid));
1098 a.leid.address.nsh.si = gid_address_nsh_si (&adj->leid);
1103 a.reid.type = eid_type;
1104 a.leid.type = eid_type;
1110 vl_api_show_one_rloc_probe_state_t_handler
1111 (vl_api_show_one_rloc_probe_state_t * mp)
1113 vl_api_show_one_rloc_probe_state_reply_t *rmp = 0;
1117 REPLY_MACRO2 (VL_API_SHOW_ONE_RLOC_PROBE_STATE_REPLY,
1119 rmp->is_enable = vnet_lisp_rloc_probe_state_get ();
1125 vl_api_show_one_map_register_state_t_handler
1126 (vl_api_show_one_map_register_state_t * mp)
1128 vl_api_show_one_map_register_state_reply_t *rmp = 0;
1132 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_STATE_REPLY,
1134 rmp->is_enable = vnet_lisp_map_register_state_get ();
1140 vl_api_one_adjacencies_get_t_handler (vl_api_one_adjacencies_get_t * mp)
1142 vl_api_one_adjacencies_get_reply_t *rmp = 0;
1143 lisp_adjacency_t *adjs = 0;
1146 u32 vni = clib_net_to_host_u32 (mp->vni);
1148 adjs = vnet_lisp_adjacencies_get_by_vni (vni);
1149 size = vec_len (adjs) * sizeof (vl_api_one_adjacency_t);
1152 REPLY_MACRO4 (VL_API_ONE_ADJACENCIES_GET_REPLY, size,
1154 rmp->count = clib_host_to_net_u32 (vec_len (adjs));
1155 one_adjacency_copy (rmp->adjacencies, adjs);
1163 vl_api_one_eid_table_vni_dump_t_handler (vl_api_one_eid_table_vni_dump_t * mp)
1167 vl_api_registration_t *reg;
1168 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1170 reg = vl_api_client_index_to_registration (mp->client_index);
1175 hash_foreach_pair (p, lcm->table_id_by_vni,
1177 hash_set (vnis, p->key, 0);
1180 hash_foreach_pair (p, lcm->bd_id_by_vni,
1182 hash_set (vnis, p->key, 0);
1185 hash_foreach_pair (p, vnis,
1187 send_eid_table_vni (p->key, reg, mp->context);
1195 vl_api_show_one_status_t_handler (vl_api_show_one_status_t * mp)
1197 vl_api_show_one_status_reply_t *rmp = NULL;
1201 REPLY_MACRO2(VL_API_SHOW_ONE_STATUS_REPLY,
1203 rmp->gpe_status = vnet_lisp_gpe_enable_disable_status ();
1204 rmp->feature_status = vnet_lisp_enable_disable_status ();
1210 vl_api_one_get_map_request_itr_rlocs_t_handler
1211 (vl_api_one_get_map_request_itr_rlocs_t * mp)
1213 vl_api_one_get_map_request_itr_rlocs_reply_t *rmp = NULL;
1214 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1215 locator_set_t *loc_set = 0;
1219 if (~0 == lcm->mreq_itr_rlocs)
1221 tmp_str = format (0, " ");
1226 pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
1227 tmp_str = format (0, "%s", loc_set->name);
1231 REPLY_MACRO2(VL_API_ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY,
1233 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1234 ARRAY_LEN(rmp->locator_set_name) - 1);
1242 vl_api_show_one_nsh_mapping_t_handler (vl_api_show_one_nsh_mapping_t * mp)
1244 vl_api_show_one_nsh_mapping_reply_t *rmp = NULL;
1245 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1247 locator_set_t *ls = 0;
1252 if (lcm->nsh_map_index == (u32) ~ 0)
1254 tmp_str = format (0, "N/A");
1258 m = pool_elt_at_index (lcm->mapping_pool, lcm->nsh_map_index);
1259 if (~0 != m->locator_set_index)
1262 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1263 tmp_str = format (0, "%s", ls->name);
1268 tmp_str = format (0, "N/A");
1271 vec_add1 (tmp_str, 0);
1274 REPLY_MACRO2(VL_API_SHOW_ONE_NSH_MAPPING_REPLY,
1276 rmp->is_set = is_set;
1277 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1278 ARRAY_LEN(rmp->locator_set_name) - 1);
1284 vl_api_show_one_pitr_t_handler (vl_api_show_one_pitr_t * mp)
1286 vl_api_show_one_pitr_reply_t *rmp = NULL;
1287 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1289 locator_set_t *ls = 0;
1293 u8 is_enable = (lcm->flags & LISP_FLAG_PITR_MODE)
1294 && lcm->pitr_map_index != ~0;
1298 tmp_str = format (0, "N/A");
1302 m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index);
1303 if (~0 != m->locator_set_index)
1306 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1307 tmp_str = format (0, "%s", ls->name);
1311 tmp_str = format (0, "N/A");
1314 vec_add1 (tmp_str, 0);
1317 REPLY_MACRO2(VL_API_SHOW_ONE_PITR_REPLY,
1319 rmp->status = lcm->flags & LISP_FLAG_PITR_MODE;
1320 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1321 ARRAY_LEN(rmp->locator_set_name) - 1);
1327 vl_api_show_one_stats_enable_disable_t_handler
1328 (vl_api_show_one_stats_enable_disable_t * mp)
1330 vl_api_show_one_stats_enable_disable_reply_t *rmp = NULL;
1331 vnet_api_error_t rv = 0;
1334 REPLY_MACRO2 (VL_API_SHOW_ONE_STATS_ENABLE_DISABLE_REPLY,
1336 rmp->is_enable = vnet_lisp_stats_enable_disable_state ();
1342 vl_api_one_stats_enable_disable_t_handler
1343 (vl_api_one_stats_enable_disable_t * mp)
1345 vl_api_one_enable_disable_reply_t *rmp = NULL;
1347 vnet_api_error_t rv = vnet_lisp_stats_enable_disable (mp->is_enable);
1348 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
1352 vl_api_one_stats_flush_t_handler (vl_api_one_stats_flush_t * mp)
1354 vl_api_one_stats_flush_reply_t *rmp;
1357 rv = vnet_lisp_flush_stats ();
1358 REPLY_MACRO (VL_API_ONE_STATS_FLUSH_REPLY);
1362 vl_api_one_stats_dump_t_handler (vl_api_one_stats_dump_t * mp)
1364 vl_api_one_stats_details_t *rmp;
1365 lisp_api_stats_t *stats, *stat;
1368 stats = vnet_lisp_get_stats ();
1369 vec_foreach (stat, stats)
1372 REPLY_DETAILS (VL_API_ONE_STATS_DETAILS,
1374 fid_to_api_eid (&stat->deid, &rmp->deid);
1375 fid_to_api_eid (&stat->seid, &rmp->seid);
1376 rmp->vni = clib_host_to_net_u32 (stat->vni);
1378 ip_address_encode2 (&stat->rmt_rloc, &rmp->rloc);
1379 ip_address_encode2 (&stat->loc_rloc, &rmp->lloc);
1381 rmp->pkt_count = clib_host_to_net_u32 (stat->counters.packets);
1382 rmp->bytes = clib_host_to_net_u32 (stat->counters.bytes);
1389 vl_api_one_add_del_l2_arp_entry_t_handler
1390 (vl_api_one_add_del_l2_arp_entry_t * mp)
1392 vl_api_one_add_del_l2_arp_entry_reply_t *rmp;
1394 gid_address_t _arp, *arp = &_arp;
1397 clib_memset (arp, 0, sizeof (*arp));
1399 gid_address_type (arp) = GID_ADDR_ARP;
1400 gid_address_arp_bd (arp) = clib_net_to_host_u32 (mp->bd);
1402 ip4_address_decode (mp->entry.ip4, &ip4);
1403 ip_address_set (&gid_address_arp_ndp_ip (arp), &ip4, AF_IP4);
1404 mac_address_decode (mp->entry.mac, &mac);
1406 rv = vnet_lisp_add_del_l2_arp_ndp_entry (arp, mac.bytes, mp->is_add);
1408 REPLY_MACRO (VL_API_ONE_ADD_DEL_L2_ARP_ENTRY_REPLY);
1412 vl_api_one_add_del_ndp_entry_t_handler (vl_api_one_add_del_ndp_entry_t * mp)
1414 vl_api_one_add_del_ndp_entry_reply_t *rmp;
1416 gid_address_t _g, *g = &_g;
1419 clib_memset (g, 0, sizeof (*g));
1421 gid_address_type (g) = GID_ADDR_NDP;
1422 gid_address_ndp_bd (g) = clib_net_to_host_u32 (mp->bd);
1424 ip6_address_decode (mp->entry.ip6, &ip6);
1425 ip_address_set (&gid_address_arp_ndp_ip (g), &ip6, AF_IP6);
1426 mac_address_decode (mp->entry.mac, &mac);
1428 rv = vnet_lisp_add_del_l2_arp_ndp_entry (g, mac.bytes, mp->is_add);
1430 REPLY_MACRO (VL_API_ONE_ADD_DEL_NDP_ENTRY_REPLY);
1434 vl_api_one_ndp_bd_get_t_handler (vl_api_one_ndp_bd_get_t * mp)
1436 vl_api_one_ndp_bd_get_reply_t *rmp;
1441 u32 *bds = vnet_lisp_ndp_bds_get ();
1442 u32 size = hash_elts (bds) * sizeof (u32);
1445 REPLY_MACRO4 (VL_API_ONE_NDP_BD_GET_REPLY, size,
1447 rmp->count = clib_host_to_net_u32 (hash_elts (bds));
1448 hash_foreach_pair (p, bds,
1450 rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
1459 vl_api_one_l2_arp_bd_get_t_handler (vl_api_one_l2_arp_bd_get_t * mp)
1461 vl_api_one_l2_arp_bd_get_reply_t *rmp;
1466 u32 *bds = vnet_lisp_l2_arp_bds_get ();
1467 u32 size = hash_elts (bds) * sizeof (u32);
1470 REPLY_MACRO4 (VL_API_ONE_L2_ARP_BD_GET_REPLY, size,
1472 rmp->count = clib_host_to_net_u32 (hash_elts (bds));
1473 hash_foreach_pair (p, bds,
1475 rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
1484 vl_api_one_l2_arp_entries_get_t_handler (vl_api_one_l2_arp_entries_get_t * mp)
1486 vl_api_one_l2_arp_entries_get_reply_t *rmp;
1487 lisp_api_l2_arp_entry_t *entries = 0, *e;
1491 u32 bd = clib_net_to_host_u32 (mp->bd);
1493 entries = vnet_lisp_l2_arp_entries_get_by_bd (bd);
1494 u32 size = vec_len (entries) * sizeof (vl_api_one_l2_arp_entry_t);
1497 REPLY_MACRO4 (VL_API_ONE_L2_ARP_ENTRIES_GET_REPLY, size,
1499 rmp->count = clib_host_to_net_u32 (vec_len (entries));
1500 vec_foreach (e, entries)
1502 mac_address_encode ((mac_address_t *) e->mac, rmp->entries[i].mac);
1503 ip4_address_encode ((ip4_address_t *) &e->ip4, rmp->entries[i].ip4);
1513 vl_api_one_map_register_fallback_threshold_t_handler
1514 (vl_api_one_map_register_fallback_threshold_t * mp)
1516 vl_api_one_map_register_fallback_threshold_reply_t *rmp;
1519 mp->value = clib_net_to_host_u32 (mp->value);
1520 rv = vnet_lisp_map_register_fallback_threshold_set (mp->value);
1521 REPLY_MACRO (VL_API_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY);
1525 vl_api_show_one_map_register_fallback_threshold_t_handler
1526 (vl_api_show_one_map_register_fallback_threshold_t * mp)
1528 vl_api_show_one_map_register_fallback_threshold_reply_t *rmp;
1531 u32 value = vnet_lisp_map_register_fallback_threshold_get ();
1534 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY,
1536 rmp->value = clib_host_to_net_u32 (value);
1542 vl_api_one_set_transport_protocol_t_handler
1543 (vl_api_one_set_transport_protocol_t * mp)
1545 vl_api_one_set_transport_protocol_reply_t *rmp;
1548 rv = vnet_lisp_set_transport_protocol (mp->protocol);
1550 REPLY_MACRO (VL_API_ONE_SET_TRANSPORT_PROTOCOL_REPLY);
1554 vl_api_one_get_transport_protocol_t_handler
1555 (vl_api_one_get_transport_protocol_t * mp)
1557 vl_api_one_get_transport_protocol_reply_t *rmp;
1559 u8 proto = (u8) vnet_lisp_get_transport_protocol ();
1562 REPLY_MACRO2 (VL_API_ONE_GET_TRANSPORT_PROTOCOL_REPLY,
1564 rmp->protocol = proto;
1570 vl_api_one_ndp_entries_get_t_handler (vl_api_one_ndp_entries_get_t * mp)
1572 vl_api_one_ndp_entries_get_reply_t *rmp = 0;
1573 lisp_api_ndp_entry_t *entries = 0, *e;
1577 u32 bd = clib_net_to_host_u32 (mp->bd);
1579 entries = vnet_lisp_ndp_entries_get_by_bd (bd);
1580 u32 size = vec_len (entries) * sizeof (vl_api_one_ndp_entry_t);
1583 REPLY_MACRO4 (VL_API_ONE_NDP_ENTRIES_GET_REPLY, size,
1585 rmp->count = clib_host_to_net_u32 (vec_len (entries));
1586 vec_foreach (e, entries)
1588 mac_address_encode ((mac_address_t *) e->mac, rmp->entries[i].mac);
1589 ip6_address_encode ((ip6_address_t *) &e->ip6, rmp->entries[i].ip6);
1599 vl_api_one_enable_disable_xtr_mode_t_handler
1600 (vl_api_one_enable_disable_xtr_mode_t * mp)
1602 vl_api_one_enable_disable_xtr_mode_reply_t *rmp = 0;
1603 int rv = vnet_lisp_enable_disable_xtr_mode (mp->is_enable);
1605 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_XTR_MODE_REPLY);
1609 vl_api_one_show_xtr_mode_t_handler (vl_api_one_show_xtr_mode_t * mp)
1611 vl_api_one_show_xtr_mode_reply_t *rmp = 0;
1615 REPLY_MACRO2 (VL_API_ONE_SHOW_XTR_MODE_REPLY,
1617 rmp->is_enable = vnet_lisp_get_xtr_mode ();
1623 vl_api_one_enable_disable_pitr_mode_t_handler
1624 (vl_api_one_enable_disable_pitr_mode_t * mp)
1626 vl_api_one_enable_disable_pitr_mode_reply_t *rmp = 0;
1627 int rv = vnet_lisp_enable_disable_pitr_mode (mp->is_enable);
1629 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_PITR_MODE_REPLY);
1633 vl_api_one_show_pitr_mode_t_handler (vl_api_one_show_pitr_mode_t * mp)
1635 vl_api_one_show_pitr_mode_reply_t *rmp = 0;
1639 REPLY_MACRO2 (VL_API_ONE_SHOW_PITR_MODE_REPLY,
1641 rmp->is_enable = vnet_lisp_get_pitr_mode ();
1647 vl_api_one_enable_disable_petr_mode_t_handler
1648 (vl_api_one_enable_disable_petr_mode_t * mp)
1650 vl_api_one_enable_disable_petr_mode_reply_t *rmp = 0;
1651 int rv = vnet_lisp_enable_disable_petr_mode (mp->is_enable);
1653 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_PETR_MODE_REPLY);
1657 vl_api_one_show_petr_mode_t_handler (vl_api_one_show_petr_mode_t * mp)
1659 vl_api_one_show_petr_mode_reply_t *rmp = 0;
1663 REPLY_MACRO2 (VL_API_ONE_SHOW_PETR_MODE_REPLY,
1665 rmp->is_enable = vnet_lisp_get_petr_mode ();
1672 * Add vpe's API message handlers to the table.
1673 * vlib has already mapped shared memory and
1674 * added the client registration handlers.
1675 * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1677 #include <lisp/lisp-cp/one.api.c>
1679 static clib_error_t *
1680 one_api_hookup (vlib_main_t * vm)
1682 one_base_msg_id = setup_message_id_table ();
1687 VLIB_API_INIT_FUNCTION (one_api_hookup);
1689 #include <vlib/unix/plugin.h>
1690 #include <vpp/app/version.h>
1693 VLIB_PLUGIN_REGISTER () = {
1694 .version = VPP_BUILD_VER,
1695 .description = "Locator ID Separation Protocol (LISP)",
1700 * fd.io coding-style-patch-verification: ON
1703 * eval: (c-set-style "gnu")