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 <vnet/lisp-cp/control.h>
26 #include <vnet/lisp-gpe/lisp_gpe.h>
28 #include <vnet/vnet_msg_enum.h>
30 #define vl_api_one_add_del_locator_set_t_endian vl_noop_handler
31 #define vl_api_one_add_del_locator_set_t_print vl_noop_handler
32 #define vl_api_one_add_del_remote_mapping_t_endian vl_noop_handler
33 #define vl_api_one_add_del_remote_mapping_t_print vl_noop_handler
35 #define vl_api_one_add_del_locator_set_t_endian vl_noop_handler
36 #define vl_api_one_add_del_locator_set_t_print vl_noop_handler
37 #define vl_api_one_add_del_remote_mapping_t_endian vl_noop_handler
38 #define vl_api_one_add_del_remote_mapping_t_print vl_noop_handler
40 #define vl_api_one_add_del_l2_arp_entry vl_noop_handler
41 #define vl_api_one_l2_arp_bd_get vl_noop_handler
43 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
44 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
46 #define vl_typedefs /* define message structures */
47 #include <vnet/vnet_all_api_h.h>
50 #define vl_endianfun /* define message structures */
51 #include <vnet/vnet_all_api_h.h>
54 /* instantiate all the print functions we know about */
55 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
57 #include <vnet/vnet_all_api_h.h>
60 #include <vlibapi/api_helper_macros.h>
62 #define REPLY_DETAILS(t, body) \
64 vl_api_registration_t * reg; \
65 rv = vl_msg_api_pd_handler (mp, rv); \
66 reg = vl_api_client_index_to_registration (mp->client_index); \
70 rmp = vl_msg_api_alloc (sizeof (*rmp)); \
71 rmp->_vl_msg_id = ntohs((t)); \
72 rmp->context = mp->context; \
73 do {body;} while (0); \
74 vl_api_send_msg (reg, (u8 *)&rmp); \
77 #define foreach_vpe_api_msg \
78 _(ONE_ADD_DEL_LOCATOR_SET, one_add_del_locator_set) \
79 _(ONE_ADD_DEL_LOCATOR, one_add_del_locator) \
80 _(ONE_ADD_DEL_LOCAL_EID, one_add_del_local_eid) \
81 _(ONE_ADD_DEL_MAP_RESOLVER, one_add_del_map_resolver) \
82 _(ONE_ADD_DEL_MAP_SERVER, one_add_del_map_server) \
83 _(ONE_ENABLE_DISABLE, one_enable_disable) \
84 _(ONE_RLOC_PROBE_ENABLE_DISABLE, one_rloc_probe_enable_disable) \
85 _(ONE_MAP_REGISTER_ENABLE_DISABLE, one_map_register_enable_disable) \
86 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD, \
87 one_map_register_fallback_threshold) \
88 _(ONE_ADD_DEL_REMOTE_MAPPING, one_add_del_remote_mapping) \
89 _(ONE_ADD_DEL_ADJACENCY, one_add_del_adjacency) \
90 _(ONE_PITR_SET_LOCATOR_SET, one_pitr_set_locator_set) \
91 _(ONE_NSH_SET_LOCATOR_SET, one_nsh_set_locator_set) \
92 _(ONE_MAP_REQUEST_MODE, one_map_request_mode) \
93 _(ONE_EID_TABLE_ADD_DEL_MAP, one_eid_table_add_del_map) \
94 _(ONE_LOCATOR_SET_DUMP, one_locator_set_dump) \
95 _(ONE_LOCATOR_DUMP, one_locator_dump) \
96 _(ONE_EID_TABLE_DUMP, one_eid_table_dump) \
97 _(ONE_MAP_RESOLVER_DUMP, one_map_resolver_dump) \
98 _(ONE_MAP_SERVER_DUMP, one_map_server_dump) \
99 _(ONE_EID_TABLE_MAP_DUMP, one_eid_table_map_dump) \
100 _(ONE_EID_TABLE_VNI_DUMP, one_eid_table_vni_dump) \
101 _(ONE_ADJACENCIES_GET, one_adjacencies_get) \
102 _(ONE_MAP_REGISTER_SET_TTL, one_map_register_set_ttl) \
103 _(SHOW_ONE_NSH_MAPPING, show_one_nsh_mapping) \
104 _(SHOW_ONE_RLOC_PROBE_STATE, show_one_rloc_probe_state) \
105 _(SHOW_ONE_MAP_REGISTER_STATE, show_one_map_register_state) \
106 _(SHOW_ONE_MAP_REGISTER_TTL, show_one_map_register_ttl) \
107 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, \
108 show_one_map_register_fallback_threshold) \
109 _(SHOW_ONE_STATUS, show_one_status) \
110 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \
111 one_add_del_map_request_itr_rlocs) \
112 _(ONE_GET_MAP_REQUEST_ITR_RLOCS, one_get_map_request_itr_rlocs) \
113 _(SHOW_ONE_PITR, show_one_pitr) \
114 _(SHOW_ONE_MAP_REQUEST_MODE, show_one_map_request_mode) \
115 _(ONE_USE_PETR, one_use_petr) \
116 _(SHOW_ONE_USE_PETR, show_one_use_petr) \
117 _(SHOW_ONE_STATS_ENABLE_DISABLE, show_one_stats_enable_disable) \
118 _(ONE_STATS_ENABLE_DISABLE, one_stats_enable_disable) \
119 _(ONE_STATS_DUMP, one_stats_dump) \
120 _(ONE_STATS_FLUSH, one_stats_flush) \
121 _(ONE_L2_ARP_BD_GET, one_l2_arp_bd_get) \
122 _(ONE_L2_ARP_ENTRIES_GET, one_l2_arp_entries_get) \
123 _(ONE_ADD_DEL_L2_ARP_ENTRY, one_add_del_l2_arp_entry) \
124 _(ONE_ADD_DEL_NDP_ENTRY, one_add_del_ndp_entry) \
125 _(ONE_NDP_BD_GET, one_ndp_bd_get) \
126 _(ONE_NDP_ENTRIES_GET, one_ndp_entries_get) \
127 _(ONE_SET_TRANSPORT_PROTOCOL, one_set_transport_protocol) \
128 _(ONE_GET_TRANSPORT_PROTOCOL, one_get_transport_protocol) \
129 _(ONE_ENABLE_DISABLE_XTR_MODE, one_enable_disable_xtr_mode) \
130 _(ONE_SHOW_XTR_MODE, one_show_xtr_mode) \
131 _(ONE_ENABLE_DISABLE_PITR_MODE, one_enable_disable_pitr_mode) \
132 _(ONE_SHOW_PITR_MODE, one_show_pitr_mode) \
133 _(ONE_ENABLE_DISABLE_PETR_MODE, one_enable_disable_petr_mode) \
134 _(ONE_SHOW_PETR_MODE, one_show_petr_mode) \
138 unformat_one_locs (vl_api_one_remote_locator_t * rmt_locs, u32 rloc_num)
141 locator_t *locs = 0, loc;
142 vl_api_one_remote_locator_t *r;
144 for (i = 0; i < rloc_num; i++)
146 /* remote locators */
148 clib_memset (&loc, 0, sizeof (loc));
149 gid_address_ip_set (&loc.address, &r->addr,
150 r->is_ip4 ? AF_IP4 : AF_IP6);
152 loc.priority = r->priority;
153 loc.weight = r->weight;
155 vec_add1 (locs, loc);
161 vl_api_one_map_register_set_ttl_t_handler (vl_api_one_map_register_set_ttl_t *
164 vl_api_one_map_register_set_ttl_reply_t *rmp;
167 mp->ttl = clib_net_to_host_u32 (mp->ttl);
168 rv = vnet_lisp_map_register_set_ttl (mp->ttl);
170 REPLY_MACRO (VL_API_ONE_MAP_REGISTER_SET_TTL_REPLY);
174 vl_api_show_one_map_register_ttl_t_handler
175 (vl_api_show_one_map_register_ttl_t * mp)
177 vl_api_show_one_map_register_ttl_reply_t *rmp;
180 u32 ttl = vnet_lisp_map_register_get_ttl ();
182 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_TTL_REPLY,
184 rmp->ttl = clib_host_to_net_u32 (ttl);
190 vl_api_one_add_del_locator_set_t_handler (vl_api_one_add_del_locator_set_t *
193 vl_api_one_add_del_locator_set_reply_t *rmp;
195 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
197 vl_api_one_local_locator_t *ls_loc;
198 u32 ls_index = ~0, locator_num;
199 u8 *locator_name = NULL;
202 clib_memset (a, 0, sizeof (a[0]));
204 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
205 locator_name = format (0, "%s", mp->locator_set_name);
206 vec_terminate_c_string (locator_name);
208 a->name = locator_name;
209 a->is_add = mp->is_add;
211 locator_num = clib_net_to_host_u32 (mp->locator_num);
213 clib_memset (&locator, 0, sizeof (locator));
214 for (i = 0; i < locator_num; i++)
216 ls_loc = &mp->locators[i];
217 VALIDATE_SW_IF_INDEX (ls_loc);
219 locator.sw_if_index = htonl (ls_loc->sw_if_index);
220 locator.priority = ls_loc->priority;
221 locator.weight = ls_loc->weight;
223 vec_add1 (a->locators, locator);
226 rv = vnet_lisp_add_del_locator_set (a, &ls_index);
228 BAD_SW_IF_INDEX_LABEL;
230 vec_free (locator_name);
231 vec_free (a->locators);
234 REPLY_MACRO2 (VL_API_ONE_ADD_DEL_LOCATOR_SET_REPLY,
236 rmp->ls_index = clib_host_to_net_u32 (ls_index);
242 vl_api_one_add_del_locator_t_handler (vl_api_one_add_del_locator_t * mp)
244 vl_api_one_add_del_locator_reply_t *rmp;
246 locator_t locator, *locators = NULL;
247 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
249 u8 *locator_name = NULL;
251 clib_memset (&locator, 0, sizeof (locator));
252 clib_memset (a, 0, sizeof (a[0]));
254 locator.sw_if_index = ntohl (mp->sw_if_index);
255 locator.priority = mp->priority;
256 locator.weight = mp->weight;
258 vec_add1 (locators, locator);
260 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
261 locator_name = format (0, "%s", mp->locator_set_name);
262 vec_terminate_c_string (locator_name);
264 a->name = locator_name;
265 a->locators = locators;
266 a->is_add = mp->is_add;
269 rv = vnet_lisp_add_del_locator (a, NULL, &ls_index);
272 vec_free (locator_name);
274 REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCATOR_REPLY);
281 } __attribute__ ((__packed__)) lisp_nsh_api_t;
284 unformat_one_eid_api (gid_address_t * dst, u32 vni, u8 type, void *src,
292 gid_address_type (dst) = GID_ADDR_IP_PREFIX;
293 gid_address_ip_set (dst, src, AF_IP4);
294 gid_address_ippref_len (dst) = len;
295 ip_prefix_normalize (&gid_address_ippref (dst));
298 gid_address_type (dst) = GID_ADDR_IP_PREFIX;
299 gid_address_ip_set (dst, src, AF_IP6);
300 gid_address_ippref_len (dst) = len;
301 ip_prefix_normalize (&gid_address_ippref (dst));
304 gid_address_type (dst) = GID_ADDR_MAC;
305 clib_memcpy (&gid_address_mac (dst), src, 6);
308 gid_address_type (dst) = GID_ADDR_NSH;
310 gid_address_nsh_spi (dst) = clib_net_to_host_u32 (nsh->spi);
311 gid_address_nsh_si (dst) = nsh->si;
315 return VNET_API_ERROR_INVALID_VALUE;
318 gid_address_vni (dst) = vni;
324 vl_api_one_add_del_local_eid_t_handler (vl_api_one_add_del_local_eid_t * mp)
326 vl_api_one_add_del_local_eid_reply_t *rmp;
327 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
329 gid_address_t _eid, *eid = &_eid;
331 u32 locator_set_index = ~0, map_index = ~0;
332 vnet_lisp_add_del_mapping_args_t _a, *a = &_a;
333 u8 *name = NULL, *key = NULL;
334 clib_memset (a, 0, sizeof (a[0]));
335 clib_memset (eid, 0, sizeof (eid[0]));
337 rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
338 mp->eid_type, mp->eid, mp->prefix_len);
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];
360 key = format (0, "%s", mp->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 = clib_net_to_host_u16 (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_set (&addr, mp->ip_address, mp->is_ipv6 ? AF_IP6 : AF_IP4);
401 rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
403 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_SERVER_REPLY);
407 vl_api_one_add_del_map_resolver_t_handler (vl_api_one_add_del_map_resolver_t
410 vl_api_one_add_del_map_resolver_reply_t *rmp;
412 vnet_lisp_add_del_map_resolver_args_t _a, *a = &_a;
414 clib_memset (a, 0, sizeof (a[0]));
416 a->is_add = mp->is_add;
417 ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? AF_IP6 : AF_IP4);
419 rv = vnet_lisp_add_del_map_resolver (a);
421 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_RESOLVER_REPLY);
425 vl_api_one_map_register_enable_disable_t_handler
426 (vl_api_one_map_register_enable_disable_t * mp)
428 vl_api_one_map_register_enable_disable_reply_t *rmp;
431 vnet_lisp_map_register_enable_disable (mp->is_enabled);
432 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
436 vl_api_one_rloc_probe_enable_disable_t_handler
437 (vl_api_one_rloc_probe_enable_disable_t * mp)
439 vl_api_one_rloc_probe_enable_disable_reply_t *rmp;
442 vnet_lisp_rloc_probe_enable_disable (mp->is_enabled);
443 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
447 vl_api_one_enable_disable_t_handler (vl_api_one_enable_disable_t * mp)
449 vl_api_one_enable_disable_reply_t *rmp;
452 vnet_lisp_enable_disable (mp->is_en);
453 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
457 vl_api_show_one_map_request_mode_t_handler
458 (vl_api_show_one_map_request_mode_t * mp)
461 vl_api_show_one_map_request_mode_reply_t *rmp;
464 REPLY_MACRO2(VL_API_SHOW_ONE_MAP_REQUEST_MODE_REPLY,
466 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_set (&addr, &mp->address, mp->is_ip4 ? AF_IP4 : AF_IP6);
524 rv = vnet_lisp_use_petr (&addr, mp->is_add);
526 REPLY_MACRO (VL_API_ONE_USE_PETR_REPLY);
530 vl_api_show_one_use_petr_t_handler (vl_api_show_one_use_petr_t * mp)
532 vl_api_show_one_use_petr_reply_t *rmp = NULL;
533 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
535 locator_set_t *ls = 0;
541 clib_memset (&addr, 0, sizeof (addr));
542 status = lcm->flags & LISP_FLAG_USE_PETR;
545 m = pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index);
546 if (~0 != m->locator_set_index)
549 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
550 loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
551 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);
560 switch (ip_addr_version (ip))
563 clib_memcpy (rmp->address, &ip_addr_v4 (ip),
564 sizeof (ip_addr_v4 (ip)));
568 clib_memcpy (rmp->address, &ip_addr_v6 (ip),
569 sizeof (ip_addr_v6 (ip)));
575 rmp->is_ip4 = (gid_address_ip_version (&addr) == AF_IP4);
581 vl_api_one_add_del_map_request_itr_rlocs_t_handler
582 (vl_api_one_add_del_map_request_itr_rlocs_t * mp)
584 vl_api_one_add_del_map_request_itr_rlocs_reply_t *rmp;
586 u8 *locator_set_name = NULL;
587 vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
589 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
590 locator_set_name = format (0, "%s", mp->locator_set_name);
591 vec_terminate_c_string (locator_set_name);
593 a->is_add = mp->is_add;
594 a->locator_set_name = locator_set_name;
596 rv = vnet_lisp_add_del_mreq_itr_rlocs (a);
598 vec_free (locator_set_name);
600 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
604 vl_api_one_add_del_remote_mapping_t_handler
605 (vl_api_one_add_del_remote_mapping_t * mp)
607 locator_t *rlocs = 0;
608 vl_api_one_add_del_remote_mapping_reply_t *rmp;
610 gid_address_t _eid, *eid = &_eid;
611 u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num);
613 clib_memset (eid, 0, sizeof (eid[0]));
615 rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
616 mp->eid_type, mp->eid, mp->eid_len);
620 rlocs = unformat_one_locs (mp->rlocs, rloc_num);
624 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
625 clib_memset (a, 0, sizeof (a[0]));
626 gid_address_copy (&a->reid, eid);
628 rv = vnet_lisp_add_del_adjacency (a);
635 /* NOTE: for now this works as a static remote mapping, i.e.,
636 * not authoritative and ttl infinite. */
639 vnet_lisp_add_del_mapping_args_t _m_args, *m_args = &_m_args;
640 clib_memset (m_args, 0, sizeof (m_args[0]));
641 gid_address_copy (&m_args->eid, eid);
642 m_args->action = mp->action;
643 m_args->is_static = 1;
645 m_args->authoritative = 0;
646 rv = vnet_lisp_add_mapping (m_args, rlocs, NULL, NULL);
649 rv = vnet_lisp_del_mapping (eid, NULL);
652 vnet_lisp_clear_all_remote_adjacencies ();
657 REPLY_MACRO (VL_API_ONE_ADD_DEL_REMOTE_MAPPING_REPLY);
661 vl_api_one_add_del_adjacency_t_handler (vl_api_one_add_del_adjacency_t * mp)
663 vl_api_one_add_del_adjacency_reply_t *rmp;
664 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
667 clib_memset (a, 0, sizeof (a[0]));
669 rv = unformat_one_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni),
670 mp->eid_type, mp->leid, mp->leid_len);
671 rv |= unformat_one_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni),
672 mp->eid_type, mp->reid, mp->reid_len);
677 a->is_add = mp->is_add;
678 rv = vnet_lisp_add_del_adjacency (a);
681 REPLY_MACRO (VL_API_ONE_ADD_DEL_ADJACENCY_REPLY);
685 send_one_locator_details (lisp_cp_main_t * lcm,
686 locator_t * loc, vl_api_registration_t * reg,
689 vl_api_one_locator_details_t *rmp;
691 rmp = vl_msg_api_alloc (sizeof (*rmp));
692 clib_memset (rmp, 0, sizeof (*rmp));
693 rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_DETAILS);
694 rmp->context = context;
696 rmp->local = loc->local;
699 rmp->sw_if_index = ntohl (loc->sw_if_index);
703 rmp->is_ipv6 = gid_address_ip_version (&loc->address);
704 ip_address_copy_addr (rmp->ip_address, &gid_address_ip (&loc->address));
706 rmp->priority = loc->priority;
707 rmp->weight = loc->weight;
709 vl_api_send_msg (reg, (u8 *) rmp);
713 vl_api_one_locator_dump_t_handler (vl_api_one_locator_dump_t * mp)
716 vl_api_registration_t *reg;
717 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
718 locator_set_t *lsit = 0;
720 u32 ls_index = ~0, *locit = 0;
723 reg = vl_api_client_index_to_registration (mp->client_index);
727 if (mp->is_index_set)
728 ls_index = htonl (mp->ls_index);
731 /* make sure we get a proper C-string */
732 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
733 ls_name = format (0, "%s", mp->ls_name);
734 vec_terminate_c_string (ls_name);
735 p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
741 if (pool_is_free_index (lcm->locator_set_pool, ls_index))
744 lsit = pool_elt_at_index (lcm->locator_set_pool, ls_index);
746 vec_foreach (locit, lsit->locator_indices)
748 loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
749 send_one_locator_details (lcm, loc, reg, mp->context);
756 send_one_locator_set_details (lisp_cp_main_t * lcm,
757 locator_set_t * lsit,
758 vl_api_registration_t * reg, u32 context,
761 vl_api_one_locator_set_details_t *rmp;
764 rmp = vl_msg_api_alloc (sizeof (*rmp));
765 clib_memset (rmp, 0, sizeof (*rmp));
766 rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_SET_DETAILS);
767 rmp->context = context;
769 rmp->ls_index = htonl (ls_index);
772 ASSERT (lsit->name != NULL);
773 strncpy ((char *) rmp->ls_name, (char *) lsit->name,
774 vec_len (lsit->name));
778 str = format (0, "<remote-%d>", ls_index);
779 strncpy ((char *) rmp->ls_name, (char *) str, vec_len (str));
783 vl_api_send_msg (reg, (u8 *) rmp);
787 vl_api_one_locator_set_dump_t_handler (vl_api_one_locator_set_dump_t * mp)
789 vl_api_registration_t *reg;
790 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
791 locator_set_t *lsit = NULL;
794 reg = vl_api_client_index_to_registration (mp->client_index);
800 pool_foreach (lsit, lcm->locator_set_pool,
802 if (filter && !((1 == filter && lsit->local) ||
803 (2 == filter && !lsit->local)))
807 send_one_locator_set_details (lcm, lsit, reg, mp->context,
808 lsit - lcm->locator_set_pool);
814 one_fid_put_api (u8 * dst, fid_address_t * src, u8 * prefix_length)
816 ASSERT (prefix_length);
817 ip_prefix_t *ippref = &fid_addr_ippref (src);
819 switch (fid_addr_type (src))
821 case FID_ADDR_IP_PREF:
822 if (ip_prefix_version (ippref) == AF_IP4)
823 clib_memcpy (dst, &ip_prefix_v4 (ippref), 4);
825 clib_memcpy (dst, &ip_prefix_v6 (ippref), 16);
826 prefix_length[0] = ip_prefix_len (ippref);
830 prefix_length[0] = 0;
831 clib_memcpy (dst, fid_addr_mac (src), 6);
835 clib_warning ("Unknown FID type %d!", fid_addr_type (src));
841 fid_type_to_api_type (fid_address_t * fid)
845 switch (fid_addr_type (fid))
847 case FID_ADDR_IP_PREF:
848 ippref = &fid_addr_ippref (fid);
849 if (ip_prefix_version (ippref) == AF_IP4)
851 else if (ip_prefix_version (ippref) == AF_IP6)
866 send_one_eid_table_details (mapping_t * mapit,
867 vl_api_registration_t * reg, u32 context,
871 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
872 locator_set_t *ls = 0;
873 vl_api_one_eid_table_details_t *rmp = NULL;
874 gid_address_t *gid = NULL;
876 ip_prefix_t *ip_prefix = NULL;
878 if (mapit->pitr_set || mapit->nsh_set)
883 case 0: /* all mappings */
886 case 1: /* local only */
890 case 2: /* remote only */
895 clib_warning ("Filter error, unknown filter: %d", filter);
900 ip_prefix = &gid_address_ippref (gid);
901 mac = gid_address_mac (gid);
903 rmp = vl_msg_api_alloc (sizeof (*rmp));
904 clib_memset (rmp, 0, sizeof (*rmp));
905 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_DETAILS);
907 ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index);
908 if (vec_len (ls->locator_indices) == 0)
909 rmp->locator_set_index = ~0;
911 rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index);
913 rmp->is_local = mapit->local;
914 rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
915 rmp->action = mapit->action;
916 rmp->authoritative = mapit->authoritative;
918 switch (gid_address_type (gid))
920 case GID_ADDR_SRC_DST:
922 fid = &gid_address_sd_src (gid);
923 rmp->eid_type = fid_type_to_api_type (fid);
924 one_fid_put_api (rmp->seid, &gid_address_sd_src (gid),
925 &rmp->seid_prefix_len);
926 one_fid_put_api (rmp->eid, &gid_address_sd_dst (gid),
927 &rmp->eid_prefix_len);
929 case GID_ADDR_IP_PREFIX:
930 rmp->eid_prefix_len = ip_prefix_len (ip_prefix);
931 if (ip_prefix_version (ip_prefix) == AF_IP4)
933 rmp->eid_type = 0; /* ipv4 type */
934 clib_memcpy (rmp->eid, &ip_prefix_v4 (ip_prefix),
935 sizeof (ip_prefix_v4 (ip_prefix)));
939 rmp->eid_type = 1; /* ipv6 type */
940 clib_memcpy (rmp->eid, &ip_prefix_v6 (ip_prefix),
941 sizeof (ip_prefix_v6 (ip_prefix)));
945 rmp->eid_type = 2; /* l2 mac type */
946 clib_memcpy (rmp->eid, mac, 6);
949 rmp->eid_type = 3; /* NSH type */
951 nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (gid));
952 nsh.si = gid_address_nsh_si (gid);
953 clib_memcpy (rmp->eid, &nsh, sizeof (nsh));
958 rmp->context = context;
959 rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
960 rmp->key_id = clib_host_to_net_u16 (mapit->key_id);
961 memcpy (rmp->key, mapit->key, vec_len (mapit->key));
962 vl_api_send_msg (reg, (u8 *) rmp);
966 vl_api_one_eid_table_dump_t_handler (vl_api_one_eid_table_dump_t * mp)
969 vl_api_registration_t *reg;
970 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
971 mapping_t *mapit = NULL;
972 gid_address_t _eid, *eid = &_eid;
974 reg = vl_api_client_index_to_registration (mp->client_index);
980 clib_memset (eid, 0, sizeof (*eid));
982 unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
983 mp->eid_type, mp->eid, mp->prefix_length);
985 mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
989 mapit = pool_elt_at_index (lcm->mapping_pool, mi);
990 send_one_eid_table_details (mapit, reg, mp->context,
991 0 /* ignore filter */ );
996 pool_foreach (mapit, lcm->mapping_pool,
998 send_one_eid_table_details(mapit, reg, mp->context,
1006 send_one_map_server_details (ip_address_t * ip, vl_api_registration_t * reg,
1009 vl_api_one_map_server_details_t *rmp = NULL;
1011 rmp = vl_msg_api_alloc (sizeof (*rmp));
1012 clib_memset (rmp, 0, sizeof (*rmp));
1013 rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_SERVER_DETAILS);
1015 switch (ip_addr_version (ip))
1019 clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
1020 sizeof (ip_addr_v4 (ip)));
1025 clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
1026 sizeof (ip_addr_v6 (ip)));
1032 rmp->context = context;
1034 vl_api_send_msg (reg, (u8 *) rmp);
1038 vl_api_one_map_server_dump_t_handler (vl_api_one_map_server_dump_t * mp)
1040 vl_api_registration_t *reg;
1041 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1044 reg = vl_api_client_index_to_registration (mp->client_index);
1048 vec_foreach (mr, lcm->map_servers)
1050 send_one_map_server_details (&mr->address, reg, mp->context);
1055 send_one_map_resolver_details (ip_address_t * ip,
1056 vl_api_registration_t * reg, u32 context)
1058 vl_api_one_map_resolver_details_t *rmp = NULL;
1060 rmp = vl_msg_api_alloc (sizeof (*rmp));
1061 clib_memset (rmp, 0, sizeof (*rmp));
1062 rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_RESOLVER_DETAILS);
1064 switch (ip_addr_version (ip))
1068 clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
1069 sizeof (ip_addr_v4 (ip)));
1074 clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
1075 sizeof (ip_addr_v6 (ip)));
1081 rmp->context = context;
1083 vl_api_send_msg (reg, (u8 *) rmp);
1087 vl_api_one_map_resolver_dump_t_handler (vl_api_one_map_resolver_dump_t * mp)
1089 vl_api_registration_t *reg;
1090 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1093 reg = vl_api_client_index_to_registration (mp->client_index);
1097 vec_foreach (mr, lcm->map_resolvers)
1099 send_one_map_resolver_details (&mr->address, reg, mp->context);
1104 send_eid_table_map_pair (hash_pair_t * p, vl_api_registration_t * reg,
1107 vl_api_one_eid_table_map_details_t *rmp = NULL;
1109 rmp = vl_msg_api_alloc (sizeof (*rmp));
1110 clib_memset (rmp, 0, sizeof (*rmp));
1111 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_MAP_DETAILS);
1113 rmp->vni = clib_host_to_net_u32 (p->key);
1114 rmp->dp_table = clib_host_to_net_u32 (p->value[0]);
1115 rmp->context = context;
1116 vl_api_send_msg (reg, (u8 *) rmp);
1120 vl_api_one_eid_table_map_dump_t_handler (vl_api_one_eid_table_map_dump_t * mp)
1122 vl_api_registration_t *reg;
1123 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1125 uword *vni_table = 0;
1127 reg = vl_api_client_index_to_registration (mp->client_index);
1133 vni_table = lcm->bd_id_by_vni;
1137 vni_table = lcm->table_id_by_vni;
1141 hash_foreach_pair (p, vni_table,
1143 send_eid_table_map_pair (p, reg, mp->context);
1149 send_eid_table_vni (u32 vni, vl_api_registration_t * reg, u32 context)
1151 vl_api_one_eid_table_vni_details_t *rmp = 0;
1153 rmp = vl_msg_api_alloc (sizeof (*rmp));
1154 clib_memset (rmp, 0, sizeof (*rmp));
1155 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_VNI_DETAILS);
1156 rmp->context = context;
1157 rmp->vni = clib_host_to_net_u32 (vni);
1158 vl_api_send_msg (reg, (u8 *) rmp);
1162 one_adjacency_copy (vl_api_one_adjacency_t * dst, lisp_adjacency_t * adjs)
1164 lisp_adjacency_t *adj;
1165 vl_api_one_adjacency_t a;
1166 u32 i, n = vec_len (adjs);
1169 for (i = 0; i < n; i++)
1171 adj = vec_elt_at_index (adjs, i);
1172 clib_memset (&a, 0, sizeof (a));
1174 switch (gid_address_type (&adj->reid))
1176 case GID_ADDR_IP_PREFIX:
1177 a.reid_prefix_len = gid_address_ippref_len (&adj->reid);
1178 a.leid_prefix_len = gid_address_ippref_len (&adj->leid);
1179 if (gid_address_ip_version (&adj->reid) == AF_IP4)
1181 a.eid_type = 0; /* ipv4 type */
1182 clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 4);
1183 clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 4);
1187 a.eid_type = 1; /* ipv6 type */
1188 clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 16);
1189 clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 16);
1193 a.eid_type = 2; /* l2 mac type */
1194 mac_copy (a.reid, gid_address_mac (&adj->reid));
1195 mac_copy (a.leid, gid_address_mac (&adj->leid));
1198 a.eid_type = 3; /* NSH type */
1199 nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (&adj->reid));
1200 nsh.si = gid_address_nsh_si (&adj->reid);
1201 clib_memcpy (a.reid, &nsh, sizeof (nsh));
1203 nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (&adj->leid));
1204 nsh.si = gid_address_nsh_si (&adj->leid);
1205 clib_memcpy (a.leid, &nsh, sizeof (nsh));
1215 vl_api_show_one_rloc_probe_state_t_handler
1216 (vl_api_show_one_rloc_probe_state_t * mp)
1218 vl_api_show_one_rloc_probe_state_reply_t *rmp = 0;
1222 REPLY_MACRO2 (VL_API_SHOW_ONE_RLOC_PROBE_STATE_REPLY,
1224 rmp->is_enabled = vnet_lisp_rloc_probe_state_get ();
1230 vl_api_show_one_map_register_state_t_handler
1231 (vl_api_show_one_map_register_state_t * mp)
1233 vl_api_show_one_map_register_state_reply_t *rmp = 0;
1237 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_STATE_REPLY,
1239 rmp->is_enabled = vnet_lisp_map_register_state_get ();
1245 vl_api_one_adjacencies_get_t_handler (vl_api_one_adjacencies_get_t * mp)
1247 vl_api_one_adjacencies_get_reply_t *rmp = 0;
1248 lisp_adjacency_t *adjs = 0;
1251 u32 vni = clib_net_to_host_u32 (mp->vni);
1253 adjs = vnet_lisp_adjacencies_get_by_vni (vni);
1254 size = vec_len (adjs) * sizeof (vl_api_one_adjacency_t);
1257 REPLY_MACRO4 (VL_API_ONE_ADJACENCIES_GET_REPLY, size,
1259 rmp->count = clib_host_to_net_u32 (vec_len (adjs));
1260 one_adjacency_copy (rmp->adjacencies, adjs);
1268 vl_api_one_eid_table_vni_dump_t_handler (vl_api_one_eid_table_vni_dump_t * mp)
1272 vl_api_registration_t *reg;
1273 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1275 reg = vl_api_client_index_to_registration (mp->client_index);
1280 hash_foreach_pair (p, lcm->table_id_by_vni,
1282 hash_set (vnis, p->key, 0);
1285 hash_foreach_pair (p, lcm->bd_id_by_vni,
1287 hash_set (vnis, p->key, 0);
1290 hash_foreach_pair (p, vnis,
1292 send_eid_table_vni (p->key, reg, mp->context);
1300 vl_api_show_one_status_t_handler (vl_api_show_one_status_t * mp)
1302 vl_api_show_one_status_reply_t *rmp = NULL;
1306 REPLY_MACRO2(VL_API_SHOW_ONE_STATUS_REPLY,
1308 rmp->gpe_status = vnet_lisp_gpe_enable_disable_status ();
1309 rmp->feature_status = vnet_lisp_enable_disable_status ();
1315 vl_api_one_get_map_request_itr_rlocs_t_handler
1316 (vl_api_one_get_map_request_itr_rlocs_t * mp)
1318 vl_api_one_get_map_request_itr_rlocs_reply_t *rmp = NULL;
1319 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1320 locator_set_t *loc_set = 0;
1324 if (~0 == lcm->mreq_itr_rlocs)
1326 tmp_str = format (0, " ");
1331 pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
1332 tmp_str = format (0, "%s", loc_set->name);
1336 REPLY_MACRO2(VL_API_ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY,
1338 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1339 ARRAY_LEN(rmp->locator_set_name) - 1);
1347 vl_api_show_one_nsh_mapping_t_handler (vl_api_show_one_nsh_mapping_t * mp)
1349 vl_api_show_one_nsh_mapping_reply_t *rmp = NULL;
1350 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1352 locator_set_t *ls = 0;
1357 if (lcm->nsh_map_index == (u32) ~ 0)
1359 tmp_str = format (0, "N/A");
1363 m = pool_elt_at_index (lcm->mapping_pool, lcm->nsh_map_index);
1364 if (~0 != m->locator_set_index)
1367 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1368 tmp_str = format (0, "%s", ls->name);
1373 tmp_str = format (0, "N/A");
1376 vec_add1 (tmp_str, 0);
1379 REPLY_MACRO2(VL_API_SHOW_ONE_NSH_MAPPING_REPLY,
1381 rmp->is_set = is_set;
1382 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1383 ARRAY_LEN(rmp->locator_set_name) - 1);
1389 vl_api_show_one_pitr_t_handler (vl_api_show_one_pitr_t * mp)
1391 vl_api_show_one_pitr_reply_t *rmp = NULL;
1392 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1394 locator_set_t *ls = 0;
1398 u8 is_enabled = (lcm->flags & LISP_FLAG_PITR_MODE)
1399 && lcm->pitr_map_index != ~0;
1403 tmp_str = format (0, "N/A");
1407 m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index);
1408 if (~0 != m->locator_set_index)
1411 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1412 tmp_str = format (0, "%s", ls->name);
1416 tmp_str = format (0, "N/A");
1419 vec_add1 (tmp_str, 0);
1422 REPLY_MACRO2(VL_API_SHOW_ONE_PITR_REPLY,
1424 rmp->status = lcm->flags & LISP_FLAG_PITR_MODE;
1425 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1426 ARRAY_LEN(rmp->locator_set_name) - 1);
1432 vl_api_show_one_stats_enable_disable_t_handler
1433 (vl_api_show_one_stats_enable_disable_t * mp)
1435 vl_api_show_one_stats_enable_disable_reply_t *rmp = NULL;
1436 vnet_api_error_t rv = 0;
1439 REPLY_MACRO2 (VL_API_SHOW_ONE_STATS_ENABLE_DISABLE_REPLY,
1441 rmp->is_en = vnet_lisp_stats_enable_disable_state ();
1447 vl_api_one_stats_enable_disable_t_handler
1448 (vl_api_one_stats_enable_disable_t * mp)
1450 vl_api_one_enable_disable_reply_t *rmp = NULL;
1452 vnet_api_error_t rv = vnet_lisp_stats_enable_disable (mp->is_en);
1453 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
1457 lisp_fid_addr_to_api (fid_address_t * fid, u8 * dst, u8 * api_eid_type,
1460 switch (fid_addr_type (fid))
1462 case FID_ADDR_IP_PREF:
1463 *prefix_length = fid_addr_prefix_length (fid);
1464 if (fid_addr_ip_version (fid) == AF_IP4)
1466 *api_eid_type = 0; /* ipv4 type */
1467 clib_memcpy (dst, &fid_addr_ippref (fid), 4);
1471 *api_eid_type = 1; /* ipv6 type */
1472 clib_memcpy (dst, &fid_addr_ippref (fid), 16);
1476 *api_eid_type = 2; /* l2 mac type */
1477 mac_copy (dst, fid_addr_mac (fid));
1485 vl_api_one_stats_flush_t_handler (vl_api_one_stats_flush_t * mp)
1487 vl_api_one_stats_flush_reply_t *rmp;
1490 rv = vnet_lisp_flush_stats ();
1491 REPLY_MACRO (VL_API_ONE_STATS_FLUSH_REPLY);
1495 vl_api_one_stats_dump_t_handler (vl_api_one_stats_dump_t * mp)
1497 vl_api_one_stats_details_t *rmp;
1498 lisp_api_stats_t *stats, *stat;
1501 stats = vnet_lisp_get_stats ();
1502 vec_foreach (stat, stats)
1505 REPLY_DETAILS (VL_API_ONE_STATS_DETAILS,
1507 lisp_fid_addr_to_api (&stat->deid, rmp->deid, &rmp->eid_type,
1508 &rmp->deid_pref_len);
1509 lisp_fid_addr_to_api (&stat->seid, rmp->seid, &rmp->eid_type,
1510 &rmp->seid_pref_len);
1511 rmp->vni = clib_host_to_net_u32 (stat->vni);
1513 rmp->is_ip4 = ip_addr_version (&stat->rmt_rloc) == AF_IP4 ? 1 : 0;
1514 ip_address_copy_addr (rmp->rloc, &stat->rmt_rloc);
1515 ip_address_copy_addr (rmp->lloc, &stat->loc_rloc);
1517 rmp->pkt_count = clib_host_to_net_u32 (stat->counters.packets);
1518 rmp->bytes = clib_host_to_net_u32 (stat->counters.bytes);
1525 vl_api_one_add_del_l2_arp_entry_t_handler
1526 (vl_api_one_add_del_l2_arp_entry_t * mp)
1528 vl_api_one_add_del_l2_arp_entry_reply_t *rmp;
1530 gid_address_t _arp, *arp = &_arp;
1531 clib_memset (arp, 0, sizeof (*arp));
1533 gid_address_type (arp) = GID_ADDR_ARP;
1534 gid_address_arp_bd (arp) = clib_net_to_host_u32 (mp->bd);
1536 /* vpp keeps ip4 addresses in network byte order */
1537 ip_address_set (&gid_address_arp_ndp_ip (arp), &mp->ip4, AF_IP4);
1539 rv = vnet_lisp_add_del_l2_arp_ndp_entry (arp, mp->mac, mp->is_add);
1541 REPLY_MACRO (VL_API_ONE_ADD_DEL_L2_ARP_ENTRY_REPLY);
1545 vl_api_one_add_del_ndp_entry_t_handler (vl_api_one_add_del_ndp_entry_t * mp)
1547 vl_api_one_add_del_ndp_entry_reply_t *rmp;
1549 gid_address_t _g, *g = &_g;
1550 clib_memset (g, 0, sizeof (*g));
1552 gid_address_type (g) = GID_ADDR_NDP;
1553 gid_address_ndp_bd (g) = clib_net_to_host_u32 (mp->bd);
1554 ip_address_set (&gid_address_arp_ndp_ip (g), mp->ip6, AF_IP6);
1556 rv = vnet_lisp_add_del_l2_arp_ndp_entry (g, mp->mac, mp->is_add);
1558 REPLY_MACRO (VL_API_ONE_ADD_DEL_NDP_ENTRY_REPLY);
1562 vl_api_one_ndp_bd_get_t_handler (vl_api_one_ndp_bd_get_t * mp)
1564 vl_api_one_ndp_bd_get_reply_t *rmp;
1569 u32 *bds = vnet_lisp_ndp_bds_get ();
1570 u32 size = hash_elts (bds) * sizeof (u32);
1573 REPLY_MACRO4 (VL_API_ONE_NDP_BD_GET_REPLY, size,
1575 rmp->count = clib_host_to_net_u32 (hash_elts (bds));
1576 hash_foreach_pair (p, bds,
1578 rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
1587 vl_api_one_l2_arp_bd_get_t_handler (vl_api_one_l2_arp_bd_get_t * mp)
1589 vl_api_one_l2_arp_bd_get_reply_t *rmp;
1594 u32 *bds = vnet_lisp_l2_arp_bds_get ();
1595 u32 size = hash_elts (bds) * sizeof (u32);
1598 REPLY_MACRO4 (VL_API_ONE_L2_ARP_BD_GET_REPLY, size,
1600 rmp->count = clib_host_to_net_u32 (hash_elts (bds));
1601 hash_foreach_pair (p, bds,
1603 rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
1612 vl_api_one_l2_arp_entries_get_t_handler (vl_api_one_l2_arp_entries_get_t * mp)
1614 vl_api_one_l2_arp_entries_get_reply_t *rmp;
1615 lisp_api_l2_arp_entry_t *entries = 0, *e;
1619 u32 bd = clib_net_to_host_u32 (mp->bd);
1621 entries = vnet_lisp_l2_arp_entries_get_by_bd (bd);
1622 u32 size = vec_len (entries) * sizeof (vl_api_one_l2_arp_entry_t);
1625 REPLY_MACRO4 (VL_API_ONE_L2_ARP_ENTRIES_GET_REPLY, size,
1627 rmp->count = clib_host_to_net_u32 (vec_len (entries));
1628 vec_foreach (e, entries)
1630 mac_copy (rmp->entries[i].mac, e->mac);
1631 rmp->entries[i].ip4 = e->ip4;
1641 vl_api_one_map_register_fallback_threshold_t_handler
1642 (vl_api_one_map_register_fallback_threshold_t * mp)
1644 vl_api_one_map_register_fallback_threshold_reply_t *rmp;
1647 mp->value = clib_net_to_host_u32 (mp->value);
1648 rv = vnet_lisp_map_register_fallback_threshold_set (mp->value);
1649 REPLY_MACRO (VL_API_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY);
1653 vl_api_show_one_map_register_fallback_threshold_t_handler
1654 (vl_api_show_one_map_register_fallback_threshold_t * mp)
1656 vl_api_show_one_map_register_fallback_threshold_reply_t *rmp;
1659 u32 value = vnet_lisp_map_register_fallback_threshold_get ();
1662 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY,
1664 rmp->value = clib_host_to_net_u32 (value);
1670 vl_api_one_set_transport_protocol_t_handler
1671 (vl_api_one_set_transport_protocol_t * mp)
1673 vl_api_one_set_transport_protocol_reply_t *rmp;
1676 rv = vnet_lisp_set_transport_protocol (mp->protocol);
1678 REPLY_MACRO (VL_API_ONE_SET_TRANSPORT_PROTOCOL_REPLY);
1682 vl_api_one_get_transport_protocol_t_handler
1683 (vl_api_one_get_transport_protocol_t * mp)
1685 vl_api_one_get_transport_protocol_reply_t *rmp;
1687 u8 proto = (u8) vnet_lisp_get_transport_protocol ();
1690 REPLY_MACRO2 (VL_API_ONE_GET_TRANSPORT_PROTOCOL_REPLY,
1692 rmp->protocol = proto;
1698 vl_api_one_ndp_entries_get_t_handler (vl_api_one_ndp_entries_get_t * mp)
1700 vl_api_one_ndp_entries_get_reply_t *rmp = 0;
1701 lisp_api_ndp_entry_t *entries = 0, *e;
1705 u32 bd = clib_net_to_host_u32 (mp->bd);
1707 entries = vnet_lisp_ndp_entries_get_by_bd (bd);
1708 u32 size = vec_len (entries) * sizeof (vl_api_one_ndp_entry_t);
1711 REPLY_MACRO4 (VL_API_ONE_NDP_ENTRIES_GET_REPLY, size,
1713 rmp->count = clib_host_to_net_u32 (vec_len (entries));
1714 vec_foreach (e, entries)
1716 mac_copy (rmp->entries[i].mac, e->mac);
1717 clib_memcpy (rmp->entries[i].ip6, e->ip6, 16);
1727 vl_api_one_enable_disable_xtr_mode_t_handler
1728 (vl_api_one_enable_disable_xtr_mode_t * mp)
1730 vl_api_one_enable_disable_xtr_mode_reply_t *rmp = 0;
1731 int rv = vnet_lisp_enable_disable_xtr_mode (mp->is_en);
1733 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_XTR_MODE_REPLY);
1737 vl_api_one_show_xtr_mode_t_handler (vl_api_one_show_xtr_mode_t * mp)
1739 vl_api_one_show_xtr_mode_reply_t *rmp = 0;
1743 REPLY_MACRO2 (VL_API_ONE_SHOW_XTR_MODE_REPLY,
1745 rmp->is_en = vnet_lisp_get_xtr_mode ();
1751 vl_api_one_enable_disable_pitr_mode_t_handler
1752 (vl_api_one_enable_disable_pitr_mode_t * mp)
1754 vl_api_one_enable_disable_pitr_mode_reply_t *rmp = 0;
1755 int rv = vnet_lisp_enable_disable_pitr_mode (mp->is_en);
1757 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_PITR_MODE_REPLY);
1761 vl_api_one_show_pitr_mode_t_handler (vl_api_one_show_pitr_mode_t * mp)
1763 vl_api_one_show_pitr_mode_reply_t *rmp = 0;
1767 REPLY_MACRO2 (VL_API_ONE_SHOW_PITR_MODE_REPLY,
1769 rmp->is_en = vnet_lisp_get_pitr_mode ();
1775 vl_api_one_enable_disable_petr_mode_t_handler
1776 (vl_api_one_enable_disable_petr_mode_t * mp)
1778 vl_api_one_enable_disable_petr_mode_reply_t *rmp = 0;
1779 int rv = vnet_lisp_enable_disable_petr_mode (mp->is_en);
1781 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_PETR_MODE_REPLY);
1785 vl_api_one_show_petr_mode_t_handler (vl_api_one_show_petr_mode_t * mp)
1787 vl_api_one_show_petr_mode_reply_t *rmp = 0;
1791 REPLY_MACRO2 (VL_API_ONE_SHOW_PETR_MODE_REPLY,
1793 rmp->is_en = vnet_lisp_get_petr_mode ();
1800 * Add vpe's API message handlers to the table.
1801 * vlib has already mapped shared memory and
1802 * added the client registration handlers.
1803 * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1805 #define vl_msg_name_crc_list
1806 #include <vnet/vnet_all_api_h.h>
1807 #undef vl_msg_name_crc_list
1810 setup_message_id_table (api_main_t * am)
1812 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1813 foreach_vl_msg_name_crc_one;
1817 static clib_error_t *
1818 one_api_hookup (vlib_main_t * vm)
1820 api_main_t *am = vlibapi_get_main ();
1823 vl_msg_api_set_handlers(VL_API_##N, #n, \
1824 vl_api_##n##_t_handler, \
1826 vl_api_##n##_t_endian, \
1827 vl_api_##n##_t_print, \
1828 sizeof(vl_api_##n##_t), 1);
1829 foreach_vpe_api_msg;
1833 * Set up the (msg_name, crc, message-id) table
1835 setup_message_id_table (am);
1840 VLIB_API_INIT_FUNCTION (one_api_hookup);
1843 * fd.io coding-style-patch-verification: ON
1846 * eval: (c-set-style "gnu")