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_typedefs /* define message structures */
51 #include <vnet/vnet_all_api_h.h>
54 #define vl_endianfun /* define message structures */
55 #include <vnet/vnet_all_api_h.h>
58 /* instantiate all the print functions we know about */
59 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
61 #include <vnet/vnet_all_api_h.h>
64 #include <vlibapi/api_helper_macros.h>
66 #define REPLY_DETAILS(t, body) \
68 unix_shared_memory_queue_t * q; \
69 rv = vl_msg_api_pd_handler (mp, rv); \
70 q = vl_api_client_index_to_input_queue (mp->client_index); \
74 rmp = vl_msg_api_alloc (sizeof (*rmp)); \
75 rmp->_vl_msg_id = ntohs((t)); \
76 rmp->context = mp->context; \
77 do {body;} while (0); \
78 vl_msg_api_send_shmem (q, (u8 *)&rmp); \
81 #define foreach_vpe_api_msg \
82 _(ONE_ADD_DEL_LOCATOR_SET, one_add_del_locator_set) \
83 _(ONE_ADD_DEL_LOCATOR, one_add_del_locator) \
84 _(ONE_ADD_DEL_LOCAL_EID, one_add_del_local_eid) \
85 _(ONE_ADD_DEL_MAP_RESOLVER, one_add_del_map_resolver) \
86 _(ONE_ADD_DEL_MAP_SERVER, one_add_del_map_server) \
87 _(ONE_ENABLE_DISABLE, one_enable_disable) \
88 _(ONE_RLOC_PROBE_ENABLE_DISABLE, one_rloc_probe_enable_disable) \
89 _(ONE_MAP_REGISTER_ENABLE_DISABLE, one_map_register_enable_disable) \
90 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD, \
91 one_map_register_fallback_threshold) \
92 _(ONE_ADD_DEL_REMOTE_MAPPING, one_add_del_remote_mapping) \
93 _(ONE_ADD_DEL_ADJACENCY, one_add_del_adjacency) \
94 _(ONE_PITR_SET_LOCATOR_SET, one_pitr_set_locator_set) \
95 _(ONE_NSH_SET_LOCATOR_SET, one_nsh_set_locator_set) \
96 _(ONE_MAP_REQUEST_MODE, one_map_request_mode) \
97 _(ONE_EID_TABLE_ADD_DEL_MAP, one_eid_table_add_del_map) \
98 _(ONE_LOCATOR_SET_DUMP, one_locator_set_dump) \
99 _(ONE_LOCATOR_DUMP, one_locator_dump) \
100 _(ONE_EID_TABLE_DUMP, one_eid_table_dump) \
101 _(ONE_MAP_RESOLVER_DUMP, one_map_resolver_dump) \
102 _(ONE_MAP_SERVER_DUMP, one_map_server_dump) \
103 _(ONE_EID_TABLE_MAP_DUMP, one_eid_table_map_dump) \
104 _(ONE_EID_TABLE_VNI_DUMP, one_eid_table_vni_dump) \
105 _(ONE_ADJACENCIES_GET, one_adjacencies_get) \
106 _(ONE_MAP_REGISTER_SET_TTL, one_map_register_set_ttl) \
107 _(SHOW_ONE_NSH_MAPPING, show_one_nsh_mapping) \
108 _(SHOW_ONE_RLOC_PROBE_STATE, show_one_rloc_probe_state) \
109 _(SHOW_ONE_MAP_REGISTER_STATE, show_one_map_register_state) \
110 _(SHOW_ONE_MAP_REGISTER_TTL, show_one_map_register_ttl) \
111 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, \
112 show_one_map_register_fallback_threshold) \
113 _(SHOW_ONE_STATUS, show_one_status) \
114 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \
115 one_add_del_map_request_itr_rlocs) \
116 _(ONE_GET_MAP_REQUEST_ITR_RLOCS, one_get_map_request_itr_rlocs) \
117 _(SHOW_ONE_PITR, show_one_pitr) \
118 _(SHOW_ONE_MAP_REQUEST_MODE, show_one_map_request_mode) \
119 _(ONE_USE_PETR, one_use_petr) \
120 _(SHOW_ONE_USE_PETR, show_one_use_petr) \
121 _(SHOW_ONE_STATS_ENABLE_DISABLE, show_one_stats_enable_disable) \
122 _(ONE_STATS_ENABLE_DISABLE, one_stats_enable_disable) \
123 _(ONE_STATS_DUMP, one_stats_dump) \
124 _(ONE_STATS_FLUSH, one_stats_flush) \
125 _(ONE_L2_ARP_BD_GET, one_l2_arp_bd_get) \
126 _(ONE_L2_ARP_ENTRIES_GET, one_l2_arp_entries_get) \
127 _(ONE_ADD_DEL_L2_ARP_ENTRY, one_add_del_l2_arp_entry) \
131 unformat_one_locs (vl_api_one_remote_locator_t * rmt_locs, u32 rloc_num)
134 locator_t *locs = 0, loc;
135 vl_api_one_remote_locator_t *r;
137 for (i = 0; i < rloc_num; i++)
139 /* remote locators */
141 memset (&loc, 0, sizeof (loc));
142 gid_address_ip_set (&loc.address, &r->addr, r->is_ip4 ? IP4 : IP6);
144 loc.priority = r->priority;
145 loc.weight = r->weight;
147 vec_add1 (locs, loc);
153 vl_api_one_map_register_set_ttl_t_handler (vl_api_one_map_register_set_ttl_t *
156 vl_api_one_map_register_set_ttl_reply_t *rmp;
159 mp->ttl = clib_net_to_host_u32 (mp->ttl);
160 rv = vnet_lisp_map_register_set_ttl (mp->ttl);
162 REPLY_MACRO (VL_API_ONE_MAP_REGISTER_SET_TTL_REPLY);
166 vl_api_show_one_map_register_ttl_t_handler
167 (vl_api_show_one_map_register_ttl_t * mp)
169 vl_api_show_one_map_register_ttl_reply_t *rmp;
172 u32 ttl = vnet_lisp_map_register_get_ttl ();
174 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_TTL_REPLY,
176 rmp->ttl = clib_host_to_net_u32 (ttl);
182 vl_api_one_add_del_locator_set_t_handler (vl_api_one_add_del_locator_set_t *
185 vl_api_one_add_del_locator_set_reply_t *rmp;
187 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
189 vl_api_one_local_locator_t *ls_loc;
190 u32 ls_index = ~0, locator_num;
191 u8 *locator_name = NULL;
194 memset (a, 0, sizeof (a[0]));
196 locator_name = format (0, "%s", mp->locator_set_name);
198 a->name = locator_name;
199 a->is_add = mp->is_add;
201 locator_num = clib_net_to_host_u32 (mp->locator_num);
203 memset (&locator, 0, sizeof (locator));
204 for (i = 0; i < locator_num; i++)
206 ls_loc = &mp->locators[i];
207 VALIDATE_SW_IF_INDEX (ls_loc);
209 locator.sw_if_index = htonl (ls_loc->sw_if_index);
210 locator.priority = ls_loc->priority;
211 locator.weight = ls_loc->weight;
213 vec_add1 (a->locators, locator);
216 rv = vnet_lisp_add_del_locator_set (a, &ls_index);
218 BAD_SW_IF_INDEX_LABEL;
220 vec_free (locator_name);
221 vec_free (a->locators);
224 REPLY_MACRO2 (VL_API_ONE_ADD_DEL_LOCATOR_SET_REPLY,
226 rmp->ls_index = clib_host_to_net_u32 (ls_index);
232 vl_api_one_add_del_locator_t_handler (vl_api_one_add_del_locator_t * mp)
234 vl_api_one_add_del_locator_reply_t *rmp;
236 locator_t locator, *locators = NULL;
237 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
239 u8 *locator_name = NULL;
241 memset (&locator, 0, sizeof (locator));
242 memset (a, 0, sizeof (a[0]));
244 locator.sw_if_index = ntohl (mp->sw_if_index);
245 locator.priority = mp->priority;
246 locator.weight = mp->weight;
248 vec_add1 (locators, locator);
250 locator_name = format (0, "%s", mp->locator_set_name);
252 a->name = locator_name;
253 a->locators = locators;
254 a->is_add = mp->is_add;
257 rv = vnet_lisp_add_del_locator (a, NULL, &ls_index);
260 vec_free (locator_name);
262 REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCATOR_REPLY);
269 } __attribute__ ((__packed__)) lisp_nsh_api_t;
272 unformat_one_eid_api (gid_address_t * dst, u32 vni, u8 type, void *src,
280 gid_address_type (dst) = GID_ADDR_IP_PREFIX;
281 gid_address_ip_set (dst, src, IP4);
282 gid_address_ippref_len (dst) = len;
283 ip_prefix_normalize (&gid_address_ippref (dst));
286 gid_address_type (dst) = GID_ADDR_IP_PREFIX;
287 gid_address_ip_set (dst, src, IP6);
288 gid_address_ippref_len (dst) = len;
289 ip_prefix_normalize (&gid_address_ippref (dst));
292 gid_address_type (dst) = GID_ADDR_MAC;
293 clib_memcpy (&gid_address_mac (dst), src, 6);
296 gid_address_type (dst) = GID_ADDR_NSH;
298 gid_address_nsh_spi (dst) = clib_net_to_host_u32 (nsh->spi);
299 gid_address_nsh_si (dst) = nsh->si;
303 return VNET_API_ERROR_INVALID_VALUE;
306 gid_address_vni (dst) = vni;
312 vl_api_one_add_del_local_eid_t_handler (vl_api_one_add_del_local_eid_t * mp)
314 vl_api_one_add_del_local_eid_reply_t *rmp;
315 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
317 gid_address_t _eid, *eid = &_eid;
319 u32 locator_set_index = ~0, map_index = ~0;
320 vnet_lisp_add_del_mapping_args_t _a, *a = &_a;
321 u8 *name = NULL, *key = NULL;
322 memset (a, 0, sizeof (a[0]));
323 memset (eid, 0, sizeof (eid[0]));
325 rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
326 mp->eid_type, mp->eid, mp->prefix_len);
330 if (gid_address_type (eid) == GID_ADDR_NSH)
332 rv = VNET_API_ERROR_INVALID_VALUE;
336 name = format (0, "%s", mp->locator_set_name);
337 p = hash_get_mem (lcm->locator_set_index_by_name, name);
340 rv = VNET_API_ERROR_INVALID_VALUE;
343 locator_set_index = p[0];
346 key = format (0, "%s", mp->key);
348 /* XXX treat batch configuration */
349 a->is_add = mp->is_add;
350 gid_address_copy (&a->eid, eid);
351 a->locator_set_index = locator_set_index;
354 a->key_id = clib_net_to_host_u16 (mp->key_id);
356 rv = vnet_lisp_add_del_local_mapping (a, &map_index);
361 gid_address_free (&a->eid);
363 REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCAL_EID_REPLY);
367 vl_api_one_eid_table_add_del_map_t_handler
368 (vl_api_one_eid_table_add_del_map_t * mp)
370 vl_api_one_eid_table_add_del_map_reply_t *rmp;
372 rv = vnet_lisp_eid_table_map (clib_net_to_host_u32 (mp->vni),
373 clib_net_to_host_u32 (mp->dp_table),
374 mp->is_l2, mp->is_add);
375 REPLY_MACRO (VL_API_ONE_EID_TABLE_ADD_DEL_MAP_REPLY)}
378 vl_api_one_add_del_map_server_t_handler (vl_api_one_add_del_map_server_t * mp)
380 vl_api_one_add_del_map_server_reply_t *rmp;
384 memset (&addr, 0, sizeof (addr));
386 ip_address_set (&addr, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
387 rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
389 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_SERVER_REPLY);
393 vl_api_one_add_del_map_resolver_t_handler (vl_api_one_add_del_map_resolver_t
396 vl_api_one_add_del_map_resolver_reply_t *rmp;
398 vnet_lisp_add_del_map_resolver_args_t _a, *a = &_a;
400 memset (a, 0, sizeof (a[0]));
402 a->is_add = mp->is_add;
403 ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
405 rv = vnet_lisp_add_del_map_resolver (a);
407 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_RESOLVER_REPLY);
411 vl_api_one_map_register_enable_disable_t_handler
412 (vl_api_one_map_register_enable_disable_t * mp)
414 vl_api_one_map_register_enable_disable_reply_t *rmp;
417 vnet_lisp_map_register_enable_disable (mp->is_enabled);
418 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
422 vl_api_one_rloc_probe_enable_disable_t_handler
423 (vl_api_one_rloc_probe_enable_disable_t * mp)
425 vl_api_one_rloc_probe_enable_disable_reply_t *rmp;
428 vnet_lisp_rloc_probe_enable_disable (mp->is_enabled);
429 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
433 vl_api_one_enable_disable_t_handler (vl_api_one_enable_disable_t * mp)
435 vl_api_one_enable_disable_reply_t *rmp;
438 vnet_lisp_enable_disable (mp->is_en);
439 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
443 vl_api_show_one_map_request_mode_t_handler
444 (vl_api_show_one_map_request_mode_t * mp)
447 vl_api_show_one_map_request_mode_reply_t *rmp;
450 REPLY_MACRO2(VL_API_SHOW_ONE_MAP_REQUEST_MODE_REPLY,
452 rmp->mode = vnet_lisp_get_map_request_mode ();
458 vl_api_one_map_request_mode_t_handler (vl_api_one_map_request_mode_t * mp)
460 vl_api_one_map_request_mode_reply_t *rmp;
463 rv = vnet_lisp_set_map_request_mode (mp->mode);
465 REPLY_MACRO (VL_API_ONE_MAP_REQUEST_MODE_REPLY);
469 vl_api_one_nsh_set_locator_set_t_handler (vl_api_one_nsh_set_locator_set_t
472 vl_api_one_nsh_set_locator_set_reply_t *rmp;
476 ls_name = format (0, "%s", mp->ls_name);
477 rv = vnet_lisp_nsh_set_locator_set (ls_name, mp->is_add);
480 REPLY_MACRO (VL_API_ONE_PITR_SET_LOCATOR_SET_REPLY);
484 vl_api_one_pitr_set_locator_set_t_handler (vl_api_one_pitr_set_locator_set_t
487 vl_api_one_pitr_set_locator_set_reply_t *rmp;
491 ls_name = format (0, "%s", mp->ls_name);
492 rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
495 REPLY_MACRO (VL_API_ONE_PITR_SET_LOCATOR_SET_REPLY);
499 vl_api_one_use_petr_t_handler (vl_api_one_use_petr_t * mp)
501 vl_api_one_use_petr_reply_t *rmp;
505 ip_address_set (&addr, &mp->address, mp->is_ip4 ? IP4 : IP6);
506 rv = vnet_lisp_use_petr (&addr, mp->is_add);
508 REPLY_MACRO (VL_API_ONE_USE_PETR_REPLY);
512 vl_api_show_one_use_petr_t_handler (vl_api_show_one_use_petr_t * mp)
514 unix_shared_memory_queue_t *q = NULL;
515 vl_api_show_one_use_petr_reply_t *rmp = NULL;
516 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
518 locator_set_t *ls = 0;
524 q = vl_api_client_index_to_input_queue (mp->client_index);
530 memset (&addr, 0, sizeof (addr));
531 status = lcm->flags & LISP_FLAG_USE_PETR;
534 m = pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index);
535 if (~0 != m->locator_set_index)
538 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
539 loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
540 gid_address_copy (&addr, &loc->address);
545 REPLY_MACRO2 (VL_API_SHOW_ONE_USE_PETR_REPLY,
547 rmp->status = status;
548 ip_address_t *ip = &gid_address_ip (&addr);
549 switch (ip_addr_version (ip))
552 clib_memcpy (rmp->address, &ip_addr_v4 (ip),
553 sizeof (ip_addr_v4 (ip)));
557 clib_memcpy (rmp->address, &ip_addr_v6 (ip),
558 sizeof (ip_addr_v6 (ip)));
564 rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4);
570 vl_api_one_add_del_map_request_itr_rlocs_t_handler
571 (vl_api_one_add_del_map_request_itr_rlocs_t * mp)
573 vl_api_one_add_del_map_request_itr_rlocs_reply_t *rmp;
575 u8 *locator_set_name = NULL;
576 vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
578 locator_set_name = format (0, "%s", mp->locator_set_name);
580 a->is_add = mp->is_add;
581 a->locator_set_name = locator_set_name;
583 rv = vnet_lisp_add_del_mreq_itr_rlocs (a);
585 vec_free (locator_set_name);
587 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
591 vl_api_one_add_del_remote_mapping_t_handler
592 (vl_api_one_add_del_remote_mapping_t * mp)
594 locator_t *rlocs = 0;
595 vl_api_one_add_del_remote_mapping_reply_t *rmp;
597 gid_address_t _eid, *eid = &_eid;
598 u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num);
600 memset (eid, 0, sizeof (eid[0]));
602 rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
603 mp->eid_type, mp->eid, mp->eid_len);
607 rlocs = unformat_one_locs (mp->rlocs, rloc_num);
611 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
612 gid_address_copy (&a->reid, eid);
614 rv = vnet_lisp_add_del_adjacency (a);
621 /* NOTE: for now this works as a static remote mapping, i.e.,
622 * not authoritative and ttl infinite. */
623 rv = vnet_lisp_add_del_mapping (eid, rlocs, mp->action, 0, ~0,
624 mp->is_add, 1 /* is_static */ , 0);
627 vnet_lisp_clear_all_remote_adjacencies ();
632 REPLY_MACRO (VL_API_ONE_ADD_DEL_REMOTE_MAPPING_REPLY);
636 vl_api_one_add_del_adjacency_t_handler (vl_api_one_add_del_adjacency_t * mp)
638 vl_api_one_add_del_adjacency_reply_t *rmp;
639 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
642 memset (a, 0, sizeof (a[0]));
644 rv = unformat_one_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni),
645 mp->eid_type, mp->leid, mp->leid_len);
646 rv |= unformat_one_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni),
647 mp->eid_type, mp->reid, mp->reid_len);
652 a->is_add = mp->is_add;
653 rv = vnet_lisp_add_del_adjacency (a);
656 REPLY_MACRO (VL_API_ONE_ADD_DEL_ADJACENCY_REPLY);
660 send_one_locator_details (lisp_cp_main_t * lcm,
662 unix_shared_memory_queue_t * q, u32 context)
664 vl_api_one_locator_details_t *rmp;
666 rmp = vl_msg_api_alloc (sizeof (*rmp));
667 memset (rmp, 0, sizeof (*rmp));
668 rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_DETAILS);
669 rmp->context = context;
671 rmp->local = loc->local;
674 rmp->sw_if_index = ntohl (loc->sw_if_index);
678 rmp->is_ipv6 = gid_address_ip_version (&loc->address);
679 ip_address_copy_addr (rmp->ip_address, &gid_address_ip (&loc->address));
681 rmp->priority = loc->priority;
682 rmp->weight = loc->weight;
684 vl_msg_api_send_shmem (q, (u8 *) & rmp);
688 vl_api_one_locator_dump_t_handler (vl_api_one_locator_dump_t * mp)
691 unix_shared_memory_queue_t *q = 0;
692 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
693 locator_set_t *lsit = 0;
695 u32 ls_index = ~0, *locit = 0;
698 q = vl_api_client_index_to_input_queue (mp->client_index);
704 if (mp->is_index_set)
705 ls_index = htonl (mp->ls_index);
708 /* make sure we get a proper C-string */
709 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
710 ls_name = format (0, "%s", mp->ls_name);
711 p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
717 if (pool_is_free_index (lcm->locator_set_pool, ls_index))
720 lsit = pool_elt_at_index (lcm->locator_set_pool, ls_index);
722 vec_foreach (locit, lsit->locator_indices)
724 loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
725 send_one_locator_details (lcm, loc, q, mp->context);
732 send_one_locator_set_details (lisp_cp_main_t * lcm,
733 locator_set_t * lsit,
734 unix_shared_memory_queue_t * q,
735 u32 context, u32 ls_index)
737 vl_api_one_locator_set_details_t *rmp;
740 rmp = vl_msg_api_alloc (sizeof (*rmp));
741 memset (rmp, 0, sizeof (*rmp));
742 rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_SET_DETAILS);
743 rmp->context = context;
745 rmp->ls_index = htonl (ls_index);
748 ASSERT (lsit->name != NULL);
749 strncpy ((char *) rmp->ls_name, (char *) lsit->name,
750 vec_len (lsit->name));
754 str = format (0, "<remote-%d>", ls_index);
755 strncpy ((char *) rmp->ls_name, (char *) str, vec_len (str));
759 vl_msg_api_send_shmem (q, (u8 *) & rmp);
763 vl_api_one_locator_set_dump_t_handler (vl_api_one_locator_set_dump_t * mp)
765 unix_shared_memory_queue_t *q = NULL;
766 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
767 locator_set_t *lsit = NULL;
770 q = vl_api_client_index_to_input_queue (mp->client_index);
778 pool_foreach (lsit, lcm->locator_set_pool,
780 if (filter && !((1 == filter && lsit->local) ||
781 (2 == filter && !lsit->local)))
785 send_one_locator_set_details (lcm, lsit, q, mp->context,
786 lsit - lcm->locator_set_pool);
792 one_fid_put_api (u8 * dst, fid_address_t * src, u8 * prefix_length)
794 ASSERT (prefix_length);
795 ip_prefix_t *ippref = &fid_addr_ippref (src);
797 switch (fid_addr_type (src))
799 case FID_ADDR_IP_PREF:
800 if (ip_prefix_version (ippref) == IP4)
801 clib_memcpy (dst, &ip_prefix_v4 (ippref), 4);
803 clib_memcpy (dst, &ip_prefix_v6 (ippref), 16);
804 prefix_length[0] = ip_prefix_len (ippref);
808 prefix_length[0] = 0;
809 clib_memcpy (dst, fid_addr_mac (src), 6);
813 clib_warning ("Unknown FID type %d!", fid_addr_type (src));
819 fid_type_to_api_type (fid_address_t * fid)
823 switch (fid_addr_type (fid))
825 case FID_ADDR_IP_PREF:
826 ippref = &fid_addr_ippref (fid);
827 if (ip_prefix_version (ippref) == IP4)
829 else if (ip_prefix_version (ippref) == IP6)
844 send_one_eid_table_details (mapping_t * mapit,
845 unix_shared_memory_queue_t * q,
846 u32 context, u8 filter)
849 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
850 locator_set_t *ls = 0;
851 vl_api_one_eid_table_details_t *rmp = NULL;
852 gid_address_t *gid = NULL;
854 ip_prefix_t *ip_prefix = NULL;
856 if (mapit->pitr_set || mapit->nsh_set)
861 case 0: /* all mappings */
864 case 1: /* local only */
868 case 2: /* remote only */
873 clib_warning ("Filter error, unknown filter: %d", filter);
878 ip_prefix = &gid_address_ippref (gid);
879 mac = gid_address_mac (gid);
881 rmp = vl_msg_api_alloc (sizeof (*rmp));
882 memset (rmp, 0, sizeof (*rmp));
883 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_DETAILS);
885 ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index);
886 if (vec_len (ls->locator_indices) == 0)
887 rmp->locator_set_index = ~0;
889 rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index);
891 rmp->is_local = mapit->local;
892 rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
893 rmp->action = mapit->action;
894 rmp->authoritative = mapit->authoritative;
896 switch (gid_address_type (gid))
898 case GID_ADDR_SRC_DST:
900 fid = &gid_address_sd_src (gid);
901 rmp->eid_type = fid_type_to_api_type (fid);
902 one_fid_put_api (rmp->seid, &gid_address_sd_src (gid),
903 &rmp->seid_prefix_len);
904 one_fid_put_api (rmp->eid, &gid_address_sd_dst (gid),
905 &rmp->eid_prefix_len);
907 case GID_ADDR_IP_PREFIX:
908 rmp->eid_prefix_len = ip_prefix_len (ip_prefix);
909 if (ip_prefix_version (ip_prefix) == IP4)
911 rmp->eid_type = 0; /* ipv4 type */
912 clib_memcpy (rmp->eid, &ip_prefix_v4 (ip_prefix),
913 sizeof (ip_prefix_v4 (ip_prefix)));
917 rmp->eid_type = 1; /* ipv6 type */
918 clib_memcpy (rmp->eid, &ip_prefix_v6 (ip_prefix),
919 sizeof (ip_prefix_v6 (ip_prefix)));
923 rmp->eid_type = 2; /* l2 mac type */
924 clib_memcpy (rmp->eid, mac, 6);
927 rmp->eid_type = 3; /* NSH type */
929 nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (gid));
930 nsh.si = gid_address_nsh_si (gid);
931 clib_memcpy (rmp->eid, &nsh, sizeof (nsh));
936 rmp->context = context;
937 rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
938 rmp->key_id = clib_host_to_net_u16 (mapit->key_id);
939 memcpy (rmp->key, mapit->key, vec_len (mapit->key));
940 vl_msg_api_send_shmem (q, (u8 *) & rmp);
944 vl_api_one_eid_table_dump_t_handler (vl_api_one_eid_table_dump_t * mp)
947 unix_shared_memory_queue_t *q = NULL;
948 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
949 mapping_t *mapit = NULL;
950 gid_address_t _eid, *eid = &_eid;
952 q = vl_api_client_index_to_input_queue (mp->client_index);
960 memset (eid, 0, sizeof (*eid));
962 unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
963 mp->eid_type, mp->eid, mp->prefix_length);
965 mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
969 mapit = pool_elt_at_index (lcm->mapping_pool, mi);
970 send_one_eid_table_details (mapit, q, mp->context,
971 0 /* ignore filter */ );
976 pool_foreach (mapit, lcm->mapping_pool,
978 send_one_eid_table_details(mapit, q, mp->context,
986 send_one_map_server_details (ip_address_t * ip,
987 unix_shared_memory_queue_t * q, u32 context)
989 vl_api_one_map_server_details_t *rmp = NULL;
991 rmp = vl_msg_api_alloc (sizeof (*rmp));
992 memset (rmp, 0, sizeof (*rmp));
993 rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_SERVER_DETAILS);
995 switch (ip_addr_version (ip))
999 clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
1000 sizeof (ip_addr_v4 (ip)));
1005 clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
1006 sizeof (ip_addr_v6 (ip)));
1012 rmp->context = context;
1014 vl_msg_api_send_shmem (q, (u8 *) & rmp);
1018 vl_api_one_map_server_dump_t_handler (vl_api_one_map_server_dump_t * mp)
1020 unix_shared_memory_queue_t *q = NULL;
1021 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1024 q = vl_api_client_index_to_input_queue (mp->client_index);
1030 vec_foreach (mr, lcm->map_servers)
1032 send_one_map_server_details (&mr->address, q, mp->context);
1037 send_one_map_resolver_details (ip_address_t * ip,
1038 unix_shared_memory_queue_t * q, u32 context)
1040 vl_api_one_map_resolver_details_t *rmp = NULL;
1042 rmp = vl_msg_api_alloc (sizeof (*rmp));
1043 memset (rmp, 0, sizeof (*rmp));
1044 rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_RESOLVER_DETAILS);
1046 switch (ip_addr_version (ip))
1050 clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
1051 sizeof (ip_addr_v4 (ip)));
1056 clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
1057 sizeof (ip_addr_v6 (ip)));
1063 rmp->context = context;
1065 vl_msg_api_send_shmem (q, (u8 *) & rmp);
1069 vl_api_one_map_resolver_dump_t_handler (vl_api_one_map_resolver_dump_t * mp)
1071 unix_shared_memory_queue_t *q = NULL;
1072 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1075 q = vl_api_client_index_to_input_queue (mp->client_index);
1081 vec_foreach (mr, lcm->map_resolvers)
1083 send_one_map_resolver_details (&mr->address, q, mp->context);
1088 send_eid_table_map_pair (hash_pair_t * p,
1089 unix_shared_memory_queue_t * q, u32 context)
1091 vl_api_one_eid_table_map_details_t *rmp = NULL;
1093 rmp = vl_msg_api_alloc (sizeof (*rmp));
1094 memset (rmp, 0, sizeof (*rmp));
1095 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_MAP_DETAILS);
1097 rmp->vni = clib_host_to_net_u32 (p->key);
1098 rmp->dp_table = clib_host_to_net_u32 (p->value[0]);
1099 rmp->context = context;
1100 vl_msg_api_send_shmem (q, (u8 *) & rmp);
1104 vl_api_one_eid_table_map_dump_t_handler (vl_api_one_eid_table_map_dump_t * mp)
1106 unix_shared_memory_queue_t *q = NULL;
1107 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1109 uword *vni_table = 0;
1111 q = vl_api_client_index_to_input_queue (mp->client_index);
1119 vni_table = lcm->bd_id_by_vni;
1123 vni_table = lcm->table_id_by_vni;
1127 hash_foreach_pair (p, vni_table,
1129 send_eid_table_map_pair (p, q, mp->context);
1135 send_eid_table_vni (u32 vni, unix_shared_memory_queue_t * q, u32 context)
1137 vl_api_one_eid_table_vni_details_t *rmp = 0;
1139 rmp = vl_msg_api_alloc (sizeof (*rmp));
1140 memset (rmp, 0, sizeof (*rmp));
1141 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_VNI_DETAILS);
1142 rmp->context = context;
1143 rmp->vni = clib_host_to_net_u32 (vni);
1144 vl_msg_api_send_shmem (q, (u8 *) & rmp);
1148 one_adjacency_copy (vl_api_one_adjacency_t * dst, lisp_adjacency_t * adjs)
1150 lisp_adjacency_t *adj;
1151 vl_api_one_adjacency_t a;
1152 u32 i, n = vec_len (adjs);
1155 for (i = 0; i < n; i++)
1157 adj = vec_elt_at_index (adjs, i);
1158 memset (&a, 0, sizeof (a));
1160 switch (gid_address_type (&adj->reid))
1162 case GID_ADDR_IP_PREFIX:
1163 a.reid_prefix_len = gid_address_ippref_len (&adj->reid);
1164 a.leid_prefix_len = gid_address_ippref_len (&adj->leid);
1165 if (gid_address_ip_version (&adj->reid) == IP4)
1167 a.eid_type = 0; /* ipv4 type */
1168 clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 4);
1169 clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 4);
1173 a.eid_type = 1; /* ipv6 type */
1174 clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 16);
1175 clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 16);
1179 a.eid_type = 2; /* l2 mac type */
1180 mac_copy (a.reid, gid_address_mac (&adj->reid));
1181 mac_copy (a.leid, gid_address_mac (&adj->leid));
1184 a.eid_type = 3; /* NSH type */
1185 nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (&adj->reid));
1186 nsh.si = gid_address_nsh_si (&adj->reid);
1187 clib_memcpy (a.reid, &nsh, sizeof (nsh));
1189 nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (&adj->leid));
1190 nsh.si = gid_address_nsh_si (&adj->leid);
1191 clib_memcpy (a.leid, &nsh, sizeof (nsh));
1201 vl_api_show_one_rloc_probe_state_t_handler
1202 (vl_api_show_one_rloc_probe_state_t * mp)
1204 vl_api_show_one_rloc_probe_state_reply_t *rmp = 0;
1208 REPLY_MACRO2 (VL_API_SHOW_ONE_RLOC_PROBE_STATE_REPLY,
1210 rmp->is_enabled = vnet_lisp_rloc_probe_state_get ();
1216 vl_api_show_one_map_register_state_t_handler
1217 (vl_api_show_one_map_register_state_t * mp)
1219 vl_api_show_one_map_register_state_reply_t *rmp = 0;
1223 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_STATE_REPLY,
1225 rmp->is_enabled = vnet_lisp_map_register_state_get ();
1231 vl_api_one_adjacencies_get_t_handler (vl_api_one_adjacencies_get_t * mp)
1233 vl_api_one_adjacencies_get_reply_t *rmp = 0;
1234 lisp_adjacency_t *adjs = 0;
1237 u32 vni = clib_net_to_host_u32 (mp->vni);
1239 adjs = vnet_lisp_adjacencies_get_by_vni (vni);
1240 size = vec_len (adjs) * sizeof (vl_api_one_adjacency_t);
1243 REPLY_MACRO4 (VL_API_ONE_ADJACENCIES_GET_REPLY, size,
1245 rmp->count = clib_host_to_net_u32 (vec_len (adjs));
1246 one_adjacency_copy (rmp->adjacencies, adjs);
1254 vl_api_one_eid_table_vni_dump_t_handler (vl_api_one_eid_table_vni_dump_t * mp)
1258 unix_shared_memory_queue_t *q = 0;
1259 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1261 q = vl_api_client_index_to_input_queue (mp->client_index);
1268 hash_foreach_pair (p, lcm->table_id_by_vni,
1270 hash_set (vnis, p->key, 0);
1273 hash_foreach_pair (p, lcm->bd_id_by_vni,
1275 hash_set (vnis, p->key, 0);
1278 hash_foreach_pair (p, vnis,
1280 send_eid_table_vni (p->key, q, mp->context);
1288 vl_api_show_one_status_t_handler (vl_api_show_one_status_t * mp)
1290 unix_shared_memory_queue_t *q = NULL;
1291 vl_api_show_one_status_reply_t *rmp = NULL;
1294 q = vl_api_client_index_to_input_queue (mp->client_index);
1301 REPLY_MACRO2(VL_API_SHOW_ONE_STATUS_REPLY,
1303 rmp->gpe_status = vnet_lisp_gpe_enable_disable_status ();
1304 rmp->feature_status = vnet_lisp_enable_disable_status ();
1310 vl_api_one_get_map_request_itr_rlocs_t_handler
1311 (vl_api_one_get_map_request_itr_rlocs_t * mp)
1313 unix_shared_memory_queue_t *q = NULL;
1314 vl_api_one_get_map_request_itr_rlocs_reply_t *rmp = NULL;
1315 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1316 locator_set_t *loc_set = 0;
1320 q = vl_api_client_index_to_input_queue (mp->client_index);
1326 if (~0 == lcm->mreq_itr_rlocs)
1328 tmp_str = format (0, " ");
1333 pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
1334 tmp_str = format (0, "%s", loc_set->name);
1338 REPLY_MACRO2(VL_API_ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY,
1340 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1341 ARRAY_LEN(rmp->locator_set_name) - 1);
1349 vl_api_show_one_nsh_mapping_t_handler (vl_api_show_one_nsh_mapping_t * mp)
1351 unix_shared_memory_queue_t *q = NULL;
1352 vl_api_show_one_nsh_mapping_reply_t *rmp = NULL;
1353 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1355 locator_set_t *ls = 0;
1360 q = vl_api_client_index_to_input_queue (mp->client_index);
1366 if (lcm->nsh_map_index == (u32) ~ 0)
1368 tmp_str = format (0, "N/A");
1372 m = pool_elt_at_index (lcm->mapping_pool, lcm->nsh_map_index);
1373 if (~0 != m->locator_set_index)
1376 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1377 tmp_str = format (0, "%s", ls->name);
1382 tmp_str = format (0, "N/A");
1385 vec_add1 (tmp_str, 0);
1388 REPLY_MACRO2(VL_API_SHOW_ONE_NSH_MAPPING_REPLY,
1390 rmp->is_set = is_set;
1391 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1392 ARRAY_LEN(rmp->locator_set_name) - 1);
1398 vl_api_show_one_pitr_t_handler (vl_api_show_one_pitr_t * mp)
1400 unix_shared_memory_queue_t *q = NULL;
1401 vl_api_show_one_pitr_reply_t *rmp = NULL;
1402 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1404 locator_set_t *ls = 0;
1408 q = vl_api_client_index_to_input_queue (mp->client_index);
1414 if (!lcm->lisp_pitr)
1416 tmp_str = format (0, "N/A");
1420 m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index);
1421 if (~0 != m->locator_set_index)
1424 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1425 tmp_str = format (0, "%s", ls->name);
1429 tmp_str = format (0, "N/A");
1432 vec_add1 (tmp_str, 0);
1435 REPLY_MACRO2(VL_API_SHOW_ONE_PITR_REPLY,
1437 rmp->status = lcm->lisp_pitr;
1438 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1439 ARRAY_LEN(rmp->locator_set_name) - 1);
1445 vl_api_show_one_stats_enable_disable_t_handler
1446 (vl_api_show_one_stats_enable_disable_t * mp)
1448 vl_api_show_one_stats_enable_disable_reply_t *rmp = NULL;
1449 vnet_api_error_t rv = 0;
1452 REPLY_MACRO2 (VL_API_SHOW_ONE_STATS_ENABLE_DISABLE_REPLY,
1454 rmp->is_en = vnet_lisp_stats_enable_disable_state ();
1460 vl_api_one_stats_enable_disable_t_handler
1461 (vl_api_one_stats_enable_disable_t * mp)
1463 vl_api_one_enable_disable_reply_t *rmp = NULL;
1465 vnet_api_error_t rv = vnet_lisp_stats_enable_disable (mp->is_en);
1466 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
1470 lisp_fid_addr_to_api (fid_address_t * fid, u8 * dst, u8 * api_eid_type,
1473 switch (fid_addr_type (fid))
1475 case FID_ADDR_IP_PREF:
1476 *prefix_length = fid_addr_prefix_length (fid);
1477 if (fid_addr_ip_version (fid) == IP4)
1479 *api_eid_type = 0; /* ipv4 type */
1480 clib_memcpy (dst, &fid_addr_ippref (fid), 4);
1484 *api_eid_type = 1; /* ipv6 type */
1485 clib_memcpy (dst, &fid_addr_ippref (fid), 16);
1489 *api_eid_type = 2; /* l2 mac type */
1490 mac_copy (dst, fid_addr_mac (fid));
1498 vl_api_one_stats_flush_t_handler (vl_api_one_stats_flush_t * mp)
1500 vl_api_one_stats_flush_reply_t *rmp;
1503 rv = vnet_lisp_flush_stats ();
1504 REPLY_MACRO (VL_API_ONE_STATS_FLUSH_REPLY);
1508 vl_api_one_stats_dump_t_handler (vl_api_one_stats_dump_t * mp)
1510 vl_api_one_stats_details_t *rmp;
1511 lisp_api_stats_t *stats, *stat;
1514 stats = vnet_lisp_get_stats ();
1515 vec_foreach (stat, stats)
1518 REPLY_DETAILS (VL_API_ONE_STATS_DETAILS,
1520 lisp_fid_addr_to_api (&stat->deid, rmp->deid, &rmp->eid_type,
1521 &rmp->deid_pref_len);
1522 lisp_fid_addr_to_api (&stat->seid, rmp->seid, &rmp->eid_type,
1523 &rmp->seid_pref_len);
1524 rmp->vni = clib_host_to_net_u32 (stat->vni);
1526 rmp->is_ip4 = ip_addr_version (&stat->rmt_rloc) == IP4 ? 1 : 0;
1527 ip_address_copy_addr (rmp->rloc, &stat->rmt_rloc);
1528 ip_address_copy_addr (rmp->lloc, &stat->loc_rloc);
1530 rmp->pkt_count = clib_host_to_net_u32 (stat->counters.packets);
1531 rmp->bytes = clib_host_to_net_u32 (stat->counters.bytes);
1538 vl_api_one_add_del_l2_arp_entry_t_handler
1539 (vl_api_one_add_del_l2_arp_entry_t * mp)
1541 vl_api_one_add_del_l2_arp_entry_reply_t *rmp;
1543 gid_address_t _arp, *arp = &_arp;
1544 memset (arp, 0, sizeof (*arp));
1546 gid_address_type (arp) = GID_ADDR_ARP;
1547 gid_address_arp_bd (arp) = clib_net_to_host_u32 (mp->bd);
1549 /* vpp keeps ip4 addresses in network byte order */
1550 clib_memcpy (&gid_address_arp_ip4 (arp), &mp->ip4, 4);
1552 rv = vnet_lisp_add_del_l2_arp_entry (arp, mp->mac, mp->is_add);
1554 REPLY_MACRO (VL_API_ONE_ADD_DEL_L2_ARP_ENTRY_REPLY);
1558 vl_api_one_l2_arp_bd_get_t_handler (vl_api_one_l2_arp_bd_get_t * mp)
1560 vl_api_one_l2_arp_bd_get_reply_t *rmp;
1565 u32 *bds = vnet_lisp_l2_arp_bds_get ();
1566 u32 size = hash_elts (bds) * sizeof (u32);
1569 REPLY_MACRO4 (VL_API_ONE_L2_ARP_BD_GET_REPLY, size,
1571 rmp->count = clib_host_to_net_u32 (hash_elts (bds));
1572 hash_foreach_pair (p, bds,
1574 rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
1583 vl_api_one_l2_arp_entries_get_t_handler (vl_api_one_l2_arp_entries_get_t * mp)
1585 vl_api_one_l2_arp_entries_get_reply_t *rmp;
1586 lisp_api_l2_arp_entry_t *entries = 0, *e;
1590 u32 bd = clib_net_to_host_u32 (mp->bd);
1592 entries = vnet_lisp_l2_arp_entries_get_by_bd (bd);
1593 u32 size = vec_len (entries) * sizeof (vl_api_one_l2_arp_entry_t);
1596 REPLY_MACRO4 (VL_API_ONE_L2_ARP_ENTRIES_GET_REPLY, size,
1598 rmp->count = clib_host_to_net_u32 (vec_len (entries));
1599 vec_foreach (e, entries)
1601 mac_copy (rmp->entries[i].mac, e->mac);
1602 rmp->entries[i].ip4 = e->ip4;
1612 vl_api_one_map_register_fallback_threshold_t_handler
1613 (vl_api_one_map_register_fallback_threshold_t * mp)
1615 vl_api_one_map_register_fallback_threshold_reply_t *rmp;
1618 mp->value = clib_net_to_host_u32 (mp->value);
1619 rv = vnet_lisp_map_register_fallback_threshold_set (mp->value);
1620 REPLY_MACRO (VL_API_ONE_MAP_REGISTER_FALLBACK_THRESHOLD);
1624 vl_api_show_one_map_register_fallback_threshold_t_handler
1625 (vl_api_show_one_map_register_fallback_threshold_t * mp)
1627 vl_api_show_one_map_register_fallback_threshold_reply_t *rmp;
1630 u32 value = vnet_lisp_map_register_fallback_threshold_get ();
1633 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY,
1635 rmp->value = clib_host_to_net_u32 (value);
1642 * Add vpe's API message handlers to the table.
1643 * vlib has alread mapped shared memory and
1644 * added the client registration handlers.
1645 * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1647 #define vl_msg_name_crc_list
1648 #include <vnet/vnet_all_api_h.h>
1649 #undef vl_msg_name_crc_list
1652 setup_message_id_table (api_main_t * am)
1654 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1655 foreach_vl_msg_name_crc_one;
1659 static clib_error_t *
1660 one_api_hookup (vlib_main_t * vm)
1662 api_main_t *am = &api_main;
1665 vl_msg_api_set_handlers(VL_API_##N, #n, \
1666 vl_api_##n##_t_handler, \
1668 vl_api_##n##_t_endian, \
1669 vl_api_##n##_t_print, \
1670 sizeof(vl_api_##n##_t), 1);
1671 foreach_vpe_api_msg;
1675 * Set up the (msg_name, crc, message-id) table
1677 setup_message_id_table (am);
1682 VLIB_API_INIT_FUNCTION (one_api_hookup);
1685 * fd.io coding-style-patch-verification: ON
1688 * eval: (c-set-style "gnu")