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 <vnet/ethernet/mac_address.h>
24 #include <lisp/lisp-cp/lisp_types.h>
26 /* define message IDs */
27 #include <lisp/lisp-cp/one.api_enum.h>
28 #include <lisp/lisp-cp/one.api_types.h>
29 #include <vlibmemory/vlib.api_types.h>
33 /* API message ID base */
39 one_test_main_t one_test_main;
41 #define __plugin_msg_base one_test_main.msg_id_base
42 #include <vlibapi/vat_helper_macros.h>
46 vlib_cli_output (handle, (char *) s); \
50 #define LISP_PING(_lm, mp_ping) \
51 if (!(_lm)->ping_id) \
52 (_lm)->ping_id = vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC)); \
53 mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping)); \
54 mp_ping->_vl_msg_id = htons ((_lm)->ping_id); \
55 mp_ping->client_index = vam->my_client_index; \
56 fformat (vam->ofp, "Sending ping id=%d\n", (_lm)->ping_id); \
57 vam->result_ready = 0; \
63 } __attribute__ ((__packed__)) lisp_nsh_api_t;
66 unformat_nsh_address (unformat_input_t * input, va_list * args)
68 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
69 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
73 format_nsh_address_vat (u8 * s, va_list * args)
75 nsh_t *a = va_arg (*args, nsh_t *);
76 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
80 format_lisp_transport_protocol (u8 * s, va_list * args)
82 u32 proto = va_arg (*args, u32);
87 return format (s, "udp");
89 return format (s, "api");
97 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
99 vat_main_t *vam = &vat_main;
104 s = format (s, "%=16d%=16d%=16d",
105 ntohl (mp->sw_if_index), mp->priority, mp->weight);
109 s = format (s, "%=16U%=16d%=16d",
111 mp->ip_address, mp->priority, mp->weight);
114 print (vam->ofp, "%v", s);
119 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
122 vat_main_t *vam = &vat_main;
125 ls_name = format (0, "%s", mp->ls_name);
127 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
132 static void vl_api_one_get_transport_protocol_reply_t_handler
133 (vl_api_one_get_transport_protocol_reply_t * mp)
135 vat_main_t *vam = &vat_main;
136 i32 retval = ntohl (mp->retval);
139 vam->async_errors += (retval < 0);
143 u32 proto = mp->protocol;
144 print (vam->ofp, "Transport protocol: %U",
145 format_lisp_transport_protocol, proto);
146 vam->retval = retval;
147 vam->result_ready = 1;
151 static void vl_api_one_add_del_locator_set_reply_t_handler
152 (vl_api_one_add_del_locator_set_reply_t * mp)
154 vat_main_t *vam = &vat_main;
155 i32 retval = ntohl (mp->retval);
158 vam->async_errors += (retval < 0);
162 vam->retval = retval;
163 vam->result_ready = 1;
168 format_lisp_flat_eid (u8 * s, va_list * args)
170 vl_api_eid_t *eid = va_arg (*args, vl_api_eid_t *);
174 case EID_TYPE_API_PREFIX:
175 if (eid->address.prefix.address.af)
176 return format (s, "%U/%d", format_ip6_address,
177 eid->address.prefix.address.un.ip6,
178 eid->address.prefix.len);
179 return format (s, "%U/%d", format_ip4_address,
180 eid->address.prefix.address.un.ip4,
181 eid->address.prefix.len);
182 case EID_TYPE_API_MAC:
183 return format (s, "%U", format_ethernet_address, eid->address.mac);
184 case EID_TYPE_API_NSH:
185 return format (s, "%U", format_nsh_address_vat, eid->address.nsh);
191 format_lisp_eid_vat (u8 * s, va_list * args)
193 vl_api_eid_t *deid = va_arg (*args, vl_api_eid_t *);
194 vl_api_eid_t *seid = va_arg (*args, vl_api_eid_t *);
195 u8 is_src_dst = (u8) va_arg (*args, int);
198 s = format (s, "%U|", format_lisp_flat_eid, seid);
200 s = format (s, "%U", format_lisp_flat_eid, deid);
206 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
208 vat_main_t *vam = &vat_main;
211 if (~0 == mp->locator_set_index)
212 s = format (0, "action: %d", mp->action);
214 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
216 eid = format (0, "%U", format_lisp_eid_vat,
217 &mp->deid, &mp->seid, mp->is_src_dst);
220 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
221 clib_net_to_host_u32 (mp->vni),
223 mp->is_local ? "local" : "remote",
224 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
225 clib_net_to_host_u16 (mp->key.id), mp->key.key);
232 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
234 vat_main_t *vam = &vat_main;
235 u8 *seid = 0, *deid = 0;
236 ip46_address_t lloc, rloc;
238 deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0);
240 seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0);
247 clib_memcpy (&lloc.ip6, mp->lloc.un.ip6, 16);
248 clib_memcpy (&rloc.ip6, mp->rloc.un.ip6, 16);
252 clib_memcpy (&lloc.ip4, mp->lloc.un.ip4, 4);
253 clib_memcpy (&rloc.ip4, mp->rloc.un.ip4, 4);
257 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
258 clib_net_to_host_u32 (mp->vni),
260 format_ip46_address, lloc,
261 format_ip46_address, rloc,
262 clib_net_to_host_u32 (mp->pkt_count),
263 clib_net_to_host_u32 (mp->bytes));
270 vl_api_one_eid_table_map_details_t_handler
271 (vl_api_one_eid_table_map_details_t * mp)
273 vat_main_t *vam = &vat_main;
275 u8 *line = format (0, "%=10d%=10d",
276 clib_net_to_host_u32 (mp->vni),
277 clib_net_to_host_u32 (mp->dp_table));
278 print (vam->ofp, "%v", line);
283 vl_api_one_eid_table_vni_details_t_handler
284 (vl_api_one_eid_table_vni_details_t * mp)
286 vat_main_t *vam = &vat_main;
288 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
289 print (vam->ofp, "%v", line);
294 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
295 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
297 vat_main_t *vam = &vat_main;
298 int retval = clib_net_to_host_u32 (mp->retval);
300 print (vam->ofp, "fallback threshold value: %d", mp->value);
302 vam->retval = retval;
303 vam->result_ready = 1;
307 vl_api_show_one_map_register_state_reply_t_handler
308 (vl_api_show_one_map_register_state_reply_t * mp)
310 vat_main_t *vam = &vat_main;
311 int retval = clib_net_to_host_u32 (mp->retval);
313 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
315 vam->retval = retval;
316 vam->result_ready = 1;
320 vl_api_show_one_rloc_probe_state_reply_t_handler
321 (vl_api_show_one_rloc_probe_state_reply_t * mp)
323 vat_main_t *vam = &vat_main;
324 int retval = clib_net_to_host_u32 (mp->retval);
329 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
331 vam->retval = retval;
332 vam->result_ready = 1;
336 vl_api_show_one_stats_enable_disable_reply_t_handler
337 (vl_api_show_one_stats_enable_disable_reply_t * mp)
339 vat_main_t *vam = &vat_main;
340 int retval = clib_net_to_host_u32 (mp->retval);
345 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
347 vam->retval = retval;
348 vam->result_ready = 1;
352 vl_api_one_ndp_entries_get_reply_t_handler
353 (vl_api_one_ndp_entries_get_reply_t * mp)
355 vat_main_t *vam = &vat_main;
357 int retval = clib_net_to_host_u32 (mp->retval);
362 n = clib_net_to_host_u32 (mp->count);
364 for (i = 0; i < n; i++)
365 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
366 format_ethernet_address, mp->entries[i].mac);
369 vam->retval = retval;
370 vam->result_ready = 1;
374 vl_api_one_l2_arp_entries_get_reply_t_handler
375 (vl_api_one_l2_arp_entries_get_reply_t * mp)
377 vat_main_t *vam = &vat_main;
379 int retval = clib_net_to_host_u32 (mp->retval);
384 n = clib_net_to_host_u32 (mp->count);
386 for (i = 0; i < n; i++)
387 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
388 format_ethernet_address, mp->entries[i].mac);
391 vam->retval = retval;
392 vam->result_ready = 1;
396 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
398 vat_main_t *vam = &vat_main;
400 int retval = clib_net_to_host_u32 (mp->retval);
405 n = clib_net_to_host_u32 (mp->count);
407 for (i = 0; i < n; i++)
409 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
413 vam->retval = retval;
414 vam->result_ready = 1;
418 vl_api_one_l2_arp_bd_get_reply_t_handler
419 (vl_api_one_l2_arp_bd_get_reply_t * mp)
421 vat_main_t *vam = &vat_main;
423 int retval = clib_net_to_host_u32 (mp->retval);
428 n = clib_net_to_host_u32 (mp->count);
430 for (i = 0; i < n; i++)
432 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
436 vam->retval = retval;
437 vam->result_ready = 1;
441 vl_api_one_adjacencies_get_reply_t_handler
442 (vl_api_one_adjacencies_get_reply_t * mp)
444 vat_main_t *vam = &vat_main;
446 int retval = clib_net_to_host_u32 (mp->retval);
447 vl_api_one_adjacency_t *a;
452 n = clib_net_to_host_u32 (mp->count);
454 for (i = 0; i < n; i++)
456 a = &mp->adjacencies[i];
457 print (vam->ofp, "%U %40U",
458 format_lisp_flat_eid, a->leid, format_lisp_flat_eid, a->reid);
462 vam->retval = retval;
463 vam->result_ready = 1;
467 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
469 vat_main_t *vam = &vat_main;
471 print (vam->ofp, "%=20U",
472 mp->ip_address.af ? format_ip6_address : format_ip4_address,
477 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
480 vat_main_t *vam = &vat_main;
482 print (vam->ofp, "%=20U",
483 mp->ip_address.af ? format_ip6_address : format_ip4_address,
488 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
490 vat_main_t *vam = &vat_main;
491 i32 retval = ntohl (mp->retval);
495 print (vam->ofp, "feature: %s\ngpe: %s",
496 mp->feature_status ? "enabled" : "disabled",
497 mp->gpe_status ? "enabled" : "disabled");
500 vam->retval = retval;
501 vam->result_ready = 1;
505 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
506 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
508 vat_main_t *vam = &vat_main;
509 i32 retval = ntohl (mp->retval);
513 print (vam->ofp, "%=20s", mp->locator_set_name);
516 vam->retval = retval;
517 vam->result_ready = 1;
521 format_lisp_map_request_mode (u8 * s, va_list * args)
523 u32 mode = va_arg (*args, u32);
528 return format (0, "dst-only");
530 return format (0, "src-dst");
536 vl_api_show_one_map_request_mode_reply_t_handler
537 (vl_api_show_one_map_request_mode_reply_t * mp)
539 vat_main_t *vam = &vat_main;
540 i32 retval = ntohl (mp->retval);
545 print (vam->ofp, "map_request_mode: %U",
546 format_lisp_map_request_mode, mode);
549 vam->retval = retval;
550 vam->result_ready = 1;
554 vl_api_one_show_xtr_mode_reply_t_handler
555 (vl_api_one_show_xtr_mode_reply_t * mp)
557 vat_main_t *vam = &vat_main;
558 i32 retval = ntohl (mp->retval);
562 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
565 vam->retval = retval;
566 vam->result_ready = 1;
570 vl_api_one_show_pitr_mode_reply_t_handler
571 (vl_api_one_show_pitr_mode_reply_t * mp)
573 vat_main_t *vam = &vat_main;
574 i32 retval = ntohl (mp->retval);
578 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
581 vam->retval = retval;
582 vam->result_ready = 1;
586 vl_api_one_show_petr_mode_reply_t_handler
587 (vl_api_one_show_petr_mode_reply_t * mp)
589 vat_main_t *vam = &vat_main;
590 i32 retval = ntohl (mp->retval);
594 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
597 vam->retval = retval;
598 vam->result_ready = 1;
602 vl_api_show_one_use_petr_reply_t_handler
603 (vl_api_show_one_use_petr_reply_t * mp)
605 vat_main_t *vam = &vat_main;
606 i32 retval = ntohl (mp->retval);
610 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
613 print (vam->ofp, "Proxy-ETR address; %U",
614 mp->ip_address.af ? format_ip6_address : format_ip4_address,
619 vam->retval = retval;
620 vam->result_ready = 1;
624 vl_api_show_one_nsh_mapping_reply_t_handler
625 (vl_api_show_one_nsh_mapping_reply_t * mp)
627 vat_main_t *vam = &vat_main;
628 i32 retval = ntohl (mp->retval);
632 print (vam->ofp, "%-20s%-16s",
633 mp->is_set ? "set" : "not-set",
634 mp->is_set ? (char *) mp->locator_set_name : "");
637 vam->retval = retval;
638 vam->result_ready = 1;
642 vl_api_show_one_map_register_ttl_reply_t_handler
643 (vl_api_show_one_map_register_ttl_reply_t * mp)
645 vat_main_t *vam = &vat_main;
646 i32 retval = ntohl (mp->retval);
650 print (vam->ofp, "ttl: %u", mp->ttl);
653 vam->retval = retval;
654 vam->result_ready = 1;
658 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
660 vat_main_t *vam = &vat_main;
661 i32 retval = ntohl (mp->retval);
665 print (vam->ofp, "%-20s%-16s",
666 mp->status ? "enabled" : "disabled",
667 mp->status ? (char *) mp->locator_set_name : "");
670 vam->retval = retval;
671 vam->result_ready = 1;
675 /** Used for parsing LISP eids */
676 typedef CLIB_PACKED(struct{
682 u32 len; /**< prefix length if IP */
683 u8 type; /**< type of eid */
688 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
690 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
692 clib_memset (a, 0, sizeof (a[0]));
694 if (unformat (input, "%U/%d", unformat_ip46_address, a->addr.ip, &a->len))
696 a->type = 0; /* ip prefix type */
698 else if (unformat (input, "%U", unformat_ethernet_address, &a->addr.mac))
700 a->type = 1; /* mac type */
702 else if (unformat (input, "%U", unformat_nsh_address, a->addr.nsh))
704 a->type = 2; /* NSH type */
705 a->addr.nsh.spi = clib_host_to_net_u32 (a->addr.nsh.spi);
714 if (ip46_address_is_ip4 (&a->addr.ip))
715 return a->len > 32 ? 1 : 0;
717 return a->len > 128 ? 1 : 0;
724 lisp_eid_put_vat (vl_api_eid_t * eid, const lisp_eid_vat_t * vat_eid)
726 eid->type = vat_eid->type;
729 case EID_TYPE_API_PREFIX:
730 if (ip46_address_is_ip4 (&vat_eid->addr.ip))
732 clib_memcpy (&eid->address.prefix.address.un.ip4,
733 &vat_eid->addr.ip.ip4, 4);
734 eid->address.prefix.address.af = ADDRESS_IP4;
735 eid->address.prefix.len = vat_eid->len;
739 clib_memcpy (&eid->address.prefix.address.un.ip6,
740 &vat_eid->addr.ip.ip6, 16);
741 eid->address.prefix.address.af = ADDRESS_IP6;
742 eid->address.prefix.len = vat_eid->len;
745 case EID_TYPE_API_MAC:
746 clib_memcpy (&eid->address.mac, &vat_eid->addr.mac,
747 sizeof (eid->address.mac));
749 case EID_TYPE_API_NSH:
750 clib_memcpy (&eid->address.nsh, &vat_eid->addr.nsh,
751 sizeof (eid->address.nsh));
760 api_one_add_del_locator_set (vat_main_t * vam)
762 unformat_input_t *input = vam->input;
763 vl_api_one_add_del_locator_set_t *mp;
765 u8 *locator_set_name = NULL;
766 u8 locator_set_name_set = 0;
767 vl_api_local_locator_t locator, *locators = 0;
768 u32 sw_if_index, priority, weight;
772 /* Parse args required to build the message */
773 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
775 if (unformat (input, "del"))
779 else if (unformat (input, "locator-set %s", &locator_set_name))
781 locator_set_name_set = 1;
783 else if (unformat (input, "sw_if_index %u p %u w %u",
784 &sw_if_index, &priority, &weight))
786 locator.sw_if_index = htonl (sw_if_index);
787 locator.priority = priority;
788 locator.weight = weight;
789 vec_add1 (locators, locator);
793 (input, "iface %U p %u w %u", unformat_sw_if_index, vam,
794 &sw_if_index, &priority, &weight))
796 locator.sw_if_index = htonl (sw_if_index);
797 locator.priority = priority;
798 locator.weight = weight;
799 vec_add1 (locators, locator);
805 if (locator_set_name_set == 0)
807 errmsg ("missing locator-set name");
812 if (vec_len (locator_set_name) > 64)
814 errmsg ("locator-set name too long");
815 vec_free (locator_set_name);
819 vec_add1 (locator_set_name, 0);
821 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
823 /* Construct the API message */
824 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
827 clib_memcpy (mp->locator_set_name, locator_set_name,
828 vec_len (locator_set_name));
829 vec_free (locator_set_name);
831 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
833 clib_memcpy (mp->locators, locators, data_len);
839 /* Wait for a reply... */
844 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
847 api_one_add_del_locator (vat_main_t * vam)
849 unformat_input_t *input = vam->input;
850 vl_api_one_add_del_locator_t *mp;
851 u32 tmp_if_index = ~0;
852 u32 sw_if_index = ~0;
853 u8 sw_if_index_set = 0;
854 u8 sw_if_index_if_name_set = 0;
860 u8 *locator_set_name = NULL;
861 u8 locator_set_name_set = 0;
864 /* Parse args required to build the message */
865 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
867 if (unformat (input, "del"))
871 else if (unformat (input, "locator-set %s", &locator_set_name))
873 locator_set_name_set = 1;
875 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
878 sw_if_index_if_name_set = 1;
879 sw_if_index = tmp_if_index;
881 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
884 sw_if_index = tmp_if_index;
886 else if (unformat (input, "p %d", &priority))
890 else if (unformat (input, "w %d", &weight))
898 if (locator_set_name_set == 0)
900 errmsg ("missing locator-set name");
904 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
906 errmsg ("missing sw_if_index");
907 vec_free (locator_set_name);
911 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
913 errmsg ("cannot use both params interface name and sw_if_index");
914 vec_free (locator_set_name);
918 if (priority_set == 0)
920 errmsg ("missing locator-set priority");
921 vec_free (locator_set_name);
927 errmsg ("missing locator-set weight");
928 vec_free (locator_set_name);
932 if (vec_len (locator_set_name) > 64)
934 errmsg ("locator-set name too long");
935 vec_free (locator_set_name);
938 vec_add1 (locator_set_name, 0);
940 /* Construct the API message */
941 M (ONE_ADD_DEL_LOCATOR, mp);
944 mp->sw_if_index = ntohl (sw_if_index);
945 mp->priority = priority;
947 clib_memcpy (mp->locator_set_name, locator_set_name,
948 vec_len (locator_set_name));
949 vec_free (locator_set_name);
954 /* Wait for a reply... */
959 #define api_lisp_add_del_locator api_one_add_del_locator
962 api_one_add_del_local_eid (vat_main_t * vam)
964 unformat_input_t *input = vam->input;
965 vl_api_one_add_del_local_eid_t *mp;
968 lisp_eid_vat_t _eid, *eid = &_eid;
969 u8 *locator_set_name = 0;
970 u8 locator_set_name_set = 0;
976 /* Parse args required to build the message */
977 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
979 if (unformat (input, "del"))
983 else if (unformat (input, "vni %d", &vni))
987 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
991 else if (unformat (input, "locator-set %s", &locator_set_name))
993 locator_set_name_set = 1;
995 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
997 else if (unformat (input, "secret-key %_%v%_", &key))
1003 if (locator_set_name_set == 0)
1005 errmsg ("missing locator-set name");
1011 errmsg ("EID address not set!");
1012 vec_free (locator_set_name);
1016 if (key && (0 == key_id))
1018 errmsg ("invalid key_id!");
1022 if (vec_len (key) > 64)
1024 errmsg ("key too long");
1029 if (vec_len (locator_set_name) > 64)
1031 errmsg ("locator-set name too long");
1032 vec_free (locator_set_name);
1035 vec_add1 (locator_set_name, 0);
1037 /* Construct the API message */
1038 M (ONE_ADD_DEL_LOCAL_EID, mp);
1040 mp->is_add = is_add;
1041 lisp_eid_put_vat (&mp->eid, eid);
1042 mp->vni = clib_host_to_net_u32 (vni);
1043 mp->key.id = key_id;
1044 clib_memcpy (mp->locator_set_name, locator_set_name,
1045 vec_len (locator_set_name));
1046 clib_memcpy (mp->key.key, key, vec_len (key));
1048 vec_free (locator_set_name);
1054 /* Wait for a reply... */
1060 api_one_add_del_map_server (vat_main_t * vam)
1062 unformat_input_t *input = vam->input;
1063 vl_api_one_add_del_map_server_t *mp;
1071 /* Parse args required to build the message */
1072 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1074 if (unformat (input, "del"))
1078 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
1082 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
1090 if (ipv4_set && ipv6_set)
1092 errmsg ("both eid v4 and v6 addresses set");
1096 if (!ipv4_set && !ipv6_set)
1098 errmsg ("eid addresses not set");
1102 /* Construct the API message */
1103 M (ONE_ADD_DEL_MAP_SERVER, mp);
1105 mp->is_add = is_add;
1108 mp->ip_address.af = 1;
1109 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
1113 mp->ip_address.af = 0;
1114 clib_memcpy (mp->ip_address.un.ip4, &ipv4, sizeof (ipv4));
1120 /* Wait for a reply... */
1125 #define api_lisp_add_del_map_server api_one_add_del_map_server
1128 api_one_add_del_map_resolver (vat_main_t * vam)
1130 unformat_input_t *input = vam->input;
1131 vl_api_one_add_del_map_resolver_t *mp;
1139 /* Parse args required to build the message */
1140 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1142 if (unformat (input, "del"))
1146 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
1150 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
1158 if (ipv4_set && ipv6_set)
1160 errmsg ("both eid v4 and v6 addresses set");
1164 if (!ipv4_set && !ipv6_set)
1166 errmsg ("eid addresses not set");
1170 /* Construct the API message */
1171 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
1173 mp->is_add = is_add;
1176 mp->ip_address.af = 1;
1177 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
1181 mp->ip_address.af = 0;
1182 clib_memcpy (mp->ip_address.un.ip6, &ipv4, sizeof (ipv4));
1188 /* Wait for a reply... */
1194 api_one_rloc_probe_enable_disable (vat_main_t * vam)
1196 unformat_input_t *input = vam->input;
1197 vl_api_one_rloc_probe_enable_disable_t *mp;
1202 /* Parse args required to build the message */
1203 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1205 if (unformat (input, "enable"))
1210 else if (unformat (input, "disable"))
1218 errmsg ("Value not set");
1222 /* Construct the API message */
1223 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
1225 mp->is_enable = is_enable;
1230 /* Wait for a reply... */
1235 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
1238 api_one_map_register_enable_disable (vat_main_t * vam)
1240 unformat_input_t *input = vam->input;
1241 vl_api_one_map_register_enable_disable_t *mp;
1246 /* Parse args required to build the message */
1247 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1249 if (unformat (input, "enable"))
1254 else if (unformat (input, "disable"))
1262 errmsg ("Value not set");
1266 /* Construct the API message */
1267 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
1269 mp->is_enable = is_enable;
1274 /* Wait for a reply... */
1279 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
1282 api_one_enable_disable (vat_main_t * vam)
1284 unformat_input_t *input = vam->input;
1285 vl_api_one_enable_disable_t *mp;
1290 /* Parse args required to build the message */
1291 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1293 if (unformat (input, "enable"))
1298 else if (unformat (input, "disable"))
1308 errmsg ("Value not set");
1312 /* Construct the API message */
1313 M (ONE_ENABLE_DISABLE, mp);
1315 mp->is_enable = is_enable;
1320 /* Wait for a reply... */
1325 #define api_lisp_enable_disable api_one_enable_disable
1328 api_one_enable_disable_xtr_mode (vat_main_t * vam)
1330 unformat_input_t *input = vam->input;
1331 vl_api_one_enable_disable_xtr_mode_t *mp;
1336 /* Parse args required to build the message */
1337 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1339 if (unformat (input, "enable"))
1344 else if (unformat (input, "disable"))
1354 errmsg ("Value not set");
1358 /* Construct the API message */
1359 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
1361 mp->is_enable = is_enable;
1366 /* Wait for a reply... */
1372 api_one_show_xtr_mode (vat_main_t * vam)
1374 vl_api_one_show_xtr_mode_t *mp;
1377 /* Construct the API message */
1378 M (ONE_SHOW_XTR_MODE, mp);
1383 /* Wait for a reply... */
1389 api_one_enable_disable_pitr_mode (vat_main_t * vam)
1391 unformat_input_t *input = vam->input;
1392 vl_api_one_enable_disable_pitr_mode_t *mp;
1397 /* Parse args required to build the message */
1398 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1400 if (unformat (input, "enable"))
1405 else if (unformat (input, "disable"))
1415 errmsg ("Value not set");
1419 /* Construct the API message */
1420 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
1422 mp->is_enable = is_enable;
1427 /* Wait for a reply... */
1433 api_one_show_pitr_mode (vat_main_t * vam)
1435 vl_api_one_show_pitr_mode_t *mp;
1438 /* Construct the API message */
1439 M (ONE_SHOW_PITR_MODE, mp);
1444 /* Wait for a reply... */
1450 api_one_enable_disable_petr_mode (vat_main_t * vam)
1452 unformat_input_t *input = vam->input;
1453 vl_api_one_enable_disable_petr_mode_t *mp;
1458 /* Parse args required to build the message */
1459 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1461 if (unformat (input, "enable"))
1466 else if (unformat (input, "disable"))
1476 errmsg ("Value not set");
1480 /* Construct the API message */
1481 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
1483 mp->is_enable = is_enable;
1488 /* Wait for a reply... */
1494 api_one_show_petr_mode (vat_main_t * vam)
1496 vl_api_one_show_petr_mode_t *mp;
1499 /* Construct the API message */
1500 M (ONE_SHOW_PETR_MODE, mp);
1505 /* Wait for a reply... */
1511 api_show_one_map_register_state (vat_main_t * vam)
1513 vl_api_show_one_map_register_state_t *mp;
1516 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
1521 /* wait for reply */
1526 #define api_show_lisp_map_register_state api_show_one_map_register_state
1529 api_show_one_rloc_probe_state (vat_main_t * vam)
1531 vl_api_show_one_rloc_probe_state_t *mp;
1534 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
1539 /* wait for reply */
1544 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
1547 api_one_add_del_ndp_entry (vat_main_t * vam)
1549 vl_api_one_add_del_ndp_entry_t *mp;
1550 unformat_input_t *input = vam->input;
1556 u8 ip6[16] = { 0, };
1560 /* Parse args required to build the message */
1561 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1563 if (unformat (input, "del"))
1565 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
1567 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
1569 else if (unformat (input, "bd %d", &bd))
1573 errmsg ("parse error '%U'", format_unformat_error, input);
1578 if (!bd_set || !ip_set || (!mac_set && is_add))
1580 errmsg ("Missing BD, IP or MAC!");
1584 M (ONE_ADD_DEL_NDP_ENTRY, mp);
1585 mp->is_add = is_add;
1586 clib_memcpy (&mp->entry.mac, mac, 6);
1587 mp->bd = clib_host_to_net_u32 (bd);
1588 clib_memcpy (&mp->entry.ip6, ip6, sizeof (mp->entry.ip6));
1593 /* wait for reply */
1599 api_one_add_del_l2_arp_entry (vat_main_t * vam)
1601 vl_api_one_add_del_l2_arp_entry_t *mp;
1602 unformat_input_t *input = vam->input;
1608 u32 ip4 = 0, bd = ~0;
1611 /* Parse args required to build the message */
1612 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1614 if (unformat (input, "del"))
1616 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
1618 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
1620 else if (unformat (input, "bd %d", &bd))
1624 errmsg ("parse error '%U'", format_unformat_error, input);
1629 if (!bd_set || !ip_set || (!mac_set && is_add))
1631 errmsg ("Missing BD, IP or MAC!");
1635 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
1636 mp->is_add = is_add;
1637 clib_memcpy (&mp->entry.mac, mac, 6);
1638 mp->bd = clib_host_to_net_u32 (bd);
1639 clib_memcpy (mp->entry.ip4, &ip4, sizeof (mp->entry.ip4));
1644 /* wait for reply */
1650 api_one_ndp_bd_get (vat_main_t * vam)
1652 vl_api_one_ndp_bd_get_t *mp;
1655 M (ONE_NDP_BD_GET, mp);
1660 /* wait for reply */
1666 api_one_ndp_entries_get (vat_main_t * vam)
1668 vl_api_one_ndp_entries_get_t *mp;
1669 unformat_input_t *input = vam->input;
1674 /* Parse args required to build the message */
1675 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1677 if (unformat (input, "bd %d", &bd))
1681 errmsg ("parse error '%U'", format_unformat_error, input);
1688 errmsg ("Expected bridge domain!");
1692 M (ONE_NDP_ENTRIES_GET, mp);
1693 mp->bd = clib_host_to_net_u32 (bd);
1698 /* wait for reply */
1704 api_one_l2_arp_bd_get (vat_main_t * vam)
1706 vl_api_one_l2_arp_bd_get_t *mp;
1709 M (ONE_L2_ARP_BD_GET, mp);
1714 /* wait for reply */
1720 api_one_l2_arp_entries_get (vat_main_t * vam)
1722 vl_api_one_l2_arp_entries_get_t *mp;
1723 unformat_input_t *input = vam->input;
1728 /* Parse args required to build the message */
1729 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1731 if (unformat (input, "bd %d", &bd))
1735 errmsg ("parse error '%U'", format_unformat_error, input);
1742 errmsg ("Expected bridge domain!");
1746 M (ONE_L2_ARP_ENTRIES_GET, mp);
1747 mp->bd = clib_host_to_net_u32 (bd);
1752 /* wait for reply */
1758 api_one_stats_enable_disable (vat_main_t * vam)
1760 vl_api_one_stats_enable_disable_t *mp;
1761 unformat_input_t *input = vam->input;
1766 /* Parse args required to build the message */
1767 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1769 if (unformat (input, "enable"))
1774 else if (unformat (input, "disable"))
1784 errmsg ("Value not set");
1788 M (ONE_STATS_ENABLE_DISABLE, mp);
1789 mp->is_enable = is_enable;
1794 /* wait for reply */
1800 api_show_one_stats_enable_disable (vat_main_t * vam)
1802 vl_api_show_one_stats_enable_disable_t *mp;
1805 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
1810 /* wait for reply */
1816 api_show_one_map_request_mode (vat_main_t * vam)
1818 vl_api_show_one_map_request_mode_t *mp;
1821 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
1826 /* wait for reply */
1831 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
1834 api_one_map_request_mode (vat_main_t * vam)
1836 unformat_input_t *input = vam->input;
1837 vl_api_one_map_request_mode_t *mp;
1841 /* Parse args required to build the message */
1842 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1844 if (unformat (input, "dst-only"))
1846 else if (unformat (input, "src-dst"))
1850 errmsg ("parse error '%U'", format_unformat_error, input);
1855 M (ONE_MAP_REQUEST_MODE, mp);
1862 /* wait for reply */
1867 #define api_lisp_map_request_mode api_one_map_request_mode
1870 * Enable/disable ONE proxy ITR.
1872 * @param vam vpp API test context
1873 * @return return code
1876 api_one_pitr_set_locator_set (vat_main_t * vam)
1879 unformat_input_t *input = vam->input;
1880 vl_api_one_pitr_set_locator_set_t *mp;
1885 /* Parse args required to build the message */
1886 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1888 if (unformat (input, "del"))
1890 else if (unformat (input, "locator-set %s", &ls_name))
1894 errmsg ("parse error '%U'", format_unformat_error, input);
1901 errmsg ("locator-set name not set!");
1905 M (ONE_PITR_SET_LOCATOR_SET, mp);
1907 mp->is_add = is_add;
1908 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
1914 /* wait for reply */
1919 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
1922 api_one_nsh_set_locator_set (vat_main_t * vam)
1925 unformat_input_t *input = vam->input;
1926 vl_api_one_nsh_set_locator_set_t *mp;
1931 /* Parse args required to build the message */
1932 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1934 if (unformat (input, "del"))
1936 else if (unformat (input, "ls %s", &ls_name))
1940 errmsg ("parse error '%U'", format_unformat_error, input);
1945 if (!ls_name_set && is_add)
1947 errmsg ("locator-set name not set!");
1951 M (ONE_NSH_SET_LOCATOR_SET, mp);
1953 mp->is_add = is_add;
1954 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
1960 /* wait for reply */
1966 api_show_one_pitr (vat_main_t * vam)
1968 vl_api_show_one_pitr_t *mp;
1971 if (!vam->json_output)
1973 print (vam->ofp, "%=20s", "lisp status:");
1976 M (SHOW_ONE_PITR, mp);
1980 /* Wait for a reply... */
1985 #define api_show_lisp_pitr api_show_one_pitr
1988 api_one_use_petr (vat_main_t * vam)
1990 unformat_input_t *input = vam->input;
1991 vl_api_one_use_petr_t *mp;
1996 clib_memset (&ip, 0, sizeof (ip));
1998 /* Parse args required to build the message */
1999 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2001 if (unformat (input, "disable"))
2004 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
2007 ip_addr_version (&ip) = AF_IP4;
2010 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
2013 ip_addr_version (&ip) = AF_IP6;
2017 errmsg ("parse error '%U'", format_unformat_error, input);
2022 M (ONE_USE_PETR, mp);
2024 mp->is_add = is_add;
2027 mp->ip_address.af = ip_addr_version (&ip) == AF_IP4 ? 0 : 1;
2028 if (mp->ip_address.af)
2029 clib_memcpy (mp->ip_address.un.ip6, &ip, 16);
2031 clib_memcpy (mp->ip_address.un.ip4, &ip, 4);
2037 /* wait for reply */
2042 #define api_lisp_use_petr api_one_use_petr
2045 api_show_one_nsh_mapping (vat_main_t * vam)
2047 vl_api_show_one_use_petr_t *mp;
2050 if (!vam->json_output)
2052 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
2055 M (SHOW_ONE_NSH_MAPPING, mp);
2059 /* Wait for a reply... */
2065 api_show_one_use_petr (vat_main_t * vam)
2067 vl_api_show_one_use_petr_t *mp;
2070 if (!vam->json_output)
2072 print (vam->ofp, "%=20s", "Proxy-ETR status:");
2075 M (SHOW_ONE_USE_PETR, mp);
2079 /* Wait for a reply... */
2084 #define api_show_lisp_use_petr api_show_one_use_petr
2087 * Add/delete mapping between vni and vrf
2090 api_one_eid_table_add_del_map (vat_main_t * vam)
2092 unformat_input_t *input = vam->input;
2093 vl_api_one_eid_table_add_del_map_t *mp;
2094 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
2095 u32 vni, vrf, bd_index;
2098 /* Parse args required to build the message */
2099 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2101 if (unformat (input, "del"))
2103 else if (unformat (input, "vrf %d", &vrf))
2105 else if (unformat (input, "bd_index %d", &bd_index))
2107 else if (unformat (input, "vni %d", &vni))
2113 if (!vni_set || (!vrf_set && !bd_index_set))
2115 errmsg ("missing arguments!");
2119 if (vrf_set && bd_index_set)
2121 errmsg ("error: both vrf and bd entered!");
2125 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
2127 mp->is_add = is_add;
2128 mp->vni = htonl (vni);
2129 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
2130 mp->is_l2 = bd_index_set;
2135 /* wait for reply */
2140 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
2143 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
2145 u32 *action = va_arg (*args, u32 *);
2148 if (unformat (input, "%s", &s))
2150 if (!strcmp ((char *) s, "no-action"))
2152 else if (!strcmp ((char *) s, "natively-forward"))
2154 else if (!strcmp ((char *) s, "send-map-request"))
2156 else if (!strcmp ((char *) s, "drop"))
2160 clib_warning ("invalid action: '%s'", s);
2172 * Add/del remote mapping to/from ONE control plane
2174 * @param vam vpp API test context
2175 * @return return code
2178 api_one_add_del_remote_mapping (vat_main_t * vam)
2180 unformat_input_t *input = vam->input;
2181 vl_api_one_add_del_remote_mapping_t *mp;
2183 lisp_eid_vat_t _eid, *eid = &_eid;
2184 lisp_eid_vat_t _seid, *seid = &_seid;
2185 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
2186 u32 action = ~0, p, w, data_len;
2187 ip4_address_t rloc4;
2188 ip6_address_t rloc6;
2189 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
2192 clib_memset (&rloc, 0, sizeof (rloc));
2194 /* Parse args required to build the message */
2195 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2197 if (unformat (input, "del-all"))
2201 else if (unformat (input, "del"))
2205 else if (unformat (input, "add"))
2209 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
2213 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
2217 else if (unformat (input, "vni %d", &vni))
2221 else if (unformat (input, "p %d w %d", &p, &w))
2225 errmsg ("No RLOC configured for setting priority/weight!");
2228 curr_rloc->priority = p;
2229 curr_rloc->weight = w;
2231 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
2233 rloc.ip_address.af = 0;
2234 clib_memcpy (&rloc.ip_address.un.ip6, &rloc6, sizeof (rloc6));
2235 vec_add1 (rlocs, rloc);
2236 curr_rloc = &rlocs[vec_len (rlocs) - 1];
2238 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
2240 rloc.ip_address.af = 1;
2241 clib_memcpy (&rloc.ip_address.un.ip4, &rloc4, sizeof (rloc4));
2242 vec_add1 (rlocs, rloc);
2243 curr_rloc = &rlocs[vec_len (rlocs) - 1];
2245 else if (unformat (input, "action %U",
2246 unformat_negative_mapping_action, &action))
2252 clib_warning ("parse error '%U'", format_unformat_error, input);
2259 errmsg ("missing params!");
2263 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
2265 errmsg ("no action set for negative map-reply!");
2269 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
2271 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
2272 mp->is_add = is_add;
2273 mp->vni = htonl (vni);
2274 mp->action = (u8) action;
2275 mp->is_src_dst = seid_set;
2276 mp->del_all = del_all;
2277 lisp_eid_put_vat (&mp->deid, eid);
2278 lisp_eid_put_vat (&mp->seid, seid);
2280 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
2281 clib_memcpy (mp->rlocs, rlocs, data_len);
2287 /* Wait for a reply... */
2292 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
2295 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
2296 * forwarding entries in data-plane accordingly.
2298 * @param vam vpp API test context
2299 * @return return code
2302 api_one_add_del_adjacency (vat_main_t * vam)
2304 unformat_input_t *input = vam->input;
2305 vl_api_one_add_del_adjacency_t *mp;
2309 lisp_eid_vat_t leid, reid;
2311 leid.type = reid.type = (u8) ~ 0;
2313 /* Parse args required to build the message */
2314 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2316 if (unformat (input, "del"))
2320 else if (unformat (input, "add"))
2324 else if (unformat (input, "reid %U/%d", unformat_ip46_address,
2325 &reid.addr.ip, &reid.len))
2327 reid.type = 0; /* ipv4 */
2329 else if (unformat (input, "reid %U", unformat_ethernet_address,
2332 reid.type = 1; /* mac */
2334 else if (unformat (input, "leid %U/%d", unformat_ip46_address,
2335 &leid.addr.ip, &leid.len))
2337 leid.type = 0; /* ipv4 */
2339 else if (unformat (input, "leid %U", unformat_ethernet_address,
2342 leid.type = 1; /* mac */
2344 else if (unformat (input, "vni %d", &vni))
2350 errmsg ("parse error '%U'", format_unformat_error, input);
2355 if ((u8) ~ 0 == reid.type)
2357 errmsg ("missing params!");
2361 if (leid.type != reid.type)
2363 errmsg ("remote and local EIDs are of different types!");
2367 M (ONE_ADD_DEL_ADJACENCY, mp);
2368 mp->is_add = is_add;
2369 mp->vni = htonl (vni);
2370 lisp_eid_put_vat (&mp->leid, &leid);
2371 lisp_eid_put_vat (&mp->reid, &reid);
2376 /* Wait for a reply... */
2381 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
2385 api_one_map_register_fallback_threshold (vat_main_t * vam)
2387 unformat_input_t *input = vam->input;
2388 vl_api_one_map_register_fallback_threshold_t *mp;
2393 /* Parse args required to build the message */
2394 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2396 if (unformat (input, "%u", &value))
2400 clib_warning ("parse error '%U'", format_unformat_error, input);
2407 errmsg ("fallback threshold value is missing!");
2411 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
2412 mp->value = clib_host_to_net_u32 (value);
2417 /* Wait for a reply... */
2423 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
2425 vl_api_show_one_map_register_fallback_threshold_t *mp;
2428 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
2433 /* Wait for a reply... */
2439 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
2441 u32 *proto = va_arg (*args, u32 *);
2443 if (unformat (input, "udp"))
2445 else if (unformat (input, "api"))
2454 api_one_set_transport_protocol (vat_main_t * vam)
2456 unformat_input_t *input = vam->input;
2457 vl_api_one_set_transport_protocol_t *mp;
2462 /* Parse args required to build the message */
2463 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2465 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
2469 clib_warning ("parse error '%U'", format_unformat_error, input);
2476 errmsg ("Transport protocol missing!");
2480 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
2481 mp->protocol = (u8) protocol;
2486 /* Wait for a reply... */
2492 api_one_get_transport_protocol (vat_main_t * vam)
2494 vl_api_one_get_transport_protocol_t *mp;
2497 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
2502 /* Wait for a reply... */
2508 api_one_map_register_set_ttl (vat_main_t * vam)
2510 unformat_input_t *input = vam->input;
2511 vl_api_one_map_register_set_ttl_t *mp;
2516 /* Parse args required to build the message */
2517 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2519 if (unformat (input, "%u", &ttl))
2523 clib_warning ("parse error '%U'", format_unformat_error, input);
2530 errmsg ("TTL value missing!");
2534 M (ONE_MAP_REGISTER_SET_TTL, mp);
2535 mp->ttl = clib_host_to_net_u32 (ttl);
2540 /* Wait for a reply... */
2546 api_show_one_map_register_ttl (vat_main_t * vam)
2548 vl_api_show_one_map_register_ttl_t *mp;
2551 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
2556 /* Wait for a reply... */
2562 * Add/del map request itr rlocs from ONE control plane and updates
2564 * @param vam vpp API test context
2565 * @return return code
2568 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
2570 unformat_input_t *input = vam->input;
2571 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
2572 u8 *locator_set_name = 0;
2573 u8 locator_set_name_set = 0;
2577 /* Parse args required to build the message */
2578 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2580 if (unformat (input, "del"))
2584 else if (unformat (input, "%_%v%_", &locator_set_name))
2586 locator_set_name_set = 1;
2590 clib_warning ("parse error '%U'", format_unformat_error, input);
2595 if (is_add && !locator_set_name_set)
2597 errmsg ("itr-rloc is not set!");
2601 if (is_add && vec_len (locator_set_name) > 64)
2603 errmsg ("itr-rloc locator-set name too long");
2604 vec_free (locator_set_name);
2608 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
2609 mp->is_add = is_add;
2612 clib_memcpy (mp->locator_set_name, locator_set_name,
2613 vec_len (locator_set_name));
2617 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
2619 vec_free (locator_set_name);
2624 /* Wait for a reply... */
2629 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
2632 api_one_locator_dump (vat_main_t * vam)
2634 unformat_input_t *input = vam->input;
2635 vl_api_one_locator_dump_t *mp;
2636 vl_api_control_ping_t *mp_ping;
2637 u8 is_index_set = 0, is_name_set = 0;
2642 /* Parse args required to build the message */
2643 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2645 if (unformat (input, "ls_name %_%v%_", &ls_name))
2649 else if (unformat (input, "ls_index %d", &ls_index))
2655 errmsg ("parse error '%U'", format_unformat_error, input);
2660 if (!is_index_set && !is_name_set)
2662 errmsg ("error: expected one of index or name!");
2666 if (is_index_set && is_name_set)
2668 errmsg ("error: only one param expected!");
2672 if (vec_len (ls_name) > 62)
2674 errmsg ("error: locator set name too long!");
2678 if (!vam->json_output)
2680 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
2683 M (ONE_LOCATOR_DUMP, mp);
2684 mp->is_index_set = is_index_set;
2687 mp->ls_index = clib_host_to_net_u32 (ls_index);
2690 vec_add1 (ls_name, 0);
2691 strncpy ((char *) mp->ls_name, (char *) ls_name,
2692 sizeof (mp->ls_name) - 1);
2698 /* Use a control ping for synchronization */
2699 LISP_PING (&one_test_main, mp_ping);
2702 /* Wait for a reply... */
2707 #define api_lisp_locator_dump api_one_locator_dump
2710 api_one_locator_set_dump (vat_main_t * vam)
2712 vl_api_one_locator_set_dump_t *mp;
2713 vl_api_control_ping_t *mp_ping;
2714 unformat_input_t *input = vam->input;
2718 /* Parse args required to build the message */
2719 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2721 if (unformat (input, "local"))
2725 else if (unformat (input, "remote"))
2731 errmsg ("parse error '%U'", format_unformat_error, input);
2736 if (!vam->json_output)
2738 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
2741 M (ONE_LOCATOR_SET_DUMP, mp);
2743 mp->filter = filter;
2748 /* Use a control ping for synchronization */
2749 LISP_PING (&one_test_main, mp_ping);
2752 /* Wait for a reply... */
2757 #define api_lisp_locator_set_dump api_one_locator_set_dump
2760 api_one_eid_table_map_dump (vat_main_t * vam)
2764 unformat_input_t *input = vam->input;
2765 vl_api_one_eid_table_map_dump_t *mp;
2766 vl_api_control_ping_t *mp_ping;
2769 /* Parse args required to build the message */
2770 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2772 if (unformat (input, "l2"))
2777 else if (unformat (input, "l3"))
2784 errmsg ("parse error '%U'", format_unformat_error, input);
2791 errmsg ("expected one of 'l2' or 'l3' parameter!");
2795 if (!vam->json_output)
2797 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
2800 M (ONE_EID_TABLE_MAP_DUMP, mp);
2806 /* Use a control ping for synchronization */
2807 LISP_PING (&one_test_main, mp_ping);
2810 /* Wait for a reply... */
2815 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
2818 api_one_eid_table_vni_dump (vat_main_t * vam)
2820 vl_api_one_eid_table_vni_dump_t *mp;
2821 vl_api_control_ping_t *mp_ping;
2824 if (!vam->json_output)
2826 print (vam->ofp, "VNI");
2829 M (ONE_EID_TABLE_VNI_DUMP, mp);
2834 /* Use a control ping for synchronization */
2835 LISP_PING (&one_test_main, mp_ping);
2838 /* Wait for a reply... */
2843 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
2846 api_one_eid_table_dump (vat_main_t * vam)
2848 unformat_input_t *i = vam->input;
2849 vl_api_one_eid_table_dump_t *mp;
2850 vl_api_control_ping_t *mp_ping;
2857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2860 (i, "eid %U/%d", unformat_ip46_address, &eid.addr.ip, &eid.len))
2866 if (unformat (i, "eid %U", unformat_ethernet_address, &eid.addr.mac))
2871 else if (unformat (i, "eid %U", unformat_nsh_address, &eid.addr.nsh))
2876 else if (unformat (i, "vni %d", &t))
2880 else if (unformat (i, "local"))
2884 else if (unformat (i, "remote"))
2890 errmsg ("parse error '%U'", format_unformat_error, i);
2895 if (!vam->json_output)
2897 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
2898 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
2901 M (ONE_EID_TABLE_DUMP, mp);
2903 mp->filter = filter;
2907 mp->vni = htonl (vni);
2908 lisp_eid_put_vat (&mp->eid, &eid);
2914 /* Use a control ping for synchronization */
2915 LISP_PING (&one_test_main, mp_ping);
2918 /* Wait for a reply... */
2924 api_one_adjacencies_get (vat_main_t * vam)
2926 unformat_input_t *i = vam->input;
2927 vl_api_one_adjacencies_get_t *mp;
2932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2934 if (unformat (i, "vni %d", &vni))
2940 errmsg ("parse error '%U'", format_unformat_error, i);
2947 errmsg ("vni not set!");
2951 if (!vam->json_output)
2953 print (vam->ofp, "%s %40s", "leid", "reid");
2956 M (ONE_ADJACENCIES_GET, mp);
2957 mp->vni = clib_host_to_net_u32 (vni);
2962 /* Wait for a reply... */
2968 api_one_map_server_dump (vat_main_t * vam)
2970 vl_api_one_map_server_dump_t *mp;
2971 vl_api_control_ping_t *mp_ping;
2974 if (!vam->json_output)
2976 print (vam->ofp, "%=20s", "Map server");
2979 M (ONE_MAP_SERVER_DUMP, mp);
2983 /* Use a control ping for synchronization */
2984 LISP_PING (&one_test_main, mp_ping);
2987 /* Wait for a reply... */
2992 #define api_lisp_map_server_dump api_one_map_server_dump
2995 api_one_map_resolver_dump (vat_main_t * vam)
2997 vl_api_one_map_resolver_dump_t *mp;
2998 vl_api_control_ping_t *mp_ping;
3001 if (!vam->json_output)
3003 print (vam->ofp, "%=20s", "Map resolver");
3006 M (ONE_MAP_RESOLVER_DUMP, mp);
3010 /* Use a control ping for synchronization */
3011 LISP_PING (&one_test_main, mp_ping);
3014 /* Wait for a reply... */
3019 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
3022 api_one_stats_flush (vat_main_t * vam)
3024 vl_api_one_stats_flush_t *mp;
3027 M (ONE_STATS_FLUSH, mp);
3034 api_one_stats_dump (vat_main_t * vam)
3036 vl_api_one_stats_dump_t *mp;
3037 vl_api_control_ping_t *mp_ping;
3040 M (ONE_STATS_DUMP, mp);
3044 /* Use a control ping for synchronization */
3045 LISP_PING (&one_test_main, mp_ping);
3048 /* Wait for a reply... */
3054 api_show_one_status (vat_main_t * vam)
3056 vl_api_show_one_status_t *mp;
3059 if (!vam->json_output)
3061 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
3064 M (SHOW_ONE_STATUS, mp);
3067 /* Wait for a reply... */
3073 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
3075 vl_api_one_get_map_request_itr_rlocs_t *mp;
3078 if (!vam->json_output)
3080 print (vam->ofp, "%=20s", "itr-rlocs:");
3083 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
3086 /* Wait for a reply... */
3091 #define vat_plugin_register vat_plugin_register_one
3092 #include <lisp/lisp-cp/one.api_test.c>
3095 * fd.io coding-style-patch-verification: ON
3098 * eval: (c-set-style "gnu")