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/l2/l2_input.h>
28 #include <vnet/l2tp/l2tp.h>
29 #include <vnet/vxlan/vxlan.h>
30 #include <vnet/geneve/geneve.h>
31 #include <vnet/gre/gre.h>
32 #include <vnet/vxlan-gpe/vxlan_gpe.h>
33 #include <vnet/lisp-gpe/lisp_gpe.h>
35 #include <vpp/api/vpe_msg_enum.h>
36 #include <vnet/l2/l2_classify.h>
37 #include <vnet/l2/l2_vtr.h>
38 #include <vnet/classify/in_out_acl.h>
39 #include <vnet/classify/policer_classify.h>
40 #include <vnet/classify/flow_classify.h>
41 #include <vnet/mpls/mpls.h>
42 #include <vnet/ipsec/ipsec.h>
43 #include <vnet/ipsec/ikev2.h>
45 #include <vnet/cop/cop.h>
46 #include <vnet/ip/ip6_hop_by_hop.h>
47 #include <vnet/ip/ip_source_and_port_range_check.h>
48 #include <vnet/policer/xlate.h>
49 #include <vnet/span/span.h>
50 #include <vnet/policer/policer.h>
51 #include <vnet/policer/police.h>
52 #include <vnet/mfib/mfib_types.h>
53 #include <vnet/dhcp/dhcp_proxy.h>
54 #include <vnet/bonding/node.h>
55 #include <vnet/qos/qos_types.h>
56 #include "vat/json_format.h"
57 #include <vnet/ip/ip_types_api.h>
58 #include <vnet/ethernet/ethernet_types_api.h>
63 #define vl_typedefs /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
67 /* declare message handlers for each api */
69 #define vl_endianfun /* define message structures */
70 #include <vpp/api/vpe_all_api_h.h>
73 /* instantiate all the print functions we know about */
74 #define vl_print(handle, ...)
76 #include <vpp/api/vpe_all_api_h.h>
79 #define __plugin_msg_base 0
80 #include <vlibapi/vat_helper_macros.h>
82 #if VPP_API_TEST_BUILTIN == 0
86 const mac_address_t ZERO_MAC_ADDRESS = {
100 vat_socket_connect (vat_main_t * vam)
102 vam->socket_client_main = &socket_client_main;
103 return vl_socket_client_connect ((char *) vam->socket_name, "vpp_api_test",
104 0 /* default socket rx, tx buffer */ );
106 #else /* vpp built-in case, we don't do sockets... */
108 vat_socket_connect (vat_main_t * vam)
114 vl_socket_client_read (int wait)
120 vl_socket_client_write ()
126 vl_socket_client_msg_alloc (int nbytes)
134 vat_time_now (vat_main_t * vam)
136 #if VPP_API_TEST_BUILTIN
137 return vlib_time_now (vam->vlib_main);
139 return clib_time_now (&vam->clib_time);
144 errmsg (char *fmt, ...)
146 vat_main_t *vam = &vat_main;
151 s = va_format (0, fmt, &va);
156 #if VPP_API_TEST_BUILTIN
157 vlib_cli_output (vam->vlib_main, (char *) s);
160 if (vam->ifp != stdin)
161 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
162 vam->input_line_number);
163 fformat (vam->ofp, (char *) s);
171 #if VPP_API_TEST_BUILTIN == 0
173 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
175 vat_main_t *vam = va_arg (*args, vat_main_t *);
176 u32 *result = va_arg (*args, u32 *);
180 if (!unformat (input, "%s", &if_name))
183 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
191 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
196 /* Parse an IP4 address %d.%d.%d.%d. */
198 unformat_ip4_address (unformat_input_t * input, va_list * args)
200 u8 *result = va_arg (*args, u8 *);
203 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
206 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
218 unformat_ethernet_address (unformat_input_t * input, va_list * args)
220 u8 *result = va_arg (*args, u8 *);
223 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
224 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
228 for (i = 0; i < 6; i++)
229 if (a[i] >= (1 << 8))
232 for (i = 0; i < 6; i++)
238 /* Returns ethernet type as an int in host byte order. */
240 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
243 u16 *result = va_arg (*args, u16 *);
247 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
249 if (type >= (1 << 16))
257 /* Parse an IP6 address. */
259 unformat_ip6_address (unformat_input_t * input, va_list * args)
261 ip6_address_t *result = va_arg (*args, ip6_address_t *);
263 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
264 uword c, n_colon, double_colon_index;
266 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
267 double_colon_index = ARRAY_LEN (hex_quads);
268 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
271 if (c >= '0' && c <= '9')
273 else if (c >= 'a' && c <= 'f')
274 hex_digit = c + 10 - 'a';
275 else if (c >= 'A' && c <= 'F')
276 hex_digit = c + 10 - 'A';
277 else if (c == ':' && n_colon < 2)
281 unformat_put_input (input);
285 /* Too many hex quads. */
286 if (n_hex_quads >= ARRAY_LEN (hex_quads))
291 hex_quad = (hex_quad << 4) | hex_digit;
293 /* Hex quad must fit in 16 bits. */
294 if (n_hex_digits >= 4)
301 /* Save position of :: */
304 /* More than one :: ? */
305 if (double_colon_index < ARRAY_LEN (hex_quads))
307 double_colon_index = n_hex_quads;
310 if (n_colon > 0 && n_hex_digits > 0)
312 hex_quads[n_hex_quads++] = hex_quad;
318 if (n_hex_digits > 0)
319 hex_quads[n_hex_quads++] = hex_quad;
324 /* Expand :: to appropriate number of zero hex quads. */
325 if (double_colon_index < ARRAY_LEN (hex_quads))
327 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
329 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
330 hex_quads[n_zero + i] = hex_quads[i];
332 for (i = 0; i < n_zero; i++)
333 hex_quads[double_colon_index + i] = 0;
335 n_hex_quads = ARRAY_LEN (hex_quads);
338 /* Too few hex quads given. */
339 if (n_hex_quads < ARRAY_LEN (hex_quads))
342 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
343 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
350 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
352 u32 *r = va_arg (*args, u32 *);
355 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
356 foreach_ipsec_policy_action
364 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
366 u32 *r = va_arg (*args, u32 *);
369 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
370 foreach_ipsec_crypto_alg
378 format_ipsec_crypto_alg (u8 * s, va_list * args)
380 u32 i = va_arg (*args, u32);
385 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
386 foreach_ipsec_crypto_alg
389 return format (s, "unknown");
391 return format (s, "%s", t);
395 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
397 u32 *r = va_arg (*args, u32 *);
400 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
401 foreach_ipsec_integ_alg
409 format_ipsec_integ_alg (u8 * s, va_list * args)
411 u32 i = va_arg (*args, u32);
416 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
417 foreach_ipsec_integ_alg
420 return format (s, "unknown");
422 return format (s, "%s", t);
426 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
428 u32 *r = va_arg (*args, u32 *);
431 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
432 foreach_ikev2_auth_method
440 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
442 u32 *r = va_arg (*args, u32 *);
445 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
446 foreach_ikev2_id_type
452 #else /* VPP_API_TEST_BUILTIN == 1 */
454 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
456 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
457 vnet_main_t *vnm = vnet_get_main ();
458 u32 *result = va_arg (*args, u32 *);
460 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
464 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
466 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
467 vnet_main_t *vnm = vnet_get_main ();
468 u32 *result = va_arg (*args, u32 *);
470 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
473 #endif /* VPP_API_TEST_BUILTIN */
476 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
478 u8 *r = va_arg (*args, u8 *);
480 if (unformat (input, "kbps"))
481 *r = SSE2_QOS_RATE_KBPS;
482 else if (unformat (input, "pps"))
483 *r = SSE2_QOS_RATE_PPS;
490 unformat_policer_round_type (unformat_input_t * input, va_list * args)
492 u8 *r = va_arg (*args, u8 *);
494 if (unformat (input, "closest"))
495 *r = SSE2_QOS_ROUND_TO_CLOSEST;
496 else if (unformat (input, "up"))
497 *r = SSE2_QOS_ROUND_TO_UP;
498 else if (unformat (input, "down"))
499 *r = SSE2_QOS_ROUND_TO_DOWN;
506 unformat_policer_type (unformat_input_t * input, va_list * args)
508 u8 *r = va_arg (*args, u8 *);
510 if (unformat (input, "1r2c"))
511 *r = SSE2_QOS_POLICER_TYPE_1R2C;
512 else if (unformat (input, "1r3c"))
513 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
514 else if (unformat (input, "2r3c-2698"))
515 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
516 else if (unformat (input, "2r3c-4115"))
517 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
518 else if (unformat (input, "2r3c-mef5cf1"))
519 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
526 unformat_dscp (unformat_input_t * input, va_list * va)
528 u8 *r = va_arg (*va, u8 *);
531 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
540 unformat_policer_action_type (unformat_input_t * input, va_list * va)
542 sse2_qos_pol_action_params_st *a
543 = va_arg (*va, sse2_qos_pol_action_params_st *);
545 if (unformat (input, "drop"))
546 a->action_type = SSE2_QOS_ACTION_DROP;
547 else if (unformat (input, "transmit"))
548 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
549 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
550 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
557 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
559 u32 *r = va_arg (*va, u32 *);
562 if (unformat (input, "ip4"))
563 tid = POLICER_CLASSIFY_TABLE_IP4;
564 else if (unformat (input, "ip6"))
565 tid = POLICER_CLASSIFY_TABLE_IP6;
566 else if (unformat (input, "l2"))
567 tid = POLICER_CLASSIFY_TABLE_L2;
576 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
578 u32 *r = va_arg (*va, u32 *);
581 if (unformat (input, "ip4"))
582 tid = FLOW_CLASSIFY_TABLE_IP4;
583 else if (unformat (input, "ip6"))
584 tid = FLOW_CLASSIFY_TABLE_IP6;
592 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
593 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
594 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
595 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
597 #if (VPP_API_TEST_BUILTIN==0)
599 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
601 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
602 mfib_itf_attribute_t attr;
605 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
607 if (unformat (input, mfib_itf_flag_long_names[attr]))
608 *iflags |= (1 << attr);
610 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
612 if (unformat (input, mfib_itf_flag_names[attr]))
613 *iflags |= (1 << attr);
616 return (old == *iflags ? 0 : 1);
620 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
622 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
623 mfib_entry_attribute_t attr;
626 FOR_EACH_MFIB_ATTRIBUTE (attr)
628 if (unformat (input, mfib_flag_long_names[attr]))
629 *eflags |= (1 << attr);
631 FOR_EACH_MFIB_ATTRIBUTE (attr)
633 if (unformat (input, mfib_flag_names[attr]))
634 *eflags |= (1 << attr);
637 return (old == *eflags ? 0 : 1);
641 format_ip4_address (u8 * s, va_list * args)
643 u8 *a = va_arg (*args, u8 *);
644 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
648 format_ip6_address (u8 * s, va_list * args)
650 ip6_address_t *a = va_arg (*args, ip6_address_t *);
651 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
653 i_max_n_zero = ARRAY_LEN (a->as_u16);
655 i_first_zero = i_max_n_zero;
657 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
659 u32 is_zero = a->as_u16[i] == 0;
660 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
666 if ((!is_zero && n_zeros > max_n_zeros)
667 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
669 i_max_n_zero = i_first_zero;
670 max_n_zeros = n_zeros;
671 i_first_zero = ARRAY_LEN (a->as_u16);
676 last_double_colon = 0;
677 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
679 if (i == i_max_n_zero && max_n_zeros > 1)
681 s = format (s, "::");
682 i += max_n_zeros - 1;
683 last_double_colon = 1;
687 s = format (s, "%s%x",
688 (last_double_colon || i == 0) ? "" : ":",
689 clib_net_to_host_u16 (a->as_u16[i]));
690 last_double_colon = 0;
697 /* Format an IP46 address. */
699 format_ip46_address (u8 * s, va_list * args)
701 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
702 ip46_type_t type = va_arg (*args, ip46_type_t);
708 is_ip4 = ip46_address_is_ip4 (ip46);
719 format (s, "%U", format_ip4_address, &ip46->ip4) :
720 format (s, "%U", format_ip6_address, &ip46->ip6);
724 format_ethernet_address (u8 * s, va_list * args)
726 u8 *a = va_arg (*args, u8 *);
728 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
729 a[0], a[1], a[2], a[3], a[4], a[5]);
734 increment_v4_address (ip4_address_t * a)
738 v = ntohl (a->as_u32) + 1;
739 a->as_u32 = ntohl (v);
743 increment_v6_address (ip6_address_t * a)
747 v0 = clib_net_to_host_u64 (a->as_u64[0]);
748 v1 = clib_net_to_host_u64 (a->as_u64[1]);
753 a->as_u64[0] = clib_net_to_host_u64 (v0);
754 a->as_u64[1] = clib_net_to_host_u64 (v1);
758 increment_mac_address (u8 * mac)
760 u64 tmp = *((u64 *) mac);
761 tmp = clib_net_to_host_u64 (tmp);
762 tmp += 1 << 16; /* skip unused (least significant) octets */
763 tmp = clib_host_to_net_u64 (tmp);
765 clib_memcpy (mac, &tmp, 6);
768 static void vl_api_create_loopback_reply_t_handler
769 (vl_api_create_loopback_reply_t * mp)
771 vat_main_t *vam = &vat_main;
772 i32 retval = ntohl (mp->retval);
774 vam->retval = retval;
775 vam->regenerate_interface_table = 1;
776 vam->sw_if_index = ntohl (mp->sw_if_index);
777 vam->result_ready = 1;
780 static void vl_api_create_loopback_reply_t_handler_json
781 (vl_api_create_loopback_reply_t * mp)
783 vat_main_t *vam = &vat_main;
784 vat_json_node_t node;
786 vat_json_init_object (&node);
787 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
788 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
790 vat_json_print (vam->ofp, &node);
791 vat_json_free (&node);
792 vam->retval = ntohl (mp->retval);
793 vam->result_ready = 1;
796 static void vl_api_create_loopback_instance_reply_t_handler
797 (vl_api_create_loopback_instance_reply_t * mp)
799 vat_main_t *vam = &vat_main;
800 i32 retval = ntohl (mp->retval);
802 vam->retval = retval;
803 vam->regenerate_interface_table = 1;
804 vam->sw_if_index = ntohl (mp->sw_if_index);
805 vam->result_ready = 1;
808 static void vl_api_create_loopback_instance_reply_t_handler_json
809 (vl_api_create_loopback_instance_reply_t * mp)
811 vat_main_t *vam = &vat_main;
812 vat_json_node_t node;
814 vat_json_init_object (&node);
815 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
816 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
818 vat_json_print (vam->ofp, &node);
819 vat_json_free (&node);
820 vam->retval = ntohl (mp->retval);
821 vam->result_ready = 1;
824 static void vl_api_af_packet_create_reply_t_handler
825 (vl_api_af_packet_create_reply_t * mp)
827 vat_main_t *vam = &vat_main;
828 i32 retval = ntohl (mp->retval);
830 vam->retval = retval;
831 vam->regenerate_interface_table = 1;
832 vam->sw_if_index = ntohl (mp->sw_if_index);
833 vam->result_ready = 1;
836 static void vl_api_af_packet_create_reply_t_handler_json
837 (vl_api_af_packet_create_reply_t * mp)
839 vat_main_t *vam = &vat_main;
840 vat_json_node_t node;
842 vat_json_init_object (&node);
843 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
844 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
846 vat_json_print (vam->ofp, &node);
847 vat_json_free (&node);
849 vam->retval = ntohl (mp->retval);
850 vam->result_ready = 1;
853 static void vl_api_create_vlan_subif_reply_t_handler
854 (vl_api_create_vlan_subif_reply_t * mp)
856 vat_main_t *vam = &vat_main;
857 i32 retval = ntohl (mp->retval);
859 vam->retval = retval;
860 vam->regenerate_interface_table = 1;
861 vam->sw_if_index = ntohl (mp->sw_if_index);
862 vam->result_ready = 1;
865 static void vl_api_create_vlan_subif_reply_t_handler_json
866 (vl_api_create_vlan_subif_reply_t * mp)
868 vat_main_t *vam = &vat_main;
869 vat_json_node_t node;
871 vat_json_init_object (&node);
872 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
873 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
875 vat_json_print (vam->ofp, &node);
876 vat_json_free (&node);
878 vam->retval = ntohl (mp->retval);
879 vam->result_ready = 1;
882 static void vl_api_create_subif_reply_t_handler
883 (vl_api_create_subif_reply_t * mp)
885 vat_main_t *vam = &vat_main;
886 i32 retval = ntohl (mp->retval);
888 vam->retval = retval;
889 vam->regenerate_interface_table = 1;
890 vam->sw_if_index = ntohl (mp->sw_if_index);
891 vam->result_ready = 1;
894 static void vl_api_create_subif_reply_t_handler_json
895 (vl_api_create_subif_reply_t * mp)
897 vat_main_t *vam = &vat_main;
898 vat_json_node_t node;
900 vat_json_init_object (&node);
901 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
902 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
904 vat_json_print (vam->ofp, &node);
905 vat_json_free (&node);
907 vam->retval = ntohl (mp->retval);
908 vam->result_ready = 1;
911 static void vl_api_interface_name_renumber_reply_t_handler
912 (vl_api_interface_name_renumber_reply_t * mp)
914 vat_main_t *vam = &vat_main;
915 i32 retval = ntohl (mp->retval);
917 vam->retval = retval;
918 vam->regenerate_interface_table = 1;
919 vam->result_ready = 1;
922 static void vl_api_interface_name_renumber_reply_t_handler_json
923 (vl_api_interface_name_renumber_reply_t * mp)
925 vat_main_t *vam = &vat_main;
926 vat_json_node_t node;
928 vat_json_init_object (&node);
929 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
931 vat_json_print (vam->ofp, &node);
932 vat_json_free (&node);
934 vam->retval = ntohl (mp->retval);
935 vam->result_ready = 1;
939 * Special-case: build the interface table, maintain
940 * the next loopback sw_if_index vbl.
942 static void vl_api_sw_interface_details_t_handler
943 (vl_api_sw_interface_details_t * mp)
945 vat_main_t *vam = &vat_main;
946 u8 *s = format (0, "%s%c", mp->interface_name, 0);
948 hash_set_mem (vam->sw_if_index_by_interface_name, s,
949 ntohl (mp->sw_if_index));
951 /* In sub interface case, fill the sub interface table entry */
952 if (mp->sw_if_index != mp->sup_sw_if_index)
954 sw_interface_subif_t *sub = NULL;
956 vec_add2 (vam->sw_if_subif_table, sub, 1);
958 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
959 strncpy ((char *) sub->interface_name, (char *) s,
960 vec_len (sub->interface_name));
961 sub->sw_if_index = ntohl (mp->sw_if_index);
962 sub->sub_id = ntohl (mp->sub_id);
964 sub->sub_dot1ad = mp->sub_dot1ad;
965 sub->sub_number_of_tags = mp->sub_number_of_tags;
966 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
967 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
968 sub->sub_exact_match = mp->sub_exact_match;
969 sub->sub_default = mp->sub_default;
970 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
971 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
973 /* vlan tag rewrite */
974 sub->vtr_op = ntohl (mp->vtr_op);
975 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
976 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
977 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
981 static void vl_api_sw_interface_details_t_handler_json
982 (vl_api_sw_interface_details_t * mp)
984 vat_main_t *vam = &vat_main;
985 vat_json_node_t *node = NULL;
987 if (VAT_JSON_ARRAY != vam->json_tree.type)
989 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
990 vat_json_init_array (&vam->json_tree);
992 node = vat_json_array_add (&vam->json_tree);
994 vat_json_init_object (node);
995 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
996 vat_json_object_add_uint (node, "sup_sw_if_index",
997 ntohl (mp->sup_sw_if_index));
998 vat_json_object_add_uint (node, "l2_address_length",
999 ntohl (mp->l2_address_length));
1000 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
1001 sizeof (mp->l2_address));
1002 vat_json_object_add_string_copy (node, "interface_name",
1003 mp->interface_name);
1004 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
1005 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
1006 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1007 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1008 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1009 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1010 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
1011 vat_json_object_add_uint (node, "sub_number_of_tags",
1012 mp->sub_number_of_tags);
1013 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1014 ntohs (mp->sub_outer_vlan_id));
1015 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1016 ntohs (mp->sub_inner_vlan_id));
1017 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
1018 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
1019 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
1020 mp->sub_outer_vlan_id_any);
1021 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1022 mp->sub_inner_vlan_id_any);
1023 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1024 vat_json_object_add_uint (node, "vtr_push_dot1q",
1025 ntohl (mp->vtr_push_dot1q));
1026 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1027 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1030 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1032 format_ethernet_address,
1034 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1036 format_ethernet_address,
1038 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1039 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1043 #if VPP_API_TEST_BUILTIN == 0
1044 static void vl_api_sw_interface_event_t_handler
1045 (vl_api_sw_interface_event_t * mp)
1047 vat_main_t *vam = &vat_main;
1048 if (vam->interface_event_display)
1049 errmsg ("interface flags: sw_if_index %d %s %s",
1050 ntohl (mp->sw_if_index),
1051 mp->admin_up_down ? "admin-up" : "admin-down",
1052 mp->link_up_down ? "link-up" : "link-down");
1056 static void vl_api_sw_interface_event_t_handler_json
1057 (vl_api_sw_interface_event_t * mp)
1059 /* JSON output not supported */
1063 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1065 vat_main_t *vam = &vat_main;
1066 i32 retval = ntohl (mp->retval);
1068 vam->retval = retval;
1069 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1070 vam->result_ready = 1;
1074 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1076 vat_main_t *vam = &vat_main;
1077 vat_json_node_t node;
1078 api_main_t *am = &api_main;
1082 vat_json_init_object (&node);
1083 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1084 vat_json_object_add_uint (&node, "reply_in_shmem",
1085 ntohl (mp->reply_in_shmem));
1086 /* Toss the shared-memory original... */
1087 pthread_mutex_lock (&am->vlib_rp->mutex);
1088 oldheap = svm_push_data_heap (am->vlib_rp);
1090 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1093 svm_pop_heap (oldheap);
1094 pthread_mutex_unlock (&am->vlib_rp->mutex);
1096 vat_json_print (vam->ofp, &node);
1097 vat_json_free (&node);
1099 vam->retval = ntohl (mp->retval);
1100 vam->result_ready = 1;
1104 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1106 vat_main_t *vam = &vat_main;
1107 i32 retval = ntohl (mp->retval);
1108 u32 length = ntohl (mp->length);
1110 vec_reset_length (vam->cmd_reply);
1112 vam->retval = retval;
1115 vec_validate (vam->cmd_reply, length);
1116 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1117 vam->cmd_reply[length] = 0;
1119 vam->result_ready = 1;
1123 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1125 vat_main_t *vam = &vat_main;
1126 vat_json_node_t node;
1128 vec_reset_length (vam->cmd_reply);
1130 vat_json_init_object (&node);
1131 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1132 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1134 vat_json_print (vam->ofp, &node);
1135 vat_json_free (&node);
1137 vam->retval = ntohl (mp->retval);
1138 vam->result_ready = 1;
1141 static void vl_api_classify_add_del_table_reply_t_handler
1142 (vl_api_classify_add_del_table_reply_t * mp)
1144 vat_main_t *vam = &vat_main;
1145 i32 retval = ntohl (mp->retval);
1146 if (vam->async_mode)
1148 vam->async_errors += (retval < 0);
1152 vam->retval = retval;
1154 ((mp->new_table_index != 0xFFFFFFFF) ||
1155 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1156 (mp->match_n_vectors != 0xFFFFFFFF)))
1158 * Note: this is just barely thread-safe, depends on
1159 * the main thread spinning waiting for an answer...
1161 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1162 ntohl (mp->new_table_index),
1163 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1164 vam->result_ready = 1;
1168 static void vl_api_classify_add_del_table_reply_t_handler_json
1169 (vl_api_classify_add_del_table_reply_t * mp)
1171 vat_main_t *vam = &vat_main;
1172 vat_json_node_t node;
1174 vat_json_init_object (&node);
1175 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1176 vat_json_object_add_uint (&node, "new_table_index",
1177 ntohl (mp->new_table_index));
1178 vat_json_object_add_uint (&node, "skip_n_vectors",
1179 ntohl (mp->skip_n_vectors));
1180 vat_json_object_add_uint (&node, "match_n_vectors",
1181 ntohl (mp->match_n_vectors));
1183 vat_json_print (vam->ofp, &node);
1184 vat_json_free (&node);
1186 vam->retval = ntohl (mp->retval);
1187 vam->result_ready = 1;
1190 static void vl_api_get_node_index_reply_t_handler
1191 (vl_api_get_node_index_reply_t * mp)
1193 vat_main_t *vam = &vat_main;
1194 i32 retval = ntohl (mp->retval);
1195 if (vam->async_mode)
1197 vam->async_errors += (retval < 0);
1201 vam->retval = retval;
1203 errmsg ("node index %d", ntohl (mp->node_index));
1204 vam->result_ready = 1;
1208 static void vl_api_get_node_index_reply_t_handler_json
1209 (vl_api_get_node_index_reply_t * mp)
1211 vat_main_t *vam = &vat_main;
1212 vat_json_node_t node;
1214 vat_json_init_object (&node);
1215 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1216 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1218 vat_json_print (vam->ofp, &node);
1219 vat_json_free (&node);
1221 vam->retval = ntohl (mp->retval);
1222 vam->result_ready = 1;
1225 static void vl_api_get_next_index_reply_t_handler
1226 (vl_api_get_next_index_reply_t * mp)
1228 vat_main_t *vam = &vat_main;
1229 i32 retval = ntohl (mp->retval);
1230 if (vam->async_mode)
1232 vam->async_errors += (retval < 0);
1236 vam->retval = retval;
1238 errmsg ("next node index %d", ntohl (mp->next_index));
1239 vam->result_ready = 1;
1243 static void vl_api_get_next_index_reply_t_handler_json
1244 (vl_api_get_next_index_reply_t * mp)
1246 vat_main_t *vam = &vat_main;
1247 vat_json_node_t node;
1249 vat_json_init_object (&node);
1250 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1251 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1253 vat_json_print (vam->ofp, &node);
1254 vat_json_free (&node);
1256 vam->retval = ntohl (mp->retval);
1257 vam->result_ready = 1;
1260 static void vl_api_add_node_next_reply_t_handler
1261 (vl_api_add_node_next_reply_t * mp)
1263 vat_main_t *vam = &vat_main;
1264 i32 retval = ntohl (mp->retval);
1265 if (vam->async_mode)
1267 vam->async_errors += (retval < 0);
1271 vam->retval = retval;
1273 errmsg ("next index %d", ntohl (mp->next_index));
1274 vam->result_ready = 1;
1278 static void vl_api_add_node_next_reply_t_handler_json
1279 (vl_api_add_node_next_reply_t * mp)
1281 vat_main_t *vam = &vat_main;
1282 vat_json_node_t node;
1284 vat_json_init_object (&node);
1285 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1286 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1288 vat_json_print (vam->ofp, &node);
1289 vat_json_free (&node);
1291 vam->retval = ntohl (mp->retval);
1292 vam->result_ready = 1;
1295 static void vl_api_show_version_reply_t_handler
1296 (vl_api_show_version_reply_t * mp)
1298 vat_main_t *vam = &vat_main;
1299 i32 retval = ntohl (mp->retval);
1303 errmsg (" program: %s", mp->program);
1304 errmsg (" version: %s", mp->version);
1305 errmsg (" build date: %s", mp->build_date);
1306 errmsg ("build directory: %s", mp->build_directory);
1308 vam->retval = retval;
1309 vam->result_ready = 1;
1312 static void vl_api_show_version_reply_t_handler_json
1313 (vl_api_show_version_reply_t * mp)
1315 vat_main_t *vam = &vat_main;
1316 vat_json_node_t node;
1318 vat_json_init_object (&node);
1319 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1320 vat_json_object_add_string_copy (&node, "program", mp->program);
1321 vat_json_object_add_string_copy (&node, "version", mp->version);
1322 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1323 vat_json_object_add_string_copy (&node, "build_directory",
1324 mp->build_directory);
1326 vat_json_print (vam->ofp, &node);
1327 vat_json_free (&node);
1329 vam->retval = ntohl (mp->retval);
1330 vam->result_ready = 1;
1333 static void vl_api_show_threads_reply_t_handler
1334 (vl_api_show_threads_reply_t * mp)
1336 vat_main_t *vam = &vat_main;
1337 i32 retval = ntohl (mp->retval);
1341 count = ntohl (mp->count);
1343 for (i = 0; i < count; i++)
1345 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1346 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1347 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1348 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1349 ntohl (mp->thread_data[i].cpu_socket));
1351 vam->retval = retval;
1352 vam->result_ready = 1;
1355 static void vl_api_show_threads_reply_t_handler_json
1356 (vl_api_show_threads_reply_t * mp)
1358 vat_main_t *vam = &vat_main;
1359 vat_json_node_t node;
1360 vl_api_thread_data_t *td;
1361 i32 retval = ntohl (mp->retval);
1365 count = ntohl (mp->count);
1367 vat_json_init_object (&node);
1368 vat_json_object_add_int (&node, "retval", retval);
1369 vat_json_object_add_uint (&node, "count", count);
1371 for (i = 0; i < count; i++)
1373 td = &mp->thread_data[i];
1374 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1375 vat_json_object_add_string_copy (&node, "name", td->name);
1376 vat_json_object_add_string_copy (&node, "type", td->type);
1377 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1378 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1379 vat_json_object_add_int (&node, "core", ntohl (td->id));
1380 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1383 vat_json_print (vam->ofp, &node);
1384 vat_json_free (&node);
1386 vam->retval = retval;
1387 vam->result_ready = 1;
1391 api_show_threads (vat_main_t * vam)
1393 vl_api_show_threads_t *mp;
1397 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1398 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1400 M (SHOW_THREADS, mp);
1408 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1410 u32 sw_if_index = ntohl (mp->sw_if_index);
1411 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1412 mp->mac_ip ? "mac/ip binding" : "address resolution",
1413 ntohl (mp->pid), format_ip4_address, &mp->address,
1414 format_ethernet_address, mp->new_mac, sw_if_index);
1418 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1420 /* JSON output not supported */
1424 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1426 u32 sw_if_index = ntohl (mp->sw_if_index);
1427 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1428 mp->mac_ip ? "mac/ip binding" : "address resolution",
1429 ntohl (mp->pid), format_ip6_address, mp->address,
1430 format_ethernet_address, mp->new_mac, sw_if_index);
1434 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1436 /* JSON output not supported */
1440 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1442 u32 n_macs = ntohl (mp->n_macs);
1443 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1444 ntohl (mp->pid), mp->client_index, n_macs);
1446 for (i = 0; i < n_macs; i++)
1448 vl_api_mac_entry_t *mac = &mp->mac[i];
1449 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1450 i + 1, ntohl (mac->sw_if_index),
1451 format_ethernet_address, mac->mac_addr, mac->action);
1458 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1460 /* JSON output not supported */
1463 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1464 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1467 * Special-case: build the bridge domain table, maintain
1468 * the next bd id vbl.
1470 static void vl_api_bridge_domain_details_t_handler
1471 (vl_api_bridge_domain_details_t * mp)
1473 vat_main_t *vam = &vat_main;
1474 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1477 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1478 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1480 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1481 ntohl (mp->bd_id), mp->learn, mp->forward,
1482 mp->flood, ntohl (mp->bvi_sw_if_index),
1483 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1487 vl_api_bridge_domain_sw_if_t *sw_ifs;
1488 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1491 sw_ifs = mp->sw_if_details;
1492 for (i = 0; i < n_sw_ifs; i++)
1498 sw_if_index = ntohl (sw_ifs->sw_if_index);
1501 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1503 if ((u32) p->value[0] == sw_if_index)
1505 sw_if_name = (u8 *)(p->key);
1510 print (vam->ofp, "%7d %3d %s", sw_if_index,
1511 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1512 "sw_if_index not found!");
1519 static void vl_api_bridge_domain_details_t_handler_json
1520 (vl_api_bridge_domain_details_t * mp)
1522 vat_main_t *vam = &vat_main;
1523 vat_json_node_t *node, *array = NULL;
1524 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1526 if (VAT_JSON_ARRAY != vam->json_tree.type)
1528 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1529 vat_json_init_array (&vam->json_tree);
1531 node = vat_json_array_add (&vam->json_tree);
1533 vat_json_init_object (node);
1534 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1535 vat_json_object_add_uint (node, "flood", mp->flood);
1536 vat_json_object_add_uint (node, "forward", mp->forward);
1537 vat_json_object_add_uint (node, "learn", mp->learn);
1538 vat_json_object_add_uint (node, "bvi_sw_if_index",
1539 ntohl (mp->bvi_sw_if_index));
1540 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1541 array = vat_json_object_add (node, "sw_if");
1542 vat_json_init_array (array);
1548 vl_api_bridge_domain_sw_if_t *sw_ifs;
1551 sw_ifs = mp->sw_if_details;
1552 for (i = 0; i < n_sw_ifs; i++)
1554 node = vat_json_array_add (array);
1555 vat_json_init_object (node);
1556 vat_json_object_add_uint (node, "sw_if_index",
1557 ntohl (sw_ifs->sw_if_index));
1558 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1564 static void vl_api_control_ping_reply_t_handler
1565 (vl_api_control_ping_reply_t * mp)
1567 vat_main_t *vam = &vat_main;
1568 i32 retval = ntohl (mp->retval);
1569 if (vam->async_mode)
1571 vam->async_errors += (retval < 0);
1575 vam->retval = retval;
1576 vam->result_ready = 1;
1578 if (vam->socket_client_main)
1579 vam->socket_client_main->control_pings_outstanding--;
1582 static void vl_api_control_ping_reply_t_handler_json
1583 (vl_api_control_ping_reply_t * mp)
1585 vat_main_t *vam = &vat_main;
1586 i32 retval = ntohl (mp->retval);
1588 if (VAT_JSON_NONE != vam->json_tree.type)
1590 vat_json_print (vam->ofp, &vam->json_tree);
1591 vat_json_free (&vam->json_tree);
1592 vam->json_tree.type = VAT_JSON_NONE;
1597 vat_json_init_array (&vam->json_tree);
1598 vat_json_print (vam->ofp, &vam->json_tree);
1599 vam->json_tree.type = VAT_JSON_NONE;
1602 vam->retval = retval;
1603 vam->result_ready = 1;
1607 vl_api_bridge_domain_set_mac_age_reply_t_handler
1608 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1610 vat_main_t *vam = &vat_main;
1611 i32 retval = ntohl (mp->retval);
1612 if (vam->async_mode)
1614 vam->async_errors += (retval < 0);
1618 vam->retval = retval;
1619 vam->result_ready = 1;
1623 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1624 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1626 vat_main_t *vam = &vat_main;
1627 vat_json_node_t node;
1629 vat_json_init_object (&node);
1630 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1632 vat_json_print (vam->ofp, &node);
1633 vat_json_free (&node);
1635 vam->retval = ntohl (mp->retval);
1636 vam->result_ready = 1;
1640 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1642 vat_main_t *vam = &vat_main;
1643 i32 retval = ntohl (mp->retval);
1644 if (vam->async_mode)
1646 vam->async_errors += (retval < 0);
1650 vam->retval = retval;
1651 vam->result_ready = 1;
1655 static void vl_api_l2_flags_reply_t_handler_json
1656 (vl_api_l2_flags_reply_t * mp)
1658 vat_main_t *vam = &vat_main;
1659 vat_json_node_t node;
1661 vat_json_init_object (&node);
1662 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1663 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1664 ntohl (mp->resulting_feature_bitmap));
1666 vat_json_print (vam->ofp, &node);
1667 vat_json_free (&node);
1669 vam->retval = ntohl (mp->retval);
1670 vam->result_ready = 1;
1673 static void vl_api_bridge_flags_reply_t_handler
1674 (vl_api_bridge_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_bridge_flags_reply_t_handler_json
1690 (vl_api_bridge_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_tap_connect_reply_t_handler
1708 (vl_api_tap_connect_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->sw_if_index = ntohl (mp->sw_if_index);
1720 vam->result_ready = 1;
1725 static void vl_api_tap_connect_reply_t_handler_json
1726 (vl_api_tap_connect_reply_t * mp)
1728 vat_main_t *vam = &vat_main;
1729 vat_json_node_t node;
1731 vat_json_init_object (&node);
1732 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1733 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1735 vat_json_print (vam->ofp, &node);
1736 vat_json_free (&node);
1738 vam->retval = ntohl (mp->retval);
1739 vam->result_ready = 1;
1744 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1746 vat_main_t *vam = &vat_main;
1747 i32 retval = ntohl (mp->retval);
1748 if (vam->async_mode)
1750 vam->async_errors += (retval < 0);
1754 vam->retval = retval;
1755 vam->sw_if_index = ntohl (mp->sw_if_index);
1756 vam->result_ready = 1;
1760 static void vl_api_tap_modify_reply_t_handler_json
1761 (vl_api_tap_modify_reply_t * mp)
1763 vat_main_t *vam = &vat_main;
1764 vat_json_node_t node;
1766 vat_json_init_object (&node);
1767 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1768 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1770 vat_json_print (vam->ofp, &node);
1771 vat_json_free (&node);
1773 vam->retval = ntohl (mp->retval);
1774 vam->result_ready = 1;
1778 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_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_reply_t_handler_json
1794 (vl_api_tap_delete_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_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1812 vat_main_t *vam = &vat_main;
1813 i32 retval = ntohl (mp->retval);
1814 if (vam->async_mode)
1816 vam->async_errors += (retval < 0);
1820 vam->retval = retval;
1821 vam->sw_if_index = ntohl (mp->sw_if_index);
1822 vam->result_ready = 1;
1827 static void vl_api_tap_create_v2_reply_t_handler_json
1828 (vl_api_tap_create_v2_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_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1848 vat_main_t *vam = &vat_main;
1849 i32 retval = ntohl (mp->retval);
1850 if (vam->async_mode)
1852 vam->async_errors += (retval < 0);
1856 vam->retval = retval;
1857 vam->result_ready = 1;
1861 static void vl_api_tap_delete_v2_reply_t_handler_json
1862 (vl_api_tap_delete_v2_reply_t * mp)
1864 vat_main_t *vam = &vat_main;
1865 vat_json_node_t node;
1867 vat_json_init_object (&node);
1868 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1870 vat_json_print (vam->ofp, &node);
1871 vat_json_free (&node);
1873 vam->retval = ntohl (mp->retval);
1874 vam->result_ready = 1;
1878 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1880 vat_main_t *vam = &vat_main;
1881 i32 retval = ntohl (mp->retval);
1883 if (vam->async_mode)
1885 vam->async_errors += (retval < 0);
1889 vam->retval = retval;
1890 vam->sw_if_index = ntohl (mp->sw_if_index);
1891 vam->result_ready = 1;
1895 static void vl_api_bond_create_reply_t_handler_json
1896 (vl_api_bond_create_reply_t * mp)
1898 vat_main_t *vam = &vat_main;
1899 vat_json_node_t node;
1901 vat_json_init_object (&node);
1902 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1903 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1905 vat_json_print (vam->ofp, &node);
1906 vat_json_free (&node);
1908 vam->retval = ntohl (mp->retval);
1909 vam->result_ready = 1;
1913 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1915 vat_main_t *vam = &vat_main;
1916 i32 retval = ntohl (mp->retval);
1918 if (vam->async_mode)
1920 vam->async_errors += (retval < 0);
1924 vam->retval = retval;
1925 vam->result_ready = 1;
1929 static void vl_api_bond_delete_reply_t_handler_json
1930 (vl_api_bond_delete_reply_t * mp)
1932 vat_main_t *vam = &vat_main;
1933 vat_json_node_t node;
1935 vat_json_init_object (&node);
1936 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1938 vat_json_print (vam->ofp, &node);
1939 vat_json_free (&node);
1941 vam->retval = ntohl (mp->retval);
1942 vam->result_ready = 1;
1946 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1948 vat_main_t *vam = &vat_main;
1949 i32 retval = ntohl (mp->retval);
1951 if (vam->async_mode)
1953 vam->async_errors += (retval < 0);
1957 vam->retval = retval;
1958 vam->result_ready = 1;
1962 static void vl_api_bond_enslave_reply_t_handler_json
1963 (vl_api_bond_enslave_reply_t * mp)
1965 vat_main_t *vam = &vat_main;
1966 vat_json_node_t node;
1968 vat_json_init_object (&node);
1969 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1971 vat_json_print (vam->ofp, &node);
1972 vat_json_free (&node);
1974 vam->retval = ntohl (mp->retval);
1975 vam->result_ready = 1;
1979 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1982 vat_main_t *vam = &vat_main;
1983 i32 retval = ntohl (mp->retval);
1985 if (vam->async_mode)
1987 vam->async_errors += (retval < 0);
1991 vam->retval = retval;
1992 vam->result_ready = 1;
1996 static void vl_api_bond_detach_slave_reply_t_handler_json
1997 (vl_api_bond_detach_slave_reply_t * mp)
1999 vat_main_t *vam = &vat_main;
2000 vat_json_node_t node;
2002 vat_json_init_object (&node);
2003 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2005 vat_json_print (vam->ofp, &node);
2006 vat_json_free (&node);
2008 vam->retval = ntohl (mp->retval);
2009 vam->result_ready = 1;
2012 static void vl_api_sw_interface_bond_details_t_handler
2013 (vl_api_sw_interface_bond_details_t * mp)
2015 vat_main_t *vam = &vat_main;
2018 "%-16s %-12d %-12U %-13U %-14u %-14u",
2019 mp->interface_name, ntohl (mp->sw_if_index),
2020 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2021 ntohl (mp->active_slaves), ntohl (mp->slaves));
2024 static void vl_api_sw_interface_bond_details_t_handler_json
2025 (vl_api_sw_interface_bond_details_t * mp)
2027 vat_main_t *vam = &vat_main;
2028 vat_json_node_t *node = NULL;
2030 if (VAT_JSON_ARRAY != vam->json_tree.type)
2032 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2033 vat_json_init_array (&vam->json_tree);
2035 node = vat_json_array_add (&vam->json_tree);
2037 vat_json_init_object (node);
2038 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2039 vat_json_object_add_string_copy (node, "interface_name",
2040 mp->interface_name);
2041 vat_json_object_add_uint (node, "mode", mp->mode);
2042 vat_json_object_add_uint (node, "load_balance", mp->lb);
2043 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2044 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2048 api_sw_interface_bond_dump (vat_main_t * vam)
2050 vl_api_sw_interface_bond_dump_t *mp;
2051 vl_api_control_ping_t *mp_ping;
2055 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2056 "interface name", "sw_if_index", "mode", "load balance",
2057 "active slaves", "slaves");
2059 /* Get list of bond interfaces */
2060 M (SW_INTERFACE_BOND_DUMP, mp);
2063 /* Use a control ping for synchronization */
2064 MPING (CONTROL_PING, mp_ping);
2071 static void vl_api_sw_interface_slave_details_t_handler
2072 (vl_api_sw_interface_slave_details_t * mp)
2074 vat_main_t *vam = &vat_main;
2077 "%-25s %-12d %-12d %d", mp->interface_name,
2078 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2081 static void vl_api_sw_interface_slave_details_t_handler_json
2082 (vl_api_sw_interface_slave_details_t * mp)
2084 vat_main_t *vam = &vat_main;
2085 vat_json_node_t *node = NULL;
2087 if (VAT_JSON_ARRAY != vam->json_tree.type)
2089 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2090 vat_json_init_array (&vam->json_tree);
2092 node = vat_json_array_add (&vam->json_tree);
2094 vat_json_init_object (node);
2095 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2096 vat_json_object_add_string_copy (node, "interface_name",
2097 mp->interface_name);
2098 vat_json_object_add_uint (node, "passive", mp->is_passive);
2099 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2103 api_sw_interface_slave_dump (vat_main_t * vam)
2105 unformat_input_t *i = vam->input;
2106 vl_api_sw_interface_slave_dump_t *mp;
2107 vl_api_control_ping_t *mp_ping;
2108 u32 sw_if_index = ~0;
2109 u8 sw_if_index_set = 0;
2112 /* Parse args required to build the message */
2113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2115 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2116 sw_if_index_set = 1;
2117 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2118 sw_if_index_set = 1;
2123 if (sw_if_index_set == 0)
2125 errmsg ("missing vpp interface name. ");
2130 "\n%-25s %-12s %-12s %s",
2131 "slave interface name", "sw_if_index", "passive", "long_timeout");
2133 /* Get list of bond interfaces */
2134 M (SW_INTERFACE_SLAVE_DUMP, mp);
2135 mp->sw_if_index = ntohl (sw_if_index);
2138 /* Use a control ping for synchronization */
2139 MPING (CONTROL_PING, mp_ping);
2146 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2147 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2149 vat_main_t *vam = &vat_main;
2150 i32 retval = ntohl (mp->retval);
2151 if (vam->async_mode)
2153 vam->async_errors += (retval < 0);
2157 vam->retval = retval;
2158 vam->sw_if_index = ntohl (mp->sw_if_index);
2159 vam->result_ready = 1;
2161 vam->regenerate_interface_table = 1;
2164 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2165 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2167 vat_main_t *vam = &vat_main;
2168 vat_json_node_t node;
2170 vat_json_init_object (&node);
2171 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2172 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2173 ntohl (mp->sw_if_index));
2175 vat_json_print (vam->ofp, &node);
2176 vat_json_free (&node);
2178 vam->retval = ntohl (mp->retval);
2179 vam->result_ready = 1;
2182 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2183 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2185 vat_main_t *vam = &vat_main;
2186 i32 retval = ntohl (mp->retval);
2187 if (vam->async_mode)
2189 vam->async_errors += (retval < 0);
2193 vam->retval = retval;
2194 vam->sw_if_index = ntohl (mp->sw_if_index);
2195 vam->result_ready = 1;
2199 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2200 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2202 vat_main_t *vam = &vat_main;
2203 vat_json_node_t node;
2205 vat_json_init_object (&node);
2206 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2207 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2209 vat_json_print (vam->ofp, &node);
2210 vat_json_free (&node);
2212 vam->retval = ntohl (mp->retval);
2213 vam->result_ready = 1;
2216 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2217 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2219 vat_main_t *vam = &vat_main;
2220 i32 retval = ntohl (mp->retval);
2221 if (vam->async_mode)
2223 vam->async_errors += (retval < 0);
2227 vam->retval = retval;
2228 vam->result_ready = 1;
2232 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2233 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2235 vat_main_t *vam = &vat_main;
2236 vat_json_node_t node;
2238 vat_json_init_object (&node);
2239 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2240 vat_json_object_add_uint (&node, "fwd_entry_index",
2241 clib_net_to_host_u32 (mp->fwd_entry_index));
2243 vat_json_print (vam->ofp, &node);
2244 vat_json_free (&node);
2246 vam->retval = ntohl (mp->retval);
2247 vam->result_ready = 1;
2251 format_lisp_transport_protocol (u8 * s, va_list * args)
2253 u32 proto = va_arg (*args, u32);
2258 return format (s, "udp");
2260 return format (s, "api");
2267 static void vl_api_one_get_transport_protocol_reply_t_handler
2268 (vl_api_one_get_transport_protocol_reply_t * mp)
2270 vat_main_t *vam = &vat_main;
2271 i32 retval = ntohl (mp->retval);
2272 if (vam->async_mode)
2274 vam->async_errors += (retval < 0);
2278 u32 proto = mp->protocol;
2279 print (vam->ofp, "Transport protocol: %U",
2280 format_lisp_transport_protocol, proto);
2281 vam->retval = retval;
2282 vam->result_ready = 1;
2286 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2287 (vl_api_one_get_transport_protocol_reply_t * mp)
2289 vat_main_t *vam = &vat_main;
2290 vat_json_node_t node;
2293 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2296 vat_json_init_object (&node);
2297 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2298 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2301 vat_json_print (vam->ofp, &node);
2302 vat_json_free (&node);
2304 vam->retval = ntohl (mp->retval);
2305 vam->result_ready = 1;
2308 static void vl_api_one_add_del_locator_set_reply_t_handler
2309 (vl_api_one_add_del_locator_set_reply_t * mp)
2311 vat_main_t *vam = &vat_main;
2312 i32 retval = ntohl (mp->retval);
2313 if (vam->async_mode)
2315 vam->async_errors += (retval < 0);
2319 vam->retval = retval;
2320 vam->result_ready = 1;
2324 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2325 (vl_api_one_add_del_locator_set_reply_t * mp)
2327 vat_main_t *vam = &vat_main;
2328 vat_json_node_t node;
2330 vat_json_init_object (&node);
2331 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2332 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2334 vat_json_print (vam->ofp, &node);
2335 vat_json_free (&node);
2337 vam->retval = ntohl (mp->retval);
2338 vam->result_ready = 1;
2341 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2342 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2344 vat_main_t *vam = &vat_main;
2345 i32 retval = ntohl (mp->retval);
2346 if (vam->async_mode)
2348 vam->async_errors += (retval < 0);
2352 vam->retval = retval;
2353 vam->sw_if_index = ntohl (mp->sw_if_index);
2354 vam->result_ready = 1;
2356 vam->regenerate_interface_table = 1;
2359 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2360 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2362 vat_main_t *vam = &vat_main;
2363 vat_json_node_t node;
2365 vat_json_init_object (&node);
2366 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2367 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2369 vat_json_print (vam->ofp, &node);
2370 vat_json_free (&node);
2372 vam->retval = ntohl (mp->retval);
2373 vam->result_ready = 1;
2376 static void vl_api_vxlan_offload_rx_reply_t_handler
2377 (vl_api_vxlan_offload_rx_reply_t * mp)
2379 vat_main_t *vam = &vat_main;
2380 i32 retval = ntohl (mp->retval);
2381 if (vam->async_mode)
2383 vam->async_errors += (retval < 0);
2387 vam->retval = retval;
2388 vam->result_ready = 1;
2392 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2393 (vl_api_vxlan_offload_rx_reply_t * mp)
2395 vat_main_t *vam = &vat_main;
2396 vat_json_node_t node;
2398 vat_json_init_object (&node);
2399 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2401 vat_json_print (vam->ofp, &node);
2402 vat_json_free (&node);
2404 vam->retval = ntohl (mp->retval);
2405 vam->result_ready = 1;
2408 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2409 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2411 vat_main_t *vam = &vat_main;
2412 i32 retval = ntohl (mp->retval);
2413 if (vam->async_mode)
2415 vam->async_errors += (retval < 0);
2419 vam->retval = retval;
2420 vam->sw_if_index = ntohl (mp->sw_if_index);
2421 vam->result_ready = 1;
2425 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2426 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2428 vat_main_t *vam = &vat_main;
2429 vat_json_node_t node;
2431 vat_json_init_object (&node);
2432 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2433 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2435 vat_json_print (vam->ofp, &node);
2436 vat_json_free (&node);
2438 vam->retval = ntohl (mp->retval);
2439 vam->result_ready = 1;
2442 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2443 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2445 vat_main_t *vam = &vat_main;
2446 i32 retval = ntohl (mp->retval);
2447 if (vam->async_mode)
2449 vam->async_errors += (retval < 0);
2453 vam->retval = retval;
2454 vam->sw_if_index = ntohl (mp->sw_if_index);
2455 vam->result_ready = 1;
2457 vam->regenerate_interface_table = 1;
2460 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2461 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2463 vat_main_t *vam = &vat_main;
2464 vat_json_node_t node;
2466 vat_json_init_object (&node);
2467 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2468 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2470 vat_json_print (vam->ofp, &node);
2471 vat_json_free (&node);
2473 vam->retval = ntohl (mp->retval);
2474 vam->result_ready = 1;
2477 static void vl_api_gre_add_del_tunnel_reply_t_handler
2478 (vl_api_gre_add_del_tunnel_reply_t * mp)
2480 vat_main_t *vam = &vat_main;
2481 i32 retval = ntohl (mp->retval);
2482 if (vam->async_mode)
2484 vam->async_errors += (retval < 0);
2488 vam->retval = retval;
2489 vam->sw_if_index = ntohl (mp->sw_if_index);
2490 vam->result_ready = 1;
2494 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2495 (vl_api_gre_add_del_tunnel_reply_t * mp)
2497 vat_main_t *vam = &vat_main;
2498 vat_json_node_t node;
2500 vat_json_init_object (&node);
2501 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2502 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2504 vat_json_print (vam->ofp, &node);
2505 vat_json_free (&node);
2507 vam->retval = ntohl (mp->retval);
2508 vam->result_ready = 1;
2511 static void vl_api_create_vhost_user_if_reply_t_handler
2512 (vl_api_create_vhost_user_if_reply_t * mp)
2514 vat_main_t *vam = &vat_main;
2515 i32 retval = ntohl (mp->retval);
2516 if (vam->async_mode)
2518 vam->async_errors += (retval < 0);
2522 vam->retval = retval;
2523 vam->sw_if_index = ntohl (mp->sw_if_index);
2524 vam->result_ready = 1;
2526 vam->regenerate_interface_table = 1;
2529 static void vl_api_create_vhost_user_if_reply_t_handler_json
2530 (vl_api_create_vhost_user_if_reply_t * mp)
2532 vat_main_t *vam = &vat_main;
2533 vat_json_node_t node;
2535 vat_json_init_object (&node);
2536 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2537 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2539 vat_json_print (vam->ofp, &node);
2540 vat_json_free (&node);
2542 vam->retval = ntohl (mp->retval);
2543 vam->result_ready = 1;
2546 static void vl_api_dns_resolve_name_reply_t_handler
2547 (vl_api_dns_resolve_name_reply_t * mp)
2549 vat_main_t *vam = &vat_main;
2550 i32 retval = ntohl (mp->retval);
2551 if (vam->async_mode)
2553 vam->async_errors += (retval < 0);
2557 vam->retval = retval;
2558 vam->result_ready = 1;
2563 clib_warning ("ip4 address %U", format_ip4_address,
2564 (ip4_address_t *) mp->ip4_address);
2566 clib_warning ("ip6 address %U", format_ip6_address,
2567 (ip6_address_t *) mp->ip6_address);
2570 clib_warning ("retval %d", retval);
2574 static void vl_api_dns_resolve_name_reply_t_handler_json
2575 (vl_api_dns_resolve_name_reply_t * mp)
2577 clib_warning ("not implemented");
2580 static void vl_api_dns_resolve_ip_reply_t_handler
2581 (vl_api_dns_resolve_ip_reply_t * mp)
2583 vat_main_t *vam = &vat_main;
2584 i32 retval = ntohl (mp->retval);
2585 if (vam->async_mode)
2587 vam->async_errors += (retval < 0);
2591 vam->retval = retval;
2592 vam->result_ready = 1;
2596 clib_warning ("canonical name %s", mp->name);
2599 clib_warning ("retval %d", retval);
2603 static void vl_api_dns_resolve_ip_reply_t_handler_json
2604 (vl_api_dns_resolve_ip_reply_t * mp)
2606 clib_warning ("not implemented");
2610 static void vl_api_ip_address_details_t_handler
2611 (vl_api_ip_address_details_t * mp)
2613 vat_main_t *vam = &vat_main;
2614 static ip_address_details_t empty_ip_address_details = { {0} };
2615 ip_address_details_t *address = NULL;
2616 ip_details_t *current_ip_details = NULL;
2617 ip_details_t *details = NULL;
2619 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2621 if (!details || vam->current_sw_if_index >= vec_len (details)
2622 || !details[vam->current_sw_if_index].present)
2624 errmsg ("ip address details arrived but not stored");
2625 errmsg ("ip_dump should be called first");
2629 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2631 #define addresses (current_ip_details->addr)
2633 vec_validate_init_empty (addresses, vec_len (addresses),
2634 empty_ip_address_details);
2636 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2638 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2639 address->prefix_length = mp->prefix_length;
2643 static void vl_api_ip_address_details_t_handler_json
2644 (vl_api_ip_address_details_t * mp)
2646 vat_main_t *vam = &vat_main;
2647 vat_json_node_t *node = NULL;
2648 struct in6_addr ip6;
2651 if (VAT_JSON_ARRAY != vam->json_tree.type)
2653 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2654 vat_json_init_array (&vam->json_tree);
2656 node = vat_json_array_add (&vam->json_tree);
2658 vat_json_init_object (node);
2661 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2662 vat_json_object_add_ip6 (node, "ip", ip6);
2666 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2667 vat_json_object_add_ip4 (node, "ip", ip4);
2669 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2673 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2675 vat_main_t *vam = &vat_main;
2676 static ip_details_t empty_ip_details = { 0 };
2677 ip_details_t *ip = NULL;
2678 u32 sw_if_index = ~0;
2680 sw_if_index = ntohl (mp->sw_if_index);
2682 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2683 sw_if_index, empty_ip_details);
2685 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2692 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2694 vat_main_t *vam = &vat_main;
2696 if (VAT_JSON_ARRAY != vam->json_tree.type)
2698 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2699 vat_json_init_array (&vam->json_tree);
2701 vat_json_array_add_uint (&vam->json_tree,
2702 clib_net_to_host_u32 (mp->sw_if_index));
2706 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2708 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2709 "router_addr %U host_mac %U",
2710 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2712 format_ip4_address, &mp->lease.host_address,
2713 format_ip4_address, &mp->lease.router_address,
2714 format_ethernet_address, mp->lease.host_mac);
2717 static void vl_api_dhcp_compl_event_t_handler_json
2718 (vl_api_dhcp_compl_event_t * mp)
2720 /* JSON output not supported */
2724 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2727 vat_main_t *vam = &vat_main;
2728 static u64 default_counter = 0;
2730 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2732 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2733 sw_if_index, default_counter);
2734 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2738 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2739 interface_counter_t counter)
2741 vat_main_t *vam = &vat_main;
2742 static interface_counter_t default_counter = { 0, };
2744 vec_validate_init_empty (vam->combined_interface_counters,
2745 vnet_counter_type, NULL);
2746 vec_validate_init_empty (vam->combined_interface_counters
2747 [vnet_counter_type], sw_if_index, default_counter);
2748 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2751 static void vl_api_vnet_interface_simple_counters_t_handler
2752 (vl_api_vnet_interface_simple_counters_t * mp)
2757 static void vl_api_vnet_interface_combined_counters_t_handler
2758 (vl_api_vnet_interface_combined_counters_t * mp)
2763 static void vl_api_vnet_interface_simple_counters_t_handler_json
2764 (vl_api_vnet_interface_simple_counters_t * mp)
2769 u32 first_sw_if_index;
2772 count = ntohl (mp->count);
2773 first_sw_if_index = ntohl (mp->first_sw_if_index);
2775 v_packets = (u64 *) & mp->data;
2776 for (i = 0; i < count; i++)
2778 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2779 set_simple_interface_counter (mp->vnet_counter_type,
2780 first_sw_if_index + i, packets);
2785 static void vl_api_vnet_interface_combined_counters_t_handler_json
2786 (vl_api_vnet_interface_combined_counters_t * mp)
2788 interface_counter_t counter;
2790 u32 first_sw_if_index;
2794 count = ntohl (mp->count);
2795 first_sw_if_index = ntohl (mp->first_sw_if_index);
2797 v = (vlib_counter_t *) & mp->data;
2798 for (i = 0; i < count; i++)
2801 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2803 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2804 set_combined_interface_counter (mp->vnet_counter_type,
2805 first_sw_if_index + i, counter);
2811 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2813 vat_main_t *vam = &vat_main;
2816 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2818 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2827 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2829 vat_main_t *vam = &vat_main;
2832 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2834 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2842 static void vl_api_vnet_ip4_fib_counters_t_handler
2843 (vl_api_vnet_ip4_fib_counters_t * mp)
2848 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2849 (vl_api_vnet_ip4_fib_counters_t * mp)
2851 vat_main_t *vam = &vat_main;
2852 vl_api_ip4_fib_counter_t *v;
2853 ip4_fib_counter_t *counter;
2860 vrf_id = ntohl (mp->vrf_id);
2861 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2862 if (~0 == vrf_index)
2864 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2865 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2866 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2867 vec_validate (vam->ip4_fib_counters, vrf_index);
2868 vam->ip4_fib_counters[vrf_index] = NULL;
2871 vec_free (vam->ip4_fib_counters[vrf_index]);
2872 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2873 count = ntohl (mp->count);
2874 for (i = 0; i < count; i++)
2876 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2877 counter = &vam->ip4_fib_counters[vrf_index][i];
2878 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2879 counter->address = ip4;
2880 counter->address_length = v->address_length;
2881 counter->packets = clib_net_to_host_u64 (v->packets);
2882 counter->bytes = clib_net_to_host_u64 (v->bytes);
2887 static void vl_api_vnet_ip4_nbr_counters_t_handler
2888 (vl_api_vnet_ip4_nbr_counters_t * mp)
2893 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2894 (vl_api_vnet_ip4_nbr_counters_t * mp)
2896 vat_main_t *vam = &vat_main;
2897 vl_api_ip4_nbr_counter_t *v;
2898 ip4_nbr_counter_t *counter;
2903 sw_if_index = ntohl (mp->sw_if_index);
2904 count = ntohl (mp->count);
2905 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2908 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2910 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2911 for (i = 0; i < count; i++)
2913 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2914 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2915 counter->address.s_addr = v->address;
2916 counter->packets = clib_net_to_host_u64 (v->packets);
2917 counter->bytes = clib_net_to_host_u64 (v->bytes);
2918 counter->linkt = v->link_type;
2923 static void vl_api_vnet_ip6_fib_counters_t_handler
2924 (vl_api_vnet_ip6_fib_counters_t * mp)
2929 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2930 (vl_api_vnet_ip6_fib_counters_t * mp)
2932 vat_main_t *vam = &vat_main;
2933 vl_api_ip6_fib_counter_t *v;
2934 ip6_fib_counter_t *counter;
2935 struct in6_addr ip6;
2941 vrf_id = ntohl (mp->vrf_id);
2942 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2943 if (~0 == vrf_index)
2945 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2946 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2947 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2948 vec_validate (vam->ip6_fib_counters, vrf_index);
2949 vam->ip6_fib_counters[vrf_index] = NULL;
2952 vec_free (vam->ip6_fib_counters[vrf_index]);
2953 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2954 count = ntohl (mp->count);
2955 for (i = 0; i < count; i++)
2957 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2958 counter = &vam->ip6_fib_counters[vrf_index][i];
2959 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2960 counter->address = ip6;
2961 counter->address_length = v->address_length;
2962 counter->packets = clib_net_to_host_u64 (v->packets);
2963 counter->bytes = clib_net_to_host_u64 (v->bytes);
2968 static void vl_api_vnet_ip6_nbr_counters_t_handler
2969 (vl_api_vnet_ip6_nbr_counters_t * mp)
2974 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2975 (vl_api_vnet_ip6_nbr_counters_t * mp)
2977 vat_main_t *vam = &vat_main;
2978 vl_api_ip6_nbr_counter_t *v;
2979 ip6_nbr_counter_t *counter;
2980 struct in6_addr ip6;
2985 sw_if_index = ntohl (mp->sw_if_index);
2986 count = ntohl (mp->count);
2987 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2990 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2992 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2993 for (i = 0; i < count; i++)
2995 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2996 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2997 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2998 counter->address = ip6;
2999 counter->packets = clib_net_to_host_u64 (v->packets);
3000 counter->bytes = clib_net_to_host_u64 (v->bytes);
3005 static void vl_api_get_first_msg_id_reply_t_handler
3006 (vl_api_get_first_msg_id_reply_t * mp)
3008 vat_main_t *vam = &vat_main;
3009 i32 retval = ntohl (mp->retval);
3011 if (vam->async_mode)
3013 vam->async_errors += (retval < 0);
3017 vam->retval = retval;
3018 vam->result_ready = 1;
3022 errmsg ("first message id %d", ntohs (mp->first_msg_id));
3026 static void vl_api_get_first_msg_id_reply_t_handler_json
3027 (vl_api_get_first_msg_id_reply_t * mp)
3029 vat_main_t *vam = &vat_main;
3030 vat_json_node_t node;
3032 vat_json_init_object (&node);
3033 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3034 vat_json_object_add_uint (&node, "first_msg_id",
3035 (uint) ntohs (mp->first_msg_id));
3037 vat_json_print (vam->ofp, &node);
3038 vat_json_free (&node);
3040 vam->retval = ntohl (mp->retval);
3041 vam->result_ready = 1;
3044 static void vl_api_get_node_graph_reply_t_handler
3045 (vl_api_get_node_graph_reply_t * mp)
3047 vat_main_t *vam = &vat_main;
3048 api_main_t *am = &api_main;
3049 i32 retval = ntohl (mp->retval);
3050 u8 *pvt_copy, *reply;
3055 if (vam->async_mode)
3057 vam->async_errors += (retval < 0);
3061 vam->retval = retval;
3062 vam->result_ready = 1;
3065 /* "Should never happen..." */
3069 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3070 pvt_copy = vec_dup (reply);
3072 /* Toss the shared-memory original... */
3073 pthread_mutex_lock (&am->vlib_rp->mutex);
3074 oldheap = svm_push_data_heap (am->vlib_rp);
3078 svm_pop_heap (oldheap);
3079 pthread_mutex_unlock (&am->vlib_rp->mutex);
3081 if (vam->graph_nodes)
3083 hash_free (vam->graph_node_index_by_name);
3085 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3087 node = vam->graph_nodes[0][i];
3088 vec_free (node->name);
3089 vec_free (node->next_nodes);
3092 vec_free (vam->graph_nodes[0]);
3093 vec_free (vam->graph_nodes);
3096 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3097 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3098 vec_free (pvt_copy);
3100 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3102 node = vam->graph_nodes[0][i];
3103 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3107 static void vl_api_get_node_graph_reply_t_handler_json
3108 (vl_api_get_node_graph_reply_t * mp)
3110 vat_main_t *vam = &vat_main;
3111 api_main_t *am = &api_main;
3113 vat_json_node_t node;
3116 /* $$$$ make this real? */
3117 vat_json_init_object (&node);
3118 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3119 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3121 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3123 /* Toss the shared-memory original... */
3124 pthread_mutex_lock (&am->vlib_rp->mutex);
3125 oldheap = svm_push_data_heap (am->vlib_rp);
3129 svm_pop_heap (oldheap);
3130 pthread_mutex_unlock (&am->vlib_rp->mutex);
3132 vat_json_print (vam->ofp, &node);
3133 vat_json_free (&node);
3135 vam->retval = ntohl (mp->retval);
3136 vam->result_ready = 1;
3140 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3142 vat_main_t *vam = &vat_main;
3147 s = format (s, "%=16d%=16d%=16d",
3148 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3152 s = format (s, "%=16U%=16d%=16d",
3153 mp->is_ipv6 ? format_ip6_address :
3155 mp->ip_address, mp->priority, mp->weight);
3158 print (vam->ofp, "%v", s);
3163 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3165 vat_main_t *vam = &vat_main;
3166 vat_json_node_t *node = NULL;
3167 struct in6_addr ip6;
3170 if (VAT_JSON_ARRAY != vam->json_tree.type)
3172 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3173 vat_json_init_array (&vam->json_tree);
3175 node = vat_json_array_add (&vam->json_tree);
3176 vat_json_init_object (node);
3178 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3179 vat_json_object_add_uint (node, "priority", mp->priority);
3180 vat_json_object_add_uint (node, "weight", mp->weight);
3183 vat_json_object_add_uint (node, "sw_if_index",
3184 clib_net_to_host_u32 (mp->sw_if_index));
3189 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3190 vat_json_object_add_ip6 (node, "address", ip6);
3194 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3195 vat_json_object_add_ip4 (node, "address", ip4);
3201 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3204 vat_main_t *vam = &vat_main;
3207 ls_name = format (0, "%s", mp->ls_name);
3209 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3215 vl_api_one_locator_set_details_t_handler_json
3216 (vl_api_one_locator_set_details_t * mp)
3218 vat_main_t *vam = &vat_main;
3219 vat_json_node_t *node = 0;
3222 ls_name = format (0, "%s", mp->ls_name);
3223 vec_add1 (ls_name, 0);
3225 if (VAT_JSON_ARRAY != vam->json_tree.type)
3227 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3228 vat_json_init_array (&vam->json_tree);
3230 node = vat_json_array_add (&vam->json_tree);
3232 vat_json_init_object (node);
3233 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3234 vat_json_object_add_uint (node, "ls_index",
3235 clib_net_to_host_u32 (mp->ls_index));
3243 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3246 unformat_nsh_address (unformat_input_t * input, va_list * args)
3248 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3249 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3253 format_nsh_address_vat (u8 * s, va_list * args)
3255 nsh_t *a = va_arg (*args, nsh_t *);
3256 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3260 format_lisp_flat_eid (u8 * s, va_list * args)
3262 u32 type = va_arg (*args, u32);
3263 u8 *eid = va_arg (*args, u8 *);
3264 u32 eid_len = va_arg (*args, u32);
3269 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3271 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3273 return format (s, "%U", format_ethernet_address, eid);
3275 return format (s, "%U", format_nsh_address_vat, eid);
3281 format_lisp_eid_vat (u8 * s, va_list * args)
3283 u32 type = va_arg (*args, u32);
3284 u8 *eid = va_arg (*args, u8 *);
3285 u32 eid_len = va_arg (*args, u32);
3286 u8 *seid = va_arg (*args, u8 *);
3287 u32 seid_len = va_arg (*args, u32);
3288 u32 is_src_dst = va_arg (*args, u32);
3291 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3293 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3299 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3301 vat_main_t *vam = &vat_main;
3302 u8 *s = 0, *eid = 0;
3304 if (~0 == mp->locator_set_index)
3305 s = format (0, "action: %d", mp->action);
3307 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3309 eid = format (0, "%U", format_lisp_eid_vat,
3313 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3316 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3317 clib_net_to_host_u32 (mp->vni),
3319 mp->is_local ? "local" : "remote",
3320 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3321 clib_net_to_host_u16 (mp->key_id), mp->key);
3328 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3331 vat_main_t *vam = &vat_main;
3332 vat_json_node_t *node = 0;
3335 if (VAT_JSON_ARRAY != vam->json_tree.type)
3337 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3338 vat_json_init_array (&vam->json_tree);
3340 node = vat_json_array_add (&vam->json_tree);
3342 vat_json_init_object (node);
3343 if (~0 == mp->locator_set_index)
3344 vat_json_object_add_uint (node, "action", mp->action);
3346 vat_json_object_add_uint (node, "locator_set_index",
3347 clib_net_to_host_u32 (mp->locator_set_index));
3349 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3350 if (mp->eid_type == 3)
3352 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3353 vat_json_init_object (nsh_json);
3354 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3355 vat_json_object_add_uint (nsh_json, "spi",
3356 clib_net_to_host_u32 (nsh->spi));
3357 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3361 eid = format (0, "%U", format_lisp_eid_vat,
3365 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3367 vat_json_object_add_string_copy (node, "eid", eid);
3370 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3371 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3372 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3376 vat_json_object_add_uint (node, "key_id",
3377 clib_net_to_host_u16 (mp->key_id));
3378 vat_json_object_add_string_copy (node, "key", mp->key);
3383 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3385 vat_main_t *vam = &vat_main;
3386 u8 *seid = 0, *deid = 0;
3387 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3389 deid = format (0, "%U", format_lisp_eid_vat,
3390 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3392 seid = format (0, "%U", format_lisp_eid_vat,
3393 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3399 format_ip_address_fcn = format_ip4_address;
3401 format_ip_address_fcn = format_ip6_address;
3404 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3405 clib_net_to_host_u32 (mp->vni),
3407 format_ip_address_fcn, mp->lloc,
3408 format_ip_address_fcn, mp->rloc,
3409 clib_net_to_host_u32 (mp->pkt_count),
3410 clib_net_to_host_u32 (mp->bytes));
3417 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3419 struct in6_addr ip6;
3421 vat_main_t *vam = &vat_main;
3422 vat_json_node_t *node = 0;
3423 u8 *deid = 0, *seid = 0;
3425 if (VAT_JSON_ARRAY != vam->json_tree.type)
3427 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3428 vat_json_init_array (&vam->json_tree);
3430 node = vat_json_array_add (&vam->json_tree);
3432 vat_json_init_object (node);
3433 deid = format (0, "%U", format_lisp_eid_vat,
3434 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3436 seid = format (0, "%U", format_lisp_eid_vat,
3437 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3442 vat_json_object_add_string_copy (node, "seid", seid);
3443 vat_json_object_add_string_copy (node, "deid", deid);
3444 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3448 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3449 vat_json_object_add_ip4 (node, "lloc", ip4);
3450 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3451 vat_json_object_add_ip4 (node, "rloc", ip4);
3455 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3456 vat_json_object_add_ip6 (node, "lloc", ip6);
3457 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3458 vat_json_object_add_ip6 (node, "rloc", ip6);
3460 vat_json_object_add_uint (node, "pkt_count",
3461 clib_net_to_host_u32 (mp->pkt_count));
3462 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3469 vl_api_one_eid_table_map_details_t_handler
3470 (vl_api_one_eid_table_map_details_t * mp)
3472 vat_main_t *vam = &vat_main;
3474 u8 *line = format (0, "%=10d%=10d",
3475 clib_net_to_host_u32 (mp->vni),
3476 clib_net_to_host_u32 (mp->dp_table));
3477 print (vam->ofp, "%v", line);
3482 vl_api_one_eid_table_map_details_t_handler_json
3483 (vl_api_one_eid_table_map_details_t * mp)
3485 vat_main_t *vam = &vat_main;
3486 vat_json_node_t *node = NULL;
3488 if (VAT_JSON_ARRAY != vam->json_tree.type)
3490 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3491 vat_json_init_array (&vam->json_tree);
3493 node = vat_json_array_add (&vam->json_tree);
3494 vat_json_init_object (node);
3495 vat_json_object_add_uint (node, "dp_table",
3496 clib_net_to_host_u32 (mp->dp_table));
3497 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3501 vl_api_one_eid_table_vni_details_t_handler
3502 (vl_api_one_eid_table_vni_details_t * mp)
3504 vat_main_t *vam = &vat_main;
3506 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3507 print (vam->ofp, "%v", line);
3512 vl_api_one_eid_table_vni_details_t_handler_json
3513 (vl_api_one_eid_table_vni_details_t * mp)
3515 vat_main_t *vam = &vat_main;
3516 vat_json_node_t *node = NULL;
3518 if (VAT_JSON_ARRAY != vam->json_tree.type)
3520 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3521 vat_json_init_array (&vam->json_tree);
3523 node = vat_json_array_add (&vam->json_tree);
3524 vat_json_init_object (node);
3525 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3529 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3530 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3532 vat_main_t *vam = &vat_main;
3533 int retval = clib_net_to_host_u32 (mp->retval);
3535 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3536 print (vam->ofp, "fallback threshold value: %d", mp->value);
3538 vam->retval = retval;
3539 vam->result_ready = 1;
3543 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3544 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3546 vat_main_t *vam = &vat_main;
3547 vat_json_node_t _node, *node = &_node;
3548 int retval = clib_net_to_host_u32 (mp->retval);
3550 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3551 vat_json_init_object (node);
3552 vat_json_object_add_uint (node, "value", mp->value);
3554 vat_json_print (vam->ofp, node);
3555 vat_json_free (node);
3557 vam->retval = retval;
3558 vam->result_ready = 1;
3562 vl_api_show_one_map_register_state_reply_t_handler
3563 (vl_api_show_one_map_register_state_reply_t * mp)
3565 vat_main_t *vam = &vat_main;
3566 int retval = clib_net_to_host_u32 (mp->retval);
3568 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3570 vam->retval = retval;
3571 vam->result_ready = 1;
3575 vl_api_show_one_map_register_state_reply_t_handler_json
3576 (vl_api_show_one_map_register_state_reply_t * mp)
3578 vat_main_t *vam = &vat_main;
3579 vat_json_node_t _node, *node = &_node;
3580 int retval = clib_net_to_host_u32 (mp->retval);
3582 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3584 vat_json_init_object (node);
3585 vat_json_object_add_string_copy (node, "state", s);
3587 vat_json_print (vam->ofp, node);
3588 vat_json_free (node);
3590 vam->retval = retval;
3591 vam->result_ready = 1;
3596 vl_api_show_one_rloc_probe_state_reply_t_handler
3597 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3599 vat_main_t *vam = &vat_main;
3600 int retval = clib_net_to_host_u32 (mp->retval);
3605 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3607 vam->retval = retval;
3608 vam->result_ready = 1;
3612 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3613 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3615 vat_main_t *vam = &vat_main;
3616 vat_json_node_t _node, *node = &_node;
3617 int retval = clib_net_to_host_u32 (mp->retval);
3619 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3620 vat_json_init_object (node);
3621 vat_json_object_add_string_copy (node, "state", s);
3623 vat_json_print (vam->ofp, node);
3624 vat_json_free (node);
3626 vam->retval = retval;
3627 vam->result_ready = 1;
3632 vl_api_show_one_stats_enable_disable_reply_t_handler
3633 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3635 vat_main_t *vam = &vat_main;
3636 int retval = clib_net_to_host_u32 (mp->retval);
3641 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3643 vam->retval = retval;
3644 vam->result_ready = 1;
3648 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3649 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3651 vat_main_t *vam = &vat_main;
3652 vat_json_node_t _node, *node = &_node;
3653 int retval = clib_net_to_host_u32 (mp->retval);
3655 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3656 vat_json_init_object (node);
3657 vat_json_object_add_string_copy (node, "state", s);
3659 vat_json_print (vam->ofp, node);
3660 vat_json_free (node);
3662 vam->retval = retval;
3663 vam->result_ready = 1;
3668 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3670 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3671 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3672 e->vni = clib_net_to_host_u32 (e->vni);
3676 gpe_fwd_entries_get_reply_t_net_to_host
3677 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3681 mp->count = clib_net_to_host_u32 (mp->count);
3682 for (i = 0; i < mp->count; i++)
3684 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3689 format_gpe_encap_mode (u8 * s, va_list * args)
3691 u32 mode = va_arg (*args, u32);
3696 return format (s, "lisp");
3698 return format (s, "vxlan");
3704 vl_api_gpe_get_encap_mode_reply_t_handler
3705 (vl_api_gpe_get_encap_mode_reply_t * mp)
3707 vat_main_t *vam = &vat_main;
3709 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3710 vam->retval = ntohl (mp->retval);
3711 vam->result_ready = 1;
3715 vl_api_gpe_get_encap_mode_reply_t_handler_json
3716 (vl_api_gpe_get_encap_mode_reply_t * mp)
3718 vat_main_t *vam = &vat_main;
3719 vat_json_node_t node;
3721 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3722 vec_add1 (encap_mode, 0);
3724 vat_json_init_object (&node);
3725 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3727 vec_free (encap_mode);
3728 vat_json_print (vam->ofp, &node);
3729 vat_json_free (&node);
3731 vam->retval = ntohl (mp->retval);
3732 vam->result_ready = 1;
3736 vl_api_gpe_fwd_entry_path_details_t_handler
3737 (vl_api_gpe_fwd_entry_path_details_t * mp)
3739 vat_main_t *vam = &vat_main;
3740 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3742 if (mp->lcl_loc.is_ip4)
3743 format_ip_address_fcn = format_ip4_address;
3745 format_ip_address_fcn = format_ip6_address;
3747 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3748 format_ip_address_fcn, &mp->lcl_loc,
3749 format_ip_address_fcn, &mp->rmt_loc);
3753 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3755 struct in6_addr ip6;
3760 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3761 vat_json_object_add_ip4 (n, "address", ip4);
3765 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3766 vat_json_object_add_ip6 (n, "address", ip6);
3768 vat_json_object_add_uint (n, "weight", loc->weight);
3772 vl_api_gpe_fwd_entry_path_details_t_handler_json
3773 (vl_api_gpe_fwd_entry_path_details_t * mp)
3775 vat_main_t *vam = &vat_main;
3776 vat_json_node_t *node = NULL;
3777 vat_json_node_t *loc_node;
3779 if (VAT_JSON_ARRAY != vam->json_tree.type)
3781 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3782 vat_json_init_array (&vam->json_tree);
3784 node = vat_json_array_add (&vam->json_tree);
3785 vat_json_init_object (node);
3787 loc_node = vat_json_object_add (node, "local_locator");
3788 vat_json_init_object (loc_node);
3789 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3791 loc_node = vat_json_object_add (node, "remote_locator");
3792 vat_json_init_object (loc_node);
3793 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3797 vl_api_gpe_fwd_entries_get_reply_t_handler
3798 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3800 vat_main_t *vam = &vat_main;
3802 int retval = clib_net_to_host_u32 (mp->retval);
3803 vl_api_gpe_fwd_entry_t *e;
3808 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3810 for (i = 0; i < mp->count; i++)
3812 e = &mp->entries[i];
3813 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3814 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3815 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3819 vam->retval = retval;
3820 vam->result_ready = 1;
3824 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3825 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3828 vat_main_t *vam = &vat_main;
3829 vat_json_node_t *e = 0, root;
3831 int retval = clib_net_to_host_u32 (mp->retval);
3832 vl_api_gpe_fwd_entry_t *fwd;
3837 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3838 vat_json_init_array (&root);
3840 for (i = 0; i < mp->count; i++)
3842 e = vat_json_array_add (&root);
3843 fwd = &mp->entries[i];
3845 vat_json_init_object (e);
3846 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3847 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3848 vat_json_object_add_int (e, "vni", fwd->vni);
3849 vat_json_object_add_int (e, "action", fwd->action);
3851 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3852 fwd->leid_prefix_len);
3854 vat_json_object_add_string_copy (e, "leid", s);
3857 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3858 fwd->reid_prefix_len);
3860 vat_json_object_add_string_copy (e, "reid", s);
3864 vat_json_print (vam->ofp, &root);
3865 vat_json_free (&root);
3868 vam->retval = retval;
3869 vam->result_ready = 1;
3873 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3874 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3876 vat_main_t *vam = &vat_main;
3878 int retval = clib_net_to_host_u32 (mp->retval);
3879 vl_api_gpe_native_fwd_rpath_t *r;
3884 n = clib_net_to_host_u32 (mp->count);
3886 for (i = 0; i < n; i++)
3888 r = &mp->entries[i];
3889 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3890 clib_net_to_host_u32 (r->fib_index),
3891 clib_net_to_host_u32 (r->nh_sw_if_index),
3892 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3896 vam->retval = retval;
3897 vam->result_ready = 1;
3901 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3902 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3904 vat_main_t *vam = &vat_main;
3905 vat_json_node_t root, *e;
3907 int retval = clib_net_to_host_u32 (mp->retval);
3908 vl_api_gpe_native_fwd_rpath_t *r;
3914 n = clib_net_to_host_u32 (mp->count);
3915 vat_json_init_array (&root);
3917 for (i = 0; i < n; i++)
3919 e = vat_json_array_add (&root);
3920 vat_json_init_object (e);
3921 r = &mp->entries[i];
3923 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3926 vat_json_object_add_string_copy (e, "ip4", s);
3929 vat_json_object_add_uint (e, "fib_index",
3930 clib_net_to_host_u32 (r->fib_index));
3931 vat_json_object_add_uint (e, "nh_sw_if_index",
3932 clib_net_to_host_u32 (r->nh_sw_if_index));
3935 vat_json_print (vam->ofp, &root);
3936 vat_json_free (&root);
3939 vam->retval = retval;
3940 vam->result_ready = 1;
3944 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3945 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3947 vat_main_t *vam = &vat_main;
3949 int retval = clib_net_to_host_u32 (mp->retval);
3954 n = clib_net_to_host_u32 (mp->count);
3956 for (i = 0; i < n; i++)
3957 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3960 vam->retval = retval;
3961 vam->result_ready = 1;
3965 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3966 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3968 vat_main_t *vam = &vat_main;
3969 vat_json_node_t root;
3971 int retval = clib_net_to_host_u32 (mp->retval);
3976 n = clib_net_to_host_u32 (mp->count);
3977 vat_json_init_array (&root);
3979 for (i = 0; i < n; i++)
3980 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3982 vat_json_print (vam->ofp, &root);
3983 vat_json_free (&root);
3986 vam->retval = retval;
3987 vam->result_ready = 1;
3991 vl_api_one_ndp_entries_get_reply_t_handler
3992 (vl_api_one_ndp_entries_get_reply_t * mp)
3994 vat_main_t *vam = &vat_main;
3996 int retval = clib_net_to_host_u32 (mp->retval);
4001 n = clib_net_to_host_u32 (mp->count);
4003 for (i = 0; i < n; i++)
4004 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
4005 format_ethernet_address, mp->entries[i].mac);
4008 vam->retval = retval;
4009 vam->result_ready = 1;
4013 vl_api_one_ndp_entries_get_reply_t_handler_json
4014 (vl_api_one_ndp_entries_get_reply_t * mp)
4017 vat_main_t *vam = &vat_main;
4018 vat_json_node_t *e = 0, root;
4020 int retval = clib_net_to_host_u32 (mp->retval);
4021 vl_api_one_ndp_entry_t *arp_entry;
4026 n = clib_net_to_host_u32 (mp->count);
4027 vat_json_init_array (&root);
4029 for (i = 0; i < n; i++)
4031 e = vat_json_array_add (&root);
4032 arp_entry = &mp->entries[i];
4034 vat_json_init_object (e);
4035 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4038 vat_json_object_add_string_copy (e, "mac", s);
4041 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
4043 vat_json_object_add_string_copy (e, "ip6", s);
4047 vat_json_print (vam->ofp, &root);
4048 vat_json_free (&root);
4051 vam->retval = retval;
4052 vam->result_ready = 1;
4056 vl_api_one_l2_arp_entries_get_reply_t_handler
4057 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4059 vat_main_t *vam = &vat_main;
4061 int retval = clib_net_to_host_u32 (mp->retval);
4066 n = clib_net_to_host_u32 (mp->count);
4068 for (i = 0; i < n; i++)
4069 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
4070 format_ethernet_address, mp->entries[i].mac);
4073 vam->retval = retval;
4074 vam->result_ready = 1;
4078 vl_api_one_l2_arp_entries_get_reply_t_handler_json
4079 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4082 vat_main_t *vam = &vat_main;
4083 vat_json_node_t *e = 0, root;
4085 int retval = clib_net_to_host_u32 (mp->retval);
4086 vl_api_one_l2_arp_entry_t *arp_entry;
4091 n = clib_net_to_host_u32 (mp->count);
4092 vat_json_init_array (&root);
4094 for (i = 0; i < n; i++)
4096 e = vat_json_array_add (&root);
4097 arp_entry = &mp->entries[i];
4099 vat_json_init_object (e);
4100 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4103 vat_json_object_add_string_copy (e, "mac", s);
4106 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4108 vat_json_object_add_string_copy (e, "ip4", s);
4112 vat_json_print (vam->ofp, &root);
4113 vat_json_free (&root);
4116 vam->retval = retval;
4117 vam->result_ready = 1;
4121 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4123 vat_main_t *vam = &vat_main;
4125 int retval = clib_net_to_host_u32 (mp->retval);
4130 n = clib_net_to_host_u32 (mp->count);
4132 for (i = 0; i < n; i++)
4134 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4138 vam->retval = retval;
4139 vam->result_ready = 1;
4143 vl_api_one_ndp_bd_get_reply_t_handler_json
4144 (vl_api_one_ndp_bd_get_reply_t * mp)
4146 vat_main_t *vam = &vat_main;
4147 vat_json_node_t root;
4149 int retval = clib_net_to_host_u32 (mp->retval);
4154 n = clib_net_to_host_u32 (mp->count);
4155 vat_json_init_array (&root);
4157 for (i = 0; i < n; i++)
4159 vat_json_array_add_uint (&root,
4160 clib_net_to_host_u32 (mp->bridge_domains[i]));
4163 vat_json_print (vam->ofp, &root);
4164 vat_json_free (&root);
4167 vam->retval = retval;
4168 vam->result_ready = 1;
4172 vl_api_one_l2_arp_bd_get_reply_t_handler
4173 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4175 vat_main_t *vam = &vat_main;
4177 int retval = clib_net_to_host_u32 (mp->retval);
4182 n = clib_net_to_host_u32 (mp->count);
4184 for (i = 0; i < n; i++)
4186 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4190 vam->retval = retval;
4191 vam->result_ready = 1;
4195 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4196 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4198 vat_main_t *vam = &vat_main;
4199 vat_json_node_t root;
4201 int retval = clib_net_to_host_u32 (mp->retval);
4206 n = clib_net_to_host_u32 (mp->count);
4207 vat_json_init_array (&root);
4209 for (i = 0; i < n; i++)
4211 vat_json_array_add_uint (&root,
4212 clib_net_to_host_u32 (mp->bridge_domains[i]));
4215 vat_json_print (vam->ofp, &root);
4216 vat_json_free (&root);
4219 vam->retval = retval;
4220 vam->result_ready = 1;
4224 vl_api_one_adjacencies_get_reply_t_handler
4225 (vl_api_one_adjacencies_get_reply_t * mp)
4227 vat_main_t *vam = &vat_main;
4229 int retval = clib_net_to_host_u32 (mp->retval);
4230 vl_api_one_adjacency_t *a;
4235 n = clib_net_to_host_u32 (mp->count);
4237 for (i = 0; i < n; i++)
4239 a = &mp->adjacencies[i];
4240 print (vam->ofp, "%U %40U",
4241 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4242 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4246 vam->retval = retval;
4247 vam->result_ready = 1;
4251 vl_api_one_adjacencies_get_reply_t_handler_json
4252 (vl_api_one_adjacencies_get_reply_t * mp)
4255 vat_main_t *vam = &vat_main;
4256 vat_json_node_t *e = 0, root;
4258 int retval = clib_net_to_host_u32 (mp->retval);
4259 vl_api_one_adjacency_t *a;
4264 n = clib_net_to_host_u32 (mp->count);
4265 vat_json_init_array (&root);
4267 for (i = 0; i < n; i++)
4269 e = vat_json_array_add (&root);
4270 a = &mp->adjacencies[i];
4272 vat_json_init_object (e);
4273 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4274 a->leid_prefix_len);
4276 vat_json_object_add_string_copy (e, "leid", s);
4279 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4280 a->reid_prefix_len);
4282 vat_json_object_add_string_copy (e, "reid", s);
4286 vat_json_print (vam->ofp, &root);
4287 vat_json_free (&root);
4290 vam->retval = retval;
4291 vam->result_ready = 1;
4295 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4297 vat_main_t *vam = &vat_main;
4299 print (vam->ofp, "%=20U",
4300 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4305 vl_api_one_map_server_details_t_handler_json
4306 (vl_api_one_map_server_details_t * mp)
4308 vat_main_t *vam = &vat_main;
4309 vat_json_node_t *node = NULL;
4310 struct in6_addr ip6;
4313 if (VAT_JSON_ARRAY != vam->json_tree.type)
4315 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4316 vat_json_init_array (&vam->json_tree);
4318 node = vat_json_array_add (&vam->json_tree);
4320 vat_json_init_object (node);
4323 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4324 vat_json_object_add_ip6 (node, "map-server", ip6);
4328 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4329 vat_json_object_add_ip4 (node, "map-server", ip4);
4334 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4337 vat_main_t *vam = &vat_main;
4339 print (vam->ofp, "%=20U",
4340 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4345 vl_api_one_map_resolver_details_t_handler_json
4346 (vl_api_one_map_resolver_details_t * mp)
4348 vat_main_t *vam = &vat_main;
4349 vat_json_node_t *node = NULL;
4350 struct in6_addr ip6;
4353 if (VAT_JSON_ARRAY != vam->json_tree.type)
4355 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4356 vat_json_init_array (&vam->json_tree);
4358 node = vat_json_array_add (&vam->json_tree);
4360 vat_json_init_object (node);
4363 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4364 vat_json_object_add_ip6 (node, "map resolver", ip6);
4368 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4369 vat_json_object_add_ip4 (node, "map resolver", ip4);
4374 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4376 vat_main_t *vam = &vat_main;
4377 i32 retval = ntohl (mp->retval);
4381 print (vam->ofp, "feature: %s\ngpe: %s",
4382 mp->feature_status ? "enabled" : "disabled",
4383 mp->gpe_status ? "enabled" : "disabled");
4386 vam->retval = retval;
4387 vam->result_ready = 1;
4391 vl_api_show_one_status_reply_t_handler_json
4392 (vl_api_show_one_status_reply_t * mp)
4394 vat_main_t *vam = &vat_main;
4395 vat_json_node_t node;
4396 u8 *gpe_status = NULL;
4397 u8 *feature_status = NULL;
4399 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4400 feature_status = format (0, "%s",
4401 mp->feature_status ? "enabled" : "disabled");
4402 vec_add1 (gpe_status, 0);
4403 vec_add1 (feature_status, 0);
4405 vat_json_init_object (&node);
4406 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4407 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4409 vec_free (gpe_status);
4410 vec_free (feature_status);
4412 vat_json_print (vam->ofp, &node);
4413 vat_json_free (&node);
4415 vam->retval = ntohl (mp->retval);
4416 vam->result_ready = 1;
4420 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4421 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4423 vat_main_t *vam = &vat_main;
4424 i32 retval = ntohl (mp->retval);
4428 print (vam->ofp, "%=20s", mp->locator_set_name);
4431 vam->retval = retval;
4432 vam->result_ready = 1;
4436 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4437 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4439 vat_main_t *vam = &vat_main;
4440 vat_json_node_t *node = NULL;
4442 if (VAT_JSON_ARRAY != vam->json_tree.type)
4444 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4445 vat_json_init_array (&vam->json_tree);
4447 node = vat_json_array_add (&vam->json_tree);
4449 vat_json_init_object (node);
4450 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4452 vat_json_print (vam->ofp, node);
4453 vat_json_free (node);
4455 vam->retval = ntohl (mp->retval);
4456 vam->result_ready = 1;
4460 format_lisp_map_request_mode (u8 * s, va_list * args)
4462 u32 mode = va_arg (*args, u32);
4467 return format (0, "dst-only");
4469 return format (0, "src-dst");
4475 vl_api_show_one_map_request_mode_reply_t_handler
4476 (vl_api_show_one_map_request_mode_reply_t * mp)
4478 vat_main_t *vam = &vat_main;
4479 i32 retval = ntohl (mp->retval);
4483 u32 mode = mp->mode;
4484 print (vam->ofp, "map_request_mode: %U",
4485 format_lisp_map_request_mode, mode);
4488 vam->retval = retval;
4489 vam->result_ready = 1;
4493 vl_api_show_one_map_request_mode_reply_t_handler_json
4494 (vl_api_show_one_map_request_mode_reply_t * mp)
4496 vat_main_t *vam = &vat_main;
4497 vat_json_node_t node;
4502 s = format (0, "%U", format_lisp_map_request_mode, mode);
4505 vat_json_init_object (&node);
4506 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4507 vat_json_print (vam->ofp, &node);
4508 vat_json_free (&node);
4511 vam->retval = ntohl (mp->retval);
4512 vam->result_ready = 1;
4516 vl_api_one_show_xtr_mode_reply_t_handler
4517 (vl_api_one_show_xtr_mode_reply_t * mp)
4519 vat_main_t *vam = &vat_main;
4520 i32 retval = ntohl (mp->retval);
4524 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4527 vam->retval = retval;
4528 vam->result_ready = 1;
4532 vl_api_one_show_xtr_mode_reply_t_handler_json
4533 (vl_api_one_show_xtr_mode_reply_t * mp)
4535 vat_main_t *vam = &vat_main;
4536 vat_json_node_t node;
4539 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4540 vec_add1 (status, 0);
4542 vat_json_init_object (&node);
4543 vat_json_object_add_string_copy (&node, "status", status);
4547 vat_json_print (vam->ofp, &node);
4548 vat_json_free (&node);
4550 vam->retval = ntohl (mp->retval);
4551 vam->result_ready = 1;
4555 vl_api_one_show_pitr_mode_reply_t_handler
4556 (vl_api_one_show_pitr_mode_reply_t * mp)
4558 vat_main_t *vam = &vat_main;
4559 i32 retval = ntohl (mp->retval);
4563 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4566 vam->retval = retval;
4567 vam->result_ready = 1;
4571 vl_api_one_show_pitr_mode_reply_t_handler_json
4572 (vl_api_one_show_pitr_mode_reply_t * mp)
4574 vat_main_t *vam = &vat_main;
4575 vat_json_node_t node;
4578 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4579 vec_add1 (status, 0);
4581 vat_json_init_object (&node);
4582 vat_json_object_add_string_copy (&node, "status", status);
4586 vat_json_print (vam->ofp, &node);
4587 vat_json_free (&node);
4589 vam->retval = ntohl (mp->retval);
4590 vam->result_ready = 1;
4594 vl_api_one_show_petr_mode_reply_t_handler
4595 (vl_api_one_show_petr_mode_reply_t * mp)
4597 vat_main_t *vam = &vat_main;
4598 i32 retval = ntohl (mp->retval);
4602 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4605 vam->retval = retval;
4606 vam->result_ready = 1;
4610 vl_api_one_show_petr_mode_reply_t_handler_json
4611 (vl_api_one_show_petr_mode_reply_t * mp)
4613 vat_main_t *vam = &vat_main;
4614 vat_json_node_t node;
4617 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4618 vec_add1 (status, 0);
4620 vat_json_init_object (&node);
4621 vat_json_object_add_string_copy (&node, "status", status);
4625 vat_json_print (vam->ofp, &node);
4626 vat_json_free (&node);
4628 vam->retval = ntohl (mp->retval);
4629 vam->result_ready = 1;
4633 vl_api_show_one_use_petr_reply_t_handler
4634 (vl_api_show_one_use_petr_reply_t * mp)
4636 vat_main_t *vam = &vat_main;
4637 i32 retval = ntohl (mp->retval);
4641 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4644 print (vam->ofp, "Proxy-ETR address; %U",
4645 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4650 vam->retval = retval;
4651 vam->result_ready = 1;
4655 vl_api_show_one_use_petr_reply_t_handler_json
4656 (vl_api_show_one_use_petr_reply_t * mp)
4658 vat_main_t *vam = &vat_main;
4659 vat_json_node_t node;
4662 struct in6_addr ip6;
4664 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4665 vec_add1 (status, 0);
4667 vat_json_init_object (&node);
4668 vat_json_object_add_string_copy (&node, "status", status);
4673 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4674 vat_json_object_add_ip6 (&node, "address", ip6);
4678 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4679 vat_json_object_add_ip4 (&node, "address", ip4);
4685 vat_json_print (vam->ofp, &node);
4686 vat_json_free (&node);
4688 vam->retval = ntohl (mp->retval);
4689 vam->result_ready = 1;
4693 vl_api_show_one_nsh_mapping_reply_t_handler
4694 (vl_api_show_one_nsh_mapping_reply_t * mp)
4696 vat_main_t *vam = &vat_main;
4697 i32 retval = ntohl (mp->retval);
4701 print (vam->ofp, "%-20s%-16s",
4702 mp->is_set ? "set" : "not-set",
4703 mp->is_set ? (char *) mp->locator_set_name : "");
4706 vam->retval = retval;
4707 vam->result_ready = 1;
4711 vl_api_show_one_nsh_mapping_reply_t_handler_json
4712 (vl_api_show_one_nsh_mapping_reply_t * mp)
4714 vat_main_t *vam = &vat_main;
4715 vat_json_node_t node;
4718 status = format (0, "%s", mp->is_set ? "yes" : "no");
4719 vec_add1 (status, 0);
4721 vat_json_init_object (&node);
4722 vat_json_object_add_string_copy (&node, "is_set", status);
4725 vat_json_object_add_string_copy (&node, "locator_set",
4726 mp->locator_set_name);
4731 vat_json_print (vam->ofp, &node);
4732 vat_json_free (&node);
4734 vam->retval = ntohl (mp->retval);
4735 vam->result_ready = 1;
4739 vl_api_show_one_map_register_ttl_reply_t_handler
4740 (vl_api_show_one_map_register_ttl_reply_t * mp)
4742 vat_main_t *vam = &vat_main;
4743 i32 retval = ntohl (mp->retval);
4745 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4749 print (vam->ofp, "ttl: %u", mp->ttl);
4752 vam->retval = retval;
4753 vam->result_ready = 1;
4757 vl_api_show_one_map_register_ttl_reply_t_handler_json
4758 (vl_api_show_one_map_register_ttl_reply_t * mp)
4760 vat_main_t *vam = &vat_main;
4761 vat_json_node_t node;
4763 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4764 vat_json_init_object (&node);
4765 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4767 vat_json_print (vam->ofp, &node);
4768 vat_json_free (&node);
4770 vam->retval = ntohl (mp->retval);
4771 vam->result_ready = 1;
4775 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4777 vat_main_t *vam = &vat_main;
4778 i32 retval = ntohl (mp->retval);
4782 print (vam->ofp, "%-20s%-16s",
4783 mp->status ? "enabled" : "disabled",
4784 mp->status ? (char *) mp->locator_set_name : "");
4787 vam->retval = retval;
4788 vam->result_ready = 1;
4792 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4794 vat_main_t *vam = &vat_main;
4795 vat_json_node_t node;
4798 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4799 vec_add1 (status, 0);
4801 vat_json_init_object (&node);
4802 vat_json_object_add_string_copy (&node, "status", status);
4805 vat_json_object_add_string_copy (&node, "locator_set",
4806 mp->locator_set_name);
4811 vat_json_print (vam->ofp, &node);
4812 vat_json_free (&node);
4814 vam->retval = ntohl (mp->retval);
4815 vam->result_ready = 1;
4819 format_policer_type (u8 * s, va_list * va)
4821 u32 i = va_arg (*va, u32);
4823 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4824 s = format (s, "1r2c");
4825 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4826 s = format (s, "1r3c");
4827 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4828 s = format (s, "2r3c-2698");
4829 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4830 s = format (s, "2r3c-4115");
4831 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4832 s = format (s, "2r3c-mef5cf1");
4834 s = format (s, "ILLEGAL");
4839 format_policer_rate_type (u8 * s, va_list * va)
4841 u32 i = va_arg (*va, u32);
4843 if (i == SSE2_QOS_RATE_KBPS)
4844 s = format (s, "kbps");
4845 else if (i == SSE2_QOS_RATE_PPS)
4846 s = format (s, "pps");
4848 s = format (s, "ILLEGAL");
4853 format_policer_round_type (u8 * s, va_list * va)
4855 u32 i = va_arg (*va, u32);
4857 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4858 s = format (s, "closest");
4859 else if (i == SSE2_QOS_ROUND_TO_UP)
4860 s = format (s, "up");
4861 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4862 s = format (s, "down");
4864 s = format (s, "ILLEGAL");
4869 format_policer_action_type (u8 * s, va_list * va)
4871 u32 i = va_arg (*va, u32);
4873 if (i == SSE2_QOS_ACTION_DROP)
4874 s = format (s, "drop");
4875 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4876 s = format (s, "transmit");
4877 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4878 s = format (s, "mark-and-transmit");
4880 s = format (s, "ILLEGAL");
4885 format_dscp (u8 * s, va_list * va)
4887 u32 i = va_arg (*va, u32);
4892 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4896 return format (s, "ILLEGAL");
4898 s = format (s, "%s", t);
4903 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4905 vat_main_t *vam = &vat_main;
4906 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4908 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4909 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4911 conform_dscp_str = format (0, "");
4913 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4914 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4916 exceed_dscp_str = format (0, "");
4918 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4919 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4921 violate_dscp_str = format (0, "");
4923 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4924 "rate type %U, round type %U, %s rate, %s color-aware, "
4925 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4926 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4927 "conform action %U%s, exceed action %U%s, violate action %U%s",
4929 format_policer_type, mp->type,
4932 clib_net_to_host_u64 (mp->cb),
4933 clib_net_to_host_u64 (mp->eb),
4934 format_policer_rate_type, mp->rate_type,
4935 format_policer_round_type, mp->round_type,
4936 mp->single_rate ? "single" : "dual",
4937 mp->color_aware ? "is" : "not",
4938 ntohl (mp->cir_tokens_per_period),
4939 ntohl (mp->pir_tokens_per_period),
4941 ntohl (mp->current_limit),
4942 ntohl (mp->current_bucket),
4943 ntohl (mp->extended_limit),
4944 ntohl (mp->extended_bucket),
4945 clib_net_to_host_u64 (mp->last_update_time),
4946 format_policer_action_type, mp->conform_action_type,
4948 format_policer_action_type, mp->exceed_action_type,
4950 format_policer_action_type, mp->violate_action_type,
4953 vec_free (conform_dscp_str);
4954 vec_free (exceed_dscp_str);
4955 vec_free (violate_dscp_str);
4958 static void vl_api_policer_details_t_handler_json
4959 (vl_api_policer_details_t * mp)
4961 vat_main_t *vam = &vat_main;
4962 vat_json_node_t *node;
4963 u8 *rate_type_str, *round_type_str, *type_str;
4964 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4966 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4968 format (0, "%U", format_policer_round_type, mp->round_type);
4969 type_str = format (0, "%U", format_policer_type, mp->type);
4970 conform_action_str = format (0, "%U", format_policer_action_type,
4971 mp->conform_action_type);
4972 exceed_action_str = format (0, "%U", format_policer_action_type,
4973 mp->exceed_action_type);
4974 violate_action_str = format (0, "%U", format_policer_action_type,
4975 mp->violate_action_type);
4977 if (VAT_JSON_ARRAY != vam->json_tree.type)
4979 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4980 vat_json_init_array (&vam->json_tree);
4982 node = vat_json_array_add (&vam->json_tree);
4984 vat_json_init_object (node);
4985 vat_json_object_add_string_copy (node, "name", mp->name);
4986 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4987 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4988 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4989 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4990 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4991 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4992 vat_json_object_add_string_copy (node, "type", type_str);
4993 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4994 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4995 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4996 vat_json_object_add_uint (node, "cir_tokens_per_period",
4997 ntohl (mp->cir_tokens_per_period));
4998 vat_json_object_add_uint (node, "eir_tokens_per_period",
4999 ntohl (mp->pir_tokens_per_period));
5000 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
5001 vat_json_object_add_uint (node, "current_bucket",
5002 ntohl (mp->current_bucket));
5003 vat_json_object_add_uint (node, "extended_limit",
5004 ntohl (mp->extended_limit));
5005 vat_json_object_add_uint (node, "extended_bucket",
5006 ntohl (mp->extended_bucket));
5007 vat_json_object_add_uint (node, "last_update_time",
5008 ntohl (mp->last_update_time));
5009 vat_json_object_add_string_copy (node, "conform_action",
5010 conform_action_str);
5011 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5013 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
5014 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
5015 vec_free (dscp_str);
5017 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
5018 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5020 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
5021 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
5022 vec_free (dscp_str);
5024 vat_json_object_add_string_copy (node, "violate_action",
5025 violate_action_str);
5026 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5028 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
5029 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
5030 vec_free (dscp_str);
5033 vec_free (rate_type_str);
5034 vec_free (round_type_str);
5035 vec_free (type_str);
5036 vec_free (conform_action_str);
5037 vec_free (exceed_action_str);
5038 vec_free (violate_action_str);
5042 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
5045 vat_main_t *vam = &vat_main;
5046 int i, count = ntohl (mp->count);
5049 print (vam->ofp, "classify table ids (%d) : ", count);
5050 for (i = 0; i < count; i++)
5052 print (vam->ofp, "%d", ntohl (mp->ids[i]));
5053 print (vam->ofp, (i < count - 1) ? "," : "");
5055 vam->retval = ntohl (mp->retval);
5056 vam->result_ready = 1;
5060 vl_api_classify_table_ids_reply_t_handler_json
5061 (vl_api_classify_table_ids_reply_t * mp)
5063 vat_main_t *vam = &vat_main;
5064 int i, count = ntohl (mp->count);
5068 vat_json_node_t node;
5070 vat_json_init_object (&node);
5071 for (i = 0; i < count; i++)
5073 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
5075 vat_json_print (vam->ofp, &node);
5076 vat_json_free (&node);
5078 vam->retval = ntohl (mp->retval);
5079 vam->result_ready = 1;
5083 vl_api_classify_table_by_interface_reply_t_handler
5084 (vl_api_classify_table_by_interface_reply_t * mp)
5086 vat_main_t *vam = &vat_main;
5089 table_id = ntohl (mp->l2_table_id);
5091 print (vam->ofp, "l2 table id : %d", table_id);
5093 print (vam->ofp, "l2 table id : No input ACL tables configured");
5094 table_id = ntohl (mp->ip4_table_id);
5096 print (vam->ofp, "ip4 table id : %d", table_id);
5098 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5099 table_id = ntohl (mp->ip6_table_id);
5101 print (vam->ofp, "ip6 table id : %d", table_id);
5103 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5104 vam->retval = ntohl (mp->retval);
5105 vam->result_ready = 1;
5109 vl_api_classify_table_by_interface_reply_t_handler_json
5110 (vl_api_classify_table_by_interface_reply_t * mp)
5112 vat_main_t *vam = &vat_main;
5113 vat_json_node_t node;
5115 vat_json_init_object (&node);
5117 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5118 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5119 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5121 vat_json_print (vam->ofp, &node);
5122 vat_json_free (&node);
5124 vam->retval = ntohl (mp->retval);
5125 vam->result_ready = 1;
5128 static void vl_api_policer_add_del_reply_t_handler
5129 (vl_api_policer_add_del_reply_t * mp)
5131 vat_main_t *vam = &vat_main;
5132 i32 retval = ntohl (mp->retval);
5133 if (vam->async_mode)
5135 vam->async_errors += (retval < 0);
5139 vam->retval = retval;
5140 vam->result_ready = 1;
5141 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5143 * Note: this is just barely thread-safe, depends on
5144 * the main thread spinning waiting for an answer...
5146 errmsg ("policer index %d", ntohl (mp->policer_index));
5150 static void vl_api_policer_add_del_reply_t_handler_json
5151 (vl_api_policer_add_del_reply_t * mp)
5153 vat_main_t *vam = &vat_main;
5154 vat_json_node_t node;
5156 vat_json_init_object (&node);
5157 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5158 vat_json_object_add_uint (&node, "policer_index",
5159 ntohl (mp->policer_index));
5161 vat_json_print (vam->ofp, &node);
5162 vat_json_free (&node);
5164 vam->retval = ntohl (mp->retval);
5165 vam->result_ready = 1;
5168 /* Format hex dump. */
5170 format_hex_bytes (u8 * s, va_list * va)
5172 u8 *bytes = va_arg (*va, u8 *);
5173 int n_bytes = va_arg (*va, int);
5176 /* Print short or long form depending on byte count. */
5177 uword short_form = n_bytes <= 32;
5178 u32 indent = format_get_indent (s);
5183 for (i = 0; i < n_bytes; i++)
5185 if (!short_form && (i % 32) == 0)
5186 s = format (s, "%08x: ", i);
5187 s = format (s, "%02x", bytes[i]);
5188 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5189 s = format (s, "\n%U", format_white_space, indent);
5196 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5199 vat_main_t *vam = &vat_main;
5200 i32 retval = ntohl (mp->retval);
5203 print (vam->ofp, "classify table info :");
5204 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5205 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5206 ntohl (mp->miss_next_index));
5207 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5208 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5209 ntohl (mp->match_n_vectors));
5210 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5211 ntohl (mp->mask_length));
5213 vam->retval = retval;
5214 vam->result_ready = 1;
5218 vl_api_classify_table_info_reply_t_handler_json
5219 (vl_api_classify_table_info_reply_t * mp)
5221 vat_main_t *vam = &vat_main;
5222 vat_json_node_t node;
5224 i32 retval = ntohl (mp->retval);
5227 vat_json_init_object (&node);
5229 vat_json_object_add_int (&node, "sessions",
5230 ntohl (mp->active_sessions));
5231 vat_json_object_add_int (&node, "nexttbl",
5232 ntohl (mp->next_table_index));
5233 vat_json_object_add_int (&node, "nextnode",
5234 ntohl (mp->miss_next_index));
5235 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5236 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5237 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5238 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5239 ntohl (mp->mask_length), 0);
5240 vat_json_object_add_string_copy (&node, "mask", s);
5242 vat_json_print (vam->ofp, &node);
5243 vat_json_free (&node);
5245 vam->retval = ntohl (mp->retval);
5246 vam->result_ready = 1;
5250 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5253 vat_main_t *vam = &vat_main;
5255 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5256 ntohl (mp->hit_next_index), ntohl (mp->advance),
5257 ntohl (mp->opaque_index));
5258 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5259 ntohl (mp->match_length));
5263 vl_api_classify_session_details_t_handler_json
5264 (vl_api_classify_session_details_t * mp)
5266 vat_main_t *vam = &vat_main;
5267 vat_json_node_t *node = NULL;
5269 if (VAT_JSON_ARRAY != vam->json_tree.type)
5271 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5272 vat_json_init_array (&vam->json_tree);
5274 node = vat_json_array_add (&vam->json_tree);
5276 vat_json_init_object (node);
5277 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5278 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5279 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5281 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5283 vat_json_object_add_string_copy (node, "match", s);
5286 static void vl_api_pg_create_interface_reply_t_handler
5287 (vl_api_pg_create_interface_reply_t * mp)
5289 vat_main_t *vam = &vat_main;
5291 vam->retval = ntohl (mp->retval);
5292 vam->result_ready = 1;
5295 static void vl_api_pg_create_interface_reply_t_handler_json
5296 (vl_api_pg_create_interface_reply_t * mp)
5298 vat_main_t *vam = &vat_main;
5299 vat_json_node_t node;
5301 i32 retval = ntohl (mp->retval);
5304 vat_json_init_object (&node);
5306 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5308 vat_json_print (vam->ofp, &node);
5309 vat_json_free (&node);
5311 vam->retval = ntohl (mp->retval);
5312 vam->result_ready = 1;
5315 static void vl_api_policer_classify_details_t_handler
5316 (vl_api_policer_classify_details_t * mp)
5318 vat_main_t *vam = &vat_main;
5320 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5321 ntohl (mp->table_index));
5324 static void vl_api_policer_classify_details_t_handler_json
5325 (vl_api_policer_classify_details_t * mp)
5327 vat_main_t *vam = &vat_main;
5328 vat_json_node_t *node;
5330 if (VAT_JSON_ARRAY != vam->json_tree.type)
5332 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5333 vat_json_init_array (&vam->json_tree);
5335 node = vat_json_array_add (&vam->json_tree);
5337 vat_json_init_object (node);
5338 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5339 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5342 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5343 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5345 vat_main_t *vam = &vat_main;
5346 i32 retval = ntohl (mp->retval);
5347 if (vam->async_mode)
5349 vam->async_errors += (retval < 0);
5353 vam->retval = retval;
5354 vam->sw_if_index = ntohl (mp->sw_if_index);
5355 vam->result_ready = 1;
5357 vam->regenerate_interface_table = 1;
5360 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5361 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5363 vat_main_t *vam = &vat_main;
5364 vat_json_node_t node;
5366 vat_json_init_object (&node);
5367 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5368 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5370 vat_json_print (vam->ofp, &node);
5371 vat_json_free (&node);
5373 vam->retval = ntohl (mp->retval);
5374 vam->result_ready = 1;
5377 static void vl_api_flow_classify_details_t_handler
5378 (vl_api_flow_classify_details_t * mp)
5380 vat_main_t *vam = &vat_main;
5382 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5383 ntohl (mp->table_index));
5386 static void vl_api_flow_classify_details_t_handler_json
5387 (vl_api_flow_classify_details_t * mp)
5389 vat_main_t *vam = &vat_main;
5390 vat_json_node_t *node;
5392 if (VAT_JSON_ARRAY != vam->json_tree.type)
5394 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5395 vat_json_init_array (&vam->json_tree);
5397 node = vat_json_array_add (&vam->json_tree);
5399 vat_json_init_object (node);
5400 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5401 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5404 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5405 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5406 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5407 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5408 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5409 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5410 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5411 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5412 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5413 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5414 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5415 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5416 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5417 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5418 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5419 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5420 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5421 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5422 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5423 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5424 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5425 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5428 * Generate boilerplate reply handlers, which
5429 * dig the return value out of the xxx_reply_t API message,
5430 * stick it into vam->retval, and set vam->result_ready
5432 * Could also do this by pointing N message decode slots at
5433 * a single function, but that could break in subtle ways.
5436 #define foreach_standard_reply_retval_handler \
5437 _(sw_interface_set_flags_reply) \
5438 _(sw_interface_add_del_address_reply) \
5439 _(sw_interface_set_rx_mode_reply) \
5440 _(sw_interface_set_rx_placement_reply) \
5441 _(sw_interface_set_table_reply) \
5442 _(sw_interface_set_mpls_enable_reply) \
5443 _(sw_interface_set_vpath_reply) \
5444 _(sw_interface_set_vxlan_bypass_reply) \
5445 _(sw_interface_set_geneve_bypass_reply) \
5446 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5447 _(sw_interface_set_l2_bridge_reply) \
5448 _(bridge_domain_add_del_reply) \
5449 _(sw_interface_set_l2_xconnect_reply) \
5450 _(l2fib_add_del_reply) \
5451 _(l2fib_flush_int_reply) \
5452 _(l2fib_flush_bd_reply) \
5453 _(ip_add_del_route_reply) \
5454 _(ip_table_add_del_reply) \
5455 _(ip_mroute_add_del_reply) \
5456 _(mpls_route_add_del_reply) \
5457 _(mpls_table_add_del_reply) \
5458 _(mpls_ip_bind_unbind_reply) \
5459 _(bier_route_add_del_reply) \
5460 _(bier_table_add_del_reply) \
5461 _(proxy_arp_add_del_reply) \
5462 _(proxy_arp_intfc_enable_disable_reply) \
5463 _(sw_interface_set_unnumbered_reply) \
5464 _(ip_neighbor_add_del_reply) \
5465 _(oam_add_del_reply) \
5466 _(reset_fib_reply) \
5467 _(dhcp_proxy_config_reply) \
5468 _(dhcp_proxy_set_vss_reply) \
5469 _(dhcp_client_config_reply) \
5470 _(set_ip_flow_hash_reply) \
5471 _(sw_interface_ip6_enable_disable_reply) \
5472 _(sw_interface_ip6_set_link_local_address_reply) \
5473 _(ip6nd_proxy_add_del_reply) \
5474 _(sw_interface_ip6nd_ra_prefix_reply) \
5475 _(sw_interface_ip6nd_ra_config_reply) \
5476 _(set_arp_neighbor_limit_reply) \
5477 _(l2_patch_add_del_reply) \
5478 _(sr_mpls_policy_add_reply) \
5479 _(sr_mpls_policy_mod_reply) \
5480 _(sr_mpls_policy_del_reply) \
5481 _(sr_policy_add_reply) \
5482 _(sr_policy_mod_reply) \
5483 _(sr_policy_del_reply) \
5484 _(sr_localsid_add_del_reply) \
5485 _(sr_steering_add_del_reply) \
5486 _(classify_add_del_session_reply) \
5487 _(classify_set_interface_ip_table_reply) \
5488 _(classify_set_interface_l2_tables_reply) \
5489 _(l2tpv3_set_tunnel_cookies_reply) \
5490 _(l2tpv3_interface_enable_disable_reply) \
5491 _(l2tpv3_set_lookup_key_reply) \
5492 _(l2_fib_clear_table_reply) \
5493 _(l2_interface_efp_filter_reply) \
5494 _(l2_interface_vlan_tag_rewrite_reply) \
5495 _(modify_vhost_user_if_reply) \
5496 _(delete_vhost_user_if_reply) \
5497 _(ip_probe_neighbor_reply) \
5498 _(ip_scan_neighbor_enable_disable_reply) \
5499 _(want_ip4_arp_events_reply) \
5500 _(want_ip6_nd_events_reply) \
5501 _(want_l2_macs_events_reply) \
5502 _(input_acl_set_interface_reply) \
5503 _(ipsec_spd_add_del_reply) \
5504 _(ipsec_interface_add_del_spd_reply) \
5505 _(ipsec_spd_add_del_entry_reply) \
5506 _(ipsec_sad_add_del_entry_reply) \
5507 _(ipsec_sa_set_key_reply) \
5508 _(ipsec_tunnel_if_add_del_reply) \
5509 _(ipsec_tunnel_if_set_key_reply) \
5510 _(ipsec_tunnel_if_set_sa_reply) \
5511 _(ikev2_profile_add_del_reply) \
5512 _(ikev2_profile_set_auth_reply) \
5513 _(ikev2_profile_set_id_reply) \
5514 _(ikev2_profile_set_ts_reply) \
5515 _(ikev2_set_local_key_reply) \
5516 _(ikev2_set_responder_reply) \
5517 _(ikev2_set_ike_transforms_reply) \
5518 _(ikev2_set_esp_transforms_reply) \
5519 _(ikev2_set_sa_lifetime_reply) \
5520 _(ikev2_initiate_sa_init_reply) \
5521 _(ikev2_initiate_del_ike_sa_reply) \
5522 _(ikev2_initiate_del_child_sa_reply) \
5523 _(ikev2_initiate_rekey_child_sa_reply) \
5524 _(delete_loopback_reply) \
5525 _(bd_ip_mac_add_del_reply) \
5526 _(want_interface_events_reply) \
5527 _(want_stats_reply) \
5528 _(cop_interface_enable_disable_reply) \
5529 _(cop_whitelist_enable_disable_reply) \
5530 _(sw_interface_clear_stats_reply) \
5531 _(ioam_enable_reply) \
5532 _(ioam_disable_reply) \
5533 _(one_add_del_locator_reply) \
5534 _(one_add_del_local_eid_reply) \
5535 _(one_add_del_remote_mapping_reply) \
5536 _(one_add_del_adjacency_reply) \
5537 _(one_add_del_map_resolver_reply) \
5538 _(one_add_del_map_server_reply) \
5539 _(one_enable_disable_reply) \
5540 _(one_rloc_probe_enable_disable_reply) \
5541 _(one_map_register_enable_disable_reply) \
5542 _(one_map_register_set_ttl_reply) \
5543 _(one_set_transport_protocol_reply) \
5544 _(one_map_register_fallback_threshold_reply) \
5545 _(one_pitr_set_locator_set_reply) \
5546 _(one_map_request_mode_reply) \
5547 _(one_add_del_map_request_itr_rlocs_reply) \
5548 _(one_eid_table_add_del_map_reply) \
5549 _(one_use_petr_reply) \
5550 _(one_stats_enable_disable_reply) \
5551 _(one_add_del_l2_arp_entry_reply) \
5552 _(one_add_del_ndp_entry_reply) \
5553 _(one_stats_flush_reply) \
5554 _(one_enable_disable_xtr_mode_reply) \
5555 _(one_enable_disable_pitr_mode_reply) \
5556 _(one_enable_disable_petr_mode_reply) \
5557 _(gpe_enable_disable_reply) \
5558 _(gpe_set_encap_mode_reply) \
5559 _(gpe_add_del_iface_reply) \
5560 _(gpe_add_del_native_fwd_rpath_reply) \
5561 _(af_packet_delete_reply) \
5562 _(policer_classify_set_interface_reply) \
5563 _(netmap_create_reply) \
5564 _(netmap_delete_reply) \
5565 _(set_ipfix_exporter_reply) \
5566 _(set_ipfix_classify_stream_reply) \
5567 _(ipfix_classify_table_add_del_reply) \
5568 _(flow_classify_set_interface_reply) \
5569 _(sw_interface_span_enable_disable_reply) \
5570 _(pg_capture_reply) \
5571 _(pg_enable_disable_reply) \
5572 _(ip_source_and_port_range_check_add_del_reply) \
5573 _(ip_source_and_port_range_check_interface_add_del_reply)\
5574 _(delete_subif_reply) \
5575 _(l2_interface_pbb_tag_rewrite_reply) \
5577 _(feature_enable_disable_reply) \
5578 _(sw_interface_tag_add_del_reply) \
5579 _(hw_interface_set_mtu_reply) \
5580 _(p2p_ethernet_add_reply) \
5581 _(p2p_ethernet_del_reply) \
5582 _(lldp_config_reply) \
5583 _(sw_interface_set_lldp_reply) \
5584 _(tcp_configure_src_addresses_reply) \
5585 _(dns_enable_disable_reply) \
5586 _(dns_name_server_add_del_reply) \
5587 _(session_rule_add_del_reply) \
5588 _(ip_container_proxy_add_del_reply) \
5589 _(output_acl_set_interface_reply) \
5590 _(qos_record_enable_disable_reply)
5593 static void vl_api_##n##_t_handler \
5594 (vl_api_##n##_t * mp) \
5596 vat_main_t * vam = &vat_main; \
5597 i32 retval = ntohl(mp->retval); \
5598 if (vam->async_mode) { \
5599 vam->async_errors += (retval < 0); \
5601 vam->retval = retval; \
5602 vam->result_ready = 1; \
5605 foreach_standard_reply_retval_handler;
5609 static void vl_api_##n##_t_handler_json \
5610 (vl_api_##n##_t * mp) \
5612 vat_main_t * vam = &vat_main; \
5613 vat_json_node_t node; \
5614 vat_json_init_object(&node); \
5615 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5616 vat_json_print(vam->ofp, &node); \
5617 vam->retval = ntohl(mp->retval); \
5618 vam->result_ready = 1; \
5620 foreach_standard_reply_retval_handler;
5624 * Table of message reply handlers, must include boilerplate handlers
5628 #define foreach_vpe_api_reply_msg \
5629 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5630 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5631 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5632 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5633 _(CONTROL_PING_REPLY, control_ping_reply) \
5634 _(CLI_REPLY, cli_reply) \
5635 _(CLI_INBAND_REPLY, cli_inband_reply) \
5636 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5637 sw_interface_add_del_address_reply) \
5638 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5639 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5640 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5641 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5642 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5643 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5644 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5645 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5646 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5647 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5648 sw_interface_set_l2_xconnect_reply) \
5649 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5650 sw_interface_set_l2_bridge_reply) \
5651 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5652 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5653 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5654 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5655 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5656 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5657 _(L2_FLAGS_REPLY, l2_flags_reply) \
5658 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5659 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5660 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5661 _(TAP_DELETE_REPLY, tap_delete_reply) \
5662 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5663 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5664 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5665 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5666 _(BOND_CREATE_REPLY, bond_create_reply) \
5667 _(BOND_DELETE_REPLY, bond_delete_reply) \
5668 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5669 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5670 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5671 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5672 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5673 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5674 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5675 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5676 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5677 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5678 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5679 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5680 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5681 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5682 proxy_arp_intfc_enable_disable_reply) \
5683 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5684 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5685 sw_interface_set_unnumbered_reply) \
5686 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5687 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5688 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5689 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5690 _(RESET_FIB_REPLY, reset_fib_reply) \
5691 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5692 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5693 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5694 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5695 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5696 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5697 sw_interface_ip6_enable_disable_reply) \
5698 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5699 sw_interface_ip6_set_link_local_address_reply) \
5700 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5701 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5702 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5703 sw_interface_ip6nd_ra_prefix_reply) \
5704 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5705 sw_interface_ip6nd_ra_config_reply) \
5706 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5707 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5708 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5709 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5710 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5711 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5712 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5713 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5714 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5715 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5716 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5717 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5718 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5719 classify_set_interface_ip_table_reply) \
5720 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5721 classify_set_interface_l2_tables_reply) \
5722 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5723 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5724 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5725 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5726 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5727 l2tpv3_interface_enable_disable_reply) \
5728 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5729 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5730 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5731 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5732 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5733 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5734 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5735 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5736 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5737 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5738 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5739 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5740 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5741 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5742 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5743 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5744 _(SHOW_VERSION_REPLY, show_version_reply) \
5745 _(SHOW_THREADS_REPLY, show_threads_reply) \
5746 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5747 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5748 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5749 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5750 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5751 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5752 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5753 _(IP4_ARP_EVENT, ip4_arp_event) \
5754 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5755 _(IP6_ND_EVENT, ip6_nd_event) \
5756 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5757 _(L2_MACS_EVENT, l2_macs_event) \
5758 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5759 _(IP_ADDRESS_DETAILS, ip_address_details) \
5760 _(IP_DETAILS, ip_details) \
5761 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5762 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5763 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5764 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5765 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5766 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5767 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5768 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5769 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5770 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5771 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5772 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5773 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5774 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5775 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5776 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5777 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5778 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5779 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5780 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5781 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5782 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5783 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5784 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5785 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5786 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5787 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5788 _(WANT_STATS_REPLY, want_stats_reply) \
5789 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5790 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5791 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5792 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5793 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5794 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5795 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5796 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5797 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5798 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5799 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5800 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5801 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5802 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5803 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5804 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5805 one_map_register_enable_disable_reply) \
5806 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5807 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5808 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5809 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5810 one_map_register_fallback_threshold_reply) \
5811 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5812 one_rloc_probe_enable_disable_reply) \
5813 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5814 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5815 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5816 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5817 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5818 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5819 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5820 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5821 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5822 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5823 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5824 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5825 _(ONE_STATS_DETAILS, one_stats_details) \
5826 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5827 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5828 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5829 show_one_stats_enable_disable_reply) \
5830 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5831 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5832 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5833 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5834 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5835 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5836 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5837 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5838 one_enable_disable_pitr_mode_reply) \
5839 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5840 one_enable_disable_petr_mode_reply) \
5841 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5842 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5843 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5844 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5845 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5846 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5847 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5848 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5849 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5850 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5851 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5852 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5853 gpe_add_del_native_fwd_rpath_reply) \
5854 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5855 gpe_fwd_entry_path_details) \
5856 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5857 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5858 one_add_del_map_request_itr_rlocs_reply) \
5859 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5860 one_get_map_request_itr_rlocs_reply) \
5861 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5862 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5863 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5864 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5865 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5866 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5867 show_one_map_register_state_reply) \
5868 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5869 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5870 show_one_map_register_fallback_threshold_reply) \
5871 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5872 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5873 _(AF_PACKET_DETAILS, af_packet_details) \
5874 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5875 _(POLICER_DETAILS, policer_details) \
5876 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5877 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5878 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5879 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5880 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5881 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5882 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5883 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5884 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5885 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5886 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5887 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5888 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5889 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5890 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5891 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5892 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5893 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5894 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5895 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5896 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5897 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5898 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5899 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5900 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5901 ip_source_and_port_range_check_add_del_reply) \
5902 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5903 ip_source_and_port_range_check_interface_add_del_reply) \
5904 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5905 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5906 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5907 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5908 _(PUNT_REPLY, punt_reply) \
5909 _(IP_FIB_DETAILS, ip_fib_details) \
5910 _(IP6_FIB_DETAILS, ip6_fib_details) \
5911 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5912 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5913 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5914 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5915 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5916 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5917 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5918 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5919 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5920 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5921 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5922 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5923 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5924 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5925 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5926 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5927 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5928 _(SESSION_RULES_DETAILS, session_rules_details) \
5929 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5930 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5931 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5933 #define foreach_standalone_reply_msg \
5934 _(SW_INTERFACE_EVENT, sw_interface_event) \
5935 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5936 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5937 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5938 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5939 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5940 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5948 #define STR_VTR_OP_CASE(op) \
5949 case L2_VTR_ ## op: \
5953 str_vtr_op (u32 vtr_op)
5957 STR_VTR_OP_CASE (DISABLED);
5958 STR_VTR_OP_CASE (PUSH_1);
5959 STR_VTR_OP_CASE (PUSH_2);
5960 STR_VTR_OP_CASE (POP_1);
5961 STR_VTR_OP_CASE (POP_2);
5962 STR_VTR_OP_CASE (TRANSLATE_1_1);
5963 STR_VTR_OP_CASE (TRANSLATE_1_2);
5964 STR_VTR_OP_CASE (TRANSLATE_2_1);
5965 STR_VTR_OP_CASE (TRANSLATE_2_2);
5972 dump_sub_interface_table (vat_main_t * vam)
5974 const sw_interface_subif_t *sub = NULL;
5976 if (vam->json_output)
5979 ("JSON output supported only for VPE API calls and dump_stats_table");
5984 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5985 "Interface", "sw_if_index",
5986 "sub id", "dot1ad", "tags", "outer id",
5987 "inner id", "exact", "default", "outer any", "inner any");
5989 vec_foreach (sub, vam->sw_if_subif_table)
5992 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5993 sub->interface_name,
5995 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5996 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5997 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5998 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5999 if (sub->vtr_op != L2_VTR_DISABLED)
6002 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
6003 "tag1: %d tag2: %d ]",
6004 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
6005 sub->vtr_tag1, sub->vtr_tag2);
6013 name_sort_cmp (void *a1, void *a2)
6015 name_sort_t *n1 = a1;
6016 name_sort_t *n2 = a2;
6018 return strcmp ((char *) n1->name, (char *) n2->name);
6022 dump_interface_table (vat_main_t * vam)
6025 name_sort_t *nses = 0, *ns;
6027 if (vam->json_output)
6030 ("JSON output supported only for VPE API calls and dump_stats_table");
6035 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6037 vec_add2 (nses, ns, 1);
6038 ns->name = (u8 *)(p->key);
6039 ns->value = (u32) p->value[0];
6043 vec_sort_with_function (nses, name_sort_cmp);
6045 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
6046 vec_foreach (ns, nses)
6048 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6055 dump_ip_table (vat_main_t * vam, int is_ipv6)
6057 const ip_details_t *det = NULL;
6058 const ip_address_details_t *address = NULL;
6061 print (vam->ofp, "%-12s", "sw_if_index");
6063 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6070 print (vam->ofp, "%-12d", i);
6071 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6076 vec_foreach (address, det->addr)
6080 is_ipv6 ? format_ip6_address : format_ip4_address,
6081 address->ip, address->prefix_length);
6089 dump_ipv4_table (vat_main_t * vam)
6091 if (vam->json_output)
6094 ("JSON output supported only for VPE API calls and dump_stats_table");
6098 return dump_ip_table (vam, 0);
6102 dump_ipv6_table (vat_main_t * vam)
6104 if (vam->json_output)
6107 ("JSON output supported only for VPE API calls and dump_stats_table");
6111 return dump_ip_table (vam, 1);
6115 counter_type_to_str (u8 counter_type, u8 is_combined)
6119 switch (counter_type)
6121 case VNET_INTERFACE_COUNTER_DROP:
6123 case VNET_INTERFACE_COUNTER_PUNT:
6125 case VNET_INTERFACE_COUNTER_IP4:
6127 case VNET_INTERFACE_COUNTER_IP6:
6129 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6131 case VNET_INTERFACE_COUNTER_RX_MISS:
6133 case VNET_INTERFACE_COUNTER_RX_ERROR:
6135 case VNET_INTERFACE_COUNTER_TX_ERROR:
6138 return "INVALID-COUNTER-TYPE";
6143 switch (counter_type)
6145 case VNET_INTERFACE_COUNTER_RX:
6147 case VNET_INTERFACE_COUNTER_TX:
6150 return "INVALID-COUNTER-TYPE";
6156 dump_stats_table (vat_main_t * vam)
6158 vat_json_node_t node;
6159 vat_json_node_t *msg_array;
6160 vat_json_node_t *msg;
6161 vat_json_node_t *counter_array;
6162 vat_json_node_t *counter;
6163 interface_counter_t c;
6165 ip4_fib_counter_t *c4;
6166 ip6_fib_counter_t *c6;
6167 ip4_nbr_counter_t *n4;
6168 ip6_nbr_counter_t *n6;
6171 if (!vam->json_output)
6173 clib_warning ("dump_stats_table supported only in JSON format");
6177 vat_json_init_object (&node);
6179 /* interface counters */
6180 msg_array = vat_json_object_add (&node, "interface_counters");
6181 vat_json_init_array (msg_array);
6182 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6184 msg = vat_json_array_add (msg_array);
6185 vat_json_init_object (msg);
6186 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6187 (u8 *) counter_type_to_str (i, 0));
6188 vat_json_object_add_int (msg, "is_combined", 0);
6189 counter_array = vat_json_object_add (msg, "data");
6190 vat_json_init_array (counter_array);
6191 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6193 packets = vam->simple_interface_counters[i][j];
6194 vat_json_array_add_uint (counter_array, packets);
6197 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6199 msg = vat_json_array_add (msg_array);
6200 vat_json_init_object (msg);
6201 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6202 (u8 *) counter_type_to_str (i, 1));
6203 vat_json_object_add_int (msg, "is_combined", 1);
6204 counter_array = vat_json_object_add (msg, "data");
6205 vat_json_init_array (counter_array);
6206 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6208 c = vam->combined_interface_counters[i][j];
6209 counter = vat_json_array_add (counter_array);
6210 vat_json_init_object (counter);
6211 vat_json_object_add_uint (counter, "packets", c.packets);
6212 vat_json_object_add_uint (counter, "bytes", c.bytes);
6216 /* ip4 fib counters */
6217 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6218 vat_json_init_array (msg_array);
6219 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6221 msg = vat_json_array_add (msg_array);
6222 vat_json_init_object (msg);
6223 vat_json_object_add_uint (msg, "vrf_id",
6224 vam->ip4_fib_counters_vrf_id_by_index[i]);
6225 counter_array = vat_json_object_add (msg, "c");
6226 vat_json_init_array (counter_array);
6227 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6229 counter = vat_json_array_add (counter_array);
6230 vat_json_init_object (counter);
6231 c4 = &vam->ip4_fib_counters[i][j];
6232 vat_json_object_add_ip4 (counter, "address", c4->address);
6233 vat_json_object_add_uint (counter, "address_length",
6234 c4->address_length);
6235 vat_json_object_add_uint (counter, "packets", c4->packets);
6236 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6240 /* ip6 fib counters */
6241 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6242 vat_json_init_array (msg_array);
6243 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6245 msg = vat_json_array_add (msg_array);
6246 vat_json_init_object (msg);
6247 vat_json_object_add_uint (msg, "vrf_id",
6248 vam->ip6_fib_counters_vrf_id_by_index[i]);
6249 counter_array = vat_json_object_add (msg, "c");
6250 vat_json_init_array (counter_array);
6251 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6253 counter = vat_json_array_add (counter_array);
6254 vat_json_init_object (counter);
6255 c6 = &vam->ip6_fib_counters[i][j];
6256 vat_json_object_add_ip6 (counter, "address", c6->address);
6257 vat_json_object_add_uint (counter, "address_length",
6258 c6->address_length);
6259 vat_json_object_add_uint (counter, "packets", c6->packets);
6260 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6264 /* ip4 nbr counters */
6265 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6266 vat_json_init_array (msg_array);
6267 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6269 msg = vat_json_array_add (msg_array);
6270 vat_json_init_object (msg);
6271 vat_json_object_add_uint (msg, "sw_if_index", i);
6272 counter_array = vat_json_object_add (msg, "c");
6273 vat_json_init_array (counter_array);
6274 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6276 counter = vat_json_array_add (counter_array);
6277 vat_json_init_object (counter);
6278 n4 = &vam->ip4_nbr_counters[i][j];
6279 vat_json_object_add_ip4 (counter, "address", n4->address);
6280 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6281 vat_json_object_add_uint (counter, "packets", n4->packets);
6282 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6286 /* ip6 nbr counters */
6287 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6288 vat_json_init_array (msg_array);
6289 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6291 msg = vat_json_array_add (msg_array);
6292 vat_json_init_object (msg);
6293 vat_json_object_add_uint (msg, "sw_if_index", i);
6294 counter_array = vat_json_object_add (msg, "c");
6295 vat_json_init_array (counter_array);
6296 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6298 counter = vat_json_array_add (counter_array);
6299 vat_json_init_object (counter);
6300 n6 = &vam->ip6_nbr_counters[i][j];
6301 vat_json_object_add_ip6 (counter, "address", n6->address);
6302 vat_json_object_add_uint (counter, "packets", n6->packets);
6303 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6307 vat_json_print (vam->ofp, &node);
6308 vat_json_free (&node);
6314 * Pass CLI buffers directly in the CLI_INBAND API message,
6315 * instead of an additional shared memory area.
6318 exec_inband (vat_main_t * vam)
6320 vl_api_cli_inband_t *mp;
6321 unformat_input_t *i = vam->input;
6324 if (vec_len (i->buffer) == 0)
6327 if (vam->exec_mode == 0 && unformat (i, "mode"))
6332 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6339 * In order for the CLI command to work, it
6340 * must be a vector ending in \n, not a C-string ending
6343 u32 len = vec_len (vam->input->buffer);
6344 M2 (CLI_INBAND, mp, len);
6345 clib_memcpy (mp->cmd, vam->input->buffer, len);
6346 mp->length = htonl (len);
6350 /* json responses may or may not include a useful reply... */
6351 if (vec_len (vam->cmd_reply))
6352 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6357 exec (vat_main_t * vam)
6359 return exec_inband (vam);
6363 api_create_loopback (vat_main_t * vam)
6365 unformat_input_t *i = vam->input;
6366 vl_api_create_loopback_t *mp;
6367 vl_api_create_loopback_instance_t *mp_lbi;
6370 u8 is_specified = 0;
6371 u32 user_instance = 0;
6374 clib_memset (mac_address, 0, sizeof (mac_address));
6376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6378 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6380 if (unformat (i, "instance %d", &user_instance))
6388 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6389 mp_lbi->is_specified = is_specified;
6391 mp_lbi->user_instance = htonl (user_instance);
6393 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6398 /* Construct the API message */
6399 M (CREATE_LOOPBACK, mp);
6401 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6410 api_delete_loopback (vat_main_t * vam)
6412 unformat_input_t *i = vam->input;
6413 vl_api_delete_loopback_t *mp;
6414 u32 sw_if_index = ~0;
6417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6419 if (unformat (i, "sw_if_index %d", &sw_if_index))
6425 if (sw_if_index == ~0)
6427 errmsg ("missing sw_if_index");
6431 /* Construct the API message */
6432 M (DELETE_LOOPBACK, mp);
6433 mp->sw_if_index = ntohl (sw_if_index);
6441 api_want_stats (vat_main_t * vam)
6443 unformat_input_t *i = vam->input;
6444 vl_api_want_stats_t *mp;
6448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6450 if (unformat (i, "enable"))
6452 else if (unformat (i, "disable"))
6460 errmsg ("missing enable|disable");
6465 mp->enable_disable = enable;
6473 api_want_interface_events (vat_main_t * vam)
6475 unformat_input_t *i = vam->input;
6476 vl_api_want_interface_events_t *mp;
6480 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6482 if (unformat (i, "enable"))
6484 else if (unformat (i, "disable"))
6492 errmsg ("missing enable|disable");
6496 M (WANT_INTERFACE_EVENTS, mp);
6497 mp->enable_disable = enable;
6499 vam->interface_event_display = enable;
6507 /* Note: non-static, called once to set up the initial intfc table */
6509 api_sw_interface_dump (vat_main_t * vam)
6511 vl_api_sw_interface_dump_t *mp;
6512 vl_api_control_ping_t *mp_ping;
6514 name_sort_t *nses = 0, *ns;
6515 sw_interface_subif_t *sub = NULL;
6518 /* Toss the old name table */
6520 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6522 vec_add2 (nses, ns, 1);
6523 ns->name = (u8 *)(p->key);
6524 ns->value = (u32) p->value[0];
6528 hash_free (vam->sw_if_index_by_interface_name);
6530 vec_foreach (ns, nses) vec_free (ns->name);
6534 vec_foreach (sub, vam->sw_if_subif_table)
6536 vec_free (sub->interface_name);
6538 vec_free (vam->sw_if_subif_table);
6540 /* recreate the interface name hash table */
6541 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6544 * Ask for all interface names. Otherwise, the epic catalog of
6545 * name filters becomes ridiculously long, and vat ends up needing
6546 * to be taught about new interface types.
6548 M (SW_INTERFACE_DUMP, mp);
6551 /* Use a control ping for synchronization */
6552 MPING (CONTROL_PING, mp_ping);
6560 api_sw_interface_set_flags (vat_main_t * vam)
6562 unformat_input_t *i = vam->input;
6563 vl_api_sw_interface_set_flags_t *mp;
6565 u8 sw_if_index_set = 0;
6569 /* Parse args required to build the message */
6570 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6572 if (unformat (i, "admin-up"))
6574 else if (unformat (i, "admin-down"))
6577 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6578 sw_if_index_set = 1;
6579 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6580 sw_if_index_set = 1;
6585 if (sw_if_index_set == 0)
6587 errmsg ("missing interface name or sw_if_index");
6591 /* Construct the API message */
6592 M (SW_INTERFACE_SET_FLAGS, mp);
6593 mp->sw_if_index = ntohl (sw_if_index);
6594 mp->admin_up_down = admin_up;
6599 /* Wait for a reply, return the good/bad news... */
6605 api_sw_interface_set_rx_mode (vat_main_t * vam)
6607 unformat_input_t *i = vam->input;
6608 vl_api_sw_interface_set_rx_mode_t *mp;
6610 u8 sw_if_index_set = 0;
6612 u8 queue_id_valid = 0;
6614 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6616 /* Parse args required to build the message */
6617 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6619 if (unformat (i, "queue %d", &queue_id))
6621 else if (unformat (i, "polling"))
6622 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6623 else if (unformat (i, "interrupt"))
6624 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6625 else if (unformat (i, "adaptive"))
6626 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6628 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6629 sw_if_index_set = 1;
6630 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6631 sw_if_index_set = 1;
6636 if (sw_if_index_set == 0)
6638 errmsg ("missing interface name or sw_if_index");
6641 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6643 errmsg ("missing rx-mode");
6647 /* Construct the API message */
6648 M (SW_INTERFACE_SET_RX_MODE, mp);
6649 mp->sw_if_index = ntohl (sw_if_index);
6651 mp->queue_id_valid = queue_id_valid;
6652 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6657 /* Wait for a reply, return the good/bad news... */
6663 api_sw_interface_set_rx_placement (vat_main_t * vam)
6665 unformat_input_t *i = vam->input;
6666 vl_api_sw_interface_set_rx_placement_t *mp;
6668 u8 sw_if_index_set = 0;
6671 u32 queue_id, thread_index;
6673 /* Parse args required to build the message */
6674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6676 if (unformat (i, "queue %d", &queue_id))
6678 else if (unformat (i, "main"))
6680 else if (unformat (i, "worker %d", &thread_index))
6683 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6684 sw_if_index_set = 1;
6685 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6686 sw_if_index_set = 1;
6691 if (sw_if_index_set == 0)
6693 errmsg ("missing interface name or sw_if_index");
6699 /* Construct the API message */
6700 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6701 mp->sw_if_index = ntohl (sw_if_index);
6702 mp->worker_id = ntohl (thread_index);
6703 mp->queue_id = ntohl (queue_id);
6704 mp->is_main = is_main;
6708 /* Wait for a reply, return the good/bad news... */
6713 static void vl_api_sw_interface_rx_placement_details_t_handler
6714 (vl_api_sw_interface_rx_placement_details_t * mp)
6716 vat_main_t *vam = &vat_main;
6717 u32 worker_id = ntohl (mp->worker_id);
6720 "\n%-11d %-11s %-6d %-5d %-9s",
6721 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6722 worker_id, ntohl (mp->queue_id),
6724 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6727 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6728 (vl_api_sw_interface_rx_placement_details_t * mp)
6730 vat_main_t *vam = &vat_main;
6731 vat_json_node_t *node = NULL;
6733 if (VAT_JSON_ARRAY != vam->json_tree.type)
6735 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6736 vat_json_init_array (&vam->json_tree);
6738 node = vat_json_array_add (&vam->json_tree);
6740 vat_json_init_object (node);
6741 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6742 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6743 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6744 vat_json_object_add_uint (node, "mode", mp->mode);
6748 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6750 unformat_input_t *i = vam->input;
6751 vl_api_sw_interface_rx_placement_dump_t *mp;
6752 vl_api_control_ping_t *mp_ping;
6755 u8 sw_if_index_set = 0;
6757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6759 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6761 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6768 "\n%-11s %-11s %-6s %-5s %-4s",
6769 "sw_if_index", "main/worker", "thread", "queue", "mode");
6771 /* Dump Interface rx placement */
6772 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6774 if (sw_if_index_set)
6775 mp->sw_if_index = htonl (sw_if_index);
6777 mp->sw_if_index = ~0;
6781 /* Use a control ping for synchronization */
6782 MPING (CONTROL_PING, mp_ping);
6790 api_sw_interface_clear_stats (vat_main_t * vam)
6792 unformat_input_t *i = vam->input;
6793 vl_api_sw_interface_clear_stats_t *mp;
6795 u8 sw_if_index_set = 0;
6798 /* Parse args required to build the message */
6799 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6801 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6802 sw_if_index_set = 1;
6803 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6804 sw_if_index_set = 1;
6809 /* Construct the API message */
6810 M (SW_INTERFACE_CLEAR_STATS, mp);
6812 if (sw_if_index_set == 1)
6813 mp->sw_if_index = ntohl (sw_if_index);
6815 mp->sw_if_index = ~0;
6820 /* Wait for a reply, return the good/bad news... */
6826 api_sw_interface_add_del_address (vat_main_t * vam)
6828 unformat_input_t *i = vam->input;
6829 vl_api_sw_interface_add_del_address_t *mp;
6831 u8 sw_if_index_set = 0;
6832 u8 is_add = 1, del_all = 0;
6833 u32 address_length = 0;
6834 u8 v4_address_set = 0;
6835 u8 v6_address_set = 0;
6836 ip4_address_t v4address;
6837 ip6_address_t v6address;
6840 /* Parse args required to build the message */
6841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6843 if (unformat (i, "del-all"))
6845 else if (unformat (i, "del"))
6848 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6849 sw_if_index_set = 1;
6850 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6851 sw_if_index_set = 1;
6852 else if (unformat (i, "%U/%d",
6853 unformat_ip4_address, &v4address, &address_length))
6855 else if (unformat (i, "%U/%d",
6856 unformat_ip6_address, &v6address, &address_length))
6862 if (sw_if_index_set == 0)
6864 errmsg ("missing interface name or sw_if_index");
6867 if (v4_address_set && v6_address_set)
6869 errmsg ("both v4 and v6 addresses set");
6872 if (!v4_address_set && !v6_address_set && !del_all)
6874 errmsg ("no addresses set");
6878 /* Construct the API message */
6879 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6881 mp->sw_if_index = ntohl (sw_if_index);
6882 mp->is_add = is_add;
6883 mp->del_all = del_all;
6887 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6891 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6893 mp->address_length = address_length;
6898 /* Wait for a reply, return good/bad news */
6904 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6906 unformat_input_t *i = vam->input;
6907 vl_api_sw_interface_set_mpls_enable_t *mp;
6909 u8 sw_if_index_set = 0;
6913 /* Parse args required to build the message */
6914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6916 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6917 sw_if_index_set = 1;
6918 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6919 sw_if_index_set = 1;
6920 else if (unformat (i, "disable"))
6922 else if (unformat (i, "dis"))
6928 if (sw_if_index_set == 0)
6930 errmsg ("missing interface name or sw_if_index");
6934 /* Construct the API message */
6935 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6937 mp->sw_if_index = ntohl (sw_if_index);
6938 mp->enable = enable;
6943 /* Wait for a reply... */
6949 api_sw_interface_set_table (vat_main_t * vam)
6951 unformat_input_t *i = vam->input;
6952 vl_api_sw_interface_set_table_t *mp;
6953 u32 sw_if_index, vrf_id = 0;
6954 u8 sw_if_index_set = 0;
6958 /* Parse args required to build the message */
6959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6961 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6962 sw_if_index_set = 1;
6963 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6964 sw_if_index_set = 1;
6965 else if (unformat (i, "vrf %d", &vrf_id))
6967 else if (unformat (i, "ipv6"))
6973 if (sw_if_index_set == 0)
6975 errmsg ("missing interface name or sw_if_index");
6979 /* Construct the API message */
6980 M (SW_INTERFACE_SET_TABLE, mp);
6982 mp->sw_if_index = ntohl (sw_if_index);
6983 mp->is_ipv6 = is_ipv6;
6984 mp->vrf_id = ntohl (vrf_id);
6989 /* Wait for a reply... */
6994 static void vl_api_sw_interface_get_table_reply_t_handler
6995 (vl_api_sw_interface_get_table_reply_t * mp)
6997 vat_main_t *vam = &vat_main;
6999 print (vam->ofp, "%d", ntohl (mp->vrf_id));
7001 vam->retval = ntohl (mp->retval);
7002 vam->result_ready = 1;
7006 static void vl_api_sw_interface_get_table_reply_t_handler_json
7007 (vl_api_sw_interface_get_table_reply_t * mp)
7009 vat_main_t *vam = &vat_main;
7010 vat_json_node_t node;
7012 vat_json_init_object (&node);
7013 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
7014 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
7016 vat_json_print (vam->ofp, &node);
7017 vat_json_free (&node);
7019 vam->retval = ntohl (mp->retval);
7020 vam->result_ready = 1;
7024 api_sw_interface_get_table (vat_main_t * vam)
7026 unformat_input_t *i = vam->input;
7027 vl_api_sw_interface_get_table_t *mp;
7029 u8 sw_if_index_set = 0;
7033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7035 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7036 sw_if_index_set = 1;
7037 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7038 sw_if_index_set = 1;
7039 else if (unformat (i, "ipv6"))
7045 if (sw_if_index_set == 0)
7047 errmsg ("missing interface name or sw_if_index");
7051 M (SW_INTERFACE_GET_TABLE, mp);
7052 mp->sw_if_index = htonl (sw_if_index);
7053 mp->is_ipv6 = is_ipv6;
7061 api_sw_interface_set_vpath (vat_main_t * vam)
7063 unformat_input_t *i = vam->input;
7064 vl_api_sw_interface_set_vpath_t *mp;
7065 u32 sw_if_index = 0;
7066 u8 sw_if_index_set = 0;
7070 /* Parse args required to build the message */
7071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7073 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7074 sw_if_index_set = 1;
7075 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7076 sw_if_index_set = 1;
7077 else if (unformat (i, "enable"))
7079 else if (unformat (i, "disable"))
7085 if (sw_if_index_set == 0)
7087 errmsg ("missing interface name or sw_if_index");
7091 /* Construct the API message */
7092 M (SW_INTERFACE_SET_VPATH, mp);
7094 mp->sw_if_index = ntohl (sw_if_index);
7095 mp->enable = is_enable;
7100 /* Wait for a reply... */
7106 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
7108 unformat_input_t *i = vam->input;
7109 vl_api_sw_interface_set_vxlan_bypass_t *mp;
7110 u32 sw_if_index = 0;
7111 u8 sw_if_index_set = 0;
7116 /* Parse args required to build the message */
7117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7119 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7120 sw_if_index_set = 1;
7121 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7122 sw_if_index_set = 1;
7123 else if (unformat (i, "enable"))
7125 else if (unformat (i, "disable"))
7127 else if (unformat (i, "ip4"))
7129 else if (unformat (i, "ip6"))
7135 if (sw_if_index_set == 0)
7137 errmsg ("missing interface name or sw_if_index");
7141 /* Construct the API message */
7142 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
7144 mp->sw_if_index = ntohl (sw_if_index);
7145 mp->enable = is_enable;
7146 mp->is_ipv6 = is_ipv6;
7151 /* Wait for a reply... */
7157 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
7159 unformat_input_t *i = vam->input;
7160 vl_api_sw_interface_set_geneve_bypass_t *mp;
7161 u32 sw_if_index = 0;
7162 u8 sw_if_index_set = 0;
7167 /* Parse args required to build the message */
7168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7170 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7171 sw_if_index_set = 1;
7172 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7173 sw_if_index_set = 1;
7174 else if (unformat (i, "enable"))
7176 else if (unformat (i, "disable"))
7178 else if (unformat (i, "ip4"))
7180 else if (unformat (i, "ip6"))
7186 if (sw_if_index_set == 0)
7188 errmsg ("missing interface name or sw_if_index");
7192 /* Construct the API message */
7193 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7195 mp->sw_if_index = ntohl (sw_if_index);
7196 mp->enable = is_enable;
7197 mp->is_ipv6 = is_ipv6;
7202 /* Wait for a reply... */
7208 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7210 unformat_input_t *i = vam->input;
7211 vl_api_sw_interface_set_l2_xconnect_t *mp;
7213 u8 rx_sw_if_index_set = 0;
7215 u8 tx_sw_if_index_set = 0;
7219 /* Parse args required to build the message */
7220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7222 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7223 rx_sw_if_index_set = 1;
7224 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7225 tx_sw_if_index_set = 1;
7226 else if (unformat (i, "rx"))
7228 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7230 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7232 rx_sw_if_index_set = 1;
7237 else if (unformat (i, "tx"))
7239 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7241 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7243 tx_sw_if_index_set = 1;
7248 else if (unformat (i, "enable"))
7250 else if (unformat (i, "disable"))
7256 if (rx_sw_if_index_set == 0)
7258 errmsg ("missing rx interface name or rx_sw_if_index");
7262 if (enable && (tx_sw_if_index_set == 0))
7264 errmsg ("missing tx interface name or tx_sw_if_index");
7268 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7270 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7271 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7272 mp->enable = enable;
7280 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7282 unformat_input_t *i = vam->input;
7283 vl_api_sw_interface_set_l2_bridge_t *mp;
7284 vl_api_l2_port_type_t port_type;
7286 u8 rx_sw_if_index_set = 0;
7293 port_type = L2_API_PORT_TYPE_NORMAL;
7295 /* Parse args required to build the message */
7296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7298 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7299 rx_sw_if_index_set = 1;
7300 else if (unformat (i, "bd_id %d", &bd_id))
7304 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7305 rx_sw_if_index_set = 1;
7306 else if (unformat (i, "shg %d", &shg))
7308 else if (unformat (i, "bvi"))
7309 port_type = L2_API_PORT_TYPE_BVI;
7310 else if (unformat (i, "uu-fwd"))
7311 port_type = L2_API_PORT_TYPE_UU_FWD;
7312 else if (unformat (i, "enable"))
7314 else if (unformat (i, "disable"))
7320 if (rx_sw_if_index_set == 0)
7322 errmsg ("missing rx interface name or sw_if_index");
7326 if (enable && (bd_id_set == 0))
7328 errmsg ("missing bridge domain");
7332 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7334 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7335 mp->bd_id = ntohl (bd_id);
7337 mp->port_type = ntohl (port_type);
7338 mp->enable = enable;
7346 api_bridge_domain_dump (vat_main_t * vam)
7348 unformat_input_t *i = vam->input;
7349 vl_api_bridge_domain_dump_t *mp;
7350 vl_api_control_ping_t *mp_ping;
7354 /* Parse args required to build the message */
7355 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7357 if (unformat (i, "bd_id %d", &bd_id))
7363 M (BRIDGE_DOMAIN_DUMP, mp);
7364 mp->bd_id = ntohl (bd_id);
7367 /* Use a control ping for synchronization */
7368 MPING (CONTROL_PING, mp_ping);
7376 api_bridge_domain_add_del (vat_main_t * vam)
7378 unformat_input_t *i = vam->input;
7379 vl_api_bridge_domain_add_del_t *mp;
7382 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7387 /* Parse args required to build the message */
7388 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7390 if (unformat (i, "bd_id %d", &bd_id))
7392 else if (unformat (i, "flood %d", &flood))
7394 else if (unformat (i, "uu-flood %d", &uu_flood))
7396 else if (unformat (i, "forward %d", &forward))
7398 else if (unformat (i, "learn %d", &learn))
7400 else if (unformat (i, "arp-term %d", &arp_term))
7402 else if (unformat (i, "mac-age %d", &mac_age))
7404 else if (unformat (i, "bd-tag %s", &bd_tag))
7406 else if (unformat (i, "del"))
7409 flood = uu_flood = forward = learn = 0;
7417 errmsg ("missing bridge domain");
7424 errmsg ("mac age must be less than 256 ");
7429 if ((bd_tag) && (vec_len (bd_tag) > 63))
7431 errmsg ("bd-tag cannot be longer than 63");
7436 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7438 mp->bd_id = ntohl (bd_id);
7440 mp->uu_flood = uu_flood;
7441 mp->forward = forward;
7443 mp->arp_term = arp_term;
7444 mp->is_add = is_add;
7445 mp->mac_age = (u8) mac_age;
7448 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7449 mp->bd_tag[vec_len (bd_tag)] = 0;
7460 api_l2fib_flush_bd (vat_main_t * vam)
7462 unformat_input_t *i = vam->input;
7463 vl_api_l2fib_flush_bd_t *mp;
7467 /* Parse args required to build the message */
7468 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7470 if (unformat (i, "bd_id %d", &bd_id));
7477 errmsg ("missing bridge domain");
7481 M (L2FIB_FLUSH_BD, mp);
7483 mp->bd_id = htonl (bd_id);
7491 api_l2fib_flush_int (vat_main_t * vam)
7493 unformat_input_t *i = vam->input;
7494 vl_api_l2fib_flush_int_t *mp;
7495 u32 sw_if_index = ~0;
7498 /* Parse args required to build the message */
7499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7501 if (unformat (i, "sw_if_index %d", &sw_if_index));
7503 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7508 if (sw_if_index == ~0)
7510 errmsg ("missing interface name or sw_if_index");
7514 M (L2FIB_FLUSH_INT, mp);
7516 mp->sw_if_index = ntohl (sw_if_index);
7524 api_l2fib_add_del (vat_main_t * vam)
7526 unformat_input_t *i = vam->input;
7527 vl_api_l2fib_add_del_t *mp;
7533 u32 sw_if_index = 0;
7534 u8 sw_if_index_set = 0;
7543 /* Parse args required to build the message */
7544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7546 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7548 else if (unformat (i, "bd_id %d", &bd_id))
7550 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7551 sw_if_index_set = 1;
7552 else if (unformat (i, "sw_if"))
7554 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7557 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7558 sw_if_index_set = 1;
7563 else if (unformat (i, "static"))
7565 else if (unformat (i, "filter"))
7570 else if (unformat (i, "bvi"))
7575 else if (unformat (i, "del"))
7577 else if (unformat (i, "count %d", &count))
7585 errmsg ("missing mac address");
7591 errmsg ("missing bridge domain");
7595 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7597 errmsg ("missing interface name or sw_if_index");
7603 /* Turn on async mode */
7604 vam->async_mode = 1;
7605 vam->async_errors = 0;
7606 before = vat_time_now (vam);
7609 for (j = 0; j < count; j++)
7611 M (L2FIB_ADD_DEL, mp);
7613 clib_memcpy (mp->mac, mac, 6);
7614 mp->bd_id = ntohl (bd_id);
7615 mp->is_add = is_add;
7616 mp->sw_if_index = ntohl (sw_if_index);
7620 mp->static_mac = static_mac;
7621 mp->filter_mac = filter_mac;
7622 mp->bvi_mac = bvi_mac;
7624 increment_mac_address (mac);
7631 vl_api_control_ping_t *mp_ping;
7634 /* Shut off async mode */
7635 vam->async_mode = 0;
7637 MPING (CONTROL_PING, mp_ping);
7640 timeout = vat_time_now (vam) + 1.0;
7641 while (vat_time_now (vam) < timeout)
7642 if (vam->result_ready == 1)
7647 if (vam->retval == -99)
7650 if (vam->async_errors > 0)
7652 errmsg ("%d asynchronous errors", vam->async_errors);
7655 vam->async_errors = 0;
7656 after = vat_time_now (vam);
7658 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7659 count, after - before, count / (after - before));
7665 /* Wait for a reply... */
7669 /* Return the good/bad news */
7670 return (vam->retval);
7674 api_bridge_domain_set_mac_age (vat_main_t * vam)
7676 unformat_input_t *i = vam->input;
7677 vl_api_bridge_domain_set_mac_age_t *mp;
7682 /* Parse args required to build the message */
7683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7685 if (unformat (i, "bd_id %d", &bd_id));
7686 else if (unformat (i, "mac-age %d", &mac_age));
7693 errmsg ("missing bridge domain");
7699 errmsg ("mac age must be less than 256 ");
7703 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7705 mp->bd_id = htonl (bd_id);
7706 mp->mac_age = (u8) mac_age;
7714 api_l2_flags (vat_main_t * vam)
7716 unformat_input_t *i = vam->input;
7717 vl_api_l2_flags_t *mp;
7720 u8 sw_if_index_set = 0;
7724 /* Parse args required to build the message */
7725 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7727 if (unformat (i, "sw_if_index %d", &sw_if_index))
7728 sw_if_index_set = 1;
7729 else if (unformat (i, "sw_if"))
7731 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7734 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7735 sw_if_index_set = 1;
7740 else if (unformat (i, "learn"))
7742 else if (unformat (i, "forward"))
7744 else if (unformat (i, "flood"))
7746 else if (unformat (i, "uu-flood"))
7747 flags |= L2_UU_FLOOD;
7748 else if (unformat (i, "arp-term"))
7749 flags |= L2_ARP_TERM;
7750 else if (unformat (i, "off"))
7752 else if (unformat (i, "disable"))
7758 if (sw_if_index_set == 0)
7760 errmsg ("missing interface name or sw_if_index");
7766 mp->sw_if_index = ntohl (sw_if_index);
7767 mp->feature_bitmap = ntohl (flags);
7768 mp->is_set = is_set;
7776 api_bridge_flags (vat_main_t * vam)
7778 unformat_input_t *i = vam->input;
7779 vl_api_bridge_flags_t *mp;
7783 bd_flags_t flags = 0;
7786 /* Parse args required to build the message */
7787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7789 if (unformat (i, "bd_id %d", &bd_id))
7791 else if (unformat (i, "learn"))
7792 flags |= BRIDGE_API_FLAG_LEARN;
7793 else if (unformat (i, "forward"))
7794 flags |= BRIDGE_API_FLAG_FWD;
7795 else if (unformat (i, "flood"))
7796 flags |= BRIDGE_API_FLAG_FLOOD;
7797 else if (unformat (i, "uu-flood"))
7798 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7799 else if (unformat (i, "arp-term"))
7800 flags |= BRIDGE_API_FLAG_ARP_TERM;
7801 else if (unformat (i, "off"))
7803 else if (unformat (i, "disable"))
7811 errmsg ("missing bridge domain");
7815 M (BRIDGE_FLAGS, mp);
7817 mp->bd_id = ntohl (bd_id);
7818 mp->flags = ntohl (flags);
7819 mp->is_set = is_set;
7827 api_bd_ip_mac_add_del (vat_main_t * vam)
7829 unformat_input_t *i = vam->input;
7830 vl_api_bd_ip_mac_add_del_t *mp;
7837 ip4_address_t v4addr;
7838 ip6_address_t v6addr;
7843 /* Parse args required to build the message */
7844 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7846 if (unformat (i, "bd_id %d", &bd_id))
7850 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7854 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7859 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7863 else if (unformat (i, "del"))
7871 errmsg ("missing bridge domain");
7874 else if (ip_set == 0)
7876 errmsg ("missing IP address");
7879 else if (mac_set == 0)
7881 errmsg ("missing MAC address");
7885 M (BD_IP_MAC_ADD_DEL, mp);
7887 mp->bd_id = ntohl (bd_id);
7888 mp->is_ipv6 = is_ipv6;
7889 mp->is_add = is_add;
7891 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7893 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7894 clib_memcpy (mp->mac_address, macaddr, 6);
7900 static void vl_api_bd_ip_mac_details_t_handler
7901 (vl_api_bd_ip_mac_details_t * mp)
7903 vat_main_t *vam = &vat_main;
7908 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7911 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7914 "\n%-5d %-7s %-20U %-30s",
7915 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7916 format_ethernet_address, mp->mac_address, ip);
7921 static void vl_api_bd_ip_mac_details_t_handler_json
7922 (vl_api_bd_ip_mac_details_t * mp)
7924 vat_main_t *vam = &vat_main;
7925 vat_json_node_t *node = NULL;
7927 if (VAT_JSON_ARRAY != vam->json_tree.type)
7929 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7930 vat_json_init_array (&vam->json_tree);
7932 node = vat_json_array_add (&vam->json_tree);
7934 vat_json_init_object (node);
7935 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7936 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7937 vat_json_object_add_string_copy (node, "mac_address",
7938 format (0, "%U", format_ethernet_address,
7944 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7947 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7948 vat_json_object_add_string_copy (node, "ip_address", ip);
7953 api_bd_ip_mac_dump (vat_main_t * vam)
7955 unformat_input_t *i = vam->input;
7956 vl_api_bd_ip_mac_dump_t *mp;
7957 vl_api_control_ping_t *mp_ping;
7962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7964 if (unformat (i, "bd_id %d", &bd_id))
7973 "\n%-5s %-7s %-20s %-30s",
7974 "bd_id", "is_ipv6", "mac_address", "ip_address");
7976 /* Dump Bridge Domain Ip to Mac entries */
7977 M (BD_IP_MAC_DUMP, mp);
7980 mp->bd_id = htonl (bd_id);
7986 /* Use a control ping for synchronization */
7987 MPING (CONTROL_PING, mp_ping);
7995 api_tap_connect (vat_main_t * vam)
7997 unformat_input_t *i = vam->input;
7998 vl_api_tap_connect_t *mp;
8004 ip4_address_t ip4_address;
8006 int ip4_address_set = 0;
8007 ip6_address_t ip6_address;
8009 int ip6_address_set = 0;
8012 clib_memset (mac_address, 0, sizeof (mac_address));
8014 /* Parse args required to build the message */
8015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8017 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8021 else if (unformat (i, "random-mac"))
8023 else if (unformat (i, "tapname %s", &tap_name))
8025 else if (unformat (i, "tag %s", &tag))
8027 else if (unformat (i, "address %U/%d",
8028 unformat_ip4_address, &ip4_address, &ip4_mask_width))
8029 ip4_address_set = 1;
8030 else if (unformat (i, "address %U/%d",
8031 unformat_ip6_address, &ip6_address, &ip6_mask_width))
8032 ip6_address_set = 1;
8039 errmsg ("missing tap name");
8042 if (vec_len (tap_name) > 63)
8044 errmsg ("tap name too long");
8047 vec_add1 (tap_name, 0);
8049 if (vec_len (tag) > 63)
8051 errmsg ("tag too long");
8055 /* Construct the API message */
8056 M (TAP_CONNECT, mp);
8058 mp->use_random_mac = random_mac;
8059 clib_memcpy (mp->mac_address, mac_address, 6);
8060 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8062 clib_memcpy (mp->tag, tag, vec_len (tag));
8064 if (ip4_address_set)
8066 mp->ip4_address_set = 1;
8067 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
8068 mp->ip4_mask_width = ip4_mask_width;
8070 if (ip6_address_set)
8072 mp->ip6_address_set = 1;
8073 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
8074 mp->ip6_mask_width = ip6_mask_width;
8077 vec_free (tap_name);
8083 /* Wait for a reply... */
8089 api_tap_modify (vat_main_t * vam)
8091 unformat_input_t *i = vam->input;
8092 vl_api_tap_modify_t *mp;
8097 u32 sw_if_index = ~0;
8098 u8 sw_if_index_set = 0;
8101 clib_memset (mac_address, 0, sizeof (mac_address));
8103 /* Parse args required to build the message */
8104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8106 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8107 sw_if_index_set = 1;
8108 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8109 sw_if_index_set = 1;
8110 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8114 else if (unformat (i, "random-mac"))
8116 else if (unformat (i, "tapname %s", &tap_name))
8122 if (sw_if_index_set == 0)
8124 errmsg ("missing vpp interface name");
8129 errmsg ("missing tap name");
8132 if (vec_len (tap_name) > 63)
8134 errmsg ("tap name too long");
8136 vec_add1 (tap_name, 0);
8138 /* Construct the API message */
8141 mp->use_random_mac = random_mac;
8142 mp->sw_if_index = ntohl (sw_if_index);
8143 clib_memcpy (mp->mac_address, mac_address, 6);
8144 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8145 vec_free (tap_name);
8150 /* Wait for a reply... */
8156 api_tap_delete (vat_main_t * vam)
8158 unformat_input_t *i = vam->input;
8159 vl_api_tap_delete_t *mp;
8160 u32 sw_if_index = ~0;
8161 u8 sw_if_index_set = 0;
8164 /* Parse args required to build the message */
8165 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8167 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8168 sw_if_index_set = 1;
8169 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8170 sw_if_index_set = 1;
8175 if (sw_if_index_set == 0)
8177 errmsg ("missing vpp interface name");
8181 /* Construct the API message */
8184 mp->sw_if_index = ntohl (sw_if_index);
8189 /* Wait for a reply... */
8195 api_tap_create_v2 (vat_main_t * vam)
8197 unformat_input_t *i = vam->input;
8198 vl_api_tap_create_v2_t *mp;
8202 u8 *host_if_name = 0;
8204 u8 host_mac_addr[6];
8205 u8 host_mac_addr_set = 0;
8206 u8 *host_bridge = 0;
8207 ip4_address_t host_ip4_addr;
8208 ip4_address_t host_ip4_gw;
8209 u8 host_ip4_gw_set = 0;
8210 u32 host_ip4_prefix_len = 0;
8211 ip6_address_t host_ip6_addr;
8212 ip6_address_t host_ip6_gw;
8213 u8 host_ip6_gw_set = 0;
8214 u32 host_ip6_prefix_len = 0;
8216 u32 rx_ring_sz = 0, tx_ring_sz = 0;
8218 clib_memset (mac_address, 0, sizeof (mac_address));
8220 /* Parse args required to build the message */
8221 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8223 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8227 else if (unformat (i, "id %u", &id))
8229 else if (unformat (i, "host-if-name %s", &host_if_name))
8231 else if (unformat (i, "host-ns %s", &host_ns))
8233 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8235 host_mac_addr_set = 1;
8236 else if (unformat (i, "host-bridge %s", &host_bridge))
8238 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8239 &host_ip4_addr, &host_ip4_prefix_len))
8241 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8242 &host_ip6_addr, &host_ip6_prefix_len))
8244 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8246 host_ip4_gw_set = 1;
8247 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8249 host_ip6_gw_set = 1;
8250 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8252 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8258 if (vec_len (host_if_name) > 63)
8260 errmsg ("tap name too long. ");
8263 if (vec_len (host_ns) > 63)
8265 errmsg ("host name space too long. ");
8268 if (vec_len (host_bridge) > 63)
8270 errmsg ("host bridge name too long. ");
8273 if (host_ip4_prefix_len > 32)
8275 errmsg ("host ip4 prefix length not valid. ");
8278 if (host_ip6_prefix_len > 128)
8280 errmsg ("host ip6 prefix length not valid. ");
8283 if (!is_pow2 (rx_ring_sz))
8285 errmsg ("rx ring size must be power of 2. ");
8288 if (rx_ring_sz > 32768)
8290 errmsg ("rx ring size must be 32768 or lower. ");
8293 if (!is_pow2 (tx_ring_sz))
8295 errmsg ("tx ring size must be power of 2. ");
8298 if (tx_ring_sz > 32768)
8300 errmsg ("tx ring size must be 32768 or lower. ");
8304 /* Construct the API message */
8305 M (TAP_CREATE_V2, mp);
8307 mp->use_random_mac = random_mac;
8309 mp->id = ntohl (id);
8310 mp->host_namespace_set = host_ns != 0;
8311 mp->host_bridge_set = host_bridge != 0;
8312 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8313 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8314 mp->rx_ring_sz = ntohs (rx_ring_sz);
8315 mp->tx_ring_sz = ntohs (tx_ring_sz);
8317 if (random_mac == 0)
8318 clib_memcpy (mp->mac_address, mac_address, 6);
8319 if (host_mac_addr_set)
8320 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8322 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8324 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8326 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8327 if (host_ip4_prefix_len)
8328 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8329 if (host_ip6_prefix_len)
8330 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8331 if (host_ip4_gw_set)
8332 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8333 if (host_ip6_gw_set)
8334 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8337 vec_free (host_if_name);
8338 vec_free (host_bridge);
8343 /* Wait for a reply... */
8349 api_tap_delete_v2 (vat_main_t * vam)
8351 unformat_input_t *i = vam->input;
8352 vl_api_tap_delete_v2_t *mp;
8353 u32 sw_if_index = ~0;
8354 u8 sw_if_index_set = 0;
8357 /* Parse args required to build the message */
8358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8360 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8361 sw_if_index_set = 1;
8362 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8363 sw_if_index_set = 1;
8368 if (sw_if_index_set == 0)
8370 errmsg ("missing vpp interface name. ");
8374 /* Construct the API message */
8375 M (TAP_DELETE_V2, mp);
8377 mp->sw_if_index = ntohl (sw_if_index);
8382 /* Wait for a reply... */
8388 api_bond_create (vat_main_t * vam)
8390 unformat_input_t *i = vam->input;
8391 vl_api_bond_create_t *mp;
8399 clib_memset (mac_address, 0, sizeof (mac_address));
8402 /* Parse args required to build the message */
8403 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8405 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8407 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8408 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8410 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8417 if (mode_is_set == 0)
8419 errmsg ("Missing bond mode. ");
8423 /* Construct the API message */
8424 M (BOND_CREATE, mp);
8426 mp->use_custom_mac = custom_mac;
8432 clib_memcpy (mp->mac_address, mac_address, 6);
8437 /* Wait for a reply... */
8443 api_bond_delete (vat_main_t * vam)
8445 unformat_input_t *i = vam->input;
8446 vl_api_bond_delete_t *mp;
8447 u32 sw_if_index = ~0;
8448 u8 sw_if_index_set = 0;
8451 /* Parse args required to build the message */
8452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8454 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8455 sw_if_index_set = 1;
8456 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8457 sw_if_index_set = 1;
8462 if (sw_if_index_set == 0)
8464 errmsg ("missing vpp interface name. ");
8468 /* Construct the API message */
8469 M (BOND_DELETE, mp);
8471 mp->sw_if_index = ntohl (sw_if_index);
8476 /* Wait for a reply... */
8482 api_bond_enslave (vat_main_t * vam)
8484 unformat_input_t *i = vam->input;
8485 vl_api_bond_enslave_t *mp;
8486 u32 bond_sw_if_index;
8490 u32 bond_sw_if_index_is_set = 0;
8492 u8 sw_if_index_is_set = 0;
8494 /* Parse args required to build the message */
8495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8497 if (unformat (i, "sw_if_index %d", &sw_if_index))
8498 sw_if_index_is_set = 1;
8499 else if (unformat (i, "bond %u", &bond_sw_if_index))
8500 bond_sw_if_index_is_set = 1;
8501 else if (unformat (i, "passive %d", &is_passive))
8503 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8509 if (bond_sw_if_index_is_set == 0)
8511 errmsg ("Missing bond sw_if_index. ");
8514 if (sw_if_index_is_set == 0)
8516 errmsg ("Missing slave sw_if_index. ");
8520 /* Construct the API message */
8521 M (BOND_ENSLAVE, mp);
8523 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8524 mp->sw_if_index = ntohl (sw_if_index);
8525 mp->is_long_timeout = is_long_timeout;
8526 mp->is_passive = is_passive;
8531 /* Wait for a reply... */
8537 api_bond_detach_slave (vat_main_t * vam)
8539 unformat_input_t *i = vam->input;
8540 vl_api_bond_detach_slave_t *mp;
8541 u32 sw_if_index = ~0;
8542 u8 sw_if_index_set = 0;
8545 /* Parse args required to build the message */
8546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8548 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8549 sw_if_index_set = 1;
8550 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8551 sw_if_index_set = 1;
8556 if (sw_if_index_set == 0)
8558 errmsg ("missing vpp interface name. ");
8562 /* Construct the API message */
8563 M (BOND_DETACH_SLAVE, mp);
8565 mp->sw_if_index = ntohl (sw_if_index);
8570 /* Wait for a reply... */
8576 api_ip_table_add_del (vat_main_t * vam)
8578 unformat_input_t *i = vam->input;
8579 vl_api_ip_table_add_del_t *mp;
8585 /* Parse args required to build the message */
8586 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8588 if (unformat (i, "ipv6"))
8590 else if (unformat (i, "del"))
8592 else if (unformat (i, "add"))
8594 else if (unformat (i, "table %d", &table_id))
8598 clib_warning ("parse error '%U'", format_unformat_error, i);
8605 errmsg ("missing table-ID");
8609 /* Construct the API message */
8610 M (IP_TABLE_ADD_DEL, mp);
8612 mp->table_id = ntohl (table_id);
8613 mp->is_ipv6 = is_ipv6;
8614 mp->is_add = is_add;
8619 /* Wait for a reply... */
8626 api_ip_add_del_route (vat_main_t * vam)
8628 unformat_input_t *i = vam->input;
8629 vl_api_ip_add_del_route_t *mp;
8630 u32 sw_if_index = ~0, vrf_id = 0;
8632 u8 is_local = 0, is_drop = 0;
8633 u8 is_unreach = 0, is_prohibit = 0;
8635 u32 next_hop_weight = 1;
8636 u8 is_multipath = 0;
8638 u8 address_length_set = 0;
8639 u32 next_hop_table_id = 0;
8640 u32 resolve_attempts = 0;
8641 u32 dst_address_length = 0;
8642 u8 next_hop_set = 0;
8643 ip4_address_t v4_dst_address, v4_next_hop_address;
8644 ip6_address_t v6_dst_address, v6_next_hop_address;
8648 u32 random_add_del = 0;
8649 u32 *random_vector = 0;
8651 u32 random_seed = 0xdeaddabe;
8652 u32 classify_table_index = ~0;
8654 u8 resolve_host = 0, resolve_attached = 0;
8655 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8656 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8657 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8659 clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8660 clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8661 /* Parse args required to build the message */
8662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8664 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8666 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8668 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8673 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8678 else if (unformat (i, "/%d", &dst_address_length))
8680 address_length_set = 1;
8683 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8684 &v4_next_hop_address))
8688 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8689 &v6_next_hop_address))
8695 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8699 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8703 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8705 else if (unformat (i, "weight %d", &next_hop_weight))
8707 else if (unformat (i, "drop"))
8711 else if (unformat (i, "null-send-unreach"))
8715 else if (unformat (i, "null-send-prohibit"))
8719 else if (unformat (i, "local"))
8723 else if (unformat (i, "classify %d", &classify_table_index))
8727 else if (unformat (i, "del"))
8729 else if (unformat (i, "add"))
8731 else if (unformat (i, "resolve-via-host"))
8733 else if (unformat (i, "resolve-via-attached"))
8734 resolve_attached = 1;
8735 else if (unformat (i, "multipath"))
8737 else if (unformat (i, "vrf %d", &vrf_id))
8739 else if (unformat (i, "count %d", &count))
8741 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8743 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8745 else if (unformat (i, "out-label %d", &next_hop_out_label))
8747 vl_api_fib_mpls_label_t fib_label = {
8748 .label = ntohl (next_hop_out_label),
8752 vec_add1 (next_hop_out_label_stack, fib_label);
8754 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8756 else if (unformat (i, "random"))
8758 else if (unformat (i, "seed %d", &random_seed))
8762 clib_warning ("parse error '%U'", format_unformat_error, i);
8767 if (!next_hop_set && !is_drop && !is_local &&
8768 !is_classify && !is_unreach && !is_prohibit &&
8769 MPLS_LABEL_INVALID == next_hop_via_label)
8772 ("next hop / local / drop / unreach / prohibit / classify not set");
8776 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8778 errmsg ("next hop and next-hop via label set");
8781 if (address_set == 0)
8783 errmsg ("missing addresses");
8787 if (address_length_set == 0)
8789 errmsg ("missing address length");
8793 /* Generate a pile of unique, random routes */
8796 u32 this_random_address;
8797 random_hash = hash_create (count, sizeof (uword));
8799 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8800 for (j = 0; j <= count; j++)
8804 this_random_address = random_u32 (&random_seed);
8805 this_random_address =
8806 clib_host_to_net_u32 (this_random_address);
8808 while (hash_get (random_hash, this_random_address));
8809 vec_add1 (random_vector, this_random_address);
8810 hash_set (random_hash, this_random_address, 1);
8812 hash_free (random_hash);
8813 v4_dst_address.as_u32 = random_vector[0];
8818 /* Turn on async mode */
8819 vam->async_mode = 1;
8820 vam->async_errors = 0;
8821 before = vat_time_now (vam);
8824 for (j = 0; j < count; j++)
8826 /* Construct the API message */
8827 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8828 vec_len (next_hop_out_label_stack));
8830 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8831 mp->table_id = ntohl (vrf_id);
8833 mp->is_add = is_add;
8834 mp->is_drop = is_drop;
8835 mp->is_unreach = is_unreach;
8836 mp->is_prohibit = is_prohibit;
8837 mp->is_ipv6 = is_ipv6;
8838 mp->is_local = is_local;
8839 mp->is_classify = is_classify;
8840 mp->is_multipath = is_multipath;
8841 mp->is_resolve_host = resolve_host;
8842 mp->is_resolve_attached = resolve_attached;
8843 mp->next_hop_weight = next_hop_weight;
8844 mp->next_hop_preference = 0;
8845 mp->dst_address_length = dst_address_length;
8846 mp->next_hop_table_id = ntohl (next_hop_table_id);
8847 mp->classify_table_index = ntohl (classify_table_index);
8848 mp->next_hop_via_label = ntohl (next_hop_via_label);
8849 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8850 if (0 != mp->next_hop_n_out_labels)
8852 memcpy (mp->next_hop_out_label_stack,
8853 next_hop_out_label_stack,
8854 (vec_len (next_hop_out_label_stack) *
8855 sizeof (vl_api_fib_mpls_label_t)));
8856 vec_free (next_hop_out_label_stack);
8861 clib_memcpy (mp->dst_address, &v6_dst_address,
8862 sizeof (v6_dst_address));
8864 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8865 sizeof (v6_next_hop_address));
8866 increment_v6_address (&v6_dst_address);
8870 clib_memcpy (mp->dst_address, &v4_dst_address,
8871 sizeof (v4_dst_address));
8873 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8874 sizeof (v4_next_hop_address));
8876 v4_dst_address.as_u32 = random_vector[j + 1];
8878 increment_v4_address (&v4_dst_address);
8882 /* If we receive SIGTERM, stop now... */
8887 /* When testing multiple add/del ops, use a control-ping to sync */
8890 vl_api_control_ping_t *mp_ping;
8894 /* Shut off async mode */
8895 vam->async_mode = 0;
8897 MPING (CONTROL_PING, mp_ping);
8900 timeout = vat_time_now (vam) + 1.0;
8901 while (vat_time_now (vam) < timeout)
8902 if (vam->result_ready == 1)
8907 if (vam->retval == -99)
8910 if (vam->async_errors > 0)
8912 errmsg ("%d asynchronous errors", vam->async_errors);
8915 vam->async_errors = 0;
8916 after = vat_time_now (vam);
8918 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8922 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8923 count, after - before, count / (after - before));
8929 /* Wait for a reply... */
8934 /* Return the good/bad news */
8935 return (vam->retval);
8939 api_ip_mroute_add_del (vat_main_t * vam)
8941 unformat_input_t *i = vam->input;
8942 vl_api_ip_mroute_add_del_t *mp;
8943 u32 sw_if_index = ~0, vrf_id = 0;
8948 u32 grp_address_length = 0;
8949 ip4_address_t v4_grp_address, v4_src_address;
8950 ip6_address_t v6_grp_address, v6_src_address;
8951 mfib_itf_flags_t iflags = 0;
8952 mfib_entry_flags_t eflags = 0;
8955 /* Parse args required to build the message */
8956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8958 if (unformat (i, "sw_if_index %d", &sw_if_index))
8960 else if (unformat (i, "%U %U",
8961 unformat_ip4_address, &v4_src_address,
8962 unformat_ip4_address, &v4_grp_address))
8964 grp_address_length = 64;
8968 else if (unformat (i, "%U %U",
8969 unformat_ip6_address, &v6_src_address,
8970 unformat_ip6_address, &v6_grp_address))
8972 grp_address_length = 256;
8976 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8978 clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
8979 grp_address_length = 32;
8983 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8985 clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
8986 grp_address_length = 128;
8990 else if (unformat (i, "/%d", &grp_address_length))
8992 else if (unformat (i, "local"))
8996 else if (unformat (i, "del"))
8998 else if (unformat (i, "add"))
9000 else if (unformat (i, "vrf %d", &vrf_id))
9002 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
9004 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
9008 clib_warning ("parse error '%U'", format_unformat_error, i);
9013 if (address_set == 0)
9015 errmsg ("missing addresses\n");
9019 /* Construct the API message */
9020 M (IP_MROUTE_ADD_DEL, mp);
9022 mp->next_hop_sw_if_index = ntohl (sw_if_index);
9023 mp->table_id = ntohl (vrf_id);
9025 mp->is_add = is_add;
9026 mp->is_ipv6 = is_ipv6;
9027 mp->is_local = is_local;
9028 mp->itf_flags = ntohl (iflags);
9029 mp->entry_flags = ntohl (eflags);
9030 mp->grp_address_length = grp_address_length;
9031 mp->grp_address_length = ntohs (mp->grp_address_length);
9035 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
9036 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
9040 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
9041 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
9047 /* Wait for a reply... */
9053 api_mpls_table_add_del (vat_main_t * vam)
9055 unformat_input_t *i = vam->input;
9056 vl_api_mpls_table_add_del_t *mp;
9061 /* Parse args required to build the message */
9062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9064 if (unformat (i, "table %d", &table_id))
9066 else if (unformat (i, "del"))
9068 else if (unformat (i, "add"))
9072 clib_warning ("parse error '%U'", format_unformat_error, i);
9079 errmsg ("missing table-ID");
9083 /* Construct the API message */
9084 M (MPLS_TABLE_ADD_DEL, mp);
9086 mp->mt_table_id = ntohl (table_id);
9087 mp->mt_is_add = is_add;
9092 /* Wait for a reply... */
9099 api_mpls_route_add_del (vat_main_t * vam)
9101 unformat_input_t *i = vam->input;
9102 vl_api_mpls_route_add_del_t *mp;
9103 u32 sw_if_index = ~0, table_id = 0;
9105 u32 next_hop_weight = 1;
9106 u8 is_multipath = 0;
9107 u32 next_hop_table_id = 0;
9108 u8 next_hop_set = 0;
9109 ip4_address_t v4_next_hop_address = {
9112 ip6_address_t v6_next_hop_address = { {0} };
9116 u32 classify_table_index = ~0;
9118 u8 resolve_host = 0, resolve_attached = 0;
9119 u8 is_interface_rx = 0;
9120 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9121 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9122 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9123 mpls_label_t local_label = MPLS_LABEL_INVALID;
9125 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
9127 /* Parse args required to build the message */
9128 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9130 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9132 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9134 else if (unformat (i, "%d", &local_label))
9136 else if (unformat (i, "eos"))
9138 else if (unformat (i, "non-eos"))
9140 else if (unformat (i, "via %U", unformat_ip4_address,
9141 &v4_next_hop_address))
9144 next_hop_proto = DPO_PROTO_IP4;
9146 else if (unformat (i, "via %U", unformat_ip6_address,
9147 &v6_next_hop_address))
9150 next_hop_proto = DPO_PROTO_IP6;
9152 else if (unformat (i, "weight %d", &next_hop_weight))
9154 else if (unformat (i, "classify %d", &classify_table_index))
9158 else if (unformat (i, "del"))
9160 else if (unformat (i, "add"))
9162 else if (unformat (i, "resolve-via-host"))
9164 else if (unformat (i, "resolve-via-attached"))
9165 resolve_attached = 1;
9166 else if (unformat (i, "multipath"))
9168 else if (unformat (i, "count %d", &count))
9170 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
9173 next_hop_proto = DPO_PROTO_IP4;
9175 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
9178 next_hop_proto = DPO_PROTO_IP6;
9182 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
9186 next_hop_proto = DPO_PROTO_ETHERNET;
9187 is_interface_rx = 1;
9189 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
9192 next_hop_proto = DPO_PROTO_ETHERNET;
9193 is_interface_rx = 1;
9195 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
9197 else if (unformat (i, "via via-label %d", &next_hop_via_label))
9199 else if (unformat (i, "out-label %d", &next_hop_out_label))
9201 vl_api_fib_mpls_label_t fib_label = {
9202 .label = ntohl (next_hop_out_label),
9206 vec_add1 (next_hop_out_label_stack, fib_label);
9210 clib_warning ("parse error '%U'", format_unformat_error, i);
9215 if (!next_hop_set && !is_classify)
9217 errmsg ("next hop / classify not set");
9221 if (MPLS_LABEL_INVALID == local_label)
9223 errmsg ("missing label");
9229 /* Turn on async mode */
9230 vam->async_mode = 1;
9231 vam->async_errors = 0;
9232 before = vat_time_now (vam);
9235 for (j = 0; j < count; j++)
9237 /* Construct the API message */
9238 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9239 vec_len (next_hop_out_label_stack));
9241 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
9242 mp->mr_table_id = ntohl (table_id);
9244 mp->mr_is_add = is_add;
9245 mp->mr_next_hop_proto = next_hop_proto;
9246 mp->mr_is_classify = is_classify;
9247 mp->mr_is_multipath = is_multipath;
9248 mp->mr_is_resolve_host = resolve_host;
9249 mp->mr_is_resolve_attached = resolve_attached;
9250 mp->mr_is_interface_rx = is_interface_rx;
9251 mp->mr_next_hop_weight = next_hop_weight;
9252 mp->mr_next_hop_preference = 0;
9253 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
9254 mp->mr_classify_table_index = ntohl (classify_table_index);
9255 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
9256 mp->mr_label = ntohl (local_label);
9257 mp->mr_eos = is_eos;
9259 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9260 if (0 != mp->mr_next_hop_n_out_labels)
9262 memcpy (mp->mr_next_hop_out_label_stack,
9263 next_hop_out_label_stack,
9264 vec_len (next_hop_out_label_stack) *
9265 sizeof (vl_api_fib_mpls_label_t));
9266 vec_free (next_hop_out_label_stack);
9271 if (DPO_PROTO_IP4 == next_hop_proto)
9273 clib_memcpy (mp->mr_next_hop,
9274 &v4_next_hop_address,
9275 sizeof (v4_next_hop_address));
9277 else if (DPO_PROTO_IP6 == next_hop_proto)
9280 clib_memcpy (mp->mr_next_hop,
9281 &v6_next_hop_address,
9282 sizeof (v6_next_hop_address));
9289 /* If we receive SIGTERM, stop now... */
9294 /* When testing multiple add/del ops, use a control-ping to sync */
9297 vl_api_control_ping_t *mp_ping;
9301 /* Shut off async mode */
9302 vam->async_mode = 0;
9304 MPING (CONTROL_PING, mp_ping);
9307 timeout = vat_time_now (vam) + 1.0;
9308 while (vat_time_now (vam) < timeout)
9309 if (vam->result_ready == 1)
9314 if (vam->retval == -99)
9317 if (vam->async_errors > 0)
9319 errmsg ("%d asynchronous errors", vam->async_errors);
9322 vam->async_errors = 0;
9323 after = vat_time_now (vam);
9325 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9329 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9330 count, after - before, count / (after - before));
9336 /* Wait for a reply... */
9341 /* Return the good/bad news */
9342 return (vam->retval);
9346 api_mpls_ip_bind_unbind (vat_main_t * vam)
9348 unformat_input_t *i = vam->input;
9349 vl_api_mpls_ip_bind_unbind_t *mp;
9350 u32 ip_table_id = 0;
9353 ip4_address_t v4_address;
9354 ip6_address_t v6_address;
9357 mpls_label_t local_label = MPLS_LABEL_INVALID;
9360 /* Parse args required to build the message */
9361 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9363 if (unformat (i, "%U/%d", unformat_ip4_address,
9364 &v4_address, &address_length))
9369 else if (unformat (i, "%U/%d", unformat_ip6_address,
9370 &v6_address, &address_length))
9375 else if (unformat (i, "%d", &local_label))
9377 else if (unformat (i, "table-id %d", &ip_table_id))
9379 else if (unformat (i, "unbind"))
9381 else if (unformat (i, "bind"))
9385 clib_warning ("parse error '%U'", format_unformat_error, i);
9392 errmsg ("IP address not set");
9396 if (MPLS_LABEL_INVALID == local_label)
9398 errmsg ("missing label");
9402 /* Construct the API message */
9403 M (MPLS_IP_BIND_UNBIND, mp);
9405 mp->mb_is_bind = is_bind;
9406 mp->mb_is_ip4 = is_ip4;
9407 mp->mb_ip_table_id = ntohl (ip_table_id);
9408 mp->mb_mpls_table_id = 0;
9409 mp->mb_label = ntohl (local_label);
9410 mp->mb_address_length = address_length;
9413 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9415 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9420 /* Wait for a reply... */
9426 api_sr_mpls_policy_add (vat_main_t * vam)
9428 unformat_input_t *i = vam->input;
9429 vl_api_sr_mpls_policy_add_t *mp;
9435 u32 *segments = NULL;
9438 /* Parse args required to build the message */
9439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9441 if (unformat (i, "bsid %d", &bsid))
9443 else if (unformat (i, "weight %d", &weight))
9445 else if (unformat (i, "spray"))
9447 else if (unformat (i, "next %d", &sid))
9450 vec_add1 (segments, htonl (sid));
9454 clib_warning ("parse error '%U'", format_unformat_error, i);
9461 errmsg ("bsid not set");
9465 if (n_segments == 0)
9467 errmsg ("no sid in segment stack");
9471 /* Construct the API message */
9472 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
9474 mp->bsid = htonl (bsid);
9475 mp->weight = htonl (weight);
9477 mp->n_segments = n_segments;
9478 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
9479 vec_free (segments);
9484 /* Wait for a reply... */
9490 api_sr_mpls_policy_del (vat_main_t * vam)
9492 unformat_input_t *i = vam->input;
9493 vl_api_sr_mpls_policy_del_t *mp;
9497 /* Parse args required to build the message */
9498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9500 if (unformat (i, "bsid %d", &bsid))
9504 clib_warning ("parse error '%U'", format_unformat_error, i);
9511 errmsg ("bsid not set");
9515 /* Construct the API message */
9516 M (SR_MPLS_POLICY_DEL, mp);
9518 mp->bsid = htonl (bsid);
9523 /* Wait for a reply... */
9529 api_bier_table_add_del (vat_main_t * vam)
9531 unformat_input_t *i = vam->input;
9532 vl_api_bier_table_add_del_t *mp;
9534 u32 set = 0, sub_domain = 0, hdr_len = 3;
9535 mpls_label_t local_label = MPLS_LABEL_INVALID;
9538 /* Parse args required to build the message */
9539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9541 if (unformat (i, "sub-domain %d", &sub_domain))
9543 else if (unformat (i, "set %d", &set))
9545 else if (unformat (i, "label %d", &local_label))
9547 else if (unformat (i, "hdr-len %d", &hdr_len))
9549 else if (unformat (i, "add"))
9551 else if (unformat (i, "del"))
9555 clib_warning ("parse error '%U'", format_unformat_error, i);
9560 if (MPLS_LABEL_INVALID == local_label)
9562 errmsg ("missing label\n");
9566 /* Construct the API message */
9567 M (BIER_TABLE_ADD_DEL, mp);
9569 mp->bt_is_add = is_add;
9570 mp->bt_label = ntohl (local_label);
9571 mp->bt_tbl_id.bt_set = set;
9572 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9573 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9578 /* Wait for a reply... */
9585 api_bier_route_add_del (vat_main_t * vam)
9587 unformat_input_t *i = vam->input;
9588 vl_api_bier_route_add_del_t *mp;
9590 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9591 ip4_address_t v4_next_hop_address;
9592 ip6_address_t v6_next_hop_address;
9593 u8 next_hop_set = 0;
9594 u8 next_hop_proto_is_ip4 = 1;
9595 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9598 /* Parse args required to build the message */
9599 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9601 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9603 next_hop_proto_is_ip4 = 1;
9606 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9608 next_hop_proto_is_ip4 = 0;
9611 if (unformat (i, "sub-domain %d", &sub_domain))
9613 else if (unformat (i, "set %d", &set))
9615 else if (unformat (i, "hdr-len %d", &hdr_len))
9617 else if (unformat (i, "bp %d", &bp))
9619 else if (unformat (i, "add"))
9621 else if (unformat (i, "del"))
9623 else if (unformat (i, "out-label %d", &next_hop_out_label))
9627 clib_warning ("parse error '%U'", format_unformat_error, i);
9632 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9634 errmsg ("next hop / label set\n");
9639 errmsg ("bit=position not set\n");
9643 /* Construct the API message */
9644 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9646 mp->br_is_add = is_add;
9647 mp->br_tbl_id.bt_set = set;
9648 mp->br_tbl_id.bt_sub_domain = sub_domain;
9649 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9650 mp->br_bp = ntohs (bp);
9652 mp->br_paths[0].n_labels = 1;
9653 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9654 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9656 if (next_hop_proto_is_ip4)
9658 clib_memcpy (mp->br_paths[0].next_hop,
9659 &v4_next_hop_address, sizeof (v4_next_hop_address));
9663 clib_memcpy (mp->br_paths[0].next_hop,
9664 &v6_next_hop_address, sizeof (v6_next_hop_address));
9670 /* Wait for a reply... */
9677 api_proxy_arp_add_del (vat_main_t * vam)
9679 unformat_input_t *i = vam->input;
9680 vl_api_proxy_arp_add_del_t *mp;
9683 ip4_address_t lo, hi;
9687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9689 if (unformat (i, "vrf %d", &vrf_id))
9691 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9692 unformat_ip4_address, &hi))
9694 else if (unformat (i, "del"))
9698 clib_warning ("parse error '%U'", format_unformat_error, i);
9705 errmsg ("address range not set");
9709 M (PROXY_ARP_ADD_DEL, mp);
9711 mp->proxy.vrf_id = ntohl (vrf_id);
9712 mp->is_add = is_add;
9713 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9714 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9722 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9724 unformat_input_t *i = vam->input;
9725 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9728 u8 sw_if_index_set = 0;
9731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9733 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9734 sw_if_index_set = 1;
9735 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9736 sw_if_index_set = 1;
9737 else if (unformat (i, "enable"))
9739 else if (unformat (i, "disable"))
9743 clib_warning ("parse error '%U'", format_unformat_error, i);
9748 if (sw_if_index_set == 0)
9750 errmsg ("missing interface name or sw_if_index");
9754 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9756 mp->sw_if_index = ntohl (sw_if_index);
9757 mp->enable_disable = enable;
9765 api_mpls_tunnel_add_del (vat_main_t * vam)
9767 unformat_input_t *i = vam->input;
9768 vl_api_mpls_tunnel_add_del_t *mp;
9772 u32 sw_if_index = ~0;
9773 u32 next_hop_sw_if_index = ~0;
9774 u32 next_hop_proto_is_ip4 = 1;
9776 u32 next_hop_table_id = 0;
9777 ip4_address_t v4_next_hop_address = {
9780 ip6_address_t v6_next_hop_address = { {0} };
9781 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9782 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9783 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9788 if (unformat (i, "add"))
9792 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9794 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9796 else if (unformat (i, "via %U",
9797 unformat_ip4_address, &v4_next_hop_address))
9799 next_hop_proto_is_ip4 = 1;
9801 else if (unformat (i, "via %U",
9802 unformat_ip6_address, &v6_next_hop_address))
9804 next_hop_proto_is_ip4 = 0;
9806 else if (unformat (i, "via-label %d", &next_hop_via_label))
9810 (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
9812 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9814 else if (unformat (i, "l2-only"))
9816 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9818 else if (unformat (i, "out-label %d", &next_hop_out_label))
9820 vl_api_fib_mpls_label_t fib_label = {
9821 .label = ntohl (next_hop_out_label),
9825 vec_add1 (next_hop_out_label_stack, fib_label);
9829 clib_warning ("parse error '%U'", format_unformat_error, i);
9834 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9835 vec_len (next_hop_out_label_stack));
9837 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9838 mp->mt_sw_if_index = ntohl (sw_if_index);
9839 mp->mt_is_add = is_add;
9840 mp->mt_l2_only = l2_only;
9841 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9842 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9843 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9844 mp->mt_next_hop_weight = 1;
9845 mp->mt_next_hop_preference = 0;
9847 mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9849 if (0 != mp->mt_next_hop_n_out_labels)
9851 clib_memcpy (mp->mt_next_hop_out_label_stack,
9852 next_hop_out_label_stack,
9853 (vec_len (next_hop_out_label_stack) *
9854 sizeof (vl_api_fib_mpls_label_t)));
9855 vec_free (next_hop_out_label_stack);
9858 if (next_hop_proto_is_ip4)
9860 clib_memcpy (mp->mt_next_hop,
9861 &v4_next_hop_address, sizeof (v4_next_hop_address));
9865 clib_memcpy (mp->mt_next_hop,
9866 &v6_next_hop_address, sizeof (v6_next_hop_address));
9875 api_sw_interface_set_unnumbered (vat_main_t * vam)
9877 unformat_input_t *i = vam->input;
9878 vl_api_sw_interface_set_unnumbered_t *mp;
9880 u32 unnum_sw_index = ~0;
9882 u8 sw_if_index_set = 0;
9885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9887 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9888 sw_if_index_set = 1;
9889 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9890 sw_if_index_set = 1;
9891 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9893 else if (unformat (i, "del"))
9897 clib_warning ("parse error '%U'", format_unformat_error, i);
9902 if (sw_if_index_set == 0)
9904 errmsg ("missing interface name or sw_if_index");
9908 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9910 mp->sw_if_index = ntohl (sw_if_index);
9911 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9912 mp->is_add = is_add;
9920 api_ip_neighbor_add_del (vat_main_t * vam)
9922 unformat_input_t *i = vam->input;
9923 vl_api_ip_neighbor_add_del_t *mp;
9925 u8 sw_if_index_set = 0;
9928 u8 is_no_fib_entry = 0;
9931 u8 v4_address_set = 0;
9932 u8 v6_address_set = 0;
9933 ip4_address_t v4address;
9934 ip6_address_t v6address;
9937 clib_memset (mac_address, 0, sizeof (mac_address));
9939 /* Parse args required to build the message */
9940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9942 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9946 else if (unformat (i, "del"))
9949 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9950 sw_if_index_set = 1;
9951 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9952 sw_if_index_set = 1;
9953 else if (unformat (i, "is_static"))
9955 else if (unformat (i, "no-fib-entry"))
9956 is_no_fib_entry = 1;
9957 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9959 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9963 clib_warning ("parse error '%U'", format_unformat_error, i);
9968 if (sw_if_index_set == 0)
9970 errmsg ("missing interface name or sw_if_index");
9973 if (v4_address_set && v6_address_set)
9975 errmsg ("both v4 and v6 addresses set");
9978 if (!v4_address_set && !v6_address_set)
9980 errmsg ("no address set");
9984 /* Construct the API message */
9985 M (IP_NEIGHBOR_ADD_DEL, mp);
9987 mp->sw_if_index = ntohl (sw_if_index);
9988 mp->is_add = is_add;
9989 mp->is_static = is_static;
9990 mp->is_no_adj_fib = is_no_fib_entry;
9992 clib_memcpy (mp->mac_address, mac_address, 6);
9996 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
10000 /* mp->is_ipv6 = 0; via clib_memset in M macro above */
10001 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
10007 /* Wait for a reply, return good/bad news */
10013 api_create_vlan_subif (vat_main_t * vam)
10015 unformat_input_t *i = vam->input;
10016 vl_api_create_vlan_subif_t *mp;
10018 u8 sw_if_index_set = 0;
10020 u8 vlan_id_set = 0;
10023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10025 if (unformat (i, "sw_if_index %d", &sw_if_index))
10026 sw_if_index_set = 1;
10028 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10029 sw_if_index_set = 1;
10030 else if (unformat (i, "vlan %d", &vlan_id))
10034 clib_warning ("parse error '%U'", format_unformat_error, i);
10039 if (sw_if_index_set == 0)
10041 errmsg ("missing interface name or sw_if_index");
10045 if (vlan_id_set == 0)
10047 errmsg ("missing vlan_id");
10050 M (CREATE_VLAN_SUBIF, mp);
10052 mp->sw_if_index = ntohl (sw_if_index);
10053 mp->vlan_id = ntohl (vlan_id);
10060 #define foreach_create_subif_bit \
10067 _(outer_vlan_id_any) \
10068 _(inner_vlan_id_any)
10071 api_create_subif (vat_main_t * vam)
10073 unformat_input_t *i = vam->input;
10074 vl_api_create_subif_t *mp;
10076 u8 sw_if_index_set = 0;
10083 u32 exact_match = 0;
10084 u32 default_sub = 0;
10085 u32 outer_vlan_id_any = 0;
10086 u32 inner_vlan_id_any = 0;
10088 u16 outer_vlan_id = 0;
10089 u16 inner_vlan_id = 0;
10092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10094 if (unformat (i, "sw_if_index %d", &sw_if_index))
10095 sw_if_index_set = 1;
10097 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10098 sw_if_index_set = 1;
10099 else if (unformat (i, "sub_id %d", &sub_id))
10101 else if (unformat (i, "outer_vlan_id %d", &tmp))
10102 outer_vlan_id = tmp;
10103 else if (unformat (i, "inner_vlan_id %d", &tmp))
10104 inner_vlan_id = tmp;
10106 #define _(a) else if (unformat (i, #a)) a = 1 ;
10107 foreach_create_subif_bit
10111 clib_warning ("parse error '%U'", format_unformat_error, i);
10116 if (sw_if_index_set == 0)
10118 errmsg ("missing interface name or sw_if_index");
10122 if (sub_id_set == 0)
10124 errmsg ("missing sub_id");
10127 M (CREATE_SUBIF, mp);
10129 mp->sw_if_index = ntohl (sw_if_index);
10130 mp->sub_id = ntohl (sub_id);
10132 #define _(a) mp->a = a;
10133 foreach_create_subif_bit;
10136 mp->outer_vlan_id = ntohs (outer_vlan_id);
10137 mp->inner_vlan_id = ntohs (inner_vlan_id);
10145 api_oam_add_del (vat_main_t * vam)
10147 unformat_input_t *i = vam->input;
10148 vl_api_oam_add_del_t *mp;
10151 ip4_address_t src, dst;
10156 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10158 if (unformat (i, "vrf %d", &vrf_id))
10160 else if (unformat (i, "src %U", unformat_ip4_address, &src))
10162 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
10164 else if (unformat (i, "del"))
10168 clib_warning ("parse error '%U'", format_unformat_error, i);
10175 errmsg ("missing src addr");
10181 errmsg ("missing dst addr");
10185 M (OAM_ADD_DEL, mp);
10187 mp->vrf_id = ntohl (vrf_id);
10188 mp->is_add = is_add;
10189 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
10190 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
10198 api_reset_fib (vat_main_t * vam)
10200 unformat_input_t *i = vam->input;
10201 vl_api_reset_fib_t *mp;
10207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10209 if (unformat (i, "vrf %d", &vrf_id))
10211 else if (unformat (i, "ipv6"))
10215 clib_warning ("parse error '%U'", format_unformat_error, i);
10220 if (vrf_id_set == 0)
10222 errmsg ("missing vrf id");
10228 mp->vrf_id = ntohl (vrf_id);
10229 mp->is_ipv6 = is_ipv6;
10237 api_dhcp_proxy_config (vat_main_t * vam)
10239 unformat_input_t *i = vam->input;
10240 vl_api_dhcp_proxy_config_t *mp;
10242 u32 server_vrf_id = 0;
10244 u8 v4_address_set = 0;
10245 u8 v6_address_set = 0;
10246 ip4_address_t v4address;
10247 ip6_address_t v6address;
10248 u8 v4_src_address_set = 0;
10249 u8 v6_src_address_set = 0;
10250 ip4_address_t v4srcaddress;
10251 ip6_address_t v6srcaddress;
10254 /* Parse args required to build the message */
10255 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10257 if (unformat (i, "del"))
10259 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
10261 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
10263 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
10264 v4_address_set = 1;
10265 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
10266 v6_address_set = 1;
10267 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
10268 v4_src_address_set = 1;
10269 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
10270 v6_src_address_set = 1;
10275 if (v4_address_set && v6_address_set)
10277 errmsg ("both v4 and v6 server addresses set");
10280 if (!v4_address_set && !v6_address_set)
10282 errmsg ("no server addresses set");
10286 if (v4_src_address_set && v6_src_address_set)
10288 errmsg ("both v4 and v6 src addresses set");
10291 if (!v4_src_address_set && !v6_src_address_set)
10293 errmsg ("no src addresses set");
10297 if (!(v4_src_address_set && v4_address_set) &&
10298 !(v6_src_address_set && v6_address_set))
10300 errmsg ("no matching server and src addresses set");
10304 /* Construct the API message */
10305 M (DHCP_PROXY_CONFIG, mp);
10307 mp->is_add = is_add;
10308 mp->rx_vrf_id = ntohl (rx_vrf_id);
10309 mp->server_vrf_id = ntohl (server_vrf_id);
10310 if (v6_address_set)
10313 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
10314 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
10318 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
10319 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
10325 /* Wait for a reply, return good/bad news */
10330 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
10331 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
10334 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
10336 vat_main_t *vam = &vat_main;
10337 u32 i, count = mp->count;
10338 vl_api_dhcp_server_t *s;
10342 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10343 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10344 ntohl (mp->rx_vrf_id),
10345 format_ip6_address, mp->dhcp_src_address,
10346 mp->vss_type, mp->vss_vpn_ascii_id,
10347 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10350 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10351 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10352 ntohl (mp->rx_vrf_id),
10353 format_ip4_address, mp->dhcp_src_address,
10354 mp->vss_type, mp->vss_vpn_ascii_id,
10355 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10357 for (i = 0; i < count; i++)
10359 s = &mp->servers[i];
10363 " Server Table-ID %d, Server Address %U",
10364 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
10367 " Server Table-ID %d, Server Address %U",
10368 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
10372 static void vl_api_dhcp_proxy_details_t_handler_json
10373 (vl_api_dhcp_proxy_details_t * mp)
10375 vat_main_t *vam = &vat_main;
10376 vat_json_node_t *node = NULL;
10377 u32 i, count = mp->count;
10378 struct in_addr ip4;
10379 struct in6_addr ip6;
10380 vl_api_dhcp_server_t *s;
10382 if (VAT_JSON_ARRAY != vam->json_tree.type)
10384 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10385 vat_json_init_array (&vam->json_tree);
10387 node = vat_json_array_add (&vam->json_tree);
10389 vat_json_init_object (node);
10390 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
10391 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
10392 sizeof (mp->vss_type));
10393 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
10394 mp->vss_vpn_ascii_id);
10395 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
10396 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10400 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10401 vat_json_object_add_ip6 (node, "src_address", ip6);
10405 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10406 vat_json_object_add_ip4 (node, "src_address", ip4);
10409 for (i = 0; i < count; i++)
10411 s = &mp->servers[i];
10413 vat_json_object_add_uint (node, "server-table-id",
10414 ntohl (s->server_vrf_id));
10418 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10419 vat_json_object_add_ip4 (node, "src_address", ip4);
10423 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10424 vat_json_object_add_ip6 (node, "server_address", ip6);
10430 api_dhcp_proxy_dump (vat_main_t * vam)
10432 unformat_input_t *i = vam->input;
10433 vl_api_control_ping_t *mp_ping;
10434 vl_api_dhcp_proxy_dump_t *mp;
10438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10440 if (unformat (i, "ipv6"))
10444 clib_warning ("parse error '%U'", format_unformat_error, i);
10449 M (DHCP_PROXY_DUMP, mp);
10451 mp->is_ip6 = is_ipv6;
10454 /* Use a control ping for synchronization */
10455 MPING (CONTROL_PING, mp_ping);
10463 api_dhcp_proxy_set_vss (vat_main_t * vam)
10465 unformat_input_t *i = vam->input;
10466 vl_api_dhcp_proxy_set_vss_t *mp;
10470 u8 vss_type = VSS_TYPE_DEFAULT;
10471 u8 *vpn_ascii_id = 0;
10476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10478 if (unformat (i, "tbl_id %d", &tbl_id))
10480 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10481 vss_type = VSS_TYPE_ASCII;
10482 else if (unformat (i, "fib_id %d", &fib_id))
10483 vss_type = VSS_TYPE_VPN_ID;
10484 else if (unformat (i, "oui %d", &oui))
10485 vss_type = VSS_TYPE_VPN_ID;
10486 else if (unformat (i, "ipv6"))
10488 else if (unformat (i, "del"))
10496 errmsg ("missing tbl_id ");
10497 vec_free (vpn_ascii_id);
10501 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10503 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10504 vec_free (vpn_ascii_id);
10508 M (DHCP_PROXY_SET_VSS, mp);
10509 mp->tbl_id = ntohl (tbl_id);
10510 mp->vss_type = vss_type;
10513 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10514 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10516 mp->vpn_index = ntohl (fib_id);
10517 mp->oui = ntohl (oui);
10518 mp->is_ipv6 = is_ipv6;
10519 mp->is_add = is_add;
10524 vec_free (vpn_ascii_id);
10529 api_dhcp_client_config (vat_main_t * vam)
10531 unformat_input_t *i = vam->input;
10532 vl_api_dhcp_client_config_t *mp;
10534 u8 sw_if_index_set = 0;
10537 u8 disable_event = 0;
10540 /* Parse args required to build the message */
10541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10543 if (unformat (i, "del"))
10546 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10547 sw_if_index_set = 1;
10548 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10549 sw_if_index_set = 1;
10550 else if (unformat (i, "hostname %s", &hostname))
10552 else if (unformat (i, "disable_event"))
10558 if (sw_if_index_set == 0)
10560 errmsg ("missing interface name or sw_if_index");
10564 if (vec_len (hostname) > 63)
10566 errmsg ("hostname too long");
10568 vec_add1 (hostname, 0);
10570 /* Construct the API message */
10571 M (DHCP_CLIENT_CONFIG, mp);
10573 mp->is_add = is_add;
10574 mp->client.sw_if_index = htonl (sw_if_index);
10575 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10576 vec_free (hostname);
10577 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10578 mp->client.pid = htonl (getpid ());
10583 /* Wait for a reply, return good/bad news */
10589 api_set_ip_flow_hash (vat_main_t * vam)
10591 unformat_input_t *i = vam->input;
10592 vl_api_set_ip_flow_hash_t *mp;
10604 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10606 if (unformat (i, "vrf %d", &vrf_id))
10608 else if (unformat (i, "ipv6"))
10610 else if (unformat (i, "src"))
10612 else if (unformat (i, "dst"))
10614 else if (unformat (i, "sport"))
10616 else if (unformat (i, "dport"))
10618 else if (unformat (i, "proto"))
10620 else if (unformat (i, "reverse"))
10625 clib_warning ("parse error '%U'", format_unformat_error, i);
10630 if (vrf_id_set == 0)
10632 errmsg ("missing vrf id");
10636 M (SET_IP_FLOW_HASH, mp);
10642 mp->reverse = reverse;
10643 mp->vrf_id = ntohl (vrf_id);
10644 mp->is_ipv6 = is_ipv6;
10652 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10654 unformat_input_t *i = vam->input;
10655 vl_api_sw_interface_ip6_enable_disable_t *mp;
10657 u8 sw_if_index_set = 0;
10661 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10663 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10664 sw_if_index_set = 1;
10665 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10666 sw_if_index_set = 1;
10667 else if (unformat (i, "enable"))
10669 else if (unformat (i, "disable"))
10673 clib_warning ("parse error '%U'", format_unformat_error, i);
10678 if (sw_if_index_set == 0)
10680 errmsg ("missing interface name or sw_if_index");
10684 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10686 mp->sw_if_index = ntohl (sw_if_index);
10687 mp->enable = enable;
10695 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10697 unformat_input_t *i = vam->input;
10698 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10700 u8 sw_if_index_set = 0;
10701 u8 v6_address_set = 0;
10702 ip6_address_t v6address;
10705 /* Parse args required to build the message */
10706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10708 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10709 sw_if_index_set = 1;
10710 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10711 sw_if_index_set = 1;
10712 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10713 v6_address_set = 1;
10718 if (sw_if_index_set == 0)
10720 errmsg ("missing interface name or sw_if_index");
10723 if (!v6_address_set)
10725 errmsg ("no address set");
10729 /* Construct the API message */
10730 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10732 mp->sw_if_index = ntohl (sw_if_index);
10733 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10738 /* Wait for a reply, return good/bad news */
10744 api_ip6nd_proxy_add_del (vat_main_t * vam)
10746 unformat_input_t *i = vam->input;
10747 vl_api_ip6nd_proxy_add_del_t *mp;
10748 u32 sw_if_index = ~0;
10749 u8 v6_address_set = 0;
10750 ip6_address_t v6address;
10754 /* Parse args required to build the message */
10755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10757 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10759 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10761 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10762 v6_address_set = 1;
10763 if (unformat (i, "del"))
10767 clib_warning ("parse error '%U'", format_unformat_error, i);
10772 if (sw_if_index == ~0)
10774 errmsg ("missing interface name or sw_if_index");
10777 if (!v6_address_set)
10779 errmsg ("no address set");
10783 /* Construct the API message */
10784 M (IP6ND_PROXY_ADD_DEL, mp);
10786 mp->is_del = is_del;
10787 mp->sw_if_index = ntohl (sw_if_index);
10788 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10793 /* Wait for a reply, return good/bad news */
10799 api_ip6nd_proxy_dump (vat_main_t * vam)
10801 vl_api_ip6nd_proxy_dump_t *mp;
10802 vl_api_control_ping_t *mp_ping;
10805 M (IP6ND_PROXY_DUMP, mp);
10809 /* Use a control ping for synchronization */
10810 MPING (CONTROL_PING, mp_ping);
10817 static void vl_api_ip6nd_proxy_details_t_handler
10818 (vl_api_ip6nd_proxy_details_t * mp)
10820 vat_main_t *vam = &vat_main;
10822 print (vam->ofp, "host %U sw_if_index %d",
10823 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10826 static void vl_api_ip6nd_proxy_details_t_handler_json
10827 (vl_api_ip6nd_proxy_details_t * mp)
10829 vat_main_t *vam = &vat_main;
10830 struct in6_addr ip6;
10831 vat_json_node_t *node = NULL;
10833 if (VAT_JSON_ARRAY != vam->json_tree.type)
10835 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10836 vat_json_init_array (&vam->json_tree);
10838 node = vat_json_array_add (&vam->json_tree);
10840 vat_json_init_object (node);
10841 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10843 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10844 vat_json_object_add_ip6 (node, "host", ip6);
10848 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10850 unformat_input_t *i = vam->input;
10851 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10853 u8 sw_if_index_set = 0;
10854 u32 address_length = 0;
10855 u8 v6_address_set = 0;
10856 ip6_address_t v6address;
10857 u8 use_default = 0;
10858 u8 no_advertise = 0;
10860 u8 no_autoconfig = 0;
10863 u32 val_lifetime = 0;
10864 u32 pref_lifetime = 0;
10867 /* Parse args required to build the message */
10868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10870 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10871 sw_if_index_set = 1;
10872 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10873 sw_if_index_set = 1;
10874 else if (unformat (i, "%U/%d",
10875 unformat_ip6_address, &v6address, &address_length))
10876 v6_address_set = 1;
10877 else if (unformat (i, "val_life %d", &val_lifetime))
10879 else if (unformat (i, "pref_life %d", &pref_lifetime))
10881 else if (unformat (i, "def"))
10883 else if (unformat (i, "noadv"))
10885 else if (unformat (i, "offl"))
10887 else if (unformat (i, "noauto"))
10889 else if (unformat (i, "nolink"))
10891 else if (unformat (i, "isno"))
10895 clib_warning ("parse error '%U'", format_unformat_error, i);
10900 if (sw_if_index_set == 0)
10902 errmsg ("missing interface name or sw_if_index");
10905 if (!v6_address_set)
10907 errmsg ("no address set");
10911 /* Construct the API message */
10912 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10914 mp->sw_if_index = ntohl (sw_if_index);
10915 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10916 mp->address_length = address_length;
10917 mp->use_default = use_default;
10918 mp->no_advertise = no_advertise;
10919 mp->off_link = off_link;
10920 mp->no_autoconfig = no_autoconfig;
10921 mp->no_onlink = no_onlink;
10923 mp->val_lifetime = ntohl (val_lifetime);
10924 mp->pref_lifetime = ntohl (pref_lifetime);
10929 /* Wait for a reply, return good/bad news */
10935 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10937 unformat_input_t *i = vam->input;
10938 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10940 u8 sw_if_index_set = 0;
10945 u8 send_unicast = 0;
10948 u8 default_router = 0;
10949 u32 max_interval = 0;
10950 u32 min_interval = 0;
10952 u32 initial_count = 0;
10953 u32 initial_interval = 0;
10957 /* Parse args required to build the message */
10958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10960 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10961 sw_if_index_set = 1;
10962 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10963 sw_if_index_set = 1;
10964 else if (unformat (i, "maxint %d", &max_interval))
10966 else if (unformat (i, "minint %d", &min_interval))
10968 else if (unformat (i, "life %d", &lifetime))
10970 else if (unformat (i, "count %d", &initial_count))
10972 else if (unformat (i, "interval %d", &initial_interval))
10974 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10976 else if (unformat (i, "managed"))
10978 else if (unformat (i, "other"))
10980 else if (unformat (i, "ll"))
10982 else if (unformat (i, "send"))
10984 else if (unformat (i, "cease"))
10986 else if (unformat (i, "isno"))
10988 else if (unformat (i, "def"))
10989 default_router = 1;
10992 clib_warning ("parse error '%U'", format_unformat_error, i);
10997 if (sw_if_index_set == 0)
10999 errmsg ("missing interface name or sw_if_index");
11003 /* Construct the API message */
11004 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
11006 mp->sw_if_index = ntohl (sw_if_index);
11007 mp->max_interval = ntohl (max_interval);
11008 mp->min_interval = ntohl (min_interval);
11009 mp->lifetime = ntohl (lifetime);
11010 mp->initial_count = ntohl (initial_count);
11011 mp->initial_interval = ntohl (initial_interval);
11012 mp->suppress = suppress;
11013 mp->managed = managed;
11015 mp->ll_option = ll_option;
11016 mp->send_unicast = send_unicast;
11019 mp->default_router = default_router;
11024 /* Wait for a reply, return good/bad news */
11030 api_set_arp_neighbor_limit (vat_main_t * vam)
11032 unformat_input_t *i = vam->input;
11033 vl_api_set_arp_neighbor_limit_t *mp;
11039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11041 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
11043 else if (unformat (i, "ipv6"))
11047 clib_warning ("parse error '%U'", format_unformat_error, i);
11052 if (limit_set == 0)
11054 errmsg ("missing limit value");
11058 M (SET_ARP_NEIGHBOR_LIMIT, mp);
11060 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
11061 mp->is_ipv6 = is_ipv6;
11069 api_l2_patch_add_del (vat_main_t * vam)
11071 unformat_input_t *i = vam->input;
11072 vl_api_l2_patch_add_del_t *mp;
11073 u32 rx_sw_if_index;
11074 u8 rx_sw_if_index_set = 0;
11075 u32 tx_sw_if_index;
11076 u8 tx_sw_if_index_set = 0;
11080 /* Parse args required to build the message */
11081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11083 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
11084 rx_sw_if_index_set = 1;
11085 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
11086 tx_sw_if_index_set = 1;
11087 else if (unformat (i, "rx"))
11089 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11091 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
11093 rx_sw_if_index_set = 1;
11098 else if (unformat (i, "tx"))
11100 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11102 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
11104 tx_sw_if_index_set = 1;
11109 else if (unformat (i, "del"))
11115 if (rx_sw_if_index_set == 0)
11117 errmsg ("missing rx interface name or rx_sw_if_index");
11121 if (tx_sw_if_index_set == 0)
11123 errmsg ("missing tx interface name or tx_sw_if_index");
11127 M (L2_PATCH_ADD_DEL, mp);
11129 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
11130 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
11131 mp->is_add = is_add;
11139 u8 localsid_addr[16];
11148 api_sr_localsid_add_del (vat_main_t * vam)
11150 unformat_input_t *i = vam->input;
11151 vl_api_sr_localsid_add_del_t *mp;
11154 ip6_address_t localsid;
11158 u32 fib_table = ~(u32) 0;
11159 ip6_address_t nh_addr6;
11160 ip4_address_t nh_addr4;
11161 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
11162 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
11164 bool nexthop_set = 0;
11168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11170 if (unformat (i, "del"))
11172 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
11173 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
11175 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
11177 else if (unformat (i, "behavior %u", &behavior));
11178 else if (unformat (i, "sw_if_index %u", &sw_if_index));
11179 else if (unformat (i, "fib-table %u", &fib_table));
11180 else if (unformat (i, "end.psp %u", &behavior));
11185 M (SR_LOCALSID_ADD_DEL, mp);
11187 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
11190 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
11191 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
11193 mp->behavior = behavior;
11194 mp->sw_if_index = ntohl (sw_if_index);
11195 mp->fib_table = ntohl (fib_table);
11196 mp->end_psp = end_psp;
11197 mp->is_del = is_del;
11205 api_ioam_enable (vat_main_t * vam)
11207 unformat_input_t *input = vam->input;
11208 vl_api_ioam_enable_t *mp;
11210 int has_trace_option = 0;
11211 int has_pot_option = 0;
11212 int has_seqno_option = 0;
11213 int has_analyse_option = 0;
11216 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11218 if (unformat (input, "trace"))
11219 has_trace_option = 1;
11220 else if (unformat (input, "pot"))
11221 has_pot_option = 1;
11222 else if (unformat (input, "seqno"))
11223 has_seqno_option = 1;
11224 else if (unformat (input, "analyse"))
11225 has_analyse_option = 1;
11229 M (IOAM_ENABLE, mp);
11230 mp->id = htons (id);
11231 mp->seqno = has_seqno_option;
11232 mp->analyse = has_analyse_option;
11233 mp->pot_enable = has_pot_option;
11234 mp->trace_enable = has_trace_option;
11243 api_ioam_disable (vat_main_t * vam)
11245 vl_api_ioam_disable_t *mp;
11248 M (IOAM_DISABLE, mp);
11254 #define foreach_tcp_proto_field \
11258 #define foreach_udp_proto_field \
11262 #define foreach_ip4_proto_field \
11274 u16 src_port, dst_port;
11277 #if VPP_API_TEST_BUILTIN == 0
11279 unformat_tcp_mask (unformat_input_t * input, va_list * args)
11281 u8 **maskp = va_arg (*args, u8 **);
11283 u8 found_something = 0;
11286 #define _(a) u8 a=0;
11287 foreach_tcp_proto_field;
11290 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11293 #define _(a) else if (unformat (input, #a)) a=1;
11294 foreach_tcp_proto_field
11300 #define _(a) found_something += a;
11301 foreach_tcp_proto_field;
11304 if (found_something == 0)
11307 vec_validate (mask, sizeof (*tcp) - 1);
11309 tcp = (tcp_header_t *) mask;
11311 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
11312 foreach_tcp_proto_field;
11320 unformat_udp_mask (unformat_input_t * input, va_list * args)
11322 u8 **maskp = va_arg (*args, u8 **);
11324 u8 found_something = 0;
11327 #define _(a) u8 a=0;
11328 foreach_udp_proto_field;
11331 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11334 #define _(a) else if (unformat (input, #a)) a=1;
11335 foreach_udp_proto_field
11341 #define _(a) found_something += a;
11342 foreach_udp_proto_field;
11345 if (found_something == 0)
11348 vec_validate (mask, sizeof (*udp) - 1);
11350 udp = (udp_header_t *) mask;
11352 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
11353 foreach_udp_proto_field;
11361 unformat_l4_mask (unformat_input_t * input, va_list * args)
11363 u8 **maskp = va_arg (*args, u8 **);
11364 u16 src_port = 0, dst_port = 0;
11365 tcpudp_header_t *tcpudp;
11367 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11369 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
11371 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
11373 else if (unformat (input, "src_port"))
11375 else if (unformat (input, "dst_port"))
11381 if (!src_port && !dst_port)
11385 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
11387 tcpudp = (tcpudp_header_t *) mask;
11388 tcpudp->src_port = src_port;
11389 tcpudp->dst_port = dst_port;
11397 unformat_ip4_mask (unformat_input_t * input, va_list * args)
11399 u8 **maskp = va_arg (*args, u8 **);
11401 u8 found_something = 0;
11404 #define _(a) u8 a=0;
11405 foreach_ip4_proto_field;
11411 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11413 if (unformat (input, "version"))
11415 else if (unformat (input, "hdr_length"))
11417 else if (unformat (input, "src"))
11419 else if (unformat (input, "dst"))
11421 else if (unformat (input, "proto"))
11424 #define _(a) else if (unformat (input, #a)) a=1;
11425 foreach_ip4_proto_field
11431 #define _(a) found_something += a;
11432 foreach_ip4_proto_field;
11435 if (found_something == 0)
11438 vec_validate (mask, sizeof (*ip) - 1);
11440 ip = (ip4_header_t *) mask;
11442 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
11443 foreach_ip4_proto_field;
11446 ip->ip_version_and_header_length = 0;
11449 ip->ip_version_and_header_length |= 0xF0;
11452 ip->ip_version_and_header_length |= 0x0F;
11458 #define foreach_ip6_proto_field \
11461 _(payload_length) \
11466 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11468 u8 **maskp = va_arg (*args, u8 **);
11470 u8 found_something = 0;
11472 u32 ip_version_traffic_class_and_flow_label;
11474 #define _(a) u8 a=0;
11475 foreach_ip6_proto_field;
11478 u8 traffic_class = 0;
11481 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11483 if (unformat (input, "version"))
11485 else if (unformat (input, "traffic-class"))
11487 else if (unformat (input, "flow-label"))
11489 else if (unformat (input, "src"))
11491 else if (unformat (input, "dst"))
11493 else if (unformat (input, "proto"))
11496 #define _(a) else if (unformat (input, #a)) a=1;
11497 foreach_ip6_proto_field
11503 #define _(a) found_something += a;
11504 foreach_ip6_proto_field;
11507 if (found_something == 0)
11510 vec_validate (mask, sizeof (*ip) - 1);
11512 ip = (ip6_header_t *) mask;
11514 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
11515 foreach_ip6_proto_field;
11518 ip_version_traffic_class_and_flow_label = 0;
11521 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11524 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11527 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11529 ip->ip_version_traffic_class_and_flow_label =
11530 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11537 unformat_l3_mask (unformat_input_t * input, va_list * args)
11539 u8 **maskp = va_arg (*args, u8 **);
11541 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11543 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11545 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11554 unformat_l2_mask (unformat_input_t * input, va_list * args)
11556 u8 **maskp = va_arg (*args, u8 **);
11563 u8 ignore_tag1 = 0;
11564 u8 ignore_tag2 = 0;
11571 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11573 if (unformat (input, "src"))
11575 else if (unformat (input, "dst"))
11577 else if (unformat (input, "proto"))
11579 else if (unformat (input, "tag1"))
11581 else if (unformat (input, "tag2"))
11583 else if (unformat (input, "ignore-tag1"))
11585 else if (unformat (input, "ignore-tag2"))
11587 else if (unformat (input, "cos1"))
11589 else if (unformat (input, "cos2"))
11591 else if (unformat (input, "dot1q"))
11593 else if (unformat (input, "dot1ad"))
11598 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11599 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11602 if (tag1 || ignore_tag1 || cos1 || dot1q)
11604 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11607 vec_validate (mask, len - 1);
11610 clib_memset (mask, 0xff, 6);
11613 clib_memset (mask + 6, 0xff, 6);
11615 if (tag2 || dot1ad)
11617 /* inner vlan tag */
11626 mask[21] = mask[20] = 0xff;
11647 mask[16] = mask[17] = 0xff;
11657 mask[12] = mask[13] = 0xff;
11664 unformat_classify_mask (unformat_input_t * input, va_list * args)
11666 u8 **maskp = va_arg (*args, u8 **);
11667 u32 *skipp = va_arg (*args, u32 *);
11668 u32 *matchp = va_arg (*args, u32 *);
11676 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11678 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11680 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11682 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11684 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11698 if (mask || l2 || l3 || l4)
11700 if (l2 || l3 || l4)
11702 /* "With a free Ethernet header in every package" */
11704 vec_validate (l2, 13);
11708 vec_append (mask, l3);
11713 vec_append (mask, l4);
11718 /* Scan forward looking for the first significant mask octet */
11719 for (i = 0; i < vec_len (mask); i++)
11723 /* compute (skip, match) params */
11724 *skipp = i / sizeof (u32x4);
11725 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11727 /* Pad mask to an even multiple of the vector size */
11728 while (vec_len (mask) % sizeof (u32x4))
11729 vec_add1 (mask, 0);
11731 match = vec_len (mask) / sizeof (u32x4);
11733 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11735 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11736 if (*tmp || *(tmp + 1))
11741 clib_warning ("BUG: match 0");
11743 _vec_len (mask) = match * sizeof (u32x4);
11753 #endif /* VPP_API_TEST_BUILTIN */
11755 #define foreach_l2_next \
11757 _(ethernet, ETHERNET_INPUT) \
11758 _(ip4, IP4_INPUT) \
11762 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11764 u32 *miss_next_indexp = va_arg (*args, u32 *);
11765 u32 next_index = 0;
11769 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11773 if (unformat (input, "%d", &tmp))
11782 *miss_next_indexp = next_index;
11786 #define foreach_ip_next \
11789 _(rewrite, REWRITE)
11792 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11794 u32 *miss_next_indexp = va_arg (*args, u32 *);
11795 u32 next_index = 0;
11799 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11803 if (unformat (input, "%d", &tmp))
11812 *miss_next_indexp = next_index;
11816 #define foreach_acl_next \
11820 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11822 u32 *miss_next_indexp = va_arg (*args, u32 *);
11823 u32 next_index = 0;
11827 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11831 if (unformat (input, "permit"))
11836 else if (unformat (input, "%d", &tmp))
11845 *miss_next_indexp = next_index;
11850 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11852 u32 *r = va_arg (*args, u32 *);
11854 if (unformat (input, "conform-color"))
11855 *r = POLICE_CONFORM;
11856 else if (unformat (input, "exceed-color"))
11857 *r = POLICE_EXCEED;
11865 api_classify_add_del_table (vat_main_t * vam)
11867 unformat_input_t *i = vam->input;
11868 vl_api_classify_add_del_table_t *mp;
11875 u32 table_index = ~0;
11876 u32 next_table_index = ~0;
11877 u32 miss_next_index = ~0;
11878 u32 memory_size = 32 << 20;
11880 u32 current_data_flag = 0;
11881 int current_data_offset = 0;
11884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11886 if (unformat (i, "del"))
11888 else if (unformat (i, "del-chain"))
11893 else if (unformat (i, "buckets %d", &nbuckets))
11895 else if (unformat (i, "memory_size %d", &memory_size))
11897 else if (unformat (i, "skip %d", &skip))
11899 else if (unformat (i, "match %d", &match))
11901 else if (unformat (i, "table %d", &table_index))
11903 else if (unformat (i, "mask %U", unformat_classify_mask,
11904 &mask, &skip, &match))
11906 else if (unformat (i, "next-table %d", &next_table_index))
11908 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11911 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11914 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11917 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11919 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11925 if (is_add && mask == 0)
11927 errmsg ("Mask required");
11931 if (is_add && skip == ~0)
11933 errmsg ("skip count required");
11937 if (is_add && match == ~0)
11939 errmsg ("match count required");
11943 if (!is_add && table_index == ~0)
11945 errmsg ("table index required for delete");
11949 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11951 mp->is_add = is_add;
11952 mp->del_chain = del_chain;
11953 mp->table_index = ntohl (table_index);
11954 mp->nbuckets = ntohl (nbuckets);
11955 mp->memory_size = ntohl (memory_size);
11956 mp->skip_n_vectors = ntohl (skip);
11957 mp->match_n_vectors = ntohl (match);
11958 mp->next_table_index = ntohl (next_table_index);
11959 mp->miss_next_index = ntohl (miss_next_index);
11960 mp->current_data_flag = ntohl (current_data_flag);
11961 mp->current_data_offset = ntohl (current_data_offset);
11962 mp->mask_len = ntohl (vec_len (mask));
11963 clib_memcpy (mp->mask, mask, vec_len (mask));
11972 #if VPP_API_TEST_BUILTIN == 0
11974 unformat_l4_match (unformat_input_t * input, va_list * args)
11976 u8 **matchp = va_arg (*args, u8 **);
11978 u8 *proto_header = 0;
11984 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11986 if (unformat (input, "src_port %d", &src_port))
11988 else if (unformat (input, "dst_port %d", &dst_port))
11994 h.src_port = clib_host_to_net_u16 (src_port);
11995 h.dst_port = clib_host_to_net_u16 (dst_port);
11996 vec_validate (proto_header, sizeof (h) - 1);
11997 memcpy (proto_header, &h, sizeof (h));
11999 *matchp = proto_header;
12005 unformat_ip4_match (unformat_input_t * input, va_list * args)
12007 u8 **matchp = va_arg (*args, u8 **);
12012 int hdr_length = 0;
12013 u32 hdr_length_val;
12014 int src = 0, dst = 0;
12015 ip4_address_t src_val, dst_val;
12022 int fragment_id = 0;
12023 u32 fragment_id_val;
12029 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12031 if (unformat (input, "version %d", &version_val))
12033 else if (unformat (input, "hdr_length %d", &hdr_length_val))
12035 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
12037 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
12039 else if (unformat (input, "proto %d", &proto_val))
12041 else if (unformat (input, "tos %d", &tos_val))
12043 else if (unformat (input, "length %d", &length_val))
12045 else if (unformat (input, "fragment_id %d", &fragment_id_val))
12047 else if (unformat (input, "ttl %d", &ttl_val))
12049 else if (unformat (input, "checksum %d", &checksum_val))
12055 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
12056 + ttl + checksum == 0)
12060 * Aligned because we use the real comparison functions
12062 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12064 ip = (ip4_header_t *) match;
12066 /* These are realistically matched in practice */
12068 ip->src_address.as_u32 = src_val.as_u32;
12071 ip->dst_address.as_u32 = dst_val.as_u32;
12074 ip->protocol = proto_val;
12077 /* These are not, but they're included for completeness */
12079 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
12082 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
12088 ip->length = clib_host_to_net_u16 (length_val);
12094 ip->checksum = clib_host_to_net_u16 (checksum_val);
12101 unformat_ip6_match (unformat_input_t * input, va_list * args)
12103 u8 **matchp = va_arg (*args, u8 **);
12108 u8 traffic_class = 0;
12109 u32 traffic_class_val = 0;
12112 int src = 0, dst = 0;
12113 ip6_address_t src_val, dst_val;
12116 int payload_length = 0;
12117 u32 payload_length_val;
12120 u32 ip_version_traffic_class_and_flow_label;
12122 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12124 if (unformat (input, "version %d", &version_val))
12126 else if (unformat (input, "traffic_class %d", &traffic_class_val))
12128 else if (unformat (input, "flow_label %d", &flow_label_val))
12130 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
12132 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
12134 else if (unformat (input, "proto %d", &proto_val))
12136 else if (unformat (input, "payload_length %d", &payload_length_val))
12137 payload_length = 1;
12138 else if (unformat (input, "hop_limit %d", &hop_limit_val))
12144 if (version + traffic_class + flow_label + src + dst + proto +
12145 payload_length + hop_limit == 0)
12149 * Aligned because we use the real comparison functions
12151 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12153 ip = (ip6_header_t *) match;
12156 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
12159 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
12162 ip->protocol = proto_val;
12164 ip_version_traffic_class_and_flow_label = 0;
12167 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
12170 ip_version_traffic_class_and_flow_label |=
12171 (traffic_class_val & 0xFF) << 20;
12174 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
12176 ip->ip_version_traffic_class_and_flow_label =
12177 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
12179 if (payload_length)
12180 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
12183 ip->hop_limit = hop_limit_val;
12190 unformat_l3_match (unformat_input_t * input, va_list * args)
12192 u8 **matchp = va_arg (*args, u8 **);
12194 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12196 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
12198 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
12207 unformat_vlan_tag (unformat_input_t * input, va_list * args)
12209 u8 *tagp = va_arg (*args, u8 *);
12212 if (unformat (input, "%d", &tag))
12214 tagp[0] = (tag >> 8) & 0x0F;
12215 tagp[1] = tag & 0xFF;
12223 unformat_l2_match (unformat_input_t * input, va_list * args)
12225 u8 **matchp = va_arg (*args, u8 **);
12238 u8 ignore_tag1 = 0;
12239 u8 ignore_tag2 = 0;
12245 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12247 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
12250 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
12252 else if (unformat (input, "proto %U",
12253 unformat_ethernet_type_host_byte_order, &proto_val))
12255 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
12257 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
12259 else if (unformat (input, "ignore-tag1"))
12261 else if (unformat (input, "ignore-tag2"))
12263 else if (unformat (input, "cos1 %d", &cos1_val))
12265 else if (unformat (input, "cos2 %d", &cos2_val))
12270 if ((src + dst + proto + tag1 + tag2 +
12271 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
12274 if (tag1 || ignore_tag1 || cos1)
12276 if (tag2 || ignore_tag2 || cos2)
12279 vec_validate_aligned (match, len - 1, sizeof (u32x4));
12282 clib_memcpy (match, dst_val, 6);
12285 clib_memcpy (match + 6, src_val, 6);
12289 /* inner vlan tag */
12290 match[19] = tag2_val[1];
12291 match[18] = tag2_val[0];
12293 match[18] |= (cos2_val & 0x7) << 5;
12296 match[21] = proto_val & 0xff;
12297 match[20] = proto_val >> 8;
12301 match[15] = tag1_val[1];
12302 match[14] = tag1_val[0];
12305 match[14] |= (cos1_val & 0x7) << 5;
12311 match[15] = tag1_val[1];
12312 match[14] = tag1_val[0];
12315 match[17] = proto_val & 0xff;
12316 match[16] = proto_val >> 8;
12319 match[14] |= (cos1_val & 0x7) << 5;
12325 match[18] |= (cos2_val & 0x7) << 5;
12327 match[14] |= (cos1_val & 0x7) << 5;
12330 match[13] = proto_val & 0xff;
12331 match[12] = proto_val >> 8;
12339 unformat_qos_source (unformat_input_t * input, va_list * args)
12341 int *qs = va_arg (*args, int *);
12343 if (unformat (input, "ip"))
12344 *qs = QOS_SOURCE_IP;
12345 else if (unformat (input, "mpls"))
12346 *qs = QOS_SOURCE_MPLS;
12347 else if (unformat (input, "ext"))
12348 *qs = QOS_SOURCE_EXT;
12349 else if (unformat (input, "vlan"))
12350 *qs = QOS_SOURCE_VLAN;
12359 api_unformat_classify_match (unformat_input_t * input, va_list * args)
12361 u8 **matchp = va_arg (*args, u8 **);
12362 u32 skip_n_vectors = va_arg (*args, u32);
12363 u32 match_n_vectors = va_arg (*args, u32);
12370 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12372 if (unformat (input, "hex %U", unformat_hex_string, &match))
12374 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
12376 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
12378 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
12392 if (match || l2 || l3 || l4)
12394 if (l2 || l3 || l4)
12396 /* "Win a free Ethernet header in every packet" */
12398 vec_validate_aligned (l2, 13, sizeof (u32x4));
12402 vec_append_aligned (match, l3, sizeof (u32x4));
12407 vec_append_aligned (match, l4, sizeof (u32x4));
12412 /* Make sure the vector is big enough even if key is all 0's */
12413 vec_validate_aligned
12414 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12417 /* Set size, include skipped vectors */
12418 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12429 api_classify_add_del_session (vat_main_t * vam)
12431 unformat_input_t *i = vam->input;
12432 vl_api_classify_add_del_session_t *mp;
12434 u32 table_index = ~0;
12435 u32 hit_next_index = ~0;
12436 u32 opaque_index = ~0;
12439 u32 skip_n_vectors = 0;
12440 u32 match_n_vectors = 0;
12446 * Warning: you have to supply skip_n and match_n
12447 * because the API client cant simply look at the classify
12451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12453 if (unformat (i, "del"))
12455 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12458 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12461 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12464 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12466 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12468 else if (unformat (i, "opaque-index %d", &opaque_index))
12470 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12472 else if (unformat (i, "match_n %d", &match_n_vectors))
12474 else if (unformat (i, "match %U", api_unformat_classify_match,
12475 &match, skip_n_vectors, match_n_vectors))
12477 else if (unformat (i, "advance %d", &advance))
12479 else if (unformat (i, "table-index %d", &table_index))
12481 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12483 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12485 else if (unformat (i, "action %d", &action))
12487 else if (unformat (i, "metadata %d", &metadata))
12493 if (table_index == ~0)
12495 errmsg ("Table index required");
12499 if (is_add && match == 0)
12501 errmsg ("Match value required");
12505 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12507 mp->is_add = is_add;
12508 mp->table_index = ntohl (table_index);
12509 mp->hit_next_index = ntohl (hit_next_index);
12510 mp->opaque_index = ntohl (opaque_index);
12511 mp->advance = ntohl (advance);
12512 mp->action = action;
12513 mp->metadata = ntohl (metadata);
12514 mp->match_len = ntohl (vec_len (match));
12515 clib_memcpy (mp->match, match, vec_len (match));
12524 api_classify_set_interface_ip_table (vat_main_t * vam)
12526 unformat_input_t *i = vam->input;
12527 vl_api_classify_set_interface_ip_table_t *mp;
12529 int sw_if_index_set;
12530 u32 table_index = ~0;
12534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12536 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12537 sw_if_index_set = 1;
12538 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12539 sw_if_index_set = 1;
12540 else if (unformat (i, "table %d", &table_index))
12544 clib_warning ("parse error '%U'", format_unformat_error, i);
12549 if (sw_if_index_set == 0)
12551 errmsg ("missing interface name or sw_if_index");
12556 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12558 mp->sw_if_index = ntohl (sw_if_index);
12559 mp->table_index = ntohl (table_index);
12560 mp->is_ipv6 = is_ipv6;
12568 api_classify_set_interface_l2_tables (vat_main_t * vam)
12570 unformat_input_t *i = vam->input;
12571 vl_api_classify_set_interface_l2_tables_t *mp;
12573 int sw_if_index_set;
12574 u32 ip4_table_index = ~0;
12575 u32 ip6_table_index = ~0;
12576 u32 other_table_index = ~0;
12580 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12582 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12583 sw_if_index_set = 1;
12584 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12585 sw_if_index_set = 1;
12586 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12588 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12590 else if (unformat (i, "other-table %d", &other_table_index))
12592 else if (unformat (i, "is-input %d", &is_input))
12596 clib_warning ("parse error '%U'", format_unformat_error, i);
12601 if (sw_if_index_set == 0)
12603 errmsg ("missing interface name or sw_if_index");
12608 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12610 mp->sw_if_index = ntohl (sw_if_index);
12611 mp->ip4_table_index = ntohl (ip4_table_index);
12612 mp->ip6_table_index = ntohl (ip6_table_index);
12613 mp->other_table_index = ntohl (other_table_index);
12614 mp->is_input = (u8) is_input;
12622 api_set_ipfix_exporter (vat_main_t * vam)
12624 unformat_input_t *i = vam->input;
12625 vl_api_set_ipfix_exporter_t *mp;
12626 ip4_address_t collector_address;
12627 u8 collector_address_set = 0;
12628 u32 collector_port = ~0;
12629 ip4_address_t src_address;
12630 u8 src_address_set = 0;
12633 u32 template_interval = ~0;
12634 u8 udp_checksum = 0;
12637 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12639 if (unformat (i, "collector_address %U", unformat_ip4_address,
12640 &collector_address))
12641 collector_address_set = 1;
12642 else if (unformat (i, "collector_port %d", &collector_port))
12644 else if (unformat (i, "src_address %U", unformat_ip4_address,
12646 src_address_set = 1;
12647 else if (unformat (i, "vrf_id %d", &vrf_id))
12649 else if (unformat (i, "path_mtu %d", &path_mtu))
12651 else if (unformat (i, "template_interval %d", &template_interval))
12653 else if (unformat (i, "udp_checksum"))
12659 if (collector_address_set == 0)
12661 errmsg ("collector_address required");
12665 if (src_address_set == 0)
12667 errmsg ("src_address required");
12671 M (SET_IPFIX_EXPORTER, mp);
12673 memcpy (mp->collector_address, collector_address.data,
12674 sizeof (collector_address.data));
12675 mp->collector_port = htons ((u16) collector_port);
12676 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12677 mp->vrf_id = htonl (vrf_id);
12678 mp->path_mtu = htonl (path_mtu);
12679 mp->template_interval = htonl (template_interval);
12680 mp->udp_checksum = udp_checksum;
12688 api_set_ipfix_classify_stream (vat_main_t * vam)
12690 unformat_input_t *i = vam->input;
12691 vl_api_set_ipfix_classify_stream_t *mp;
12693 u32 src_port = UDP_DST_PORT_ipfix;
12696 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12698 if (unformat (i, "domain %d", &domain_id))
12700 else if (unformat (i, "src_port %d", &src_port))
12704 errmsg ("unknown input `%U'", format_unformat_error, i);
12709 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12711 mp->domain_id = htonl (domain_id);
12712 mp->src_port = htons ((u16) src_port);
12720 api_ipfix_classify_table_add_del (vat_main_t * vam)
12722 unformat_input_t *i = vam->input;
12723 vl_api_ipfix_classify_table_add_del_t *mp;
12725 u32 classify_table_index = ~0;
12727 u8 transport_protocol = 255;
12730 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12732 if (unformat (i, "add"))
12734 else if (unformat (i, "del"))
12736 else if (unformat (i, "table %d", &classify_table_index))
12738 else if (unformat (i, "ip4"))
12740 else if (unformat (i, "ip6"))
12742 else if (unformat (i, "tcp"))
12743 transport_protocol = 6;
12744 else if (unformat (i, "udp"))
12745 transport_protocol = 17;
12748 errmsg ("unknown input `%U'", format_unformat_error, i);
12755 errmsg ("expecting: add|del");
12758 if (classify_table_index == ~0)
12760 errmsg ("classifier table not specified");
12763 if (ip_version == 0)
12765 errmsg ("IP version not specified");
12769 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12771 mp->is_add = is_add;
12772 mp->table_id = htonl (classify_table_index);
12773 mp->ip_version = ip_version;
12774 mp->transport_protocol = transport_protocol;
12782 api_get_node_index (vat_main_t * vam)
12784 unformat_input_t *i = vam->input;
12785 vl_api_get_node_index_t *mp;
12789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12791 if (unformat (i, "node %s", &name))
12798 errmsg ("node name required");
12801 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12803 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12807 M (GET_NODE_INDEX, mp);
12808 clib_memcpy (mp->node_name, name, vec_len (name));
12817 api_get_next_index (vat_main_t * vam)
12819 unformat_input_t *i = vam->input;
12820 vl_api_get_next_index_t *mp;
12821 u8 *node_name = 0, *next_node_name = 0;
12824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12826 if (unformat (i, "node-name %s", &node_name))
12828 else if (unformat (i, "next-node-name %s", &next_node_name))
12832 if (node_name == 0)
12834 errmsg ("node name required");
12837 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12839 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12843 if (next_node_name == 0)
12845 errmsg ("next node name required");
12848 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12850 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12854 M (GET_NEXT_INDEX, mp);
12855 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12856 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12857 vec_free (node_name);
12858 vec_free (next_node_name);
12866 api_add_node_next (vat_main_t * vam)
12868 unformat_input_t *i = vam->input;
12869 vl_api_add_node_next_t *mp;
12874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12876 if (unformat (i, "node %s", &name))
12878 else if (unformat (i, "next %s", &next))
12885 errmsg ("node name required");
12888 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12890 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12895 errmsg ("next node required");
12898 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12900 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12904 M (ADD_NODE_NEXT, mp);
12905 clib_memcpy (mp->node_name, name, vec_len (name));
12906 clib_memcpy (mp->next_name, next, vec_len (next));
12916 api_l2tpv3_create_tunnel (vat_main_t * vam)
12918 unformat_input_t *i = vam->input;
12919 ip6_address_t client_address, our_address;
12920 int client_address_set = 0;
12921 int our_address_set = 0;
12922 u32 local_session_id = 0;
12923 u32 remote_session_id = 0;
12924 u64 local_cookie = 0;
12925 u64 remote_cookie = 0;
12926 u8 l2_sublayer_present = 0;
12927 vl_api_l2tpv3_create_tunnel_t *mp;
12930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12932 if (unformat (i, "client_address %U", unformat_ip6_address,
12934 client_address_set = 1;
12935 else if (unformat (i, "our_address %U", unformat_ip6_address,
12937 our_address_set = 1;
12938 else if (unformat (i, "local_session_id %d", &local_session_id))
12940 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12942 else if (unformat (i, "local_cookie %lld", &local_cookie))
12944 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12946 else if (unformat (i, "l2-sublayer-present"))
12947 l2_sublayer_present = 1;
12952 if (client_address_set == 0)
12954 errmsg ("client_address required");
12958 if (our_address_set == 0)
12960 errmsg ("our_address required");
12964 M (L2TPV3_CREATE_TUNNEL, mp);
12966 clib_memcpy (mp->client_address, client_address.as_u8,
12967 sizeof (mp->client_address));
12969 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12971 mp->local_session_id = ntohl (local_session_id);
12972 mp->remote_session_id = ntohl (remote_session_id);
12973 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12974 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12975 mp->l2_sublayer_present = l2_sublayer_present;
12984 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12986 unformat_input_t *i = vam->input;
12988 u8 sw_if_index_set = 0;
12989 u64 new_local_cookie = 0;
12990 u64 new_remote_cookie = 0;
12991 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12994 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12996 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12997 sw_if_index_set = 1;
12998 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12999 sw_if_index_set = 1;
13000 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
13002 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
13008 if (sw_if_index_set == 0)
13010 errmsg ("missing interface name or sw_if_index");
13014 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
13016 mp->sw_if_index = ntohl (sw_if_index);
13017 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
13018 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
13026 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
13028 unformat_input_t *i = vam->input;
13029 vl_api_l2tpv3_interface_enable_disable_t *mp;
13031 u8 sw_if_index_set = 0;
13032 u8 enable_disable = 1;
13035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13037 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13038 sw_if_index_set = 1;
13039 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13040 sw_if_index_set = 1;
13041 else if (unformat (i, "enable"))
13042 enable_disable = 1;
13043 else if (unformat (i, "disable"))
13044 enable_disable = 0;
13049 if (sw_if_index_set == 0)
13051 errmsg ("missing interface name or sw_if_index");
13055 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
13057 mp->sw_if_index = ntohl (sw_if_index);
13058 mp->enable_disable = enable_disable;
13066 api_l2tpv3_set_lookup_key (vat_main_t * vam)
13068 unformat_input_t *i = vam->input;
13069 vl_api_l2tpv3_set_lookup_key_t *mp;
13073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13075 if (unformat (i, "lookup_v6_src"))
13076 key = L2T_LOOKUP_SRC_ADDRESS;
13077 else if (unformat (i, "lookup_v6_dst"))
13078 key = L2T_LOOKUP_DST_ADDRESS;
13079 else if (unformat (i, "lookup_session_id"))
13080 key = L2T_LOOKUP_SESSION_ID;
13085 if (key == (u8) ~ 0)
13087 errmsg ("l2tp session lookup key unset");
13091 M (L2TPV3_SET_LOOKUP_KEY, mp);
13100 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
13101 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13103 vat_main_t *vam = &vat_main;
13105 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
13106 format_ip6_address, mp->our_address,
13107 format_ip6_address, mp->client_address,
13108 clib_net_to_host_u32 (mp->sw_if_index));
13111 " local cookies %016llx %016llx remote cookie %016llx",
13112 clib_net_to_host_u64 (mp->local_cookie[0]),
13113 clib_net_to_host_u64 (mp->local_cookie[1]),
13114 clib_net_to_host_u64 (mp->remote_cookie));
13116 print (vam->ofp, " local session-id %d remote session-id %d",
13117 clib_net_to_host_u32 (mp->local_session_id),
13118 clib_net_to_host_u32 (mp->remote_session_id));
13120 print (vam->ofp, " l2 specific sublayer %s\n",
13121 mp->l2_sublayer_present ? "preset" : "absent");
13125 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
13126 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13128 vat_main_t *vam = &vat_main;
13129 vat_json_node_t *node = NULL;
13130 struct in6_addr addr;
13132 if (VAT_JSON_ARRAY != vam->json_tree.type)
13134 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13135 vat_json_init_array (&vam->json_tree);
13137 node = vat_json_array_add (&vam->json_tree);
13139 vat_json_init_object (node);
13141 clib_memcpy (&addr, mp->our_address, sizeof (addr));
13142 vat_json_object_add_ip6 (node, "our_address", addr);
13143 clib_memcpy (&addr, mp->client_address, sizeof (addr));
13144 vat_json_object_add_ip6 (node, "client_address", addr);
13146 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
13147 vat_json_init_array (lc);
13148 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
13149 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
13150 vat_json_object_add_uint (node, "remote_cookie",
13151 clib_net_to_host_u64 (mp->remote_cookie));
13153 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
13154 vat_json_object_add_uint (node, "local_session_id",
13155 clib_net_to_host_u32 (mp->local_session_id));
13156 vat_json_object_add_uint (node, "remote_session_id",
13157 clib_net_to_host_u32 (mp->remote_session_id));
13158 vat_json_object_add_string_copy (node, "l2_sublayer",
13159 mp->l2_sublayer_present ? (u8 *) "present"
13160 : (u8 *) "absent");
13164 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
13166 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
13167 vl_api_control_ping_t *mp_ping;
13170 /* Get list of l2tpv3-tunnel interfaces */
13171 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
13174 /* Use a control ping for synchronization */
13175 MPING (CONTROL_PING, mp_ping);
13183 static void vl_api_sw_interface_tap_details_t_handler
13184 (vl_api_sw_interface_tap_details_t * mp)
13186 vat_main_t *vam = &vat_main;
13188 print (vam->ofp, "%-16s %d",
13189 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
13192 static void vl_api_sw_interface_tap_details_t_handler_json
13193 (vl_api_sw_interface_tap_details_t * mp)
13195 vat_main_t *vam = &vat_main;
13196 vat_json_node_t *node = NULL;
13198 if (VAT_JSON_ARRAY != vam->json_tree.type)
13200 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13201 vat_json_init_array (&vam->json_tree);
13203 node = vat_json_array_add (&vam->json_tree);
13205 vat_json_init_object (node);
13206 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13207 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13211 api_sw_interface_tap_dump (vat_main_t * vam)
13213 vl_api_sw_interface_tap_dump_t *mp;
13214 vl_api_control_ping_t *mp_ping;
13217 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
13218 /* Get list of tap interfaces */
13219 M (SW_INTERFACE_TAP_DUMP, mp);
13222 /* Use a control ping for synchronization */
13223 MPING (CONTROL_PING, mp_ping);
13230 static void vl_api_sw_interface_tap_v2_details_t_handler
13231 (vl_api_sw_interface_tap_v2_details_t * mp)
13233 vat_main_t *vam = &vat_main;
13235 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
13236 mp->host_ip4_prefix_len);
13237 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
13238 mp->host_ip6_prefix_len);
13241 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
13242 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
13243 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
13244 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
13245 mp->host_bridge, ip4, ip6);
13251 static void vl_api_sw_interface_tap_v2_details_t_handler_json
13252 (vl_api_sw_interface_tap_v2_details_t * mp)
13254 vat_main_t *vam = &vat_main;
13255 vat_json_node_t *node = NULL;
13257 if (VAT_JSON_ARRAY != vam->json_tree.type)
13259 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13260 vat_json_init_array (&vam->json_tree);
13262 node = vat_json_array_add (&vam->json_tree);
13264 vat_json_init_object (node);
13265 vat_json_object_add_uint (node, "id", ntohl (mp->id));
13266 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13267 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13268 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
13269 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
13270 vat_json_object_add_string_copy (node, "host_mac_addr",
13271 format (0, "%U", format_ethernet_address,
13272 &mp->host_mac_addr));
13273 vat_json_object_add_string_copy (node, "host_namespace",
13274 mp->host_namespace);
13275 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
13276 vat_json_object_add_string_copy (node, "host_ip4_addr",
13277 format (0, "%U/%d", format_ip4_address,
13279 mp->host_ip4_prefix_len));
13280 vat_json_object_add_string_copy (node, "host_ip6_addr",
13281 format (0, "%U/%d", format_ip6_address,
13283 mp->host_ip6_prefix_len));
13288 api_sw_interface_tap_v2_dump (vat_main_t * vam)
13290 vl_api_sw_interface_tap_v2_dump_t *mp;
13291 vl_api_control_ping_t *mp_ping;
13295 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
13296 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
13297 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
13300 /* Get list of tap interfaces */
13301 M (SW_INTERFACE_TAP_V2_DUMP, mp);
13304 /* Use a control ping for synchronization */
13305 MPING (CONTROL_PING, mp_ping);
13313 api_vxlan_offload_rx (vat_main_t * vam)
13315 unformat_input_t *line_input = vam->input;
13316 vl_api_vxlan_offload_rx_t *mp;
13317 u32 hw_if_index = ~0, rx_if_index = ~0;
13321 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13323 if (unformat (line_input, "del"))
13325 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
13328 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
13330 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
13333 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
13337 errmsg ("parse error '%U'", format_unformat_error, line_input);
13342 if (hw_if_index == ~0)
13344 errmsg ("no hw interface");
13348 if (rx_if_index == ~0)
13350 errmsg ("no rx tunnel");
13354 M (VXLAN_OFFLOAD_RX, mp);
13356 mp->hw_if_index = ntohl (hw_if_index);
13357 mp->sw_if_index = ntohl (rx_if_index);
13358 mp->enable = is_add;
13365 static uword unformat_vxlan_decap_next
13366 (unformat_input_t * input, va_list * args)
13368 u32 *result = va_arg (*args, u32 *);
13371 if (unformat (input, "l2"))
13372 *result = VXLAN_INPUT_NEXT_L2_INPUT;
13373 else if (unformat (input, "%d", &tmp))
13381 api_vxlan_add_del_tunnel (vat_main_t * vam)
13383 unformat_input_t *line_input = vam->input;
13384 vl_api_vxlan_add_del_tunnel_t *mp;
13385 ip46_address_t src, dst;
13387 u8 ipv4_set = 0, ipv6_set = 0;
13392 u32 mcast_sw_if_index = ~0;
13393 u32 encap_vrf_id = 0;
13394 u32 decap_next_index = ~0;
13398 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13399 clib_memset (&src, 0, sizeof src);
13400 clib_memset (&dst, 0, sizeof dst);
13402 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13404 if (unformat (line_input, "del"))
13406 else if (unformat (line_input, "instance %d", &instance))
13409 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13415 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13421 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13427 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13432 else if (unformat (line_input, "group %U %U",
13433 unformat_ip4_address, &dst.ip4,
13434 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13436 grp_set = dst_set = 1;
13439 else if (unformat (line_input, "group %U",
13440 unformat_ip4_address, &dst.ip4))
13442 grp_set = dst_set = 1;
13445 else if (unformat (line_input, "group %U %U",
13446 unformat_ip6_address, &dst.ip6,
13447 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13449 grp_set = dst_set = 1;
13452 else if (unformat (line_input, "group %U",
13453 unformat_ip6_address, &dst.ip6))
13455 grp_set = dst_set = 1;
13459 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13461 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13463 else if (unformat (line_input, "decap-next %U",
13464 unformat_vxlan_decap_next, &decap_next_index))
13466 else if (unformat (line_input, "vni %d", &vni))
13470 errmsg ("parse error '%U'", format_unformat_error, line_input);
13477 errmsg ("tunnel src address not specified");
13482 errmsg ("tunnel dst address not specified");
13486 if (grp_set && !ip46_address_is_multicast (&dst))
13488 errmsg ("tunnel group address not multicast");
13491 if (grp_set && mcast_sw_if_index == ~0)
13493 errmsg ("tunnel nonexistent multicast device");
13496 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13498 errmsg ("tunnel dst address must be unicast");
13503 if (ipv4_set && ipv6_set)
13505 errmsg ("both IPv4 and IPv6 addresses specified");
13509 if ((vni == 0) || (vni >> 24))
13511 errmsg ("vni not specified or out of range");
13515 M (VXLAN_ADD_DEL_TUNNEL, mp);
13519 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13520 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13524 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13525 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13528 mp->instance = htonl (instance);
13529 mp->encap_vrf_id = ntohl (encap_vrf_id);
13530 mp->decap_next_index = ntohl (decap_next_index);
13531 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13532 mp->vni = ntohl (vni);
13533 mp->is_add = is_add;
13534 mp->is_ipv6 = ipv6_set;
13541 static void vl_api_vxlan_tunnel_details_t_handler
13542 (vl_api_vxlan_tunnel_details_t * mp)
13544 vat_main_t *vam = &vat_main;
13545 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13546 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13548 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13549 ntohl (mp->sw_if_index),
13550 ntohl (mp->instance),
13551 format_ip46_address, &src, IP46_TYPE_ANY,
13552 format_ip46_address, &dst, IP46_TYPE_ANY,
13553 ntohl (mp->encap_vrf_id),
13554 ntohl (mp->decap_next_index), ntohl (mp->vni),
13555 ntohl (mp->mcast_sw_if_index));
13558 static void vl_api_vxlan_tunnel_details_t_handler_json
13559 (vl_api_vxlan_tunnel_details_t * mp)
13561 vat_main_t *vam = &vat_main;
13562 vat_json_node_t *node = NULL;
13564 if (VAT_JSON_ARRAY != vam->json_tree.type)
13566 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13567 vat_json_init_array (&vam->json_tree);
13569 node = vat_json_array_add (&vam->json_tree);
13571 vat_json_init_object (node);
13572 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13574 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13578 struct in6_addr ip6;
13580 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13581 vat_json_object_add_ip6 (node, "src_address", ip6);
13582 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13583 vat_json_object_add_ip6 (node, "dst_address", ip6);
13587 struct in_addr ip4;
13589 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13590 vat_json_object_add_ip4 (node, "src_address", ip4);
13591 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13592 vat_json_object_add_ip4 (node, "dst_address", ip4);
13594 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13595 vat_json_object_add_uint (node, "decap_next_index",
13596 ntohl (mp->decap_next_index));
13597 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13598 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13599 vat_json_object_add_uint (node, "mcast_sw_if_index",
13600 ntohl (mp->mcast_sw_if_index));
13604 api_vxlan_tunnel_dump (vat_main_t * vam)
13606 unformat_input_t *i = vam->input;
13607 vl_api_vxlan_tunnel_dump_t *mp;
13608 vl_api_control_ping_t *mp_ping;
13610 u8 sw_if_index_set = 0;
13613 /* Parse args required to build the message */
13614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13616 if (unformat (i, "sw_if_index %d", &sw_if_index))
13617 sw_if_index_set = 1;
13622 if (sw_if_index_set == 0)
13627 if (!vam->json_output)
13629 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13630 "sw_if_index", "instance", "src_address", "dst_address",
13631 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13634 /* Get list of vxlan-tunnel interfaces */
13635 M (VXLAN_TUNNEL_DUMP, mp);
13637 mp->sw_if_index = htonl (sw_if_index);
13641 /* Use a control ping for synchronization */
13642 MPING (CONTROL_PING, mp_ping);
13649 static uword unformat_geneve_decap_next
13650 (unformat_input_t * input, va_list * args)
13652 u32 *result = va_arg (*args, u32 *);
13655 if (unformat (input, "l2"))
13656 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13657 else if (unformat (input, "%d", &tmp))
13665 api_geneve_add_del_tunnel (vat_main_t * vam)
13667 unformat_input_t *line_input = vam->input;
13668 vl_api_geneve_add_del_tunnel_t *mp;
13669 ip46_address_t src, dst;
13671 u8 ipv4_set = 0, ipv6_set = 0;
13675 u32 mcast_sw_if_index = ~0;
13676 u32 encap_vrf_id = 0;
13677 u32 decap_next_index = ~0;
13681 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13682 clib_memset (&src, 0, sizeof src);
13683 clib_memset (&dst, 0, sizeof dst);
13685 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13687 if (unformat (line_input, "del"))
13690 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13696 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13702 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13708 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13713 else if (unformat (line_input, "group %U %U",
13714 unformat_ip4_address, &dst.ip4,
13715 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13717 grp_set = dst_set = 1;
13720 else if (unformat (line_input, "group %U",
13721 unformat_ip4_address, &dst.ip4))
13723 grp_set = dst_set = 1;
13726 else if (unformat (line_input, "group %U %U",
13727 unformat_ip6_address, &dst.ip6,
13728 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13730 grp_set = dst_set = 1;
13733 else if (unformat (line_input, "group %U",
13734 unformat_ip6_address, &dst.ip6))
13736 grp_set = dst_set = 1;
13740 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13742 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13744 else if (unformat (line_input, "decap-next %U",
13745 unformat_geneve_decap_next, &decap_next_index))
13747 else if (unformat (line_input, "vni %d", &vni))
13751 errmsg ("parse error '%U'", format_unformat_error, line_input);
13758 errmsg ("tunnel src address not specified");
13763 errmsg ("tunnel dst address not specified");
13767 if (grp_set && !ip46_address_is_multicast (&dst))
13769 errmsg ("tunnel group address not multicast");
13772 if (grp_set && mcast_sw_if_index == ~0)
13774 errmsg ("tunnel nonexistent multicast device");
13777 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13779 errmsg ("tunnel dst address must be unicast");
13784 if (ipv4_set && ipv6_set)
13786 errmsg ("both IPv4 and IPv6 addresses specified");
13790 if ((vni == 0) || (vni >> 24))
13792 errmsg ("vni not specified or out of range");
13796 M (GENEVE_ADD_DEL_TUNNEL, mp);
13800 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13801 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13805 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13806 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13808 mp->encap_vrf_id = ntohl (encap_vrf_id);
13809 mp->decap_next_index = ntohl (decap_next_index);
13810 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13811 mp->vni = ntohl (vni);
13812 mp->is_add = is_add;
13813 mp->is_ipv6 = ipv6_set;
13820 static void vl_api_geneve_tunnel_details_t_handler
13821 (vl_api_geneve_tunnel_details_t * mp)
13823 vat_main_t *vam = &vat_main;
13824 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13825 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13827 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13828 ntohl (mp->sw_if_index),
13829 format_ip46_address, &src, IP46_TYPE_ANY,
13830 format_ip46_address, &dst, IP46_TYPE_ANY,
13831 ntohl (mp->encap_vrf_id),
13832 ntohl (mp->decap_next_index), ntohl (mp->vni),
13833 ntohl (mp->mcast_sw_if_index));
13836 static void vl_api_geneve_tunnel_details_t_handler_json
13837 (vl_api_geneve_tunnel_details_t * mp)
13839 vat_main_t *vam = &vat_main;
13840 vat_json_node_t *node = NULL;
13842 if (VAT_JSON_ARRAY != vam->json_tree.type)
13844 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13845 vat_json_init_array (&vam->json_tree);
13847 node = vat_json_array_add (&vam->json_tree);
13849 vat_json_init_object (node);
13850 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13853 struct in6_addr ip6;
13855 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13856 vat_json_object_add_ip6 (node, "src_address", ip6);
13857 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13858 vat_json_object_add_ip6 (node, "dst_address", ip6);
13862 struct in_addr ip4;
13864 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13865 vat_json_object_add_ip4 (node, "src_address", ip4);
13866 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13867 vat_json_object_add_ip4 (node, "dst_address", ip4);
13869 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13870 vat_json_object_add_uint (node, "decap_next_index",
13871 ntohl (mp->decap_next_index));
13872 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13873 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13874 vat_json_object_add_uint (node, "mcast_sw_if_index",
13875 ntohl (mp->mcast_sw_if_index));
13879 api_geneve_tunnel_dump (vat_main_t * vam)
13881 unformat_input_t *i = vam->input;
13882 vl_api_geneve_tunnel_dump_t *mp;
13883 vl_api_control_ping_t *mp_ping;
13885 u8 sw_if_index_set = 0;
13888 /* Parse args required to build the message */
13889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13891 if (unformat (i, "sw_if_index %d", &sw_if_index))
13892 sw_if_index_set = 1;
13897 if (sw_if_index_set == 0)
13902 if (!vam->json_output)
13904 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13905 "sw_if_index", "local_address", "remote_address",
13906 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13909 /* Get list of geneve-tunnel interfaces */
13910 M (GENEVE_TUNNEL_DUMP, mp);
13912 mp->sw_if_index = htonl (sw_if_index);
13916 /* Use a control ping for synchronization */
13917 M (CONTROL_PING, mp_ping);
13925 api_gre_add_del_tunnel (vat_main_t * vam)
13927 unformat_input_t *line_input = vam->input;
13928 vl_api_gre_add_del_tunnel_t *mp;
13929 ip4_address_t src4, dst4;
13930 ip6_address_t src6, dst6;
13934 u8 t_type = GRE_TUNNEL_TYPE_L3;
13937 u32 outer_fib_id = 0;
13938 u32 session_id = 0;
13942 clib_memset (&src4, 0, sizeof src4);
13943 clib_memset (&dst4, 0, sizeof dst4);
13944 clib_memset (&src6, 0, sizeof src6);
13945 clib_memset (&dst6, 0, sizeof dst6);
13947 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13949 if (unformat (line_input, "del"))
13951 else if (unformat (line_input, "instance %d", &instance))
13953 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13958 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13963 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13968 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13973 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13975 else if (unformat (line_input, "teb"))
13976 t_type = GRE_TUNNEL_TYPE_TEB;
13977 else if (unformat (line_input, "erspan %d", &session_id))
13978 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13981 errmsg ("parse error '%U'", format_unformat_error, line_input);
13988 errmsg ("tunnel src address not specified");
13993 errmsg ("tunnel dst address not specified");
13996 if (ipv4_set && ipv6_set)
13998 errmsg ("both IPv4 and IPv6 addresses specified");
14003 M (GRE_ADD_DEL_TUNNEL, mp);
14007 clib_memcpy (&mp->src_address, &src4, 4);
14008 clib_memcpy (&mp->dst_address, &dst4, 4);
14012 clib_memcpy (&mp->src_address, &src6, 16);
14013 clib_memcpy (&mp->dst_address, &dst6, 16);
14015 mp->instance = htonl (instance);
14016 mp->outer_fib_id = htonl (outer_fib_id);
14017 mp->is_add = is_add;
14018 mp->session_id = htons ((u16) session_id);
14019 mp->tunnel_type = t_type;
14020 mp->is_ipv6 = ipv6_set;
14027 static void vl_api_gre_tunnel_details_t_handler
14028 (vl_api_gre_tunnel_details_t * mp)
14030 vat_main_t *vam = &vat_main;
14031 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
14032 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
14034 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
14035 ntohl (mp->sw_if_index),
14036 ntohl (mp->instance),
14037 format_ip46_address, &src, IP46_TYPE_ANY,
14038 format_ip46_address, &dst, IP46_TYPE_ANY,
14039 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
14042 static void vl_api_gre_tunnel_details_t_handler_json
14043 (vl_api_gre_tunnel_details_t * mp)
14045 vat_main_t *vam = &vat_main;
14046 vat_json_node_t *node = NULL;
14047 struct in_addr ip4;
14048 struct in6_addr ip6;
14050 if (VAT_JSON_ARRAY != vam->json_tree.type)
14052 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14053 vat_json_init_array (&vam->json_tree);
14055 node = vat_json_array_add (&vam->json_tree);
14057 vat_json_init_object (node);
14058 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14059 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
14062 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
14063 vat_json_object_add_ip4 (node, "src_address", ip4);
14064 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
14065 vat_json_object_add_ip4 (node, "dst_address", ip4);
14069 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
14070 vat_json_object_add_ip6 (node, "src_address", ip6);
14071 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
14072 vat_json_object_add_ip6 (node, "dst_address", ip6);
14074 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
14075 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
14076 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
14077 vat_json_object_add_uint (node, "session_id", mp->session_id);
14081 api_gre_tunnel_dump (vat_main_t * vam)
14083 unformat_input_t *i = vam->input;
14084 vl_api_gre_tunnel_dump_t *mp;
14085 vl_api_control_ping_t *mp_ping;
14087 u8 sw_if_index_set = 0;
14090 /* Parse args required to build the message */
14091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14093 if (unformat (i, "sw_if_index %d", &sw_if_index))
14094 sw_if_index_set = 1;
14099 if (sw_if_index_set == 0)
14104 if (!vam->json_output)
14106 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
14107 "sw_if_index", "instance", "src_address", "dst_address",
14108 "tunnel_type", "outer_fib_id", "session_id");
14111 /* Get list of gre-tunnel interfaces */
14112 M (GRE_TUNNEL_DUMP, mp);
14114 mp->sw_if_index = htonl (sw_if_index);
14118 /* Use a control ping for synchronization */
14119 MPING (CONTROL_PING, mp_ping);
14127 api_l2_fib_clear_table (vat_main_t * vam)
14129 // unformat_input_t * i = vam->input;
14130 vl_api_l2_fib_clear_table_t *mp;
14133 M (L2_FIB_CLEAR_TABLE, mp);
14141 api_l2_interface_efp_filter (vat_main_t * vam)
14143 unformat_input_t *i = vam->input;
14144 vl_api_l2_interface_efp_filter_t *mp;
14147 u8 sw_if_index_set = 0;
14150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14152 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14153 sw_if_index_set = 1;
14154 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14155 sw_if_index_set = 1;
14156 else if (unformat (i, "enable"))
14158 else if (unformat (i, "disable"))
14162 clib_warning ("parse error '%U'", format_unformat_error, i);
14167 if (sw_if_index_set == 0)
14169 errmsg ("missing sw_if_index");
14173 M (L2_INTERFACE_EFP_FILTER, mp);
14175 mp->sw_if_index = ntohl (sw_if_index);
14176 mp->enable_disable = enable;
14183 #define foreach_vtr_op \
14184 _("disable", L2_VTR_DISABLED) \
14185 _("push-1", L2_VTR_PUSH_1) \
14186 _("push-2", L2_VTR_PUSH_2) \
14187 _("pop-1", L2_VTR_POP_1) \
14188 _("pop-2", L2_VTR_POP_2) \
14189 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
14190 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
14191 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
14192 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
14195 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
14197 unformat_input_t *i = vam->input;
14198 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
14200 u8 sw_if_index_set = 0;
14203 u32 push_dot1q = 1;
14208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14210 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14211 sw_if_index_set = 1;
14212 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14213 sw_if_index_set = 1;
14214 else if (unformat (i, "vtr_op %d", &vtr_op))
14216 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
14219 else if (unformat (i, "push_dot1q %d", &push_dot1q))
14221 else if (unformat (i, "tag1 %d", &tag1))
14223 else if (unformat (i, "tag2 %d", &tag2))
14227 clib_warning ("parse error '%U'", format_unformat_error, i);
14232 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
14234 errmsg ("missing vtr operation or sw_if_index");
14238 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
14239 mp->sw_if_index = ntohl (sw_if_index);
14240 mp->vtr_op = ntohl (vtr_op);
14241 mp->push_dot1q = ntohl (push_dot1q);
14242 mp->tag1 = ntohl (tag1);
14243 mp->tag2 = ntohl (tag2);
14251 api_create_vhost_user_if (vat_main_t * vam)
14253 unformat_input_t *i = vam->input;
14254 vl_api_create_vhost_user_if_t *mp;
14257 u8 file_name_set = 0;
14258 u32 custom_dev_instance = ~0;
14260 u8 use_custom_mac = 0;
14261 u8 disable_mrg_rxbuf = 0;
14262 u8 disable_indirect_desc = 0;
14266 /* Shut up coverity */
14267 clib_memset (hwaddr, 0, sizeof (hwaddr));
14269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14271 if (unformat (i, "socket %s", &file_name))
14275 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14277 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
14278 use_custom_mac = 1;
14279 else if (unformat (i, "server"))
14281 else if (unformat (i, "disable_mrg_rxbuf"))
14282 disable_mrg_rxbuf = 1;
14283 else if (unformat (i, "disable_indirect_desc"))
14284 disable_indirect_desc = 1;
14285 else if (unformat (i, "tag %s", &tag))
14291 if (file_name_set == 0)
14293 errmsg ("missing socket file name");
14297 if (vec_len (file_name) > 255)
14299 errmsg ("socket file name too long");
14302 vec_add1 (file_name, 0);
14304 M (CREATE_VHOST_USER_IF, mp);
14306 mp->is_server = is_server;
14307 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
14308 mp->disable_indirect_desc = disable_indirect_desc;
14309 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14310 vec_free (file_name);
14311 if (custom_dev_instance != ~0)
14314 mp->custom_dev_instance = ntohl (custom_dev_instance);
14317 mp->use_custom_mac = use_custom_mac;
14318 clib_memcpy (mp->mac_address, hwaddr, 6);
14320 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
14329 api_modify_vhost_user_if (vat_main_t * vam)
14331 unformat_input_t *i = vam->input;
14332 vl_api_modify_vhost_user_if_t *mp;
14335 u8 file_name_set = 0;
14336 u32 custom_dev_instance = ~0;
14337 u8 sw_if_index_set = 0;
14338 u32 sw_if_index = (u32) ~ 0;
14341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14343 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14344 sw_if_index_set = 1;
14345 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14346 sw_if_index_set = 1;
14347 else if (unformat (i, "socket %s", &file_name))
14351 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14353 else if (unformat (i, "server"))
14359 if (sw_if_index_set == 0)
14361 errmsg ("missing sw_if_index or interface name");
14365 if (file_name_set == 0)
14367 errmsg ("missing socket file name");
14371 if (vec_len (file_name) > 255)
14373 errmsg ("socket file name too long");
14376 vec_add1 (file_name, 0);
14378 M (MODIFY_VHOST_USER_IF, mp);
14380 mp->sw_if_index = ntohl (sw_if_index);
14381 mp->is_server = is_server;
14382 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14383 vec_free (file_name);
14384 if (custom_dev_instance != ~0)
14387 mp->custom_dev_instance = ntohl (custom_dev_instance);
14396 api_delete_vhost_user_if (vat_main_t * vam)
14398 unformat_input_t *i = vam->input;
14399 vl_api_delete_vhost_user_if_t *mp;
14400 u32 sw_if_index = ~0;
14401 u8 sw_if_index_set = 0;
14404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14406 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14407 sw_if_index_set = 1;
14408 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14409 sw_if_index_set = 1;
14414 if (sw_if_index_set == 0)
14416 errmsg ("missing sw_if_index or interface name");
14421 M (DELETE_VHOST_USER_IF, mp);
14423 mp->sw_if_index = ntohl (sw_if_index);
14430 static void vl_api_sw_interface_vhost_user_details_t_handler
14431 (vl_api_sw_interface_vhost_user_details_t * mp)
14433 vat_main_t *vam = &vat_main;
14435 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14436 (char *) mp->interface_name,
14437 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14438 clib_net_to_host_u64 (mp->features), mp->is_server,
14439 ntohl (mp->num_regions), (char *) mp->sock_filename);
14440 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14443 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14444 (vl_api_sw_interface_vhost_user_details_t * mp)
14446 vat_main_t *vam = &vat_main;
14447 vat_json_node_t *node = NULL;
14449 if (VAT_JSON_ARRAY != vam->json_tree.type)
14451 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14452 vat_json_init_array (&vam->json_tree);
14454 node = vat_json_array_add (&vam->json_tree);
14456 vat_json_init_object (node);
14457 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14458 vat_json_object_add_string_copy (node, "interface_name",
14459 mp->interface_name);
14460 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14461 ntohl (mp->virtio_net_hdr_sz));
14462 vat_json_object_add_uint (node, "features",
14463 clib_net_to_host_u64 (mp->features));
14464 vat_json_object_add_uint (node, "is_server", mp->is_server);
14465 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14466 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14467 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14471 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14473 vl_api_sw_interface_vhost_user_dump_t *mp;
14474 vl_api_control_ping_t *mp_ping;
14477 "Interface name idx hdr_sz features server regions filename");
14479 /* Get list of vhost-user interfaces */
14480 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14483 /* Use a control ping for synchronization */
14484 MPING (CONTROL_PING, mp_ping);
14492 api_show_version (vat_main_t * vam)
14494 vl_api_show_version_t *mp;
14497 M (SHOW_VERSION, mp);
14506 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14508 unformat_input_t *line_input = vam->input;
14509 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14510 ip4_address_t local4, remote4;
14511 ip6_address_t local6, remote6;
14513 u8 ipv4_set = 0, ipv6_set = 0;
14517 u32 mcast_sw_if_index = ~0;
14518 u32 encap_vrf_id = 0;
14519 u32 decap_vrf_id = 0;
14525 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14526 clib_memset (&local4, 0, sizeof local4);
14527 clib_memset (&remote4, 0, sizeof remote4);
14528 clib_memset (&local6, 0, sizeof local6);
14529 clib_memset (&remote6, 0, sizeof remote6);
14531 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14533 if (unformat (line_input, "del"))
14535 else if (unformat (line_input, "local %U",
14536 unformat_ip4_address, &local4))
14541 else if (unformat (line_input, "remote %U",
14542 unformat_ip4_address, &remote4))
14547 else if (unformat (line_input, "local %U",
14548 unformat_ip6_address, &local6))
14553 else if (unformat (line_input, "remote %U",
14554 unformat_ip6_address, &remote6))
14559 else if (unformat (line_input, "group %U %U",
14560 unformat_ip4_address, &remote4,
14561 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14563 grp_set = remote_set = 1;
14566 else if (unformat (line_input, "group %U",
14567 unformat_ip4_address, &remote4))
14569 grp_set = remote_set = 1;
14572 else if (unformat (line_input, "group %U %U",
14573 unformat_ip6_address, &remote6,
14574 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14576 grp_set = remote_set = 1;
14579 else if (unformat (line_input, "group %U",
14580 unformat_ip6_address, &remote6))
14582 grp_set = remote_set = 1;
14586 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14588 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14590 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14592 else if (unformat (line_input, "vni %d", &vni))
14594 else if (unformat (line_input, "next-ip4"))
14596 else if (unformat (line_input, "next-ip6"))
14598 else if (unformat (line_input, "next-ethernet"))
14600 else if (unformat (line_input, "next-nsh"))
14604 errmsg ("parse error '%U'", format_unformat_error, line_input);
14609 if (local_set == 0)
14611 errmsg ("tunnel local address not specified");
14614 if (remote_set == 0)
14616 errmsg ("tunnel remote address not specified");
14619 if (grp_set && mcast_sw_if_index == ~0)
14621 errmsg ("tunnel nonexistent multicast device");
14624 if (ipv4_set && ipv6_set)
14626 errmsg ("both IPv4 and IPv6 addresses specified");
14632 errmsg ("vni not specified");
14636 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14641 clib_memcpy (&mp->local, &local6, sizeof (local6));
14642 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14646 clib_memcpy (&mp->local, &local4, sizeof (local4));
14647 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14650 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14651 mp->encap_vrf_id = ntohl (encap_vrf_id);
14652 mp->decap_vrf_id = ntohl (decap_vrf_id);
14653 mp->protocol = protocol;
14654 mp->vni = ntohl (vni);
14655 mp->is_add = is_add;
14656 mp->is_ipv6 = ipv6_set;
14663 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14664 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14666 vat_main_t *vam = &vat_main;
14667 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14668 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14670 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14671 ntohl (mp->sw_if_index),
14672 format_ip46_address, &local, IP46_TYPE_ANY,
14673 format_ip46_address, &remote, IP46_TYPE_ANY,
14674 ntohl (mp->vni), mp->protocol,
14675 ntohl (mp->mcast_sw_if_index),
14676 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14680 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14681 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14683 vat_main_t *vam = &vat_main;
14684 vat_json_node_t *node = NULL;
14685 struct in_addr ip4;
14686 struct in6_addr ip6;
14688 if (VAT_JSON_ARRAY != vam->json_tree.type)
14690 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14691 vat_json_init_array (&vam->json_tree);
14693 node = vat_json_array_add (&vam->json_tree);
14695 vat_json_init_object (node);
14696 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14699 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14700 vat_json_object_add_ip6 (node, "local", ip6);
14701 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14702 vat_json_object_add_ip6 (node, "remote", ip6);
14706 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14707 vat_json_object_add_ip4 (node, "local", ip4);
14708 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14709 vat_json_object_add_ip4 (node, "remote", ip4);
14711 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14712 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14713 vat_json_object_add_uint (node, "mcast_sw_if_index",
14714 ntohl (mp->mcast_sw_if_index));
14715 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14716 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14717 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14721 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14723 unformat_input_t *i = vam->input;
14724 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14725 vl_api_control_ping_t *mp_ping;
14727 u8 sw_if_index_set = 0;
14730 /* Parse args required to build the message */
14731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14733 if (unformat (i, "sw_if_index %d", &sw_if_index))
14734 sw_if_index_set = 1;
14739 if (sw_if_index_set == 0)
14744 if (!vam->json_output)
14746 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14747 "sw_if_index", "local", "remote", "vni",
14748 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14751 /* Get list of vxlan-tunnel interfaces */
14752 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14754 mp->sw_if_index = htonl (sw_if_index);
14758 /* Use a control ping for synchronization */
14759 MPING (CONTROL_PING, mp_ping);
14766 static void vl_api_l2_fib_table_details_t_handler
14767 (vl_api_l2_fib_table_details_t * mp)
14769 vat_main_t *vam = &vat_main;
14771 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14773 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14774 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14778 static void vl_api_l2_fib_table_details_t_handler_json
14779 (vl_api_l2_fib_table_details_t * mp)
14781 vat_main_t *vam = &vat_main;
14782 vat_json_node_t *node = NULL;
14784 if (VAT_JSON_ARRAY != vam->json_tree.type)
14786 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14787 vat_json_init_array (&vam->json_tree);
14789 node = vat_json_array_add (&vam->json_tree);
14791 vat_json_init_object (node);
14792 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14793 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14794 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14795 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14796 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14797 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14801 api_l2_fib_table_dump (vat_main_t * vam)
14803 unformat_input_t *i = vam->input;
14804 vl_api_l2_fib_table_dump_t *mp;
14805 vl_api_control_ping_t *mp_ping;
14810 /* Parse args required to build the message */
14811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14813 if (unformat (i, "bd_id %d", &bd_id))
14819 if (bd_id_set == 0)
14821 errmsg ("missing bridge domain");
14825 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14827 /* Get list of l2 fib entries */
14828 M (L2_FIB_TABLE_DUMP, mp);
14830 mp->bd_id = ntohl (bd_id);
14833 /* Use a control ping for synchronization */
14834 MPING (CONTROL_PING, mp_ping);
14843 api_interface_name_renumber (vat_main_t * vam)
14845 unformat_input_t *line_input = vam->input;
14846 vl_api_interface_name_renumber_t *mp;
14847 u32 sw_if_index = ~0;
14848 u32 new_show_dev_instance = ~0;
14851 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14853 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14856 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14858 else if (unformat (line_input, "new_show_dev_instance %d",
14859 &new_show_dev_instance))
14865 if (sw_if_index == ~0)
14867 errmsg ("missing interface name or sw_if_index");
14871 if (new_show_dev_instance == ~0)
14873 errmsg ("missing new_show_dev_instance");
14877 M (INTERFACE_NAME_RENUMBER, mp);
14879 mp->sw_if_index = ntohl (sw_if_index);
14880 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14888 api_ip_probe_neighbor (vat_main_t * vam)
14890 unformat_input_t *i = vam->input;
14891 vl_api_ip_probe_neighbor_t *mp;
14899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14901 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14903 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14905 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14907 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14918 errmsg ("missing interface");
14924 errmsg ("missing addresses");
14928 M (IP_PROBE_NEIGHBOR, mp);
14930 mp->sw_if_index = ntohl (sw_if_index);
14931 mp->is_ipv6 = is_ipv6;
14932 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14940 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14942 unformat_input_t *i = vam->input;
14943 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14944 u8 mode = IP_SCAN_V46_NEIGHBORS;
14945 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14950 if (unformat (i, "ip4"))
14951 mode = IP_SCAN_V4_NEIGHBORS;
14952 else if (unformat (i, "ip6"))
14953 mode = IP_SCAN_V6_NEIGHBORS;
14954 if (unformat (i, "both"))
14955 mode = IP_SCAN_V46_NEIGHBORS;
14956 else if (unformat (i, "disable"))
14957 mode = IP_SCAN_DISABLED;
14958 else if (unformat (i, "interval %d", &interval))
14960 else if (unformat (i, "max-time %d", &time))
14962 else if (unformat (i, "max-update %d", &update))
14964 else if (unformat (i, "delay %d", &delay))
14966 else if (unformat (i, "stale %d", &stale))
14972 if (interval > 255)
14974 errmsg ("interval cannot exceed 255 minutes.");
14979 errmsg ("max-time cannot exceed 255 usec.");
14984 errmsg ("max-update cannot exceed 255.");
14989 errmsg ("delay cannot exceed 255 msec.");
14994 errmsg ("stale cannot exceed 255 minutes.");
14998 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
15000 mp->scan_interval = interval;
15001 mp->max_proc_time = time;
15002 mp->max_update = update;
15003 mp->scan_int_delay = delay;
15004 mp->stale_threshold = stale;
15012 api_want_ip4_arp_events (vat_main_t * vam)
15014 unformat_input_t *line_input = vam->input;
15015 vl_api_want_ip4_arp_events_t *mp;
15016 ip4_address_t address;
15017 int address_set = 0;
15018 u32 enable_disable = 1;
15021 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15023 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
15025 else if (unformat (line_input, "del"))
15026 enable_disable = 0;
15031 if (address_set == 0)
15033 errmsg ("missing addresses");
15037 M (WANT_IP4_ARP_EVENTS, mp);
15038 mp->enable_disable = enable_disable;
15039 mp->pid = htonl (getpid ());
15040 mp->address = address.as_u32;
15048 api_want_ip6_nd_events (vat_main_t * vam)
15050 unformat_input_t *line_input = vam->input;
15051 vl_api_want_ip6_nd_events_t *mp;
15052 ip6_address_t address;
15053 int address_set = 0;
15054 u32 enable_disable = 1;
15057 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15059 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
15061 else if (unformat (line_input, "del"))
15062 enable_disable = 0;
15067 if (address_set == 0)
15069 errmsg ("missing addresses");
15073 M (WANT_IP6_ND_EVENTS, mp);
15074 mp->enable_disable = enable_disable;
15075 mp->pid = htonl (getpid ());
15076 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
15084 api_want_l2_macs_events (vat_main_t * vam)
15086 unformat_input_t *line_input = vam->input;
15087 vl_api_want_l2_macs_events_t *mp;
15088 u8 enable_disable = 1;
15089 u32 scan_delay = 0;
15090 u32 max_macs_in_event = 0;
15091 u32 learn_limit = 0;
15094 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15096 if (unformat (line_input, "learn-limit %d", &learn_limit))
15098 else if (unformat (line_input, "scan-delay %d", &scan_delay))
15100 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
15102 else if (unformat (line_input, "disable"))
15103 enable_disable = 0;
15108 M (WANT_L2_MACS_EVENTS, mp);
15109 mp->enable_disable = enable_disable;
15110 mp->pid = htonl (getpid ());
15111 mp->learn_limit = htonl (learn_limit);
15112 mp->scan_delay = (u8) scan_delay;
15113 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
15120 api_input_acl_set_interface (vat_main_t * vam)
15122 unformat_input_t *i = vam->input;
15123 vl_api_input_acl_set_interface_t *mp;
15125 int sw_if_index_set;
15126 u32 ip4_table_index = ~0;
15127 u32 ip6_table_index = ~0;
15128 u32 l2_table_index = ~0;
15132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15134 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15135 sw_if_index_set = 1;
15136 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15137 sw_if_index_set = 1;
15138 else if (unformat (i, "del"))
15140 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15142 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15144 else if (unformat (i, "l2-table %d", &l2_table_index))
15148 clib_warning ("parse error '%U'", format_unformat_error, i);
15153 if (sw_if_index_set == 0)
15155 errmsg ("missing interface name or sw_if_index");
15159 M (INPUT_ACL_SET_INTERFACE, mp);
15161 mp->sw_if_index = ntohl (sw_if_index);
15162 mp->ip4_table_index = ntohl (ip4_table_index);
15163 mp->ip6_table_index = ntohl (ip6_table_index);
15164 mp->l2_table_index = ntohl (l2_table_index);
15165 mp->is_add = is_add;
15173 api_output_acl_set_interface (vat_main_t * vam)
15175 unformat_input_t *i = vam->input;
15176 vl_api_output_acl_set_interface_t *mp;
15178 int sw_if_index_set;
15179 u32 ip4_table_index = ~0;
15180 u32 ip6_table_index = ~0;
15181 u32 l2_table_index = ~0;
15185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15187 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15188 sw_if_index_set = 1;
15189 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15190 sw_if_index_set = 1;
15191 else if (unformat (i, "del"))
15193 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15195 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15197 else if (unformat (i, "l2-table %d", &l2_table_index))
15201 clib_warning ("parse error '%U'", format_unformat_error, i);
15206 if (sw_if_index_set == 0)
15208 errmsg ("missing interface name or sw_if_index");
15212 M (OUTPUT_ACL_SET_INTERFACE, mp);
15214 mp->sw_if_index = ntohl (sw_if_index);
15215 mp->ip4_table_index = ntohl (ip4_table_index);
15216 mp->ip6_table_index = ntohl (ip6_table_index);
15217 mp->l2_table_index = ntohl (l2_table_index);
15218 mp->is_add = is_add;
15226 api_ip_address_dump (vat_main_t * vam)
15228 unformat_input_t *i = vam->input;
15229 vl_api_ip_address_dump_t *mp;
15230 vl_api_control_ping_t *mp_ping;
15231 u32 sw_if_index = ~0;
15232 u8 sw_if_index_set = 0;
15237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15239 if (unformat (i, "sw_if_index %d", &sw_if_index))
15240 sw_if_index_set = 1;
15242 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15243 sw_if_index_set = 1;
15244 else if (unformat (i, "ipv4"))
15246 else if (unformat (i, "ipv6"))
15252 if (ipv4_set && ipv6_set)
15254 errmsg ("ipv4 and ipv6 flags cannot be both set");
15258 if ((!ipv4_set) && (!ipv6_set))
15260 errmsg ("no ipv4 nor ipv6 flag set");
15264 if (sw_if_index_set == 0)
15266 errmsg ("missing interface name or sw_if_index");
15270 vam->current_sw_if_index = sw_if_index;
15271 vam->is_ipv6 = ipv6_set;
15273 M (IP_ADDRESS_DUMP, mp);
15274 mp->sw_if_index = ntohl (sw_if_index);
15275 mp->is_ipv6 = ipv6_set;
15278 /* Use a control ping for synchronization */
15279 MPING (CONTROL_PING, mp_ping);
15287 api_ip_dump (vat_main_t * vam)
15289 vl_api_ip_dump_t *mp;
15290 vl_api_control_ping_t *mp_ping;
15291 unformat_input_t *in = vam->input;
15298 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
15300 if (unformat (in, "ipv4"))
15302 else if (unformat (in, "ipv6"))
15308 if (ipv4_set && ipv6_set)
15310 errmsg ("ipv4 and ipv6 flags cannot be both set");
15314 if ((!ipv4_set) && (!ipv6_set))
15316 errmsg ("no ipv4 nor ipv6 flag set");
15320 is_ipv6 = ipv6_set;
15321 vam->is_ipv6 = is_ipv6;
15323 /* free old data */
15324 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
15326 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
15328 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
15331 mp->is_ipv6 = ipv6_set;
15334 /* Use a control ping for synchronization */
15335 MPING (CONTROL_PING, mp_ping);
15343 api_ipsec_spd_add_del (vat_main_t * vam)
15345 unformat_input_t *i = vam->input;
15346 vl_api_ipsec_spd_add_del_t *mp;
15351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15353 if (unformat (i, "spd_id %d", &spd_id))
15355 else if (unformat (i, "del"))
15359 clib_warning ("parse error '%U'", format_unformat_error, i);
15365 errmsg ("spd_id must be set");
15369 M (IPSEC_SPD_ADD_DEL, mp);
15371 mp->spd_id = ntohl (spd_id);
15372 mp->is_add = is_add;
15380 api_ipsec_interface_add_del_spd (vat_main_t * vam)
15382 unformat_input_t *i = vam->input;
15383 vl_api_ipsec_interface_add_del_spd_t *mp;
15385 u8 sw_if_index_set = 0;
15386 u32 spd_id = (u32) ~ 0;
15390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15392 if (unformat (i, "del"))
15394 else if (unformat (i, "spd_id %d", &spd_id))
15397 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15398 sw_if_index_set = 1;
15399 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15400 sw_if_index_set = 1;
15403 clib_warning ("parse error '%U'", format_unformat_error, i);
15409 if (spd_id == (u32) ~ 0)
15411 errmsg ("spd_id must be set");
15415 if (sw_if_index_set == 0)
15417 errmsg ("missing interface name or sw_if_index");
15421 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15423 mp->spd_id = ntohl (spd_id);
15424 mp->sw_if_index = ntohl (sw_if_index);
15425 mp->is_add = is_add;
15433 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15435 unformat_input_t *i = vam->input;
15436 vl_api_ipsec_spd_add_del_entry_t *mp;
15437 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15438 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15440 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15441 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15442 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15443 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15446 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15447 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15448 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15449 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15450 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15451 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15453 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15455 if (unformat (i, "del"))
15457 if (unformat (i, "outbound"))
15459 if (unformat (i, "inbound"))
15461 else if (unformat (i, "spd_id %d", &spd_id))
15463 else if (unformat (i, "sa_id %d", &sa_id))
15465 else if (unformat (i, "priority %d", &priority))
15467 else if (unformat (i, "protocol %d", &protocol))
15469 else if (unformat (i, "lport_start %d", &lport_start))
15471 else if (unformat (i, "lport_stop %d", &lport_stop))
15473 else if (unformat (i, "rport_start %d", &rport_start))
15475 else if (unformat (i, "rport_stop %d", &rport_stop))
15479 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15485 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15492 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15498 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15505 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15511 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15518 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15524 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15530 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15532 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15534 clib_warning ("unsupported action: 'resolve'");
15540 clib_warning ("parse error '%U'", format_unformat_error, i);
15546 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15548 mp->spd_id = ntohl (spd_id);
15549 mp->priority = ntohl (priority);
15550 mp->is_outbound = is_outbound;
15552 mp->is_ipv6 = is_ipv6;
15553 if (is_ipv6 || is_ip_any)
15555 clib_memcpy (mp->remote_address_start, &raddr6_start,
15556 sizeof (ip6_address_t));
15557 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15558 sizeof (ip6_address_t));
15559 clib_memcpy (mp->local_address_start, &laddr6_start,
15560 sizeof (ip6_address_t));
15561 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15562 sizeof (ip6_address_t));
15566 clib_memcpy (mp->remote_address_start, &raddr4_start,
15567 sizeof (ip4_address_t));
15568 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15569 sizeof (ip4_address_t));
15570 clib_memcpy (mp->local_address_start, &laddr4_start,
15571 sizeof (ip4_address_t));
15572 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15573 sizeof (ip4_address_t));
15575 mp->protocol = (u8) protocol;
15576 mp->local_port_start = ntohs ((u16) lport_start);
15577 mp->local_port_stop = ntohs ((u16) lport_stop);
15578 mp->remote_port_start = ntohs ((u16) rport_start);
15579 mp->remote_port_stop = ntohs ((u16) rport_stop);
15580 mp->policy = (u8) policy;
15581 mp->sa_id = ntohl (sa_id);
15582 mp->is_add = is_add;
15583 mp->is_ip_any = is_ip_any;
15590 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15592 unformat_input_t *i = vam->input;
15593 vl_api_ipsec_sad_add_del_entry_t *mp;
15594 u32 sad_id = 0, spi = 0;
15595 u8 *ck = 0, *ik = 0;
15598 u8 protocol = IPSEC_PROTOCOL_AH;
15599 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15600 u32 crypto_alg = 0, integ_alg = 0;
15601 ip4_address_t tun_src4;
15602 ip4_address_t tun_dst4;
15603 ip6_address_t tun_src6;
15604 ip6_address_t tun_dst6;
15607 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15609 if (unformat (i, "del"))
15611 else if (unformat (i, "sad_id %d", &sad_id))
15613 else if (unformat (i, "spi %d", &spi))
15615 else if (unformat (i, "esp"))
15616 protocol = IPSEC_PROTOCOL_ESP;
15617 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15620 is_tunnel_ipv6 = 0;
15622 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15625 is_tunnel_ipv6 = 0;
15627 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15630 is_tunnel_ipv6 = 1;
15632 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15635 is_tunnel_ipv6 = 1;
15639 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15641 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15643 clib_warning ("unsupported crypto-alg: '%U'",
15644 format_ipsec_crypto_alg, crypto_alg);
15648 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15652 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15654 if (integ_alg >= IPSEC_INTEG_N_ALG)
15656 clib_warning ("unsupported integ-alg: '%U'",
15657 format_ipsec_integ_alg, integ_alg);
15661 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15665 clib_warning ("parse error '%U'", format_unformat_error, i);
15671 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15673 mp->sad_id = ntohl (sad_id);
15674 mp->is_add = is_add;
15675 mp->protocol = protocol;
15676 mp->spi = ntohl (spi);
15677 mp->is_tunnel = is_tunnel;
15678 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15679 mp->crypto_algorithm = crypto_alg;
15680 mp->integrity_algorithm = integ_alg;
15681 mp->crypto_key_length = vec_len (ck);
15682 mp->integrity_key_length = vec_len (ik);
15684 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15685 mp->crypto_key_length = sizeof (mp->crypto_key);
15687 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15688 mp->integrity_key_length = sizeof (mp->integrity_key);
15691 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15693 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15697 if (is_tunnel_ipv6)
15699 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15700 sizeof (ip6_address_t));
15701 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15702 sizeof (ip6_address_t));
15706 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15707 sizeof (ip4_address_t));
15708 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15709 sizeof (ip4_address_t));
15719 api_ipsec_sa_set_key (vat_main_t * vam)
15721 unformat_input_t *i = vam->input;
15722 vl_api_ipsec_sa_set_key_t *mp;
15724 u8 *ck = 0, *ik = 0;
15727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15729 if (unformat (i, "sa_id %d", &sa_id))
15731 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15733 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15737 clib_warning ("parse error '%U'", format_unformat_error, i);
15742 M (IPSEC_SA_SET_KEY, mp);
15744 mp->sa_id = ntohl (sa_id);
15745 mp->crypto_key_length = vec_len (ck);
15746 mp->integrity_key_length = vec_len (ik);
15748 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15749 mp->crypto_key_length = sizeof (mp->crypto_key);
15751 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15752 mp->integrity_key_length = sizeof (mp->integrity_key);
15755 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15757 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15765 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15767 unformat_input_t *i = vam->input;
15768 vl_api_ipsec_tunnel_if_add_del_t *mp;
15769 u32 local_spi = 0, remote_spi = 0;
15770 u32 crypto_alg = 0, integ_alg = 0;
15771 u8 *lck = NULL, *rck = NULL;
15772 u8 *lik = NULL, *rik = NULL;
15773 ip4_address_t local_ip = { {0} };
15774 ip4_address_t remote_ip = { {0} };
15777 u8 anti_replay = 0;
15782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15784 if (unformat (i, "del"))
15786 else if (unformat (i, "esn"))
15788 else if (unformat (i, "anti_replay"))
15790 else if (unformat (i, "local_spi %d", &local_spi))
15792 else if (unformat (i, "remote_spi %d", &remote_spi))
15794 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15796 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15798 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15801 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15803 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15805 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15809 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15811 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15813 errmsg ("unsupported crypto-alg: '%U'\n",
15814 format_ipsec_crypto_alg, crypto_alg);
15820 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15822 if (integ_alg >= IPSEC_INTEG_N_ALG)
15824 errmsg ("unsupported integ-alg: '%U'\n",
15825 format_ipsec_integ_alg, integ_alg);
15829 else if (unformat (i, "instance %u", &instance))
15833 errmsg ("parse error '%U'\n", format_unformat_error, i);
15838 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15840 mp->is_add = is_add;
15842 mp->anti_replay = anti_replay;
15844 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15845 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15847 mp->local_spi = htonl (local_spi);
15848 mp->remote_spi = htonl (remote_spi);
15849 mp->crypto_alg = (u8) crypto_alg;
15851 mp->local_crypto_key_len = 0;
15854 mp->local_crypto_key_len = vec_len (lck);
15855 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15856 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15857 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15860 mp->remote_crypto_key_len = 0;
15863 mp->remote_crypto_key_len = vec_len (rck);
15864 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15865 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15866 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15869 mp->integ_alg = (u8) integ_alg;
15871 mp->local_integ_key_len = 0;
15874 mp->local_integ_key_len = vec_len (lik);
15875 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15876 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15877 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15880 mp->remote_integ_key_len = 0;
15883 mp->remote_integ_key_len = vec_len (rik);
15884 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15885 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15886 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15891 mp->renumber = renumber;
15892 mp->show_instance = ntohl (instance);
15901 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15903 vat_main_t *vam = &vat_main;
15905 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15906 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15907 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15908 "tunnel_src_addr %U tunnel_dst_addr %U "
15909 "salt %u seq_outbound %lu last_seq_inbound %lu "
15910 "replay_window %lu total_data_size %lu\n",
15911 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15913 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15914 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15915 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15916 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15917 mp->tunnel_src_addr,
15918 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15919 mp->tunnel_dst_addr,
15921 clib_net_to_host_u64 (mp->seq_outbound),
15922 clib_net_to_host_u64 (mp->last_seq_inbound),
15923 clib_net_to_host_u64 (mp->replay_window),
15924 clib_net_to_host_u64 (mp->total_data_size));
15927 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15928 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15930 static void vl_api_ipsec_sa_details_t_handler_json
15931 (vl_api_ipsec_sa_details_t * mp)
15933 vat_main_t *vam = &vat_main;
15934 vat_json_node_t *node = NULL;
15935 struct in_addr src_ip4, dst_ip4;
15936 struct in6_addr src_ip6, dst_ip6;
15938 if (VAT_JSON_ARRAY != vam->json_tree.type)
15940 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15941 vat_json_init_array (&vam->json_tree);
15943 node = vat_json_array_add (&vam->json_tree);
15945 vat_json_init_object (node);
15946 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15947 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15948 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15949 vat_json_object_add_uint (node, "proto", mp->protocol);
15950 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15951 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15952 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15953 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15954 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15955 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15956 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15957 mp->crypto_key_len);
15958 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15959 mp->integ_key_len);
15960 if (mp->is_tunnel_ip6)
15962 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15963 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15964 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15965 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15969 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15970 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15971 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15972 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15974 vat_json_object_add_uint (node, "replay_window",
15975 clib_net_to_host_u64 (mp->replay_window));
15976 vat_json_object_add_uint (node, "total_data_size",
15977 clib_net_to_host_u64 (mp->total_data_size));
15982 api_ipsec_sa_dump (vat_main_t * vam)
15984 unformat_input_t *i = vam->input;
15985 vl_api_ipsec_sa_dump_t *mp;
15986 vl_api_control_ping_t *mp_ping;
15990 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15992 if (unformat (i, "sa_id %d", &sa_id))
15996 clib_warning ("parse error '%U'", format_unformat_error, i);
16001 M (IPSEC_SA_DUMP, mp);
16003 mp->sa_id = ntohl (sa_id);
16007 /* Use a control ping for synchronization */
16008 M (CONTROL_PING, mp_ping);
16016 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
16018 unformat_input_t *i = vam->input;
16019 vl_api_ipsec_tunnel_if_set_key_t *mp;
16020 u32 sw_if_index = ~0;
16021 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
16026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16028 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16031 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
16032 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
16034 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
16035 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
16036 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
16037 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
16039 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
16040 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
16041 else if (unformat (i, "%U", unformat_hex_string, &key))
16045 clib_warning ("parse error '%U'", format_unformat_error, i);
16050 if (sw_if_index == ~0)
16052 errmsg ("interface must be specified");
16056 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
16058 errmsg ("key type must be specified");
16064 errmsg ("algorithm must be specified");
16068 if (vec_len (key) == 0)
16070 errmsg ("key must be specified");
16074 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
16076 mp->sw_if_index = htonl (sw_if_index);
16078 mp->key_type = key_type;
16079 mp->key_len = vec_len (key);
16080 clib_memcpy (mp->key, key, vec_len (key));
16089 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
16091 unformat_input_t *i = vam->input;
16092 vl_api_ipsec_tunnel_if_set_sa_t *mp;
16093 u32 sw_if_index = ~0;
16095 u8 is_outbound = (u8) ~ 0;
16098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16100 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16102 else if (unformat (i, "sa_id %d", &sa_id))
16104 else if (unformat (i, "outbound"))
16106 else if (unformat (i, "inbound"))
16110 clib_warning ("parse error '%U'", format_unformat_error, i);
16115 if (sw_if_index == ~0)
16117 errmsg ("interface must be specified");
16123 errmsg ("SA ID must be specified");
16127 M (IPSEC_TUNNEL_IF_SET_SA, mp);
16129 mp->sw_if_index = htonl (sw_if_index);
16130 mp->sa_id = htonl (sa_id);
16131 mp->is_outbound = is_outbound;
16140 api_ikev2_profile_add_del (vat_main_t * vam)
16142 unformat_input_t *i = vam->input;
16143 vl_api_ikev2_profile_add_del_t *mp;
16148 const char *valid_chars = "a-zA-Z0-9_";
16150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16152 if (unformat (i, "del"))
16154 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16155 vec_add1 (name, 0);
16158 errmsg ("parse error '%U'", format_unformat_error, i);
16163 if (!vec_len (name))
16165 errmsg ("profile name must be specified");
16169 if (vec_len (name) > 64)
16171 errmsg ("profile name too long");
16175 M (IKEV2_PROFILE_ADD_DEL, mp);
16177 clib_memcpy (mp->name, name, vec_len (name));
16178 mp->is_add = is_add;
16187 api_ikev2_profile_set_auth (vat_main_t * vam)
16189 unformat_input_t *i = vam->input;
16190 vl_api_ikev2_profile_set_auth_t *mp;
16193 u32 auth_method = 0;
16197 const char *valid_chars = "a-zA-Z0-9_";
16199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16201 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16202 vec_add1 (name, 0);
16203 else if (unformat (i, "auth_method %U",
16204 unformat_ikev2_auth_method, &auth_method))
16206 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
16208 else if (unformat (i, "auth_data %v", &data))
16212 errmsg ("parse error '%U'", format_unformat_error, i);
16217 if (!vec_len (name))
16219 errmsg ("profile name must be specified");
16223 if (vec_len (name) > 64)
16225 errmsg ("profile name too long");
16229 if (!vec_len (data))
16231 errmsg ("auth_data must be specified");
16237 errmsg ("auth_method must be specified");
16241 M (IKEV2_PROFILE_SET_AUTH, mp);
16243 mp->is_hex = is_hex;
16244 mp->auth_method = (u8) auth_method;
16245 mp->data_len = vec_len (data);
16246 clib_memcpy (mp->name, name, vec_len (name));
16247 clib_memcpy (mp->data, data, vec_len (data));
16257 api_ikev2_profile_set_id (vat_main_t * vam)
16259 unformat_input_t *i = vam->input;
16260 vl_api_ikev2_profile_set_id_t *mp;
16268 const char *valid_chars = "a-zA-Z0-9_";
16270 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16272 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16273 vec_add1 (name, 0);
16274 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
16276 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
16278 data = vec_new (u8, 4);
16279 clib_memcpy (data, ip4.as_u8, 4);
16281 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
16283 else if (unformat (i, "id_data %v", &data))
16285 else if (unformat (i, "local"))
16287 else if (unformat (i, "remote"))
16291 errmsg ("parse error '%U'", format_unformat_error, i);
16296 if (!vec_len (name))
16298 errmsg ("profile name must be specified");
16302 if (vec_len (name) > 64)
16304 errmsg ("profile name too long");
16308 if (!vec_len (data))
16310 errmsg ("id_data must be specified");
16316 errmsg ("id_type must be specified");
16320 M (IKEV2_PROFILE_SET_ID, mp);
16322 mp->is_local = is_local;
16323 mp->id_type = (u8) id_type;
16324 mp->data_len = vec_len (data);
16325 clib_memcpy (mp->name, name, vec_len (name));
16326 clib_memcpy (mp->data, data, vec_len (data));
16336 api_ikev2_profile_set_ts (vat_main_t * vam)
16338 unformat_input_t *i = vam->input;
16339 vl_api_ikev2_profile_set_ts_t *mp;
16342 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
16343 ip4_address_t start_addr, end_addr;
16345 const char *valid_chars = "a-zA-Z0-9_";
16348 start_addr.as_u32 = 0;
16349 end_addr.as_u32 = (u32) ~ 0;
16351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16353 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16354 vec_add1 (name, 0);
16355 else if (unformat (i, "protocol %d", &proto))
16357 else if (unformat (i, "start_port %d", &start_port))
16359 else if (unformat (i, "end_port %d", &end_port))
16362 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
16364 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
16366 else if (unformat (i, "local"))
16368 else if (unformat (i, "remote"))
16372 errmsg ("parse error '%U'", format_unformat_error, i);
16377 if (!vec_len (name))
16379 errmsg ("profile name must be specified");
16383 if (vec_len (name) > 64)
16385 errmsg ("profile name too long");
16389 M (IKEV2_PROFILE_SET_TS, mp);
16391 mp->is_local = is_local;
16392 mp->proto = (u8) proto;
16393 mp->start_port = (u16) start_port;
16394 mp->end_port = (u16) end_port;
16395 mp->start_addr = start_addr.as_u32;
16396 mp->end_addr = end_addr.as_u32;
16397 clib_memcpy (mp->name, name, vec_len (name));
16406 api_ikev2_set_local_key (vat_main_t * vam)
16408 unformat_input_t *i = vam->input;
16409 vl_api_ikev2_set_local_key_t *mp;
16413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16415 if (unformat (i, "file %v", &file))
16416 vec_add1 (file, 0);
16419 errmsg ("parse error '%U'", format_unformat_error, i);
16424 if (!vec_len (file))
16426 errmsg ("RSA key file must be specified");
16430 if (vec_len (file) > 256)
16432 errmsg ("file name too long");
16436 M (IKEV2_SET_LOCAL_KEY, mp);
16438 clib_memcpy (mp->key_file, file, vec_len (file));
16447 api_ikev2_set_responder (vat_main_t * vam)
16449 unformat_input_t *i = vam->input;
16450 vl_api_ikev2_set_responder_t *mp;
16453 u32 sw_if_index = ~0;
16454 ip4_address_t address;
16456 const char *valid_chars = "a-zA-Z0-9_";
16458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16461 (i, "%U interface %d address %U", unformat_token, valid_chars,
16462 &name, &sw_if_index, unformat_ip4_address, &address))
16463 vec_add1 (name, 0);
16466 errmsg ("parse error '%U'", format_unformat_error, i);
16471 if (!vec_len (name))
16473 errmsg ("profile name must be specified");
16477 if (vec_len (name) > 64)
16479 errmsg ("profile name too long");
16483 M (IKEV2_SET_RESPONDER, mp);
16485 clib_memcpy (mp->name, name, vec_len (name));
16488 mp->sw_if_index = sw_if_index;
16489 clib_memcpy (mp->address, &address, sizeof (address));
16497 api_ikev2_set_ike_transforms (vat_main_t * vam)
16499 unformat_input_t *i = vam->input;
16500 vl_api_ikev2_set_ike_transforms_t *mp;
16503 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16505 const char *valid_chars = "a-zA-Z0-9_";
16507 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16509 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16510 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16511 vec_add1 (name, 0);
16514 errmsg ("parse error '%U'", format_unformat_error, i);
16519 if (!vec_len (name))
16521 errmsg ("profile name must be specified");
16525 if (vec_len (name) > 64)
16527 errmsg ("profile name too long");
16531 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16533 clib_memcpy (mp->name, name, vec_len (name));
16535 mp->crypto_alg = crypto_alg;
16536 mp->crypto_key_size = crypto_key_size;
16537 mp->integ_alg = integ_alg;
16538 mp->dh_group = dh_group;
16547 api_ikev2_set_esp_transforms (vat_main_t * vam)
16549 unformat_input_t *i = vam->input;
16550 vl_api_ikev2_set_esp_transforms_t *mp;
16553 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16555 const char *valid_chars = "a-zA-Z0-9_";
16557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16559 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16560 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16561 vec_add1 (name, 0);
16564 errmsg ("parse error '%U'", format_unformat_error, i);
16569 if (!vec_len (name))
16571 errmsg ("profile name must be specified");
16575 if (vec_len (name) > 64)
16577 errmsg ("profile name too long");
16581 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16583 clib_memcpy (mp->name, name, vec_len (name));
16585 mp->crypto_alg = crypto_alg;
16586 mp->crypto_key_size = crypto_key_size;
16587 mp->integ_alg = integ_alg;
16588 mp->dh_group = dh_group;
16596 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16598 unformat_input_t *i = vam->input;
16599 vl_api_ikev2_set_sa_lifetime_t *mp;
16602 u64 lifetime, lifetime_maxdata;
16603 u32 lifetime_jitter, handover;
16605 const char *valid_chars = "a-zA-Z0-9_";
16607 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16609 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16610 &lifetime, &lifetime_jitter, &handover,
16611 &lifetime_maxdata))
16612 vec_add1 (name, 0);
16615 errmsg ("parse error '%U'", format_unformat_error, i);
16620 if (!vec_len (name))
16622 errmsg ("profile name must be specified");
16626 if (vec_len (name) > 64)
16628 errmsg ("profile name too long");
16632 M (IKEV2_SET_SA_LIFETIME, mp);
16634 clib_memcpy (mp->name, name, vec_len (name));
16636 mp->lifetime = lifetime;
16637 mp->lifetime_jitter = lifetime_jitter;
16638 mp->handover = handover;
16639 mp->lifetime_maxdata = lifetime_maxdata;
16647 api_ikev2_initiate_sa_init (vat_main_t * vam)
16649 unformat_input_t *i = vam->input;
16650 vl_api_ikev2_initiate_sa_init_t *mp;
16654 const char *valid_chars = "a-zA-Z0-9_";
16656 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16658 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16659 vec_add1 (name, 0);
16662 errmsg ("parse error '%U'", format_unformat_error, i);
16667 if (!vec_len (name))
16669 errmsg ("profile name must be specified");
16673 if (vec_len (name) > 64)
16675 errmsg ("profile name too long");
16679 M (IKEV2_INITIATE_SA_INIT, mp);
16681 clib_memcpy (mp->name, name, vec_len (name));
16690 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16692 unformat_input_t *i = vam->input;
16693 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16700 if (unformat (i, "%lx", &ispi))
16704 errmsg ("parse error '%U'", format_unformat_error, i);
16709 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16719 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16721 unformat_input_t *i = vam->input;
16722 vl_api_ikev2_initiate_del_child_sa_t *mp;
16727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16729 if (unformat (i, "%x", &ispi))
16733 errmsg ("parse error '%U'", format_unformat_error, i);
16738 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16748 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16750 unformat_input_t *i = vam->input;
16751 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16758 if (unformat (i, "%x", &ispi))
16762 errmsg ("parse error '%U'", format_unformat_error, i);
16767 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16777 api_get_first_msg_id (vat_main_t * vam)
16779 vl_api_get_first_msg_id_t *mp;
16780 unformat_input_t *i = vam->input;
16785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16787 if (unformat (i, "client %s", &name))
16795 errmsg ("missing client name");
16798 vec_add1 (name, 0);
16800 if (vec_len (name) > 63)
16802 errmsg ("client name too long");
16806 M (GET_FIRST_MSG_ID, mp);
16807 clib_memcpy (mp->name, name, vec_len (name));
16814 api_cop_interface_enable_disable (vat_main_t * vam)
16816 unformat_input_t *line_input = vam->input;
16817 vl_api_cop_interface_enable_disable_t *mp;
16818 u32 sw_if_index = ~0;
16819 u8 enable_disable = 1;
16822 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16824 if (unformat (line_input, "disable"))
16825 enable_disable = 0;
16826 if (unformat (line_input, "enable"))
16827 enable_disable = 1;
16828 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16829 vam, &sw_if_index))
16831 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16837 if (sw_if_index == ~0)
16839 errmsg ("missing interface name or sw_if_index");
16843 /* Construct the API message */
16844 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16845 mp->sw_if_index = ntohl (sw_if_index);
16846 mp->enable_disable = enable_disable;
16850 /* Wait for the reply */
16856 api_cop_whitelist_enable_disable (vat_main_t * vam)
16858 unformat_input_t *line_input = vam->input;
16859 vl_api_cop_whitelist_enable_disable_t *mp;
16860 u32 sw_if_index = ~0;
16861 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16865 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16867 if (unformat (line_input, "ip4"))
16869 else if (unformat (line_input, "ip6"))
16871 else if (unformat (line_input, "default"))
16873 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16874 vam, &sw_if_index))
16876 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16878 else if (unformat (line_input, "fib-id %d", &fib_id))
16884 if (sw_if_index == ~0)
16886 errmsg ("missing interface name or sw_if_index");
16890 /* Construct the API message */
16891 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16892 mp->sw_if_index = ntohl (sw_if_index);
16893 mp->fib_id = ntohl (fib_id);
16896 mp->default_cop = default_cop;
16900 /* Wait for the reply */
16906 api_get_node_graph (vat_main_t * vam)
16908 vl_api_get_node_graph_t *mp;
16911 M (GET_NODE_GRAPH, mp);
16915 /* Wait for the reply */
16921 /** Used for parsing LISP eids */
16922 typedef CLIB_PACKED(struct{
16923 u8 addr[16]; /**< eid address */
16924 u32 len; /**< prefix length if IP */
16925 u8 type; /**< type of eid */
16930 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16932 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16934 clib_memset (a, 0, sizeof (a[0]));
16936 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16938 a->type = 0; /* ipv4 type */
16940 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16942 a->type = 1; /* ipv6 type */
16944 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16946 a->type = 2; /* mac type */
16948 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16950 a->type = 3; /* NSH type */
16951 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16952 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16959 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16968 lisp_eid_size_vat (u8 type)
16985 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16987 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16991 api_one_add_del_locator_set (vat_main_t * vam)
16993 unformat_input_t *input = vam->input;
16994 vl_api_one_add_del_locator_set_t *mp;
16996 u8 *locator_set_name = NULL;
16997 u8 locator_set_name_set = 0;
16998 vl_api_local_locator_t locator, *locators = 0;
16999 u32 sw_if_index, priority, weight;
17003 /* Parse args required to build the message */
17004 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17006 if (unformat (input, "del"))
17010 else if (unformat (input, "locator-set %s", &locator_set_name))
17012 locator_set_name_set = 1;
17014 else if (unformat (input, "sw_if_index %u p %u w %u",
17015 &sw_if_index, &priority, &weight))
17017 locator.sw_if_index = htonl (sw_if_index);
17018 locator.priority = priority;
17019 locator.weight = weight;
17020 vec_add1 (locators, locator);
17024 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
17025 &sw_if_index, &priority, &weight))
17027 locator.sw_if_index = htonl (sw_if_index);
17028 locator.priority = priority;
17029 locator.weight = weight;
17030 vec_add1 (locators, locator);
17036 if (locator_set_name_set == 0)
17038 errmsg ("missing locator-set name");
17039 vec_free (locators);
17043 if (vec_len (locator_set_name) > 64)
17045 errmsg ("locator-set name too long");
17046 vec_free (locator_set_name);
17047 vec_free (locators);
17050 vec_add1 (locator_set_name, 0);
17052 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
17054 /* Construct the API message */
17055 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
17057 mp->is_add = is_add;
17058 clib_memcpy (mp->locator_set_name, locator_set_name,
17059 vec_len (locator_set_name));
17060 vec_free (locator_set_name);
17062 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
17064 clib_memcpy (mp->locators, locators, data_len);
17065 vec_free (locators);
17070 /* Wait for a reply... */
17075 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
17078 api_one_add_del_locator (vat_main_t * vam)
17080 unformat_input_t *input = vam->input;
17081 vl_api_one_add_del_locator_t *mp;
17082 u32 tmp_if_index = ~0;
17083 u32 sw_if_index = ~0;
17084 u8 sw_if_index_set = 0;
17085 u8 sw_if_index_if_name_set = 0;
17087 u8 priority_set = 0;
17091 u8 *locator_set_name = NULL;
17092 u8 locator_set_name_set = 0;
17095 /* Parse args required to build the message */
17096 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17098 if (unformat (input, "del"))
17102 else if (unformat (input, "locator-set %s", &locator_set_name))
17104 locator_set_name_set = 1;
17106 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
17109 sw_if_index_if_name_set = 1;
17110 sw_if_index = tmp_if_index;
17112 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
17114 sw_if_index_set = 1;
17115 sw_if_index = tmp_if_index;
17117 else if (unformat (input, "p %d", &priority))
17121 else if (unformat (input, "w %d", &weight))
17129 if (locator_set_name_set == 0)
17131 errmsg ("missing locator-set name");
17135 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
17137 errmsg ("missing sw_if_index");
17138 vec_free (locator_set_name);
17142 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
17144 errmsg ("cannot use both params interface name and sw_if_index");
17145 vec_free (locator_set_name);
17149 if (priority_set == 0)
17151 errmsg ("missing locator-set priority");
17152 vec_free (locator_set_name);
17156 if (weight_set == 0)
17158 errmsg ("missing locator-set weight");
17159 vec_free (locator_set_name);
17163 if (vec_len (locator_set_name) > 64)
17165 errmsg ("locator-set name too long");
17166 vec_free (locator_set_name);
17169 vec_add1 (locator_set_name, 0);
17171 /* Construct the API message */
17172 M (ONE_ADD_DEL_LOCATOR, mp);
17174 mp->is_add = is_add;
17175 mp->sw_if_index = ntohl (sw_if_index);
17176 mp->priority = priority;
17177 mp->weight = weight;
17178 clib_memcpy (mp->locator_set_name, locator_set_name,
17179 vec_len (locator_set_name));
17180 vec_free (locator_set_name);
17185 /* Wait for a reply... */
17190 #define api_lisp_add_del_locator api_one_add_del_locator
17193 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
17195 u32 *key_id = va_arg (*args, u32 *);
17198 if (unformat (input, "%s", &s))
17200 if (!strcmp ((char *) s, "sha1"))
17201 key_id[0] = HMAC_SHA_1_96;
17202 else if (!strcmp ((char *) s, "sha256"))
17203 key_id[0] = HMAC_SHA_256_128;
17206 clib_warning ("invalid key_id: '%s'", s);
17207 key_id[0] = HMAC_NO_KEY;
17218 api_one_add_del_local_eid (vat_main_t * vam)
17220 unformat_input_t *input = vam->input;
17221 vl_api_one_add_del_local_eid_t *mp;
17224 lisp_eid_vat_t _eid, *eid = &_eid;
17225 u8 *locator_set_name = 0;
17226 u8 locator_set_name_set = 0;
17232 /* Parse args required to build the message */
17233 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17235 if (unformat (input, "del"))
17239 else if (unformat (input, "vni %d", &vni))
17243 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17247 else if (unformat (input, "locator-set %s", &locator_set_name))
17249 locator_set_name_set = 1;
17251 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17253 else if (unformat (input, "secret-key %_%v%_", &key))
17259 if (locator_set_name_set == 0)
17261 errmsg ("missing locator-set name");
17267 errmsg ("EID address not set!");
17268 vec_free (locator_set_name);
17272 if (key && (0 == key_id))
17274 errmsg ("invalid key_id!");
17278 if (vec_len (key) > 64)
17280 errmsg ("key too long");
17285 if (vec_len (locator_set_name) > 64)
17287 errmsg ("locator-set name too long");
17288 vec_free (locator_set_name);
17291 vec_add1 (locator_set_name, 0);
17293 /* Construct the API message */
17294 M (ONE_ADD_DEL_LOCAL_EID, mp);
17296 mp->is_add = is_add;
17297 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17298 mp->eid_type = eid->type;
17299 mp->prefix_len = eid->len;
17300 mp->vni = clib_host_to_net_u32 (vni);
17301 mp->key_id = clib_host_to_net_u16 (key_id);
17302 clib_memcpy (mp->locator_set_name, locator_set_name,
17303 vec_len (locator_set_name));
17304 clib_memcpy (mp->key, key, vec_len (key));
17306 vec_free (locator_set_name);
17312 /* Wait for a reply... */
17317 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17320 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17322 u32 dp_table = 0, vni = 0;;
17323 unformat_input_t *input = vam->input;
17324 vl_api_gpe_add_del_fwd_entry_t *mp;
17326 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17327 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17328 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17329 u32 action = ~0, w;
17330 ip4_address_t rmt_rloc4, lcl_rloc4;
17331 ip6_address_t rmt_rloc6, lcl_rloc6;
17332 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17335 clib_memset (&rloc, 0, sizeof (rloc));
17337 /* Parse args required to build the message */
17338 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17340 if (unformat (input, "del"))
17342 else if (unformat (input, "add"))
17344 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17348 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17352 else if (unformat (input, "vrf %d", &dp_table))
17354 else if (unformat (input, "bd %d", &dp_table))
17356 else if (unformat (input, "vni %d", &vni))
17358 else if (unformat (input, "w %d", &w))
17362 errmsg ("No RLOC configured for setting priority/weight!");
17365 curr_rloc->weight = w;
17367 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17368 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17372 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17374 vec_add1 (lcl_locs, rloc);
17376 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17377 vec_add1 (rmt_locs, rloc);
17378 /* weight saved in rmt loc */
17379 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17381 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17382 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17385 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17387 vec_add1 (lcl_locs, rloc);
17389 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17390 vec_add1 (rmt_locs, rloc);
17391 /* weight saved in rmt loc */
17392 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17394 else if (unformat (input, "action %d", &action))
17400 clib_warning ("parse error '%U'", format_unformat_error, input);
17407 errmsg ("remote eid addresses not set");
17411 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17413 errmsg ("eid types don't match");
17417 if (0 == rmt_locs && (u32) ~ 0 == action)
17419 errmsg ("action not set for negative mapping");
17423 /* Construct the API message */
17424 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17425 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17427 mp->is_add = is_add;
17428 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17429 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17430 mp->eid_type = rmt_eid->type;
17431 mp->dp_table = clib_host_to_net_u32 (dp_table);
17432 mp->vni = clib_host_to_net_u32 (vni);
17433 mp->rmt_len = rmt_eid->len;
17434 mp->lcl_len = lcl_eid->len;
17435 mp->action = action;
17437 if (0 != rmt_locs && 0 != lcl_locs)
17439 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17440 clib_memcpy (mp->locs, lcl_locs,
17441 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17443 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17444 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17445 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17447 vec_free (lcl_locs);
17448 vec_free (rmt_locs);
17453 /* Wait for a reply... */
17459 api_one_add_del_map_server (vat_main_t * vam)
17461 unformat_input_t *input = vam->input;
17462 vl_api_one_add_del_map_server_t *mp;
17466 ip4_address_t ipv4;
17467 ip6_address_t ipv6;
17470 /* Parse args required to build the message */
17471 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17473 if (unformat (input, "del"))
17477 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17481 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17489 if (ipv4_set && ipv6_set)
17491 errmsg ("both eid v4 and v6 addresses set");
17495 if (!ipv4_set && !ipv6_set)
17497 errmsg ("eid addresses not set");
17501 /* Construct the API message */
17502 M (ONE_ADD_DEL_MAP_SERVER, mp);
17504 mp->is_add = is_add;
17508 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17513 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17519 /* Wait for a reply... */
17524 #define api_lisp_add_del_map_server api_one_add_del_map_server
17527 api_one_add_del_map_resolver (vat_main_t * vam)
17529 unformat_input_t *input = vam->input;
17530 vl_api_one_add_del_map_resolver_t *mp;
17534 ip4_address_t ipv4;
17535 ip6_address_t ipv6;
17538 /* Parse args required to build the message */
17539 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17541 if (unformat (input, "del"))
17545 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17549 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17557 if (ipv4_set && ipv6_set)
17559 errmsg ("both eid v4 and v6 addresses set");
17563 if (!ipv4_set && !ipv6_set)
17565 errmsg ("eid addresses not set");
17569 /* Construct the API message */
17570 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17572 mp->is_add = is_add;
17576 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17581 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17587 /* Wait for a reply... */
17592 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17595 api_lisp_gpe_enable_disable (vat_main_t * vam)
17597 unformat_input_t *input = vam->input;
17598 vl_api_gpe_enable_disable_t *mp;
17603 /* Parse args required to build the message */
17604 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17606 if (unformat (input, "enable"))
17611 else if (unformat (input, "disable"))
17622 errmsg ("Value not set");
17626 /* Construct the API message */
17627 M (GPE_ENABLE_DISABLE, mp);
17634 /* Wait for a reply... */
17640 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17642 unformat_input_t *input = vam->input;
17643 vl_api_one_rloc_probe_enable_disable_t *mp;
17648 /* Parse args required to build the message */
17649 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17651 if (unformat (input, "enable"))
17656 else if (unformat (input, "disable"))
17664 errmsg ("Value not set");
17668 /* Construct the API message */
17669 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17671 mp->is_enabled = is_en;
17676 /* Wait for a reply... */
17681 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17684 api_one_map_register_enable_disable (vat_main_t * vam)
17686 unformat_input_t *input = vam->input;
17687 vl_api_one_map_register_enable_disable_t *mp;
17692 /* Parse args required to build the message */
17693 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17695 if (unformat (input, "enable"))
17700 else if (unformat (input, "disable"))
17708 errmsg ("Value not set");
17712 /* Construct the API message */
17713 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17715 mp->is_enabled = is_en;
17720 /* Wait for a reply... */
17725 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17728 api_one_enable_disable (vat_main_t * vam)
17730 unformat_input_t *input = vam->input;
17731 vl_api_one_enable_disable_t *mp;
17736 /* Parse args required to build the message */
17737 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17739 if (unformat (input, "enable"))
17744 else if (unformat (input, "disable"))
17754 errmsg ("Value not set");
17758 /* Construct the API message */
17759 M (ONE_ENABLE_DISABLE, mp);
17766 /* Wait for a reply... */
17771 #define api_lisp_enable_disable api_one_enable_disable
17774 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17776 unformat_input_t *input = vam->input;
17777 vl_api_one_enable_disable_xtr_mode_t *mp;
17782 /* Parse args required to build the message */
17783 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17785 if (unformat (input, "enable"))
17790 else if (unformat (input, "disable"))
17800 errmsg ("Value not set");
17804 /* Construct the API message */
17805 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17812 /* Wait for a reply... */
17818 api_one_show_xtr_mode (vat_main_t * vam)
17820 vl_api_one_show_xtr_mode_t *mp;
17823 /* Construct the API message */
17824 M (ONE_SHOW_XTR_MODE, mp);
17829 /* Wait for a reply... */
17835 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17837 unformat_input_t *input = vam->input;
17838 vl_api_one_enable_disable_pitr_mode_t *mp;
17843 /* Parse args required to build the message */
17844 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17846 if (unformat (input, "enable"))
17851 else if (unformat (input, "disable"))
17861 errmsg ("Value not set");
17865 /* Construct the API message */
17866 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17873 /* Wait for a reply... */
17879 api_one_show_pitr_mode (vat_main_t * vam)
17881 vl_api_one_show_pitr_mode_t *mp;
17884 /* Construct the API message */
17885 M (ONE_SHOW_PITR_MODE, mp);
17890 /* Wait for a reply... */
17896 api_one_enable_disable_petr_mode (vat_main_t * vam)
17898 unformat_input_t *input = vam->input;
17899 vl_api_one_enable_disable_petr_mode_t *mp;
17904 /* Parse args required to build the message */
17905 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17907 if (unformat (input, "enable"))
17912 else if (unformat (input, "disable"))
17922 errmsg ("Value not set");
17926 /* Construct the API message */
17927 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17934 /* Wait for a reply... */
17940 api_one_show_petr_mode (vat_main_t * vam)
17942 vl_api_one_show_petr_mode_t *mp;
17945 /* Construct the API message */
17946 M (ONE_SHOW_PETR_MODE, mp);
17951 /* Wait for a reply... */
17957 api_show_one_map_register_state (vat_main_t * vam)
17959 vl_api_show_one_map_register_state_t *mp;
17962 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17967 /* wait for reply */
17972 #define api_show_lisp_map_register_state api_show_one_map_register_state
17975 api_show_one_rloc_probe_state (vat_main_t * vam)
17977 vl_api_show_one_rloc_probe_state_t *mp;
17980 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17985 /* wait for reply */
17990 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17993 api_one_add_del_ndp_entry (vat_main_t * vam)
17995 vl_api_one_add_del_ndp_entry_t *mp;
17996 unformat_input_t *input = vam->input;
18001 u8 mac[6] = { 0, };
18002 u8 ip6[16] = { 0, };
18006 /* Parse args required to build the message */
18007 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18009 if (unformat (input, "del"))
18011 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
18013 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
18015 else if (unformat (input, "bd %d", &bd))
18019 errmsg ("parse error '%U'", format_unformat_error, input);
18024 if (!bd_set || !ip_set || (!mac_set && is_add))
18026 errmsg ("Missing BD, IP or MAC!");
18030 M (ONE_ADD_DEL_NDP_ENTRY, mp);
18031 mp->is_add = is_add;
18032 clib_memcpy (mp->mac, mac, 6);
18033 mp->bd = clib_host_to_net_u32 (bd);
18034 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
18039 /* wait for reply */
18045 api_one_add_del_l2_arp_entry (vat_main_t * vam)
18047 vl_api_one_add_del_l2_arp_entry_t *mp;
18048 unformat_input_t *input = vam->input;
18053 u8 mac[6] = { 0, };
18054 u32 ip4 = 0, bd = ~0;
18057 /* Parse args required to build the message */
18058 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18060 if (unformat (input, "del"))
18062 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
18064 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
18066 else if (unformat (input, "bd %d", &bd))
18070 errmsg ("parse error '%U'", format_unformat_error, input);
18075 if (!bd_set || !ip_set || (!mac_set && is_add))
18077 errmsg ("Missing BD, IP or MAC!");
18081 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
18082 mp->is_add = is_add;
18083 clib_memcpy (mp->mac, mac, 6);
18084 mp->bd = clib_host_to_net_u32 (bd);
18090 /* wait for reply */
18096 api_one_ndp_bd_get (vat_main_t * vam)
18098 vl_api_one_ndp_bd_get_t *mp;
18101 M (ONE_NDP_BD_GET, mp);
18106 /* wait for reply */
18112 api_one_ndp_entries_get (vat_main_t * vam)
18114 vl_api_one_ndp_entries_get_t *mp;
18115 unformat_input_t *input = vam->input;
18120 /* Parse args required to build the message */
18121 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18123 if (unformat (input, "bd %d", &bd))
18127 errmsg ("parse error '%U'", format_unformat_error, input);
18134 errmsg ("Expected bridge domain!");
18138 M (ONE_NDP_ENTRIES_GET, mp);
18139 mp->bd = clib_host_to_net_u32 (bd);
18144 /* wait for reply */
18150 api_one_l2_arp_bd_get (vat_main_t * vam)
18152 vl_api_one_l2_arp_bd_get_t *mp;
18155 M (ONE_L2_ARP_BD_GET, mp);
18160 /* wait for reply */
18166 api_one_l2_arp_entries_get (vat_main_t * vam)
18168 vl_api_one_l2_arp_entries_get_t *mp;
18169 unformat_input_t *input = vam->input;
18174 /* Parse args required to build the message */
18175 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18177 if (unformat (input, "bd %d", &bd))
18181 errmsg ("parse error '%U'", format_unformat_error, input);
18188 errmsg ("Expected bridge domain!");
18192 M (ONE_L2_ARP_ENTRIES_GET, mp);
18193 mp->bd = clib_host_to_net_u32 (bd);
18198 /* wait for reply */
18204 api_one_stats_enable_disable (vat_main_t * vam)
18206 vl_api_one_stats_enable_disable_t *mp;
18207 unformat_input_t *input = vam->input;
18212 /* Parse args required to build the message */
18213 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18215 if (unformat (input, "enable"))
18220 else if (unformat (input, "disable"))
18230 errmsg ("Value not set");
18234 M (ONE_STATS_ENABLE_DISABLE, mp);
18240 /* wait for reply */
18246 api_show_one_stats_enable_disable (vat_main_t * vam)
18248 vl_api_show_one_stats_enable_disable_t *mp;
18251 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18256 /* wait for reply */
18262 api_show_one_map_request_mode (vat_main_t * vam)
18264 vl_api_show_one_map_request_mode_t *mp;
18267 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18272 /* wait for reply */
18277 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18280 api_one_map_request_mode (vat_main_t * vam)
18282 unformat_input_t *input = vam->input;
18283 vl_api_one_map_request_mode_t *mp;
18287 /* Parse args required to build the message */
18288 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18290 if (unformat (input, "dst-only"))
18292 else if (unformat (input, "src-dst"))
18296 errmsg ("parse error '%U'", format_unformat_error, input);
18301 M (ONE_MAP_REQUEST_MODE, mp);
18308 /* wait for reply */
18313 #define api_lisp_map_request_mode api_one_map_request_mode
18316 * Enable/disable ONE proxy ITR.
18318 * @param vam vpp API test context
18319 * @return return code
18322 api_one_pitr_set_locator_set (vat_main_t * vam)
18324 u8 ls_name_set = 0;
18325 unformat_input_t *input = vam->input;
18326 vl_api_one_pitr_set_locator_set_t *mp;
18331 /* Parse args required to build the message */
18332 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18334 if (unformat (input, "del"))
18336 else if (unformat (input, "locator-set %s", &ls_name))
18340 errmsg ("parse error '%U'", format_unformat_error, input);
18347 errmsg ("locator-set name not set!");
18351 M (ONE_PITR_SET_LOCATOR_SET, mp);
18353 mp->is_add = is_add;
18354 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18355 vec_free (ls_name);
18360 /* wait for reply */
18365 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18368 api_one_nsh_set_locator_set (vat_main_t * vam)
18370 u8 ls_name_set = 0;
18371 unformat_input_t *input = vam->input;
18372 vl_api_one_nsh_set_locator_set_t *mp;
18377 /* Parse args required to build the message */
18378 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18380 if (unformat (input, "del"))
18382 else if (unformat (input, "ls %s", &ls_name))
18386 errmsg ("parse error '%U'", format_unformat_error, input);
18391 if (!ls_name_set && is_add)
18393 errmsg ("locator-set name not set!");
18397 M (ONE_NSH_SET_LOCATOR_SET, mp);
18399 mp->is_add = is_add;
18400 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18401 vec_free (ls_name);
18406 /* wait for reply */
18412 api_show_one_pitr (vat_main_t * vam)
18414 vl_api_show_one_pitr_t *mp;
18417 if (!vam->json_output)
18419 print (vam->ofp, "%=20s", "lisp status:");
18422 M (SHOW_ONE_PITR, mp);
18426 /* Wait for a reply... */
18431 #define api_show_lisp_pitr api_show_one_pitr
18434 api_one_use_petr (vat_main_t * vam)
18436 unformat_input_t *input = vam->input;
18437 vl_api_one_use_petr_t *mp;
18442 clib_memset (&ip, 0, sizeof (ip));
18444 /* Parse args required to build the message */
18445 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18447 if (unformat (input, "disable"))
18450 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18453 ip_addr_version (&ip) = IP4;
18456 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18459 ip_addr_version (&ip) = IP6;
18463 errmsg ("parse error '%U'", format_unformat_error, input);
18468 M (ONE_USE_PETR, mp);
18470 mp->is_add = is_add;
18473 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18475 clib_memcpy (mp->address, &ip, 4);
18477 clib_memcpy (mp->address, &ip, 16);
18483 /* wait for reply */
18488 #define api_lisp_use_petr api_one_use_petr
18491 api_show_one_nsh_mapping (vat_main_t * vam)
18493 vl_api_show_one_use_petr_t *mp;
18496 if (!vam->json_output)
18498 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18501 M (SHOW_ONE_NSH_MAPPING, mp);
18505 /* Wait for a reply... */
18511 api_show_one_use_petr (vat_main_t * vam)
18513 vl_api_show_one_use_petr_t *mp;
18516 if (!vam->json_output)
18518 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18521 M (SHOW_ONE_USE_PETR, mp);
18525 /* Wait for a reply... */
18530 #define api_show_lisp_use_petr api_show_one_use_petr
18533 * Add/delete mapping between vni and vrf
18536 api_one_eid_table_add_del_map (vat_main_t * vam)
18538 unformat_input_t *input = vam->input;
18539 vl_api_one_eid_table_add_del_map_t *mp;
18540 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18541 u32 vni, vrf, bd_index;
18544 /* Parse args required to build the message */
18545 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18547 if (unformat (input, "del"))
18549 else if (unformat (input, "vrf %d", &vrf))
18551 else if (unformat (input, "bd_index %d", &bd_index))
18553 else if (unformat (input, "vni %d", &vni))
18559 if (!vni_set || (!vrf_set && !bd_index_set))
18561 errmsg ("missing arguments!");
18565 if (vrf_set && bd_index_set)
18567 errmsg ("error: both vrf and bd entered!");
18571 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18573 mp->is_add = is_add;
18574 mp->vni = htonl (vni);
18575 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18576 mp->is_l2 = bd_index_set;
18581 /* wait for reply */
18586 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18589 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18591 u32 *action = va_arg (*args, u32 *);
18594 if (unformat (input, "%s", &s))
18596 if (!strcmp ((char *) s, "no-action"))
18598 else if (!strcmp ((char *) s, "natively-forward"))
18600 else if (!strcmp ((char *) s, "send-map-request"))
18602 else if (!strcmp ((char *) s, "drop"))
18606 clib_warning ("invalid action: '%s'", s);
18618 * Add/del remote mapping to/from ONE control plane
18620 * @param vam vpp API test context
18621 * @return return code
18624 api_one_add_del_remote_mapping (vat_main_t * vam)
18626 unformat_input_t *input = vam->input;
18627 vl_api_one_add_del_remote_mapping_t *mp;
18629 lisp_eid_vat_t _eid, *eid = &_eid;
18630 lisp_eid_vat_t _seid, *seid = &_seid;
18631 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18632 u32 action = ~0, p, w, data_len;
18633 ip4_address_t rloc4;
18634 ip6_address_t rloc6;
18635 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18638 clib_memset (&rloc, 0, sizeof (rloc));
18640 /* Parse args required to build the message */
18641 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18643 if (unformat (input, "del-all"))
18647 else if (unformat (input, "del"))
18651 else if (unformat (input, "add"))
18655 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18659 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18663 else if (unformat (input, "vni %d", &vni))
18667 else if (unformat (input, "p %d w %d", &p, &w))
18671 errmsg ("No RLOC configured for setting priority/weight!");
18674 curr_rloc->priority = p;
18675 curr_rloc->weight = w;
18677 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18680 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18681 vec_add1 (rlocs, rloc);
18682 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18684 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18687 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18688 vec_add1 (rlocs, rloc);
18689 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18691 else if (unformat (input, "action %U",
18692 unformat_negative_mapping_action, &action))
18698 clib_warning ("parse error '%U'", format_unformat_error, input);
18705 errmsg ("missing params!");
18709 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18711 errmsg ("no action set for negative map-reply!");
18715 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18717 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18718 mp->is_add = is_add;
18719 mp->vni = htonl (vni);
18720 mp->action = (u8) action;
18721 mp->is_src_dst = seid_set;
18722 mp->eid_len = eid->len;
18723 mp->seid_len = seid->len;
18724 mp->del_all = del_all;
18725 mp->eid_type = eid->type;
18726 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18727 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18729 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18730 clib_memcpy (mp->rlocs, rlocs, data_len);
18736 /* Wait for a reply... */
18741 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18744 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18745 * forwarding entries in data-plane accordingly.
18747 * @param vam vpp API test context
18748 * @return return code
18751 api_one_add_del_adjacency (vat_main_t * vam)
18753 unformat_input_t *input = vam->input;
18754 vl_api_one_add_del_adjacency_t *mp;
18756 ip4_address_t leid4, reid4;
18757 ip6_address_t leid6, reid6;
18758 u8 reid_mac[6] = { 0 };
18759 u8 leid_mac[6] = { 0 };
18760 u8 reid_type, leid_type;
18761 u32 leid_len = 0, reid_len = 0, len;
18765 leid_type = reid_type = (u8) ~ 0;
18767 /* Parse args required to build the message */
18768 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18770 if (unformat (input, "del"))
18774 else if (unformat (input, "add"))
18778 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18781 reid_type = 0; /* ipv4 */
18784 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18787 reid_type = 1; /* ipv6 */
18790 else if (unformat (input, "reid %U", unformat_ethernet_address,
18793 reid_type = 2; /* mac */
18795 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18798 leid_type = 0; /* ipv4 */
18801 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18804 leid_type = 1; /* ipv6 */
18807 else if (unformat (input, "leid %U", unformat_ethernet_address,
18810 leid_type = 2; /* mac */
18812 else if (unformat (input, "vni %d", &vni))
18818 errmsg ("parse error '%U'", format_unformat_error, input);
18823 if ((u8) ~ 0 == reid_type)
18825 errmsg ("missing params!");
18829 if (leid_type != reid_type)
18831 errmsg ("remote and local EIDs are of different types!");
18835 M (ONE_ADD_DEL_ADJACENCY, mp);
18836 mp->is_add = is_add;
18837 mp->vni = htonl (vni);
18838 mp->leid_len = leid_len;
18839 mp->reid_len = reid_len;
18840 mp->eid_type = reid_type;
18842 switch (mp->eid_type)
18845 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18846 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18849 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18850 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18853 clib_memcpy (mp->leid, leid_mac, 6);
18854 clib_memcpy (mp->reid, reid_mac, 6);
18857 errmsg ("unknown EID type %d!", mp->eid_type);
18864 /* Wait for a reply... */
18869 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18872 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18874 u32 *mode = va_arg (*args, u32 *);
18876 if (unformat (input, "lisp"))
18878 else if (unformat (input, "vxlan"))
18887 api_gpe_get_encap_mode (vat_main_t * vam)
18889 vl_api_gpe_get_encap_mode_t *mp;
18892 /* Construct the API message */
18893 M (GPE_GET_ENCAP_MODE, mp);
18898 /* Wait for a reply... */
18904 api_gpe_set_encap_mode (vat_main_t * vam)
18906 unformat_input_t *input = vam->input;
18907 vl_api_gpe_set_encap_mode_t *mp;
18911 /* Parse args required to build the message */
18912 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18914 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18920 /* Construct the API message */
18921 M (GPE_SET_ENCAP_MODE, mp);
18928 /* Wait for a reply... */
18934 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18936 unformat_input_t *input = vam->input;
18937 vl_api_gpe_add_del_iface_t *mp;
18938 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18939 u32 dp_table = 0, vni = 0;
18942 /* Parse args required to build the message */
18943 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18945 if (unformat (input, "up"))
18950 else if (unformat (input, "down"))
18955 else if (unformat (input, "table_id %d", &dp_table))
18959 else if (unformat (input, "bd_id %d", &dp_table))
18964 else if (unformat (input, "vni %d", &vni))
18972 if (action_set == 0)
18974 errmsg ("Action not set");
18977 if (dp_table_set == 0 || vni_set == 0)
18979 errmsg ("vni and dp_table must be set");
18983 /* Construct the API message */
18984 M (GPE_ADD_DEL_IFACE, mp);
18986 mp->is_add = is_add;
18987 mp->dp_table = clib_host_to_net_u32 (dp_table);
18989 mp->vni = clib_host_to_net_u32 (vni);
18994 /* Wait for a reply... */
19000 api_one_map_register_fallback_threshold (vat_main_t * vam)
19002 unformat_input_t *input = vam->input;
19003 vl_api_one_map_register_fallback_threshold_t *mp;
19008 /* Parse args required to build the message */
19009 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19011 if (unformat (input, "%u", &value))
19015 clib_warning ("parse error '%U'", format_unformat_error, input);
19022 errmsg ("fallback threshold value is missing!");
19026 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
19027 mp->value = clib_host_to_net_u32 (value);
19032 /* Wait for a reply... */
19038 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
19040 vl_api_show_one_map_register_fallback_threshold_t *mp;
19043 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
19048 /* Wait for a reply... */
19054 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
19056 u32 *proto = va_arg (*args, u32 *);
19058 if (unformat (input, "udp"))
19060 else if (unformat (input, "api"))
19069 api_one_set_transport_protocol (vat_main_t * vam)
19071 unformat_input_t *input = vam->input;
19072 vl_api_one_set_transport_protocol_t *mp;
19077 /* Parse args required to build the message */
19078 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19080 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
19084 clib_warning ("parse error '%U'", format_unformat_error, input);
19091 errmsg ("Transport protocol missing!");
19095 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
19096 mp->protocol = (u8) protocol;
19101 /* Wait for a reply... */
19107 api_one_get_transport_protocol (vat_main_t * vam)
19109 vl_api_one_get_transport_protocol_t *mp;
19112 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
19117 /* Wait for a reply... */
19123 api_one_map_register_set_ttl (vat_main_t * vam)
19125 unformat_input_t *input = vam->input;
19126 vl_api_one_map_register_set_ttl_t *mp;
19131 /* Parse args required to build the message */
19132 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19134 if (unformat (input, "%u", &ttl))
19138 clib_warning ("parse error '%U'", format_unformat_error, input);
19145 errmsg ("TTL value missing!");
19149 M (ONE_MAP_REGISTER_SET_TTL, mp);
19150 mp->ttl = clib_host_to_net_u32 (ttl);
19155 /* Wait for a reply... */
19161 api_show_one_map_register_ttl (vat_main_t * vam)
19163 vl_api_show_one_map_register_ttl_t *mp;
19166 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
19171 /* Wait for a reply... */
19177 * Add/del map request itr rlocs from ONE control plane and updates
19179 * @param vam vpp API test context
19180 * @return return code
19183 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
19185 unformat_input_t *input = vam->input;
19186 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
19187 u8 *locator_set_name = 0;
19188 u8 locator_set_name_set = 0;
19192 /* Parse args required to build the message */
19193 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19195 if (unformat (input, "del"))
19199 else if (unformat (input, "%_%v%_", &locator_set_name))
19201 locator_set_name_set = 1;
19205 clib_warning ("parse error '%U'", format_unformat_error, input);
19210 if (is_add && !locator_set_name_set)
19212 errmsg ("itr-rloc is not set!");
19216 if (is_add && vec_len (locator_set_name) > 64)
19218 errmsg ("itr-rloc locator-set name too long");
19219 vec_free (locator_set_name);
19223 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
19224 mp->is_add = is_add;
19227 clib_memcpy (mp->locator_set_name, locator_set_name,
19228 vec_len (locator_set_name));
19232 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19234 vec_free (locator_set_name);
19239 /* Wait for a reply... */
19244 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19247 api_one_locator_dump (vat_main_t * vam)
19249 unformat_input_t *input = vam->input;
19250 vl_api_one_locator_dump_t *mp;
19251 vl_api_control_ping_t *mp_ping;
19252 u8 is_index_set = 0, is_name_set = 0;
19257 /* Parse args required to build the message */
19258 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19260 if (unformat (input, "ls_name %_%v%_", &ls_name))
19264 else if (unformat (input, "ls_index %d", &ls_index))
19270 errmsg ("parse error '%U'", format_unformat_error, input);
19275 if (!is_index_set && !is_name_set)
19277 errmsg ("error: expected one of index or name!");
19281 if (is_index_set && is_name_set)
19283 errmsg ("error: only one param expected!");
19287 if (vec_len (ls_name) > 62)
19289 errmsg ("error: locator set name too long!");
19293 if (!vam->json_output)
19295 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19298 M (ONE_LOCATOR_DUMP, mp);
19299 mp->is_index_set = is_index_set;
19302 mp->ls_index = clib_host_to_net_u32 (ls_index);
19305 vec_add1 (ls_name, 0);
19306 strncpy ((char *) mp->ls_name, (char *) ls_name,
19307 sizeof (mp->ls_name) - 1);
19313 /* Use a control ping for synchronization */
19314 MPING (CONTROL_PING, mp_ping);
19317 /* Wait for a reply... */
19322 #define api_lisp_locator_dump api_one_locator_dump
19325 api_one_locator_set_dump (vat_main_t * vam)
19327 vl_api_one_locator_set_dump_t *mp;
19328 vl_api_control_ping_t *mp_ping;
19329 unformat_input_t *input = vam->input;
19333 /* Parse args required to build the message */
19334 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19336 if (unformat (input, "local"))
19340 else if (unformat (input, "remote"))
19346 errmsg ("parse error '%U'", format_unformat_error, input);
19351 if (!vam->json_output)
19353 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19356 M (ONE_LOCATOR_SET_DUMP, mp);
19358 mp->filter = filter;
19363 /* Use a control ping for synchronization */
19364 MPING (CONTROL_PING, mp_ping);
19367 /* Wait for a reply... */
19372 #define api_lisp_locator_set_dump api_one_locator_set_dump
19375 api_one_eid_table_map_dump (vat_main_t * vam)
19379 unformat_input_t *input = vam->input;
19380 vl_api_one_eid_table_map_dump_t *mp;
19381 vl_api_control_ping_t *mp_ping;
19384 /* Parse args required to build the message */
19385 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19387 if (unformat (input, "l2"))
19392 else if (unformat (input, "l3"))
19399 errmsg ("parse error '%U'", format_unformat_error, input);
19406 errmsg ("expected one of 'l2' or 'l3' parameter!");
19410 if (!vam->json_output)
19412 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19415 M (ONE_EID_TABLE_MAP_DUMP, mp);
19421 /* Use a control ping for synchronization */
19422 MPING (CONTROL_PING, mp_ping);
19425 /* Wait for a reply... */
19430 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19433 api_one_eid_table_vni_dump (vat_main_t * vam)
19435 vl_api_one_eid_table_vni_dump_t *mp;
19436 vl_api_control_ping_t *mp_ping;
19439 if (!vam->json_output)
19441 print (vam->ofp, "VNI");
19444 M (ONE_EID_TABLE_VNI_DUMP, mp);
19449 /* Use a control ping for synchronization */
19450 MPING (CONTROL_PING, mp_ping);
19453 /* Wait for a reply... */
19458 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19461 api_one_eid_table_dump (vat_main_t * vam)
19463 unformat_input_t *i = vam->input;
19464 vl_api_one_eid_table_dump_t *mp;
19465 vl_api_control_ping_t *mp_ping;
19466 struct in_addr ip4;
19467 struct in6_addr ip6;
19469 u8 eid_type = ~0, eid_set = 0;
19470 u32 prefix_length = ~0, t, vni = 0;
19473 lisp_nsh_api_t nsh;
19475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19477 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19483 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19489 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19494 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19499 else if (unformat (i, "vni %d", &t))
19503 else if (unformat (i, "local"))
19507 else if (unformat (i, "remote"))
19513 errmsg ("parse error '%U'", format_unformat_error, i);
19518 if (!vam->json_output)
19520 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19521 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19524 M (ONE_EID_TABLE_DUMP, mp);
19526 mp->filter = filter;
19530 mp->vni = htonl (vni);
19531 mp->eid_type = eid_type;
19535 mp->prefix_length = prefix_length;
19536 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19539 mp->prefix_length = prefix_length;
19540 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19543 clib_memcpy (mp->eid, mac, sizeof (mac));
19546 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19549 errmsg ("unknown EID type %d!", eid_type);
19557 /* Use a control ping for synchronization */
19558 MPING (CONTROL_PING, mp_ping);
19561 /* Wait for a reply... */
19566 #define api_lisp_eid_table_dump api_one_eid_table_dump
19569 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19571 unformat_input_t *i = vam->input;
19572 vl_api_gpe_fwd_entries_get_t *mp;
19577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19579 if (unformat (i, "vni %d", &vni))
19585 errmsg ("parse error '%U'", format_unformat_error, i);
19592 errmsg ("vni not set!");
19596 if (!vam->json_output)
19598 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19602 M (GPE_FWD_ENTRIES_GET, mp);
19603 mp->vni = clib_host_to_net_u32 (vni);
19608 /* Wait for a reply... */
19613 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19614 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19615 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19616 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19617 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19618 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19619 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19620 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19623 api_one_adjacencies_get (vat_main_t * vam)
19625 unformat_input_t *i = vam->input;
19626 vl_api_one_adjacencies_get_t *mp;
19631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19633 if (unformat (i, "vni %d", &vni))
19639 errmsg ("parse error '%U'", format_unformat_error, i);
19646 errmsg ("vni not set!");
19650 if (!vam->json_output)
19652 print (vam->ofp, "%s %40s", "leid", "reid");
19655 M (ONE_ADJACENCIES_GET, mp);
19656 mp->vni = clib_host_to_net_u32 (vni);
19661 /* Wait for a reply... */
19666 #define api_lisp_adjacencies_get api_one_adjacencies_get
19669 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19671 unformat_input_t *i = vam->input;
19672 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19674 u8 ip_family_set = 0, is_ip4 = 1;
19676 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19678 if (unformat (i, "ip4"))
19683 else if (unformat (i, "ip6"))
19690 errmsg ("parse error '%U'", format_unformat_error, i);
19695 if (!ip_family_set)
19697 errmsg ("ip family not set!");
19701 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19702 mp->is_ip4 = is_ip4;
19707 /* Wait for a reply... */
19713 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19715 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19718 if (!vam->json_output)
19720 print (vam->ofp, "VNIs");
19723 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19728 /* Wait for a reply... */
19734 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19736 unformat_input_t *i = vam->input;
19737 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19739 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19740 struct in_addr ip4;
19741 struct in6_addr ip6;
19742 u32 table_id = 0, nh_sw_if_index = ~0;
19744 clib_memset (&ip4, 0, sizeof (ip4));
19745 clib_memset (&ip6, 0, sizeof (ip6));
19747 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19749 if (unformat (i, "del"))
19751 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19752 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19757 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19758 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19763 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19767 nh_sw_if_index = ~0;
19769 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19773 nh_sw_if_index = ~0;
19775 else if (unformat (i, "table %d", &table_id))
19779 errmsg ("parse error '%U'", format_unformat_error, i);
19786 errmsg ("nh addr not set!");
19790 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19791 mp->is_add = is_add;
19792 mp->table_id = clib_host_to_net_u32 (table_id);
19793 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19794 mp->is_ip4 = is_ip4;
19796 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19798 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19803 /* Wait for a reply... */
19809 api_one_map_server_dump (vat_main_t * vam)
19811 vl_api_one_map_server_dump_t *mp;
19812 vl_api_control_ping_t *mp_ping;
19815 if (!vam->json_output)
19817 print (vam->ofp, "%=20s", "Map server");
19820 M (ONE_MAP_SERVER_DUMP, mp);
19824 /* Use a control ping for synchronization */
19825 MPING (CONTROL_PING, mp_ping);
19828 /* Wait for a reply... */
19833 #define api_lisp_map_server_dump api_one_map_server_dump
19836 api_one_map_resolver_dump (vat_main_t * vam)
19838 vl_api_one_map_resolver_dump_t *mp;
19839 vl_api_control_ping_t *mp_ping;
19842 if (!vam->json_output)
19844 print (vam->ofp, "%=20s", "Map resolver");
19847 M (ONE_MAP_RESOLVER_DUMP, mp);
19851 /* Use a control ping for synchronization */
19852 MPING (CONTROL_PING, mp_ping);
19855 /* Wait for a reply... */
19860 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19863 api_one_stats_flush (vat_main_t * vam)
19865 vl_api_one_stats_flush_t *mp;
19868 M (ONE_STATS_FLUSH, mp);
19875 api_one_stats_dump (vat_main_t * vam)
19877 vl_api_one_stats_dump_t *mp;
19878 vl_api_control_ping_t *mp_ping;
19881 M (ONE_STATS_DUMP, mp);
19885 /* Use a control ping for synchronization */
19886 MPING (CONTROL_PING, mp_ping);
19889 /* Wait for a reply... */
19895 api_show_one_status (vat_main_t * vam)
19897 vl_api_show_one_status_t *mp;
19900 if (!vam->json_output)
19902 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19905 M (SHOW_ONE_STATUS, mp);
19908 /* Wait for a reply... */
19913 #define api_show_lisp_status api_show_one_status
19916 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19918 vl_api_gpe_fwd_entry_path_dump_t *mp;
19919 vl_api_control_ping_t *mp_ping;
19920 unformat_input_t *i = vam->input;
19921 u32 fwd_entry_index = ~0;
19924 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19926 if (unformat (i, "index %d", &fwd_entry_index))
19932 if (~0 == fwd_entry_index)
19934 errmsg ("no index specified!");
19938 if (!vam->json_output)
19940 print (vam->ofp, "first line");
19943 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19947 /* Use a control ping for synchronization */
19948 MPING (CONTROL_PING, mp_ping);
19951 /* Wait for a reply... */
19957 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19959 vl_api_one_get_map_request_itr_rlocs_t *mp;
19962 if (!vam->json_output)
19964 print (vam->ofp, "%=20s", "itr-rlocs:");
19967 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19970 /* Wait for a reply... */
19975 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19978 api_af_packet_create (vat_main_t * vam)
19980 unformat_input_t *i = vam->input;
19981 vl_api_af_packet_create_t *mp;
19982 u8 *host_if_name = 0;
19984 u8 random_hw_addr = 1;
19987 clib_memset (hw_addr, 0, sizeof (hw_addr));
19989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19991 if (unformat (i, "name %s", &host_if_name))
19992 vec_add1 (host_if_name, 0);
19993 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19994 random_hw_addr = 0;
19999 if (!vec_len (host_if_name))
20001 errmsg ("host-interface name must be specified");
20005 if (vec_len (host_if_name) > 64)
20007 errmsg ("host-interface name too long");
20011 M (AF_PACKET_CREATE, mp);
20013 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
20014 clib_memcpy (mp->hw_addr, hw_addr, 6);
20015 mp->use_random_hw_addr = random_hw_addr;
20016 vec_free (host_if_name);
20024 fprintf (vam->ofp ? vam->ofp : stderr,
20025 " new sw_if_index = %d\n", vam->sw_if_index);
20032 api_af_packet_delete (vat_main_t * vam)
20034 unformat_input_t *i = vam->input;
20035 vl_api_af_packet_delete_t *mp;
20036 u8 *host_if_name = 0;
20039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20041 if (unformat (i, "name %s", &host_if_name))
20042 vec_add1 (host_if_name, 0);
20047 if (!vec_len (host_if_name))
20049 errmsg ("host-interface name must be specified");
20053 if (vec_len (host_if_name) > 64)
20055 errmsg ("host-interface name too long");
20059 M (AF_PACKET_DELETE, mp);
20061 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
20062 vec_free (host_if_name);
20069 static void vl_api_af_packet_details_t_handler
20070 (vl_api_af_packet_details_t * mp)
20072 vat_main_t *vam = &vat_main;
20074 print (vam->ofp, "%-16s %d",
20075 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
20078 static void vl_api_af_packet_details_t_handler_json
20079 (vl_api_af_packet_details_t * mp)
20081 vat_main_t *vam = &vat_main;
20082 vat_json_node_t *node = NULL;
20084 if (VAT_JSON_ARRAY != vam->json_tree.type)
20086 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20087 vat_json_init_array (&vam->json_tree);
20089 node = vat_json_array_add (&vam->json_tree);
20091 vat_json_init_object (node);
20092 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20093 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
20097 api_af_packet_dump (vat_main_t * vam)
20099 vl_api_af_packet_dump_t *mp;
20100 vl_api_control_ping_t *mp_ping;
20103 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
20104 /* Get list of tap interfaces */
20105 M (AF_PACKET_DUMP, mp);
20108 /* Use a control ping for synchronization */
20109 MPING (CONTROL_PING, mp_ping);
20117 api_policer_add_del (vat_main_t * vam)
20119 unformat_input_t *i = vam->input;
20120 vl_api_policer_add_del_t *mp;
20130 u8 color_aware = 0;
20131 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
20134 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
20135 conform_action.dscp = 0;
20136 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
20137 exceed_action.dscp = 0;
20138 violate_action.action_type = SSE2_QOS_ACTION_DROP;
20139 violate_action.dscp = 0;
20141 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20143 if (unformat (i, "del"))
20145 else if (unformat (i, "name %s", &name))
20146 vec_add1 (name, 0);
20147 else if (unformat (i, "cir %u", &cir))
20149 else if (unformat (i, "eir %u", &eir))
20151 else if (unformat (i, "cb %u", &cb))
20153 else if (unformat (i, "eb %u", &eb))
20155 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
20158 else if (unformat (i, "round_type %U", unformat_policer_round_type,
20161 else if (unformat (i, "type %U", unformat_policer_type, &type))
20163 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
20166 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
20169 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
20172 else if (unformat (i, "color-aware"))
20178 if (!vec_len (name))
20180 errmsg ("policer name must be specified");
20184 if (vec_len (name) > 64)
20186 errmsg ("policer name too long");
20190 M (POLICER_ADD_DEL, mp);
20192 clib_memcpy (mp->name, name, vec_len (name));
20194 mp->is_add = is_add;
20195 mp->cir = ntohl (cir);
20196 mp->eir = ntohl (eir);
20197 mp->cb = clib_net_to_host_u64 (cb);
20198 mp->eb = clib_net_to_host_u64 (eb);
20199 mp->rate_type = rate_type;
20200 mp->round_type = round_type;
20202 mp->conform_action_type = conform_action.action_type;
20203 mp->conform_dscp = conform_action.dscp;
20204 mp->exceed_action_type = exceed_action.action_type;
20205 mp->exceed_dscp = exceed_action.dscp;
20206 mp->violate_action_type = violate_action.action_type;
20207 mp->violate_dscp = violate_action.dscp;
20208 mp->color_aware = color_aware;
20216 api_policer_dump (vat_main_t * vam)
20218 unformat_input_t *i = vam->input;
20219 vl_api_policer_dump_t *mp;
20220 vl_api_control_ping_t *mp_ping;
20221 u8 *match_name = 0;
20222 u8 match_name_valid = 0;
20225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20227 if (unformat (i, "name %s", &match_name))
20229 vec_add1 (match_name, 0);
20230 match_name_valid = 1;
20236 M (POLICER_DUMP, mp);
20237 mp->match_name_valid = match_name_valid;
20238 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
20239 vec_free (match_name);
20243 /* Use a control ping for synchronization */
20244 MPING (CONTROL_PING, mp_ping);
20247 /* Wait for a reply... */
20253 api_policer_classify_set_interface (vat_main_t * vam)
20255 unformat_input_t *i = vam->input;
20256 vl_api_policer_classify_set_interface_t *mp;
20258 int sw_if_index_set;
20259 u32 ip4_table_index = ~0;
20260 u32 ip6_table_index = ~0;
20261 u32 l2_table_index = ~0;
20265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20267 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20268 sw_if_index_set = 1;
20269 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20270 sw_if_index_set = 1;
20271 else if (unformat (i, "del"))
20273 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20275 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20277 else if (unformat (i, "l2-table %d", &l2_table_index))
20281 clib_warning ("parse error '%U'", format_unformat_error, i);
20286 if (sw_if_index_set == 0)
20288 errmsg ("missing interface name or sw_if_index");
20292 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20294 mp->sw_if_index = ntohl (sw_if_index);
20295 mp->ip4_table_index = ntohl (ip4_table_index);
20296 mp->ip6_table_index = ntohl (ip6_table_index);
20297 mp->l2_table_index = ntohl (l2_table_index);
20298 mp->is_add = is_add;
20306 api_policer_classify_dump (vat_main_t * vam)
20308 unformat_input_t *i = vam->input;
20309 vl_api_policer_classify_dump_t *mp;
20310 vl_api_control_ping_t *mp_ping;
20311 u8 type = POLICER_CLASSIFY_N_TABLES;
20314 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20318 errmsg ("classify table type must be specified");
20322 if (!vam->json_output)
20324 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20327 M (POLICER_CLASSIFY_DUMP, mp);
20332 /* Use a control ping for synchronization */
20333 MPING (CONTROL_PING, mp_ping);
20336 /* Wait for a reply... */
20342 api_netmap_create (vat_main_t * vam)
20344 unformat_input_t *i = vam->input;
20345 vl_api_netmap_create_t *mp;
20348 u8 random_hw_addr = 1;
20353 clib_memset (hw_addr, 0, sizeof (hw_addr));
20355 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20357 if (unformat (i, "name %s", &if_name))
20358 vec_add1 (if_name, 0);
20359 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20360 random_hw_addr = 0;
20361 else if (unformat (i, "pipe"))
20363 else if (unformat (i, "master"))
20365 else if (unformat (i, "slave"))
20371 if (!vec_len (if_name))
20373 errmsg ("interface name must be specified");
20377 if (vec_len (if_name) > 64)
20379 errmsg ("interface name too long");
20383 M (NETMAP_CREATE, mp);
20385 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20386 clib_memcpy (mp->hw_addr, hw_addr, 6);
20387 mp->use_random_hw_addr = random_hw_addr;
20388 mp->is_pipe = is_pipe;
20389 mp->is_master = is_master;
20390 vec_free (if_name);
20398 api_netmap_delete (vat_main_t * vam)
20400 unformat_input_t *i = vam->input;
20401 vl_api_netmap_delete_t *mp;
20405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20407 if (unformat (i, "name %s", &if_name))
20408 vec_add1 (if_name, 0);
20413 if (!vec_len (if_name))
20415 errmsg ("interface name must be specified");
20419 if (vec_len (if_name) > 64)
20421 errmsg ("interface name too long");
20425 M (NETMAP_DELETE, mp);
20427 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20428 vec_free (if_name);
20436 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20438 if (fp->afi == IP46_TYPE_IP6)
20440 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20441 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20442 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20443 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20444 format_ip6_address, fp->next_hop);
20445 else if (fp->afi == IP46_TYPE_IP4)
20447 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20448 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20449 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20450 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20451 format_ip4_address, fp->next_hop);
20455 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20456 vl_api_fib_path_t * fp)
20458 struct in_addr ip4;
20459 struct in6_addr ip6;
20461 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20462 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20463 vat_json_object_add_uint (node, "is_local", fp->is_local);
20464 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20465 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20466 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20467 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20468 if (fp->afi == IP46_TYPE_IP4)
20470 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20471 vat_json_object_add_ip4 (node, "next_hop", ip4);
20473 else if (fp->afi == IP46_TYPE_IP6)
20475 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20476 vat_json_object_add_ip6 (node, "next_hop", ip6);
20481 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20483 vat_main_t *vam = &vat_main;
20484 int count = ntohl (mp->mt_count);
20485 vl_api_fib_path_t *fp;
20488 print (vam->ofp, "[%d]: sw_if_index %d via:",
20489 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20491 for (i = 0; i < count; i++)
20493 vl_api_mpls_fib_path_print (vam, fp);
20497 print (vam->ofp, "");
20500 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20501 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20504 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20506 vat_main_t *vam = &vat_main;
20507 vat_json_node_t *node = NULL;
20508 int count = ntohl (mp->mt_count);
20509 vl_api_fib_path_t *fp;
20512 if (VAT_JSON_ARRAY != vam->json_tree.type)
20514 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20515 vat_json_init_array (&vam->json_tree);
20517 node = vat_json_array_add (&vam->json_tree);
20519 vat_json_init_object (node);
20520 vat_json_object_add_uint (node, "tunnel_index",
20521 ntohl (mp->mt_tunnel_index));
20522 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20524 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20527 for (i = 0; i < count; i++)
20529 vl_api_mpls_fib_path_json_print (node, fp);
20535 api_mpls_tunnel_dump (vat_main_t * vam)
20537 vl_api_mpls_tunnel_dump_t *mp;
20538 vl_api_control_ping_t *mp_ping;
20539 u32 sw_if_index = ~0;
20542 /* Parse args required to build the message */
20543 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20545 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
20549 print (vam->ofp, " sw_if_index %d", sw_if_index);
20551 M (MPLS_TUNNEL_DUMP, mp);
20552 mp->sw_if_index = htonl (sw_if_index);
20555 /* Use a control ping for synchronization */
20556 MPING (CONTROL_PING, mp_ping);
20563 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20564 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20568 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20570 vat_main_t *vam = &vat_main;
20571 int count = ntohl (mp->count);
20572 vl_api_fib_path_t *fp;
20576 "table-id %d, label %u, ess_bit %u",
20577 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20579 for (i = 0; i < count; i++)
20581 vl_api_mpls_fib_path_print (vam, fp);
20586 static void vl_api_mpls_fib_details_t_handler_json
20587 (vl_api_mpls_fib_details_t * mp)
20589 vat_main_t *vam = &vat_main;
20590 int count = ntohl (mp->count);
20591 vat_json_node_t *node = NULL;
20592 vl_api_fib_path_t *fp;
20595 if (VAT_JSON_ARRAY != vam->json_tree.type)
20597 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20598 vat_json_init_array (&vam->json_tree);
20600 node = vat_json_array_add (&vam->json_tree);
20602 vat_json_init_object (node);
20603 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20604 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20605 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20606 vat_json_object_add_uint (node, "path_count", count);
20608 for (i = 0; i < count; i++)
20610 vl_api_mpls_fib_path_json_print (node, fp);
20616 api_mpls_fib_dump (vat_main_t * vam)
20618 vl_api_mpls_fib_dump_t *mp;
20619 vl_api_control_ping_t *mp_ping;
20622 M (MPLS_FIB_DUMP, mp);
20625 /* Use a control ping for synchronization */
20626 MPING (CONTROL_PING, mp_ping);
20633 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20634 #define vl_api_ip_fib_details_t_print vl_noop_handler
20637 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20639 vat_main_t *vam = &vat_main;
20640 int count = ntohl (mp->count);
20641 vl_api_fib_path_t *fp;
20645 "table-id %d, prefix %U/%d stats-index %d",
20646 ntohl (mp->table_id), format_ip4_address, mp->address,
20647 mp->address_length, ntohl (mp->stats_index));
20649 for (i = 0; i < count; i++)
20651 if (fp->afi == IP46_TYPE_IP6)
20653 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20654 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20655 "next_hop_table %d",
20656 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20657 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20658 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20659 else if (fp->afi == IP46_TYPE_IP4)
20661 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20662 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20663 "next_hop_table %d",
20664 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20665 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20666 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20671 static void vl_api_ip_fib_details_t_handler_json
20672 (vl_api_ip_fib_details_t * mp)
20674 vat_main_t *vam = &vat_main;
20675 int count = ntohl (mp->count);
20676 vat_json_node_t *node = NULL;
20677 struct in_addr ip4;
20678 struct in6_addr ip6;
20679 vl_api_fib_path_t *fp;
20682 if (VAT_JSON_ARRAY != vam->json_tree.type)
20684 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20685 vat_json_init_array (&vam->json_tree);
20687 node = vat_json_array_add (&vam->json_tree);
20689 vat_json_init_object (node);
20690 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20691 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20692 vat_json_object_add_ip4 (node, "prefix", ip4);
20693 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20694 vat_json_object_add_uint (node, "path_count", count);
20696 for (i = 0; i < count; i++)
20698 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20699 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20700 vat_json_object_add_uint (node, "is_local", fp->is_local);
20701 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20702 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20703 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20704 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20705 if (fp->afi == IP46_TYPE_IP4)
20707 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20708 vat_json_object_add_ip4 (node, "next_hop", ip4);
20710 else if (fp->afi == IP46_TYPE_IP6)
20712 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20713 vat_json_object_add_ip6 (node, "next_hop", ip6);
20719 api_ip_fib_dump (vat_main_t * vam)
20721 vl_api_ip_fib_dump_t *mp;
20722 vl_api_control_ping_t *mp_ping;
20725 M (IP_FIB_DUMP, mp);
20728 /* Use a control ping for synchronization */
20729 MPING (CONTROL_PING, mp_ping);
20737 api_ip_mfib_dump (vat_main_t * vam)
20739 vl_api_ip_mfib_dump_t *mp;
20740 vl_api_control_ping_t *mp_ping;
20743 M (IP_MFIB_DUMP, mp);
20746 /* Use a control ping for synchronization */
20747 MPING (CONTROL_PING, mp_ping);
20754 static void vl_api_ip_neighbor_details_t_handler
20755 (vl_api_ip_neighbor_details_t * mp)
20757 vat_main_t *vam = &vat_main;
20759 print (vam->ofp, "%c %U %U",
20760 (mp->is_static) ? 'S' : 'D',
20761 format_ethernet_address, &mp->mac_address,
20762 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20766 static void vl_api_ip_neighbor_details_t_handler_json
20767 (vl_api_ip_neighbor_details_t * mp)
20770 vat_main_t *vam = &vat_main;
20771 vat_json_node_t *node;
20772 struct in_addr ip4;
20773 struct in6_addr ip6;
20775 if (VAT_JSON_ARRAY != vam->json_tree.type)
20777 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20778 vat_json_init_array (&vam->json_tree);
20780 node = vat_json_array_add (&vam->json_tree);
20782 vat_json_init_object (node);
20783 vat_json_object_add_string_copy (node, "flag",
20784 (mp->is_static) ? (u8 *) "static" : (u8 *)
20787 vat_json_object_add_string_copy (node, "link_layer",
20788 format (0, "%U", format_ethernet_address,
20789 &mp->mac_address));
20793 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20794 vat_json_object_add_ip6 (node, "ip_address", ip6);
20798 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20799 vat_json_object_add_ip4 (node, "ip_address", ip4);
20804 api_ip_neighbor_dump (vat_main_t * vam)
20806 unformat_input_t *i = vam->input;
20807 vl_api_ip_neighbor_dump_t *mp;
20808 vl_api_control_ping_t *mp_ping;
20810 u32 sw_if_index = ~0;
20813 /* Parse args required to build the message */
20814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20816 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20818 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20820 else if (unformat (i, "ip6"))
20826 if (sw_if_index == ~0)
20828 errmsg ("missing interface name or sw_if_index");
20832 M (IP_NEIGHBOR_DUMP, mp);
20833 mp->is_ipv6 = (u8) is_ipv6;
20834 mp->sw_if_index = ntohl (sw_if_index);
20837 /* Use a control ping for synchronization */
20838 MPING (CONTROL_PING, mp_ping);
20845 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20846 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20849 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20851 vat_main_t *vam = &vat_main;
20852 int count = ntohl (mp->count);
20853 vl_api_fib_path_t *fp;
20857 "table-id %d, prefix %U/%d stats-index %d",
20858 ntohl (mp->table_id), format_ip6_address, mp->address,
20859 mp->address_length, ntohl (mp->stats_index));
20861 for (i = 0; i < count; i++)
20863 if (fp->afi == IP46_TYPE_IP6)
20865 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20866 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20867 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20868 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20869 format_ip6_address, fp->next_hop);
20870 else if (fp->afi == IP46_TYPE_IP4)
20872 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20873 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20874 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20875 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20876 format_ip4_address, fp->next_hop);
20881 static void vl_api_ip6_fib_details_t_handler_json
20882 (vl_api_ip6_fib_details_t * mp)
20884 vat_main_t *vam = &vat_main;
20885 int count = ntohl (mp->count);
20886 vat_json_node_t *node = NULL;
20887 struct in_addr ip4;
20888 struct in6_addr ip6;
20889 vl_api_fib_path_t *fp;
20892 if (VAT_JSON_ARRAY != vam->json_tree.type)
20894 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20895 vat_json_init_array (&vam->json_tree);
20897 node = vat_json_array_add (&vam->json_tree);
20899 vat_json_init_object (node);
20900 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20901 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20902 vat_json_object_add_ip6 (node, "prefix", ip6);
20903 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20904 vat_json_object_add_uint (node, "path_count", count);
20906 for (i = 0; i < count; i++)
20908 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20909 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20910 vat_json_object_add_uint (node, "is_local", fp->is_local);
20911 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20912 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20913 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20914 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20915 if (fp->afi == IP46_TYPE_IP4)
20917 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20918 vat_json_object_add_ip4 (node, "next_hop", ip4);
20920 else if (fp->afi == IP46_TYPE_IP6)
20922 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20923 vat_json_object_add_ip6 (node, "next_hop", ip6);
20929 api_ip6_fib_dump (vat_main_t * vam)
20931 vl_api_ip6_fib_dump_t *mp;
20932 vl_api_control_ping_t *mp_ping;
20935 M (IP6_FIB_DUMP, mp);
20938 /* Use a control ping for synchronization */
20939 MPING (CONTROL_PING, mp_ping);
20947 api_ip6_mfib_dump (vat_main_t * vam)
20949 vl_api_ip6_mfib_dump_t *mp;
20950 vl_api_control_ping_t *mp_ping;
20953 M (IP6_MFIB_DUMP, mp);
20956 /* Use a control ping for synchronization */
20957 MPING (CONTROL_PING, mp_ping);
20965 api_classify_table_ids (vat_main_t * vam)
20967 vl_api_classify_table_ids_t *mp;
20970 /* Construct the API message */
20971 M (CLASSIFY_TABLE_IDS, mp);
20980 api_classify_table_by_interface (vat_main_t * vam)
20982 unformat_input_t *input = vam->input;
20983 vl_api_classify_table_by_interface_t *mp;
20985 u32 sw_if_index = ~0;
20987 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20989 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20991 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20996 if (sw_if_index == ~0)
20998 errmsg ("missing interface name or sw_if_index");
21002 /* Construct the API message */
21003 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
21005 mp->sw_if_index = ntohl (sw_if_index);
21013 api_classify_table_info (vat_main_t * vam)
21015 unformat_input_t *input = vam->input;
21016 vl_api_classify_table_info_t *mp;
21020 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21022 if (unformat (input, "table_id %d", &table_id))
21027 if (table_id == ~0)
21029 errmsg ("missing table id");
21033 /* Construct the API message */
21034 M (CLASSIFY_TABLE_INFO, mp);
21036 mp->table_id = ntohl (table_id);
21044 api_classify_session_dump (vat_main_t * vam)
21046 unformat_input_t *input = vam->input;
21047 vl_api_classify_session_dump_t *mp;
21048 vl_api_control_ping_t *mp_ping;
21052 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21054 if (unformat (input, "table_id %d", &table_id))
21059 if (table_id == ~0)
21061 errmsg ("missing table id");
21065 /* Construct the API message */
21066 M (CLASSIFY_SESSION_DUMP, mp);
21068 mp->table_id = ntohl (table_id);
21071 /* Use a control ping for synchronization */
21072 MPING (CONTROL_PING, mp_ping);
21080 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
21082 vat_main_t *vam = &vat_main;
21084 print (vam->ofp, "collector_address %U, collector_port %d, "
21085 "src_address %U, vrf_id %d, path_mtu %u, "
21086 "template_interval %u, udp_checksum %d",
21087 format_ip4_address, mp->collector_address,
21088 ntohs (mp->collector_port),
21089 format_ip4_address, mp->src_address,
21090 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
21091 ntohl (mp->template_interval), mp->udp_checksum);
21094 vam->result_ready = 1;
21098 vl_api_ipfix_exporter_details_t_handler_json
21099 (vl_api_ipfix_exporter_details_t * mp)
21101 vat_main_t *vam = &vat_main;
21102 vat_json_node_t node;
21103 struct in_addr collector_address;
21104 struct in_addr src_address;
21106 vat_json_init_object (&node);
21107 clib_memcpy (&collector_address, &mp->collector_address,
21108 sizeof (collector_address));
21109 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
21110 vat_json_object_add_uint (&node, "collector_port",
21111 ntohs (mp->collector_port));
21112 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
21113 vat_json_object_add_ip4 (&node, "src_address", src_address);
21114 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
21115 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
21116 vat_json_object_add_uint (&node, "template_interval",
21117 ntohl (mp->template_interval));
21118 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
21120 vat_json_print (vam->ofp, &node);
21121 vat_json_free (&node);
21123 vam->result_ready = 1;
21127 api_ipfix_exporter_dump (vat_main_t * vam)
21129 vl_api_ipfix_exporter_dump_t *mp;
21132 /* Construct the API message */
21133 M (IPFIX_EXPORTER_DUMP, mp);
21142 api_ipfix_classify_stream_dump (vat_main_t * vam)
21144 vl_api_ipfix_classify_stream_dump_t *mp;
21147 /* Construct the API message */
21148 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
21159 vl_api_ipfix_classify_stream_details_t_handler
21160 (vl_api_ipfix_classify_stream_details_t * mp)
21162 vat_main_t *vam = &vat_main;
21163 print (vam->ofp, "domain_id %d, src_port %d",
21164 ntohl (mp->domain_id), ntohs (mp->src_port));
21166 vam->result_ready = 1;
21170 vl_api_ipfix_classify_stream_details_t_handler_json
21171 (vl_api_ipfix_classify_stream_details_t * mp)
21173 vat_main_t *vam = &vat_main;
21174 vat_json_node_t node;
21176 vat_json_init_object (&node);
21177 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
21178 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
21180 vat_json_print (vam->ofp, &node);
21181 vat_json_free (&node);
21183 vam->result_ready = 1;
21187 api_ipfix_classify_table_dump (vat_main_t * vam)
21189 vl_api_ipfix_classify_table_dump_t *mp;
21190 vl_api_control_ping_t *mp_ping;
21193 if (!vam->json_output)
21195 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
21196 "transport_protocol");
21199 /* Construct the API message */
21200 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
21205 /* Use a control ping for synchronization */
21206 MPING (CONTROL_PING, mp_ping);
21214 vl_api_ipfix_classify_table_details_t_handler
21215 (vl_api_ipfix_classify_table_details_t * mp)
21217 vat_main_t *vam = &vat_main;
21218 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
21219 mp->transport_protocol);
21223 vl_api_ipfix_classify_table_details_t_handler_json
21224 (vl_api_ipfix_classify_table_details_t * mp)
21226 vat_json_node_t *node = NULL;
21227 vat_main_t *vam = &vat_main;
21229 if (VAT_JSON_ARRAY != vam->json_tree.type)
21231 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21232 vat_json_init_array (&vam->json_tree);
21235 node = vat_json_array_add (&vam->json_tree);
21236 vat_json_init_object (node);
21238 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
21239 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
21240 vat_json_object_add_uint (node, "transport_protocol",
21241 mp->transport_protocol);
21245 api_sw_interface_span_enable_disable (vat_main_t * vam)
21247 unformat_input_t *i = vam->input;
21248 vl_api_sw_interface_span_enable_disable_t *mp;
21249 u32 src_sw_if_index = ~0;
21250 u32 dst_sw_if_index = ~0;
21255 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21258 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21260 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21264 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21266 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21268 else if (unformat (i, "disable"))
21270 else if (unformat (i, "rx"))
21272 else if (unformat (i, "tx"))
21274 else if (unformat (i, "both"))
21276 else if (unformat (i, "l2"))
21282 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21284 mp->sw_if_index_from = htonl (src_sw_if_index);
21285 mp->sw_if_index_to = htonl (dst_sw_if_index);
21295 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21298 vat_main_t *vam = &vat_main;
21299 u8 *sw_if_from_name = 0;
21300 u8 *sw_if_to_name = 0;
21301 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21302 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21303 char *states[] = { "none", "rx", "tx", "both" };
21307 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21309 if ((u32) p->value[0] == sw_if_index_from)
21311 sw_if_from_name = (u8 *)(p->key);
21315 if ((u32) p->value[0] == sw_if_index_to)
21317 sw_if_to_name = (u8 *)(p->key);
21318 if (sw_if_from_name)
21323 print (vam->ofp, "%20s => %20s (%s) %s",
21324 sw_if_from_name, sw_if_to_name, states[mp->state],
21325 mp->is_l2 ? "l2" : "device");
21329 vl_api_sw_interface_span_details_t_handler_json
21330 (vl_api_sw_interface_span_details_t * mp)
21332 vat_main_t *vam = &vat_main;
21333 vat_json_node_t *node = NULL;
21334 u8 *sw_if_from_name = 0;
21335 u8 *sw_if_to_name = 0;
21336 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21337 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21341 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21343 if ((u32) p->value[0] == sw_if_index_from)
21345 sw_if_from_name = (u8 *)(p->key);
21349 if ((u32) p->value[0] == sw_if_index_to)
21351 sw_if_to_name = (u8 *)(p->key);
21352 if (sw_if_from_name)
21358 if (VAT_JSON_ARRAY != vam->json_tree.type)
21360 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21361 vat_json_init_array (&vam->json_tree);
21363 node = vat_json_array_add (&vam->json_tree);
21365 vat_json_init_object (node);
21366 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21367 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21368 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21369 if (0 != sw_if_to_name)
21371 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21373 vat_json_object_add_uint (node, "state", mp->state);
21374 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21378 api_sw_interface_span_dump (vat_main_t * vam)
21380 unformat_input_t *input = vam->input;
21381 vl_api_sw_interface_span_dump_t *mp;
21382 vl_api_control_ping_t *mp_ping;
21386 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21388 if (unformat (input, "l2"))
21394 M (SW_INTERFACE_SPAN_DUMP, mp);
21398 /* Use a control ping for synchronization */
21399 MPING (CONTROL_PING, mp_ping);
21407 api_pg_create_interface (vat_main_t * vam)
21409 unformat_input_t *input = vam->input;
21410 vl_api_pg_create_interface_t *mp;
21414 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21416 if (unformat (input, "if_id %d", &if_id))
21423 errmsg ("missing pg interface index");
21427 /* Construct the API message */
21428 M (PG_CREATE_INTERFACE, mp);
21430 mp->interface_id = ntohl (if_id);
21438 api_pg_capture (vat_main_t * vam)
21440 unformat_input_t *input = vam->input;
21441 vl_api_pg_capture_t *mp;
21446 u8 pcap_file_set = 0;
21449 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21451 if (unformat (input, "if_id %d", &if_id))
21453 else if (unformat (input, "pcap %s", &pcap_file))
21455 else if (unformat (input, "count %d", &count))
21457 else if (unformat (input, "disable"))
21464 errmsg ("missing pg interface index");
21467 if (pcap_file_set > 0)
21469 if (vec_len (pcap_file) > 255)
21471 errmsg ("pcap file name is too long");
21476 u32 name_len = vec_len (pcap_file);
21477 /* Construct the API message */
21478 M (PG_CAPTURE, mp);
21480 mp->interface_id = ntohl (if_id);
21481 mp->is_enabled = enable;
21482 mp->count = ntohl (count);
21483 mp->pcap_name_length = ntohl (name_len);
21484 if (pcap_file_set != 0)
21486 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21488 vec_free (pcap_file);
21496 api_pg_enable_disable (vat_main_t * vam)
21498 unformat_input_t *input = vam->input;
21499 vl_api_pg_enable_disable_t *mp;
21502 u8 stream_name_set = 0;
21503 u8 *stream_name = 0;
21505 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21507 if (unformat (input, "stream %s", &stream_name))
21508 stream_name_set = 1;
21509 else if (unformat (input, "disable"))
21515 if (stream_name_set > 0)
21517 if (vec_len (stream_name) > 255)
21519 errmsg ("stream name too long");
21524 u32 name_len = vec_len (stream_name);
21525 /* Construct the API message */
21526 M (PG_ENABLE_DISABLE, mp);
21528 mp->is_enabled = enable;
21529 if (stream_name_set != 0)
21531 mp->stream_name_length = ntohl (name_len);
21532 clib_memcpy (mp->stream_name, stream_name, name_len);
21534 vec_free (stream_name);
21542 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21544 unformat_input_t *input = vam->input;
21545 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21547 u16 *low_ports = 0;
21548 u16 *high_ports = 0;
21551 ip4_address_t ip4_addr;
21552 ip6_address_t ip6_addr;
21561 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21563 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21569 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21574 else if (unformat (input, "vrf %d", &vrf_id))
21576 else if (unformat (input, "del"))
21578 else if (unformat (input, "port %d", &tmp))
21580 if (tmp == 0 || tmp > 65535)
21582 errmsg ("port %d out of range", tmp);
21586 this_hi = this_low + 1;
21587 vec_add1 (low_ports, this_low);
21588 vec_add1 (high_ports, this_hi);
21590 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21592 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21594 errmsg ("incorrect range parameters");
21598 /* Note: in debug CLI +1 is added to high before
21599 passing to real fn that does "the work"
21600 (ip_source_and_port_range_check_add_del).
21601 This fn is a wrapper around the binary API fn a
21602 control plane will call, which expects this increment
21603 to have occurred. Hence letting the binary API control
21604 plane fn do the increment for consistency between VAT
21605 and other control planes.
21608 vec_add1 (low_ports, this_low);
21609 vec_add1 (high_ports, this_hi);
21615 if (prefix_set == 0)
21617 errmsg ("<address>/<mask> not specified");
21623 errmsg ("VRF ID required, not specified");
21630 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21634 if (vec_len (low_ports) == 0)
21636 errmsg ("At least one port or port range required");
21640 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21642 mp->is_add = is_add;
21647 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21652 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21655 mp->mask_length = length;
21656 mp->number_of_ranges = vec_len (low_ports);
21658 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21659 vec_free (low_ports);
21661 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21662 vec_free (high_ports);
21664 mp->vrf_id = ntohl (vrf_id);
21672 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21674 unformat_input_t *input = vam->input;
21675 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21676 u32 sw_if_index = ~0;
21678 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21679 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21683 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21685 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21687 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21689 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21691 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21693 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21695 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21697 else if (unformat (input, "del"))
21703 if (sw_if_index == ~0)
21705 errmsg ("Interface required but not specified");
21711 errmsg ("VRF ID required but not specified");
21715 if (tcp_out_vrf_id == 0
21716 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21719 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21723 /* Construct the API message */
21724 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21726 mp->sw_if_index = ntohl (sw_if_index);
21727 mp->is_add = is_add;
21728 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21729 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21730 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21731 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21736 /* Wait for a reply... */
21742 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21744 unformat_input_t *i = vam->input;
21745 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21746 u32 local_sa_id = 0;
21747 u32 remote_sa_id = 0;
21748 ip4_address_t src_address;
21749 ip4_address_t dst_address;
21753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21755 if (unformat (i, "local_sa %d", &local_sa_id))
21757 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21759 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21761 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21763 else if (unformat (i, "del"))
21767 clib_warning ("parse error '%U'", format_unformat_error, i);
21772 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21774 mp->local_sa_id = ntohl (local_sa_id);
21775 mp->remote_sa_id = ntohl (remote_sa_id);
21776 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21777 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21778 mp->is_add = is_add;
21786 api_punt (vat_main_t * vam)
21788 unformat_input_t *i = vam->input;
21796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21798 if (unformat (i, "ip %d", &ipv))
21800 else if (unformat (i, "protocol %d", &protocol))
21802 else if (unformat (i, "port %d", &port))
21804 else if (unformat (i, "del"))
21808 clib_warning ("parse error '%U'", format_unformat_error, i);
21815 mp->is_add = (u8) is_add;
21816 mp->ipv = (u8) ipv;
21817 mp->l4_protocol = (u8) protocol;
21818 mp->l4_port = htons ((u16) port);
21825 static void vl_api_ipsec_gre_tunnel_details_t_handler
21826 (vl_api_ipsec_gre_tunnel_details_t * mp)
21828 vat_main_t *vam = &vat_main;
21830 print (vam->ofp, "%11d%15U%15U%14d%14d",
21831 ntohl (mp->sw_if_index),
21832 format_ip4_address, &mp->src_address,
21833 format_ip4_address, &mp->dst_address,
21834 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21837 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21838 (vl_api_ipsec_gre_tunnel_details_t * mp)
21840 vat_main_t *vam = &vat_main;
21841 vat_json_node_t *node = NULL;
21842 struct in_addr ip4;
21844 if (VAT_JSON_ARRAY != vam->json_tree.type)
21846 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21847 vat_json_init_array (&vam->json_tree);
21849 node = vat_json_array_add (&vam->json_tree);
21851 vat_json_init_object (node);
21852 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21853 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21854 vat_json_object_add_ip4 (node, "src_address", ip4);
21855 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21856 vat_json_object_add_ip4 (node, "dst_address", ip4);
21857 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21858 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21862 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21864 unformat_input_t *i = vam->input;
21865 vl_api_ipsec_gre_tunnel_dump_t *mp;
21866 vl_api_control_ping_t *mp_ping;
21868 u8 sw_if_index_set = 0;
21871 /* Parse args required to build the message */
21872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21874 if (unformat (i, "sw_if_index %d", &sw_if_index))
21875 sw_if_index_set = 1;
21880 if (sw_if_index_set == 0)
21885 if (!vam->json_output)
21887 print (vam->ofp, "%11s%15s%15s%14s%14s",
21888 "sw_if_index", "src_address", "dst_address",
21889 "local_sa_id", "remote_sa_id");
21892 /* Get list of gre-tunnel interfaces */
21893 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21895 mp->sw_if_index = htonl (sw_if_index);
21899 /* Use a control ping for synchronization */
21900 MPING (CONTROL_PING, mp_ping);
21908 api_delete_subif (vat_main_t * vam)
21910 unformat_input_t *i = vam->input;
21911 vl_api_delete_subif_t *mp;
21912 u32 sw_if_index = ~0;
21915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21917 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21919 if (unformat (i, "sw_if_index %d", &sw_if_index))
21925 if (sw_if_index == ~0)
21927 errmsg ("missing sw_if_index");
21931 /* Construct the API message */
21932 M (DELETE_SUBIF, mp);
21933 mp->sw_if_index = ntohl (sw_if_index);
21940 #define foreach_pbb_vtr_op \
21941 _("disable", L2_VTR_DISABLED) \
21942 _("pop", L2_VTR_POP_2) \
21943 _("push", L2_VTR_PUSH_2)
21946 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21948 unformat_input_t *i = vam->input;
21949 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21950 u32 sw_if_index = ~0, vtr_op = ~0;
21951 u16 outer_tag = ~0;
21952 u8 dmac[6], smac[6];
21953 u8 dmac_set = 0, smac_set = 0;
21959 /* Shut up coverity */
21960 clib_memset (dmac, 0, sizeof (dmac));
21961 clib_memset (smac, 0, sizeof (smac));
21963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21965 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21967 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21969 else if (unformat (i, "vtr_op %d", &vtr_op))
21971 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21974 else if (unformat (i, "translate_pbb_stag"))
21976 if (unformat (i, "%d", &tmp))
21978 vtr_op = L2_VTR_TRANSLATE_2_1;
21984 ("translate_pbb_stag operation requires outer tag definition");
21988 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21990 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21992 else if (unformat (i, "sid %d", &sid))
21994 else if (unformat (i, "vlanid %d", &tmp))
21998 clib_warning ("parse error '%U'", format_unformat_error, i);
22003 if ((sw_if_index == ~0) || (vtr_op == ~0))
22005 errmsg ("missing sw_if_index or vtr operation");
22008 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
22009 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
22012 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
22016 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
22017 mp->sw_if_index = ntohl (sw_if_index);
22018 mp->vtr_op = ntohl (vtr_op);
22019 mp->outer_tag = ntohs (outer_tag);
22020 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
22021 clib_memcpy (mp->b_smac, smac, sizeof (smac));
22022 mp->b_vlanid = ntohs (vlanid);
22023 mp->i_sid = ntohl (sid);
22031 api_flow_classify_set_interface (vat_main_t * vam)
22033 unformat_input_t *i = vam->input;
22034 vl_api_flow_classify_set_interface_t *mp;
22036 int sw_if_index_set;
22037 u32 ip4_table_index = ~0;
22038 u32 ip6_table_index = ~0;
22042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22044 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22045 sw_if_index_set = 1;
22046 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22047 sw_if_index_set = 1;
22048 else if (unformat (i, "del"))
22050 else if (unformat (i, "ip4-table %d", &ip4_table_index))
22052 else if (unformat (i, "ip6-table %d", &ip6_table_index))
22056 clib_warning ("parse error '%U'", format_unformat_error, i);
22061 if (sw_if_index_set == 0)
22063 errmsg ("missing interface name or sw_if_index");
22067 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
22069 mp->sw_if_index = ntohl (sw_if_index);
22070 mp->ip4_table_index = ntohl (ip4_table_index);
22071 mp->ip6_table_index = ntohl (ip6_table_index);
22072 mp->is_add = is_add;
22080 api_flow_classify_dump (vat_main_t * vam)
22082 unformat_input_t *i = vam->input;
22083 vl_api_flow_classify_dump_t *mp;
22084 vl_api_control_ping_t *mp_ping;
22085 u8 type = FLOW_CLASSIFY_N_TABLES;
22088 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
22092 errmsg ("classify table type must be specified");
22096 if (!vam->json_output)
22098 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
22101 M (FLOW_CLASSIFY_DUMP, mp);
22106 /* Use a control ping for synchronization */
22107 MPING (CONTROL_PING, mp_ping);
22110 /* Wait for a reply... */
22116 api_feature_enable_disable (vat_main_t * vam)
22118 unformat_input_t *i = vam->input;
22119 vl_api_feature_enable_disable_t *mp;
22121 u8 *feature_name = 0;
22122 u32 sw_if_index = ~0;
22126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22128 if (unformat (i, "arc_name %s", &arc_name))
22130 else if (unformat (i, "feature_name %s", &feature_name))
22133 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22135 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22137 else if (unformat (i, "disable"))
22145 errmsg ("missing arc name");
22148 if (vec_len (arc_name) > 63)
22150 errmsg ("arc name too long");
22153 if (feature_name == 0)
22155 errmsg ("missing feature name");
22158 if (vec_len (feature_name) > 63)
22160 errmsg ("feature name too long");
22163 if (sw_if_index == ~0)
22165 errmsg ("missing interface name or sw_if_index");
22169 /* Construct the API message */
22170 M (FEATURE_ENABLE_DISABLE, mp);
22171 mp->sw_if_index = ntohl (sw_if_index);
22172 mp->enable = enable;
22173 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
22174 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
22175 vec_free (arc_name);
22176 vec_free (feature_name);
22184 api_sw_interface_tag_add_del (vat_main_t * vam)
22186 unformat_input_t *i = vam->input;
22187 vl_api_sw_interface_tag_add_del_t *mp;
22188 u32 sw_if_index = ~0;
22193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22195 if (unformat (i, "tag %s", &tag))
22197 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22199 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22201 else if (unformat (i, "del"))
22207 if (sw_if_index == ~0)
22209 errmsg ("missing interface name or sw_if_index");
22213 if (enable && (tag == 0))
22215 errmsg ("no tag specified");
22219 /* Construct the API message */
22220 M (SW_INTERFACE_TAG_ADD_DEL, mp);
22221 mp->sw_if_index = ntohl (sw_if_index);
22222 mp->is_add = enable;
22224 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
22232 static void vl_api_l2_xconnect_details_t_handler
22233 (vl_api_l2_xconnect_details_t * mp)
22235 vat_main_t *vam = &vat_main;
22237 print (vam->ofp, "%15d%15d",
22238 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
22241 static void vl_api_l2_xconnect_details_t_handler_json
22242 (vl_api_l2_xconnect_details_t * mp)
22244 vat_main_t *vam = &vat_main;
22245 vat_json_node_t *node = NULL;
22247 if (VAT_JSON_ARRAY != vam->json_tree.type)
22249 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22250 vat_json_init_array (&vam->json_tree);
22252 node = vat_json_array_add (&vam->json_tree);
22254 vat_json_init_object (node);
22255 vat_json_object_add_uint (node, "rx_sw_if_index",
22256 ntohl (mp->rx_sw_if_index));
22257 vat_json_object_add_uint (node, "tx_sw_if_index",
22258 ntohl (mp->tx_sw_if_index));
22262 api_l2_xconnect_dump (vat_main_t * vam)
22264 vl_api_l2_xconnect_dump_t *mp;
22265 vl_api_control_ping_t *mp_ping;
22268 if (!vam->json_output)
22270 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22273 M (L2_XCONNECT_DUMP, mp);
22277 /* Use a control ping for synchronization */
22278 MPING (CONTROL_PING, mp_ping);
22286 api_hw_interface_set_mtu (vat_main_t * vam)
22288 unformat_input_t *i = vam->input;
22289 vl_api_hw_interface_set_mtu_t *mp;
22290 u32 sw_if_index = ~0;
22294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22296 if (unformat (i, "mtu %d", &mtu))
22298 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22300 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22306 if (sw_if_index == ~0)
22308 errmsg ("missing interface name or sw_if_index");
22314 errmsg ("no mtu specified");
22318 /* Construct the API message */
22319 M (HW_INTERFACE_SET_MTU, mp);
22320 mp->sw_if_index = ntohl (sw_if_index);
22321 mp->mtu = ntohs ((u16) mtu);
22329 api_p2p_ethernet_add (vat_main_t * vam)
22331 unformat_input_t *i = vam->input;
22332 vl_api_p2p_ethernet_add_t *mp;
22333 u32 parent_if_index = ~0;
22339 clib_memset (remote_mac, 0, sizeof (remote_mac));
22340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22342 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22344 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22348 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22350 else if (unformat (i, "sub_id %d", &sub_id))
22354 clib_warning ("parse error '%U'", format_unformat_error, i);
22359 if (parent_if_index == ~0)
22361 errmsg ("missing interface name or sw_if_index");
22366 errmsg ("missing remote mac address");
22371 errmsg ("missing sub-interface id");
22375 M (P2P_ETHERNET_ADD, mp);
22376 mp->parent_if_index = ntohl (parent_if_index);
22377 mp->subif_id = ntohl (sub_id);
22378 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22386 api_p2p_ethernet_del (vat_main_t * vam)
22388 unformat_input_t *i = vam->input;
22389 vl_api_p2p_ethernet_del_t *mp;
22390 u32 parent_if_index = ~0;
22395 clib_memset (remote_mac, 0, sizeof (remote_mac));
22396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22398 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22400 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22404 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22408 clib_warning ("parse error '%U'", format_unformat_error, i);
22413 if (parent_if_index == ~0)
22415 errmsg ("missing interface name or sw_if_index");
22420 errmsg ("missing remote mac address");
22424 M (P2P_ETHERNET_DEL, mp);
22425 mp->parent_if_index = ntohl (parent_if_index);
22426 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22434 api_lldp_config (vat_main_t * vam)
22436 unformat_input_t *i = vam->input;
22437 vl_api_lldp_config_t *mp;
22439 int tx_interval = 0;
22440 u8 *sys_name = NULL;
22443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22445 if (unformat (i, "system-name %s", &sys_name))
22447 else if (unformat (i, "tx-hold %d", &tx_hold))
22449 else if (unformat (i, "tx-interval %d", &tx_interval))
22453 clib_warning ("parse error '%U'", format_unformat_error, i);
22458 vec_add1 (sys_name, 0);
22460 M (LLDP_CONFIG, mp);
22461 mp->tx_hold = htonl (tx_hold);
22462 mp->tx_interval = htonl (tx_interval);
22463 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22464 vec_free (sys_name);
22472 api_sw_interface_set_lldp (vat_main_t * vam)
22474 unformat_input_t *i = vam->input;
22475 vl_api_sw_interface_set_lldp_t *mp;
22476 u32 sw_if_index = ~0;
22478 u8 *port_desc = NULL, *mgmt_oid = NULL;
22479 ip4_address_t ip4_addr;
22480 ip6_address_t ip6_addr;
22483 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
22484 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
22486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22488 if (unformat (i, "disable"))
22491 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22493 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22495 else if (unformat (i, "port-desc %s", &port_desc))
22497 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22499 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22501 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22507 if (sw_if_index == ~0)
22509 errmsg ("missing interface name or sw_if_index");
22513 /* Construct the API message */
22514 vec_add1 (port_desc, 0);
22515 vec_add1 (mgmt_oid, 0);
22516 M (SW_INTERFACE_SET_LLDP, mp);
22517 mp->sw_if_index = ntohl (sw_if_index);
22518 mp->enable = enable;
22519 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22520 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22521 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22522 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22523 vec_free (port_desc);
22524 vec_free (mgmt_oid);
22532 api_tcp_configure_src_addresses (vat_main_t * vam)
22534 vl_api_tcp_configure_src_addresses_t *mp;
22535 unformat_input_t *i = vam->input;
22536 ip4_address_t v4first, v4last;
22537 ip6_address_t v6first, v6last;
22542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22544 if (unformat (i, "%U - %U",
22545 unformat_ip4_address, &v4first,
22546 unformat_ip4_address, &v4last))
22550 errmsg ("one range per message (range already set)");
22555 else if (unformat (i, "%U - %U",
22556 unformat_ip6_address, &v6first,
22557 unformat_ip6_address, &v6last))
22561 errmsg ("one range per message (range already set)");
22566 else if (unformat (i, "vrf %d", &vrf_id))
22572 if (range_set == 0)
22574 errmsg ("address range not set");
22578 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22579 mp->vrf_id = ntohl (vrf_id);
22581 if (range_set == 2)
22584 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22585 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22590 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22591 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22598 static void vl_api_app_namespace_add_del_reply_t_handler
22599 (vl_api_app_namespace_add_del_reply_t * mp)
22601 vat_main_t *vam = &vat_main;
22602 i32 retval = ntohl (mp->retval);
22603 if (vam->async_mode)
22605 vam->async_errors += (retval < 0);
22609 vam->retval = retval;
22611 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22612 vam->result_ready = 1;
22616 static void vl_api_app_namespace_add_del_reply_t_handler_json
22617 (vl_api_app_namespace_add_del_reply_t * mp)
22619 vat_main_t *vam = &vat_main;
22620 vat_json_node_t node;
22622 vat_json_init_object (&node);
22623 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22624 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22626 vat_json_print (vam->ofp, &node);
22627 vat_json_free (&node);
22629 vam->retval = ntohl (mp->retval);
22630 vam->result_ready = 1;
22634 api_app_namespace_add_del (vat_main_t * vam)
22636 vl_api_app_namespace_add_del_t *mp;
22637 unformat_input_t *i = vam->input;
22638 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22639 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22645 if (unformat (i, "id %_%v%_", &ns_id))
22647 else if (unformat (i, "secret %lu", &secret))
22649 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22650 sw_if_index_set = 1;
22651 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22653 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22658 if (!ns_id || !secret_set || !sw_if_index_set)
22660 errmsg ("namespace id, secret and sw_if_index must be set");
22663 if (vec_len (ns_id) > 64)
22665 errmsg ("namespace id too long");
22668 M (APP_NAMESPACE_ADD_DEL, mp);
22670 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22671 mp->namespace_id_len = vec_len (ns_id);
22672 mp->secret = clib_host_to_net_u64 (secret);
22673 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22674 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22675 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22683 api_sock_init_shm (vat_main_t * vam)
22685 #if VPP_API_TEST_BUILTIN == 0
22686 unformat_input_t *i = vam->input;
22687 vl_api_shm_elem_config_t *config = 0;
22688 u64 size = 64 << 20;
22691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22693 if (unformat (i, "size %U", unformat_memory_size, &size))
22700 * Canned custom ring allocator config.
22701 * Should probably parse all of this
22703 vec_validate (config, 6);
22704 config[0].type = VL_API_VLIB_RING;
22705 config[0].size = 256;
22706 config[0].count = 32;
22708 config[1].type = VL_API_VLIB_RING;
22709 config[1].size = 1024;
22710 config[1].count = 16;
22712 config[2].type = VL_API_VLIB_RING;
22713 config[2].size = 4096;
22714 config[2].count = 2;
22716 config[3].type = VL_API_CLIENT_RING;
22717 config[3].size = 256;
22718 config[3].count = 32;
22720 config[4].type = VL_API_CLIENT_RING;
22721 config[4].size = 1024;
22722 config[4].count = 16;
22724 config[5].type = VL_API_CLIENT_RING;
22725 config[5].size = 4096;
22726 config[5].count = 2;
22728 config[6].type = VL_API_QUEUE;
22729 config[6].count = 128;
22730 config[6].size = sizeof (uword);
22732 rv = vl_socket_client_init_shm (config);
22734 vam->client_index_invalid = 1;
22742 api_dns_enable_disable (vat_main_t * vam)
22744 unformat_input_t *line_input = vam->input;
22745 vl_api_dns_enable_disable_t *mp;
22746 u8 enable_disable = 1;
22749 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22751 if (unformat (line_input, "disable"))
22752 enable_disable = 0;
22753 if (unformat (line_input, "enable"))
22754 enable_disable = 1;
22759 /* Construct the API message */
22760 M (DNS_ENABLE_DISABLE, mp);
22761 mp->enable = enable_disable;
22765 /* Wait for the reply */
22771 api_dns_resolve_name (vat_main_t * vam)
22773 unformat_input_t *line_input = vam->input;
22774 vl_api_dns_resolve_name_t *mp;
22778 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22780 if (unformat (line_input, "%s", &name))
22786 if (vec_len (name) > 127)
22788 errmsg ("name too long");
22792 /* Construct the API message */
22793 M (DNS_RESOLVE_NAME, mp);
22794 memcpy (mp->name, name, vec_len (name));
22799 /* Wait for the reply */
22805 api_dns_resolve_ip (vat_main_t * vam)
22807 unformat_input_t *line_input = vam->input;
22808 vl_api_dns_resolve_ip_t *mp;
22810 ip4_address_t addr4;
22811 ip6_address_t addr6;
22814 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22816 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22818 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22826 errmsg ("missing address");
22830 /* Construct the API message */
22831 M (DNS_RESOLVE_IP, mp);
22832 mp->is_ip6 = is_ip6;
22834 memcpy (mp->address, &addr6, sizeof (addr6));
22836 memcpy (mp->address, &addr4, sizeof (addr4));
22840 /* Wait for the reply */
22846 api_dns_name_server_add_del (vat_main_t * vam)
22848 unformat_input_t *i = vam->input;
22849 vl_api_dns_name_server_add_del_t *mp;
22851 ip6_address_t ip6_server;
22852 ip4_address_t ip4_server;
22857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22859 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22861 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22863 else if (unformat (i, "del"))
22867 clib_warning ("parse error '%U'", format_unformat_error, i);
22872 if (ip4_set && ip6_set)
22874 errmsg ("Only one server address allowed per message");
22877 if ((ip4_set + ip6_set) == 0)
22879 errmsg ("Server address required");
22883 /* Construct the API message */
22884 M (DNS_NAME_SERVER_ADD_DEL, mp);
22888 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22893 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22897 mp->is_add = is_add;
22902 /* Wait for a reply, return good/bad news */
22908 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22910 vat_main_t *vam = &vat_main;
22915 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22916 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22917 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22918 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22919 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22920 clib_net_to_host_u32 (mp->action_index), mp->tag);
22925 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22926 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22927 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22928 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22929 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22930 clib_net_to_host_u32 (mp->action_index), mp->tag);
22935 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22938 vat_main_t *vam = &vat_main;
22939 vat_json_node_t *node = NULL;
22940 struct in6_addr ip6;
22941 struct in_addr ip4;
22943 if (VAT_JSON_ARRAY != vam->json_tree.type)
22945 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22946 vat_json_init_array (&vam->json_tree);
22948 node = vat_json_array_add (&vam->json_tree);
22949 vat_json_init_object (node);
22951 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22952 vat_json_object_add_uint (node, "appns_index",
22953 clib_net_to_host_u32 (mp->appns_index));
22954 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22955 vat_json_object_add_uint (node, "scope", mp->scope);
22956 vat_json_object_add_uint (node, "action_index",
22957 clib_net_to_host_u32 (mp->action_index));
22958 vat_json_object_add_uint (node, "lcl_port",
22959 clib_net_to_host_u16 (mp->lcl_port));
22960 vat_json_object_add_uint (node, "rmt_port",
22961 clib_net_to_host_u16 (mp->rmt_port));
22962 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22963 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22964 vat_json_object_add_string_copy (node, "tag", mp->tag);
22967 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22968 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22969 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22970 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22974 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22975 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22976 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22977 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22982 api_session_rule_add_del (vat_main_t * vam)
22984 vl_api_session_rule_add_del_t *mp;
22985 unformat_input_t *i = vam->input;
22986 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22987 u32 appns_index = 0, scope = 0;
22988 ip4_address_t lcl_ip4, rmt_ip4;
22989 ip6_address_t lcl_ip6, rmt_ip6;
22990 u8 is_ip4 = 1, conn_set = 0;
22991 u8 is_add = 1, *tag = 0;
22994 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22996 if (unformat (i, "del"))
22998 else if (unformat (i, "add"))
23000 else if (unformat (i, "proto tcp"))
23002 else if (unformat (i, "proto udp"))
23004 else if (unformat (i, "appns %d", &appns_index))
23006 else if (unformat (i, "scope %d", &scope))
23008 else if (unformat (i, "tag %_%v%_", &tag))
23012 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
23013 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
23021 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
23022 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
23028 else if (unformat (i, "action %d", &action))
23033 if (proto == ~0 || !conn_set || action == ~0)
23035 errmsg ("transport proto, connection and action must be set");
23041 errmsg ("scope should be 0-3");
23045 M (SESSION_RULE_ADD_DEL, mp);
23047 mp->is_ip4 = is_ip4;
23048 mp->transport_proto = proto;
23049 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
23050 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
23051 mp->lcl_plen = lcl_plen;
23052 mp->rmt_plen = rmt_plen;
23053 mp->action_index = clib_host_to_net_u32 (action);
23054 mp->appns_index = clib_host_to_net_u32 (appns_index);
23056 mp->is_add = is_add;
23059 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
23060 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
23064 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
23065 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
23069 clib_memcpy (mp->tag, tag, vec_len (tag));
23079 api_session_rules_dump (vat_main_t * vam)
23081 vl_api_session_rules_dump_t *mp;
23082 vl_api_control_ping_t *mp_ping;
23085 if (!vam->json_output)
23087 print (vam->ofp, "%=20s", "Session Rules");
23090 M (SESSION_RULES_DUMP, mp);
23094 /* Use a control ping for synchronization */
23095 MPING (CONTROL_PING, mp_ping);
23098 /* Wait for a reply... */
23104 api_ip_container_proxy_add_del (vat_main_t * vam)
23106 vl_api_ip_container_proxy_add_del_t *mp;
23107 unformat_input_t *i = vam->input;
23108 u32 plen = ~0, sw_if_index = ~0;
23115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23117 if (unformat (i, "del"))
23119 else if (unformat (i, "add"))
23121 if (unformat (i, "%U", unformat_ip4_address, &ip4))
23126 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
23131 else if (unformat (i, "sw_if_index %u", &sw_if_index))
23136 if (sw_if_index == ~0 || plen == ~0)
23138 errmsg ("address and sw_if_index must be set");
23142 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
23144 mp->is_ip4 = is_ip4;
23145 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
23147 mp->is_add = is_add;
23149 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
23151 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
23159 api_qos_record_enable_disable (vat_main_t * vam)
23161 unformat_input_t *i = vam->input;
23162 vl_api_qos_record_enable_disable_t *mp;
23163 u32 sw_if_index, qs = 0xff;
23164 u8 sw_if_index_set = 0;
23168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23170 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
23171 sw_if_index_set = 1;
23172 else if (unformat (i, "sw_if_index %d", &sw_if_index))
23173 sw_if_index_set = 1;
23174 else if (unformat (i, "%U", unformat_qos_source, &qs))
23176 else if (unformat (i, "disable"))
23180 clib_warning ("parse error '%U'", format_unformat_error, i);
23185 if (sw_if_index_set == 0)
23187 errmsg ("missing interface name or sw_if_index");
23192 errmsg ("input location must be specified");
23196 M (QOS_RECORD_ENABLE_DISABLE, mp);
23198 mp->sw_if_index = ntohl (sw_if_index);
23199 mp->input_source = qs;
23200 mp->enable = enable;
23209 q_or_quit (vat_main_t * vam)
23211 #if VPP_API_TEST_BUILTIN == 0
23212 longjmp (vam->jump_buf, 1);
23214 return 0; /* not so much */
23218 q (vat_main_t * vam)
23220 return q_or_quit (vam);
23224 quit (vat_main_t * vam)
23226 return q_or_quit (vam);
23230 comment (vat_main_t * vam)
23236 statseg (vat_main_t * vam)
23238 ssvm_private_t *ssvmp = &vam->stat_segment;
23239 ssvm_shared_header_t *shared_header = ssvmp->sh;
23240 vlib_counter_t **counters;
23241 u64 thread0_index1_packets;
23242 u64 thread0_index1_bytes;
23243 f64 vector_rate, input_rate;
23246 uword *counter_vector_by_name;
23247 if (vam->stat_segment_lockp == 0)
23249 errmsg ("Stat segment not mapped...");
23253 /* look up "/if/rx for sw_if_index 1 as a test */
23255 clib_spinlock_lock (vam->stat_segment_lockp);
23257 counter_vector_by_name = (uword *) shared_header->opaque[1];
23259 p = hash_get_mem (counter_vector_by_name, "/if/rx");
23262 clib_spinlock_unlock (vam->stat_segment_lockp);
23263 errmsg ("/if/tx not found?");
23267 /* Fish per-thread vector of combined counters from shared memory */
23268 counters = (vlib_counter_t **) p[0];
23270 if (vec_len (counters[0]) < 2)
23272 clib_spinlock_unlock (vam->stat_segment_lockp);
23273 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
23277 /* Read thread 0 sw_if_index 1 counter */
23278 thread0_index1_packets = counters[0][1].packets;
23279 thread0_index1_bytes = counters[0][1].bytes;
23281 p = hash_get_mem (counter_vector_by_name, "vector_rate");
23284 clib_spinlock_unlock (vam->stat_segment_lockp);
23285 errmsg ("vector_rate not found?");
23289 vector_rate = *(f64 *) (p[0]);
23290 p = hash_get_mem (counter_vector_by_name, "input_rate");
23293 clib_spinlock_unlock (vam->stat_segment_lockp);
23294 errmsg ("input_rate not found?");
23297 input_rate = *(f64 *) (p[0]);
23299 clib_spinlock_unlock (vam->stat_segment_lockp);
23301 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
23302 vector_rate, input_rate);
23303 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
23304 thread0_index1_packets, thread0_index1_bytes);
23310 cmd_cmp (void *a1, void *a2)
23315 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23319 help (vat_main_t * vam)
23324 unformat_input_t *i = vam->input;
23327 if (unformat (i, "%s", &name))
23331 vec_add1 (name, 0);
23333 hs = hash_get_mem (vam->help_by_name, name);
23335 print (vam->ofp, "usage: %s %s", name, hs[0]);
23337 print (vam->ofp, "No such msg / command '%s'", name);
23342 print (vam->ofp, "Help is available for the following:");
23345 hash_foreach_pair (p, vam->function_by_name,
23347 vec_add1 (cmds, (u8 *)(p->key));
23351 vec_sort_with_function (cmds, cmd_cmp);
23353 for (j = 0; j < vec_len (cmds); j++)
23354 print (vam->ofp, "%s", cmds[j]);
23361 set (vat_main_t * vam)
23363 u8 *name = 0, *value = 0;
23364 unformat_input_t *i = vam->input;
23366 if (unformat (i, "%s", &name))
23368 /* The input buffer is a vector, not a string. */
23369 value = vec_dup (i->buffer);
23370 vec_delete (value, i->index, 0);
23371 /* Almost certainly has a trailing newline */
23372 if (value[vec_len (value) - 1] == '\n')
23373 value[vec_len (value) - 1] = 0;
23374 /* Make sure it's a proper string, one way or the other */
23375 vec_add1 (value, 0);
23376 (void) clib_macro_set_value (&vam->macro_main,
23377 (char *) name, (char *) value);
23380 errmsg ("usage: set <name> <value>");
23388 unset (vat_main_t * vam)
23392 if (unformat (vam->input, "%s", &name))
23393 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23394 errmsg ("unset: %s wasn't set", name);
23407 macro_sort_cmp (void *a1, void *a2)
23409 macro_sort_t *s1 = a1;
23410 macro_sort_t *s2 = a2;
23412 return strcmp ((char *) (s1->name), (char *) (s2->name));
23416 dump_macro_table (vat_main_t * vam)
23418 macro_sort_t *sort_me = 0, *sm;
23423 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23425 vec_add2 (sort_me, sm, 1);
23426 sm->name = (u8 *)(p->key);
23427 sm->value = (u8 *) (p->value[0]);
23431 vec_sort_with_function (sort_me, macro_sort_cmp);
23433 if (vec_len (sort_me))
23434 print (vam->ofp, "%-15s%s", "Name", "Value");
23436 print (vam->ofp, "The macro table is empty...");
23438 for (i = 0; i < vec_len (sort_me); i++)
23439 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23444 dump_node_table (vat_main_t * vam)
23447 vlib_node_t *node, *next_node;
23449 if (vec_len (vam->graph_nodes) == 0)
23451 print (vam->ofp, "Node table empty, issue get_node_graph...");
23455 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
23457 node = vam->graph_nodes[0][i];
23458 print (vam->ofp, "[%d] %s", i, node->name);
23459 for (j = 0; j < vec_len (node->next_nodes); j++)
23461 if (node->next_nodes[j] != ~0)
23463 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23464 print (vam->ofp, " [%d] %s", j, next_node->name);
23472 value_sort_cmp (void *a1, void *a2)
23474 name_sort_t *n1 = a1;
23475 name_sort_t *n2 = a2;
23477 if (n1->value < n2->value)
23479 if (n1->value > n2->value)
23486 dump_msg_api_table (vat_main_t * vam)
23488 api_main_t *am = &api_main;
23489 name_sort_t *nses = 0, *ns;
23494 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23496 vec_add2 (nses, ns, 1);
23497 ns->name = (u8 *)(hp->key);
23498 ns->value = (u32) hp->value[0];
23502 vec_sort_with_function (nses, value_sort_cmp);
23504 for (i = 0; i < vec_len (nses); i++)
23505 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23511 get_msg_id (vat_main_t * vam)
23516 if (unformat (vam->input, "%s", &name_and_crc))
23518 message_index = vl_msg_api_get_msg_index (name_and_crc);
23519 if (message_index == ~0)
23521 print (vam->ofp, " '%s' not found", name_and_crc);
23524 print (vam->ofp, " '%s' has message index %d",
23525 name_and_crc, message_index);
23528 errmsg ("name_and_crc required...");
23533 search_node_table (vat_main_t * vam)
23535 unformat_input_t *line_input = vam->input;
23538 vlib_node_t *node, *next_node;
23541 if (vam->graph_node_index_by_name == 0)
23543 print (vam->ofp, "Node table empty, issue get_node_graph...");
23547 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23549 if (unformat (line_input, "%s", &node_to_find))
23551 vec_add1 (node_to_find, 0);
23552 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23555 print (vam->ofp, "%s not found...", node_to_find);
23558 node = vam->graph_nodes[0][p[0]];
23559 print (vam->ofp, "[%d] %s", p[0], node->name);
23560 for (j = 0; j < vec_len (node->next_nodes); j++)
23562 if (node->next_nodes[j] != ~0)
23564 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23565 print (vam->ofp, " [%d] %s", j, next_node->name);
23572 clib_warning ("parse error '%U'", format_unformat_error,
23578 vec_free (node_to_find);
23587 script (vat_main_t * vam)
23589 #if (VPP_API_TEST_BUILTIN==0)
23591 char *save_current_file;
23592 unformat_input_t save_input;
23593 jmp_buf save_jump_buf;
23594 u32 save_line_number;
23596 FILE *new_fp, *save_ifp;
23598 if (unformat (vam->input, "%s", &s))
23600 new_fp = fopen ((char *) s, "r");
23603 errmsg ("Couldn't open script file %s", s);
23610 errmsg ("Missing script name");
23614 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23615 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23616 save_ifp = vam->ifp;
23617 save_line_number = vam->input_line_number;
23618 save_current_file = (char *) vam->current_file;
23620 vam->input_line_number = 0;
23622 vam->current_file = s;
23625 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23626 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23627 vam->ifp = save_ifp;
23628 vam->input_line_number = save_line_number;
23629 vam->current_file = (u8 *) save_current_file;
23634 clib_warning ("use the exec command...");
23640 echo (vat_main_t * vam)
23642 print (vam->ofp, "%v", vam->input->buffer);
23646 /* List of API message constructors, CLI names map to api_xxx */
23647 #define foreach_vpe_api_msg \
23648 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23649 _(sw_interface_dump,"") \
23650 _(sw_interface_set_flags, \
23651 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23652 _(sw_interface_add_del_address, \
23653 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23654 _(sw_interface_set_rx_mode, \
23655 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23656 _(sw_interface_set_rx_placement, \
23657 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
23658 _(sw_interface_rx_placement_dump, \
23659 "[<intfc> | sw_if_index <id>]") \
23660 _(sw_interface_set_table, \
23661 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23662 _(sw_interface_set_mpls_enable, \
23663 "<intfc> | sw_if_index [disable | dis]") \
23664 _(sw_interface_set_vpath, \
23665 "<intfc> | sw_if_index <id> enable | disable") \
23666 _(sw_interface_set_vxlan_bypass, \
23667 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23668 _(sw_interface_set_geneve_bypass, \
23669 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23670 _(sw_interface_set_l2_xconnect, \
23671 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23672 "enable | disable") \
23673 _(sw_interface_set_l2_bridge, \
23674 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23675 "[shg <split-horizon-group>] [bvi]\n" \
23676 "enable | disable") \
23677 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23678 _(bridge_domain_add_del, \
23679 "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") \
23680 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23682 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23683 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23684 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23686 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23688 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23690 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23692 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23694 "<vpp-if-name> | sw_if_index <id>") \
23695 _(sw_interface_tap_dump, "") \
23697 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23699 "<vpp-if-name> | sw_if_index <id>") \
23700 _(sw_interface_tap_v2_dump, "") \
23702 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23703 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23705 "<vpp-if-name> | sw_if_index <id>") \
23707 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23708 _(bond_detach_slave, \
23709 "sw_if_index <n>") \
23710 _(sw_interface_bond_dump, "") \
23711 _(sw_interface_slave_dump, \
23712 "<vpp-if-name> | sw_if_index <id>") \
23713 _(ip_table_add_del, \
23714 "table <n> [ipv6] [add | del]\n") \
23715 _(ip_add_del_route, \
23716 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
23717 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
23718 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
23719 "[multipath] [count <n>] [del]") \
23720 _(ip_mroute_add_del, \
23721 "<src> <grp>/<mask> [table-id <n>]\n" \
23722 "[<intfc> | sw_if_index <id>] [local] [del]") \
23723 _(mpls_table_add_del, \
23724 "table <n> [add | del]\n") \
23725 _(mpls_route_add_del, \
23726 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
23727 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
23728 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
23729 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
23730 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
23731 "[count <n>] [del]") \
23732 _(mpls_ip_bind_unbind, \
23733 "<label> <addr/len>") \
23734 _(mpls_tunnel_add_del, \
23735 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
23736 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
23737 "[l2-only] [out-label <n>]") \
23738 _(sr_mpls_policy_add, \
23739 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
23740 _(sr_mpls_policy_del, \
23742 _(bier_table_add_del, \
23743 "<label> <sub-domain> <set> <bsl> [del]") \
23744 _(bier_route_add_del, \
23745 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23746 "[<intfc> | sw_if_index <id>]" \
23747 "[weight <n>] [del] [multipath]") \
23748 _(proxy_arp_add_del, \
23749 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23750 _(proxy_arp_intfc_enable_disable, \
23751 "<intfc> | sw_if_index <id> enable | disable") \
23752 _(sw_interface_set_unnumbered, \
23753 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23754 _(ip_neighbor_add_del, \
23755 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23756 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23757 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23758 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23759 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23760 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23761 "[outer_vlan_id_any][inner_vlan_id_any]") \
23762 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23763 _(reset_fib, "vrf <n> [ipv6]") \
23764 _(dhcp_proxy_config, \
23765 "svr <v46-address> src <v46-address>\n" \
23766 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23767 _(dhcp_proxy_set_vss, \
23768 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23769 _(dhcp_proxy_dump, "ip6") \
23770 _(dhcp_client_config, \
23771 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23772 _(set_ip_flow_hash, \
23773 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23774 _(sw_interface_ip6_enable_disable, \
23775 "<intfc> | sw_if_index <id> enable | disable") \
23776 _(sw_interface_ip6_set_link_local_address, \
23777 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23778 _(ip6nd_proxy_add_del, \
23779 "<intfc> | sw_if_index <id> <ip6-address>") \
23780 _(ip6nd_proxy_dump, "") \
23781 _(sw_interface_ip6nd_ra_prefix, \
23782 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23783 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23784 "[nolink] [isno]") \
23785 _(sw_interface_ip6nd_ra_config, \
23786 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23787 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23788 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23789 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23790 _(l2_patch_add_del, \
23791 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23792 "enable | disable") \
23793 _(sr_localsid_add_del, \
23794 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23795 "fib-table <num> (end.psp) sw_if_index <num>") \
23796 _(classify_add_del_table, \
23797 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23798 " [del] [del-chain] mask <mask-value>\n" \
23799 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23800 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23801 _(classify_add_del_session, \
23802 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23803 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23804 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23805 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23806 _(classify_set_interface_ip_table, \
23807 "<intfc> | sw_if_index <nn> table <nn>") \
23808 _(classify_set_interface_l2_tables, \
23809 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23810 " [other-table <nn>]") \
23811 _(get_node_index, "node <node-name") \
23812 _(add_node_next, "node <node-name> next <next-node-name>") \
23813 _(l2tpv3_create_tunnel, \
23814 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23815 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23816 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23817 _(l2tpv3_set_tunnel_cookies, \
23818 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23819 "[new_remote_cookie <nn>]\n") \
23820 _(l2tpv3_interface_enable_disable, \
23821 "<intfc> | sw_if_index <nn> enable | disable") \
23822 _(l2tpv3_set_lookup_key, \
23823 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23824 _(sw_if_l2tpv3_tunnel_dump, "") \
23825 _(vxlan_offload_rx, \
23826 "hw { <interface name> | hw_if_index <nn>} " \
23827 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23828 _(vxlan_add_del_tunnel, \
23829 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23830 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23831 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23832 _(geneve_add_del_tunnel, \
23833 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23834 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23835 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23836 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23837 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23838 _(gre_add_del_tunnel, \
23839 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23840 "[teb | erspan <session-id>] [del]") \
23841 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23842 _(l2_fib_clear_table, "") \
23843 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23844 _(l2_interface_vlan_tag_rewrite, \
23845 "<intfc> | sw_if_index <nn> \n" \
23846 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23847 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23848 _(create_vhost_user_if, \
23849 "socket <filename> [server] [renumber <dev_instance>] " \
23850 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
23851 "[mac <mac_address>]") \
23852 _(modify_vhost_user_if, \
23853 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23854 "[server] [renumber <dev_instance>]") \
23855 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23856 _(sw_interface_vhost_user_dump, "") \
23857 _(show_version, "") \
23858 _(show_threads, "") \
23859 _(vxlan_gpe_add_del_tunnel, \
23860 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23861 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23862 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23863 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23864 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23865 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23866 _(interface_name_renumber, \
23867 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23868 _(input_acl_set_interface, \
23869 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23870 " [l2-table <nn>] [del]") \
23871 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23872 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23873 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23874 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23875 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23876 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23877 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23878 _(ip_dump, "ipv4 | ipv6") \
23879 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23880 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23882 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23883 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23884 " integ_alg <alg> integ_key <hex>") \
23885 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23886 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23887 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23888 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23889 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23890 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23891 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23892 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23893 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23894 " [instance <n>]") \
23895 _(ipsec_sa_dump, "[sa_id <n>]") \
23896 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23897 " <alg> <hex>\n") \
23898 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23899 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23900 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23901 "(auth_data 0x<data> | auth_data <data>)") \
23902 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23903 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23904 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23905 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23906 "(local|remote)") \
23907 _(ikev2_set_local_key, "file <absolute_file_path>") \
23908 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23909 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23910 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23911 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23912 _(ikev2_initiate_sa_init, "<profile_name>") \
23913 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23914 _(ikev2_initiate_del_child_sa, "<ispi>") \
23915 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23916 _(delete_loopback,"sw_if_index <nn>") \
23917 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23918 _(bd_ip_mac_dump, "[bd_id] <id>") \
23919 _(want_interface_events, "enable|disable") \
23920 _(want_stats,"enable|disable") \
23921 _(get_first_msg_id, "client <name>") \
23922 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23923 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23924 "fib-id <nn> [ip4][ip6][default]") \
23925 _(get_node_graph, " ") \
23926 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23927 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23928 _(ioam_disable, "") \
23929 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23930 " sw_if_index <sw_if_index> p <priority> " \
23931 "w <weight>] [del]") \
23932 _(one_add_del_locator, "locator-set <locator_name> " \
23933 "iface <intf> | sw_if_index <sw_if_index> " \
23934 "p <priority> w <weight> [del]") \
23935 _(one_add_del_local_eid,"vni <vni> eid " \
23936 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23937 "locator-set <locator_name> [del]" \
23938 "[key-id sha1|sha256 secret-key <secret-key>]")\
23939 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23940 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23941 _(one_enable_disable, "enable|disable") \
23942 _(one_map_register_enable_disable, "enable|disable") \
23943 _(one_map_register_fallback_threshold, "<value>") \
23944 _(one_rloc_probe_enable_disable, "enable|disable") \
23945 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23947 "rloc <locator> p <prio> " \
23948 "w <weight> [rloc <loc> ... ] " \
23949 "action <action> [del-all]") \
23950 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23952 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23953 _(one_use_petr, "ip-address> | disable") \
23954 _(one_map_request_mode, "src-dst|dst-only") \
23955 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23956 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23957 _(one_locator_set_dump, "[local | remote]") \
23958 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23959 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23960 "[local] | [remote]") \
23961 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23962 _(one_ndp_bd_get, "") \
23963 _(one_ndp_entries_get, "bd <bridge-domain>") \
23964 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23965 _(one_l2_arp_bd_get, "") \
23966 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23967 _(one_stats_enable_disable, "enable|disable") \
23968 _(show_one_stats_enable_disable, "") \
23969 _(one_eid_table_vni_dump, "") \
23970 _(one_eid_table_map_dump, "l2|l3") \
23971 _(one_map_resolver_dump, "") \
23972 _(one_map_server_dump, "") \
23973 _(one_adjacencies_get, "vni <vni>") \
23974 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23975 _(show_one_rloc_probe_state, "") \
23976 _(show_one_map_register_state, "") \
23977 _(show_one_status, "") \
23978 _(one_stats_dump, "") \
23979 _(one_stats_flush, "") \
23980 _(one_get_map_request_itr_rlocs, "") \
23981 _(one_map_register_set_ttl, "<ttl>") \
23982 _(one_set_transport_protocol, "udp|api") \
23983 _(one_get_transport_protocol, "") \
23984 _(one_enable_disable_xtr_mode, "enable|disable") \
23985 _(one_show_xtr_mode, "") \
23986 _(one_enable_disable_pitr_mode, "enable|disable") \
23987 _(one_show_pitr_mode, "") \
23988 _(one_enable_disable_petr_mode, "enable|disable") \
23989 _(one_show_petr_mode, "") \
23990 _(show_one_nsh_mapping, "") \
23991 _(show_one_pitr, "") \
23992 _(show_one_use_petr, "") \
23993 _(show_one_map_request_mode, "") \
23994 _(show_one_map_register_ttl, "") \
23995 _(show_one_map_register_fallback_threshold, "") \
23996 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23997 " sw_if_index <sw_if_index> p <priority> " \
23998 "w <weight>] [del]") \
23999 _(lisp_add_del_locator, "locator-set <locator_name> " \
24000 "iface <intf> | sw_if_index <sw_if_index> " \
24001 "p <priority> w <weight> [del]") \
24002 _(lisp_add_del_local_eid,"vni <vni> eid " \
24003 "<ipv4|ipv6>/<prefix> | <L2 address> " \
24004 "locator-set <locator_name> [del]" \
24005 "[key-id sha1|sha256 secret-key <secret-key>]") \
24006 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
24007 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
24008 _(lisp_enable_disable, "enable|disable") \
24009 _(lisp_map_register_enable_disable, "enable|disable") \
24010 _(lisp_rloc_probe_enable_disable, "enable|disable") \
24011 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
24013 "rloc <locator> p <prio> " \
24014 "w <weight> [rloc <loc> ... ] " \
24015 "action <action> [del-all]") \
24016 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
24018 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
24019 _(lisp_use_petr, "<ip-address> | disable") \
24020 _(lisp_map_request_mode, "src-dst|dst-only") \
24021 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
24022 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
24023 _(lisp_locator_set_dump, "[local | remote]") \
24024 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
24025 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
24026 "[local] | [remote]") \
24027 _(lisp_eid_table_vni_dump, "") \
24028 _(lisp_eid_table_map_dump, "l2|l3") \
24029 _(lisp_map_resolver_dump, "") \
24030 _(lisp_map_server_dump, "") \
24031 _(lisp_adjacencies_get, "vni <vni>") \
24032 _(gpe_fwd_entry_vnis_get, "") \
24033 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
24034 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
24035 "[table <table-id>]") \
24036 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
24037 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
24038 _(gpe_set_encap_mode, "lisp|vxlan") \
24039 _(gpe_get_encap_mode, "") \
24040 _(lisp_gpe_add_del_iface, "up|down") \
24041 _(lisp_gpe_enable_disable, "enable|disable") \
24042 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
24043 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
24044 _(show_lisp_rloc_probe_state, "") \
24045 _(show_lisp_map_register_state, "") \
24046 _(show_lisp_status, "") \
24047 _(lisp_get_map_request_itr_rlocs, "") \
24048 _(show_lisp_pitr, "") \
24049 _(show_lisp_use_petr, "") \
24050 _(show_lisp_map_request_mode, "") \
24051 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
24052 _(af_packet_delete, "name <host interface name>") \
24053 _(af_packet_dump, "") \
24054 _(policer_add_del, "name <policer name> <params> [del]") \
24055 _(policer_dump, "[name <policer name>]") \
24056 _(policer_classify_set_interface, \
24057 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24058 " [l2-table <nn>] [del]") \
24059 _(policer_classify_dump, "type [ip4|ip6|l2]") \
24060 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
24061 "[master|slave]") \
24062 _(netmap_delete, "name <interface name>") \
24063 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
24064 _(mpls_fib_dump, "") \
24065 _(classify_table_ids, "") \
24066 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
24067 _(classify_table_info, "table_id <nn>") \
24068 _(classify_session_dump, "table_id <nn>") \
24069 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
24070 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
24071 "[template_interval <nn>] [udp_checksum]") \
24072 _(ipfix_exporter_dump, "") \
24073 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
24074 _(ipfix_classify_stream_dump, "") \
24075 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
24076 _(ipfix_classify_table_dump, "") \
24077 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
24078 _(sw_interface_span_dump, "[l2]") \
24079 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
24080 _(pg_create_interface, "if_id <nn>") \
24081 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
24082 _(pg_enable_disable, "[stream <id>] disable") \
24083 _(ip_source_and_port_range_check_add_del, \
24084 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
24085 _(ip_source_and_port_range_check_interface_add_del, \
24086 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
24087 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
24088 _(ipsec_gre_add_del_tunnel, \
24089 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
24090 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
24091 _(delete_subif,"<intfc> | sw_if_index <nn>") \
24092 _(l2_interface_pbb_tag_rewrite, \
24093 "<intfc> | sw_if_index <nn> \n" \
24094 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
24095 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
24096 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
24097 _(flow_classify_set_interface, \
24098 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
24099 _(flow_classify_dump, "type [ip4|ip6]") \
24100 _(ip_fib_dump, "") \
24101 _(ip_mfib_dump, "") \
24102 _(ip6_fib_dump, "") \
24103 _(ip6_mfib_dump, "") \
24104 _(feature_enable_disable, "arc_name <arc_name> " \
24105 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
24106 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
24108 _(l2_xconnect_dump, "") \
24109 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
24110 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
24111 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
24112 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
24113 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
24114 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
24115 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
24116 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
24117 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
24118 _(sock_init_shm, "size <nnn>") \
24119 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
24120 _(dns_enable_disable, "[enable][disable]") \
24121 _(dns_name_server_add_del, "<ip-address> [del]") \
24122 _(dns_resolve_name, "<hostname>") \
24123 _(dns_resolve_ip, "<ip4|ip6>") \
24124 _(dns_name_server_add_del, "<ip-address> [del]") \
24125 _(dns_resolve_name, "<hostname>") \
24126 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
24127 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
24128 _(session_rules_dump, "") \
24129 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
24130 _(output_acl_set_interface, \
24131 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24132 " [l2-table <nn>] [del]") \
24133 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
24135 /* List of command functions, CLI names map directly to functions */
24136 #define foreach_cli_function \
24137 _(comment, "usage: comment <ignore-rest-of-line>") \
24138 _(dump_interface_table, "usage: dump_interface_table") \
24139 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
24140 _(dump_ipv4_table, "usage: dump_ipv4_table") \
24141 _(dump_ipv6_table, "usage: dump_ipv6_table") \
24142 _(dump_stats_table, "usage: dump_stats_table") \
24143 _(dump_macro_table, "usage: dump_macro_table ") \
24144 _(dump_node_table, "usage: dump_node_table") \
24145 _(dump_msg_api_table, "usage: dump_msg_api_table") \
24146 _(get_msg_id, "usage: get_msg_id name_and_crc") \
24147 _(echo, "usage: echo <message>") \
24148 _(exec, "usage: exec <vpe-debug-CLI-command>") \
24149 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
24150 _(help, "usage: help") \
24151 _(q, "usage: quit") \
24152 _(quit, "usage: quit") \
24153 _(search_node_table, "usage: search_node_table <name>...") \
24154 _(set, "usage: set <variable-name> <value>") \
24155 _(script, "usage: script <file-name>") \
24156 _(statseg, "usage: statseg"); \
24157 _(unset, "usage: unset <variable-name>")
24160 static void vl_api_##n##_t_handler_uni \
24161 (vl_api_##n##_t * mp) \
24163 vat_main_t * vam = &vat_main; \
24164 if (vam->json_output) { \
24165 vl_api_##n##_t_handler_json(mp); \
24167 vl_api_##n##_t_handler(mp); \
24170 foreach_vpe_api_reply_msg;
24171 #if VPP_API_TEST_BUILTIN == 0
24172 foreach_standalone_reply_msg;
24177 vat_api_hookup (vat_main_t * vam)
24180 vl_msg_api_set_handlers(VL_API_##N, #n, \
24181 vl_api_##n##_t_handler_uni, \
24183 vl_api_##n##_t_endian, \
24184 vl_api_##n##_t_print, \
24185 sizeof(vl_api_##n##_t), 1);
24186 foreach_vpe_api_reply_msg;
24187 #if VPP_API_TEST_BUILTIN == 0
24188 foreach_standalone_reply_msg;
24192 #if (VPP_API_TEST_BUILTIN==0)
24193 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
24195 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
24197 vam->function_by_name = hash_create_string (0, sizeof (uword));
24199 vam->help_by_name = hash_create_string (0, sizeof (uword));
24202 /* API messages we can send */
24203 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
24204 foreach_vpe_api_msg;
24208 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24209 foreach_vpe_api_msg;
24212 /* CLI functions */
24213 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
24214 foreach_cli_function;
24218 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24219 foreach_cli_function;
24223 #if VPP_API_TEST_BUILTIN
24224 static clib_error_t *
24225 vat_api_hookup_shim (vlib_main_t * vm)
24227 vat_api_hookup (&vat_main);
24231 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
24235 * fd.io coding-style-patch-verification: ON
24238 * eval: (c-set-style "gnu")