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_remote_locator_t_endian vl_noop_handler
31 #define vl_api_one_remote_locator_t_print vl_noop_handler
32 #define vl_api_one_local_locator_t_endian vl_noop_handler
33 #define vl_api_one_local_locator_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_locator_set_t_endian vl_noop_handler
41 #define vl_api_one_add_del_locator_set_t_print vl_noop_handler
42 #define vl_api_one_add_del_remote_mapping_t_endian vl_noop_handler
43 #define vl_api_one_add_del_remote_mapping_t_print vl_noop_handler
45 #define vl_api_one_l2_arp_entry_t_endian vl_noop_handler
46 #define vl_api_one_l2_arp_entry_t_print vl_noop_handler
47 #define vl_api_one_add_del_l2_arp_entry vl_noop_handler
48 #define vl_api_one_l2_arp_bd_get vl_noop_handler
50 #define vl_api_one_ndp_entry_t_endian vl_noop_handler
51 #define vl_api_one_ndp_entry_t_print vl_noop_handler
52 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
53 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
55 #define vl_typedefs /* define message structures */
56 #include <vnet/vnet_all_api_h.h>
59 #define vl_endianfun /* define message structures */
60 #include <vnet/vnet_all_api_h.h>
63 /* instantiate all the print functions we know about */
64 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
66 #include <vnet/vnet_all_api_h.h>
69 #include <vlibapi/api_helper_macros.h>
71 #define REPLY_DETAILS(t, body) \
73 unix_shared_memory_queue_t * q; \
74 rv = vl_msg_api_pd_handler (mp, rv); \
75 q = vl_api_client_index_to_input_queue (mp->client_index); \
79 rmp = vl_msg_api_alloc (sizeof (*rmp)); \
80 rmp->_vl_msg_id = ntohs((t)); \
81 rmp->context = mp->context; \
82 do {body;} while (0); \
83 vl_msg_api_send_shmem (q, (u8 *)&rmp); \
86 #define foreach_vpe_api_msg \
87 _(ONE_ADD_DEL_LOCATOR_SET, one_add_del_locator_set) \
88 _(ONE_ADD_DEL_LOCATOR, one_add_del_locator) \
89 _(ONE_ADD_DEL_LOCAL_EID, one_add_del_local_eid) \
90 _(ONE_ADD_DEL_MAP_RESOLVER, one_add_del_map_resolver) \
91 _(ONE_ADD_DEL_MAP_SERVER, one_add_del_map_server) \
92 _(ONE_ENABLE_DISABLE, one_enable_disable) \
93 _(ONE_RLOC_PROBE_ENABLE_DISABLE, one_rloc_probe_enable_disable) \
94 _(ONE_MAP_REGISTER_ENABLE_DISABLE, one_map_register_enable_disable) \
95 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD, \
96 one_map_register_fallback_threshold) \
97 _(ONE_ADD_DEL_REMOTE_MAPPING, one_add_del_remote_mapping) \
98 _(ONE_ADD_DEL_ADJACENCY, one_add_del_adjacency) \
99 _(ONE_PITR_SET_LOCATOR_SET, one_pitr_set_locator_set) \
100 _(ONE_NSH_SET_LOCATOR_SET, one_nsh_set_locator_set) \
101 _(ONE_MAP_REQUEST_MODE, one_map_request_mode) \
102 _(ONE_EID_TABLE_ADD_DEL_MAP, one_eid_table_add_del_map) \
103 _(ONE_LOCATOR_SET_DUMP, one_locator_set_dump) \
104 _(ONE_LOCATOR_DUMP, one_locator_dump) \
105 _(ONE_EID_TABLE_DUMP, one_eid_table_dump) \
106 _(ONE_MAP_RESOLVER_DUMP, one_map_resolver_dump) \
107 _(ONE_MAP_SERVER_DUMP, one_map_server_dump) \
108 _(ONE_EID_TABLE_MAP_DUMP, one_eid_table_map_dump) \
109 _(ONE_EID_TABLE_VNI_DUMP, one_eid_table_vni_dump) \
110 _(ONE_ADJACENCIES_GET, one_adjacencies_get) \
111 _(ONE_MAP_REGISTER_SET_TTL, one_map_register_set_ttl) \
112 _(SHOW_ONE_NSH_MAPPING, show_one_nsh_mapping) \
113 _(SHOW_ONE_RLOC_PROBE_STATE, show_one_rloc_probe_state) \
114 _(SHOW_ONE_MAP_REGISTER_STATE, show_one_map_register_state) \
115 _(SHOW_ONE_MAP_REGISTER_TTL, show_one_map_register_ttl) \
116 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, \
117 show_one_map_register_fallback_threshold) \
118 _(SHOW_ONE_STATUS, show_one_status) \
119 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \
120 one_add_del_map_request_itr_rlocs) \
121 _(ONE_GET_MAP_REQUEST_ITR_RLOCS, one_get_map_request_itr_rlocs) \
122 _(SHOW_ONE_PITR, show_one_pitr) \
123 _(SHOW_ONE_MAP_REQUEST_MODE, show_one_map_request_mode) \
124 _(ONE_USE_PETR, one_use_petr) \
125 _(SHOW_ONE_USE_PETR, show_one_use_petr) \
126 _(SHOW_ONE_STATS_ENABLE_DISABLE, show_one_stats_enable_disable) \
127 _(ONE_STATS_ENABLE_DISABLE, one_stats_enable_disable) \
128 _(ONE_STATS_DUMP, one_stats_dump) \
129 _(ONE_STATS_FLUSH, one_stats_flush) \
130 _(ONE_L2_ARP_BD_GET, one_l2_arp_bd_get) \
131 _(ONE_L2_ARP_ENTRIES_GET, one_l2_arp_entries_get) \
132 _(ONE_ADD_DEL_L2_ARP_ENTRY, one_add_del_l2_arp_entry) \
133 _(ONE_ADD_DEL_NDP_ENTRY, one_add_del_ndp_entry) \
134 _(ONE_NDP_BD_GET, one_ndp_bd_get) \
135 _(ONE_NDP_ENTRIES_GET, one_ndp_entries_get) \
136 _(ONE_SET_TRANSPORT_PROTOCOL, one_set_transport_protocol) \
137 _(ONE_GET_TRANSPORT_PROTOCOL, one_get_transport_protocol)
140 unformat_one_locs (vl_api_one_remote_locator_t * rmt_locs, u32 rloc_num)
143 locator_t *locs = 0, loc;
144 vl_api_one_remote_locator_t *r;
146 for (i = 0; i < rloc_num; i++)
148 /* remote locators */
150 memset (&loc, 0, sizeof (loc));
151 gid_address_ip_set (&loc.address, &r->addr, r->is_ip4 ? IP4 : IP6);
153 loc.priority = r->priority;
154 loc.weight = r->weight;
156 vec_add1 (locs, loc);
162 vl_api_one_map_register_set_ttl_t_handler (vl_api_one_map_register_set_ttl_t *
165 vl_api_one_map_register_set_ttl_reply_t *rmp;
168 mp->ttl = clib_net_to_host_u32 (mp->ttl);
169 rv = vnet_lisp_map_register_set_ttl (mp->ttl);
171 REPLY_MACRO (VL_API_ONE_MAP_REGISTER_SET_TTL_REPLY);
175 vl_api_show_one_map_register_ttl_t_handler
176 (vl_api_show_one_map_register_ttl_t * mp)
178 vl_api_show_one_map_register_ttl_reply_t *rmp;
181 u32 ttl = vnet_lisp_map_register_get_ttl ();
183 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_TTL_REPLY,
185 rmp->ttl = clib_host_to_net_u32 (ttl);
191 vl_api_one_add_del_locator_set_t_handler (vl_api_one_add_del_locator_set_t *
194 vl_api_one_add_del_locator_set_reply_t *rmp;
196 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
198 vl_api_one_local_locator_t *ls_loc;
199 u32 ls_index = ~0, locator_num;
200 u8 *locator_name = NULL;
203 memset (a, 0, sizeof (a[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 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 memset (&locator, 0, sizeof (locator));
252 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 locator_name = format (0, "%s", mp->locator_set_name);
261 vec_terminate_c_string (locator_name);
263 a->name = locator_name;
264 a->locators = locators;
265 a->is_add = mp->is_add;
268 rv = vnet_lisp_add_del_locator (a, NULL, &ls_index);
271 vec_free (locator_name);
273 REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCATOR_REPLY);
280 } __attribute__ ((__packed__)) lisp_nsh_api_t;
283 unformat_one_eid_api (gid_address_t * dst, u32 vni, u8 type, void *src,
291 gid_address_type (dst) = GID_ADDR_IP_PREFIX;
292 gid_address_ip_set (dst, src, IP4);
293 gid_address_ippref_len (dst) = len;
294 ip_prefix_normalize (&gid_address_ippref (dst));
297 gid_address_type (dst) = GID_ADDR_IP_PREFIX;
298 gid_address_ip_set (dst, src, IP6);
299 gid_address_ippref_len (dst) = len;
300 ip_prefix_normalize (&gid_address_ippref (dst));
303 gid_address_type (dst) = GID_ADDR_MAC;
304 clib_memcpy (&gid_address_mac (dst), src, 6);
307 gid_address_type (dst) = GID_ADDR_NSH;
309 gid_address_nsh_spi (dst) = clib_net_to_host_u32 (nsh->spi);
310 gid_address_nsh_si (dst) = nsh->si;
314 return VNET_API_ERROR_INVALID_VALUE;
317 gid_address_vni (dst) = vni;
323 vl_api_one_add_del_local_eid_t_handler (vl_api_one_add_del_local_eid_t * mp)
325 vl_api_one_add_del_local_eid_reply_t *rmp;
326 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
328 gid_address_t _eid, *eid = &_eid;
330 u32 locator_set_index = ~0, map_index = ~0;
331 vnet_lisp_add_del_mapping_args_t _a, *a = &_a;
332 u8 *name = NULL, *key = NULL;
333 memset (a, 0, sizeof (a[0]));
334 memset (eid, 0, sizeof (eid[0]));
336 rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
337 mp->eid_type, mp->eid, mp->prefix_len);
341 if (gid_address_type (eid) == GID_ADDR_NSH)
343 rv = VNET_API_ERROR_INVALID_VALUE;
347 name = format (0, "%s", mp->locator_set_name);
348 vec_terminate_c_string (name);
349 p = hash_get_mem (lcm->locator_set_index_by_name, name);
352 rv = VNET_API_ERROR_INVALID_VALUE;
355 locator_set_index = p[0];
358 key = format (0, "%s", mp->key);
360 /* XXX treat batch configuration */
361 a->is_add = mp->is_add;
362 gid_address_copy (&a->eid, eid);
363 a->locator_set_index = locator_set_index;
366 a->key_id = clib_net_to_host_u16 (mp->key_id);
368 rv = vnet_lisp_add_del_local_mapping (a, &map_index);
373 gid_address_free (&a->eid);
375 REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCAL_EID_REPLY);
379 vl_api_one_eid_table_add_del_map_t_handler
380 (vl_api_one_eid_table_add_del_map_t * mp)
382 vl_api_one_eid_table_add_del_map_reply_t *rmp;
384 rv = vnet_lisp_eid_table_map (clib_net_to_host_u32 (mp->vni),
385 clib_net_to_host_u32 (mp->dp_table),
386 mp->is_l2, mp->is_add);
387 REPLY_MACRO (VL_API_ONE_EID_TABLE_ADD_DEL_MAP_REPLY)}
390 vl_api_one_add_del_map_server_t_handler (vl_api_one_add_del_map_server_t * mp)
392 vl_api_one_add_del_map_server_reply_t *rmp;
396 memset (&addr, 0, sizeof (addr));
398 ip_address_set (&addr, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
399 rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
401 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_SERVER_REPLY);
405 vl_api_one_add_del_map_resolver_t_handler (vl_api_one_add_del_map_resolver_t
408 vl_api_one_add_del_map_resolver_reply_t *rmp;
410 vnet_lisp_add_del_map_resolver_args_t _a, *a = &_a;
412 memset (a, 0, sizeof (a[0]));
414 a->is_add = mp->is_add;
415 ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
417 rv = vnet_lisp_add_del_map_resolver (a);
419 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_RESOLVER_REPLY);
423 vl_api_one_map_register_enable_disable_t_handler
424 (vl_api_one_map_register_enable_disable_t * mp)
426 vl_api_one_map_register_enable_disable_reply_t *rmp;
429 vnet_lisp_map_register_enable_disable (mp->is_enabled);
430 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
434 vl_api_one_rloc_probe_enable_disable_t_handler
435 (vl_api_one_rloc_probe_enable_disable_t * mp)
437 vl_api_one_rloc_probe_enable_disable_reply_t *rmp;
440 vnet_lisp_rloc_probe_enable_disable (mp->is_enabled);
441 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
445 vl_api_one_enable_disable_t_handler (vl_api_one_enable_disable_t * mp)
447 vl_api_one_enable_disable_reply_t *rmp;
450 vnet_lisp_enable_disable (mp->is_en);
451 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
455 vl_api_show_one_map_request_mode_t_handler
456 (vl_api_show_one_map_request_mode_t * mp)
459 vl_api_show_one_map_request_mode_reply_t *rmp;
462 REPLY_MACRO2(VL_API_SHOW_ONE_MAP_REQUEST_MODE_REPLY,
464 rmp->mode = vnet_lisp_get_map_request_mode ();
470 vl_api_one_map_request_mode_t_handler (vl_api_one_map_request_mode_t * mp)
472 vl_api_one_map_request_mode_reply_t *rmp;
475 rv = vnet_lisp_set_map_request_mode (mp->mode);
477 REPLY_MACRO (VL_API_ONE_MAP_REQUEST_MODE_REPLY);
481 vl_api_one_nsh_set_locator_set_t_handler (vl_api_one_nsh_set_locator_set_t
484 vl_api_one_nsh_set_locator_set_reply_t *rmp;
488 ls_name = format (0, "%s", mp->ls_name);
489 vec_terminate_c_string (ls_name);
490 rv = vnet_lisp_nsh_set_locator_set (ls_name, mp->is_add);
493 REPLY_MACRO (VL_API_ONE_PITR_SET_LOCATOR_SET_REPLY);
497 vl_api_one_pitr_set_locator_set_t_handler (vl_api_one_pitr_set_locator_set_t
500 vl_api_one_pitr_set_locator_set_reply_t *rmp;
504 ls_name = format (0, "%s", mp->ls_name);
505 vec_terminate_c_string (ls_name);
506 rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
509 REPLY_MACRO (VL_API_ONE_PITR_SET_LOCATOR_SET_REPLY);
513 vl_api_one_use_petr_t_handler (vl_api_one_use_petr_t * mp)
515 vl_api_one_use_petr_reply_t *rmp;
519 ip_address_set (&addr, &mp->address, mp->is_ip4 ? IP4 : IP6);
520 rv = vnet_lisp_use_petr (&addr, mp->is_add);
522 REPLY_MACRO (VL_API_ONE_USE_PETR_REPLY);
526 vl_api_show_one_use_petr_t_handler (vl_api_show_one_use_petr_t * mp)
528 unix_shared_memory_queue_t *q = NULL;
529 vl_api_show_one_use_petr_reply_t *rmp = NULL;
530 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
532 locator_set_t *ls = 0;
538 q = vl_api_client_index_to_input_queue (mp->client_index);
544 memset (&addr, 0, sizeof (addr));
545 status = lcm->flags & LISP_FLAG_USE_PETR;
548 m = pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index);
549 if (~0 != m->locator_set_index)
552 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
553 loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
554 gid_address_copy (&addr, &loc->address);
559 REPLY_MACRO2 (VL_API_SHOW_ONE_USE_PETR_REPLY,
561 rmp->status = status;
562 ip_address_t *ip = &gid_address_ip (&addr);
563 switch (ip_addr_version (ip))
566 clib_memcpy (rmp->address, &ip_addr_v4 (ip),
567 sizeof (ip_addr_v4 (ip)));
571 clib_memcpy (rmp->address, &ip_addr_v6 (ip),
572 sizeof (ip_addr_v6 (ip)));
578 rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4);
584 vl_api_one_add_del_map_request_itr_rlocs_t_handler
585 (vl_api_one_add_del_map_request_itr_rlocs_t * mp)
587 vl_api_one_add_del_map_request_itr_rlocs_reply_t *rmp;
589 u8 *locator_set_name = NULL;
590 vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
592 locator_set_name = format (0, "%s", mp->locator_set_name);
593 vec_terminate_c_string (locator_set_name);
595 a->is_add = mp->is_add;
596 a->locator_set_name = locator_set_name;
598 rv = vnet_lisp_add_del_mreq_itr_rlocs (a);
600 vec_free (locator_set_name);
602 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
606 vl_api_one_add_del_remote_mapping_t_handler
607 (vl_api_one_add_del_remote_mapping_t * mp)
609 locator_t *rlocs = 0;
610 vl_api_one_add_del_remote_mapping_reply_t *rmp;
612 gid_address_t _eid, *eid = &_eid;
613 u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num);
615 memset (eid, 0, sizeof (eid[0]));
617 rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
618 mp->eid_type, mp->eid, mp->eid_len);
622 rlocs = unformat_one_locs (mp->rlocs, rloc_num);
626 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
627 gid_address_copy (&a->reid, eid);
629 rv = vnet_lisp_add_del_adjacency (a);
636 /* NOTE: for now this works as a static remote mapping, i.e.,
637 * not authoritative and ttl infinite. */
640 vnet_lisp_add_del_mapping_args_t _m_args, *m_args = &_m_args;
641 memset (m_args, 0, sizeof (m_args[0]));
642 gid_address_copy (&m_args->eid, eid);
643 m_args->action = mp->action;
644 m_args->is_static = 1;
646 m_args->authoritative = 0;
647 rv = vnet_lisp_add_mapping (m_args, rlocs, NULL, NULL);
650 rv = vnet_lisp_del_mapping (eid, NULL);
653 vnet_lisp_clear_all_remote_adjacencies ();
658 REPLY_MACRO (VL_API_ONE_ADD_DEL_REMOTE_MAPPING_REPLY);
662 vl_api_one_add_del_adjacency_t_handler (vl_api_one_add_del_adjacency_t * mp)
664 vl_api_one_add_del_adjacency_reply_t *rmp;
665 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
668 memset (a, 0, sizeof (a[0]));
670 rv = unformat_one_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni),
671 mp->eid_type, mp->leid, mp->leid_len);
672 rv |= unformat_one_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni),
673 mp->eid_type, mp->reid, mp->reid_len);
678 a->is_add = mp->is_add;
679 rv = vnet_lisp_add_del_adjacency (a);
682 REPLY_MACRO (VL_API_ONE_ADD_DEL_ADJACENCY_REPLY);
686 send_one_locator_details (lisp_cp_main_t * lcm,
688 unix_shared_memory_queue_t * q, u32 context)
690 vl_api_one_locator_details_t *rmp;
692 rmp = vl_msg_api_alloc (sizeof (*rmp));
693 memset (rmp, 0, sizeof (*rmp));
694 rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_DETAILS);
695 rmp->context = context;
697 rmp->local = loc->local;
700 rmp->sw_if_index = ntohl (loc->sw_if_index);
704 rmp->is_ipv6 = gid_address_ip_version (&loc->address);
705 ip_address_copy_addr (rmp->ip_address, &gid_address_ip (&loc->address));
707 rmp->priority = loc->priority;
708 rmp->weight = loc->weight;
710 vl_msg_api_send_shmem (q, (u8 *) & rmp);
714 vl_api_one_locator_dump_t_handler (vl_api_one_locator_dump_t * mp)
717 unix_shared_memory_queue_t *q = 0;
718 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
719 locator_set_t *lsit = 0;
721 u32 ls_index = ~0, *locit = 0;
724 q = vl_api_client_index_to_input_queue (mp->client_index);
730 if (mp->is_index_set)
731 ls_index = htonl (mp->ls_index);
734 /* make sure we get a proper C-string */
735 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
736 ls_name = format (0, "%s", mp->ls_name);
737 vec_terminate_c_string (ls_name);
738 p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
744 if (pool_is_free_index (lcm->locator_set_pool, ls_index))
747 lsit = pool_elt_at_index (lcm->locator_set_pool, ls_index);
749 vec_foreach (locit, lsit->locator_indices)
751 loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
752 send_one_locator_details (lcm, loc, q, mp->context);
759 send_one_locator_set_details (lisp_cp_main_t * lcm,
760 locator_set_t * lsit,
761 unix_shared_memory_queue_t * q,
762 u32 context, u32 ls_index)
764 vl_api_one_locator_set_details_t *rmp;
767 rmp = vl_msg_api_alloc (sizeof (*rmp));
768 memset (rmp, 0, sizeof (*rmp));
769 rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_SET_DETAILS);
770 rmp->context = context;
772 rmp->ls_index = htonl (ls_index);
775 ASSERT (lsit->name != NULL);
776 strncpy ((char *) rmp->ls_name, (char *) lsit->name,
777 vec_len (lsit->name));
781 str = format (0, "<remote-%d>", ls_index);
782 strncpy ((char *) rmp->ls_name, (char *) str, vec_len (str));
786 vl_msg_api_send_shmem (q, (u8 *) & rmp);
790 vl_api_one_locator_set_dump_t_handler (vl_api_one_locator_set_dump_t * mp)
792 unix_shared_memory_queue_t *q = NULL;
793 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
794 locator_set_t *lsit = NULL;
797 q = vl_api_client_index_to_input_queue (mp->client_index);
805 pool_foreach (lsit, lcm->locator_set_pool,
807 if (filter && !((1 == filter && lsit->local) ||
808 (2 == filter && !lsit->local)))
812 send_one_locator_set_details (lcm, lsit, q, mp->context,
813 lsit - lcm->locator_set_pool);
819 one_fid_put_api (u8 * dst, fid_address_t * src, u8 * prefix_length)
821 ASSERT (prefix_length);
822 ip_prefix_t *ippref = &fid_addr_ippref (src);
824 switch (fid_addr_type (src))
826 case FID_ADDR_IP_PREF:
827 if (ip_prefix_version (ippref) == IP4)
828 clib_memcpy (dst, &ip_prefix_v4 (ippref), 4);
830 clib_memcpy (dst, &ip_prefix_v6 (ippref), 16);
831 prefix_length[0] = ip_prefix_len (ippref);
835 prefix_length[0] = 0;
836 clib_memcpy (dst, fid_addr_mac (src), 6);
840 clib_warning ("Unknown FID type %d!", fid_addr_type (src));
846 fid_type_to_api_type (fid_address_t * fid)
850 switch (fid_addr_type (fid))
852 case FID_ADDR_IP_PREF:
853 ippref = &fid_addr_ippref (fid);
854 if (ip_prefix_version (ippref) == IP4)
856 else if (ip_prefix_version (ippref) == IP6)
871 send_one_eid_table_details (mapping_t * mapit,
872 unix_shared_memory_queue_t * q,
873 u32 context, u8 filter)
876 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
877 locator_set_t *ls = 0;
878 vl_api_one_eid_table_details_t *rmp = NULL;
879 gid_address_t *gid = NULL;
881 ip_prefix_t *ip_prefix = NULL;
883 if (mapit->pitr_set || mapit->nsh_set)
888 case 0: /* all mappings */
891 case 1: /* local only */
895 case 2: /* remote only */
900 clib_warning ("Filter error, unknown filter: %d", filter);
905 ip_prefix = &gid_address_ippref (gid);
906 mac = gid_address_mac (gid);
908 rmp = vl_msg_api_alloc (sizeof (*rmp));
909 memset (rmp, 0, sizeof (*rmp));
910 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_DETAILS);
912 ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index);
913 if (vec_len (ls->locator_indices) == 0)
914 rmp->locator_set_index = ~0;
916 rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index);
918 rmp->is_local = mapit->local;
919 rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
920 rmp->action = mapit->action;
921 rmp->authoritative = mapit->authoritative;
923 switch (gid_address_type (gid))
925 case GID_ADDR_SRC_DST:
927 fid = &gid_address_sd_src (gid);
928 rmp->eid_type = fid_type_to_api_type (fid);
929 one_fid_put_api (rmp->seid, &gid_address_sd_src (gid),
930 &rmp->seid_prefix_len);
931 one_fid_put_api (rmp->eid, &gid_address_sd_dst (gid),
932 &rmp->eid_prefix_len);
934 case GID_ADDR_IP_PREFIX:
935 rmp->eid_prefix_len = ip_prefix_len (ip_prefix);
936 if (ip_prefix_version (ip_prefix) == IP4)
938 rmp->eid_type = 0; /* ipv4 type */
939 clib_memcpy (rmp->eid, &ip_prefix_v4 (ip_prefix),
940 sizeof (ip_prefix_v4 (ip_prefix)));
944 rmp->eid_type = 1; /* ipv6 type */
945 clib_memcpy (rmp->eid, &ip_prefix_v6 (ip_prefix),
946 sizeof (ip_prefix_v6 (ip_prefix)));
950 rmp->eid_type = 2; /* l2 mac type */
951 clib_memcpy (rmp->eid, mac, 6);
954 rmp->eid_type = 3; /* NSH type */
956 nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (gid));
957 nsh.si = gid_address_nsh_si (gid);
958 clib_memcpy (rmp->eid, &nsh, sizeof (nsh));
963 rmp->context = context;
964 rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
965 rmp->key_id = clib_host_to_net_u16 (mapit->key_id);
966 memcpy (rmp->key, mapit->key, vec_len (mapit->key));
967 vl_msg_api_send_shmem (q, (u8 *) & rmp);
971 vl_api_one_eid_table_dump_t_handler (vl_api_one_eid_table_dump_t * mp)
974 unix_shared_memory_queue_t *q = NULL;
975 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
976 mapping_t *mapit = NULL;
977 gid_address_t _eid, *eid = &_eid;
979 q = vl_api_client_index_to_input_queue (mp->client_index);
987 memset (eid, 0, sizeof (*eid));
989 unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
990 mp->eid_type, mp->eid, mp->prefix_length);
992 mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
996 mapit = pool_elt_at_index (lcm->mapping_pool, mi);
997 send_one_eid_table_details (mapit, q, mp->context,
998 0 /* ignore filter */ );
1003 pool_foreach (mapit, lcm->mapping_pool,
1005 send_one_eid_table_details(mapit, q, mp->context,
1013 send_one_map_server_details (ip_address_t * ip,
1014 unix_shared_memory_queue_t * q, u32 context)
1016 vl_api_one_map_server_details_t *rmp = NULL;
1018 rmp = vl_msg_api_alloc (sizeof (*rmp));
1019 memset (rmp, 0, sizeof (*rmp));
1020 rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_SERVER_DETAILS);
1022 switch (ip_addr_version (ip))
1026 clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
1027 sizeof (ip_addr_v4 (ip)));
1032 clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
1033 sizeof (ip_addr_v6 (ip)));
1039 rmp->context = context;
1041 vl_msg_api_send_shmem (q, (u8 *) & rmp);
1045 vl_api_one_map_server_dump_t_handler (vl_api_one_map_server_dump_t * mp)
1047 unix_shared_memory_queue_t *q = NULL;
1048 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1051 q = vl_api_client_index_to_input_queue (mp->client_index);
1057 vec_foreach (mr, lcm->map_servers)
1059 send_one_map_server_details (&mr->address, q, mp->context);
1064 send_one_map_resolver_details (ip_address_t * ip,
1065 unix_shared_memory_queue_t * q, u32 context)
1067 vl_api_one_map_resolver_details_t *rmp = NULL;
1069 rmp = vl_msg_api_alloc (sizeof (*rmp));
1070 memset (rmp, 0, sizeof (*rmp));
1071 rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_RESOLVER_DETAILS);
1073 switch (ip_addr_version (ip))
1077 clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
1078 sizeof (ip_addr_v4 (ip)));
1083 clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
1084 sizeof (ip_addr_v6 (ip)));
1090 rmp->context = context;
1092 vl_msg_api_send_shmem (q, (u8 *) & rmp);
1096 vl_api_one_map_resolver_dump_t_handler (vl_api_one_map_resolver_dump_t * mp)
1098 unix_shared_memory_queue_t *q = NULL;
1099 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1102 q = vl_api_client_index_to_input_queue (mp->client_index);
1108 vec_foreach (mr, lcm->map_resolvers)
1110 send_one_map_resolver_details (&mr->address, q, mp->context);
1115 send_eid_table_map_pair (hash_pair_t * p,
1116 unix_shared_memory_queue_t * q, u32 context)
1118 vl_api_one_eid_table_map_details_t *rmp = NULL;
1120 rmp = vl_msg_api_alloc (sizeof (*rmp));
1121 memset (rmp, 0, sizeof (*rmp));
1122 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_MAP_DETAILS);
1124 rmp->vni = clib_host_to_net_u32 (p->key);
1125 rmp->dp_table = clib_host_to_net_u32 (p->value[0]);
1126 rmp->context = context;
1127 vl_msg_api_send_shmem (q, (u8 *) & rmp);
1131 vl_api_one_eid_table_map_dump_t_handler (vl_api_one_eid_table_map_dump_t * mp)
1133 unix_shared_memory_queue_t *q = NULL;
1134 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1136 uword *vni_table = 0;
1138 q = vl_api_client_index_to_input_queue (mp->client_index);
1146 vni_table = lcm->bd_id_by_vni;
1150 vni_table = lcm->table_id_by_vni;
1154 hash_foreach_pair (p, vni_table,
1156 send_eid_table_map_pair (p, q, mp->context);
1162 send_eid_table_vni (u32 vni, unix_shared_memory_queue_t * q, u32 context)
1164 vl_api_one_eid_table_vni_details_t *rmp = 0;
1166 rmp = vl_msg_api_alloc (sizeof (*rmp));
1167 memset (rmp, 0, sizeof (*rmp));
1168 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_VNI_DETAILS);
1169 rmp->context = context;
1170 rmp->vni = clib_host_to_net_u32 (vni);
1171 vl_msg_api_send_shmem (q, (u8 *) & rmp);
1175 one_adjacency_copy (vl_api_one_adjacency_t * dst, lisp_adjacency_t * adjs)
1177 lisp_adjacency_t *adj;
1178 vl_api_one_adjacency_t a;
1179 u32 i, n = vec_len (adjs);
1182 for (i = 0; i < n; i++)
1184 adj = vec_elt_at_index (adjs, i);
1185 memset (&a, 0, sizeof (a));
1187 switch (gid_address_type (&adj->reid))
1189 case GID_ADDR_IP_PREFIX:
1190 a.reid_prefix_len = gid_address_ippref_len (&adj->reid);
1191 a.leid_prefix_len = gid_address_ippref_len (&adj->leid);
1192 if (gid_address_ip_version (&adj->reid) == IP4)
1194 a.eid_type = 0; /* ipv4 type */
1195 clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 4);
1196 clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 4);
1200 a.eid_type = 1; /* ipv6 type */
1201 clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 16);
1202 clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 16);
1206 a.eid_type = 2; /* l2 mac type */
1207 mac_copy (a.reid, gid_address_mac (&adj->reid));
1208 mac_copy (a.leid, gid_address_mac (&adj->leid));
1211 a.eid_type = 3; /* NSH type */
1212 nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (&adj->reid));
1213 nsh.si = gid_address_nsh_si (&adj->reid);
1214 clib_memcpy (a.reid, &nsh, sizeof (nsh));
1216 nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (&adj->leid));
1217 nsh.si = gid_address_nsh_si (&adj->leid);
1218 clib_memcpy (a.leid, &nsh, sizeof (nsh));
1228 vl_api_show_one_rloc_probe_state_t_handler
1229 (vl_api_show_one_rloc_probe_state_t * mp)
1231 vl_api_show_one_rloc_probe_state_reply_t *rmp = 0;
1235 REPLY_MACRO2 (VL_API_SHOW_ONE_RLOC_PROBE_STATE_REPLY,
1237 rmp->is_enabled = vnet_lisp_rloc_probe_state_get ();
1243 vl_api_show_one_map_register_state_t_handler
1244 (vl_api_show_one_map_register_state_t * mp)
1246 vl_api_show_one_map_register_state_reply_t *rmp = 0;
1250 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_STATE_REPLY,
1252 rmp->is_enabled = vnet_lisp_map_register_state_get ();
1258 vl_api_one_adjacencies_get_t_handler (vl_api_one_adjacencies_get_t * mp)
1260 vl_api_one_adjacencies_get_reply_t *rmp = 0;
1261 lisp_adjacency_t *adjs = 0;
1264 u32 vni = clib_net_to_host_u32 (mp->vni);
1266 adjs = vnet_lisp_adjacencies_get_by_vni (vni);
1267 size = vec_len (adjs) * sizeof (vl_api_one_adjacency_t);
1270 REPLY_MACRO4 (VL_API_ONE_ADJACENCIES_GET_REPLY, size,
1272 rmp->count = clib_host_to_net_u32 (vec_len (adjs));
1273 one_adjacency_copy (rmp->adjacencies, adjs);
1281 vl_api_one_eid_table_vni_dump_t_handler (vl_api_one_eid_table_vni_dump_t * mp)
1285 unix_shared_memory_queue_t *q = 0;
1286 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1288 q = vl_api_client_index_to_input_queue (mp->client_index);
1295 hash_foreach_pair (p, lcm->table_id_by_vni,
1297 hash_set (vnis, p->key, 0);
1300 hash_foreach_pair (p, lcm->bd_id_by_vni,
1302 hash_set (vnis, p->key, 0);
1305 hash_foreach_pair (p, vnis,
1307 send_eid_table_vni (p->key, q, mp->context);
1315 vl_api_show_one_status_t_handler (vl_api_show_one_status_t * mp)
1317 unix_shared_memory_queue_t *q = NULL;
1318 vl_api_show_one_status_reply_t *rmp = NULL;
1321 q = vl_api_client_index_to_input_queue (mp->client_index);
1328 REPLY_MACRO2(VL_API_SHOW_ONE_STATUS_REPLY,
1330 rmp->gpe_status = vnet_lisp_gpe_enable_disable_status ();
1331 rmp->feature_status = vnet_lisp_enable_disable_status ();
1337 vl_api_one_get_map_request_itr_rlocs_t_handler
1338 (vl_api_one_get_map_request_itr_rlocs_t * mp)
1340 unix_shared_memory_queue_t *q = NULL;
1341 vl_api_one_get_map_request_itr_rlocs_reply_t *rmp = NULL;
1342 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1343 locator_set_t *loc_set = 0;
1347 q = vl_api_client_index_to_input_queue (mp->client_index);
1353 if (~0 == lcm->mreq_itr_rlocs)
1355 tmp_str = format (0, " ");
1360 pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
1361 tmp_str = format (0, "%s", loc_set->name);
1365 REPLY_MACRO2(VL_API_ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY,
1367 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1368 ARRAY_LEN(rmp->locator_set_name) - 1);
1376 vl_api_show_one_nsh_mapping_t_handler (vl_api_show_one_nsh_mapping_t * mp)
1378 unix_shared_memory_queue_t *q = NULL;
1379 vl_api_show_one_nsh_mapping_reply_t *rmp = NULL;
1380 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1382 locator_set_t *ls = 0;
1387 q = vl_api_client_index_to_input_queue (mp->client_index);
1393 if (lcm->nsh_map_index == (u32) ~ 0)
1395 tmp_str = format (0, "N/A");
1399 m = pool_elt_at_index (lcm->mapping_pool, lcm->nsh_map_index);
1400 if (~0 != m->locator_set_index)
1403 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1404 tmp_str = format (0, "%s", ls->name);
1409 tmp_str = format (0, "N/A");
1412 vec_add1 (tmp_str, 0);
1415 REPLY_MACRO2(VL_API_SHOW_ONE_NSH_MAPPING_REPLY,
1417 rmp->is_set = is_set;
1418 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1419 ARRAY_LEN(rmp->locator_set_name) - 1);
1425 vl_api_show_one_pitr_t_handler (vl_api_show_one_pitr_t * mp)
1427 unix_shared_memory_queue_t *q = NULL;
1428 vl_api_show_one_pitr_reply_t *rmp = NULL;
1429 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1431 locator_set_t *ls = 0;
1435 q = vl_api_client_index_to_input_queue (mp->client_index);
1441 if (!lcm->lisp_pitr)
1443 tmp_str = format (0, "N/A");
1447 m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index);
1448 if (~0 != m->locator_set_index)
1451 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1452 tmp_str = format (0, "%s", ls->name);
1456 tmp_str = format (0, "N/A");
1459 vec_add1 (tmp_str, 0);
1462 REPLY_MACRO2(VL_API_SHOW_ONE_PITR_REPLY,
1464 rmp->status = lcm->lisp_pitr;
1465 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1466 ARRAY_LEN(rmp->locator_set_name) - 1);
1472 vl_api_show_one_stats_enable_disable_t_handler
1473 (vl_api_show_one_stats_enable_disable_t * mp)
1475 vl_api_show_one_stats_enable_disable_reply_t *rmp = NULL;
1476 vnet_api_error_t rv = 0;
1479 REPLY_MACRO2 (VL_API_SHOW_ONE_STATS_ENABLE_DISABLE_REPLY,
1481 rmp->is_en = vnet_lisp_stats_enable_disable_state ();
1487 vl_api_one_stats_enable_disable_t_handler
1488 (vl_api_one_stats_enable_disable_t * mp)
1490 vl_api_one_enable_disable_reply_t *rmp = NULL;
1492 vnet_api_error_t rv = vnet_lisp_stats_enable_disable (mp->is_en);
1493 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
1497 lisp_fid_addr_to_api (fid_address_t * fid, u8 * dst, u8 * api_eid_type,
1500 switch (fid_addr_type (fid))
1502 case FID_ADDR_IP_PREF:
1503 *prefix_length = fid_addr_prefix_length (fid);
1504 if (fid_addr_ip_version (fid) == IP4)
1506 *api_eid_type = 0; /* ipv4 type */
1507 clib_memcpy (dst, &fid_addr_ippref (fid), 4);
1511 *api_eid_type = 1; /* ipv6 type */
1512 clib_memcpy (dst, &fid_addr_ippref (fid), 16);
1516 *api_eid_type = 2; /* l2 mac type */
1517 mac_copy (dst, fid_addr_mac (fid));
1525 vl_api_one_stats_flush_t_handler (vl_api_one_stats_flush_t * mp)
1527 vl_api_one_stats_flush_reply_t *rmp;
1530 rv = vnet_lisp_flush_stats ();
1531 REPLY_MACRO (VL_API_ONE_STATS_FLUSH_REPLY);
1535 vl_api_one_stats_dump_t_handler (vl_api_one_stats_dump_t * mp)
1537 vl_api_one_stats_details_t *rmp;
1538 lisp_api_stats_t *stats, *stat;
1541 stats = vnet_lisp_get_stats ();
1542 vec_foreach (stat, stats)
1545 REPLY_DETAILS (VL_API_ONE_STATS_DETAILS,
1547 lisp_fid_addr_to_api (&stat->deid, rmp->deid, &rmp->eid_type,
1548 &rmp->deid_pref_len);
1549 lisp_fid_addr_to_api (&stat->seid, rmp->seid, &rmp->eid_type,
1550 &rmp->seid_pref_len);
1551 rmp->vni = clib_host_to_net_u32 (stat->vni);
1553 rmp->is_ip4 = ip_addr_version (&stat->rmt_rloc) == IP4 ? 1 : 0;
1554 ip_address_copy_addr (rmp->rloc, &stat->rmt_rloc);
1555 ip_address_copy_addr (rmp->lloc, &stat->loc_rloc);
1557 rmp->pkt_count = clib_host_to_net_u32 (stat->counters.packets);
1558 rmp->bytes = clib_host_to_net_u32 (stat->counters.bytes);
1565 vl_api_one_add_del_l2_arp_entry_t_handler
1566 (vl_api_one_add_del_l2_arp_entry_t * mp)
1568 vl_api_one_add_del_l2_arp_entry_reply_t *rmp;
1570 gid_address_t _arp, *arp = &_arp;
1571 memset (arp, 0, sizeof (*arp));
1573 gid_address_type (arp) = GID_ADDR_ARP;
1574 gid_address_arp_bd (arp) = clib_net_to_host_u32 (mp->bd);
1576 /* vpp keeps ip4 addresses in network byte order */
1577 ip_address_set (&gid_address_arp_ndp_ip (arp), &mp->ip4, IP4);
1579 rv = vnet_lisp_add_del_l2_arp_ndp_entry (arp, mp->mac, mp->is_add);
1581 REPLY_MACRO (VL_API_ONE_ADD_DEL_L2_ARP_ENTRY_REPLY);
1585 vl_api_one_add_del_ndp_entry_t_handler (vl_api_one_add_del_ndp_entry_t * mp)
1587 vl_api_one_add_del_ndp_entry_reply_t *rmp;
1589 gid_address_t _g, *g = &_g;
1590 memset (g, 0, sizeof (*g));
1592 gid_address_type (g) = GID_ADDR_NDP;
1593 gid_address_ndp_bd (g) = clib_net_to_host_u32 (mp->bd);
1594 ip_address_set (&gid_address_arp_ndp_ip (g), mp->ip6, IP6);
1596 rv = vnet_lisp_add_del_l2_arp_ndp_entry (g, mp->mac, mp->is_add);
1598 REPLY_MACRO (VL_API_ONE_ADD_DEL_NDP_ENTRY_REPLY);
1602 vl_api_one_ndp_bd_get_t_handler (vl_api_one_ndp_bd_get_t * mp)
1604 vl_api_one_ndp_bd_get_reply_t *rmp;
1609 u32 *bds = vnet_lisp_ndp_bds_get ();
1610 u32 size = hash_elts (bds) * sizeof (u32);
1613 REPLY_MACRO4 (VL_API_ONE_NDP_BD_GET_REPLY, size,
1615 rmp->count = clib_host_to_net_u32 (hash_elts (bds));
1616 hash_foreach_pair (p, bds,
1618 rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
1627 vl_api_one_l2_arp_bd_get_t_handler (vl_api_one_l2_arp_bd_get_t * mp)
1629 vl_api_one_l2_arp_bd_get_reply_t *rmp;
1634 u32 *bds = vnet_lisp_l2_arp_bds_get ();
1635 u32 size = hash_elts (bds) * sizeof (u32);
1638 REPLY_MACRO4 (VL_API_ONE_L2_ARP_BD_GET_REPLY, size,
1640 rmp->count = clib_host_to_net_u32 (hash_elts (bds));
1641 hash_foreach_pair (p, bds,
1643 rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
1652 vl_api_one_l2_arp_entries_get_t_handler (vl_api_one_l2_arp_entries_get_t * mp)
1654 vl_api_one_l2_arp_entries_get_reply_t *rmp;
1655 lisp_api_l2_arp_entry_t *entries = 0, *e;
1659 u32 bd = clib_net_to_host_u32 (mp->bd);
1661 entries = vnet_lisp_l2_arp_entries_get_by_bd (bd);
1662 u32 size = vec_len (entries) * sizeof (vl_api_one_l2_arp_entry_t);
1665 REPLY_MACRO4 (VL_API_ONE_L2_ARP_ENTRIES_GET_REPLY, size,
1667 rmp->count = clib_host_to_net_u32 (vec_len (entries));
1668 vec_foreach (e, entries)
1670 mac_copy (rmp->entries[i].mac, e->mac);
1671 rmp->entries[i].ip4 = e->ip4;
1681 vl_api_one_map_register_fallback_threshold_t_handler
1682 (vl_api_one_map_register_fallback_threshold_t * mp)
1684 vl_api_one_map_register_fallback_threshold_reply_t *rmp;
1687 mp->value = clib_net_to_host_u32 (mp->value);
1688 rv = vnet_lisp_map_register_fallback_threshold_set (mp->value);
1689 REPLY_MACRO (VL_API_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY);
1693 vl_api_show_one_map_register_fallback_threshold_t_handler
1694 (vl_api_show_one_map_register_fallback_threshold_t * mp)
1696 vl_api_show_one_map_register_fallback_threshold_reply_t *rmp;
1699 u32 value = vnet_lisp_map_register_fallback_threshold_get ();
1702 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY,
1704 rmp->value = clib_host_to_net_u32 (value);
1710 vl_api_one_set_transport_protocol_t_handler
1711 (vl_api_one_set_transport_protocol_t * mp)
1713 vl_api_one_set_transport_protocol_reply_t *rmp;
1716 rv = vnet_lisp_set_transport_protocol (mp->protocol);
1718 REPLY_MACRO (VL_API_ONE_SET_TRANSPORT_PROTOCOL_REPLY);
1722 vl_api_one_get_transport_protocol_t_handler
1723 (vl_api_one_get_transport_protocol_t * mp)
1725 vl_api_one_get_transport_protocol_reply_t *rmp;
1727 u8 proto = (u8) vnet_lisp_get_transport_protocol ();
1730 REPLY_MACRO2 (VL_API_ONE_GET_TRANSPORT_PROTOCOL_REPLY,
1732 rmp->protocol = proto;
1738 vl_api_one_ndp_entries_get_t_handler (vl_api_one_ndp_entries_get_t * mp)
1740 vl_api_one_ndp_entries_get_reply_t *rmp = 0;
1741 lisp_api_ndp_entry_t *entries = 0, *e;
1745 u32 bd = clib_net_to_host_u32 (mp->bd);
1747 entries = vnet_lisp_ndp_entries_get_by_bd (bd);
1748 u32 size = vec_len (entries) * sizeof (vl_api_one_ndp_entry_t);
1751 REPLY_MACRO4 (VL_API_ONE_NDP_ENTRIES_GET_REPLY, size,
1753 rmp->count = clib_host_to_net_u32 (vec_len (entries));
1754 vec_foreach (e, entries)
1756 mac_copy (rmp->entries[i].mac, e->mac);
1757 clib_memcpy (rmp->entries[i].ip6, e->ip6, 16);
1768 * Add vpe's API message handlers to the table.
1769 * vlib has alread mapped shared memory and
1770 * added the client registration handlers.
1771 * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1773 #define vl_msg_name_crc_list
1774 #include <vnet/vnet_all_api_h.h>
1775 #undef vl_msg_name_crc_list
1778 setup_message_id_table (api_main_t * am)
1780 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1781 foreach_vl_msg_name_crc_one;
1785 static clib_error_t *
1786 one_api_hookup (vlib_main_t * vm)
1788 api_main_t *am = &api_main;
1791 vl_msg_api_set_handlers(VL_API_##N, #n, \
1792 vl_api_##n##_t_handler, \
1794 vl_api_##n##_t_endian, \
1795 vl_api_##n##_t_print, \
1796 sizeof(vl_api_##n##_t), 1);
1797 foreach_vpe_api_msg;
1801 * Set up the (msg_name, crc, message-id) table
1803 setup_message_id_table (am);
1808 VLIB_API_INIT_FUNCTION (one_api_hookup);
1811 * fd.io coding-style-patch-verification: ON
1814 * eval: (c-set-style "gnu")