2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vpp/api/types.h>
22 #include <vppinfra/socket.h>
23 #include <vlibapi/api.h>
24 #include <vlibmemory/api.h>
25 #include <vnet/ip/ip.h>
26 #include <vnet/ip/ip_neighbor.h>
27 #include <vnet/ip/ip_types_api.h>
28 #include <vnet/l2/l2_input.h>
29 #include <vnet/l2tp/l2tp.h>
30 #include <vnet/vxlan/vxlan.h>
31 #include <vnet/geneve/geneve.h>
32 #include <vnet/gre/gre.h>
33 #include <vnet/vxlan-gpe/vxlan_gpe.h>
34 #include <vnet/lisp-gpe/lisp_gpe.h>
36 #include <vpp/api/vpe_msg_enum.h>
37 #include <vnet/l2/l2_classify.h>
38 #include <vnet/l2/l2_vtr.h>
39 #include <vnet/classify/in_out_acl.h>
40 #include <vnet/classify/policer_classify.h>
41 #include <vnet/classify/flow_classify.h>
42 #include <vnet/mpls/mpls.h>
43 #include <vnet/ipsec/ipsec.h>
44 #include <vnet/ipsec/ikev2.h>
46 #include <vnet/cop/cop.h>
47 #include <vnet/ip/ip6_hop_by_hop.h>
48 #include <vnet/ip/ip_source_and_port_range_check.h>
49 #include <vnet/policer/xlate.h>
50 #include <vnet/span/span.h>
51 #include <vnet/policer/policer.h>
52 #include <vnet/policer/police.h>
53 #include <vnet/mfib/mfib_types.h>
54 #include <vnet/dhcp/dhcp_proxy.h>
55 #include <vnet/bonding/node.h>
56 #include <vnet/qos/qos_types.h>
57 #include <vnet/ethernet/ethernet_types_api.h>
58 #include <vnet/ip/ip_types_api.h>
59 #include "vat/json_format.h"
60 #include <vnet/ip/ip_types_api.h>
61 #include <vnet/ethernet/ethernet_types_api.h>
66 #define vl_typedefs /* define message structures */
67 #include <vpp/api/vpe_all_api_h.h>
70 /* declare message handlers for each api */
72 #define vl_endianfun /* define message structures */
73 #include <vpp/api/vpe_all_api_h.h>
76 /* instantiate all the print functions we know about */
77 #define vl_print(handle, ...)
79 #include <vpp/api/vpe_all_api_h.h>
82 #define __plugin_msg_base 0
83 #include <vlibapi/vat_helper_macros.h>
85 #if VPP_API_TEST_BUILTIN == 0
95 vat_socket_connect (vat_main_t * vam)
98 vam->socket_client_main = &socket_client_main;
99 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
101 0 /* default socket rx, tx buffer */ )))
103 /* vpp expects the client index in network order */
104 vam->my_client_index = htonl (socket_client_main.client_index);
107 #else /* vpp built-in case, we don't do sockets... */
109 vat_socket_connect (vat_main_t * vam)
115 vl_socket_client_read (int wait)
121 vl_socket_client_write ()
127 vl_socket_client_msg_alloc (int nbytes)
135 vat_time_now (vat_main_t * vam)
137 #if VPP_API_TEST_BUILTIN
138 return vlib_time_now (vam->vlib_main);
140 return clib_time_now (&vam->clib_time);
145 errmsg (char *fmt, ...)
147 vat_main_t *vam = &vat_main;
152 s = va_format (0, fmt, &va);
157 #if VPP_API_TEST_BUILTIN
158 vlib_cli_output (vam->vlib_main, (char *) s);
161 if (vam->ifp != stdin)
162 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
163 vam->input_line_number);
164 fformat (vam->ofp, (char *) s);
172 #if VPP_API_TEST_BUILTIN == 0
174 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
176 vat_main_t *vam = va_arg (*args, vat_main_t *);
177 u32 *result = va_arg (*args, u32 *);
181 if (!unformat (input, "%s", &if_name))
184 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
192 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
197 /* Parse an IP4 address %d.%d.%d.%d. */
199 unformat_ip4_address (unformat_input_t * input, va_list * args)
201 u8 *result = va_arg (*args, u8 *);
204 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
207 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
219 unformat_ethernet_address (unformat_input_t * input, va_list * args)
221 u8 *result = va_arg (*args, u8 *);
224 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
225 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
229 for (i = 0; i < 6; i++)
230 if (a[i] >= (1 << 8))
233 for (i = 0; i < 6; i++)
239 /* Returns ethernet type as an int in host byte order. */
241 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
244 u16 *result = va_arg (*args, u16 *);
248 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
250 if (type >= (1 << 16))
258 /* Parse an IP6 address. */
260 unformat_ip6_address (unformat_input_t * input, va_list * args)
262 ip6_address_t *result = va_arg (*args, ip6_address_t *);
264 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
265 uword c, n_colon, double_colon_index;
267 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
268 double_colon_index = ARRAY_LEN (hex_quads);
269 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
272 if (c >= '0' && c <= '9')
274 else if (c >= 'a' && c <= 'f')
275 hex_digit = c + 10 - 'a';
276 else if (c >= 'A' && c <= 'F')
277 hex_digit = c + 10 - 'A';
278 else if (c == ':' && n_colon < 2)
282 unformat_put_input (input);
286 /* Too many hex quads. */
287 if (n_hex_quads >= ARRAY_LEN (hex_quads))
292 hex_quad = (hex_quad << 4) | hex_digit;
294 /* Hex quad must fit in 16 bits. */
295 if (n_hex_digits >= 4)
302 /* Save position of :: */
305 /* More than one :: ? */
306 if (double_colon_index < ARRAY_LEN (hex_quads))
308 double_colon_index = n_hex_quads;
311 if (n_colon > 0 && n_hex_digits > 0)
313 hex_quads[n_hex_quads++] = hex_quad;
319 if (n_hex_digits > 0)
320 hex_quads[n_hex_quads++] = hex_quad;
325 /* Expand :: to appropriate number of zero hex quads. */
326 if (double_colon_index < ARRAY_LEN (hex_quads))
328 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
330 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
331 hex_quads[n_zero + i] = hex_quads[i];
333 for (i = 0; i < n_zero; i++)
334 hex_quads[double_colon_index + i] = 0;
336 n_hex_quads = ARRAY_LEN (hex_quads);
339 /* Too few hex quads given. */
340 if (n_hex_quads < ARRAY_LEN (hex_quads))
343 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
344 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
351 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
353 u32 *r = va_arg (*args, u32 *);
356 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
357 foreach_ipsec_policy_action
365 format_ipsec_crypto_alg (u8 * s, va_list * args)
367 u32 i = va_arg (*args, u32);
372 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
373 foreach_ipsec_crypto_alg
376 return format (s, "unknown");
378 return format (s, "%s", t);
382 format_ipsec_integ_alg (u8 * s, va_list * args)
384 u32 i = va_arg (*args, u32);
389 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
390 foreach_ipsec_integ_alg
393 return format (s, "unknown");
395 return format (s, "%s", t);
399 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
401 u32 *r = va_arg (*args, u32 *);
404 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
405 foreach_ikev2_auth_method
413 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
415 u32 *r = va_arg (*args, u32 *);
418 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
419 foreach_ikev2_id_type
425 #else /* VPP_API_TEST_BUILTIN == 1 */
427 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
429 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
430 vnet_main_t *vnm = vnet_get_main ();
431 u32 *result = va_arg (*args, u32 *);
433 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
437 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
439 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
440 vnet_main_t *vnm = vnet_get_main ();
441 u32 *result = va_arg (*args, u32 *);
443 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
446 #endif /* VPP_API_TEST_BUILTIN */
449 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
451 u32 *r = va_arg (*args, u32 *);
454 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
455 foreach_ipsec_crypto_alg
463 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
465 u32 *r = va_arg (*args, u32 *);
468 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
469 foreach_ipsec_integ_alg
477 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
479 u8 *r = va_arg (*args, u8 *);
481 if (unformat (input, "kbps"))
482 *r = SSE2_QOS_RATE_KBPS;
483 else if (unformat (input, "pps"))
484 *r = SSE2_QOS_RATE_PPS;
491 unformat_policer_round_type (unformat_input_t * input, va_list * args)
493 u8 *r = va_arg (*args, u8 *);
495 if (unformat (input, "closest"))
496 *r = SSE2_QOS_ROUND_TO_CLOSEST;
497 else if (unformat (input, "up"))
498 *r = SSE2_QOS_ROUND_TO_UP;
499 else if (unformat (input, "down"))
500 *r = SSE2_QOS_ROUND_TO_DOWN;
507 unformat_policer_type (unformat_input_t * input, va_list * args)
509 u8 *r = va_arg (*args, u8 *);
511 if (unformat (input, "1r2c"))
512 *r = SSE2_QOS_POLICER_TYPE_1R2C;
513 else if (unformat (input, "1r3c"))
514 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
515 else if (unformat (input, "2r3c-2698"))
516 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
517 else if (unformat (input, "2r3c-4115"))
518 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
519 else if (unformat (input, "2r3c-mef5cf1"))
520 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
527 unformat_dscp (unformat_input_t * input, va_list * va)
529 u8 *r = va_arg (*va, u8 *);
532 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
541 unformat_policer_action_type (unformat_input_t * input, va_list * va)
543 sse2_qos_pol_action_params_st *a
544 = va_arg (*va, sse2_qos_pol_action_params_st *);
546 if (unformat (input, "drop"))
547 a->action_type = SSE2_QOS_ACTION_DROP;
548 else if (unformat (input, "transmit"))
549 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
550 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
551 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
558 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
560 u32 *r = va_arg (*va, u32 *);
563 if (unformat (input, "ip4"))
564 tid = POLICER_CLASSIFY_TABLE_IP4;
565 else if (unformat (input, "ip6"))
566 tid = POLICER_CLASSIFY_TABLE_IP6;
567 else if (unformat (input, "l2"))
568 tid = POLICER_CLASSIFY_TABLE_L2;
577 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
579 u32 *r = va_arg (*va, u32 *);
582 if (unformat (input, "ip4"))
583 tid = FLOW_CLASSIFY_TABLE_IP4;
584 else if (unformat (input, "ip6"))
585 tid = FLOW_CLASSIFY_TABLE_IP6;
593 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
594 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
595 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
596 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
598 #if (VPP_API_TEST_BUILTIN==0)
600 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
602 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
603 mfib_itf_attribute_t attr;
606 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
608 if (unformat (input, mfib_itf_flag_long_names[attr]))
609 *iflags |= (1 << attr);
611 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
613 if (unformat (input, mfib_itf_flag_names[attr]))
614 *iflags |= (1 << attr);
617 return (old == *iflags ? 0 : 1);
621 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
623 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
624 mfib_entry_attribute_t attr;
627 FOR_EACH_MFIB_ATTRIBUTE (attr)
629 if (unformat (input, mfib_flag_long_names[attr]))
630 *eflags |= (1 << attr);
632 FOR_EACH_MFIB_ATTRIBUTE (attr)
634 if (unformat (input, mfib_flag_names[attr]))
635 *eflags |= (1 << attr);
638 return (old == *eflags ? 0 : 1);
642 format_ip4_address (u8 * s, va_list * args)
644 u8 *a = va_arg (*args, u8 *);
645 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
649 format_ip6_address (u8 * s, va_list * args)
651 ip6_address_t *a = va_arg (*args, ip6_address_t *);
652 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
654 i_max_n_zero = ARRAY_LEN (a->as_u16);
656 i_first_zero = i_max_n_zero;
658 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
660 u32 is_zero = a->as_u16[i] == 0;
661 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
667 if ((!is_zero && n_zeros > max_n_zeros)
668 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
670 i_max_n_zero = i_first_zero;
671 max_n_zeros = n_zeros;
672 i_first_zero = ARRAY_LEN (a->as_u16);
677 last_double_colon = 0;
678 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
680 if (i == i_max_n_zero && max_n_zeros > 1)
682 s = format (s, "::");
683 i += max_n_zeros - 1;
684 last_double_colon = 1;
688 s = format (s, "%s%x",
689 (last_double_colon || i == 0) ? "" : ":",
690 clib_net_to_host_u16 (a->as_u16[i]));
691 last_double_colon = 0;
698 /* Format an IP46 address. */
700 format_ip46_address (u8 * s, va_list * args)
702 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
703 ip46_type_t type = va_arg (*args, ip46_type_t);
709 is_ip4 = ip46_address_is_ip4 (ip46);
720 format (s, "%U", format_ip4_address, &ip46->ip4) :
721 format (s, "%U", format_ip6_address, &ip46->ip6);
725 format_ethernet_address (u8 * s, va_list * args)
727 u8 *a = va_arg (*args, u8 *);
729 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
730 a[0], a[1], a[2], a[3], a[4], a[5]);
735 increment_v4_address (ip4_address_t * a)
739 v = ntohl (a->as_u32) + 1;
740 a->as_u32 = ntohl (v);
744 increment_v6_address (ip6_address_t * a)
748 v0 = clib_net_to_host_u64 (a->as_u64[0]);
749 v1 = clib_net_to_host_u64 (a->as_u64[1]);
754 a->as_u64[0] = clib_net_to_host_u64 (v0);
755 a->as_u64[1] = clib_net_to_host_u64 (v1);
759 increment_mac_address (u8 * mac)
761 u64 tmp = *((u64 *) mac);
762 tmp = clib_net_to_host_u64 (tmp);
763 tmp += 1 << 16; /* skip unused (least significant) octets */
764 tmp = clib_host_to_net_u64 (tmp);
766 clib_memcpy (mac, &tmp, 6);
769 static void vl_api_create_loopback_reply_t_handler
770 (vl_api_create_loopback_reply_t * mp)
772 vat_main_t *vam = &vat_main;
773 i32 retval = ntohl (mp->retval);
775 vam->retval = retval;
776 vam->regenerate_interface_table = 1;
777 vam->sw_if_index = ntohl (mp->sw_if_index);
778 vam->result_ready = 1;
781 static void vl_api_create_loopback_reply_t_handler_json
782 (vl_api_create_loopback_reply_t * mp)
784 vat_main_t *vam = &vat_main;
785 vat_json_node_t node;
787 vat_json_init_object (&node);
788 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
789 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
791 vat_json_print (vam->ofp, &node);
792 vat_json_free (&node);
793 vam->retval = ntohl (mp->retval);
794 vam->result_ready = 1;
797 static void vl_api_create_loopback_instance_reply_t_handler
798 (vl_api_create_loopback_instance_reply_t * mp)
800 vat_main_t *vam = &vat_main;
801 i32 retval = ntohl (mp->retval);
803 vam->retval = retval;
804 vam->regenerate_interface_table = 1;
805 vam->sw_if_index = ntohl (mp->sw_if_index);
806 vam->result_ready = 1;
809 static void vl_api_create_loopback_instance_reply_t_handler_json
810 (vl_api_create_loopback_instance_reply_t * mp)
812 vat_main_t *vam = &vat_main;
813 vat_json_node_t node;
815 vat_json_init_object (&node);
816 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
817 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
819 vat_json_print (vam->ofp, &node);
820 vat_json_free (&node);
821 vam->retval = ntohl (mp->retval);
822 vam->result_ready = 1;
825 static void vl_api_af_packet_create_reply_t_handler
826 (vl_api_af_packet_create_reply_t * mp)
828 vat_main_t *vam = &vat_main;
829 i32 retval = ntohl (mp->retval);
831 vam->retval = retval;
832 vam->regenerate_interface_table = 1;
833 vam->sw_if_index = ntohl (mp->sw_if_index);
834 vam->result_ready = 1;
837 static void vl_api_af_packet_create_reply_t_handler_json
838 (vl_api_af_packet_create_reply_t * mp)
840 vat_main_t *vam = &vat_main;
841 vat_json_node_t node;
843 vat_json_init_object (&node);
844 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
845 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
847 vat_json_print (vam->ofp, &node);
848 vat_json_free (&node);
850 vam->retval = ntohl (mp->retval);
851 vam->result_ready = 1;
854 static void vl_api_create_vlan_subif_reply_t_handler
855 (vl_api_create_vlan_subif_reply_t * mp)
857 vat_main_t *vam = &vat_main;
858 i32 retval = ntohl (mp->retval);
860 vam->retval = retval;
861 vam->regenerate_interface_table = 1;
862 vam->sw_if_index = ntohl (mp->sw_if_index);
863 vam->result_ready = 1;
866 static void vl_api_create_vlan_subif_reply_t_handler_json
867 (vl_api_create_vlan_subif_reply_t * mp)
869 vat_main_t *vam = &vat_main;
870 vat_json_node_t node;
872 vat_json_init_object (&node);
873 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
874 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
876 vat_json_print (vam->ofp, &node);
877 vat_json_free (&node);
879 vam->retval = ntohl (mp->retval);
880 vam->result_ready = 1;
883 static void vl_api_create_subif_reply_t_handler
884 (vl_api_create_subif_reply_t * mp)
886 vat_main_t *vam = &vat_main;
887 i32 retval = ntohl (mp->retval);
889 vam->retval = retval;
890 vam->regenerate_interface_table = 1;
891 vam->sw_if_index = ntohl (mp->sw_if_index);
892 vam->result_ready = 1;
895 static void vl_api_create_subif_reply_t_handler_json
896 (vl_api_create_subif_reply_t * mp)
898 vat_main_t *vam = &vat_main;
899 vat_json_node_t node;
901 vat_json_init_object (&node);
902 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
903 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
905 vat_json_print (vam->ofp, &node);
906 vat_json_free (&node);
908 vam->retval = ntohl (mp->retval);
909 vam->result_ready = 1;
912 static void vl_api_interface_name_renumber_reply_t_handler
913 (vl_api_interface_name_renumber_reply_t * mp)
915 vat_main_t *vam = &vat_main;
916 i32 retval = ntohl (mp->retval);
918 vam->retval = retval;
919 vam->regenerate_interface_table = 1;
920 vam->result_ready = 1;
923 static void vl_api_interface_name_renumber_reply_t_handler_json
924 (vl_api_interface_name_renumber_reply_t * mp)
926 vat_main_t *vam = &vat_main;
927 vat_json_node_t node;
929 vat_json_init_object (&node);
930 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
932 vat_json_print (vam->ofp, &node);
933 vat_json_free (&node);
935 vam->retval = ntohl (mp->retval);
936 vam->result_ready = 1;
940 * Special-case: build the interface table, maintain
941 * the next loopback sw_if_index vbl.
943 static void vl_api_sw_interface_details_t_handler
944 (vl_api_sw_interface_details_t * mp)
946 vat_main_t *vam = &vat_main;
947 u8 *s = format (0, "%s%c", mp->interface_name, 0);
949 hash_set_mem (vam->sw_if_index_by_interface_name, s,
950 ntohl (mp->sw_if_index));
952 /* In sub interface case, fill the sub interface table entry */
953 if (mp->sw_if_index != mp->sup_sw_if_index)
955 sw_interface_subif_t *sub = NULL;
957 vec_add2 (vam->sw_if_subif_table, sub, 1);
959 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
960 strncpy ((char *) sub->interface_name, (char *) s,
961 vec_len (sub->interface_name));
962 sub->sw_if_index = ntohl (mp->sw_if_index);
963 sub->sub_id = ntohl (mp->sub_id);
965 sub->sub_dot1ad = mp->sub_dot1ad;
966 sub->sub_number_of_tags = mp->sub_number_of_tags;
967 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
968 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
969 sub->sub_exact_match = mp->sub_exact_match;
970 sub->sub_default = mp->sub_default;
971 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
972 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
974 /* vlan tag rewrite */
975 sub->vtr_op = ntohl (mp->vtr_op);
976 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
977 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
978 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
982 static void vl_api_sw_interface_details_t_handler_json
983 (vl_api_sw_interface_details_t * mp)
985 vat_main_t *vam = &vat_main;
986 vat_json_node_t *node = NULL;
988 if (VAT_JSON_ARRAY != vam->json_tree.type)
990 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
991 vat_json_init_array (&vam->json_tree);
993 node = vat_json_array_add (&vam->json_tree);
995 vat_json_init_object (node);
996 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
997 vat_json_object_add_uint (node, "sup_sw_if_index",
998 ntohl (mp->sup_sw_if_index));
999 vat_json_object_add_uint (node, "l2_address_length",
1000 ntohl (mp->l2_address_length));
1001 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
1002 sizeof (mp->l2_address));
1003 vat_json_object_add_string_copy (node, "interface_name",
1004 mp->interface_name);
1005 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
1006 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
1007 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1008 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1009 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1010 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1011 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
1012 vat_json_object_add_uint (node, "sub_number_of_tags",
1013 mp->sub_number_of_tags);
1014 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1015 ntohs (mp->sub_outer_vlan_id));
1016 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1017 ntohs (mp->sub_inner_vlan_id));
1018 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
1019 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
1020 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
1021 mp->sub_outer_vlan_id_any);
1022 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1023 mp->sub_inner_vlan_id_any);
1024 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1025 vat_json_object_add_uint (node, "vtr_push_dot1q",
1026 ntohl (mp->vtr_push_dot1q));
1027 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1028 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1031 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1033 format_ethernet_address,
1035 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1037 format_ethernet_address,
1039 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1040 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1044 #if VPP_API_TEST_BUILTIN == 0
1045 static void vl_api_sw_interface_event_t_handler
1046 (vl_api_sw_interface_event_t * mp)
1048 vat_main_t *vam = &vat_main;
1049 if (vam->interface_event_display)
1050 errmsg ("interface flags: sw_if_index %d %s %s",
1051 ntohl (mp->sw_if_index),
1052 mp->admin_up_down ? "admin-up" : "admin-down",
1053 mp->link_up_down ? "link-up" : "link-down");
1057 static void vl_api_sw_interface_event_t_handler_json
1058 (vl_api_sw_interface_event_t * mp)
1060 /* JSON output not supported */
1064 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1066 vat_main_t *vam = &vat_main;
1067 i32 retval = ntohl (mp->retval);
1069 vam->retval = retval;
1070 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1071 vam->result_ready = 1;
1075 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1077 vat_main_t *vam = &vat_main;
1078 vat_json_node_t node;
1079 api_main_t *am = &api_main;
1083 vat_json_init_object (&node);
1084 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1085 vat_json_object_add_uint (&node, "reply_in_shmem",
1086 ntohl (mp->reply_in_shmem));
1087 /* Toss the shared-memory original... */
1088 pthread_mutex_lock (&am->vlib_rp->mutex);
1089 oldheap = svm_push_data_heap (am->vlib_rp);
1091 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1094 svm_pop_heap (oldheap);
1095 pthread_mutex_unlock (&am->vlib_rp->mutex);
1097 vat_json_print (vam->ofp, &node);
1098 vat_json_free (&node);
1100 vam->retval = ntohl (mp->retval);
1101 vam->result_ready = 1;
1105 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1107 vat_main_t *vam = &vat_main;
1108 i32 retval = ntohl (mp->retval);
1109 u32 length = vl_api_string_len (&mp->reply);
1111 vec_reset_length (vam->cmd_reply);
1113 vam->retval = retval;
1116 vec_validate (vam->cmd_reply, length);
1117 clib_memcpy ((char *) (vam->cmd_reply),
1118 vl_api_from_api_string (&mp->reply), length);
1119 vam->cmd_reply[length] = 0;
1121 vam->result_ready = 1;
1125 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1127 vat_main_t *vam = &vat_main;
1128 vat_json_node_t node;
1130 vec_reset_length (vam->cmd_reply);
1132 vat_json_init_object (&node);
1133 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1134 vat_json_object_add_string_copy (&node, "reply",
1135 vl_api_from_api_string (&mp->reply));
1137 vat_json_print (vam->ofp, &node);
1138 vat_json_free (&node);
1140 vam->retval = ntohl (mp->retval);
1141 vam->result_ready = 1;
1144 static void vl_api_classify_add_del_table_reply_t_handler
1145 (vl_api_classify_add_del_table_reply_t * mp)
1147 vat_main_t *vam = &vat_main;
1148 i32 retval = ntohl (mp->retval);
1149 if (vam->async_mode)
1151 vam->async_errors += (retval < 0);
1155 vam->retval = retval;
1157 ((mp->new_table_index != 0xFFFFFFFF) ||
1158 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1159 (mp->match_n_vectors != 0xFFFFFFFF)))
1161 * Note: this is just barely thread-safe, depends on
1162 * the main thread spinning waiting for an answer...
1164 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1165 ntohl (mp->new_table_index),
1166 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1167 vam->result_ready = 1;
1171 static void vl_api_classify_add_del_table_reply_t_handler_json
1172 (vl_api_classify_add_del_table_reply_t * mp)
1174 vat_main_t *vam = &vat_main;
1175 vat_json_node_t node;
1177 vat_json_init_object (&node);
1178 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1179 vat_json_object_add_uint (&node, "new_table_index",
1180 ntohl (mp->new_table_index));
1181 vat_json_object_add_uint (&node, "skip_n_vectors",
1182 ntohl (mp->skip_n_vectors));
1183 vat_json_object_add_uint (&node, "match_n_vectors",
1184 ntohl (mp->match_n_vectors));
1186 vat_json_print (vam->ofp, &node);
1187 vat_json_free (&node);
1189 vam->retval = ntohl (mp->retval);
1190 vam->result_ready = 1;
1193 static void vl_api_get_node_index_reply_t_handler
1194 (vl_api_get_node_index_reply_t * mp)
1196 vat_main_t *vam = &vat_main;
1197 i32 retval = ntohl (mp->retval);
1198 if (vam->async_mode)
1200 vam->async_errors += (retval < 0);
1204 vam->retval = retval;
1206 errmsg ("node index %d", ntohl (mp->node_index));
1207 vam->result_ready = 1;
1211 static void vl_api_get_node_index_reply_t_handler_json
1212 (vl_api_get_node_index_reply_t * mp)
1214 vat_main_t *vam = &vat_main;
1215 vat_json_node_t node;
1217 vat_json_init_object (&node);
1218 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1219 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1221 vat_json_print (vam->ofp, &node);
1222 vat_json_free (&node);
1224 vam->retval = ntohl (mp->retval);
1225 vam->result_ready = 1;
1228 static void vl_api_get_next_index_reply_t_handler
1229 (vl_api_get_next_index_reply_t * mp)
1231 vat_main_t *vam = &vat_main;
1232 i32 retval = ntohl (mp->retval);
1233 if (vam->async_mode)
1235 vam->async_errors += (retval < 0);
1239 vam->retval = retval;
1241 errmsg ("next node index %d", ntohl (mp->next_index));
1242 vam->result_ready = 1;
1246 static void vl_api_get_next_index_reply_t_handler_json
1247 (vl_api_get_next_index_reply_t * mp)
1249 vat_main_t *vam = &vat_main;
1250 vat_json_node_t node;
1252 vat_json_init_object (&node);
1253 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1254 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1256 vat_json_print (vam->ofp, &node);
1257 vat_json_free (&node);
1259 vam->retval = ntohl (mp->retval);
1260 vam->result_ready = 1;
1263 static void vl_api_add_node_next_reply_t_handler
1264 (vl_api_add_node_next_reply_t * mp)
1266 vat_main_t *vam = &vat_main;
1267 i32 retval = ntohl (mp->retval);
1268 if (vam->async_mode)
1270 vam->async_errors += (retval < 0);
1274 vam->retval = retval;
1276 errmsg ("next index %d", ntohl (mp->next_index));
1277 vam->result_ready = 1;
1281 static void vl_api_add_node_next_reply_t_handler_json
1282 (vl_api_add_node_next_reply_t * mp)
1284 vat_main_t *vam = &vat_main;
1285 vat_json_node_t node;
1287 vat_json_init_object (&node);
1288 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1289 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1291 vat_json_print (vam->ofp, &node);
1292 vat_json_free (&node);
1294 vam->retval = ntohl (mp->retval);
1295 vam->result_ready = 1;
1298 static void vl_api_show_version_reply_t_handler
1299 (vl_api_show_version_reply_t * mp)
1301 vat_main_t *vam = &vat_main;
1302 i32 retval = ntohl (mp->retval);
1307 char *p = (char *) &mp->program;
1309 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1310 errmsg (" program: %s\n", s);
1314 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1315 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1316 errmsg (" version: %s\n", s);
1320 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1321 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1322 errmsg (" build date: %s\n", s);
1326 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1327 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1328 errmsg ("build directory: %s\n", s);
1331 vam->retval = retval;
1332 vam->result_ready = 1;
1335 static void vl_api_show_version_reply_t_handler_json
1336 (vl_api_show_version_reply_t * mp)
1338 vat_main_t *vam = &vat_main;
1339 vat_json_node_t node;
1341 vat_json_init_object (&node);
1342 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1343 char *p = (char *) &mp->program;
1344 vat_json_object_add_string_copy (&node, "program",
1345 vl_api_from_api_string ((vl_api_string_t *)
1347 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1348 vat_json_object_add_string_copy (&node, "version",
1349 vl_api_from_api_string ((vl_api_string_t *)
1351 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1352 vat_json_object_add_string_copy (&node, "build_date",
1353 vl_api_from_api_string ((vl_api_string_t *)
1355 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1356 vat_json_object_add_string_copy (&node, "build_directory",
1357 vl_api_from_api_string ((vl_api_string_t *)
1360 vat_json_print (vam->ofp, &node);
1361 vat_json_free (&node);
1363 vam->retval = ntohl (mp->retval);
1364 vam->result_ready = 1;
1367 static void vl_api_show_threads_reply_t_handler
1368 (vl_api_show_threads_reply_t * mp)
1370 vat_main_t *vam = &vat_main;
1371 i32 retval = ntohl (mp->retval);
1375 count = ntohl (mp->count);
1377 for (i = 0; i < count; i++)
1379 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1380 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1381 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1382 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1383 ntohl (mp->thread_data[i].cpu_socket));
1385 vam->retval = retval;
1386 vam->result_ready = 1;
1389 static void vl_api_show_threads_reply_t_handler_json
1390 (vl_api_show_threads_reply_t * mp)
1392 vat_main_t *vam = &vat_main;
1393 vat_json_node_t node;
1394 vl_api_thread_data_t *td;
1395 i32 retval = ntohl (mp->retval);
1399 count = ntohl (mp->count);
1401 vat_json_init_object (&node);
1402 vat_json_object_add_int (&node, "retval", retval);
1403 vat_json_object_add_uint (&node, "count", count);
1405 for (i = 0; i < count; i++)
1407 td = &mp->thread_data[i];
1408 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1409 vat_json_object_add_string_copy (&node, "name", td->name);
1410 vat_json_object_add_string_copy (&node, "type", td->type);
1411 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1412 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1413 vat_json_object_add_int (&node, "core", ntohl (td->id));
1414 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1417 vat_json_print (vam->ofp, &node);
1418 vat_json_free (&node);
1420 vam->retval = retval;
1421 vam->result_ready = 1;
1425 api_show_threads (vat_main_t * vam)
1427 vl_api_show_threads_t *mp;
1431 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1432 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1434 M (SHOW_THREADS, mp);
1442 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1444 u32 sw_if_index = ntohl (mp->sw_if_index);
1445 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1446 mp->mac_ip ? "mac/ip binding" : "address resolution",
1447 ntohl (mp->pid), format_ip4_address, mp->ip,
1448 format_vl_api_mac_address, &mp->mac, sw_if_index);
1452 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1454 /* JSON output not supported */
1458 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1460 u32 sw_if_index = ntohl (mp->sw_if_index);
1461 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1462 mp->mac_ip ? "mac/ip binding" : "address resolution",
1463 ntohl (mp->pid), format_vl_api_ip6_address, mp->ip,
1464 format_vl_api_mac_address, mp->mac, sw_if_index);
1468 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1470 /* JSON output not supported */
1474 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1476 u32 n_macs = ntohl (mp->n_macs);
1477 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1478 ntohl (mp->pid), mp->client_index, n_macs);
1480 for (i = 0; i < n_macs; i++)
1482 vl_api_mac_entry_t *mac = &mp->mac[i];
1483 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1484 i + 1, ntohl (mac->sw_if_index),
1485 format_ethernet_address, mac->mac_addr, mac->action);
1492 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1494 /* JSON output not supported */
1497 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1498 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1501 * Special-case: build the bridge domain table, maintain
1502 * the next bd id vbl.
1504 static void vl_api_bridge_domain_details_t_handler
1505 (vl_api_bridge_domain_details_t * mp)
1507 vat_main_t *vam = &vat_main;
1508 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1511 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1512 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1514 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1515 ntohl (mp->bd_id), mp->learn, mp->forward,
1516 mp->flood, ntohl (mp->bvi_sw_if_index),
1517 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1521 vl_api_bridge_domain_sw_if_t *sw_ifs;
1522 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1525 sw_ifs = mp->sw_if_details;
1526 for (i = 0; i < n_sw_ifs; i++)
1532 sw_if_index = ntohl (sw_ifs->sw_if_index);
1535 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1537 if ((u32) p->value[0] == sw_if_index)
1539 sw_if_name = (u8 *)(p->key);
1544 print (vam->ofp, "%7d %3d %s", sw_if_index,
1545 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1546 "sw_if_index not found!");
1553 static void vl_api_bridge_domain_details_t_handler_json
1554 (vl_api_bridge_domain_details_t * mp)
1556 vat_main_t *vam = &vat_main;
1557 vat_json_node_t *node, *array = NULL;
1558 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1560 if (VAT_JSON_ARRAY != vam->json_tree.type)
1562 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1563 vat_json_init_array (&vam->json_tree);
1565 node = vat_json_array_add (&vam->json_tree);
1567 vat_json_init_object (node);
1568 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1569 vat_json_object_add_uint (node, "flood", mp->flood);
1570 vat_json_object_add_uint (node, "forward", mp->forward);
1571 vat_json_object_add_uint (node, "learn", mp->learn);
1572 vat_json_object_add_uint (node, "bvi_sw_if_index",
1573 ntohl (mp->bvi_sw_if_index));
1574 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1575 array = vat_json_object_add (node, "sw_if");
1576 vat_json_init_array (array);
1582 vl_api_bridge_domain_sw_if_t *sw_ifs;
1585 sw_ifs = mp->sw_if_details;
1586 for (i = 0; i < n_sw_ifs; i++)
1588 node = vat_json_array_add (array);
1589 vat_json_init_object (node);
1590 vat_json_object_add_uint (node, "sw_if_index",
1591 ntohl (sw_ifs->sw_if_index));
1592 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1598 static void vl_api_control_ping_reply_t_handler
1599 (vl_api_control_ping_reply_t * mp)
1601 vat_main_t *vam = &vat_main;
1602 i32 retval = ntohl (mp->retval);
1603 if (vam->async_mode)
1605 vam->async_errors += (retval < 0);
1609 vam->retval = retval;
1610 vam->result_ready = 1;
1612 if (vam->socket_client_main)
1613 vam->socket_client_main->control_pings_outstanding--;
1616 static void vl_api_control_ping_reply_t_handler_json
1617 (vl_api_control_ping_reply_t * mp)
1619 vat_main_t *vam = &vat_main;
1620 i32 retval = ntohl (mp->retval);
1622 if (VAT_JSON_NONE != vam->json_tree.type)
1624 vat_json_print (vam->ofp, &vam->json_tree);
1625 vat_json_free (&vam->json_tree);
1626 vam->json_tree.type = VAT_JSON_NONE;
1631 vat_json_init_array (&vam->json_tree);
1632 vat_json_print (vam->ofp, &vam->json_tree);
1633 vam->json_tree.type = VAT_JSON_NONE;
1636 vam->retval = retval;
1637 vam->result_ready = 1;
1641 vl_api_bridge_domain_set_mac_age_reply_t_handler
1642 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1644 vat_main_t *vam = &vat_main;
1645 i32 retval = ntohl (mp->retval);
1646 if (vam->async_mode)
1648 vam->async_errors += (retval < 0);
1652 vam->retval = retval;
1653 vam->result_ready = 1;
1657 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1658 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1660 vat_main_t *vam = &vat_main;
1661 vat_json_node_t node;
1663 vat_json_init_object (&node);
1664 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1666 vat_json_print (vam->ofp, &node);
1667 vat_json_free (&node);
1669 vam->retval = ntohl (mp->retval);
1670 vam->result_ready = 1;
1674 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1676 vat_main_t *vam = &vat_main;
1677 i32 retval = ntohl (mp->retval);
1678 if (vam->async_mode)
1680 vam->async_errors += (retval < 0);
1684 vam->retval = retval;
1685 vam->result_ready = 1;
1689 static void vl_api_l2_flags_reply_t_handler_json
1690 (vl_api_l2_flags_reply_t * mp)
1692 vat_main_t *vam = &vat_main;
1693 vat_json_node_t node;
1695 vat_json_init_object (&node);
1696 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1697 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1698 ntohl (mp->resulting_feature_bitmap));
1700 vat_json_print (vam->ofp, &node);
1701 vat_json_free (&node);
1703 vam->retval = ntohl (mp->retval);
1704 vam->result_ready = 1;
1707 static void vl_api_bridge_flags_reply_t_handler
1708 (vl_api_bridge_flags_reply_t * mp)
1710 vat_main_t *vam = &vat_main;
1711 i32 retval = ntohl (mp->retval);
1712 if (vam->async_mode)
1714 vam->async_errors += (retval < 0);
1718 vam->retval = retval;
1719 vam->result_ready = 1;
1723 static void vl_api_bridge_flags_reply_t_handler_json
1724 (vl_api_bridge_flags_reply_t * mp)
1726 vat_main_t *vam = &vat_main;
1727 vat_json_node_t node;
1729 vat_json_init_object (&node);
1730 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1731 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1732 ntohl (mp->resulting_feature_bitmap));
1734 vat_json_print (vam->ofp, &node);
1735 vat_json_free (&node);
1737 vam->retval = ntohl (mp->retval);
1738 vam->result_ready = 1;
1742 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1744 vat_main_t *vam = &vat_main;
1745 i32 retval = ntohl (mp->retval);
1746 if (vam->async_mode)
1748 vam->async_errors += (retval < 0);
1752 vam->retval = retval;
1753 vam->sw_if_index = ntohl (mp->sw_if_index);
1754 vam->result_ready = 1;
1759 static void vl_api_tap_create_v2_reply_t_handler_json
1760 (vl_api_tap_create_v2_reply_t * mp)
1762 vat_main_t *vam = &vat_main;
1763 vat_json_node_t node;
1765 vat_json_init_object (&node);
1766 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1767 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1769 vat_json_print (vam->ofp, &node);
1770 vat_json_free (&node);
1772 vam->retval = ntohl (mp->retval);
1773 vam->result_ready = 1;
1778 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1780 vat_main_t *vam = &vat_main;
1781 i32 retval = ntohl (mp->retval);
1782 if (vam->async_mode)
1784 vam->async_errors += (retval < 0);
1788 vam->retval = retval;
1789 vam->result_ready = 1;
1793 static void vl_api_tap_delete_v2_reply_t_handler_json
1794 (vl_api_tap_delete_v2_reply_t * mp)
1796 vat_main_t *vam = &vat_main;
1797 vat_json_node_t node;
1799 vat_json_init_object (&node);
1800 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1802 vat_json_print (vam->ofp, &node);
1803 vat_json_free (&node);
1805 vam->retval = ntohl (mp->retval);
1806 vam->result_ready = 1;
1810 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1813 vat_main_t *vam = &vat_main;
1814 i32 retval = ntohl (mp->retval);
1815 if (vam->async_mode)
1817 vam->async_errors += (retval < 0);
1821 vam->retval = retval;
1822 vam->sw_if_index = ntohl (mp->sw_if_index);
1823 vam->result_ready = 1;
1827 static void vl_api_virtio_pci_create_reply_t_handler_json
1828 (vl_api_virtio_pci_create_reply_t * mp)
1830 vat_main_t *vam = &vat_main;
1831 vat_json_node_t node;
1833 vat_json_init_object (&node);
1834 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1835 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1837 vat_json_print (vam->ofp, &node);
1838 vat_json_free (&node);
1840 vam->retval = ntohl (mp->retval);
1841 vam->result_ready = 1;
1846 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1849 vat_main_t *vam = &vat_main;
1850 i32 retval = ntohl (mp->retval);
1851 if (vam->async_mode)
1853 vam->async_errors += (retval < 0);
1857 vam->retval = retval;
1858 vam->result_ready = 1;
1862 static void vl_api_virtio_pci_delete_reply_t_handler_json
1863 (vl_api_virtio_pci_delete_reply_t * mp)
1865 vat_main_t *vam = &vat_main;
1866 vat_json_node_t node;
1868 vat_json_init_object (&node);
1869 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1871 vat_json_print (vam->ofp, &node);
1872 vat_json_free (&node);
1874 vam->retval = ntohl (mp->retval);
1875 vam->result_ready = 1;
1879 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1881 vat_main_t *vam = &vat_main;
1882 i32 retval = ntohl (mp->retval);
1884 if (vam->async_mode)
1886 vam->async_errors += (retval < 0);
1890 vam->retval = retval;
1891 vam->sw_if_index = ntohl (mp->sw_if_index);
1892 vam->result_ready = 1;
1896 static void vl_api_bond_create_reply_t_handler_json
1897 (vl_api_bond_create_reply_t * mp)
1899 vat_main_t *vam = &vat_main;
1900 vat_json_node_t node;
1902 vat_json_init_object (&node);
1903 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1904 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1906 vat_json_print (vam->ofp, &node);
1907 vat_json_free (&node);
1909 vam->retval = ntohl (mp->retval);
1910 vam->result_ready = 1;
1914 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1916 vat_main_t *vam = &vat_main;
1917 i32 retval = ntohl (mp->retval);
1919 if (vam->async_mode)
1921 vam->async_errors += (retval < 0);
1925 vam->retval = retval;
1926 vam->result_ready = 1;
1930 static void vl_api_bond_delete_reply_t_handler_json
1931 (vl_api_bond_delete_reply_t * mp)
1933 vat_main_t *vam = &vat_main;
1934 vat_json_node_t node;
1936 vat_json_init_object (&node);
1937 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1939 vat_json_print (vam->ofp, &node);
1940 vat_json_free (&node);
1942 vam->retval = ntohl (mp->retval);
1943 vam->result_ready = 1;
1947 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1949 vat_main_t *vam = &vat_main;
1950 i32 retval = ntohl (mp->retval);
1952 if (vam->async_mode)
1954 vam->async_errors += (retval < 0);
1958 vam->retval = retval;
1959 vam->result_ready = 1;
1963 static void vl_api_bond_enslave_reply_t_handler_json
1964 (vl_api_bond_enslave_reply_t * mp)
1966 vat_main_t *vam = &vat_main;
1967 vat_json_node_t node;
1969 vat_json_init_object (&node);
1970 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1972 vat_json_print (vam->ofp, &node);
1973 vat_json_free (&node);
1975 vam->retval = ntohl (mp->retval);
1976 vam->result_ready = 1;
1980 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1983 vat_main_t *vam = &vat_main;
1984 i32 retval = ntohl (mp->retval);
1986 if (vam->async_mode)
1988 vam->async_errors += (retval < 0);
1992 vam->retval = retval;
1993 vam->result_ready = 1;
1997 static void vl_api_bond_detach_slave_reply_t_handler_json
1998 (vl_api_bond_detach_slave_reply_t * mp)
2000 vat_main_t *vam = &vat_main;
2001 vat_json_node_t node;
2003 vat_json_init_object (&node);
2004 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2006 vat_json_print (vam->ofp, &node);
2007 vat_json_free (&node);
2009 vam->retval = ntohl (mp->retval);
2010 vam->result_ready = 1;
2013 static void vl_api_sw_interface_bond_details_t_handler
2014 (vl_api_sw_interface_bond_details_t * mp)
2016 vat_main_t *vam = &vat_main;
2019 "%-16s %-12d %-12U %-13U %-14u %-14u",
2020 mp->interface_name, ntohl (mp->sw_if_index),
2021 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2022 ntohl (mp->active_slaves), ntohl (mp->slaves));
2025 static void vl_api_sw_interface_bond_details_t_handler_json
2026 (vl_api_sw_interface_bond_details_t * mp)
2028 vat_main_t *vam = &vat_main;
2029 vat_json_node_t *node = NULL;
2031 if (VAT_JSON_ARRAY != vam->json_tree.type)
2033 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2034 vat_json_init_array (&vam->json_tree);
2036 node = vat_json_array_add (&vam->json_tree);
2038 vat_json_init_object (node);
2039 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2040 vat_json_object_add_string_copy (node, "interface_name",
2041 mp->interface_name);
2042 vat_json_object_add_uint (node, "mode", mp->mode);
2043 vat_json_object_add_uint (node, "load_balance", mp->lb);
2044 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2045 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2049 api_sw_interface_bond_dump (vat_main_t * vam)
2051 vl_api_sw_interface_bond_dump_t *mp;
2052 vl_api_control_ping_t *mp_ping;
2056 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2057 "interface name", "sw_if_index", "mode", "load balance",
2058 "active slaves", "slaves");
2060 /* Get list of bond interfaces */
2061 M (SW_INTERFACE_BOND_DUMP, mp);
2064 /* Use a control ping for synchronization */
2065 MPING (CONTROL_PING, mp_ping);
2072 static void vl_api_sw_interface_slave_details_t_handler
2073 (vl_api_sw_interface_slave_details_t * mp)
2075 vat_main_t *vam = &vat_main;
2078 "%-25s %-12d %-12d %d", mp->interface_name,
2079 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2082 static void vl_api_sw_interface_slave_details_t_handler_json
2083 (vl_api_sw_interface_slave_details_t * mp)
2085 vat_main_t *vam = &vat_main;
2086 vat_json_node_t *node = NULL;
2088 if (VAT_JSON_ARRAY != vam->json_tree.type)
2090 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2091 vat_json_init_array (&vam->json_tree);
2093 node = vat_json_array_add (&vam->json_tree);
2095 vat_json_init_object (node);
2096 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2097 vat_json_object_add_string_copy (node, "interface_name",
2098 mp->interface_name);
2099 vat_json_object_add_uint (node, "passive", mp->is_passive);
2100 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2104 api_sw_interface_slave_dump (vat_main_t * vam)
2106 unformat_input_t *i = vam->input;
2107 vl_api_sw_interface_slave_dump_t *mp;
2108 vl_api_control_ping_t *mp_ping;
2109 u32 sw_if_index = ~0;
2110 u8 sw_if_index_set = 0;
2113 /* Parse args required to build the message */
2114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2116 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2117 sw_if_index_set = 1;
2118 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2119 sw_if_index_set = 1;
2124 if (sw_if_index_set == 0)
2126 errmsg ("missing vpp interface name. ");
2131 "\n%-25s %-12s %-12s %s",
2132 "slave interface name", "sw_if_index", "passive", "long_timeout");
2134 /* Get list of bond interfaces */
2135 M (SW_INTERFACE_SLAVE_DUMP, mp);
2136 mp->sw_if_index = ntohl (sw_if_index);
2139 /* Use a control ping for synchronization */
2140 MPING (CONTROL_PING, mp_ping);
2147 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2148 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2150 vat_main_t *vam = &vat_main;
2151 i32 retval = ntohl (mp->retval);
2152 if (vam->async_mode)
2154 vam->async_errors += (retval < 0);
2158 vam->retval = retval;
2159 vam->sw_if_index = ntohl (mp->sw_if_index);
2160 vam->result_ready = 1;
2162 vam->regenerate_interface_table = 1;
2165 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2166 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2168 vat_main_t *vam = &vat_main;
2169 vat_json_node_t node;
2171 vat_json_init_object (&node);
2172 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2173 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2174 ntohl (mp->sw_if_index));
2176 vat_json_print (vam->ofp, &node);
2177 vat_json_free (&node);
2179 vam->retval = ntohl (mp->retval);
2180 vam->result_ready = 1;
2183 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2184 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2186 vat_main_t *vam = &vat_main;
2187 i32 retval = ntohl (mp->retval);
2188 if (vam->async_mode)
2190 vam->async_errors += (retval < 0);
2194 vam->retval = retval;
2195 vam->sw_if_index = ntohl (mp->sw_if_index);
2196 vam->result_ready = 1;
2200 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2201 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2203 vat_main_t *vam = &vat_main;
2204 vat_json_node_t node;
2206 vat_json_init_object (&node);
2207 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2208 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2210 vat_json_print (vam->ofp, &node);
2211 vat_json_free (&node);
2213 vam->retval = ntohl (mp->retval);
2214 vam->result_ready = 1;
2217 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2218 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2220 vat_main_t *vam = &vat_main;
2221 i32 retval = ntohl (mp->retval);
2222 if (vam->async_mode)
2224 vam->async_errors += (retval < 0);
2228 vam->retval = retval;
2229 vam->result_ready = 1;
2233 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2234 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2236 vat_main_t *vam = &vat_main;
2237 vat_json_node_t node;
2239 vat_json_init_object (&node);
2240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2241 vat_json_object_add_uint (&node, "fwd_entry_index",
2242 clib_net_to_host_u32 (mp->fwd_entry_index));
2244 vat_json_print (vam->ofp, &node);
2245 vat_json_free (&node);
2247 vam->retval = ntohl (mp->retval);
2248 vam->result_ready = 1;
2252 format_lisp_transport_protocol (u8 * s, va_list * args)
2254 u32 proto = va_arg (*args, u32);
2259 return format (s, "udp");
2261 return format (s, "api");
2268 static void vl_api_one_get_transport_protocol_reply_t_handler
2269 (vl_api_one_get_transport_protocol_reply_t * mp)
2271 vat_main_t *vam = &vat_main;
2272 i32 retval = ntohl (mp->retval);
2273 if (vam->async_mode)
2275 vam->async_errors += (retval < 0);
2279 u32 proto = mp->protocol;
2280 print (vam->ofp, "Transport protocol: %U",
2281 format_lisp_transport_protocol, proto);
2282 vam->retval = retval;
2283 vam->result_ready = 1;
2287 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2288 (vl_api_one_get_transport_protocol_reply_t * mp)
2290 vat_main_t *vam = &vat_main;
2291 vat_json_node_t node;
2294 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2297 vat_json_init_object (&node);
2298 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2299 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2302 vat_json_print (vam->ofp, &node);
2303 vat_json_free (&node);
2305 vam->retval = ntohl (mp->retval);
2306 vam->result_ready = 1;
2309 static void vl_api_one_add_del_locator_set_reply_t_handler
2310 (vl_api_one_add_del_locator_set_reply_t * mp)
2312 vat_main_t *vam = &vat_main;
2313 i32 retval = ntohl (mp->retval);
2314 if (vam->async_mode)
2316 vam->async_errors += (retval < 0);
2320 vam->retval = retval;
2321 vam->result_ready = 1;
2325 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2326 (vl_api_one_add_del_locator_set_reply_t * mp)
2328 vat_main_t *vam = &vat_main;
2329 vat_json_node_t node;
2331 vat_json_init_object (&node);
2332 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2333 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2335 vat_json_print (vam->ofp, &node);
2336 vat_json_free (&node);
2338 vam->retval = ntohl (mp->retval);
2339 vam->result_ready = 1;
2342 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2343 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2345 vat_main_t *vam = &vat_main;
2346 i32 retval = ntohl (mp->retval);
2347 if (vam->async_mode)
2349 vam->async_errors += (retval < 0);
2353 vam->retval = retval;
2354 vam->sw_if_index = ntohl (mp->sw_if_index);
2355 vam->result_ready = 1;
2357 vam->regenerate_interface_table = 1;
2360 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2361 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2363 vat_main_t *vam = &vat_main;
2364 vat_json_node_t node;
2366 vat_json_init_object (&node);
2367 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2368 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2370 vat_json_print (vam->ofp, &node);
2371 vat_json_free (&node);
2373 vam->retval = ntohl (mp->retval);
2374 vam->result_ready = 1;
2377 static void vl_api_vxlan_offload_rx_reply_t_handler
2378 (vl_api_vxlan_offload_rx_reply_t * mp)
2380 vat_main_t *vam = &vat_main;
2381 i32 retval = ntohl (mp->retval);
2382 if (vam->async_mode)
2384 vam->async_errors += (retval < 0);
2388 vam->retval = retval;
2389 vam->result_ready = 1;
2393 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2394 (vl_api_vxlan_offload_rx_reply_t * mp)
2396 vat_main_t *vam = &vat_main;
2397 vat_json_node_t node;
2399 vat_json_init_object (&node);
2400 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2402 vat_json_print (vam->ofp, &node);
2403 vat_json_free (&node);
2405 vam->retval = ntohl (mp->retval);
2406 vam->result_ready = 1;
2409 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2410 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2412 vat_main_t *vam = &vat_main;
2413 i32 retval = ntohl (mp->retval);
2414 if (vam->async_mode)
2416 vam->async_errors += (retval < 0);
2420 vam->retval = retval;
2421 vam->sw_if_index = ntohl (mp->sw_if_index);
2422 vam->result_ready = 1;
2426 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2427 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2429 vat_main_t *vam = &vat_main;
2430 vat_json_node_t node;
2432 vat_json_init_object (&node);
2433 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2434 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2436 vat_json_print (vam->ofp, &node);
2437 vat_json_free (&node);
2439 vam->retval = ntohl (mp->retval);
2440 vam->result_ready = 1;
2443 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2444 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2446 vat_main_t *vam = &vat_main;
2447 i32 retval = ntohl (mp->retval);
2448 if (vam->async_mode)
2450 vam->async_errors += (retval < 0);
2454 vam->retval = retval;
2455 vam->sw_if_index = ntohl (mp->sw_if_index);
2456 vam->result_ready = 1;
2458 vam->regenerate_interface_table = 1;
2461 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2462 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2464 vat_main_t *vam = &vat_main;
2465 vat_json_node_t node;
2467 vat_json_init_object (&node);
2468 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2469 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2471 vat_json_print (vam->ofp, &node);
2472 vat_json_free (&node);
2474 vam->retval = ntohl (mp->retval);
2475 vam->result_ready = 1;
2478 static void vl_api_gre_add_del_tunnel_reply_t_handler
2479 (vl_api_gre_add_del_tunnel_reply_t * mp)
2481 vat_main_t *vam = &vat_main;
2482 i32 retval = ntohl (mp->retval);
2483 if (vam->async_mode)
2485 vam->async_errors += (retval < 0);
2489 vam->retval = retval;
2490 vam->sw_if_index = ntohl (mp->sw_if_index);
2491 vam->result_ready = 1;
2495 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2496 (vl_api_gre_add_del_tunnel_reply_t * mp)
2498 vat_main_t *vam = &vat_main;
2499 vat_json_node_t node;
2501 vat_json_init_object (&node);
2502 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2503 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2505 vat_json_print (vam->ofp, &node);
2506 vat_json_free (&node);
2508 vam->retval = ntohl (mp->retval);
2509 vam->result_ready = 1;
2512 static void vl_api_create_vhost_user_if_reply_t_handler
2513 (vl_api_create_vhost_user_if_reply_t * mp)
2515 vat_main_t *vam = &vat_main;
2516 i32 retval = ntohl (mp->retval);
2517 if (vam->async_mode)
2519 vam->async_errors += (retval < 0);
2523 vam->retval = retval;
2524 vam->sw_if_index = ntohl (mp->sw_if_index);
2525 vam->result_ready = 1;
2527 vam->regenerate_interface_table = 1;
2530 static void vl_api_create_vhost_user_if_reply_t_handler_json
2531 (vl_api_create_vhost_user_if_reply_t * mp)
2533 vat_main_t *vam = &vat_main;
2534 vat_json_node_t node;
2536 vat_json_init_object (&node);
2537 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2538 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2540 vat_json_print (vam->ofp, &node);
2541 vat_json_free (&node);
2543 vam->retval = ntohl (mp->retval);
2544 vam->result_ready = 1;
2547 static void vl_api_dns_resolve_name_reply_t_handler
2548 (vl_api_dns_resolve_name_reply_t * mp)
2550 vat_main_t *vam = &vat_main;
2551 i32 retval = ntohl (mp->retval);
2552 if (vam->async_mode)
2554 vam->async_errors += (retval < 0);
2558 vam->retval = retval;
2559 vam->result_ready = 1;
2564 clib_warning ("ip4 address %U", format_ip4_address,
2565 (ip4_address_t *) mp->ip4_address);
2567 clib_warning ("ip6 address %U", format_ip6_address,
2568 (ip6_address_t *) mp->ip6_address);
2571 clib_warning ("retval %d", retval);
2575 static void vl_api_dns_resolve_name_reply_t_handler_json
2576 (vl_api_dns_resolve_name_reply_t * mp)
2578 clib_warning ("not implemented");
2581 static void vl_api_dns_resolve_ip_reply_t_handler
2582 (vl_api_dns_resolve_ip_reply_t * mp)
2584 vat_main_t *vam = &vat_main;
2585 i32 retval = ntohl (mp->retval);
2586 if (vam->async_mode)
2588 vam->async_errors += (retval < 0);
2592 vam->retval = retval;
2593 vam->result_ready = 1;
2597 clib_warning ("canonical name %s", mp->name);
2600 clib_warning ("retval %d", retval);
2604 static void vl_api_dns_resolve_ip_reply_t_handler_json
2605 (vl_api_dns_resolve_ip_reply_t * mp)
2607 clib_warning ("not implemented");
2611 static void vl_api_ip_address_details_t_handler
2612 (vl_api_ip_address_details_t * mp)
2614 vat_main_t *vam = &vat_main;
2615 static ip_address_details_t empty_ip_address_details = { {0} };
2616 ip_address_details_t *address = NULL;
2617 ip_details_t *current_ip_details = NULL;
2618 ip_details_t *details = NULL;
2620 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2622 if (!details || vam->current_sw_if_index >= vec_len (details)
2623 || !details[vam->current_sw_if_index].present)
2625 errmsg ("ip address details arrived but not stored");
2626 errmsg ("ip_dump should be called first");
2630 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2632 #define addresses (current_ip_details->addr)
2634 vec_validate_init_empty (addresses, vec_len (addresses),
2635 empty_ip_address_details);
2637 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2639 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2640 address->prefix_length = mp->prefix_length;
2644 static void vl_api_ip_address_details_t_handler_json
2645 (vl_api_ip_address_details_t * mp)
2647 vat_main_t *vam = &vat_main;
2648 vat_json_node_t *node = NULL;
2649 struct in6_addr ip6;
2652 if (VAT_JSON_ARRAY != vam->json_tree.type)
2654 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2655 vat_json_init_array (&vam->json_tree);
2657 node = vat_json_array_add (&vam->json_tree);
2659 vat_json_init_object (node);
2662 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2663 vat_json_object_add_ip6 (node, "ip", ip6);
2667 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2668 vat_json_object_add_ip4 (node, "ip", ip4);
2670 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2674 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2676 vat_main_t *vam = &vat_main;
2677 static ip_details_t empty_ip_details = { 0 };
2678 ip_details_t *ip = NULL;
2679 u32 sw_if_index = ~0;
2681 sw_if_index = ntohl (mp->sw_if_index);
2683 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2684 sw_if_index, empty_ip_details);
2686 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2693 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2695 vat_main_t *vam = &vat_main;
2697 if (VAT_JSON_ARRAY != vam->json_tree.type)
2699 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2700 vat_json_init_array (&vam->json_tree);
2702 vat_json_array_add_uint (&vam->json_tree,
2703 clib_net_to_host_u32 (mp->sw_if_index));
2707 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2709 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2710 "router_addr %U host_mac %U",
2711 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2713 format_ip4_address, &mp->lease.host_address,
2714 format_ip4_address, &mp->lease.router_address,
2715 format_ethernet_address, mp->lease.host_mac);
2718 static void vl_api_dhcp_compl_event_t_handler_json
2719 (vl_api_dhcp_compl_event_t * mp)
2721 /* JSON output not supported */
2724 static void vl_api_get_first_msg_id_reply_t_handler
2725 (vl_api_get_first_msg_id_reply_t * mp)
2727 vat_main_t *vam = &vat_main;
2728 i32 retval = ntohl (mp->retval);
2730 if (vam->async_mode)
2732 vam->async_errors += (retval < 0);
2736 vam->retval = retval;
2737 vam->result_ready = 1;
2741 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2745 static void vl_api_get_first_msg_id_reply_t_handler_json
2746 (vl_api_get_first_msg_id_reply_t * mp)
2748 vat_main_t *vam = &vat_main;
2749 vat_json_node_t node;
2751 vat_json_init_object (&node);
2752 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2753 vat_json_object_add_uint (&node, "first_msg_id",
2754 (uint) ntohs (mp->first_msg_id));
2756 vat_json_print (vam->ofp, &node);
2757 vat_json_free (&node);
2759 vam->retval = ntohl (mp->retval);
2760 vam->result_ready = 1;
2763 static void vl_api_get_node_graph_reply_t_handler
2764 (vl_api_get_node_graph_reply_t * mp)
2766 vat_main_t *vam = &vat_main;
2767 api_main_t *am = &api_main;
2768 i32 retval = ntohl (mp->retval);
2769 u8 *pvt_copy, *reply;
2774 if (vam->async_mode)
2776 vam->async_errors += (retval < 0);
2780 vam->retval = retval;
2781 vam->result_ready = 1;
2784 /* "Should never happen..." */
2788 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2789 pvt_copy = vec_dup (reply);
2791 /* Toss the shared-memory original... */
2792 pthread_mutex_lock (&am->vlib_rp->mutex);
2793 oldheap = svm_push_data_heap (am->vlib_rp);
2797 svm_pop_heap (oldheap);
2798 pthread_mutex_unlock (&am->vlib_rp->mutex);
2800 if (vam->graph_nodes)
2802 hash_free (vam->graph_node_index_by_name);
2804 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2806 node = vam->graph_nodes[0][i];
2807 vec_free (node->name);
2808 vec_free (node->next_nodes);
2811 vec_free (vam->graph_nodes[0]);
2812 vec_free (vam->graph_nodes);
2815 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2816 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2817 vec_free (pvt_copy);
2819 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2821 node = vam->graph_nodes[0][i];
2822 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2826 static void vl_api_get_node_graph_reply_t_handler_json
2827 (vl_api_get_node_graph_reply_t * mp)
2829 vat_main_t *vam = &vat_main;
2830 api_main_t *am = &api_main;
2832 vat_json_node_t node;
2835 /* $$$$ make this real? */
2836 vat_json_init_object (&node);
2837 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2838 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2840 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2842 /* Toss the shared-memory original... */
2843 pthread_mutex_lock (&am->vlib_rp->mutex);
2844 oldheap = svm_push_data_heap (am->vlib_rp);
2848 svm_pop_heap (oldheap);
2849 pthread_mutex_unlock (&am->vlib_rp->mutex);
2851 vat_json_print (vam->ofp, &node);
2852 vat_json_free (&node);
2854 vam->retval = ntohl (mp->retval);
2855 vam->result_ready = 1;
2859 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2861 vat_main_t *vam = &vat_main;
2866 s = format (s, "%=16d%=16d%=16d",
2867 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2871 s = format (s, "%=16U%=16d%=16d",
2872 mp->is_ipv6 ? format_ip6_address :
2874 mp->ip_address, mp->priority, mp->weight);
2877 print (vam->ofp, "%v", s);
2882 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2884 vat_main_t *vam = &vat_main;
2885 vat_json_node_t *node = NULL;
2886 struct in6_addr ip6;
2889 if (VAT_JSON_ARRAY != vam->json_tree.type)
2891 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2892 vat_json_init_array (&vam->json_tree);
2894 node = vat_json_array_add (&vam->json_tree);
2895 vat_json_init_object (node);
2897 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2898 vat_json_object_add_uint (node, "priority", mp->priority);
2899 vat_json_object_add_uint (node, "weight", mp->weight);
2902 vat_json_object_add_uint (node, "sw_if_index",
2903 clib_net_to_host_u32 (mp->sw_if_index));
2908 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2909 vat_json_object_add_ip6 (node, "address", ip6);
2913 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2914 vat_json_object_add_ip4 (node, "address", ip4);
2920 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2923 vat_main_t *vam = &vat_main;
2926 ls_name = format (0, "%s", mp->ls_name);
2928 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2934 vl_api_one_locator_set_details_t_handler_json
2935 (vl_api_one_locator_set_details_t * mp)
2937 vat_main_t *vam = &vat_main;
2938 vat_json_node_t *node = 0;
2941 ls_name = format (0, "%s", mp->ls_name);
2942 vec_add1 (ls_name, 0);
2944 if (VAT_JSON_ARRAY != vam->json_tree.type)
2946 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2947 vat_json_init_array (&vam->json_tree);
2949 node = vat_json_array_add (&vam->json_tree);
2951 vat_json_init_object (node);
2952 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2953 vat_json_object_add_uint (node, "ls_index",
2954 clib_net_to_host_u32 (mp->ls_index));
2962 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2965 unformat_nsh_address (unformat_input_t * input, va_list * args)
2967 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2968 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2972 format_nsh_address_vat (u8 * s, va_list * args)
2974 nsh_t *a = va_arg (*args, nsh_t *);
2975 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2979 format_lisp_flat_eid (u8 * s, va_list * args)
2981 u32 type = va_arg (*args, u32);
2982 u8 *eid = va_arg (*args, u8 *);
2983 u32 eid_len = va_arg (*args, u32);
2988 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2990 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2992 return format (s, "%U", format_ethernet_address, eid);
2994 return format (s, "%U", format_nsh_address_vat, eid);
3000 format_lisp_eid_vat (u8 * s, va_list * args)
3002 u32 type = va_arg (*args, u32);
3003 u8 *eid = va_arg (*args, u8 *);
3004 u32 eid_len = va_arg (*args, u32);
3005 u8 *seid = va_arg (*args, u8 *);
3006 u32 seid_len = va_arg (*args, u32);
3007 u32 is_src_dst = va_arg (*args, u32);
3010 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3012 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3018 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3020 vat_main_t *vam = &vat_main;
3021 u8 *s = 0, *eid = 0;
3023 if (~0 == mp->locator_set_index)
3024 s = format (0, "action: %d", mp->action);
3026 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3028 eid = format (0, "%U", format_lisp_eid_vat,
3032 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3035 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3036 clib_net_to_host_u32 (mp->vni),
3038 mp->is_local ? "local" : "remote",
3039 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3040 clib_net_to_host_u16 (mp->key_id), mp->key);
3047 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3050 vat_main_t *vam = &vat_main;
3051 vat_json_node_t *node = 0;
3054 if (VAT_JSON_ARRAY != vam->json_tree.type)
3056 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3057 vat_json_init_array (&vam->json_tree);
3059 node = vat_json_array_add (&vam->json_tree);
3061 vat_json_init_object (node);
3062 if (~0 == mp->locator_set_index)
3063 vat_json_object_add_uint (node, "action", mp->action);
3065 vat_json_object_add_uint (node, "locator_set_index",
3066 clib_net_to_host_u32 (mp->locator_set_index));
3068 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3069 if (mp->eid_type == 3)
3071 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3072 vat_json_init_object (nsh_json);
3073 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3074 vat_json_object_add_uint (nsh_json, "spi",
3075 clib_net_to_host_u32 (nsh->spi));
3076 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3080 eid = format (0, "%U", format_lisp_eid_vat,
3084 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3086 vat_json_object_add_string_copy (node, "eid", eid);
3089 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3090 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3091 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3095 vat_json_object_add_uint (node, "key_id",
3096 clib_net_to_host_u16 (mp->key_id));
3097 vat_json_object_add_string_copy (node, "key", mp->key);
3102 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3104 vat_main_t *vam = &vat_main;
3105 u8 *seid = 0, *deid = 0;
3106 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3108 deid = format (0, "%U", format_lisp_eid_vat,
3109 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3111 seid = format (0, "%U", format_lisp_eid_vat,
3112 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3118 format_ip_address_fcn = format_ip4_address;
3120 format_ip_address_fcn = format_ip6_address;
3123 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3124 clib_net_to_host_u32 (mp->vni),
3126 format_ip_address_fcn, mp->lloc,
3127 format_ip_address_fcn, mp->rloc,
3128 clib_net_to_host_u32 (mp->pkt_count),
3129 clib_net_to_host_u32 (mp->bytes));
3136 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3138 struct in6_addr ip6;
3140 vat_main_t *vam = &vat_main;
3141 vat_json_node_t *node = 0;
3142 u8 *deid = 0, *seid = 0;
3144 if (VAT_JSON_ARRAY != vam->json_tree.type)
3146 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3147 vat_json_init_array (&vam->json_tree);
3149 node = vat_json_array_add (&vam->json_tree);
3151 vat_json_init_object (node);
3152 deid = format (0, "%U", format_lisp_eid_vat,
3153 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3155 seid = format (0, "%U", format_lisp_eid_vat,
3156 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3161 vat_json_object_add_string_copy (node, "seid", seid);
3162 vat_json_object_add_string_copy (node, "deid", deid);
3163 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3167 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3168 vat_json_object_add_ip4 (node, "lloc", ip4);
3169 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3170 vat_json_object_add_ip4 (node, "rloc", ip4);
3174 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3175 vat_json_object_add_ip6 (node, "lloc", ip6);
3176 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3177 vat_json_object_add_ip6 (node, "rloc", ip6);
3179 vat_json_object_add_uint (node, "pkt_count",
3180 clib_net_to_host_u32 (mp->pkt_count));
3181 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3188 vl_api_one_eid_table_map_details_t_handler
3189 (vl_api_one_eid_table_map_details_t * mp)
3191 vat_main_t *vam = &vat_main;
3193 u8 *line = format (0, "%=10d%=10d",
3194 clib_net_to_host_u32 (mp->vni),
3195 clib_net_to_host_u32 (mp->dp_table));
3196 print (vam->ofp, "%v", line);
3201 vl_api_one_eid_table_map_details_t_handler_json
3202 (vl_api_one_eid_table_map_details_t * mp)
3204 vat_main_t *vam = &vat_main;
3205 vat_json_node_t *node = NULL;
3207 if (VAT_JSON_ARRAY != vam->json_tree.type)
3209 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3210 vat_json_init_array (&vam->json_tree);
3212 node = vat_json_array_add (&vam->json_tree);
3213 vat_json_init_object (node);
3214 vat_json_object_add_uint (node, "dp_table",
3215 clib_net_to_host_u32 (mp->dp_table));
3216 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3220 vl_api_one_eid_table_vni_details_t_handler
3221 (vl_api_one_eid_table_vni_details_t * mp)
3223 vat_main_t *vam = &vat_main;
3225 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3226 print (vam->ofp, "%v", line);
3231 vl_api_one_eid_table_vni_details_t_handler_json
3232 (vl_api_one_eid_table_vni_details_t * mp)
3234 vat_main_t *vam = &vat_main;
3235 vat_json_node_t *node = NULL;
3237 if (VAT_JSON_ARRAY != vam->json_tree.type)
3239 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3240 vat_json_init_array (&vam->json_tree);
3242 node = vat_json_array_add (&vam->json_tree);
3243 vat_json_init_object (node);
3244 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3248 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3249 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3251 vat_main_t *vam = &vat_main;
3252 int retval = clib_net_to_host_u32 (mp->retval);
3254 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3255 print (vam->ofp, "fallback threshold value: %d", mp->value);
3257 vam->retval = retval;
3258 vam->result_ready = 1;
3262 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3263 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3265 vat_main_t *vam = &vat_main;
3266 vat_json_node_t _node, *node = &_node;
3267 int retval = clib_net_to_host_u32 (mp->retval);
3269 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3270 vat_json_init_object (node);
3271 vat_json_object_add_uint (node, "value", mp->value);
3273 vat_json_print (vam->ofp, node);
3274 vat_json_free (node);
3276 vam->retval = retval;
3277 vam->result_ready = 1;
3281 vl_api_show_one_map_register_state_reply_t_handler
3282 (vl_api_show_one_map_register_state_reply_t * mp)
3284 vat_main_t *vam = &vat_main;
3285 int retval = clib_net_to_host_u32 (mp->retval);
3287 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3289 vam->retval = retval;
3290 vam->result_ready = 1;
3294 vl_api_show_one_map_register_state_reply_t_handler_json
3295 (vl_api_show_one_map_register_state_reply_t * mp)
3297 vat_main_t *vam = &vat_main;
3298 vat_json_node_t _node, *node = &_node;
3299 int retval = clib_net_to_host_u32 (mp->retval);
3301 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3303 vat_json_init_object (node);
3304 vat_json_object_add_string_copy (node, "state", s);
3306 vat_json_print (vam->ofp, node);
3307 vat_json_free (node);
3309 vam->retval = retval;
3310 vam->result_ready = 1;
3315 vl_api_show_one_rloc_probe_state_reply_t_handler
3316 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3318 vat_main_t *vam = &vat_main;
3319 int retval = clib_net_to_host_u32 (mp->retval);
3324 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3326 vam->retval = retval;
3327 vam->result_ready = 1;
3331 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3332 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3334 vat_main_t *vam = &vat_main;
3335 vat_json_node_t _node, *node = &_node;
3336 int retval = clib_net_to_host_u32 (mp->retval);
3338 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3339 vat_json_init_object (node);
3340 vat_json_object_add_string_copy (node, "state", s);
3342 vat_json_print (vam->ofp, node);
3343 vat_json_free (node);
3345 vam->retval = retval;
3346 vam->result_ready = 1;
3351 vl_api_show_one_stats_enable_disable_reply_t_handler
3352 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3354 vat_main_t *vam = &vat_main;
3355 int retval = clib_net_to_host_u32 (mp->retval);
3360 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3362 vam->retval = retval;
3363 vam->result_ready = 1;
3367 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3368 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3370 vat_main_t *vam = &vat_main;
3371 vat_json_node_t _node, *node = &_node;
3372 int retval = clib_net_to_host_u32 (mp->retval);
3374 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3375 vat_json_init_object (node);
3376 vat_json_object_add_string_copy (node, "state", s);
3378 vat_json_print (vam->ofp, node);
3379 vat_json_free (node);
3381 vam->retval = retval;
3382 vam->result_ready = 1;
3387 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3389 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3390 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3391 e->vni = clib_net_to_host_u32 (e->vni);
3395 gpe_fwd_entries_get_reply_t_net_to_host
3396 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3400 mp->count = clib_net_to_host_u32 (mp->count);
3401 for (i = 0; i < mp->count; i++)
3403 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3408 format_gpe_encap_mode (u8 * s, va_list * args)
3410 u32 mode = va_arg (*args, u32);
3415 return format (s, "lisp");
3417 return format (s, "vxlan");
3423 vl_api_gpe_get_encap_mode_reply_t_handler
3424 (vl_api_gpe_get_encap_mode_reply_t * mp)
3426 vat_main_t *vam = &vat_main;
3428 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3429 vam->retval = ntohl (mp->retval);
3430 vam->result_ready = 1;
3434 vl_api_gpe_get_encap_mode_reply_t_handler_json
3435 (vl_api_gpe_get_encap_mode_reply_t * mp)
3437 vat_main_t *vam = &vat_main;
3438 vat_json_node_t node;
3440 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3441 vec_add1 (encap_mode, 0);
3443 vat_json_init_object (&node);
3444 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3446 vec_free (encap_mode);
3447 vat_json_print (vam->ofp, &node);
3448 vat_json_free (&node);
3450 vam->retval = ntohl (mp->retval);
3451 vam->result_ready = 1;
3455 vl_api_gpe_fwd_entry_path_details_t_handler
3456 (vl_api_gpe_fwd_entry_path_details_t * mp)
3458 vat_main_t *vam = &vat_main;
3459 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3461 if (mp->lcl_loc.is_ip4)
3462 format_ip_address_fcn = format_ip4_address;
3464 format_ip_address_fcn = format_ip6_address;
3466 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3467 format_ip_address_fcn, &mp->lcl_loc,
3468 format_ip_address_fcn, &mp->rmt_loc);
3472 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3474 struct in6_addr ip6;
3479 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3480 vat_json_object_add_ip4 (n, "address", ip4);
3484 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3485 vat_json_object_add_ip6 (n, "address", ip6);
3487 vat_json_object_add_uint (n, "weight", loc->weight);
3491 vl_api_gpe_fwd_entry_path_details_t_handler_json
3492 (vl_api_gpe_fwd_entry_path_details_t * mp)
3494 vat_main_t *vam = &vat_main;
3495 vat_json_node_t *node = NULL;
3496 vat_json_node_t *loc_node;
3498 if (VAT_JSON_ARRAY != vam->json_tree.type)
3500 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3501 vat_json_init_array (&vam->json_tree);
3503 node = vat_json_array_add (&vam->json_tree);
3504 vat_json_init_object (node);
3506 loc_node = vat_json_object_add (node, "local_locator");
3507 vat_json_init_object (loc_node);
3508 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3510 loc_node = vat_json_object_add (node, "remote_locator");
3511 vat_json_init_object (loc_node);
3512 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3516 vl_api_gpe_fwd_entries_get_reply_t_handler
3517 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3519 vat_main_t *vam = &vat_main;
3521 int retval = clib_net_to_host_u32 (mp->retval);
3522 vl_api_gpe_fwd_entry_t *e;
3527 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3529 for (i = 0; i < mp->count; i++)
3531 e = &mp->entries[i];
3532 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3533 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3534 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3538 vam->retval = retval;
3539 vam->result_ready = 1;
3543 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3544 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3547 vat_main_t *vam = &vat_main;
3548 vat_json_node_t *e = 0, root;
3550 int retval = clib_net_to_host_u32 (mp->retval);
3551 vl_api_gpe_fwd_entry_t *fwd;
3556 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3557 vat_json_init_array (&root);
3559 for (i = 0; i < mp->count; i++)
3561 e = vat_json_array_add (&root);
3562 fwd = &mp->entries[i];
3564 vat_json_init_object (e);
3565 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3566 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3567 vat_json_object_add_int (e, "vni", fwd->vni);
3568 vat_json_object_add_int (e, "action", fwd->action);
3570 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3571 fwd->leid_prefix_len);
3573 vat_json_object_add_string_copy (e, "leid", s);
3576 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3577 fwd->reid_prefix_len);
3579 vat_json_object_add_string_copy (e, "reid", s);
3583 vat_json_print (vam->ofp, &root);
3584 vat_json_free (&root);
3587 vam->retval = retval;
3588 vam->result_ready = 1;
3592 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3593 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3595 vat_main_t *vam = &vat_main;
3597 int retval = clib_net_to_host_u32 (mp->retval);
3598 vl_api_gpe_native_fwd_rpath_t *r;
3603 n = clib_net_to_host_u32 (mp->count);
3605 for (i = 0; i < n; i++)
3607 r = &mp->entries[i];
3608 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3609 clib_net_to_host_u32 (r->fib_index),
3610 clib_net_to_host_u32 (r->nh_sw_if_index),
3611 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3615 vam->retval = retval;
3616 vam->result_ready = 1;
3620 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3621 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3623 vat_main_t *vam = &vat_main;
3624 vat_json_node_t root, *e;
3626 int retval = clib_net_to_host_u32 (mp->retval);
3627 vl_api_gpe_native_fwd_rpath_t *r;
3633 n = clib_net_to_host_u32 (mp->count);
3634 vat_json_init_array (&root);
3636 for (i = 0; i < n; i++)
3638 e = vat_json_array_add (&root);
3639 vat_json_init_object (e);
3640 r = &mp->entries[i];
3642 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3645 vat_json_object_add_string_copy (e, "ip4", s);
3648 vat_json_object_add_uint (e, "fib_index",
3649 clib_net_to_host_u32 (r->fib_index));
3650 vat_json_object_add_uint (e, "nh_sw_if_index",
3651 clib_net_to_host_u32 (r->nh_sw_if_index));
3654 vat_json_print (vam->ofp, &root);
3655 vat_json_free (&root);
3658 vam->retval = retval;
3659 vam->result_ready = 1;
3663 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3664 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3666 vat_main_t *vam = &vat_main;
3668 int retval = clib_net_to_host_u32 (mp->retval);
3673 n = clib_net_to_host_u32 (mp->count);
3675 for (i = 0; i < n; i++)
3676 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3679 vam->retval = retval;
3680 vam->result_ready = 1;
3684 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3685 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3687 vat_main_t *vam = &vat_main;
3688 vat_json_node_t root;
3690 int retval = clib_net_to_host_u32 (mp->retval);
3695 n = clib_net_to_host_u32 (mp->count);
3696 vat_json_init_array (&root);
3698 for (i = 0; i < n; i++)
3699 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3701 vat_json_print (vam->ofp, &root);
3702 vat_json_free (&root);
3705 vam->retval = retval;
3706 vam->result_ready = 1;
3710 vl_api_one_ndp_entries_get_reply_t_handler
3711 (vl_api_one_ndp_entries_get_reply_t * mp)
3713 vat_main_t *vam = &vat_main;
3715 int retval = clib_net_to_host_u32 (mp->retval);
3720 n = clib_net_to_host_u32 (mp->count);
3722 for (i = 0; i < n; i++)
3723 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3724 format_ethernet_address, mp->entries[i].mac);
3727 vam->retval = retval;
3728 vam->result_ready = 1;
3732 vl_api_one_ndp_entries_get_reply_t_handler_json
3733 (vl_api_one_ndp_entries_get_reply_t * mp)
3736 vat_main_t *vam = &vat_main;
3737 vat_json_node_t *e = 0, root;
3739 int retval = clib_net_to_host_u32 (mp->retval);
3740 vl_api_one_ndp_entry_t *arp_entry;
3745 n = clib_net_to_host_u32 (mp->count);
3746 vat_json_init_array (&root);
3748 for (i = 0; i < n; i++)
3750 e = vat_json_array_add (&root);
3751 arp_entry = &mp->entries[i];
3753 vat_json_init_object (e);
3754 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3757 vat_json_object_add_string_copy (e, "mac", s);
3760 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3762 vat_json_object_add_string_copy (e, "ip6", s);
3766 vat_json_print (vam->ofp, &root);
3767 vat_json_free (&root);
3770 vam->retval = retval;
3771 vam->result_ready = 1;
3775 vl_api_one_l2_arp_entries_get_reply_t_handler
3776 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3778 vat_main_t *vam = &vat_main;
3780 int retval = clib_net_to_host_u32 (mp->retval);
3785 n = clib_net_to_host_u32 (mp->count);
3787 for (i = 0; i < n; i++)
3788 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3789 format_ethernet_address, mp->entries[i].mac);
3792 vam->retval = retval;
3793 vam->result_ready = 1;
3797 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3798 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3801 vat_main_t *vam = &vat_main;
3802 vat_json_node_t *e = 0, root;
3804 int retval = clib_net_to_host_u32 (mp->retval);
3805 vl_api_one_l2_arp_entry_t *arp_entry;
3810 n = clib_net_to_host_u32 (mp->count);
3811 vat_json_init_array (&root);
3813 for (i = 0; i < n; i++)
3815 e = vat_json_array_add (&root);
3816 arp_entry = &mp->entries[i];
3818 vat_json_init_object (e);
3819 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3822 vat_json_object_add_string_copy (e, "mac", s);
3825 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3827 vat_json_object_add_string_copy (e, "ip4", s);
3831 vat_json_print (vam->ofp, &root);
3832 vat_json_free (&root);
3835 vam->retval = retval;
3836 vam->result_ready = 1;
3840 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3842 vat_main_t *vam = &vat_main;
3844 int retval = clib_net_to_host_u32 (mp->retval);
3849 n = clib_net_to_host_u32 (mp->count);
3851 for (i = 0; i < n; i++)
3853 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3857 vam->retval = retval;
3858 vam->result_ready = 1;
3862 vl_api_one_ndp_bd_get_reply_t_handler_json
3863 (vl_api_one_ndp_bd_get_reply_t * mp)
3865 vat_main_t *vam = &vat_main;
3866 vat_json_node_t root;
3868 int retval = clib_net_to_host_u32 (mp->retval);
3873 n = clib_net_to_host_u32 (mp->count);
3874 vat_json_init_array (&root);
3876 for (i = 0; i < n; i++)
3878 vat_json_array_add_uint (&root,
3879 clib_net_to_host_u32 (mp->bridge_domains[i]));
3882 vat_json_print (vam->ofp, &root);
3883 vat_json_free (&root);
3886 vam->retval = retval;
3887 vam->result_ready = 1;
3891 vl_api_one_l2_arp_bd_get_reply_t_handler
3892 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3894 vat_main_t *vam = &vat_main;
3896 int retval = clib_net_to_host_u32 (mp->retval);
3901 n = clib_net_to_host_u32 (mp->count);
3903 for (i = 0; i < n; i++)
3905 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3909 vam->retval = retval;
3910 vam->result_ready = 1;
3914 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3915 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3917 vat_main_t *vam = &vat_main;
3918 vat_json_node_t root;
3920 int retval = clib_net_to_host_u32 (mp->retval);
3925 n = clib_net_to_host_u32 (mp->count);
3926 vat_json_init_array (&root);
3928 for (i = 0; i < n; i++)
3930 vat_json_array_add_uint (&root,
3931 clib_net_to_host_u32 (mp->bridge_domains[i]));
3934 vat_json_print (vam->ofp, &root);
3935 vat_json_free (&root);
3938 vam->retval = retval;
3939 vam->result_ready = 1;
3943 vl_api_one_adjacencies_get_reply_t_handler
3944 (vl_api_one_adjacencies_get_reply_t * mp)
3946 vat_main_t *vam = &vat_main;
3948 int retval = clib_net_to_host_u32 (mp->retval);
3949 vl_api_one_adjacency_t *a;
3954 n = clib_net_to_host_u32 (mp->count);
3956 for (i = 0; i < n; i++)
3958 a = &mp->adjacencies[i];
3959 print (vam->ofp, "%U %40U",
3960 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3961 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3965 vam->retval = retval;
3966 vam->result_ready = 1;
3970 vl_api_one_adjacencies_get_reply_t_handler_json
3971 (vl_api_one_adjacencies_get_reply_t * mp)
3974 vat_main_t *vam = &vat_main;
3975 vat_json_node_t *e = 0, root;
3977 int retval = clib_net_to_host_u32 (mp->retval);
3978 vl_api_one_adjacency_t *a;
3983 n = clib_net_to_host_u32 (mp->count);
3984 vat_json_init_array (&root);
3986 for (i = 0; i < n; i++)
3988 e = vat_json_array_add (&root);
3989 a = &mp->adjacencies[i];
3991 vat_json_init_object (e);
3992 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3993 a->leid_prefix_len);
3995 vat_json_object_add_string_copy (e, "leid", s);
3998 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3999 a->reid_prefix_len);
4001 vat_json_object_add_string_copy (e, "reid", s);
4005 vat_json_print (vam->ofp, &root);
4006 vat_json_free (&root);
4009 vam->retval = retval;
4010 vam->result_ready = 1;
4014 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4016 vat_main_t *vam = &vat_main;
4018 print (vam->ofp, "%=20U",
4019 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4024 vl_api_one_map_server_details_t_handler_json
4025 (vl_api_one_map_server_details_t * mp)
4027 vat_main_t *vam = &vat_main;
4028 vat_json_node_t *node = NULL;
4029 struct in6_addr ip6;
4032 if (VAT_JSON_ARRAY != vam->json_tree.type)
4034 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4035 vat_json_init_array (&vam->json_tree);
4037 node = vat_json_array_add (&vam->json_tree);
4039 vat_json_init_object (node);
4042 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4043 vat_json_object_add_ip6 (node, "map-server", ip6);
4047 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4048 vat_json_object_add_ip4 (node, "map-server", ip4);
4053 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4056 vat_main_t *vam = &vat_main;
4058 print (vam->ofp, "%=20U",
4059 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4064 vl_api_one_map_resolver_details_t_handler_json
4065 (vl_api_one_map_resolver_details_t * mp)
4067 vat_main_t *vam = &vat_main;
4068 vat_json_node_t *node = NULL;
4069 struct in6_addr ip6;
4072 if (VAT_JSON_ARRAY != vam->json_tree.type)
4074 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4075 vat_json_init_array (&vam->json_tree);
4077 node = vat_json_array_add (&vam->json_tree);
4079 vat_json_init_object (node);
4082 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4083 vat_json_object_add_ip6 (node, "map resolver", ip6);
4087 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4088 vat_json_object_add_ip4 (node, "map resolver", ip4);
4093 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4095 vat_main_t *vam = &vat_main;
4096 i32 retval = ntohl (mp->retval);
4100 print (vam->ofp, "feature: %s\ngpe: %s",
4101 mp->feature_status ? "enabled" : "disabled",
4102 mp->gpe_status ? "enabled" : "disabled");
4105 vam->retval = retval;
4106 vam->result_ready = 1;
4110 vl_api_show_one_status_reply_t_handler_json
4111 (vl_api_show_one_status_reply_t * mp)
4113 vat_main_t *vam = &vat_main;
4114 vat_json_node_t node;
4115 u8 *gpe_status = NULL;
4116 u8 *feature_status = NULL;
4118 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4119 feature_status = format (0, "%s",
4120 mp->feature_status ? "enabled" : "disabled");
4121 vec_add1 (gpe_status, 0);
4122 vec_add1 (feature_status, 0);
4124 vat_json_init_object (&node);
4125 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4126 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4128 vec_free (gpe_status);
4129 vec_free (feature_status);
4131 vat_json_print (vam->ofp, &node);
4132 vat_json_free (&node);
4134 vam->retval = ntohl (mp->retval);
4135 vam->result_ready = 1;
4139 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4140 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4142 vat_main_t *vam = &vat_main;
4143 i32 retval = ntohl (mp->retval);
4147 print (vam->ofp, "%=20s", mp->locator_set_name);
4150 vam->retval = retval;
4151 vam->result_ready = 1;
4155 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4156 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4158 vat_main_t *vam = &vat_main;
4159 vat_json_node_t *node = NULL;
4161 if (VAT_JSON_ARRAY != vam->json_tree.type)
4163 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4164 vat_json_init_array (&vam->json_tree);
4166 node = vat_json_array_add (&vam->json_tree);
4168 vat_json_init_object (node);
4169 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4171 vat_json_print (vam->ofp, node);
4172 vat_json_free (node);
4174 vam->retval = ntohl (mp->retval);
4175 vam->result_ready = 1;
4179 format_lisp_map_request_mode (u8 * s, va_list * args)
4181 u32 mode = va_arg (*args, u32);
4186 return format (0, "dst-only");
4188 return format (0, "src-dst");
4194 vl_api_show_one_map_request_mode_reply_t_handler
4195 (vl_api_show_one_map_request_mode_reply_t * mp)
4197 vat_main_t *vam = &vat_main;
4198 i32 retval = ntohl (mp->retval);
4202 u32 mode = mp->mode;
4203 print (vam->ofp, "map_request_mode: %U",
4204 format_lisp_map_request_mode, mode);
4207 vam->retval = retval;
4208 vam->result_ready = 1;
4212 vl_api_show_one_map_request_mode_reply_t_handler_json
4213 (vl_api_show_one_map_request_mode_reply_t * mp)
4215 vat_main_t *vam = &vat_main;
4216 vat_json_node_t node;
4221 s = format (0, "%U", format_lisp_map_request_mode, mode);
4224 vat_json_init_object (&node);
4225 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4226 vat_json_print (vam->ofp, &node);
4227 vat_json_free (&node);
4230 vam->retval = ntohl (mp->retval);
4231 vam->result_ready = 1;
4235 vl_api_one_show_xtr_mode_reply_t_handler
4236 (vl_api_one_show_xtr_mode_reply_t * mp)
4238 vat_main_t *vam = &vat_main;
4239 i32 retval = ntohl (mp->retval);
4243 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4246 vam->retval = retval;
4247 vam->result_ready = 1;
4251 vl_api_one_show_xtr_mode_reply_t_handler_json
4252 (vl_api_one_show_xtr_mode_reply_t * mp)
4254 vat_main_t *vam = &vat_main;
4255 vat_json_node_t node;
4258 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4259 vec_add1 (status, 0);
4261 vat_json_init_object (&node);
4262 vat_json_object_add_string_copy (&node, "status", status);
4266 vat_json_print (vam->ofp, &node);
4267 vat_json_free (&node);
4269 vam->retval = ntohl (mp->retval);
4270 vam->result_ready = 1;
4274 vl_api_one_show_pitr_mode_reply_t_handler
4275 (vl_api_one_show_pitr_mode_reply_t * mp)
4277 vat_main_t *vam = &vat_main;
4278 i32 retval = ntohl (mp->retval);
4282 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4285 vam->retval = retval;
4286 vam->result_ready = 1;
4290 vl_api_one_show_pitr_mode_reply_t_handler_json
4291 (vl_api_one_show_pitr_mode_reply_t * mp)
4293 vat_main_t *vam = &vat_main;
4294 vat_json_node_t node;
4297 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4298 vec_add1 (status, 0);
4300 vat_json_init_object (&node);
4301 vat_json_object_add_string_copy (&node, "status", status);
4305 vat_json_print (vam->ofp, &node);
4306 vat_json_free (&node);
4308 vam->retval = ntohl (mp->retval);
4309 vam->result_ready = 1;
4313 vl_api_one_show_petr_mode_reply_t_handler
4314 (vl_api_one_show_petr_mode_reply_t * mp)
4316 vat_main_t *vam = &vat_main;
4317 i32 retval = ntohl (mp->retval);
4321 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4324 vam->retval = retval;
4325 vam->result_ready = 1;
4329 vl_api_one_show_petr_mode_reply_t_handler_json
4330 (vl_api_one_show_petr_mode_reply_t * mp)
4332 vat_main_t *vam = &vat_main;
4333 vat_json_node_t node;
4336 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4337 vec_add1 (status, 0);
4339 vat_json_init_object (&node);
4340 vat_json_object_add_string_copy (&node, "status", status);
4344 vat_json_print (vam->ofp, &node);
4345 vat_json_free (&node);
4347 vam->retval = ntohl (mp->retval);
4348 vam->result_ready = 1;
4352 vl_api_show_one_use_petr_reply_t_handler
4353 (vl_api_show_one_use_petr_reply_t * mp)
4355 vat_main_t *vam = &vat_main;
4356 i32 retval = ntohl (mp->retval);
4360 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4363 print (vam->ofp, "Proxy-ETR address; %U",
4364 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4369 vam->retval = retval;
4370 vam->result_ready = 1;
4374 vl_api_show_one_use_petr_reply_t_handler_json
4375 (vl_api_show_one_use_petr_reply_t * mp)
4377 vat_main_t *vam = &vat_main;
4378 vat_json_node_t node;
4381 struct in6_addr ip6;
4383 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4384 vec_add1 (status, 0);
4386 vat_json_init_object (&node);
4387 vat_json_object_add_string_copy (&node, "status", status);
4392 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4393 vat_json_object_add_ip6 (&node, "address", ip6);
4397 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4398 vat_json_object_add_ip4 (&node, "address", ip4);
4404 vat_json_print (vam->ofp, &node);
4405 vat_json_free (&node);
4407 vam->retval = ntohl (mp->retval);
4408 vam->result_ready = 1;
4412 vl_api_show_one_nsh_mapping_reply_t_handler
4413 (vl_api_show_one_nsh_mapping_reply_t * mp)
4415 vat_main_t *vam = &vat_main;
4416 i32 retval = ntohl (mp->retval);
4420 print (vam->ofp, "%-20s%-16s",
4421 mp->is_set ? "set" : "not-set",
4422 mp->is_set ? (char *) mp->locator_set_name : "");
4425 vam->retval = retval;
4426 vam->result_ready = 1;
4430 vl_api_show_one_nsh_mapping_reply_t_handler_json
4431 (vl_api_show_one_nsh_mapping_reply_t * mp)
4433 vat_main_t *vam = &vat_main;
4434 vat_json_node_t node;
4437 status = format (0, "%s", mp->is_set ? "yes" : "no");
4438 vec_add1 (status, 0);
4440 vat_json_init_object (&node);
4441 vat_json_object_add_string_copy (&node, "is_set", status);
4444 vat_json_object_add_string_copy (&node, "locator_set",
4445 mp->locator_set_name);
4450 vat_json_print (vam->ofp, &node);
4451 vat_json_free (&node);
4453 vam->retval = ntohl (mp->retval);
4454 vam->result_ready = 1;
4458 vl_api_show_one_map_register_ttl_reply_t_handler
4459 (vl_api_show_one_map_register_ttl_reply_t * mp)
4461 vat_main_t *vam = &vat_main;
4462 i32 retval = ntohl (mp->retval);
4464 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4468 print (vam->ofp, "ttl: %u", mp->ttl);
4471 vam->retval = retval;
4472 vam->result_ready = 1;
4476 vl_api_show_one_map_register_ttl_reply_t_handler_json
4477 (vl_api_show_one_map_register_ttl_reply_t * mp)
4479 vat_main_t *vam = &vat_main;
4480 vat_json_node_t node;
4482 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4483 vat_json_init_object (&node);
4484 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4486 vat_json_print (vam->ofp, &node);
4487 vat_json_free (&node);
4489 vam->retval = ntohl (mp->retval);
4490 vam->result_ready = 1;
4494 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4496 vat_main_t *vam = &vat_main;
4497 i32 retval = ntohl (mp->retval);
4501 print (vam->ofp, "%-20s%-16s",
4502 mp->status ? "enabled" : "disabled",
4503 mp->status ? (char *) mp->locator_set_name : "");
4506 vam->retval = retval;
4507 vam->result_ready = 1;
4511 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4513 vat_main_t *vam = &vat_main;
4514 vat_json_node_t node;
4517 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4518 vec_add1 (status, 0);
4520 vat_json_init_object (&node);
4521 vat_json_object_add_string_copy (&node, "status", status);
4524 vat_json_object_add_string_copy (&node, "locator_set",
4525 mp->locator_set_name);
4530 vat_json_print (vam->ofp, &node);
4531 vat_json_free (&node);
4533 vam->retval = ntohl (mp->retval);
4534 vam->result_ready = 1;
4538 format_policer_type (u8 * s, va_list * va)
4540 u32 i = va_arg (*va, u32);
4542 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4543 s = format (s, "1r2c");
4544 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4545 s = format (s, "1r3c");
4546 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4547 s = format (s, "2r3c-2698");
4548 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4549 s = format (s, "2r3c-4115");
4550 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4551 s = format (s, "2r3c-mef5cf1");
4553 s = format (s, "ILLEGAL");
4558 format_policer_rate_type (u8 * s, va_list * va)
4560 u32 i = va_arg (*va, u32);
4562 if (i == SSE2_QOS_RATE_KBPS)
4563 s = format (s, "kbps");
4564 else if (i == SSE2_QOS_RATE_PPS)
4565 s = format (s, "pps");
4567 s = format (s, "ILLEGAL");
4572 format_policer_round_type (u8 * s, va_list * va)
4574 u32 i = va_arg (*va, u32);
4576 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4577 s = format (s, "closest");
4578 else if (i == SSE2_QOS_ROUND_TO_UP)
4579 s = format (s, "up");
4580 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4581 s = format (s, "down");
4583 s = format (s, "ILLEGAL");
4588 format_policer_action_type (u8 * s, va_list * va)
4590 u32 i = va_arg (*va, u32);
4592 if (i == SSE2_QOS_ACTION_DROP)
4593 s = format (s, "drop");
4594 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4595 s = format (s, "transmit");
4596 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4597 s = format (s, "mark-and-transmit");
4599 s = format (s, "ILLEGAL");
4604 format_dscp (u8 * s, va_list * va)
4606 u32 i = va_arg (*va, u32);
4611 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4615 return format (s, "ILLEGAL");
4617 s = format (s, "%s", t);
4622 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4624 vat_main_t *vam = &vat_main;
4625 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4627 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4628 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4630 conform_dscp_str = format (0, "");
4632 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4633 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4635 exceed_dscp_str = format (0, "");
4637 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4638 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4640 violate_dscp_str = format (0, "");
4642 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4643 "rate type %U, round type %U, %s rate, %s color-aware, "
4644 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4645 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4646 "conform action %U%s, exceed action %U%s, violate action %U%s",
4648 format_policer_type, mp->type,
4651 clib_net_to_host_u64 (mp->cb),
4652 clib_net_to_host_u64 (mp->eb),
4653 format_policer_rate_type, mp->rate_type,
4654 format_policer_round_type, mp->round_type,
4655 mp->single_rate ? "single" : "dual",
4656 mp->color_aware ? "is" : "not",
4657 ntohl (mp->cir_tokens_per_period),
4658 ntohl (mp->pir_tokens_per_period),
4660 ntohl (mp->current_limit),
4661 ntohl (mp->current_bucket),
4662 ntohl (mp->extended_limit),
4663 ntohl (mp->extended_bucket),
4664 clib_net_to_host_u64 (mp->last_update_time),
4665 format_policer_action_type, mp->conform_action_type,
4667 format_policer_action_type, mp->exceed_action_type,
4669 format_policer_action_type, mp->violate_action_type,
4672 vec_free (conform_dscp_str);
4673 vec_free (exceed_dscp_str);
4674 vec_free (violate_dscp_str);
4677 static void vl_api_policer_details_t_handler_json
4678 (vl_api_policer_details_t * mp)
4680 vat_main_t *vam = &vat_main;
4681 vat_json_node_t *node;
4682 u8 *rate_type_str, *round_type_str, *type_str;
4683 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4685 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4687 format (0, "%U", format_policer_round_type, mp->round_type);
4688 type_str = format (0, "%U", format_policer_type, mp->type);
4689 conform_action_str = format (0, "%U", format_policer_action_type,
4690 mp->conform_action_type);
4691 exceed_action_str = format (0, "%U", format_policer_action_type,
4692 mp->exceed_action_type);
4693 violate_action_str = format (0, "%U", format_policer_action_type,
4694 mp->violate_action_type);
4696 if (VAT_JSON_ARRAY != vam->json_tree.type)
4698 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4699 vat_json_init_array (&vam->json_tree);
4701 node = vat_json_array_add (&vam->json_tree);
4703 vat_json_init_object (node);
4704 vat_json_object_add_string_copy (node, "name", mp->name);
4705 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4706 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4707 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4708 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4709 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4710 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4711 vat_json_object_add_string_copy (node, "type", type_str);
4712 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4713 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4714 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4715 vat_json_object_add_uint (node, "cir_tokens_per_period",
4716 ntohl (mp->cir_tokens_per_period));
4717 vat_json_object_add_uint (node, "eir_tokens_per_period",
4718 ntohl (mp->pir_tokens_per_period));
4719 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4720 vat_json_object_add_uint (node, "current_bucket",
4721 ntohl (mp->current_bucket));
4722 vat_json_object_add_uint (node, "extended_limit",
4723 ntohl (mp->extended_limit));
4724 vat_json_object_add_uint (node, "extended_bucket",
4725 ntohl (mp->extended_bucket));
4726 vat_json_object_add_uint (node, "last_update_time",
4727 ntohl (mp->last_update_time));
4728 vat_json_object_add_string_copy (node, "conform_action",
4729 conform_action_str);
4730 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4732 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4733 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4734 vec_free (dscp_str);
4736 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4737 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4739 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4740 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4741 vec_free (dscp_str);
4743 vat_json_object_add_string_copy (node, "violate_action",
4744 violate_action_str);
4745 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4747 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4748 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4749 vec_free (dscp_str);
4752 vec_free (rate_type_str);
4753 vec_free (round_type_str);
4754 vec_free (type_str);
4755 vec_free (conform_action_str);
4756 vec_free (exceed_action_str);
4757 vec_free (violate_action_str);
4761 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4764 vat_main_t *vam = &vat_main;
4765 int i, count = ntohl (mp->count);
4768 print (vam->ofp, "classify table ids (%d) : ", count);
4769 for (i = 0; i < count; i++)
4771 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4772 print (vam->ofp, (i < count - 1) ? "," : "");
4774 vam->retval = ntohl (mp->retval);
4775 vam->result_ready = 1;
4779 vl_api_classify_table_ids_reply_t_handler_json
4780 (vl_api_classify_table_ids_reply_t * mp)
4782 vat_main_t *vam = &vat_main;
4783 int i, count = ntohl (mp->count);
4787 vat_json_node_t node;
4789 vat_json_init_object (&node);
4790 for (i = 0; i < count; i++)
4792 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4794 vat_json_print (vam->ofp, &node);
4795 vat_json_free (&node);
4797 vam->retval = ntohl (mp->retval);
4798 vam->result_ready = 1;
4802 vl_api_classify_table_by_interface_reply_t_handler
4803 (vl_api_classify_table_by_interface_reply_t * mp)
4805 vat_main_t *vam = &vat_main;
4808 table_id = ntohl (mp->l2_table_id);
4810 print (vam->ofp, "l2 table id : %d", table_id);
4812 print (vam->ofp, "l2 table id : No input ACL tables configured");
4813 table_id = ntohl (mp->ip4_table_id);
4815 print (vam->ofp, "ip4 table id : %d", table_id);
4817 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4818 table_id = ntohl (mp->ip6_table_id);
4820 print (vam->ofp, "ip6 table id : %d", table_id);
4822 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4823 vam->retval = ntohl (mp->retval);
4824 vam->result_ready = 1;
4828 vl_api_classify_table_by_interface_reply_t_handler_json
4829 (vl_api_classify_table_by_interface_reply_t * mp)
4831 vat_main_t *vam = &vat_main;
4832 vat_json_node_t node;
4834 vat_json_init_object (&node);
4836 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4837 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4838 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4840 vat_json_print (vam->ofp, &node);
4841 vat_json_free (&node);
4843 vam->retval = ntohl (mp->retval);
4844 vam->result_ready = 1;
4847 static void vl_api_policer_add_del_reply_t_handler
4848 (vl_api_policer_add_del_reply_t * mp)
4850 vat_main_t *vam = &vat_main;
4851 i32 retval = ntohl (mp->retval);
4852 if (vam->async_mode)
4854 vam->async_errors += (retval < 0);
4858 vam->retval = retval;
4859 vam->result_ready = 1;
4860 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4862 * Note: this is just barely thread-safe, depends on
4863 * the main thread spinning waiting for an answer...
4865 errmsg ("policer index %d", ntohl (mp->policer_index));
4869 static void vl_api_policer_add_del_reply_t_handler_json
4870 (vl_api_policer_add_del_reply_t * mp)
4872 vat_main_t *vam = &vat_main;
4873 vat_json_node_t node;
4875 vat_json_init_object (&node);
4876 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4877 vat_json_object_add_uint (&node, "policer_index",
4878 ntohl (mp->policer_index));
4880 vat_json_print (vam->ofp, &node);
4881 vat_json_free (&node);
4883 vam->retval = ntohl (mp->retval);
4884 vam->result_ready = 1;
4887 /* Format hex dump. */
4889 format_hex_bytes (u8 * s, va_list * va)
4891 u8 *bytes = va_arg (*va, u8 *);
4892 int n_bytes = va_arg (*va, int);
4895 /* Print short or long form depending on byte count. */
4896 uword short_form = n_bytes <= 32;
4897 u32 indent = format_get_indent (s);
4902 for (i = 0; i < n_bytes; i++)
4904 if (!short_form && (i % 32) == 0)
4905 s = format (s, "%08x: ", i);
4906 s = format (s, "%02x", bytes[i]);
4907 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4908 s = format (s, "\n%U", format_white_space, indent);
4915 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4918 vat_main_t *vam = &vat_main;
4919 i32 retval = ntohl (mp->retval);
4922 print (vam->ofp, "classify table info :");
4923 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4924 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4925 ntohl (mp->miss_next_index));
4926 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4927 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4928 ntohl (mp->match_n_vectors));
4929 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4930 ntohl (mp->mask_length));
4932 vam->retval = retval;
4933 vam->result_ready = 1;
4937 vl_api_classify_table_info_reply_t_handler_json
4938 (vl_api_classify_table_info_reply_t * mp)
4940 vat_main_t *vam = &vat_main;
4941 vat_json_node_t node;
4943 i32 retval = ntohl (mp->retval);
4946 vat_json_init_object (&node);
4948 vat_json_object_add_int (&node, "sessions",
4949 ntohl (mp->active_sessions));
4950 vat_json_object_add_int (&node, "nexttbl",
4951 ntohl (mp->next_table_index));
4952 vat_json_object_add_int (&node, "nextnode",
4953 ntohl (mp->miss_next_index));
4954 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4955 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4956 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4957 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4958 ntohl (mp->mask_length), 0);
4959 vat_json_object_add_string_copy (&node, "mask", s);
4961 vat_json_print (vam->ofp, &node);
4962 vat_json_free (&node);
4964 vam->retval = ntohl (mp->retval);
4965 vam->result_ready = 1;
4969 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4972 vat_main_t *vam = &vat_main;
4974 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4975 ntohl (mp->hit_next_index), ntohl (mp->advance),
4976 ntohl (mp->opaque_index));
4977 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4978 ntohl (mp->match_length));
4982 vl_api_classify_session_details_t_handler_json
4983 (vl_api_classify_session_details_t * mp)
4985 vat_main_t *vam = &vat_main;
4986 vat_json_node_t *node = NULL;
4988 if (VAT_JSON_ARRAY != vam->json_tree.type)
4990 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4991 vat_json_init_array (&vam->json_tree);
4993 node = vat_json_array_add (&vam->json_tree);
4995 vat_json_init_object (node);
4996 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4997 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4998 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5000 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5002 vat_json_object_add_string_copy (node, "match", s);
5005 static void vl_api_pg_create_interface_reply_t_handler
5006 (vl_api_pg_create_interface_reply_t * mp)
5008 vat_main_t *vam = &vat_main;
5010 vam->retval = ntohl (mp->retval);
5011 vam->result_ready = 1;
5014 static void vl_api_pg_create_interface_reply_t_handler_json
5015 (vl_api_pg_create_interface_reply_t * mp)
5017 vat_main_t *vam = &vat_main;
5018 vat_json_node_t node;
5020 i32 retval = ntohl (mp->retval);
5023 vat_json_init_object (&node);
5025 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5027 vat_json_print (vam->ofp, &node);
5028 vat_json_free (&node);
5030 vam->retval = ntohl (mp->retval);
5031 vam->result_ready = 1;
5034 static void vl_api_policer_classify_details_t_handler
5035 (vl_api_policer_classify_details_t * mp)
5037 vat_main_t *vam = &vat_main;
5039 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5040 ntohl (mp->table_index));
5043 static void vl_api_policer_classify_details_t_handler_json
5044 (vl_api_policer_classify_details_t * mp)
5046 vat_main_t *vam = &vat_main;
5047 vat_json_node_t *node;
5049 if (VAT_JSON_ARRAY != vam->json_tree.type)
5051 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5052 vat_json_init_array (&vam->json_tree);
5054 node = vat_json_array_add (&vam->json_tree);
5056 vat_json_init_object (node);
5057 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5058 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5061 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5062 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5064 vat_main_t *vam = &vat_main;
5065 i32 retval = ntohl (mp->retval);
5066 if (vam->async_mode)
5068 vam->async_errors += (retval < 0);
5072 vam->retval = retval;
5073 vam->sw_if_index = ntohl (mp->sw_if_index);
5074 vam->result_ready = 1;
5076 vam->regenerate_interface_table = 1;
5079 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5080 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5082 vat_main_t *vam = &vat_main;
5083 vat_json_node_t node;
5085 vat_json_init_object (&node);
5086 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5087 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5089 vat_json_print (vam->ofp, &node);
5090 vat_json_free (&node);
5092 vam->retval = ntohl (mp->retval);
5093 vam->result_ready = 1;
5096 static void vl_api_flow_classify_details_t_handler
5097 (vl_api_flow_classify_details_t * mp)
5099 vat_main_t *vam = &vat_main;
5101 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5102 ntohl (mp->table_index));
5105 static void vl_api_flow_classify_details_t_handler_json
5106 (vl_api_flow_classify_details_t * mp)
5108 vat_main_t *vam = &vat_main;
5109 vat_json_node_t *node;
5111 if (VAT_JSON_ARRAY != vam->json_tree.type)
5113 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5114 vat_json_init_array (&vam->json_tree);
5116 node = vat_json_array_add (&vam->json_tree);
5118 vat_json_init_object (node);
5119 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5120 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5123 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5124 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5125 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5126 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5127 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5128 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5129 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5130 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5131 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5132 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5135 * Generate boilerplate reply handlers, which
5136 * dig the return value out of the xxx_reply_t API message,
5137 * stick it into vam->retval, and set vam->result_ready
5139 * Could also do this by pointing N message decode slots at
5140 * a single function, but that could break in subtle ways.
5143 #define foreach_standard_reply_retval_handler \
5144 _(sw_interface_set_flags_reply) \
5145 _(sw_interface_add_del_address_reply) \
5146 _(sw_interface_set_rx_mode_reply) \
5147 _(sw_interface_set_rx_placement_reply) \
5148 _(sw_interface_set_table_reply) \
5149 _(sw_interface_set_mpls_enable_reply) \
5150 _(sw_interface_set_vpath_reply) \
5151 _(sw_interface_set_vxlan_bypass_reply) \
5152 _(sw_interface_set_geneve_bypass_reply) \
5153 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5154 _(sw_interface_set_l2_bridge_reply) \
5155 _(bridge_domain_add_del_reply) \
5156 _(sw_interface_set_l2_xconnect_reply) \
5157 _(l2fib_add_del_reply) \
5158 _(l2fib_flush_int_reply) \
5159 _(l2fib_flush_bd_reply) \
5160 _(ip_add_del_route_reply) \
5161 _(ip_table_add_del_reply) \
5162 _(ip_mroute_add_del_reply) \
5163 _(mpls_route_add_del_reply) \
5164 _(mpls_table_add_del_reply) \
5165 _(mpls_ip_bind_unbind_reply) \
5166 _(bier_route_add_del_reply) \
5167 _(bier_table_add_del_reply) \
5168 _(proxy_arp_add_del_reply) \
5169 _(proxy_arp_intfc_enable_disable_reply) \
5170 _(sw_interface_set_unnumbered_reply) \
5171 _(ip_neighbor_add_del_reply) \
5172 _(oam_add_del_reply) \
5173 _(reset_fib_reply) \
5174 _(dhcp_proxy_config_reply) \
5175 _(dhcp_proxy_set_vss_reply) \
5176 _(dhcp_client_config_reply) \
5177 _(set_ip_flow_hash_reply) \
5178 _(sw_interface_ip6_enable_disable_reply) \
5179 _(ip6nd_proxy_add_del_reply) \
5180 _(sw_interface_ip6nd_ra_prefix_reply) \
5181 _(sw_interface_ip6nd_ra_config_reply) \
5182 _(set_arp_neighbor_limit_reply) \
5183 _(l2_patch_add_del_reply) \
5184 _(sr_mpls_policy_add_reply) \
5185 _(sr_mpls_policy_mod_reply) \
5186 _(sr_mpls_policy_del_reply) \
5187 _(sr_policy_add_reply) \
5188 _(sr_policy_mod_reply) \
5189 _(sr_policy_del_reply) \
5190 _(sr_localsid_add_del_reply) \
5191 _(sr_steering_add_del_reply) \
5192 _(classify_add_del_session_reply) \
5193 _(classify_set_interface_ip_table_reply) \
5194 _(classify_set_interface_l2_tables_reply) \
5195 _(l2tpv3_set_tunnel_cookies_reply) \
5196 _(l2tpv3_interface_enable_disable_reply) \
5197 _(l2tpv3_set_lookup_key_reply) \
5198 _(l2_fib_clear_table_reply) \
5199 _(l2_interface_efp_filter_reply) \
5200 _(l2_interface_vlan_tag_rewrite_reply) \
5201 _(modify_vhost_user_if_reply) \
5202 _(delete_vhost_user_if_reply) \
5203 _(ip_probe_neighbor_reply) \
5204 _(ip_scan_neighbor_enable_disable_reply) \
5205 _(want_ip4_arp_events_reply) \
5206 _(want_ip6_nd_events_reply) \
5207 _(want_l2_macs_events_reply) \
5208 _(input_acl_set_interface_reply) \
5209 _(ipsec_spd_add_del_reply) \
5210 _(ipsec_interface_add_del_spd_reply) \
5211 _(ipsec_spd_entry_add_del_reply) \
5212 _(ipsec_sad_entry_add_del_reply) \
5213 _(ipsec_sa_set_key_reply) \
5214 _(ipsec_tunnel_if_add_del_reply) \
5215 _(ipsec_tunnel_if_set_key_reply) \
5216 _(ipsec_tunnel_if_set_sa_reply) \
5217 _(ikev2_profile_add_del_reply) \
5218 _(ikev2_profile_set_auth_reply) \
5219 _(ikev2_profile_set_id_reply) \
5220 _(ikev2_profile_set_ts_reply) \
5221 _(ikev2_set_local_key_reply) \
5222 _(ikev2_set_responder_reply) \
5223 _(ikev2_set_ike_transforms_reply) \
5224 _(ikev2_set_esp_transforms_reply) \
5225 _(ikev2_set_sa_lifetime_reply) \
5226 _(ikev2_initiate_sa_init_reply) \
5227 _(ikev2_initiate_del_ike_sa_reply) \
5228 _(ikev2_initiate_del_child_sa_reply) \
5229 _(ikev2_initiate_rekey_child_sa_reply) \
5230 _(delete_loopback_reply) \
5231 _(bd_ip_mac_add_del_reply) \
5232 _(bd_ip_mac_flush_reply) \
5233 _(want_interface_events_reply) \
5234 _(cop_interface_enable_disable_reply) \
5235 _(cop_whitelist_enable_disable_reply) \
5236 _(sw_interface_clear_stats_reply) \
5237 _(ioam_enable_reply) \
5238 _(ioam_disable_reply) \
5239 _(one_add_del_locator_reply) \
5240 _(one_add_del_local_eid_reply) \
5241 _(one_add_del_remote_mapping_reply) \
5242 _(one_add_del_adjacency_reply) \
5243 _(one_add_del_map_resolver_reply) \
5244 _(one_add_del_map_server_reply) \
5245 _(one_enable_disable_reply) \
5246 _(one_rloc_probe_enable_disable_reply) \
5247 _(one_map_register_enable_disable_reply) \
5248 _(one_map_register_set_ttl_reply) \
5249 _(one_set_transport_protocol_reply) \
5250 _(one_map_register_fallback_threshold_reply) \
5251 _(one_pitr_set_locator_set_reply) \
5252 _(one_map_request_mode_reply) \
5253 _(one_add_del_map_request_itr_rlocs_reply) \
5254 _(one_eid_table_add_del_map_reply) \
5255 _(one_use_petr_reply) \
5256 _(one_stats_enable_disable_reply) \
5257 _(one_add_del_l2_arp_entry_reply) \
5258 _(one_add_del_ndp_entry_reply) \
5259 _(one_stats_flush_reply) \
5260 _(one_enable_disable_xtr_mode_reply) \
5261 _(one_enable_disable_pitr_mode_reply) \
5262 _(one_enable_disable_petr_mode_reply) \
5263 _(gpe_enable_disable_reply) \
5264 _(gpe_set_encap_mode_reply) \
5265 _(gpe_add_del_iface_reply) \
5266 _(gpe_add_del_native_fwd_rpath_reply) \
5267 _(af_packet_delete_reply) \
5268 _(policer_classify_set_interface_reply) \
5269 _(netmap_create_reply) \
5270 _(netmap_delete_reply) \
5271 _(set_ipfix_exporter_reply) \
5272 _(set_ipfix_classify_stream_reply) \
5273 _(ipfix_classify_table_add_del_reply) \
5274 _(flow_classify_set_interface_reply) \
5275 _(sw_interface_span_enable_disable_reply) \
5276 _(pg_capture_reply) \
5277 _(pg_enable_disable_reply) \
5278 _(ip_source_and_port_range_check_add_del_reply) \
5279 _(ip_source_and_port_range_check_interface_add_del_reply)\
5280 _(delete_subif_reply) \
5281 _(l2_interface_pbb_tag_rewrite_reply) \
5283 _(feature_enable_disable_reply) \
5284 _(sw_interface_tag_add_del_reply) \
5285 _(hw_interface_set_mtu_reply) \
5286 _(p2p_ethernet_add_reply) \
5287 _(p2p_ethernet_del_reply) \
5288 _(lldp_config_reply) \
5289 _(sw_interface_set_lldp_reply) \
5290 _(tcp_configure_src_addresses_reply) \
5291 _(dns_enable_disable_reply) \
5292 _(dns_name_server_add_del_reply) \
5293 _(session_rule_add_del_reply) \
5294 _(ip_container_proxy_add_del_reply) \
5295 _(output_acl_set_interface_reply) \
5296 _(qos_record_enable_disable_reply)
5299 static void vl_api_##n##_t_handler \
5300 (vl_api_##n##_t * mp) \
5302 vat_main_t * vam = &vat_main; \
5303 i32 retval = ntohl(mp->retval); \
5304 if (vam->async_mode) { \
5305 vam->async_errors += (retval < 0); \
5307 vam->retval = retval; \
5308 vam->result_ready = 1; \
5311 foreach_standard_reply_retval_handler;
5315 static void vl_api_##n##_t_handler_json \
5316 (vl_api_##n##_t * mp) \
5318 vat_main_t * vam = &vat_main; \
5319 vat_json_node_t node; \
5320 vat_json_init_object(&node); \
5321 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5322 vat_json_print(vam->ofp, &node); \
5323 vam->retval = ntohl(mp->retval); \
5324 vam->result_ready = 1; \
5326 foreach_standard_reply_retval_handler;
5330 * Table of message reply handlers, must include boilerplate handlers
5334 #define foreach_vpe_api_reply_msg \
5335 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5336 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5337 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5338 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5339 _(CONTROL_PING_REPLY, control_ping_reply) \
5340 _(CLI_REPLY, cli_reply) \
5341 _(CLI_INBAND_REPLY, cli_inband_reply) \
5342 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5343 sw_interface_add_del_address_reply) \
5344 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5345 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5346 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5347 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5348 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5349 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5350 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5351 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5352 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5353 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5354 sw_interface_set_l2_xconnect_reply) \
5355 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5356 sw_interface_set_l2_bridge_reply) \
5357 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5358 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5359 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5360 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5361 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5362 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5363 _(L2_FLAGS_REPLY, l2_flags_reply) \
5364 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5365 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5366 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5367 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5368 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5369 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5370 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5371 _(BOND_CREATE_REPLY, bond_create_reply) \
5372 _(BOND_DELETE_REPLY, bond_delete_reply) \
5373 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5374 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5375 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5376 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5377 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5378 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5379 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5380 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5381 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5382 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5383 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5384 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5385 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5386 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5387 proxy_arp_intfc_enable_disable_reply) \
5388 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5389 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5390 sw_interface_set_unnumbered_reply) \
5391 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5392 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5393 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5394 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5395 _(RESET_FIB_REPLY, reset_fib_reply) \
5396 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5397 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5398 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5399 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5400 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5401 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5402 sw_interface_ip6_enable_disable_reply) \
5403 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5404 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5405 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5406 sw_interface_ip6nd_ra_prefix_reply) \
5407 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5408 sw_interface_ip6nd_ra_config_reply) \
5409 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5410 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5411 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5412 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5413 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5414 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5415 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5416 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5417 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5418 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5419 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5420 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5421 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5422 classify_set_interface_ip_table_reply) \
5423 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5424 classify_set_interface_l2_tables_reply) \
5425 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5426 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5427 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5428 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5429 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5430 l2tpv3_interface_enable_disable_reply) \
5431 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5432 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5433 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5434 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5435 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5436 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5437 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5438 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5439 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5440 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5441 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5442 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5443 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5444 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5445 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5446 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5447 _(SHOW_VERSION_REPLY, show_version_reply) \
5448 _(SHOW_THREADS_REPLY, show_threads_reply) \
5449 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5450 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5451 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5452 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5453 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5454 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5455 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5456 _(IP4_ARP_EVENT, ip4_arp_event) \
5457 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5458 _(IP6_ND_EVENT, ip6_nd_event) \
5459 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5460 _(L2_MACS_EVENT, l2_macs_event) \
5461 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5462 _(IP_ADDRESS_DETAILS, ip_address_details) \
5463 _(IP_DETAILS, ip_details) \
5464 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5465 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5466 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5467 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5468 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5469 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5470 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5471 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5472 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5473 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5474 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5475 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5476 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5477 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5478 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5479 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5480 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5481 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5482 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5483 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5484 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5485 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5486 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5487 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5488 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5489 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5490 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5491 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5492 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5493 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5494 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5495 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5496 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5497 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5498 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5499 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5500 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5501 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5502 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5503 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5504 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5505 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5506 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5507 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5508 one_map_register_enable_disable_reply) \
5509 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5510 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5511 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5512 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5513 one_map_register_fallback_threshold_reply) \
5514 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5515 one_rloc_probe_enable_disable_reply) \
5516 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5517 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5518 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5519 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5520 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5521 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5522 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5523 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5524 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5525 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5526 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5527 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5528 _(ONE_STATS_DETAILS, one_stats_details) \
5529 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5530 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5531 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5532 show_one_stats_enable_disable_reply) \
5533 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5534 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5535 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5536 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5537 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5538 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5539 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5540 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5541 one_enable_disable_pitr_mode_reply) \
5542 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5543 one_enable_disable_petr_mode_reply) \
5544 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5545 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5546 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5547 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5548 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5549 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5550 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5551 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5552 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5553 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5554 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5555 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5556 gpe_add_del_native_fwd_rpath_reply) \
5557 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5558 gpe_fwd_entry_path_details) \
5559 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5560 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5561 one_add_del_map_request_itr_rlocs_reply) \
5562 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5563 one_get_map_request_itr_rlocs_reply) \
5564 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5565 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5566 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5567 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5568 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5569 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5570 show_one_map_register_state_reply) \
5571 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5572 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5573 show_one_map_register_fallback_threshold_reply) \
5574 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5575 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5576 _(AF_PACKET_DETAILS, af_packet_details) \
5577 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5578 _(POLICER_DETAILS, policer_details) \
5579 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5580 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5581 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5582 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5583 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5584 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5585 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5586 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5587 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5588 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5589 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5590 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5591 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5592 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5593 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5594 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5595 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5596 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5597 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5598 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5599 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5600 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5601 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5602 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5603 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5604 ip_source_and_port_range_check_add_del_reply) \
5605 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5606 ip_source_and_port_range_check_interface_add_del_reply) \
5607 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5608 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5609 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5610 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5611 _(SET_PUNT_REPLY, set_punt_reply) \
5612 _(IP_FIB_DETAILS, ip_fib_details) \
5613 _(IP6_FIB_DETAILS, ip6_fib_details) \
5614 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5615 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5616 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5617 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5618 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5619 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5620 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5621 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5622 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5623 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5624 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5625 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5626 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5627 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5628 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5629 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5630 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5631 _(SESSION_RULES_DETAILS, session_rules_details) \
5632 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5633 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5634 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5636 #define foreach_standalone_reply_msg \
5637 _(SW_INTERFACE_EVENT, sw_interface_event)
5645 #define STR_VTR_OP_CASE(op) \
5646 case L2_VTR_ ## op: \
5650 str_vtr_op (u32 vtr_op)
5654 STR_VTR_OP_CASE (DISABLED);
5655 STR_VTR_OP_CASE (PUSH_1);
5656 STR_VTR_OP_CASE (PUSH_2);
5657 STR_VTR_OP_CASE (POP_1);
5658 STR_VTR_OP_CASE (POP_2);
5659 STR_VTR_OP_CASE (TRANSLATE_1_1);
5660 STR_VTR_OP_CASE (TRANSLATE_1_2);
5661 STR_VTR_OP_CASE (TRANSLATE_2_1);
5662 STR_VTR_OP_CASE (TRANSLATE_2_2);
5669 dump_sub_interface_table (vat_main_t * vam)
5671 const sw_interface_subif_t *sub = NULL;
5673 if (vam->json_output)
5676 ("JSON output supported only for VPE API calls and dump_stats_table");
5681 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5682 "Interface", "sw_if_index",
5683 "sub id", "dot1ad", "tags", "outer id",
5684 "inner id", "exact", "default", "outer any", "inner any");
5686 vec_foreach (sub, vam->sw_if_subif_table)
5689 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5690 sub->interface_name,
5692 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5693 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5694 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5695 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5696 if (sub->vtr_op != L2_VTR_DISABLED)
5699 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5700 "tag1: %d tag2: %d ]",
5701 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5702 sub->vtr_tag1, sub->vtr_tag2);
5710 name_sort_cmp (void *a1, void *a2)
5712 name_sort_t *n1 = a1;
5713 name_sort_t *n2 = a2;
5715 return strcmp ((char *) n1->name, (char *) n2->name);
5719 dump_interface_table (vat_main_t * vam)
5722 name_sort_t *nses = 0, *ns;
5724 if (vam->json_output)
5727 ("JSON output supported only for VPE API calls and dump_stats_table");
5732 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5734 vec_add2 (nses, ns, 1);
5735 ns->name = (u8 *)(p->key);
5736 ns->value = (u32) p->value[0];
5740 vec_sort_with_function (nses, name_sort_cmp);
5742 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5743 vec_foreach (ns, nses)
5745 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5752 dump_ip_table (vat_main_t * vam, int is_ipv6)
5754 const ip_details_t *det = NULL;
5755 const ip_address_details_t *address = NULL;
5758 print (vam->ofp, "%-12s", "sw_if_index");
5760 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5767 print (vam->ofp, "%-12d", i);
5768 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5773 vec_foreach (address, det->addr)
5777 is_ipv6 ? format_ip6_address : format_ip4_address,
5778 address->ip, address->prefix_length);
5786 dump_ipv4_table (vat_main_t * vam)
5788 if (vam->json_output)
5791 ("JSON output supported only for VPE API calls and dump_stats_table");
5795 return dump_ip_table (vam, 0);
5799 dump_ipv6_table (vat_main_t * vam)
5801 if (vam->json_output)
5804 ("JSON output supported only for VPE API calls and dump_stats_table");
5808 return dump_ip_table (vam, 1);
5812 * Pass CLI buffers directly in the CLI_INBAND API message,
5813 * instead of an additional shared memory area.
5816 exec_inband (vat_main_t * vam)
5818 vl_api_cli_inband_t *mp;
5819 unformat_input_t *i = vam->input;
5822 if (vec_len (i->buffer) == 0)
5825 if (vam->exec_mode == 0 && unformat (i, "mode"))
5830 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5837 * In order for the CLI command to work, it
5838 * must be a vector ending in \n, not a C-string ending
5841 u32 len = vec_len (vam->input->buffer);
5842 M2 (CLI_INBAND, mp, len);
5843 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5847 /* json responses may or may not include a useful reply... */
5848 if (vec_len (vam->cmd_reply))
5849 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5854 exec (vat_main_t * vam)
5856 return exec_inband (vam);
5860 api_create_loopback (vat_main_t * vam)
5862 unformat_input_t *i = vam->input;
5863 vl_api_create_loopback_t *mp;
5864 vl_api_create_loopback_instance_t *mp_lbi;
5867 u8 is_specified = 0;
5868 u32 user_instance = 0;
5871 clib_memset (mac_address, 0, sizeof (mac_address));
5873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5875 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5877 if (unformat (i, "instance %d", &user_instance))
5885 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5886 mp_lbi->is_specified = is_specified;
5888 mp_lbi->user_instance = htonl (user_instance);
5890 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5895 /* Construct the API message */
5896 M (CREATE_LOOPBACK, mp);
5898 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5907 api_delete_loopback (vat_main_t * vam)
5909 unformat_input_t *i = vam->input;
5910 vl_api_delete_loopback_t *mp;
5911 u32 sw_if_index = ~0;
5914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5916 if (unformat (i, "sw_if_index %d", &sw_if_index))
5922 if (sw_if_index == ~0)
5924 errmsg ("missing sw_if_index");
5928 /* Construct the API message */
5929 M (DELETE_LOOPBACK, mp);
5930 mp->sw_if_index = ntohl (sw_if_index);
5938 api_want_interface_events (vat_main_t * vam)
5940 unformat_input_t *i = vam->input;
5941 vl_api_want_interface_events_t *mp;
5945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5947 if (unformat (i, "enable"))
5949 else if (unformat (i, "disable"))
5957 errmsg ("missing enable|disable");
5961 M (WANT_INTERFACE_EVENTS, mp);
5962 mp->enable_disable = enable;
5964 vam->interface_event_display = enable;
5972 /* Note: non-static, called once to set up the initial intfc table */
5974 api_sw_interface_dump (vat_main_t * vam)
5976 vl_api_sw_interface_dump_t *mp;
5977 vl_api_control_ping_t *mp_ping;
5979 name_sort_t *nses = 0, *ns;
5980 sw_interface_subif_t *sub = NULL;
5983 /* Toss the old name table */
5985 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5987 vec_add2 (nses, ns, 1);
5988 ns->name = (u8 *)(p->key);
5989 ns->value = (u32) p->value[0];
5993 hash_free (vam->sw_if_index_by_interface_name);
5995 vec_foreach (ns, nses) vec_free (ns->name);
5999 vec_foreach (sub, vam->sw_if_subif_table)
6001 vec_free (sub->interface_name);
6003 vec_free (vam->sw_if_subif_table);
6005 /* recreate the interface name hash table */
6006 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6009 * Ask for all interface names. Otherwise, the epic catalog of
6010 * name filters becomes ridiculously long, and vat ends up needing
6011 * to be taught about new interface types.
6013 M (SW_INTERFACE_DUMP, mp);
6016 /* Use a control ping for synchronization */
6017 MPING (CONTROL_PING, mp_ping);
6025 api_sw_interface_set_flags (vat_main_t * vam)
6027 unformat_input_t *i = vam->input;
6028 vl_api_sw_interface_set_flags_t *mp;
6030 u8 sw_if_index_set = 0;
6034 /* Parse args required to build the message */
6035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6037 if (unformat (i, "admin-up"))
6039 else if (unformat (i, "admin-down"))
6042 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6043 sw_if_index_set = 1;
6044 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6045 sw_if_index_set = 1;
6050 if (sw_if_index_set == 0)
6052 errmsg ("missing interface name or sw_if_index");
6056 /* Construct the API message */
6057 M (SW_INTERFACE_SET_FLAGS, mp);
6058 mp->sw_if_index = ntohl (sw_if_index);
6059 mp->admin_up_down = admin_up;
6064 /* Wait for a reply, return the good/bad news... */
6070 api_sw_interface_set_rx_mode (vat_main_t * vam)
6072 unformat_input_t *i = vam->input;
6073 vl_api_sw_interface_set_rx_mode_t *mp;
6075 u8 sw_if_index_set = 0;
6077 u8 queue_id_valid = 0;
6079 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6081 /* Parse args required to build the message */
6082 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6084 if (unformat (i, "queue %d", &queue_id))
6086 else if (unformat (i, "polling"))
6087 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6088 else if (unformat (i, "interrupt"))
6089 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6090 else if (unformat (i, "adaptive"))
6091 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6093 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6094 sw_if_index_set = 1;
6095 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6096 sw_if_index_set = 1;
6101 if (sw_if_index_set == 0)
6103 errmsg ("missing interface name or sw_if_index");
6106 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6108 errmsg ("missing rx-mode");
6112 /* Construct the API message */
6113 M (SW_INTERFACE_SET_RX_MODE, mp);
6114 mp->sw_if_index = ntohl (sw_if_index);
6116 mp->queue_id_valid = queue_id_valid;
6117 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6122 /* Wait for a reply, return the good/bad news... */
6128 api_sw_interface_set_rx_placement (vat_main_t * vam)
6130 unformat_input_t *i = vam->input;
6131 vl_api_sw_interface_set_rx_placement_t *mp;
6133 u8 sw_if_index_set = 0;
6136 u32 queue_id, thread_index;
6138 /* Parse args required to build the message */
6139 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6141 if (unformat (i, "queue %d", &queue_id))
6143 else if (unformat (i, "main"))
6145 else if (unformat (i, "worker %d", &thread_index))
6148 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6149 sw_if_index_set = 1;
6150 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6151 sw_if_index_set = 1;
6156 if (sw_if_index_set == 0)
6158 errmsg ("missing interface name or sw_if_index");
6164 /* Construct the API message */
6165 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6166 mp->sw_if_index = ntohl (sw_if_index);
6167 mp->worker_id = ntohl (thread_index);
6168 mp->queue_id = ntohl (queue_id);
6169 mp->is_main = is_main;
6173 /* Wait for a reply, return the good/bad news... */
6178 static void vl_api_sw_interface_rx_placement_details_t_handler
6179 (vl_api_sw_interface_rx_placement_details_t * mp)
6181 vat_main_t *vam = &vat_main;
6182 u32 worker_id = ntohl (mp->worker_id);
6185 "\n%-11d %-11s %-6d %-5d %-9s",
6186 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6187 worker_id, ntohl (mp->queue_id),
6189 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6192 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6193 (vl_api_sw_interface_rx_placement_details_t * mp)
6195 vat_main_t *vam = &vat_main;
6196 vat_json_node_t *node = NULL;
6198 if (VAT_JSON_ARRAY != vam->json_tree.type)
6200 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6201 vat_json_init_array (&vam->json_tree);
6203 node = vat_json_array_add (&vam->json_tree);
6205 vat_json_init_object (node);
6206 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6207 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6208 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6209 vat_json_object_add_uint (node, "mode", mp->mode);
6213 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6215 unformat_input_t *i = vam->input;
6216 vl_api_sw_interface_rx_placement_dump_t *mp;
6217 vl_api_control_ping_t *mp_ping;
6220 u8 sw_if_index_set = 0;
6222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6224 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6226 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6233 "\n%-11s %-11s %-6s %-5s %-4s",
6234 "sw_if_index", "main/worker", "thread", "queue", "mode");
6236 /* Dump Interface rx placement */
6237 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6239 if (sw_if_index_set)
6240 mp->sw_if_index = htonl (sw_if_index);
6242 mp->sw_if_index = ~0;
6246 /* Use a control ping for synchronization */
6247 MPING (CONTROL_PING, mp_ping);
6255 api_sw_interface_clear_stats (vat_main_t * vam)
6257 unformat_input_t *i = vam->input;
6258 vl_api_sw_interface_clear_stats_t *mp;
6260 u8 sw_if_index_set = 0;
6263 /* Parse args required to build the message */
6264 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6266 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6267 sw_if_index_set = 1;
6268 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6269 sw_if_index_set = 1;
6274 /* Construct the API message */
6275 M (SW_INTERFACE_CLEAR_STATS, mp);
6277 if (sw_if_index_set == 1)
6278 mp->sw_if_index = ntohl (sw_if_index);
6280 mp->sw_if_index = ~0;
6285 /* Wait for a reply, return the good/bad news... */
6291 api_sw_interface_add_del_address (vat_main_t * vam)
6293 unformat_input_t *i = vam->input;
6294 vl_api_sw_interface_add_del_address_t *mp;
6296 u8 sw_if_index_set = 0;
6297 u8 is_add = 1, del_all = 0;
6298 u32 address_length = 0;
6299 u8 v4_address_set = 0;
6300 u8 v6_address_set = 0;
6301 ip4_address_t v4address;
6302 ip6_address_t v6address;
6305 /* Parse args required to build the message */
6306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6308 if (unformat (i, "del-all"))
6310 else if (unformat (i, "del"))
6313 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6314 sw_if_index_set = 1;
6315 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6316 sw_if_index_set = 1;
6317 else if (unformat (i, "%U/%d",
6318 unformat_ip4_address, &v4address, &address_length))
6320 else if (unformat (i, "%U/%d",
6321 unformat_ip6_address, &v6address, &address_length))
6327 if (sw_if_index_set == 0)
6329 errmsg ("missing interface name or sw_if_index");
6332 if (v4_address_set && v6_address_set)
6334 errmsg ("both v4 and v6 addresses set");
6337 if (!v4_address_set && !v6_address_set && !del_all)
6339 errmsg ("no addresses set");
6343 /* Construct the API message */
6344 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6346 mp->sw_if_index = ntohl (sw_if_index);
6347 mp->is_add = is_add;
6348 mp->del_all = del_all;
6352 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6356 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6358 mp->address_length = address_length;
6363 /* Wait for a reply, return good/bad news */
6369 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6371 unformat_input_t *i = vam->input;
6372 vl_api_sw_interface_set_mpls_enable_t *mp;
6374 u8 sw_if_index_set = 0;
6378 /* Parse args required to build the message */
6379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6381 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6382 sw_if_index_set = 1;
6383 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6384 sw_if_index_set = 1;
6385 else if (unformat (i, "disable"))
6387 else if (unformat (i, "dis"))
6393 if (sw_if_index_set == 0)
6395 errmsg ("missing interface name or sw_if_index");
6399 /* Construct the API message */
6400 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6402 mp->sw_if_index = ntohl (sw_if_index);
6403 mp->enable = enable;
6408 /* Wait for a reply... */
6414 api_sw_interface_set_table (vat_main_t * vam)
6416 unformat_input_t *i = vam->input;
6417 vl_api_sw_interface_set_table_t *mp;
6418 u32 sw_if_index, vrf_id = 0;
6419 u8 sw_if_index_set = 0;
6423 /* Parse args required to build the message */
6424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6426 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6427 sw_if_index_set = 1;
6428 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6429 sw_if_index_set = 1;
6430 else if (unformat (i, "vrf %d", &vrf_id))
6432 else if (unformat (i, "ipv6"))
6438 if (sw_if_index_set == 0)
6440 errmsg ("missing interface name or sw_if_index");
6444 /* Construct the API message */
6445 M (SW_INTERFACE_SET_TABLE, mp);
6447 mp->sw_if_index = ntohl (sw_if_index);
6448 mp->is_ipv6 = is_ipv6;
6449 mp->vrf_id = ntohl (vrf_id);
6454 /* Wait for a reply... */
6459 static void vl_api_sw_interface_get_table_reply_t_handler
6460 (vl_api_sw_interface_get_table_reply_t * mp)
6462 vat_main_t *vam = &vat_main;
6464 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6466 vam->retval = ntohl (mp->retval);
6467 vam->result_ready = 1;
6471 static void vl_api_sw_interface_get_table_reply_t_handler_json
6472 (vl_api_sw_interface_get_table_reply_t * mp)
6474 vat_main_t *vam = &vat_main;
6475 vat_json_node_t node;
6477 vat_json_init_object (&node);
6478 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6479 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6481 vat_json_print (vam->ofp, &node);
6482 vat_json_free (&node);
6484 vam->retval = ntohl (mp->retval);
6485 vam->result_ready = 1;
6489 api_sw_interface_get_table (vat_main_t * vam)
6491 unformat_input_t *i = vam->input;
6492 vl_api_sw_interface_get_table_t *mp;
6494 u8 sw_if_index_set = 0;
6498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6500 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6501 sw_if_index_set = 1;
6502 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6503 sw_if_index_set = 1;
6504 else if (unformat (i, "ipv6"))
6510 if (sw_if_index_set == 0)
6512 errmsg ("missing interface name or sw_if_index");
6516 M (SW_INTERFACE_GET_TABLE, mp);
6517 mp->sw_if_index = htonl (sw_if_index);
6518 mp->is_ipv6 = is_ipv6;
6526 api_sw_interface_set_vpath (vat_main_t * vam)
6528 unformat_input_t *i = vam->input;
6529 vl_api_sw_interface_set_vpath_t *mp;
6530 u32 sw_if_index = 0;
6531 u8 sw_if_index_set = 0;
6535 /* Parse args required to build the message */
6536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6538 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6539 sw_if_index_set = 1;
6540 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6541 sw_if_index_set = 1;
6542 else if (unformat (i, "enable"))
6544 else if (unformat (i, "disable"))
6550 if (sw_if_index_set == 0)
6552 errmsg ("missing interface name or sw_if_index");
6556 /* Construct the API message */
6557 M (SW_INTERFACE_SET_VPATH, mp);
6559 mp->sw_if_index = ntohl (sw_if_index);
6560 mp->enable = is_enable;
6565 /* Wait for a reply... */
6571 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6573 unformat_input_t *i = vam->input;
6574 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6575 u32 sw_if_index = 0;
6576 u8 sw_if_index_set = 0;
6581 /* Parse args required to build the message */
6582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6584 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6585 sw_if_index_set = 1;
6586 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6587 sw_if_index_set = 1;
6588 else if (unformat (i, "enable"))
6590 else if (unformat (i, "disable"))
6592 else if (unformat (i, "ip4"))
6594 else if (unformat (i, "ip6"))
6600 if (sw_if_index_set == 0)
6602 errmsg ("missing interface name or sw_if_index");
6606 /* Construct the API message */
6607 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6609 mp->sw_if_index = ntohl (sw_if_index);
6610 mp->enable = is_enable;
6611 mp->is_ipv6 = is_ipv6;
6616 /* Wait for a reply... */
6622 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6624 unformat_input_t *i = vam->input;
6625 vl_api_sw_interface_set_geneve_bypass_t *mp;
6626 u32 sw_if_index = 0;
6627 u8 sw_if_index_set = 0;
6632 /* Parse args required to build the message */
6633 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6635 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6636 sw_if_index_set = 1;
6637 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6638 sw_if_index_set = 1;
6639 else if (unformat (i, "enable"))
6641 else if (unformat (i, "disable"))
6643 else if (unformat (i, "ip4"))
6645 else if (unformat (i, "ip6"))
6651 if (sw_if_index_set == 0)
6653 errmsg ("missing interface name or sw_if_index");
6657 /* Construct the API message */
6658 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6660 mp->sw_if_index = ntohl (sw_if_index);
6661 mp->enable = is_enable;
6662 mp->is_ipv6 = is_ipv6;
6667 /* Wait for a reply... */
6673 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6675 unformat_input_t *i = vam->input;
6676 vl_api_sw_interface_set_l2_xconnect_t *mp;
6678 u8 rx_sw_if_index_set = 0;
6680 u8 tx_sw_if_index_set = 0;
6684 /* Parse args required to build the message */
6685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6687 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6688 rx_sw_if_index_set = 1;
6689 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6690 tx_sw_if_index_set = 1;
6691 else if (unformat (i, "rx"))
6693 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6695 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6697 rx_sw_if_index_set = 1;
6702 else if (unformat (i, "tx"))
6704 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6706 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6708 tx_sw_if_index_set = 1;
6713 else if (unformat (i, "enable"))
6715 else if (unformat (i, "disable"))
6721 if (rx_sw_if_index_set == 0)
6723 errmsg ("missing rx interface name or rx_sw_if_index");
6727 if (enable && (tx_sw_if_index_set == 0))
6729 errmsg ("missing tx interface name or tx_sw_if_index");
6733 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6735 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6736 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6737 mp->enable = enable;
6745 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6747 unformat_input_t *i = vam->input;
6748 vl_api_sw_interface_set_l2_bridge_t *mp;
6749 vl_api_l2_port_type_t port_type;
6751 u8 rx_sw_if_index_set = 0;
6758 port_type = L2_API_PORT_TYPE_NORMAL;
6760 /* Parse args required to build the message */
6761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6763 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6764 rx_sw_if_index_set = 1;
6765 else if (unformat (i, "bd_id %d", &bd_id))
6769 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6770 rx_sw_if_index_set = 1;
6771 else if (unformat (i, "shg %d", &shg))
6773 else if (unformat (i, "bvi"))
6774 port_type = L2_API_PORT_TYPE_BVI;
6775 else if (unformat (i, "uu-fwd"))
6776 port_type = L2_API_PORT_TYPE_UU_FWD;
6777 else if (unformat (i, "enable"))
6779 else if (unformat (i, "disable"))
6785 if (rx_sw_if_index_set == 0)
6787 errmsg ("missing rx interface name or sw_if_index");
6791 if (enable && (bd_id_set == 0))
6793 errmsg ("missing bridge domain");
6797 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6799 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6800 mp->bd_id = ntohl (bd_id);
6802 mp->port_type = ntohl (port_type);
6803 mp->enable = enable;
6811 api_bridge_domain_dump (vat_main_t * vam)
6813 unformat_input_t *i = vam->input;
6814 vl_api_bridge_domain_dump_t *mp;
6815 vl_api_control_ping_t *mp_ping;
6819 /* Parse args required to build the message */
6820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6822 if (unformat (i, "bd_id %d", &bd_id))
6828 M (BRIDGE_DOMAIN_DUMP, mp);
6829 mp->bd_id = ntohl (bd_id);
6832 /* Use a control ping for synchronization */
6833 MPING (CONTROL_PING, mp_ping);
6841 api_bridge_domain_add_del (vat_main_t * vam)
6843 unformat_input_t *i = vam->input;
6844 vl_api_bridge_domain_add_del_t *mp;
6847 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6852 /* Parse args required to build the message */
6853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6855 if (unformat (i, "bd_id %d", &bd_id))
6857 else if (unformat (i, "flood %d", &flood))
6859 else if (unformat (i, "uu-flood %d", &uu_flood))
6861 else if (unformat (i, "forward %d", &forward))
6863 else if (unformat (i, "learn %d", &learn))
6865 else if (unformat (i, "arp-term %d", &arp_term))
6867 else if (unformat (i, "mac-age %d", &mac_age))
6869 else if (unformat (i, "bd-tag %s", &bd_tag))
6871 else if (unformat (i, "del"))
6874 flood = uu_flood = forward = learn = 0;
6882 errmsg ("missing bridge domain");
6889 errmsg ("mac age must be less than 256 ");
6894 if ((bd_tag) && (vec_len (bd_tag) > 63))
6896 errmsg ("bd-tag cannot be longer than 63");
6901 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6903 mp->bd_id = ntohl (bd_id);
6905 mp->uu_flood = uu_flood;
6906 mp->forward = forward;
6908 mp->arp_term = arp_term;
6909 mp->is_add = is_add;
6910 mp->mac_age = (u8) mac_age;
6913 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6914 mp->bd_tag[vec_len (bd_tag)] = 0;
6925 api_l2fib_flush_bd (vat_main_t * vam)
6927 unformat_input_t *i = vam->input;
6928 vl_api_l2fib_flush_bd_t *mp;
6932 /* Parse args required to build the message */
6933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6935 if (unformat (i, "bd_id %d", &bd_id));
6942 errmsg ("missing bridge domain");
6946 M (L2FIB_FLUSH_BD, mp);
6948 mp->bd_id = htonl (bd_id);
6956 api_l2fib_flush_int (vat_main_t * vam)
6958 unformat_input_t *i = vam->input;
6959 vl_api_l2fib_flush_int_t *mp;
6960 u32 sw_if_index = ~0;
6963 /* Parse args required to build the message */
6964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6966 if (unformat (i, "sw_if_index %d", &sw_if_index));
6968 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6973 if (sw_if_index == ~0)
6975 errmsg ("missing interface name or sw_if_index");
6979 M (L2FIB_FLUSH_INT, mp);
6981 mp->sw_if_index = ntohl (sw_if_index);
6989 api_l2fib_add_del (vat_main_t * vam)
6991 unformat_input_t *i = vam->input;
6992 vl_api_l2fib_add_del_t *mp;
6998 u32 sw_if_index = 0;
6999 u8 sw_if_index_set = 0;
7008 /* Parse args required to build the message */
7009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7011 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7013 else if (unformat (i, "bd_id %d", &bd_id))
7015 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7016 sw_if_index_set = 1;
7017 else if (unformat (i, "sw_if"))
7019 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7022 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7023 sw_if_index_set = 1;
7028 else if (unformat (i, "static"))
7030 else if (unformat (i, "filter"))
7035 else if (unformat (i, "bvi"))
7040 else if (unformat (i, "del"))
7042 else if (unformat (i, "count %d", &count))
7050 errmsg ("missing mac address");
7056 errmsg ("missing bridge domain");
7060 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7062 errmsg ("missing interface name or sw_if_index");
7068 /* Turn on async mode */
7069 vam->async_mode = 1;
7070 vam->async_errors = 0;
7071 before = vat_time_now (vam);
7074 for (j = 0; j < count; j++)
7076 M (L2FIB_ADD_DEL, mp);
7078 clib_memcpy (mp->mac, mac, 6);
7079 mp->bd_id = ntohl (bd_id);
7080 mp->is_add = is_add;
7081 mp->sw_if_index = ntohl (sw_if_index);
7085 mp->static_mac = static_mac;
7086 mp->filter_mac = filter_mac;
7087 mp->bvi_mac = bvi_mac;
7089 increment_mac_address (mac);
7096 vl_api_control_ping_t *mp_ping;
7099 /* Shut off async mode */
7100 vam->async_mode = 0;
7102 MPING (CONTROL_PING, mp_ping);
7105 timeout = vat_time_now (vam) + 1.0;
7106 while (vat_time_now (vam) < timeout)
7107 if (vam->result_ready == 1)
7112 if (vam->retval == -99)
7115 if (vam->async_errors > 0)
7117 errmsg ("%d asynchronous errors", vam->async_errors);
7120 vam->async_errors = 0;
7121 after = vat_time_now (vam);
7123 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7124 count, after - before, count / (after - before));
7130 /* Wait for a reply... */
7134 /* Return the good/bad news */
7135 return (vam->retval);
7139 api_bridge_domain_set_mac_age (vat_main_t * vam)
7141 unformat_input_t *i = vam->input;
7142 vl_api_bridge_domain_set_mac_age_t *mp;
7147 /* Parse args required to build the message */
7148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7150 if (unformat (i, "bd_id %d", &bd_id));
7151 else if (unformat (i, "mac-age %d", &mac_age));
7158 errmsg ("missing bridge domain");
7164 errmsg ("mac age must be less than 256 ");
7168 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7170 mp->bd_id = htonl (bd_id);
7171 mp->mac_age = (u8) mac_age;
7179 api_l2_flags (vat_main_t * vam)
7181 unformat_input_t *i = vam->input;
7182 vl_api_l2_flags_t *mp;
7185 u8 sw_if_index_set = 0;
7189 /* Parse args required to build the message */
7190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7192 if (unformat (i, "sw_if_index %d", &sw_if_index))
7193 sw_if_index_set = 1;
7194 else if (unformat (i, "sw_if"))
7196 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7199 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7200 sw_if_index_set = 1;
7205 else if (unformat (i, "learn"))
7207 else if (unformat (i, "forward"))
7209 else if (unformat (i, "flood"))
7211 else if (unformat (i, "uu-flood"))
7212 flags |= L2_UU_FLOOD;
7213 else if (unformat (i, "arp-term"))
7214 flags |= L2_ARP_TERM;
7215 else if (unformat (i, "off"))
7217 else if (unformat (i, "disable"))
7223 if (sw_if_index_set == 0)
7225 errmsg ("missing interface name or sw_if_index");
7231 mp->sw_if_index = ntohl (sw_if_index);
7232 mp->feature_bitmap = ntohl (flags);
7233 mp->is_set = is_set;
7241 api_bridge_flags (vat_main_t * vam)
7243 unformat_input_t *i = vam->input;
7244 vl_api_bridge_flags_t *mp;
7248 bd_flags_t flags = 0;
7251 /* Parse args required to build the message */
7252 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7254 if (unformat (i, "bd_id %d", &bd_id))
7256 else if (unformat (i, "learn"))
7257 flags |= BRIDGE_API_FLAG_LEARN;
7258 else if (unformat (i, "forward"))
7259 flags |= BRIDGE_API_FLAG_FWD;
7260 else if (unformat (i, "flood"))
7261 flags |= BRIDGE_API_FLAG_FLOOD;
7262 else if (unformat (i, "uu-flood"))
7263 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7264 else if (unformat (i, "arp-term"))
7265 flags |= BRIDGE_API_FLAG_ARP_TERM;
7266 else if (unformat (i, "off"))
7268 else if (unformat (i, "disable"))
7276 errmsg ("missing bridge domain");
7280 M (BRIDGE_FLAGS, mp);
7282 mp->bd_id = ntohl (bd_id);
7283 mp->flags = ntohl (flags);
7284 mp->is_set = is_set;
7292 api_bd_ip_mac_add_del (vat_main_t * vam)
7294 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7295 vl_api_mac_address_t mac = { 0 };
7296 unformat_input_t *i = vam->input;
7297 vl_api_bd_ip_mac_add_del_t *mp;
7309 /* Parse args required to build the message */
7310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7312 if (unformat (i, "bd_id %d", &bd_id))
7316 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7320 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7324 else if (unformat (i, "del"))
7332 errmsg ("missing bridge domain");
7335 else if (ip_set == 0)
7337 errmsg ("missing IP address");
7340 else if (mac_set == 0)
7342 errmsg ("missing MAC address");
7346 M (BD_IP_MAC_ADD_DEL, mp);
7348 mp->bd_id = ntohl (bd_id);
7349 mp->is_add = is_add;
7351 clib_memcpy (&mp->ip, &ip, sizeof (ip));
7352 clib_memcpy (&mp->mac, &mac, sizeof (mac));
7360 api_bd_ip_mac_flush (vat_main_t * vam)
7362 unformat_input_t *i = vam->input;
7363 vl_api_bd_ip_mac_flush_t *mp;
7368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7370 if (unformat (i, "bd_id %d", &bd_id))
7380 errmsg ("missing bridge domain");
7384 M (BD_IP_MAC_FLUSH, mp);
7386 mp->bd_id = ntohl (bd_id);
7393 static void vl_api_bd_ip_mac_details_t_handler
7394 (vl_api_bd_ip_mac_details_t * mp)
7396 vat_main_t *vam = &vat_main;
7401 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7404 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7407 "\n%-5d %-7s %-20U %-30s",
7408 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7409 format_ethernet_address, mp->mac_address, ip);
7414 static void vl_api_bd_ip_mac_details_t_handler_json
7415 (vl_api_bd_ip_mac_details_t * mp)
7417 vat_main_t *vam = &vat_main;
7418 vat_json_node_t *node = NULL;
7420 if (VAT_JSON_ARRAY != vam->json_tree.type)
7422 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7423 vat_json_init_array (&vam->json_tree);
7425 node = vat_json_array_add (&vam->json_tree);
7427 vat_json_init_object (node);
7428 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7429 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7430 vat_json_object_add_string_copy (node, "mac_address",
7431 format (0, "%U", format_ethernet_address,
7437 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7440 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7441 vat_json_object_add_string_copy (node, "ip_address", ip);
7446 api_bd_ip_mac_dump (vat_main_t * vam)
7448 unformat_input_t *i = vam->input;
7449 vl_api_bd_ip_mac_dump_t *mp;
7450 vl_api_control_ping_t *mp_ping;
7455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7457 if (unformat (i, "bd_id %d", &bd_id))
7466 "\n%-5s %-7s %-20s %-30s",
7467 "bd_id", "is_ipv6", "mac_address", "ip_address");
7469 /* Dump Bridge Domain Ip to Mac entries */
7470 M (BD_IP_MAC_DUMP, mp);
7473 mp->bd_id = htonl (bd_id);
7479 /* Use a control ping for synchronization */
7480 MPING (CONTROL_PING, mp_ping);
7488 api_tap_create_v2 (vat_main_t * vam)
7490 unformat_input_t *i = vam->input;
7491 vl_api_tap_create_v2_t *mp;
7495 u8 *host_if_name = 0;
7497 u8 host_mac_addr[6];
7498 u8 host_mac_addr_set = 0;
7499 u8 *host_bridge = 0;
7500 ip4_address_t host_ip4_addr;
7501 ip4_address_t host_ip4_gw;
7502 u8 host_ip4_gw_set = 0;
7503 u32 host_ip4_prefix_len = 0;
7504 ip6_address_t host_ip6_addr;
7505 ip6_address_t host_ip6_gw;
7506 u8 host_ip6_gw_set = 0;
7507 u32 host_ip6_prefix_len = 0;
7509 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7511 clib_memset (mac_address, 0, sizeof (mac_address));
7513 /* Parse args required to build the message */
7514 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7516 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7520 else if (unformat (i, "id %u", &id))
7522 else if (unformat (i, "host-if-name %s", &host_if_name))
7524 else if (unformat (i, "host-ns %s", &host_ns))
7526 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7528 host_mac_addr_set = 1;
7529 else if (unformat (i, "host-bridge %s", &host_bridge))
7531 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7532 &host_ip4_addr, &host_ip4_prefix_len))
7534 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7535 &host_ip6_addr, &host_ip6_prefix_len))
7537 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7539 host_ip4_gw_set = 1;
7540 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7542 host_ip6_gw_set = 1;
7543 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7545 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7551 if (vec_len (host_if_name) > 63)
7553 errmsg ("tap name too long. ");
7556 if (vec_len (host_ns) > 63)
7558 errmsg ("host name space too long. ");
7561 if (vec_len (host_bridge) > 63)
7563 errmsg ("host bridge name too long. ");
7566 if (host_ip4_prefix_len > 32)
7568 errmsg ("host ip4 prefix length not valid. ");
7571 if (host_ip6_prefix_len > 128)
7573 errmsg ("host ip6 prefix length not valid. ");
7576 if (!is_pow2 (rx_ring_sz))
7578 errmsg ("rx ring size must be power of 2. ");
7581 if (rx_ring_sz > 32768)
7583 errmsg ("rx ring size must be 32768 or lower. ");
7586 if (!is_pow2 (tx_ring_sz))
7588 errmsg ("tx ring size must be power of 2. ");
7591 if (tx_ring_sz > 32768)
7593 errmsg ("tx ring size must be 32768 or lower. ");
7597 /* Construct the API message */
7598 M (TAP_CREATE_V2, mp);
7600 mp->use_random_mac = random_mac;
7602 mp->id = ntohl (id);
7603 mp->host_namespace_set = host_ns != 0;
7604 mp->host_bridge_set = host_bridge != 0;
7605 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7606 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7607 mp->rx_ring_sz = ntohs (rx_ring_sz);
7608 mp->tx_ring_sz = ntohs (tx_ring_sz);
7610 if (random_mac == 0)
7611 clib_memcpy (mp->mac_address, mac_address, 6);
7612 if (host_mac_addr_set)
7613 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7615 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7617 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7619 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7620 if (host_ip4_prefix_len)
7621 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7622 if (host_ip6_prefix_len)
7623 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7624 if (host_ip4_gw_set)
7625 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7626 if (host_ip6_gw_set)
7627 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7630 vec_free (host_if_name);
7631 vec_free (host_bridge);
7636 /* Wait for a reply... */
7642 api_tap_delete_v2 (vat_main_t * vam)
7644 unformat_input_t *i = vam->input;
7645 vl_api_tap_delete_v2_t *mp;
7646 u32 sw_if_index = ~0;
7647 u8 sw_if_index_set = 0;
7650 /* Parse args required to build the message */
7651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7653 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7654 sw_if_index_set = 1;
7655 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7656 sw_if_index_set = 1;
7661 if (sw_if_index_set == 0)
7663 errmsg ("missing vpp interface name. ");
7667 /* Construct the API message */
7668 M (TAP_DELETE_V2, mp);
7670 mp->sw_if_index = ntohl (sw_if_index);
7675 /* Wait for a reply... */
7681 unformat_pci_addr (unformat_input_t * input, va_list * args)
7690 addr = va_arg (*args, struct pci_addr_t *);
7693 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7696 addr->domain = x[0];
7699 addr->function = x[3];
7705 api_virtio_pci_create (vat_main_t * vam)
7707 unformat_input_t *i = vam->input;
7708 vl_api_virtio_pci_create_t *mp;
7712 u64 features = (u64) ~ (0ULL);
7713 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7716 clib_memset (mac_address, 0, sizeof (mac_address));
7718 /* Parse args required to build the message */
7719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7721 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7725 else if (unformat (i, "pci-addr %U", unformat_pci_addr, &pci_addr))
7727 else if (unformat (i, "features 0x%llx", &features))
7729 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
7731 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
7739 errmsg ("pci address must be non zero. ");
7742 if (!is_pow2 (rx_ring_sz))
7744 errmsg ("rx ring size must be power of 2. ");
7747 if (rx_ring_sz > 32768)
7749 errmsg ("rx ring size must be 32768 or lower. ");
7752 if (!is_pow2 (tx_ring_sz))
7754 errmsg ("tx ring size must be power of 2. ");
7757 if (tx_ring_sz > 32768)
7759 errmsg ("tx ring size must be 32768 or lower. ");
7763 /* Construct the API message */
7764 M (VIRTIO_PCI_CREATE, mp);
7766 mp->use_random_mac = random_mac;
7768 mp->pci_addr = htonl (pci_addr);
7769 mp->features = clib_host_to_net_u64 (features);
7770 mp->rx_ring_sz = htons (rx_ring_sz);
7771 mp->tx_ring_sz = htons (tx_ring_sz);
7773 if (random_mac == 0)
7774 clib_memcpy (mp->mac_address, mac_address, 6);
7779 /* Wait for a reply... */
7785 api_virtio_pci_delete (vat_main_t * vam)
7787 unformat_input_t *i = vam->input;
7788 vl_api_virtio_pci_delete_t *mp;
7789 u32 sw_if_index = ~0;
7790 u8 sw_if_index_set = 0;
7793 /* Parse args required to build the message */
7794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7796 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7797 sw_if_index_set = 1;
7798 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7799 sw_if_index_set = 1;
7804 if (sw_if_index_set == 0)
7806 errmsg ("missing vpp interface name. ");
7810 /* Construct the API message */
7811 M (VIRTIO_PCI_DELETE, mp);
7813 mp->sw_if_index = htonl (sw_if_index);
7818 /* Wait for a reply... */
7824 api_bond_create (vat_main_t * vam)
7826 unformat_input_t *i = vam->input;
7827 vl_api_bond_create_t *mp;
7836 clib_memset (mac_address, 0, sizeof (mac_address));
7839 /* Parse args required to build the message */
7840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7842 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7844 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7845 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7847 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7850 else if (unformat (i, "id %u", &id))
7856 if (mode_is_set == 0)
7858 errmsg ("Missing bond mode. ");
7862 /* Construct the API message */
7863 M (BOND_CREATE, mp);
7865 mp->use_custom_mac = custom_mac;
7869 mp->id = htonl (id);
7872 clib_memcpy (mp->mac_address, mac_address, 6);
7877 /* Wait for a reply... */
7883 api_bond_delete (vat_main_t * vam)
7885 unformat_input_t *i = vam->input;
7886 vl_api_bond_delete_t *mp;
7887 u32 sw_if_index = ~0;
7888 u8 sw_if_index_set = 0;
7891 /* Parse args required to build the message */
7892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7894 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7895 sw_if_index_set = 1;
7896 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7897 sw_if_index_set = 1;
7902 if (sw_if_index_set == 0)
7904 errmsg ("missing vpp interface name. ");
7908 /* Construct the API message */
7909 M (BOND_DELETE, mp);
7911 mp->sw_if_index = ntohl (sw_if_index);
7916 /* Wait for a reply... */
7922 api_bond_enslave (vat_main_t * vam)
7924 unformat_input_t *i = vam->input;
7925 vl_api_bond_enslave_t *mp;
7926 u32 bond_sw_if_index;
7930 u32 bond_sw_if_index_is_set = 0;
7932 u8 sw_if_index_is_set = 0;
7934 /* Parse args required to build the message */
7935 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7937 if (unformat (i, "sw_if_index %d", &sw_if_index))
7938 sw_if_index_is_set = 1;
7939 else if (unformat (i, "bond %u", &bond_sw_if_index))
7940 bond_sw_if_index_is_set = 1;
7941 else if (unformat (i, "passive %d", &is_passive))
7943 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7949 if (bond_sw_if_index_is_set == 0)
7951 errmsg ("Missing bond sw_if_index. ");
7954 if (sw_if_index_is_set == 0)
7956 errmsg ("Missing slave sw_if_index. ");
7960 /* Construct the API message */
7961 M (BOND_ENSLAVE, mp);
7963 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7964 mp->sw_if_index = ntohl (sw_if_index);
7965 mp->is_long_timeout = is_long_timeout;
7966 mp->is_passive = is_passive;
7971 /* Wait for a reply... */
7977 api_bond_detach_slave (vat_main_t * vam)
7979 unformat_input_t *i = vam->input;
7980 vl_api_bond_detach_slave_t *mp;
7981 u32 sw_if_index = ~0;
7982 u8 sw_if_index_set = 0;
7985 /* Parse args required to build the message */
7986 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7988 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7989 sw_if_index_set = 1;
7990 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7991 sw_if_index_set = 1;
7996 if (sw_if_index_set == 0)
7998 errmsg ("missing vpp interface name. ");
8002 /* Construct the API message */
8003 M (BOND_DETACH_SLAVE, mp);
8005 mp->sw_if_index = ntohl (sw_if_index);
8010 /* Wait for a reply... */
8016 api_ip_table_add_del (vat_main_t * vam)
8018 unformat_input_t *i = vam->input;
8019 vl_api_ip_table_add_del_t *mp;
8025 /* Parse args required to build the message */
8026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8028 if (unformat (i, "ipv6"))
8030 else if (unformat (i, "del"))
8032 else if (unformat (i, "add"))
8034 else if (unformat (i, "table %d", &table_id))
8038 clib_warning ("parse error '%U'", format_unformat_error, i);
8045 errmsg ("missing table-ID");
8049 /* Construct the API message */
8050 M (IP_TABLE_ADD_DEL, mp);
8052 mp->table_id = ntohl (table_id);
8053 mp->is_ipv6 = is_ipv6;
8054 mp->is_add = is_add;
8059 /* Wait for a reply... */
8066 api_ip_add_del_route (vat_main_t * vam)
8068 unformat_input_t *i = vam->input;
8069 vl_api_ip_add_del_route_t *mp;
8070 u32 sw_if_index = ~0, vrf_id = 0;
8072 u8 is_local = 0, is_drop = 0;
8073 u8 is_unreach = 0, is_prohibit = 0;
8075 u32 next_hop_weight = 1;
8076 u8 is_multipath = 0;
8078 u8 address_length_set = 0;
8079 u32 next_hop_table_id = 0;
8080 u32 resolve_attempts = 0;
8081 u32 dst_address_length = 0;
8082 u8 next_hop_set = 0;
8083 ip4_address_t v4_dst_address, v4_next_hop_address;
8084 ip6_address_t v6_dst_address, v6_next_hop_address;
8088 u32 random_add_del = 0;
8089 u32 *random_vector = 0;
8091 u32 random_seed = 0xdeaddabe;
8092 u32 classify_table_index = ~0;
8094 u8 resolve_host = 0, resolve_attached = 0;
8095 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8096 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8097 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8099 clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8100 clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8101 /* Parse args required to build the message */
8102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8104 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8106 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8108 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8113 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8118 else if (unformat (i, "/%d", &dst_address_length))
8120 address_length_set = 1;
8123 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8124 &v4_next_hop_address))
8128 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8129 &v6_next_hop_address))
8135 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8139 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8143 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8145 else if (unformat (i, "weight %d", &next_hop_weight))
8147 else if (unformat (i, "drop"))
8151 else if (unformat (i, "null-send-unreach"))
8155 else if (unformat (i, "null-send-prohibit"))
8159 else if (unformat (i, "local"))
8163 else if (unformat (i, "classify %d", &classify_table_index))
8167 else if (unformat (i, "del"))
8169 else if (unformat (i, "add"))
8171 else if (unformat (i, "resolve-via-host"))
8173 else if (unformat (i, "resolve-via-attached"))
8174 resolve_attached = 1;
8175 else if (unformat (i, "multipath"))
8177 else if (unformat (i, "vrf %d", &vrf_id))
8179 else if (unformat (i, "count %d", &count))
8181 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8183 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8185 else if (unformat (i, "out-label %d", &next_hop_out_label))
8187 vl_api_fib_mpls_label_t fib_label = {
8188 .label = ntohl (next_hop_out_label),
8192 vec_add1 (next_hop_out_label_stack, fib_label);
8194 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8196 else if (unformat (i, "random"))
8198 else if (unformat (i, "seed %d", &random_seed))
8202 clib_warning ("parse error '%U'", format_unformat_error, i);
8207 if (!next_hop_set && !is_drop && !is_local &&
8208 !is_classify && !is_unreach && !is_prohibit &&
8209 MPLS_LABEL_INVALID == next_hop_via_label)
8212 ("next hop / local / drop / unreach / prohibit / classify not set");
8216 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8218 errmsg ("next hop and next-hop via label set");
8221 if (address_set == 0)
8223 errmsg ("missing addresses");
8227 if (address_length_set == 0)
8229 errmsg ("missing address length");
8233 /* Generate a pile of unique, random routes */
8236 u32 this_random_address;
8237 random_hash = hash_create (count, sizeof (uword));
8239 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8240 for (j = 0; j <= count; j++)
8244 this_random_address = random_u32 (&random_seed);
8245 this_random_address =
8246 clib_host_to_net_u32 (this_random_address);
8248 while (hash_get (random_hash, this_random_address));
8249 vec_add1 (random_vector, this_random_address);
8250 hash_set (random_hash, this_random_address, 1);
8252 hash_free (random_hash);
8253 v4_dst_address.as_u32 = random_vector[0];
8258 /* Turn on async mode */
8259 vam->async_mode = 1;
8260 vam->async_errors = 0;
8261 before = vat_time_now (vam);
8264 for (j = 0; j < count; j++)
8266 /* Construct the API message */
8267 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8268 vec_len (next_hop_out_label_stack));
8270 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8271 mp->table_id = ntohl (vrf_id);
8273 mp->is_add = is_add;
8274 mp->is_drop = is_drop;
8275 mp->is_unreach = is_unreach;
8276 mp->is_prohibit = is_prohibit;
8277 mp->is_ipv6 = is_ipv6;
8278 mp->is_local = is_local;
8279 mp->is_classify = is_classify;
8280 mp->is_multipath = is_multipath;
8281 mp->is_resolve_host = resolve_host;
8282 mp->is_resolve_attached = resolve_attached;
8283 mp->next_hop_weight = next_hop_weight;
8284 mp->next_hop_preference = 0;
8285 mp->dst_address_length = dst_address_length;
8286 mp->next_hop_table_id = ntohl (next_hop_table_id);
8287 mp->classify_table_index = ntohl (classify_table_index);
8288 mp->next_hop_via_label = ntohl (next_hop_via_label);
8289 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8290 if (0 != mp->next_hop_n_out_labels)
8292 memcpy (mp->next_hop_out_label_stack,
8293 next_hop_out_label_stack,
8294 (vec_len (next_hop_out_label_stack) *
8295 sizeof (vl_api_fib_mpls_label_t)));
8296 vec_free (next_hop_out_label_stack);
8301 clib_memcpy (mp->dst_address, &v6_dst_address,
8302 sizeof (v6_dst_address));
8304 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8305 sizeof (v6_next_hop_address));
8306 increment_v6_address (&v6_dst_address);
8310 clib_memcpy (mp->dst_address, &v4_dst_address,
8311 sizeof (v4_dst_address));
8313 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8314 sizeof (v4_next_hop_address));
8316 v4_dst_address.as_u32 = random_vector[j + 1];
8318 increment_v4_address (&v4_dst_address);
8322 /* If we receive SIGTERM, stop now... */
8327 /* When testing multiple add/del ops, use a control-ping to sync */
8330 vl_api_control_ping_t *mp_ping;
8334 /* Shut off async mode */
8335 vam->async_mode = 0;
8337 MPING (CONTROL_PING, mp_ping);
8340 timeout = vat_time_now (vam) + 1.0;
8341 while (vat_time_now (vam) < timeout)
8342 if (vam->result_ready == 1)
8347 if (vam->retval == -99)
8350 if (vam->async_errors > 0)
8352 errmsg ("%d asynchronous errors", vam->async_errors);
8355 vam->async_errors = 0;
8356 after = vat_time_now (vam);
8358 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8362 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8363 count, after - before, count / (after - before));
8369 /* Wait for a reply... */
8374 /* Return the good/bad news */
8375 return (vam->retval);
8379 api_ip_mroute_add_del (vat_main_t * vam)
8381 unformat_input_t *i = vam->input;
8382 vl_api_ip_mroute_add_del_t *mp;
8383 u32 sw_if_index = ~0, vrf_id = 0;
8388 u32 grp_address_length = 0;
8389 ip4_address_t v4_grp_address, v4_src_address;
8390 ip6_address_t v6_grp_address, v6_src_address;
8391 mfib_itf_flags_t iflags = 0;
8392 mfib_entry_flags_t eflags = 0;
8395 /* Parse args required to build the message */
8396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8398 if (unformat (i, "sw_if_index %d", &sw_if_index))
8400 else if (unformat (i, "%U %U",
8401 unformat_ip4_address, &v4_src_address,
8402 unformat_ip4_address, &v4_grp_address))
8404 grp_address_length = 64;
8408 else if (unformat (i, "%U %U",
8409 unformat_ip6_address, &v6_src_address,
8410 unformat_ip6_address, &v6_grp_address))
8412 grp_address_length = 256;
8416 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8418 clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
8419 grp_address_length = 32;
8423 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8425 clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
8426 grp_address_length = 128;
8430 else if (unformat (i, "/%d", &grp_address_length))
8432 else if (unformat (i, "local"))
8436 else if (unformat (i, "del"))
8438 else if (unformat (i, "add"))
8440 else if (unformat (i, "vrf %d", &vrf_id))
8442 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8444 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8448 clib_warning ("parse error '%U'", format_unformat_error, i);
8453 if (address_set == 0)
8455 errmsg ("missing addresses\n");
8459 /* Construct the API message */
8460 M (IP_MROUTE_ADD_DEL, mp);
8462 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8463 mp->table_id = ntohl (vrf_id);
8465 mp->is_add = is_add;
8466 mp->is_ipv6 = is_ipv6;
8467 mp->is_local = is_local;
8468 mp->itf_flags = ntohl (iflags);
8469 mp->entry_flags = ntohl (eflags);
8470 mp->grp_address_length = grp_address_length;
8471 mp->grp_address_length = ntohs (mp->grp_address_length);
8475 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8476 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8480 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8481 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8487 /* Wait for a reply... */
8493 api_mpls_table_add_del (vat_main_t * vam)
8495 unformat_input_t *i = vam->input;
8496 vl_api_mpls_table_add_del_t *mp;
8501 /* Parse args required to build the message */
8502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8504 if (unformat (i, "table %d", &table_id))
8506 else if (unformat (i, "del"))
8508 else if (unformat (i, "add"))
8512 clib_warning ("parse error '%U'", format_unformat_error, i);
8519 errmsg ("missing table-ID");
8523 /* Construct the API message */
8524 M (MPLS_TABLE_ADD_DEL, mp);
8526 mp->mt_table_id = ntohl (table_id);
8527 mp->mt_is_add = is_add;
8532 /* Wait for a reply... */
8539 api_mpls_route_add_del (vat_main_t * vam)
8541 unformat_input_t *i = vam->input;
8542 vl_api_mpls_route_add_del_t *mp;
8543 u32 sw_if_index = ~0, table_id = 0;
8545 u32 next_hop_weight = 1;
8546 u8 is_multipath = 0;
8547 u32 next_hop_table_id = 0;
8548 u8 next_hop_set = 0;
8549 ip4_address_t v4_next_hop_address = {
8552 ip6_address_t v6_next_hop_address = { {0} };
8556 u32 classify_table_index = ~0;
8558 u8 resolve_host = 0, resolve_attached = 0;
8559 u8 is_interface_rx = 0;
8560 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8561 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8562 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8563 mpls_label_t local_label = MPLS_LABEL_INVALID;
8565 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
8567 /* Parse args required to build the message */
8568 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8570 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8572 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8574 else if (unformat (i, "%d", &local_label))
8576 else if (unformat (i, "eos"))
8578 else if (unformat (i, "non-eos"))
8580 else if (unformat (i, "via %U", unformat_ip4_address,
8581 &v4_next_hop_address))
8584 next_hop_proto = DPO_PROTO_IP4;
8586 else if (unformat (i, "via %U", unformat_ip6_address,
8587 &v6_next_hop_address))
8590 next_hop_proto = DPO_PROTO_IP6;
8592 else if (unformat (i, "weight %d", &next_hop_weight))
8594 else if (unformat (i, "classify %d", &classify_table_index))
8598 else if (unformat (i, "del"))
8600 else if (unformat (i, "add"))
8602 else if (unformat (i, "resolve-via-host"))
8604 else if (unformat (i, "resolve-via-attached"))
8605 resolve_attached = 1;
8606 else if (unformat (i, "multipath"))
8608 else if (unformat (i, "count %d", &count))
8610 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
8613 next_hop_proto = DPO_PROTO_IP4;
8615 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
8618 next_hop_proto = DPO_PROTO_IP6;
8622 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
8626 next_hop_proto = DPO_PROTO_ETHERNET;
8627 is_interface_rx = 1;
8629 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
8632 next_hop_proto = DPO_PROTO_ETHERNET;
8633 is_interface_rx = 1;
8635 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
8637 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8639 else if (unformat (i, "out-label %d", &next_hop_out_label))
8641 vl_api_fib_mpls_label_t fib_label = {
8642 .label = ntohl (next_hop_out_label),
8646 vec_add1 (next_hop_out_label_stack, fib_label);
8650 clib_warning ("parse error '%U'", format_unformat_error, i);
8655 if (!next_hop_set && !is_classify)
8657 errmsg ("next hop / classify not set");
8661 if (MPLS_LABEL_INVALID == local_label)
8663 errmsg ("missing label");
8669 /* Turn on async mode */
8670 vam->async_mode = 1;
8671 vam->async_errors = 0;
8672 before = vat_time_now (vam);
8675 for (j = 0; j < count; j++)
8677 /* Construct the API message */
8678 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
8679 vec_len (next_hop_out_label_stack));
8681 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8682 mp->mr_table_id = ntohl (table_id);
8684 mp->mr_is_add = is_add;
8685 mp->mr_next_hop_proto = next_hop_proto;
8686 mp->mr_is_classify = is_classify;
8687 mp->mr_is_multipath = is_multipath;
8688 mp->mr_is_resolve_host = resolve_host;
8689 mp->mr_is_resolve_attached = resolve_attached;
8690 mp->mr_is_interface_rx = is_interface_rx;
8691 mp->mr_next_hop_weight = next_hop_weight;
8692 mp->mr_next_hop_preference = 0;
8693 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8694 mp->mr_classify_table_index = ntohl (classify_table_index);
8695 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8696 mp->mr_label = ntohl (local_label);
8697 mp->mr_eos = is_eos;
8699 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8700 if (0 != mp->mr_next_hop_n_out_labels)
8702 memcpy (mp->mr_next_hop_out_label_stack,
8703 next_hop_out_label_stack,
8704 vec_len (next_hop_out_label_stack) *
8705 sizeof (vl_api_fib_mpls_label_t));
8706 vec_free (next_hop_out_label_stack);
8711 if (DPO_PROTO_IP4 == next_hop_proto)
8713 clib_memcpy (mp->mr_next_hop,
8714 &v4_next_hop_address,
8715 sizeof (v4_next_hop_address));
8717 else if (DPO_PROTO_IP6 == next_hop_proto)
8720 clib_memcpy (mp->mr_next_hop,
8721 &v6_next_hop_address,
8722 sizeof (v6_next_hop_address));
8729 /* If we receive SIGTERM, stop now... */
8734 /* When testing multiple add/del ops, use a control-ping to sync */
8737 vl_api_control_ping_t *mp_ping;
8741 /* Shut off async mode */
8742 vam->async_mode = 0;
8744 MPING (CONTROL_PING, mp_ping);
8747 timeout = vat_time_now (vam) + 1.0;
8748 while (vat_time_now (vam) < timeout)
8749 if (vam->result_ready == 1)
8754 if (vam->retval == -99)
8757 if (vam->async_errors > 0)
8759 errmsg ("%d asynchronous errors", vam->async_errors);
8762 vam->async_errors = 0;
8763 after = vat_time_now (vam);
8765 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8769 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8770 count, after - before, count / (after - before));
8776 /* Wait for a reply... */
8781 /* Return the good/bad news */
8782 return (vam->retval);
8786 api_mpls_ip_bind_unbind (vat_main_t * vam)
8788 unformat_input_t *i = vam->input;
8789 vl_api_mpls_ip_bind_unbind_t *mp;
8790 u32 ip_table_id = 0;
8793 ip4_address_t v4_address;
8794 ip6_address_t v6_address;
8797 mpls_label_t local_label = MPLS_LABEL_INVALID;
8800 /* Parse args required to build the message */
8801 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8803 if (unformat (i, "%U/%d", unformat_ip4_address,
8804 &v4_address, &address_length))
8809 else if (unformat (i, "%U/%d", unformat_ip6_address,
8810 &v6_address, &address_length))
8815 else if (unformat (i, "%d", &local_label))
8817 else if (unformat (i, "table-id %d", &ip_table_id))
8819 else if (unformat (i, "unbind"))
8821 else if (unformat (i, "bind"))
8825 clib_warning ("parse error '%U'", format_unformat_error, i);
8832 errmsg ("IP address not set");
8836 if (MPLS_LABEL_INVALID == local_label)
8838 errmsg ("missing label");
8842 /* Construct the API message */
8843 M (MPLS_IP_BIND_UNBIND, mp);
8845 mp->mb_is_bind = is_bind;
8846 mp->mb_is_ip4 = is_ip4;
8847 mp->mb_ip_table_id = ntohl (ip_table_id);
8848 mp->mb_mpls_table_id = 0;
8849 mp->mb_label = ntohl (local_label);
8850 mp->mb_address_length = address_length;
8853 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8855 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8860 /* Wait for a reply... */
8866 api_sr_mpls_policy_add (vat_main_t * vam)
8868 unformat_input_t *i = vam->input;
8869 vl_api_sr_mpls_policy_add_t *mp;
8875 u32 *segments = NULL;
8878 /* Parse args required to build the message */
8879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8881 if (unformat (i, "bsid %d", &bsid))
8883 else if (unformat (i, "weight %d", &weight))
8885 else if (unformat (i, "spray"))
8887 else if (unformat (i, "next %d", &sid))
8890 vec_add1 (segments, htonl (sid));
8894 clib_warning ("parse error '%U'", format_unformat_error, i);
8901 errmsg ("bsid not set");
8905 if (n_segments == 0)
8907 errmsg ("no sid in segment stack");
8911 /* Construct the API message */
8912 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8914 mp->bsid = htonl (bsid);
8915 mp->weight = htonl (weight);
8917 mp->n_segments = n_segments;
8918 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8919 vec_free (segments);
8924 /* Wait for a reply... */
8930 api_sr_mpls_policy_del (vat_main_t * vam)
8932 unformat_input_t *i = vam->input;
8933 vl_api_sr_mpls_policy_del_t *mp;
8937 /* Parse args required to build the message */
8938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8940 if (unformat (i, "bsid %d", &bsid))
8944 clib_warning ("parse error '%U'", format_unformat_error, i);
8951 errmsg ("bsid not set");
8955 /* Construct the API message */
8956 M (SR_MPLS_POLICY_DEL, mp);
8958 mp->bsid = htonl (bsid);
8963 /* Wait for a reply... */
8969 api_bier_table_add_del (vat_main_t * vam)
8971 unformat_input_t *i = vam->input;
8972 vl_api_bier_table_add_del_t *mp;
8974 u32 set = 0, sub_domain = 0, hdr_len = 3;
8975 mpls_label_t local_label = MPLS_LABEL_INVALID;
8978 /* Parse args required to build the message */
8979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8981 if (unformat (i, "sub-domain %d", &sub_domain))
8983 else if (unformat (i, "set %d", &set))
8985 else if (unformat (i, "label %d", &local_label))
8987 else if (unformat (i, "hdr-len %d", &hdr_len))
8989 else if (unformat (i, "add"))
8991 else if (unformat (i, "del"))
8995 clib_warning ("parse error '%U'", format_unformat_error, i);
9000 if (MPLS_LABEL_INVALID == local_label)
9002 errmsg ("missing label\n");
9006 /* Construct the API message */
9007 M (BIER_TABLE_ADD_DEL, mp);
9009 mp->bt_is_add = is_add;
9010 mp->bt_label = ntohl (local_label);
9011 mp->bt_tbl_id.bt_set = set;
9012 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9013 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9018 /* Wait for a reply... */
9025 api_bier_route_add_del (vat_main_t * vam)
9027 unformat_input_t *i = vam->input;
9028 vl_api_bier_route_add_del_t *mp;
9030 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9031 ip4_address_t v4_next_hop_address;
9032 ip6_address_t v6_next_hop_address;
9033 u8 next_hop_set = 0;
9034 u8 next_hop_proto_is_ip4 = 1;
9035 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9038 /* Parse args required to build the message */
9039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9041 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9043 next_hop_proto_is_ip4 = 1;
9046 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9048 next_hop_proto_is_ip4 = 0;
9051 if (unformat (i, "sub-domain %d", &sub_domain))
9053 else if (unformat (i, "set %d", &set))
9055 else if (unformat (i, "hdr-len %d", &hdr_len))
9057 else if (unformat (i, "bp %d", &bp))
9059 else if (unformat (i, "add"))
9061 else if (unformat (i, "del"))
9063 else if (unformat (i, "out-label %d", &next_hop_out_label))
9067 clib_warning ("parse error '%U'", format_unformat_error, i);
9072 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9074 errmsg ("next hop / label set\n");
9079 errmsg ("bit=position not set\n");
9083 /* Construct the API message */
9084 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9086 mp->br_is_add = is_add;
9087 mp->br_tbl_id.bt_set = set;
9088 mp->br_tbl_id.bt_sub_domain = sub_domain;
9089 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9090 mp->br_bp = ntohs (bp);
9092 mp->br_paths[0].n_labels = 1;
9093 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9094 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9096 if (next_hop_proto_is_ip4)
9098 clib_memcpy (mp->br_paths[0].next_hop,
9099 &v4_next_hop_address, sizeof (v4_next_hop_address));
9103 clib_memcpy (mp->br_paths[0].next_hop,
9104 &v6_next_hop_address, sizeof (v6_next_hop_address));
9110 /* Wait for a reply... */
9117 api_proxy_arp_add_del (vat_main_t * vam)
9119 unformat_input_t *i = vam->input;
9120 vl_api_proxy_arp_add_del_t *mp;
9123 vl_api_ip4_address_t lo, hi;
9127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9129 if (unformat (i, "vrf %d", &vrf_id))
9131 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
9132 unformat_vl_api_ip4_address, &hi))
9134 else if (unformat (i, "del"))
9138 clib_warning ("parse error '%U'", format_unformat_error, i);
9145 errmsg ("address range not set");
9149 M (PROXY_ARP_ADD_DEL, mp);
9151 mp->proxy.table_id = ntohl (vrf_id);
9152 mp->is_add = is_add;
9153 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
9154 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
9162 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9164 unformat_input_t *i = vam->input;
9165 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9168 u8 sw_if_index_set = 0;
9171 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9173 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9174 sw_if_index_set = 1;
9175 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9176 sw_if_index_set = 1;
9177 else if (unformat (i, "enable"))
9179 else if (unformat (i, "disable"))
9183 clib_warning ("parse error '%U'", format_unformat_error, i);
9188 if (sw_if_index_set == 0)
9190 errmsg ("missing interface name or sw_if_index");
9194 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9196 mp->sw_if_index = ntohl (sw_if_index);
9197 mp->enable_disable = enable;
9205 api_mpls_tunnel_add_del (vat_main_t * vam)
9207 unformat_input_t *i = vam->input;
9208 vl_api_mpls_tunnel_add_del_t *mp;
9212 u32 sw_if_index = ~0;
9213 u32 next_hop_sw_if_index = ~0;
9214 u32 next_hop_proto_is_ip4 = 1;
9216 u32 next_hop_table_id = 0;
9217 ip4_address_t v4_next_hop_address = {
9220 ip6_address_t v6_next_hop_address = { {0} };
9221 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9222 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9223 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9226 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9228 if (unformat (i, "add"))
9232 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9234 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9236 else if (unformat (i, "via %U",
9237 unformat_ip4_address, &v4_next_hop_address))
9239 next_hop_proto_is_ip4 = 1;
9241 else if (unformat (i, "via %U",
9242 unformat_ip6_address, &v6_next_hop_address))
9244 next_hop_proto_is_ip4 = 0;
9246 else if (unformat (i, "via-label %d", &next_hop_via_label))
9250 (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
9252 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9254 else if (unformat (i, "l2-only"))
9256 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9258 else if (unformat (i, "out-label %d", &next_hop_out_label))
9260 vl_api_fib_mpls_label_t fib_label = {
9261 .label = ntohl (next_hop_out_label),
9265 vec_add1 (next_hop_out_label_stack, fib_label);
9269 clib_warning ("parse error '%U'", format_unformat_error, i);
9274 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9275 vec_len (next_hop_out_label_stack));
9277 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9278 mp->mt_sw_if_index = ntohl (sw_if_index);
9279 mp->mt_is_add = is_add;
9280 mp->mt_l2_only = l2_only;
9281 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9282 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9283 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9284 mp->mt_next_hop_weight = 1;
9285 mp->mt_next_hop_preference = 0;
9287 mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9289 if (0 != mp->mt_next_hop_n_out_labels)
9291 clib_memcpy (mp->mt_next_hop_out_label_stack,
9292 next_hop_out_label_stack,
9293 (vec_len (next_hop_out_label_stack) *
9294 sizeof (vl_api_fib_mpls_label_t)));
9295 vec_free (next_hop_out_label_stack);
9298 if (next_hop_proto_is_ip4)
9300 clib_memcpy (mp->mt_next_hop,
9301 &v4_next_hop_address, sizeof (v4_next_hop_address));
9305 clib_memcpy (mp->mt_next_hop,
9306 &v6_next_hop_address, sizeof (v6_next_hop_address));
9315 api_sw_interface_set_unnumbered (vat_main_t * vam)
9317 unformat_input_t *i = vam->input;
9318 vl_api_sw_interface_set_unnumbered_t *mp;
9320 u32 unnum_sw_index = ~0;
9322 u8 sw_if_index_set = 0;
9325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9327 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9328 sw_if_index_set = 1;
9329 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9330 sw_if_index_set = 1;
9331 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9333 else if (unformat (i, "del"))
9337 clib_warning ("parse error '%U'", format_unformat_error, i);
9342 if (sw_if_index_set == 0)
9344 errmsg ("missing interface name or sw_if_index");
9348 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9350 mp->sw_if_index = ntohl (sw_if_index);
9351 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9352 mp->is_add = is_add;
9360 api_ip_neighbor_add_del (vat_main_t * vam)
9362 vl_api_mac_address_t mac_address;
9363 unformat_input_t *i = vam->input;
9364 vl_api_ip_neighbor_add_del_t *mp;
9365 vl_api_address_t ip_address;
9367 u8 sw_if_index_set = 0;
9372 ip_neighbor_flags_t flags;
9374 flags = IP_NEIGHBOR_FLAG_NONE;
9375 clib_memset (&ip_address, 0, sizeof (ip_address));
9376 clib_memset (&mac_address, 0, sizeof (mac_address));
9377 /* Parse args required to build the message */
9378 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9380 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9384 else if (unformat (i, "del"))
9387 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9388 sw_if_index_set = 1;
9389 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9390 sw_if_index_set = 1;
9391 else if (unformat (i, "static"))
9392 flags |= IP_NEIGHBOR_FLAG_STATIC;
9393 else if (unformat (i, "no-fib-entry"))
9394 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9395 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9399 clib_warning ("parse error '%U'", format_unformat_error, i);
9404 if (sw_if_index_set == 0)
9406 errmsg ("missing interface name or sw_if_index");
9411 errmsg ("no address set");
9415 /* Construct the API message */
9416 M (IP_NEIGHBOR_ADD_DEL, mp);
9418 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9419 mp->is_add = is_add;
9420 mp->neighbor.flags = htonl (flags);
9422 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9423 sizeof (mac_address));
9425 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9430 /* Wait for a reply, return good/bad news */
9436 api_create_vlan_subif (vat_main_t * vam)
9438 unformat_input_t *i = vam->input;
9439 vl_api_create_vlan_subif_t *mp;
9441 u8 sw_if_index_set = 0;
9446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9448 if (unformat (i, "sw_if_index %d", &sw_if_index))
9449 sw_if_index_set = 1;
9451 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9452 sw_if_index_set = 1;
9453 else if (unformat (i, "vlan %d", &vlan_id))
9457 clib_warning ("parse error '%U'", format_unformat_error, i);
9462 if (sw_if_index_set == 0)
9464 errmsg ("missing interface name or sw_if_index");
9468 if (vlan_id_set == 0)
9470 errmsg ("missing vlan_id");
9473 M (CREATE_VLAN_SUBIF, mp);
9475 mp->sw_if_index = ntohl (sw_if_index);
9476 mp->vlan_id = ntohl (vlan_id);
9483 #define foreach_create_subif_bit \
9490 _(outer_vlan_id_any) \
9491 _(inner_vlan_id_any)
9494 api_create_subif (vat_main_t * vam)
9496 unformat_input_t *i = vam->input;
9497 vl_api_create_subif_t *mp;
9499 u8 sw_if_index_set = 0;
9506 u32 exact_match = 0;
9507 u32 default_sub = 0;
9508 u32 outer_vlan_id_any = 0;
9509 u32 inner_vlan_id_any = 0;
9511 u16 outer_vlan_id = 0;
9512 u16 inner_vlan_id = 0;
9515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9517 if (unformat (i, "sw_if_index %d", &sw_if_index))
9518 sw_if_index_set = 1;
9520 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9521 sw_if_index_set = 1;
9522 else if (unformat (i, "sub_id %d", &sub_id))
9524 else if (unformat (i, "outer_vlan_id %d", &tmp))
9525 outer_vlan_id = tmp;
9526 else if (unformat (i, "inner_vlan_id %d", &tmp))
9527 inner_vlan_id = tmp;
9529 #define _(a) else if (unformat (i, #a)) a = 1 ;
9530 foreach_create_subif_bit
9534 clib_warning ("parse error '%U'", format_unformat_error, i);
9539 if (sw_if_index_set == 0)
9541 errmsg ("missing interface name or sw_if_index");
9545 if (sub_id_set == 0)
9547 errmsg ("missing sub_id");
9550 M (CREATE_SUBIF, mp);
9552 mp->sw_if_index = ntohl (sw_if_index);
9553 mp->sub_id = ntohl (sub_id);
9555 #define _(a) mp->a = a;
9556 foreach_create_subif_bit;
9559 mp->outer_vlan_id = ntohs (outer_vlan_id);
9560 mp->inner_vlan_id = ntohs (inner_vlan_id);
9568 api_oam_add_del (vat_main_t * vam)
9570 unformat_input_t *i = vam->input;
9571 vl_api_oam_add_del_t *mp;
9574 ip4_address_t src, dst;
9579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9581 if (unformat (i, "vrf %d", &vrf_id))
9583 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9585 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9587 else if (unformat (i, "del"))
9591 clib_warning ("parse error '%U'", format_unformat_error, i);
9598 errmsg ("missing src addr");
9604 errmsg ("missing dst addr");
9608 M (OAM_ADD_DEL, mp);
9610 mp->vrf_id = ntohl (vrf_id);
9611 mp->is_add = is_add;
9612 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9613 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9621 api_reset_fib (vat_main_t * vam)
9623 unformat_input_t *i = vam->input;
9624 vl_api_reset_fib_t *mp;
9630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9632 if (unformat (i, "vrf %d", &vrf_id))
9634 else if (unformat (i, "ipv6"))
9638 clib_warning ("parse error '%U'", format_unformat_error, i);
9643 if (vrf_id_set == 0)
9645 errmsg ("missing vrf id");
9651 mp->vrf_id = ntohl (vrf_id);
9652 mp->is_ipv6 = is_ipv6;
9660 api_dhcp_proxy_config (vat_main_t * vam)
9662 unformat_input_t *i = vam->input;
9663 vl_api_dhcp_proxy_config_t *mp;
9665 u32 server_vrf_id = 0;
9667 u8 v4_address_set = 0;
9668 u8 v6_address_set = 0;
9669 ip4_address_t v4address;
9670 ip6_address_t v6address;
9671 u8 v4_src_address_set = 0;
9672 u8 v6_src_address_set = 0;
9673 ip4_address_t v4srcaddress;
9674 ip6_address_t v6srcaddress;
9677 /* Parse args required to build the message */
9678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9680 if (unformat (i, "del"))
9682 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9684 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9686 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9688 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9690 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9691 v4_src_address_set = 1;
9692 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9693 v6_src_address_set = 1;
9698 if (v4_address_set && v6_address_set)
9700 errmsg ("both v4 and v6 server addresses set");
9703 if (!v4_address_set && !v6_address_set)
9705 errmsg ("no server addresses set");
9709 if (v4_src_address_set && v6_src_address_set)
9711 errmsg ("both v4 and v6 src addresses set");
9714 if (!v4_src_address_set && !v6_src_address_set)
9716 errmsg ("no src addresses set");
9720 if (!(v4_src_address_set && v4_address_set) &&
9721 !(v6_src_address_set && v6_address_set))
9723 errmsg ("no matching server and src addresses set");
9727 /* Construct the API message */
9728 M (DHCP_PROXY_CONFIG, mp);
9730 mp->is_add = is_add;
9731 mp->rx_vrf_id = ntohl (rx_vrf_id);
9732 mp->server_vrf_id = ntohl (server_vrf_id);
9736 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9737 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9741 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9742 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9748 /* Wait for a reply, return good/bad news */
9753 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9754 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9757 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9759 vat_main_t *vam = &vat_main;
9760 u32 i, count = mp->count;
9761 vl_api_dhcp_server_t *s;
9765 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9766 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9767 ntohl (mp->rx_vrf_id),
9768 format_ip6_address, mp->dhcp_src_address,
9769 mp->vss_type, mp->vss_vpn_ascii_id,
9770 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9773 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9774 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9775 ntohl (mp->rx_vrf_id),
9776 format_ip4_address, mp->dhcp_src_address,
9777 mp->vss_type, mp->vss_vpn_ascii_id,
9778 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9780 for (i = 0; i < count; i++)
9782 s = &mp->servers[i];
9786 " Server Table-ID %d, Server Address %U",
9787 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9790 " Server Table-ID %d, Server Address %U",
9791 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9795 static void vl_api_dhcp_proxy_details_t_handler_json
9796 (vl_api_dhcp_proxy_details_t * mp)
9798 vat_main_t *vam = &vat_main;
9799 vat_json_node_t *node = NULL;
9800 u32 i, count = mp->count;
9802 struct in6_addr ip6;
9803 vl_api_dhcp_server_t *s;
9805 if (VAT_JSON_ARRAY != vam->json_tree.type)
9807 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9808 vat_json_init_array (&vam->json_tree);
9810 node = vat_json_array_add (&vam->json_tree);
9812 vat_json_init_object (node);
9813 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9814 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9815 sizeof (mp->vss_type));
9816 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9817 mp->vss_vpn_ascii_id);
9818 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9819 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9823 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9824 vat_json_object_add_ip6 (node, "src_address", ip6);
9828 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9829 vat_json_object_add_ip4 (node, "src_address", ip4);
9832 for (i = 0; i < count; i++)
9834 s = &mp->servers[i];
9836 vat_json_object_add_uint (node, "server-table-id",
9837 ntohl (s->server_vrf_id));
9841 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9842 vat_json_object_add_ip4 (node, "src_address", ip4);
9846 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9847 vat_json_object_add_ip6 (node, "server_address", ip6);
9853 api_dhcp_proxy_dump (vat_main_t * vam)
9855 unformat_input_t *i = vam->input;
9856 vl_api_control_ping_t *mp_ping;
9857 vl_api_dhcp_proxy_dump_t *mp;
9861 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9863 if (unformat (i, "ipv6"))
9867 clib_warning ("parse error '%U'", format_unformat_error, i);
9872 M (DHCP_PROXY_DUMP, mp);
9874 mp->is_ip6 = is_ipv6;
9877 /* Use a control ping for synchronization */
9878 MPING (CONTROL_PING, mp_ping);
9886 api_dhcp_proxy_set_vss (vat_main_t * vam)
9888 unformat_input_t *i = vam->input;
9889 vl_api_dhcp_proxy_set_vss_t *mp;
9893 u8 vss_type = VSS_TYPE_DEFAULT;
9894 u8 *vpn_ascii_id = 0;
9899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9901 if (unformat (i, "tbl_id %d", &tbl_id))
9903 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9904 vss_type = VSS_TYPE_ASCII;
9905 else if (unformat (i, "fib_id %d", &fib_id))
9906 vss_type = VSS_TYPE_VPN_ID;
9907 else if (unformat (i, "oui %d", &oui))
9908 vss_type = VSS_TYPE_VPN_ID;
9909 else if (unformat (i, "ipv6"))
9911 else if (unformat (i, "del"))
9919 errmsg ("missing tbl_id ");
9920 vec_free (vpn_ascii_id);
9924 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9926 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9927 vec_free (vpn_ascii_id);
9931 M (DHCP_PROXY_SET_VSS, mp);
9932 mp->tbl_id = ntohl (tbl_id);
9933 mp->vss_type = vss_type;
9936 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9937 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9939 mp->vpn_index = ntohl (fib_id);
9940 mp->oui = ntohl (oui);
9941 mp->is_ipv6 = is_ipv6;
9942 mp->is_add = is_add;
9947 vec_free (vpn_ascii_id);
9952 api_dhcp_client_config (vat_main_t * vam)
9954 unformat_input_t *i = vam->input;
9955 vl_api_dhcp_client_config_t *mp;
9957 u8 sw_if_index_set = 0;
9960 u8 disable_event = 0;
9963 /* Parse args required to build the message */
9964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9966 if (unformat (i, "del"))
9969 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9970 sw_if_index_set = 1;
9971 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9972 sw_if_index_set = 1;
9973 else if (unformat (i, "hostname %s", &hostname))
9975 else if (unformat (i, "disable_event"))
9981 if (sw_if_index_set == 0)
9983 errmsg ("missing interface name or sw_if_index");
9987 if (vec_len (hostname) > 63)
9989 errmsg ("hostname too long");
9991 vec_add1 (hostname, 0);
9993 /* Construct the API message */
9994 M (DHCP_CLIENT_CONFIG, mp);
9996 mp->is_add = is_add;
9997 mp->client.sw_if_index = htonl (sw_if_index);
9998 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
9999 vec_free (hostname);
10000 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10001 mp->client.pid = htonl (getpid ());
10006 /* Wait for a reply, return good/bad news */
10012 api_set_ip_flow_hash (vat_main_t * vam)
10014 unformat_input_t *i = vam->input;
10015 vl_api_set_ip_flow_hash_t *mp;
10027 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10029 if (unformat (i, "vrf %d", &vrf_id))
10031 else if (unformat (i, "ipv6"))
10033 else if (unformat (i, "src"))
10035 else if (unformat (i, "dst"))
10037 else if (unformat (i, "sport"))
10039 else if (unformat (i, "dport"))
10041 else if (unformat (i, "proto"))
10043 else if (unformat (i, "reverse"))
10048 clib_warning ("parse error '%U'", format_unformat_error, i);
10053 if (vrf_id_set == 0)
10055 errmsg ("missing vrf id");
10059 M (SET_IP_FLOW_HASH, mp);
10065 mp->reverse = reverse;
10066 mp->vrf_id = ntohl (vrf_id);
10067 mp->is_ipv6 = is_ipv6;
10075 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10077 unformat_input_t *i = vam->input;
10078 vl_api_sw_interface_ip6_enable_disable_t *mp;
10080 u8 sw_if_index_set = 0;
10084 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10086 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10087 sw_if_index_set = 1;
10088 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10089 sw_if_index_set = 1;
10090 else if (unformat (i, "enable"))
10092 else if (unformat (i, "disable"))
10096 clib_warning ("parse error '%U'", format_unformat_error, i);
10101 if (sw_if_index_set == 0)
10103 errmsg ("missing interface name or sw_if_index");
10107 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10109 mp->sw_if_index = ntohl (sw_if_index);
10110 mp->enable = enable;
10118 api_ip6nd_proxy_add_del (vat_main_t * vam)
10120 unformat_input_t *i = vam->input;
10121 vl_api_ip6nd_proxy_add_del_t *mp;
10122 u32 sw_if_index = ~0;
10123 u8 v6_address_set = 0;
10124 vl_api_ip6_address_t v6address;
10128 /* Parse args required to build the message */
10129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10131 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10133 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10135 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
10136 v6_address_set = 1;
10137 if (unformat (i, "del"))
10141 clib_warning ("parse error '%U'", format_unformat_error, i);
10146 if (sw_if_index == ~0)
10148 errmsg ("missing interface name or sw_if_index");
10151 if (!v6_address_set)
10153 errmsg ("no address set");
10157 /* Construct the API message */
10158 M (IP6ND_PROXY_ADD_DEL, mp);
10160 mp->is_del = is_del;
10161 mp->sw_if_index = ntohl (sw_if_index);
10162 clib_memcpy (mp->ip, v6address, sizeof (v6address));
10167 /* Wait for a reply, return good/bad news */
10173 api_ip6nd_proxy_dump (vat_main_t * vam)
10175 vl_api_ip6nd_proxy_dump_t *mp;
10176 vl_api_control_ping_t *mp_ping;
10179 M (IP6ND_PROXY_DUMP, mp);
10183 /* Use a control ping for synchronization */
10184 MPING (CONTROL_PING, mp_ping);
10191 static void vl_api_ip6nd_proxy_details_t_handler
10192 (vl_api_ip6nd_proxy_details_t * mp)
10194 vat_main_t *vam = &vat_main;
10196 print (vam->ofp, "host %U sw_if_index %d",
10197 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
10200 static void vl_api_ip6nd_proxy_details_t_handler_json
10201 (vl_api_ip6nd_proxy_details_t * mp)
10203 vat_main_t *vam = &vat_main;
10204 struct in6_addr ip6;
10205 vat_json_node_t *node = NULL;
10207 if (VAT_JSON_ARRAY != vam->json_tree.type)
10209 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10210 vat_json_init_array (&vam->json_tree);
10212 node = vat_json_array_add (&vam->json_tree);
10214 vat_json_init_object (node);
10215 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10217 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
10218 vat_json_object_add_ip6 (node, "host", ip6);
10222 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10224 unformat_input_t *i = vam->input;
10225 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10227 u8 sw_if_index_set = 0;
10228 u32 address_length = 0;
10229 u8 v6_address_set = 0;
10230 vl_api_prefix_t pfx;
10231 u8 use_default = 0;
10232 u8 no_advertise = 0;
10234 u8 no_autoconfig = 0;
10237 u32 val_lifetime = 0;
10238 u32 pref_lifetime = 0;
10241 /* Parse args required to build the message */
10242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10244 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10245 sw_if_index_set = 1;
10246 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10247 sw_if_index_set = 1;
10248 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
10249 v6_address_set = 1;
10250 else if (unformat (i, "val_life %d", &val_lifetime))
10252 else if (unformat (i, "pref_life %d", &pref_lifetime))
10254 else if (unformat (i, "def"))
10256 else if (unformat (i, "noadv"))
10258 else if (unformat (i, "offl"))
10260 else if (unformat (i, "noauto"))
10262 else if (unformat (i, "nolink"))
10264 else if (unformat (i, "isno"))
10268 clib_warning ("parse error '%U'", format_unformat_error, i);
10273 if (sw_if_index_set == 0)
10275 errmsg ("missing interface name or sw_if_index");
10278 if (!v6_address_set)
10280 errmsg ("no address set");
10284 /* Construct the API message */
10285 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10287 mp->sw_if_index = ntohl (sw_if_index);
10288 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
10289 mp->use_default = use_default;
10290 mp->no_advertise = no_advertise;
10291 mp->off_link = off_link;
10292 mp->no_autoconfig = no_autoconfig;
10293 mp->no_onlink = no_onlink;
10295 mp->val_lifetime = ntohl (val_lifetime);
10296 mp->pref_lifetime = ntohl (pref_lifetime);
10301 /* Wait for a reply, return good/bad news */
10307 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10309 unformat_input_t *i = vam->input;
10310 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10312 u8 sw_if_index_set = 0;
10317 u8 send_unicast = 0;
10320 u8 default_router = 0;
10321 u32 max_interval = 0;
10322 u32 min_interval = 0;
10324 u32 initial_count = 0;
10325 u32 initial_interval = 0;
10329 /* Parse args required to build the message */
10330 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10332 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10333 sw_if_index_set = 1;
10334 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10335 sw_if_index_set = 1;
10336 else if (unformat (i, "maxint %d", &max_interval))
10338 else if (unformat (i, "minint %d", &min_interval))
10340 else if (unformat (i, "life %d", &lifetime))
10342 else if (unformat (i, "count %d", &initial_count))
10344 else if (unformat (i, "interval %d", &initial_interval))
10346 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10348 else if (unformat (i, "managed"))
10350 else if (unformat (i, "other"))
10352 else if (unformat (i, "ll"))
10354 else if (unformat (i, "send"))
10356 else if (unformat (i, "cease"))
10358 else if (unformat (i, "isno"))
10360 else if (unformat (i, "def"))
10361 default_router = 1;
10364 clib_warning ("parse error '%U'", format_unformat_error, i);
10369 if (sw_if_index_set == 0)
10371 errmsg ("missing interface name or sw_if_index");
10375 /* Construct the API message */
10376 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10378 mp->sw_if_index = ntohl (sw_if_index);
10379 mp->max_interval = ntohl (max_interval);
10380 mp->min_interval = ntohl (min_interval);
10381 mp->lifetime = ntohl (lifetime);
10382 mp->initial_count = ntohl (initial_count);
10383 mp->initial_interval = ntohl (initial_interval);
10384 mp->suppress = suppress;
10385 mp->managed = managed;
10387 mp->ll_option = ll_option;
10388 mp->send_unicast = send_unicast;
10391 mp->default_router = default_router;
10396 /* Wait for a reply, return good/bad news */
10402 api_set_arp_neighbor_limit (vat_main_t * vam)
10404 unformat_input_t *i = vam->input;
10405 vl_api_set_arp_neighbor_limit_t *mp;
10411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10413 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10415 else if (unformat (i, "ipv6"))
10419 clib_warning ("parse error '%U'", format_unformat_error, i);
10424 if (limit_set == 0)
10426 errmsg ("missing limit value");
10430 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10432 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10433 mp->is_ipv6 = is_ipv6;
10441 api_l2_patch_add_del (vat_main_t * vam)
10443 unformat_input_t *i = vam->input;
10444 vl_api_l2_patch_add_del_t *mp;
10445 u32 rx_sw_if_index;
10446 u8 rx_sw_if_index_set = 0;
10447 u32 tx_sw_if_index;
10448 u8 tx_sw_if_index_set = 0;
10452 /* Parse args required to build the message */
10453 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10455 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10456 rx_sw_if_index_set = 1;
10457 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10458 tx_sw_if_index_set = 1;
10459 else if (unformat (i, "rx"))
10461 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10463 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10465 rx_sw_if_index_set = 1;
10470 else if (unformat (i, "tx"))
10472 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10474 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10476 tx_sw_if_index_set = 1;
10481 else if (unformat (i, "del"))
10487 if (rx_sw_if_index_set == 0)
10489 errmsg ("missing rx interface name or rx_sw_if_index");
10493 if (tx_sw_if_index_set == 0)
10495 errmsg ("missing tx interface name or tx_sw_if_index");
10499 M (L2_PATCH_ADD_DEL, mp);
10501 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10502 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10503 mp->is_add = is_add;
10511 u8 localsid_addr[16];
10520 api_sr_localsid_add_del (vat_main_t * vam)
10522 unformat_input_t *i = vam->input;
10523 vl_api_sr_localsid_add_del_t *mp;
10526 ip6_address_t localsid;
10530 u32 fib_table = ~(u32) 0;
10531 ip6_address_t nh_addr6;
10532 ip4_address_t nh_addr4;
10533 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10534 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10536 bool nexthop_set = 0;
10540 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10542 if (unformat (i, "del"))
10544 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10545 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10547 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10549 else if (unformat (i, "behavior %u", &behavior));
10550 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10551 else if (unformat (i, "fib-table %u", &fib_table));
10552 else if (unformat (i, "end.psp %u", &behavior));
10557 M (SR_LOCALSID_ADD_DEL, mp);
10559 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10562 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10563 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10565 mp->behavior = behavior;
10566 mp->sw_if_index = ntohl (sw_if_index);
10567 mp->fib_table = ntohl (fib_table);
10568 mp->end_psp = end_psp;
10569 mp->is_del = is_del;
10577 api_ioam_enable (vat_main_t * vam)
10579 unformat_input_t *input = vam->input;
10580 vl_api_ioam_enable_t *mp;
10582 int has_trace_option = 0;
10583 int has_pot_option = 0;
10584 int has_seqno_option = 0;
10585 int has_analyse_option = 0;
10588 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10590 if (unformat (input, "trace"))
10591 has_trace_option = 1;
10592 else if (unformat (input, "pot"))
10593 has_pot_option = 1;
10594 else if (unformat (input, "seqno"))
10595 has_seqno_option = 1;
10596 else if (unformat (input, "analyse"))
10597 has_analyse_option = 1;
10601 M (IOAM_ENABLE, mp);
10602 mp->id = htons (id);
10603 mp->seqno = has_seqno_option;
10604 mp->analyse = has_analyse_option;
10605 mp->pot_enable = has_pot_option;
10606 mp->trace_enable = has_trace_option;
10615 api_ioam_disable (vat_main_t * vam)
10617 vl_api_ioam_disable_t *mp;
10620 M (IOAM_DISABLE, mp);
10626 #define foreach_tcp_proto_field \
10630 #define foreach_udp_proto_field \
10634 #define foreach_ip4_proto_field \
10646 u16 src_port, dst_port;
10649 #if VPP_API_TEST_BUILTIN == 0
10651 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10653 u8 **maskp = va_arg (*args, u8 **);
10655 u8 found_something = 0;
10658 #define _(a) u8 a=0;
10659 foreach_tcp_proto_field;
10662 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10665 #define _(a) else if (unformat (input, #a)) a=1;
10666 foreach_tcp_proto_field
10672 #define _(a) found_something += a;
10673 foreach_tcp_proto_field;
10676 if (found_something == 0)
10679 vec_validate (mask, sizeof (*tcp) - 1);
10681 tcp = (tcp_header_t *) mask;
10683 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10684 foreach_tcp_proto_field;
10692 unformat_udp_mask (unformat_input_t * input, va_list * args)
10694 u8 **maskp = va_arg (*args, u8 **);
10696 u8 found_something = 0;
10699 #define _(a) u8 a=0;
10700 foreach_udp_proto_field;
10703 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10706 #define _(a) else if (unformat (input, #a)) a=1;
10707 foreach_udp_proto_field
10713 #define _(a) found_something += a;
10714 foreach_udp_proto_field;
10717 if (found_something == 0)
10720 vec_validate (mask, sizeof (*udp) - 1);
10722 udp = (udp_header_t *) mask;
10724 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10725 foreach_udp_proto_field;
10733 unformat_l4_mask (unformat_input_t * input, va_list * args)
10735 u8 **maskp = va_arg (*args, u8 **);
10736 u16 src_port = 0, dst_port = 0;
10737 tcpudp_header_t *tcpudp;
10739 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10741 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10743 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10745 else if (unformat (input, "src_port"))
10747 else if (unformat (input, "dst_port"))
10753 if (!src_port && !dst_port)
10757 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10759 tcpudp = (tcpudp_header_t *) mask;
10760 tcpudp->src_port = src_port;
10761 tcpudp->dst_port = dst_port;
10769 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10771 u8 **maskp = va_arg (*args, u8 **);
10773 u8 found_something = 0;
10776 #define _(a) u8 a=0;
10777 foreach_ip4_proto_field;
10783 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10785 if (unformat (input, "version"))
10787 else if (unformat (input, "hdr_length"))
10789 else if (unformat (input, "src"))
10791 else if (unformat (input, "dst"))
10793 else if (unformat (input, "proto"))
10796 #define _(a) else if (unformat (input, #a)) a=1;
10797 foreach_ip4_proto_field
10803 #define _(a) found_something += a;
10804 foreach_ip4_proto_field;
10807 if (found_something == 0)
10810 vec_validate (mask, sizeof (*ip) - 1);
10812 ip = (ip4_header_t *) mask;
10814 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10815 foreach_ip4_proto_field;
10818 ip->ip_version_and_header_length = 0;
10821 ip->ip_version_and_header_length |= 0xF0;
10824 ip->ip_version_and_header_length |= 0x0F;
10830 #define foreach_ip6_proto_field \
10833 _(payload_length) \
10838 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10840 u8 **maskp = va_arg (*args, u8 **);
10842 u8 found_something = 0;
10844 u32 ip_version_traffic_class_and_flow_label;
10846 #define _(a) u8 a=0;
10847 foreach_ip6_proto_field;
10850 u8 traffic_class = 0;
10853 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10855 if (unformat (input, "version"))
10857 else if (unformat (input, "traffic-class"))
10859 else if (unformat (input, "flow-label"))
10861 else if (unformat (input, "src"))
10863 else if (unformat (input, "dst"))
10865 else if (unformat (input, "proto"))
10868 #define _(a) else if (unformat (input, #a)) a=1;
10869 foreach_ip6_proto_field
10875 #define _(a) found_something += a;
10876 foreach_ip6_proto_field;
10879 if (found_something == 0)
10882 vec_validate (mask, sizeof (*ip) - 1);
10884 ip = (ip6_header_t *) mask;
10886 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10887 foreach_ip6_proto_field;
10890 ip_version_traffic_class_and_flow_label = 0;
10893 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10896 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10899 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10901 ip->ip_version_traffic_class_and_flow_label =
10902 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10909 unformat_l3_mask (unformat_input_t * input, va_list * args)
10911 u8 **maskp = va_arg (*args, u8 **);
10913 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10915 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10917 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10926 unformat_l2_mask (unformat_input_t * input, va_list * args)
10928 u8 **maskp = va_arg (*args, u8 **);
10935 u8 ignore_tag1 = 0;
10936 u8 ignore_tag2 = 0;
10943 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10945 if (unformat (input, "src"))
10947 else if (unformat (input, "dst"))
10949 else if (unformat (input, "proto"))
10951 else if (unformat (input, "tag1"))
10953 else if (unformat (input, "tag2"))
10955 else if (unformat (input, "ignore-tag1"))
10957 else if (unformat (input, "ignore-tag2"))
10959 else if (unformat (input, "cos1"))
10961 else if (unformat (input, "cos2"))
10963 else if (unformat (input, "dot1q"))
10965 else if (unformat (input, "dot1ad"))
10970 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10971 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10974 if (tag1 || ignore_tag1 || cos1 || dot1q)
10976 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10979 vec_validate (mask, len - 1);
10982 clib_memset (mask, 0xff, 6);
10985 clib_memset (mask + 6, 0xff, 6);
10987 if (tag2 || dot1ad)
10989 /* inner vlan tag */
10998 mask[21] = mask[20] = 0xff;
11019 mask[16] = mask[17] = 0xff;
11029 mask[12] = mask[13] = 0xff;
11036 unformat_classify_mask (unformat_input_t * input, va_list * args)
11038 u8 **maskp = va_arg (*args, u8 **);
11039 u32 *skipp = va_arg (*args, u32 *);
11040 u32 *matchp = va_arg (*args, u32 *);
11048 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11050 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11052 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11054 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11056 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11070 if (mask || l2 || l3 || l4)
11072 if (l2 || l3 || l4)
11074 /* "With a free Ethernet header in every package" */
11076 vec_validate (l2, 13);
11080 vec_append (mask, l3);
11085 vec_append (mask, l4);
11090 /* Scan forward looking for the first significant mask octet */
11091 for (i = 0; i < vec_len (mask); i++)
11095 /* compute (skip, match) params */
11096 *skipp = i / sizeof (u32x4);
11097 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11099 /* Pad mask to an even multiple of the vector size */
11100 while (vec_len (mask) % sizeof (u32x4))
11101 vec_add1 (mask, 0);
11103 match = vec_len (mask) / sizeof (u32x4);
11105 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11107 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11108 if (*tmp || *(tmp + 1))
11113 clib_warning ("BUG: match 0");
11115 _vec_len (mask) = match * sizeof (u32x4);
11125 #endif /* VPP_API_TEST_BUILTIN */
11127 #define foreach_l2_next \
11129 _(ethernet, ETHERNET_INPUT) \
11130 _(ip4, IP4_INPUT) \
11134 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11136 u32 *miss_next_indexp = va_arg (*args, u32 *);
11137 u32 next_index = 0;
11141 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11145 if (unformat (input, "%d", &tmp))
11154 *miss_next_indexp = next_index;
11158 #define foreach_ip_next \
11161 _(rewrite, REWRITE)
11164 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11166 u32 *miss_next_indexp = va_arg (*args, u32 *);
11167 u32 next_index = 0;
11171 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11175 if (unformat (input, "%d", &tmp))
11184 *miss_next_indexp = next_index;
11188 #define foreach_acl_next \
11192 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11194 u32 *miss_next_indexp = va_arg (*args, u32 *);
11195 u32 next_index = 0;
11199 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11203 if (unformat (input, "permit"))
11208 else if (unformat (input, "%d", &tmp))
11217 *miss_next_indexp = next_index;
11222 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11224 u32 *r = va_arg (*args, u32 *);
11226 if (unformat (input, "conform-color"))
11227 *r = POLICE_CONFORM;
11228 else if (unformat (input, "exceed-color"))
11229 *r = POLICE_EXCEED;
11237 api_classify_add_del_table (vat_main_t * vam)
11239 unformat_input_t *i = vam->input;
11240 vl_api_classify_add_del_table_t *mp;
11247 u32 table_index = ~0;
11248 u32 next_table_index = ~0;
11249 u32 miss_next_index = ~0;
11250 u32 memory_size = 32 << 20;
11252 u32 current_data_flag = 0;
11253 int current_data_offset = 0;
11256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11258 if (unformat (i, "del"))
11260 else if (unformat (i, "del-chain"))
11265 else if (unformat (i, "buckets %d", &nbuckets))
11267 else if (unformat (i, "memory_size %d", &memory_size))
11269 else if (unformat (i, "skip %d", &skip))
11271 else if (unformat (i, "match %d", &match))
11273 else if (unformat (i, "table %d", &table_index))
11275 else if (unformat (i, "mask %U", unformat_classify_mask,
11276 &mask, &skip, &match))
11278 else if (unformat (i, "next-table %d", &next_table_index))
11280 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11283 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11286 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11289 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11291 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11297 if (is_add && mask == 0)
11299 errmsg ("Mask required");
11303 if (is_add && skip == ~0)
11305 errmsg ("skip count required");
11309 if (is_add && match == ~0)
11311 errmsg ("match count required");
11315 if (!is_add && table_index == ~0)
11317 errmsg ("table index required for delete");
11321 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11323 mp->is_add = is_add;
11324 mp->del_chain = del_chain;
11325 mp->table_index = ntohl (table_index);
11326 mp->nbuckets = ntohl (nbuckets);
11327 mp->memory_size = ntohl (memory_size);
11328 mp->skip_n_vectors = ntohl (skip);
11329 mp->match_n_vectors = ntohl (match);
11330 mp->next_table_index = ntohl (next_table_index);
11331 mp->miss_next_index = ntohl (miss_next_index);
11332 mp->current_data_flag = ntohl (current_data_flag);
11333 mp->current_data_offset = ntohl (current_data_offset);
11334 mp->mask_len = ntohl (vec_len (mask));
11335 clib_memcpy (mp->mask, mask, vec_len (mask));
11344 #if VPP_API_TEST_BUILTIN == 0
11346 unformat_l4_match (unformat_input_t * input, va_list * args)
11348 u8 **matchp = va_arg (*args, u8 **);
11350 u8 *proto_header = 0;
11356 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11358 if (unformat (input, "src_port %d", &src_port))
11360 else if (unformat (input, "dst_port %d", &dst_port))
11366 h.src_port = clib_host_to_net_u16 (src_port);
11367 h.dst_port = clib_host_to_net_u16 (dst_port);
11368 vec_validate (proto_header, sizeof (h) - 1);
11369 memcpy (proto_header, &h, sizeof (h));
11371 *matchp = proto_header;
11377 unformat_ip4_match (unformat_input_t * input, va_list * args)
11379 u8 **matchp = va_arg (*args, u8 **);
11384 int hdr_length = 0;
11385 u32 hdr_length_val;
11386 int src = 0, dst = 0;
11387 ip4_address_t src_val, dst_val;
11394 int fragment_id = 0;
11395 u32 fragment_id_val;
11401 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11403 if (unformat (input, "version %d", &version_val))
11405 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11407 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11409 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11411 else if (unformat (input, "proto %d", &proto_val))
11413 else if (unformat (input, "tos %d", &tos_val))
11415 else if (unformat (input, "length %d", &length_val))
11417 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11419 else if (unformat (input, "ttl %d", &ttl_val))
11421 else if (unformat (input, "checksum %d", &checksum_val))
11427 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11428 + ttl + checksum == 0)
11432 * Aligned because we use the real comparison functions
11434 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11436 ip = (ip4_header_t *) match;
11438 /* These are realistically matched in practice */
11440 ip->src_address.as_u32 = src_val.as_u32;
11443 ip->dst_address.as_u32 = dst_val.as_u32;
11446 ip->protocol = proto_val;
11449 /* These are not, but they're included for completeness */
11451 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11454 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11460 ip->length = clib_host_to_net_u16 (length_val);
11466 ip->checksum = clib_host_to_net_u16 (checksum_val);
11473 unformat_ip6_match (unformat_input_t * input, va_list * args)
11475 u8 **matchp = va_arg (*args, u8 **);
11480 u8 traffic_class = 0;
11481 u32 traffic_class_val = 0;
11484 int src = 0, dst = 0;
11485 ip6_address_t src_val, dst_val;
11488 int payload_length = 0;
11489 u32 payload_length_val;
11492 u32 ip_version_traffic_class_and_flow_label;
11494 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11496 if (unformat (input, "version %d", &version_val))
11498 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11500 else if (unformat (input, "flow_label %d", &flow_label_val))
11502 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11504 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11506 else if (unformat (input, "proto %d", &proto_val))
11508 else if (unformat (input, "payload_length %d", &payload_length_val))
11509 payload_length = 1;
11510 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11516 if (version + traffic_class + flow_label + src + dst + proto +
11517 payload_length + hop_limit == 0)
11521 * Aligned because we use the real comparison functions
11523 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11525 ip = (ip6_header_t *) match;
11528 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11531 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11534 ip->protocol = proto_val;
11536 ip_version_traffic_class_and_flow_label = 0;
11539 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11542 ip_version_traffic_class_and_flow_label |=
11543 (traffic_class_val & 0xFF) << 20;
11546 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11548 ip->ip_version_traffic_class_and_flow_label =
11549 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11551 if (payload_length)
11552 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11555 ip->hop_limit = hop_limit_val;
11562 unformat_l3_match (unformat_input_t * input, va_list * args)
11564 u8 **matchp = va_arg (*args, u8 **);
11566 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11568 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11570 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11579 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11581 u8 *tagp = va_arg (*args, u8 *);
11584 if (unformat (input, "%d", &tag))
11586 tagp[0] = (tag >> 8) & 0x0F;
11587 tagp[1] = tag & 0xFF;
11595 unformat_l2_match (unformat_input_t * input, va_list * args)
11597 u8 **matchp = va_arg (*args, u8 **);
11610 u8 ignore_tag1 = 0;
11611 u8 ignore_tag2 = 0;
11617 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11619 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11622 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11624 else if (unformat (input, "proto %U",
11625 unformat_ethernet_type_host_byte_order, &proto_val))
11627 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11629 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11631 else if (unformat (input, "ignore-tag1"))
11633 else if (unformat (input, "ignore-tag2"))
11635 else if (unformat (input, "cos1 %d", &cos1_val))
11637 else if (unformat (input, "cos2 %d", &cos2_val))
11642 if ((src + dst + proto + tag1 + tag2 +
11643 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11646 if (tag1 || ignore_tag1 || cos1)
11648 if (tag2 || ignore_tag2 || cos2)
11651 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11654 clib_memcpy (match, dst_val, 6);
11657 clib_memcpy (match + 6, src_val, 6);
11661 /* inner vlan tag */
11662 match[19] = tag2_val[1];
11663 match[18] = tag2_val[0];
11665 match[18] |= (cos2_val & 0x7) << 5;
11668 match[21] = proto_val & 0xff;
11669 match[20] = proto_val >> 8;
11673 match[15] = tag1_val[1];
11674 match[14] = tag1_val[0];
11677 match[14] |= (cos1_val & 0x7) << 5;
11683 match[15] = tag1_val[1];
11684 match[14] = tag1_val[0];
11687 match[17] = proto_val & 0xff;
11688 match[16] = proto_val >> 8;
11691 match[14] |= (cos1_val & 0x7) << 5;
11697 match[18] |= (cos2_val & 0x7) << 5;
11699 match[14] |= (cos1_val & 0x7) << 5;
11702 match[13] = proto_val & 0xff;
11703 match[12] = proto_val >> 8;
11711 unformat_qos_source (unformat_input_t * input, va_list * args)
11713 int *qs = va_arg (*args, int *);
11715 if (unformat (input, "ip"))
11716 *qs = QOS_SOURCE_IP;
11717 else if (unformat (input, "mpls"))
11718 *qs = QOS_SOURCE_MPLS;
11719 else if (unformat (input, "ext"))
11720 *qs = QOS_SOURCE_EXT;
11721 else if (unformat (input, "vlan"))
11722 *qs = QOS_SOURCE_VLAN;
11731 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11733 u8 **matchp = va_arg (*args, u8 **);
11734 u32 skip_n_vectors = va_arg (*args, u32);
11735 u32 match_n_vectors = va_arg (*args, u32);
11742 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11744 if (unformat (input, "hex %U", unformat_hex_string, &match))
11746 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11748 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11750 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11764 if (match || l2 || l3 || l4)
11766 if (l2 || l3 || l4)
11768 /* "Win a free Ethernet header in every packet" */
11770 vec_validate_aligned (l2, 13, sizeof (u32x4));
11774 vec_append_aligned (match, l3, sizeof (u32x4));
11779 vec_append_aligned (match, l4, sizeof (u32x4));
11784 /* Make sure the vector is big enough even if key is all 0's */
11785 vec_validate_aligned
11786 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11789 /* Set size, include skipped vectors */
11790 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11801 api_classify_add_del_session (vat_main_t * vam)
11803 unformat_input_t *i = vam->input;
11804 vl_api_classify_add_del_session_t *mp;
11806 u32 table_index = ~0;
11807 u32 hit_next_index = ~0;
11808 u32 opaque_index = ~0;
11811 u32 skip_n_vectors = 0;
11812 u32 match_n_vectors = 0;
11818 * Warning: you have to supply skip_n and match_n
11819 * because the API client cant simply look at the classify
11823 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11825 if (unformat (i, "del"))
11827 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11830 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11833 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11836 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11838 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11840 else if (unformat (i, "opaque-index %d", &opaque_index))
11842 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11844 else if (unformat (i, "match_n %d", &match_n_vectors))
11846 else if (unformat (i, "match %U", api_unformat_classify_match,
11847 &match, skip_n_vectors, match_n_vectors))
11849 else if (unformat (i, "advance %d", &advance))
11851 else if (unformat (i, "table-index %d", &table_index))
11853 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11855 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11857 else if (unformat (i, "action %d", &action))
11859 else if (unformat (i, "metadata %d", &metadata))
11865 if (table_index == ~0)
11867 errmsg ("Table index required");
11871 if (is_add && match == 0)
11873 errmsg ("Match value required");
11877 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11879 mp->is_add = is_add;
11880 mp->table_index = ntohl (table_index);
11881 mp->hit_next_index = ntohl (hit_next_index);
11882 mp->opaque_index = ntohl (opaque_index);
11883 mp->advance = ntohl (advance);
11884 mp->action = action;
11885 mp->metadata = ntohl (metadata);
11886 mp->match_len = ntohl (vec_len (match));
11887 clib_memcpy (mp->match, match, vec_len (match));
11896 api_classify_set_interface_ip_table (vat_main_t * vam)
11898 unformat_input_t *i = vam->input;
11899 vl_api_classify_set_interface_ip_table_t *mp;
11901 int sw_if_index_set;
11902 u32 table_index = ~0;
11906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11908 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11909 sw_if_index_set = 1;
11910 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11911 sw_if_index_set = 1;
11912 else if (unformat (i, "table %d", &table_index))
11916 clib_warning ("parse error '%U'", format_unformat_error, i);
11921 if (sw_if_index_set == 0)
11923 errmsg ("missing interface name or sw_if_index");
11928 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11930 mp->sw_if_index = ntohl (sw_if_index);
11931 mp->table_index = ntohl (table_index);
11932 mp->is_ipv6 = is_ipv6;
11940 api_classify_set_interface_l2_tables (vat_main_t * vam)
11942 unformat_input_t *i = vam->input;
11943 vl_api_classify_set_interface_l2_tables_t *mp;
11945 int sw_if_index_set;
11946 u32 ip4_table_index = ~0;
11947 u32 ip6_table_index = ~0;
11948 u32 other_table_index = ~0;
11952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11954 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11955 sw_if_index_set = 1;
11956 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11957 sw_if_index_set = 1;
11958 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11960 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11962 else if (unformat (i, "other-table %d", &other_table_index))
11964 else if (unformat (i, "is-input %d", &is_input))
11968 clib_warning ("parse error '%U'", format_unformat_error, i);
11973 if (sw_if_index_set == 0)
11975 errmsg ("missing interface name or sw_if_index");
11980 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11982 mp->sw_if_index = ntohl (sw_if_index);
11983 mp->ip4_table_index = ntohl (ip4_table_index);
11984 mp->ip6_table_index = ntohl (ip6_table_index);
11985 mp->other_table_index = ntohl (other_table_index);
11986 mp->is_input = (u8) is_input;
11994 api_set_ipfix_exporter (vat_main_t * vam)
11996 unformat_input_t *i = vam->input;
11997 vl_api_set_ipfix_exporter_t *mp;
11998 ip4_address_t collector_address;
11999 u8 collector_address_set = 0;
12000 u32 collector_port = ~0;
12001 ip4_address_t src_address;
12002 u8 src_address_set = 0;
12005 u32 template_interval = ~0;
12006 u8 udp_checksum = 0;
12009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12011 if (unformat (i, "collector_address %U", unformat_ip4_address,
12012 &collector_address))
12013 collector_address_set = 1;
12014 else if (unformat (i, "collector_port %d", &collector_port))
12016 else if (unformat (i, "src_address %U", unformat_ip4_address,
12018 src_address_set = 1;
12019 else if (unformat (i, "vrf_id %d", &vrf_id))
12021 else if (unformat (i, "path_mtu %d", &path_mtu))
12023 else if (unformat (i, "template_interval %d", &template_interval))
12025 else if (unformat (i, "udp_checksum"))
12031 if (collector_address_set == 0)
12033 errmsg ("collector_address required");
12037 if (src_address_set == 0)
12039 errmsg ("src_address required");
12043 M (SET_IPFIX_EXPORTER, mp);
12045 memcpy (mp->collector_address, collector_address.data,
12046 sizeof (collector_address.data));
12047 mp->collector_port = htons ((u16) collector_port);
12048 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12049 mp->vrf_id = htonl (vrf_id);
12050 mp->path_mtu = htonl (path_mtu);
12051 mp->template_interval = htonl (template_interval);
12052 mp->udp_checksum = udp_checksum;
12060 api_set_ipfix_classify_stream (vat_main_t * vam)
12062 unformat_input_t *i = vam->input;
12063 vl_api_set_ipfix_classify_stream_t *mp;
12065 u32 src_port = UDP_DST_PORT_ipfix;
12068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12070 if (unformat (i, "domain %d", &domain_id))
12072 else if (unformat (i, "src_port %d", &src_port))
12076 errmsg ("unknown input `%U'", format_unformat_error, i);
12081 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12083 mp->domain_id = htonl (domain_id);
12084 mp->src_port = htons ((u16) src_port);
12092 api_ipfix_classify_table_add_del (vat_main_t * vam)
12094 unformat_input_t *i = vam->input;
12095 vl_api_ipfix_classify_table_add_del_t *mp;
12097 u32 classify_table_index = ~0;
12099 u8 transport_protocol = 255;
12102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12104 if (unformat (i, "add"))
12106 else if (unformat (i, "del"))
12108 else if (unformat (i, "table %d", &classify_table_index))
12110 else if (unformat (i, "ip4"))
12112 else if (unformat (i, "ip6"))
12114 else if (unformat (i, "tcp"))
12115 transport_protocol = 6;
12116 else if (unformat (i, "udp"))
12117 transport_protocol = 17;
12120 errmsg ("unknown input `%U'", format_unformat_error, i);
12127 errmsg ("expecting: add|del");
12130 if (classify_table_index == ~0)
12132 errmsg ("classifier table not specified");
12135 if (ip_version == 0)
12137 errmsg ("IP version not specified");
12141 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12143 mp->is_add = is_add;
12144 mp->table_id = htonl (classify_table_index);
12145 mp->ip_version = ip_version;
12146 mp->transport_protocol = transport_protocol;
12154 api_get_node_index (vat_main_t * vam)
12156 unformat_input_t *i = vam->input;
12157 vl_api_get_node_index_t *mp;
12161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12163 if (unformat (i, "node %s", &name))
12170 errmsg ("node name required");
12173 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12175 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12179 M (GET_NODE_INDEX, mp);
12180 clib_memcpy (mp->node_name, name, vec_len (name));
12189 api_get_next_index (vat_main_t * vam)
12191 unformat_input_t *i = vam->input;
12192 vl_api_get_next_index_t *mp;
12193 u8 *node_name = 0, *next_node_name = 0;
12196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12198 if (unformat (i, "node-name %s", &node_name))
12200 else if (unformat (i, "next-node-name %s", &next_node_name))
12204 if (node_name == 0)
12206 errmsg ("node name required");
12209 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12211 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12215 if (next_node_name == 0)
12217 errmsg ("next node name required");
12220 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12222 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12226 M (GET_NEXT_INDEX, mp);
12227 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12228 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12229 vec_free (node_name);
12230 vec_free (next_node_name);
12238 api_add_node_next (vat_main_t * vam)
12240 unformat_input_t *i = vam->input;
12241 vl_api_add_node_next_t *mp;
12246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12248 if (unformat (i, "node %s", &name))
12250 else if (unformat (i, "next %s", &next))
12257 errmsg ("node name required");
12260 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12262 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12267 errmsg ("next node required");
12270 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12272 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12276 M (ADD_NODE_NEXT, mp);
12277 clib_memcpy (mp->node_name, name, vec_len (name));
12278 clib_memcpy (mp->next_name, next, vec_len (next));
12288 api_l2tpv3_create_tunnel (vat_main_t * vam)
12290 unformat_input_t *i = vam->input;
12291 ip6_address_t client_address, our_address;
12292 int client_address_set = 0;
12293 int our_address_set = 0;
12294 u32 local_session_id = 0;
12295 u32 remote_session_id = 0;
12296 u64 local_cookie = 0;
12297 u64 remote_cookie = 0;
12298 u8 l2_sublayer_present = 0;
12299 vl_api_l2tpv3_create_tunnel_t *mp;
12302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12304 if (unformat (i, "client_address %U", unformat_ip6_address,
12306 client_address_set = 1;
12307 else if (unformat (i, "our_address %U", unformat_ip6_address,
12309 our_address_set = 1;
12310 else if (unformat (i, "local_session_id %d", &local_session_id))
12312 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12314 else if (unformat (i, "local_cookie %lld", &local_cookie))
12316 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12318 else if (unformat (i, "l2-sublayer-present"))
12319 l2_sublayer_present = 1;
12324 if (client_address_set == 0)
12326 errmsg ("client_address required");
12330 if (our_address_set == 0)
12332 errmsg ("our_address required");
12336 M (L2TPV3_CREATE_TUNNEL, mp);
12338 clib_memcpy (mp->client_address, client_address.as_u8,
12339 sizeof (mp->client_address));
12341 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12343 mp->local_session_id = ntohl (local_session_id);
12344 mp->remote_session_id = ntohl (remote_session_id);
12345 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12346 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12347 mp->l2_sublayer_present = l2_sublayer_present;
12356 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12358 unformat_input_t *i = vam->input;
12360 u8 sw_if_index_set = 0;
12361 u64 new_local_cookie = 0;
12362 u64 new_remote_cookie = 0;
12363 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12366 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12368 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12369 sw_if_index_set = 1;
12370 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12371 sw_if_index_set = 1;
12372 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12374 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12380 if (sw_if_index_set == 0)
12382 errmsg ("missing interface name or sw_if_index");
12386 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12388 mp->sw_if_index = ntohl (sw_if_index);
12389 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12390 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12398 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12400 unformat_input_t *i = vam->input;
12401 vl_api_l2tpv3_interface_enable_disable_t *mp;
12403 u8 sw_if_index_set = 0;
12404 u8 enable_disable = 1;
12407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12409 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12410 sw_if_index_set = 1;
12411 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12412 sw_if_index_set = 1;
12413 else if (unformat (i, "enable"))
12414 enable_disable = 1;
12415 else if (unformat (i, "disable"))
12416 enable_disable = 0;
12421 if (sw_if_index_set == 0)
12423 errmsg ("missing interface name or sw_if_index");
12427 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12429 mp->sw_if_index = ntohl (sw_if_index);
12430 mp->enable_disable = enable_disable;
12438 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12440 unformat_input_t *i = vam->input;
12441 vl_api_l2tpv3_set_lookup_key_t *mp;
12445 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12447 if (unformat (i, "lookup_v6_src"))
12448 key = L2T_LOOKUP_SRC_ADDRESS;
12449 else if (unformat (i, "lookup_v6_dst"))
12450 key = L2T_LOOKUP_DST_ADDRESS;
12451 else if (unformat (i, "lookup_session_id"))
12452 key = L2T_LOOKUP_SESSION_ID;
12457 if (key == (u8) ~ 0)
12459 errmsg ("l2tp session lookup key unset");
12463 M (L2TPV3_SET_LOOKUP_KEY, mp);
12472 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12473 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12475 vat_main_t *vam = &vat_main;
12477 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12478 format_ip6_address, mp->our_address,
12479 format_ip6_address, mp->client_address,
12480 clib_net_to_host_u32 (mp->sw_if_index));
12483 " local cookies %016llx %016llx remote cookie %016llx",
12484 clib_net_to_host_u64 (mp->local_cookie[0]),
12485 clib_net_to_host_u64 (mp->local_cookie[1]),
12486 clib_net_to_host_u64 (mp->remote_cookie));
12488 print (vam->ofp, " local session-id %d remote session-id %d",
12489 clib_net_to_host_u32 (mp->local_session_id),
12490 clib_net_to_host_u32 (mp->remote_session_id));
12492 print (vam->ofp, " l2 specific sublayer %s\n",
12493 mp->l2_sublayer_present ? "preset" : "absent");
12497 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12498 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12500 vat_main_t *vam = &vat_main;
12501 vat_json_node_t *node = NULL;
12502 struct in6_addr addr;
12504 if (VAT_JSON_ARRAY != vam->json_tree.type)
12506 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12507 vat_json_init_array (&vam->json_tree);
12509 node = vat_json_array_add (&vam->json_tree);
12511 vat_json_init_object (node);
12513 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12514 vat_json_object_add_ip6 (node, "our_address", addr);
12515 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12516 vat_json_object_add_ip6 (node, "client_address", addr);
12518 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12519 vat_json_init_array (lc);
12520 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12521 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12522 vat_json_object_add_uint (node, "remote_cookie",
12523 clib_net_to_host_u64 (mp->remote_cookie));
12525 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12526 vat_json_object_add_uint (node, "local_session_id",
12527 clib_net_to_host_u32 (mp->local_session_id));
12528 vat_json_object_add_uint (node, "remote_session_id",
12529 clib_net_to_host_u32 (mp->remote_session_id));
12530 vat_json_object_add_string_copy (node, "l2_sublayer",
12531 mp->l2_sublayer_present ? (u8 *) "present"
12532 : (u8 *) "absent");
12536 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12538 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12539 vl_api_control_ping_t *mp_ping;
12542 /* Get list of l2tpv3-tunnel interfaces */
12543 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12546 /* Use a control ping for synchronization */
12547 MPING (CONTROL_PING, mp_ping);
12555 static void vl_api_sw_interface_tap_v2_details_t_handler
12556 (vl_api_sw_interface_tap_v2_details_t * mp)
12558 vat_main_t *vam = &vat_main;
12560 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12561 mp->host_ip4_prefix_len);
12562 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12563 mp->host_ip6_prefix_len);
12566 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12567 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12568 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12569 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12570 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12576 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12577 (vl_api_sw_interface_tap_v2_details_t * mp)
12579 vat_main_t *vam = &vat_main;
12580 vat_json_node_t *node = NULL;
12582 if (VAT_JSON_ARRAY != vam->json_tree.type)
12584 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12585 vat_json_init_array (&vam->json_tree);
12587 node = vat_json_array_add (&vam->json_tree);
12589 vat_json_init_object (node);
12590 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12591 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12592 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12593 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12594 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12595 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12596 vat_json_object_add_string_copy (node, "host_mac_addr",
12597 format (0, "%U", format_ethernet_address,
12598 &mp->host_mac_addr));
12599 vat_json_object_add_string_copy (node, "host_namespace",
12600 mp->host_namespace);
12601 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12602 vat_json_object_add_string_copy (node, "host_ip4_addr",
12603 format (0, "%U/%d", format_ip4_address,
12605 mp->host_ip4_prefix_len));
12606 vat_json_object_add_string_copy (node, "host_ip6_addr",
12607 format (0, "%U/%d", format_ip6_address,
12609 mp->host_ip6_prefix_len));
12614 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12616 vl_api_sw_interface_tap_v2_dump_t *mp;
12617 vl_api_control_ping_t *mp_ping;
12621 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12622 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12623 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12626 /* Get list of tap interfaces */
12627 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12630 /* Use a control ping for synchronization */
12631 MPING (CONTROL_PING, mp_ping);
12638 static void vl_api_sw_interface_virtio_pci_details_t_handler
12639 (vl_api_sw_interface_virtio_pci_details_t * mp)
12641 vat_main_t *vam = &vat_main;
12655 addr.as_u32 = ntohl (mp->pci_addr);
12656 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
12657 addr.slot, addr.function);
12660 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
12661 pci_addr, ntohl (mp->sw_if_index),
12662 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12663 format_ethernet_address, mp->mac_addr,
12664 clib_net_to_host_u64 (mp->features));
12665 vec_free (pci_addr);
12668 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
12669 (vl_api_sw_interface_virtio_pci_details_t * mp)
12671 vat_main_t *vam = &vat_main;
12672 vat_json_node_t *node = NULL;
12674 if (VAT_JSON_ARRAY != vam->json_tree.type)
12676 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12677 vat_json_init_array (&vam->json_tree);
12679 node = vat_json_array_add (&vam->json_tree);
12681 vat_json_init_object (node);
12682 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
12683 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12684 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12685 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12686 vat_json_object_add_uint (node, "features",
12687 clib_net_to_host_u64 (mp->features));
12688 vat_json_object_add_string_copy (node, "mac_addr",
12689 format (0, "%U", format_ethernet_address,
12694 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12696 vl_api_sw_interface_virtio_pci_dump_t *mp;
12697 vl_api_control_ping_t *mp_ping;
12701 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12702 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12703 "mac_addr", "features");
12705 /* Get list of tap interfaces */
12706 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12709 /* Use a control ping for synchronization */
12710 MPING (CONTROL_PING, mp_ping);
12718 api_vxlan_offload_rx (vat_main_t * vam)
12720 unformat_input_t *line_input = vam->input;
12721 vl_api_vxlan_offload_rx_t *mp;
12722 u32 hw_if_index = ~0, rx_if_index = ~0;
12726 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12728 if (unformat (line_input, "del"))
12730 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12733 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12735 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12738 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12742 errmsg ("parse error '%U'", format_unformat_error, line_input);
12747 if (hw_if_index == ~0)
12749 errmsg ("no hw interface");
12753 if (rx_if_index == ~0)
12755 errmsg ("no rx tunnel");
12759 M (VXLAN_OFFLOAD_RX, mp);
12761 mp->hw_if_index = ntohl (hw_if_index);
12762 mp->sw_if_index = ntohl (rx_if_index);
12763 mp->enable = is_add;
12770 static uword unformat_vxlan_decap_next
12771 (unformat_input_t * input, va_list * args)
12773 u32 *result = va_arg (*args, u32 *);
12776 if (unformat (input, "l2"))
12777 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12778 else if (unformat (input, "%d", &tmp))
12786 api_vxlan_add_del_tunnel (vat_main_t * vam)
12788 unformat_input_t *line_input = vam->input;
12789 vl_api_vxlan_add_del_tunnel_t *mp;
12790 ip46_address_t src, dst;
12792 u8 ipv4_set = 0, ipv6_set = 0;
12797 u32 mcast_sw_if_index = ~0;
12798 u32 encap_vrf_id = 0;
12799 u32 decap_next_index = ~0;
12803 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12804 clib_memset (&src, 0, sizeof src);
12805 clib_memset (&dst, 0, sizeof dst);
12807 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12809 if (unformat (line_input, "del"))
12811 else if (unformat (line_input, "instance %d", &instance))
12814 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12820 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12826 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12832 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12837 else if (unformat (line_input, "group %U %U",
12838 unformat_ip4_address, &dst.ip4,
12839 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12841 grp_set = dst_set = 1;
12844 else if (unformat (line_input, "group %U",
12845 unformat_ip4_address, &dst.ip4))
12847 grp_set = dst_set = 1;
12850 else if (unformat (line_input, "group %U %U",
12851 unformat_ip6_address, &dst.ip6,
12852 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12854 grp_set = dst_set = 1;
12857 else if (unformat (line_input, "group %U",
12858 unformat_ip6_address, &dst.ip6))
12860 grp_set = dst_set = 1;
12864 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12866 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12868 else if (unformat (line_input, "decap-next %U",
12869 unformat_vxlan_decap_next, &decap_next_index))
12871 else if (unformat (line_input, "vni %d", &vni))
12875 errmsg ("parse error '%U'", format_unformat_error, line_input);
12882 errmsg ("tunnel src address not specified");
12887 errmsg ("tunnel dst address not specified");
12891 if (grp_set && !ip46_address_is_multicast (&dst))
12893 errmsg ("tunnel group address not multicast");
12896 if (grp_set && mcast_sw_if_index == ~0)
12898 errmsg ("tunnel nonexistent multicast device");
12901 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12903 errmsg ("tunnel dst address must be unicast");
12908 if (ipv4_set && ipv6_set)
12910 errmsg ("both IPv4 and IPv6 addresses specified");
12914 if ((vni == 0) || (vni >> 24))
12916 errmsg ("vni not specified or out of range");
12920 M (VXLAN_ADD_DEL_TUNNEL, mp);
12924 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12925 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12929 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12930 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12933 mp->instance = htonl (instance);
12934 mp->encap_vrf_id = ntohl (encap_vrf_id);
12935 mp->decap_next_index = ntohl (decap_next_index);
12936 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12937 mp->vni = ntohl (vni);
12938 mp->is_add = is_add;
12939 mp->is_ipv6 = ipv6_set;
12946 static void vl_api_vxlan_tunnel_details_t_handler
12947 (vl_api_vxlan_tunnel_details_t * mp)
12949 vat_main_t *vam = &vat_main;
12950 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12951 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12953 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12954 ntohl (mp->sw_if_index),
12955 ntohl (mp->instance),
12956 format_ip46_address, &src, IP46_TYPE_ANY,
12957 format_ip46_address, &dst, IP46_TYPE_ANY,
12958 ntohl (mp->encap_vrf_id),
12959 ntohl (mp->decap_next_index), ntohl (mp->vni),
12960 ntohl (mp->mcast_sw_if_index));
12963 static void vl_api_vxlan_tunnel_details_t_handler_json
12964 (vl_api_vxlan_tunnel_details_t * mp)
12966 vat_main_t *vam = &vat_main;
12967 vat_json_node_t *node = NULL;
12969 if (VAT_JSON_ARRAY != vam->json_tree.type)
12971 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12972 vat_json_init_array (&vam->json_tree);
12974 node = vat_json_array_add (&vam->json_tree);
12976 vat_json_init_object (node);
12977 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12979 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12983 struct in6_addr ip6;
12985 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12986 vat_json_object_add_ip6 (node, "src_address", ip6);
12987 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12988 vat_json_object_add_ip6 (node, "dst_address", ip6);
12992 struct in_addr ip4;
12994 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12995 vat_json_object_add_ip4 (node, "src_address", ip4);
12996 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12997 vat_json_object_add_ip4 (node, "dst_address", ip4);
12999 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13000 vat_json_object_add_uint (node, "decap_next_index",
13001 ntohl (mp->decap_next_index));
13002 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13003 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13004 vat_json_object_add_uint (node, "mcast_sw_if_index",
13005 ntohl (mp->mcast_sw_if_index));
13009 api_vxlan_tunnel_dump (vat_main_t * vam)
13011 unformat_input_t *i = vam->input;
13012 vl_api_vxlan_tunnel_dump_t *mp;
13013 vl_api_control_ping_t *mp_ping;
13015 u8 sw_if_index_set = 0;
13018 /* Parse args required to build the message */
13019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13021 if (unformat (i, "sw_if_index %d", &sw_if_index))
13022 sw_if_index_set = 1;
13027 if (sw_if_index_set == 0)
13032 if (!vam->json_output)
13034 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13035 "sw_if_index", "instance", "src_address", "dst_address",
13036 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13039 /* Get list of vxlan-tunnel interfaces */
13040 M (VXLAN_TUNNEL_DUMP, mp);
13042 mp->sw_if_index = htonl (sw_if_index);
13046 /* Use a control ping for synchronization */
13047 MPING (CONTROL_PING, mp_ping);
13054 static uword unformat_geneve_decap_next
13055 (unformat_input_t * input, va_list * args)
13057 u32 *result = va_arg (*args, u32 *);
13060 if (unformat (input, "l2"))
13061 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13062 else if (unformat (input, "%d", &tmp))
13070 api_geneve_add_del_tunnel (vat_main_t * vam)
13072 unformat_input_t *line_input = vam->input;
13073 vl_api_geneve_add_del_tunnel_t *mp;
13074 ip46_address_t src, dst;
13076 u8 ipv4_set = 0, ipv6_set = 0;
13080 u32 mcast_sw_if_index = ~0;
13081 u32 encap_vrf_id = 0;
13082 u32 decap_next_index = ~0;
13086 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13087 clib_memset (&src, 0, sizeof src);
13088 clib_memset (&dst, 0, sizeof dst);
13090 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13092 if (unformat (line_input, "del"))
13095 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13101 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13107 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13113 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13118 else if (unformat (line_input, "group %U %U",
13119 unformat_ip4_address, &dst.ip4,
13120 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13122 grp_set = dst_set = 1;
13125 else if (unformat (line_input, "group %U",
13126 unformat_ip4_address, &dst.ip4))
13128 grp_set = dst_set = 1;
13131 else if (unformat (line_input, "group %U %U",
13132 unformat_ip6_address, &dst.ip6,
13133 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13135 grp_set = dst_set = 1;
13138 else if (unformat (line_input, "group %U",
13139 unformat_ip6_address, &dst.ip6))
13141 grp_set = dst_set = 1;
13145 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13147 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13149 else if (unformat (line_input, "decap-next %U",
13150 unformat_geneve_decap_next, &decap_next_index))
13152 else if (unformat (line_input, "vni %d", &vni))
13156 errmsg ("parse error '%U'", format_unformat_error, line_input);
13163 errmsg ("tunnel src address not specified");
13168 errmsg ("tunnel dst address not specified");
13172 if (grp_set && !ip46_address_is_multicast (&dst))
13174 errmsg ("tunnel group address not multicast");
13177 if (grp_set && mcast_sw_if_index == ~0)
13179 errmsg ("tunnel nonexistent multicast device");
13182 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13184 errmsg ("tunnel dst address must be unicast");
13189 if (ipv4_set && ipv6_set)
13191 errmsg ("both IPv4 and IPv6 addresses specified");
13195 if ((vni == 0) || (vni >> 24))
13197 errmsg ("vni not specified or out of range");
13201 M (GENEVE_ADD_DEL_TUNNEL, mp);
13205 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13206 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13210 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13211 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13213 mp->encap_vrf_id = ntohl (encap_vrf_id);
13214 mp->decap_next_index = ntohl (decap_next_index);
13215 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13216 mp->vni = ntohl (vni);
13217 mp->is_add = is_add;
13218 mp->is_ipv6 = ipv6_set;
13225 static void vl_api_geneve_tunnel_details_t_handler
13226 (vl_api_geneve_tunnel_details_t * mp)
13228 vat_main_t *vam = &vat_main;
13229 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13230 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13232 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13233 ntohl (mp->sw_if_index),
13234 format_ip46_address, &src, IP46_TYPE_ANY,
13235 format_ip46_address, &dst, IP46_TYPE_ANY,
13236 ntohl (mp->encap_vrf_id),
13237 ntohl (mp->decap_next_index), ntohl (mp->vni),
13238 ntohl (mp->mcast_sw_if_index));
13241 static void vl_api_geneve_tunnel_details_t_handler_json
13242 (vl_api_geneve_tunnel_details_t * mp)
13244 vat_main_t *vam = &vat_main;
13245 vat_json_node_t *node = NULL;
13247 if (VAT_JSON_ARRAY != vam->json_tree.type)
13249 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13250 vat_json_init_array (&vam->json_tree);
13252 node = vat_json_array_add (&vam->json_tree);
13254 vat_json_init_object (node);
13255 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13258 struct in6_addr ip6;
13260 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13261 vat_json_object_add_ip6 (node, "src_address", ip6);
13262 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13263 vat_json_object_add_ip6 (node, "dst_address", ip6);
13267 struct in_addr ip4;
13269 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13270 vat_json_object_add_ip4 (node, "src_address", ip4);
13271 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13272 vat_json_object_add_ip4 (node, "dst_address", ip4);
13274 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13275 vat_json_object_add_uint (node, "decap_next_index",
13276 ntohl (mp->decap_next_index));
13277 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13278 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13279 vat_json_object_add_uint (node, "mcast_sw_if_index",
13280 ntohl (mp->mcast_sw_if_index));
13284 api_geneve_tunnel_dump (vat_main_t * vam)
13286 unformat_input_t *i = vam->input;
13287 vl_api_geneve_tunnel_dump_t *mp;
13288 vl_api_control_ping_t *mp_ping;
13290 u8 sw_if_index_set = 0;
13293 /* Parse args required to build the message */
13294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13296 if (unformat (i, "sw_if_index %d", &sw_if_index))
13297 sw_if_index_set = 1;
13302 if (sw_if_index_set == 0)
13307 if (!vam->json_output)
13309 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13310 "sw_if_index", "local_address", "remote_address",
13311 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13314 /* Get list of geneve-tunnel interfaces */
13315 M (GENEVE_TUNNEL_DUMP, mp);
13317 mp->sw_if_index = htonl (sw_if_index);
13321 /* Use a control ping for synchronization */
13322 M (CONTROL_PING, mp_ping);
13330 api_gre_add_del_tunnel (vat_main_t * vam)
13332 unformat_input_t *line_input = vam->input;
13333 vl_api_gre_add_del_tunnel_t *mp;
13334 ip4_address_t src4, dst4;
13335 ip6_address_t src6, dst6;
13339 u8 t_type = GRE_TUNNEL_TYPE_L3;
13342 u32 outer_fib_id = 0;
13343 u32 session_id = 0;
13347 clib_memset (&src4, 0, sizeof src4);
13348 clib_memset (&dst4, 0, sizeof dst4);
13349 clib_memset (&src6, 0, sizeof src6);
13350 clib_memset (&dst6, 0, sizeof dst6);
13352 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13354 if (unformat (line_input, "del"))
13356 else if (unformat (line_input, "instance %d", &instance))
13358 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13363 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13368 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13373 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13378 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13380 else if (unformat (line_input, "teb"))
13381 t_type = GRE_TUNNEL_TYPE_TEB;
13382 else if (unformat (line_input, "erspan %d", &session_id))
13383 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13386 errmsg ("parse error '%U'", format_unformat_error, line_input);
13393 errmsg ("tunnel src address not specified");
13398 errmsg ("tunnel dst address not specified");
13401 if (ipv4_set && ipv6_set)
13403 errmsg ("both IPv4 and IPv6 addresses specified");
13408 M (GRE_ADD_DEL_TUNNEL, mp);
13412 clib_memcpy (&mp->src_address, &src4, 4);
13413 clib_memcpy (&mp->dst_address, &dst4, 4);
13417 clib_memcpy (&mp->src_address, &src6, 16);
13418 clib_memcpy (&mp->dst_address, &dst6, 16);
13420 mp->instance = htonl (instance);
13421 mp->outer_fib_id = htonl (outer_fib_id);
13422 mp->is_add = is_add;
13423 mp->session_id = htons ((u16) session_id);
13424 mp->tunnel_type = t_type;
13425 mp->is_ipv6 = ipv6_set;
13432 static void vl_api_gre_tunnel_details_t_handler
13433 (vl_api_gre_tunnel_details_t * mp)
13435 vat_main_t *vam = &vat_main;
13436 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13437 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13439 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13440 ntohl (mp->sw_if_index),
13441 ntohl (mp->instance),
13442 format_ip46_address, &src, IP46_TYPE_ANY,
13443 format_ip46_address, &dst, IP46_TYPE_ANY,
13444 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13447 static void vl_api_gre_tunnel_details_t_handler_json
13448 (vl_api_gre_tunnel_details_t * mp)
13450 vat_main_t *vam = &vat_main;
13451 vat_json_node_t *node = NULL;
13452 struct in_addr ip4;
13453 struct in6_addr ip6;
13455 if (VAT_JSON_ARRAY != vam->json_tree.type)
13457 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13458 vat_json_init_array (&vam->json_tree);
13460 node = vat_json_array_add (&vam->json_tree);
13462 vat_json_init_object (node);
13463 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13464 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13467 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13468 vat_json_object_add_ip4 (node, "src_address", ip4);
13469 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13470 vat_json_object_add_ip4 (node, "dst_address", ip4);
13474 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13475 vat_json_object_add_ip6 (node, "src_address", ip6);
13476 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13477 vat_json_object_add_ip6 (node, "dst_address", ip6);
13479 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13480 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13481 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13482 vat_json_object_add_uint (node, "session_id", mp->session_id);
13486 api_gre_tunnel_dump (vat_main_t * vam)
13488 unformat_input_t *i = vam->input;
13489 vl_api_gre_tunnel_dump_t *mp;
13490 vl_api_control_ping_t *mp_ping;
13492 u8 sw_if_index_set = 0;
13495 /* Parse args required to build the message */
13496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13498 if (unformat (i, "sw_if_index %d", &sw_if_index))
13499 sw_if_index_set = 1;
13504 if (sw_if_index_set == 0)
13509 if (!vam->json_output)
13511 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13512 "sw_if_index", "instance", "src_address", "dst_address",
13513 "tunnel_type", "outer_fib_id", "session_id");
13516 /* Get list of gre-tunnel interfaces */
13517 M (GRE_TUNNEL_DUMP, mp);
13519 mp->sw_if_index = htonl (sw_if_index);
13523 /* Use a control ping for synchronization */
13524 MPING (CONTROL_PING, mp_ping);
13532 api_l2_fib_clear_table (vat_main_t * vam)
13534 // unformat_input_t * i = vam->input;
13535 vl_api_l2_fib_clear_table_t *mp;
13538 M (L2_FIB_CLEAR_TABLE, mp);
13546 api_l2_interface_efp_filter (vat_main_t * vam)
13548 unformat_input_t *i = vam->input;
13549 vl_api_l2_interface_efp_filter_t *mp;
13552 u8 sw_if_index_set = 0;
13555 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13557 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13558 sw_if_index_set = 1;
13559 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13560 sw_if_index_set = 1;
13561 else if (unformat (i, "enable"))
13563 else if (unformat (i, "disable"))
13567 clib_warning ("parse error '%U'", format_unformat_error, i);
13572 if (sw_if_index_set == 0)
13574 errmsg ("missing sw_if_index");
13578 M (L2_INTERFACE_EFP_FILTER, mp);
13580 mp->sw_if_index = ntohl (sw_if_index);
13581 mp->enable_disable = enable;
13588 #define foreach_vtr_op \
13589 _("disable", L2_VTR_DISABLED) \
13590 _("push-1", L2_VTR_PUSH_1) \
13591 _("push-2", L2_VTR_PUSH_2) \
13592 _("pop-1", L2_VTR_POP_1) \
13593 _("pop-2", L2_VTR_POP_2) \
13594 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13595 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13596 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13597 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13600 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13602 unformat_input_t *i = vam->input;
13603 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13605 u8 sw_if_index_set = 0;
13608 u32 push_dot1q = 1;
13613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13615 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13616 sw_if_index_set = 1;
13617 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13618 sw_if_index_set = 1;
13619 else if (unformat (i, "vtr_op %d", &vtr_op))
13621 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13624 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13626 else if (unformat (i, "tag1 %d", &tag1))
13628 else if (unformat (i, "tag2 %d", &tag2))
13632 clib_warning ("parse error '%U'", format_unformat_error, i);
13637 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13639 errmsg ("missing vtr operation or sw_if_index");
13643 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13644 mp->sw_if_index = ntohl (sw_if_index);
13645 mp->vtr_op = ntohl (vtr_op);
13646 mp->push_dot1q = ntohl (push_dot1q);
13647 mp->tag1 = ntohl (tag1);
13648 mp->tag2 = ntohl (tag2);
13656 api_create_vhost_user_if (vat_main_t * vam)
13658 unformat_input_t *i = vam->input;
13659 vl_api_create_vhost_user_if_t *mp;
13662 u8 file_name_set = 0;
13663 u32 custom_dev_instance = ~0;
13665 u8 use_custom_mac = 0;
13666 u8 disable_mrg_rxbuf = 0;
13667 u8 disable_indirect_desc = 0;
13671 /* Shut up coverity */
13672 clib_memset (hwaddr, 0, sizeof (hwaddr));
13674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13676 if (unformat (i, "socket %s", &file_name))
13680 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13682 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13683 use_custom_mac = 1;
13684 else if (unformat (i, "server"))
13686 else if (unformat (i, "disable_mrg_rxbuf"))
13687 disable_mrg_rxbuf = 1;
13688 else if (unformat (i, "disable_indirect_desc"))
13689 disable_indirect_desc = 1;
13690 else if (unformat (i, "tag %s", &tag))
13696 if (file_name_set == 0)
13698 errmsg ("missing socket file name");
13702 if (vec_len (file_name) > 255)
13704 errmsg ("socket file name too long");
13707 vec_add1 (file_name, 0);
13709 M (CREATE_VHOST_USER_IF, mp);
13711 mp->is_server = is_server;
13712 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13713 mp->disable_indirect_desc = disable_indirect_desc;
13714 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13715 vec_free (file_name);
13716 if (custom_dev_instance != ~0)
13719 mp->custom_dev_instance = ntohl (custom_dev_instance);
13722 mp->use_custom_mac = use_custom_mac;
13723 clib_memcpy (mp->mac_address, hwaddr, 6);
13725 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13734 api_modify_vhost_user_if (vat_main_t * vam)
13736 unformat_input_t *i = vam->input;
13737 vl_api_modify_vhost_user_if_t *mp;
13740 u8 file_name_set = 0;
13741 u32 custom_dev_instance = ~0;
13742 u8 sw_if_index_set = 0;
13743 u32 sw_if_index = (u32) ~ 0;
13746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13748 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13749 sw_if_index_set = 1;
13750 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13751 sw_if_index_set = 1;
13752 else if (unformat (i, "socket %s", &file_name))
13756 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13758 else if (unformat (i, "server"))
13764 if (sw_if_index_set == 0)
13766 errmsg ("missing sw_if_index or interface name");
13770 if (file_name_set == 0)
13772 errmsg ("missing socket file name");
13776 if (vec_len (file_name) > 255)
13778 errmsg ("socket file name too long");
13781 vec_add1 (file_name, 0);
13783 M (MODIFY_VHOST_USER_IF, mp);
13785 mp->sw_if_index = ntohl (sw_if_index);
13786 mp->is_server = is_server;
13787 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13788 vec_free (file_name);
13789 if (custom_dev_instance != ~0)
13792 mp->custom_dev_instance = ntohl (custom_dev_instance);
13801 api_delete_vhost_user_if (vat_main_t * vam)
13803 unformat_input_t *i = vam->input;
13804 vl_api_delete_vhost_user_if_t *mp;
13805 u32 sw_if_index = ~0;
13806 u8 sw_if_index_set = 0;
13809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13811 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13812 sw_if_index_set = 1;
13813 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13814 sw_if_index_set = 1;
13819 if (sw_if_index_set == 0)
13821 errmsg ("missing sw_if_index or interface name");
13826 M (DELETE_VHOST_USER_IF, mp);
13828 mp->sw_if_index = ntohl (sw_if_index);
13835 static void vl_api_sw_interface_vhost_user_details_t_handler
13836 (vl_api_sw_interface_vhost_user_details_t * mp)
13838 vat_main_t *vam = &vat_main;
13840 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13841 (char *) mp->interface_name,
13842 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13843 clib_net_to_host_u64 (mp->features), mp->is_server,
13844 ntohl (mp->num_regions), (char *) mp->sock_filename);
13845 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13848 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13849 (vl_api_sw_interface_vhost_user_details_t * mp)
13851 vat_main_t *vam = &vat_main;
13852 vat_json_node_t *node = NULL;
13854 if (VAT_JSON_ARRAY != vam->json_tree.type)
13856 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13857 vat_json_init_array (&vam->json_tree);
13859 node = vat_json_array_add (&vam->json_tree);
13861 vat_json_init_object (node);
13862 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13863 vat_json_object_add_string_copy (node, "interface_name",
13864 mp->interface_name);
13865 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13866 ntohl (mp->virtio_net_hdr_sz));
13867 vat_json_object_add_uint (node, "features",
13868 clib_net_to_host_u64 (mp->features));
13869 vat_json_object_add_uint (node, "is_server", mp->is_server);
13870 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13871 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13872 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13876 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13878 vl_api_sw_interface_vhost_user_dump_t *mp;
13879 vl_api_control_ping_t *mp_ping;
13882 "Interface name idx hdr_sz features server regions filename");
13884 /* Get list of vhost-user interfaces */
13885 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13888 /* Use a control ping for synchronization */
13889 MPING (CONTROL_PING, mp_ping);
13897 api_show_version (vat_main_t * vam)
13899 vl_api_show_version_t *mp;
13902 M (SHOW_VERSION, mp);
13911 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13913 unformat_input_t *line_input = vam->input;
13914 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13915 ip4_address_t local4, remote4;
13916 ip6_address_t local6, remote6;
13918 u8 ipv4_set = 0, ipv6_set = 0;
13922 u32 mcast_sw_if_index = ~0;
13923 u32 encap_vrf_id = 0;
13924 u32 decap_vrf_id = 0;
13930 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13931 clib_memset (&local4, 0, sizeof local4);
13932 clib_memset (&remote4, 0, sizeof remote4);
13933 clib_memset (&local6, 0, sizeof local6);
13934 clib_memset (&remote6, 0, sizeof remote6);
13936 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13938 if (unformat (line_input, "del"))
13940 else if (unformat (line_input, "local %U",
13941 unformat_ip4_address, &local4))
13946 else if (unformat (line_input, "remote %U",
13947 unformat_ip4_address, &remote4))
13952 else if (unformat (line_input, "local %U",
13953 unformat_ip6_address, &local6))
13958 else if (unformat (line_input, "remote %U",
13959 unformat_ip6_address, &remote6))
13964 else if (unformat (line_input, "group %U %U",
13965 unformat_ip4_address, &remote4,
13966 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13968 grp_set = remote_set = 1;
13971 else if (unformat (line_input, "group %U",
13972 unformat_ip4_address, &remote4))
13974 grp_set = remote_set = 1;
13977 else if (unformat (line_input, "group %U %U",
13978 unformat_ip6_address, &remote6,
13979 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13981 grp_set = remote_set = 1;
13984 else if (unformat (line_input, "group %U",
13985 unformat_ip6_address, &remote6))
13987 grp_set = remote_set = 1;
13991 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13993 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13995 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13997 else if (unformat (line_input, "vni %d", &vni))
13999 else if (unformat (line_input, "next-ip4"))
14001 else if (unformat (line_input, "next-ip6"))
14003 else if (unformat (line_input, "next-ethernet"))
14005 else if (unformat (line_input, "next-nsh"))
14009 errmsg ("parse error '%U'", format_unformat_error, line_input);
14014 if (local_set == 0)
14016 errmsg ("tunnel local address not specified");
14019 if (remote_set == 0)
14021 errmsg ("tunnel remote address not specified");
14024 if (grp_set && mcast_sw_if_index == ~0)
14026 errmsg ("tunnel nonexistent multicast device");
14029 if (ipv4_set && ipv6_set)
14031 errmsg ("both IPv4 and IPv6 addresses specified");
14037 errmsg ("vni not specified");
14041 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14046 clib_memcpy (&mp->local, &local6, sizeof (local6));
14047 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14051 clib_memcpy (&mp->local, &local4, sizeof (local4));
14052 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14055 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14056 mp->encap_vrf_id = ntohl (encap_vrf_id);
14057 mp->decap_vrf_id = ntohl (decap_vrf_id);
14058 mp->protocol = protocol;
14059 mp->vni = ntohl (vni);
14060 mp->is_add = is_add;
14061 mp->is_ipv6 = ipv6_set;
14068 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14069 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14071 vat_main_t *vam = &vat_main;
14072 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14073 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14075 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14076 ntohl (mp->sw_if_index),
14077 format_ip46_address, &local, IP46_TYPE_ANY,
14078 format_ip46_address, &remote, IP46_TYPE_ANY,
14079 ntohl (mp->vni), mp->protocol,
14080 ntohl (mp->mcast_sw_if_index),
14081 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14085 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14086 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14088 vat_main_t *vam = &vat_main;
14089 vat_json_node_t *node = NULL;
14090 struct in_addr ip4;
14091 struct in6_addr ip6;
14093 if (VAT_JSON_ARRAY != vam->json_tree.type)
14095 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14096 vat_json_init_array (&vam->json_tree);
14098 node = vat_json_array_add (&vam->json_tree);
14100 vat_json_init_object (node);
14101 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14104 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14105 vat_json_object_add_ip6 (node, "local", ip6);
14106 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14107 vat_json_object_add_ip6 (node, "remote", ip6);
14111 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14112 vat_json_object_add_ip4 (node, "local", ip4);
14113 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14114 vat_json_object_add_ip4 (node, "remote", ip4);
14116 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14117 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14118 vat_json_object_add_uint (node, "mcast_sw_if_index",
14119 ntohl (mp->mcast_sw_if_index));
14120 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14121 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14122 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14126 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14128 unformat_input_t *i = vam->input;
14129 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14130 vl_api_control_ping_t *mp_ping;
14132 u8 sw_if_index_set = 0;
14135 /* Parse args required to build the message */
14136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14138 if (unformat (i, "sw_if_index %d", &sw_if_index))
14139 sw_if_index_set = 1;
14144 if (sw_if_index_set == 0)
14149 if (!vam->json_output)
14151 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14152 "sw_if_index", "local", "remote", "vni",
14153 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14156 /* Get list of vxlan-tunnel interfaces */
14157 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14159 mp->sw_if_index = htonl (sw_if_index);
14163 /* Use a control ping for synchronization */
14164 MPING (CONTROL_PING, mp_ping);
14171 static void vl_api_l2_fib_table_details_t_handler
14172 (vl_api_l2_fib_table_details_t * mp)
14174 vat_main_t *vam = &vat_main;
14176 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14178 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14179 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14183 static void vl_api_l2_fib_table_details_t_handler_json
14184 (vl_api_l2_fib_table_details_t * mp)
14186 vat_main_t *vam = &vat_main;
14187 vat_json_node_t *node = NULL;
14189 if (VAT_JSON_ARRAY != vam->json_tree.type)
14191 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14192 vat_json_init_array (&vam->json_tree);
14194 node = vat_json_array_add (&vam->json_tree);
14196 vat_json_init_object (node);
14197 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14198 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14199 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14200 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14201 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14202 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14206 api_l2_fib_table_dump (vat_main_t * vam)
14208 unformat_input_t *i = vam->input;
14209 vl_api_l2_fib_table_dump_t *mp;
14210 vl_api_control_ping_t *mp_ping;
14215 /* Parse args required to build the message */
14216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14218 if (unformat (i, "bd_id %d", &bd_id))
14224 if (bd_id_set == 0)
14226 errmsg ("missing bridge domain");
14230 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14232 /* Get list of l2 fib entries */
14233 M (L2_FIB_TABLE_DUMP, mp);
14235 mp->bd_id = ntohl (bd_id);
14238 /* Use a control ping for synchronization */
14239 MPING (CONTROL_PING, mp_ping);
14248 api_interface_name_renumber (vat_main_t * vam)
14250 unformat_input_t *line_input = vam->input;
14251 vl_api_interface_name_renumber_t *mp;
14252 u32 sw_if_index = ~0;
14253 u32 new_show_dev_instance = ~0;
14256 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14258 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14261 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14263 else if (unformat (line_input, "new_show_dev_instance %d",
14264 &new_show_dev_instance))
14270 if (sw_if_index == ~0)
14272 errmsg ("missing interface name or sw_if_index");
14276 if (new_show_dev_instance == ~0)
14278 errmsg ("missing new_show_dev_instance");
14282 M (INTERFACE_NAME_RENUMBER, mp);
14284 mp->sw_if_index = ntohl (sw_if_index);
14285 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14293 api_ip_probe_neighbor (vat_main_t * vam)
14295 unformat_input_t *i = vam->input;
14296 vl_api_ip_probe_neighbor_t *mp;
14297 vl_api_address_t dst_adr;
14303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14305 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14307 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14309 else if (unformat (i, "address %U", unformat_vl_api_address, dst_adr))
14317 errmsg ("missing interface");
14323 errmsg ("missing addresses");
14327 M (IP_PROBE_NEIGHBOR, mp);
14329 mp->sw_if_index = ntohl (sw_if_index);
14330 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
14338 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14340 unformat_input_t *i = vam->input;
14341 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14342 u8 mode = IP_SCAN_V46_NEIGHBORS;
14343 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14348 if (unformat (i, "ip4"))
14349 mode = IP_SCAN_V4_NEIGHBORS;
14350 else if (unformat (i, "ip6"))
14351 mode = IP_SCAN_V6_NEIGHBORS;
14352 if (unformat (i, "both"))
14353 mode = IP_SCAN_V46_NEIGHBORS;
14354 else if (unformat (i, "disable"))
14355 mode = IP_SCAN_DISABLED;
14356 else if (unformat (i, "interval %d", &interval))
14358 else if (unformat (i, "max-time %d", &time))
14360 else if (unformat (i, "max-update %d", &update))
14362 else if (unformat (i, "delay %d", &delay))
14364 else if (unformat (i, "stale %d", &stale))
14370 if (interval > 255)
14372 errmsg ("interval cannot exceed 255 minutes.");
14377 errmsg ("max-time cannot exceed 255 usec.");
14382 errmsg ("max-update cannot exceed 255.");
14387 errmsg ("delay cannot exceed 255 msec.");
14392 errmsg ("stale cannot exceed 255 minutes.");
14396 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14398 mp->scan_interval = interval;
14399 mp->max_proc_time = time;
14400 mp->max_update = update;
14401 mp->scan_int_delay = delay;
14402 mp->stale_threshold = stale;
14410 api_want_ip4_arp_events (vat_main_t * vam)
14412 unformat_input_t *line_input = vam->input;
14413 vl_api_want_ip4_arp_events_t *mp;
14414 ip4_address_t address;
14415 int address_set = 0;
14416 u32 enable_disable = 1;
14419 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14421 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14423 else if (unformat (line_input, "del"))
14424 enable_disable = 0;
14429 if (address_set == 0)
14431 errmsg ("missing addresses");
14435 M (WANT_IP4_ARP_EVENTS, mp);
14436 mp->enable_disable = enable_disable;
14437 mp->pid = htonl (getpid ());
14438 clib_memcpy (mp->ip, &address, sizeof (address));
14446 api_want_ip6_nd_events (vat_main_t * vam)
14448 unformat_input_t *line_input = vam->input;
14449 vl_api_want_ip6_nd_events_t *mp;
14450 vl_api_ip6_address_t address;
14451 int address_set = 0;
14452 u32 enable_disable = 1;
14455 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14458 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
14460 else if (unformat (line_input, "del"))
14461 enable_disable = 0;
14466 if (address_set == 0)
14468 errmsg ("missing addresses");
14472 M (WANT_IP6_ND_EVENTS, mp);
14473 mp->enable_disable = enable_disable;
14474 mp->pid = htonl (getpid ());
14475 clib_memcpy (&mp->ip, &address, sizeof (address));
14483 api_want_l2_macs_events (vat_main_t * vam)
14485 unformat_input_t *line_input = vam->input;
14486 vl_api_want_l2_macs_events_t *mp;
14487 u8 enable_disable = 1;
14488 u32 scan_delay = 0;
14489 u32 max_macs_in_event = 0;
14490 u32 learn_limit = 0;
14493 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14495 if (unformat (line_input, "learn-limit %d", &learn_limit))
14497 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14499 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14501 else if (unformat (line_input, "disable"))
14502 enable_disable = 0;
14507 M (WANT_L2_MACS_EVENTS, mp);
14508 mp->enable_disable = enable_disable;
14509 mp->pid = htonl (getpid ());
14510 mp->learn_limit = htonl (learn_limit);
14511 mp->scan_delay = (u8) scan_delay;
14512 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14519 api_input_acl_set_interface (vat_main_t * vam)
14521 unformat_input_t *i = vam->input;
14522 vl_api_input_acl_set_interface_t *mp;
14524 int sw_if_index_set;
14525 u32 ip4_table_index = ~0;
14526 u32 ip6_table_index = ~0;
14527 u32 l2_table_index = ~0;
14531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14533 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14534 sw_if_index_set = 1;
14535 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14536 sw_if_index_set = 1;
14537 else if (unformat (i, "del"))
14539 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14541 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14543 else if (unformat (i, "l2-table %d", &l2_table_index))
14547 clib_warning ("parse error '%U'", format_unformat_error, i);
14552 if (sw_if_index_set == 0)
14554 errmsg ("missing interface name or sw_if_index");
14558 M (INPUT_ACL_SET_INTERFACE, mp);
14560 mp->sw_if_index = ntohl (sw_if_index);
14561 mp->ip4_table_index = ntohl (ip4_table_index);
14562 mp->ip6_table_index = ntohl (ip6_table_index);
14563 mp->l2_table_index = ntohl (l2_table_index);
14564 mp->is_add = is_add;
14572 api_output_acl_set_interface (vat_main_t * vam)
14574 unformat_input_t *i = vam->input;
14575 vl_api_output_acl_set_interface_t *mp;
14577 int sw_if_index_set;
14578 u32 ip4_table_index = ~0;
14579 u32 ip6_table_index = ~0;
14580 u32 l2_table_index = ~0;
14584 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14586 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14587 sw_if_index_set = 1;
14588 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14589 sw_if_index_set = 1;
14590 else if (unformat (i, "del"))
14592 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14594 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14596 else if (unformat (i, "l2-table %d", &l2_table_index))
14600 clib_warning ("parse error '%U'", format_unformat_error, i);
14605 if (sw_if_index_set == 0)
14607 errmsg ("missing interface name or sw_if_index");
14611 M (OUTPUT_ACL_SET_INTERFACE, mp);
14613 mp->sw_if_index = ntohl (sw_if_index);
14614 mp->ip4_table_index = ntohl (ip4_table_index);
14615 mp->ip6_table_index = ntohl (ip6_table_index);
14616 mp->l2_table_index = ntohl (l2_table_index);
14617 mp->is_add = is_add;
14625 api_ip_address_dump (vat_main_t * vam)
14627 unformat_input_t *i = vam->input;
14628 vl_api_ip_address_dump_t *mp;
14629 vl_api_control_ping_t *mp_ping;
14630 u32 sw_if_index = ~0;
14631 u8 sw_if_index_set = 0;
14636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14638 if (unformat (i, "sw_if_index %d", &sw_if_index))
14639 sw_if_index_set = 1;
14641 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14642 sw_if_index_set = 1;
14643 else if (unformat (i, "ipv4"))
14645 else if (unformat (i, "ipv6"))
14651 if (ipv4_set && ipv6_set)
14653 errmsg ("ipv4 and ipv6 flags cannot be both set");
14657 if ((!ipv4_set) && (!ipv6_set))
14659 errmsg ("no ipv4 nor ipv6 flag set");
14663 if (sw_if_index_set == 0)
14665 errmsg ("missing interface name or sw_if_index");
14669 vam->current_sw_if_index = sw_if_index;
14670 vam->is_ipv6 = ipv6_set;
14672 M (IP_ADDRESS_DUMP, mp);
14673 mp->sw_if_index = ntohl (sw_if_index);
14674 mp->is_ipv6 = ipv6_set;
14677 /* Use a control ping for synchronization */
14678 MPING (CONTROL_PING, mp_ping);
14686 api_ip_dump (vat_main_t * vam)
14688 vl_api_ip_dump_t *mp;
14689 vl_api_control_ping_t *mp_ping;
14690 unformat_input_t *in = vam->input;
14697 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14699 if (unformat (in, "ipv4"))
14701 else if (unformat (in, "ipv6"))
14707 if (ipv4_set && ipv6_set)
14709 errmsg ("ipv4 and ipv6 flags cannot be both set");
14713 if ((!ipv4_set) && (!ipv6_set))
14715 errmsg ("no ipv4 nor ipv6 flag set");
14719 is_ipv6 = ipv6_set;
14720 vam->is_ipv6 = is_ipv6;
14722 /* free old data */
14723 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14725 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14727 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14730 mp->is_ipv6 = ipv6_set;
14733 /* Use a control ping for synchronization */
14734 MPING (CONTROL_PING, mp_ping);
14742 api_ipsec_spd_add_del (vat_main_t * vam)
14744 unformat_input_t *i = vam->input;
14745 vl_api_ipsec_spd_add_del_t *mp;
14750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14752 if (unformat (i, "spd_id %d", &spd_id))
14754 else if (unformat (i, "del"))
14758 clib_warning ("parse error '%U'", format_unformat_error, i);
14764 errmsg ("spd_id must be set");
14768 M (IPSEC_SPD_ADD_DEL, mp);
14770 mp->spd_id = ntohl (spd_id);
14771 mp->is_add = is_add;
14779 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14781 unformat_input_t *i = vam->input;
14782 vl_api_ipsec_interface_add_del_spd_t *mp;
14784 u8 sw_if_index_set = 0;
14785 u32 spd_id = (u32) ~ 0;
14789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14791 if (unformat (i, "del"))
14793 else if (unformat (i, "spd_id %d", &spd_id))
14796 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14797 sw_if_index_set = 1;
14798 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14799 sw_if_index_set = 1;
14802 clib_warning ("parse error '%U'", format_unformat_error, i);
14808 if (spd_id == (u32) ~ 0)
14810 errmsg ("spd_id must be set");
14814 if (sw_if_index_set == 0)
14816 errmsg ("missing interface name or sw_if_index");
14820 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14822 mp->spd_id = ntohl (spd_id);
14823 mp->sw_if_index = ntohl (sw_if_index);
14824 mp->is_add = is_add;
14832 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14834 unformat_input_t *i = vam->input;
14835 vl_api_ipsec_spd_entry_add_del_t *mp;
14836 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14837 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14839 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14840 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14841 vl_api_address_t laddr_start = { }, laddr_stop =
14850 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14852 if (unformat (i, "del"))
14854 if (unformat (i, "outbound"))
14856 if (unformat (i, "inbound"))
14858 else if (unformat (i, "spd_id %d", &spd_id))
14860 else if (unformat (i, "sa_id %d", &sa_id))
14862 else if (unformat (i, "priority %d", &priority))
14864 else if (unformat (i, "protocol %d", &protocol))
14866 else if (unformat (i, "lport_start %d", &lport_start))
14868 else if (unformat (i, "lport_stop %d", &lport_stop))
14870 else if (unformat (i, "rport_start %d", &rport_start))
14872 else if (unformat (i, "rport_stop %d", &rport_stop))
14874 else if (unformat (i, "laddr_start %U",
14875 unformat_vl_api_address, &laddr_start))
14877 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14880 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14883 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14887 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14889 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14891 clib_warning ("unsupported action: 'resolve'");
14897 clib_warning ("parse error '%U'", format_unformat_error, i);
14903 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14905 mp->is_add = is_add;
14907 mp->entry.spd_id = ntohl (spd_id);
14908 mp->entry.priority = ntohl (priority);
14909 mp->entry.is_outbound = is_outbound;
14911 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14912 sizeof (vl_api_address_t));
14913 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14914 sizeof (vl_api_address_t));
14915 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14916 sizeof (vl_api_address_t));
14917 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14918 sizeof (vl_api_address_t));
14920 mp->entry.protocol = (u8) protocol;
14921 mp->entry.local_port_start = ntohs ((u16) lport_start);
14922 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14923 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14924 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14925 mp->entry.policy = (u8) policy;
14926 mp->entry.sa_id = ntohl (sa_id);
14934 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14936 unformat_input_t *i = vam->input;
14937 vl_api_ipsec_sad_entry_add_del_t *mp;
14938 u32 sad_id = 0, spi = 0;
14939 u8 *ck = 0, *ik = 0;
14942 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14943 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14944 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14945 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14946 vl_api_address_t tun_src, tun_dst;
14949 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14951 if (unformat (i, "del"))
14953 else if (unformat (i, "sad_id %d", &sad_id))
14955 else if (unformat (i, "spi %d", &spi))
14957 else if (unformat (i, "esp"))
14958 protocol = IPSEC_API_PROTO_ESP;
14960 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14962 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14963 if (ADDRESS_IP6 == tun_src.af)
14964 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14967 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14969 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14970 if (ADDRESS_IP6 == tun_src.af)
14971 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14974 if (unformat (i, "crypto_alg %U",
14975 unformat_ipsec_api_crypto_alg, &crypto_alg))
14977 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14979 else if (unformat (i, "integ_alg %U",
14980 unformat_ipsec_api_integ_alg, &integ_alg))
14982 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14986 clib_warning ("parse error '%U'", format_unformat_error, i);
14992 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14994 mp->is_add = is_add;
14995 mp->entry.sad_id = ntohl (sad_id);
14996 mp->entry.protocol = protocol;
14997 mp->entry.spi = ntohl (spi);
14998 mp->entry.flags = flags;
15000 mp->entry.crypto_algorithm = crypto_alg;
15001 mp->entry.integrity_algorithm = integ_alg;
15002 mp->entry.crypto_key.length = vec_len (ck);
15003 mp->entry.integrity_key.length = vec_len (ik);
15005 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
15006 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
15008 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
15009 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
15012 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
15014 clib_memcpy (mp->entry.integrity_key.data, ik,
15015 mp->entry.integrity_key.length);
15017 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
15019 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
15020 sizeof (mp->entry.tunnel_src));
15021 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
15022 sizeof (mp->entry.tunnel_dst));
15031 api_ipsec_sa_set_key (vat_main_t * vam)
15033 unformat_input_t *i = vam->input;
15034 vl_api_ipsec_sa_set_key_t *mp;
15036 u8 *ck = 0, *ik = 0;
15039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15041 if (unformat (i, "sa_id %d", &sa_id))
15043 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15045 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15049 clib_warning ("parse error '%U'", format_unformat_error, i);
15054 M (IPSEC_SA_SET_KEY, mp);
15056 mp->sa_id = ntohl (sa_id);
15057 mp->crypto_key.length = vec_len (ck);
15058 mp->integrity_key.length = vec_len (ik);
15060 if (mp->crypto_key.length > sizeof (mp->crypto_key.data))
15061 mp->crypto_key.length = sizeof (mp->crypto_key.data);
15063 if (mp->integrity_key.length > sizeof (mp->integrity_key.data))
15064 mp->integrity_key.length = sizeof (mp->integrity_key.data);
15067 clib_memcpy (mp->crypto_key.data, ck, mp->crypto_key.length);
15069 clib_memcpy (mp->integrity_key.data, ik, mp->integrity_key.length);
15077 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15079 unformat_input_t *i = vam->input;
15080 vl_api_ipsec_tunnel_if_add_del_t *mp;
15081 u32 local_spi = 0, remote_spi = 0;
15082 u32 crypto_alg = 0, integ_alg = 0;
15083 u8 *lck = NULL, *rck = NULL;
15084 u8 *lik = NULL, *rik = NULL;
15085 ip4_address_t local_ip = { {0} };
15086 ip4_address_t remote_ip = { {0} };
15089 u8 anti_replay = 0;
15094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15096 if (unformat (i, "del"))
15098 else if (unformat (i, "esn"))
15100 else if (unformat (i, "anti_replay"))
15102 else if (unformat (i, "local_spi %d", &local_spi))
15104 else if (unformat (i, "remote_spi %d", &remote_spi))
15106 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15108 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15110 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15113 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15115 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15117 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15121 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
15123 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15125 errmsg ("unsupported crypto-alg: '%U'\n",
15126 format_ipsec_crypto_alg, crypto_alg);
15132 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
15134 if (integ_alg >= IPSEC_INTEG_N_ALG)
15136 errmsg ("unsupported integ-alg: '%U'\n",
15137 format_ipsec_integ_alg, integ_alg);
15141 else if (unformat (i, "instance %u", &instance))
15145 errmsg ("parse error '%U'\n", format_unformat_error, i);
15150 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15152 mp->is_add = is_add;
15154 mp->anti_replay = anti_replay;
15156 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15157 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15159 mp->local_spi = htonl (local_spi);
15160 mp->remote_spi = htonl (remote_spi);
15161 mp->crypto_alg = (u8) crypto_alg;
15163 mp->local_crypto_key_len = 0;
15166 mp->local_crypto_key_len = vec_len (lck);
15167 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15168 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15169 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15172 mp->remote_crypto_key_len = 0;
15175 mp->remote_crypto_key_len = vec_len (rck);
15176 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15177 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15178 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15181 mp->integ_alg = (u8) integ_alg;
15183 mp->local_integ_key_len = 0;
15186 mp->local_integ_key_len = vec_len (lik);
15187 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15188 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15189 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15192 mp->remote_integ_key_len = 0;
15195 mp->remote_integ_key_len = vec_len (rik);
15196 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15197 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15198 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15203 mp->renumber = renumber;
15204 mp->show_instance = ntohl (instance);
15213 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15215 vat_main_t *vam = &vat_main;
15217 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15218 "crypto_key %U integ_alg %u integ_key %U flags %x "
15219 "tunnel_src_addr %U tunnel_dst_addr %U "
15220 "salt %u seq_outbound %lu last_seq_inbound %lu "
15221 "replay_window %lu total_data_size %lu\n",
15222 ntohl (mp->entry.sad_id),
15223 ntohl (mp->sw_if_index),
15224 ntohl (mp->entry.spi),
15225 ntohl (mp->entry.protocol),
15226 ntohl (mp->entry.crypto_algorithm),
15227 format_hex_bytes, mp->entry.crypto_key.data,
15228 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
15229 format_hex_bytes, mp->entry.integrity_key.data,
15230 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
15231 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
15232 &mp->entry.tunnel_dst, ntohl (mp->salt),
15233 clib_net_to_host_u64 (mp->seq_outbound),
15234 clib_net_to_host_u64 (mp->last_seq_inbound),
15235 clib_net_to_host_u64 (mp->replay_window),
15236 clib_net_to_host_u64 (mp->total_data_size));
15239 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15240 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15243 vat_json_object_add_address (vat_json_node_t * node,
15244 const vl_api_address_t * addr)
15246 if (ADDRESS_IP6 == addr->af)
15248 struct in6_addr ip6;
15250 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
15251 vat_json_object_add_ip6 (node, "ip_address", ip6);
15255 struct in_addr ip4;
15257 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
15258 vat_json_object_add_ip4 (node, "ip_address", ip4);
15262 static void vl_api_ipsec_sa_details_t_handler_json
15263 (vl_api_ipsec_sa_details_t * mp)
15265 vat_main_t *vam = &vat_main;
15266 vat_json_node_t *node = NULL;
15267 vl_api_ipsec_sad_flags_t flags;
15269 if (VAT_JSON_ARRAY != vam->json_tree.type)
15271 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15272 vat_json_init_array (&vam->json_tree);
15274 node = vat_json_array_add (&vam->json_tree);
15276 vat_json_init_object (node);
15277 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
15278 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15279 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
15280 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
15281 vat_json_object_add_uint (node, "crypto_alg",
15282 ntohl (mp->entry.crypto_algorithm));
15283 vat_json_object_add_uint (node, "integ_alg",
15284 ntohl (mp->entry.integrity_algorithm));
15285 flags = ntohl (mp->entry.flags);
15286 vat_json_object_add_uint (node, "use_esn",
15288 IPSEC_API_SAD_FLAG_USE_EXTENDED_SEQ_NUM));
15289 vat_json_object_add_uint (node, "use_anti_replay",
15290 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
15291 vat_json_object_add_uint (node, "is_tunnel",
15292 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
15293 vat_json_object_add_uint (node, "is_tunnel_ip6",
15294 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
15295 vat_json_object_add_uint (node, "udp_encap",
15296 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
15297 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
15298 mp->entry.crypto_key.length);
15299 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
15300 mp->entry.integrity_key.length);
15301 vat_json_object_add_address (node, &mp->entry.tunnel_src);
15302 vat_json_object_add_address (node, &mp->entry.tunnel_dst);
15303 vat_json_object_add_uint (node, "replay_window",
15304 clib_net_to_host_u64 (mp->replay_window));
15305 vat_json_object_add_uint (node, "total_data_size",
15306 clib_net_to_host_u64 (mp->total_data_size));
15310 api_ipsec_sa_dump (vat_main_t * vam)
15312 unformat_input_t *i = vam->input;
15313 vl_api_ipsec_sa_dump_t *mp;
15314 vl_api_control_ping_t *mp_ping;
15318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15320 if (unformat (i, "sa_id %d", &sa_id))
15324 clib_warning ("parse error '%U'", format_unformat_error, i);
15329 M (IPSEC_SA_DUMP, mp);
15331 mp->sa_id = ntohl (sa_id);
15335 /* Use a control ping for synchronization */
15336 M (CONTROL_PING, mp_ping);
15344 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15346 unformat_input_t *i = vam->input;
15347 vl_api_ipsec_tunnel_if_set_key_t *mp;
15348 u32 sw_if_index = ~0;
15349 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15356 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15360 (i, "local crypto %U", unformat_ipsec_api_crypto_alg, &alg))
15361 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15364 (i, "remote crypto %U", unformat_ipsec_api_crypto_alg, &alg))
15365 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15368 (i, "local integ %U", unformat_ipsec_api_integ_alg, &alg))
15369 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15372 (i, "remote integ %U", unformat_ipsec_api_integ_alg, &alg))
15373 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15374 else if (unformat (i, "%U", unformat_hex_string, &key))
15378 clib_warning ("parse error '%U'", format_unformat_error, i);
15383 if (sw_if_index == ~0)
15385 errmsg ("interface must be specified");
15389 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15391 errmsg ("key type must be specified");
15397 errmsg ("algorithm must be specified");
15401 if (vec_len (key) == 0)
15403 errmsg ("key must be specified");
15407 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15409 mp->sw_if_index = htonl (sw_if_index);
15411 mp->key_type = key_type;
15412 mp->key_len = vec_len (key);
15413 clib_memcpy (mp->key, key, vec_len (key));
15422 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15424 unformat_input_t *i = vam->input;
15425 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15426 u32 sw_if_index = ~0;
15428 u8 is_outbound = (u8) ~ 0;
15431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15433 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15435 else if (unformat (i, "sa_id %d", &sa_id))
15437 else if (unformat (i, "outbound"))
15439 else if (unformat (i, "inbound"))
15443 clib_warning ("parse error '%U'", format_unformat_error, i);
15448 if (sw_if_index == ~0)
15450 errmsg ("interface must be specified");
15456 errmsg ("SA ID must be specified");
15460 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15462 mp->sw_if_index = htonl (sw_if_index);
15463 mp->sa_id = htonl (sa_id);
15464 mp->is_outbound = is_outbound;
15473 api_ikev2_profile_add_del (vat_main_t * vam)
15475 unformat_input_t *i = vam->input;
15476 vl_api_ikev2_profile_add_del_t *mp;
15481 const char *valid_chars = "a-zA-Z0-9_";
15483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15485 if (unformat (i, "del"))
15487 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15488 vec_add1 (name, 0);
15491 errmsg ("parse error '%U'", format_unformat_error, i);
15496 if (!vec_len (name))
15498 errmsg ("profile name must be specified");
15502 if (vec_len (name) > 64)
15504 errmsg ("profile name too long");
15508 M (IKEV2_PROFILE_ADD_DEL, mp);
15510 clib_memcpy (mp->name, name, vec_len (name));
15511 mp->is_add = is_add;
15520 api_ikev2_profile_set_auth (vat_main_t * vam)
15522 unformat_input_t *i = vam->input;
15523 vl_api_ikev2_profile_set_auth_t *mp;
15526 u32 auth_method = 0;
15530 const char *valid_chars = "a-zA-Z0-9_";
15532 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15534 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15535 vec_add1 (name, 0);
15536 else if (unformat (i, "auth_method %U",
15537 unformat_ikev2_auth_method, &auth_method))
15539 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15541 else if (unformat (i, "auth_data %v", &data))
15545 errmsg ("parse error '%U'", format_unformat_error, i);
15550 if (!vec_len (name))
15552 errmsg ("profile name must be specified");
15556 if (vec_len (name) > 64)
15558 errmsg ("profile name too long");
15562 if (!vec_len (data))
15564 errmsg ("auth_data must be specified");
15570 errmsg ("auth_method must be specified");
15574 M (IKEV2_PROFILE_SET_AUTH, mp);
15576 mp->is_hex = is_hex;
15577 mp->auth_method = (u8) auth_method;
15578 mp->data_len = vec_len (data);
15579 clib_memcpy (mp->name, name, vec_len (name));
15580 clib_memcpy (mp->data, data, vec_len (data));
15590 api_ikev2_profile_set_id (vat_main_t * vam)
15592 unformat_input_t *i = vam->input;
15593 vl_api_ikev2_profile_set_id_t *mp;
15601 const char *valid_chars = "a-zA-Z0-9_";
15603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15605 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15606 vec_add1 (name, 0);
15607 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15609 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15611 data = vec_new (u8, 4);
15612 clib_memcpy (data, ip4.as_u8, 4);
15614 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15616 else if (unformat (i, "id_data %v", &data))
15618 else if (unformat (i, "local"))
15620 else if (unformat (i, "remote"))
15624 errmsg ("parse error '%U'", format_unformat_error, i);
15629 if (!vec_len (name))
15631 errmsg ("profile name must be specified");
15635 if (vec_len (name) > 64)
15637 errmsg ("profile name too long");
15641 if (!vec_len (data))
15643 errmsg ("id_data must be specified");
15649 errmsg ("id_type must be specified");
15653 M (IKEV2_PROFILE_SET_ID, mp);
15655 mp->is_local = is_local;
15656 mp->id_type = (u8) id_type;
15657 mp->data_len = vec_len (data);
15658 clib_memcpy (mp->name, name, vec_len (name));
15659 clib_memcpy (mp->data, data, vec_len (data));
15669 api_ikev2_profile_set_ts (vat_main_t * vam)
15671 unformat_input_t *i = vam->input;
15672 vl_api_ikev2_profile_set_ts_t *mp;
15675 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15676 ip4_address_t start_addr, end_addr;
15678 const char *valid_chars = "a-zA-Z0-9_";
15681 start_addr.as_u32 = 0;
15682 end_addr.as_u32 = (u32) ~ 0;
15684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15686 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15687 vec_add1 (name, 0);
15688 else if (unformat (i, "protocol %d", &proto))
15690 else if (unformat (i, "start_port %d", &start_port))
15692 else if (unformat (i, "end_port %d", &end_port))
15695 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15697 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15699 else if (unformat (i, "local"))
15701 else if (unformat (i, "remote"))
15705 errmsg ("parse error '%U'", format_unformat_error, i);
15710 if (!vec_len (name))
15712 errmsg ("profile name must be specified");
15716 if (vec_len (name) > 64)
15718 errmsg ("profile name too long");
15722 M (IKEV2_PROFILE_SET_TS, mp);
15724 mp->is_local = is_local;
15725 mp->proto = (u8) proto;
15726 mp->start_port = (u16) start_port;
15727 mp->end_port = (u16) end_port;
15728 mp->start_addr = start_addr.as_u32;
15729 mp->end_addr = end_addr.as_u32;
15730 clib_memcpy (mp->name, name, vec_len (name));
15739 api_ikev2_set_local_key (vat_main_t * vam)
15741 unformat_input_t *i = vam->input;
15742 vl_api_ikev2_set_local_key_t *mp;
15746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15748 if (unformat (i, "file %v", &file))
15749 vec_add1 (file, 0);
15752 errmsg ("parse error '%U'", format_unformat_error, i);
15757 if (!vec_len (file))
15759 errmsg ("RSA key file must be specified");
15763 if (vec_len (file) > 256)
15765 errmsg ("file name too long");
15769 M (IKEV2_SET_LOCAL_KEY, mp);
15771 clib_memcpy (mp->key_file, file, vec_len (file));
15780 api_ikev2_set_responder (vat_main_t * vam)
15782 unformat_input_t *i = vam->input;
15783 vl_api_ikev2_set_responder_t *mp;
15786 u32 sw_if_index = ~0;
15787 ip4_address_t address;
15789 const char *valid_chars = "a-zA-Z0-9_";
15791 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15794 (i, "%U interface %d address %U", unformat_token, valid_chars,
15795 &name, &sw_if_index, unformat_ip4_address, &address))
15796 vec_add1 (name, 0);
15799 errmsg ("parse error '%U'", format_unformat_error, i);
15804 if (!vec_len (name))
15806 errmsg ("profile name must be specified");
15810 if (vec_len (name) > 64)
15812 errmsg ("profile name too long");
15816 M (IKEV2_SET_RESPONDER, mp);
15818 clib_memcpy (mp->name, name, vec_len (name));
15821 mp->sw_if_index = sw_if_index;
15822 clib_memcpy (mp->address, &address, sizeof (address));
15830 api_ikev2_set_ike_transforms (vat_main_t * vam)
15832 unformat_input_t *i = vam->input;
15833 vl_api_ikev2_set_ike_transforms_t *mp;
15836 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15838 const char *valid_chars = "a-zA-Z0-9_";
15840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15842 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15843 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15844 vec_add1 (name, 0);
15847 errmsg ("parse error '%U'", format_unformat_error, i);
15852 if (!vec_len (name))
15854 errmsg ("profile name must be specified");
15858 if (vec_len (name) > 64)
15860 errmsg ("profile name too long");
15864 M (IKEV2_SET_IKE_TRANSFORMS, mp);
15866 clib_memcpy (mp->name, name, vec_len (name));
15868 mp->crypto_alg = crypto_alg;
15869 mp->crypto_key_size = crypto_key_size;
15870 mp->integ_alg = integ_alg;
15871 mp->dh_group = dh_group;
15880 api_ikev2_set_esp_transforms (vat_main_t * vam)
15882 unformat_input_t *i = vam->input;
15883 vl_api_ikev2_set_esp_transforms_t *mp;
15886 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15888 const char *valid_chars = "a-zA-Z0-9_";
15890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15892 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15893 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15894 vec_add1 (name, 0);
15897 errmsg ("parse error '%U'", format_unformat_error, i);
15902 if (!vec_len (name))
15904 errmsg ("profile name must be specified");
15908 if (vec_len (name) > 64)
15910 errmsg ("profile name too long");
15914 M (IKEV2_SET_ESP_TRANSFORMS, mp);
15916 clib_memcpy (mp->name, name, vec_len (name));
15918 mp->crypto_alg = crypto_alg;
15919 mp->crypto_key_size = crypto_key_size;
15920 mp->integ_alg = integ_alg;
15921 mp->dh_group = dh_group;
15929 api_ikev2_set_sa_lifetime (vat_main_t * vam)
15931 unformat_input_t *i = vam->input;
15932 vl_api_ikev2_set_sa_lifetime_t *mp;
15935 u64 lifetime, lifetime_maxdata;
15936 u32 lifetime_jitter, handover;
15938 const char *valid_chars = "a-zA-Z0-9_";
15940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15942 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
15943 &lifetime, &lifetime_jitter, &handover,
15944 &lifetime_maxdata))
15945 vec_add1 (name, 0);
15948 errmsg ("parse error '%U'", format_unformat_error, i);
15953 if (!vec_len (name))
15955 errmsg ("profile name must be specified");
15959 if (vec_len (name) > 64)
15961 errmsg ("profile name too long");
15965 M (IKEV2_SET_SA_LIFETIME, mp);
15967 clib_memcpy (mp->name, name, vec_len (name));
15969 mp->lifetime = lifetime;
15970 mp->lifetime_jitter = lifetime_jitter;
15971 mp->handover = handover;
15972 mp->lifetime_maxdata = lifetime_maxdata;
15980 api_ikev2_initiate_sa_init (vat_main_t * vam)
15982 unformat_input_t *i = vam->input;
15983 vl_api_ikev2_initiate_sa_init_t *mp;
15987 const char *valid_chars = "a-zA-Z0-9_";
15989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15991 if (unformat (i, "%U", unformat_token, valid_chars, &name))
15992 vec_add1 (name, 0);
15995 errmsg ("parse error '%U'", format_unformat_error, i);
16000 if (!vec_len (name))
16002 errmsg ("profile name must be specified");
16006 if (vec_len (name) > 64)
16008 errmsg ("profile name too long");
16012 M (IKEV2_INITIATE_SA_INIT, mp);
16014 clib_memcpy (mp->name, name, vec_len (name));
16023 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16025 unformat_input_t *i = vam->input;
16026 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16033 if (unformat (i, "%lx", &ispi))
16037 errmsg ("parse error '%U'", format_unformat_error, i);
16042 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16052 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16054 unformat_input_t *i = vam->input;
16055 vl_api_ikev2_initiate_del_child_sa_t *mp;
16060 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16062 if (unformat (i, "%x", &ispi))
16066 errmsg ("parse error '%U'", format_unformat_error, i);
16071 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16081 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16083 unformat_input_t *i = vam->input;
16084 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16091 if (unformat (i, "%x", &ispi))
16095 errmsg ("parse error '%U'", format_unformat_error, i);
16100 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16110 api_get_first_msg_id (vat_main_t * vam)
16112 vl_api_get_first_msg_id_t *mp;
16113 unformat_input_t *i = vam->input;
16118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16120 if (unformat (i, "client %s", &name))
16128 errmsg ("missing client name");
16131 vec_add1 (name, 0);
16133 if (vec_len (name) > 63)
16135 errmsg ("client name too long");
16139 M (GET_FIRST_MSG_ID, mp);
16140 clib_memcpy (mp->name, name, vec_len (name));
16147 api_cop_interface_enable_disable (vat_main_t * vam)
16149 unformat_input_t *line_input = vam->input;
16150 vl_api_cop_interface_enable_disable_t *mp;
16151 u32 sw_if_index = ~0;
16152 u8 enable_disable = 1;
16155 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16157 if (unformat (line_input, "disable"))
16158 enable_disable = 0;
16159 if (unformat (line_input, "enable"))
16160 enable_disable = 1;
16161 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16162 vam, &sw_if_index))
16164 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16170 if (sw_if_index == ~0)
16172 errmsg ("missing interface name or sw_if_index");
16176 /* Construct the API message */
16177 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16178 mp->sw_if_index = ntohl (sw_if_index);
16179 mp->enable_disable = enable_disable;
16183 /* Wait for the reply */
16189 api_cop_whitelist_enable_disable (vat_main_t * vam)
16191 unformat_input_t *line_input = vam->input;
16192 vl_api_cop_whitelist_enable_disable_t *mp;
16193 u32 sw_if_index = ~0;
16194 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16198 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16200 if (unformat (line_input, "ip4"))
16202 else if (unformat (line_input, "ip6"))
16204 else if (unformat (line_input, "default"))
16206 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16207 vam, &sw_if_index))
16209 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16211 else if (unformat (line_input, "fib-id %d", &fib_id))
16217 if (sw_if_index == ~0)
16219 errmsg ("missing interface name or sw_if_index");
16223 /* Construct the API message */
16224 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16225 mp->sw_if_index = ntohl (sw_if_index);
16226 mp->fib_id = ntohl (fib_id);
16229 mp->default_cop = default_cop;
16233 /* Wait for the reply */
16239 api_get_node_graph (vat_main_t * vam)
16241 vl_api_get_node_graph_t *mp;
16244 M (GET_NODE_GRAPH, mp);
16248 /* Wait for the reply */
16254 /** Used for parsing LISP eids */
16255 typedef CLIB_PACKED(struct{
16256 u8 addr[16]; /**< eid address */
16257 u32 len; /**< prefix length if IP */
16258 u8 type; /**< type of eid */
16263 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16265 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16267 clib_memset (a, 0, sizeof (a[0]));
16269 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16271 a->type = 0; /* ipv4 type */
16273 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16275 a->type = 1; /* ipv6 type */
16277 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16279 a->type = 2; /* mac type */
16281 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16283 a->type = 3; /* NSH type */
16284 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16285 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16292 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16301 lisp_eid_size_vat (u8 type)
16318 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16320 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16324 api_one_add_del_locator_set (vat_main_t * vam)
16326 unformat_input_t *input = vam->input;
16327 vl_api_one_add_del_locator_set_t *mp;
16329 u8 *locator_set_name = NULL;
16330 u8 locator_set_name_set = 0;
16331 vl_api_local_locator_t locator, *locators = 0;
16332 u32 sw_if_index, priority, weight;
16336 /* Parse args required to build the message */
16337 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16339 if (unformat (input, "del"))
16343 else if (unformat (input, "locator-set %s", &locator_set_name))
16345 locator_set_name_set = 1;
16347 else if (unformat (input, "sw_if_index %u p %u w %u",
16348 &sw_if_index, &priority, &weight))
16350 locator.sw_if_index = htonl (sw_if_index);
16351 locator.priority = priority;
16352 locator.weight = weight;
16353 vec_add1 (locators, locator);
16357 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16358 &sw_if_index, &priority, &weight))
16360 locator.sw_if_index = htonl (sw_if_index);
16361 locator.priority = priority;
16362 locator.weight = weight;
16363 vec_add1 (locators, locator);
16369 if (locator_set_name_set == 0)
16371 errmsg ("missing locator-set name");
16372 vec_free (locators);
16376 if (vec_len (locator_set_name) > 64)
16378 errmsg ("locator-set name too long");
16379 vec_free (locator_set_name);
16380 vec_free (locators);
16383 vec_add1 (locator_set_name, 0);
16385 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16387 /* Construct the API message */
16388 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16390 mp->is_add = is_add;
16391 clib_memcpy (mp->locator_set_name, locator_set_name,
16392 vec_len (locator_set_name));
16393 vec_free (locator_set_name);
16395 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16397 clib_memcpy (mp->locators, locators, data_len);
16398 vec_free (locators);
16403 /* Wait for a reply... */
16408 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16411 api_one_add_del_locator (vat_main_t * vam)
16413 unformat_input_t *input = vam->input;
16414 vl_api_one_add_del_locator_t *mp;
16415 u32 tmp_if_index = ~0;
16416 u32 sw_if_index = ~0;
16417 u8 sw_if_index_set = 0;
16418 u8 sw_if_index_if_name_set = 0;
16420 u8 priority_set = 0;
16424 u8 *locator_set_name = NULL;
16425 u8 locator_set_name_set = 0;
16428 /* Parse args required to build the message */
16429 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16431 if (unformat (input, "del"))
16435 else if (unformat (input, "locator-set %s", &locator_set_name))
16437 locator_set_name_set = 1;
16439 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16442 sw_if_index_if_name_set = 1;
16443 sw_if_index = tmp_if_index;
16445 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16447 sw_if_index_set = 1;
16448 sw_if_index = tmp_if_index;
16450 else if (unformat (input, "p %d", &priority))
16454 else if (unformat (input, "w %d", &weight))
16462 if (locator_set_name_set == 0)
16464 errmsg ("missing locator-set name");
16468 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16470 errmsg ("missing sw_if_index");
16471 vec_free (locator_set_name);
16475 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16477 errmsg ("cannot use both params interface name and sw_if_index");
16478 vec_free (locator_set_name);
16482 if (priority_set == 0)
16484 errmsg ("missing locator-set priority");
16485 vec_free (locator_set_name);
16489 if (weight_set == 0)
16491 errmsg ("missing locator-set weight");
16492 vec_free (locator_set_name);
16496 if (vec_len (locator_set_name) > 64)
16498 errmsg ("locator-set name too long");
16499 vec_free (locator_set_name);
16502 vec_add1 (locator_set_name, 0);
16504 /* Construct the API message */
16505 M (ONE_ADD_DEL_LOCATOR, mp);
16507 mp->is_add = is_add;
16508 mp->sw_if_index = ntohl (sw_if_index);
16509 mp->priority = priority;
16510 mp->weight = weight;
16511 clib_memcpy (mp->locator_set_name, locator_set_name,
16512 vec_len (locator_set_name));
16513 vec_free (locator_set_name);
16518 /* Wait for a reply... */
16523 #define api_lisp_add_del_locator api_one_add_del_locator
16526 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16528 u32 *key_id = va_arg (*args, u32 *);
16531 if (unformat (input, "%s", &s))
16533 if (!strcmp ((char *) s, "sha1"))
16534 key_id[0] = HMAC_SHA_1_96;
16535 else if (!strcmp ((char *) s, "sha256"))
16536 key_id[0] = HMAC_SHA_256_128;
16539 clib_warning ("invalid key_id: '%s'", s);
16540 key_id[0] = HMAC_NO_KEY;
16551 api_one_add_del_local_eid (vat_main_t * vam)
16553 unformat_input_t *input = vam->input;
16554 vl_api_one_add_del_local_eid_t *mp;
16557 lisp_eid_vat_t _eid, *eid = &_eid;
16558 u8 *locator_set_name = 0;
16559 u8 locator_set_name_set = 0;
16565 /* Parse args required to build the message */
16566 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16568 if (unformat (input, "del"))
16572 else if (unformat (input, "vni %d", &vni))
16576 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16580 else if (unformat (input, "locator-set %s", &locator_set_name))
16582 locator_set_name_set = 1;
16584 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
16586 else if (unformat (input, "secret-key %_%v%_", &key))
16592 if (locator_set_name_set == 0)
16594 errmsg ("missing locator-set name");
16600 errmsg ("EID address not set!");
16601 vec_free (locator_set_name);
16605 if (key && (0 == key_id))
16607 errmsg ("invalid key_id!");
16611 if (vec_len (key) > 64)
16613 errmsg ("key too long");
16618 if (vec_len (locator_set_name) > 64)
16620 errmsg ("locator-set name too long");
16621 vec_free (locator_set_name);
16624 vec_add1 (locator_set_name, 0);
16626 /* Construct the API message */
16627 M (ONE_ADD_DEL_LOCAL_EID, mp);
16629 mp->is_add = is_add;
16630 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16631 mp->eid_type = eid->type;
16632 mp->prefix_len = eid->len;
16633 mp->vni = clib_host_to_net_u32 (vni);
16634 mp->key_id = clib_host_to_net_u16 (key_id);
16635 clib_memcpy (mp->locator_set_name, locator_set_name,
16636 vec_len (locator_set_name));
16637 clib_memcpy (mp->key, key, vec_len (key));
16639 vec_free (locator_set_name);
16645 /* Wait for a reply... */
16650 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16653 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16655 u32 dp_table = 0, vni = 0;;
16656 unformat_input_t *input = vam->input;
16657 vl_api_gpe_add_del_fwd_entry_t *mp;
16659 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16660 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16661 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16662 u32 action = ~0, w;
16663 ip4_address_t rmt_rloc4, lcl_rloc4;
16664 ip6_address_t rmt_rloc6, lcl_rloc6;
16665 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16668 clib_memset (&rloc, 0, sizeof (rloc));
16670 /* Parse args required to build the message */
16671 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16673 if (unformat (input, "del"))
16675 else if (unformat (input, "add"))
16677 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16681 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16685 else if (unformat (input, "vrf %d", &dp_table))
16687 else if (unformat (input, "bd %d", &dp_table))
16689 else if (unformat (input, "vni %d", &vni))
16691 else if (unformat (input, "w %d", &w))
16695 errmsg ("No RLOC configured for setting priority/weight!");
16698 curr_rloc->weight = w;
16700 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16701 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16705 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16707 vec_add1 (lcl_locs, rloc);
16709 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16710 vec_add1 (rmt_locs, rloc);
16711 /* weight saved in rmt loc */
16712 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16714 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16715 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16718 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16720 vec_add1 (lcl_locs, rloc);
16722 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16723 vec_add1 (rmt_locs, rloc);
16724 /* weight saved in rmt loc */
16725 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16727 else if (unformat (input, "action %d", &action))
16733 clib_warning ("parse error '%U'", format_unformat_error, input);
16740 errmsg ("remote eid addresses not set");
16744 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16746 errmsg ("eid types don't match");
16750 if (0 == rmt_locs && (u32) ~ 0 == action)
16752 errmsg ("action not set for negative mapping");
16756 /* Construct the API message */
16757 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16758 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16760 mp->is_add = is_add;
16761 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16762 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16763 mp->eid_type = rmt_eid->type;
16764 mp->dp_table = clib_host_to_net_u32 (dp_table);
16765 mp->vni = clib_host_to_net_u32 (vni);
16766 mp->rmt_len = rmt_eid->len;
16767 mp->lcl_len = lcl_eid->len;
16768 mp->action = action;
16770 if (0 != rmt_locs && 0 != lcl_locs)
16772 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16773 clib_memcpy (mp->locs, lcl_locs,
16774 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16776 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16777 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16778 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16780 vec_free (lcl_locs);
16781 vec_free (rmt_locs);
16786 /* Wait for a reply... */
16792 api_one_add_del_map_server (vat_main_t * vam)
16794 unformat_input_t *input = vam->input;
16795 vl_api_one_add_del_map_server_t *mp;
16799 ip4_address_t ipv4;
16800 ip6_address_t ipv6;
16803 /* Parse args required to build the message */
16804 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16806 if (unformat (input, "del"))
16810 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16814 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16822 if (ipv4_set && ipv6_set)
16824 errmsg ("both eid v4 and v6 addresses set");
16828 if (!ipv4_set && !ipv6_set)
16830 errmsg ("eid addresses not set");
16834 /* Construct the API message */
16835 M (ONE_ADD_DEL_MAP_SERVER, mp);
16837 mp->is_add = is_add;
16841 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16846 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16852 /* Wait for a reply... */
16857 #define api_lisp_add_del_map_server api_one_add_del_map_server
16860 api_one_add_del_map_resolver (vat_main_t * vam)
16862 unformat_input_t *input = vam->input;
16863 vl_api_one_add_del_map_resolver_t *mp;
16867 ip4_address_t ipv4;
16868 ip6_address_t ipv6;
16871 /* Parse args required to build the message */
16872 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16874 if (unformat (input, "del"))
16878 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16882 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16890 if (ipv4_set && ipv6_set)
16892 errmsg ("both eid v4 and v6 addresses set");
16896 if (!ipv4_set && !ipv6_set)
16898 errmsg ("eid addresses not set");
16902 /* Construct the API message */
16903 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16905 mp->is_add = is_add;
16909 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16914 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16920 /* Wait for a reply... */
16925 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16928 api_lisp_gpe_enable_disable (vat_main_t * vam)
16930 unformat_input_t *input = vam->input;
16931 vl_api_gpe_enable_disable_t *mp;
16936 /* Parse args required to build the message */
16937 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16939 if (unformat (input, "enable"))
16944 else if (unformat (input, "disable"))
16955 errmsg ("Value not set");
16959 /* Construct the API message */
16960 M (GPE_ENABLE_DISABLE, mp);
16967 /* Wait for a reply... */
16973 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16975 unformat_input_t *input = vam->input;
16976 vl_api_one_rloc_probe_enable_disable_t *mp;
16981 /* Parse args required to build the message */
16982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16984 if (unformat (input, "enable"))
16989 else if (unformat (input, "disable"))
16997 errmsg ("Value not set");
17001 /* Construct the API message */
17002 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17004 mp->is_enabled = is_en;
17009 /* Wait for a reply... */
17014 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17017 api_one_map_register_enable_disable (vat_main_t * vam)
17019 unformat_input_t *input = vam->input;
17020 vl_api_one_map_register_enable_disable_t *mp;
17025 /* Parse args required to build the message */
17026 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17028 if (unformat (input, "enable"))
17033 else if (unformat (input, "disable"))
17041 errmsg ("Value not set");
17045 /* Construct the API message */
17046 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17048 mp->is_enabled = is_en;
17053 /* Wait for a reply... */
17058 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17061 api_one_enable_disable (vat_main_t * vam)
17063 unformat_input_t *input = vam->input;
17064 vl_api_one_enable_disable_t *mp;
17069 /* Parse args required to build the message */
17070 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17072 if (unformat (input, "enable"))
17077 else if (unformat (input, "disable"))
17087 errmsg ("Value not set");
17091 /* Construct the API message */
17092 M (ONE_ENABLE_DISABLE, mp);
17099 /* Wait for a reply... */
17104 #define api_lisp_enable_disable api_one_enable_disable
17107 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17109 unformat_input_t *input = vam->input;
17110 vl_api_one_enable_disable_xtr_mode_t *mp;
17115 /* Parse args required to build the message */
17116 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17118 if (unformat (input, "enable"))
17123 else if (unformat (input, "disable"))
17133 errmsg ("Value not set");
17137 /* Construct the API message */
17138 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17145 /* Wait for a reply... */
17151 api_one_show_xtr_mode (vat_main_t * vam)
17153 vl_api_one_show_xtr_mode_t *mp;
17156 /* Construct the API message */
17157 M (ONE_SHOW_XTR_MODE, mp);
17162 /* Wait for a reply... */
17168 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17170 unformat_input_t *input = vam->input;
17171 vl_api_one_enable_disable_pitr_mode_t *mp;
17176 /* Parse args required to build the message */
17177 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17179 if (unformat (input, "enable"))
17184 else if (unformat (input, "disable"))
17194 errmsg ("Value not set");
17198 /* Construct the API message */
17199 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17206 /* Wait for a reply... */
17212 api_one_show_pitr_mode (vat_main_t * vam)
17214 vl_api_one_show_pitr_mode_t *mp;
17217 /* Construct the API message */
17218 M (ONE_SHOW_PITR_MODE, mp);
17223 /* Wait for a reply... */
17229 api_one_enable_disable_petr_mode (vat_main_t * vam)
17231 unformat_input_t *input = vam->input;
17232 vl_api_one_enable_disable_petr_mode_t *mp;
17237 /* Parse args required to build the message */
17238 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17240 if (unformat (input, "enable"))
17245 else if (unformat (input, "disable"))
17255 errmsg ("Value not set");
17259 /* Construct the API message */
17260 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17267 /* Wait for a reply... */
17273 api_one_show_petr_mode (vat_main_t * vam)
17275 vl_api_one_show_petr_mode_t *mp;
17278 /* Construct the API message */
17279 M (ONE_SHOW_PETR_MODE, mp);
17284 /* Wait for a reply... */
17290 api_show_one_map_register_state (vat_main_t * vam)
17292 vl_api_show_one_map_register_state_t *mp;
17295 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17300 /* wait for reply */
17305 #define api_show_lisp_map_register_state api_show_one_map_register_state
17308 api_show_one_rloc_probe_state (vat_main_t * vam)
17310 vl_api_show_one_rloc_probe_state_t *mp;
17313 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17318 /* wait for reply */
17323 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17326 api_one_add_del_ndp_entry (vat_main_t * vam)
17328 vl_api_one_add_del_ndp_entry_t *mp;
17329 unformat_input_t *input = vam->input;
17334 u8 mac[6] = { 0, };
17335 u8 ip6[16] = { 0, };
17339 /* Parse args required to build the message */
17340 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17342 if (unformat (input, "del"))
17344 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17346 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17348 else if (unformat (input, "bd %d", &bd))
17352 errmsg ("parse error '%U'", format_unformat_error, input);
17357 if (!bd_set || !ip_set || (!mac_set && is_add))
17359 errmsg ("Missing BD, IP or MAC!");
17363 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17364 mp->is_add = is_add;
17365 clib_memcpy (mp->mac, mac, 6);
17366 mp->bd = clib_host_to_net_u32 (bd);
17367 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17372 /* wait for reply */
17378 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17380 vl_api_one_add_del_l2_arp_entry_t *mp;
17381 unformat_input_t *input = vam->input;
17386 u8 mac[6] = { 0, };
17387 u32 ip4 = 0, bd = ~0;
17390 /* Parse args required to build the message */
17391 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17393 if (unformat (input, "del"))
17395 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17397 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17399 else if (unformat (input, "bd %d", &bd))
17403 errmsg ("parse error '%U'", format_unformat_error, input);
17408 if (!bd_set || !ip_set || (!mac_set && is_add))
17410 errmsg ("Missing BD, IP or MAC!");
17414 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17415 mp->is_add = is_add;
17416 clib_memcpy (mp->mac, mac, 6);
17417 mp->bd = clib_host_to_net_u32 (bd);
17423 /* wait for reply */
17429 api_one_ndp_bd_get (vat_main_t * vam)
17431 vl_api_one_ndp_bd_get_t *mp;
17434 M (ONE_NDP_BD_GET, mp);
17439 /* wait for reply */
17445 api_one_ndp_entries_get (vat_main_t * vam)
17447 vl_api_one_ndp_entries_get_t *mp;
17448 unformat_input_t *input = vam->input;
17453 /* Parse args required to build the message */
17454 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17456 if (unformat (input, "bd %d", &bd))
17460 errmsg ("parse error '%U'", format_unformat_error, input);
17467 errmsg ("Expected bridge domain!");
17471 M (ONE_NDP_ENTRIES_GET, mp);
17472 mp->bd = clib_host_to_net_u32 (bd);
17477 /* wait for reply */
17483 api_one_l2_arp_bd_get (vat_main_t * vam)
17485 vl_api_one_l2_arp_bd_get_t *mp;
17488 M (ONE_L2_ARP_BD_GET, mp);
17493 /* wait for reply */
17499 api_one_l2_arp_entries_get (vat_main_t * vam)
17501 vl_api_one_l2_arp_entries_get_t *mp;
17502 unformat_input_t *input = vam->input;
17507 /* Parse args required to build the message */
17508 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17510 if (unformat (input, "bd %d", &bd))
17514 errmsg ("parse error '%U'", format_unformat_error, input);
17521 errmsg ("Expected bridge domain!");
17525 M (ONE_L2_ARP_ENTRIES_GET, mp);
17526 mp->bd = clib_host_to_net_u32 (bd);
17531 /* wait for reply */
17537 api_one_stats_enable_disable (vat_main_t * vam)
17539 vl_api_one_stats_enable_disable_t *mp;
17540 unformat_input_t *input = vam->input;
17545 /* Parse args required to build the message */
17546 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17548 if (unformat (input, "enable"))
17553 else if (unformat (input, "disable"))
17563 errmsg ("Value not set");
17567 M (ONE_STATS_ENABLE_DISABLE, mp);
17573 /* wait for reply */
17579 api_show_one_stats_enable_disable (vat_main_t * vam)
17581 vl_api_show_one_stats_enable_disable_t *mp;
17584 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
17589 /* wait for reply */
17595 api_show_one_map_request_mode (vat_main_t * vam)
17597 vl_api_show_one_map_request_mode_t *mp;
17600 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
17605 /* wait for reply */
17610 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
17613 api_one_map_request_mode (vat_main_t * vam)
17615 unformat_input_t *input = vam->input;
17616 vl_api_one_map_request_mode_t *mp;
17620 /* Parse args required to build the message */
17621 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17623 if (unformat (input, "dst-only"))
17625 else if (unformat (input, "src-dst"))
17629 errmsg ("parse error '%U'", format_unformat_error, input);
17634 M (ONE_MAP_REQUEST_MODE, mp);
17641 /* wait for reply */
17646 #define api_lisp_map_request_mode api_one_map_request_mode
17649 * Enable/disable ONE proxy ITR.
17651 * @param vam vpp API test context
17652 * @return return code
17655 api_one_pitr_set_locator_set (vat_main_t * vam)
17657 u8 ls_name_set = 0;
17658 unformat_input_t *input = vam->input;
17659 vl_api_one_pitr_set_locator_set_t *mp;
17664 /* Parse args required to build the message */
17665 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17667 if (unformat (input, "del"))
17669 else if (unformat (input, "locator-set %s", &ls_name))
17673 errmsg ("parse error '%U'", format_unformat_error, input);
17680 errmsg ("locator-set name not set!");
17684 M (ONE_PITR_SET_LOCATOR_SET, mp);
17686 mp->is_add = is_add;
17687 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17688 vec_free (ls_name);
17693 /* wait for reply */
17698 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17701 api_one_nsh_set_locator_set (vat_main_t * vam)
17703 u8 ls_name_set = 0;
17704 unformat_input_t *input = vam->input;
17705 vl_api_one_nsh_set_locator_set_t *mp;
17710 /* Parse args required to build the message */
17711 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17713 if (unformat (input, "del"))
17715 else if (unformat (input, "ls %s", &ls_name))
17719 errmsg ("parse error '%U'", format_unformat_error, input);
17724 if (!ls_name_set && is_add)
17726 errmsg ("locator-set name not set!");
17730 M (ONE_NSH_SET_LOCATOR_SET, mp);
17732 mp->is_add = is_add;
17733 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17734 vec_free (ls_name);
17739 /* wait for reply */
17745 api_show_one_pitr (vat_main_t * vam)
17747 vl_api_show_one_pitr_t *mp;
17750 if (!vam->json_output)
17752 print (vam->ofp, "%=20s", "lisp status:");
17755 M (SHOW_ONE_PITR, mp);
17759 /* Wait for a reply... */
17764 #define api_show_lisp_pitr api_show_one_pitr
17767 api_one_use_petr (vat_main_t * vam)
17769 unformat_input_t *input = vam->input;
17770 vl_api_one_use_petr_t *mp;
17775 clib_memset (&ip, 0, sizeof (ip));
17777 /* Parse args required to build the message */
17778 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17780 if (unformat (input, "disable"))
17783 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17786 ip_addr_version (&ip) = IP4;
17789 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17792 ip_addr_version (&ip) = IP6;
17796 errmsg ("parse error '%U'", format_unformat_error, input);
17801 M (ONE_USE_PETR, mp);
17803 mp->is_add = is_add;
17806 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17808 clib_memcpy (mp->address, &ip, 4);
17810 clib_memcpy (mp->address, &ip, 16);
17816 /* wait for reply */
17821 #define api_lisp_use_petr api_one_use_petr
17824 api_show_one_nsh_mapping (vat_main_t * vam)
17826 vl_api_show_one_use_petr_t *mp;
17829 if (!vam->json_output)
17831 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17834 M (SHOW_ONE_NSH_MAPPING, mp);
17838 /* Wait for a reply... */
17844 api_show_one_use_petr (vat_main_t * vam)
17846 vl_api_show_one_use_petr_t *mp;
17849 if (!vam->json_output)
17851 print (vam->ofp, "%=20s", "Proxy-ETR status:");
17854 M (SHOW_ONE_USE_PETR, mp);
17858 /* Wait for a reply... */
17863 #define api_show_lisp_use_petr api_show_one_use_petr
17866 * Add/delete mapping between vni and vrf
17869 api_one_eid_table_add_del_map (vat_main_t * vam)
17871 unformat_input_t *input = vam->input;
17872 vl_api_one_eid_table_add_del_map_t *mp;
17873 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
17874 u32 vni, vrf, bd_index;
17877 /* Parse args required to build the message */
17878 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17880 if (unformat (input, "del"))
17882 else if (unformat (input, "vrf %d", &vrf))
17884 else if (unformat (input, "bd_index %d", &bd_index))
17886 else if (unformat (input, "vni %d", &vni))
17892 if (!vni_set || (!vrf_set && !bd_index_set))
17894 errmsg ("missing arguments!");
17898 if (vrf_set && bd_index_set)
17900 errmsg ("error: both vrf and bd entered!");
17904 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17906 mp->is_add = is_add;
17907 mp->vni = htonl (vni);
17908 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17909 mp->is_l2 = bd_index_set;
17914 /* wait for reply */
17919 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
17922 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
17924 u32 *action = va_arg (*args, u32 *);
17927 if (unformat (input, "%s", &s))
17929 if (!strcmp ((char *) s, "no-action"))
17931 else if (!strcmp ((char *) s, "natively-forward"))
17933 else if (!strcmp ((char *) s, "send-map-request"))
17935 else if (!strcmp ((char *) s, "drop"))
17939 clib_warning ("invalid action: '%s'", s);
17951 * Add/del remote mapping to/from ONE control plane
17953 * @param vam vpp API test context
17954 * @return return code
17957 api_one_add_del_remote_mapping (vat_main_t * vam)
17959 unformat_input_t *input = vam->input;
17960 vl_api_one_add_del_remote_mapping_t *mp;
17962 lisp_eid_vat_t _eid, *eid = &_eid;
17963 lisp_eid_vat_t _seid, *seid = &_seid;
17964 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17965 u32 action = ~0, p, w, data_len;
17966 ip4_address_t rloc4;
17967 ip6_address_t rloc6;
17968 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17971 clib_memset (&rloc, 0, sizeof (rloc));
17973 /* Parse args required to build the message */
17974 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17976 if (unformat (input, "del-all"))
17980 else if (unformat (input, "del"))
17984 else if (unformat (input, "add"))
17988 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17992 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17996 else if (unformat (input, "vni %d", &vni))
18000 else if (unformat (input, "p %d w %d", &p, &w))
18004 errmsg ("No RLOC configured for setting priority/weight!");
18007 curr_rloc->priority = p;
18008 curr_rloc->weight = w;
18010 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18013 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18014 vec_add1 (rlocs, rloc);
18015 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18017 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18020 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18021 vec_add1 (rlocs, rloc);
18022 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18024 else if (unformat (input, "action %U",
18025 unformat_negative_mapping_action, &action))
18031 clib_warning ("parse error '%U'", format_unformat_error, input);
18038 errmsg ("missing params!");
18042 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18044 errmsg ("no action set for negative map-reply!");
18048 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18050 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18051 mp->is_add = is_add;
18052 mp->vni = htonl (vni);
18053 mp->action = (u8) action;
18054 mp->is_src_dst = seid_set;
18055 mp->eid_len = eid->len;
18056 mp->seid_len = seid->len;
18057 mp->del_all = del_all;
18058 mp->eid_type = eid->type;
18059 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18060 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18062 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18063 clib_memcpy (mp->rlocs, rlocs, data_len);
18069 /* Wait for a reply... */
18074 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18077 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18078 * forwarding entries in data-plane accordingly.
18080 * @param vam vpp API test context
18081 * @return return code
18084 api_one_add_del_adjacency (vat_main_t * vam)
18086 unformat_input_t *input = vam->input;
18087 vl_api_one_add_del_adjacency_t *mp;
18089 ip4_address_t leid4, reid4;
18090 ip6_address_t leid6, reid6;
18091 u8 reid_mac[6] = { 0 };
18092 u8 leid_mac[6] = { 0 };
18093 u8 reid_type, leid_type;
18094 u32 leid_len = 0, reid_len = 0, len;
18098 leid_type = reid_type = (u8) ~ 0;
18100 /* Parse args required to build the message */
18101 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18103 if (unformat (input, "del"))
18107 else if (unformat (input, "add"))
18111 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18114 reid_type = 0; /* ipv4 */
18117 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18120 reid_type = 1; /* ipv6 */
18123 else if (unformat (input, "reid %U", unformat_ethernet_address,
18126 reid_type = 2; /* mac */
18128 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18131 leid_type = 0; /* ipv4 */
18134 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18137 leid_type = 1; /* ipv6 */
18140 else if (unformat (input, "leid %U", unformat_ethernet_address,
18143 leid_type = 2; /* mac */
18145 else if (unformat (input, "vni %d", &vni))
18151 errmsg ("parse error '%U'", format_unformat_error, input);
18156 if ((u8) ~ 0 == reid_type)
18158 errmsg ("missing params!");
18162 if (leid_type != reid_type)
18164 errmsg ("remote and local EIDs are of different types!");
18168 M (ONE_ADD_DEL_ADJACENCY, mp);
18169 mp->is_add = is_add;
18170 mp->vni = htonl (vni);
18171 mp->leid_len = leid_len;
18172 mp->reid_len = reid_len;
18173 mp->eid_type = reid_type;
18175 switch (mp->eid_type)
18178 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18179 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18182 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18183 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18186 clib_memcpy (mp->leid, leid_mac, 6);
18187 clib_memcpy (mp->reid, reid_mac, 6);
18190 errmsg ("unknown EID type %d!", mp->eid_type);
18197 /* Wait for a reply... */
18202 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18205 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18207 u32 *mode = va_arg (*args, u32 *);
18209 if (unformat (input, "lisp"))
18211 else if (unformat (input, "vxlan"))
18220 api_gpe_get_encap_mode (vat_main_t * vam)
18222 vl_api_gpe_get_encap_mode_t *mp;
18225 /* Construct the API message */
18226 M (GPE_GET_ENCAP_MODE, mp);
18231 /* Wait for a reply... */
18237 api_gpe_set_encap_mode (vat_main_t * vam)
18239 unformat_input_t *input = vam->input;
18240 vl_api_gpe_set_encap_mode_t *mp;
18244 /* Parse args required to build the message */
18245 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18247 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18253 /* Construct the API message */
18254 M (GPE_SET_ENCAP_MODE, mp);
18261 /* Wait for a reply... */
18267 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18269 unformat_input_t *input = vam->input;
18270 vl_api_gpe_add_del_iface_t *mp;
18271 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18272 u32 dp_table = 0, vni = 0;
18275 /* Parse args required to build the message */
18276 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18278 if (unformat (input, "up"))
18283 else if (unformat (input, "down"))
18288 else if (unformat (input, "table_id %d", &dp_table))
18292 else if (unformat (input, "bd_id %d", &dp_table))
18297 else if (unformat (input, "vni %d", &vni))
18305 if (action_set == 0)
18307 errmsg ("Action not set");
18310 if (dp_table_set == 0 || vni_set == 0)
18312 errmsg ("vni and dp_table must be set");
18316 /* Construct the API message */
18317 M (GPE_ADD_DEL_IFACE, mp);
18319 mp->is_add = is_add;
18320 mp->dp_table = clib_host_to_net_u32 (dp_table);
18322 mp->vni = clib_host_to_net_u32 (vni);
18327 /* Wait for a reply... */
18333 api_one_map_register_fallback_threshold (vat_main_t * vam)
18335 unformat_input_t *input = vam->input;
18336 vl_api_one_map_register_fallback_threshold_t *mp;
18341 /* Parse args required to build the message */
18342 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18344 if (unformat (input, "%u", &value))
18348 clib_warning ("parse error '%U'", format_unformat_error, input);
18355 errmsg ("fallback threshold value is missing!");
18359 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18360 mp->value = clib_host_to_net_u32 (value);
18365 /* Wait for a reply... */
18371 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18373 vl_api_show_one_map_register_fallback_threshold_t *mp;
18376 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18381 /* Wait for a reply... */
18387 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18389 u32 *proto = va_arg (*args, u32 *);
18391 if (unformat (input, "udp"))
18393 else if (unformat (input, "api"))
18402 api_one_set_transport_protocol (vat_main_t * vam)
18404 unformat_input_t *input = vam->input;
18405 vl_api_one_set_transport_protocol_t *mp;
18410 /* Parse args required to build the message */
18411 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18413 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18417 clib_warning ("parse error '%U'", format_unformat_error, input);
18424 errmsg ("Transport protocol missing!");
18428 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18429 mp->protocol = (u8) protocol;
18434 /* Wait for a reply... */
18440 api_one_get_transport_protocol (vat_main_t * vam)
18442 vl_api_one_get_transport_protocol_t *mp;
18445 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18450 /* Wait for a reply... */
18456 api_one_map_register_set_ttl (vat_main_t * vam)
18458 unformat_input_t *input = vam->input;
18459 vl_api_one_map_register_set_ttl_t *mp;
18464 /* Parse args required to build the message */
18465 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18467 if (unformat (input, "%u", &ttl))
18471 clib_warning ("parse error '%U'", format_unformat_error, input);
18478 errmsg ("TTL value missing!");
18482 M (ONE_MAP_REGISTER_SET_TTL, mp);
18483 mp->ttl = clib_host_to_net_u32 (ttl);
18488 /* Wait for a reply... */
18494 api_show_one_map_register_ttl (vat_main_t * vam)
18496 vl_api_show_one_map_register_ttl_t *mp;
18499 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18504 /* Wait for a reply... */
18510 * Add/del map request itr rlocs from ONE control plane and updates
18512 * @param vam vpp API test context
18513 * @return return code
18516 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18518 unformat_input_t *input = vam->input;
18519 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18520 u8 *locator_set_name = 0;
18521 u8 locator_set_name_set = 0;
18525 /* Parse args required to build the message */
18526 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18528 if (unformat (input, "del"))
18532 else if (unformat (input, "%_%v%_", &locator_set_name))
18534 locator_set_name_set = 1;
18538 clib_warning ("parse error '%U'", format_unformat_error, input);
18543 if (is_add && !locator_set_name_set)
18545 errmsg ("itr-rloc is not set!");
18549 if (is_add && vec_len (locator_set_name) > 64)
18551 errmsg ("itr-rloc locator-set name too long");
18552 vec_free (locator_set_name);
18556 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18557 mp->is_add = is_add;
18560 clib_memcpy (mp->locator_set_name, locator_set_name,
18561 vec_len (locator_set_name));
18565 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18567 vec_free (locator_set_name);
18572 /* Wait for a reply... */
18577 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18580 api_one_locator_dump (vat_main_t * vam)
18582 unformat_input_t *input = vam->input;
18583 vl_api_one_locator_dump_t *mp;
18584 vl_api_control_ping_t *mp_ping;
18585 u8 is_index_set = 0, is_name_set = 0;
18590 /* Parse args required to build the message */
18591 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18593 if (unformat (input, "ls_name %_%v%_", &ls_name))
18597 else if (unformat (input, "ls_index %d", &ls_index))
18603 errmsg ("parse error '%U'", format_unformat_error, input);
18608 if (!is_index_set && !is_name_set)
18610 errmsg ("error: expected one of index or name!");
18614 if (is_index_set && is_name_set)
18616 errmsg ("error: only one param expected!");
18620 if (vec_len (ls_name) > 62)
18622 errmsg ("error: locator set name too long!");
18626 if (!vam->json_output)
18628 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
18631 M (ONE_LOCATOR_DUMP, mp);
18632 mp->is_index_set = is_index_set;
18635 mp->ls_index = clib_host_to_net_u32 (ls_index);
18638 vec_add1 (ls_name, 0);
18639 strncpy ((char *) mp->ls_name, (char *) ls_name,
18640 sizeof (mp->ls_name) - 1);
18646 /* Use a control ping for synchronization */
18647 MPING (CONTROL_PING, mp_ping);
18650 /* Wait for a reply... */
18655 #define api_lisp_locator_dump api_one_locator_dump
18658 api_one_locator_set_dump (vat_main_t * vam)
18660 vl_api_one_locator_set_dump_t *mp;
18661 vl_api_control_ping_t *mp_ping;
18662 unformat_input_t *input = vam->input;
18666 /* Parse args required to build the message */
18667 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18669 if (unformat (input, "local"))
18673 else if (unformat (input, "remote"))
18679 errmsg ("parse error '%U'", format_unformat_error, input);
18684 if (!vam->json_output)
18686 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18689 M (ONE_LOCATOR_SET_DUMP, mp);
18691 mp->filter = filter;
18696 /* Use a control ping for synchronization */
18697 MPING (CONTROL_PING, mp_ping);
18700 /* Wait for a reply... */
18705 #define api_lisp_locator_set_dump api_one_locator_set_dump
18708 api_one_eid_table_map_dump (vat_main_t * vam)
18712 unformat_input_t *input = vam->input;
18713 vl_api_one_eid_table_map_dump_t *mp;
18714 vl_api_control_ping_t *mp_ping;
18717 /* Parse args required to build the message */
18718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18720 if (unformat (input, "l2"))
18725 else if (unformat (input, "l3"))
18732 errmsg ("parse error '%U'", format_unformat_error, input);
18739 errmsg ("expected one of 'l2' or 'l3' parameter!");
18743 if (!vam->json_output)
18745 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18748 M (ONE_EID_TABLE_MAP_DUMP, mp);
18754 /* Use a control ping for synchronization */
18755 MPING (CONTROL_PING, mp_ping);
18758 /* Wait for a reply... */
18763 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18766 api_one_eid_table_vni_dump (vat_main_t * vam)
18768 vl_api_one_eid_table_vni_dump_t *mp;
18769 vl_api_control_ping_t *mp_ping;
18772 if (!vam->json_output)
18774 print (vam->ofp, "VNI");
18777 M (ONE_EID_TABLE_VNI_DUMP, mp);
18782 /* Use a control ping for synchronization */
18783 MPING (CONTROL_PING, mp_ping);
18786 /* Wait for a reply... */
18791 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18794 api_one_eid_table_dump (vat_main_t * vam)
18796 unformat_input_t *i = vam->input;
18797 vl_api_one_eid_table_dump_t *mp;
18798 vl_api_control_ping_t *mp_ping;
18799 struct in_addr ip4;
18800 struct in6_addr ip6;
18802 u8 eid_type = ~0, eid_set = 0;
18803 u32 prefix_length = ~0, t, vni = 0;
18806 lisp_nsh_api_t nsh;
18808 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18810 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18816 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18822 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18827 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18832 else if (unformat (i, "vni %d", &t))
18836 else if (unformat (i, "local"))
18840 else if (unformat (i, "remote"))
18846 errmsg ("parse error '%U'", format_unformat_error, i);
18851 if (!vam->json_output)
18853 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
18854 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
18857 M (ONE_EID_TABLE_DUMP, mp);
18859 mp->filter = filter;
18863 mp->vni = htonl (vni);
18864 mp->eid_type = eid_type;
18868 mp->prefix_length = prefix_length;
18869 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
18872 mp->prefix_length = prefix_length;
18873 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
18876 clib_memcpy (mp->eid, mac, sizeof (mac));
18879 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
18882 errmsg ("unknown EID type %d!", eid_type);
18890 /* Use a control ping for synchronization */
18891 MPING (CONTROL_PING, mp_ping);
18894 /* Wait for a reply... */
18899 #define api_lisp_eid_table_dump api_one_eid_table_dump
18902 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18904 unformat_input_t *i = vam->input;
18905 vl_api_gpe_fwd_entries_get_t *mp;
18910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18912 if (unformat (i, "vni %d", &vni))
18918 errmsg ("parse error '%U'", format_unformat_error, i);
18925 errmsg ("vni not set!");
18929 if (!vam->json_output)
18931 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18935 M (GPE_FWD_ENTRIES_GET, mp);
18936 mp->vni = clib_host_to_net_u32 (vni);
18941 /* Wait for a reply... */
18946 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18947 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18948 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18949 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18950 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18951 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18952 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18953 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18956 api_one_adjacencies_get (vat_main_t * vam)
18958 unformat_input_t *i = vam->input;
18959 vl_api_one_adjacencies_get_t *mp;
18964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18966 if (unformat (i, "vni %d", &vni))
18972 errmsg ("parse error '%U'", format_unformat_error, i);
18979 errmsg ("vni not set!");
18983 if (!vam->json_output)
18985 print (vam->ofp, "%s %40s", "leid", "reid");
18988 M (ONE_ADJACENCIES_GET, mp);
18989 mp->vni = clib_host_to_net_u32 (vni);
18994 /* Wait for a reply... */
18999 #define api_lisp_adjacencies_get api_one_adjacencies_get
19002 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19004 unformat_input_t *i = vam->input;
19005 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19007 u8 ip_family_set = 0, is_ip4 = 1;
19009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19011 if (unformat (i, "ip4"))
19016 else if (unformat (i, "ip6"))
19023 errmsg ("parse error '%U'", format_unformat_error, i);
19028 if (!ip_family_set)
19030 errmsg ("ip family not set!");
19034 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19035 mp->is_ip4 = is_ip4;
19040 /* Wait for a reply... */
19046 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19048 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19051 if (!vam->json_output)
19053 print (vam->ofp, "VNIs");
19056 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19061 /* Wait for a reply... */
19067 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19069 unformat_input_t *i = vam->input;
19070 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19072 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19073 struct in_addr ip4;
19074 struct in6_addr ip6;
19075 u32 table_id = 0, nh_sw_if_index = ~0;
19077 clib_memset (&ip4, 0, sizeof (ip4));
19078 clib_memset (&ip6, 0, sizeof (ip6));
19080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19082 if (unformat (i, "del"))
19084 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19085 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19090 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19091 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19096 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19100 nh_sw_if_index = ~0;
19102 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19106 nh_sw_if_index = ~0;
19108 else if (unformat (i, "table %d", &table_id))
19112 errmsg ("parse error '%U'", format_unformat_error, i);
19119 errmsg ("nh addr not set!");
19123 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19124 mp->is_add = is_add;
19125 mp->table_id = clib_host_to_net_u32 (table_id);
19126 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19127 mp->is_ip4 = is_ip4;
19129 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19131 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19136 /* Wait for a reply... */
19142 api_one_map_server_dump (vat_main_t * vam)
19144 vl_api_one_map_server_dump_t *mp;
19145 vl_api_control_ping_t *mp_ping;
19148 if (!vam->json_output)
19150 print (vam->ofp, "%=20s", "Map server");
19153 M (ONE_MAP_SERVER_DUMP, mp);
19157 /* Use a control ping for synchronization */
19158 MPING (CONTROL_PING, mp_ping);
19161 /* Wait for a reply... */
19166 #define api_lisp_map_server_dump api_one_map_server_dump
19169 api_one_map_resolver_dump (vat_main_t * vam)
19171 vl_api_one_map_resolver_dump_t *mp;
19172 vl_api_control_ping_t *mp_ping;
19175 if (!vam->json_output)
19177 print (vam->ofp, "%=20s", "Map resolver");
19180 M (ONE_MAP_RESOLVER_DUMP, mp);
19184 /* Use a control ping for synchronization */
19185 MPING (CONTROL_PING, mp_ping);
19188 /* Wait for a reply... */
19193 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19196 api_one_stats_flush (vat_main_t * vam)
19198 vl_api_one_stats_flush_t *mp;
19201 M (ONE_STATS_FLUSH, mp);
19208 api_one_stats_dump (vat_main_t * vam)
19210 vl_api_one_stats_dump_t *mp;
19211 vl_api_control_ping_t *mp_ping;
19214 M (ONE_STATS_DUMP, mp);
19218 /* Use a control ping for synchronization */
19219 MPING (CONTROL_PING, mp_ping);
19222 /* Wait for a reply... */
19228 api_show_one_status (vat_main_t * vam)
19230 vl_api_show_one_status_t *mp;
19233 if (!vam->json_output)
19235 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19238 M (SHOW_ONE_STATUS, mp);
19241 /* Wait for a reply... */
19246 #define api_show_lisp_status api_show_one_status
19249 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19251 vl_api_gpe_fwd_entry_path_dump_t *mp;
19252 vl_api_control_ping_t *mp_ping;
19253 unformat_input_t *i = vam->input;
19254 u32 fwd_entry_index = ~0;
19257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19259 if (unformat (i, "index %d", &fwd_entry_index))
19265 if (~0 == fwd_entry_index)
19267 errmsg ("no index specified!");
19271 if (!vam->json_output)
19273 print (vam->ofp, "first line");
19276 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19280 /* Use a control ping for synchronization */
19281 MPING (CONTROL_PING, mp_ping);
19284 /* Wait for a reply... */
19290 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19292 vl_api_one_get_map_request_itr_rlocs_t *mp;
19295 if (!vam->json_output)
19297 print (vam->ofp, "%=20s", "itr-rlocs:");
19300 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19303 /* Wait for a reply... */
19308 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19311 api_af_packet_create (vat_main_t * vam)
19313 unformat_input_t *i = vam->input;
19314 vl_api_af_packet_create_t *mp;
19315 u8 *host_if_name = 0;
19317 u8 random_hw_addr = 1;
19320 clib_memset (hw_addr, 0, sizeof (hw_addr));
19322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19324 if (unformat (i, "name %s", &host_if_name))
19325 vec_add1 (host_if_name, 0);
19326 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19327 random_hw_addr = 0;
19332 if (!vec_len (host_if_name))
19334 errmsg ("host-interface name must be specified");
19338 if (vec_len (host_if_name) > 64)
19340 errmsg ("host-interface name too long");
19344 M (AF_PACKET_CREATE, mp);
19346 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19347 clib_memcpy (mp->hw_addr, hw_addr, 6);
19348 mp->use_random_hw_addr = random_hw_addr;
19349 vec_free (host_if_name);
19357 fprintf (vam->ofp ? vam->ofp : stderr,
19358 " new sw_if_index = %d\n", vam->sw_if_index);
19365 api_af_packet_delete (vat_main_t * vam)
19367 unformat_input_t *i = vam->input;
19368 vl_api_af_packet_delete_t *mp;
19369 u8 *host_if_name = 0;
19372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19374 if (unformat (i, "name %s", &host_if_name))
19375 vec_add1 (host_if_name, 0);
19380 if (!vec_len (host_if_name))
19382 errmsg ("host-interface name must be specified");
19386 if (vec_len (host_if_name) > 64)
19388 errmsg ("host-interface name too long");
19392 M (AF_PACKET_DELETE, mp);
19394 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19395 vec_free (host_if_name);
19402 static void vl_api_af_packet_details_t_handler
19403 (vl_api_af_packet_details_t * mp)
19405 vat_main_t *vam = &vat_main;
19407 print (vam->ofp, "%-16s %d",
19408 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19411 static void vl_api_af_packet_details_t_handler_json
19412 (vl_api_af_packet_details_t * mp)
19414 vat_main_t *vam = &vat_main;
19415 vat_json_node_t *node = NULL;
19417 if (VAT_JSON_ARRAY != vam->json_tree.type)
19419 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19420 vat_json_init_array (&vam->json_tree);
19422 node = vat_json_array_add (&vam->json_tree);
19424 vat_json_init_object (node);
19425 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19426 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19430 api_af_packet_dump (vat_main_t * vam)
19432 vl_api_af_packet_dump_t *mp;
19433 vl_api_control_ping_t *mp_ping;
19436 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19437 /* Get list of tap interfaces */
19438 M (AF_PACKET_DUMP, mp);
19441 /* Use a control ping for synchronization */
19442 MPING (CONTROL_PING, mp_ping);
19450 api_policer_add_del (vat_main_t * vam)
19452 unformat_input_t *i = vam->input;
19453 vl_api_policer_add_del_t *mp;
19463 u8 color_aware = 0;
19464 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19467 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19468 conform_action.dscp = 0;
19469 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19470 exceed_action.dscp = 0;
19471 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19472 violate_action.dscp = 0;
19474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19476 if (unformat (i, "del"))
19478 else if (unformat (i, "name %s", &name))
19479 vec_add1 (name, 0);
19480 else if (unformat (i, "cir %u", &cir))
19482 else if (unformat (i, "eir %u", &eir))
19484 else if (unformat (i, "cb %u", &cb))
19486 else if (unformat (i, "eb %u", &eb))
19488 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19491 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19494 else if (unformat (i, "type %U", unformat_policer_type, &type))
19496 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19499 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19502 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19505 else if (unformat (i, "color-aware"))
19511 if (!vec_len (name))
19513 errmsg ("policer name must be specified");
19517 if (vec_len (name) > 64)
19519 errmsg ("policer name too long");
19523 M (POLICER_ADD_DEL, mp);
19525 clib_memcpy (mp->name, name, vec_len (name));
19527 mp->is_add = is_add;
19528 mp->cir = ntohl (cir);
19529 mp->eir = ntohl (eir);
19530 mp->cb = clib_net_to_host_u64 (cb);
19531 mp->eb = clib_net_to_host_u64 (eb);
19532 mp->rate_type = rate_type;
19533 mp->round_type = round_type;
19535 mp->conform_action_type = conform_action.action_type;
19536 mp->conform_dscp = conform_action.dscp;
19537 mp->exceed_action_type = exceed_action.action_type;
19538 mp->exceed_dscp = exceed_action.dscp;
19539 mp->violate_action_type = violate_action.action_type;
19540 mp->violate_dscp = violate_action.dscp;
19541 mp->color_aware = color_aware;
19549 api_policer_dump (vat_main_t * vam)
19551 unformat_input_t *i = vam->input;
19552 vl_api_policer_dump_t *mp;
19553 vl_api_control_ping_t *mp_ping;
19554 u8 *match_name = 0;
19555 u8 match_name_valid = 0;
19558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19560 if (unformat (i, "name %s", &match_name))
19562 vec_add1 (match_name, 0);
19563 match_name_valid = 1;
19569 M (POLICER_DUMP, mp);
19570 mp->match_name_valid = match_name_valid;
19571 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19572 vec_free (match_name);
19576 /* Use a control ping for synchronization */
19577 MPING (CONTROL_PING, mp_ping);
19580 /* Wait for a reply... */
19586 api_policer_classify_set_interface (vat_main_t * vam)
19588 unformat_input_t *i = vam->input;
19589 vl_api_policer_classify_set_interface_t *mp;
19591 int sw_if_index_set;
19592 u32 ip4_table_index = ~0;
19593 u32 ip6_table_index = ~0;
19594 u32 l2_table_index = ~0;
19598 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19600 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19601 sw_if_index_set = 1;
19602 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19603 sw_if_index_set = 1;
19604 else if (unformat (i, "del"))
19606 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19608 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19610 else if (unformat (i, "l2-table %d", &l2_table_index))
19614 clib_warning ("parse error '%U'", format_unformat_error, i);
19619 if (sw_if_index_set == 0)
19621 errmsg ("missing interface name or sw_if_index");
19625 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19627 mp->sw_if_index = ntohl (sw_if_index);
19628 mp->ip4_table_index = ntohl (ip4_table_index);
19629 mp->ip6_table_index = ntohl (ip6_table_index);
19630 mp->l2_table_index = ntohl (l2_table_index);
19631 mp->is_add = is_add;
19639 api_policer_classify_dump (vat_main_t * vam)
19641 unformat_input_t *i = vam->input;
19642 vl_api_policer_classify_dump_t *mp;
19643 vl_api_control_ping_t *mp_ping;
19644 u8 type = POLICER_CLASSIFY_N_TABLES;
19647 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19651 errmsg ("classify table type must be specified");
19655 if (!vam->json_output)
19657 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19660 M (POLICER_CLASSIFY_DUMP, mp);
19665 /* Use a control ping for synchronization */
19666 MPING (CONTROL_PING, mp_ping);
19669 /* Wait for a reply... */
19675 api_netmap_create (vat_main_t * vam)
19677 unformat_input_t *i = vam->input;
19678 vl_api_netmap_create_t *mp;
19681 u8 random_hw_addr = 1;
19686 clib_memset (hw_addr, 0, sizeof (hw_addr));
19688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19690 if (unformat (i, "name %s", &if_name))
19691 vec_add1 (if_name, 0);
19692 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19693 random_hw_addr = 0;
19694 else if (unformat (i, "pipe"))
19696 else if (unformat (i, "master"))
19698 else if (unformat (i, "slave"))
19704 if (!vec_len (if_name))
19706 errmsg ("interface name must be specified");
19710 if (vec_len (if_name) > 64)
19712 errmsg ("interface name too long");
19716 M (NETMAP_CREATE, mp);
19718 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19719 clib_memcpy (mp->hw_addr, hw_addr, 6);
19720 mp->use_random_hw_addr = random_hw_addr;
19721 mp->is_pipe = is_pipe;
19722 mp->is_master = is_master;
19723 vec_free (if_name);
19731 api_netmap_delete (vat_main_t * vam)
19733 unformat_input_t *i = vam->input;
19734 vl_api_netmap_delete_t *mp;
19738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19740 if (unformat (i, "name %s", &if_name))
19741 vec_add1 (if_name, 0);
19746 if (!vec_len (if_name))
19748 errmsg ("interface name must be specified");
19752 if (vec_len (if_name) > 64)
19754 errmsg ("interface name too long");
19758 M (NETMAP_DELETE, mp);
19760 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19761 vec_free (if_name);
19769 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
19771 if (fp->afi == IP46_TYPE_IP6)
19773 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19774 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19775 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
19776 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19777 format_ip6_address, fp->next_hop);
19778 else if (fp->afi == IP46_TYPE_IP4)
19780 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19781 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19782 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
19783 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19784 format_ip4_address, fp->next_hop);
19788 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19789 vl_api_fib_path_t * fp)
19791 struct in_addr ip4;
19792 struct in6_addr ip6;
19794 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19795 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19796 vat_json_object_add_uint (node, "is_local", fp->is_local);
19797 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19798 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19799 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19800 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19801 if (fp->afi == IP46_TYPE_IP4)
19803 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19804 vat_json_object_add_ip4 (node, "next_hop", ip4);
19806 else if (fp->afi == IP46_TYPE_IP6)
19808 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19809 vat_json_object_add_ip6 (node, "next_hop", ip6);
19814 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19816 vat_main_t *vam = &vat_main;
19817 int count = ntohl (mp->mt_count);
19818 vl_api_fib_path_t *fp;
19821 print (vam->ofp, "[%d]: sw_if_index %d via:",
19822 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19824 for (i = 0; i < count; i++)
19826 vl_api_mpls_fib_path_print (vam, fp);
19830 print (vam->ofp, "");
19833 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19834 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19837 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19839 vat_main_t *vam = &vat_main;
19840 vat_json_node_t *node = NULL;
19841 int count = ntohl (mp->mt_count);
19842 vl_api_fib_path_t *fp;
19845 if (VAT_JSON_ARRAY != vam->json_tree.type)
19847 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19848 vat_json_init_array (&vam->json_tree);
19850 node = vat_json_array_add (&vam->json_tree);
19852 vat_json_init_object (node);
19853 vat_json_object_add_uint (node, "tunnel_index",
19854 ntohl (mp->mt_tunnel_index));
19855 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
19857 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
19860 for (i = 0; i < count; i++)
19862 vl_api_mpls_fib_path_json_print (node, fp);
19868 api_mpls_tunnel_dump (vat_main_t * vam)
19870 vl_api_mpls_tunnel_dump_t *mp;
19871 vl_api_control_ping_t *mp_ping;
19872 u32 sw_if_index = ~0;
19875 /* Parse args required to build the message */
19876 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
19878 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
19882 print (vam->ofp, " sw_if_index %d", sw_if_index);
19884 M (MPLS_TUNNEL_DUMP, mp);
19885 mp->sw_if_index = htonl (sw_if_index);
19888 /* Use a control ping for synchronization */
19889 MPING (CONTROL_PING, mp_ping);
19896 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
19897 #define vl_api_mpls_fib_details_t_print vl_noop_handler
19901 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
19903 vat_main_t *vam = &vat_main;
19904 int count = ntohl (mp->count);
19905 vl_api_fib_path_t *fp;
19909 "table-id %d, label %u, ess_bit %u",
19910 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
19912 for (i = 0; i < count; i++)
19914 vl_api_mpls_fib_path_print (vam, fp);
19919 static void vl_api_mpls_fib_details_t_handler_json
19920 (vl_api_mpls_fib_details_t * mp)
19922 vat_main_t *vam = &vat_main;
19923 int count = ntohl (mp->count);
19924 vat_json_node_t *node = NULL;
19925 vl_api_fib_path_t *fp;
19928 if (VAT_JSON_ARRAY != vam->json_tree.type)
19930 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19931 vat_json_init_array (&vam->json_tree);
19933 node = vat_json_array_add (&vam->json_tree);
19935 vat_json_init_object (node);
19936 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19937 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
19938 vat_json_object_add_uint (node, "label", ntohl (mp->label));
19939 vat_json_object_add_uint (node, "path_count", count);
19941 for (i = 0; i < count; i++)
19943 vl_api_mpls_fib_path_json_print (node, fp);
19949 api_mpls_fib_dump (vat_main_t * vam)
19951 vl_api_mpls_fib_dump_t *mp;
19952 vl_api_control_ping_t *mp_ping;
19955 M (MPLS_FIB_DUMP, mp);
19958 /* Use a control ping for synchronization */
19959 MPING (CONTROL_PING, mp_ping);
19966 #define vl_api_ip_fib_details_t_endian vl_noop_handler
19967 #define vl_api_ip_fib_details_t_print vl_noop_handler
19970 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
19972 vat_main_t *vam = &vat_main;
19973 int count = ntohl (mp->count);
19974 vl_api_fib_path_t *fp;
19978 "table-id %d, prefix %U/%d stats-index %d",
19979 ntohl (mp->table_id), format_ip4_address, mp->address,
19980 mp->address_length, ntohl (mp->stats_index));
19982 for (i = 0; i < count; i++)
19984 if (fp->afi == IP46_TYPE_IP6)
19986 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19987 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
19988 "next_hop_table %d",
19989 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19990 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19991 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
19992 else if (fp->afi == IP46_TYPE_IP4)
19994 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19995 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
19996 "next_hop_table %d",
19997 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19998 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19999 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20004 static void vl_api_ip_fib_details_t_handler_json
20005 (vl_api_ip_fib_details_t * mp)
20007 vat_main_t *vam = &vat_main;
20008 int count = ntohl (mp->count);
20009 vat_json_node_t *node = NULL;
20010 struct in_addr ip4;
20011 struct in6_addr ip6;
20012 vl_api_fib_path_t *fp;
20015 if (VAT_JSON_ARRAY != vam->json_tree.type)
20017 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20018 vat_json_init_array (&vam->json_tree);
20020 node = vat_json_array_add (&vam->json_tree);
20022 vat_json_init_object (node);
20023 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20024 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20025 vat_json_object_add_ip4 (node, "prefix", ip4);
20026 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20027 vat_json_object_add_uint (node, "path_count", count);
20029 for (i = 0; i < count; i++)
20031 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20032 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20033 vat_json_object_add_uint (node, "is_local", fp->is_local);
20034 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20035 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20036 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20037 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20038 if (fp->afi == IP46_TYPE_IP4)
20040 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20041 vat_json_object_add_ip4 (node, "next_hop", ip4);
20043 else if (fp->afi == IP46_TYPE_IP6)
20045 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20046 vat_json_object_add_ip6 (node, "next_hop", ip6);
20052 api_ip_fib_dump (vat_main_t * vam)
20054 vl_api_ip_fib_dump_t *mp;
20055 vl_api_control_ping_t *mp_ping;
20058 M (IP_FIB_DUMP, mp);
20061 /* Use a control ping for synchronization */
20062 MPING (CONTROL_PING, mp_ping);
20070 api_ip_mfib_dump (vat_main_t * vam)
20072 vl_api_ip_mfib_dump_t *mp;
20073 vl_api_control_ping_t *mp_ping;
20076 M (IP_MFIB_DUMP, mp);
20079 /* Use a control ping for synchronization */
20080 MPING (CONTROL_PING, mp_ping);
20087 static void vl_api_ip_neighbor_details_t_handler
20088 (vl_api_ip_neighbor_details_t * mp)
20090 vat_main_t *vam = &vat_main;
20092 print (vam->ofp, "%c %U %U",
20093 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
20094 format_vl_api_mac_address, &mp->neighbor.mac_address,
20095 format_vl_api_address, &mp->neighbor.ip_address);
20098 static void vl_api_ip_neighbor_details_t_handler_json
20099 (vl_api_ip_neighbor_details_t * mp)
20102 vat_main_t *vam = &vat_main;
20103 vat_json_node_t *node;
20105 if (VAT_JSON_ARRAY != vam->json_tree.type)
20107 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20108 vat_json_init_array (&vam->json_tree);
20110 node = vat_json_array_add (&vam->json_tree);
20112 vat_json_init_object (node);
20113 vat_json_object_add_string_copy
20115 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
20116 (u8 *) "static" : (u8 *) "dynamic"));
20118 vat_json_object_add_string_copy (node, "link_layer",
20119 format (0, "%U", format_vl_api_mac_address,
20120 &mp->neighbor.mac_address));
20121 vat_json_object_add_address (node, &mp->neighbor.ip_address);
20125 api_ip_neighbor_dump (vat_main_t * vam)
20127 unformat_input_t *i = vam->input;
20128 vl_api_ip_neighbor_dump_t *mp;
20129 vl_api_control_ping_t *mp_ping;
20131 u32 sw_if_index = ~0;
20134 /* Parse args required to build the message */
20135 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20137 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20139 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20141 else if (unformat (i, "ip6"))
20147 if (sw_if_index == ~0)
20149 errmsg ("missing interface name or sw_if_index");
20153 M (IP_NEIGHBOR_DUMP, mp);
20154 mp->is_ipv6 = (u8) is_ipv6;
20155 mp->sw_if_index = ntohl (sw_if_index);
20158 /* Use a control ping for synchronization */
20159 MPING (CONTROL_PING, mp_ping);
20166 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20167 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20170 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20172 vat_main_t *vam = &vat_main;
20173 int count = ntohl (mp->count);
20174 vl_api_fib_path_t *fp;
20178 "table-id %d, prefix %U/%d stats-index %d",
20179 ntohl (mp->table_id), format_ip6_address, mp->address,
20180 mp->address_length, ntohl (mp->stats_index));
20182 for (i = 0; i < count; i++)
20184 if (fp->afi == IP46_TYPE_IP6)
20186 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20187 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20188 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20189 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20190 format_ip6_address, fp->next_hop);
20191 else if (fp->afi == IP46_TYPE_IP4)
20193 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20194 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20195 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20196 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20197 format_ip4_address, fp->next_hop);
20202 static void vl_api_ip6_fib_details_t_handler_json
20203 (vl_api_ip6_fib_details_t * mp)
20205 vat_main_t *vam = &vat_main;
20206 int count = ntohl (mp->count);
20207 vat_json_node_t *node = NULL;
20208 struct in_addr ip4;
20209 struct in6_addr ip6;
20210 vl_api_fib_path_t *fp;
20213 if (VAT_JSON_ARRAY != vam->json_tree.type)
20215 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20216 vat_json_init_array (&vam->json_tree);
20218 node = vat_json_array_add (&vam->json_tree);
20220 vat_json_init_object (node);
20221 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20222 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20223 vat_json_object_add_ip6 (node, "prefix", ip6);
20224 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20225 vat_json_object_add_uint (node, "path_count", count);
20227 for (i = 0; i < count; i++)
20229 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20230 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20231 vat_json_object_add_uint (node, "is_local", fp->is_local);
20232 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20233 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20234 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20235 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20236 if (fp->afi == IP46_TYPE_IP4)
20238 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20239 vat_json_object_add_ip4 (node, "next_hop", ip4);
20241 else if (fp->afi == IP46_TYPE_IP6)
20243 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20244 vat_json_object_add_ip6 (node, "next_hop", ip6);
20250 api_ip6_fib_dump (vat_main_t * vam)
20252 vl_api_ip6_fib_dump_t *mp;
20253 vl_api_control_ping_t *mp_ping;
20256 M (IP6_FIB_DUMP, mp);
20259 /* Use a control ping for synchronization */
20260 MPING (CONTROL_PING, mp_ping);
20268 api_ip6_mfib_dump (vat_main_t * vam)
20270 vl_api_ip6_mfib_dump_t *mp;
20271 vl_api_control_ping_t *mp_ping;
20274 M (IP6_MFIB_DUMP, mp);
20277 /* Use a control ping for synchronization */
20278 MPING (CONTROL_PING, mp_ping);
20286 api_classify_table_ids (vat_main_t * vam)
20288 vl_api_classify_table_ids_t *mp;
20291 /* Construct the API message */
20292 M (CLASSIFY_TABLE_IDS, mp);
20301 api_classify_table_by_interface (vat_main_t * vam)
20303 unformat_input_t *input = vam->input;
20304 vl_api_classify_table_by_interface_t *mp;
20306 u32 sw_if_index = ~0;
20308 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20310 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20312 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20317 if (sw_if_index == ~0)
20319 errmsg ("missing interface name or sw_if_index");
20323 /* Construct the API message */
20324 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20326 mp->sw_if_index = ntohl (sw_if_index);
20334 api_classify_table_info (vat_main_t * vam)
20336 unformat_input_t *input = vam->input;
20337 vl_api_classify_table_info_t *mp;
20341 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20343 if (unformat (input, "table_id %d", &table_id))
20348 if (table_id == ~0)
20350 errmsg ("missing table id");
20354 /* Construct the API message */
20355 M (CLASSIFY_TABLE_INFO, mp);
20357 mp->table_id = ntohl (table_id);
20365 api_classify_session_dump (vat_main_t * vam)
20367 unformat_input_t *input = vam->input;
20368 vl_api_classify_session_dump_t *mp;
20369 vl_api_control_ping_t *mp_ping;
20373 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20375 if (unformat (input, "table_id %d", &table_id))
20380 if (table_id == ~0)
20382 errmsg ("missing table id");
20386 /* Construct the API message */
20387 M (CLASSIFY_SESSION_DUMP, mp);
20389 mp->table_id = ntohl (table_id);
20392 /* Use a control ping for synchronization */
20393 MPING (CONTROL_PING, mp_ping);
20401 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20403 vat_main_t *vam = &vat_main;
20405 print (vam->ofp, "collector_address %U, collector_port %d, "
20406 "src_address %U, vrf_id %d, path_mtu %u, "
20407 "template_interval %u, udp_checksum %d",
20408 format_ip4_address, mp->collector_address,
20409 ntohs (mp->collector_port),
20410 format_ip4_address, mp->src_address,
20411 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20412 ntohl (mp->template_interval), mp->udp_checksum);
20415 vam->result_ready = 1;
20419 vl_api_ipfix_exporter_details_t_handler_json
20420 (vl_api_ipfix_exporter_details_t * mp)
20422 vat_main_t *vam = &vat_main;
20423 vat_json_node_t node;
20424 struct in_addr collector_address;
20425 struct in_addr src_address;
20427 vat_json_init_object (&node);
20428 clib_memcpy (&collector_address, &mp->collector_address,
20429 sizeof (collector_address));
20430 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20431 vat_json_object_add_uint (&node, "collector_port",
20432 ntohs (mp->collector_port));
20433 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20434 vat_json_object_add_ip4 (&node, "src_address", src_address);
20435 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20436 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20437 vat_json_object_add_uint (&node, "template_interval",
20438 ntohl (mp->template_interval));
20439 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20441 vat_json_print (vam->ofp, &node);
20442 vat_json_free (&node);
20444 vam->result_ready = 1;
20448 api_ipfix_exporter_dump (vat_main_t * vam)
20450 vl_api_ipfix_exporter_dump_t *mp;
20453 /* Construct the API message */
20454 M (IPFIX_EXPORTER_DUMP, mp);
20463 api_ipfix_classify_stream_dump (vat_main_t * vam)
20465 vl_api_ipfix_classify_stream_dump_t *mp;
20468 /* Construct the API message */
20469 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20480 vl_api_ipfix_classify_stream_details_t_handler
20481 (vl_api_ipfix_classify_stream_details_t * mp)
20483 vat_main_t *vam = &vat_main;
20484 print (vam->ofp, "domain_id %d, src_port %d",
20485 ntohl (mp->domain_id), ntohs (mp->src_port));
20487 vam->result_ready = 1;
20491 vl_api_ipfix_classify_stream_details_t_handler_json
20492 (vl_api_ipfix_classify_stream_details_t * mp)
20494 vat_main_t *vam = &vat_main;
20495 vat_json_node_t node;
20497 vat_json_init_object (&node);
20498 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20499 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20501 vat_json_print (vam->ofp, &node);
20502 vat_json_free (&node);
20504 vam->result_ready = 1;
20508 api_ipfix_classify_table_dump (vat_main_t * vam)
20510 vl_api_ipfix_classify_table_dump_t *mp;
20511 vl_api_control_ping_t *mp_ping;
20514 if (!vam->json_output)
20516 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20517 "transport_protocol");
20520 /* Construct the API message */
20521 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20526 /* Use a control ping for synchronization */
20527 MPING (CONTROL_PING, mp_ping);
20535 vl_api_ipfix_classify_table_details_t_handler
20536 (vl_api_ipfix_classify_table_details_t * mp)
20538 vat_main_t *vam = &vat_main;
20539 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20540 mp->transport_protocol);
20544 vl_api_ipfix_classify_table_details_t_handler_json
20545 (vl_api_ipfix_classify_table_details_t * mp)
20547 vat_json_node_t *node = NULL;
20548 vat_main_t *vam = &vat_main;
20550 if (VAT_JSON_ARRAY != vam->json_tree.type)
20552 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20553 vat_json_init_array (&vam->json_tree);
20556 node = vat_json_array_add (&vam->json_tree);
20557 vat_json_init_object (node);
20559 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20560 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20561 vat_json_object_add_uint (node, "transport_protocol",
20562 mp->transport_protocol);
20566 api_sw_interface_span_enable_disable (vat_main_t * vam)
20568 unformat_input_t *i = vam->input;
20569 vl_api_sw_interface_span_enable_disable_t *mp;
20570 u32 src_sw_if_index = ~0;
20571 u32 dst_sw_if_index = ~0;
20576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20579 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
20581 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
20585 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
20587 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
20589 else if (unformat (i, "disable"))
20591 else if (unformat (i, "rx"))
20593 else if (unformat (i, "tx"))
20595 else if (unformat (i, "both"))
20597 else if (unformat (i, "l2"))
20603 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20605 mp->sw_if_index_from = htonl (src_sw_if_index);
20606 mp->sw_if_index_to = htonl (dst_sw_if_index);
20616 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
20619 vat_main_t *vam = &vat_main;
20620 u8 *sw_if_from_name = 0;
20621 u8 *sw_if_to_name = 0;
20622 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20623 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20624 char *states[] = { "none", "rx", "tx", "both" };
20628 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20630 if ((u32) p->value[0] == sw_if_index_from)
20632 sw_if_from_name = (u8 *)(p->key);
20636 if ((u32) p->value[0] == sw_if_index_to)
20638 sw_if_to_name = (u8 *)(p->key);
20639 if (sw_if_from_name)
20644 print (vam->ofp, "%20s => %20s (%s) %s",
20645 sw_if_from_name, sw_if_to_name, states[mp->state],
20646 mp->is_l2 ? "l2" : "device");
20650 vl_api_sw_interface_span_details_t_handler_json
20651 (vl_api_sw_interface_span_details_t * mp)
20653 vat_main_t *vam = &vat_main;
20654 vat_json_node_t *node = NULL;
20655 u8 *sw_if_from_name = 0;
20656 u8 *sw_if_to_name = 0;
20657 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20658 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20662 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20664 if ((u32) p->value[0] == sw_if_index_from)
20666 sw_if_from_name = (u8 *)(p->key);
20670 if ((u32) p->value[0] == sw_if_index_to)
20672 sw_if_to_name = (u8 *)(p->key);
20673 if (sw_if_from_name)
20679 if (VAT_JSON_ARRAY != vam->json_tree.type)
20681 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20682 vat_json_init_array (&vam->json_tree);
20684 node = vat_json_array_add (&vam->json_tree);
20686 vat_json_init_object (node);
20687 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20688 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20689 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20690 if (0 != sw_if_to_name)
20692 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20694 vat_json_object_add_uint (node, "state", mp->state);
20695 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
20699 api_sw_interface_span_dump (vat_main_t * vam)
20701 unformat_input_t *input = vam->input;
20702 vl_api_sw_interface_span_dump_t *mp;
20703 vl_api_control_ping_t *mp_ping;
20707 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20709 if (unformat (input, "l2"))
20715 M (SW_INTERFACE_SPAN_DUMP, mp);
20719 /* Use a control ping for synchronization */
20720 MPING (CONTROL_PING, mp_ping);
20728 api_pg_create_interface (vat_main_t * vam)
20730 unformat_input_t *input = vam->input;
20731 vl_api_pg_create_interface_t *mp;
20735 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20737 if (unformat (input, "if_id %d", &if_id))
20744 errmsg ("missing pg interface index");
20748 /* Construct the API message */
20749 M (PG_CREATE_INTERFACE, mp);
20751 mp->interface_id = ntohl (if_id);
20759 api_pg_capture (vat_main_t * vam)
20761 unformat_input_t *input = vam->input;
20762 vl_api_pg_capture_t *mp;
20767 u8 pcap_file_set = 0;
20770 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20772 if (unformat (input, "if_id %d", &if_id))
20774 else if (unformat (input, "pcap %s", &pcap_file))
20776 else if (unformat (input, "count %d", &count))
20778 else if (unformat (input, "disable"))
20785 errmsg ("missing pg interface index");
20788 if (pcap_file_set > 0)
20790 if (vec_len (pcap_file) > 255)
20792 errmsg ("pcap file name is too long");
20797 u32 name_len = vec_len (pcap_file);
20798 /* Construct the API message */
20799 M (PG_CAPTURE, mp);
20801 mp->interface_id = ntohl (if_id);
20802 mp->is_enabled = enable;
20803 mp->count = ntohl (count);
20804 mp->pcap_name_length = ntohl (name_len);
20805 if (pcap_file_set != 0)
20807 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20809 vec_free (pcap_file);
20817 api_pg_enable_disable (vat_main_t * vam)
20819 unformat_input_t *input = vam->input;
20820 vl_api_pg_enable_disable_t *mp;
20823 u8 stream_name_set = 0;
20824 u8 *stream_name = 0;
20826 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20828 if (unformat (input, "stream %s", &stream_name))
20829 stream_name_set = 1;
20830 else if (unformat (input, "disable"))
20836 if (stream_name_set > 0)
20838 if (vec_len (stream_name) > 255)
20840 errmsg ("stream name too long");
20845 u32 name_len = vec_len (stream_name);
20846 /* Construct the API message */
20847 M (PG_ENABLE_DISABLE, mp);
20849 mp->is_enabled = enable;
20850 if (stream_name_set != 0)
20852 mp->stream_name_length = ntohl (name_len);
20853 clib_memcpy (mp->stream_name, stream_name, name_len);
20855 vec_free (stream_name);
20863 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
20865 unformat_input_t *input = vam->input;
20866 vl_api_ip_source_and_port_range_check_add_del_t *mp;
20868 u16 *low_ports = 0;
20869 u16 *high_ports = 0;
20872 vl_api_prefix_t prefix;
20880 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20882 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
20884 else if (unformat (input, "vrf %d", &vrf_id))
20886 else if (unformat (input, "del"))
20888 else if (unformat (input, "port %d", &tmp))
20890 if (tmp == 0 || tmp > 65535)
20892 errmsg ("port %d out of range", tmp);
20896 this_hi = this_low + 1;
20897 vec_add1 (low_ports, this_low);
20898 vec_add1 (high_ports, this_hi);
20900 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
20902 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
20904 errmsg ("incorrect range parameters");
20908 /* Note: in debug CLI +1 is added to high before
20909 passing to real fn that does "the work"
20910 (ip_source_and_port_range_check_add_del).
20911 This fn is a wrapper around the binary API fn a
20912 control plane will call, which expects this increment
20913 to have occurred. Hence letting the binary API control
20914 plane fn do the increment for consistency between VAT
20915 and other control planes.
20918 vec_add1 (low_ports, this_low);
20919 vec_add1 (high_ports, this_hi);
20925 if (prefix_set == 0)
20927 errmsg ("<address>/<mask> not specified");
20933 errmsg ("VRF ID required, not specified");
20940 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20944 if (vec_len (low_ports) == 0)
20946 errmsg ("At least one port or port range required");
20950 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
20952 mp->is_add = is_add;
20954 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
20956 mp->number_of_ranges = vec_len (low_ports);
20958 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20959 vec_free (low_ports);
20961 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20962 vec_free (high_ports);
20964 mp->vrf_id = ntohl (vrf_id);
20972 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20974 unformat_input_t *input = vam->input;
20975 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20976 u32 sw_if_index = ~0;
20978 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20979 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20983 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20985 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20987 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20989 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20991 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20993 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20995 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20997 else if (unformat (input, "del"))
21003 if (sw_if_index == ~0)
21005 errmsg ("Interface required but not specified");
21011 errmsg ("VRF ID required but not specified");
21015 if (tcp_out_vrf_id == 0
21016 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21019 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21023 /* Construct the API message */
21024 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21026 mp->sw_if_index = ntohl (sw_if_index);
21027 mp->is_add = is_add;
21028 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21029 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21030 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21031 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21036 /* Wait for a reply... */
21042 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21044 unformat_input_t *i = vam->input;
21045 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21046 u32 local_sa_id = 0;
21047 u32 remote_sa_id = 0;
21048 ip4_address_t src_address;
21049 ip4_address_t dst_address;
21053 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21055 if (unformat (i, "local_sa %d", &local_sa_id))
21057 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21059 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21061 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21063 else if (unformat (i, "del"))
21067 clib_warning ("parse error '%U'", format_unformat_error, i);
21072 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21074 mp->local_sa_id = ntohl (local_sa_id);
21075 mp->remote_sa_id = ntohl (remote_sa_id);
21076 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21077 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21078 mp->is_add = is_add;
21086 api_set_punt (vat_main_t * vam)
21088 unformat_input_t *i = vam->input;
21089 vl_api_set_punt_t *mp;
21096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21098 if (unformat (i, "ip %d", &ipv))
21100 else if (unformat (i, "protocol %d", &protocol))
21102 else if (unformat (i, "port %d", &port))
21104 else if (unformat (i, "del"))
21108 clib_warning ("parse error '%U'", format_unformat_error, i);
21115 mp->is_add = (u8) is_add;
21116 mp->punt.ipv = (u8) ipv;
21117 mp->punt.l4_protocol = (u8) protocol;
21118 mp->punt.l4_port = htons ((u16) port);
21125 static void vl_api_ipsec_gre_tunnel_details_t_handler
21126 (vl_api_ipsec_gre_tunnel_details_t * mp)
21128 vat_main_t *vam = &vat_main;
21130 print (vam->ofp, "%11d%15U%15U%14d%14d",
21131 ntohl (mp->sw_if_index),
21132 format_ip4_address, &mp->src_address,
21133 format_ip4_address, &mp->dst_address,
21134 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21137 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21138 (vl_api_ipsec_gre_tunnel_details_t * mp)
21140 vat_main_t *vam = &vat_main;
21141 vat_json_node_t *node = NULL;
21142 struct in_addr ip4;
21144 if (VAT_JSON_ARRAY != vam->json_tree.type)
21146 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21147 vat_json_init_array (&vam->json_tree);
21149 node = vat_json_array_add (&vam->json_tree);
21151 vat_json_init_object (node);
21152 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21153 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21154 vat_json_object_add_ip4 (node, "src_address", ip4);
21155 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21156 vat_json_object_add_ip4 (node, "dst_address", ip4);
21157 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21158 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21162 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21164 unformat_input_t *i = vam->input;
21165 vl_api_ipsec_gre_tunnel_dump_t *mp;
21166 vl_api_control_ping_t *mp_ping;
21168 u8 sw_if_index_set = 0;
21171 /* Parse args required to build the message */
21172 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21174 if (unformat (i, "sw_if_index %d", &sw_if_index))
21175 sw_if_index_set = 1;
21180 if (sw_if_index_set == 0)
21185 if (!vam->json_output)
21187 print (vam->ofp, "%11s%15s%15s%14s%14s",
21188 "sw_if_index", "src_address", "dst_address",
21189 "local_sa_id", "remote_sa_id");
21192 /* Get list of gre-tunnel interfaces */
21193 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21195 mp->sw_if_index = htonl (sw_if_index);
21199 /* Use a control ping for synchronization */
21200 MPING (CONTROL_PING, mp_ping);
21208 api_delete_subif (vat_main_t * vam)
21210 unformat_input_t *i = vam->input;
21211 vl_api_delete_subif_t *mp;
21212 u32 sw_if_index = ~0;
21215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21217 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21219 if (unformat (i, "sw_if_index %d", &sw_if_index))
21225 if (sw_if_index == ~0)
21227 errmsg ("missing sw_if_index");
21231 /* Construct the API message */
21232 M (DELETE_SUBIF, mp);
21233 mp->sw_if_index = ntohl (sw_if_index);
21240 #define foreach_pbb_vtr_op \
21241 _("disable", L2_VTR_DISABLED) \
21242 _("pop", L2_VTR_POP_2) \
21243 _("push", L2_VTR_PUSH_2)
21246 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21248 unformat_input_t *i = vam->input;
21249 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21250 u32 sw_if_index = ~0, vtr_op = ~0;
21251 u16 outer_tag = ~0;
21252 u8 dmac[6], smac[6];
21253 u8 dmac_set = 0, smac_set = 0;
21259 /* Shut up coverity */
21260 clib_memset (dmac, 0, sizeof (dmac));
21261 clib_memset (smac, 0, sizeof (smac));
21263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21265 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21267 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21269 else if (unformat (i, "vtr_op %d", &vtr_op))
21271 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21274 else if (unformat (i, "translate_pbb_stag"))
21276 if (unformat (i, "%d", &tmp))
21278 vtr_op = L2_VTR_TRANSLATE_2_1;
21284 ("translate_pbb_stag operation requires outer tag definition");
21288 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21290 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21292 else if (unformat (i, "sid %d", &sid))
21294 else if (unformat (i, "vlanid %d", &tmp))
21298 clib_warning ("parse error '%U'", format_unformat_error, i);
21303 if ((sw_if_index == ~0) || (vtr_op == ~0))
21305 errmsg ("missing sw_if_index or vtr operation");
21308 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21309 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21312 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21316 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21317 mp->sw_if_index = ntohl (sw_if_index);
21318 mp->vtr_op = ntohl (vtr_op);
21319 mp->outer_tag = ntohs (outer_tag);
21320 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21321 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21322 mp->b_vlanid = ntohs (vlanid);
21323 mp->i_sid = ntohl (sid);
21331 api_flow_classify_set_interface (vat_main_t * vam)
21333 unformat_input_t *i = vam->input;
21334 vl_api_flow_classify_set_interface_t *mp;
21336 int sw_if_index_set;
21337 u32 ip4_table_index = ~0;
21338 u32 ip6_table_index = ~0;
21342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21344 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21345 sw_if_index_set = 1;
21346 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21347 sw_if_index_set = 1;
21348 else if (unformat (i, "del"))
21350 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21352 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21356 clib_warning ("parse error '%U'", format_unformat_error, i);
21361 if (sw_if_index_set == 0)
21363 errmsg ("missing interface name or sw_if_index");
21367 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21369 mp->sw_if_index = ntohl (sw_if_index);
21370 mp->ip4_table_index = ntohl (ip4_table_index);
21371 mp->ip6_table_index = ntohl (ip6_table_index);
21372 mp->is_add = is_add;
21380 api_flow_classify_dump (vat_main_t * vam)
21382 unformat_input_t *i = vam->input;
21383 vl_api_flow_classify_dump_t *mp;
21384 vl_api_control_ping_t *mp_ping;
21385 u8 type = FLOW_CLASSIFY_N_TABLES;
21388 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21392 errmsg ("classify table type must be specified");
21396 if (!vam->json_output)
21398 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21401 M (FLOW_CLASSIFY_DUMP, mp);
21406 /* Use a control ping for synchronization */
21407 MPING (CONTROL_PING, mp_ping);
21410 /* Wait for a reply... */
21416 api_feature_enable_disable (vat_main_t * vam)
21418 unformat_input_t *i = vam->input;
21419 vl_api_feature_enable_disable_t *mp;
21421 u8 *feature_name = 0;
21422 u32 sw_if_index = ~0;
21426 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21428 if (unformat (i, "arc_name %s", &arc_name))
21430 else if (unformat (i, "feature_name %s", &feature_name))
21433 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21435 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21437 else if (unformat (i, "disable"))
21445 errmsg ("missing arc name");
21448 if (vec_len (arc_name) > 63)
21450 errmsg ("arc name too long");
21453 if (feature_name == 0)
21455 errmsg ("missing feature name");
21458 if (vec_len (feature_name) > 63)
21460 errmsg ("feature name too long");
21463 if (sw_if_index == ~0)
21465 errmsg ("missing interface name or sw_if_index");
21469 /* Construct the API message */
21470 M (FEATURE_ENABLE_DISABLE, mp);
21471 mp->sw_if_index = ntohl (sw_if_index);
21472 mp->enable = enable;
21473 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21474 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21475 vec_free (arc_name);
21476 vec_free (feature_name);
21484 api_sw_interface_tag_add_del (vat_main_t * vam)
21486 unformat_input_t *i = vam->input;
21487 vl_api_sw_interface_tag_add_del_t *mp;
21488 u32 sw_if_index = ~0;
21493 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21495 if (unformat (i, "tag %s", &tag))
21497 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21499 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21501 else if (unformat (i, "del"))
21507 if (sw_if_index == ~0)
21509 errmsg ("missing interface name or sw_if_index");
21513 if (enable && (tag == 0))
21515 errmsg ("no tag specified");
21519 /* Construct the API message */
21520 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21521 mp->sw_if_index = ntohl (sw_if_index);
21522 mp->is_add = enable;
21524 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21532 static void vl_api_l2_xconnect_details_t_handler
21533 (vl_api_l2_xconnect_details_t * mp)
21535 vat_main_t *vam = &vat_main;
21537 print (vam->ofp, "%15d%15d",
21538 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21541 static void vl_api_l2_xconnect_details_t_handler_json
21542 (vl_api_l2_xconnect_details_t * mp)
21544 vat_main_t *vam = &vat_main;
21545 vat_json_node_t *node = NULL;
21547 if (VAT_JSON_ARRAY != vam->json_tree.type)
21549 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21550 vat_json_init_array (&vam->json_tree);
21552 node = vat_json_array_add (&vam->json_tree);
21554 vat_json_init_object (node);
21555 vat_json_object_add_uint (node, "rx_sw_if_index",
21556 ntohl (mp->rx_sw_if_index));
21557 vat_json_object_add_uint (node, "tx_sw_if_index",
21558 ntohl (mp->tx_sw_if_index));
21562 api_l2_xconnect_dump (vat_main_t * vam)
21564 vl_api_l2_xconnect_dump_t *mp;
21565 vl_api_control_ping_t *mp_ping;
21568 if (!vam->json_output)
21570 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
21573 M (L2_XCONNECT_DUMP, mp);
21577 /* Use a control ping for synchronization */
21578 MPING (CONTROL_PING, mp_ping);
21586 api_hw_interface_set_mtu (vat_main_t * vam)
21588 unformat_input_t *i = vam->input;
21589 vl_api_hw_interface_set_mtu_t *mp;
21590 u32 sw_if_index = ~0;
21594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21596 if (unformat (i, "mtu %d", &mtu))
21598 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21600 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21606 if (sw_if_index == ~0)
21608 errmsg ("missing interface name or sw_if_index");
21614 errmsg ("no mtu specified");
21618 /* Construct the API message */
21619 M (HW_INTERFACE_SET_MTU, mp);
21620 mp->sw_if_index = ntohl (sw_if_index);
21621 mp->mtu = ntohs ((u16) mtu);
21629 api_p2p_ethernet_add (vat_main_t * vam)
21631 unformat_input_t *i = vam->input;
21632 vl_api_p2p_ethernet_add_t *mp;
21633 u32 parent_if_index = ~0;
21639 clib_memset (remote_mac, 0, sizeof (remote_mac));
21640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21642 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21644 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21648 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21650 else if (unformat (i, "sub_id %d", &sub_id))
21654 clib_warning ("parse error '%U'", format_unformat_error, i);
21659 if (parent_if_index == ~0)
21661 errmsg ("missing interface name or sw_if_index");
21666 errmsg ("missing remote mac address");
21671 errmsg ("missing sub-interface id");
21675 M (P2P_ETHERNET_ADD, mp);
21676 mp->parent_if_index = ntohl (parent_if_index);
21677 mp->subif_id = ntohl (sub_id);
21678 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21686 api_p2p_ethernet_del (vat_main_t * vam)
21688 unformat_input_t *i = vam->input;
21689 vl_api_p2p_ethernet_del_t *mp;
21690 u32 parent_if_index = ~0;
21695 clib_memset (remote_mac, 0, sizeof (remote_mac));
21696 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21698 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21700 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21704 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21708 clib_warning ("parse error '%U'", format_unformat_error, i);
21713 if (parent_if_index == ~0)
21715 errmsg ("missing interface name or sw_if_index");
21720 errmsg ("missing remote mac address");
21724 M (P2P_ETHERNET_DEL, mp);
21725 mp->parent_if_index = ntohl (parent_if_index);
21726 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21734 api_lldp_config (vat_main_t * vam)
21736 unformat_input_t *i = vam->input;
21737 vl_api_lldp_config_t *mp;
21739 int tx_interval = 0;
21740 u8 *sys_name = NULL;
21743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21745 if (unformat (i, "system-name %s", &sys_name))
21747 else if (unformat (i, "tx-hold %d", &tx_hold))
21749 else if (unformat (i, "tx-interval %d", &tx_interval))
21753 clib_warning ("parse error '%U'", format_unformat_error, i);
21758 vec_add1 (sys_name, 0);
21760 M (LLDP_CONFIG, mp);
21761 mp->tx_hold = htonl (tx_hold);
21762 mp->tx_interval = htonl (tx_interval);
21763 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21764 vec_free (sys_name);
21772 api_sw_interface_set_lldp (vat_main_t * vam)
21774 unformat_input_t *i = vam->input;
21775 vl_api_sw_interface_set_lldp_t *mp;
21776 u32 sw_if_index = ~0;
21778 u8 *port_desc = NULL, *mgmt_oid = NULL;
21779 ip4_address_t ip4_addr;
21780 ip6_address_t ip6_addr;
21783 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
21784 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
21786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21788 if (unformat (i, "disable"))
21791 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21793 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21795 else if (unformat (i, "port-desc %s", &port_desc))
21797 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21799 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21801 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
21807 if (sw_if_index == ~0)
21809 errmsg ("missing interface name or sw_if_index");
21813 /* Construct the API message */
21814 vec_add1 (port_desc, 0);
21815 vec_add1 (mgmt_oid, 0);
21816 M (SW_INTERFACE_SET_LLDP, mp);
21817 mp->sw_if_index = ntohl (sw_if_index);
21818 mp->enable = enable;
21819 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
21820 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
21821 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
21822 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
21823 vec_free (port_desc);
21824 vec_free (mgmt_oid);
21832 api_tcp_configure_src_addresses (vat_main_t * vam)
21834 vl_api_tcp_configure_src_addresses_t *mp;
21835 unformat_input_t *i = vam->input;
21836 ip4_address_t v4first, v4last;
21837 ip6_address_t v6first, v6last;
21842 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21844 if (unformat (i, "%U - %U",
21845 unformat_ip4_address, &v4first,
21846 unformat_ip4_address, &v4last))
21850 errmsg ("one range per message (range already set)");
21855 else if (unformat (i, "%U - %U",
21856 unformat_ip6_address, &v6first,
21857 unformat_ip6_address, &v6last))
21861 errmsg ("one range per message (range already set)");
21866 else if (unformat (i, "vrf %d", &vrf_id))
21872 if (range_set == 0)
21874 errmsg ("address range not set");
21878 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
21879 mp->vrf_id = ntohl (vrf_id);
21881 if (range_set == 2)
21884 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
21885 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
21890 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
21891 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
21898 static void vl_api_app_namespace_add_del_reply_t_handler
21899 (vl_api_app_namespace_add_del_reply_t * mp)
21901 vat_main_t *vam = &vat_main;
21902 i32 retval = ntohl (mp->retval);
21903 if (vam->async_mode)
21905 vam->async_errors += (retval < 0);
21909 vam->retval = retval;
21911 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
21912 vam->result_ready = 1;
21916 static void vl_api_app_namespace_add_del_reply_t_handler_json
21917 (vl_api_app_namespace_add_del_reply_t * mp)
21919 vat_main_t *vam = &vat_main;
21920 vat_json_node_t node;
21922 vat_json_init_object (&node);
21923 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
21924 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
21926 vat_json_print (vam->ofp, &node);
21927 vat_json_free (&node);
21929 vam->retval = ntohl (mp->retval);
21930 vam->result_ready = 1;
21934 api_app_namespace_add_del (vat_main_t * vam)
21936 vl_api_app_namespace_add_del_t *mp;
21937 unformat_input_t *i = vam->input;
21938 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
21939 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
21943 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21945 if (unformat (i, "id %_%v%_", &ns_id))
21947 else if (unformat (i, "secret %lu", &secret))
21949 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21950 sw_if_index_set = 1;
21951 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
21953 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
21958 if (!ns_id || !secret_set || !sw_if_index_set)
21960 errmsg ("namespace id, secret and sw_if_index must be set");
21963 if (vec_len (ns_id) > 64)
21965 errmsg ("namespace id too long");
21968 M (APP_NAMESPACE_ADD_DEL, mp);
21970 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
21971 mp->namespace_id_len = vec_len (ns_id);
21972 mp->secret = clib_host_to_net_u64 (secret);
21973 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21974 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
21975 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
21983 api_sock_init_shm (vat_main_t * vam)
21985 #if VPP_API_TEST_BUILTIN == 0
21986 unformat_input_t *i = vam->input;
21987 vl_api_shm_elem_config_t *config = 0;
21988 u64 size = 64 << 20;
21991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21993 if (unformat (i, "size %U", unformat_memory_size, &size))
22000 * Canned custom ring allocator config.
22001 * Should probably parse all of this
22003 vec_validate (config, 6);
22004 config[0].type = VL_API_VLIB_RING;
22005 config[0].size = 256;
22006 config[0].count = 32;
22008 config[1].type = VL_API_VLIB_RING;
22009 config[1].size = 1024;
22010 config[1].count = 16;
22012 config[2].type = VL_API_VLIB_RING;
22013 config[2].size = 4096;
22014 config[2].count = 2;
22016 config[3].type = VL_API_CLIENT_RING;
22017 config[3].size = 256;
22018 config[3].count = 32;
22020 config[4].type = VL_API_CLIENT_RING;
22021 config[4].size = 1024;
22022 config[4].count = 16;
22024 config[5].type = VL_API_CLIENT_RING;
22025 config[5].size = 4096;
22026 config[5].count = 2;
22028 config[6].type = VL_API_QUEUE;
22029 config[6].count = 128;
22030 config[6].size = sizeof (uword);
22032 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
22034 vam->client_index_invalid = 1;
22042 api_dns_enable_disable (vat_main_t * vam)
22044 unformat_input_t *line_input = vam->input;
22045 vl_api_dns_enable_disable_t *mp;
22046 u8 enable_disable = 1;
22049 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22051 if (unformat (line_input, "disable"))
22052 enable_disable = 0;
22053 if (unformat (line_input, "enable"))
22054 enable_disable = 1;
22059 /* Construct the API message */
22060 M (DNS_ENABLE_DISABLE, mp);
22061 mp->enable = enable_disable;
22065 /* Wait for the reply */
22071 api_dns_resolve_name (vat_main_t * vam)
22073 unformat_input_t *line_input = vam->input;
22074 vl_api_dns_resolve_name_t *mp;
22078 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22080 if (unformat (line_input, "%s", &name))
22086 if (vec_len (name) > 127)
22088 errmsg ("name too long");
22092 /* Construct the API message */
22093 M (DNS_RESOLVE_NAME, mp);
22094 memcpy (mp->name, name, vec_len (name));
22099 /* Wait for the reply */
22105 api_dns_resolve_ip (vat_main_t * vam)
22107 unformat_input_t *line_input = vam->input;
22108 vl_api_dns_resolve_ip_t *mp;
22110 ip4_address_t addr4;
22111 ip6_address_t addr6;
22114 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22116 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22118 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22126 errmsg ("missing address");
22130 /* Construct the API message */
22131 M (DNS_RESOLVE_IP, mp);
22132 mp->is_ip6 = is_ip6;
22134 memcpy (mp->address, &addr6, sizeof (addr6));
22136 memcpy (mp->address, &addr4, sizeof (addr4));
22140 /* Wait for the reply */
22146 api_dns_name_server_add_del (vat_main_t * vam)
22148 unformat_input_t *i = vam->input;
22149 vl_api_dns_name_server_add_del_t *mp;
22151 ip6_address_t ip6_server;
22152 ip4_address_t ip4_server;
22157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22159 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22161 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22163 else if (unformat (i, "del"))
22167 clib_warning ("parse error '%U'", format_unformat_error, i);
22172 if (ip4_set && ip6_set)
22174 errmsg ("Only one server address allowed per message");
22177 if ((ip4_set + ip6_set) == 0)
22179 errmsg ("Server address required");
22183 /* Construct the API message */
22184 M (DNS_NAME_SERVER_ADD_DEL, mp);
22188 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22193 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22197 mp->is_add = is_add;
22202 /* Wait for a reply, return good/bad news */
22208 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22210 vat_main_t *vam = &vat_main;
22215 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22216 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22217 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22218 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22219 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22220 clib_net_to_host_u32 (mp->action_index), mp->tag);
22225 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22226 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22227 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22228 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22229 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22230 clib_net_to_host_u32 (mp->action_index), mp->tag);
22235 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22238 vat_main_t *vam = &vat_main;
22239 vat_json_node_t *node = NULL;
22240 struct in6_addr ip6;
22241 struct in_addr ip4;
22243 if (VAT_JSON_ARRAY != vam->json_tree.type)
22245 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22246 vat_json_init_array (&vam->json_tree);
22248 node = vat_json_array_add (&vam->json_tree);
22249 vat_json_init_object (node);
22251 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22252 vat_json_object_add_uint (node, "appns_index",
22253 clib_net_to_host_u32 (mp->appns_index));
22254 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22255 vat_json_object_add_uint (node, "scope", mp->scope);
22256 vat_json_object_add_uint (node, "action_index",
22257 clib_net_to_host_u32 (mp->action_index));
22258 vat_json_object_add_uint (node, "lcl_port",
22259 clib_net_to_host_u16 (mp->lcl_port));
22260 vat_json_object_add_uint (node, "rmt_port",
22261 clib_net_to_host_u16 (mp->rmt_port));
22262 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22263 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22264 vat_json_object_add_string_copy (node, "tag", mp->tag);
22267 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22268 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22269 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22270 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22274 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22275 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22276 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22277 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22282 api_session_rule_add_del (vat_main_t * vam)
22284 vl_api_session_rule_add_del_t *mp;
22285 unformat_input_t *i = vam->input;
22286 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22287 u32 appns_index = 0, scope = 0;
22288 ip4_address_t lcl_ip4, rmt_ip4;
22289 ip6_address_t lcl_ip6, rmt_ip6;
22290 u8 is_ip4 = 1, conn_set = 0;
22291 u8 is_add = 1, *tag = 0;
22294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22296 if (unformat (i, "del"))
22298 else if (unformat (i, "add"))
22300 else if (unformat (i, "proto tcp"))
22302 else if (unformat (i, "proto udp"))
22304 else if (unformat (i, "appns %d", &appns_index))
22306 else if (unformat (i, "scope %d", &scope))
22308 else if (unformat (i, "tag %_%v%_", &tag))
22312 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22313 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22321 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22322 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22328 else if (unformat (i, "action %d", &action))
22333 if (proto == ~0 || !conn_set || action == ~0)
22335 errmsg ("transport proto, connection and action must be set");
22341 errmsg ("scope should be 0-3");
22345 M (SESSION_RULE_ADD_DEL, mp);
22347 mp->is_ip4 = is_ip4;
22348 mp->transport_proto = proto;
22349 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22350 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22351 mp->lcl_plen = lcl_plen;
22352 mp->rmt_plen = rmt_plen;
22353 mp->action_index = clib_host_to_net_u32 (action);
22354 mp->appns_index = clib_host_to_net_u32 (appns_index);
22356 mp->is_add = is_add;
22359 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22360 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22364 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22365 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22369 clib_memcpy (mp->tag, tag, vec_len (tag));
22379 api_session_rules_dump (vat_main_t * vam)
22381 vl_api_session_rules_dump_t *mp;
22382 vl_api_control_ping_t *mp_ping;
22385 if (!vam->json_output)
22387 print (vam->ofp, "%=20s", "Session Rules");
22390 M (SESSION_RULES_DUMP, mp);
22394 /* Use a control ping for synchronization */
22395 MPING (CONTROL_PING, mp_ping);
22398 /* Wait for a reply... */
22404 api_ip_container_proxy_add_del (vat_main_t * vam)
22406 vl_api_ip_container_proxy_add_del_t *mp;
22407 unformat_input_t *i = vam->input;
22408 u32 sw_if_index = ~0;
22409 vl_api_prefix_t pfx = { };
22413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22415 if (unformat (i, "del"))
22417 else if (unformat (i, "add"))
22419 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
22421 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22426 if (sw_if_index == ~0 || pfx.address_length == 0)
22428 errmsg ("address and sw_if_index must be set");
22432 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22434 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22435 mp->is_add = is_add;
22436 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
22444 api_qos_record_enable_disable (vat_main_t * vam)
22446 unformat_input_t *i = vam->input;
22447 vl_api_qos_record_enable_disable_t *mp;
22448 u32 sw_if_index, qs = 0xff;
22449 u8 sw_if_index_set = 0;
22453 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22455 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22456 sw_if_index_set = 1;
22457 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22458 sw_if_index_set = 1;
22459 else if (unformat (i, "%U", unformat_qos_source, &qs))
22461 else if (unformat (i, "disable"))
22465 clib_warning ("parse error '%U'", format_unformat_error, i);
22470 if (sw_if_index_set == 0)
22472 errmsg ("missing interface name or sw_if_index");
22477 errmsg ("input location must be specified");
22481 M (QOS_RECORD_ENABLE_DISABLE, mp);
22483 mp->sw_if_index = ntohl (sw_if_index);
22484 mp->input_source = qs;
22485 mp->enable = enable;
22494 q_or_quit (vat_main_t * vam)
22496 #if VPP_API_TEST_BUILTIN == 0
22497 longjmp (vam->jump_buf, 1);
22499 return 0; /* not so much */
22503 q (vat_main_t * vam)
22505 return q_or_quit (vam);
22509 quit (vat_main_t * vam)
22511 return q_or_quit (vam);
22515 comment (vat_main_t * vam)
22521 statseg (vat_main_t * vam)
22523 ssvm_private_t *ssvmp = &vam->stat_segment;
22524 ssvm_shared_header_t *shared_header = ssvmp->sh;
22525 vlib_counter_t **counters;
22526 u64 thread0_index1_packets;
22527 u64 thread0_index1_bytes;
22528 f64 vector_rate, input_rate;
22531 uword *counter_vector_by_name;
22532 if (vam->stat_segment_lockp == 0)
22534 errmsg ("Stat segment not mapped...");
22538 /* look up "/if/rx for sw_if_index 1 as a test */
22540 clib_spinlock_lock (vam->stat_segment_lockp);
22542 counter_vector_by_name = (uword *) shared_header->opaque[1];
22544 p = hash_get_mem (counter_vector_by_name, "/if/rx");
22547 clib_spinlock_unlock (vam->stat_segment_lockp);
22548 errmsg ("/if/tx not found?");
22552 /* Fish per-thread vector of combined counters from shared memory */
22553 counters = (vlib_counter_t **) p[0];
22555 if (vec_len (counters[0]) < 2)
22557 clib_spinlock_unlock (vam->stat_segment_lockp);
22558 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
22562 /* Read thread 0 sw_if_index 1 counter */
22563 thread0_index1_packets = counters[0][1].packets;
22564 thread0_index1_bytes = counters[0][1].bytes;
22566 p = hash_get_mem (counter_vector_by_name, "vector_rate");
22569 clib_spinlock_unlock (vam->stat_segment_lockp);
22570 errmsg ("vector_rate not found?");
22574 vector_rate = *(f64 *) (p[0]);
22575 p = hash_get_mem (counter_vector_by_name, "input_rate");
22578 clib_spinlock_unlock (vam->stat_segment_lockp);
22579 errmsg ("input_rate not found?");
22582 input_rate = *(f64 *) (p[0]);
22584 clib_spinlock_unlock (vam->stat_segment_lockp);
22586 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
22587 vector_rate, input_rate);
22588 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
22589 thread0_index1_packets, thread0_index1_bytes);
22595 cmd_cmp (void *a1, void *a2)
22600 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22604 help (vat_main_t * vam)
22609 unformat_input_t *i = vam->input;
22612 if (unformat (i, "%s", &name))
22616 vec_add1 (name, 0);
22618 hs = hash_get_mem (vam->help_by_name, name);
22620 print (vam->ofp, "usage: %s %s", name, hs[0]);
22622 print (vam->ofp, "No such msg / command '%s'", name);
22627 print (vam->ofp, "Help is available for the following:");
22630 hash_foreach_pair (p, vam->function_by_name,
22632 vec_add1 (cmds, (u8 *)(p->key));
22636 vec_sort_with_function (cmds, cmd_cmp);
22638 for (j = 0; j < vec_len (cmds); j++)
22639 print (vam->ofp, "%s", cmds[j]);
22646 set (vat_main_t * vam)
22648 u8 *name = 0, *value = 0;
22649 unformat_input_t *i = vam->input;
22651 if (unformat (i, "%s", &name))
22653 /* The input buffer is a vector, not a string. */
22654 value = vec_dup (i->buffer);
22655 vec_delete (value, i->index, 0);
22656 /* Almost certainly has a trailing newline */
22657 if (value[vec_len (value) - 1] == '\n')
22658 value[vec_len (value) - 1] = 0;
22659 /* Make sure it's a proper string, one way or the other */
22660 vec_add1 (value, 0);
22661 (void) clib_macro_set_value (&vam->macro_main,
22662 (char *) name, (char *) value);
22665 errmsg ("usage: set <name> <value>");
22673 unset (vat_main_t * vam)
22677 if (unformat (vam->input, "%s", &name))
22678 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
22679 errmsg ("unset: %s wasn't set", name);
22692 macro_sort_cmp (void *a1, void *a2)
22694 macro_sort_t *s1 = a1;
22695 macro_sort_t *s2 = a2;
22697 return strcmp ((char *) (s1->name), (char *) (s2->name));
22701 dump_macro_table (vat_main_t * vam)
22703 macro_sort_t *sort_me = 0, *sm;
22708 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
22710 vec_add2 (sort_me, sm, 1);
22711 sm->name = (u8 *)(p->key);
22712 sm->value = (u8 *) (p->value[0]);
22716 vec_sort_with_function (sort_me, macro_sort_cmp);
22718 if (vec_len (sort_me))
22719 print (vam->ofp, "%-15s%s", "Name", "Value");
22721 print (vam->ofp, "The macro table is empty...");
22723 for (i = 0; i < vec_len (sort_me); i++)
22724 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
22729 dump_node_table (vat_main_t * vam)
22732 vlib_node_t *node, *next_node;
22734 if (vec_len (vam->graph_nodes) == 0)
22736 print (vam->ofp, "Node table empty, issue get_node_graph...");
22740 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
22742 node = vam->graph_nodes[0][i];
22743 print (vam->ofp, "[%d] %s", i, node->name);
22744 for (j = 0; j < vec_len (node->next_nodes); j++)
22746 if (node->next_nodes[j] != ~0)
22748 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22749 print (vam->ofp, " [%d] %s", j, next_node->name);
22757 value_sort_cmp (void *a1, void *a2)
22759 name_sort_t *n1 = a1;
22760 name_sort_t *n2 = a2;
22762 if (n1->value < n2->value)
22764 if (n1->value > n2->value)
22771 dump_msg_api_table (vat_main_t * vam)
22773 api_main_t *am = &api_main;
22774 name_sort_t *nses = 0, *ns;
22779 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
22781 vec_add2 (nses, ns, 1);
22782 ns->name = (u8 *)(hp->key);
22783 ns->value = (u32) hp->value[0];
22787 vec_sort_with_function (nses, value_sort_cmp);
22789 for (i = 0; i < vec_len (nses); i++)
22790 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
22796 get_msg_id (vat_main_t * vam)
22801 if (unformat (vam->input, "%s", &name_and_crc))
22803 message_index = vl_msg_api_get_msg_index (name_and_crc);
22804 if (message_index == ~0)
22806 print (vam->ofp, " '%s' not found", name_and_crc);
22809 print (vam->ofp, " '%s' has message index %d",
22810 name_and_crc, message_index);
22813 errmsg ("name_and_crc required...");
22818 search_node_table (vat_main_t * vam)
22820 unformat_input_t *line_input = vam->input;
22823 vlib_node_t *node, *next_node;
22826 if (vam->graph_node_index_by_name == 0)
22828 print (vam->ofp, "Node table empty, issue get_node_graph...");
22832 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22834 if (unformat (line_input, "%s", &node_to_find))
22836 vec_add1 (node_to_find, 0);
22837 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
22840 print (vam->ofp, "%s not found...", node_to_find);
22843 node = vam->graph_nodes[0][p[0]];
22844 print (vam->ofp, "[%d] %s", p[0], node->name);
22845 for (j = 0; j < vec_len (node->next_nodes); j++)
22847 if (node->next_nodes[j] != ~0)
22849 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22850 print (vam->ofp, " [%d] %s", j, next_node->name);
22857 clib_warning ("parse error '%U'", format_unformat_error,
22863 vec_free (node_to_find);
22872 script (vat_main_t * vam)
22874 #if (VPP_API_TEST_BUILTIN==0)
22876 char *save_current_file;
22877 unformat_input_t save_input;
22878 jmp_buf save_jump_buf;
22879 u32 save_line_number;
22881 FILE *new_fp, *save_ifp;
22883 if (unformat (vam->input, "%s", &s))
22885 new_fp = fopen ((char *) s, "r");
22888 errmsg ("Couldn't open script file %s", s);
22895 errmsg ("Missing script name");
22899 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
22900 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
22901 save_ifp = vam->ifp;
22902 save_line_number = vam->input_line_number;
22903 save_current_file = (char *) vam->current_file;
22905 vam->input_line_number = 0;
22907 vam->current_file = s;
22910 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
22911 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
22912 vam->ifp = save_ifp;
22913 vam->input_line_number = save_line_number;
22914 vam->current_file = (u8 *) save_current_file;
22919 clib_warning ("use the exec command...");
22925 echo (vat_main_t * vam)
22927 print (vam->ofp, "%v", vam->input->buffer);
22931 /* List of API message constructors, CLI names map to api_xxx */
22932 #define foreach_vpe_api_msg \
22933 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
22934 _(sw_interface_dump,"") \
22935 _(sw_interface_set_flags, \
22936 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
22937 _(sw_interface_add_del_address, \
22938 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
22939 _(sw_interface_set_rx_mode, \
22940 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
22941 _(sw_interface_set_rx_placement, \
22942 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
22943 _(sw_interface_rx_placement_dump, \
22944 "[<intfc> | sw_if_index <id>]") \
22945 _(sw_interface_set_table, \
22946 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
22947 _(sw_interface_set_mpls_enable, \
22948 "<intfc> | sw_if_index [disable | dis]") \
22949 _(sw_interface_set_vpath, \
22950 "<intfc> | sw_if_index <id> enable | disable") \
22951 _(sw_interface_set_vxlan_bypass, \
22952 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22953 _(sw_interface_set_geneve_bypass, \
22954 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22955 _(sw_interface_set_l2_xconnect, \
22956 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22957 "enable | disable") \
22958 _(sw_interface_set_l2_bridge, \
22959 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
22960 "[shg <split-horizon-group>] [bvi]\n" \
22961 "enable | disable") \
22962 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
22963 _(bridge_domain_add_del, \
22964 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [mac-age 0-255] [bd-tag <text>] [del]\n") \
22965 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
22967 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
22968 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
22969 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
22971 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22973 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22975 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
22977 "<vpp-if-name> | sw_if_index <id>") \
22978 _(sw_interface_tap_v2_dump, "") \
22979 _(virtio_pci_create, \
22980 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [tx-ring-size <num> [rx-ring-size <num>] [features <hex-value>]") \
22981 _(virtio_pci_delete, \
22982 "<vpp-if-name> | sw_if_index <id>") \
22983 _(sw_interface_virtio_pci_dump, "") \
22985 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
22986 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
22989 "<vpp-if-name> | sw_if_index <id>") \
22991 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
22992 _(bond_detach_slave, \
22993 "sw_if_index <n>") \
22994 _(sw_interface_bond_dump, "") \
22995 _(sw_interface_slave_dump, \
22996 "<vpp-if-name> | sw_if_index <id>") \
22997 _(ip_table_add_del, \
22998 "table <n> [ipv6] [add | del]\n") \
22999 _(ip_add_del_route, \
23000 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
23001 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
23002 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
23003 "[multipath] [count <n>] [del]") \
23004 _(ip_mroute_add_del, \
23005 "<src> <grp>/<mask> [table-id <n>]\n" \
23006 "[<intfc> | sw_if_index <id>] [local] [del]") \
23007 _(mpls_table_add_del, \
23008 "table <n> [add | del]\n") \
23009 _(mpls_route_add_del, \
23010 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
23011 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
23012 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
23013 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
23014 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
23015 "[count <n>] [del]") \
23016 _(mpls_ip_bind_unbind, \
23017 "<label> <addr/len>") \
23018 _(mpls_tunnel_add_del, \
23019 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
23020 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
23021 "[l2-only] [out-label <n>]") \
23022 _(sr_mpls_policy_add, \
23023 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
23024 _(sr_mpls_policy_del, \
23026 _(bier_table_add_del, \
23027 "<label> <sub-domain> <set> <bsl> [del]") \
23028 _(bier_route_add_del, \
23029 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23030 "[<intfc> | sw_if_index <id>]" \
23031 "[weight <n>] [del] [multipath]") \
23032 _(proxy_arp_add_del, \
23033 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23034 _(proxy_arp_intfc_enable_disable, \
23035 "<intfc> | sw_if_index <id> enable | disable") \
23036 _(sw_interface_set_unnumbered, \
23037 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23038 _(ip_neighbor_add_del, \
23039 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23040 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23041 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23042 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23043 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23044 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23045 "[outer_vlan_id_any][inner_vlan_id_any]") \
23046 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23047 _(reset_fib, "vrf <n> [ipv6]") \
23048 _(dhcp_proxy_config, \
23049 "svr <v46-address> src <v46-address>\n" \
23050 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23051 _(dhcp_proxy_set_vss, \
23052 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23053 _(dhcp_proxy_dump, "ip6") \
23054 _(dhcp_client_config, \
23055 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23056 _(set_ip_flow_hash, \
23057 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23058 _(sw_interface_ip6_enable_disable, \
23059 "<intfc> | sw_if_index <id> enable | disable") \
23060 _(ip6nd_proxy_add_del, \
23061 "<intfc> | sw_if_index <id> <ip6-address>") \
23062 _(ip6nd_proxy_dump, "") \
23063 _(sw_interface_ip6nd_ra_prefix, \
23064 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23065 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23066 "[nolink] [isno]") \
23067 _(sw_interface_ip6nd_ra_config, \
23068 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23069 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23070 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23071 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23072 _(l2_patch_add_del, \
23073 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23074 "enable | disable") \
23075 _(sr_localsid_add_del, \
23076 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23077 "fib-table <num> (end.psp) sw_if_index <num>") \
23078 _(classify_add_del_table, \
23079 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23080 " [del] [del-chain] mask <mask-value>\n" \
23081 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23082 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23083 _(classify_add_del_session, \
23084 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23085 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23086 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23087 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23088 _(classify_set_interface_ip_table, \
23089 "<intfc> | sw_if_index <nn> table <nn>") \
23090 _(classify_set_interface_l2_tables, \
23091 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23092 " [other-table <nn>]") \
23093 _(get_node_index, "node <node-name") \
23094 _(add_node_next, "node <node-name> next <next-node-name>") \
23095 _(l2tpv3_create_tunnel, \
23096 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23097 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23098 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23099 _(l2tpv3_set_tunnel_cookies, \
23100 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23101 "[new_remote_cookie <nn>]\n") \
23102 _(l2tpv3_interface_enable_disable, \
23103 "<intfc> | sw_if_index <nn> enable | disable") \
23104 _(l2tpv3_set_lookup_key, \
23105 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23106 _(sw_if_l2tpv3_tunnel_dump, "") \
23107 _(vxlan_offload_rx, \
23108 "hw { <interface name> | hw_if_index <nn>} " \
23109 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23110 _(vxlan_add_del_tunnel, \
23111 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23112 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23113 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23114 _(geneve_add_del_tunnel, \
23115 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23116 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23117 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23118 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23119 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23120 _(gre_add_del_tunnel, \
23121 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23122 "[teb | erspan <session-id>] [del]") \
23123 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23124 _(l2_fib_clear_table, "") \
23125 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23126 _(l2_interface_vlan_tag_rewrite, \
23127 "<intfc> | sw_if_index <nn> \n" \
23128 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23129 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23130 _(create_vhost_user_if, \
23131 "socket <filename> [server] [renumber <dev_instance>] " \
23132 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
23133 "[mac <mac_address>]") \
23134 _(modify_vhost_user_if, \
23135 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23136 "[server] [renumber <dev_instance>]") \
23137 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23138 _(sw_interface_vhost_user_dump, "") \
23139 _(show_version, "") \
23140 _(show_threads, "") \
23141 _(vxlan_gpe_add_del_tunnel, \
23142 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23143 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23144 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23145 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23146 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23147 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23148 _(interface_name_renumber, \
23149 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23150 _(input_acl_set_interface, \
23151 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23152 " [l2-table <nn>] [del]") \
23153 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23154 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23155 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23156 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23157 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23158 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23159 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23160 _(ip_dump, "ipv4 | ipv6") \
23161 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23162 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23164 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23165 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23166 " integ_alg <alg> integ_key <hex>") \
23167 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
23168 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23169 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23170 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23171 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23172 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23173 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23174 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23175 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23176 " [instance <n>]") \
23177 _(ipsec_sa_dump, "[sa_id <n>]") \
23178 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23179 " <alg> <hex>\n") \
23180 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23181 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23182 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23183 "(auth_data 0x<data> | auth_data <data>)") \
23184 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23185 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23186 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23187 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23188 "(local|remote)") \
23189 _(ikev2_set_local_key, "file <absolute_file_path>") \
23190 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23191 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23192 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23193 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23194 _(ikev2_initiate_sa_init, "<profile_name>") \
23195 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23196 _(ikev2_initiate_del_child_sa, "<ispi>") \
23197 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23198 _(delete_loopback,"sw_if_index <nn>") \
23199 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23200 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
23201 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
23202 _(want_interface_events, "enable|disable") \
23203 _(get_first_msg_id, "client <name>") \
23204 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23205 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23206 "fib-id <nn> [ip4][ip6][default]") \
23207 _(get_node_graph, " ") \
23208 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23209 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23210 _(ioam_disable, "") \
23211 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23212 " sw_if_index <sw_if_index> p <priority> " \
23213 "w <weight>] [del]") \
23214 _(one_add_del_locator, "locator-set <locator_name> " \
23215 "iface <intf> | sw_if_index <sw_if_index> " \
23216 "p <priority> w <weight> [del]") \
23217 _(one_add_del_local_eid,"vni <vni> eid " \
23218 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23219 "locator-set <locator_name> [del]" \
23220 "[key-id sha1|sha256 secret-key <secret-key>]")\
23221 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23222 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23223 _(one_enable_disable, "enable|disable") \
23224 _(one_map_register_enable_disable, "enable|disable") \
23225 _(one_map_register_fallback_threshold, "<value>") \
23226 _(one_rloc_probe_enable_disable, "enable|disable") \
23227 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23229 "rloc <locator> p <prio> " \
23230 "w <weight> [rloc <loc> ... ] " \
23231 "action <action> [del-all]") \
23232 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23234 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23235 _(one_use_petr, "ip-address> | disable") \
23236 _(one_map_request_mode, "src-dst|dst-only") \
23237 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23238 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23239 _(one_locator_set_dump, "[local | remote]") \
23240 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23241 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23242 "[local] | [remote]") \
23243 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23244 _(one_ndp_bd_get, "") \
23245 _(one_ndp_entries_get, "bd <bridge-domain>") \
23246 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23247 _(one_l2_arp_bd_get, "") \
23248 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23249 _(one_stats_enable_disable, "enable|disable") \
23250 _(show_one_stats_enable_disable, "") \
23251 _(one_eid_table_vni_dump, "") \
23252 _(one_eid_table_map_dump, "l2|l3") \
23253 _(one_map_resolver_dump, "") \
23254 _(one_map_server_dump, "") \
23255 _(one_adjacencies_get, "vni <vni>") \
23256 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23257 _(show_one_rloc_probe_state, "") \
23258 _(show_one_map_register_state, "") \
23259 _(show_one_status, "") \
23260 _(one_stats_dump, "") \
23261 _(one_stats_flush, "") \
23262 _(one_get_map_request_itr_rlocs, "") \
23263 _(one_map_register_set_ttl, "<ttl>") \
23264 _(one_set_transport_protocol, "udp|api") \
23265 _(one_get_transport_protocol, "") \
23266 _(one_enable_disable_xtr_mode, "enable|disable") \
23267 _(one_show_xtr_mode, "") \
23268 _(one_enable_disable_pitr_mode, "enable|disable") \
23269 _(one_show_pitr_mode, "") \
23270 _(one_enable_disable_petr_mode, "enable|disable") \
23271 _(one_show_petr_mode, "") \
23272 _(show_one_nsh_mapping, "") \
23273 _(show_one_pitr, "") \
23274 _(show_one_use_petr, "") \
23275 _(show_one_map_request_mode, "") \
23276 _(show_one_map_register_ttl, "") \
23277 _(show_one_map_register_fallback_threshold, "") \
23278 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23279 " sw_if_index <sw_if_index> p <priority> " \
23280 "w <weight>] [del]") \
23281 _(lisp_add_del_locator, "locator-set <locator_name> " \
23282 "iface <intf> | sw_if_index <sw_if_index> " \
23283 "p <priority> w <weight> [del]") \
23284 _(lisp_add_del_local_eid,"vni <vni> eid " \
23285 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23286 "locator-set <locator_name> [del]" \
23287 "[key-id sha1|sha256 secret-key <secret-key>]") \
23288 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23289 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23290 _(lisp_enable_disable, "enable|disable") \
23291 _(lisp_map_register_enable_disable, "enable|disable") \
23292 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23293 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23295 "rloc <locator> p <prio> " \
23296 "w <weight> [rloc <loc> ... ] " \
23297 "action <action> [del-all]") \
23298 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23300 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23301 _(lisp_use_petr, "<ip-address> | disable") \
23302 _(lisp_map_request_mode, "src-dst|dst-only") \
23303 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23304 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23305 _(lisp_locator_set_dump, "[local | remote]") \
23306 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23307 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23308 "[local] | [remote]") \
23309 _(lisp_eid_table_vni_dump, "") \
23310 _(lisp_eid_table_map_dump, "l2|l3") \
23311 _(lisp_map_resolver_dump, "") \
23312 _(lisp_map_server_dump, "") \
23313 _(lisp_adjacencies_get, "vni <vni>") \
23314 _(gpe_fwd_entry_vnis_get, "") \
23315 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23316 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23317 "[table <table-id>]") \
23318 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23319 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23320 _(gpe_set_encap_mode, "lisp|vxlan") \
23321 _(gpe_get_encap_mode, "") \
23322 _(lisp_gpe_add_del_iface, "up|down") \
23323 _(lisp_gpe_enable_disable, "enable|disable") \
23324 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23325 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23326 _(show_lisp_rloc_probe_state, "") \
23327 _(show_lisp_map_register_state, "") \
23328 _(show_lisp_status, "") \
23329 _(lisp_get_map_request_itr_rlocs, "") \
23330 _(show_lisp_pitr, "") \
23331 _(show_lisp_use_petr, "") \
23332 _(show_lisp_map_request_mode, "") \
23333 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23334 _(af_packet_delete, "name <host interface name>") \
23335 _(af_packet_dump, "") \
23336 _(policer_add_del, "name <policer name> <params> [del]") \
23337 _(policer_dump, "[name <policer name>]") \
23338 _(policer_classify_set_interface, \
23339 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23340 " [l2-table <nn>] [del]") \
23341 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23342 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23343 "[master|slave]") \
23344 _(netmap_delete, "name <interface name>") \
23345 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23346 _(mpls_fib_dump, "") \
23347 _(classify_table_ids, "") \
23348 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23349 _(classify_table_info, "table_id <nn>") \
23350 _(classify_session_dump, "table_id <nn>") \
23351 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23352 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23353 "[template_interval <nn>] [udp_checksum]") \
23354 _(ipfix_exporter_dump, "") \
23355 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23356 _(ipfix_classify_stream_dump, "") \
23357 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23358 _(ipfix_classify_table_dump, "") \
23359 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23360 _(sw_interface_span_dump, "[l2]") \
23361 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23362 _(pg_create_interface, "if_id <nn>") \
23363 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23364 _(pg_enable_disable, "[stream <id>] disable") \
23365 _(ip_source_and_port_range_check_add_del, \
23366 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23367 _(ip_source_and_port_range_check_interface_add_del, \
23368 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23369 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23370 _(ipsec_gre_add_del_tunnel, \
23371 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23372 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23373 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23374 _(l2_interface_pbb_tag_rewrite, \
23375 "<intfc> | sw_if_index <nn> \n" \
23376 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23377 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23378 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23379 _(flow_classify_set_interface, \
23380 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23381 _(flow_classify_dump, "type [ip4|ip6]") \
23382 _(ip_fib_dump, "") \
23383 _(ip_mfib_dump, "") \
23384 _(ip6_fib_dump, "") \
23385 _(ip6_mfib_dump, "") \
23386 _(feature_enable_disable, "arc_name <arc_name> " \
23387 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23388 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23390 _(l2_xconnect_dump, "") \
23391 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
23392 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23393 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23394 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23395 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23396 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23397 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23398 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23399 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23400 _(sock_init_shm, "size <nnn>") \
23401 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23402 _(dns_enable_disable, "[enable][disable]") \
23403 _(dns_name_server_add_del, "<ip-address> [del]") \
23404 _(dns_resolve_name, "<hostname>") \
23405 _(dns_resolve_ip, "<ip4|ip6>") \
23406 _(dns_name_server_add_del, "<ip-address> [del]") \
23407 _(dns_resolve_name, "<hostname>") \
23408 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23409 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23410 _(session_rules_dump, "") \
23411 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23412 _(output_acl_set_interface, \
23413 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23414 " [l2-table <nn>] [del]") \
23415 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
23417 /* List of command functions, CLI names map directly to functions */
23418 #define foreach_cli_function \
23419 _(comment, "usage: comment <ignore-rest-of-line>") \
23420 _(dump_interface_table, "usage: dump_interface_table") \
23421 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23422 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23423 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23424 _(dump_macro_table, "usage: dump_macro_table ") \
23425 _(dump_node_table, "usage: dump_node_table") \
23426 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23427 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23428 _(echo, "usage: echo <message>") \
23429 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23430 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23431 _(help, "usage: help") \
23432 _(q, "usage: quit") \
23433 _(quit, "usage: quit") \
23434 _(search_node_table, "usage: search_node_table <name>...") \
23435 _(set, "usage: set <variable-name> <value>") \
23436 _(script, "usage: script <file-name>") \
23437 _(statseg, "usage: statseg"); \
23438 _(unset, "usage: unset <variable-name>")
23441 static void vl_api_##n##_t_handler_uni \
23442 (vl_api_##n##_t * mp) \
23444 vat_main_t * vam = &vat_main; \
23445 if (vam->json_output) { \
23446 vl_api_##n##_t_handler_json(mp); \
23448 vl_api_##n##_t_handler(mp); \
23451 foreach_vpe_api_reply_msg;
23452 #if VPP_API_TEST_BUILTIN == 0
23453 foreach_standalone_reply_msg;
23458 vat_api_hookup (vat_main_t * vam)
23461 vl_msg_api_set_handlers(VL_API_##N, #n, \
23462 vl_api_##n##_t_handler_uni, \
23464 vl_api_##n##_t_endian, \
23465 vl_api_##n##_t_print, \
23466 sizeof(vl_api_##n##_t), 1);
23467 foreach_vpe_api_reply_msg;
23468 #if VPP_API_TEST_BUILTIN == 0
23469 foreach_standalone_reply_msg;
23473 #if (VPP_API_TEST_BUILTIN==0)
23474 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23476 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23478 vam->function_by_name = hash_create_string (0, sizeof (uword));
23480 vam->help_by_name = hash_create_string (0, sizeof (uword));
23483 /* API messages we can send */
23484 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23485 foreach_vpe_api_msg;
23489 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23490 foreach_vpe_api_msg;
23493 /* CLI functions */
23494 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23495 foreach_cli_function;
23499 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23500 foreach_cli_function;
23504 #if VPP_API_TEST_BUILTIN
23505 static clib_error_t *
23506 vat_api_hookup_shim (vlib_main_t * vm)
23508 vat_api_hookup (&vat_main);
23512 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
23516 * fd.io coding-style-patch-verification: ON
23519 * eval: (c-set-style "gnu")