2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 #include <vlibapi/api.h>
18 #include <vlibmemory/api.h>
19 #include <vppinfra/error.h>
21 #include <vnet/ip/ip_format_fns.h>
22 #include <vnet/ethernet/ethernet_format_fns.h>
23 #include <lisp/lisp-cp/lisp_types.h>
25 /* define message IDs */
26 #include <lisp/lisp-cp/one.api_enum.h>
27 #include <lisp/lisp-cp/one.api_types.h>
28 #include <vpp/api/vpe.api_types.h>
32 /* API message ID base */
38 one_test_main_t one_test_main;
40 #define __plugin_msg_base one_test_main.msg_id_base
41 #include <vlibapi/vat_helper_macros.h>
43 /* Macro to finish up custom dump fns */
44 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
47 vl_print (handle, (char *)s); \
51 #define LISP_PING(_lm, mp_ping) \
52 if (!(_lm)->ping_id) \
53 (_lm)->ping_id = vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC)); \
54 mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping)); \
55 mp_ping->_vl_msg_id = htons ((_lm)->ping_id); \
56 mp_ping->client_index = vam->my_client_index; \
57 fformat (vam->ofp, "Sending ping id=%d\n", (_lm)->ping_id); \
58 vam->result_ready = 0; \
64 } __attribute__ ((__packed__)) lisp_nsh_api_t;
67 unformat_nsh_address (unformat_input_t * input, va_list * args)
69 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
70 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
74 format_nsh_address_vat (u8 * s, va_list * args)
76 nsh_t *a = va_arg (*args, nsh_t *);
77 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
81 format_lisp_transport_protocol (u8 * s, va_list * args)
83 u32 proto = va_arg (*args, u32);
88 return format (s, "udp");
90 return format (s, "api");
98 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
100 vat_main_t *vam = &vat_main;
105 s = format (s, "%=16d%=16d%=16d",
106 ntohl (mp->sw_if_index), mp->priority, mp->weight);
110 s = format (s, "%=16U%=16d%=16d",
112 mp->ip_address, mp->priority, mp->weight);
115 print (vam->ofp, "%v", s);
120 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
123 vat_main_t *vam = &vat_main;
126 ls_name = format (0, "%s", mp->ls_name);
128 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
133 static void vl_api_one_get_transport_protocol_reply_t_handler
134 (vl_api_one_get_transport_protocol_reply_t * mp)
136 vat_main_t *vam = &vat_main;
137 i32 retval = ntohl (mp->retval);
140 vam->async_errors += (retval < 0);
144 u32 proto = mp->protocol;
145 print (vam->ofp, "Transport protocol: %U",
146 format_lisp_transport_protocol, proto);
147 vam->retval = retval;
148 vam->result_ready = 1;
152 static void vl_api_one_add_del_locator_set_reply_t_handler
153 (vl_api_one_add_del_locator_set_reply_t * mp)
155 vat_main_t *vam = &vat_main;
156 i32 retval = ntohl (mp->retval);
159 vam->async_errors += (retval < 0);
163 vam->retval = retval;
164 vam->result_ready = 1;
169 format_lisp_flat_eid (u8 * s, va_list * args)
171 vl_api_eid_t *eid = va_arg (*args, vl_api_eid_t *);
175 case EID_TYPE_API_PREFIX:
176 if (eid->address.prefix.address.af)
177 return format (s, "%U/%d", format_ip6_address,
178 eid->address.prefix.address.un.ip6,
179 eid->address.prefix.len);
180 return format (s, "%U/%d", format_ip4_address,
181 eid->address.prefix.address.un.ip4,
182 eid->address.prefix.len);
183 case EID_TYPE_API_MAC:
184 return format (s, "%U", format_ethernet_address, eid->address.mac);
185 case EID_TYPE_API_NSH:
186 return format (s, "%U", format_nsh_address_vat, eid->address.nsh);
192 format_lisp_eid_vat (u8 * s, va_list * args)
194 vl_api_eid_t *deid = va_arg (*args, vl_api_eid_t *);
195 vl_api_eid_t *seid = va_arg (*args, vl_api_eid_t *);
196 u8 is_src_dst = (u8) va_arg (*args, int);
199 s = format (s, "%U|", format_lisp_flat_eid, seid);
201 s = format (s, "%U", format_lisp_flat_eid, deid);
207 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
209 vat_main_t *vam = &vat_main;
212 if (~0 == mp->locator_set_index)
213 s = format (0, "action: %d", mp->action);
215 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
217 eid = format (0, "%U", format_lisp_eid_vat,
218 &mp->deid, &mp->seid, mp->is_src_dst);
221 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
222 clib_net_to_host_u32 (mp->vni),
224 mp->is_local ? "local" : "remote",
225 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
226 clib_net_to_host_u16 (mp->key.id), mp->key.key);
233 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
235 vat_main_t *vam = &vat_main;
236 u8 *seid = 0, *deid = 0;
237 ip46_address_t lloc, rloc;
239 deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0);
241 seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0);
248 clib_memcpy (&lloc.ip6, mp->lloc.un.ip6, 16);
249 clib_memcpy (&rloc.ip6, mp->rloc.un.ip6, 16);
253 clib_memcpy (&lloc.ip4, mp->lloc.un.ip4, 4);
254 clib_memcpy (&rloc.ip4, mp->rloc.un.ip4, 4);
258 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
259 clib_net_to_host_u32 (mp->vni),
261 format_ip46_address, lloc,
262 format_ip46_address, rloc,
263 clib_net_to_host_u32 (mp->pkt_count),
264 clib_net_to_host_u32 (mp->bytes));
271 vl_api_one_eid_table_map_details_t_handler
272 (vl_api_one_eid_table_map_details_t * mp)
274 vat_main_t *vam = &vat_main;
276 u8 *line = format (0, "%=10d%=10d",
277 clib_net_to_host_u32 (mp->vni),
278 clib_net_to_host_u32 (mp->dp_table));
279 print (vam->ofp, "%v", line);
284 vl_api_one_eid_table_vni_details_t_handler
285 (vl_api_one_eid_table_vni_details_t * mp)
287 vat_main_t *vam = &vat_main;
289 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
290 print (vam->ofp, "%v", line);
295 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
296 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
298 vat_main_t *vam = &vat_main;
299 int retval = clib_net_to_host_u32 (mp->retval);
301 print (vam->ofp, "fallback threshold value: %d", mp->value);
303 vam->retval = retval;
304 vam->result_ready = 1;
308 vl_api_show_one_map_register_state_reply_t_handler
309 (vl_api_show_one_map_register_state_reply_t * mp)
311 vat_main_t *vam = &vat_main;
312 int retval = clib_net_to_host_u32 (mp->retval);
314 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
316 vam->retval = retval;
317 vam->result_ready = 1;
321 vl_api_show_one_rloc_probe_state_reply_t_handler
322 (vl_api_show_one_rloc_probe_state_reply_t * mp)
324 vat_main_t *vam = &vat_main;
325 int retval = clib_net_to_host_u32 (mp->retval);
330 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
332 vam->retval = retval;
333 vam->result_ready = 1;
337 vl_api_show_one_stats_enable_disable_reply_t_handler
338 (vl_api_show_one_stats_enable_disable_reply_t * mp)
340 vat_main_t *vam = &vat_main;
341 int retval = clib_net_to_host_u32 (mp->retval);
346 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
348 vam->retval = retval;
349 vam->result_ready = 1;
353 vl_api_one_ndp_entries_get_reply_t_handler
354 (vl_api_one_ndp_entries_get_reply_t * mp)
356 vat_main_t *vam = &vat_main;
358 int retval = clib_net_to_host_u32 (mp->retval);
363 n = clib_net_to_host_u32 (mp->count);
365 for (i = 0; i < n; i++)
366 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
367 format_ethernet_address, mp->entries[i].mac);
370 vam->retval = retval;
371 vam->result_ready = 1;
375 vl_api_one_l2_arp_entries_get_reply_t_handler
376 (vl_api_one_l2_arp_entries_get_reply_t * mp)
378 vat_main_t *vam = &vat_main;
380 int retval = clib_net_to_host_u32 (mp->retval);
385 n = clib_net_to_host_u32 (mp->count);
387 for (i = 0; i < n; i++)
388 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
389 format_ethernet_address, mp->entries[i].mac);
392 vam->retval = retval;
393 vam->result_ready = 1;
397 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
399 vat_main_t *vam = &vat_main;
401 int retval = clib_net_to_host_u32 (mp->retval);
406 n = clib_net_to_host_u32 (mp->count);
408 for (i = 0; i < n; i++)
410 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
414 vam->retval = retval;
415 vam->result_ready = 1;
419 vl_api_one_l2_arp_bd_get_reply_t_handler
420 (vl_api_one_l2_arp_bd_get_reply_t * mp)
422 vat_main_t *vam = &vat_main;
424 int retval = clib_net_to_host_u32 (mp->retval);
429 n = clib_net_to_host_u32 (mp->count);
431 for (i = 0; i < n; i++)
433 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
437 vam->retval = retval;
438 vam->result_ready = 1;
442 vl_api_one_adjacencies_get_reply_t_handler
443 (vl_api_one_adjacencies_get_reply_t * mp)
445 vat_main_t *vam = &vat_main;
447 int retval = clib_net_to_host_u32 (mp->retval);
448 vl_api_one_adjacency_t *a;
453 n = clib_net_to_host_u32 (mp->count);
455 for (i = 0; i < n; i++)
457 a = &mp->adjacencies[i];
458 print (vam->ofp, "%U %40U",
459 format_lisp_flat_eid, a->leid, format_lisp_flat_eid, a->reid);
463 vam->retval = retval;
464 vam->result_ready = 1;
468 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
470 vat_main_t *vam = &vat_main;
472 print (vam->ofp, "%=20U",
473 mp->ip_address.af ? format_ip6_address : format_ip4_address,
478 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
481 vat_main_t *vam = &vat_main;
483 print (vam->ofp, "%=20U",
484 mp->ip_address.af ? format_ip6_address : format_ip4_address,
489 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
491 vat_main_t *vam = &vat_main;
492 i32 retval = ntohl (mp->retval);
496 print (vam->ofp, "feature: %s\ngpe: %s",
497 mp->feature_status ? "enabled" : "disabled",
498 mp->gpe_status ? "enabled" : "disabled");
501 vam->retval = retval;
502 vam->result_ready = 1;
506 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
507 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
509 vat_main_t *vam = &vat_main;
510 i32 retval = ntohl (mp->retval);
514 print (vam->ofp, "%=20s", mp->locator_set_name);
517 vam->retval = retval;
518 vam->result_ready = 1;
522 format_lisp_map_request_mode (u8 * s, va_list * args)
524 u32 mode = va_arg (*args, u32);
529 return format (0, "dst-only");
531 return format (0, "src-dst");
537 vl_api_show_one_map_request_mode_reply_t_handler
538 (vl_api_show_one_map_request_mode_reply_t * mp)
540 vat_main_t *vam = &vat_main;
541 i32 retval = ntohl (mp->retval);
546 print (vam->ofp, "map_request_mode: %U",
547 format_lisp_map_request_mode, mode);
550 vam->retval = retval;
551 vam->result_ready = 1;
555 vl_api_one_show_xtr_mode_reply_t_handler
556 (vl_api_one_show_xtr_mode_reply_t * mp)
558 vat_main_t *vam = &vat_main;
559 i32 retval = ntohl (mp->retval);
563 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
566 vam->retval = retval;
567 vam->result_ready = 1;
571 vl_api_one_show_pitr_mode_reply_t_handler
572 (vl_api_one_show_pitr_mode_reply_t * mp)
574 vat_main_t *vam = &vat_main;
575 i32 retval = ntohl (mp->retval);
579 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
582 vam->retval = retval;
583 vam->result_ready = 1;
587 vl_api_one_show_petr_mode_reply_t_handler
588 (vl_api_one_show_petr_mode_reply_t * mp)
590 vat_main_t *vam = &vat_main;
591 i32 retval = ntohl (mp->retval);
595 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
598 vam->retval = retval;
599 vam->result_ready = 1;
603 vl_api_show_one_use_petr_reply_t_handler
604 (vl_api_show_one_use_petr_reply_t * mp)
606 vat_main_t *vam = &vat_main;
607 i32 retval = ntohl (mp->retval);
611 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
614 print (vam->ofp, "Proxy-ETR address; %U",
615 mp->ip_address.af ? format_ip6_address : format_ip4_address,
620 vam->retval = retval;
621 vam->result_ready = 1;
625 vl_api_show_one_nsh_mapping_reply_t_handler
626 (vl_api_show_one_nsh_mapping_reply_t * mp)
628 vat_main_t *vam = &vat_main;
629 i32 retval = ntohl (mp->retval);
633 print (vam->ofp, "%-20s%-16s",
634 mp->is_set ? "set" : "not-set",
635 mp->is_set ? (char *) mp->locator_set_name : "");
638 vam->retval = retval;
639 vam->result_ready = 1;
643 vl_api_show_one_map_register_ttl_reply_t_handler
644 (vl_api_show_one_map_register_ttl_reply_t * mp)
646 vat_main_t *vam = &vat_main;
647 i32 retval = ntohl (mp->retval);
651 print (vam->ofp, "ttl: %u", mp->ttl);
654 vam->retval = retval;
655 vam->result_ready = 1;
659 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
661 vat_main_t *vam = &vat_main;
662 i32 retval = ntohl (mp->retval);
666 print (vam->ofp, "%-20s%-16s",
667 mp->status ? "enabled" : "disabled",
668 mp->status ? (char *) mp->locator_set_name : "");
671 vam->retval = retval;
672 vam->result_ready = 1;
676 /** Used for parsing LISP eids */
677 typedef CLIB_PACKED(struct{
683 u32 len; /**< prefix length if IP */
684 u8 type; /**< type of eid */
689 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
691 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
693 clib_memset (a, 0, sizeof (a[0]));
695 if (unformat (input, "%U/%d", unformat_ip46_address, a->addr.ip, &a->len))
697 a->type = 0; /* ip prefix type */
699 else if (unformat (input, "%U", unformat_ethernet_address, &a->addr.mac))
701 a->type = 1; /* mac type */
703 else if (unformat (input, "%U", unformat_nsh_address, a->addr.nsh))
705 a->type = 2; /* NSH type */
706 a->addr.nsh.spi = clib_host_to_net_u32 (a->addr.nsh.spi);
715 if (ip46_address_is_ip4 (&a->addr.ip))
716 return a->len > 32 ? 1 : 0;
718 return a->len > 128 ? 1 : 0;
725 lisp_eid_put_vat (vl_api_eid_t * eid, const lisp_eid_vat_t * vat_eid)
727 eid->type = vat_eid->type;
730 case EID_TYPE_API_PREFIX:
731 if (ip46_address_is_ip4 (&vat_eid->addr.ip))
733 clib_memcpy (&eid->address.prefix.address.un.ip4,
734 &vat_eid->addr.ip.ip4, 4);
735 eid->address.prefix.address.af = ADDRESS_IP4;
736 eid->address.prefix.len = vat_eid->len;
740 clib_memcpy (&eid->address.prefix.address.un.ip6,
741 &vat_eid->addr.ip.ip6, 16);
742 eid->address.prefix.address.af = ADDRESS_IP6;
743 eid->address.prefix.len = vat_eid->len;
746 case EID_TYPE_API_MAC:
747 clib_memcpy (&eid->address.mac, &vat_eid->addr.mac,
748 sizeof (eid->address.mac));
750 case EID_TYPE_API_NSH:
751 clib_memcpy (&eid->address.nsh, &vat_eid->addr.nsh,
752 sizeof (eid->address.nsh));
761 api_one_add_del_locator_set (vat_main_t * vam)
763 unformat_input_t *input = vam->input;
764 vl_api_one_add_del_locator_set_t *mp;
766 u8 *locator_set_name = NULL;
767 u8 locator_set_name_set = 0;
768 vl_api_local_locator_t locator, *locators = 0;
769 u32 sw_if_index, priority, weight;
773 /* Parse args required to build the message */
774 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
776 if (unformat (input, "del"))
780 else if (unformat (input, "locator-set %s", &locator_set_name))
782 locator_set_name_set = 1;
784 else if (unformat (input, "sw_if_index %u p %u w %u",
785 &sw_if_index, &priority, &weight))
787 locator.sw_if_index = htonl (sw_if_index);
788 locator.priority = priority;
789 locator.weight = weight;
790 vec_add1 (locators, locator);
794 (input, "iface %U p %u w %u", unformat_sw_if_index, vam,
795 &sw_if_index, &priority, &weight))
797 locator.sw_if_index = htonl (sw_if_index);
798 locator.priority = priority;
799 locator.weight = weight;
800 vec_add1 (locators, locator);
806 if (locator_set_name_set == 0)
808 errmsg ("missing locator-set name");
813 if (vec_len (locator_set_name) > 64)
815 errmsg ("locator-set name too long");
816 vec_free (locator_set_name);
820 vec_add1 (locator_set_name, 0);
822 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
824 /* Construct the API message */
825 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
828 clib_memcpy (mp->locator_set_name, locator_set_name,
829 vec_len (locator_set_name));
830 vec_free (locator_set_name);
832 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
834 clib_memcpy (mp->locators, locators, data_len);
840 /* Wait for a reply... */
845 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
848 api_one_add_del_locator (vat_main_t * vam)
850 unformat_input_t *input = vam->input;
851 vl_api_one_add_del_locator_t *mp;
852 u32 tmp_if_index = ~0;
853 u32 sw_if_index = ~0;
854 u8 sw_if_index_set = 0;
855 u8 sw_if_index_if_name_set = 0;
861 u8 *locator_set_name = NULL;
862 u8 locator_set_name_set = 0;
865 /* Parse args required to build the message */
866 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
868 if (unformat (input, "del"))
872 else if (unformat (input, "locator-set %s", &locator_set_name))
874 locator_set_name_set = 1;
876 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
879 sw_if_index_if_name_set = 1;
880 sw_if_index = tmp_if_index;
882 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
885 sw_if_index = tmp_if_index;
887 else if (unformat (input, "p %d", &priority))
891 else if (unformat (input, "w %d", &weight))
899 if (locator_set_name_set == 0)
901 errmsg ("missing locator-set name");
905 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
907 errmsg ("missing sw_if_index");
908 vec_free (locator_set_name);
912 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
914 errmsg ("cannot use both params interface name and sw_if_index");
915 vec_free (locator_set_name);
919 if (priority_set == 0)
921 errmsg ("missing locator-set priority");
922 vec_free (locator_set_name);
928 errmsg ("missing locator-set weight");
929 vec_free (locator_set_name);
933 if (vec_len (locator_set_name) > 64)
935 errmsg ("locator-set name too long");
936 vec_free (locator_set_name);
939 vec_add1 (locator_set_name, 0);
941 /* Construct the API message */
942 M (ONE_ADD_DEL_LOCATOR, mp);
945 mp->sw_if_index = ntohl (sw_if_index);
946 mp->priority = priority;
948 clib_memcpy (mp->locator_set_name, locator_set_name,
949 vec_len (locator_set_name));
950 vec_free (locator_set_name);
955 /* Wait for a reply... */
960 #define api_lisp_add_del_locator api_one_add_del_locator
963 api_one_add_del_local_eid (vat_main_t * vam)
965 unformat_input_t *input = vam->input;
966 vl_api_one_add_del_local_eid_t *mp;
969 lisp_eid_vat_t _eid, *eid = &_eid;
970 u8 *locator_set_name = 0;
971 u8 locator_set_name_set = 0;
977 /* Parse args required to build the message */
978 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
980 if (unformat (input, "del"))
984 else if (unformat (input, "vni %d", &vni))
988 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
992 else if (unformat (input, "locator-set %s", &locator_set_name))
994 locator_set_name_set = 1;
996 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
998 else if (unformat (input, "secret-key %_%v%_", &key))
1004 if (locator_set_name_set == 0)
1006 errmsg ("missing locator-set name");
1012 errmsg ("EID address not set!");
1013 vec_free (locator_set_name);
1017 if (key && (0 == key_id))
1019 errmsg ("invalid key_id!");
1023 if (vec_len (key) > 64)
1025 errmsg ("key too long");
1030 if (vec_len (locator_set_name) > 64)
1032 errmsg ("locator-set name too long");
1033 vec_free (locator_set_name);
1036 vec_add1 (locator_set_name, 0);
1038 /* Construct the API message */
1039 M (ONE_ADD_DEL_LOCAL_EID, mp);
1041 mp->is_add = is_add;
1042 lisp_eid_put_vat (&mp->eid, eid);
1043 mp->vni = clib_host_to_net_u32 (vni);
1044 mp->key.id = key_id;
1045 clib_memcpy (mp->locator_set_name, locator_set_name,
1046 vec_len (locator_set_name));
1047 clib_memcpy (mp->key.key, key, vec_len (key));
1049 vec_free (locator_set_name);
1055 /* Wait for a reply... */
1061 api_one_add_del_map_server (vat_main_t * vam)
1063 unformat_input_t *input = vam->input;
1064 vl_api_one_add_del_map_server_t *mp;
1072 /* Parse args required to build the message */
1073 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1075 if (unformat (input, "del"))
1079 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
1083 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
1091 if (ipv4_set && ipv6_set)
1093 errmsg ("both eid v4 and v6 addresses set");
1097 if (!ipv4_set && !ipv6_set)
1099 errmsg ("eid addresses not set");
1103 /* Construct the API message */
1104 M (ONE_ADD_DEL_MAP_SERVER, mp);
1106 mp->is_add = is_add;
1109 mp->ip_address.af = 1;
1110 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
1114 mp->ip_address.af = 0;
1115 clib_memcpy (mp->ip_address.un.ip4, &ipv4, sizeof (ipv4));
1121 /* Wait for a reply... */
1126 #define api_lisp_add_del_map_server api_one_add_del_map_server
1129 api_one_add_del_map_resolver (vat_main_t * vam)
1131 unformat_input_t *input = vam->input;
1132 vl_api_one_add_del_map_resolver_t *mp;
1140 /* Parse args required to build the message */
1141 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1143 if (unformat (input, "del"))
1147 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
1151 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
1159 if (ipv4_set && ipv6_set)
1161 errmsg ("both eid v4 and v6 addresses set");
1165 if (!ipv4_set && !ipv6_set)
1167 errmsg ("eid addresses not set");
1171 /* Construct the API message */
1172 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
1174 mp->is_add = is_add;
1177 mp->ip_address.af = 1;
1178 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
1182 mp->ip_address.af = 0;
1183 clib_memcpy (mp->ip_address.un.ip6, &ipv4, sizeof (ipv4));
1189 /* Wait for a reply... */
1195 api_one_rloc_probe_enable_disable (vat_main_t * vam)
1197 unformat_input_t *input = vam->input;
1198 vl_api_one_rloc_probe_enable_disable_t *mp;
1203 /* Parse args required to build the message */
1204 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1206 if (unformat (input, "enable"))
1211 else if (unformat (input, "disable"))
1219 errmsg ("Value not set");
1223 /* Construct the API message */
1224 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
1226 mp->is_enable = is_enable;
1231 /* Wait for a reply... */
1236 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
1239 api_one_map_register_enable_disable (vat_main_t * vam)
1241 unformat_input_t *input = vam->input;
1242 vl_api_one_map_register_enable_disable_t *mp;
1247 /* Parse args required to build the message */
1248 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1250 if (unformat (input, "enable"))
1255 else if (unformat (input, "disable"))
1263 errmsg ("Value not set");
1267 /* Construct the API message */
1268 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
1270 mp->is_enable = is_enable;
1275 /* Wait for a reply... */
1280 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
1283 api_one_enable_disable (vat_main_t * vam)
1285 unformat_input_t *input = vam->input;
1286 vl_api_one_enable_disable_t *mp;
1291 /* Parse args required to build the message */
1292 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1294 if (unformat (input, "enable"))
1299 else if (unformat (input, "disable"))
1309 errmsg ("Value not set");
1313 /* Construct the API message */
1314 M (ONE_ENABLE_DISABLE, mp);
1316 mp->is_enable = is_enable;
1321 /* Wait for a reply... */
1326 #define api_lisp_enable_disable api_one_enable_disable
1329 api_one_enable_disable_xtr_mode (vat_main_t * vam)
1331 unformat_input_t *input = vam->input;
1332 vl_api_one_enable_disable_xtr_mode_t *mp;
1337 /* Parse args required to build the message */
1338 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1340 if (unformat (input, "enable"))
1345 else if (unformat (input, "disable"))
1355 errmsg ("Value not set");
1359 /* Construct the API message */
1360 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
1362 mp->is_enable = is_enable;
1367 /* Wait for a reply... */
1373 api_one_show_xtr_mode (vat_main_t * vam)
1375 vl_api_one_show_xtr_mode_t *mp;
1378 /* Construct the API message */
1379 M (ONE_SHOW_XTR_MODE, mp);
1384 /* Wait for a reply... */
1390 api_one_enable_disable_pitr_mode (vat_main_t * vam)
1392 unformat_input_t *input = vam->input;
1393 vl_api_one_enable_disable_pitr_mode_t *mp;
1398 /* Parse args required to build the message */
1399 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1401 if (unformat (input, "enable"))
1406 else if (unformat (input, "disable"))
1416 errmsg ("Value not set");
1420 /* Construct the API message */
1421 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
1423 mp->is_enable = is_enable;
1428 /* Wait for a reply... */
1434 api_one_show_pitr_mode (vat_main_t * vam)
1436 vl_api_one_show_pitr_mode_t *mp;
1439 /* Construct the API message */
1440 M (ONE_SHOW_PITR_MODE, mp);
1445 /* Wait for a reply... */
1451 api_one_enable_disable_petr_mode (vat_main_t * vam)
1453 unformat_input_t *input = vam->input;
1454 vl_api_one_enable_disable_petr_mode_t *mp;
1459 /* Parse args required to build the message */
1460 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1462 if (unformat (input, "enable"))
1467 else if (unformat (input, "disable"))
1477 errmsg ("Value not set");
1481 /* Construct the API message */
1482 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
1484 mp->is_enable = is_enable;
1489 /* Wait for a reply... */
1495 api_one_show_petr_mode (vat_main_t * vam)
1497 vl_api_one_show_petr_mode_t *mp;
1500 /* Construct the API message */
1501 M (ONE_SHOW_PETR_MODE, mp);
1506 /* Wait for a reply... */
1512 api_show_one_map_register_state (vat_main_t * vam)
1514 vl_api_show_one_map_register_state_t *mp;
1517 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
1522 /* wait for reply */
1527 #define api_show_lisp_map_register_state api_show_one_map_register_state
1530 api_show_one_rloc_probe_state (vat_main_t * vam)
1532 vl_api_show_one_rloc_probe_state_t *mp;
1535 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
1540 /* wait for reply */
1545 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
1548 api_one_add_del_ndp_entry (vat_main_t * vam)
1550 vl_api_one_add_del_ndp_entry_t *mp;
1551 unformat_input_t *input = vam->input;
1557 u8 ip6[16] = { 0, };
1561 /* Parse args required to build the message */
1562 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1564 if (unformat (input, "del"))
1566 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
1568 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
1570 else if (unformat (input, "bd %d", &bd))
1574 errmsg ("parse error '%U'", format_unformat_error, input);
1579 if (!bd_set || !ip_set || (!mac_set && is_add))
1581 errmsg ("Missing BD, IP or MAC!");
1585 M (ONE_ADD_DEL_NDP_ENTRY, mp);
1586 mp->is_add = is_add;
1587 clib_memcpy (&mp->entry.mac, mac, 6);
1588 mp->bd = clib_host_to_net_u32 (bd);
1589 clib_memcpy (&mp->entry.ip6, ip6, sizeof (mp->entry.ip6));
1594 /* wait for reply */
1600 api_one_add_del_l2_arp_entry (vat_main_t * vam)
1602 vl_api_one_add_del_l2_arp_entry_t *mp;
1603 unformat_input_t *input = vam->input;
1609 u32 ip4 = 0, bd = ~0;
1612 /* Parse args required to build the message */
1613 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1615 if (unformat (input, "del"))
1617 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
1619 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
1621 else if (unformat (input, "bd %d", &bd))
1625 errmsg ("parse error '%U'", format_unformat_error, input);
1630 if (!bd_set || !ip_set || (!mac_set && is_add))
1632 errmsg ("Missing BD, IP or MAC!");
1636 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
1637 mp->is_add = is_add;
1638 clib_memcpy (&mp->entry.mac, mac, 6);
1639 mp->bd = clib_host_to_net_u32 (bd);
1640 clib_memcpy (mp->entry.ip4, &ip4, sizeof (mp->entry.ip4));
1645 /* wait for reply */
1651 api_one_ndp_bd_get (vat_main_t * vam)
1653 vl_api_one_ndp_bd_get_t *mp;
1656 M (ONE_NDP_BD_GET, mp);
1661 /* wait for reply */
1667 api_one_ndp_entries_get (vat_main_t * vam)
1669 vl_api_one_ndp_entries_get_t *mp;
1670 unformat_input_t *input = vam->input;
1675 /* Parse args required to build the message */
1676 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1678 if (unformat (input, "bd %d", &bd))
1682 errmsg ("parse error '%U'", format_unformat_error, input);
1689 errmsg ("Expected bridge domain!");
1693 M (ONE_NDP_ENTRIES_GET, mp);
1694 mp->bd = clib_host_to_net_u32 (bd);
1699 /* wait for reply */
1705 api_one_l2_arp_bd_get (vat_main_t * vam)
1707 vl_api_one_l2_arp_bd_get_t *mp;
1710 M (ONE_L2_ARP_BD_GET, mp);
1715 /* wait for reply */
1721 api_one_l2_arp_entries_get (vat_main_t * vam)
1723 vl_api_one_l2_arp_entries_get_t *mp;
1724 unformat_input_t *input = vam->input;
1729 /* Parse args required to build the message */
1730 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1732 if (unformat (input, "bd %d", &bd))
1736 errmsg ("parse error '%U'", format_unformat_error, input);
1743 errmsg ("Expected bridge domain!");
1747 M (ONE_L2_ARP_ENTRIES_GET, mp);
1748 mp->bd = clib_host_to_net_u32 (bd);
1753 /* wait for reply */
1759 api_one_stats_enable_disable (vat_main_t * vam)
1761 vl_api_one_stats_enable_disable_t *mp;
1762 unformat_input_t *input = vam->input;
1767 /* Parse args required to build the message */
1768 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1770 if (unformat (input, "enable"))
1775 else if (unformat (input, "disable"))
1785 errmsg ("Value not set");
1789 M (ONE_STATS_ENABLE_DISABLE, mp);
1790 mp->is_enable = is_enable;
1795 /* wait for reply */
1801 api_show_one_stats_enable_disable (vat_main_t * vam)
1803 vl_api_show_one_stats_enable_disable_t *mp;
1806 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
1811 /* wait for reply */
1817 api_show_one_map_request_mode (vat_main_t * vam)
1819 vl_api_show_one_map_request_mode_t *mp;
1822 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
1827 /* wait for reply */
1832 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
1835 api_one_map_request_mode (vat_main_t * vam)
1837 unformat_input_t *input = vam->input;
1838 vl_api_one_map_request_mode_t *mp;
1842 /* Parse args required to build the message */
1843 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1845 if (unformat (input, "dst-only"))
1847 else if (unformat (input, "src-dst"))
1851 errmsg ("parse error '%U'", format_unformat_error, input);
1856 M (ONE_MAP_REQUEST_MODE, mp);
1863 /* wait for reply */
1868 #define api_lisp_map_request_mode api_one_map_request_mode
1871 * Enable/disable ONE proxy ITR.
1873 * @param vam vpp API test context
1874 * @return return code
1877 api_one_pitr_set_locator_set (vat_main_t * vam)
1880 unformat_input_t *input = vam->input;
1881 vl_api_one_pitr_set_locator_set_t *mp;
1886 /* Parse args required to build the message */
1887 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1889 if (unformat (input, "del"))
1891 else if (unformat (input, "locator-set %s", &ls_name))
1895 errmsg ("parse error '%U'", format_unformat_error, input);
1902 errmsg ("locator-set name not set!");
1906 M (ONE_PITR_SET_LOCATOR_SET, mp);
1908 mp->is_add = is_add;
1909 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
1915 /* wait for reply */
1920 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
1923 api_one_nsh_set_locator_set (vat_main_t * vam)
1926 unformat_input_t *input = vam->input;
1927 vl_api_one_nsh_set_locator_set_t *mp;
1932 /* Parse args required to build the message */
1933 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1935 if (unformat (input, "del"))
1937 else if (unformat (input, "ls %s", &ls_name))
1941 errmsg ("parse error '%U'", format_unformat_error, input);
1946 if (!ls_name_set && is_add)
1948 errmsg ("locator-set name not set!");
1952 M (ONE_NSH_SET_LOCATOR_SET, mp);
1954 mp->is_add = is_add;
1955 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
1961 /* wait for reply */
1967 api_show_one_pitr (vat_main_t * vam)
1969 vl_api_show_one_pitr_t *mp;
1972 if (!vam->json_output)
1974 print (vam->ofp, "%=20s", "lisp status:");
1977 M (SHOW_ONE_PITR, mp);
1981 /* Wait for a reply... */
1986 #define api_show_lisp_pitr api_show_one_pitr
1989 api_one_use_petr (vat_main_t * vam)
1991 unformat_input_t *input = vam->input;
1992 vl_api_one_use_petr_t *mp;
1997 clib_memset (&ip, 0, sizeof (ip));
1999 /* Parse args required to build the message */
2000 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2002 if (unformat (input, "disable"))
2005 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
2008 ip_addr_version (&ip) = AF_IP4;
2011 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
2014 ip_addr_version (&ip) = AF_IP6;
2018 errmsg ("parse error '%U'", format_unformat_error, input);
2023 M (ONE_USE_PETR, mp);
2025 mp->is_add = is_add;
2028 mp->ip_address.af = ip_addr_version (&ip) == AF_IP4 ? 0 : 1;
2029 if (mp->ip_address.af)
2030 clib_memcpy (mp->ip_address.un.ip6, &ip, 16);
2032 clib_memcpy (mp->ip_address.un.ip4, &ip, 4);
2038 /* wait for reply */
2043 #define api_lisp_use_petr api_one_use_petr
2046 api_show_one_nsh_mapping (vat_main_t * vam)
2048 vl_api_show_one_use_petr_t *mp;
2051 if (!vam->json_output)
2053 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
2056 M (SHOW_ONE_NSH_MAPPING, mp);
2060 /* Wait for a reply... */
2066 api_show_one_use_petr (vat_main_t * vam)
2068 vl_api_show_one_use_petr_t *mp;
2071 if (!vam->json_output)
2073 print (vam->ofp, "%=20s", "Proxy-ETR status:");
2076 M (SHOW_ONE_USE_PETR, mp);
2080 /* Wait for a reply... */
2085 #define api_show_lisp_use_petr api_show_one_use_petr
2088 * Add/delete mapping between vni and vrf
2091 api_one_eid_table_add_del_map (vat_main_t * vam)
2093 unformat_input_t *input = vam->input;
2094 vl_api_one_eid_table_add_del_map_t *mp;
2095 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
2096 u32 vni, vrf, bd_index;
2099 /* Parse args required to build the message */
2100 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2102 if (unformat (input, "del"))
2104 else if (unformat (input, "vrf %d", &vrf))
2106 else if (unformat (input, "bd_index %d", &bd_index))
2108 else if (unformat (input, "vni %d", &vni))
2114 if (!vni_set || (!vrf_set && !bd_index_set))
2116 errmsg ("missing arguments!");
2120 if (vrf_set && bd_index_set)
2122 errmsg ("error: both vrf and bd entered!");
2126 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
2128 mp->is_add = is_add;
2129 mp->vni = htonl (vni);
2130 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
2131 mp->is_l2 = bd_index_set;
2136 /* wait for reply */
2141 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
2144 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
2146 u32 *action = va_arg (*args, u32 *);
2149 if (unformat (input, "%s", &s))
2151 if (!strcmp ((char *) s, "no-action"))
2153 else if (!strcmp ((char *) s, "natively-forward"))
2155 else if (!strcmp ((char *) s, "send-map-request"))
2157 else if (!strcmp ((char *) s, "drop"))
2161 clib_warning ("invalid action: '%s'", s);
2173 * Add/del remote mapping to/from ONE control plane
2175 * @param vam vpp API test context
2176 * @return return code
2179 api_one_add_del_remote_mapping (vat_main_t * vam)
2181 unformat_input_t *input = vam->input;
2182 vl_api_one_add_del_remote_mapping_t *mp;
2184 lisp_eid_vat_t _eid, *eid = &_eid;
2185 lisp_eid_vat_t _seid, *seid = &_seid;
2186 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
2187 u32 action = ~0, p, w, data_len;
2188 ip4_address_t rloc4;
2189 ip6_address_t rloc6;
2190 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
2193 clib_memset (&rloc, 0, sizeof (rloc));
2195 /* Parse args required to build the message */
2196 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2198 if (unformat (input, "del-all"))
2202 else if (unformat (input, "del"))
2206 else if (unformat (input, "add"))
2210 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
2214 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
2218 else if (unformat (input, "vni %d", &vni))
2222 else if (unformat (input, "p %d w %d", &p, &w))
2226 errmsg ("No RLOC configured for setting priority/weight!");
2229 curr_rloc->priority = p;
2230 curr_rloc->weight = w;
2232 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
2234 rloc.ip_address.af = 0;
2235 clib_memcpy (&rloc.ip_address.un.ip6, &rloc6, sizeof (rloc6));
2236 vec_add1 (rlocs, rloc);
2237 curr_rloc = &rlocs[vec_len (rlocs) - 1];
2239 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
2241 rloc.ip_address.af = 1;
2242 clib_memcpy (&rloc.ip_address.un.ip4, &rloc4, sizeof (rloc4));
2243 vec_add1 (rlocs, rloc);
2244 curr_rloc = &rlocs[vec_len (rlocs) - 1];
2246 else if (unformat (input, "action %U",
2247 unformat_negative_mapping_action, &action))
2253 clib_warning ("parse error '%U'", format_unformat_error, input);
2260 errmsg ("missing params!");
2264 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
2266 errmsg ("no action set for negative map-reply!");
2270 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
2272 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
2273 mp->is_add = is_add;
2274 mp->vni = htonl (vni);
2275 mp->action = (u8) action;
2276 mp->is_src_dst = seid_set;
2277 mp->del_all = del_all;
2278 lisp_eid_put_vat (&mp->deid, eid);
2279 lisp_eid_put_vat (&mp->seid, seid);
2281 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
2282 clib_memcpy (mp->rlocs, rlocs, data_len);
2288 /* Wait for a reply... */
2293 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
2296 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
2297 * forwarding entries in data-plane accordingly.
2299 * @param vam vpp API test context
2300 * @return return code
2303 api_one_add_del_adjacency (vat_main_t * vam)
2305 unformat_input_t *input = vam->input;
2306 vl_api_one_add_del_adjacency_t *mp;
2310 lisp_eid_vat_t leid, reid;
2312 leid.type = reid.type = (u8) ~ 0;
2314 /* Parse args required to build the message */
2315 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2317 if (unformat (input, "del"))
2321 else if (unformat (input, "add"))
2325 else if (unformat (input, "reid %U/%d", unformat_ip46_address,
2326 &reid.addr.ip, &reid.len))
2328 reid.type = 0; /* ipv4 */
2330 else if (unformat (input, "reid %U", unformat_ethernet_address,
2333 reid.type = 1; /* mac */
2335 else if (unformat (input, "leid %U/%d", unformat_ip46_address,
2336 &leid.addr.ip, &leid.len))
2338 leid.type = 0; /* ipv4 */
2340 else if (unformat (input, "leid %U", unformat_ethernet_address,
2343 leid.type = 1; /* mac */
2345 else if (unformat (input, "vni %d", &vni))
2351 errmsg ("parse error '%U'", format_unformat_error, input);
2356 if ((u8) ~ 0 == reid.type)
2358 errmsg ("missing params!");
2362 if (leid.type != reid.type)
2364 errmsg ("remote and local EIDs are of different types!");
2368 M (ONE_ADD_DEL_ADJACENCY, mp);
2369 mp->is_add = is_add;
2370 mp->vni = htonl (vni);
2371 lisp_eid_put_vat (&mp->leid, &leid);
2372 lisp_eid_put_vat (&mp->reid, &reid);
2377 /* Wait for a reply... */
2382 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
2386 api_one_map_register_fallback_threshold (vat_main_t * vam)
2388 unformat_input_t *input = vam->input;
2389 vl_api_one_map_register_fallback_threshold_t *mp;
2394 /* Parse args required to build the message */
2395 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2397 if (unformat (input, "%u", &value))
2401 clib_warning ("parse error '%U'", format_unformat_error, input);
2408 errmsg ("fallback threshold value is missing!");
2412 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
2413 mp->value = clib_host_to_net_u32 (value);
2418 /* Wait for a reply... */
2424 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
2426 vl_api_show_one_map_register_fallback_threshold_t *mp;
2429 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
2434 /* Wait for a reply... */
2440 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
2442 u32 *proto = va_arg (*args, u32 *);
2444 if (unformat (input, "udp"))
2446 else if (unformat (input, "api"))
2455 api_one_set_transport_protocol (vat_main_t * vam)
2457 unformat_input_t *input = vam->input;
2458 vl_api_one_set_transport_protocol_t *mp;
2463 /* Parse args required to build the message */
2464 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2466 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
2470 clib_warning ("parse error '%U'", format_unformat_error, input);
2477 errmsg ("Transport protocol missing!");
2481 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
2482 mp->protocol = (u8) protocol;
2487 /* Wait for a reply... */
2493 api_one_get_transport_protocol (vat_main_t * vam)
2495 vl_api_one_get_transport_protocol_t *mp;
2498 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
2503 /* Wait for a reply... */
2509 api_one_map_register_set_ttl (vat_main_t * vam)
2511 unformat_input_t *input = vam->input;
2512 vl_api_one_map_register_set_ttl_t *mp;
2517 /* Parse args required to build the message */
2518 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2520 if (unformat (input, "%u", &ttl))
2524 clib_warning ("parse error '%U'", format_unformat_error, input);
2531 errmsg ("TTL value missing!");
2535 M (ONE_MAP_REGISTER_SET_TTL, mp);
2536 mp->ttl = clib_host_to_net_u32 (ttl);
2541 /* Wait for a reply... */
2547 api_show_one_map_register_ttl (vat_main_t * vam)
2549 vl_api_show_one_map_register_ttl_t *mp;
2552 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
2557 /* Wait for a reply... */
2563 * Add/del map request itr rlocs from ONE control plane and updates
2565 * @param vam vpp API test context
2566 * @return return code
2569 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
2571 unformat_input_t *input = vam->input;
2572 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
2573 u8 *locator_set_name = 0;
2574 u8 locator_set_name_set = 0;
2578 /* Parse args required to build the message */
2579 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2581 if (unformat (input, "del"))
2585 else if (unformat (input, "%_%v%_", &locator_set_name))
2587 locator_set_name_set = 1;
2591 clib_warning ("parse error '%U'", format_unformat_error, input);
2596 if (is_add && !locator_set_name_set)
2598 errmsg ("itr-rloc is not set!");
2602 if (is_add && vec_len (locator_set_name) > 64)
2604 errmsg ("itr-rloc locator-set name too long");
2605 vec_free (locator_set_name);
2609 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
2610 mp->is_add = is_add;
2613 clib_memcpy (mp->locator_set_name, locator_set_name,
2614 vec_len (locator_set_name));
2618 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
2620 vec_free (locator_set_name);
2625 /* Wait for a reply... */
2630 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
2633 api_one_locator_dump (vat_main_t * vam)
2635 unformat_input_t *input = vam->input;
2636 vl_api_one_locator_dump_t *mp;
2637 vl_api_control_ping_t *mp_ping;
2638 u8 is_index_set = 0, is_name_set = 0;
2643 /* Parse args required to build the message */
2644 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2646 if (unformat (input, "ls_name %_%v%_", &ls_name))
2650 else if (unformat (input, "ls_index %d", &ls_index))
2656 errmsg ("parse error '%U'", format_unformat_error, input);
2661 if (!is_index_set && !is_name_set)
2663 errmsg ("error: expected one of index or name!");
2667 if (is_index_set && is_name_set)
2669 errmsg ("error: only one param expected!");
2673 if (vec_len (ls_name) > 62)
2675 errmsg ("error: locator set name too long!");
2679 if (!vam->json_output)
2681 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
2684 M (ONE_LOCATOR_DUMP, mp);
2685 mp->is_index_set = is_index_set;
2688 mp->ls_index = clib_host_to_net_u32 (ls_index);
2691 vec_add1 (ls_name, 0);
2692 strncpy ((char *) mp->ls_name, (char *) ls_name,
2693 sizeof (mp->ls_name) - 1);
2699 /* Use a control ping for synchronization */
2700 LISP_PING (&one_test_main, mp_ping);
2703 /* Wait for a reply... */
2708 #define api_lisp_locator_dump api_one_locator_dump
2711 api_one_locator_set_dump (vat_main_t * vam)
2713 vl_api_one_locator_set_dump_t *mp;
2714 vl_api_control_ping_t *mp_ping;
2715 unformat_input_t *input = vam->input;
2719 /* Parse args required to build the message */
2720 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2722 if (unformat (input, "local"))
2726 else if (unformat (input, "remote"))
2732 errmsg ("parse error '%U'", format_unformat_error, input);
2737 if (!vam->json_output)
2739 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
2742 M (ONE_LOCATOR_SET_DUMP, mp);
2744 mp->filter = filter;
2749 /* Use a control ping for synchronization */
2750 LISP_PING (&one_test_main, mp_ping);
2753 /* Wait for a reply... */
2758 #define api_lisp_locator_set_dump api_one_locator_set_dump
2761 api_one_eid_table_map_dump (vat_main_t * vam)
2765 unformat_input_t *input = vam->input;
2766 vl_api_one_eid_table_map_dump_t *mp;
2767 vl_api_control_ping_t *mp_ping;
2770 /* Parse args required to build the message */
2771 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2773 if (unformat (input, "l2"))
2778 else if (unformat (input, "l3"))
2785 errmsg ("parse error '%U'", format_unformat_error, input);
2792 errmsg ("expected one of 'l2' or 'l3' parameter!");
2796 if (!vam->json_output)
2798 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
2801 M (ONE_EID_TABLE_MAP_DUMP, mp);
2807 /* Use a control ping for synchronization */
2808 LISP_PING (&one_test_main, mp_ping);
2811 /* Wait for a reply... */
2816 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
2819 api_one_eid_table_vni_dump (vat_main_t * vam)
2821 vl_api_one_eid_table_vni_dump_t *mp;
2822 vl_api_control_ping_t *mp_ping;
2825 if (!vam->json_output)
2827 print (vam->ofp, "VNI");
2830 M (ONE_EID_TABLE_VNI_DUMP, mp);
2835 /* Use a control ping for synchronization */
2836 LISP_PING (&one_test_main, mp_ping);
2839 /* Wait for a reply... */
2844 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
2847 api_one_eid_table_dump (vat_main_t * vam)
2849 unformat_input_t *i = vam->input;
2850 vl_api_one_eid_table_dump_t *mp;
2851 vl_api_control_ping_t *mp_ping;
2858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2861 (i, "eid %U/%d", unformat_ip46_address, &eid.addr.ip, &eid.len))
2867 if (unformat (i, "eid %U", unformat_ethernet_address, &eid.addr.mac))
2872 else if (unformat (i, "eid %U", unformat_nsh_address, &eid.addr.nsh))
2877 else if (unformat (i, "vni %d", &t))
2881 else if (unformat (i, "local"))
2885 else if (unformat (i, "remote"))
2891 errmsg ("parse error '%U'", format_unformat_error, i);
2896 if (!vam->json_output)
2898 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
2899 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
2902 M (ONE_EID_TABLE_DUMP, mp);
2904 mp->filter = filter;
2908 mp->vni = htonl (vni);
2909 lisp_eid_put_vat (&mp->eid, &eid);
2915 /* Use a control ping for synchronization */
2916 LISP_PING (&one_test_main, mp_ping);
2919 /* Wait for a reply... */
2925 api_one_adjacencies_get (vat_main_t * vam)
2927 unformat_input_t *i = vam->input;
2928 vl_api_one_adjacencies_get_t *mp;
2933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2935 if (unformat (i, "vni %d", &vni))
2941 errmsg ("parse error '%U'", format_unformat_error, i);
2948 errmsg ("vni not set!");
2952 if (!vam->json_output)
2954 print (vam->ofp, "%s %40s", "leid", "reid");
2957 M (ONE_ADJACENCIES_GET, mp);
2958 mp->vni = clib_host_to_net_u32 (vni);
2963 /* Wait for a reply... */
2969 api_one_map_server_dump (vat_main_t * vam)
2971 vl_api_one_map_server_dump_t *mp;
2972 vl_api_control_ping_t *mp_ping;
2975 if (!vam->json_output)
2977 print (vam->ofp, "%=20s", "Map server");
2980 M (ONE_MAP_SERVER_DUMP, mp);
2984 /* Use a control ping for synchronization */
2985 LISP_PING (&one_test_main, mp_ping);
2988 /* Wait for a reply... */
2993 #define api_lisp_map_server_dump api_one_map_server_dump
2996 api_one_map_resolver_dump (vat_main_t * vam)
2998 vl_api_one_map_resolver_dump_t *mp;
2999 vl_api_control_ping_t *mp_ping;
3002 if (!vam->json_output)
3004 print (vam->ofp, "%=20s", "Map resolver");
3007 M (ONE_MAP_RESOLVER_DUMP, mp);
3011 /* Use a control ping for synchronization */
3012 LISP_PING (&one_test_main, mp_ping);
3015 /* Wait for a reply... */
3020 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
3023 api_one_stats_flush (vat_main_t * vam)
3025 vl_api_one_stats_flush_t *mp;
3028 M (ONE_STATS_FLUSH, mp);
3035 api_one_stats_dump (vat_main_t * vam)
3037 vl_api_one_stats_dump_t *mp;
3038 vl_api_control_ping_t *mp_ping;
3041 M (ONE_STATS_DUMP, mp);
3045 /* Use a control ping for synchronization */
3046 LISP_PING (&one_test_main, mp_ping);
3049 /* Wait for a reply... */
3055 api_show_one_status (vat_main_t * vam)
3057 vl_api_show_one_status_t *mp;
3060 if (!vam->json_output)
3062 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
3065 M (SHOW_ONE_STATUS, mp);
3068 /* Wait for a reply... */
3074 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
3076 vl_api_one_get_map_request_itr_rlocs_t *mp;
3079 if (!vam->json_output)
3081 print (vam->ofp, "%=20s", "itr-rlocs:");
3084 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
3087 /* Wait for a reply... */
3092 #define vat_plugin_register vat_plugin_register_one
3093 #include <lisp/lisp-cp/one.api_test.c>
3096 * fd.io coding-style-patch-verification: ON
3099 * eval: (c-set-style "gnu")