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>
44 /* Macro to finish up custom dump fns */
45 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
48 vl_print (handle, (char *)s); \
52 #define LISP_PING(_lm, mp_ping) \
53 if (!(_lm)->ping_id) \
54 (_lm)->ping_id = vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC)); \
55 mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping)); \
56 mp_ping->_vl_msg_id = htons ((_lm)->ping_id); \
57 mp_ping->client_index = vam->my_client_index; \
58 fformat (vam->ofp, "Sending ping id=%d\n", (_lm)->ping_id); \
59 vam->result_ready = 0; \
65 } __attribute__ ((__packed__)) lisp_nsh_api_t;
68 unformat_nsh_address (unformat_input_t * input, va_list * args)
70 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
71 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
75 format_nsh_address_vat (u8 * s, va_list * args)
77 nsh_t *a = va_arg (*args, nsh_t *);
78 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
82 format_lisp_transport_protocol (u8 * s, va_list * args)
84 u32 proto = va_arg (*args, u32);
89 return format (s, "udp");
91 return format (s, "api");
99 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
101 vat_main_t *vam = &vat_main;
106 s = format (s, "%=16d%=16d%=16d",
107 ntohl (mp->sw_if_index), mp->priority, mp->weight);
111 s = format (s, "%=16U%=16d%=16d",
113 mp->ip_address, mp->priority, mp->weight);
116 print (vam->ofp, "%v", s);
121 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
124 vat_main_t *vam = &vat_main;
127 ls_name = format (0, "%s", mp->ls_name);
129 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
134 static void vl_api_one_get_transport_protocol_reply_t_handler
135 (vl_api_one_get_transport_protocol_reply_t * mp)
137 vat_main_t *vam = &vat_main;
138 i32 retval = ntohl (mp->retval);
141 vam->async_errors += (retval < 0);
145 u32 proto = mp->protocol;
146 print (vam->ofp, "Transport protocol: %U",
147 format_lisp_transport_protocol, proto);
148 vam->retval = retval;
149 vam->result_ready = 1;
153 static void vl_api_one_add_del_locator_set_reply_t_handler
154 (vl_api_one_add_del_locator_set_reply_t * mp)
156 vat_main_t *vam = &vat_main;
157 i32 retval = ntohl (mp->retval);
160 vam->async_errors += (retval < 0);
164 vam->retval = retval;
165 vam->result_ready = 1;
170 format_lisp_flat_eid (u8 * s, va_list * args)
172 vl_api_eid_t *eid = va_arg (*args, vl_api_eid_t *);
176 case EID_TYPE_API_PREFIX:
177 if (eid->address.prefix.address.af)
178 return format (s, "%U/%d", format_ip6_address,
179 eid->address.prefix.address.un.ip6,
180 eid->address.prefix.len);
181 return format (s, "%U/%d", format_ip4_address,
182 eid->address.prefix.address.un.ip4,
183 eid->address.prefix.len);
184 case EID_TYPE_API_MAC:
185 return format (s, "%U", format_ethernet_address, eid->address.mac);
186 case EID_TYPE_API_NSH:
187 return format (s, "%U", format_nsh_address_vat, eid->address.nsh);
193 format_lisp_eid_vat (u8 * s, va_list * args)
195 vl_api_eid_t *deid = va_arg (*args, vl_api_eid_t *);
196 vl_api_eid_t *seid = va_arg (*args, vl_api_eid_t *);
197 u8 is_src_dst = (u8) va_arg (*args, int);
200 s = format (s, "%U|", format_lisp_flat_eid, seid);
202 s = format (s, "%U", format_lisp_flat_eid, deid);
208 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
210 vat_main_t *vam = &vat_main;
213 if (~0 == mp->locator_set_index)
214 s = format (0, "action: %d", mp->action);
216 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
218 eid = format (0, "%U", format_lisp_eid_vat,
219 &mp->deid, &mp->seid, mp->is_src_dst);
222 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
223 clib_net_to_host_u32 (mp->vni),
225 mp->is_local ? "local" : "remote",
226 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
227 clib_net_to_host_u16 (mp->key.id), mp->key.key);
234 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
236 vat_main_t *vam = &vat_main;
237 u8 *seid = 0, *deid = 0;
238 ip46_address_t lloc, rloc;
240 deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0);
242 seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0);
249 clib_memcpy (&lloc.ip6, mp->lloc.un.ip6, 16);
250 clib_memcpy (&rloc.ip6, mp->rloc.un.ip6, 16);
254 clib_memcpy (&lloc.ip4, mp->lloc.un.ip4, 4);
255 clib_memcpy (&rloc.ip4, mp->rloc.un.ip4, 4);
259 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
260 clib_net_to_host_u32 (mp->vni),
262 format_ip46_address, lloc,
263 format_ip46_address, rloc,
264 clib_net_to_host_u32 (mp->pkt_count),
265 clib_net_to_host_u32 (mp->bytes));
272 vl_api_one_eid_table_map_details_t_handler
273 (vl_api_one_eid_table_map_details_t * mp)
275 vat_main_t *vam = &vat_main;
277 u8 *line = format (0, "%=10d%=10d",
278 clib_net_to_host_u32 (mp->vni),
279 clib_net_to_host_u32 (mp->dp_table));
280 print (vam->ofp, "%v", line);
285 vl_api_one_eid_table_vni_details_t_handler
286 (vl_api_one_eid_table_vni_details_t * mp)
288 vat_main_t *vam = &vat_main;
290 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
291 print (vam->ofp, "%v", line);
296 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
297 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
299 vat_main_t *vam = &vat_main;
300 int retval = clib_net_to_host_u32 (mp->retval);
302 print (vam->ofp, "fallback threshold value: %d", mp->value);
304 vam->retval = retval;
305 vam->result_ready = 1;
309 vl_api_show_one_map_register_state_reply_t_handler
310 (vl_api_show_one_map_register_state_reply_t * mp)
312 vat_main_t *vam = &vat_main;
313 int retval = clib_net_to_host_u32 (mp->retval);
315 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
317 vam->retval = retval;
318 vam->result_ready = 1;
322 vl_api_show_one_rloc_probe_state_reply_t_handler
323 (vl_api_show_one_rloc_probe_state_reply_t * mp)
325 vat_main_t *vam = &vat_main;
326 int retval = clib_net_to_host_u32 (mp->retval);
331 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
333 vam->retval = retval;
334 vam->result_ready = 1;
338 vl_api_show_one_stats_enable_disable_reply_t_handler
339 (vl_api_show_one_stats_enable_disable_reply_t * mp)
341 vat_main_t *vam = &vat_main;
342 int retval = clib_net_to_host_u32 (mp->retval);
347 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
349 vam->retval = retval;
350 vam->result_ready = 1;
354 vl_api_one_ndp_entries_get_reply_t_handler
355 (vl_api_one_ndp_entries_get_reply_t * mp)
357 vat_main_t *vam = &vat_main;
359 int retval = clib_net_to_host_u32 (mp->retval);
364 n = clib_net_to_host_u32 (mp->count);
366 for (i = 0; i < n; i++)
367 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
368 format_ethernet_address, mp->entries[i].mac);
371 vam->retval = retval;
372 vam->result_ready = 1;
376 vl_api_one_l2_arp_entries_get_reply_t_handler
377 (vl_api_one_l2_arp_entries_get_reply_t * mp)
379 vat_main_t *vam = &vat_main;
381 int retval = clib_net_to_host_u32 (mp->retval);
386 n = clib_net_to_host_u32 (mp->count);
388 for (i = 0; i < n; i++)
389 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
390 format_ethernet_address, mp->entries[i].mac);
393 vam->retval = retval;
394 vam->result_ready = 1;
398 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
400 vat_main_t *vam = &vat_main;
402 int retval = clib_net_to_host_u32 (mp->retval);
407 n = clib_net_to_host_u32 (mp->count);
409 for (i = 0; i < n; i++)
411 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
415 vam->retval = retval;
416 vam->result_ready = 1;
420 vl_api_one_l2_arp_bd_get_reply_t_handler
421 (vl_api_one_l2_arp_bd_get_reply_t * mp)
423 vat_main_t *vam = &vat_main;
425 int retval = clib_net_to_host_u32 (mp->retval);
430 n = clib_net_to_host_u32 (mp->count);
432 for (i = 0; i < n; i++)
434 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
438 vam->retval = retval;
439 vam->result_ready = 1;
443 vl_api_one_adjacencies_get_reply_t_handler
444 (vl_api_one_adjacencies_get_reply_t * mp)
446 vat_main_t *vam = &vat_main;
448 int retval = clib_net_to_host_u32 (mp->retval);
449 vl_api_one_adjacency_t *a;
454 n = clib_net_to_host_u32 (mp->count);
456 for (i = 0; i < n; i++)
458 a = &mp->adjacencies[i];
459 print (vam->ofp, "%U %40U",
460 format_lisp_flat_eid, a->leid, format_lisp_flat_eid, a->reid);
464 vam->retval = retval;
465 vam->result_ready = 1;
469 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
471 vat_main_t *vam = &vat_main;
473 print (vam->ofp, "%=20U",
474 mp->ip_address.af ? format_ip6_address : format_ip4_address,
479 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
482 vat_main_t *vam = &vat_main;
484 print (vam->ofp, "%=20U",
485 mp->ip_address.af ? format_ip6_address : format_ip4_address,
490 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
492 vat_main_t *vam = &vat_main;
493 i32 retval = ntohl (mp->retval);
497 print (vam->ofp, "feature: %s\ngpe: %s",
498 mp->feature_status ? "enabled" : "disabled",
499 mp->gpe_status ? "enabled" : "disabled");
502 vam->retval = retval;
503 vam->result_ready = 1;
507 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
508 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
510 vat_main_t *vam = &vat_main;
511 i32 retval = ntohl (mp->retval);
515 print (vam->ofp, "%=20s", mp->locator_set_name);
518 vam->retval = retval;
519 vam->result_ready = 1;
523 format_lisp_map_request_mode (u8 * s, va_list * args)
525 u32 mode = va_arg (*args, u32);
530 return format (0, "dst-only");
532 return format (0, "src-dst");
538 vl_api_show_one_map_request_mode_reply_t_handler
539 (vl_api_show_one_map_request_mode_reply_t * mp)
541 vat_main_t *vam = &vat_main;
542 i32 retval = ntohl (mp->retval);
547 print (vam->ofp, "map_request_mode: %U",
548 format_lisp_map_request_mode, mode);
551 vam->retval = retval;
552 vam->result_ready = 1;
556 vl_api_one_show_xtr_mode_reply_t_handler
557 (vl_api_one_show_xtr_mode_reply_t * mp)
559 vat_main_t *vam = &vat_main;
560 i32 retval = ntohl (mp->retval);
564 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
567 vam->retval = retval;
568 vam->result_ready = 1;
572 vl_api_one_show_pitr_mode_reply_t_handler
573 (vl_api_one_show_pitr_mode_reply_t * mp)
575 vat_main_t *vam = &vat_main;
576 i32 retval = ntohl (mp->retval);
580 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
583 vam->retval = retval;
584 vam->result_ready = 1;
588 vl_api_one_show_petr_mode_reply_t_handler
589 (vl_api_one_show_petr_mode_reply_t * mp)
591 vat_main_t *vam = &vat_main;
592 i32 retval = ntohl (mp->retval);
596 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
599 vam->retval = retval;
600 vam->result_ready = 1;
604 vl_api_show_one_use_petr_reply_t_handler
605 (vl_api_show_one_use_petr_reply_t * mp)
607 vat_main_t *vam = &vat_main;
608 i32 retval = ntohl (mp->retval);
612 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
615 print (vam->ofp, "Proxy-ETR address; %U",
616 mp->ip_address.af ? format_ip6_address : format_ip4_address,
621 vam->retval = retval;
622 vam->result_ready = 1;
626 vl_api_show_one_nsh_mapping_reply_t_handler
627 (vl_api_show_one_nsh_mapping_reply_t * mp)
629 vat_main_t *vam = &vat_main;
630 i32 retval = ntohl (mp->retval);
634 print (vam->ofp, "%-20s%-16s",
635 mp->is_set ? "set" : "not-set",
636 mp->is_set ? (char *) mp->locator_set_name : "");
639 vam->retval = retval;
640 vam->result_ready = 1;
644 vl_api_show_one_map_register_ttl_reply_t_handler
645 (vl_api_show_one_map_register_ttl_reply_t * mp)
647 vat_main_t *vam = &vat_main;
648 i32 retval = ntohl (mp->retval);
652 print (vam->ofp, "ttl: %u", mp->ttl);
655 vam->retval = retval;
656 vam->result_ready = 1;
660 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
662 vat_main_t *vam = &vat_main;
663 i32 retval = ntohl (mp->retval);
667 print (vam->ofp, "%-20s%-16s",
668 mp->status ? "enabled" : "disabled",
669 mp->status ? (char *) mp->locator_set_name : "");
672 vam->retval = retval;
673 vam->result_ready = 1;
677 /** Used for parsing LISP eids */
678 typedef CLIB_PACKED(struct{
684 u32 len; /**< prefix length if IP */
685 u8 type; /**< type of eid */
690 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
692 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
694 clib_memset (a, 0, sizeof (a[0]));
696 if (unformat (input, "%U/%d", unformat_ip46_address, a->addr.ip, &a->len))
698 a->type = 0; /* ip prefix type */
700 else if (unformat (input, "%U", unformat_ethernet_address, &a->addr.mac))
702 a->type = 1; /* mac type */
704 else if (unformat (input, "%U", unformat_nsh_address, a->addr.nsh))
706 a->type = 2; /* NSH type */
707 a->addr.nsh.spi = clib_host_to_net_u32 (a->addr.nsh.spi);
716 if (ip46_address_is_ip4 (&a->addr.ip))
717 return a->len > 32 ? 1 : 0;
719 return a->len > 128 ? 1 : 0;
726 lisp_eid_put_vat (vl_api_eid_t * eid, const lisp_eid_vat_t * vat_eid)
728 eid->type = vat_eid->type;
731 case EID_TYPE_API_PREFIX:
732 if (ip46_address_is_ip4 (&vat_eid->addr.ip))
734 clib_memcpy (&eid->address.prefix.address.un.ip4,
735 &vat_eid->addr.ip.ip4, 4);
736 eid->address.prefix.address.af = ADDRESS_IP4;
737 eid->address.prefix.len = vat_eid->len;
741 clib_memcpy (&eid->address.prefix.address.un.ip6,
742 &vat_eid->addr.ip.ip6, 16);
743 eid->address.prefix.address.af = ADDRESS_IP6;
744 eid->address.prefix.len = vat_eid->len;
747 case EID_TYPE_API_MAC:
748 clib_memcpy (&eid->address.mac, &vat_eid->addr.mac,
749 sizeof (eid->address.mac));
751 case EID_TYPE_API_NSH:
752 clib_memcpy (&eid->address.nsh, &vat_eid->addr.nsh,
753 sizeof (eid->address.nsh));
762 api_one_add_del_locator_set (vat_main_t * vam)
764 unformat_input_t *input = vam->input;
765 vl_api_one_add_del_locator_set_t *mp;
767 u8 *locator_set_name = NULL;
768 u8 locator_set_name_set = 0;
769 vl_api_local_locator_t locator, *locators = 0;
770 u32 sw_if_index, priority, weight;
774 /* Parse args required to build the message */
775 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
777 if (unformat (input, "del"))
781 else if (unformat (input, "locator-set %s", &locator_set_name))
783 locator_set_name_set = 1;
785 else if (unformat (input, "sw_if_index %u p %u w %u",
786 &sw_if_index, &priority, &weight))
788 locator.sw_if_index = htonl (sw_if_index);
789 locator.priority = priority;
790 locator.weight = weight;
791 vec_add1 (locators, locator);
795 (input, "iface %U p %u w %u", unformat_sw_if_index, vam,
796 &sw_if_index, &priority, &weight))
798 locator.sw_if_index = htonl (sw_if_index);
799 locator.priority = priority;
800 locator.weight = weight;
801 vec_add1 (locators, locator);
807 if (locator_set_name_set == 0)
809 errmsg ("missing locator-set name");
814 if (vec_len (locator_set_name) > 64)
816 errmsg ("locator-set name too long");
817 vec_free (locator_set_name);
821 vec_add1 (locator_set_name, 0);
823 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
825 /* Construct the API message */
826 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
829 clib_memcpy (mp->locator_set_name, locator_set_name,
830 vec_len (locator_set_name));
831 vec_free (locator_set_name);
833 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
835 clib_memcpy (mp->locators, locators, data_len);
841 /* Wait for a reply... */
846 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
849 api_one_add_del_locator (vat_main_t * vam)
851 unformat_input_t *input = vam->input;
852 vl_api_one_add_del_locator_t *mp;
853 u32 tmp_if_index = ~0;
854 u32 sw_if_index = ~0;
855 u8 sw_if_index_set = 0;
856 u8 sw_if_index_if_name_set = 0;
862 u8 *locator_set_name = NULL;
863 u8 locator_set_name_set = 0;
866 /* Parse args required to build the message */
867 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
869 if (unformat (input, "del"))
873 else if (unformat (input, "locator-set %s", &locator_set_name))
875 locator_set_name_set = 1;
877 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
880 sw_if_index_if_name_set = 1;
881 sw_if_index = tmp_if_index;
883 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
886 sw_if_index = tmp_if_index;
888 else if (unformat (input, "p %d", &priority))
892 else if (unformat (input, "w %d", &weight))
900 if (locator_set_name_set == 0)
902 errmsg ("missing locator-set name");
906 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
908 errmsg ("missing sw_if_index");
909 vec_free (locator_set_name);
913 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
915 errmsg ("cannot use both params interface name and sw_if_index");
916 vec_free (locator_set_name);
920 if (priority_set == 0)
922 errmsg ("missing locator-set priority");
923 vec_free (locator_set_name);
929 errmsg ("missing locator-set weight");
930 vec_free (locator_set_name);
934 if (vec_len (locator_set_name) > 64)
936 errmsg ("locator-set name too long");
937 vec_free (locator_set_name);
940 vec_add1 (locator_set_name, 0);
942 /* Construct the API message */
943 M (ONE_ADD_DEL_LOCATOR, mp);
946 mp->sw_if_index = ntohl (sw_if_index);
947 mp->priority = priority;
949 clib_memcpy (mp->locator_set_name, locator_set_name,
950 vec_len (locator_set_name));
951 vec_free (locator_set_name);
956 /* Wait for a reply... */
961 #define api_lisp_add_del_locator api_one_add_del_locator
964 api_one_add_del_local_eid (vat_main_t * vam)
966 unformat_input_t *input = vam->input;
967 vl_api_one_add_del_local_eid_t *mp;
970 lisp_eid_vat_t _eid, *eid = &_eid;
971 u8 *locator_set_name = 0;
972 u8 locator_set_name_set = 0;
978 /* Parse args required to build the message */
979 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
981 if (unformat (input, "del"))
985 else if (unformat (input, "vni %d", &vni))
989 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
993 else if (unformat (input, "locator-set %s", &locator_set_name))
995 locator_set_name_set = 1;
997 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
999 else if (unformat (input, "secret-key %_%v%_", &key))
1005 if (locator_set_name_set == 0)
1007 errmsg ("missing locator-set name");
1013 errmsg ("EID address not set!");
1014 vec_free (locator_set_name);
1018 if (key && (0 == key_id))
1020 errmsg ("invalid key_id!");
1024 if (vec_len (key) > 64)
1026 errmsg ("key too long");
1031 if (vec_len (locator_set_name) > 64)
1033 errmsg ("locator-set name too long");
1034 vec_free (locator_set_name);
1037 vec_add1 (locator_set_name, 0);
1039 /* Construct the API message */
1040 M (ONE_ADD_DEL_LOCAL_EID, mp);
1042 mp->is_add = is_add;
1043 lisp_eid_put_vat (&mp->eid, eid);
1044 mp->vni = clib_host_to_net_u32 (vni);
1045 mp->key.id = key_id;
1046 clib_memcpy (mp->locator_set_name, locator_set_name,
1047 vec_len (locator_set_name));
1048 clib_memcpy (mp->key.key, key, vec_len (key));
1050 vec_free (locator_set_name);
1056 /* Wait for a reply... */
1062 api_one_add_del_map_server (vat_main_t * vam)
1064 unformat_input_t *input = vam->input;
1065 vl_api_one_add_del_map_server_t *mp;
1073 /* Parse args required to build the message */
1074 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1076 if (unformat (input, "del"))
1080 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
1084 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
1092 if (ipv4_set && ipv6_set)
1094 errmsg ("both eid v4 and v6 addresses set");
1098 if (!ipv4_set && !ipv6_set)
1100 errmsg ("eid addresses not set");
1104 /* Construct the API message */
1105 M (ONE_ADD_DEL_MAP_SERVER, mp);
1107 mp->is_add = is_add;
1110 mp->ip_address.af = 1;
1111 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
1115 mp->ip_address.af = 0;
1116 clib_memcpy (mp->ip_address.un.ip4, &ipv4, sizeof (ipv4));
1122 /* Wait for a reply... */
1127 #define api_lisp_add_del_map_server api_one_add_del_map_server
1130 api_one_add_del_map_resolver (vat_main_t * vam)
1132 unformat_input_t *input = vam->input;
1133 vl_api_one_add_del_map_resolver_t *mp;
1141 /* Parse args required to build the message */
1142 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1144 if (unformat (input, "del"))
1148 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
1152 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
1160 if (ipv4_set && ipv6_set)
1162 errmsg ("both eid v4 and v6 addresses set");
1166 if (!ipv4_set && !ipv6_set)
1168 errmsg ("eid addresses not set");
1172 /* Construct the API message */
1173 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
1175 mp->is_add = is_add;
1178 mp->ip_address.af = 1;
1179 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
1183 mp->ip_address.af = 0;
1184 clib_memcpy (mp->ip_address.un.ip6, &ipv4, sizeof (ipv4));
1190 /* Wait for a reply... */
1196 api_one_rloc_probe_enable_disable (vat_main_t * vam)
1198 unformat_input_t *input = vam->input;
1199 vl_api_one_rloc_probe_enable_disable_t *mp;
1204 /* Parse args required to build the message */
1205 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1207 if (unformat (input, "enable"))
1212 else if (unformat (input, "disable"))
1220 errmsg ("Value not set");
1224 /* Construct the API message */
1225 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
1227 mp->is_enable = is_enable;
1232 /* Wait for a reply... */
1237 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
1240 api_one_map_register_enable_disable (vat_main_t * vam)
1242 unformat_input_t *input = vam->input;
1243 vl_api_one_map_register_enable_disable_t *mp;
1248 /* Parse args required to build the message */
1249 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1251 if (unformat (input, "enable"))
1256 else if (unformat (input, "disable"))
1264 errmsg ("Value not set");
1268 /* Construct the API message */
1269 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
1271 mp->is_enable = is_enable;
1276 /* Wait for a reply... */
1281 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
1284 api_one_enable_disable (vat_main_t * vam)
1286 unformat_input_t *input = vam->input;
1287 vl_api_one_enable_disable_t *mp;
1292 /* Parse args required to build the message */
1293 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1295 if (unformat (input, "enable"))
1300 else if (unformat (input, "disable"))
1310 errmsg ("Value not set");
1314 /* Construct the API message */
1315 M (ONE_ENABLE_DISABLE, mp);
1317 mp->is_enable = is_enable;
1322 /* Wait for a reply... */
1327 #define api_lisp_enable_disable api_one_enable_disable
1330 api_one_enable_disable_xtr_mode (vat_main_t * vam)
1332 unformat_input_t *input = vam->input;
1333 vl_api_one_enable_disable_xtr_mode_t *mp;
1338 /* Parse args required to build the message */
1339 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1341 if (unformat (input, "enable"))
1346 else if (unformat (input, "disable"))
1356 errmsg ("Value not set");
1360 /* Construct the API message */
1361 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
1363 mp->is_enable = is_enable;
1368 /* Wait for a reply... */
1374 api_one_show_xtr_mode (vat_main_t * vam)
1376 vl_api_one_show_xtr_mode_t *mp;
1379 /* Construct the API message */
1380 M (ONE_SHOW_XTR_MODE, mp);
1385 /* Wait for a reply... */
1391 api_one_enable_disable_pitr_mode (vat_main_t * vam)
1393 unformat_input_t *input = vam->input;
1394 vl_api_one_enable_disable_pitr_mode_t *mp;
1399 /* Parse args required to build the message */
1400 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1402 if (unformat (input, "enable"))
1407 else if (unformat (input, "disable"))
1417 errmsg ("Value not set");
1421 /* Construct the API message */
1422 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
1424 mp->is_enable = is_enable;
1429 /* Wait for a reply... */
1435 api_one_show_pitr_mode (vat_main_t * vam)
1437 vl_api_one_show_pitr_mode_t *mp;
1440 /* Construct the API message */
1441 M (ONE_SHOW_PITR_MODE, mp);
1446 /* Wait for a reply... */
1452 api_one_enable_disable_petr_mode (vat_main_t * vam)
1454 unformat_input_t *input = vam->input;
1455 vl_api_one_enable_disable_petr_mode_t *mp;
1460 /* Parse args required to build the message */
1461 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1463 if (unformat (input, "enable"))
1468 else if (unformat (input, "disable"))
1478 errmsg ("Value not set");
1482 /* Construct the API message */
1483 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
1485 mp->is_enable = is_enable;
1490 /* Wait for a reply... */
1496 api_one_show_petr_mode (vat_main_t * vam)
1498 vl_api_one_show_petr_mode_t *mp;
1501 /* Construct the API message */
1502 M (ONE_SHOW_PETR_MODE, mp);
1507 /* Wait for a reply... */
1513 api_show_one_map_register_state (vat_main_t * vam)
1515 vl_api_show_one_map_register_state_t *mp;
1518 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
1523 /* wait for reply */
1528 #define api_show_lisp_map_register_state api_show_one_map_register_state
1531 api_show_one_rloc_probe_state (vat_main_t * vam)
1533 vl_api_show_one_rloc_probe_state_t *mp;
1536 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
1541 /* wait for reply */
1546 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
1549 api_one_add_del_ndp_entry (vat_main_t * vam)
1551 vl_api_one_add_del_ndp_entry_t *mp;
1552 unformat_input_t *input = vam->input;
1558 u8 ip6[16] = { 0, };
1562 /* Parse args required to build the message */
1563 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1565 if (unformat (input, "del"))
1567 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
1569 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
1571 else if (unformat (input, "bd %d", &bd))
1575 errmsg ("parse error '%U'", format_unformat_error, input);
1580 if (!bd_set || !ip_set || (!mac_set && is_add))
1582 errmsg ("Missing BD, IP or MAC!");
1586 M (ONE_ADD_DEL_NDP_ENTRY, mp);
1587 mp->is_add = is_add;
1588 clib_memcpy (&mp->entry.mac, mac, 6);
1589 mp->bd = clib_host_to_net_u32 (bd);
1590 clib_memcpy (&mp->entry.ip6, ip6, sizeof (mp->entry.ip6));
1595 /* wait for reply */
1601 api_one_add_del_l2_arp_entry (vat_main_t * vam)
1603 vl_api_one_add_del_l2_arp_entry_t *mp;
1604 unformat_input_t *input = vam->input;
1610 u32 ip4 = 0, bd = ~0;
1613 /* Parse args required to build the message */
1614 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1616 if (unformat (input, "del"))
1618 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
1620 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
1622 else if (unformat (input, "bd %d", &bd))
1626 errmsg ("parse error '%U'", format_unformat_error, input);
1631 if (!bd_set || !ip_set || (!mac_set && is_add))
1633 errmsg ("Missing BD, IP or MAC!");
1637 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
1638 mp->is_add = is_add;
1639 clib_memcpy (&mp->entry.mac, mac, 6);
1640 mp->bd = clib_host_to_net_u32 (bd);
1641 clib_memcpy (mp->entry.ip4, &ip4, sizeof (mp->entry.ip4));
1646 /* wait for reply */
1652 api_one_ndp_bd_get (vat_main_t * vam)
1654 vl_api_one_ndp_bd_get_t *mp;
1657 M (ONE_NDP_BD_GET, mp);
1662 /* wait for reply */
1668 api_one_ndp_entries_get (vat_main_t * vam)
1670 vl_api_one_ndp_entries_get_t *mp;
1671 unformat_input_t *input = vam->input;
1676 /* Parse args required to build the message */
1677 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1679 if (unformat (input, "bd %d", &bd))
1683 errmsg ("parse error '%U'", format_unformat_error, input);
1690 errmsg ("Expected bridge domain!");
1694 M (ONE_NDP_ENTRIES_GET, mp);
1695 mp->bd = clib_host_to_net_u32 (bd);
1700 /* wait for reply */
1706 api_one_l2_arp_bd_get (vat_main_t * vam)
1708 vl_api_one_l2_arp_bd_get_t *mp;
1711 M (ONE_L2_ARP_BD_GET, mp);
1716 /* wait for reply */
1722 api_one_l2_arp_entries_get (vat_main_t * vam)
1724 vl_api_one_l2_arp_entries_get_t *mp;
1725 unformat_input_t *input = vam->input;
1730 /* Parse args required to build the message */
1731 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1733 if (unformat (input, "bd %d", &bd))
1737 errmsg ("parse error '%U'", format_unformat_error, input);
1744 errmsg ("Expected bridge domain!");
1748 M (ONE_L2_ARP_ENTRIES_GET, mp);
1749 mp->bd = clib_host_to_net_u32 (bd);
1754 /* wait for reply */
1760 api_one_stats_enable_disable (vat_main_t * vam)
1762 vl_api_one_stats_enable_disable_t *mp;
1763 unformat_input_t *input = vam->input;
1768 /* Parse args required to build the message */
1769 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1771 if (unformat (input, "enable"))
1776 else if (unformat (input, "disable"))
1786 errmsg ("Value not set");
1790 M (ONE_STATS_ENABLE_DISABLE, mp);
1791 mp->is_enable = is_enable;
1796 /* wait for reply */
1802 api_show_one_stats_enable_disable (vat_main_t * vam)
1804 vl_api_show_one_stats_enable_disable_t *mp;
1807 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
1812 /* wait for reply */
1818 api_show_one_map_request_mode (vat_main_t * vam)
1820 vl_api_show_one_map_request_mode_t *mp;
1823 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
1828 /* wait for reply */
1833 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
1836 api_one_map_request_mode (vat_main_t * vam)
1838 unformat_input_t *input = vam->input;
1839 vl_api_one_map_request_mode_t *mp;
1843 /* Parse args required to build the message */
1844 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1846 if (unformat (input, "dst-only"))
1848 else if (unformat (input, "src-dst"))
1852 errmsg ("parse error '%U'", format_unformat_error, input);
1857 M (ONE_MAP_REQUEST_MODE, mp);
1864 /* wait for reply */
1869 #define api_lisp_map_request_mode api_one_map_request_mode
1872 * Enable/disable ONE proxy ITR.
1874 * @param vam vpp API test context
1875 * @return return code
1878 api_one_pitr_set_locator_set (vat_main_t * vam)
1881 unformat_input_t *input = vam->input;
1882 vl_api_one_pitr_set_locator_set_t *mp;
1887 /* Parse args required to build the message */
1888 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1890 if (unformat (input, "del"))
1892 else if (unformat (input, "locator-set %s", &ls_name))
1896 errmsg ("parse error '%U'", format_unformat_error, input);
1903 errmsg ("locator-set name not set!");
1907 M (ONE_PITR_SET_LOCATOR_SET, mp);
1909 mp->is_add = is_add;
1910 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
1916 /* wait for reply */
1921 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
1924 api_one_nsh_set_locator_set (vat_main_t * vam)
1927 unformat_input_t *input = vam->input;
1928 vl_api_one_nsh_set_locator_set_t *mp;
1933 /* Parse args required to build the message */
1934 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1936 if (unformat (input, "del"))
1938 else if (unformat (input, "ls %s", &ls_name))
1942 errmsg ("parse error '%U'", format_unformat_error, input);
1947 if (!ls_name_set && is_add)
1949 errmsg ("locator-set name not set!");
1953 M (ONE_NSH_SET_LOCATOR_SET, mp);
1955 mp->is_add = is_add;
1956 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
1962 /* wait for reply */
1968 api_show_one_pitr (vat_main_t * vam)
1970 vl_api_show_one_pitr_t *mp;
1973 if (!vam->json_output)
1975 print (vam->ofp, "%=20s", "lisp status:");
1978 M (SHOW_ONE_PITR, mp);
1982 /* Wait for a reply... */
1987 #define api_show_lisp_pitr api_show_one_pitr
1990 api_one_use_petr (vat_main_t * vam)
1992 unformat_input_t *input = vam->input;
1993 vl_api_one_use_petr_t *mp;
1998 clib_memset (&ip, 0, sizeof (ip));
2000 /* Parse args required to build the message */
2001 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2003 if (unformat (input, "disable"))
2006 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
2009 ip_addr_version (&ip) = AF_IP4;
2012 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
2015 ip_addr_version (&ip) = AF_IP6;
2019 errmsg ("parse error '%U'", format_unformat_error, input);
2024 M (ONE_USE_PETR, mp);
2026 mp->is_add = is_add;
2029 mp->ip_address.af = ip_addr_version (&ip) == AF_IP4 ? 0 : 1;
2030 if (mp->ip_address.af)
2031 clib_memcpy (mp->ip_address.un.ip6, &ip, 16);
2033 clib_memcpy (mp->ip_address.un.ip4, &ip, 4);
2039 /* wait for reply */
2044 #define api_lisp_use_petr api_one_use_petr
2047 api_show_one_nsh_mapping (vat_main_t * vam)
2049 vl_api_show_one_use_petr_t *mp;
2052 if (!vam->json_output)
2054 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
2057 M (SHOW_ONE_NSH_MAPPING, mp);
2061 /* Wait for a reply... */
2067 api_show_one_use_petr (vat_main_t * vam)
2069 vl_api_show_one_use_petr_t *mp;
2072 if (!vam->json_output)
2074 print (vam->ofp, "%=20s", "Proxy-ETR status:");
2077 M (SHOW_ONE_USE_PETR, mp);
2081 /* Wait for a reply... */
2086 #define api_show_lisp_use_petr api_show_one_use_petr
2089 * Add/delete mapping between vni and vrf
2092 api_one_eid_table_add_del_map (vat_main_t * vam)
2094 unformat_input_t *input = vam->input;
2095 vl_api_one_eid_table_add_del_map_t *mp;
2096 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
2097 u32 vni, vrf, bd_index;
2100 /* Parse args required to build the message */
2101 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2103 if (unformat (input, "del"))
2105 else if (unformat (input, "vrf %d", &vrf))
2107 else if (unformat (input, "bd_index %d", &bd_index))
2109 else if (unformat (input, "vni %d", &vni))
2115 if (!vni_set || (!vrf_set && !bd_index_set))
2117 errmsg ("missing arguments!");
2121 if (vrf_set && bd_index_set)
2123 errmsg ("error: both vrf and bd entered!");
2127 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
2129 mp->is_add = is_add;
2130 mp->vni = htonl (vni);
2131 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
2132 mp->is_l2 = bd_index_set;
2137 /* wait for reply */
2142 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
2145 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
2147 u32 *action = va_arg (*args, u32 *);
2150 if (unformat (input, "%s", &s))
2152 if (!strcmp ((char *) s, "no-action"))
2154 else if (!strcmp ((char *) s, "natively-forward"))
2156 else if (!strcmp ((char *) s, "send-map-request"))
2158 else if (!strcmp ((char *) s, "drop"))
2162 clib_warning ("invalid action: '%s'", s);
2174 * Add/del remote mapping to/from ONE control plane
2176 * @param vam vpp API test context
2177 * @return return code
2180 api_one_add_del_remote_mapping (vat_main_t * vam)
2182 unformat_input_t *input = vam->input;
2183 vl_api_one_add_del_remote_mapping_t *mp;
2185 lisp_eid_vat_t _eid, *eid = &_eid;
2186 lisp_eid_vat_t _seid, *seid = &_seid;
2187 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
2188 u32 action = ~0, p, w, data_len;
2189 ip4_address_t rloc4;
2190 ip6_address_t rloc6;
2191 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
2194 clib_memset (&rloc, 0, sizeof (rloc));
2196 /* Parse args required to build the message */
2197 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2199 if (unformat (input, "del-all"))
2203 else if (unformat (input, "del"))
2207 else if (unformat (input, "add"))
2211 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
2215 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
2219 else if (unformat (input, "vni %d", &vni))
2223 else if (unformat (input, "p %d w %d", &p, &w))
2227 errmsg ("No RLOC configured for setting priority/weight!");
2230 curr_rloc->priority = p;
2231 curr_rloc->weight = w;
2233 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
2235 rloc.ip_address.af = 0;
2236 clib_memcpy (&rloc.ip_address.un.ip6, &rloc6, sizeof (rloc6));
2237 vec_add1 (rlocs, rloc);
2238 curr_rloc = &rlocs[vec_len (rlocs) - 1];
2240 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
2242 rloc.ip_address.af = 1;
2243 clib_memcpy (&rloc.ip_address.un.ip4, &rloc4, sizeof (rloc4));
2244 vec_add1 (rlocs, rloc);
2245 curr_rloc = &rlocs[vec_len (rlocs) - 1];
2247 else if (unformat (input, "action %U",
2248 unformat_negative_mapping_action, &action))
2254 clib_warning ("parse error '%U'", format_unformat_error, input);
2261 errmsg ("missing params!");
2265 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
2267 errmsg ("no action set for negative map-reply!");
2271 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
2273 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
2274 mp->is_add = is_add;
2275 mp->vni = htonl (vni);
2276 mp->action = (u8) action;
2277 mp->is_src_dst = seid_set;
2278 mp->del_all = del_all;
2279 lisp_eid_put_vat (&mp->deid, eid);
2280 lisp_eid_put_vat (&mp->seid, seid);
2282 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
2283 clib_memcpy (mp->rlocs, rlocs, data_len);
2289 /* Wait for a reply... */
2294 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
2297 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
2298 * forwarding entries in data-plane accordingly.
2300 * @param vam vpp API test context
2301 * @return return code
2304 api_one_add_del_adjacency (vat_main_t * vam)
2306 unformat_input_t *input = vam->input;
2307 vl_api_one_add_del_adjacency_t *mp;
2311 lisp_eid_vat_t leid, reid;
2313 leid.type = reid.type = (u8) ~ 0;
2315 /* Parse args required to build the message */
2316 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2318 if (unformat (input, "del"))
2322 else if (unformat (input, "add"))
2326 else if (unformat (input, "reid %U/%d", unformat_ip46_address,
2327 &reid.addr.ip, &reid.len))
2329 reid.type = 0; /* ipv4 */
2331 else if (unformat (input, "reid %U", unformat_ethernet_address,
2334 reid.type = 1; /* mac */
2336 else if (unformat (input, "leid %U/%d", unformat_ip46_address,
2337 &leid.addr.ip, &leid.len))
2339 leid.type = 0; /* ipv4 */
2341 else if (unformat (input, "leid %U", unformat_ethernet_address,
2344 leid.type = 1; /* mac */
2346 else if (unformat (input, "vni %d", &vni))
2352 errmsg ("parse error '%U'", format_unformat_error, input);
2357 if ((u8) ~ 0 == reid.type)
2359 errmsg ("missing params!");
2363 if (leid.type != reid.type)
2365 errmsg ("remote and local EIDs are of different types!");
2369 M (ONE_ADD_DEL_ADJACENCY, mp);
2370 mp->is_add = is_add;
2371 mp->vni = htonl (vni);
2372 lisp_eid_put_vat (&mp->leid, &leid);
2373 lisp_eid_put_vat (&mp->reid, &reid);
2378 /* Wait for a reply... */
2383 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
2387 api_one_map_register_fallback_threshold (vat_main_t * vam)
2389 unformat_input_t *input = vam->input;
2390 vl_api_one_map_register_fallback_threshold_t *mp;
2395 /* Parse args required to build the message */
2396 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2398 if (unformat (input, "%u", &value))
2402 clib_warning ("parse error '%U'", format_unformat_error, input);
2409 errmsg ("fallback threshold value is missing!");
2413 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
2414 mp->value = clib_host_to_net_u32 (value);
2419 /* Wait for a reply... */
2425 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
2427 vl_api_show_one_map_register_fallback_threshold_t *mp;
2430 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
2435 /* Wait for a reply... */
2441 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
2443 u32 *proto = va_arg (*args, u32 *);
2445 if (unformat (input, "udp"))
2447 else if (unformat (input, "api"))
2456 api_one_set_transport_protocol (vat_main_t * vam)
2458 unformat_input_t *input = vam->input;
2459 vl_api_one_set_transport_protocol_t *mp;
2464 /* Parse args required to build the message */
2465 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2467 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
2471 clib_warning ("parse error '%U'", format_unformat_error, input);
2478 errmsg ("Transport protocol missing!");
2482 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
2483 mp->protocol = (u8) protocol;
2488 /* Wait for a reply... */
2494 api_one_get_transport_protocol (vat_main_t * vam)
2496 vl_api_one_get_transport_protocol_t *mp;
2499 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
2504 /* Wait for a reply... */
2510 api_one_map_register_set_ttl (vat_main_t * vam)
2512 unformat_input_t *input = vam->input;
2513 vl_api_one_map_register_set_ttl_t *mp;
2518 /* Parse args required to build the message */
2519 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2521 if (unformat (input, "%u", &ttl))
2525 clib_warning ("parse error '%U'", format_unformat_error, input);
2532 errmsg ("TTL value missing!");
2536 M (ONE_MAP_REGISTER_SET_TTL, mp);
2537 mp->ttl = clib_host_to_net_u32 (ttl);
2542 /* Wait for a reply... */
2548 api_show_one_map_register_ttl (vat_main_t * vam)
2550 vl_api_show_one_map_register_ttl_t *mp;
2553 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
2558 /* Wait for a reply... */
2564 * Add/del map request itr rlocs from ONE control plane and updates
2566 * @param vam vpp API test context
2567 * @return return code
2570 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
2572 unformat_input_t *input = vam->input;
2573 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
2574 u8 *locator_set_name = 0;
2575 u8 locator_set_name_set = 0;
2579 /* Parse args required to build the message */
2580 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2582 if (unformat (input, "del"))
2586 else if (unformat (input, "%_%v%_", &locator_set_name))
2588 locator_set_name_set = 1;
2592 clib_warning ("parse error '%U'", format_unformat_error, input);
2597 if (is_add && !locator_set_name_set)
2599 errmsg ("itr-rloc is not set!");
2603 if (is_add && vec_len (locator_set_name) > 64)
2605 errmsg ("itr-rloc locator-set name too long");
2606 vec_free (locator_set_name);
2610 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
2611 mp->is_add = is_add;
2614 clib_memcpy (mp->locator_set_name, locator_set_name,
2615 vec_len (locator_set_name));
2619 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
2621 vec_free (locator_set_name);
2626 /* Wait for a reply... */
2631 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
2634 api_one_locator_dump (vat_main_t * vam)
2636 unformat_input_t *input = vam->input;
2637 vl_api_one_locator_dump_t *mp;
2638 vl_api_control_ping_t *mp_ping;
2639 u8 is_index_set = 0, is_name_set = 0;
2644 /* Parse args required to build the message */
2645 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2647 if (unformat (input, "ls_name %_%v%_", &ls_name))
2651 else if (unformat (input, "ls_index %d", &ls_index))
2657 errmsg ("parse error '%U'", format_unformat_error, input);
2662 if (!is_index_set && !is_name_set)
2664 errmsg ("error: expected one of index or name!");
2668 if (is_index_set && is_name_set)
2670 errmsg ("error: only one param expected!");
2674 if (vec_len (ls_name) > 62)
2676 errmsg ("error: locator set name too long!");
2680 if (!vam->json_output)
2682 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
2685 M (ONE_LOCATOR_DUMP, mp);
2686 mp->is_index_set = is_index_set;
2689 mp->ls_index = clib_host_to_net_u32 (ls_index);
2692 vec_add1 (ls_name, 0);
2693 strncpy ((char *) mp->ls_name, (char *) ls_name,
2694 sizeof (mp->ls_name) - 1);
2700 /* Use a control ping for synchronization */
2701 LISP_PING (&one_test_main, mp_ping);
2704 /* Wait for a reply... */
2709 #define api_lisp_locator_dump api_one_locator_dump
2712 api_one_locator_set_dump (vat_main_t * vam)
2714 vl_api_one_locator_set_dump_t *mp;
2715 vl_api_control_ping_t *mp_ping;
2716 unformat_input_t *input = vam->input;
2720 /* Parse args required to build the message */
2721 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2723 if (unformat (input, "local"))
2727 else if (unformat (input, "remote"))
2733 errmsg ("parse error '%U'", format_unformat_error, input);
2738 if (!vam->json_output)
2740 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
2743 M (ONE_LOCATOR_SET_DUMP, mp);
2745 mp->filter = filter;
2750 /* Use a control ping for synchronization */
2751 LISP_PING (&one_test_main, mp_ping);
2754 /* Wait for a reply... */
2759 #define api_lisp_locator_set_dump api_one_locator_set_dump
2762 api_one_eid_table_map_dump (vat_main_t * vam)
2766 unformat_input_t *input = vam->input;
2767 vl_api_one_eid_table_map_dump_t *mp;
2768 vl_api_control_ping_t *mp_ping;
2771 /* Parse args required to build the message */
2772 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2774 if (unformat (input, "l2"))
2779 else if (unformat (input, "l3"))
2786 errmsg ("parse error '%U'", format_unformat_error, input);
2793 errmsg ("expected one of 'l2' or 'l3' parameter!");
2797 if (!vam->json_output)
2799 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
2802 M (ONE_EID_TABLE_MAP_DUMP, mp);
2808 /* Use a control ping for synchronization */
2809 LISP_PING (&one_test_main, mp_ping);
2812 /* Wait for a reply... */
2817 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
2820 api_one_eid_table_vni_dump (vat_main_t * vam)
2822 vl_api_one_eid_table_vni_dump_t *mp;
2823 vl_api_control_ping_t *mp_ping;
2826 if (!vam->json_output)
2828 print (vam->ofp, "VNI");
2831 M (ONE_EID_TABLE_VNI_DUMP, mp);
2836 /* Use a control ping for synchronization */
2837 LISP_PING (&one_test_main, mp_ping);
2840 /* Wait for a reply... */
2845 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
2848 api_one_eid_table_dump (vat_main_t * vam)
2850 unformat_input_t *i = vam->input;
2851 vl_api_one_eid_table_dump_t *mp;
2852 vl_api_control_ping_t *mp_ping;
2859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2862 (i, "eid %U/%d", unformat_ip46_address, &eid.addr.ip, &eid.len))
2868 if (unformat (i, "eid %U", unformat_ethernet_address, &eid.addr.mac))
2873 else if (unformat (i, "eid %U", unformat_nsh_address, &eid.addr.nsh))
2878 else if (unformat (i, "vni %d", &t))
2882 else if (unformat (i, "local"))
2886 else if (unformat (i, "remote"))
2892 errmsg ("parse error '%U'", format_unformat_error, i);
2897 if (!vam->json_output)
2899 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
2900 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
2903 M (ONE_EID_TABLE_DUMP, mp);
2905 mp->filter = filter;
2909 mp->vni = htonl (vni);
2910 lisp_eid_put_vat (&mp->eid, &eid);
2916 /* Use a control ping for synchronization */
2917 LISP_PING (&one_test_main, mp_ping);
2920 /* Wait for a reply... */
2926 api_one_adjacencies_get (vat_main_t * vam)
2928 unformat_input_t *i = vam->input;
2929 vl_api_one_adjacencies_get_t *mp;
2934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2936 if (unformat (i, "vni %d", &vni))
2942 errmsg ("parse error '%U'", format_unformat_error, i);
2949 errmsg ("vni not set!");
2953 if (!vam->json_output)
2955 print (vam->ofp, "%s %40s", "leid", "reid");
2958 M (ONE_ADJACENCIES_GET, mp);
2959 mp->vni = clib_host_to_net_u32 (vni);
2964 /* Wait for a reply... */
2970 api_one_map_server_dump (vat_main_t * vam)
2972 vl_api_one_map_server_dump_t *mp;
2973 vl_api_control_ping_t *mp_ping;
2976 if (!vam->json_output)
2978 print (vam->ofp, "%=20s", "Map server");
2981 M (ONE_MAP_SERVER_DUMP, mp);
2985 /* Use a control ping for synchronization */
2986 LISP_PING (&one_test_main, mp_ping);
2989 /* Wait for a reply... */
2994 #define api_lisp_map_server_dump api_one_map_server_dump
2997 api_one_map_resolver_dump (vat_main_t * vam)
2999 vl_api_one_map_resolver_dump_t *mp;
3000 vl_api_control_ping_t *mp_ping;
3003 if (!vam->json_output)
3005 print (vam->ofp, "%=20s", "Map resolver");
3008 M (ONE_MAP_RESOLVER_DUMP, mp);
3012 /* Use a control ping for synchronization */
3013 LISP_PING (&one_test_main, mp_ping);
3016 /* Wait for a reply... */
3021 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
3024 api_one_stats_flush (vat_main_t * vam)
3026 vl_api_one_stats_flush_t *mp;
3029 M (ONE_STATS_FLUSH, mp);
3036 api_one_stats_dump (vat_main_t * vam)
3038 vl_api_one_stats_dump_t *mp;
3039 vl_api_control_ping_t *mp_ping;
3042 M (ONE_STATS_DUMP, mp);
3046 /* Use a control ping for synchronization */
3047 LISP_PING (&one_test_main, mp_ping);
3050 /* Wait for a reply... */
3056 api_show_one_status (vat_main_t * vam)
3058 vl_api_show_one_status_t *mp;
3061 if (!vam->json_output)
3063 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
3066 M (SHOW_ONE_STATUS, mp);
3069 /* Wait for a reply... */
3075 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
3077 vl_api_one_get_map_request_itr_rlocs_t *mp;
3080 if (!vam->json_output)
3082 print (vam->ofp, "%=20s", "itr-rlocs:");
3085 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
3088 /* Wait for a reply... */
3093 #define vat_plugin_register vat_plugin_register_one
3094 #include <lisp/lisp-cp/one.api_test.c>
3097 * fd.io coding-style-patch-verification: ON
3100 * eval: (c-set-style "gnu")