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/ip/ip_types_api.h>
29 #include <vnet/ethernet/ethernet_types_api.h>
31 #include <vnet/vnet_msg_enum.h>
33 #define vl_api_one_add_del_locator_set_t_endian vl_noop_handler
34 #define vl_api_one_add_del_locator_set_t_print vl_noop_handler
35 #define vl_api_one_add_del_remote_mapping_t_endian vl_noop_handler
36 #define vl_api_one_add_del_remote_mapping_t_print vl_noop_handler
38 #define vl_api_one_add_del_locator_set_t_endian vl_noop_handler
39 #define vl_api_one_add_del_locator_set_t_print vl_noop_handler
40 #define vl_api_one_add_del_remote_mapping_t_endian vl_noop_handler
41 #define vl_api_one_add_del_remote_mapping_t_print vl_noop_handler
43 #define vl_api_one_add_del_l2_arp_entry vl_noop_handler
44 #define vl_api_one_l2_arp_bd_get vl_noop_handler
46 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
47 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
49 #define vl_typedefs /* define message structures */
50 #include <vnet/vnet_all_api_h.h>
53 #define vl_endianfun /* define message structures */
54 #include <vnet/vnet_all_api_h.h>
57 /* instantiate all the print functions we know about */
58 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
60 #include <vnet/vnet_all_api_h.h>
63 #include <vlibapi/api_helper_macros.h>
65 #define REPLY_DETAILS(t, body) \
67 vl_api_registration_t * reg; \
68 rv = vl_msg_api_pd_handler (mp, rv); \
69 reg = vl_api_client_index_to_registration (mp->client_index); \
73 rmp = vl_msg_api_alloc (sizeof (*rmp)); \
74 rmp->_vl_msg_id = ntohs((t)); \
75 rmp->context = mp->context; \
76 do {body;} while (0); \
77 vl_api_send_msg (reg, (u8 *)&rmp); \
80 #define foreach_vpe_api_msg \
81 _(ONE_ADD_DEL_LOCATOR_SET, one_add_del_locator_set) \
82 _(ONE_ADD_DEL_LOCATOR, one_add_del_locator) \
83 _(ONE_ADD_DEL_LOCAL_EID, one_add_del_local_eid) \
84 _(ONE_ADD_DEL_MAP_RESOLVER, one_add_del_map_resolver) \
85 _(ONE_ADD_DEL_MAP_SERVER, one_add_del_map_server) \
86 _(ONE_ENABLE_DISABLE, one_enable_disable) \
87 _(ONE_RLOC_PROBE_ENABLE_DISABLE, one_rloc_probe_enable_disable) \
88 _(ONE_MAP_REGISTER_ENABLE_DISABLE, one_map_register_enable_disable) \
89 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD, \
90 one_map_register_fallback_threshold) \
91 _(ONE_ADD_DEL_REMOTE_MAPPING, one_add_del_remote_mapping) \
92 _(ONE_ADD_DEL_ADJACENCY, one_add_del_adjacency) \
93 _(ONE_PITR_SET_LOCATOR_SET, one_pitr_set_locator_set) \
94 _(ONE_NSH_SET_LOCATOR_SET, one_nsh_set_locator_set) \
95 _(ONE_MAP_REQUEST_MODE, one_map_request_mode) \
96 _(ONE_EID_TABLE_ADD_DEL_MAP, one_eid_table_add_del_map) \
97 _(ONE_LOCATOR_SET_DUMP, one_locator_set_dump) \
98 _(ONE_LOCATOR_DUMP, one_locator_dump) \
99 _(ONE_EID_TABLE_DUMP, one_eid_table_dump) \
100 _(ONE_MAP_RESOLVER_DUMP, one_map_resolver_dump) \
101 _(ONE_MAP_SERVER_DUMP, one_map_server_dump) \
102 _(ONE_EID_TABLE_MAP_DUMP, one_eid_table_map_dump) \
103 _(ONE_EID_TABLE_VNI_DUMP, one_eid_table_vni_dump) \
104 _(ONE_ADJACENCIES_GET, one_adjacencies_get) \
105 _(ONE_MAP_REGISTER_SET_TTL, one_map_register_set_ttl) \
106 _(SHOW_ONE_NSH_MAPPING, show_one_nsh_mapping) \
107 _(SHOW_ONE_RLOC_PROBE_STATE, show_one_rloc_probe_state) \
108 _(SHOW_ONE_MAP_REGISTER_STATE, show_one_map_register_state) \
109 _(SHOW_ONE_MAP_REGISTER_TTL, show_one_map_register_ttl) \
110 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, \
111 show_one_map_register_fallback_threshold) \
112 _(SHOW_ONE_STATUS, show_one_status) \
113 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \
114 one_add_del_map_request_itr_rlocs) \
115 _(ONE_GET_MAP_REQUEST_ITR_RLOCS, one_get_map_request_itr_rlocs) \
116 _(SHOW_ONE_PITR, show_one_pitr) \
117 _(SHOW_ONE_MAP_REQUEST_MODE, show_one_map_request_mode) \
118 _(ONE_USE_PETR, one_use_petr) \
119 _(SHOW_ONE_USE_PETR, show_one_use_petr) \
120 _(SHOW_ONE_STATS_ENABLE_DISABLE, show_one_stats_enable_disable) \
121 _(ONE_STATS_ENABLE_DISABLE, one_stats_enable_disable) \
122 _(ONE_STATS_DUMP, one_stats_dump) \
123 _(ONE_STATS_FLUSH, one_stats_flush) \
124 _(ONE_L2_ARP_BD_GET, one_l2_arp_bd_get) \
125 _(ONE_L2_ARP_ENTRIES_GET, one_l2_arp_entries_get) \
126 _(ONE_ADD_DEL_L2_ARP_ENTRY, one_add_del_l2_arp_entry) \
127 _(ONE_ADD_DEL_NDP_ENTRY, one_add_del_ndp_entry) \
128 _(ONE_NDP_BD_GET, one_ndp_bd_get) \
129 _(ONE_NDP_ENTRIES_GET, one_ndp_entries_get) \
130 _(ONE_SET_TRANSPORT_PROTOCOL, one_set_transport_protocol) \
131 _(ONE_GET_TRANSPORT_PROTOCOL, one_get_transport_protocol) \
132 _(ONE_ENABLE_DISABLE_XTR_MODE, one_enable_disable_xtr_mode) \
133 _(ONE_SHOW_XTR_MODE, one_show_xtr_mode) \
134 _(ONE_ENABLE_DISABLE_PITR_MODE, one_enable_disable_pitr_mode) \
135 _(ONE_SHOW_PITR_MODE, one_show_pitr_mode) \
136 _(ONE_ENABLE_DISABLE_PETR_MODE, one_enable_disable_petr_mode) \
137 _(ONE_SHOW_PETR_MODE, one_show_petr_mode) \
141 unformat_one_locs (vl_api_remote_locator_t * rmt_locs, u32 rloc_num)
144 locator_t *locs = 0, loc;
145 vl_api_remote_locator_t *r;
147 for (i = 0; i < rloc_num; i++)
149 /* remote locators */
151 clib_memset (&loc, 0, sizeof (loc));
152 ip_address_decode2 (&r->ip_address, &loc.address.ippref.addr);
153 loc.address.ippref.len =
154 ip_address_max_len (loc.address.ippref.addr.version);
156 loc.priority = r->priority;
157 loc.weight = r->weight;
159 vec_add1 (locs, loc);
165 vl_api_one_map_register_set_ttl_t_handler (vl_api_one_map_register_set_ttl_t *
168 vl_api_one_map_register_set_ttl_reply_t *rmp;
171 mp->ttl = clib_net_to_host_u32 (mp->ttl);
172 rv = vnet_lisp_map_register_set_ttl (mp->ttl);
174 REPLY_MACRO (VL_API_ONE_MAP_REGISTER_SET_TTL_REPLY);
178 vl_api_show_one_map_register_ttl_t_handler
179 (vl_api_show_one_map_register_ttl_t * mp)
181 vl_api_show_one_map_register_ttl_reply_t *rmp;
184 u32 ttl = vnet_lisp_map_register_get_ttl ();
186 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_TTL_REPLY,
188 rmp->ttl = clib_host_to_net_u32 (ttl);
194 vl_api_one_add_del_locator_set_t_handler (vl_api_one_add_del_locator_set_t *
197 vl_api_one_add_del_locator_set_reply_t *rmp;
199 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
201 vl_api_local_locator_t *ls_loc;
202 u32 ls_index = ~0, locator_num;
203 u8 *locator_name = NULL;
206 clib_memset (a, 0, sizeof (a[0]));
208 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
209 locator_name = format (0, "%s", mp->locator_set_name);
210 vec_terminate_c_string (locator_name);
212 a->name = locator_name;
213 a->is_add = mp->is_add;
215 locator_num = clib_net_to_host_u32 (mp->locator_num);
217 clib_memset (&locator, 0, sizeof (locator));
218 for (i = 0; i < locator_num; i++)
220 ls_loc = &mp->locators[i];
221 VALIDATE_SW_IF_INDEX (ls_loc);
223 locator.sw_if_index = htonl (ls_loc->sw_if_index);
224 locator.priority = ls_loc->priority;
225 locator.weight = ls_loc->weight;
227 vec_add1 (a->locators, locator);
230 rv = vnet_lisp_add_del_locator_set (a, &ls_index);
232 BAD_SW_IF_INDEX_LABEL;
234 vec_free (locator_name);
235 vec_free (a->locators);
238 REPLY_MACRO2 (VL_API_ONE_ADD_DEL_LOCATOR_SET_REPLY,
240 rmp->ls_index = clib_host_to_net_u32 (ls_index);
246 vl_api_one_add_del_locator_t_handler (vl_api_one_add_del_locator_t * mp)
248 vl_api_one_add_del_locator_reply_t *rmp;
250 locator_t locator, *locators = NULL;
251 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
253 u8 *locator_name = NULL;
255 clib_memset (&locator, 0, sizeof (locator));
256 clib_memset (a, 0, sizeof (a[0]));
258 locator.sw_if_index = ntohl (mp->sw_if_index);
259 locator.priority = mp->priority;
260 locator.weight = mp->weight;
262 vec_add1 (locators, locator);
264 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
265 locator_name = format (0, "%s", mp->locator_set_name);
266 vec_terminate_c_string (locator_name);
268 a->name = locator_name;
269 a->locators = locators;
270 a->is_add = mp->is_add;
273 rv = vnet_lisp_add_del_locator (a, NULL, &ls_index);
276 vec_free (locator_name);
278 REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCATOR_REPLY);
285 } __attribute__ ((__packed__)) lisp_nsh_api_t;
288 unformat_one_eid_api (gid_address_t * dst, u32 vni, vl_api_eid_t * eid)
294 case EID_TYPE_API_PREFIX:
295 ip_prefix_decode (&eid->address.prefix, &prefix);
296 gid_address_type (dst) = GID_ADDR_IP_PREFIX;
297 if (prefix.fp_proto == FIB_PROTOCOL_IP4)
298 gid_address_ip_set (dst, &prefix.fp_addr.ip4, AF_IP4);
299 if (prefix.fp_proto == FIB_PROTOCOL_IP6)
300 gid_address_ip_set (dst, &prefix.fp_addr.ip6, AF_IP6);
301 gid_address_ippref_len (dst) = prefix.fp_len;
302 ip_prefix_normalize (&gid_address_ippref (dst));
304 case EID_TYPE_API_MAC:
305 gid_address_type (dst) = GID_ADDR_MAC;
306 mac_address_decode (eid->address.mac,
307 (mac_address_t *) & gid_address_mac (dst));
309 case EID_TYPE_API_NSH:
310 gid_address_type (dst) = GID_ADDR_NSH;
311 gid_address_nsh_spi (dst) = clib_net_to_host_u32 (eid->address.nsh.spi);
312 gid_address_nsh_si (dst) = eid->address.nsh.si;
316 return VNET_API_ERROR_INVALID_VALUE;
319 gid_address_vni (dst) = vni;
325 fid_to_api_eid (fid_address_t * fid, vl_api_eid_t * eid)
327 fib_prefix_t fib_prefix;
330 switch (fid_addr_type (fid))
332 case FID_ADDR_IP_PREF:
333 eid_type = EID_TYPE_API_PREFIX;
334 ip_prefix_to_fib_prefix (&fid_addr_ippref (fid), &fib_prefix);
335 ip_prefix_encode (&fib_prefix, &eid->address.prefix);
338 eid_type = EID_TYPE_API_MAC;
339 mac_address_encode ((mac_address_t *) fid_addr_mac (fid),
347 eid->type = eid_type;
351 vl_api_one_add_del_local_eid_t_handler (vl_api_one_add_del_local_eid_t * mp)
353 vl_api_one_add_del_local_eid_reply_t *rmp;
354 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
356 gid_address_t _eid, *eid = &_eid;
358 u32 locator_set_index = ~0, map_index = ~0;
359 vnet_lisp_add_del_mapping_args_t _a, *a = &_a;
360 u8 *name = NULL, *key = NULL;
361 clib_memset (a, 0, sizeof (a[0]));
362 clib_memset (eid, 0, sizeof (eid[0]));
364 rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->eid);
368 if (gid_address_type (eid) == GID_ADDR_NSH)
370 rv = VNET_API_ERROR_INVALID_VALUE;
374 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
375 name = format (0, "%s", mp->locator_set_name);
376 vec_terminate_c_string (name);
377 p = hash_get_mem (lcm->locator_set_index_by_name, name);
380 rv = VNET_API_ERROR_INVALID_VALUE;
383 locator_set_index = p[0];
385 if (mp->key.id != KEY_ID_API_HMAC_NO_KEY)
386 key = format (0, "%s", mp->key.key);
388 /* XXX treat batch configuration */
389 a->is_add = mp->is_add;
390 gid_address_copy (&a->eid, eid);
391 a->locator_set_index = locator_set_index;
394 a->key_id = mp->key.id;
396 rv = vnet_lisp_add_del_local_mapping (a, &map_index);
401 gid_address_free (&a->eid);
403 REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCAL_EID_REPLY);
407 vl_api_one_eid_table_add_del_map_t_handler
408 (vl_api_one_eid_table_add_del_map_t * mp)
410 vl_api_one_eid_table_add_del_map_reply_t *rmp;
412 rv = vnet_lisp_eid_table_map (clib_net_to_host_u32 (mp->vni),
413 clib_net_to_host_u32 (mp->dp_table),
414 mp->is_l2, mp->is_add);
415 REPLY_MACRO (VL_API_ONE_EID_TABLE_ADD_DEL_MAP_REPLY)}
418 vl_api_one_add_del_map_server_t_handler (vl_api_one_add_del_map_server_t * mp)
420 vl_api_one_add_del_map_server_reply_t *rmp;
424 clib_memset (&addr, 0, sizeof (addr));
426 ip_address_decode2 (&mp->ip_address, &addr);
428 rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
430 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_SERVER_REPLY);
434 vl_api_one_add_del_map_resolver_t_handler (vl_api_one_add_del_map_resolver_t
437 vl_api_one_add_del_map_resolver_reply_t *rmp;
439 vnet_lisp_add_del_map_resolver_args_t _a, *a = &_a;
441 clib_memset (a, 0, sizeof (a[0]));
443 ip_address_decode2 (&mp->ip_address, &a->address);
445 a->is_add = mp->is_add;
447 rv = vnet_lisp_add_del_map_resolver (a);
449 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_RESOLVER_REPLY);
453 vl_api_one_map_register_enable_disable_t_handler
454 (vl_api_one_map_register_enable_disable_t * mp)
456 vl_api_one_map_register_enable_disable_reply_t *rmp;
459 vnet_lisp_map_register_enable_disable (mp->is_enable);
460 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
464 vl_api_one_rloc_probe_enable_disable_t_handler
465 (vl_api_one_rloc_probe_enable_disable_t * mp)
467 vl_api_one_rloc_probe_enable_disable_reply_t *rmp;
470 vnet_lisp_rloc_probe_enable_disable (mp->is_enable);
471 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
475 vl_api_one_enable_disable_t_handler (vl_api_one_enable_disable_t * mp)
477 vl_api_one_enable_disable_reply_t *rmp;
480 vnet_lisp_enable_disable (mp->is_enable);
481 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
485 vl_api_show_one_map_request_mode_t_handler
486 (vl_api_show_one_map_request_mode_t * mp)
489 vl_api_show_one_map_request_mode_reply_t *rmp;
492 REPLY_MACRO2(VL_API_SHOW_ONE_MAP_REQUEST_MODE_REPLY,
494 rmp->mode = vnet_lisp_get_map_request_mode ();
500 vl_api_one_map_request_mode_t_handler (vl_api_one_map_request_mode_t * mp)
502 vl_api_one_map_request_mode_reply_t *rmp;
505 rv = vnet_lisp_set_map_request_mode (mp->mode);
507 REPLY_MACRO (VL_API_ONE_MAP_REQUEST_MODE_REPLY);
511 vl_api_one_nsh_set_locator_set_t_handler (vl_api_one_nsh_set_locator_set_t
514 vl_api_one_nsh_set_locator_set_reply_t *rmp;
518 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
519 ls_name = format (0, "%s", mp->ls_name);
520 vec_terminate_c_string (ls_name);
521 rv = vnet_lisp_nsh_set_locator_set (ls_name, mp->is_add);
524 REPLY_MACRO (VL_API_ONE_PITR_SET_LOCATOR_SET_REPLY);
528 vl_api_one_pitr_set_locator_set_t_handler (vl_api_one_pitr_set_locator_set_t
531 vl_api_one_pitr_set_locator_set_reply_t *rmp;
535 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
536 ls_name = format (0, "%s", mp->ls_name);
537 vec_terminate_c_string (ls_name);
538 rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
541 REPLY_MACRO (VL_API_ONE_PITR_SET_LOCATOR_SET_REPLY);
545 vl_api_one_use_petr_t_handler (vl_api_one_use_petr_t * mp)
547 vl_api_one_use_petr_reply_t *rmp;
551 ip_address_decode2 (&mp->ip_address, &addr);
553 rv = vnet_lisp_use_petr (&addr, mp->is_add);
555 REPLY_MACRO (VL_API_ONE_USE_PETR_REPLY);
559 vl_api_show_one_use_petr_t_handler (vl_api_show_one_use_petr_t * mp)
561 vl_api_show_one_use_petr_reply_t *rmp = NULL;
562 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
564 locator_set_t *ls = 0;
570 clib_memset (&addr, 0, sizeof (addr));
571 status = lcm->flags & LISP_FLAG_USE_PETR;
574 m = pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index);
575 if (~0 != m->locator_set_index)
578 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
579 loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
580 gid_address_copy (&addr, &loc->address);
585 REPLY_MACRO2 (VL_API_SHOW_ONE_USE_PETR_REPLY,
587 rmp->status = status;
588 ip_address_t *ip = &gid_address_ip (&addr);
590 ip_address_encode2 (ip, &rmp->ip_address);
596 vl_api_one_add_del_map_request_itr_rlocs_t_handler
597 (vl_api_one_add_del_map_request_itr_rlocs_t * mp)
599 vl_api_one_add_del_map_request_itr_rlocs_reply_t *rmp;
601 u8 *locator_set_name = NULL;
602 vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
604 mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
605 locator_set_name = format (0, "%s", mp->locator_set_name);
606 vec_terminate_c_string (locator_set_name);
608 a->is_add = mp->is_add;
609 a->locator_set_name = locator_set_name;
611 rv = vnet_lisp_add_del_mreq_itr_rlocs (a);
613 vec_free (locator_set_name);
615 REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
619 vl_api_one_add_del_remote_mapping_t_handler
620 (vl_api_one_add_del_remote_mapping_t * mp)
622 locator_t *rlocs = 0;
623 vl_api_one_add_del_remote_mapping_reply_t *rmp;
625 gid_address_t _eid, *eid = &_eid;
626 u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num);
628 clib_memset (eid, 0, sizeof (eid[0]));
630 rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->deid);
634 rlocs = unformat_one_locs (mp->rlocs, rloc_num);
638 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
639 clib_memset (a, 0, sizeof (a[0]));
640 gid_address_copy (&a->reid, eid);
642 rv = vnet_lisp_add_del_adjacency (a);
649 /* NOTE: for now this works as a static remote mapping, i.e.,
650 * not authoritative and ttl infinite. */
653 vnet_lisp_add_del_mapping_args_t _m_args, *m_args = &_m_args;
654 clib_memset (m_args, 0, sizeof (m_args[0]));
655 gid_address_copy (&m_args->eid, eid);
656 m_args->action = mp->action;
657 m_args->is_static = 1;
659 m_args->authoritative = 0;
660 rv = vnet_lisp_add_mapping (m_args, rlocs, NULL, NULL);
663 rv = vnet_lisp_del_mapping (eid, NULL);
666 vnet_lisp_clear_all_remote_adjacencies ();
671 REPLY_MACRO (VL_API_ONE_ADD_DEL_REMOTE_MAPPING_REPLY);
675 vl_api_one_add_del_adjacency_t_handler (vl_api_one_add_del_adjacency_t * mp)
677 vl_api_one_add_del_adjacency_reply_t *rmp;
678 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
681 clib_memset (a, 0, sizeof (a[0]));
684 unformat_one_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni),
687 unformat_one_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni),
693 a->is_add = mp->is_add;
694 rv = vnet_lisp_add_del_adjacency (a);
697 REPLY_MACRO (VL_API_ONE_ADD_DEL_ADJACENCY_REPLY);
701 send_one_locator_details (lisp_cp_main_t * lcm,
702 locator_t * loc, vl_api_registration_t * reg,
705 vl_api_one_locator_details_t *rmp;
707 rmp = vl_msg_api_alloc (sizeof (*rmp));
708 clib_memset (rmp, 0, sizeof (*rmp));
709 rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_DETAILS);
710 rmp->context = context;
712 rmp->local = loc->local;
715 rmp->sw_if_index = ntohl (loc->sw_if_index);
719 ip_address_encode2 (&loc->address.ippref.addr, &rmp->ip_address);
721 rmp->priority = loc->priority;
722 rmp->weight = loc->weight;
724 vl_api_send_msg (reg, (u8 *) rmp);
728 vl_api_one_locator_dump_t_handler (vl_api_one_locator_dump_t * mp)
731 vl_api_registration_t *reg;
732 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
733 locator_set_t *lsit = 0;
735 u32 ls_index = ~0, *locit = 0;
738 reg = vl_api_client_index_to_registration (mp->client_index);
742 if (mp->is_index_set)
743 ls_index = htonl (mp->ls_index);
746 /* make sure we get a proper C-string */
747 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
748 ls_name = format (0, "%s", mp->ls_name);
749 vec_terminate_c_string (ls_name);
750 p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
756 if (pool_is_free_index (lcm->locator_set_pool, ls_index))
759 lsit = pool_elt_at_index (lcm->locator_set_pool, ls_index);
761 vec_foreach (locit, lsit->locator_indices)
763 loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
764 send_one_locator_details (lcm, loc, reg, mp->context);
771 send_one_locator_set_details (lisp_cp_main_t * lcm,
772 locator_set_t * lsit,
773 vl_api_registration_t * reg, u32 context,
776 vl_api_one_locator_set_details_t *rmp;
779 rmp = vl_msg_api_alloc (sizeof (*rmp));
780 clib_memset (rmp, 0, sizeof (*rmp));
781 rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_SET_DETAILS);
782 rmp->context = context;
784 rmp->ls_index = htonl (ls_index);
787 ASSERT (lsit->name != NULL);
788 strncpy ((char *) rmp->ls_name, (char *) lsit->name,
789 vec_len (lsit->name));
793 str = format (0, "<remote-%d>", ls_index);
794 strncpy ((char *) rmp->ls_name, (char *) str, vec_len (str));
798 vl_api_send_msg (reg, (u8 *) rmp);
802 vl_api_one_locator_set_dump_t_handler (vl_api_one_locator_set_dump_t * mp)
804 vl_api_registration_t *reg;
805 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
806 locator_set_t *lsit = NULL;
809 reg = vl_api_client_index_to_registration (mp->client_index);
815 pool_foreach (lsit, lcm->locator_set_pool,
817 if (filter && !((1 == filter && lsit->local) ||
818 (2 == filter && !lsit->local)))
822 send_one_locator_set_details (lcm, lsit, reg, mp->context,
823 lsit - lcm->locator_set_pool);
829 send_one_eid_table_details (mapping_t * mapit,
830 vl_api_registration_t * reg, u32 context,
833 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
834 locator_set_t *ls = 0;
835 vl_api_one_eid_table_details_t *rmp = NULL;
836 gid_address_t *gid = NULL;
838 fib_prefix_t fib_prefix;
840 if (mapit->pitr_set || mapit->nsh_set)
843 switch (ntohl (filter))
845 case ONE_FILTER_API_ALL: /* all mappings */
848 case ONE_FILTER_API_LOCAL: /* local only */
852 case ONE_FILTER_API_REMOTE: /* remote only */
857 clib_warning ("Filter error, unknown filter: %d", filter);
863 rmp = vl_msg_api_alloc (sizeof (*rmp));
864 clib_memset (rmp, 0, sizeof (*rmp));
865 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_DETAILS);
867 ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index);
868 if (vec_len (ls->locator_indices) == 0)
869 rmp->locator_set_index = ~0;
871 rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index);
873 rmp->is_local = mapit->local;
874 rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
875 rmp->action = mapit->action;
876 rmp->authoritative = mapit->authoritative;
878 switch (gid_address_type (gid))
880 case GID_ADDR_SRC_DST:
881 fid_to_api_eid (&gid_address_sd_src (gid), &rmp->seid);
882 fid_to_api_eid (&gid_address_sd_dst (gid), &rmp->deid);
884 case GID_ADDR_IP_PREFIX:
885 eid_type = EID_TYPE_API_PREFIX;
886 rmp->seid.type = eid_type;
887 ip_prefix_to_fib_prefix (&gid_address_ippref (gid), &fib_prefix);
888 ip_prefix_encode (&fib_prefix, &rmp->seid.address.prefix);
891 eid_type = EID_TYPE_API_MAC;
892 rmp->seid.type = eid_type;
893 mac_address_encode ((mac_address_t *) gid_address_mac (gid),
894 rmp->seid.address.mac);
897 eid_type = EID_TYPE_API_NSH;
898 rmp->seid.type = eid_type;
899 rmp->seid.address.nsh.spi =
900 clib_host_to_net_u32 (gid_address_nsh_spi (gid));
901 rmp->seid.address.nsh.si = gid_address_nsh_si (gid);
908 rmp->context = context;
909 rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
910 rmp->key.id = mapit->key_id;
911 memcpy (rmp->key.key, mapit->key, vec_len (mapit->key));
912 vl_api_send_msg (reg, (u8 *) rmp);
916 vl_api_one_eid_table_dump_t_handler (vl_api_one_eid_table_dump_t * mp)
919 vl_api_registration_t *reg;
920 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
921 mapping_t *mapit = NULL;
922 gid_address_t _eid, *eid = &_eid;
924 reg = vl_api_client_index_to_registration (mp->client_index);
930 clib_memset (eid, 0, sizeof (*eid));
932 unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->eid);
934 mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
938 mapit = pool_elt_at_index (lcm->mapping_pool, mi);
939 send_one_eid_table_details (mapit, reg, mp->context,
940 0 /* ignore filter */ );
945 pool_foreach (mapit, lcm->mapping_pool,
947 send_one_eid_table_details(mapit, reg, mp->context,
955 send_one_map_server_details (ip_address_t * ip, vl_api_registration_t * reg,
958 vl_api_one_map_server_details_t *rmp = NULL;
960 rmp = vl_msg_api_alloc (sizeof (*rmp));
961 clib_memset (rmp, 0, sizeof (*rmp));
962 rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_SERVER_DETAILS);
965 ip_address_encode2 (ip, &rmp->ip_address);
967 rmp->context = context;
969 vl_api_send_msg (reg, (u8 *) rmp);
973 vl_api_one_map_server_dump_t_handler (vl_api_one_map_server_dump_t * mp)
975 vl_api_registration_t *reg;
976 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
979 reg = vl_api_client_index_to_registration (mp->client_index);
983 vec_foreach (mr, lcm->map_servers)
985 send_one_map_server_details (&mr->address, reg, mp->context);
990 send_one_map_resolver_details (ip_address_t * ip,
991 vl_api_registration_t * reg, u32 context)
993 vl_api_one_map_resolver_details_t *rmp = NULL;
995 rmp = vl_msg_api_alloc (sizeof (*rmp));
996 clib_memset (rmp, 0, sizeof (*rmp));
997 rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_RESOLVER_DETAILS);
999 ip_address_encode2 (ip, &rmp->ip_address);
1000 rmp->context = context;
1002 vl_api_send_msg (reg, (u8 *) rmp);
1006 vl_api_one_map_resolver_dump_t_handler (vl_api_one_map_resolver_dump_t * mp)
1008 vl_api_registration_t *reg;
1009 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1012 reg = vl_api_client_index_to_registration (mp->client_index);
1016 vec_foreach (mr, lcm->map_resolvers)
1018 send_one_map_resolver_details (&mr->address, reg, mp->context);
1023 send_eid_table_map_pair (hash_pair_t * p, vl_api_registration_t * reg,
1026 vl_api_one_eid_table_map_details_t *rmp = NULL;
1028 rmp = vl_msg_api_alloc (sizeof (*rmp));
1029 clib_memset (rmp, 0, sizeof (*rmp));
1030 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_MAP_DETAILS);
1032 rmp->vni = clib_host_to_net_u32 (p->key);
1033 rmp->dp_table = clib_host_to_net_u32 (p->value[0]);
1034 rmp->context = context;
1035 vl_api_send_msg (reg, (u8 *) rmp);
1039 vl_api_one_eid_table_map_dump_t_handler (vl_api_one_eid_table_map_dump_t * mp)
1041 vl_api_registration_t *reg;
1042 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1044 uword *vni_table = 0;
1046 reg = vl_api_client_index_to_registration (mp->client_index);
1052 vni_table = lcm->bd_id_by_vni;
1056 vni_table = lcm->table_id_by_vni;
1060 hash_foreach_pair (p, vni_table,
1062 send_eid_table_map_pair (p, reg, mp->context);
1068 send_eid_table_vni (u32 vni, vl_api_registration_t * reg, u32 context)
1070 vl_api_one_eid_table_vni_details_t *rmp = 0;
1072 rmp = vl_msg_api_alloc (sizeof (*rmp));
1073 clib_memset (rmp, 0, sizeof (*rmp));
1074 rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_VNI_DETAILS);
1075 rmp->context = context;
1076 rmp->vni = clib_host_to_net_u32 (vni);
1077 vl_api_send_msg (reg, (u8 *) rmp);
1081 one_adjacency_copy (vl_api_one_adjacency_t * dst, lisp_adjacency_t * adjs)
1083 lisp_adjacency_t *adj;
1084 vl_api_one_adjacency_t a;
1085 u32 i, n = vec_len (adjs);
1086 fib_prefix_t rfib_prefix, lfib_prefix;
1089 for (i = 0; i < n; i++)
1091 adj = vec_elt_at_index (adjs, i);
1092 clib_memset (&a, 0, sizeof (a));
1094 switch (gid_address_type (&adj->reid))
1096 case GID_ADDR_IP_PREFIX:
1097 eid_type = EID_TYPE_API_PREFIX;
1098 ip_prefix_to_fib_prefix (&gid_address_ippref (&adj->reid),
1100 ip_prefix_to_fib_prefix (&gid_address_ippref (&adj->leid),
1102 ip_prefix_encode (&rfib_prefix, &a.reid.address.prefix);
1103 ip_prefix_encode (&lfib_prefix, &a.leid.address.prefix);
1106 eid_type = EID_TYPE_API_PREFIX;
1107 mac_address_encode ((mac_address_t *) gid_address_mac (&adj->reid),
1108 a.reid.address.mac);
1109 mac_address_encode ((mac_address_t *) gid_address_mac (&adj->leid),
1110 a.leid.address.mac);
1113 eid_type = EID_TYPE_API_PREFIX;
1114 a.reid.address.nsh.spi =
1115 clib_host_to_net_u32 (gid_address_nsh_spi (&adj->reid));
1116 a.reid.address.nsh.si = gid_address_nsh_si (&adj->reid);
1117 a.leid.address.nsh.spi =
1118 clib_host_to_net_u32 (gid_address_nsh_spi (&adj->leid));
1119 a.leid.address.nsh.si = gid_address_nsh_si (&adj->leid);
1124 a.reid.type = eid_type;
1125 a.leid.type = eid_type;
1131 vl_api_show_one_rloc_probe_state_t_handler
1132 (vl_api_show_one_rloc_probe_state_t * mp)
1134 vl_api_show_one_rloc_probe_state_reply_t *rmp = 0;
1138 REPLY_MACRO2 (VL_API_SHOW_ONE_RLOC_PROBE_STATE_REPLY,
1140 rmp->is_enable = vnet_lisp_rloc_probe_state_get ();
1146 vl_api_show_one_map_register_state_t_handler
1147 (vl_api_show_one_map_register_state_t * mp)
1149 vl_api_show_one_map_register_state_reply_t *rmp = 0;
1153 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_STATE_REPLY,
1155 rmp->is_enable = vnet_lisp_map_register_state_get ();
1161 vl_api_one_adjacencies_get_t_handler (vl_api_one_adjacencies_get_t * mp)
1163 vl_api_one_adjacencies_get_reply_t *rmp = 0;
1164 lisp_adjacency_t *adjs = 0;
1167 u32 vni = clib_net_to_host_u32 (mp->vni);
1169 adjs = vnet_lisp_adjacencies_get_by_vni (vni);
1170 size = vec_len (adjs) * sizeof (vl_api_one_adjacency_t);
1173 REPLY_MACRO4 (VL_API_ONE_ADJACENCIES_GET_REPLY, size,
1175 rmp->count = clib_host_to_net_u32 (vec_len (adjs));
1176 one_adjacency_copy (rmp->adjacencies, adjs);
1184 vl_api_one_eid_table_vni_dump_t_handler (vl_api_one_eid_table_vni_dump_t * mp)
1188 vl_api_registration_t *reg;
1189 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1191 reg = vl_api_client_index_to_registration (mp->client_index);
1196 hash_foreach_pair (p, lcm->table_id_by_vni,
1198 hash_set (vnis, p->key, 0);
1201 hash_foreach_pair (p, lcm->bd_id_by_vni,
1203 hash_set (vnis, p->key, 0);
1206 hash_foreach_pair (p, vnis,
1208 send_eid_table_vni (p->key, reg, mp->context);
1216 vl_api_show_one_status_t_handler (vl_api_show_one_status_t * mp)
1218 vl_api_show_one_status_reply_t *rmp = NULL;
1222 REPLY_MACRO2(VL_API_SHOW_ONE_STATUS_REPLY,
1224 rmp->gpe_status = vnet_lisp_gpe_enable_disable_status ();
1225 rmp->feature_status = vnet_lisp_enable_disable_status ();
1231 vl_api_one_get_map_request_itr_rlocs_t_handler
1232 (vl_api_one_get_map_request_itr_rlocs_t * mp)
1234 vl_api_one_get_map_request_itr_rlocs_reply_t *rmp = NULL;
1235 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1236 locator_set_t *loc_set = 0;
1240 if (~0 == lcm->mreq_itr_rlocs)
1242 tmp_str = format (0, " ");
1247 pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
1248 tmp_str = format (0, "%s", loc_set->name);
1252 REPLY_MACRO2(VL_API_ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY,
1254 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1255 ARRAY_LEN(rmp->locator_set_name) - 1);
1263 vl_api_show_one_nsh_mapping_t_handler (vl_api_show_one_nsh_mapping_t * mp)
1265 vl_api_show_one_nsh_mapping_reply_t *rmp = NULL;
1266 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1268 locator_set_t *ls = 0;
1273 if (lcm->nsh_map_index == (u32) ~ 0)
1275 tmp_str = format (0, "N/A");
1279 m = pool_elt_at_index (lcm->mapping_pool, lcm->nsh_map_index);
1280 if (~0 != m->locator_set_index)
1283 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1284 tmp_str = format (0, "%s", ls->name);
1289 tmp_str = format (0, "N/A");
1292 vec_add1 (tmp_str, 0);
1295 REPLY_MACRO2(VL_API_SHOW_ONE_NSH_MAPPING_REPLY,
1297 rmp->is_set = is_set;
1298 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1299 ARRAY_LEN(rmp->locator_set_name) - 1);
1305 vl_api_show_one_pitr_t_handler (vl_api_show_one_pitr_t * mp)
1307 vl_api_show_one_pitr_reply_t *rmp = NULL;
1308 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
1310 locator_set_t *ls = 0;
1314 u8 is_enable = (lcm->flags & LISP_FLAG_PITR_MODE)
1315 && lcm->pitr_map_index != ~0;
1319 tmp_str = format (0, "N/A");
1323 m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index);
1324 if (~0 != m->locator_set_index)
1327 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
1328 tmp_str = format (0, "%s", ls->name);
1332 tmp_str = format (0, "N/A");
1335 vec_add1 (tmp_str, 0);
1338 REPLY_MACRO2(VL_API_SHOW_ONE_PITR_REPLY,
1340 rmp->status = lcm->flags & LISP_FLAG_PITR_MODE;
1341 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1342 ARRAY_LEN(rmp->locator_set_name) - 1);
1348 vl_api_show_one_stats_enable_disable_t_handler
1349 (vl_api_show_one_stats_enable_disable_t * mp)
1351 vl_api_show_one_stats_enable_disable_reply_t *rmp = NULL;
1352 vnet_api_error_t rv = 0;
1355 REPLY_MACRO2 (VL_API_SHOW_ONE_STATS_ENABLE_DISABLE_REPLY,
1357 rmp->is_enable = vnet_lisp_stats_enable_disable_state ();
1363 vl_api_one_stats_enable_disable_t_handler
1364 (vl_api_one_stats_enable_disable_t * mp)
1366 vl_api_one_enable_disable_reply_t *rmp = NULL;
1368 vnet_api_error_t rv = vnet_lisp_stats_enable_disable (mp->is_enable);
1369 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
1373 vl_api_one_stats_flush_t_handler (vl_api_one_stats_flush_t * mp)
1375 vl_api_one_stats_flush_reply_t *rmp;
1378 rv = vnet_lisp_flush_stats ();
1379 REPLY_MACRO (VL_API_ONE_STATS_FLUSH_REPLY);
1383 vl_api_one_stats_dump_t_handler (vl_api_one_stats_dump_t * mp)
1385 vl_api_one_stats_details_t *rmp;
1386 lisp_api_stats_t *stats, *stat;
1389 stats = vnet_lisp_get_stats ();
1390 vec_foreach (stat, stats)
1393 REPLY_DETAILS (VL_API_ONE_STATS_DETAILS,
1395 fid_to_api_eid (&stat->deid, &rmp->deid);
1396 fid_to_api_eid (&stat->seid, &rmp->seid);
1397 rmp->vni = clib_host_to_net_u32 (stat->vni);
1399 ip_address_encode2 (&stat->rmt_rloc, &rmp->rloc);
1400 ip_address_encode2 (&stat->loc_rloc, &rmp->lloc);
1402 rmp->pkt_count = clib_host_to_net_u32 (stat->counters.packets);
1403 rmp->bytes = clib_host_to_net_u32 (stat->counters.bytes);
1410 vl_api_one_add_del_l2_arp_entry_t_handler
1411 (vl_api_one_add_del_l2_arp_entry_t * mp)
1413 vl_api_one_add_del_l2_arp_entry_reply_t *rmp;
1415 gid_address_t _arp, *arp = &_arp;
1418 clib_memset (arp, 0, sizeof (*arp));
1420 gid_address_type (arp) = GID_ADDR_ARP;
1421 gid_address_arp_bd (arp) = clib_net_to_host_u32 (mp->bd);
1423 ip4_address_decode (mp->entry.ip4, &ip4);
1424 ip_address_set (&gid_address_arp_ndp_ip (arp), &ip4, AF_IP4);
1425 mac_address_decode (mp->entry.mac, &mac);
1427 rv = vnet_lisp_add_del_l2_arp_ndp_entry (arp, mac.bytes, mp->is_add);
1429 REPLY_MACRO (VL_API_ONE_ADD_DEL_L2_ARP_ENTRY_REPLY);
1433 vl_api_one_add_del_ndp_entry_t_handler (vl_api_one_add_del_ndp_entry_t * mp)
1435 vl_api_one_add_del_ndp_entry_reply_t *rmp;
1437 gid_address_t _g, *g = &_g;
1440 clib_memset (g, 0, sizeof (*g));
1442 gid_address_type (g) = GID_ADDR_NDP;
1443 gid_address_ndp_bd (g) = clib_net_to_host_u32 (mp->bd);
1445 ip6_address_decode (mp->entry.ip6, &ip6);
1446 ip_address_set (&gid_address_arp_ndp_ip (g), &ip6, AF_IP6);
1447 mac_address_decode (mp->entry.mac, &mac);
1449 rv = vnet_lisp_add_del_l2_arp_ndp_entry (g, mac.bytes, mp->is_add);
1451 REPLY_MACRO (VL_API_ONE_ADD_DEL_NDP_ENTRY_REPLY);
1455 vl_api_one_ndp_bd_get_t_handler (vl_api_one_ndp_bd_get_t * mp)
1457 vl_api_one_ndp_bd_get_reply_t *rmp;
1462 u32 *bds = vnet_lisp_ndp_bds_get ();
1463 u32 size = hash_elts (bds) * sizeof (u32);
1466 REPLY_MACRO4 (VL_API_ONE_NDP_BD_GET_REPLY, size,
1468 rmp->count = clib_host_to_net_u32 (hash_elts (bds));
1469 hash_foreach_pair (p, bds,
1471 rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
1480 vl_api_one_l2_arp_bd_get_t_handler (vl_api_one_l2_arp_bd_get_t * mp)
1482 vl_api_one_l2_arp_bd_get_reply_t *rmp;
1487 u32 *bds = vnet_lisp_l2_arp_bds_get ();
1488 u32 size = hash_elts (bds) * sizeof (u32);
1491 REPLY_MACRO4 (VL_API_ONE_L2_ARP_BD_GET_REPLY, size,
1493 rmp->count = clib_host_to_net_u32 (hash_elts (bds));
1494 hash_foreach_pair (p, bds,
1496 rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
1505 vl_api_one_l2_arp_entries_get_t_handler (vl_api_one_l2_arp_entries_get_t * mp)
1507 vl_api_one_l2_arp_entries_get_reply_t *rmp;
1508 lisp_api_l2_arp_entry_t *entries = 0, *e;
1512 u32 bd = clib_net_to_host_u32 (mp->bd);
1514 entries = vnet_lisp_l2_arp_entries_get_by_bd (bd);
1515 u32 size = vec_len (entries) * sizeof (vl_api_one_l2_arp_entry_t);
1518 REPLY_MACRO4 (VL_API_ONE_L2_ARP_ENTRIES_GET_REPLY, size,
1520 rmp->count = clib_host_to_net_u32 (vec_len (entries));
1521 vec_foreach (e, entries)
1523 mac_address_encode ((mac_address_t *) e->mac, rmp->entries[i].mac);
1524 ip4_address_encode ((ip4_address_t *) &e->ip4, rmp->entries[i].ip4);
1534 vl_api_one_map_register_fallback_threshold_t_handler
1535 (vl_api_one_map_register_fallback_threshold_t * mp)
1537 vl_api_one_map_register_fallback_threshold_reply_t *rmp;
1540 mp->value = clib_net_to_host_u32 (mp->value);
1541 rv = vnet_lisp_map_register_fallback_threshold_set (mp->value);
1542 REPLY_MACRO (VL_API_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY);
1546 vl_api_show_one_map_register_fallback_threshold_t_handler
1547 (vl_api_show_one_map_register_fallback_threshold_t * mp)
1549 vl_api_show_one_map_register_fallback_threshold_reply_t *rmp;
1552 u32 value = vnet_lisp_map_register_fallback_threshold_get ();
1555 REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY,
1557 rmp->value = clib_host_to_net_u32 (value);
1563 vl_api_one_set_transport_protocol_t_handler
1564 (vl_api_one_set_transport_protocol_t * mp)
1566 vl_api_one_set_transport_protocol_reply_t *rmp;
1569 rv = vnet_lisp_set_transport_protocol (mp->protocol);
1571 REPLY_MACRO (VL_API_ONE_SET_TRANSPORT_PROTOCOL_REPLY);
1575 vl_api_one_get_transport_protocol_t_handler
1576 (vl_api_one_get_transport_protocol_t * mp)
1578 vl_api_one_get_transport_protocol_reply_t *rmp;
1580 u8 proto = (u8) vnet_lisp_get_transport_protocol ();
1583 REPLY_MACRO2 (VL_API_ONE_GET_TRANSPORT_PROTOCOL_REPLY,
1585 rmp->protocol = proto;
1591 vl_api_one_ndp_entries_get_t_handler (vl_api_one_ndp_entries_get_t * mp)
1593 vl_api_one_ndp_entries_get_reply_t *rmp = 0;
1594 lisp_api_ndp_entry_t *entries = 0, *e;
1598 u32 bd = clib_net_to_host_u32 (mp->bd);
1600 entries = vnet_lisp_ndp_entries_get_by_bd (bd);
1601 u32 size = vec_len (entries) * sizeof (vl_api_one_ndp_entry_t);
1604 REPLY_MACRO4 (VL_API_ONE_NDP_ENTRIES_GET_REPLY, size,
1606 rmp->count = clib_host_to_net_u32 (vec_len (entries));
1607 vec_foreach (e, entries)
1609 mac_address_encode ((mac_address_t *) e->mac, rmp->entries[i].mac);
1610 ip6_address_encode ((ip6_address_t *) &e->ip6, rmp->entries[i].ip6);
1620 vl_api_one_enable_disable_xtr_mode_t_handler
1621 (vl_api_one_enable_disable_xtr_mode_t * mp)
1623 vl_api_one_enable_disable_xtr_mode_reply_t *rmp = 0;
1624 int rv = vnet_lisp_enable_disable_xtr_mode (mp->is_enable);
1626 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_XTR_MODE_REPLY);
1630 vl_api_one_show_xtr_mode_t_handler (vl_api_one_show_xtr_mode_t * mp)
1632 vl_api_one_show_xtr_mode_reply_t *rmp = 0;
1636 REPLY_MACRO2 (VL_API_ONE_SHOW_XTR_MODE_REPLY,
1638 rmp->is_enable = vnet_lisp_get_xtr_mode ();
1644 vl_api_one_enable_disable_pitr_mode_t_handler
1645 (vl_api_one_enable_disable_pitr_mode_t * mp)
1647 vl_api_one_enable_disable_pitr_mode_reply_t *rmp = 0;
1648 int rv = vnet_lisp_enable_disable_pitr_mode (mp->is_enable);
1650 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_PITR_MODE_REPLY);
1654 vl_api_one_show_pitr_mode_t_handler (vl_api_one_show_pitr_mode_t * mp)
1656 vl_api_one_show_pitr_mode_reply_t *rmp = 0;
1660 REPLY_MACRO2 (VL_API_ONE_SHOW_PITR_MODE_REPLY,
1662 rmp->is_enable = vnet_lisp_get_pitr_mode ();
1668 vl_api_one_enable_disable_petr_mode_t_handler
1669 (vl_api_one_enable_disable_petr_mode_t * mp)
1671 vl_api_one_enable_disable_petr_mode_reply_t *rmp = 0;
1672 int rv = vnet_lisp_enable_disable_petr_mode (mp->is_enable);
1674 REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_PETR_MODE_REPLY);
1678 vl_api_one_show_petr_mode_t_handler (vl_api_one_show_petr_mode_t * mp)
1680 vl_api_one_show_petr_mode_reply_t *rmp = 0;
1684 REPLY_MACRO2 (VL_API_ONE_SHOW_PETR_MODE_REPLY,
1686 rmp->is_enable = vnet_lisp_get_petr_mode ();
1693 * Add vpe's API message handlers to the table.
1694 * vlib has already mapped shared memory and
1695 * added the client registration handlers.
1696 * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1698 #define vl_msg_name_crc_list
1699 #include <vnet/vnet_all_api_h.h>
1700 #undef vl_msg_name_crc_list
1703 setup_message_id_table (api_main_t * am)
1705 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1706 foreach_vl_msg_name_crc_one;
1710 static clib_error_t *
1711 one_api_hookup (vlib_main_t * vm)
1713 api_main_t *am = vlibapi_get_main ();
1716 vl_msg_api_set_handlers(VL_API_##N, #n, \
1717 vl_api_##n##_t_handler, \
1719 vl_api_##n##_t_endian, \
1720 vl_api_##n##_t_print, \
1721 sizeof(vl_api_##n##_t), 1);
1722 foreach_vpe_api_msg;
1726 * Set up the (msg_name, crc, message-id) table
1728 setup_message_id_table (am);
1733 VLIB_API_INIT_FUNCTION (one_api_hookup);
1736 * fd.io coding-style-patch-verification: ON
1739 * eval: (c-set-style "gnu")