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;
674 /** Used for parsing LISP eids */
675 typedef CLIB_PACKED(struct{
681 u32 len; /**< prefix length if IP */
682 u8 type; /**< type of eid */
686 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
688 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
690 clib_memset (a, 0, sizeof (a[0]));
692 if (unformat (input, "%U/%d", unformat_ip46_address, a->addr.ip, &a->len))
694 a->type = 0; /* ip prefix type */
696 else if (unformat (input, "%U", unformat_ethernet_address, &a->addr.mac))
698 a->type = 1; /* mac type */
700 else if (unformat (input, "%U", unformat_nsh_address, a->addr.nsh))
702 a->type = 2; /* NSH type */
703 a->addr.nsh.spi = clib_host_to_net_u32 (a->addr.nsh.spi);
712 if (ip46_address_is_ip4 (&a->addr.ip))
713 return a->len > 32 ? 1 : 0;
715 return a->len > 128 ? 1 : 0;
722 lisp_eid_put_vat (vl_api_eid_t * eid, const lisp_eid_vat_t * vat_eid)
724 eid->type = vat_eid->type;
727 case EID_TYPE_API_PREFIX:
728 if (ip46_address_is_ip4 (&vat_eid->addr.ip))
730 clib_memcpy (&eid->address.prefix.address.un.ip4,
731 &vat_eid->addr.ip.ip4, 4);
732 eid->address.prefix.address.af = ADDRESS_IP4;
733 eid->address.prefix.len = vat_eid->len;
737 clib_memcpy (&eid->address.prefix.address.un.ip6,
738 &vat_eid->addr.ip.ip6, 16);
739 eid->address.prefix.address.af = ADDRESS_IP6;
740 eid->address.prefix.len = vat_eid->len;
743 case EID_TYPE_API_MAC:
744 clib_memcpy (&eid->address.mac, &vat_eid->addr.mac,
745 sizeof (eid->address.mac));
747 case EID_TYPE_API_NSH:
748 clib_memcpy (&eid->address.nsh, &vat_eid->addr.nsh,
749 sizeof (eid->address.nsh));
758 api_one_add_del_locator_set (vat_main_t * vam)
760 unformat_input_t *input = vam->input;
761 vl_api_one_add_del_locator_set_t *mp;
763 u8 *locator_set_name = NULL;
764 u8 locator_set_name_set = 0;
765 vl_api_local_locator_t locator, *locators = 0;
766 u32 sw_if_index, priority, weight;
770 /* Parse args required to build the message */
771 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
773 if (unformat (input, "del"))
777 else if (unformat (input, "locator-set %s", &locator_set_name))
779 locator_set_name_set = 1;
781 else if (unformat (input, "sw_if_index %u p %u w %u",
782 &sw_if_index, &priority, &weight))
784 locator.sw_if_index = htonl (sw_if_index);
785 locator.priority = priority;
786 locator.weight = weight;
787 vec_add1 (locators, locator);
791 (input, "iface %U p %u w %u", unformat_sw_if_index, vam,
792 &sw_if_index, &priority, &weight))
794 locator.sw_if_index = htonl (sw_if_index);
795 locator.priority = priority;
796 locator.weight = weight;
797 vec_add1 (locators, locator);
803 if (locator_set_name_set == 0)
805 errmsg ("missing locator-set name");
810 if (vec_len (locator_set_name) > 64)
812 errmsg ("locator-set name too long");
813 vec_free (locator_set_name);
817 vec_add1 (locator_set_name, 0);
819 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
821 /* Construct the API message */
822 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
825 clib_memcpy (mp->locator_set_name, locator_set_name,
826 vec_len (locator_set_name));
827 vec_free (locator_set_name);
829 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
831 clib_memcpy (mp->locators, locators, data_len);
837 /* Wait for a reply... */
842 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
845 api_one_add_del_locator (vat_main_t * vam)
847 unformat_input_t *input = vam->input;
848 vl_api_one_add_del_locator_t *mp;
849 u32 tmp_if_index = ~0;
850 u32 sw_if_index = ~0;
851 u8 sw_if_index_set = 0;
852 u8 sw_if_index_if_name_set = 0;
858 u8 *locator_set_name = NULL;
859 u8 locator_set_name_set = 0;
862 /* Parse args required to build the message */
863 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
865 if (unformat (input, "del"))
869 else if (unformat (input, "locator-set %s", &locator_set_name))
871 locator_set_name_set = 1;
873 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
876 sw_if_index_if_name_set = 1;
877 sw_if_index = tmp_if_index;
879 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
882 sw_if_index = tmp_if_index;
884 else if (unformat (input, "p %d", &priority))
888 else if (unformat (input, "w %d", &weight))
896 if (locator_set_name_set == 0)
898 errmsg ("missing locator-set name");
902 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
904 errmsg ("missing sw_if_index");
905 vec_free (locator_set_name);
909 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
911 errmsg ("cannot use both params interface name and sw_if_index");
912 vec_free (locator_set_name);
916 if (priority_set == 0)
918 errmsg ("missing locator-set priority");
919 vec_free (locator_set_name);
925 errmsg ("missing locator-set weight");
926 vec_free (locator_set_name);
930 if (vec_len (locator_set_name) > 64)
932 errmsg ("locator-set name too long");
933 vec_free (locator_set_name);
936 vec_add1 (locator_set_name, 0);
938 /* Construct the API message */
939 M (ONE_ADD_DEL_LOCATOR, mp);
942 mp->sw_if_index = ntohl (sw_if_index);
943 mp->priority = priority;
945 clib_memcpy (mp->locator_set_name, locator_set_name,
946 vec_len (locator_set_name));
947 vec_free (locator_set_name);
952 /* Wait for a reply... */
957 #define api_lisp_add_del_locator api_one_add_del_locator
960 api_one_add_del_local_eid (vat_main_t * vam)
962 unformat_input_t *input = vam->input;
963 vl_api_one_add_del_local_eid_t *mp;
966 lisp_eid_vat_t _eid, *eid = &_eid;
967 u8 *locator_set_name = 0;
968 u8 locator_set_name_set = 0;
974 /* Parse args required to build the message */
975 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
977 if (unformat (input, "del"))
981 else if (unformat (input, "vni %d", &vni))
985 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
989 else if (unformat (input, "locator-set %s", &locator_set_name))
991 locator_set_name_set = 1;
993 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
995 else if (unformat (input, "secret-key %_%v%_", &key))
1001 if (locator_set_name_set == 0)
1003 errmsg ("missing locator-set name");
1009 errmsg ("EID address not set!");
1010 vec_free (locator_set_name);
1014 if (key && (0 == key_id))
1016 errmsg ("invalid key_id!");
1020 if (vec_len (key) > 64)
1022 errmsg ("key too long");
1027 if (vec_len (locator_set_name) > 64)
1029 errmsg ("locator-set name too long");
1030 vec_free (locator_set_name);
1033 vec_add1 (locator_set_name, 0);
1035 /* Construct the API message */
1036 M (ONE_ADD_DEL_LOCAL_EID, mp);
1038 mp->is_add = is_add;
1039 lisp_eid_put_vat (&mp->eid, eid);
1040 mp->vni = clib_host_to_net_u32 (vni);
1041 mp->key.id = key_id;
1042 clib_memcpy (mp->locator_set_name, locator_set_name,
1043 vec_len (locator_set_name));
1044 clib_memcpy (mp->key.key, key, vec_len (key));
1046 vec_free (locator_set_name);
1052 /* Wait for a reply... */
1058 api_one_add_del_map_server (vat_main_t * vam)
1060 unformat_input_t *input = vam->input;
1061 vl_api_one_add_del_map_server_t *mp;
1069 /* Parse args required to build the message */
1070 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1072 if (unformat (input, "del"))
1076 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
1080 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
1088 if (ipv4_set && ipv6_set)
1090 errmsg ("both eid v4 and v6 addresses set");
1094 if (!ipv4_set && !ipv6_set)
1096 errmsg ("eid addresses not set");
1100 /* Construct the API message */
1101 M (ONE_ADD_DEL_MAP_SERVER, mp);
1103 mp->is_add = is_add;
1106 mp->ip_address.af = 1;
1107 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
1111 mp->ip_address.af = 0;
1112 clib_memcpy (mp->ip_address.un.ip4, &ipv4, sizeof (ipv4));
1118 /* Wait for a reply... */
1123 #define api_lisp_add_del_map_server api_one_add_del_map_server
1126 api_one_add_del_map_resolver (vat_main_t * vam)
1128 unformat_input_t *input = vam->input;
1129 vl_api_one_add_del_map_resolver_t *mp;
1137 /* Parse args required to build the message */
1138 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1140 if (unformat (input, "del"))
1144 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
1148 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
1156 if (ipv4_set && ipv6_set)
1158 errmsg ("both eid v4 and v6 addresses set");
1162 if (!ipv4_set && !ipv6_set)
1164 errmsg ("eid addresses not set");
1168 /* Construct the API message */
1169 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
1171 mp->is_add = is_add;
1174 mp->ip_address.af = 1;
1175 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
1179 mp->ip_address.af = 0;
1180 clib_memcpy (mp->ip_address.un.ip6, &ipv4, sizeof (ipv4));
1186 /* Wait for a reply... */
1192 api_one_rloc_probe_enable_disable (vat_main_t * vam)
1194 unformat_input_t *input = vam->input;
1195 vl_api_one_rloc_probe_enable_disable_t *mp;
1200 /* Parse args required to build the message */
1201 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1203 if (unformat (input, "enable"))
1208 else if (unformat (input, "disable"))
1216 errmsg ("Value not set");
1220 /* Construct the API message */
1221 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
1223 mp->is_enable = is_enable;
1228 /* Wait for a reply... */
1233 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
1236 api_one_map_register_enable_disable (vat_main_t * vam)
1238 unformat_input_t *input = vam->input;
1239 vl_api_one_map_register_enable_disable_t *mp;
1244 /* Parse args required to build the message */
1245 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1247 if (unformat (input, "enable"))
1252 else if (unformat (input, "disable"))
1260 errmsg ("Value not set");
1264 /* Construct the API message */
1265 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
1267 mp->is_enable = is_enable;
1272 /* Wait for a reply... */
1277 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
1280 api_one_enable_disable (vat_main_t * vam)
1282 unformat_input_t *input = vam->input;
1283 vl_api_one_enable_disable_t *mp;
1288 /* Parse args required to build the message */
1289 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1291 if (unformat (input, "enable"))
1296 else if (unformat (input, "disable"))
1306 errmsg ("Value not set");
1310 /* Construct the API message */
1311 M (ONE_ENABLE_DISABLE, mp);
1313 mp->is_enable = is_enable;
1318 /* Wait for a reply... */
1323 #define api_lisp_enable_disable api_one_enable_disable
1326 api_one_enable_disable_xtr_mode (vat_main_t * vam)
1328 unformat_input_t *input = vam->input;
1329 vl_api_one_enable_disable_xtr_mode_t *mp;
1334 /* Parse args required to build the message */
1335 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1337 if (unformat (input, "enable"))
1342 else if (unformat (input, "disable"))
1352 errmsg ("Value not set");
1356 /* Construct the API message */
1357 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
1359 mp->is_enable = is_enable;
1364 /* Wait for a reply... */
1370 api_one_show_xtr_mode (vat_main_t * vam)
1372 vl_api_one_show_xtr_mode_t *mp;
1375 /* Construct the API message */
1376 M (ONE_SHOW_XTR_MODE, mp);
1381 /* Wait for a reply... */
1387 api_one_enable_disable_pitr_mode (vat_main_t * vam)
1389 unformat_input_t *input = vam->input;
1390 vl_api_one_enable_disable_pitr_mode_t *mp;
1395 /* Parse args required to build the message */
1396 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1398 if (unformat (input, "enable"))
1403 else if (unformat (input, "disable"))
1413 errmsg ("Value not set");
1417 /* Construct the API message */
1418 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
1420 mp->is_enable = is_enable;
1425 /* Wait for a reply... */
1431 api_one_show_pitr_mode (vat_main_t * vam)
1433 vl_api_one_show_pitr_mode_t *mp;
1436 /* Construct the API message */
1437 M (ONE_SHOW_PITR_MODE, mp);
1442 /* Wait for a reply... */
1448 api_one_enable_disable_petr_mode (vat_main_t * vam)
1450 unformat_input_t *input = vam->input;
1451 vl_api_one_enable_disable_petr_mode_t *mp;
1456 /* Parse args required to build the message */
1457 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1459 if (unformat (input, "enable"))
1464 else if (unformat (input, "disable"))
1474 errmsg ("Value not set");
1478 /* Construct the API message */
1479 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
1481 mp->is_enable = is_enable;
1486 /* Wait for a reply... */
1492 api_one_show_petr_mode (vat_main_t * vam)
1494 vl_api_one_show_petr_mode_t *mp;
1497 /* Construct the API message */
1498 M (ONE_SHOW_PETR_MODE, mp);
1503 /* Wait for a reply... */
1509 api_show_one_map_register_state (vat_main_t * vam)
1511 vl_api_show_one_map_register_state_t *mp;
1514 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
1519 /* wait for reply */
1524 #define api_show_lisp_map_register_state api_show_one_map_register_state
1527 api_show_one_rloc_probe_state (vat_main_t * vam)
1529 vl_api_show_one_rloc_probe_state_t *mp;
1532 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
1537 /* wait for reply */
1542 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
1545 api_one_add_del_ndp_entry (vat_main_t * vam)
1547 vl_api_one_add_del_ndp_entry_t *mp;
1548 unformat_input_t *input = vam->input;
1554 u8 ip6[16] = { 0, };
1558 /* Parse args required to build the message */
1559 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1561 if (unformat (input, "del"))
1563 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
1565 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
1567 else if (unformat (input, "bd %d", &bd))
1571 errmsg ("parse error '%U'", format_unformat_error, input);
1576 if (!bd_set || !ip_set || (!mac_set && is_add))
1578 errmsg ("Missing BD, IP or MAC!");
1582 M (ONE_ADD_DEL_NDP_ENTRY, mp);
1583 mp->is_add = is_add;
1584 clib_memcpy (&mp->entry.mac, mac, 6);
1585 mp->bd = clib_host_to_net_u32 (bd);
1586 clib_memcpy (&mp->entry.ip6, ip6, sizeof (mp->entry.ip6));
1591 /* wait for reply */
1597 api_one_add_del_l2_arp_entry (vat_main_t * vam)
1599 vl_api_one_add_del_l2_arp_entry_t *mp;
1600 unformat_input_t *input = vam->input;
1606 u32 ip4 = 0, bd = ~0;
1609 /* Parse args required to build the message */
1610 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1612 if (unformat (input, "del"))
1614 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
1616 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
1618 else if (unformat (input, "bd %d", &bd))
1622 errmsg ("parse error '%U'", format_unformat_error, input);
1627 if (!bd_set || !ip_set || (!mac_set && is_add))
1629 errmsg ("Missing BD, IP or MAC!");
1633 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
1634 mp->is_add = is_add;
1635 clib_memcpy (&mp->entry.mac, mac, 6);
1636 mp->bd = clib_host_to_net_u32 (bd);
1637 clib_memcpy (mp->entry.ip4, &ip4, sizeof (mp->entry.ip4));
1642 /* wait for reply */
1648 api_one_ndp_bd_get (vat_main_t * vam)
1650 vl_api_one_ndp_bd_get_t *mp;
1653 M (ONE_NDP_BD_GET, mp);
1658 /* wait for reply */
1664 api_one_ndp_entries_get (vat_main_t * vam)
1666 vl_api_one_ndp_entries_get_t *mp;
1667 unformat_input_t *input = vam->input;
1672 /* Parse args required to build the message */
1673 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1675 if (unformat (input, "bd %d", &bd))
1679 errmsg ("parse error '%U'", format_unformat_error, input);
1686 errmsg ("Expected bridge domain!");
1690 M (ONE_NDP_ENTRIES_GET, mp);
1691 mp->bd = clib_host_to_net_u32 (bd);
1696 /* wait for reply */
1702 api_one_l2_arp_bd_get (vat_main_t * vam)
1704 vl_api_one_l2_arp_bd_get_t *mp;
1707 M (ONE_L2_ARP_BD_GET, mp);
1712 /* wait for reply */
1718 api_one_l2_arp_entries_get (vat_main_t * vam)
1720 vl_api_one_l2_arp_entries_get_t *mp;
1721 unformat_input_t *input = vam->input;
1726 /* Parse args required to build the message */
1727 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1729 if (unformat (input, "bd %d", &bd))
1733 errmsg ("parse error '%U'", format_unformat_error, input);
1740 errmsg ("Expected bridge domain!");
1744 M (ONE_L2_ARP_ENTRIES_GET, mp);
1745 mp->bd = clib_host_to_net_u32 (bd);
1750 /* wait for reply */
1756 api_one_stats_enable_disable (vat_main_t * vam)
1758 vl_api_one_stats_enable_disable_t *mp;
1759 unformat_input_t *input = vam->input;
1764 /* Parse args required to build the message */
1765 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1767 if (unformat (input, "enable"))
1772 else if (unformat (input, "disable"))
1782 errmsg ("Value not set");
1786 M (ONE_STATS_ENABLE_DISABLE, mp);
1787 mp->is_enable = is_enable;
1792 /* wait for reply */
1798 api_show_one_stats_enable_disable (vat_main_t * vam)
1800 vl_api_show_one_stats_enable_disable_t *mp;
1803 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
1808 /* wait for reply */
1814 api_show_one_map_request_mode (vat_main_t * vam)
1816 vl_api_show_one_map_request_mode_t *mp;
1819 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
1824 /* wait for reply */
1829 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
1832 api_one_map_request_mode (vat_main_t * vam)
1834 unformat_input_t *input = vam->input;
1835 vl_api_one_map_request_mode_t *mp;
1839 /* Parse args required to build the message */
1840 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1842 if (unformat (input, "dst-only"))
1844 else if (unformat (input, "src-dst"))
1848 errmsg ("parse error '%U'", format_unformat_error, input);
1853 M (ONE_MAP_REQUEST_MODE, mp);
1860 /* wait for reply */
1865 #define api_lisp_map_request_mode api_one_map_request_mode
1868 * Enable/disable ONE proxy ITR.
1870 * @param vam vpp API test context
1871 * @return return code
1874 api_one_pitr_set_locator_set (vat_main_t * vam)
1877 unformat_input_t *input = vam->input;
1878 vl_api_one_pitr_set_locator_set_t *mp;
1883 /* Parse args required to build the message */
1884 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1886 if (unformat (input, "del"))
1888 else if (unformat (input, "locator-set %s", &ls_name))
1892 errmsg ("parse error '%U'", format_unformat_error, input);
1899 errmsg ("locator-set name not set!");
1903 M (ONE_PITR_SET_LOCATOR_SET, mp);
1905 mp->is_add = is_add;
1906 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
1912 /* wait for reply */
1917 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
1920 api_one_nsh_set_locator_set (vat_main_t * vam)
1923 unformat_input_t *input = vam->input;
1924 vl_api_one_nsh_set_locator_set_t *mp;
1929 /* Parse args required to build the message */
1930 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1932 if (unformat (input, "del"))
1934 else if (unformat (input, "ls %s", &ls_name))
1938 errmsg ("parse error '%U'", format_unformat_error, input);
1943 if (!ls_name_set && is_add)
1945 errmsg ("locator-set name not set!");
1949 M (ONE_NSH_SET_LOCATOR_SET, mp);
1951 mp->is_add = is_add;
1952 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
1958 /* wait for reply */
1964 api_show_one_pitr (vat_main_t * vam)
1966 vl_api_show_one_pitr_t *mp;
1969 if (!vam->json_output)
1971 print (vam->ofp, "%=20s", "lisp status:");
1974 M (SHOW_ONE_PITR, mp);
1978 /* Wait for a reply... */
1983 #define api_show_lisp_pitr api_show_one_pitr
1986 api_one_use_petr (vat_main_t * vam)
1988 unformat_input_t *input = vam->input;
1989 vl_api_one_use_petr_t *mp;
1994 clib_memset (&ip, 0, sizeof (ip));
1996 /* Parse args required to build the message */
1997 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1999 if (unformat (input, "disable"))
2002 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
2005 ip_addr_version (&ip) = AF_IP4;
2008 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
2011 ip_addr_version (&ip) = AF_IP6;
2015 errmsg ("parse error '%U'", format_unformat_error, input);
2020 M (ONE_USE_PETR, mp);
2022 mp->is_add = is_add;
2025 mp->ip_address.af = ip_addr_version (&ip) == AF_IP4 ? 0 : 1;
2026 if (mp->ip_address.af)
2027 clib_memcpy (mp->ip_address.un.ip6, &ip, 16);
2029 clib_memcpy (mp->ip_address.un.ip4, &ip, 4);
2035 /* wait for reply */
2040 #define api_lisp_use_petr api_one_use_petr
2043 api_show_one_nsh_mapping (vat_main_t * vam)
2045 vl_api_show_one_use_petr_t *mp;
2048 if (!vam->json_output)
2050 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
2053 M (SHOW_ONE_NSH_MAPPING, mp);
2057 /* Wait for a reply... */
2063 api_show_one_use_petr (vat_main_t * vam)
2065 vl_api_show_one_use_petr_t *mp;
2068 if (!vam->json_output)
2070 print (vam->ofp, "%=20s", "Proxy-ETR status:");
2073 M (SHOW_ONE_USE_PETR, mp);
2077 /* Wait for a reply... */
2082 #define api_show_lisp_use_petr api_show_one_use_petr
2085 * Add/delete mapping between vni and vrf
2088 api_one_eid_table_add_del_map (vat_main_t * vam)
2090 unformat_input_t *input = vam->input;
2091 vl_api_one_eid_table_add_del_map_t *mp;
2092 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
2093 u32 vni, vrf, bd_index;
2096 /* Parse args required to build the message */
2097 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2099 if (unformat (input, "del"))
2101 else if (unformat (input, "vrf %d", &vrf))
2103 else if (unformat (input, "bd_index %d", &bd_index))
2105 else if (unformat (input, "vni %d", &vni))
2111 if (!vni_set || (!vrf_set && !bd_index_set))
2113 errmsg ("missing arguments!");
2117 if (vrf_set && bd_index_set)
2119 errmsg ("error: both vrf and bd entered!");
2123 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
2125 mp->is_add = is_add;
2126 mp->vni = htonl (vni);
2127 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
2128 mp->is_l2 = bd_index_set;
2133 /* wait for reply */
2138 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
2141 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
2143 u32 *action = va_arg (*args, u32 *);
2146 if (unformat (input, "%s", &s))
2148 if (!strcmp ((char *) s, "no-action"))
2150 else if (!strcmp ((char *) s, "natively-forward"))
2152 else if (!strcmp ((char *) s, "send-map-request"))
2154 else if (!strcmp ((char *) s, "drop"))
2158 clib_warning ("invalid action: '%s'", s);
2170 * Add/del remote mapping to/from ONE control plane
2172 * @param vam vpp API test context
2173 * @return return code
2176 api_one_add_del_remote_mapping (vat_main_t * vam)
2178 unformat_input_t *input = vam->input;
2179 vl_api_one_add_del_remote_mapping_t *mp;
2181 lisp_eid_vat_t _eid, *eid = &_eid;
2182 lisp_eid_vat_t _seid, *seid = &_seid;
2183 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
2184 u32 action = ~0, p, w, data_len;
2185 ip4_address_t rloc4;
2186 ip6_address_t rloc6;
2187 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
2190 clib_memset (&rloc, 0, sizeof (rloc));
2192 /* Parse args required to build the message */
2193 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2195 if (unformat (input, "del-all"))
2199 else if (unformat (input, "del"))
2203 else if (unformat (input, "add"))
2207 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
2211 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
2215 else if (unformat (input, "vni %d", &vni))
2219 else if (unformat (input, "p %d w %d", &p, &w))
2223 errmsg ("No RLOC configured for setting priority/weight!");
2226 curr_rloc->priority = p;
2227 curr_rloc->weight = w;
2229 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
2231 rloc.ip_address.af = 0;
2232 clib_memcpy (&rloc.ip_address.un.ip6, &rloc6, sizeof (rloc6));
2233 vec_add1 (rlocs, rloc);
2234 curr_rloc = &rlocs[vec_len (rlocs) - 1];
2236 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
2238 rloc.ip_address.af = 1;
2239 clib_memcpy (&rloc.ip_address.un.ip4, &rloc4, sizeof (rloc4));
2240 vec_add1 (rlocs, rloc);
2241 curr_rloc = &rlocs[vec_len (rlocs) - 1];
2243 else if (unformat (input, "action %U",
2244 unformat_negative_mapping_action, &action))
2250 clib_warning ("parse error '%U'", format_unformat_error, input);
2257 errmsg ("missing params!");
2261 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
2263 errmsg ("no action set for negative map-reply!");
2267 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
2269 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
2270 mp->is_add = is_add;
2271 mp->vni = htonl (vni);
2272 mp->action = (u8) action;
2273 mp->is_src_dst = seid_set;
2274 mp->del_all = del_all;
2275 lisp_eid_put_vat (&mp->deid, eid);
2276 lisp_eid_put_vat (&mp->seid, seid);
2278 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
2279 clib_memcpy (mp->rlocs, rlocs, data_len);
2285 /* Wait for a reply... */
2290 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
2293 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
2294 * forwarding entries in data-plane accordingly.
2296 * @param vam vpp API test context
2297 * @return return code
2300 api_one_add_del_adjacency (vat_main_t * vam)
2302 unformat_input_t *input = vam->input;
2303 vl_api_one_add_del_adjacency_t *mp;
2307 lisp_eid_vat_t leid, reid;
2309 leid.type = reid.type = (u8) ~ 0;
2311 /* Parse args required to build the message */
2312 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2314 if (unformat (input, "del"))
2318 else if (unformat (input, "add"))
2322 else if (unformat (input, "reid %U/%d", unformat_ip46_address,
2323 &reid.addr.ip, &reid.len))
2325 reid.type = 0; /* ipv4 */
2327 else if (unformat (input, "reid %U", unformat_ethernet_address,
2330 reid.type = 1; /* mac */
2332 else if (unformat (input, "leid %U/%d", unformat_ip46_address,
2333 &leid.addr.ip, &leid.len))
2335 leid.type = 0; /* ipv4 */
2337 else if (unformat (input, "leid %U", unformat_ethernet_address,
2340 leid.type = 1; /* mac */
2342 else if (unformat (input, "vni %d", &vni))
2348 errmsg ("parse error '%U'", format_unformat_error, input);
2353 if ((u8) ~ 0 == reid.type)
2355 errmsg ("missing params!");
2359 if (leid.type != reid.type)
2361 errmsg ("remote and local EIDs are of different types!");
2365 M (ONE_ADD_DEL_ADJACENCY, mp);
2366 mp->is_add = is_add;
2367 mp->vni = htonl (vni);
2368 lisp_eid_put_vat (&mp->leid, &leid);
2369 lisp_eid_put_vat (&mp->reid, &reid);
2374 /* Wait for a reply... */
2379 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
2383 api_one_map_register_fallback_threshold (vat_main_t * vam)
2385 unformat_input_t *input = vam->input;
2386 vl_api_one_map_register_fallback_threshold_t *mp;
2391 /* Parse args required to build the message */
2392 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2394 if (unformat (input, "%u", &value))
2398 clib_warning ("parse error '%U'", format_unformat_error, input);
2405 errmsg ("fallback threshold value is missing!");
2409 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
2410 mp->value = clib_host_to_net_u32 (value);
2415 /* Wait for a reply... */
2421 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
2423 vl_api_show_one_map_register_fallback_threshold_t *mp;
2426 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
2431 /* Wait for a reply... */
2437 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
2439 u32 *proto = va_arg (*args, u32 *);
2441 if (unformat (input, "udp"))
2443 else if (unformat (input, "api"))
2452 api_one_set_transport_protocol (vat_main_t * vam)
2454 unformat_input_t *input = vam->input;
2455 vl_api_one_set_transport_protocol_t *mp;
2460 /* Parse args required to build the message */
2461 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2463 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
2467 clib_warning ("parse error '%U'", format_unformat_error, input);
2474 errmsg ("Transport protocol missing!");
2478 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
2479 mp->protocol = (u8) protocol;
2484 /* Wait for a reply... */
2490 api_one_get_transport_protocol (vat_main_t * vam)
2492 vl_api_one_get_transport_protocol_t *mp;
2495 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
2500 /* Wait for a reply... */
2506 api_one_map_register_set_ttl (vat_main_t * vam)
2508 unformat_input_t *input = vam->input;
2509 vl_api_one_map_register_set_ttl_t *mp;
2514 /* Parse args required to build the message */
2515 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2517 if (unformat (input, "%u", &ttl))
2521 clib_warning ("parse error '%U'", format_unformat_error, input);
2528 errmsg ("TTL value missing!");
2532 M (ONE_MAP_REGISTER_SET_TTL, mp);
2533 mp->ttl = clib_host_to_net_u32 (ttl);
2538 /* Wait for a reply... */
2544 api_show_one_map_register_ttl (vat_main_t * vam)
2546 vl_api_show_one_map_register_ttl_t *mp;
2549 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
2554 /* Wait for a reply... */
2560 * Add/del map request itr rlocs from ONE control plane and updates
2562 * @param vam vpp API test context
2563 * @return return code
2566 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
2568 unformat_input_t *input = vam->input;
2569 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
2570 u8 *locator_set_name = 0;
2571 u8 locator_set_name_set = 0;
2575 /* Parse args required to build the message */
2576 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2578 if (unformat (input, "del"))
2582 else if (unformat (input, "%_%v%_", &locator_set_name))
2584 locator_set_name_set = 1;
2588 clib_warning ("parse error '%U'", format_unformat_error, input);
2593 if (is_add && !locator_set_name_set)
2595 errmsg ("itr-rloc is not set!");
2599 if (is_add && vec_len (locator_set_name) > 64)
2601 errmsg ("itr-rloc locator-set name too long");
2602 vec_free (locator_set_name);
2606 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
2607 mp->is_add = is_add;
2610 clib_memcpy (mp->locator_set_name, locator_set_name,
2611 vec_len (locator_set_name));
2615 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
2617 vec_free (locator_set_name);
2622 /* Wait for a reply... */
2627 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
2630 api_one_locator_dump (vat_main_t * vam)
2632 unformat_input_t *input = vam->input;
2633 vl_api_one_locator_dump_t *mp;
2634 vl_api_control_ping_t *mp_ping;
2635 u8 is_index_set = 0, is_name_set = 0;
2640 /* Parse args required to build the message */
2641 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2643 if (unformat (input, "ls_name %_%v%_", &ls_name))
2647 else if (unformat (input, "ls_index %d", &ls_index))
2653 errmsg ("parse error '%U'", format_unformat_error, input);
2658 if (!is_index_set && !is_name_set)
2660 errmsg ("error: expected one of index or name!");
2664 if (is_index_set && is_name_set)
2666 errmsg ("error: only one param expected!");
2670 if (vec_len (ls_name) > 62)
2672 errmsg ("error: locator set name too long!");
2676 if (!vam->json_output)
2678 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
2681 M (ONE_LOCATOR_DUMP, mp);
2682 mp->is_index_set = is_index_set;
2685 mp->ls_index = clib_host_to_net_u32 (ls_index);
2688 vec_add1 (ls_name, 0);
2689 strncpy ((char *) mp->ls_name, (char *) ls_name,
2690 sizeof (mp->ls_name) - 1);
2696 /* Use a control ping for synchronization */
2697 LISP_PING (&one_test_main, mp_ping);
2700 /* Wait for a reply... */
2705 #define api_lisp_locator_dump api_one_locator_dump
2708 api_one_locator_set_dump (vat_main_t * vam)
2710 vl_api_one_locator_set_dump_t *mp;
2711 vl_api_control_ping_t *mp_ping;
2712 unformat_input_t *input = vam->input;
2716 /* Parse args required to build the message */
2717 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2719 if (unformat (input, "local"))
2723 else if (unformat (input, "remote"))
2729 errmsg ("parse error '%U'", format_unformat_error, input);
2734 if (!vam->json_output)
2736 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
2739 M (ONE_LOCATOR_SET_DUMP, mp);
2741 mp->filter = filter;
2746 /* Use a control ping for synchronization */
2747 LISP_PING (&one_test_main, mp_ping);
2750 /* Wait for a reply... */
2755 #define api_lisp_locator_set_dump api_one_locator_set_dump
2758 api_one_eid_table_map_dump (vat_main_t * vam)
2762 unformat_input_t *input = vam->input;
2763 vl_api_one_eid_table_map_dump_t *mp;
2764 vl_api_control_ping_t *mp_ping;
2767 /* Parse args required to build the message */
2768 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2770 if (unformat (input, "l2"))
2775 else if (unformat (input, "l3"))
2782 errmsg ("parse error '%U'", format_unformat_error, input);
2789 errmsg ("expected one of 'l2' or 'l3' parameter!");
2793 if (!vam->json_output)
2795 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
2798 M (ONE_EID_TABLE_MAP_DUMP, mp);
2804 /* Use a control ping for synchronization */
2805 LISP_PING (&one_test_main, mp_ping);
2808 /* Wait for a reply... */
2813 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
2816 api_one_eid_table_vni_dump (vat_main_t * vam)
2818 vl_api_one_eid_table_vni_dump_t *mp;
2819 vl_api_control_ping_t *mp_ping;
2822 if (!vam->json_output)
2824 print (vam->ofp, "VNI");
2827 M (ONE_EID_TABLE_VNI_DUMP, mp);
2832 /* Use a control ping for synchronization */
2833 LISP_PING (&one_test_main, mp_ping);
2836 /* Wait for a reply... */
2841 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
2844 api_one_eid_table_dump (vat_main_t * vam)
2846 unformat_input_t *i = vam->input;
2847 vl_api_one_eid_table_dump_t *mp;
2848 vl_api_control_ping_t *mp_ping;
2855 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2858 (i, "eid %U/%d", unformat_ip46_address, &eid.addr.ip, &eid.len))
2864 if (unformat (i, "eid %U", unformat_ethernet_address, &eid.addr.mac))
2869 else if (unformat (i, "eid %U", unformat_nsh_address, &eid.addr.nsh))
2874 else if (unformat (i, "vni %d", &t))
2878 else if (unformat (i, "local"))
2882 else if (unformat (i, "remote"))
2888 errmsg ("parse error '%U'", format_unformat_error, i);
2893 if (!vam->json_output)
2895 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
2896 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
2899 M (ONE_EID_TABLE_DUMP, mp);
2901 mp->filter = filter;
2905 mp->vni = htonl (vni);
2906 lisp_eid_put_vat (&mp->eid, &eid);
2912 /* Use a control ping for synchronization */
2913 LISP_PING (&one_test_main, mp_ping);
2916 /* Wait for a reply... */
2922 api_one_adjacencies_get (vat_main_t * vam)
2924 unformat_input_t *i = vam->input;
2925 vl_api_one_adjacencies_get_t *mp;
2930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2932 if (unformat (i, "vni %d", &vni))
2938 errmsg ("parse error '%U'", format_unformat_error, i);
2945 errmsg ("vni not set!");
2949 if (!vam->json_output)
2951 print (vam->ofp, "%s %40s", "leid", "reid");
2954 M (ONE_ADJACENCIES_GET, mp);
2955 mp->vni = clib_host_to_net_u32 (vni);
2960 /* Wait for a reply... */
2966 api_one_map_server_dump (vat_main_t * vam)
2968 vl_api_one_map_server_dump_t *mp;
2969 vl_api_control_ping_t *mp_ping;
2972 if (!vam->json_output)
2974 print (vam->ofp, "%=20s", "Map server");
2977 M (ONE_MAP_SERVER_DUMP, mp);
2981 /* Use a control ping for synchronization */
2982 LISP_PING (&one_test_main, mp_ping);
2985 /* Wait for a reply... */
2990 #define api_lisp_map_server_dump api_one_map_server_dump
2993 api_one_map_resolver_dump (vat_main_t * vam)
2995 vl_api_one_map_resolver_dump_t *mp;
2996 vl_api_control_ping_t *mp_ping;
2999 if (!vam->json_output)
3001 print (vam->ofp, "%=20s", "Map resolver");
3004 M (ONE_MAP_RESOLVER_DUMP, mp);
3008 /* Use a control ping for synchronization */
3009 LISP_PING (&one_test_main, mp_ping);
3012 /* Wait for a reply... */
3017 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
3020 api_one_stats_flush (vat_main_t * vam)
3022 vl_api_one_stats_flush_t *mp;
3025 M (ONE_STATS_FLUSH, mp);
3032 api_one_stats_dump (vat_main_t * vam)
3034 vl_api_one_stats_dump_t *mp;
3035 vl_api_control_ping_t *mp_ping;
3038 M (ONE_STATS_DUMP, mp);
3042 /* Use a control ping for synchronization */
3043 LISP_PING (&one_test_main, mp_ping);
3046 /* Wait for a reply... */
3052 api_show_one_status (vat_main_t * vam)
3054 vl_api_show_one_status_t *mp;
3057 if (!vam->json_output)
3059 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
3062 M (SHOW_ONE_STATUS, mp);
3065 /* Wait for a reply... */
3071 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
3073 vl_api_one_get_map_request_itr_rlocs_t *mp;
3076 if (!vam->json_output)
3078 print (vam->ofp, "%=20s", "itr-rlocs:");
3081 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
3084 /* Wait for a reply... */
3089 #define vat_plugin_register vat_plugin_register_one
3090 #include <lisp/lisp-cp/one.api_test.c>
3093 * fd.io coding-style-patch-verification: ON
3096 * eval: (c-set-style "gnu")