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 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7830 vl_api_mac_address_t mac = VL_API_ZERO_MAC_ADDRESS;
7831 unformat_input_t *i = vam->input;
7832 vl_api_bd_ip_mac_add_del_t *mp;
7844 /* Parse args required to build the message */
7845 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7847 if (unformat (i, "bd_id %d", &bd_id))
7851 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7855 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7859 else if (unformat (i, "del"))
7867 errmsg ("missing bridge domain");
7870 else if (ip_set == 0)
7872 errmsg ("missing IP address");
7875 else if (mac_set == 0)
7877 errmsg ("missing MAC address");
7881 M (BD_IP_MAC_ADD_DEL, mp);
7883 mp->bd_id = ntohl (bd_id);
7884 mp->is_add = is_add;
7886 clib_memcpy (&mp->ip, &ip, sizeof (ip));
7887 clib_memcpy (&mp->mac, &mac, sizeof (mac));
7894 static void vl_api_bd_ip_mac_details_t_handler
7895 (vl_api_bd_ip_mac_details_t * mp)
7897 vat_main_t *vam = &vat_main;
7902 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7905 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7908 "\n%-5d %-7s %-20U %-30s",
7909 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7910 format_ethernet_address, mp->mac_address, ip);
7915 static void vl_api_bd_ip_mac_details_t_handler_json
7916 (vl_api_bd_ip_mac_details_t * mp)
7918 vat_main_t *vam = &vat_main;
7919 vat_json_node_t *node = NULL;
7921 if (VAT_JSON_ARRAY != vam->json_tree.type)
7923 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7924 vat_json_init_array (&vam->json_tree);
7926 node = vat_json_array_add (&vam->json_tree);
7928 vat_json_init_object (node);
7929 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7930 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7931 vat_json_object_add_string_copy (node, "mac_address",
7932 format (0, "%U", format_ethernet_address,
7938 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7941 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7942 vat_json_object_add_string_copy (node, "ip_address", ip);
7947 api_bd_ip_mac_dump (vat_main_t * vam)
7949 unformat_input_t *i = vam->input;
7950 vl_api_bd_ip_mac_dump_t *mp;
7951 vl_api_control_ping_t *mp_ping;
7956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7958 if (unformat (i, "bd_id %d", &bd_id))
7967 "\n%-5s %-7s %-20s %-30s",
7968 "bd_id", "is_ipv6", "mac_address", "ip_address");
7970 /* Dump Bridge Domain Ip to Mac entries */
7971 M (BD_IP_MAC_DUMP, mp);
7974 mp->bd_id = htonl (bd_id);
7980 /* Use a control ping for synchronization */
7981 MPING (CONTROL_PING, mp_ping);
7989 api_tap_connect (vat_main_t * vam)
7991 unformat_input_t *i = vam->input;
7992 vl_api_tap_connect_t *mp;
7998 ip4_address_t ip4_address;
8000 int ip4_address_set = 0;
8001 ip6_address_t ip6_address;
8003 int ip6_address_set = 0;
8006 clib_memset (mac_address, 0, sizeof (mac_address));
8008 /* Parse args required to build the message */
8009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8011 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8015 else if (unformat (i, "random-mac"))
8017 else if (unformat (i, "tapname %s", &tap_name))
8019 else if (unformat (i, "tag %s", &tag))
8021 else if (unformat (i, "address %U/%d",
8022 unformat_ip4_address, &ip4_address, &ip4_mask_width))
8023 ip4_address_set = 1;
8024 else if (unformat (i, "address %U/%d",
8025 unformat_ip6_address, &ip6_address, &ip6_mask_width))
8026 ip6_address_set = 1;
8033 errmsg ("missing tap name");
8036 if (vec_len (tap_name) > 63)
8038 errmsg ("tap name too long");
8041 vec_add1 (tap_name, 0);
8043 if (vec_len (tag) > 63)
8045 errmsg ("tag too long");
8049 /* Construct the API message */
8050 M (TAP_CONNECT, mp);
8052 mp->use_random_mac = random_mac;
8053 clib_memcpy (mp->mac_address, mac_address, 6);
8054 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8056 clib_memcpy (mp->tag, tag, vec_len (tag));
8058 if (ip4_address_set)
8060 mp->ip4_address_set = 1;
8061 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
8062 mp->ip4_mask_width = ip4_mask_width;
8064 if (ip6_address_set)
8066 mp->ip6_address_set = 1;
8067 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
8068 mp->ip6_mask_width = ip6_mask_width;
8071 vec_free (tap_name);
8077 /* Wait for a reply... */
8083 api_tap_modify (vat_main_t * vam)
8085 unformat_input_t *i = vam->input;
8086 vl_api_tap_modify_t *mp;
8091 u32 sw_if_index = ~0;
8092 u8 sw_if_index_set = 0;
8095 clib_memset (mac_address, 0, sizeof (mac_address));
8097 /* Parse args required to build the message */
8098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8100 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8101 sw_if_index_set = 1;
8102 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8103 sw_if_index_set = 1;
8104 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8108 else if (unformat (i, "random-mac"))
8110 else if (unformat (i, "tapname %s", &tap_name))
8116 if (sw_if_index_set == 0)
8118 errmsg ("missing vpp interface name");
8123 errmsg ("missing tap name");
8126 if (vec_len (tap_name) > 63)
8128 errmsg ("tap name too long");
8130 vec_add1 (tap_name, 0);
8132 /* Construct the API message */
8135 mp->use_random_mac = random_mac;
8136 mp->sw_if_index = ntohl (sw_if_index);
8137 clib_memcpy (mp->mac_address, mac_address, 6);
8138 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8139 vec_free (tap_name);
8144 /* Wait for a reply... */
8150 api_tap_delete (vat_main_t * vam)
8152 unformat_input_t *i = vam->input;
8153 vl_api_tap_delete_t *mp;
8154 u32 sw_if_index = ~0;
8155 u8 sw_if_index_set = 0;
8158 /* Parse args required to build the message */
8159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8161 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8162 sw_if_index_set = 1;
8163 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8164 sw_if_index_set = 1;
8169 if (sw_if_index_set == 0)
8171 errmsg ("missing vpp interface name");
8175 /* Construct the API message */
8178 mp->sw_if_index = ntohl (sw_if_index);
8183 /* Wait for a reply... */
8189 api_tap_create_v2 (vat_main_t * vam)
8191 unformat_input_t *i = vam->input;
8192 vl_api_tap_create_v2_t *mp;
8196 u8 *host_if_name = 0;
8198 u8 host_mac_addr[6];
8199 u8 host_mac_addr_set = 0;
8200 u8 *host_bridge = 0;
8201 ip4_address_t host_ip4_addr;
8202 ip4_address_t host_ip4_gw;
8203 u8 host_ip4_gw_set = 0;
8204 u32 host_ip4_prefix_len = 0;
8205 ip6_address_t host_ip6_addr;
8206 ip6_address_t host_ip6_gw;
8207 u8 host_ip6_gw_set = 0;
8208 u32 host_ip6_prefix_len = 0;
8210 u32 rx_ring_sz = 0, tx_ring_sz = 0;
8212 clib_memset (mac_address, 0, sizeof (mac_address));
8214 /* Parse args required to build the message */
8215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8217 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8221 else if (unformat (i, "id %u", &id))
8223 else if (unformat (i, "host-if-name %s", &host_if_name))
8225 else if (unformat (i, "host-ns %s", &host_ns))
8227 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8229 host_mac_addr_set = 1;
8230 else if (unformat (i, "host-bridge %s", &host_bridge))
8232 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8233 &host_ip4_addr, &host_ip4_prefix_len))
8235 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8236 &host_ip6_addr, &host_ip6_prefix_len))
8238 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8240 host_ip4_gw_set = 1;
8241 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8243 host_ip6_gw_set = 1;
8244 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8246 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8252 if (vec_len (host_if_name) > 63)
8254 errmsg ("tap name too long. ");
8257 if (vec_len (host_ns) > 63)
8259 errmsg ("host name space too long. ");
8262 if (vec_len (host_bridge) > 63)
8264 errmsg ("host bridge name too long. ");
8267 if (host_ip4_prefix_len > 32)
8269 errmsg ("host ip4 prefix length not valid. ");
8272 if (host_ip6_prefix_len > 128)
8274 errmsg ("host ip6 prefix length not valid. ");
8277 if (!is_pow2 (rx_ring_sz))
8279 errmsg ("rx ring size must be power of 2. ");
8282 if (rx_ring_sz > 32768)
8284 errmsg ("rx ring size must be 32768 or lower. ");
8287 if (!is_pow2 (tx_ring_sz))
8289 errmsg ("tx ring size must be power of 2. ");
8292 if (tx_ring_sz > 32768)
8294 errmsg ("tx ring size must be 32768 or lower. ");
8298 /* Construct the API message */
8299 M (TAP_CREATE_V2, mp);
8301 mp->use_random_mac = random_mac;
8303 mp->id = ntohl (id);
8304 mp->host_namespace_set = host_ns != 0;
8305 mp->host_bridge_set = host_bridge != 0;
8306 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8307 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8308 mp->rx_ring_sz = ntohs (rx_ring_sz);
8309 mp->tx_ring_sz = ntohs (tx_ring_sz);
8311 if (random_mac == 0)
8312 clib_memcpy (mp->mac_address, mac_address, 6);
8313 if (host_mac_addr_set)
8314 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8316 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8318 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8320 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8321 if (host_ip4_prefix_len)
8322 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8323 if (host_ip6_prefix_len)
8324 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8325 if (host_ip4_gw_set)
8326 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8327 if (host_ip6_gw_set)
8328 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8331 vec_free (host_if_name);
8332 vec_free (host_bridge);
8337 /* Wait for a reply... */
8343 api_tap_delete_v2 (vat_main_t * vam)
8345 unformat_input_t *i = vam->input;
8346 vl_api_tap_delete_v2_t *mp;
8347 u32 sw_if_index = ~0;
8348 u8 sw_if_index_set = 0;
8351 /* Parse args required to build the message */
8352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8354 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8355 sw_if_index_set = 1;
8356 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8357 sw_if_index_set = 1;
8362 if (sw_if_index_set == 0)
8364 errmsg ("missing vpp interface name. ");
8368 /* Construct the API message */
8369 M (TAP_DELETE_V2, mp);
8371 mp->sw_if_index = ntohl (sw_if_index);
8376 /* Wait for a reply... */
8382 api_bond_create (vat_main_t * vam)
8384 unformat_input_t *i = vam->input;
8385 vl_api_bond_create_t *mp;
8393 clib_memset (mac_address, 0, sizeof (mac_address));
8396 /* Parse args required to build the message */
8397 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8399 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8401 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8402 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8404 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8411 if (mode_is_set == 0)
8413 errmsg ("Missing bond mode. ");
8417 /* Construct the API message */
8418 M (BOND_CREATE, mp);
8420 mp->use_custom_mac = custom_mac;
8426 clib_memcpy (mp->mac_address, mac_address, 6);
8431 /* Wait for a reply... */
8437 api_bond_delete (vat_main_t * vam)
8439 unformat_input_t *i = vam->input;
8440 vl_api_bond_delete_t *mp;
8441 u32 sw_if_index = ~0;
8442 u8 sw_if_index_set = 0;
8445 /* Parse args required to build the message */
8446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8448 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8449 sw_if_index_set = 1;
8450 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8451 sw_if_index_set = 1;
8456 if (sw_if_index_set == 0)
8458 errmsg ("missing vpp interface name. ");
8462 /* Construct the API message */
8463 M (BOND_DELETE, mp);
8465 mp->sw_if_index = ntohl (sw_if_index);
8470 /* Wait for a reply... */
8476 api_bond_enslave (vat_main_t * vam)
8478 unformat_input_t *i = vam->input;
8479 vl_api_bond_enslave_t *mp;
8480 u32 bond_sw_if_index;
8484 u32 bond_sw_if_index_is_set = 0;
8486 u8 sw_if_index_is_set = 0;
8488 /* Parse args required to build the message */
8489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8491 if (unformat (i, "sw_if_index %d", &sw_if_index))
8492 sw_if_index_is_set = 1;
8493 else if (unformat (i, "bond %u", &bond_sw_if_index))
8494 bond_sw_if_index_is_set = 1;
8495 else if (unformat (i, "passive %d", &is_passive))
8497 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8503 if (bond_sw_if_index_is_set == 0)
8505 errmsg ("Missing bond sw_if_index. ");
8508 if (sw_if_index_is_set == 0)
8510 errmsg ("Missing slave sw_if_index. ");
8514 /* Construct the API message */
8515 M (BOND_ENSLAVE, mp);
8517 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8518 mp->sw_if_index = ntohl (sw_if_index);
8519 mp->is_long_timeout = is_long_timeout;
8520 mp->is_passive = is_passive;
8525 /* Wait for a reply... */
8531 api_bond_detach_slave (vat_main_t * vam)
8533 unformat_input_t *i = vam->input;
8534 vl_api_bond_detach_slave_t *mp;
8535 u32 sw_if_index = ~0;
8536 u8 sw_if_index_set = 0;
8539 /* Parse args required to build the message */
8540 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8542 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8543 sw_if_index_set = 1;
8544 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8545 sw_if_index_set = 1;
8550 if (sw_if_index_set == 0)
8552 errmsg ("missing vpp interface name. ");
8556 /* Construct the API message */
8557 M (BOND_DETACH_SLAVE, mp);
8559 mp->sw_if_index = ntohl (sw_if_index);
8564 /* Wait for a reply... */
8570 api_ip_table_add_del (vat_main_t * vam)
8572 unformat_input_t *i = vam->input;
8573 vl_api_ip_table_add_del_t *mp;
8579 /* Parse args required to build the message */
8580 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8582 if (unformat (i, "ipv6"))
8584 else if (unformat (i, "del"))
8586 else if (unformat (i, "add"))
8588 else if (unformat (i, "table %d", &table_id))
8592 clib_warning ("parse error '%U'", format_unformat_error, i);
8599 errmsg ("missing table-ID");
8603 /* Construct the API message */
8604 M (IP_TABLE_ADD_DEL, mp);
8606 mp->table_id = ntohl (table_id);
8607 mp->is_ipv6 = is_ipv6;
8608 mp->is_add = is_add;
8613 /* Wait for a reply... */
8620 api_ip_add_del_route (vat_main_t * vam)
8622 unformat_input_t *i = vam->input;
8623 vl_api_ip_add_del_route_t *mp;
8624 u32 sw_if_index = ~0, vrf_id = 0;
8626 u8 is_local = 0, is_drop = 0;
8627 u8 is_unreach = 0, is_prohibit = 0;
8629 u32 next_hop_weight = 1;
8630 u8 is_multipath = 0;
8632 u8 address_length_set = 0;
8633 u32 next_hop_table_id = 0;
8634 u32 resolve_attempts = 0;
8635 u32 dst_address_length = 0;
8636 u8 next_hop_set = 0;
8637 ip4_address_t v4_dst_address, v4_next_hop_address;
8638 ip6_address_t v6_dst_address, v6_next_hop_address;
8642 u32 random_add_del = 0;
8643 u32 *random_vector = 0;
8645 u32 random_seed = 0xdeaddabe;
8646 u32 classify_table_index = ~0;
8648 u8 resolve_host = 0, resolve_attached = 0;
8649 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8650 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8651 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8653 clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8654 clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8655 /* Parse args required to build the message */
8656 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8658 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8660 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8662 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8667 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8672 else if (unformat (i, "/%d", &dst_address_length))
8674 address_length_set = 1;
8677 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8678 &v4_next_hop_address))
8682 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8683 &v6_next_hop_address))
8689 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8693 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8697 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8699 else if (unformat (i, "weight %d", &next_hop_weight))
8701 else if (unformat (i, "drop"))
8705 else if (unformat (i, "null-send-unreach"))
8709 else if (unformat (i, "null-send-prohibit"))
8713 else if (unformat (i, "local"))
8717 else if (unformat (i, "classify %d", &classify_table_index))
8721 else if (unformat (i, "del"))
8723 else if (unformat (i, "add"))
8725 else if (unformat (i, "resolve-via-host"))
8727 else if (unformat (i, "resolve-via-attached"))
8728 resolve_attached = 1;
8729 else if (unformat (i, "multipath"))
8731 else if (unformat (i, "vrf %d", &vrf_id))
8733 else if (unformat (i, "count %d", &count))
8735 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8737 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8739 else if (unformat (i, "out-label %d", &next_hop_out_label))
8741 vl_api_fib_mpls_label_t fib_label = {
8742 .label = ntohl (next_hop_out_label),
8746 vec_add1 (next_hop_out_label_stack, fib_label);
8748 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8750 else if (unformat (i, "random"))
8752 else if (unformat (i, "seed %d", &random_seed))
8756 clib_warning ("parse error '%U'", format_unformat_error, i);
8761 if (!next_hop_set && !is_drop && !is_local &&
8762 !is_classify && !is_unreach && !is_prohibit &&
8763 MPLS_LABEL_INVALID == next_hop_via_label)
8766 ("next hop / local / drop / unreach / prohibit / classify not set");
8770 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8772 errmsg ("next hop and next-hop via label set");
8775 if (address_set == 0)
8777 errmsg ("missing addresses");
8781 if (address_length_set == 0)
8783 errmsg ("missing address length");
8787 /* Generate a pile of unique, random routes */
8790 u32 this_random_address;
8791 random_hash = hash_create (count, sizeof (uword));
8793 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8794 for (j = 0; j <= count; j++)
8798 this_random_address = random_u32 (&random_seed);
8799 this_random_address =
8800 clib_host_to_net_u32 (this_random_address);
8802 while (hash_get (random_hash, this_random_address));
8803 vec_add1 (random_vector, this_random_address);
8804 hash_set (random_hash, this_random_address, 1);
8806 hash_free (random_hash);
8807 v4_dst_address.as_u32 = random_vector[0];
8812 /* Turn on async mode */
8813 vam->async_mode = 1;
8814 vam->async_errors = 0;
8815 before = vat_time_now (vam);
8818 for (j = 0; j < count; j++)
8820 /* Construct the API message */
8821 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8822 vec_len (next_hop_out_label_stack));
8824 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8825 mp->table_id = ntohl (vrf_id);
8827 mp->is_add = is_add;
8828 mp->is_drop = is_drop;
8829 mp->is_unreach = is_unreach;
8830 mp->is_prohibit = is_prohibit;
8831 mp->is_ipv6 = is_ipv6;
8832 mp->is_local = is_local;
8833 mp->is_classify = is_classify;
8834 mp->is_multipath = is_multipath;
8835 mp->is_resolve_host = resolve_host;
8836 mp->is_resolve_attached = resolve_attached;
8837 mp->next_hop_weight = next_hop_weight;
8838 mp->next_hop_preference = 0;
8839 mp->dst_address_length = dst_address_length;
8840 mp->next_hop_table_id = ntohl (next_hop_table_id);
8841 mp->classify_table_index = ntohl (classify_table_index);
8842 mp->next_hop_via_label = ntohl (next_hop_via_label);
8843 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8844 if (0 != mp->next_hop_n_out_labels)
8846 memcpy (mp->next_hop_out_label_stack,
8847 next_hop_out_label_stack,
8848 (vec_len (next_hop_out_label_stack) *
8849 sizeof (vl_api_fib_mpls_label_t)));
8850 vec_free (next_hop_out_label_stack);
8855 clib_memcpy (mp->dst_address, &v6_dst_address,
8856 sizeof (v6_dst_address));
8858 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8859 sizeof (v6_next_hop_address));
8860 increment_v6_address (&v6_dst_address);
8864 clib_memcpy (mp->dst_address, &v4_dst_address,
8865 sizeof (v4_dst_address));
8867 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8868 sizeof (v4_next_hop_address));
8870 v4_dst_address.as_u32 = random_vector[j + 1];
8872 increment_v4_address (&v4_dst_address);
8876 /* If we receive SIGTERM, stop now... */
8881 /* When testing multiple add/del ops, use a control-ping to sync */
8884 vl_api_control_ping_t *mp_ping;
8888 /* Shut off async mode */
8889 vam->async_mode = 0;
8891 MPING (CONTROL_PING, mp_ping);
8894 timeout = vat_time_now (vam) + 1.0;
8895 while (vat_time_now (vam) < timeout)
8896 if (vam->result_ready == 1)
8901 if (vam->retval == -99)
8904 if (vam->async_errors > 0)
8906 errmsg ("%d asynchronous errors", vam->async_errors);
8909 vam->async_errors = 0;
8910 after = vat_time_now (vam);
8912 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8916 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8917 count, after - before, count / (after - before));
8923 /* Wait for a reply... */
8928 /* Return the good/bad news */
8929 return (vam->retval);
8933 api_ip_mroute_add_del (vat_main_t * vam)
8935 unformat_input_t *i = vam->input;
8936 vl_api_ip_mroute_add_del_t *mp;
8937 u32 sw_if_index = ~0, vrf_id = 0;
8942 u32 grp_address_length = 0;
8943 ip4_address_t v4_grp_address, v4_src_address;
8944 ip6_address_t v6_grp_address, v6_src_address;
8945 mfib_itf_flags_t iflags = 0;
8946 mfib_entry_flags_t eflags = 0;
8949 /* Parse args required to build the message */
8950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8952 if (unformat (i, "sw_if_index %d", &sw_if_index))
8954 else if (unformat (i, "%U %U",
8955 unformat_ip4_address, &v4_src_address,
8956 unformat_ip4_address, &v4_grp_address))
8958 grp_address_length = 64;
8962 else if (unformat (i, "%U %U",
8963 unformat_ip6_address, &v6_src_address,
8964 unformat_ip6_address, &v6_grp_address))
8966 grp_address_length = 256;
8970 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8972 clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
8973 grp_address_length = 32;
8977 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8979 clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
8980 grp_address_length = 128;
8984 else if (unformat (i, "/%d", &grp_address_length))
8986 else if (unformat (i, "local"))
8990 else if (unformat (i, "del"))
8992 else if (unformat (i, "add"))
8994 else if (unformat (i, "vrf %d", &vrf_id))
8996 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8998 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
9002 clib_warning ("parse error '%U'", format_unformat_error, i);
9007 if (address_set == 0)
9009 errmsg ("missing addresses\n");
9013 /* Construct the API message */
9014 M (IP_MROUTE_ADD_DEL, mp);
9016 mp->next_hop_sw_if_index = ntohl (sw_if_index);
9017 mp->table_id = ntohl (vrf_id);
9019 mp->is_add = is_add;
9020 mp->is_ipv6 = is_ipv6;
9021 mp->is_local = is_local;
9022 mp->itf_flags = ntohl (iflags);
9023 mp->entry_flags = ntohl (eflags);
9024 mp->grp_address_length = grp_address_length;
9025 mp->grp_address_length = ntohs (mp->grp_address_length);
9029 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
9030 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
9034 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
9035 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
9041 /* Wait for a reply... */
9047 api_mpls_table_add_del (vat_main_t * vam)
9049 unformat_input_t *i = vam->input;
9050 vl_api_mpls_table_add_del_t *mp;
9055 /* Parse args required to build the message */
9056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9058 if (unformat (i, "table %d", &table_id))
9060 else if (unformat (i, "del"))
9062 else if (unformat (i, "add"))
9066 clib_warning ("parse error '%U'", format_unformat_error, i);
9073 errmsg ("missing table-ID");
9077 /* Construct the API message */
9078 M (MPLS_TABLE_ADD_DEL, mp);
9080 mp->mt_table_id = ntohl (table_id);
9081 mp->mt_is_add = is_add;
9086 /* Wait for a reply... */
9093 api_mpls_route_add_del (vat_main_t * vam)
9095 unformat_input_t *i = vam->input;
9096 vl_api_mpls_route_add_del_t *mp;
9097 u32 sw_if_index = ~0, table_id = 0;
9099 u32 next_hop_weight = 1;
9100 u8 is_multipath = 0;
9101 u32 next_hop_table_id = 0;
9102 u8 next_hop_set = 0;
9103 ip4_address_t v4_next_hop_address = {
9106 ip6_address_t v6_next_hop_address = { {0} };
9110 u32 classify_table_index = ~0;
9112 u8 resolve_host = 0, resolve_attached = 0;
9113 u8 is_interface_rx = 0;
9114 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9115 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9116 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9117 mpls_label_t local_label = MPLS_LABEL_INVALID;
9119 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
9121 /* Parse args required to build the message */
9122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9124 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9126 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9128 else if (unformat (i, "%d", &local_label))
9130 else if (unformat (i, "eos"))
9132 else if (unformat (i, "non-eos"))
9134 else if (unformat (i, "via %U", unformat_ip4_address,
9135 &v4_next_hop_address))
9138 next_hop_proto = DPO_PROTO_IP4;
9140 else if (unformat (i, "via %U", unformat_ip6_address,
9141 &v6_next_hop_address))
9144 next_hop_proto = DPO_PROTO_IP6;
9146 else if (unformat (i, "weight %d", &next_hop_weight))
9148 else if (unformat (i, "classify %d", &classify_table_index))
9152 else if (unformat (i, "del"))
9154 else if (unformat (i, "add"))
9156 else if (unformat (i, "resolve-via-host"))
9158 else if (unformat (i, "resolve-via-attached"))
9159 resolve_attached = 1;
9160 else if (unformat (i, "multipath"))
9162 else if (unformat (i, "count %d", &count))
9164 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
9167 next_hop_proto = DPO_PROTO_IP4;
9169 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
9172 next_hop_proto = DPO_PROTO_IP6;
9176 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
9180 next_hop_proto = DPO_PROTO_ETHERNET;
9181 is_interface_rx = 1;
9183 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
9186 next_hop_proto = DPO_PROTO_ETHERNET;
9187 is_interface_rx = 1;
9189 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
9191 else if (unformat (i, "via via-label %d", &next_hop_via_label))
9193 else if (unformat (i, "out-label %d", &next_hop_out_label))
9195 vl_api_fib_mpls_label_t fib_label = {
9196 .label = ntohl (next_hop_out_label),
9200 vec_add1 (next_hop_out_label_stack, fib_label);
9204 clib_warning ("parse error '%U'", format_unformat_error, i);
9209 if (!next_hop_set && !is_classify)
9211 errmsg ("next hop / classify not set");
9215 if (MPLS_LABEL_INVALID == local_label)
9217 errmsg ("missing label");
9223 /* Turn on async mode */
9224 vam->async_mode = 1;
9225 vam->async_errors = 0;
9226 before = vat_time_now (vam);
9229 for (j = 0; j < count; j++)
9231 /* Construct the API message */
9232 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9233 vec_len (next_hop_out_label_stack));
9235 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
9236 mp->mr_table_id = ntohl (table_id);
9238 mp->mr_is_add = is_add;
9239 mp->mr_next_hop_proto = next_hop_proto;
9240 mp->mr_is_classify = is_classify;
9241 mp->mr_is_multipath = is_multipath;
9242 mp->mr_is_resolve_host = resolve_host;
9243 mp->mr_is_resolve_attached = resolve_attached;
9244 mp->mr_is_interface_rx = is_interface_rx;
9245 mp->mr_next_hop_weight = next_hop_weight;
9246 mp->mr_next_hop_preference = 0;
9247 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
9248 mp->mr_classify_table_index = ntohl (classify_table_index);
9249 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
9250 mp->mr_label = ntohl (local_label);
9251 mp->mr_eos = is_eos;
9253 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9254 if (0 != mp->mr_next_hop_n_out_labels)
9256 memcpy (mp->mr_next_hop_out_label_stack,
9257 next_hop_out_label_stack,
9258 vec_len (next_hop_out_label_stack) *
9259 sizeof (vl_api_fib_mpls_label_t));
9260 vec_free (next_hop_out_label_stack);
9265 if (DPO_PROTO_IP4 == next_hop_proto)
9267 clib_memcpy (mp->mr_next_hop,
9268 &v4_next_hop_address,
9269 sizeof (v4_next_hop_address));
9271 else if (DPO_PROTO_IP6 == next_hop_proto)
9274 clib_memcpy (mp->mr_next_hop,
9275 &v6_next_hop_address,
9276 sizeof (v6_next_hop_address));
9283 /* If we receive SIGTERM, stop now... */
9288 /* When testing multiple add/del ops, use a control-ping to sync */
9291 vl_api_control_ping_t *mp_ping;
9295 /* Shut off async mode */
9296 vam->async_mode = 0;
9298 MPING (CONTROL_PING, mp_ping);
9301 timeout = vat_time_now (vam) + 1.0;
9302 while (vat_time_now (vam) < timeout)
9303 if (vam->result_ready == 1)
9308 if (vam->retval == -99)
9311 if (vam->async_errors > 0)
9313 errmsg ("%d asynchronous errors", vam->async_errors);
9316 vam->async_errors = 0;
9317 after = vat_time_now (vam);
9319 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9323 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9324 count, after - before, count / (after - before));
9330 /* Wait for a reply... */
9335 /* Return the good/bad news */
9336 return (vam->retval);
9340 api_mpls_ip_bind_unbind (vat_main_t * vam)
9342 unformat_input_t *i = vam->input;
9343 vl_api_mpls_ip_bind_unbind_t *mp;
9344 u32 ip_table_id = 0;
9347 ip4_address_t v4_address;
9348 ip6_address_t v6_address;
9351 mpls_label_t local_label = MPLS_LABEL_INVALID;
9354 /* Parse args required to build the message */
9355 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9357 if (unformat (i, "%U/%d", unformat_ip4_address,
9358 &v4_address, &address_length))
9363 else if (unformat (i, "%U/%d", unformat_ip6_address,
9364 &v6_address, &address_length))
9369 else if (unformat (i, "%d", &local_label))
9371 else if (unformat (i, "table-id %d", &ip_table_id))
9373 else if (unformat (i, "unbind"))
9375 else if (unformat (i, "bind"))
9379 clib_warning ("parse error '%U'", format_unformat_error, i);
9386 errmsg ("IP address not set");
9390 if (MPLS_LABEL_INVALID == local_label)
9392 errmsg ("missing label");
9396 /* Construct the API message */
9397 M (MPLS_IP_BIND_UNBIND, mp);
9399 mp->mb_is_bind = is_bind;
9400 mp->mb_is_ip4 = is_ip4;
9401 mp->mb_ip_table_id = ntohl (ip_table_id);
9402 mp->mb_mpls_table_id = 0;
9403 mp->mb_label = ntohl (local_label);
9404 mp->mb_address_length = address_length;
9407 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9409 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9414 /* Wait for a reply... */
9420 api_sr_mpls_policy_add (vat_main_t * vam)
9422 unformat_input_t *i = vam->input;
9423 vl_api_sr_mpls_policy_add_t *mp;
9429 u32 *segments = NULL;
9432 /* Parse args required to build the message */
9433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9435 if (unformat (i, "bsid %d", &bsid))
9437 else if (unformat (i, "weight %d", &weight))
9439 else if (unformat (i, "spray"))
9441 else if (unformat (i, "next %d", &sid))
9444 vec_add1 (segments, htonl (sid));
9448 clib_warning ("parse error '%U'", format_unformat_error, i);
9455 errmsg ("bsid not set");
9459 if (n_segments == 0)
9461 errmsg ("no sid in segment stack");
9465 /* Construct the API message */
9466 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
9468 mp->bsid = htonl (bsid);
9469 mp->weight = htonl (weight);
9471 mp->n_segments = n_segments;
9472 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
9473 vec_free (segments);
9478 /* Wait for a reply... */
9484 api_sr_mpls_policy_del (vat_main_t * vam)
9486 unformat_input_t *i = vam->input;
9487 vl_api_sr_mpls_policy_del_t *mp;
9491 /* Parse args required to build the message */
9492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9494 if (unformat (i, "bsid %d", &bsid))
9498 clib_warning ("parse error '%U'", format_unformat_error, i);
9505 errmsg ("bsid not set");
9509 /* Construct the API message */
9510 M (SR_MPLS_POLICY_DEL, mp);
9512 mp->bsid = htonl (bsid);
9517 /* Wait for a reply... */
9523 api_bier_table_add_del (vat_main_t * vam)
9525 unformat_input_t *i = vam->input;
9526 vl_api_bier_table_add_del_t *mp;
9528 u32 set = 0, sub_domain = 0, hdr_len = 3;
9529 mpls_label_t local_label = MPLS_LABEL_INVALID;
9532 /* Parse args required to build the message */
9533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9535 if (unformat (i, "sub-domain %d", &sub_domain))
9537 else if (unformat (i, "set %d", &set))
9539 else if (unformat (i, "label %d", &local_label))
9541 else if (unformat (i, "hdr-len %d", &hdr_len))
9543 else if (unformat (i, "add"))
9545 else if (unformat (i, "del"))
9549 clib_warning ("parse error '%U'", format_unformat_error, i);
9554 if (MPLS_LABEL_INVALID == local_label)
9556 errmsg ("missing label\n");
9560 /* Construct the API message */
9561 M (BIER_TABLE_ADD_DEL, mp);
9563 mp->bt_is_add = is_add;
9564 mp->bt_label = ntohl (local_label);
9565 mp->bt_tbl_id.bt_set = set;
9566 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9567 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9572 /* Wait for a reply... */
9579 api_bier_route_add_del (vat_main_t * vam)
9581 unformat_input_t *i = vam->input;
9582 vl_api_bier_route_add_del_t *mp;
9584 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9585 ip4_address_t v4_next_hop_address;
9586 ip6_address_t v6_next_hop_address;
9587 u8 next_hop_set = 0;
9588 u8 next_hop_proto_is_ip4 = 1;
9589 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9592 /* Parse args required to build the message */
9593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9595 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9597 next_hop_proto_is_ip4 = 1;
9600 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9602 next_hop_proto_is_ip4 = 0;
9605 if (unformat (i, "sub-domain %d", &sub_domain))
9607 else if (unformat (i, "set %d", &set))
9609 else if (unformat (i, "hdr-len %d", &hdr_len))
9611 else if (unformat (i, "bp %d", &bp))
9613 else if (unformat (i, "add"))
9615 else if (unformat (i, "del"))
9617 else if (unformat (i, "out-label %d", &next_hop_out_label))
9621 clib_warning ("parse error '%U'", format_unformat_error, i);
9626 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9628 errmsg ("next hop / label set\n");
9633 errmsg ("bit=position not set\n");
9637 /* Construct the API message */
9638 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9640 mp->br_is_add = is_add;
9641 mp->br_tbl_id.bt_set = set;
9642 mp->br_tbl_id.bt_sub_domain = sub_domain;
9643 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9644 mp->br_bp = ntohs (bp);
9646 mp->br_paths[0].n_labels = 1;
9647 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9648 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9650 if (next_hop_proto_is_ip4)
9652 clib_memcpy (mp->br_paths[0].next_hop,
9653 &v4_next_hop_address, sizeof (v4_next_hop_address));
9657 clib_memcpy (mp->br_paths[0].next_hop,
9658 &v6_next_hop_address, sizeof (v6_next_hop_address));
9664 /* Wait for a reply... */
9671 api_proxy_arp_add_del (vat_main_t * vam)
9673 unformat_input_t *i = vam->input;
9674 vl_api_proxy_arp_add_del_t *mp;
9677 ip4_address_t lo, hi;
9681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9683 if (unformat (i, "vrf %d", &vrf_id))
9685 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9686 unformat_ip4_address, &hi))
9688 else if (unformat (i, "del"))
9692 clib_warning ("parse error '%U'", format_unformat_error, i);
9699 errmsg ("address range not set");
9703 M (PROXY_ARP_ADD_DEL, mp);
9705 mp->proxy.vrf_id = ntohl (vrf_id);
9706 mp->is_add = is_add;
9707 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9708 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9716 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9718 unformat_input_t *i = vam->input;
9719 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9722 u8 sw_if_index_set = 0;
9725 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9727 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9728 sw_if_index_set = 1;
9729 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9730 sw_if_index_set = 1;
9731 else if (unformat (i, "enable"))
9733 else if (unformat (i, "disable"))
9737 clib_warning ("parse error '%U'", format_unformat_error, i);
9742 if (sw_if_index_set == 0)
9744 errmsg ("missing interface name or sw_if_index");
9748 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9750 mp->sw_if_index = ntohl (sw_if_index);
9751 mp->enable_disable = enable;
9759 api_mpls_tunnel_add_del (vat_main_t * vam)
9761 unformat_input_t *i = vam->input;
9762 vl_api_mpls_tunnel_add_del_t *mp;
9766 u32 sw_if_index = ~0;
9767 u32 next_hop_sw_if_index = ~0;
9768 u32 next_hop_proto_is_ip4 = 1;
9770 u32 next_hop_table_id = 0;
9771 ip4_address_t v4_next_hop_address = {
9774 ip6_address_t v6_next_hop_address = { {0} };
9775 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9776 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9777 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9782 if (unformat (i, "add"))
9786 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9788 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9790 else if (unformat (i, "via %U",
9791 unformat_ip4_address, &v4_next_hop_address))
9793 next_hop_proto_is_ip4 = 1;
9795 else if (unformat (i, "via %U",
9796 unformat_ip6_address, &v6_next_hop_address))
9798 next_hop_proto_is_ip4 = 0;
9800 else if (unformat (i, "via-label %d", &next_hop_via_label))
9804 (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
9806 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9808 else if (unformat (i, "l2-only"))
9810 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9812 else if (unformat (i, "out-label %d", &next_hop_out_label))
9814 vl_api_fib_mpls_label_t fib_label = {
9815 .label = ntohl (next_hop_out_label),
9819 vec_add1 (next_hop_out_label_stack, fib_label);
9823 clib_warning ("parse error '%U'", format_unformat_error, i);
9828 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9829 vec_len (next_hop_out_label_stack));
9831 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9832 mp->mt_sw_if_index = ntohl (sw_if_index);
9833 mp->mt_is_add = is_add;
9834 mp->mt_l2_only = l2_only;
9835 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9836 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9837 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9838 mp->mt_next_hop_weight = 1;
9839 mp->mt_next_hop_preference = 0;
9841 mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9843 if (0 != mp->mt_next_hop_n_out_labels)
9845 clib_memcpy (mp->mt_next_hop_out_label_stack,
9846 next_hop_out_label_stack,
9847 (vec_len (next_hop_out_label_stack) *
9848 sizeof (vl_api_fib_mpls_label_t)));
9849 vec_free (next_hop_out_label_stack);
9852 if (next_hop_proto_is_ip4)
9854 clib_memcpy (mp->mt_next_hop,
9855 &v4_next_hop_address, sizeof (v4_next_hop_address));
9859 clib_memcpy (mp->mt_next_hop,
9860 &v6_next_hop_address, sizeof (v6_next_hop_address));
9869 api_sw_interface_set_unnumbered (vat_main_t * vam)
9871 unformat_input_t *i = vam->input;
9872 vl_api_sw_interface_set_unnumbered_t *mp;
9874 u32 unnum_sw_index = ~0;
9876 u8 sw_if_index_set = 0;
9879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9881 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9882 sw_if_index_set = 1;
9883 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9884 sw_if_index_set = 1;
9885 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9887 else if (unformat (i, "del"))
9891 clib_warning ("parse error '%U'", format_unformat_error, i);
9896 if (sw_if_index_set == 0)
9898 errmsg ("missing interface name or sw_if_index");
9902 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9904 mp->sw_if_index = ntohl (sw_if_index);
9905 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9906 mp->is_add = is_add;
9914 api_ip_neighbor_add_del (vat_main_t * vam)
9916 unformat_input_t *i = vam->input;
9917 vl_api_ip_neighbor_add_del_t *mp;
9919 u8 sw_if_index_set = 0;
9922 u8 is_no_fib_entry = 0;
9925 u8 v4_address_set = 0;
9926 u8 v6_address_set = 0;
9927 ip4_address_t v4address;
9928 ip6_address_t v6address;
9931 clib_memset (mac_address, 0, sizeof (mac_address));
9933 /* Parse args required to build the message */
9934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9936 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9940 else if (unformat (i, "del"))
9943 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9944 sw_if_index_set = 1;
9945 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9946 sw_if_index_set = 1;
9947 else if (unformat (i, "is_static"))
9949 else if (unformat (i, "no-fib-entry"))
9950 is_no_fib_entry = 1;
9951 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9953 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9957 clib_warning ("parse error '%U'", format_unformat_error, i);
9962 if (sw_if_index_set == 0)
9964 errmsg ("missing interface name or sw_if_index");
9967 if (v4_address_set && v6_address_set)
9969 errmsg ("both v4 and v6 addresses set");
9972 if (!v4_address_set && !v6_address_set)
9974 errmsg ("no address set");
9978 /* Construct the API message */
9979 M (IP_NEIGHBOR_ADD_DEL, mp);
9981 mp->sw_if_index = ntohl (sw_if_index);
9982 mp->is_add = is_add;
9983 mp->is_static = is_static;
9984 mp->is_no_adj_fib = is_no_fib_entry;
9986 clib_memcpy (mp->mac_address, mac_address, 6);
9990 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9994 /* mp->is_ipv6 = 0; via clib_memset in M macro above */
9995 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
10001 /* Wait for a reply, return good/bad news */
10007 api_create_vlan_subif (vat_main_t * vam)
10009 unformat_input_t *i = vam->input;
10010 vl_api_create_vlan_subif_t *mp;
10012 u8 sw_if_index_set = 0;
10014 u8 vlan_id_set = 0;
10017 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10019 if (unformat (i, "sw_if_index %d", &sw_if_index))
10020 sw_if_index_set = 1;
10022 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10023 sw_if_index_set = 1;
10024 else if (unformat (i, "vlan %d", &vlan_id))
10028 clib_warning ("parse error '%U'", format_unformat_error, i);
10033 if (sw_if_index_set == 0)
10035 errmsg ("missing interface name or sw_if_index");
10039 if (vlan_id_set == 0)
10041 errmsg ("missing vlan_id");
10044 M (CREATE_VLAN_SUBIF, mp);
10046 mp->sw_if_index = ntohl (sw_if_index);
10047 mp->vlan_id = ntohl (vlan_id);
10054 #define foreach_create_subif_bit \
10061 _(outer_vlan_id_any) \
10062 _(inner_vlan_id_any)
10065 api_create_subif (vat_main_t * vam)
10067 unformat_input_t *i = vam->input;
10068 vl_api_create_subif_t *mp;
10070 u8 sw_if_index_set = 0;
10077 u32 exact_match = 0;
10078 u32 default_sub = 0;
10079 u32 outer_vlan_id_any = 0;
10080 u32 inner_vlan_id_any = 0;
10082 u16 outer_vlan_id = 0;
10083 u16 inner_vlan_id = 0;
10086 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10088 if (unformat (i, "sw_if_index %d", &sw_if_index))
10089 sw_if_index_set = 1;
10091 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10092 sw_if_index_set = 1;
10093 else if (unformat (i, "sub_id %d", &sub_id))
10095 else if (unformat (i, "outer_vlan_id %d", &tmp))
10096 outer_vlan_id = tmp;
10097 else if (unformat (i, "inner_vlan_id %d", &tmp))
10098 inner_vlan_id = tmp;
10100 #define _(a) else if (unformat (i, #a)) a = 1 ;
10101 foreach_create_subif_bit
10105 clib_warning ("parse error '%U'", format_unformat_error, i);
10110 if (sw_if_index_set == 0)
10112 errmsg ("missing interface name or sw_if_index");
10116 if (sub_id_set == 0)
10118 errmsg ("missing sub_id");
10121 M (CREATE_SUBIF, mp);
10123 mp->sw_if_index = ntohl (sw_if_index);
10124 mp->sub_id = ntohl (sub_id);
10126 #define _(a) mp->a = a;
10127 foreach_create_subif_bit;
10130 mp->outer_vlan_id = ntohs (outer_vlan_id);
10131 mp->inner_vlan_id = ntohs (inner_vlan_id);
10139 api_oam_add_del (vat_main_t * vam)
10141 unformat_input_t *i = vam->input;
10142 vl_api_oam_add_del_t *mp;
10145 ip4_address_t src, dst;
10150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10152 if (unformat (i, "vrf %d", &vrf_id))
10154 else if (unformat (i, "src %U", unformat_ip4_address, &src))
10156 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
10158 else if (unformat (i, "del"))
10162 clib_warning ("parse error '%U'", format_unformat_error, i);
10169 errmsg ("missing src addr");
10175 errmsg ("missing dst addr");
10179 M (OAM_ADD_DEL, mp);
10181 mp->vrf_id = ntohl (vrf_id);
10182 mp->is_add = is_add;
10183 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
10184 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
10192 api_reset_fib (vat_main_t * vam)
10194 unformat_input_t *i = vam->input;
10195 vl_api_reset_fib_t *mp;
10201 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10203 if (unformat (i, "vrf %d", &vrf_id))
10205 else if (unformat (i, "ipv6"))
10209 clib_warning ("parse error '%U'", format_unformat_error, i);
10214 if (vrf_id_set == 0)
10216 errmsg ("missing vrf id");
10222 mp->vrf_id = ntohl (vrf_id);
10223 mp->is_ipv6 = is_ipv6;
10231 api_dhcp_proxy_config (vat_main_t * vam)
10233 unformat_input_t *i = vam->input;
10234 vl_api_dhcp_proxy_config_t *mp;
10236 u32 server_vrf_id = 0;
10238 u8 v4_address_set = 0;
10239 u8 v6_address_set = 0;
10240 ip4_address_t v4address;
10241 ip6_address_t v6address;
10242 u8 v4_src_address_set = 0;
10243 u8 v6_src_address_set = 0;
10244 ip4_address_t v4srcaddress;
10245 ip6_address_t v6srcaddress;
10248 /* Parse args required to build the message */
10249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10251 if (unformat (i, "del"))
10253 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
10255 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
10257 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
10258 v4_address_set = 1;
10259 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
10260 v6_address_set = 1;
10261 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
10262 v4_src_address_set = 1;
10263 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
10264 v6_src_address_set = 1;
10269 if (v4_address_set && v6_address_set)
10271 errmsg ("both v4 and v6 server addresses set");
10274 if (!v4_address_set && !v6_address_set)
10276 errmsg ("no server addresses set");
10280 if (v4_src_address_set && v6_src_address_set)
10282 errmsg ("both v4 and v6 src addresses set");
10285 if (!v4_src_address_set && !v6_src_address_set)
10287 errmsg ("no src addresses set");
10291 if (!(v4_src_address_set && v4_address_set) &&
10292 !(v6_src_address_set && v6_address_set))
10294 errmsg ("no matching server and src addresses set");
10298 /* Construct the API message */
10299 M (DHCP_PROXY_CONFIG, mp);
10301 mp->is_add = is_add;
10302 mp->rx_vrf_id = ntohl (rx_vrf_id);
10303 mp->server_vrf_id = ntohl (server_vrf_id);
10304 if (v6_address_set)
10307 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
10308 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
10312 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
10313 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
10319 /* Wait for a reply, return good/bad news */
10324 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
10325 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
10328 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
10330 vat_main_t *vam = &vat_main;
10331 u32 i, count = mp->count;
10332 vl_api_dhcp_server_t *s;
10336 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10337 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10338 ntohl (mp->rx_vrf_id),
10339 format_ip6_address, mp->dhcp_src_address,
10340 mp->vss_type, mp->vss_vpn_ascii_id,
10341 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10344 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10345 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10346 ntohl (mp->rx_vrf_id),
10347 format_ip4_address, mp->dhcp_src_address,
10348 mp->vss_type, mp->vss_vpn_ascii_id,
10349 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10351 for (i = 0; i < count; i++)
10353 s = &mp->servers[i];
10357 " Server Table-ID %d, Server Address %U",
10358 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
10361 " Server Table-ID %d, Server Address %U",
10362 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
10366 static void vl_api_dhcp_proxy_details_t_handler_json
10367 (vl_api_dhcp_proxy_details_t * mp)
10369 vat_main_t *vam = &vat_main;
10370 vat_json_node_t *node = NULL;
10371 u32 i, count = mp->count;
10372 struct in_addr ip4;
10373 struct in6_addr ip6;
10374 vl_api_dhcp_server_t *s;
10376 if (VAT_JSON_ARRAY != vam->json_tree.type)
10378 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10379 vat_json_init_array (&vam->json_tree);
10381 node = vat_json_array_add (&vam->json_tree);
10383 vat_json_init_object (node);
10384 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
10385 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
10386 sizeof (mp->vss_type));
10387 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
10388 mp->vss_vpn_ascii_id);
10389 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
10390 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10394 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10395 vat_json_object_add_ip6 (node, "src_address", ip6);
10399 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10400 vat_json_object_add_ip4 (node, "src_address", ip4);
10403 for (i = 0; i < count; i++)
10405 s = &mp->servers[i];
10407 vat_json_object_add_uint (node, "server-table-id",
10408 ntohl (s->server_vrf_id));
10412 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10413 vat_json_object_add_ip4 (node, "src_address", ip4);
10417 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10418 vat_json_object_add_ip6 (node, "server_address", ip6);
10424 api_dhcp_proxy_dump (vat_main_t * vam)
10426 unformat_input_t *i = vam->input;
10427 vl_api_control_ping_t *mp_ping;
10428 vl_api_dhcp_proxy_dump_t *mp;
10432 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10434 if (unformat (i, "ipv6"))
10438 clib_warning ("parse error '%U'", format_unformat_error, i);
10443 M (DHCP_PROXY_DUMP, mp);
10445 mp->is_ip6 = is_ipv6;
10448 /* Use a control ping for synchronization */
10449 MPING (CONTROL_PING, mp_ping);
10457 api_dhcp_proxy_set_vss (vat_main_t * vam)
10459 unformat_input_t *i = vam->input;
10460 vl_api_dhcp_proxy_set_vss_t *mp;
10464 u8 vss_type = VSS_TYPE_DEFAULT;
10465 u8 *vpn_ascii_id = 0;
10470 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10472 if (unformat (i, "tbl_id %d", &tbl_id))
10474 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10475 vss_type = VSS_TYPE_ASCII;
10476 else if (unformat (i, "fib_id %d", &fib_id))
10477 vss_type = VSS_TYPE_VPN_ID;
10478 else if (unformat (i, "oui %d", &oui))
10479 vss_type = VSS_TYPE_VPN_ID;
10480 else if (unformat (i, "ipv6"))
10482 else if (unformat (i, "del"))
10490 errmsg ("missing tbl_id ");
10491 vec_free (vpn_ascii_id);
10495 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10497 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10498 vec_free (vpn_ascii_id);
10502 M (DHCP_PROXY_SET_VSS, mp);
10503 mp->tbl_id = ntohl (tbl_id);
10504 mp->vss_type = vss_type;
10507 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10508 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10510 mp->vpn_index = ntohl (fib_id);
10511 mp->oui = ntohl (oui);
10512 mp->is_ipv6 = is_ipv6;
10513 mp->is_add = is_add;
10518 vec_free (vpn_ascii_id);
10523 api_dhcp_client_config (vat_main_t * vam)
10525 unformat_input_t *i = vam->input;
10526 vl_api_dhcp_client_config_t *mp;
10528 u8 sw_if_index_set = 0;
10531 u8 disable_event = 0;
10534 /* Parse args required to build the message */
10535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10537 if (unformat (i, "del"))
10540 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10541 sw_if_index_set = 1;
10542 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10543 sw_if_index_set = 1;
10544 else if (unformat (i, "hostname %s", &hostname))
10546 else if (unformat (i, "disable_event"))
10552 if (sw_if_index_set == 0)
10554 errmsg ("missing interface name or sw_if_index");
10558 if (vec_len (hostname) > 63)
10560 errmsg ("hostname too long");
10562 vec_add1 (hostname, 0);
10564 /* Construct the API message */
10565 M (DHCP_CLIENT_CONFIG, mp);
10567 mp->is_add = is_add;
10568 mp->client.sw_if_index = htonl (sw_if_index);
10569 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10570 vec_free (hostname);
10571 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10572 mp->client.pid = htonl (getpid ());
10577 /* Wait for a reply, return good/bad news */
10583 api_set_ip_flow_hash (vat_main_t * vam)
10585 unformat_input_t *i = vam->input;
10586 vl_api_set_ip_flow_hash_t *mp;
10598 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10600 if (unformat (i, "vrf %d", &vrf_id))
10602 else if (unformat (i, "ipv6"))
10604 else if (unformat (i, "src"))
10606 else if (unformat (i, "dst"))
10608 else if (unformat (i, "sport"))
10610 else if (unformat (i, "dport"))
10612 else if (unformat (i, "proto"))
10614 else if (unformat (i, "reverse"))
10619 clib_warning ("parse error '%U'", format_unformat_error, i);
10624 if (vrf_id_set == 0)
10626 errmsg ("missing vrf id");
10630 M (SET_IP_FLOW_HASH, mp);
10636 mp->reverse = reverse;
10637 mp->vrf_id = ntohl (vrf_id);
10638 mp->is_ipv6 = is_ipv6;
10646 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10648 unformat_input_t *i = vam->input;
10649 vl_api_sw_interface_ip6_enable_disable_t *mp;
10651 u8 sw_if_index_set = 0;
10655 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10657 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10658 sw_if_index_set = 1;
10659 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10660 sw_if_index_set = 1;
10661 else if (unformat (i, "enable"))
10663 else if (unformat (i, "disable"))
10667 clib_warning ("parse error '%U'", format_unformat_error, i);
10672 if (sw_if_index_set == 0)
10674 errmsg ("missing interface name or sw_if_index");
10678 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10680 mp->sw_if_index = ntohl (sw_if_index);
10681 mp->enable = enable;
10689 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10691 unformat_input_t *i = vam->input;
10692 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10694 u8 sw_if_index_set = 0;
10695 u8 v6_address_set = 0;
10696 ip6_address_t v6address;
10699 /* Parse args required to build the message */
10700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10702 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10703 sw_if_index_set = 1;
10704 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10705 sw_if_index_set = 1;
10706 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10707 v6_address_set = 1;
10712 if (sw_if_index_set == 0)
10714 errmsg ("missing interface name or sw_if_index");
10717 if (!v6_address_set)
10719 errmsg ("no address set");
10723 /* Construct the API message */
10724 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10726 mp->sw_if_index = ntohl (sw_if_index);
10727 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10732 /* Wait for a reply, return good/bad news */
10738 api_ip6nd_proxy_add_del (vat_main_t * vam)
10740 unformat_input_t *i = vam->input;
10741 vl_api_ip6nd_proxy_add_del_t *mp;
10742 u32 sw_if_index = ~0;
10743 u8 v6_address_set = 0;
10744 ip6_address_t v6address;
10748 /* Parse args required to build the message */
10749 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10751 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10753 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10755 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10756 v6_address_set = 1;
10757 if (unformat (i, "del"))
10761 clib_warning ("parse error '%U'", format_unformat_error, i);
10766 if (sw_if_index == ~0)
10768 errmsg ("missing interface name or sw_if_index");
10771 if (!v6_address_set)
10773 errmsg ("no address set");
10777 /* Construct the API message */
10778 M (IP6ND_PROXY_ADD_DEL, mp);
10780 mp->is_del = is_del;
10781 mp->sw_if_index = ntohl (sw_if_index);
10782 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10787 /* Wait for a reply, return good/bad news */
10793 api_ip6nd_proxy_dump (vat_main_t * vam)
10795 vl_api_ip6nd_proxy_dump_t *mp;
10796 vl_api_control_ping_t *mp_ping;
10799 M (IP6ND_PROXY_DUMP, mp);
10803 /* Use a control ping for synchronization */
10804 MPING (CONTROL_PING, mp_ping);
10811 static void vl_api_ip6nd_proxy_details_t_handler
10812 (vl_api_ip6nd_proxy_details_t * mp)
10814 vat_main_t *vam = &vat_main;
10816 print (vam->ofp, "host %U sw_if_index %d",
10817 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10820 static void vl_api_ip6nd_proxy_details_t_handler_json
10821 (vl_api_ip6nd_proxy_details_t * mp)
10823 vat_main_t *vam = &vat_main;
10824 struct in6_addr ip6;
10825 vat_json_node_t *node = NULL;
10827 if (VAT_JSON_ARRAY != vam->json_tree.type)
10829 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10830 vat_json_init_array (&vam->json_tree);
10832 node = vat_json_array_add (&vam->json_tree);
10834 vat_json_init_object (node);
10835 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10837 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10838 vat_json_object_add_ip6 (node, "host", ip6);
10842 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10844 unformat_input_t *i = vam->input;
10845 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10847 u8 sw_if_index_set = 0;
10848 u32 address_length = 0;
10849 u8 v6_address_set = 0;
10850 ip6_address_t v6address;
10851 u8 use_default = 0;
10852 u8 no_advertise = 0;
10854 u8 no_autoconfig = 0;
10857 u32 val_lifetime = 0;
10858 u32 pref_lifetime = 0;
10861 /* Parse args required to build the message */
10862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10864 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10865 sw_if_index_set = 1;
10866 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10867 sw_if_index_set = 1;
10868 else if (unformat (i, "%U/%d",
10869 unformat_ip6_address, &v6address, &address_length))
10870 v6_address_set = 1;
10871 else if (unformat (i, "val_life %d", &val_lifetime))
10873 else if (unformat (i, "pref_life %d", &pref_lifetime))
10875 else if (unformat (i, "def"))
10877 else if (unformat (i, "noadv"))
10879 else if (unformat (i, "offl"))
10881 else if (unformat (i, "noauto"))
10883 else if (unformat (i, "nolink"))
10885 else if (unformat (i, "isno"))
10889 clib_warning ("parse error '%U'", format_unformat_error, i);
10894 if (sw_if_index_set == 0)
10896 errmsg ("missing interface name or sw_if_index");
10899 if (!v6_address_set)
10901 errmsg ("no address set");
10905 /* Construct the API message */
10906 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10908 mp->sw_if_index = ntohl (sw_if_index);
10909 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10910 mp->address_length = address_length;
10911 mp->use_default = use_default;
10912 mp->no_advertise = no_advertise;
10913 mp->off_link = off_link;
10914 mp->no_autoconfig = no_autoconfig;
10915 mp->no_onlink = no_onlink;
10917 mp->val_lifetime = ntohl (val_lifetime);
10918 mp->pref_lifetime = ntohl (pref_lifetime);
10923 /* Wait for a reply, return good/bad news */
10929 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10931 unformat_input_t *i = vam->input;
10932 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10934 u8 sw_if_index_set = 0;
10939 u8 send_unicast = 0;
10942 u8 default_router = 0;
10943 u32 max_interval = 0;
10944 u32 min_interval = 0;
10946 u32 initial_count = 0;
10947 u32 initial_interval = 0;
10951 /* Parse args required to build the message */
10952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10954 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10955 sw_if_index_set = 1;
10956 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10957 sw_if_index_set = 1;
10958 else if (unformat (i, "maxint %d", &max_interval))
10960 else if (unformat (i, "minint %d", &min_interval))
10962 else if (unformat (i, "life %d", &lifetime))
10964 else if (unformat (i, "count %d", &initial_count))
10966 else if (unformat (i, "interval %d", &initial_interval))
10968 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10970 else if (unformat (i, "managed"))
10972 else if (unformat (i, "other"))
10974 else if (unformat (i, "ll"))
10976 else if (unformat (i, "send"))
10978 else if (unformat (i, "cease"))
10980 else if (unformat (i, "isno"))
10982 else if (unformat (i, "def"))
10983 default_router = 1;
10986 clib_warning ("parse error '%U'", format_unformat_error, i);
10991 if (sw_if_index_set == 0)
10993 errmsg ("missing interface name or sw_if_index");
10997 /* Construct the API message */
10998 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
11000 mp->sw_if_index = ntohl (sw_if_index);
11001 mp->max_interval = ntohl (max_interval);
11002 mp->min_interval = ntohl (min_interval);
11003 mp->lifetime = ntohl (lifetime);
11004 mp->initial_count = ntohl (initial_count);
11005 mp->initial_interval = ntohl (initial_interval);
11006 mp->suppress = suppress;
11007 mp->managed = managed;
11009 mp->ll_option = ll_option;
11010 mp->send_unicast = send_unicast;
11013 mp->default_router = default_router;
11018 /* Wait for a reply, return good/bad news */
11024 api_set_arp_neighbor_limit (vat_main_t * vam)
11026 unformat_input_t *i = vam->input;
11027 vl_api_set_arp_neighbor_limit_t *mp;
11033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11035 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
11037 else if (unformat (i, "ipv6"))
11041 clib_warning ("parse error '%U'", format_unformat_error, i);
11046 if (limit_set == 0)
11048 errmsg ("missing limit value");
11052 M (SET_ARP_NEIGHBOR_LIMIT, mp);
11054 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
11055 mp->is_ipv6 = is_ipv6;
11063 api_l2_patch_add_del (vat_main_t * vam)
11065 unformat_input_t *i = vam->input;
11066 vl_api_l2_patch_add_del_t *mp;
11067 u32 rx_sw_if_index;
11068 u8 rx_sw_if_index_set = 0;
11069 u32 tx_sw_if_index;
11070 u8 tx_sw_if_index_set = 0;
11074 /* Parse args required to build the message */
11075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11077 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
11078 rx_sw_if_index_set = 1;
11079 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
11080 tx_sw_if_index_set = 1;
11081 else if (unformat (i, "rx"))
11083 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11085 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
11087 rx_sw_if_index_set = 1;
11092 else if (unformat (i, "tx"))
11094 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11096 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
11098 tx_sw_if_index_set = 1;
11103 else if (unformat (i, "del"))
11109 if (rx_sw_if_index_set == 0)
11111 errmsg ("missing rx interface name or rx_sw_if_index");
11115 if (tx_sw_if_index_set == 0)
11117 errmsg ("missing tx interface name or tx_sw_if_index");
11121 M (L2_PATCH_ADD_DEL, mp);
11123 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
11124 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
11125 mp->is_add = is_add;
11133 u8 localsid_addr[16];
11142 api_sr_localsid_add_del (vat_main_t * vam)
11144 unformat_input_t *i = vam->input;
11145 vl_api_sr_localsid_add_del_t *mp;
11148 ip6_address_t localsid;
11152 u32 fib_table = ~(u32) 0;
11153 ip6_address_t nh_addr6;
11154 ip4_address_t nh_addr4;
11155 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
11156 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
11158 bool nexthop_set = 0;
11162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11164 if (unformat (i, "del"))
11166 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
11167 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
11169 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
11171 else if (unformat (i, "behavior %u", &behavior));
11172 else if (unformat (i, "sw_if_index %u", &sw_if_index));
11173 else if (unformat (i, "fib-table %u", &fib_table));
11174 else if (unformat (i, "end.psp %u", &behavior));
11179 M (SR_LOCALSID_ADD_DEL, mp);
11181 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
11184 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
11185 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
11187 mp->behavior = behavior;
11188 mp->sw_if_index = ntohl (sw_if_index);
11189 mp->fib_table = ntohl (fib_table);
11190 mp->end_psp = end_psp;
11191 mp->is_del = is_del;
11199 api_ioam_enable (vat_main_t * vam)
11201 unformat_input_t *input = vam->input;
11202 vl_api_ioam_enable_t *mp;
11204 int has_trace_option = 0;
11205 int has_pot_option = 0;
11206 int has_seqno_option = 0;
11207 int has_analyse_option = 0;
11210 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11212 if (unformat (input, "trace"))
11213 has_trace_option = 1;
11214 else if (unformat (input, "pot"))
11215 has_pot_option = 1;
11216 else if (unformat (input, "seqno"))
11217 has_seqno_option = 1;
11218 else if (unformat (input, "analyse"))
11219 has_analyse_option = 1;
11223 M (IOAM_ENABLE, mp);
11224 mp->id = htons (id);
11225 mp->seqno = has_seqno_option;
11226 mp->analyse = has_analyse_option;
11227 mp->pot_enable = has_pot_option;
11228 mp->trace_enable = has_trace_option;
11237 api_ioam_disable (vat_main_t * vam)
11239 vl_api_ioam_disable_t *mp;
11242 M (IOAM_DISABLE, mp);
11248 #define foreach_tcp_proto_field \
11252 #define foreach_udp_proto_field \
11256 #define foreach_ip4_proto_field \
11268 u16 src_port, dst_port;
11271 #if VPP_API_TEST_BUILTIN == 0
11273 unformat_tcp_mask (unformat_input_t * input, va_list * args)
11275 u8 **maskp = va_arg (*args, u8 **);
11277 u8 found_something = 0;
11280 #define _(a) u8 a=0;
11281 foreach_tcp_proto_field;
11284 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11287 #define _(a) else if (unformat (input, #a)) a=1;
11288 foreach_tcp_proto_field
11294 #define _(a) found_something += a;
11295 foreach_tcp_proto_field;
11298 if (found_something == 0)
11301 vec_validate (mask, sizeof (*tcp) - 1);
11303 tcp = (tcp_header_t *) mask;
11305 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
11306 foreach_tcp_proto_field;
11314 unformat_udp_mask (unformat_input_t * input, va_list * args)
11316 u8 **maskp = va_arg (*args, u8 **);
11318 u8 found_something = 0;
11321 #define _(a) u8 a=0;
11322 foreach_udp_proto_field;
11325 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11328 #define _(a) else if (unformat (input, #a)) a=1;
11329 foreach_udp_proto_field
11335 #define _(a) found_something += a;
11336 foreach_udp_proto_field;
11339 if (found_something == 0)
11342 vec_validate (mask, sizeof (*udp) - 1);
11344 udp = (udp_header_t *) mask;
11346 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
11347 foreach_udp_proto_field;
11355 unformat_l4_mask (unformat_input_t * input, va_list * args)
11357 u8 **maskp = va_arg (*args, u8 **);
11358 u16 src_port = 0, dst_port = 0;
11359 tcpudp_header_t *tcpudp;
11361 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11363 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
11365 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
11367 else if (unformat (input, "src_port"))
11369 else if (unformat (input, "dst_port"))
11375 if (!src_port && !dst_port)
11379 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
11381 tcpudp = (tcpudp_header_t *) mask;
11382 tcpudp->src_port = src_port;
11383 tcpudp->dst_port = dst_port;
11391 unformat_ip4_mask (unformat_input_t * input, va_list * args)
11393 u8 **maskp = va_arg (*args, u8 **);
11395 u8 found_something = 0;
11398 #define _(a) u8 a=0;
11399 foreach_ip4_proto_field;
11405 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11407 if (unformat (input, "version"))
11409 else if (unformat (input, "hdr_length"))
11411 else if (unformat (input, "src"))
11413 else if (unformat (input, "dst"))
11415 else if (unformat (input, "proto"))
11418 #define _(a) else if (unformat (input, #a)) a=1;
11419 foreach_ip4_proto_field
11425 #define _(a) found_something += a;
11426 foreach_ip4_proto_field;
11429 if (found_something == 0)
11432 vec_validate (mask, sizeof (*ip) - 1);
11434 ip = (ip4_header_t *) mask;
11436 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
11437 foreach_ip4_proto_field;
11440 ip->ip_version_and_header_length = 0;
11443 ip->ip_version_and_header_length |= 0xF0;
11446 ip->ip_version_and_header_length |= 0x0F;
11452 #define foreach_ip6_proto_field \
11455 _(payload_length) \
11460 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11462 u8 **maskp = va_arg (*args, u8 **);
11464 u8 found_something = 0;
11466 u32 ip_version_traffic_class_and_flow_label;
11468 #define _(a) u8 a=0;
11469 foreach_ip6_proto_field;
11472 u8 traffic_class = 0;
11475 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11477 if (unformat (input, "version"))
11479 else if (unformat (input, "traffic-class"))
11481 else if (unformat (input, "flow-label"))
11483 else if (unformat (input, "src"))
11485 else if (unformat (input, "dst"))
11487 else if (unformat (input, "proto"))
11490 #define _(a) else if (unformat (input, #a)) a=1;
11491 foreach_ip6_proto_field
11497 #define _(a) found_something += a;
11498 foreach_ip6_proto_field;
11501 if (found_something == 0)
11504 vec_validate (mask, sizeof (*ip) - 1);
11506 ip = (ip6_header_t *) mask;
11508 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
11509 foreach_ip6_proto_field;
11512 ip_version_traffic_class_and_flow_label = 0;
11515 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11518 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11521 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11523 ip->ip_version_traffic_class_and_flow_label =
11524 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11531 unformat_l3_mask (unformat_input_t * input, va_list * args)
11533 u8 **maskp = va_arg (*args, u8 **);
11535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11537 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11539 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11548 unformat_l2_mask (unformat_input_t * input, va_list * args)
11550 u8 **maskp = va_arg (*args, u8 **);
11557 u8 ignore_tag1 = 0;
11558 u8 ignore_tag2 = 0;
11565 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11567 if (unformat (input, "src"))
11569 else if (unformat (input, "dst"))
11571 else if (unformat (input, "proto"))
11573 else if (unformat (input, "tag1"))
11575 else if (unformat (input, "tag2"))
11577 else if (unformat (input, "ignore-tag1"))
11579 else if (unformat (input, "ignore-tag2"))
11581 else if (unformat (input, "cos1"))
11583 else if (unformat (input, "cos2"))
11585 else if (unformat (input, "dot1q"))
11587 else if (unformat (input, "dot1ad"))
11592 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11593 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11596 if (tag1 || ignore_tag1 || cos1 || dot1q)
11598 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11601 vec_validate (mask, len - 1);
11604 clib_memset (mask, 0xff, 6);
11607 clib_memset (mask + 6, 0xff, 6);
11609 if (tag2 || dot1ad)
11611 /* inner vlan tag */
11620 mask[21] = mask[20] = 0xff;
11641 mask[16] = mask[17] = 0xff;
11651 mask[12] = mask[13] = 0xff;
11658 unformat_classify_mask (unformat_input_t * input, va_list * args)
11660 u8 **maskp = va_arg (*args, u8 **);
11661 u32 *skipp = va_arg (*args, u32 *);
11662 u32 *matchp = va_arg (*args, u32 *);
11670 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11672 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11674 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11676 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11678 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11692 if (mask || l2 || l3 || l4)
11694 if (l2 || l3 || l4)
11696 /* "With a free Ethernet header in every package" */
11698 vec_validate (l2, 13);
11702 vec_append (mask, l3);
11707 vec_append (mask, l4);
11712 /* Scan forward looking for the first significant mask octet */
11713 for (i = 0; i < vec_len (mask); i++)
11717 /* compute (skip, match) params */
11718 *skipp = i / sizeof (u32x4);
11719 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11721 /* Pad mask to an even multiple of the vector size */
11722 while (vec_len (mask) % sizeof (u32x4))
11723 vec_add1 (mask, 0);
11725 match = vec_len (mask) / sizeof (u32x4);
11727 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11729 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11730 if (*tmp || *(tmp + 1))
11735 clib_warning ("BUG: match 0");
11737 _vec_len (mask) = match * sizeof (u32x4);
11747 #endif /* VPP_API_TEST_BUILTIN */
11749 #define foreach_l2_next \
11751 _(ethernet, ETHERNET_INPUT) \
11752 _(ip4, IP4_INPUT) \
11756 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11758 u32 *miss_next_indexp = va_arg (*args, u32 *);
11759 u32 next_index = 0;
11763 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11767 if (unformat (input, "%d", &tmp))
11776 *miss_next_indexp = next_index;
11780 #define foreach_ip_next \
11783 _(rewrite, REWRITE)
11786 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11788 u32 *miss_next_indexp = va_arg (*args, u32 *);
11789 u32 next_index = 0;
11793 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11797 if (unformat (input, "%d", &tmp))
11806 *miss_next_indexp = next_index;
11810 #define foreach_acl_next \
11814 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11816 u32 *miss_next_indexp = va_arg (*args, u32 *);
11817 u32 next_index = 0;
11821 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11825 if (unformat (input, "permit"))
11830 else if (unformat (input, "%d", &tmp))
11839 *miss_next_indexp = next_index;
11844 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11846 u32 *r = va_arg (*args, u32 *);
11848 if (unformat (input, "conform-color"))
11849 *r = POLICE_CONFORM;
11850 else if (unformat (input, "exceed-color"))
11851 *r = POLICE_EXCEED;
11859 api_classify_add_del_table (vat_main_t * vam)
11861 unformat_input_t *i = vam->input;
11862 vl_api_classify_add_del_table_t *mp;
11869 u32 table_index = ~0;
11870 u32 next_table_index = ~0;
11871 u32 miss_next_index = ~0;
11872 u32 memory_size = 32 << 20;
11874 u32 current_data_flag = 0;
11875 int current_data_offset = 0;
11878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11880 if (unformat (i, "del"))
11882 else if (unformat (i, "del-chain"))
11887 else if (unformat (i, "buckets %d", &nbuckets))
11889 else if (unformat (i, "memory_size %d", &memory_size))
11891 else if (unformat (i, "skip %d", &skip))
11893 else if (unformat (i, "match %d", &match))
11895 else if (unformat (i, "table %d", &table_index))
11897 else if (unformat (i, "mask %U", unformat_classify_mask,
11898 &mask, &skip, &match))
11900 else if (unformat (i, "next-table %d", &next_table_index))
11902 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11905 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11908 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11911 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11913 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11919 if (is_add && mask == 0)
11921 errmsg ("Mask required");
11925 if (is_add && skip == ~0)
11927 errmsg ("skip count required");
11931 if (is_add && match == ~0)
11933 errmsg ("match count required");
11937 if (!is_add && table_index == ~0)
11939 errmsg ("table index required for delete");
11943 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11945 mp->is_add = is_add;
11946 mp->del_chain = del_chain;
11947 mp->table_index = ntohl (table_index);
11948 mp->nbuckets = ntohl (nbuckets);
11949 mp->memory_size = ntohl (memory_size);
11950 mp->skip_n_vectors = ntohl (skip);
11951 mp->match_n_vectors = ntohl (match);
11952 mp->next_table_index = ntohl (next_table_index);
11953 mp->miss_next_index = ntohl (miss_next_index);
11954 mp->current_data_flag = ntohl (current_data_flag);
11955 mp->current_data_offset = ntohl (current_data_offset);
11956 mp->mask_len = ntohl (vec_len (mask));
11957 clib_memcpy (mp->mask, mask, vec_len (mask));
11966 #if VPP_API_TEST_BUILTIN == 0
11968 unformat_l4_match (unformat_input_t * input, va_list * args)
11970 u8 **matchp = va_arg (*args, u8 **);
11972 u8 *proto_header = 0;
11978 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11980 if (unformat (input, "src_port %d", &src_port))
11982 else if (unformat (input, "dst_port %d", &dst_port))
11988 h.src_port = clib_host_to_net_u16 (src_port);
11989 h.dst_port = clib_host_to_net_u16 (dst_port);
11990 vec_validate (proto_header, sizeof (h) - 1);
11991 memcpy (proto_header, &h, sizeof (h));
11993 *matchp = proto_header;
11999 unformat_ip4_match (unformat_input_t * input, va_list * args)
12001 u8 **matchp = va_arg (*args, u8 **);
12006 int hdr_length = 0;
12007 u32 hdr_length_val;
12008 int src = 0, dst = 0;
12009 ip4_address_t src_val, dst_val;
12016 int fragment_id = 0;
12017 u32 fragment_id_val;
12023 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12025 if (unformat (input, "version %d", &version_val))
12027 else if (unformat (input, "hdr_length %d", &hdr_length_val))
12029 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
12031 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
12033 else if (unformat (input, "proto %d", &proto_val))
12035 else if (unformat (input, "tos %d", &tos_val))
12037 else if (unformat (input, "length %d", &length_val))
12039 else if (unformat (input, "fragment_id %d", &fragment_id_val))
12041 else if (unformat (input, "ttl %d", &ttl_val))
12043 else if (unformat (input, "checksum %d", &checksum_val))
12049 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
12050 + ttl + checksum == 0)
12054 * Aligned because we use the real comparison functions
12056 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12058 ip = (ip4_header_t *) match;
12060 /* These are realistically matched in practice */
12062 ip->src_address.as_u32 = src_val.as_u32;
12065 ip->dst_address.as_u32 = dst_val.as_u32;
12068 ip->protocol = proto_val;
12071 /* These are not, but they're included for completeness */
12073 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
12076 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
12082 ip->length = clib_host_to_net_u16 (length_val);
12088 ip->checksum = clib_host_to_net_u16 (checksum_val);
12095 unformat_ip6_match (unformat_input_t * input, va_list * args)
12097 u8 **matchp = va_arg (*args, u8 **);
12102 u8 traffic_class = 0;
12103 u32 traffic_class_val = 0;
12106 int src = 0, dst = 0;
12107 ip6_address_t src_val, dst_val;
12110 int payload_length = 0;
12111 u32 payload_length_val;
12114 u32 ip_version_traffic_class_and_flow_label;
12116 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12118 if (unformat (input, "version %d", &version_val))
12120 else if (unformat (input, "traffic_class %d", &traffic_class_val))
12122 else if (unformat (input, "flow_label %d", &flow_label_val))
12124 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
12126 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
12128 else if (unformat (input, "proto %d", &proto_val))
12130 else if (unformat (input, "payload_length %d", &payload_length_val))
12131 payload_length = 1;
12132 else if (unformat (input, "hop_limit %d", &hop_limit_val))
12138 if (version + traffic_class + flow_label + src + dst + proto +
12139 payload_length + hop_limit == 0)
12143 * Aligned because we use the real comparison functions
12145 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12147 ip = (ip6_header_t *) match;
12150 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
12153 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
12156 ip->protocol = proto_val;
12158 ip_version_traffic_class_and_flow_label = 0;
12161 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
12164 ip_version_traffic_class_and_flow_label |=
12165 (traffic_class_val & 0xFF) << 20;
12168 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
12170 ip->ip_version_traffic_class_and_flow_label =
12171 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
12173 if (payload_length)
12174 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
12177 ip->hop_limit = hop_limit_val;
12184 unformat_l3_match (unformat_input_t * input, va_list * args)
12186 u8 **matchp = va_arg (*args, u8 **);
12188 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12190 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
12192 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
12201 unformat_vlan_tag (unformat_input_t * input, va_list * args)
12203 u8 *tagp = va_arg (*args, u8 *);
12206 if (unformat (input, "%d", &tag))
12208 tagp[0] = (tag >> 8) & 0x0F;
12209 tagp[1] = tag & 0xFF;
12217 unformat_l2_match (unformat_input_t * input, va_list * args)
12219 u8 **matchp = va_arg (*args, u8 **);
12232 u8 ignore_tag1 = 0;
12233 u8 ignore_tag2 = 0;
12239 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12241 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
12244 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
12246 else if (unformat (input, "proto %U",
12247 unformat_ethernet_type_host_byte_order, &proto_val))
12249 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
12251 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
12253 else if (unformat (input, "ignore-tag1"))
12255 else if (unformat (input, "ignore-tag2"))
12257 else if (unformat (input, "cos1 %d", &cos1_val))
12259 else if (unformat (input, "cos2 %d", &cos2_val))
12264 if ((src + dst + proto + tag1 + tag2 +
12265 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
12268 if (tag1 || ignore_tag1 || cos1)
12270 if (tag2 || ignore_tag2 || cos2)
12273 vec_validate_aligned (match, len - 1, sizeof (u32x4));
12276 clib_memcpy (match, dst_val, 6);
12279 clib_memcpy (match + 6, src_val, 6);
12283 /* inner vlan tag */
12284 match[19] = tag2_val[1];
12285 match[18] = tag2_val[0];
12287 match[18] |= (cos2_val & 0x7) << 5;
12290 match[21] = proto_val & 0xff;
12291 match[20] = proto_val >> 8;
12295 match[15] = tag1_val[1];
12296 match[14] = tag1_val[0];
12299 match[14] |= (cos1_val & 0x7) << 5;
12305 match[15] = tag1_val[1];
12306 match[14] = tag1_val[0];
12309 match[17] = proto_val & 0xff;
12310 match[16] = proto_val >> 8;
12313 match[14] |= (cos1_val & 0x7) << 5;
12319 match[18] |= (cos2_val & 0x7) << 5;
12321 match[14] |= (cos1_val & 0x7) << 5;
12324 match[13] = proto_val & 0xff;
12325 match[12] = proto_val >> 8;
12333 unformat_qos_source (unformat_input_t * input, va_list * args)
12335 int *qs = va_arg (*args, int *);
12337 if (unformat (input, "ip"))
12338 *qs = QOS_SOURCE_IP;
12339 else if (unformat (input, "mpls"))
12340 *qs = QOS_SOURCE_MPLS;
12341 else if (unformat (input, "ext"))
12342 *qs = QOS_SOURCE_EXT;
12343 else if (unformat (input, "vlan"))
12344 *qs = QOS_SOURCE_VLAN;
12353 api_unformat_classify_match (unformat_input_t * input, va_list * args)
12355 u8 **matchp = va_arg (*args, u8 **);
12356 u32 skip_n_vectors = va_arg (*args, u32);
12357 u32 match_n_vectors = va_arg (*args, u32);
12364 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12366 if (unformat (input, "hex %U", unformat_hex_string, &match))
12368 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
12370 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
12372 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
12386 if (match || l2 || l3 || l4)
12388 if (l2 || l3 || l4)
12390 /* "Win a free Ethernet header in every packet" */
12392 vec_validate_aligned (l2, 13, sizeof (u32x4));
12396 vec_append_aligned (match, l3, sizeof (u32x4));
12401 vec_append_aligned (match, l4, sizeof (u32x4));
12406 /* Make sure the vector is big enough even if key is all 0's */
12407 vec_validate_aligned
12408 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12411 /* Set size, include skipped vectors */
12412 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12423 api_classify_add_del_session (vat_main_t * vam)
12425 unformat_input_t *i = vam->input;
12426 vl_api_classify_add_del_session_t *mp;
12428 u32 table_index = ~0;
12429 u32 hit_next_index = ~0;
12430 u32 opaque_index = ~0;
12433 u32 skip_n_vectors = 0;
12434 u32 match_n_vectors = 0;
12440 * Warning: you have to supply skip_n and match_n
12441 * because the API client cant simply look at the classify
12445 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12447 if (unformat (i, "del"))
12449 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12452 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12455 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12458 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12460 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12462 else if (unformat (i, "opaque-index %d", &opaque_index))
12464 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12466 else if (unformat (i, "match_n %d", &match_n_vectors))
12468 else if (unformat (i, "match %U", api_unformat_classify_match,
12469 &match, skip_n_vectors, match_n_vectors))
12471 else if (unformat (i, "advance %d", &advance))
12473 else if (unformat (i, "table-index %d", &table_index))
12475 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12477 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12479 else if (unformat (i, "action %d", &action))
12481 else if (unformat (i, "metadata %d", &metadata))
12487 if (table_index == ~0)
12489 errmsg ("Table index required");
12493 if (is_add && match == 0)
12495 errmsg ("Match value required");
12499 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12501 mp->is_add = is_add;
12502 mp->table_index = ntohl (table_index);
12503 mp->hit_next_index = ntohl (hit_next_index);
12504 mp->opaque_index = ntohl (opaque_index);
12505 mp->advance = ntohl (advance);
12506 mp->action = action;
12507 mp->metadata = ntohl (metadata);
12508 mp->match_len = ntohl (vec_len (match));
12509 clib_memcpy (mp->match, match, vec_len (match));
12518 api_classify_set_interface_ip_table (vat_main_t * vam)
12520 unformat_input_t *i = vam->input;
12521 vl_api_classify_set_interface_ip_table_t *mp;
12523 int sw_if_index_set;
12524 u32 table_index = ~0;
12528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12530 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12531 sw_if_index_set = 1;
12532 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12533 sw_if_index_set = 1;
12534 else if (unformat (i, "table %d", &table_index))
12538 clib_warning ("parse error '%U'", format_unformat_error, i);
12543 if (sw_if_index_set == 0)
12545 errmsg ("missing interface name or sw_if_index");
12550 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12552 mp->sw_if_index = ntohl (sw_if_index);
12553 mp->table_index = ntohl (table_index);
12554 mp->is_ipv6 = is_ipv6;
12562 api_classify_set_interface_l2_tables (vat_main_t * vam)
12564 unformat_input_t *i = vam->input;
12565 vl_api_classify_set_interface_l2_tables_t *mp;
12567 int sw_if_index_set;
12568 u32 ip4_table_index = ~0;
12569 u32 ip6_table_index = ~0;
12570 u32 other_table_index = ~0;
12574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12576 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12577 sw_if_index_set = 1;
12578 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12579 sw_if_index_set = 1;
12580 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12582 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12584 else if (unformat (i, "other-table %d", &other_table_index))
12586 else if (unformat (i, "is-input %d", &is_input))
12590 clib_warning ("parse error '%U'", format_unformat_error, i);
12595 if (sw_if_index_set == 0)
12597 errmsg ("missing interface name or sw_if_index");
12602 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12604 mp->sw_if_index = ntohl (sw_if_index);
12605 mp->ip4_table_index = ntohl (ip4_table_index);
12606 mp->ip6_table_index = ntohl (ip6_table_index);
12607 mp->other_table_index = ntohl (other_table_index);
12608 mp->is_input = (u8) is_input;
12616 api_set_ipfix_exporter (vat_main_t * vam)
12618 unformat_input_t *i = vam->input;
12619 vl_api_set_ipfix_exporter_t *mp;
12620 ip4_address_t collector_address;
12621 u8 collector_address_set = 0;
12622 u32 collector_port = ~0;
12623 ip4_address_t src_address;
12624 u8 src_address_set = 0;
12627 u32 template_interval = ~0;
12628 u8 udp_checksum = 0;
12631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12633 if (unformat (i, "collector_address %U", unformat_ip4_address,
12634 &collector_address))
12635 collector_address_set = 1;
12636 else if (unformat (i, "collector_port %d", &collector_port))
12638 else if (unformat (i, "src_address %U", unformat_ip4_address,
12640 src_address_set = 1;
12641 else if (unformat (i, "vrf_id %d", &vrf_id))
12643 else if (unformat (i, "path_mtu %d", &path_mtu))
12645 else if (unformat (i, "template_interval %d", &template_interval))
12647 else if (unformat (i, "udp_checksum"))
12653 if (collector_address_set == 0)
12655 errmsg ("collector_address required");
12659 if (src_address_set == 0)
12661 errmsg ("src_address required");
12665 M (SET_IPFIX_EXPORTER, mp);
12667 memcpy (mp->collector_address, collector_address.data,
12668 sizeof (collector_address.data));
12669 mp->collector_port = htons ((u16) collector_port);
12670 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12671 mp->vrf_id = htonl (vrf_id);
12672 mp->path_mtu = htonl (path_mtu);
12673 mp->template_interval = htonl (template_interval);
12674 mp->udp_checksum = udp_checksum;
12682 api_set_ipfix_classify_stream (vat_main_t * vam)
12684 unformat_input_t *i = vam->input;
12685 vl_api_set_ipfix_classify_stream_t *mp;
12687 u32 src_port = UDP_DST_PORT_ipfix;
12690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12692 if (unformat (i, "domain %d", &domain_id))
12694 else if (unformat (i, "src_port %d", &src_port))
12698 errmsg ("unknown input `%U'", format_unformat_error, i);
12703 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12705 mp->domain_id = htonl (domain_id);
12706 mp->src_port = htons ((u16) src_port);
12714 api_ipfix_classify_table_add_del (vat_main_t * vam)
12716 unformat_input_t *i = vam->input;
12717 vl_api_ipfix_classify_table_add_del_t *mp;
12719 u32 classify_table_index = ~0;
12721 u8 transport_protocol = 255;
12724 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12726 if (unformat (i, "add"))
12728 else if (unformat (i, "del"))
12730 else if (unformat (i, "table %d", &classify_table_index))
12732 else if (unformat (i, "ip4"))
12734 else if (unformat (i, "ip6"))
12736 else if (unformat (i, "tcp"))
12737 transport_protocol = 6;
12738 else if (unformat (i, "udp"))
12739 transport_protocol = 17;
12742 errmsg ("unknown input `%U'", format_unformat_error, i);
12749 errmsg ("expecting: add|del");
12752 if (classify_table_index == ~0)
12754 errmsg ("classifier table not specified");
12757 if (ip_version == 0)
12759 errmsg ("IP version not specified");
12763 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12765 mp->is_add = is_add;
12766 mp->table_id = htonl (classify_table_index);
12767 mp->ip_version = ip_version;
12768 mp->transport_protocol = transport_protocol;
12776 api_get_node_index (vat_main_t * vam)
12778 unformat_input_t *i = vam->input;
12779 vl_api_get_node_index_t *mp;
12783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12785 if (unformat (i, "node %s", &name))
12792 errmsg ("node name required");
12795 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12797 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12801 M (GET_NODE_INDEX, mp);
12802 clib_memcpy (mp->node_name, name, vec_len (name));
12811 api_get_next_index (vat_main_t * vam)
12813 unformat_input_t *i = vam->input;
12814 vl_api_get_next_index_t *mp;
12815 u8 *node_name = 0, *next_node_name = 0;
12818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12820 if (unformat (i, "node-name %s", &node_name))
12822 else if (unformat (i, "next-node-name %s", &next_node_name))
12826 if (node_name == 0)
12828 errmsg ("node name required");
12831 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12833 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12837 if (next_node_name == 0)
12839 errmsg ("next node name required");
12842 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12844 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12848 M (GET_NEXT_INDEX, mp);
12849 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12850 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12851 vec_free (node_name);
12852 vec_free (next_node_name);
12860 api_add_node_next (vat_main_t * vam)
12862 unformat_input_t *i = vam->input;
12863 vl_api_add_node_next_t *mp;
12868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12870 if (unformat (i, "node %s", &name))
12872 else if (unformat (i, "next %s", &next))
12879 errmsg ("node name required");
12882 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12884 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12889 errmsg ("next node required");
12892 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12894 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12898 M (ADD_NODE_NEXT, mp);
12899 clib_memcpy (mp->node_name, name, vec_len (name));
12900 clib_memcpy (mp->next_name, next, vec_len (next));
12910 api_l2tpv3_create_tunnel (vat_main_t * vam)
12912 unformat_input_t *i = vam->input;
12913 ip6_address_t client_address, our_address;
12914 int client_address_set = 0;
12915 int our_address_set = 0;
12916 u32 local_session_id = 0;
12917 u32 remote_session_id = 0;
12918 u64 local_cookie = 0;
12919 u64 remote_cookie = 0;
12920 u8 l2_sublayer_present = 0;
12921 vl_api_l2tpv3_create_tunnel_t *mp;
12924 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12926 if (unformat (i, "client_address %U", unformat_ip6_address,
12928 client_address_set = 1;
12929 else if (unformat (i, "our_address %U", unformat_ip6_address,
12931 our_address_set = 1;
12932 else if (unformat (i, "local_session_id %d", &local_session_id))
12934 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12936 else if (unformat (i, "local_cookie %lld", &local_cookie))
12938 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12940 else if (unformat (i, "l2-sublayer-present"))
12941 l2_sublayer_present = 1;
12946 if (client_address_set == 0)
12948 errmsg ("client_address required");
12952 if (our_address_set == 0)
12954 errmsg ("our_address required");
12958 M (L2TPV3_CREATE_TUNNEL, mp);
12960 clib_memcpy (mp->client_address, client_address.as_u8,
12961 sizeof (mp->client_address));
12963 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12965 mp->local_session_id = ntohl (local_session_id);
12966 mp->remote_session_id = ntohl (remote_session_id);
12967 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12968 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12969 mp->l2_sublayer_present = l2_sublayer_present;
12978 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12980 unformat_input_t *i = vam->input;
12982 u8 sw_if_index_set = 0;
12983 u64 new_local_cookie = 0;
12984 u64 new_remote_cookie = 0;
12985 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12990 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12991 sw_if_index_set = 1;
12992 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12993 sw_if_index_set = 1;
12994 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12996 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
13002 if (sw_if_index_set == 0)
13004 errmsg ("missing interface name or sw_if_index");
13008 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
13010 mp->sw_if_index = ntohl (sw_if_index);
13011 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
13012 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
13020 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
13022 unformat_input_t *i = vam->input;
13023 vl_api_l2tpv3_interface_enable_disable_t *mp;
13025 u8 sw_if_index_set = 0;
13026 u8 enable_disable = 1;
13029 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13031 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13032 sw_if_index_set = 1;
13033 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13034 sw_if_index_set = 1;
13035 else if (unformat (i, "enable"))
13036 enable_disable = 1;
13037 else if (unformat (i, "disable"))
13038 enable_disable = 0;
13043 if (sw_if_index_set == 0)
13045 errmsg ("missing interface name or sw_if_index");
13049 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
13051 mp->sw_if_index = ntohl (sw_if_index);
13052 mp->enable_disable = enable_disable;
13060 api_l2tpv3_set_lookup_key (vat_main_t * vam)
13062 unformat_input_t *i = vam->input;
13063 vl_api_l2tpv3_set_lookup_key_t *mp;
13067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13069 if (unformat (i, "lookup_v6_src"))
13070 key = L2T_LOOKUP_SRC_ADDRESS;
13071 else if (unformat (i, "lookup_v6_dst"))
13072 key = L2T_LOOKUP_DST_ADDRESS;
13073 else if (unformat (i, "lookup_session_id"))
13074 key = L2T_LOOKUP_SESSION_ID;
13079 if (key == (u8) ~ 0)
13081 errmsg ("l2tp session lookup key unset");
13085 M (L2TPV3_SET_LOOKUP_KEY, mp);
13094 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
13095 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13097 vat_main_t *vam = &vat_main;
13099 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
13100 format_ip6_address, mp->our_address,
13101 format_ip6_address, mp->client_address,
13102 clib_net_to_host_u32 (mp->sw_if_index));
13105 " local cookies %016llx %016llx remote cookie %016llx",
13106 clib_net_to_host_u64 (mp->local_cookie[0]),
13107 clib_net_to_host_u64 (mp->local_cookie[1]),
13108 clib_net_to_host_u64 (mp->remote_cookie));
13110 print (vam->ofp, " local session-id %d remote session-id %d",
13111 clib_net_to_host_u32 (mp->local_session_id),
13112 clib_net_to_host_u32 (mp->remote_session_id));
13114 print (vam->ofp, " l2 specific sublayer %s\n",
13115 mp->l2_sublayer_present ? "preset" : "absent");
13119 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
13120 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13122 vat_main_t *vam = &vat_main;
13123 vat_json_node_t *node = NULL;
13124 struct in6_addr addr;
13126 if (VAT_JSON_ARRAY != vam->json_tree.type)
13128 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13129 vat_json_init_array (&vam->json_tree);
13131 node = vat_json_array_add (&vam->json_tree);
13133 vat_json_init_object (node);
13135 clib_memcpy (&addr, mp->our_address, sizeof (addr));
13136 vat_json_object_add_ip6 (node, "our_address", addr);
13137 clib_memcpy (&addr, mp->client_address, sizeof (addr));
13138 vat_json_object_add_ip6 (node, "client_address", addr);
13140 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
13141 vat_json_init_array (lc);
13142 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
13143 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
13144 vat_json_object_add_uint (node, "remote_cookie",
13145 clib_net_to_host_u64 (mp->remote_cookie));
13147 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
13148 vat_json_object_add_uint (node, "local_session_id",
13149 clib_net_to_host_u32 (mp->local_session_id));
13150 vat_json_object_add_uint (node, "remote_session_id",
13151 clib_net_to_host_u32 (mp->remote_session_id));
13152 vat_json_object_add_string_copy (node, "l2_sublayer",
13153 mp->l2_sublayer_present ? (u8 *) "present"
13154 : (u8 *) "absent");
13158 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
13160 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
13161 vl_api_control_ping_t *mp_ping;
13164 /* Get list of l2tpv3-tunnel interfaces */
13165 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
13168 /* Use a control ping for synchronization */
13169 MPING (CONTROL_PING, mp_ping);
13177 static void vl_api_sw_interface_tap_details_t_handler
13178 (vl_api_sw_interface_tap_details_t * mp)
13180 vat_main_t *vam = &vat_main;
13182 print (vam->ofp, "%-16s %d",
13183 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
13186 static void vl_api_sw_interface_tap_details_t_handler_json
13187 (vl_api_sw_interface_tap_details_t * mp)
13189 vat_main_t *vam = &vat_main;
13190 vat_json_node_t *node = NULL;
13192 if (VAT_JSON_ARRAY != vam->json_tree.type)
13194 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13195 vat_json_init_array (&vam->json_tree);
13197 node = vat_json_array_add (&vam->json_tree);
13199 vat_json_init_object (node);
13200 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13201 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13205 api_sw_interface_tap_dump (vat_main_t * vam)
13207 vl_api_sw_interface_tap_dump_t *mp;
13208 vl_api_control_ping_t *mp_ping;
13211 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
13212 /* Get list of tap interfaces */
13213 M (SW_INTERFACE_TAP_DUMP, mp);
13216 /* Use a control ping for synchronization */
13217 MPING (CONTROL_PING, mp_ping);
13224 static void vl_api_sw_interface_tap_v2_details_t_handler
13225 (vl_api_sw_interface_tap_v2_details_t * mp)
13227 vat_main_t *vam = &vat_main;
13229 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
13230 mp->host_ip4_prefix_len);
13231 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
13232 mp->host_ip6_prefix_len);
13235 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
13236 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
13237 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
13238 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
13239 mp->host_bridge, ip4, ip6);
13245 static void vl_api_sw_interface_tap_v2_details_t_handler_json
13246 (vl_api_sw_interface_tap_v2_details_t * mp)
13248 vat_main_t *vam = &vat_main;
13249 vat_json_node_t *node = NULL;
13251 if (VAT_JSON_ARRAY != vam->json_tree.type)
13253 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13254 vat_json_init_array (&vam->json_tree);
13256 node = vat_json_array_add (&vam->json_tree);
13258 vat_json_init_object (node);
13259 vat_json_object_add_uint (node, "id", ntohl (mp->id));
13260 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13261 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13262 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
13263 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
13264 vat_json_object_add_string_copy (node, "host_mac_addr",
13265 format (0, "%U", format_ethernet_address,
13266 &mp->host_mac_addr));
13267 vat_json_object_add_string_copy (node, "host_namespace",
13268 mp->host_namespace);
13269 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
13270 vat_json_object_add_string_copy (node, "host_ip4_addr",
13271 format (0, "%U/%d", format_ip4_address,
13273 mp->host_ip4_prefix_len));
13274 vat_json_object_add_string_copy (node, "host_ip6_addr",
13275 format (0, "%U/%d", format_ip6_address,
13277 mp->host_ip6_prefix_len));
13282 api_sw_interface_tap_v2_dump (vat_main_t * vam)
13284 vl_api_sw_interface_tap_v2_dump_t *mp;
13285 vl_api_control_ping_t *mp_ping;
13289 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
13290 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
13291 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
13294 /* Get list of tap interfaces */
13295 M (SW_INTERFACE_TAP_V2_DUMP, mp);
13298 /* Use a control ping for synchronization */
13299 MPING (CONTROL_PING, mp_ping);
13307 api_vxlan_offload_rx (vat_main_t * vam)
13309 unformat_input_t *line_input = vam->input;
13310 vl_api_vxlan_offload_rx_t *mp;
13311 u32 hw_if_index = ~0, rx_if_index = ~0;
13315 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13317 if (unformat (line_input, "del"))
13319 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
13322 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
13324 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
13327 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
13331 errmsg ("parse error '%U'", format_unformat_error, line_input);
13336 if (hw_if_index == ~0)
13338 errmsg ("no hw interface");
13342 if (rx_if_index == ~0)
13344 errmsg ("no rx tunnel");
13348 M (VXLAN_OFFLOAD_RX, mp);
13350 mp->hw_if_index = ntohl (hw_if_index);
13351 mp->sw_if_index = ntohl (rx_if_index);
13352 mp->enable = is_add;
13359 static uword unformat_vxlan_decap_next
13360 (unformat_input_t * input, va_list * args)
13362 u32 *result = va_arg (*args, u32 *);
13365 if (unformat (input, "l2"))
13366 *result = VXLAN_INPUT_NEXT_L2_INPUT;
13367 else if (unformat (input, "%d", &tmp))
13375 api_vxlan_add_del_tunnel (vat_main_t * vam)
13377 unformat_input_t *line_input = vam->input;
13378 vl_api_vxlan_add_del_tunnel_t *mp;
13379 ip46_address_t src, dst;
13381 u8 ipv4_set = 0, ipv6_set = 0;
13386 u32 mcast_sw_if_index = ~0;
13387 u32 encap_vrf_id = 0;
13388 u32 decap_next_index = ~0;
13392 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13393 clib_memset (&src, 0, sizeof src);
13394 clib_memset (&dst, 0, sizeof dst);
13396 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13398 if (unformat (line_input, "del"))
13400 else if (unformat (line_input, "instance %d", &instance))
13403 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13409 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13415 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13421 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13426 else if (unformat (line_input, "group %U %U",
13427 unformat_ip4_address, &dst.ip4,
13428 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13430 grp_set = dst_set = 1;
13433 else if (unformat (line_input, "group %U",
13434 unformat_ip4_address, &dst.ip4))
13436 grp_set = dst_set = 1;
13439 else if (unformat (line_input, "group %U %U",
13440 unformat_ip6_address, &dst.ip6,
13441 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13443 grp_set = dst_set = 1;
13446 else if (unformat (line_input, "group %U",
13447 unformat_ip6_address, &dst.ip6))
13449 grp_set = dst_set = 1;
13453 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13455 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13457 else if (unformat (line_input, "decap-next %U",
13458 unformat_vxlan_decap_next, &decap_next_index))
13460 else if (unformat (line_input, "vni %d", &vni))
13464 errmsg ("parse error '%U'", format_unformat_error, line_input);
13471 errmsg ("tunnel src address not specified");
13476 errmsg ("tunnel dst address not specified");
13480 if (grp_set && !ip46_address_is_multicast (&dst))
13482 errmsg ("tunnel group address not multicast");
13485 if (grp_set && mcast_sw_if_index == ~0)
13487 errmsg ("tunnel nonexistent multicast device");
13490 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13492 errmsg ("tunnel dst address must be unicast");
13497 if (ipv4_set && ipv6_set)
13499 errmsg ("both IPv4 and IPv6 addresses specified");
13503 if ((vni == 0) || (vni >> 24))
13505 errmsg ("vni not specified or out of range");
13509 M (VXLAN_ADD_DEL_TUNNEL, mp);
13513 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13514 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13518 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13519 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13522 mp->instance = htonl (instance);
13523 mp->encap_vrf_id = ntohl (encap_vrf_id);
13524 mp->decap_next_index = ntohl (decap_next_index);
13525 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13526 mp->vni = ntohl (vni);
13527 mp->is_add = is_add;
13528 mp->is_ipv6 = ipv6_set;
13535 static void vl_api_vxlan_tunnel_details_t_handler
13536 (vl_api_vxlan_tunnel_details_t * mp)
13538 vat_main_t *vam = &vat_main;
13539 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13540 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13542 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13543 ntohl (mp->sw_if_index),
13544 ntohl (mp->instance),
13545 format_ip46_address, &src, IP46_TYPE_ANY,
13546 format_ip46_address, &dst, IP46_TYPE_ANY,
13547 ntohl (mp->encap_vrf_id),
13548 ntohl (mp->decap_next_index), ntohl (mp->vni),
13549 ntohl (mp->mcast_sw_if_index));
13552 static void vl_api_vxlan_tunnel_details_t_handler_json
13553 (vl_api_vxlan_tunnel_details_t * mp)
13555 vat_main_t *vam = &vat_main;
13556 vat_json_node_t *node = NULL;
13558 if (VAT_JSON_ARRAY != vam->json_tree.type)
13560 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13561 vat_json_init_array (&vam->json_tree);
13563 node = vat_json_array_add (&vam->json_tree);
13565 vat_json_init_object (node);
13566 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13568 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13572 struct in6_addr ip6;
13574 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13575 vat_json_object_add_ip6 (node, "src_address", ip6);
13576 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13577 vat_json_object_add_ip6 (node, "dst_address", ip6);
13581 struct in_addr ip4;
13583 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13584 vat_json_object_add_ip4 (node, "src_address", ip4);
13585 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13586 vat_json_object_add_ip4 (node, "dst_address", ip4);
13588 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13589 vat_json_object_add_uint (node, "decap_next_index",
13590 ntohl (mp->decap_next_index));
13591 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13592 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13593 vat_json_object_add_uint (node, "mcast_sw_if_index",
13594 ntohl (mp->mcast_sw_if_index));
13598 api_vxlan_tunnel_dump (vat_main_t * vam)
13600 unformat_input_t *i = vam->input;
13601 vl_api_vxlan_tunnel_dump_t *mp;
13602 vl_api_control_ping_t *mp_ping;
13604 u8 sw_if_index_set = 0;
13607 /* Parse args required to build the message */
13608 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13610 if (unformat (i, "sw_if_index %d", &sw_if_index))
13611 sw_if_index_set = 1;
13616 if (sw_if_index_set == 0)
13621 if (!vam->json_output)
13623 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13624 "sw_if_index", "instance", "src_address", "dst_address",
13625 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13628 /* Get list of vxlan-tunnel interfaces */
13629 M (VXLAN_TUNNEL_DUMP, mp);
13631 mp->sw_if_index = htonl (sw_if_index);
13635 /* Use a control ping for synchronization */
13636 MPING (CONTROL_PING, mp_ping);
13643 static uword unformat_geneve_decap_next
13644 (unformat_input_t * input, va_list * args)
13646 u32 *result = va_arg (*args, u32 *);
13649 if (unformat (input, "l2"))
13650 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13651 else if (unformat (input, "%d", &tmp))
13659 api_geneve_add_del_tunnel (vat_main_t * vam)
13661 unformat_input_t *line_input = vam->input;
13662 vl_api_geneve_add_del_tunnel_t *mp;
13663 ip46_address_t src, dst;
13665 u8 ipv4_set = 0, ipv6_set = 0;
13669 u32 mcast_sw_if_index = ~0;
13670 u32 encap_vrf_id = 0;
13671 u32 decap_next_index = ~0;
13675 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13676 clib_memset (&src, 0, sizeof src);
13677 clib_memset (&dst, 0, sizeof dst);
13679 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13681 if (unformat (line_input, "del"))
13684 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13690 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13696 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13702 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13707 else if (unformat (line_input, "group %U %U",
13708 unformat_ip4_address, &dst.ip4,
13709 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13711 grp_set = dst_set = 1;
13714 else if (unformat (line_input, "group %U",
13715 unformat_ip4_address, &dst.ip4))
13717 grp_set = dst_set = 1;
13720 else if (unformat (line_input, "group %U %U",
13721 unformat_ip6_address, &dst.ip6,
13722 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13724 grp_set = dst_set = 1;
13727 else if (unformat (line_input, "group %U",
13728 unformat_ip6_address, &dst.ip6))
13730 grp_set = dst_set = 1;
13734 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13736 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13738 else if (unformat (line_input, "decap-next %U",
13739 unformat_geneve_decap_next, &decap_next_index))
13741 else if (unformat (line_input, "vni %d", &vni))
13745 errmsg ("parse error '%U'", format_unformat_error, line_input);
13752 errmsg ("tunnel src address not specified");
13757 errmsg ("tunnel dst address not specified");
13761 if (grp_set && !ip46_address_is_multicast (&dst))
13763 errmsg ("tunnel group address not multicast");
13766 if (grp_set && mcast_sw_if_index == ~0)
13768 errmsg ("tunnel nonexistent multicast device");
13771 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13773 errmsg ("tunnel dst address must be unicast");
13778 if (ipv4_set && ipv6_set)
13780 errmsg ("both IPv4 and IPv6 addresses specified");
13784 if ((vni == 0) || (vni >> 24))
13786 errmsg ("vni not specified or out of range");
13790 M (GENEVE_ADD_DEL_TUNNEL, mp);
13794 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13795 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13799 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13800 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13802 mp->encap_vrf_id = ntohl (encap_vrf_id);
13803 mp->decap_next_index = ntohl (decap_next_index);
13804 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13805 mp->vni = ntohl (vni);
13806 mp->is_add = is_add;
13807 mp->is_ipv6 = ipv6_set;
13814 static void vl_api_geneve_tunnel_details_t_handler
13815 (vl_api_geneve_tunnel_details_t * mp)
13817 vat_main_t *vam = &vat_main;
13818 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13819 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13821 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13822 ntohl (mp->sw_if_index),
13823 format_ip46_address, &src, IP46_TYPE_ANY,
13824 format_ip46_address, &dst, IP46_TYPE_ANY,
13825 ntohl (mp->encap_vrf_id),
13826 ntohl (mp->decap_next_index), ntohl (mp->vni),
13827 ntohl (mp->mcast_sw_if_index));
13830 static void vl_api_geneve_tunnel_details_t_handler_json
13831 (vl_api_geneve_tunnel_details_t * mp)
13833 vat_main_t *vam = &vat_main;
13834 vat_json_node_t *node = NULL;
13836 if (VAT_JSON_ARRAY != vam->json_tree.type)
13838 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13839 vat_json_init_array (&vam->json_tree);
13841 node = vat_json_array_add (&vam->json_tree);
13843 vat_json_init_object (node);
13844 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13847 struct in6_addr ip6;
13849 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13850 vat_json_object_add_ip6 (node, "src_address", ip6);
13851 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13852 vat_json_object_add_ip6 (node, "dst_address", ip6);
13856 struct in_addr ip4;
13858 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13859 vat_json_object_add_ip4 (node, "src_address", ip4);
13860 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13861 vat_json_object_add_ip4 (node, "dst_address", ip4);
13863 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13864 vat_json_object_add_uint (node, "decap_next_index",
13865 ntohl (mp->decap_next_index));
13866 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13867 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13868 vat_json_object_add_uint (node, "mcast_sw_if_index",
13869 ntohl (mp->mcast_sw_if_index));
13873 api_geneve_tunnel_dump (vat_main_t * vam)
13875 unformat_input_t *i = vam->input;
13876 vl_api_geneve_tunnel_dump_t *mp;
13877 vl_api_control_ping_t *mp_ping;
13879 u8 sw_if_index_set = 0;
13882 /* Parse args required to build the message */
13883 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13885 if (unformat (i, "sw_if_index %d", &sw_if_index))
13886 sw_if_index_set = 1;
13891 if (sw_if_index_set == 0)
13896 if (!vam->json_output)
13898 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13899 "sw_if_index", "local_address", "remote_address",
13900 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13903 /* Get list of geneve-tunnel interfaces */
13904 M (GENEVE_TUNNEL_DUMP, mp);
13906 mp->sw_if_index = htonl (sw_if_index);
13910 /* Use a control ping for synchronization */
13911 M (CONTROL_PING, mp_ping);
13919 api_gre_add_del_tunnel (vat_main_t * vam)
13921 unformat_input_t *line_input = vam->input;
13922 vl_api_gre_add_del_tunnel_t *mp;
13923 ip4_address_t src4, dst4;
13924 ip6_address_t src6, dst6;
13928 u8 t_type = GRE_TUNNEL_TYPE_L3;
13931 u32 outer_fib_id = 0;
13932 u32 session_id = 0;
13936 clib_memset (&src4, 0, sizeof src4);
13937 clib_memset (&dst4, 0, sizeof dst4);
13938 clib_memset (&src6, 0, sizeof src6);
13939 clib_memset (&dst6, 0, sizeof dst6);
13941 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13943 if (unformat (line_input, "del"))
13945 else if (unformat (line_input, "instance %d", &instance))
13947 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13952 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13957 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13962 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13967 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13969 else if (unformat (line_input, "teb"))
13970 t_type = GRE_TUNNEL_TYPE_TEB;
13971 else if (unformat (line_input, "erspan %d", &session_id))
13972 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13975 errmsg ("parse error '%U'", format_unformat_error, line_input);
13982 errmsg ("tunnel src address not specified");
13987 errmsg ("tunnel dst address not specified");
13990 if (ipv4_set && ipv6_set)
13992 errmsg ("both IPv4 and IPv6 addresses specified");
13997 M (GRE_ADD_DEL_TUNNEL, mp);
14001 clib_memcpy (&mp->src_address, &src4, 4);
14002 clib_memcpy (&mp->dst_address, &dst4, 4);
14006 clib_memcpy (&mp->src_address, &src6, 16);
14007 clib_memcpy (&mp->dst_address, &dst6, 16);
14009 mp->instance = htonl (instance);
14010 mp->outer_fib_id = htonl (outer_fib_id);
14011 mp->is_add = is_add;
14012 mp->session_id = htons ((u16) session_id);
14013 mp->tunnel_type = t_type;
14014 mp->is_ipv6 = ipv6_set;
14021 static void vl_api_gre_tunnel_details_t_handler
14022 (vl_api_gre_tunnel_details_t * mp)
14024 vat_main_t *vam = &vat_main;
14025 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
14026 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
14028 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
14029 ntohl (mp->sw_if_index),
14030 ntohl (mp->instance),
14031 format_ip46_address, &src, IP46_TYPE_ANY,
14032 format_ip46_address, &dst, IP46_TYPE_ANY,
14033 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
14036 static void vl_api_gre_tunnel_details_t_handler_json
14037 (vl_api_gre_tunnel_details_t * mp)
14039 vat_main_t *vam = &vat_main;
14040 vat_json_node_t *node = NULL;
14041 struct in_addr ip4;
14042 struct in6_addr ip6;
14044 if (VAT_JSON_ARRAY != vam->json_tree.type)
14046 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14047 vat_json_init_array (&vam->json_tree);
14049 node = vat_json_array_add (&vam->json_tree);
14051 vat_json_init_object (node);
14052 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14053 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
14056 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
14057 vat_json_object_add_ip4 (node, "src_address", ip4);
14058 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
14059 vat_json_object_add_ip4 (node, "dst_address", ip4);
14063 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
14064 vat_json_object_add_ip6 (node, "src_address", ip6);
14065 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
14066 vat_json_object_add_ip6 (node, "dst_address", ip6);
14068 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
14069 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
14070 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
14071 vat_json_object_add_uint (node, "session_id", mp->session_id);
14075 api_gre_tunnel_dump (vat_main_t * vam)
14077 unformat_input_t *i = vam->input;
14078 vl_api_gre_tunnel_dump_t *mp;
14079 vl_api_control_ping_t *mp_ping;
14081 u8 sw_if_index_set = 0;
14084 /* Parse args required to build the message */
14085 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14087 if (unformat (i, "sw_if_index %d", &sw_if_index))
14088 sw_if_index_set = 1;
14093 if (sw_if_index_set == 0)
14098 if (!vam->json_output)
14100 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
14101 "sw_if_index", "instance", "src_address", "dst_address",
14102 "tunnel_type", "outer_fib_id", "session_id");
14105 /* Get list of gre-tunnel interfaces */
14106 M (GRE_TUNNEL_DUMP, mp);
14108 mp->sw_if_index = htonl (sw_if_index);
14112 /* Use a control ping for synchronization */
14113 MPING (CONTROL_PING, mp_ping);
14121 api_l2_fib_clear_table (vat_main_t * vam)
14123 // unformat_input_t * i = vam->input;
14124 vl_api_l2_fib_clear_table_t *mp;
14127 M (L2_FIB_CLEAR_TABLE, mp);
14135 api_l2_interface_efp_filter (vat_main_t * vam)
14137 unformat_input_t *i = vam->input;
14138 vl_api_l2_interface_efp_filter_t *mp;
14141 u8 sw_if_index_set = 0;
14144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14146 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14147 sw_if_index_set = 1;
14148 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14149 sw_if_index_set = 1;
14150 else if (unformat (i, "enable"))
14152 else if (unformat (i, "disable"))
14156 clib_warning ("parse error '%U'", format_unformat_error, i);
14161 if (sw_if_index_set == 0)
14163 errmsg ("missing sw_if_index");
14167 M (L2_INTERFACE_EFP_FILTER, mp);
14169 mp->sw_if_index = ntohl (sw_if_index);
14170 mp->enable_disable = enable;
14177 #define foreach_vtr_op \
14178 _("disable", L2_VTR_DISABLED) \
14179 _("push-1", L2_VTR_PUSH_1) \
14180 _("push-2", L2_VTR_PUSH_2) \
14181 _("pop-1", L2_VTR_POP_1) \
14182 _("pop-2", L2_VTR_POP_2) \
14183 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
14184 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
14185 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
14186 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
14189 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
14191 unformat_input_t *i = vam->input;
14192 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
14194 u8 sw_if_index_set = 0;
14197 u32 push_dot1q = 1;
14202 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14204 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14205 sw_if_index_set = 1;
14206 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14207 sw_if_index_set = 1;
14208 else if (unformat (i, "vtr_op %d", &vtr_op))
14210 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
14213 else if (unformat (i, "push_dot1q %d", &push_dot1q))
14215 else if (unformat (i, "tag1 %d", &tag1))
14217 else if (unformat (i, "tag2 %d", &tag2))
14221 clib_warning ("parse error '%U'", format_unformat_error, i);
14226 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
14228 errmsg ("missing vtr operation or sw_if_index");
14232 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
14233 mp->sw_if_index = ntohl (sw_if_index);
14234 mp->vtr_op = ntohl (vtr_op);
14235 mp->push_dot1q = ntohl (push_dot1q);
14236 mp->tag1 = ntohl (tag1);
14237 mp->tag2 = ntohl (tag2);
14245 api_create_vhost_user_if (vat_main_t * vam)
14247 unformat_input_t *i = vam->input;
14248 vl_api_create_vhost_user_if_t *mp;
14251 u8 file_name_set = 0;
14252 u32 custom_dev_instance = ~0;
14254 u8 use_custom_mac = 0;
14255 u8 disable_mrg_rxbuf = 0;
14256 u8 disable_indirect_desc = 0;
14260 /* Shut up coverity */
14261 clib_memset (hwaddr, 0, sizeof (hwaddr));
14263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14265 if (unformat (i, "socket %s", &file_name))
14269 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14271 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
14272 use_custom_mac = 1;
14273 else if (unformat (i, "server"))
14275 else if (unformat (i, "disable_mrg_rxbuf"))
14276 disable_mrg_rxbuf = 1;
14277 else if (unformat (i, "disable_indirect_desc"))
14278 disable_indirect_desc = 1;
14279 else if (unformat (i, "tag %s", &tag))
14285 if (file_name_set == 0)
14287 errmsg ("missing socket file name");
14291 if (vec_len (file_name) > 255)
14293 errmsg ("socket file name too long");
14296 vec_add1 (file_name, 0);
14298 M (CREATE_VHOST_USER_IF, mp);
14300 mp->is_server = is_server;
14301 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
14302 mp->disable_indirect_desc = disable_indirect_desc;
14303 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14304 vec_free (file_name);
14305 if (custom_dev_instance != ~0)
14308 mp->custom_dev_instance = ntohl (custom_dev_instance);
14311 mp->use_custom_mac = use_custom_mac;
14312 clib_memcpy (mp->mac_address, hwaddr, 6);
14314 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
14323 api_modify_vhost_user_if (vat_main_t * vam)
14325 unformat_input_t *i = vam->input;
14326 vl_api_modify_vhost_user_if_t *mp;
14329 u8 file_name_set = 0;
14330 u32 custom_dev_instance = ~0;
14331 u8 sw_if_index_set = 0;
14332 u32 sw_if_index = (u32) ~ 0;
14335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14337 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14338 sw_if_index_set = 1;
14339 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14340 sw_if_index_set = 1;
14341 else if (unformat (i, "socket %s", &file_name))
14345 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14347 else if (unformat (i, "server"))
14353 if (sw_if_index_set == 0)
14355 errmsg ("missing sw_if_index or interface name");
14359 if (file_name_set == 0)
14361 errmsg ("missing socket file name");
14365 if (vec_len (file_name) > 255)
14367 errmsg ("socket file name too long");
14370 vec_add1 (file_name, 0);
14372 M (MODIFY_VHOST_USER_IF, mp);
14374 mp->sw_if_index = ntohl (sw_if_index);
14375 mp->is_server = is_server;
14376 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14377 vec_free (file_name);
14378 if (custom_dev_instance != ~0)
14381 mp->custom_dev_instance = ntohl (custom_dev_instance);
14390 api_delete_vhost_user_if (vat_main_t * vam)
14392 unformat_input_t *i = vam->input;
14393 vl_api_delete_vhost_user_if_t *mp;
14394 u32 sw_if_index = ~0;
14395 u8 sw_if_index_set = 0;
14398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14400 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14401 sw_if_index_set = 1;
14402 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14403 sw_if_index_set = 1;
14408 if (sw_if_index_set == 0)
14410 errmsg ("missing sw_if_index or interface name");
14415 M (DELETE_VHOST_USER_IF, mp);
14417 mp->sw_if_index = ntohl (sw_if_index);
14424 static void vl_api_sw_interface_vhost_user_details_t_handler
14425 (vl_api_sw_interface_vhost_user_details_t * mp)
14427 vat_main_t *vam = &vat_main;
14429 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14430 (char *) mp->interface_name,
14431 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14432 clib_net_to_host_u64 (mp->features), mp->is_server,
14433 ntohl (mp->num_regions), (char *) mp->sock_filename);
14434 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14437 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14438 (vl_api_sw_interface_vhost_user_details_t * mp)
14440 vat_main_t *vam = &vat_main;
14441 vat_json_node_t *node = NULL;
14443 if (VAT_JSON_ARRAY != vam->json_tree.type)
14445 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14446 vat_json_init_array (&vam->json_tree);
14448 node = vat_json_array_add (&vam->json_tree);
14450 vat_json_init_object (node);
14451 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14452 vat_json_object_add_string_copy (node, "interface_name",
14453 mp->interface_name);
14454 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14455 ntohl (mp->virtio_net_hdr_sz));
14456 vat_json_object_add_uint (node, "features",
14457 clib_net_to_host_u64 (mp->features));
14458 vat_json_object_add_uint (node, "is_server", mp->is_server);
14459 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14460 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14461 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14465 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14467 vl_api_sw_interface_vhost_user_dump_t *mp;
14468 vl_api_control_ping_t *mp_ping;
14471 "Interface name idx hdr_sz features server regions filename");
14473 /* Get list of vhost-user interfaces */
14474 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14477 /* Use a control ping for synchronization */
14478 MPING (CONTROL_PING, mp_ping);
14486 api_show_version (vat_main_t * vam)
14488 vl_api_show_version_t *mp;
14491 M (SHOW_VERSION, mp);
14500 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14502 unformat_input_t *line_input = vam->input;
14503 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14504 ip4_address_t local4, remote4;
14505 ip6_address_t local6, remote6;
14507 u8 ipv4_set = 0, ipv6_set = 0;
14511 u32 mcast_sw_if_index = ~0;
14512 u32 encap_vrf_id = 0;
14513 u32 decap_vrf_id = 0;
14519 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14520 clib_memset (&local4, 0, sizeof local4);
14521 clib_memset (&remote4, 0, sizeof remote4);
14522 clib_memset (&local6, 0, sizeof local6);
14523 clib_memset (&remote6, 0, sizeof remote6);
14525 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14527 if (unformat (line_input, "del"))
14529 else if (unformat (line_input, "local %U",
14530 unformat_ip4_address, &local4))
14535 else if (unformat (line_input, "remote %U",
14536 unformat_ip4_address, &remote4))
14541 else if (unformat (line_input, "local %U",
14542 unformat_ip6_address, &local6))
14547 else if (unformat (line_input, "remote %U",
14548 unformat_ip6_address, &remote6))
14553 else if (unformat (line_input, "group %U %U",
14554 unformat_ip4_address, &remote4,
14555 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14557 grp_set = remote_set = 1;
14560 else if (unformat (line_input, "group %U",
14561 unformat_ip4_address, &remote4))
14563 grp_set = remote_set = 1;
14566 else if (unformat (line_input, "group %U %U",
14567 unformat_ip6_address, &remote6,
14568 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14570 grp_set = remote_set = 1;
14573 else if (unformat (line_input, "group %U",
14574 unformat_ip6_address, &remote6))
14576 grp_set = remote_set = 1;
14580 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14582 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14584 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14586 else if (unformat (line_input, "vni %d", &vni))
14588 else if (unformat (line_input, "next-ip4"))
14590 else if (unformat (line_input, "next-ip6"))
14592 else if (unformat (line_input, "next-ethernet"))
14594 else if (unformat (line_input, "next-nsh"))
14598 errmsg ("parse error '%U'", format_unformat_error, line_input);
14603 if (local_set == 0)
14605 errmsg ("tunnel local address not specified");
14608 if (remote_set == 0)
14610 errmsg ("tunnel remote address not specified");
14613 if (grp_set && mcast_sw_if_index == ~0)
14615 errmsg ("tunnel nonexistent multicast device");
14618 if (ipv4_set && ipv6_set)
14620 errmsg ("both IPv4 and IPv6 addresses specified");
14626 errmsg ("vni not specified");
14630 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14635 clib_memcpy (&mp->local, &local6, sizeof (local6));
14636 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14640 clib_memcpy (&mp->local, &local4, sizeof (local4));
14641 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14644 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14645 mp->encap_vrf_id = ntohl (encap_vrf_id);
14646 mp->decap_vrf_id = ntohl (decap_vrf_id);
14647 mp->protocol = protocol;
14648 mp->vni = ntohl (vni);
14649 mp->is_add = is_add;
14650 mp->is_ipv6 = ipv6_set;
14657 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14658 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14660 vat_main_t *vam = &vat_main;
14661 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14662 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14664 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14665 ntohl (mp->sw_if_index),
14666 format_ip46_address, &local, IP46_TYPE_ANY,
14667 format_ip46_address, &remote, IP46_TYPE_ANY,
14668 ntohl (mp->vni), mp->protocol,
14669 ntohl (mp->mcast_sw_if_index),
14670 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14674 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14675 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14677 vat_main_t *vam = &vat_main;
14678 vat_json_node_t *node = NULL;
14679 struct in_addr ip4;
14680 struct in6_addr ip6;
14682 if (VAT_JSON_ARRAY != vam->json_tree.type)
14684 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14685 vat_json_init_array (&vam->json_tree);
14687 node = vat_json_array_add (&vam->json_tree);
14689 vat_json_init_object (node);
14690 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14693 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14694 vat_json_object_add_ip6 (node, "local", ip6);
14695 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14696 vat_json_object_add_ip6 (node, "remote", ip6);
14700 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14701 vat_json_object_add_ip4 (node, "local", ip4);
14702 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14703 vat_json_object_add_ip4 (node, "remote", ip4);
14705 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14706 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14707 vat_json_object_add_uint (node, "mcast_sw_if_index",
14708 ntohl (mp->mcast_sw_if_index));
14709 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14710 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14711 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14715 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14717 unformat_input_t *i = vam->input;
14718 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14719 vl_api_control_ping_t *mp_ping;
14721 u8 sw_if_index_set = 0;
14724 /* Parse args required to build the message */
14725 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14727 if (unformat (i, "sw_if_index %d", &sw_if_index))
14728 sw_if_index_set = 1;
14733 if (sw_if_index_set == 0)
14738 if (!vam->json_output)
14740 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14741 "sw_if_index", "local", "remote", "vni",
14742 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14745 /* Get list of vxlan-tunnel interfaces */
14746 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14748 mp->sw_if_index = htonl (sw_if_index);
14752 /* Use a control ping for synchronization */
14753 MPING (CONTROL_PING, mp_ping);
14760 static void vl_api_l2_fib_table_details_t_handler
14761 (vl_api_l2_fib_table_details_t * mp)
14763 vat_main_t *vam = &vat_main;
14765 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14767 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14768 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14772 static void vl_api_l2_fib_table_details_t_handler_json
14773 (vl_api_l2_fib_table_details_t * mp)
14775 vat_main_t *vam = &vat_main;
14776 vat_json_node_t *node = NULL;
14778 if (VAT_JSON_ARRAY != vam->json_tree.type)
14780 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14781 vat_json_init_array (&vam->json_tree);
14783 node = vat_json_array_add (&vam->json_tree);
14785 vat_json_init_object (node);
14786 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14787 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14788 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14789 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14790 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14791 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14795 api_l2_fib_table_dump (vat_main_t * vam)
14797 unformat_input_t *i = vam->input;
14798 vl_api_l2_fib_table_dump_t *mp;
14799 vl_api_control_ping_t *mp_ping;
14804 /* Parse args required to build the message */
14805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14807 if (unformat (i, "bd_id %d", &bd_id))
14813 if (bd_id_set == 0)
14815 errmsg ("missing bridge domain");
14819 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14821 /* Get list of l2 fib entries */
14822 M (L2_FIB_TABLE_DUMP, mp);
14824 mp->bd_id = ntohl (bd_id);
14827 /* Use a control ping for synchronization */
14828 MPING (CONTROL_PING, mp_ping);
14837 api_interface_name_renumber (vat_main_t * vam)
14839 unformat_input_t *line_input = vam->input;
14840 vl_api_interface_name_renumber_t *mp;
14841 u32 sw_if_index = ~0;
14842 u32 new_show_dev_instance = ~0;
14845 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14847 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14850 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14852 else if (unformat (line_input, "new_show_dev_instance %d",
14853 &new_show_dev_instance))
14859 if (sw_if_index == ~0)
14861 errmsg ("missing interface name or sw_if_index");
14865 if (new_show_dev_instance == ~0)
14867 errmsg ("missing new_show_dev_instance");
14871 M (INTERFACE_NAME_RENUMBER, mp);
14873 mp->sw_if_index = ntohl (sw_if_index);
14874 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14882 api_ip_probe_neighbor (vat_main_t * vam)
14884 unformat_input_t *i = vam->input;
14885 vl_api_ip_probe_neighbor_t *mp;
14893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14895 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14897 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14899 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14901 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14912 errmsg ("missing interface");
14918 errmsg ("missing addresses");
14922 M (IP_PROBE_NEIGHBOR, mp);
14924 mp->sw_if_index = ntohl (sw_if_index);
14925 mp->is_ipv6 = is_ipv6;
14926 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14934 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14936 unformat_input_t *i = vam->input;
14937 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14938 u8 mode = IP_SCAN_V46_NEIGHBORS;
14939 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14944 if (unformat (i, "ip4"))
14945 mode = IP_SCAN_V4_NEIGHBORS;
14946 else if (unformat (i, "ip6"))
14947 mode = IP_SCAN_V6_NEIGHBORS;
14948 if (unformat (i, "both"))
14949 mode = IP_SCAN_V46_NEIGHBORS;
14950 else if (unformat (i, "disable"))
14951 mode = IP_SCAN_DISABLED;
14952 else if (unformat (i, "interval %d", &interval))
14954 else if (unformat (i, "max-time %d", &time))
14956 else if (unformat (i, "max-update %d", &update))
14958 else if (unformat (i, "delay %d", &delay))
14960 else if (unformat (i, "stale %d", &stale))
14966 if (interval > 255)
14968 errmsg ("interval cannot exceed 255 minutes.");
14973 errmsg ("max-time cannot exceed 255 usec.");
14978 errmsg ("max-update cannot exceed 255.");
14983 errmsg ("delay cannot exceed 255 msec.");
14988 errmsg ("stale cannot exceed 255 minutes.");
14992 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14994 mp->scan_interval = interval;
14995 mp->max_proc_time = time;
14996 mp->max_update = update;
14997 mp->scan_int_delay = delay;
14998 mp->stale_threshold = stale;
15006 api_want_ip4_arp_events (vat_main_t * vam)
15008 unformat_input_t *line_input = vam->input;
15009 vl_api_want_ip4_arp_events_t *mp;
15010 ip4_address_t address;
15011 int address_set = 0;
15012 u32 enable_disable = 1;
15015 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15017 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
15019 else if (unformat (line_input, "del"))
15020 enable_disable = 0;
15025 if (address_set == 0)
15027 errmsg ("missing addresses");
15031 M (WANT_IP4_ARP_EVENTS, mp);
15032 mp->enable_disable = enable_disable;
15033 mp->pid = htonl (getpid ());
15034 mp->address = address.as_u32;
15042 api_want_ip6_nd_events (vat_main_t * vam)
15044 unformat_input_t *line_input = vam->input;
15045 vl_api_want_ip6_nd_events_t *mp;
15046 ip6_address_t address;
15047 int address_set = 0;
15048 u32 enable_disable = 1;
15051 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15053 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
15055 else if (unformat (line_input, "del"))
15056 enable_disable = 0;
15061 if (address_set == 0)
15063 errmsg ("missing addresses");
15067 M (WANT_IP6_ND_EVENTS, mp);
15068 mp->enable_disable = enable_disable;
15069 mp->pid = htonl (getpid ());
15070 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
15078 api_want_l2_macs_events (vat_main_t * vam)
15080 unformat_input_t *line_input = vam->input;
15081 vl_api_want_l2_macs_events_t *mp;
15082 u8 enable_disable = 1;
15083 u32 scan_delay = 0;
15084 u32 max_macs_in_event = 0;
15085 u32 learn_limit = 0;
15088 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15090 if (unformat (line_input, "learn-limit %d", &learn_limit))
15092 else if (unformat (line_input, "scan-delay %d", &scan_delay))
15094 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
15096 else if (unformat (line_input, "disable"))
15097 enable_disable = 0;
15102 M (WANT_L2_MACS_EVENTS, mp);
15103 mp->enable_disable = enable_disable;
15104 mp->pid = htonl (getpid ());
15105 mp->learn_limit = htonl (learn_limit);
15106 mp->scan_delay = (u8) scan_delay;
15107 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
15114 api_input_acl_set_interface (vat_main_t * vam)
15116 unformat_input_t *i = vam->input;
15117 vl_api_input_acl_set_interface_t *mp;
15119 int sw_if_index_set;
15120 u32 ip4_table_index = ~0;
15121 u32 ip6_table_index = ~0;
15122 u32 l2_table_index = ~0;
15126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15128 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15129 sw_if_index_set = 1;
15130 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15131 sw_if_index_set = 1;
15132 else if (unformat (i, "del"))
15134 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15136 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15138 else if (unformat (i, "l2-table %d", &l2_table_index))
15142 clib_warning ("parse error '%U'", format_unformat_error, i);
15147 if (sw_if_index_set == 0)
15149 errmsg ("missing interface name or sw_if_index");
15153 M (INPUT_ACL_SET_INTERFACE, mp);
15155 mp->sw_if_index = ntohl (sw_if_index);
15156 mp->ip4_table_index = ntohl (ip4_table_index);
15157 mp->ip6_table_index = ntohl (ip6_table_index);
15158 mp->l2_table_index = ntohl (l2_table_index);
15159 mp->is_add = is_add;
15167 api_output_acl_set_interface (vat_main_t * vam)
15169 unformat_input_t *i = vam->input;
15170 vl_api_output_acl_set_interface_t *mp;
15172 int sw_if_index_set;
15173 u32 ip4_table_index = ~0;
15174 u32 ip6_table_index = ~0;
15175 u32 l2_table_index = ~0;
15179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15181 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15182 sw_if_index_set = 1;
15183 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15184 sw_if_index_set = 1;
15185 else if (unformat (i, "del"))
15187 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15189 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15191 else if (unformat (i, "l2-table %d", &l2_table_index))
15195 clib_warning ("parse error '%U'", format_unformat_error, i);
15200 if (sw_if_index_set == 0)
15202 errmsg ("missing interface name or sw_if_index");
15206 M (OUTPUT_ACL_SET_INTERFACE, mp);
15208 mp->sw_if_index = ntohl (sw_if_index);
15209 mp->ip4_table_index = ntohl (ip4_table_index);
15210 mp->ip6_table_index = ntohl (ip6_table_index);
15211 mp->l2_table_index = ntohl (l2_table_index);
15212 mp->is_add = is_add;
15220 api_ip_address_dump (vat_main_t * vam)
15222 unformat_input_t *i = vam->input;
15223 vl_api_ip_address_dump_t *mp;
15224 vl_api_control_ping_t *mp_ping;
15225 u32 sw_if_index = ~0;
15226 u8 sw_if_index_set = 0;
15231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15233 if (unformat (i, "sw_if_index %d", &sw_if_index))
15234 sw_if_index_set = 1;
15236 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15237 sw_if_index_set = 1;
15238 else if (unformat (i, "ipv4"))
15240 else if (unformat (i, "ipv6"))
15246 if (ipv4_set && ipv6_set)
15248 errmsg ("ipv4 and ipv6 flags cannot be both set");
15252 if ((!ipv4_set) && (!ipv6_set))
15254 errmsg ("no ipv4 nor ipv6 flag set");
15258 if (sw_if_index_set == 0)
15260 errmsg ("missing interface name or sw_if_index");
15264 vam->current_sw_if_index = sw_if_index;
15265 vam->is_ipv6 = ipv6_set;
15267 M (IP_ADDRESS_DUMP, mp);
15268 mp->sw_if_index = ntohl (sw_if_index);
15269 mp->is_ipv6 = ipv6_set;
15272 /* Use a control ping for synchronization */
15273 MPING (CONTROL_PING, mp_ping);
15281 api_ip_dump (vat_main_t * vam)
15283 vl_api_ip_dump_t *mp;
15284 vl_api_control_ping_t *mp_ping;
15285 unformat_input_t *in = vam->input;
15292 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
15294 if (unformat (in, "ipv4"))
15296 else if (unformat (in, "ipv6"))
15302 if (ipv4_set && ipv6_set)
15304 errmsg ("ipv4 and ipv6 flags cannot be both set");
15308 if ((!ipv4_set) && (!ipv6_set))
15310 errmsg ("no ipv4 nor ipv6 flag set");
15314 is_ipv6 = ipv6_set;
15315 vam->is_ipv6 = is_ipv6;
15317 /* free old data */
15318 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
15320 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
15322 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
15325 mp->is_ipv6 = ipv6_set;
15328 /* Use a control ping for synchronization */
15329 MPING (CONTROL_PING, mp_ping);
15337 api_ipsec_spd_add_del (vat_main_t * vam)
15339 unformat_input_t *i = vam->input;
15340 vl_api_ipsec_spd_add_del_t *mp;
15345 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15347 if (unformat (i, "spd_id %d", &spd_id))
15349 else if (unformat (i, "del"))
15353 clib_warning ("parse error '%U'", format_unformat_error, i);
15359 errmsg ("spd_id must be set");
15363 M (IPSEC_SPD_ADD_DEL, mp);
15365 mp->spd_id = ntohl (spd_id);
15366 mp->is_add = is_add;
15374 api_ipsec_interface_add_del_spd (vat_main_t * vam)
15376 unformat_input_t *i = vam->input;
15377 vl_api_ipsec_interface_add_del_spd_t *mp;
15379 u8 sw_if_index_set = 0;
15380 u32 spd_id = (u32) ~ 0;
15384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15386 if (unformat (i, "del"))
15388 else if (unformat (i, "spd_id %d", &spd_id))
15391 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15392 sw_if_index_set = 1;
15393 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15394 sw_if_index_set = 1;
15397 clib_warning ("parse error '%U'", format_unformat_error, i);
15403 if (spd_id == (u32) ~ 0)
15405 errmsg ("spd_id must be set");
15409 if (sw_if_index_set == 0)
15411 errmsg ("missing interface name or sw_if_index");
15415 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15417 mp->spd_id = ntohl (spd_id);
15418 mp->sw_if_index = ntohl (sw_if_index);
15419 mp->is_add = is_add;
15427 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15429 unformat_input_t *i = vam->input;
15430 vl_api_ipsec_spd_add_del_entry_t *mp;
15431 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15432 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15434 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15435 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15436 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15437 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15440 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15441 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15442 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15443 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15444 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15445 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15449 if (unformat (i, "del"))
15451 if (unformat (i, "outbound"))
15453 if (unformat (i, "inbound"))
15455 else if (unformat (i, "spd_id %d", &spd_id))
15457 else if (unformat (i, "sa_id %d", &sa_id))
15459 else if (unformat (i, "priority %d", &priority))
15461 else if (unformat (i, "protocol %d", &protocol))
15463 else if (unformat (i, "lport_start %d", &lport_start))
15465 else if (unformat (i, "lport_stop %d", &lport_stop))
15467 else if (unformat (i, "rport_start %d", &rport_start))
15469 else if (unformat (i, "rport_stop %d", &rport_stop))
15473 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15479 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15486 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15492 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15499 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15505 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15512 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15518 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15524 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15526 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15528 clib_warning ("unsupported action: 'resolve'");
15534 clib_warning ("parse error '%U'", format_unformat_error, i);
15540 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15542 mp->spd_id = ntohl (spd_id);
15543 mp->priority = ntohl (priority);
15544 mp->is_outbound = is_outbound;
15546 mp->is_ipv6 = is_ipv6;
15547 if (is_ipv6 || is_ip_any)
15549 clib_memcpy (mp->remote_address_start, &raddr6_start,
15550 sizeof (ip6_address_t));
15551 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15552 sizeof (ip6_address_t));
15553 clib_memcpy (mp->local_address_start, &laddr6_start,
15554 sizeof (ip6_address_t));
15555 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15556 sizeof (ip6_address_t));
15560 clib_memcpy (mp->remote_address_start, &raddr4_start,
15561 sizeof (ip4_address_t));
15562 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15563 sizeof (ip4_address_t));
15564 clib_memcpy (mp->local_address_start, &laddr4_start,
15565 sizeof (ip4_address_t));
15566 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15567 sizeof (ip4_address_t));
15569 mp->protocol = (u8) protocol;
15570 mp->local_port_start = ntohs ((u16) lport_start);
15571 mp->local_port_stop = ntohs ((u16) lport_stop);
15572 mp->remote_port_start = ntohs ((u16) rport_start);
15573 mp->remote_port_stop = ntohs ((u16) rport_stop);
15574 mp->policy = (u8) policy;
15575 mp->sa_id = ntohl (sa_id);
15576 mp->is_add = is_add;
15577 mp->is_ip_any = is_ip_any;
15584 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15586 unformat_input_t *i = vam->input;
15587 vl_api_ipsec_sad_add_del_entry_t *mp;
15588 u32 sad_id = 0, spi = 0;
15589 u8 *ck = 0, *ik = 0;
15592 u8 protocol = IPSEC_PROTOCOL_AH;
15593 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15594 u32 crypto_alg = 0, integ_alg = 0;
15595 ip4_address_t tun_src4;
15596 ip4_address_t tun_dst4;
15597 ip6_address_t tun_src6;
15598 ip6_address_t tun_dst6;
15601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15603 if (unformat (i, "del"))
15605 else if (unformat (i, "sad_id %d", &sad_id))
15607 else if (unformat (i, "spi %d", &spi))
15609 else if (unformat (i, "esp"))
15610 protocol = IPSEC_PROTOCOL_ESP;
15611 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15614 is_tunnel_ipv6 = 0;
15616 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15619 is_tunnel_ipv6 = 0;
15621 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15624 is_tunnel_ipv6 = 1;
15626 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15629 is_tunnel_ipv6 = 1;
15633 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15635 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15637 clib_warning ("unsupported crypto-alg: '%U'",
15638 format_ipsec_crypto_alg, crypto_alg);
15642 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15646 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15648 if (integ_alg >= IPSEC_INTEG_N_ALG)
15650 clib_warning ("unsupported integ-alg: '%U'",
15651 format_ipsec_integ_alg, integ_alg);
15655 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15659 clib_warning ("parse error '%U'", format_unformat_error, i);
15665 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15667 mp->sad_id = ntohl (sad_id);
15668 mp->is_add = is_add;
15669 mp->protocol = protocol;
15670 mp->spi = ntohl (spi);
15671 mp->is_tunnel = is_tunnel;
15672 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15673 mp->crypto_algorithm = crypto_alg;
15674 mp->integrity_algorithm = integ_alg;
15675 mp->crypto_key_length = vec_len (ck);
15676 mp->integrity_key_length = vec_len (ik);
15678 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15679 mp->crypto_key_length = sizeof (mp->crypto_key);
15681 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15682 mp->integrity_key_length = sizeof (mp->integrity_key);
15685 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15687 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15691 if (is_tunnel_ipv6)
15693 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15694 sizeof (ip6_address_t));
15695 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15696 sizeof (ip6_address_t));
15700 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15701 sizeof (ip4_address_t));
15702 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15703 sizeof (ip4_address_t));
15713 api_ipsec_sa_set_key (vat_main_t * vam)
15715 unformat_input_t *i = vam->input;
15716 vl_api_ipsec_sa_set_key_t *mp;
15718 u8 *ck = 0, *ik = 0;
15721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15723 if (unformat (i, "sa_id %d", &sa_id))
15725 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15727 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15731 clib_warning ("parse error '%U'", format_unformat_error, i);
15736 M (IPSEC_SA_SET_KEY, mp);
15738 mp->sa_id = ntohl (sa_id);
15739 mp->crypto_key_length = vec_len (ck);
15740 mp->integrity_key_length = vec_len (ik);
15742 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15743 mp->crypto_key_length = sizeof (mp->crypto_key);
15745 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15746 mp->integrity_key_length = sizeof (mp->integrity_key);
15749 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15751 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15759 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15761 unformat_input_t *i = vam->input;
15762 vl_api_ipsec_tunnel_if_add_del_t *mp;
15763 u32 local_spi = 0, remote_spi = 0;
15764 u32 crypto_alg = 0, integ_alg = 0;
15765 u8 *lck = NULL, *rck = NULL;
15766 u8 *lik = NULL, *rik = NULL;
15767 ip4_address_t local_ip = { {0} };
15768 ip4_address_t remote_ip = { {0} };
15771 u8 anti_replay = 0;
15776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15778 if (unformat (i, "del"))
15780 else if (unformat (i, "esn"))
15782 else if (unformat (i, "anti_replay"))
15784 else if (unformat (i, "local_spi %d", &local_spi))
15786 else if (unformat (i, "remote_spi %d", &remote_spi))
15788 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15790 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15792 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15795 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15797 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15799 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15803 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15805 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15807 errmsg ("unsupported crypto-alg: '%U'\n",
15808 format_ipsec_crypto_alg, crypto_alg);
15814 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15816 if (integ_alg >= IPSEC_INTEG_N_ALG)
15818 errmsg ("unsupported integ-alg: '%U'\n",
15819 format_ipsec_integ_alg, integ_alg);
15823 else if (unformat (i, "instance %u", &instance))
15827 errmsg ("parse error '%U'\n", format_unformat_error, i);
15832 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15834 mp->is_add = is_add;
15836 mp->anti_replay = anti_replay;
15838 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15839 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15841 mp->local_spi = htonl (local_spi);
15842 mp->remote_spi = htonl (remote_spi);
15843 mp->crypto_alg = (u8) crypto_alg;
15845 mp->local_crypto_key_len = 0;
15848 mp->local_crypto_key_len = vec_len (lck);
15849 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15850 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15851 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15854 mp->remote_crypto_key_len = 0;
15857 mp->remote_crypto_key_len = vec_len (rck);
15858 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15859 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15860 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15863 mp->integ_alg = (u8) integ_alg;
15865 mp->local_integ_key_len = 0;
15868 mp->local_integ_key_len = vec_len (lik);
15869 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15870 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15871 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15874 mp->remote_integ_key_len = 0;
15877 mp->remote_integ_key_len = vec_len (rik);
15878 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15879 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15880 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15885 mp->renumber = renumber;
15886 mp->show_instance = ntohl (instance);
15895 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15897 vat_main_t *vam = &vat_main;
15899 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15900 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15901 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15902 "tunnel_src_addr %U tunnel_dst_addr %U "
15903 "salt %u seq_outbound %lu last_seq_inbound %lu "
15904 "replay_window %lu total_data_size %lu\n",
15905 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15907 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15908 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15909 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15910 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15911 mp->tunnel_src_addr,
15912 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15913 mp->tunnel_dst_addr,
15915 clib_net_to_host_u64 (mp->seq_outbound),
15916 clib_net_to_host_u64 (mp->last_seq_inbound),
15917 clib_net_to_host_u64 (mp->replay_window),
15918 clib_net_to_host_u64 (mp->total_data_size));
15921 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15922 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15924 static void vl_api_ipsec_sa_details_t_handler_json
15925 (vl_api_ipsec_sa_details_t * mp)
15927 vat_main_t *vam = &vat_main;
15928 vat_json_node_t *node = NULL;
15929 struct in_addr src_ip4, dst_ip4;
15930 struct in6_addr src_ip6, dst_ip6;
15932 if (VAT_JSON_ARRAY != vam->json_tree.type)
15934 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15935 vat_json_init_array (&vam->json_tree);
15937 node = vat_json_array_add (&vam->json_tree);
15939 vat_json_init_object (node);
15940 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15941 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15942 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15943 vat_json_object_add_uint (node, "proto", mp->protocol);
15944 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15945 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15946 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15947 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15948 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15949 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15950 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15951 mp->crypto_key_len);
15952 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15953 mp->integ_key_len);
15954 if (mp->is_tunnel_ip6)
15956 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15957 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15958 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15959 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15963 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15964 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15965 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15966 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15968 vat_json_object_add_uint (node, "replay_window",
15969 clib_net_to_host_u64 (mp->replay_window));
15970 vat_json_object_add_uint (node, "total_data_size",
15971 clib_net_to_host_u64 (mp->total_data_size));
15976 api_ipsec_sa_dump (vat_main_t * vam)
15978 unformat_input_t *i = vam->input;
15979 vl_api_ipsec_sa_dump_t *mp;
15980 vl_api_control_ping_t *mp_ping;
15984 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15986 if (unformat (i, "sa_id %d", &sa_id))
15990 clib_warning ("parse error '%U'", format_unformat_error, i);
15995 M (IPSEC_SA_DUMP, mp);
15997 mp->sa_id = ntohl (sa_id);
16001 /* Use a control ping for synchronization */
16002 M (CONTROL_PING, mp_ping);
16010 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
16012 unformat_input_t *i = vam->input;
16013 vl_api_ipsec_tunnel_if_set_key_t *mp;
16014 u32 sw_if_index = ~0;
16015 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
16020 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16022 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16025 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
16026 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
16028 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
16029 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
16030 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
16031 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
16033 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
16034 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
16035 else if (unformat (i, "%U", unformat_hex_string, &key))
16039 clib_warning ("parse error '%U'", format_unformat_error, i);
16044 if (sw_if_index == ~0)
16046 errmsg ("interface must be specified");
16050 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
16052 errmsg ("key type must be specified");
16058 errmsg ("algorithm must be specified");
16062 if (vec_len (key) == 0)
16064 errmsg ("key must be specified");
16068 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
16070 mp->sw_if_index = htonl (sw_if_index);
16072 mp->key_type = key_type;
16073 mp->key_len = vec_len (key);
16074 clib_memcpy (mp->key, key, vec_len (key));
16083 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
16085 unformat_input_t *i = vam->input;
16086 vl_api_ipsec_tunnel_if_set_sa_t *mp;
16087 u32 sw_if_index = ~0;
16089 u8 is_outbound = (u8) ~ 0;
16092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16094 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16096 else if (unformat (i, "sa_id %d", &sa_id))
16098 else if (unformat (i, "outbound"))
16100 else if (unformat (i, "inbound"))
16104 clib_warning ("parse error '%U'", format_unformat_error, i);
16109 if (sw_if_index == ~0)
16111 errmsg ("interface must be specified");
16117 errmsg ("SA ID must be specified");
16121 M (IPSEC_TUNNEL_IF_SET_SA, mp);
16123 mp->sw_if_index = htonl (sw_if_index);
16124 mp->sa_id = htonl (sa_id);
16125 mp->is_outbound = is_outbound;
16134 api_ikev2_profile_add_del (vat_main_t * vam)
16136 unformat_input_t *i = vam->input;
16137 vl_api_ikev2_profile_add_del_t *mp;
16142 const char *valid_chars = "a-zA-Z0-9_";
16144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16146 if (unformat (i, "del"))
16148 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16149 vec_add1 (name, 0);
16152 errmsg ("parse error '%U'", format_unformat_error, i);
16157 if (!vec_len (name))
16159 errmsg ("profile name must be specified");
16163 if (vec_len (name) > 64)
16165 errmsg ("profile name too long");
16169 M (IKEV2_PROFILE_ADD_DEL, mp);
16171 clib_memcpy (mp->name, name, vec_len (name));
16172 mp->is_add = is_add;
16181 api_ikev2_profile_set_auth (vat_main_t * vam)
16183 unformat_input_t *i = vam->input;
16184 vl_api_ikev2_profile_set_auth_t *mp;
16187 u32 auth_method = 0;
16191 const char *valid_chars = "a-zA-Z0-9_";
16193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16195 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16196 vec_add1 (name, 0);
16197 else if (unformat (i, "auth_method %U",
16198 unformat_ikev2_auth_method, &auth_method))
16200 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
16202 else if (unformat (i, "auth_data %v", &data))
16206 errmsg ("parse error '%U'", format_unformat_error, i);
16211 if (!vec_len (name))
16213 errmsg ("profile name must be specified");
16217 if (vec_len (name) > 64)
16219 errmsg ("profile name too long");
16223 if (!vec_len (data))
16225 errmsg ("auth_data must be specified");
16231 errmsg ("auth_method must be specified");
16235 M (IKEV2_PROFILE_SET_AUTH, mp);
16237 mp->is_hex = is_hex;
16238 mp->auth_method = (u8) auth_method;
16239 mp->data_len = vec_len (data);
16240 clib_memcpy (mp->name, name, vec_len (name));
16241 clib_memcpy (mp->data, data, vec_len (data));
16251 api_ikev2_profile_set_id (vat_main_t * vam)
16253 unformat_input_t *i = vam->input;
16254 vl_api_ikev2_profile_set_id_t *mp;
16262 const char *valid_chars = "a-zA-Z0-9_";
16264 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16266 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16267 vec_add1 (name, 0);
16268 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
16270 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
16272 data = vec_new (u8, 4);
16273 clib_memcpy (data, ip4.as_u8, 4);
16275 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
16277 else if (unformat (i, "id_data %v", &data))
16279 else if (unformat (i, "local"))
16281 else if (unformat (i, "remote"))
16285 errmsg ("parse error '%U'", format_unformat_error, i);
16290 if (!vec_len (name))
16292 errmsg ("profile name must be specified");
16296 if (vec_len (name) > 64)
16298 errmsg ("profile name too long");
16302 if (!vec_len (data))
16304 errmsg ("id_data must be specified");
16310 errmsg ("id_type must be specified");
16314 M (IKEV2_PROFILE_SET_ID, mp);
16316 mp->is_local = is_local;
16317 mp->id_type = (u8) id_type;
16318 mp->data_len = vec_len (data);
16319 clib_memcpy (mp->name, name, vec_len (name));
16320 clib_memcpy (mp->data, data, vec_len (data));
16330 api_ikev2_profile_set_ts (vat_main_t * vam)
16332 unformat_input_t *i = vam->input;
16333 vl_api_ikev2_profile_set_ts_t *mp;
16336 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
16337 ip4_address_t start_addr, end_addr;
16339 const char *valid_chars = "a-zA-Z0-9_";
16342 start_addr.as_u32 = 0;
16343 end_addr.as_u32 = (u32) ~ 0;
16345 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16347 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16348 vec_add1 (name, 0);
16349 else if (unformat (i, "protocol %d", &proto))
16351 else if (unformat (i, "start_port %d", &start_port))
16353 else if (unformat (i, "end_port %d", &end_port))
16356 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
16358 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
16360 else if (unformat (i, "local"))
16362 else if (unformat (i, "remote"))
16366 errmsg ("parse error '%U'", format_unformat_error, i);
16371 if (!vec_len (name))
16373 errmsg ("profile name must be specified");
16377 if (vec_len (name) > 64)
16379 errmsg ("profile name too long");
16383 M (IKEV2_PROFILE_SET_TS, mp);
16385 mp->is_local = is_local;
16386 mp->proto = (u8) proto;
16387 mp->start_port = (u16) start_port;
16388 mp->end_port = (u16) end_port;
16389 mp->start_addr = start_addr.as_u32;
16390 mp->end_addr = end_addr.as_u32;
16391 clib_memcpy (mp->name, name, vec_len (name));
16400 api_ikev2_set_local_key (vat_main_t * vam)
16402 unformat_input_t *i = vam->input;
16403 vl_api_ikev2_set_local_key_t *mp;
16407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16409 if (unformat (i, "file %v", &file))
16410 vec_add1 (file, 0);
16413 errmsg ("parse error '%U'", format_unformat_error, i);
16418 if (!vec_len (file))
16420 errmsg ("RSA key file must be specified");
16424 if (vec_len (file) > 256)
16426 errmsg ("file name too long");
16430 M (IKEV2_SET_LOCAL_KEY, mp);
16432 clib_memcpy (mp->key_file, file, vec_len (file));
16441 api_ikev2_set_responder (vat_main_t * vam)
16443 unformat_input_t *i = vam->input;
16444 vl_api_ikev2_set_responder_t *mp;
16447 u32 sw_if_index = ~0;
16448 ip4_address_t address;
16450 const char *valid_chars = "a-zA-Z0-9_";
16452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16455 (i, "%U interface %d address %U", unformat_token, valid_chars,
16456 &name, &sw_if_index, unformat_ip4_address, &address))
16457 vec_add1 (name, 0);
16460 errmsg ("parse error '%U'", format_unformat_error, i);
16465 if (!vec_len (name))
16467 errmsg ("profile name must be specified");
16471 if (vec_len (name) > 64)
16473 errmsg ("profile name too long");
16477 M (IKEV2_SET_RESPONDER, mp);
16479 clib_memcpy (mp->name, name, vec_len (name));
16482 mp->sw_if_index = sw_if_index;
16483 clib_memcpy (mp->address, &address, sizeof (address));
16491 api_ikev2_set_ike_transforms (vat_main_t * vam)
16493 unformat_input_t *i = vam->input;
16494 vl_api_ikev2_set_ike_transforms_t *mp;
16497 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16499 const char *valid_chars = "a-zA-Z0-9_";
16501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16503 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16504 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16505 vec_add1 (name, 0);
16508 errmsg ("parse error '%U'", format_unformat_error, i);
16513 if (!vec_len (name))
16515 errmsg ("profile name must be specified");
16519 if (vec_len (name) > 64)
16521 errmsg ("profile name too long");
16525 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16527 clib_memcpy (mp->name, name, vec_len (name));
16529 mp->crypto_alg = crypto_alg;
16530 mp->crypto_key_size = crypto_key_size;
16531 mp->integ_alg = integ_alg;
16532 mp->dh_group = dh_group;
16541 api_ikev2_set_esp_transforms (vat_main_t * vam)
16543 unformat_input_t *i = vam->input;
16544 vl_api_ikev2_set_esp_transforms_t *mp;
16547 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16549 const char *valid_chars = "a-zA-Z0-9_";
16551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16553 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16554 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16555 vec_add1 (name, 0);
16558 errmsg ("parse error '%U'", format_unformat_error, i);
16563 if (!vec_len (name))
16565 errmsg ("profile name must be specified");
16569 if (vec_len (name) > 64)
16571 errmsg ("profile name too long");
16575 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16577 clib_memcpy (mp->name, name, vec_len (name));
16579 mp->crypto_alg = crypto_alg;
16580 mp->crypto_key_size = crypto_key_size;
16581 mp->integ_alg = integ_alg;
16582 mp->dh_group = dh_group;
16590 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16592 unformat_input_t *i = vam->input;
16593 vl_api_ikev2_set_sa_lifetime_t *mp;
16596 u64 lifetime, lifetime_maxdata;
16597 u32 lifetime_jitter, handover;
16599 const char *valid_chars = "a-zA-Z0-9_";
16601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16603 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16604 &lifetime, &lifetime_jitter, &handover,
16605 &lifetime_maxdata))
16606 vec_add1 (name, 0);
16609 errmsg ("parse error '%U'", format_unformat_error, i);
16614 if (!vec_len (name))
16616 errmsg ("profile name must be specified");
16620 if (vec_len (name) > 64)
16622 errmsg ("profile name too long");
16626 M (IKEV2_SET_SA_LIFETIME, mp);
16628 clib_memcpy (mp->name, name, vec_len (name));
16630 mp->lifetime = lifetime;
16631 mp->lifetime_jitter = lifetime_jitter;
16632 mp->handover = handover;
16633 mp->lifetime_maxdata = lifetime_maxdata;
16641 api_ikev2_initiate_sa_init (vat_main_t * vam)
16643 unformat_input_t *i = vam->input;
16644 vl_api_ikev2_initiate_sa_init_t *mp;
16648 const char *valid_chars = "a-zA-Z0-9_";
16650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16652 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16653 vec_add1 (name, 0);
16656 errmsg ("parse error '%U'", format_unformat_error, i);
16661 if (!vec_len (name))
16663 errmsg ("profile name must be specified");
16667 if (vec_len (name) > 64)
16669 errmsg ("profile name too long");
16673 M (IKEV2_INITIATE_SA_INIT, mp);
16675 clib_memcpy (mp->name, name, vec_len (name));
16684 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16686 unformat_input_t *i = vam->input;
16687 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16694 if (unformat (i, "%lx", &ispi))
16698 errmsg ("parse error '%U'", format_unformat_error, i);
16703 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16713 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16715 unformat_input_t *i = vam->input;
16716 vl_api_ikev2_initiate_del_child_sa_t *mp;
16721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16723 if (unformat (i, "%x", &ispi))
16727 errmsg ("parse error '%U'", format_unformat_error, i);
16732 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16742 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16744 unformat_input_t *i = vam->input;
16745 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16752 if (unformat (i, "%x", &ispi))
16756 errmsg ("parse error '%U'", format_unformat_error, i);
16761 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16771 api_get_first_msg_id (vat_main_t * vam)
16773 vl_api_get_first_msg_id_t *mp;
16774 unformat_input_t *i = vam->input;
16779 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16781 if (unformat (i, "client %s", &name))
16789 errmsg ("missing client name");
16792 vec_add1 (name, 0);
16794 if (vec_len (name) > 63)
16796 errmsg ("client name too long");
16800 M (GET_FIRST_MSG_ID, mp);
16801 clib_memcpy (mp->name, name, vec_len (name));
16808 api_cop_interface_enable_disable (vat_main_t * vam)
16810 unformat_input_t *line_input = vam->input;
16811 vl_api_cop_interface_enable_disable_t *mp;
16812 u32 sw_if_index = ~0;
16813 u8 enable_disable = 1;
16816 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16818 if (unformat (line_input, "disable"))
16819 enable_disable = 0;
16820 if (unformat (line_input, "enable"))
16821 enable_disable = 1;
16822 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16823 vam, &sw_if_index))
16825 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16831 if (sw_if_index == ~0)
16833 errmsg ("missing interface name or sw_if_index");
16837 /* Construct the API message */
16838 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16839 mp->sw_if_index = ntohl (sw_if_index);
16840 mp->enable_disable = enable_disable;
16844 /* Wait for the reply */
16850 api_cop_whitelist_enable_disable (vat_main_t * vam)
16852 unformat_input_t *line_input = vam->input;
16853 vl_api_cop_whitelist_enable_disable_t *mp;
16854 u32 sw_if_index = ~0;
16855 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16859 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16861 if (unformat (line_input, "ip4"))
16863 else if (unformat (line_input, "ip6"))
16865 else if (unformat (line_input, "default"))
16867 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16868 vam, &sw_if_index))
16870 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16872 else if (unformat (line_input, "fib-id %d", &fib_id))
16878 if (sw_if_index == ~0)
16880 errmsg ("missing interface name or sw_if_index");
16884 /* Construct the API message */
16885 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16886 mp->sw_if_index = ntohl (sw_if_index);
16887 mp->fib_id = ntohl (fib_id);
16890 mp->default_cop = default_cop;
16894 /* Wait for the reply */
16900 api_get_node_graph (vat_main_t * vam)
16902 vl_api_get_node_graph_t *mp;
16905 M (GET_NODE_GRAPH, mp);
16909 /* Wait for the reply */
16915 /** Used for parsing LISP eids */
16916 typedef CLIB_PACKED(struct{
16917 u8 addr[16]; /**< eid address */
16918 u32 len; /**< prefix length if IP */
16919 u8 type; /**< type of eid */
16924 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16926 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16928 clib_memset (a, 0, sizeof (a[0]));
16930 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16932 a->type = 0; /* ipv4 type */
16934 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16936 a->type = 1; /* ipv6 type */
16938 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16940 a->type = 2; /* mac type */
16942 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16944 a->type = 3; /* NSH type */
16945 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16946 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16953 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16962 lisp_eid_size_vat (u8 type)
16979 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16981 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16985 api_one_add_del_locator_set (vat_main_t * vam)
16987 unformat_input_t *input = vam->input;
16988 vl_api_one_add_del_locator_set_t *mp;
16990 u8 *locator_set_name = NULL;
16991 u8 locator_set_name_set = 0;
16992 vl_api_local_locator_t locator, *locators = 0;
16993 u32 sw_if_index, priority, weight;
16997 /* Parse args required to build the message */
16998 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17000 if (unformat (input, "del"))
17004 else if (unformat (input, "locator-set %s", &locator_set_name))
17006 locator_set_name_set = 1;
17008 else if (unformat (input, "sw_if_index %u p %u w %u",
17009 &sw_if_index, &priority, &weight))
17011 locator.sw_if_index = htonl (sw_if_index);
17012 locator.priority = priority;
17013 locator.weight = weight;
17014 vec_add1 (locators, locator);
17018 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
17019 &sw_if_index, &priority, &weight))
17021 locator.sw_if_index = htonl (sw_if_index);
17022 locator.priority = priority;
17023 locator.weight = weight;
17024 vec_add1 (locators, locator);
17030 if (locator_set_name_set == 0)
17032 errmsg ("missing locator-set name");
17033 vec_free (locators);
17037 if (vec_len (locator_set_name) > 64)
17039 errmsg ("locator-set name too long");
17040 vec_free (locator_set_name);
17041 vec_free (locators);
17044 vec_add1 (locator_set_name, 0);
17046 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
17048 /* Construct the API message */
17049 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
17051 mp->is_add = is_add;
17052 clib_memcpy (mp->locator_set_name, locator_set_name,
17053 vec_len (locator_set_name));
17054 vec_free (locator_set_name);
17056 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
17058 clib_memcpy (mp->locators, locators, data_len);
17059 vec_free (locators);
17064 /* Wait for a reply... */
17069 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
17072 api_one_add_del_locator (vat_main_t * vam)
17074 unformat_input_t *input = vam->input;
17075 vl_api_one_add_del_locator_t *mp;
17076 u32 tmp_if_index = ~0;
17077 u32 sw_if_index = ~0;
17078 u8 sw_if_index_set = 0;
17079 u8 sw_if_index_if_name_set = 0;
17081 u8 priority_set = 0;
17085 u8 *locator_set_name = NULL;
17086 u8 locator_set_name_set = 0;
17089 /* Parse args required to build the message */
17090 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17092 if (unformat (input, "del"))
17096 else if (unformat (input, "locator-set %s", &locator_set_name))
17098 locator_set_name_set = 1;
17100 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
17103 sw_if_index_if_name_set = 1;
17104 sw_if_index = tmp_if_index;
17106 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
17108 sw_if_index_set = 1;
17109 sw_if_index = tmp_if_index;
17111 else if (unformat (input, "p %d", &priority))
17115 else if (unformat (input, "w %d", &weight))
17123 if (locator_set_name_set == 0)
17125 errmsg ("missing locator-set name");
17129 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
17131 errmsg ("missing sw_if_index");
17132 vec_free (locator_set_name);
17136 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
17138 errmsg ("cannot use both params interface name and sw_if_index");
17139 vec_free (locator_set_name);
17143 if (priority_set == 0)
17145 errmsg ("missing locator-set priority");
17146 vec_free (locator_set_name);
17150 if (weight_set == 0)
17152 errmsg ("missing locator-set weight");
17153 vec_free (locator_set_name);
17157 if (vec_len (locator_set_name) > 64)
17159 errmsg ("locator-set name too long");
17160 vec_free (locator_set_name);
17163 vec_add1 (locator_set_name, 0);
17165 /* Construct the API message */
17166 M (ONE_ADD_DEL_LOCATOR, mp);
17168 mp->is_add = is_add;
17169 mp->sw_if_index = ntohl (sw_if_index);
17170 mp->priority = priority;
17171 mp->weight = weight;
17172 clib_memcpy (mp->locator_set_name, locator_set_name,
17173 vec_len (locator_set_name));
17174 vec_free (locator_set_name);
17179 /* Wait for a reply... */
17184 #define api_lisp_add_del_locator api_one_add_del_locator
17187 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
17189 u32 *key_id = va_arg (*args, u32 *);
17192 if (unformat (input, "%s", &s))
17194 if (!strcmp ((char *) s, "sha1"))
17195 key_id[0] = HMAC_SHA_1_96;
17196 else if (!strcmp ((char *) s, "sha256"))
17197 key_id[0] = HMAC_SHA_256_128;
17200 clib_warning ("invalid key_id: '%s'", s);
17201 key_id[0] = HMAC_NO_KEY;
17212 api_one_add_del_local_eid (vat_main_t * vam)
17214 unformat_input_t *input = vam->input;
17215 vl_api_one_add_del_local_eid_t *mp;
17218 lisp_eid_vat_t _eid, *eid = &_eid;
17219 u8 *locator_set_name = 0;
17220 u8 locator_set_name_set = 0;
17226 /* Parse args required to build the message */
17227 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17229 if (unformat (input, "del"))
17233 else if (unformat (input, "vni %d", &vni))
17237 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17241 else if (unformat (input, "locator-set %s", &locator_set_name))
17243 locator_set_name_set = 1;
17245 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17247 else if (unformat (input, "secret-key %_%v%_", &key))
17253 if (locator_set_name_set == 0)
17255 errmsg ("missing locator-set name");
17261 errmsg ("EID address not set!");
17262 vec_free (locator_set_name);
17266 if (key && (0 == key_id))
17268 errmsg ("invalid key_id!");
17272 if (vec_len (key) > 64)
17274 errmsg ("key too long");
17279 if (vec_len (locator_set_name) > 64)
17281 errmsg ("locator-set name too long");
17282 vec_free (locator_set_name);
17285 vec_add1 (locator_set_name, 0);
17287 /* Construct the API message */
17288 M (ONE_ADD_DEL_LOCAL_EID, mp);
17290 mp->is_add = is_add;
17291 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17292 mp->eid_type = eid->type;
17293 mp->prefix_len = eid->len;
17294 mp->vni = clib_host_to_net_u32 (vni);
17295 mp->key_id = clib_host_to_net_u16 (key_id);
17296 clib_memcpy (mp->locator_set_name, locator_set_name,
17297 vec_len (locator_set_name));
17298 clib_memcpy (mp->key, key, vec_len (key));
17300 vec_free (locator_set_name);
17306 /* Wait for a reply... */
17311 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17314 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17316 u32 dp_table = 0, vni = 0;;
17317 unformat_input_t *input = vam->input;
17318 vl_api_gpe_add_del_fwd_entry_t *mp;
17320 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17321 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17322 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17323 u32 action = ~0, w;
17324 ip4_address_t rmt_rloc4, lcl_rloc4;
17325 ip6_address_t rmt_rloc6, lcl_rloc6;
17326 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17329 clib_memset (&rloc, 0, sizeof (rloc));
17331 /* Parse args required to build the message */
17332 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17334 if (unformat (input, "del"))
17336 else if (unformat (input, "add"))
17338 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17342 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17346 else if (unformat (input, "vrf %d", &dp_table))
17348 else if (unformat (input, "bd %d", &dp_table))
17350 else if (unformat (input, "vni %d", &vni))
17352 else if (unformat (input, "w %d", &w))
17356 errmsg ("No RLOC configured for setting priority/weight!");
17359 curr_rloc->weight = w;
17361 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17362 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17366 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17368 vec_add1 (lcl_locs, rloc);
17370 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17371 vec_add1 (rmt_locs, rloc);
17372 /* weight saved in rmt loc */
17373 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17375 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17376 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17379 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17381 vec_add1 (lcl_locs, rloc);
17383 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17384 vec_add1 (rmt_locs, rloc);
17385 /* weight saved in rmt loc */
17386 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17388 else if (unformat (input, "action %d", &action))
17394 clib_warning ("parse error '%U'", format_unformat_error, input);
17401 errmsg ("remote eid addresses not set");
17405 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17407 errmsg ("eid types don't match");
17411 if (0 == rmt_locs && (u32) ~ 0 == action)
17413 errmsg ("action not set for negative mapping");
17417 /* Construct the API message */
17418 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17419 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17421 mp->is_add = is_add;
17422 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17423 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17424 mp->eid_type = rmt_eid->type;
17425 mp->dp_table = clib_host_to_net_u32 (dp_table);
17426 mp->vni = clib_host_to_net_u32 (vni);
17427 mp->rmt_len = rmt_eid->len;
17428 mp->lcl_len = lcl_eid->len;
17429 mp->action = action;
17431 if (0 != rmt_locs && 0 != lcl_locs)
17433 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17434 clib_memcpy (mp->locs, lcl_locs,
17435 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17437 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17438 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17439 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17441 vec_free (lcl_locs);
17442 vec_free (rmt_locs);
17447 /* Wait for a reply... */
17453 api_one_add_del_map_server (vat_main_t * vam)
17455 unformat_input_t *input = vam->input;
17456 vl_api_one_add_del_map_server_t *mp;
17460 ip4_address_t ipv4;
17461 ip6_address_t ipv6;
17464 /* Parse args required to build the message */
17465 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17467 if (unformat (input, "del"))
17471 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17475 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17483 if (ipv4_set && ipv6_set)
17485 errmsg ("both eid v4 and v6 addresses set");
17489 if (!ipv4_set && !ipv6_set)
17491 errmsg ("eid addresses not set");
17495 /* Construct the API message */
17496 M (ONE_ADD_DEL_MAP_SERVER, mp);
17498 mp->is_add = is_add;
17502 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17507 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17513 /* Wait for a reply... */
17518 #define api_lisp_add_del_map_server api_one_add_del_map_server
17521 api_one_add_del_map_resolver (vat_main_t * vam)
17523 unformat_input_t *input = vam->input;
17524 vl_api_one_add_del_map_resolver_t *mp;
17528 ip4_address_t ipv4;
17529 ip6_address_t ipv6;
17532 /* Parse args required to build the message */
17533 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17535 if (unformat (input, "del"))
17539 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17543 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17551 if (ipv4_set && ipv6_set)
17553 errmsg ("both eid v4 and v6 addresses set");
17557 if (!ipv4_set && !ipv6_set)
17559 errmsg ("eid addresses not set");
17563 /* Construct the API message */
17564 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17566 mp->is_add = is_add;
17570 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17575 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17581 /* Wait for a reply... */
17586 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17589 api_lisp_gpe_enable_disable (vat_main_t * vam)
17591 unformat_input_t *input = vam->input;
17592 vl_api_gpe_enable_disable_t *mp;
17597 /* Parse args required to build the message */
17598 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17600 if (unformat (input, "enable"))
17605 else if (unformat (input, "disable"))
17616 errmsg ("Value not set");
17620 /* Construct the API message */
17621 M (GPE_ENABLE_DISABLE, mp);
17628 /* Wait for a reply... */
17634 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17636 unformat_input_t *input = vam->input;
17637 vl_api_one_rloc_probe_enable_disable_t *mp;
17642 /* Parse args required to build the message */
17643 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17645 if (unformat (input, "enable"))
17650 else if (unformat (input, "disable"))
17658 errmsg ("Value not set");
17662 /* Construct the API message */
17663 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17665 mp->is_enabled = is_en;
17670 /* Wait for a reply... */
17675 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17678 api_one_map_register_enable_disable (vat_main_t * vam)
17680 unformat_input_t *input = vam->input;
17681 vl_api_one_map_register_enable_disable_t *mp;
17686 /* Parse args required to build the message */
17687 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17689 if (unformat (input, "enable"))
17694 else if (unformat (input, "disable"))
17702 errmsg ("Value not set");
17706 /* Construct the API message */
17707 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17709 mp->is_enabled = is_en;
17714 /* Wait for a reply... */
17719 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17722 api_one_enable_disable (vat_main_t * vam)
17724 unformat_input_t *input = vam->input;
17725 vl_api_one_enable_disable_t *mp;
17730 /* Parse args required to build the message */
17731 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17733 if (unformat (input, "enable"))
17738 else if (unformat (input, "disable"))
17748 errmsg ("Value not set");
17752 /* Construct the API message */
17753 M (ONE_ENABLE_DISABLE, mp);
17760 /* Wait for a reply... */
17765 #define api_lisp_enable_disable api_one_enable_disable
17768 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17770 unformat_input_t *input = vam->input;
17771 vl_api_one_enable_disable_xtr_mode_t *mp;
17776 /* Parse args required to build the message */
17777 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17779 if (unformat (input, "enable"))
17784 else if (unformat (input, "disable"))
17794 errmsg ("Value not set");
17798 /* Construct the API message */
17799 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17806 /* Wait for a reply... */
17812 api_one_show_xtr_mode (vat_main_t * vam)
17814 vl_api_one_show_xtr_mode_t *mp;
17817 /* Construct the API message */
17818 M (ONE_SHOW_XTR_MODE, mp);
17823 /* Wait for a reply... */
17829 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17831 unformat_input_t *input = vam->input;
17832 vl_api_one_enable_disable_pitr_mode_t *mp;
17837 /* Parse args required to build the message */
17838 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17840 if (unformat (input, "enable"))
17845 else if (unformat (input, "disable"))
17855 errmsg ("Value not set");
17859 /* Construct the API message */
17860 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17867 /* Wait for a reply... */
17873 api_one_show_pitr_mode (vat_main_t * vam)
17875 vl_api_one_show_pitr_mode_t *mp;
17878 /* Construct the API message */
17879 M (ONE_SHOW_PITR_MODE, mp);
17884 /* Wait for a reply... */
17890 api_one_enable_disable_petr_mode (vat_main_t * vam)
17892 unformat_input_t *input = vam->input;
17893 vl_api_one_enable_disable_petr_mode_t *mp;
17898 /* Parse args required to build the message */
17899 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17901 if (unformat (input, "enable"))
17906 else if (unformat (input, "disable"))
17916 errmsg ("Value not set");
17920 /* Construct the API message */
17921 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17928 /* Wait for a reply... */
17934 api_one_show_petr_mode (vat_main_t * vam)
17936 vl_api_one_show_petr_mode_t *mp;
17939 /* Construct the API message */
17940 M (ONE_SHOW_PETR_MODE, mp);
17945 /* Wait for a reply... */
17951 api_show_one_map_register_state (vat_main_t * vam)
17953 vl_api_show_one_map_register_state_t *mp;
17956 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17961 /* wait for reply */
17966 #define api_show_lisp_map_register_state api_show_one_map_register_state
17969 api_show_one_rloc_probe_state (vat_main_t * vam)
17971 vl_api_show_one_rloc_probe_state_t *mp;
17974 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17979 /* wait for reply */
17984 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17987 api_one_add_del_ndp_entry (vat_main_t * vam)
17989 vl_api_one_add_del_ndp_entry_t *mp;
17990 unformat_input_t *input = vam->input;
17995 u8 mac[6] = { 0, };
17996 u8 ip6[16] = { 0, };
18000 /* Parse args required to build the message */
18001 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18003 if (unformat (input, "del"))
18005 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
18007 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
18009 else if (unformat (input, "bd %d", &bd))
18013 errmsg ("parse error '%U'", format_unformat_error, input);
18018 if (!bd_set || !ip_set || (!mac_set && is_add))
18020 errmsg ("Missing BD, IP or MAC!");
18024 M (ONE_ADD_DEL_NDP_ENTRY, mp);
18025 mp->is_add = is_add;
18026 clib_memcpy (mp->mac, mac, 6);
18027 mp->bd = clib_host_to_net_u32 (bd);
18028 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
18033 /* wait for reply */
18039 api_one_add_del_l2_arp_entry (vat_main_t * vam)
18041 vl_api_one_add_del_l2_arp_entry_t *mp;
18042 unformat_input_t *input = vam->input;
18047 u8 mac[6] = { 0, };
18048 u32 ip4 = 0, bd = ~0;
18051 /* Parse args required to build the message */
18052 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18054 if (unformat (input, "del"))
18056 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
18058 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
18060 else if (unformat (input, "bd %d", &bd))
18064 errmsg ("parse error '%U'", format_unformat_error, input);
18069 if (!bd_set || !ip_set || (!mac_set && is_add))
18071 errmsg ("Missing BD, IP or MAC!");
18075 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
18076 mp->is_add = is_add;
18077 clib_memcpy (mp->mac, mac, 6);
18078 mp->bd = clib_host_to_net_u32 (bd);
18084 /* wait for reply */
18090 api_one_ndp_bd_get (vat_main_t * vam)
18092 vl_api_one_ndp_bd_get_t *mp;
18095 M (ONE_NDP_BD_GET, mp);
18100 /* wait for reply */
18106 api_one_ndp_entries_get (vat_main_t * vam)
18108 vl_api_one_ndp_entries_get_t *mp;
18109 unformat_input_t *input = vam->input;
18114 /* Parse args required to build the message */
18115 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18117 if (unformat (input, "bd %d", &bd))
18121 errmsg ("parse error '%U'", format_unformat_error, input);
18128 errmsg ("Expected bridge domain!");
18132 M (ONE_NDP_ENTRIES_GET, mp);
18133 mp->bd = clib_host_to_net_u32 (bd);
18138 /* wait for reply */
18144 api_one_l2_arp_bd_get (vat_main_t * vam)
18146 vl_api_one_l2_arp_bd_get_t *mp;
18149 M (ONE_L2_ARP_BD_GET, mp);
18154 /* wait for reply */
18160 api_one_l2_arp_entries_get (vat_main_t * vam)
18162 vl_api_one_l2_arp_entries_get_t *mp;
18163 unformat_input_t *input = vam->input;
18168 /* Parse args required to build the message */
18169 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18171 if (unformat (input, "bd %d", &bd))
18175 errmsg ("parse error '%U'", format_unformat_error, input);
18182 errmsg ("Expected bridge domain!");
18186 M (ONE_L2_ARP_ENTRIES_GET, mp);
18187 mp->bd = clib_host_to_net_u32 (bd);
18192 /* wait for reply */
18198 api_one_stats_enable_disable (vat_main_t * vam)
18200 vl_api_one_stats_enable_disable_t *mp;
18201 unformat_input_t *input = vam->input;
18206 /* Parse args required to build the message */
18207 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18209 if (unformat (input, "enable"))
18214 else if (unformat (input, "disable"))
18224 errmsg ("Value not set");
18228 M (ONE_STATS_ENABLE_DISABLE, mp);
18234 /* wait for reply */
18240 api_show_one_stats_enable_disable (vat_main_t * vam)
18242 vl_api_show_one_stats_enable_disable_t *mp;
18245 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18250 /* wait for reply */
18256 api_show_one_map_request_mode (vat_main_t * vam)
18258 vl_api_show_one_map_request_mode_t *mp;
18261 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18266 /* wait for reply */
18271 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18274 api_one_map_request_mode (vat_main_t * vam)
18276 unformat_input_t *input = vam->input;
18277 vl_api_one_map_request_mode_t *mp;
18281 /* Parse args required to build the message */
18282 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18284 if (unformat (input, "dst-only"))
18286 else if (unformat (input, "src-dst"))
18290 errmsg ("parse error '%U'", format_unformat_error, input);
18295 M (ONE_MAP_REQUEST_MODE, mp);
18302 /* wait for reply */
18307 #define api_lisp_map_request_mode api_one_map_request_mode
18310 * Enable/disable ONE proxy ITR.
18312 * @param vam vpp API test context
18313 * @return return code
18316 api_one_pitr_set_locator_set (vat_main_t * vam)
18318 u8 ls_name_set = 0;
18319 unformat_input_t *input = vam->input;
18320 vl_api_one_pitr_set_locator_set_t *mp;
18325 /* Parse args required to build the message */
18326 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18328 if (unformat (input, "del"))
18330 else if (unformat (input, "locator-set %s", &ls_name))
18334 errmsg ("parse error '%U'", format_unformat_error, input);
18341 errmsg ("locator-set name not set!");
18345 M (ONE_PITR_SET_LOCATOR_SET, mp);
18347 mp->is_add = is_add;
18348 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18349 vec_free (ls_name);
18354 /* wait for reply */
18359 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18362 api_one_nsh_set_locator_set (vat_main_t * vam)
18364 u8 ls_name_set = 0;
18365 unformat_input_t *input = vam->input;
18366 vl_api_one_nsh_set_locator_set_t *mp;
18371 /* Parse args required to build the message */
18372 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18374 if (unformat (input, "del"))
18376 else if (unformat (input, "ls %s", &ls_name))
18380 errmsg ("parse error '%U'", format_unformat_error, input);
18385 if (!ls_name_set && is_add)
18387 errmsg ("locator-set name not set!");
18391 M (ONE_NSH_SET_LOCATOR_SET, mp);
18393 mp->is_add = is_add;
18394 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18395 vec_free (ls_name);
18400 /* wait for reply */
18406 api_show_one_pitr (vat_main_t * vam)
18408 vl_api_show_one_pitr_t *mp;
18411 if (!vam->json_output)
18413 print (vam->ofp, "%=20s", "lisp status:");
18416 M (SHOW_ONE_PITR, mp);
18420 /* Wait for a reply... */
18425 #define api_show_lisp_pitr api_show_one_pitr
18428 api_one_use_petr (vat_main_t * vam)
18430 unformat_input_t *input = vam->input;
18431 vl_api_one_use_petr_t *mp;
18436 clib_memset (&ip, 0, sizeof (ip));
18438 /* Parse args required to build the message */
18439 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18441 if (unformat (input, "disable"))
18444 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18447 ip_addr_version (&ip) = IP4;
18450 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18453 ip_addr_version (&ip) = IP6;
18457 errmsg ("parse error '%U'", format_unformat_error, input);
18462 M (ONE_USE_PETR, mp);
18464 mp->is_add = is_add;
18467 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18469 clib_memcpy (mp->address, &ip, 4);
18471 clib_memcpy (mp->address, &ip, 16);
18477 /* wait for reply */
18482 #define api_lisp_use_petr api_one_use_petr
18485 api_show_one_nsh_mapping (vat_main_t * vam)
18487 vl_api_show_one_use_petr_t *mp;
18490 if (!vam->json_output)
18492 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18495 M (SHOW_ONE_NSH_MAPPING, mp);
18499 /* Wait for a reply... */
18505 api_show_one_use_petr (vat_main_t * vam)
18507 vl_api_show_one_use_petr_t *mp;
18510 if (!vam->json_output)
18512 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18515 M (SHOW_ONE_USE_PETR, mp);
18519 /* Wait for a reply... */
18524 #define api_show_lisp_use_petr api_show_one_use_petr
18527 * Add/delete mapping between vni and vrf
18530 api_one_eid_table_add_del_map (vat_main_t * vam)
18532 unformat_input_t *input = vam->input;
18533 vl_api_one_eid_table_add_del_map_t *mp;
18534 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18535 u32 vni, vrf, bd_index;
18538 /* Parse args required to build the message */
18539 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18541 if (unformat (input, "del"))
18543 else if (unformat (input, "vrf %d", &vrf))
18545 else if (unformat (input, "bd_index %d", &bd_index))
18547 else if (unformat (input, "vni %d", &vni))
18553 if (!vni_set || (!vrf_set && !bd_index_set))
18555 errmsg ("missing arguments!");
18559 if (vrf_set && bd_index_set)
18561 errmsg ("error: both vrf and bd entered!");
18565 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18567 mp->is_add = is_add;
18568 mp->vni = htonl (vni);
18569 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18570 mp->is_l2 = bd_index_set;
18575 /* wait for reply */
18580 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18583 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18585 u32 *action = va_arg (*args, u32 *);
18588 if (unformat (input, "%s", &s))
18590 if (!strcmp ((char *) s, "no-action"))
18592 else if (!strcmp ((char *) s, "natively-forward"))
18594 else if (!strcmp ((char *) s, "send-map-request"))
18596 else if (!strcmp ((char *) s, "drop"))
18600 clib_warning ("invalid action: '%s'", s);
18612 * Add/del remote mapping to/from ONE control plane
18614 * @param vam vpp API test context
18615 * @return return code
18618 api_one_add_del_remote_mapping (vat_main_t * vam)
18620 unformat_input_t *input = vam->input;
18621 vl_api_one_add_del_remote_mapping_t *mp;
18623 lisp_eid_vat_t _eid, *eid = &_eid;
18624 lisp_eid_vat_t _seid, *seid = &_seid;
18625 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18626 u32 action = ~0, p, w, data_len;
18627 ip4_address_t rloc4;
18628 ip6_address_t rloc6;
18629 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18632 clib_memset (&rloc, 0, sizeof (rloc));
18634 /* Parse args required to build the message */
18635 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18637 if (unformat (input, "del-all"))
18641 else if (unformat (input, "del"))
18645 else if (unformat (input, "add"))
18649 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18653 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18657 else if (unformat (input, "vni %d", &vni))
18661 else if (unformat (input, "p %d w %d", &p, &w))
18665 errmsg ("No RLOC configured for setting priority/weight!");
18668 curr_rloc->priority = p;
18669 curr_rloc->weight = w;
18671 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18674 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18675 vec_add1 (rlocs, rloc);
18676 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18678 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18681 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18682 vec_add1 (rlocs, rloc);
18683 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18685 else if (unformat (input, "action %U",
18686 unformat_negative_mapping_action, &action))
18692 clib_warning ("parse error '%U'", format_unformat_error, input);
18699 errmsg ("missing params!");
18703 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18705 errmsg ("no action set for negative map-reply!");
18709 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18711 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18712 mp->is_add = is_add;
18713 mp->vni = htonl (vni);
18714 mp->action = (u8) action;
18715 mp->is_src_dst = seid_set;
18716 mp->eid_len = eid->len;
18717 mp->seid_len = seid->len;
18718 mp->del_all = del_all;
18719 mp->eid_type = eid->type;
18720 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18721 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18723 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18724 clib_memcpy (mp->rlocs, rlocs, data_len);
18730 /* Wait for a reply... */
18735 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18738 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18739 * forwarding entries in data-plane accordingly.
18741 * @param vam vpp API test context
18742 * @return return code
18745 api_one_add_del_adjacency (vat_main_t * vam)
18747 unformat_input_t *input = vam->input;
18748 vl_api_one_add_del_adjacency_t *mp;
18750 ip4_address_t leid4, reid4;
18751 ip6_address_t leid6, reid6;
18752 u8 reid_mac[6] = { 0 };
18753 u8 leid_mac[6] = { 0 };
18754 u8 reid_type, leid_type;
18755 u32 leid_len = 0, reid_len = 0, len;
18759 leid_type = reid_type = (u8) ~ 0;
18761 /* Parse args required to build the message */
18762 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18764 if (unformat (input, "del"))
18768 else if (unformat (input, "add"))
18772 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18775 reid_type = 0; /* ipv4 */
18778 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18781 reid_type = 1; /* ipv6 */
18784 else if (unformat (input, "reid %U", unformat_ethernet_address,
18787 reid_type = 2; /* mac */
18789 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18792 leid_type = 0; /* ipv4 */
18795 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18798 leid_type = 1; /* ipv6 */
18801 else if (unformat (input, "leid %U", unformat_ethernet_address,
18804 leid_type = 2; /* mac */
18806 else if (unformat (input, "vni %d", &vni))
18812 errmsg ("parse error '%U'", format_unformat_error, input);
18817 if ((u8) ~ 0 == reid_type)
18819 errmsg ("missing params!");
18823 if (leid_type != reid_type)
18825 errmsg ("remote and local EIDs are of different types!");
18829 M (ONE_ADD_DEL_ADJACENCY, mp);
18830 mp->is_add = is_add;
18831 mp->vni = htonl (vni);
18832 mp->leid_len = leid_len;
18833 mp->reid_len = reid_len;
18834 mp->eid_type = reid_type;
18836 switch (mp->eid_type)
18839 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18840 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18843 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18844 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18847 clib_memcpy (mp->leid, leid_mac, 6);
18848 clib_memcpy (mp->reid, reid_mac, 6);
18851 errmsg ("unknown EID type %d!", mp->eid_type);
18858 /* Wait for a reply... */
18863 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18866 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18868 u32 *mode = va_arg (*args, u32 *);
18870 if (unformat (input, "lisp"))
18872 else if (unformat (input, "vxlan"))
18881 api_gpe_get_encap_mode (vat_main_t * vam)
18883 vl_api_gpe_get_encap_mode_t *mp;
18886 /* Construct the API message */
18887 M (GPE_GET_ENCAP_MODE, mp);
18892 /* Wait for a reply... */
18898 api_gpe_set_encap_mode (vat_main_t * vam)
18900 unformat_input_t *input = vam->input;
18901 vl_api_gpe_set_encap_mode_t *mp;
18905 /* Parse args required to build the message */
18906 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18908 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18914 /* Construct the API message */
18915 M (GPE_SET_ENCAP_MODE, mp);
18922 /* Wait for a reply... */
18928 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18930 unformat_input_t *input = vam->input;
18931 vl_api_gpe_add_del_iface_t *mp;
18932 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18933 u32 dp_table = 0, vni = 0;
18936 /* Parse args required to build the message */
18937 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18939 if (unformat (input, "up"))
18944 else if (unformat (input, "down"))
18949 else if (unformat (input, "table_id %d", &dp_table))
18953 else if (unformat (input, "bd_id %d", &dp_table))
18958 else if (unformat (input, "vni %d", &vni))
18966 if (action_set == 0)
18968 errmsg ("Action not set");
18971 if (dp_table_set == 0 || vni_set == 0)
18973 errmsg ("vni and dp_table must be set");
18977 /* Construct the API message */
18978 M (GPE_ADD_DEL_IFACE, mp);
18980 mp->is_add = is_add;
18981 mp->dp_table = clib_host_to_net_u32 (dp_table);
18983 mp->vni = clib_host_to_net_u32 (vni);
18988 /* Wait for a reply... */
18994 api_one_map_register_fallback_threshold (vat_main_t * vam)
18996 unformat_input_t *input = vam->input;
18997 vl_api_one_map_register_fallback_threshold_t *mp;
19002 /* Parse args required to build the message */
19003 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19005 if (unformat (input, "%u", &value))
19009 clib_warning ("parse error '%U'", format_unformat_error, input);
19016 errmsg ("fallback threshold value is missing!");
19020 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
19021 mp->value = clib_host_to_net_u32 (value);
19026 /* Wait for a reply... */
19032 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
19034 vl_api_show_one_map_register_fallback_threshold_t *mp;
19037 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
19042 /* Wait for a reply... */
19048 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
19050 u32 *proto = va_arg (*args, u32 *);
19052 if (unformat (input, "udp"))
19054 else if (unformat (input, "api"))
19063 api_one_set_transport_protocol (vat_main_t * vam)
19065 unformat_input_t *input = vam->input;
19066 vl_api_one_set_transport_protocol_t *mp;
19071 /* Parse args required to build the message */
19072 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19074 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
19078 clib_warning ("parse error '%U'", format_unformat_error, input);
19085 errmsg ("Transport protocol missing!");
19089 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
19090 mp->protocol = (u8) protocol;
19095 /* Wait for a reply... */
19101 api_one_get_transport_protocol (vat_main_t * vam)
19103 vl_api_one_get_transport_protocol_t *mp;
19106 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
19111 /* Wait for a reply... */
19117 api_one_map_register_set_ttl (vat_main_t * vam)
19119 unformat_input_t *input = vam->input;
19120 vl_api_one_map_register_set_ttl_t *mp;
19125 /* Parse args required to build the message */
19126 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19128 if (unformat (input, "%u", &ttl))
19132 clib_warning ("parse error '%U'", format_unformat_error, input);
19139 errmsg ("TTL value missing!");
19143 M (ONE_MAP_REGISTER_SET_TTL, mp);
19144 mp->ttl = clib_host_to_net_u32 (ttl);
19149 /* Wait for a reply... */
19155 api_show_one_map_register_ttl (vat_main_t * vam)
19157 vl_api_show_one_map_register_ttl_t *mp;
19160 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
19165 /* Wait for a reply... */
19171 * Add/del map request itr rlocs from ONE control plane and updates
19173 * @param vam vpp API test context
19174 * @return return code
19177 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
19179 unformat_input_t *input = vam->input;
19180 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
19181 u8 *locator_set_name = 0;
19182 u8 locator_set_name_set = 0;
19186 /* Parse args required to build the message */
19187 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19189 if (unformat (input, "del"))
19193 else if (unformat (input, "%_%v%_", &locator_set_name))
19195 locator_set_name_set = 1;
19199 clib_warning ("parse error '%U'", format_unformat_error, input);
19204 if (is_add && !locator_set_name_set)
19206 errmsg ("itr-rloc is not set!");
19210 if (is_add && vec_len (locator_set_name) > 64)
19212 errmsg ("itr-rloc locator-set name too long");
19213 vec_free (locator_set_name);
19217 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
19218 mp->is_add = is_add;
19221 clib_memcpy (mp->locator_set_name, locator_set_name,
19222 vec_len (locator_set_name));
19226 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19228 vec_free (locator_set_name);
19233 /* Wait for a reply... */
19238 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19241 api_one_locator_dump (vat_main_t * vam)
19243 unformat_input_t *input = vam->input;
19244 vl_api_one_locator_dump_t *mp;
19245 vl_api_control_ping_t *mp_ping;
19246 u8 is_index_set = 0, is_name_set = 0;
19251 /* Parse args required to build the message */
19252 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19254 if (unformat (input, "ls_name %_%v%_", &ls_name))
19258 else if (unformat (input, "ls_index %d", &ls_index))
19264 errmsg ("parse error '%U'", format_unformat_error, input);
19269 if (!is_index_set && !is_name_set)
19271 errmsg ("error: expected one of index or name!");
19275 if (is_index_set && is_name_set)
19277 errmsg ("error: only one param expected!");
19281 if (vec_len (ls_name) > 62)
19283 errmsg ("error: locator set name too long!");
19287 if (!vam->json_output)
19289 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19292 M (ONE_LOCATOR_DUMP, mp);
19293 mp->is_index_set = is_index_set;
19296 mp->ls_index = clib_host_to_net_u32 (ls_index);
19299 vec_add1 (ls_name, 0);
19300 strncpy ((char *) mp->ls_name, (char *) ls_name,
19301 sizeof (mp->ls_name) - 1);
19307 /* Use a control ping for synchronization */
19308 MPING (CONTROL_PING, mp_ping);
19311 /* Wait for a reply... */
19316 #define api_lisp_locator_dump api_one_locator_dump
19319 api_one_locator_set_dump (vat_main_t * vam)
19321 vl_api_one_locator_set_dump_t *mp;
19322 vl_api_control_ping_t *mp_ping;
19323 unformat_input_t *input = vam->input;
19327 /* Parse args required to build the message */
19328 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19330 if (unformat (input, "local"))
19334 else if (unformat (input, "remote"))
19340 errmsg ("parse error '%U'", format_unformat_error, input);
19345 if (!vam->json_output)
19347 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19350 M (ONE_LOCATOR_SET_DUMP, mp);
19352 mp->filter = filter;
19357 /* Use a control ping for synchronization */
19358 MPING (CONTROL_PING, mp_ping);
19361 /* Wait for a reply... */
19366 #define api_lisp_locator_set_dump api_one_locator_set_dump
19369 api_one_eid_table_map_dump (vat_main_t * vam)
19373 unformat_input_t *input = vam->input;
19374 vl_api_one_eid_table_map_dump_t *mp;
19375 vl_api_control_ping_t *mp_ping;
19378 /* Parse args required to build the message */
19379 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19381 if (unformat (input, "l2"))
19386 else if (unformat (input, "l3"))
19393 errmsg ("parse error '%U'", format_unformat_error, input);
19400 errmsg ("expected one of 'l2' or 'l3' parameter!");
19404 if (!vam->json_output)
19406 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19409 M (ONE_EID_TABLE_MAP_DUMP, mp);
19415 /* Use a control ping for synchronization */
19416 MPING (CONTROL_PING, mp_ping);
19419 /* Wait for a reply... */
19424 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19427 api_one_eid_table_vni_dump (vat_main_t * vam)
19429 vl_api_one_eid_table_vni_dump_t *mp;
19430 vl_api_control_ping_t *mp_ping;
19433 if (!vam->json_output)
19435 print (vam->ofp, "VNI");
19438 M (ONE_EID_TABLE_VNI_DUMP, mp);
19443 /* Use a control ping for synchronization */
19444 MPING (CONTROL_PING, mp_ping);
19447 /* Wait for a reply... */
19452 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19455 api_one_eid_table_dump (vat_main_t * vam)
19457 unformat_input_t *i = vam->input;
19458 vl_api_one_eid_table_dump_t *mp;
19459 vl_api_control_ping_t *mp_ping;
19460 struct in_addr ip4;
19461 struct in6_addr ip6;
19463 u8 eid_type = ~0, eid_set = 0;
19464 u32 prefix_length = ~0, t, vni = 0;
19467 lisp_nsh_api_t nsh;
19469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19471 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19477 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19483 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19488 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19493 else if (unformat (i, "vni %d", &t))
19497 else if (unformat (i, "local"))
19501 else if (unformat (i, "remote"))
19507 errmsg ("parse error '%U'", format_unformat_error, i);
19512 if (!vam->json_output)
19514 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19515 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19518 M (ONE_EID_TABLE_DUMP, mp);
19520 mp->filter = filter;
19524 mp->vni = htonl (vni);
19525 mp->eid_type = eid_type;
19529 mp->prefix_length = prefix_length;
19530 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19533 mp->prefix_length = prefix_length;
19534 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19537 clib_memcpy (mp->eid, mac, sizeof (mac));
19540 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19543 errmsg ("unknown EID type %d!", eid_type);
19551 /* Use a control ping for synchronization */
19552 MPING (CONTROL_PING, mp_ping);
19555 /* Wait for a reply... */
19560 #define api_lisp_eid_table_dump api_one_eid_table_dump
19563 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19565 unformat_input_t *i = vam->input;
19566 vl_api_gpe_fwd_entries_get_t *mp;
19571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19573 if (unformat (i, "vni %d", &vni))
19579 errmsg ("parse error '%U'", format_unformat_error, i);
19586 errmsg ("vni not set!");
19590 if (!vam->json_output)
19592 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19596 M (GPE_FWD_ENTRIES_GET, mp);
19597 mp->vni = clib_host_to_net_u32 (vni);
19602 /* Wait for a reply... */
19607 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19608 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19609 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19610 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19611 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19612 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19613 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19614 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19617 api_one_adjacencies_get (vat_main_t * vam)
19619 unformat_input_t *i = vam->input;
19620 vl_api_one_adjacencies_get_t *mp;
19625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19627 if (unformat (i, "vni %d", &vni))
19633 errmsg ("parse error '%U'", format_unformat_error, i);
19640 errmsg ("vni not set!");
19644 if (!vam->json_output)
19646 print (vam->ofp, "%s %40s", "leid", "reid");
19649 M (ONE_ADJACENCIES_GET, mp);
19650 mp->vni = clib_host_to_net_u32 (vni);
19655 /* Wait for a reply... */
19660 #define api_lisp_adjacencies_get api_one_adjacencies_get
19663 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19665 unformat_input_t *i = vam->input;
19666 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19668 u8 ip_family_set = 0, is_ip4 = 1;
19670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19672 if (unformat (i, "ip4"))
19677 else if (unformat (i, "ip6"))
19684 errmsg ("parse error '%U'", format_unformat_error, i);
19689 if (!ip_family_set)
19691 errmsg ("ip family not set!");
19695 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19696 mp->is_ip4 = is_ip4;
19701 /* Wait for a reply... */
19707 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19709 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19712 if (!vam->json_output)
19714 print (vam->ofp, "VNIs");
19717 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19722 /* Wait for a reply... */
19728 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19730 unformat_input_t *i = vam->input;
19731 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19733 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19734 struct in_addr ip4;
19735 struct in6_addr ip6;
19736 u32 table_id = 0, nh_sw_if_index = ~0;
19738 clib_memset (&ip4, 0, sizeof (ip4));
19739 clib_memset (&ip6, 0, sizeof (ip6));
19741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19743 if (unformat (i, "del"))
19745 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19746 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19751 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19752 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19757 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19761 nh_sw_if_index = ~0;
19763 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19767 nh_sw_if_index = ~0;
19769 else if (unformat (i, "table %d", &table_id))
19773 errmsg ("parse error '%U'", format_unformat_error, i);
19780 errmsg ("nh addr not set!");
19784 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19785 mp->is_add = is_add;
19786 mp->table_id = clib_host_to_net_u32 (table_id);
19787 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19788 mp->is_ip4 = is_ip4;
19790 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19792 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19797 /* Wait for a reply... */
19803 api_one_map_server_dump (vat_main_t * vam)
19805 vl_api_one_map_server_dump_t *mp;
19806 vl_api_control_ping_t *mp_ping;
19809 if (!vam->json_output)
19811 print (vam->ofp, "%=20s", "Map server");
19814 M (ONE_MAP_SERVER_DUMP, mp);
19818 /* Use a control ping for synchronization */
19819 MPING (CONTROL_PING, mp_ping);
19822 /* Wait for a reply... */
19827 #define api_lisp_map_server_dump api_one_map_server_dump
19830 api_one_map_resolver_dump (vat_main_t * vam)
19832 vl_api_one_map_resolver_dump_t *mp;
19833 vl_api_control_ping_t *mp_ping;
19836 if (!vam->json_output)
19838 print (vam->ofp, "%=20s", "Map resolver");
19841 M (ONE_MAP_RESOLVER_DUMP, mp);
19845 /* Use a control ping for synchronization */
19846 MPING (CONTROL_PING, mp_ping);
19849 /* Wait for a reply... */
19854 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19857 api_one_stats_flush (vat_main_t * vam)
19859 vl_api_one_stats_flush_t *mp;
19862 M (ONE_STATS_FLUSH, mp);
19869 api_one_stats_dump (vat_main_t * vam)
19871 vl_api_one_stats_dump_t *mp;
19872 vl_api_control_ping_t *mp_ping;
19875 M (ONE_STATS_DUMP, mp);
19879 /* Use a control ping for synchronization */
19880 MPING (CONTROL_PING, mp_ping);
19883 /* Wait for a reply... */
19889 api_show_one_status (vat_main_t * vam)
19891 vl_api_show_one_status_t *mp;
19894 if (!vam->json_output)
19896 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19899 M (SHOW_ONE_STATUS, mp);
19902 /* Wait for a reply... */
19907 #define api_show_lisp_status api_show_one_status
19910 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19912 vl_api_gpe_fwd_entry_path_dump_t *mp;
19913 vl_api_control_ping_t *mp_ping;
19914 unformat_input_t *i = vam->input;
19915 u32 fwd_entry_index = ~0;
19918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19920 if (unformat (i, "index %d", &fwd_entry_index))
19926 if (~0 == fwd_entry_index)
19928 errmsg ("no index specified!");
19932 if (!vam->json_output)
19934 print (vam->ofp, "first line");
19937 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19941 /* Use a control ping for synchronization */
19942 MPING (CONTROL_PING, mp_ping);
19945 /* Wait for a reply... */
19951 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19953 vl_api_one_get_map_request_itr_rlocs_t *mp;
19956 if (!vam->json_output)
19958 print (vam->ofp, "%=20s", "itr-rlocs:");
19961 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19964 /* Wait for a reply... */
19969 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19972 api_af_packet_create (vat_main_t * vam)
19974 unformat_input_t *i = vam->input;
19975 vl_api_af_packet_create_t *mp;
19976 u8 *host_if_name = 0;
19978 u8 random_hw_addr = 1;
19981 clib_memset (hw_addr, 0, sizeof (hw_addr));
19983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19985 if (unformat (i, "name %s", &host_if_name))
19986 vec_add1 (host_if_name, 0);
19987 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19988 random_hw_addr = 0;
19993 if (!vec_len (host_if_name))
19995 errmsg ("host-interface name must be specified");
19999 if (vec_len (host_if_name) > 64)
20001 errmsg ("host-interface name too long");
20005 M (AF_PACKET_CREATE, mp);
20007 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
20008 clib_memcpy (mp->hw_addr, hw_addr, 6);
20009 mp->use_random_hw_addr = random_hw_addr;
20010 vec_free (host_if_name);
20018 fprintf (vam->ofp ? vam->ofp : stderr,
20019 " new sw_if_index = %d\n", vam->sw_if_index);
20026 api_af_packet_delete (vat_main_t * vam)
20028 unformat_input_t *i = vam->input;
20029 vl_api_af_packet_delete_t *mp;
20030 u8 *host_if_name = 0;
20033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20035 if (unformat (i, "name %s", &host_if_name))
20036 vec_add1 (host_if_name, 0);
20041 if (!vec_len (host_if_name))
20043 errmsg ("host-interface name must be specified");
20047 if (vec_len (host_if_name) > 64)
20049 errmsg ("host-interface name too long");
20053 M (AF_PACKET_DELETE, mp);
20055 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
20056 vec_free (host_if_name);
20063 static void vl_api_af_packet_details_t_handler
20064 (vl_api_af_packet_details_t * mp)
20066 vat_main_t *vam = &vat_main;
20068 print (vam->ofp, "%-16s %d",
20069 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
20072 static void vl_api_af_packet_details_t_handler_json
20073 (vl_api_af_packet_details_t * mp)
20075 vat_main_t *vam = &vat_main;
20076 vat_json_node_t *node = NULL;
20078 if (VAT_JSON_ARRAY != vam->json_tree.type)
20080 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20081 vat_json_init_array (&vam->json_tree);
20083 node = vat_json_array_add (&vam->json_tree);
20085 vat_json_init_object (node);
20086 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20087 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
20091 api_af_packet_dump (vat_main_t * vam)
20093 vl_api_af_packet_dump_t *mp;
20094 vl_api_control_ping_t *mp_ping;
20097 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
20098 /* Get list of tap interfaces */
20099 M (AF_PACKET_DUMP, mp);
20102 /* Use a control ping for synchronization */
20103 MPING (CONTROL_PING, mp_ping);
20111 api_policer_add_del (vat_main_t * vam)
20113 unformat_input_t *i = vam->input;
20114 vl_api_policer_add_del_t *mp;
20124 u8 color_aware = 0;
20125 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
20128 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
20129 conform_action.dscp = 0;
20130 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
20131 exceed_action.dscp = 0;
20132 violate_action.action_type = SSE2_QOS_ACTION_DROP;
20133 violate_action.dscp = 0;
20135 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20137 if (unformat (i, "del"))
20139 else if (unformat (i, "name %s", &name))
20140 vec_add1 (name, 0);
20141 else if (unformat (i, "cir %u", &cir))
20143 else if (unformat (i, "eir %u", &eir))
20145 else if (unformat (i, "cb %u", &cb))
20147 else if (unformat (i, "eb %u", &eb))
20149 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
20152 else if (unformat (i, "round_type %U", unformat_policer_round_type,
20155 else if (unformat (i, "type %U", unformat_policer_type, &type))
20157 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
20160 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
20163 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
20166 else if (unformat (i, "color-aware"))
20172 if (!vec_len (name))
20174 errmsg ("policer name must be specified");
20178 if (vec_len (name) > 64)
20180 errmsg ("policer name too long");
20184 M (POLICER_ADD_DEL, mp);
20186 clib_memcpy (mp->name, name, vec_len (name));
20188 mp->is_add = is_add;
20189 mp->cir = ntohl (cir);
20190 mp->eir = ntohl (eir);
20191 mp->cb = clib_net_to_host_u64 (cb);
20192 mp->eb = clib_net_to_host_u64 (eb);
20193 mp->rate_type = rate_type;
20194 mp->round_type = round_type;
20196 mp->conform_action_type = conform_action.action_type;
20197 mp->conform_dscp = conform_action.dscp;
20198 mp->exceed_action_type = exceed_action.action_type;
20199 mp->exceed_dscp = exceed_action.dscp;
20200 mp->violate_action_type = violate_action.action_type;
20201 mp->violate_dscp = violate_action.dscp;
20202 mp->color_aware = color_aware;
20210 api_policer_dump (vat_main_t * vam)
20212 unformat_input_t *i = vam->input;
20213 vl_api_policer_dump_t *mp;
20214 vl_api_control_ping_t *mp_ping;
20215 u8 *match_name = 0;
20216 u8 match_name_valid = 0;
20219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20221 if (unformat (i, "name %s", &match_name))
20223 vec_add1 (match_name, 0);
20224 match_name_valid = 1;
20230 M (POLICER_DUMP, mp);
20231 mp->match_name_valid = match_name_valid;
20232 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
20233 vec_free (match_name);
20237 /* Use a control ping for synchronization */
20238 MPING (CONTROL_PING, mp_ping);
20241 /* Wait for a reply... */
20247 api_policer_classify_set_interface (vat_main_t * vam)
20249 unformat_input_t *i = vam->input;
20250 vl_api_policer_classify_set_interface_t *mp;
20252 int sw_if_index_set;
20253 u32 ip4_table_index = ~0;
20254 u32 ip6_table_index = ~0;
20255 u32 l2_table_index = ~0;
20259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20261 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20262 sw_if_index_set = 1;
20263 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20264 sw_if_index_set = 1;
20265 else if (unformat (i, "del"))
20267 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20269 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20271 else if (unformat (i, "l2-table %d", &l2_table_index))
20275 clib_warning ("parse error '%U'", format_unformat_error, i);
20280 if (sw_if_index_set == 0)
20282 errmsg ("missing interface name or sw_if_index");
20286 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20288 mp->sw_if_index = ntohl (sw_if_index);
20289 mp->ip4_table_index = ntohl (ip4_table_index);
20290 mp->ip6_table_index = ntohl (ip6_table_index);
20291 mp->l2_table_index = ntohl (l2_table_index);
20292 mp->is_add = is_add;
20300 api_policer_classify_dump (vat_main_t * vam)
20302 unformat_input_t *i = vam->input;
20303 vl_api_policer_classify_dump_t *mp;
20304 vl_api_control_ping_t *mp_ping;
20305 u8 type = POLICER_CLASSIFY_N_TABLES;
20308 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20312 errmsg ("classify table type must be specified");
20316 if (!vam->json_output)
20318 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20321 M (POLICER_CLASSIFY_DUMP, mp);
20326 /* Use a control ping for synchronization */
20327 MPING (CONTROL_PING, mp_ping);
20330 /* Wait for a reply... */
20336 api_netmap_create (vat_main_t * vam)
20338 unformat_input_t *i = vam->input;
20339 vl_api_netmap_create_t *mp;
20342 u8 random_hw_addr = 1;
20347 clib_memset (hw_addr, 0, sizeof (hw_addr));
20349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20351 if (unformat (i, "name %s", &if_name))
20352 vec_add1 (if_name, 0);
20353 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20354 random_hw_addr = 0;
20355 else if (unformat (i, "pipe"))
20357 else if (unformat (i, "master"))
20359 else if (unformat (i, "slave"))
20365 if (!vec_len (if_name))
20367 errmsg ("interface name must be specified");
20371 if (vec_len (if_name) > 64)
20373 errmsg ("interface name too long");
20377 M (NETMAP_CREATE, mp);
20379 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20380 clib_memcpy (mp->hw_addr, hw_addr, 6);
20381 mp->use_random_hw_addr = random_hw_addr;
20382 mp->is_pipe = is_pipe;
20383 mp->is_master = is_master;
20384 vec_free (if_name);
20392 api_netmap_delete (vat_main_t * vam)
20394 unformat_input_t *i = vam->input;
20395 vl_api_netmap_delete_t *mp;
20399 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20401 if (unformat (i, "name %s", &if_name))
20402 vec_add1 (if_name, 0);
20407 if (!vec_len (if_name))
20409 errmsg ("interface name must be specified");
20413 if (vec_len (if_name) > 64)
20415 errmsg ("interface name too long");
20419 M (NETMAP_DELETE, mp);
20421 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20422 vec_free (if_name);
20430 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20432 if (fp->afi == IP46_TYPE_IP6)
20434 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20435 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20436 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20437 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20438 format_ip6_address, fp->next_hop);
20439 else if (fp->afi == IP46_TYPE_IP4)
20441 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20442 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20443 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20444 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20445 format_ip4_address, fp->next_hop);
20449 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20450 vl_api_fib_path_t * fp)
20452 struct in_addr ip4;
20453 struct in6_addr ip6;
20455 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20456 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20457 vat_json_object_add_uint (node, "is_local", fp->is_local);
20458 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20459 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20460 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20461 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20462 if (fp->afi == IP46_TYPE_IP4)
20464 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20465 vat_json_object_add_ip4 (node, "next_hop", ip4);
20467 else if (fp->afi == IP46_TYPE_IP6)
20469 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20470 vat_json_object_add_ip6 (node, "next_hop", ip6);
20475 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20477 vat_main_t *vam = &vat_main;
20478 int count = ntohl (mp->mt_count);
20479 vl_api_fib_path_t *fp;
20482 print (vam->ofp, "[%d]: sw_if_index %d via:",
20483 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20485 for (i = 0; i < count; i++)
20487 vl_api_mpls_fib_path_print (vam, fp);
20491 print (vam->ofp, "");
20494 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20495 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20498 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20500 vat_main_t *vam = &vat_main;
20501 vat_json_node_t *node = NULL;
20502 int count = ntohl (mp->mt_count);
20503 vl_api_fib_path_t *fp;
20506 if (VAT_JSON_ARRAY != vam->json_tree.type)
20508 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20509 vat_json_init_array (&vam->json_tree);
20511 node = vat_json_array_add (&vam->json_tree);
20513 vat_json_init_object (node);
20514 vat_json_object_add_uint (node, "tunnel_index",
20515 ntohl (mp->mt_tunnel_index));
20516 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20518 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20521 for (i = 0; i < count; i++)
20523 vl_api_mpls_fib_path_json_print (node, fp);
20529 api_mpls_tunnel_dump (vat_main_t * vam)
20531 vl_api_mpls_tunnel_dump_t *mp;
20532 vl_api_control_ping_t *mp_ping;
20533 u32 sw_if_index = ~0;
20536 /* Parse args required to build the message */
20537 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20539 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
20543 print (vam->ofp, " sw_if_index %d", sw_if_index);
20545 M (MPLS_TUNNEL_DUMP, mp);
20546 mp->sw_if_index = htonl (sw_if_index);
20549 /* Use a control ping for synchronization */
20550 MPING (CONTROL_PING, mp_ping);
20557 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20558 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20562 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20564 vat_main_t *vam = &vat_main;
20565 int count = ntohl (mp->count);
20566 vl_api_fib_path_t *fp;
20570 "table-id %d, label %u, ess_bit %u",
20571 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20573 for (i = 0; i < count; i++)
20575 vl_api_mpls_fib_path_print (vam, fp);
20580 static void vl_api_mpls_fib_details_t_handler_json
20581 (vl_api_mpls_fib_details_t * mp)
20583 vat_main_t *vam = &vat_main;
20584 int count = ntohl (mp->count);
20585 vat_json_node_t *node = NULL;
20586 vl_api_fib_path_t *fp;
20589 if (VAT_JSON_ARRAY != vam->json_tree.type)
20591 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20592 vat_json_init_array (&vam->json_tree);
20594 node = vat_json_array_add (&vam->json_tree);
20596 vat_json_init_object (node);
20597 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20598 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20599 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20600 vat_json_object_add_uint (node, "path_count", count);
20602 for (i = 0; i < count; i++)
20604 vl_api_mpls_fib_path_json_print (node, fp);
20610 api_mpls_fib_dump (vat_main_t * vam)
20612 vl_api_mpls_fib_dump_t *mp;
20613 vl_api_control_ping_t *mp_ping;
20616 M (MPLS_FIB_DUMP, mp);
20619 /* Use a control ping for synchronization */
20620 MPING (CONTROL_PING, mp_ping);
20627 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20628 #define vl_api_ip_fib_details_t_print vl_noop_handler
20631 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20633 vat_main_t *vam = &vat_main;
20634 int count = ntohl (mp->count);
20635 vl_api_fib_path_t *fp;
20639 "table-id %d, prefix %U/%d stats-index %d",
20640 ntohl (mp->table_id), format_ip4_address, mp->address,
20641 mp->address_length, ntohl (mp->stats_index));
20643 for (i = 0; i < count; i++)
20645 if (fp->afi == IP46_TYPE_IP6)
20647 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20648 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20649 "next_hop_table %d",
20650 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20651 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20652 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20653 else if (fp->afi == IP46_TYPE_IP4)
20655 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20656 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20657 "next_hop_table %d",
20658 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20659 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20660 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20665 static void vl_api_ip_fib_details_t_handler_json
20666 (vl_api_ip_fib_details_t * mp)
20668 vat_main_t *vam = &vat_main;
20669 int count = ntohl (mp->count);
20670 vat_json_node_t *node = NULL;
20671 struct in_addr ip4;
20672 struct in6_addr ip6;
20673 vl_api_fib_path_t *fp;
20676 if (VAT_JSON_ARRAY != vam->json_tree.type)
20678 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20679 vat_json_init_array (&vam->json_tree);
20681 node = vat_json_array_add (&vam->json_tree);
20683 vat_json_init_object (node);
20684 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20685 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20686 vat_json_object_add_ip4 (node, "prefix", ip4);
20687 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20688 vat_json_object_add_uint (node, "path_count", count);
20690 for (i = 0; i < count; i++)
20692 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20693 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20694 vat_json_object_add_uint (node, "is_local", fp->is_local);
20695 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20696 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20697 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20698 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20699 if (fp->afi == IP46_TYPE_IP4)
20701 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20702 vat_json_object_add_ip4 (node, "next_hop", ip4);
20704 else if (fp->afi == IP46_TYPE_IP6)
20706 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20707 vat_json_object_add_ip6 (node, "next_hop", ip6);
20713 api_ip_fib_dump (vat_main_t * vam)
20715 vl_api_ip_fib_dump_t *mp;
20716 vl_api_control_ping_t *mp_ping;
20719 M (IP_FIB_DUMP, mp);
20722 /* Use a control ping for synchronization */
20723 MPING (CONTROL_PING, mp_ping);
20731 api_ip_mfib_dump (vat_main_t * vam)
20733 vl_api_ip_mfib_dump_t *mp;
20734 vl_api_control_ping_t *mp_ping;
20737 M (IP_MFIB_DUMP, mp);
20740 /* Use a control ping for synchronization */
20741 MPING (CONTROL_PING, mp_ping);
20748 static void vl_api_ip_neighbor_details_t_handler
20749 (vl_api_ip_neighbor_details_t * mp)
20751 vat_main_t *vam = &vat_main;
20753 print (vam->ofp, "%c %U %U",
20754 (mp->is_static) ? 'S' : 'D',
20755 format_ethernet_address, &mp->mac_address,
20756 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20760 static void vl_api_ip_neighbor_details_t_handler_json
20761 (vl_api_ip_neighbor_details_t * mp)
20764 vat_main_t *vam = &vat_main;
20765 vat_json_node_t *node;
20766 struct in_addr ip4;
20767 struct in6_addr ip6;
20769 if (VAT_JSON_ARRAY != vam->json_tree.type)
20771 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20772 vat_json_init_array (&vam->json_tree);
20774 node = vat_json_array_add (&vam->json_tree);
20776 vat_json_init_object (node);
20777 vat_json_object_add_string_copy (node, "flag",
20778 (mp->is_static) ? (u8 *) "static" : (u8 *)
20781 vat_json_object_add_string_copy (node, "link_layer",
20782 format (0, "%U", format_ethernet_address,
20783 &mp->mac_address));
20787 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20788 vat_json_object_add_ip6 (node, "ip_address", ip6);
20792 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20793 vat_json_object_add_ip4 (node, "ip_address", ip4);
20798 api_ip_neighbor_dump (vat_main_t * vam)
20800 unformat_input_t *i = vam->input;
20801 vl_api_ip_neighbor_dump_t *mp;
20802 vl_api_control_ping_t *mp_ping;
20804 u32 sw_if_index = ~0;
20807 /* Parse args required to build the message */
20808 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20810 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20812 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20814 else if (unformat (i, "ip6"))
20820 if (sw_if_index == ~0)
20822 errmsg ("missing interface name or sw_if_index");
20826 M (IP_NEIGHBOR_DUMP, mp);
20827 mp->is_ipv6 = (u8) is_ipv6;
20828 mp->sw_if_index = ntohl (sw_if_index);
20831 /* Use a control ping for synchronization */
20832 MPING (CONTROL_PING, mp_ping);
20839 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20840 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20843 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20845 vat_main_t *vam = &vat_main;
20846 int count = ntohl (mp->count);
20847 vl_api_fib_path_t *fp;
20851 "table-id %d, prefix %U/%d stats-index %d",
20852 ntohl (mp->table_id), format_ip6_address, mp->address,
20853 mp->address_length, ntohl (mp->stats_index));
20855 for (i = 0; i < count; i++)
20857 if (fp->afi == IP46_TYPE_IP6)
20859 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20860 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20861 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20862 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20863 format_ip6_address, fp->next_hop);
20864 else if (fp->afi == IP46_TYPE_IP4)
20866 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20867 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20868 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20869 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20870 format_ip4_address, fp->next_hop);
20875 static void vl_api_ip6_fib_details_t_handler_json
20876 (vl_api_ip6_fib_details_t * mp)
20878 vat_main_t *vam = &vat_main;
20879 int count = ntohl (mp->count);
20880 vat_json_node_t *node = NULL;
20881 struct in_addr ip4;
20882 struct in6_addr ip6;
20883 vl_api_fib_path_t *fp;
20886 if (VAT_JSON_ARRAY != vam->json_tree.type)
20888 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20889 vat_json_init_array (&vam->json_tree);
20891 node = vat_json_array_add (&vam->json_tree);
20893 vat_json_init_object (node);
20894 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20895 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20896 vat_json_object_add_ip6 (node, "prefix", ip6);
20897 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20898 vat_json_object_add_uint (node, "path_count", count);
20900 for (i = 0; i < count; i++)
20902 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20903 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20904 vat_json_object_add_uint (node, "is_local", fp->is_local);
20905 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20906 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20907 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20908 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20909 if (fp->afi == IP46_TYPE_IP4)
20911 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20912 vat_json_object_add_ip4 (node, "next_hop", ip4);
20914 else if (fp->afi == IP46_TYPE_IP6)
20916 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20917 vat_json_object_add_ip6 (node, "next_hop", ip6);
20923 api_ip6_fib_dump (vat_main_t * vam)
20925 vl_api_ip6_fib_dump_t *mp;
20926 vl_api_control_ping_t *mp_ping;
20929 M (IP6_FIB_DUMP, mp);
20932 /* Use a control ping for synchronization */
20933 MPING (CONTROL_PING, mp_ping);
20941 api_ip6_mfib_dump (vat_main_t * vam)
20943 vl_api_ip6_mfib_dump_t *mp;
20944 vl_api_control_ping_t *mp_ping;
20947 M (IP6_MFIB_DUMP, mp);
20950 /* Use a control ping for synchronization */
20951 MPING (CONTROL_PING, mp_ping);
20959 api_classify_table_ids (vat_main_t * vam)
20961 vl_api_classify_table_ids_t *mp;
20964 /* Construct the API message */
20965 M (CLASSIFY_TABLE_IDS, mp);
20974 api_classify_table_by_interface (vat_main_t * vam)
20976 unformat_input_t *input = vam->input;
20977 vl_api_classify_table_by_interface_t *mp;
20979 u32 sw_if_index = ~0;
20981 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20983 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20985 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20990 if (sw_if_index == ~0)
20992 errmsg ("missing interface name or sw_if_index");
20996 /* Construct the API message */
20997 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20999 mp->sw_if_index = ntohl (sw_if_index);
21007 api_classify_table_info (vat_main_t * vam)
21009 unformat_input_t *input = vam->input;
21010 vl_api_classify_table_info_t *mp;
21014 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21016 if (unformat (input, "table_id %d", &table_id))
21021 if (table_id == ~0)
21023 errmsg ("missing table id");
21027 /* Construct the API message */
21028 M (CLASSIFY_TABLE_INFO, mp);
21030 mp->table_id = ntohl (table_id);
21038 api_classify_session_dump (vat_main_t * vam)
21040 unformat_input_t *input = vam->input;
21041 vl_api_classify_session_dump_t *mp;
21042 vl_api_control_ping_t *mp_ping;
21046 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21048 if (unformat (input, "table_id %d", &table_id))
21053 if (table_id == ~0)
21055 errmsg ("missing table id");
21059 /* Construct the API message */
21060 M (CLASSIFY_SESSION_DUMP, mp);
21062 mp->table_id = ntohl (table_id);
21065 /* Use a control ping for synchronization */
21066 MPING (CONTROL_PING, mp_ping);
21074 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
21076 vat_main_t *vam = &vat_main;
21078 print (vam->ofp, "collector_address %U, collector_port %d, "
21079 "src_address %U, vrf_id %d, path_mtu %u, "
21080 "template_interval %u, udp_checksum %d",
21081 format_ip4_address, mp->collector_address,
21082 ntohs (mp->collector_port),
21083 format_ip4_address, mp->src_address,
21084 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
21085 ntohl (mp->template_interval), mp->udp_checksum);
21088 vam->result_ready = 1;
21092 vl_api_ipfix_exporter_details_t_handler_json
21093 (vl_api_ipfix_exporter_details_t * mp)
21095 vat_main_t *vam = &vat_main;
21096 vat_json_node_t node;
21097 struct in_addr collector_address;
21098 struct in_addr src_address;
21100 vat_json_init_object (&node);
21101 clib_memcpy (&collector_address, &mp->collector_address,
21102 sizeof (collector_address));
21103 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
21104 vat_json_object_add_uint (&node, "collector_port",
21105 ntohs (mp->collector_port));
21106 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
21107 vat_json_object_add_ip4 (&node, "src_address", src_address);
21108 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
21109 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
21110 vat_json_object_add_uint (&node, "template_interval",
21111 ntohl (mp->template_interval));
21112 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
21114 vat_json_print (vam->ofp, &node);
21115 vat_json_free (&node);
21117 vam->result_ready = 1;
21121 api_ipfix_exporter_dump (vat_main_t * vam)
21123 vl_api_ipfix_exporter_dump_t *mp;
21126 /* Construct the API message */
21127 M (IPFIX_EXPORTER_DUMP, mp);
21136 api_ipfix_classify_stream_dump (vat_main_t * vam)
21138 vl_api_ipfix_classify_stream_dump_t *mp;
21141 /* Construct the API message */
21142 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
21153 vl_api_ipfix_classify_stream_details_t_handler
21154 (vl_api_ipfix_classify_stream_details_t * mp)
21156 vat_main_t *vam = &vat_main;
21157 print (vam->ofp, "domain_id %d, src_port %d",
21158 ntohl (mp->domain_id), ntohs (mp->src_port));
21160 vam->result_ready = 1;
21164 vl_api_ipfix_classify_stream_details_t_handler_json
21165 (vl_api_ipfix_classify_stream_details_t * mp)
21167 vat_main_t *vam = &vat_main;
21168 vat_json_node_t node;
21170 vat_json_init_object (&node);
21171 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
21172 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
21174 vat_json_print (vam->ofp, &node);
21175 vat_json_free (&node);
21177 vam->result_ready = 1;
21181 api_ipfix_classify_table_dump (vat_main_t * vam)
21183 vl_api_ipfix_classify_table_dump_t *mp;
21184 vl_api_control_ping_t *mp_ping;
21187 if (!vam->json_output)
21189 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
21190 "transport_protocol");
21193 /* Construct the API message */
21194 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
21199 /* Use a control ping for synchronization */
21200 MPING (CONTROL_PING, mp_ping);
21208 vl_api_ipfix_classify_table_details_t_handler
21209 (vl_api_ipfix_classify_table_details_t * mp)
21211 vat_main_t *vam = &vat_main;
21212 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
21213 mp->transport_protocol);
21217 vl_api_ipfix_classify_table_details_t_handler_json
21218 (vl_api_ipfix_classify_table_details_t * mp)
21220 vat_json_node_t *node = NULL;
21221 vat_main_t *vam = &vat_main;
21223 if (VAT_JSON_ARRAY != vam->json_tree.type)
21225 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21226 vat_json_init_array (&vam->json_tree);
21229 node = vat_json_array_add (&vam->json_tree);
21230 vat_json_init_object (node);
21232 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
21233 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
21234 vat_json_object_add_uint (node, "transport_protocol",
21235 mp->transport_protocol);
21239 api_sw_interface_span_enable_disable (vat_main_t * vam)
21241 unformat_input_t *i = vam->input;
21242 vl_api_sw_interface_span_enable_disable_t *mp;
21243 u32 src_sw_if_index = ~0;
21244 u32 dst_sw_if_index = ~0;
21249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21252 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21254 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21258 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21260 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21262 else if (unformat (i, "disable"))
21264 else if (unformat (i, "rx"))
21266 else if (unformat (i, "tx"))
21268 else if (unformat (i, "both"))
21270 else if (unformat (i, "l2"))
21276 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21278 mp->sw_if_index_from = htonl (src_sw_if_index);
21279 mp->sw_if_index_to = htonl (dst_sw_if_index);
21289 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21292 vat_main_t *vam = &vat_main;
21293 u8 *sw_if_from_name = 0;
21294 u8 *sw_if_to_name = 0;
21295 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21296 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21297 char *states[] = { "none", "rx", "tx", "both" };
21301 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21303 if ((u32) p->value[0] == sw_if_index_from)
21305 sw_if_from_name = (u8 *)(p->key);
21309 if ((u32) p->value[0] == sw_if_index_to)
21311 sw_if_to_name = (u8 *)(p->key);
21312 if (sw_if_from_name)
21317 print (vam->ofp, "%20s => %20s (%s) %s",
21318 sw_if_from_name, sw_if_to_name, states[mp->state],
21319 mp->is_l2 ? "l2" : "device");
21323 vl_api_sw_interface_span_details_t_handler_json
21324 (vl_api_sw_interface_span_details_t * mp)
21326 vat_main_t *vam = &vat_main;
21327 vat_json_node_t *node = NULL;
21328 u8 *sw_if_from_name = 0;
21329 u8 *sw_if_to_name = 0;
21330 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21331 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21335 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21337 if ((u32) p->value[0] == sw_if_index_from)
21339 sw_if_from_name = (u8 *)(p->key);
21343 if ((u32) p->value[0] == sw_if_index_to)
21345 sw_if_to_name = (u8 *)(p->key);
21346 if (sw_if_from_name)
21352 if (VAT_JSON_ARRAY != vam->json_tree.type)
21354 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21355 vat_json_init_array (&vam->json_tree);
21357 node = vat_json_array_add (&vam->json_tree);
21359 vat_json_init_object (node);
21360 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21361 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21362 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21363 if (0 != sw_if_to_name)
21365 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21367 vat_json_object_add_uint (node, "state", mp->state);
21368 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21372 api_sw_interface_span_dump (vat_main_t * vam)
21374 unformat_input_t *input = vam->input;
21375 vl_api_sw_interface_span_dump_t *mp;
21376 vl_api_control_ping_t *mp_ping;
21380 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21382 if (unformat (input, "l2"))
21388 M (SW_INTERFACE_SPAN_DUMP, mp);
21392 /* Use a control ping for synchronization */
21393 MPING (CONTROL_PING, mp_ping);
21401 api_pg_create_interface (vat_main_t * vam)
21403 unformat_input_t *input = vam->input;
21404 vl_api_pg_create_interface_t *mp;
21408 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21410 if (unformat (input, "if_id %d", &if_id))
21417 errmsg ("missing pg interface index");
21421 /* Construct the API message */
21422 M (PG_CREATE_INTERFACE, mp);
21424 mp->interface_id = ntohl (if_id);
21432 api_pg_capture (vat_main_t * vam)
21434 unformat_input_t *input = vam->input;
21435 vl_api_pg_capture_t *mp;
21440 u8 pcap_file_set = 0;
21443 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21445 if (unformat (input, "if_id %d", &if_id))
21447 else if (unformat (input, "pcap %s", &pcap_file))
21449 else if (unformat (input, "count %d", &count))
21451 else if (unformat (input, "disable"))
21458 errmsg ("missing pg interface index");
21461 if (pcap_file_set > 0)
21463 if (vec_len (pcap_file) > 255)
21465 errmsg ("pcap file name is too long");
21470 u32 name_len = vec_len (pcap_file);
21471 /* Construct the API message */
21472 M (PG_CAPTURE, mp);
21474 mp->interface_id = ntohl (if_id);
21475 mp->is_enabled = enable;
21476 mp->count = ntohl (count);
21477 mp->pcap_name_length = ntohl (name_len);
21478 if (pcap_file_set != 0)
21480 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21482 vec_free (pcap_file);
21490 api_pg_enable_disable (vat_main_t * vam)
21492 unformat_input_t *input = vam->input;
21493 vl_api_pg_enable_disable_t *mp;
21496 u8 stream_name_set = 0;
21497 u8 *stream_name = 0;
21499 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21501 if (unformat (input, "stream %s", &stream_name))
21502 stream_name_set = 1;
21503 else if (unformat (input, "disable"))
21509 if (stream_name_set > 0)
21511 if (vec_len (stream_name) > 255)
21513 errmsg ("stream name too long");
21518 u32 name_len = vec_len (stream_name);
21519 /* Construct the API message */
21520 M (PG_ENABLE_DISABLE, mp);
21522 mp->is_enabled = enable;
21523 if (stream_name_set != 0)
21525 mp->stream_name_length = ntohl (name_len);
21526 clib_memcpy (mp->stream_name, stream_name, name_len);
21528 vec_free (stream_name);
21536 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21538 unformat_input_t *input = vam->input;
21539 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21541 u16 *low_ports = 0;
21542 u16 *high_ports = 0;
21545 ip4_address_t ip4_addr;
21546 ip6_address_t ip6_addr;
21555 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21557 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21563 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21568 else if (unformat (input, "vrf %d", &vrf_id))
21570 else if (unformat (input, "del"))
21572 else if (unformat (input, "port %d", &tmp))
21574 if (tmp == 0 || tmp > 65535)
21576 errmsg ("port %d out of range", tmp);
21580 this_hi = this_low + 1;
21581 vec_add1 (low_ports, this_low);
21582 vec_add1 (high_ports, this_hi);
21584 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21586 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21588 errmsg ("incorrect range parameters");
21592 /* Note: in debug CLI +1 is added to high before
21593 passing to real fn that does "the work"
21594 (ip_source_and_port_range_check_add_del).
21595 This fn is a wrapper around the binary API fn a
21596 control plane will call, which expects this increment
21597 to have occurred. Hence letting the binary API control
21598 plane fn do the increment for consistency between VAT
21599 and other control planes.
21602 vec_add1 (low_ports, this_low);
21603 vec_add1 (high_ports, this_hi);
21609 if (prefix_set == 0)
21611 errmsg ("<address>/<mask> not specified");
21617 errmsg ("VRF ID required, not specified");
21624 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21628 if (vec_len (low_ports) == 0)
21630 errmsg ("At least one port or port range required");
21634 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21636 mp->is_add = is_add;
21641 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21646 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21649 mp->mask_length = length;
21650 mp->number_of_ranges = vec_len (low_ports);
21652 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21653 vec_free (low_ports);
21655 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21656 vec_free (high_ports);
21658 mp->vrf_id = ntohl (vrf_id);
21666 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21668 unformat_input_t *input = vam->input;
21669 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21670 u32 sw_if_index = ~0;
21672 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21673 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21677 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21679 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21681 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21683 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21685 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21687 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21689 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21691 else if (unformat (input, "del"))
21697 if (sw_if_index == ~0)
21699 errmsg ("Interface required but not specified");
21705 errmsg ("VRF ID required but not specified");
21709 if (tcp_out_vrf_id == 0
21710 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21713 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21717 /* Construct the API message */
21718 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21720 mp->sw_if_index = ntohl (sw_if_index);
21721 mp->is_add = is_add;
21722 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21723 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21724 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21725 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21730 /* Wait for a reply... */
21736 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21738 unformat_input_t *i = vam->input;
21739 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21740 u32 local_sa_id = 0;
21741 u32 remote_sa_id = 0;
21742 ip4_address_t src_address;
21743 ip4_address_t dst_address;
21747 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21749 if (unformat (i, "local_sa %d", &local_sa_id))
21751 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21753 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21755 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21757 else if (unformat (i, "del"))
21761 clib_warning ("parse error '%U'", format_unformat_error, i);
21766 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21768 mp->local_sa_id = ntohl (local_sa_id);
21769 mp->remote_sa_id = ntohl (remote_sa_id);
21770 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21771 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21772 mp->is_add = is_add;
21780 api_punt (vat_main_t * vam)
21782 unformat_input_t *i = vam->input;
21790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21792 if (unformat (i, "ip %d", &ipv))
21794 else if (unformat (i, "protocol %d", &protocol))
21796 else if (unformat (i, "port %d", &port))
21798 else if (unformat (i, "del"))
21802 clib_warning ("parse error '%U'", format_unformat_error, i);
21809 mp->is_add = (u8) is_add;
21810 mp->ipv = (u8) ipv;
21811 mp->l4_protocol = (u8) protocol;
21812 mp->l4_port = htons ((u16) port);
21819 static void vl_api_ipsec_gre_tunnel_details_t_handler
21820 (vl_api_ipsec_gre_tunnel_details_t * mp)
21822 vat_main_t *vam = &vat_main;
21824 print (vam->ofp, "%11d%15U%15U%14d%14d",
21825 ntohl (mp->sw_if_index),
21826 format_ip4_address, &mp->src_address,
21827 format_ip4_address, &mp->dst_address,
21828 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21831 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21832 (vl_api_ipsec_gre_tunnel_details_t * mp)
21834 vat_main_t *vam = &vat_main;
21835 vat_json_node_t *node = NULL;
21836 struct in_addr ip4;
21838 if (VAT_JSON_ARRAY != vam->json_tree.type)
21840 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21841 vat_json_init_array (&vam->json_tree);
21843 node = vat_json_array_add (&vam->json_tree);
21845 vat_json_init_object (node);
21846 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21847 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21848 vat_json_object_add_ip4 (node, "src_address", ip4);
21849 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21850 vat_json_object_add_ip4 (node, "dst_address", ip4);
21851 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21852 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21856 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21858 unformat_input_t *i = vam->input;
21859 vl_api_ipsec_gre_tunnel_dump_t *mp;
21860 vl_api_control_ping_t *mp_ping;
21862 u8 sw_if_index_set = 0;
21865 /* Parse args required to build the message */
21866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21868 if (unformat (i, "sw_if_index %d", &sw_if_index))
21869 sw_if_index_set = 1;
21874 if (sw_if_index_set == 0)
21879 if (!vam->json_output)
21881 print (vam->ofp, "%11s%15s%15s%14s%14s",
21882 "sw_if_index", "src_address", "dst_address",
21883 "local_sa_id", "remote_sa_id");
21886 /* Get list of gre-tunnel interfaces */
21887 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21889 mp->sw_if_index = htonl (sw_if_index);
21893 /* Use a control ping for synchronization */
21894 MPING (CONTROL_PING, mp_ping);
21902 api_delete_subif (vat_main_t * vam)
21904 unformat_input_t *i = vam->input;
21905 vl_api_delete_subif_t *mp;
21906 u32 sw_if_index = ~0;
21909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21911 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21913 if (unformat (i, "sw_if_index %d", &sw_if_index))
21919 if (sw_if_index == ~0)
21921 errmsg ("missing sw_if_index");
21925 /* Construct the API message */
21926 M (DELETE_SUBIF, mp);
21927 mp->sw_if_index = ntohl (sw_if_index);
21934 #define foreach_pbb_vtr_op \
21935 _("disable", L2_VTR_DISABLED) \
21936 _("pop", L2_VTR_POP_2) \
21937 _("push", L2_VTR_PUSH_2)
21940 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21942 unformat_input_t *i = vam->input;
21943 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21944 u32 sw_if_index = ~0, vtr_op = ~0;
21945 u16 outer_tag = ~0;
21946 u8 dmac[6], smac[6];
21947 u8 dmac_set = 0, smac_set = 0;
21953 /* Shut up coverity */
21954 clib_memset (dmac, 0, sizeof (dmac));
21955 clib_memset (smac, 0, sizeof (smac));
21957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21959 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21961 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21963 else if (unformat (i, "vtr_op %d", &vtr_op))
21965 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21968 else if (unformat (i, "translate_pbb_stag"))
21970 if (unformat (i, "%d", &tmp))
21972 vtr_op = L2_VTR_TRANSLATE_2_1;
21978 ("translate_pbb_stag operation requires outer tag definition");
21982 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21984 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21986 else if (unformat (i, "sid %d", &sid))
21988 else if (unformat (i, "vlanid %d", &tmp))
21992 clib_warning ("parse error '%U'", format_unformat_error, i);
21997 if ((sw_if_index == ~0) || (vtr_op == ~0))
21999 errmsg ("missing sw_if_index or vtr operation");
22002 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
22003 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
22006 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
22010 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
22011 mp->sw_if_index = ntohl (sw_if_index);
22012 mp->vtr_op = ntohl (vtr_op);
22013 mp->outer_tag = ntohs (outer_tag);
22014 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
22015 clib_memcpy (mp->b_smac, smac, sizeof (smac));
22016 mp->b_vlanid = ntohs (vlanid);
22017 mp->i_sid = ntohl (sid);
22025 api_flow_classify_set_interface (vat_main_t * vam)
22027 unformat_input_t *i = vam->input;
22028 vl_api_flow_classify_set_interface_t *mp;
22030 int sw_if_index_set;
22031 u32 ip4_table_index = ~0;
22032 u32 ip6_table_index = ~0;
22036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22038 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22039 sw_if_index_set = 1;
22040 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22041 sw_if_index_set = 1;
22042 else if (unformat (i, "del"))
22044 else if (unformat (i, "ip4-table %d", &ip4_table_index))
22046 else if (unformat (i, "ip6-table %d", &ip6_table_index))
22050 clib_warning ("parse error '%U'", format_unformat_error, i);
22055 if (sw_if_index_set == 0)
22057 errmsg ("missing interface name or sw_if_index");
22061 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
22063 mp->sw_if_index = ntohl (sw_if_index);
22064 mp->ip4_table_index = ntohl (ip4_table_index);
22065 mp->ip6_table_index = ntohl (ip6_table_index);
22066 mp->is_add = is_add;
22074 api_flow_classify_dump (vat_main_t * vam)
22076 unformat_input_t *i = vam->input;
22077 vl_api_flow_classify_dump_t *mp;
22078 vl_api_control_ping_t *mp_ping;
22079 u8 type = FLOW_CLASSIFY_N_TABLES;
22082 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
22086 errmsg ("classify table type must be specified");
22090 if (!vam->json_output)
22092 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
22095 M (FLOW_CLASSIFY_DUMP, mp);
22100 /* Use a control ping for synchronization */
22101 MPING (CONTROL_PING, mp_ping);
22104 /* Wait for a reply... */
22110 api_feature_enable_disable (vat_main_t * vam)
22112 unformat_input_t *i = vam->input;
22113 vl_api_feature_enable_disable_t *mp;
22115 u8 *feature_name = 0;
22116 u32 sw_if_index = ~0;
22120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22122 if (unformat (i, "arc_name %s", &arc_name))
22124 else if (unformat (i, "feature_name %s", &feature_name))
22127 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22129 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22131 else if (unformat (i, "disable"))
22139 errmsg ("missing arc name");
22142 if (vec_len (arc_name) > 63)
22144 errmsg ("arc name too long");
22147 if (feature_name == 0)
22149 errmsg ("missing feature name");
22152 if (vec_len (feature_name) > 63)
22154 errmsg ("feature name too long");
22157 if (sw_if_index == ~0)
22159 errmsg ("missing interface name or sw_if_index");
22163 /* Construct the API message */
22164 M (FEATURE_ENABLE_DISABLE, mp);
22165 mp->sw_if_index = ntohl (sw_if_index);
22166 mp->enable = enable;
22167 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
22168 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
22169 vec_free (arc_name);
22170 vec_free (feature_name);
22178 api_sw_interface_tag_add_del (vat_main_t * vam)
22180 unformat_input_t *i = vam->input;
22181 vl_api_sw_interface_tag_add_del_t *mp;
22182 u32 sw_if_index = ~0;
22187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22189 if (unformat (i, "tag %s", &tag))
22191 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22193 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22195 else if (unformat (i, "del"))
22201 if (sw_if_index == ~0)
22203 errmsg ("missing interface name or sw_if_index");
22207 if (enable && (tag == 0))
22209 errmsg ("no tag specified");
22213 /* Construct the API message */
22214 M (SW_INTERFACE_TAG_ADD_DEL, mp);
22215 mp->sw_if_index = ntohl (sw_if_index);
22216 mp->is_add = enable;
22218 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
22226 static void vl_api_l2_xconnect_details_t_handler
22227 (vl_api_l2_xconnect_details_t * mp)
22229 vat_main_t *vam = &vat_main;
22231 print (vam->ofp, "%15d%15d",
22232 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
22235 static void vl_api_l2_xconnect_details_t_handler_json
22236 (vl_api_l2_xconnect_details_t * mp)
22238 vat_main_t *vam = &vat_main;
22239 vat_json_node_t *node = NULL;
22241 if (VAT_JSON_ARRAY != vam->json_tree.type)
22243 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22244 vat_json_init_array (&vam->json_tree);
22246 node = vat_json_array_add (&vam->json_tree);
22248 vat_json_init_object (node);
22249 vat_json_object_add_uint (node, "rx_sw_if_index",
22250 ntohl (mp->rx_sw_if_index));
22251 vat_json_object_add_uint (node, "tx_sw_if_index",
22252 ntohl (mp->tx_sw_if_index));
22256 api_l2_xconnect_dump (vat_main_t * vam)
22258 vl_api_l2_xconnect_dump_t *mp;
22259 vl_api_control_ping_t *mp_ping;
22262 if (!vam->json_output)
22264 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22267 M (L2_XCONNECT_DUMP, mp);
22271 /* Use a control ping for synchronization */
22272 MPING (CONTROL_PING, mp_ping);
22280 api_hw_interface_set_mtu (vat_main_t * vam)
22282 unformat_input_t *i = vam->input;
22283 vl_api_hw_interface_set_mtu_t *mp;
22284 u32 sw_if_index = ~0;
22288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22290 if (unformat (i, "mtu %d", &mtu))
22292 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22294 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22300 if (sw_if_index == ~0)
22302 errmsg ("missing interface name or sw_if_index");
22308 errmsg ("no mtu specified");
22312 /* Construct the API message */
22313 M (HW_INTERFACE_SET_MTU, mp);
22314 mp->sw_if_index = ntohl (sw_if_index);
22315 mp->mtu = ntohs ((u16) mtu);
22323 api_p2p_ethernet_add (vat_main_t * vam)
22325 unformat_input_t *i = vam->input;
22326 vl_api_p2p_ethernet_add_t *mp;
22327 u32 parent_if_index = ~0;
22333 clib_memset (remote_mac, 0, sizeof (remote_mac));
22334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22336 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22338 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22342 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22344 else if (unformat (i, "sub_id %d", &sub_id))
22348 clib_warning ("parse error '%U'", format_unformat_error, i);
22353 if (parent_if_index == ~0)
22355 errmsg ("missing interface name or sw_if_index");
22360 errmsg ("missing remote mac address");
22365 errmsg ("missing sub-interface id");
22369 M (P2P_ETHERNET_ADD, mp);
22370 mp->parent_if_index = ntohl (parent_if_index);
22371 mp->subif_id = ntohl (sub_id);
22372 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22380 api_p2p_ethernet_del (vat_main_t * vam)
22382 unformat_input_t *i = vam->input;
22383 vl_api_p2p_ethernet_del_t *mp;
22384 u32 parent_if_index = ~0;
22389 clib_memset (remote_mac, 0, sizeof (remote_mac));
22390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22392 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22394 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22398 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22402 clib_warning ("parse error '%U'", format_unformat_error, i);
22407 if (parent_if_index == ~0)
22409 errmsg ("missing interface name or sw_if_index");
22414 errmsg ("missing remote mac address");
22418 M (P2P_ETHERNET_DEL, mp);
22419 mp->parent_if_index = ntohl (parent_if_index);
22420 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22428 api_lldp_config (vat_main_t * vam)
22430 unformat_input_t *i = vam->input;
22431 vl_api_lldp_config_t *mp;
22433 int tx_interval = 0;
22434 u8 *sys_name = NULL;
22437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22439 if (unformat (i, "system-name %s", &sys_name))
22441 else if (unformat (i, "tx-hold %d", &tx_hold))
22443 else if (unformat (i, "tx-interval %d", &tx_interval))
22447 clib_warning ("parse error '%U'", format_unformat_error, i);
22452 vec_add1 (sys_name, 0);
22454 M (LLDP_CONFIG, mp);
22455 mp->tx_hold = htonl (tx_hold);
22456 mp->tx_interval = htonl (tx_interval);
22457 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22458 vec_free (sys_name);
22466 api_sw_interface_set_lldp (vat_main_t * vam)
22468 unformat_input_t *i = vam->input;
22469 vl_api_sw_interface_set_lldp_t *mp;
22470 u32 sw_if_index = ~0;
22472 u8 *port_desc = NULL, *mgmt_oid = NULL;
22473 ip4_address_t ip4_addr;
22474 ip6_address_t ip6_addr;
22477 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
22478 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
22480 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22482 if (unformat (i, "disable"))
22485 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22487 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22489 else if (unformat (i, "port-desc %s", &port_desc))
22491 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22493 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22495 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22501 if (sw_if_index == ~0)
22503 errmsg ("missing interface name or sw_if_index");
22507 /* Construct the API message */
22508 vec_add1 (port_desc, 0);
22509 vec_add1 (mgmt_oid, 0);
22510 M (SW_INTERFACE_SET_LLDP, mp);
22511 mp->sw_if_index = ntohl (sw_if_index);
22512 mp->enable = enable;
22513 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22514 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22515 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22516 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22517 vec_free (port_desc);
22518 vec_free (mgmt_oid);
22526 api_tcp_configure_src_addresses (vat_main_t * vam)
22528 vl_api_tcp_configure_src_addresses_t *mp;
22529 unformat_input_t *i = vam->input;
22530 ip4_address_t v4first, v4last;
22531 ip6_address_t v6first, v6last;
22536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22538 if (unformat (i, "%U - %U",
22539 unformat_ip4_address, &v4first,
22540 unformat_ip4_address, &v4last))
22544 errmsg ("one range per message (range already set)");
22549 else if (unformat (i, "%U - %U",
22550 unformat_ip6_address, &v6first,
22551 unformat_ip6_address, &v6last))
22555 errmsg ("one range per message (range already set)");
22560 else if (unformat (i, "vrf %d", &vrf_id))
22566 if (range_set == 0)
22568 errmsg ("address range not set");
22572 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22573 mp->vrf_id = ntohl (vrf_id);
22575 if (range_set == 2)
22578 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22579 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22584 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22585 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22592 static void vl_api_app_namespace_add_del_reply_t_handler
22593 (vl_api_app_namespace_add_del_reply_t * mp)
22595 vat_main_t *vam = &vat_main;
22596 i32 retval = ntohl (mp->retval);
22597 if (vam->async_mode)
22599 vam->async_errors += (retval < 0);
22603 vam->retval = retval;
22605 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22606 vam->result_ready = 1;
22610 static void vl_api_app_namespace_add_del_reply_t_handler_json
22611 (vl_api_app_namespace_add_del_reply_t * mp)
22613 vat_main_t *vam = &vat_main;
22614 vat_json_node_t node;
22616 vat_json_init_object (&node);
22617 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22618 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22620 vat_json_print (vam->ofp, &node);
22621 vat_json_free (&node);
22623 vam->retval = ntohl (mp->retval);
22624 vam->result_ready = 1;
22628 api_app_namespace_add_del (vat_main_t * vam)
22630 vl_api_app_namespace_add_del_t *mp;
22631 unformat_input_t *i = vam->input;
22632 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22633 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22637 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22639 if (unformat (i, "id %_%v%_", &ns_id))
22641 else if (unformat (i, "secret %lu", &secret))
22643 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22644 sw_if_index_set = 1;
22645 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22647 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22652 if (!ns_id || !secret_set || !sw_if_index_set)
22654 errmsg ("namespace id, secret and sw_if_index must be set");
22657 if (vec_len (ns_id) > 64)
22659 errmsg ("namespace id too long");
22662 M (APP_NAMESPACE_ADD_DEL, mp);
22664 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22665 mp->namespace_id_len = vec_len (ns_id);
22666 mp->secret = clib_host_to_net_u64 (secret);
22667 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22668 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22669 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22677 api_sock_init_shm (vat_main_t * vam)
22679 #if VPP_API_TEST_BUILTIN == 0
22680 unformat_input_t *i = vam->input;
22681 vl_api_shm_elem_config_t *config = 0;
22682 u64 size = 64 << 20;
22685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22687 if (unformat (i, "size %U", unformat_memory_size, &size))
22694 * Canned custom ring allocator config.
22695 * Should probably parse all of this
22697 vec_validate (config, 6);
22698 config[0].type = VL_API_VLIB_RING;
22699 config[0].size = 256;
22700 config[0].count = 32;
22702 config[1].type = VL_API_VLIB_RING;
22703 config[1].size = 1024;
22704 config[1].count = 16;
22706 config[2].type = VL_API_VLIB_RING;
22707 config[2].size = 4096;
22708 config[2].count = 2;
22710 config[3].type = VL_API_CLIENT_RING;
22711 config[3].size = 256;
22712 config[3].count = 32;
22714 config[4].type = VL_API_CLIENT_RING;
22715 config[4].size = 1024;
22716 config[4].count = 16;
22718 config[5].type = VL_API_CLIENT_RING;
22719 config[5].size = 4096;
22720 config[5].count = 2;
22722 config[6].type = VL_API_QUEUE;
22723 config[6].count = 128;
22724 config[6].size = sizeof (uword);
22726 rv = vl_socket_client_init_shm (config);
22728 vam->client_index_invalid = 1;
22736 api_dns_enable_disable (vat_main_t * vam)
22738 unformat_input_t *line_input = vam->input;
22739 vl_api_dns_enable_disable_t *mp;
22740 u8 enable_disable = 1;
22743 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22745 if (unformat (line_input, "disable"))
22746 enable_disable = 0;
22747 if (unformat (line_input, "enable"))
22748 enable_disable = 1;
22753 /* Construct the API message */
22754 M (DNS_ENABLE_DISABLE, mp);
22755 mp->enable = enable_disable;
22759 /* Wait for the reply */
22765 api_dns_resolve_name (vat_main_t * vam)
22767 unformat_input_t *line_input = vam->input;
22768 vl_api_dns_resolve_name_t *mp;
22772 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22774 if (unformat (line_input, "%s", &name))
22780 if (vec_len (name) > 127)
22782 errmsg ("name too long");
22786 /* Construct the API message */
22787 M (DNS_RESOLVE_NAME, mp);
22788 memcpy (mp->name, name, vec_len (name));
22793 /* Wait for the reply */
22799 api_dns_resolve_ip (vat_main_t * vam)
22801 unformat_input_t *line_input = vam->input;
22802 vl_api_dns_resolve_ip_t *mp;
22804 ip4_address_t addr4;
22805 ip6_address_t addr6;
22808 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22810 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22812 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22820 errmsg ("missing address");
22824 /* Construct the API message */
22825 M (DNS_RESOLVE_IP, mp);
22826 mp->is_ip6 = is_ip6;
22828 memcpy (mp->address, &addr6, sizeof (addr6));
22830 memcpy (mp->address, &addr4, sizeof (addr4));
22834 /* Wait for the reply */
22840 api_dns_name_server_add_del (vat_main_t * vam)
22842 unformat_input_t *i = vam->input;
22843 vl_api_dns_name_server_add_del_t *mp;
22845 ip6_address_t ip6_server;
22846 ip4_address_t ip4_server;
22851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22853 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22855 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22857 else if (unformat (i, "del"))
22861 clib_warning ("parse error '%U'", format_unformat_error, i);
22866 if (ip4_set && ip6_set)
22868 errmsg ("Only one server address allowed per message");
22871 if ((ip4_set + ip6_set) == 0)
22873 errmsg ("Server address required");
22877 /* Construct the API message */
22878 M (DNS_NAME_SERVER_ADD_DEL, mp);
22882 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22887 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22891 mp->is_add = is_add;
22896 /* Wait for a reply, return good/bad news */
22902 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22904 vat_main_t *vam = &vat_main;
22909 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22910 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22911 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22912 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22913 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22914 clib_net_to_host_u32 (mp->action_index), mp->tag);
22919 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22920 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22921 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22922 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22923 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22924 clib_net_to_host_u32 (mp->action_index), mp->tag);
22929 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22932 vat_main_t *vam = &vat_main;
22933 vat_json_node_t *node = NULL;
22934 struct in6_addr ip6;
22935 struct in_addr ip4;
22937 if (VAT_JSON_ARRAY != vam->json_tree.type)
22939 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22940 vat_json_init_array (&vam->json_tree);
22942 node = vat_json_array_add (&vam->json_tree);
22943 vat_json_init_object (node);
22945 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22946 vat_json_object_add_uint (node, "appns_index",
22947 clib_net_to_host_u32 (mp->appns_index));
22948 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22949 vat_json_object_add_uint (node, "scope", mp->scope);
22950 vat_json_object_add_uint (node, "action_index",
22951 clib_net_to_host_u32 (mp->action_index));
22952 vat_json_object_add_uint (node, "lcl_port",
22953 clib_net_to_host_u16 (mp->lcl_port));
22954 vat_json_object_add_uint (node, "rmt_port",
22955 clib_net_to_host_u16 (mp->rmt_port));
22956 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22957 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22958 vat_json_object_add_string_copy (node, "tag", mp->tag);
22961 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22962 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22963 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22964 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22968 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22969 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22970 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22971 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22976 api_session_rule_add_del (vat_main_t * vam)
22978 vl_api_session_rule_add_del_t *mp;
22979 unformat_input_t *i = vam->input;
22980 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22981 u32 appns_index = 0, scope = 0;
22982 ip4_address_t lcl_ip4, rmt_ip4;
22983 ip6_address_t lcl_ip6, rmt_ip6;
22984 u8 is_ip4 = 1, conn_set = 0;
22985 u8 is_add = 1, *tag = 0;
22988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22990 if (unformat (i, "del"))
22992 else if (unformat (i, "add"))
22994 else if (unformat (i, "proto tcp"))
22996 else if (unformat (i, "proto udp"))
22998 else if (unformat (i, "appns %d", &appns_index))
23000 else if (unformat (i, "scope %d", &scope))
23002 else if (unformat (i, "tag %_%v%_", &tag))
23006 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
23007 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
23015 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
23016 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
23022 else if (unformat (i, "action %d", &action))
23027 if (proto == ~0 || !conn_set || action == ~0)
23029 errmsg ("transport proto, connection and action must be set");
23035 errmsg ("scope should be 0-3");
23039 M (SESSION_RULE_ADD_DEL, mp);
23041 mp->is_ip4 = is_ip4;
23042 mp->transport_proto = proto;
23043 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
23044 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
23045 mp->lcl_plen = lcl_plen;
23046 mp->rmt_plen = rmt_plen;
23047 mp->action_index = clib_host_to_net_u32 (action);
23048 mp->appns_index = clib_host_to_net_u32 (appns_index);
23050 mp->is_add = is_add;
23053 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
23054 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
23058 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
23059 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
23063 clib_memcpy (mp->tag, tag, vec_len (tag));
23073 api_session_rules_dump (vat_main_t * vam)
23075 vl_api_session_rules_dump_t *mp;
23076 vl_api_control_ping_t *mp_ping;
23079 if (!vam->json_output)
23081 print (vam->ofp, "%=20s", "Session Rules");
23084 M (SESSION_RULES_DUMP, mp);
23088 /* Use a control ping for synchronization */
23089 MPING (CONTROL_PING, mp_ping);
23092 /* Wait for a reply... */
23098 api_ip_container_proxy_add_del (vat_main_t * vam)
23100 vl_api_ip_container_proxy_add_del_t *mp;
23101 unformat_input_t *i = vam->input;
23102 u32 plen = ~0, sw_if_index = ~0;
23109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23111 if (unformat (i, "del"))
23113 else if (unformat (i, "add"))
23115 if (unformat (i, "%U", unformat_ip4_address, &ip4))
23120 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
23125 else if (unformat (i, "sw_if_index %u", &sw_if_index))
23130 if (sw_if_index == ~0 || plen == ~0)
23132 errmsg ("address and sw_if_index must be set");
23136 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
23138 mp->is_ip4 = is_ip4;
23139 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
23141 mp->is_add = is_add;
23143 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
23145 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
23153 api_qos_record_enable_disable (vat_main_t * vam)
23155 unformat_input_t *i = vam->input;
23156 vl_api_qos_record_enable_disable_t *mp;
23157 u32 sw_if_index, qs = 0xff;
23158 u8 sw_if_index_set = 0;
23162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23164 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
23165 sw_if_index_set = 1;
23166 else if (unformat (i, "sw_if_index %d", &sw_if_index))
23167 sw_if_index_set = 1;
23168 else if (unformat (i, "%U", unformat_qos_source, &qs))
23170 else if (unformat (i, "disable"))
23174 clib_warning ("parse error '%U'", format_unformat_error, i);
23179 if (sw_if_index_set == 0)
23181 errmsg ("missing interface name or sw_if_index");
23186 errmsg ("input location must be specified");
23190 M (QOS_RECORD_ENABLE_DISABLE, mp);
23192 mp->sw_if_index = ntohl (sw_if_index);
23193 mp->input_source = qs;
23194 mp->enable = enable;
23203 q_or_quit (vat_main_t * vam)
23205 #if VPP_API_TEST_BUILTIN == 0
23206 longjmp (vam->jump_buf, 1);
23208 return 0; /* not so much */
23212 q (vat_main_t * vam)
23214 return q_or_quit (vam);
23218 quit (vat_main_t * vam)
23220 return q_or_quit (vam);
23224 comment (vat_main_t * vam)
23230 statseg (vat_main_t * vam)
23232 ssvm_private_t *ssvmp = &vam->stat_segment;
23233 ssvm_shared_header_t *shared_header = ssvmp->sh;
23234 vlib_counter_t **counters;
23235 u64 thread0_index1_packets;
23236 u64 thread0_index1_bytes;
23237 f64 vector_rate, input_rate;
23240 uword *counter_vector_by_name;
23241 if (vam->stat_segment_lockp == 0)
23243 errmsg ("Stat segment not mapped...");
23247 /* look up "/if/rx for sw_if_index 1 as a test */
23249 clib_spinlock_lock (vam->stat_segment_lockp);
23251 counter_vector_by_name = (uword *) shared_header->opaque[1];
23253 p = hash_get_mem (counter_vector_by_name, "/if/rx");
23256 clib_spinlock_unlock (vam->stat_segment_lockp);
23257 errmsg ("/if/tx not found?");
23261 /* Fish per-thread vector of combined counters from shared memory */
23262 counters = (vlib_counter_t **) p[0];
23264 if (vec_len (counters[0]) < 2)
23266 clib_spinlock_unlock (vam->stat_segment_lockp);
23267 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
23271 /* Read thread 0 sw_if_index 1 counter */
23272 thread0_index1_packets = counters[0][1].packets;
23273 thread0_index1_bytes = counters[0][1].bytes;
23275 p = hash_get_mem (counter_vector_by_name, "vector_rate");
23278 clib_spinlock_unlock (vam->stat_segment_lockp);
23279 errmsg ("vector_rate not found?");
23283 vector_rate = *(f64 *) (p[0]);
23284 p = hash_get_mem (counter_vector_by_name, "input_rate");
23287 clib_spinlock_unlock (vam->stat_segment_lockp);
23288 errmsg ("input_rate not found?");
23291 input_rate = *(f64 *) (p[0]);
23293 clib_spinlock_unlock (vam->stat_segment_lockp);
23295 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
23296 vector_rate, input_rate);
23297 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
23298 thread0_index1_packets, thread0_index1_bytes);
23304 cmd_cmp (void *a1, void *a2)
23309 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23313 help (vat_main_t * vam)
23318 unformat_input_t *i = vam->input;
23321 if (unformat (i, "%s", &name))
23325 vec_add1 (name, 0);
23327 hs = hash_get_mem (vam->help_by_name, name);
23329 print (vam->ofp, "usage: %s %s", name, hs[0]);
23331 print (vam->ofp, "No such msg / command '%s'", name);
23336 print (vam->ofp, "Help is available for the following:");
23339 hash_foreach_pair (p, vam->function_by_name,
23341 vec_add1 (cmds, (u8 *)(p->key));
23345 vec_sort_with_function (cmds, cmd_cmp);
23347 for (j = 0; j < vec_len (cmds); j++)
23348 print (vam->ofp, "%s", cmds[j]);
23355 set (vat_main_t * vam)
23357 u8 *name = 0, *value = 0;
23358 unformat_input_t *i = vam->input;
23360 if (unformat (i, "%s", &name))
23362 /* The input buffer is a vector, not a string. */
23363 value = vec_dup (i->buffer);
23364 vec_delete (value, i->index, 0);
23365 /* Almost certainly has a trailing newline */
23366 if (value[vec_len (value) - 1] == '\n')
23367 value[vec_len (value) - 1] = 0;
23368 /* Make sure it's a proper string, one way or the other */
23369 vec_add1 (value, 0);
23370 (void) clib_macro_set_value (&vam->macro_main,
23371 (char *) name, (char *) value);
23374 errmsg ("usage: set <name> <value>");
23382 unset (vat_main_t * vam)
23386 if (unformat (vam->input, "%s", &name))
23387 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23388 errmsg ("unset: %s wasn't set", name);
23401 macro_sort_cmp (void *a1, void *a2)
23403 macro_sort_t *s1 = a1;
23404 macro_sort_t *s2 = a2;
23406 return strcmp ((char *) (s1->name), (char *) (s2->name));
23410 dump_macro_table (vat_main_t * vam)
23412 macro_sort_t *sort_me = 0, *sm;
23417 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23419 vec_add2 (sort_me, sm, 1);
23420 sm->name = (u8 *)(p->key);
23421 sm->value = (u8 *) (p->value[0]);
23425 vec_sort_with_function (sort_me, macro_sort_cmp);
23427 if (vec_len (sort_me))
23428 print (vam->ofp, "%-15s%s", "Name", "Value");
23430 print (vam->ofp, "The macro table is empty...");
23432 for (i = 0; i < vec_len (sort_me); i++)
23433 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23438 dump_node_table (vat_main_t * vam)
23441 vlib_node_t *node, *next_node;
23443 if (vec_len (vam->graph_nodes) == 0)
23445 print (vam->ofp, "Node table empty, issue get_node_graph...");
23449 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
23451 node = vam->graph_nodes[0][i];
23452 print (vam->ofp, "[%d] %s", i, node->name);
23453 for (j = 0; j < vec_len (node->next_nodes); j++)
23455 if (node->next_nodes[j] != ~0)
23457 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23458 print (vam->ofp, " [%d] %s", j, next_node->name);
23466 value_sort_cmp (void *a1, void *a2)
23468 name_sort_t *n1 = a1;
23469 name_sort_t *n2 = a2;
23471 if (n1->value < n2->value)
23473 if (n1->value > n2->value)
23480 dump_msg_api_table (vat_main_t * vam)
23482 api_main_t *am = &api_main;
23483 name_sort_t *nses = 0, *ns;
23488 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23490 vec_add2 (nses, ns, 1);
23491 ns->name = (u8 *)(hp->key);
23492 ns->value = (u32) hp->value[0];
23496 vec_sort_with_function (nses, value_sort_cmp);
23498 for (i = 0; i < vec_len (nses); i++)
23499 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23505 get_msg_id (vat_main_t * vam)
23510 if (unformat (vam->input, "%s", &name_and_crc))
23512 message_index = vl_msg_api_get_msg_index (name_and_crc);
23513 if (message_index == ~0)
23515 print (vam->ofp, " '%s' not found", name_and_crc);
23518 print (vam->ofp, " '%s' has message index %d",
23519 name_and_crc, message_index);
23522 errmsg ("name_and_crc required...");
23527 search_node_table (vat_main_t * vam)
23529 unformat_input_t *line_input = vam->input;
23532 vlib_node_t *node, *next_node;
23535 if (vam->graph_node_index_by_name == 0)
23537 print (vam->ofp, "Node table empty, issue get_node_graph...");
23541 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23543 if (unformat (line_input, "%s", &node_to_find))
23545 vec_add1 (node_to_find, 0);
23546 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23549 print (vam->ofp, "%s not found...", node_to_find);
23552 node = vam->graph_nodes[0][p[0]];
23553 print (vam->ofp, "[%d] %s", p[0], node->name);
23554 for (j = 0; j < vec_len (node->next_nodes); j++)
23556 if (node->next_nodes[j] != ~0)
23558 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23559 print (vam->ofp, " [%d] %s", j, next_node->name);
23566 clib_warning ("parse error '%U'", format_unformat_error,
23572 vec_free (node_to_find);
23581 script (vat_main_t * vam)
23583 #if (VPP_API_TEST_BUILTIN==0)
23585 char *save_current_file;
23586 unformat_input_t save_input;
23587 jmp_buf save_jump_buf;
23588 u32 save_line_number;
23590 FILE *new_fp, *save_ifp;
23592 if (unformat (vam->input, "%s", &s))
23594 new_fp = fopen ((char *) s, "r");
23597 errmsg ("Couldn't open script file %s", s);
23604 errmsg ("Missing script name");
23608 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23609 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23610 save_ifp = vam->ifp;
23611 save_line_number = vam->input_line_number;
23612 save_current_file = (char *) vam->current_file;
23614 vam->input_line_number = 0;
23616 vam->current_file = s;
23619 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23620 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23621 vam->ifp = save_ifp;
23622 vam->input_line_number = save_line_number;
23623 vam->current_file = (u8 *) save_current_file;
23628 clib_warning ("use the exec command...");
23634 echo (vat_main_t * vam)
23636 print (vam->ofp, "%v", vam->input->buffer);
23640 /* List of API message constructors, CLI names map to api_xxx */
23641 #define foreach_vpe_api_msg \
23642 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23643 _(sw_interface_dump,"") \
23644 _(sw_interface_set_flags, \
23645 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23646 _(sw_interface_add_del_address, \
23647 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23648 _(sw_interface_set_rx_mode, \
23649 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23650 _(sw_interface_set_rx_placement, \
23651 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
23652 _(sw_interface_rx_placement_dump, \
23653 "[<intfc> | sw_if_index <id>]") \
23654 _(sw_interface_set_table, \
23655 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23656 _(sw_interface_set_mpls_enable, \
23657 "<intfc> | sw_if_index [disable | dis]") \
23658 _(sw_interface_set_vpath, \
23659 "<intfc> | sw_if_index <id> enable | disable") \
23660 _(sw_interface_set_vxlan_bypass, \
23661 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23662 _(sw_interface_set_geneve_bypass, \
23663 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23664 _(sw_interface_set_l2_xconnect, \
23665 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23666 "enable | disable") \
23667 _(sw_interface_set_l2_bridge, \
23668 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23669 "[shg <split-horizon-group>] [bvi]\n" \
23670 "enable | disable") \
23671 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23672 _(bridge_domain_add_del, \
23673 "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") \
23674 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23676 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23677 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23678 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23680 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23682 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23684 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23686 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23688 "<vpp-if-name> | sw_if_index <id>") \
23689 _(sw_interface_tap_dump, "") \
23691 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23693 "<vpp-if-name> | sw_if_index <id>") \
23694 _(sw_interface_tap_v2_dump, "") \
23696 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23697 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23699 "<vpp-if-name> | sw_if_index <id>") \
23701 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23702 _(bond_detach_slave, \
23703 "sw_if_index <n>") \
23704 _(sw_interface_bond_dump, "") \
23705 _(sw_interface_slave_dump, \
23706 "<vpp-if-name> | sw_if_index <id>") \
23707 _(ip_table_add_del, \
23708 "table <n> [ipv6] [add | del]\n") \
23709 _(ip_add_del_route, \
23710 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
23711 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
23712 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
23713 "[multipath] [count <n>] [del]") \
23714 _(ip_mroute_add_del, \
23715 "<src> <grp>/<mask> [table-id <n>]\n" \
23716 "[<intfc> | sw_if_index <id>] [local] [del]") \
23717 _(mpls_table_add_del, \
23718 "table <n> [add | del]\n") \
23719 _(mpls_route_add_del, \
23720 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
23721 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
23722 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
23723 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
23724 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
23725 "[count <n>] [del]") \
23726 _(mpls_ip_bind_unbind, \
23727 "<label> <addr/len>") \
23728 _(mpls_tunnel_add_del, \
23729 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
23730 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
23731 "[l2-only] [out-label <n>]") \
23732 _(sr_mpls_policy_add, \
23733 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
23734 _(sr_mpls_policy_del, \
23736 _(bier_table_add_del, \
23737 "<label> <sub-domain> <set> <bsl> [del]") \
23738 _(bier_route_add_del, \
23739 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23740 "[<intfc> | sw_if_index <id>]" \
23741 "[weight <n>] [del] [multipath]") \
23742 _(proxy_arp_add_del, \
23743 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23744 _(proxy_arp_intfc_enable_disable, \
23745 "<intfc> | sw_if_index <id> enable | disable") \
23746 _(sw_interface_set_unnumbered, \
23747 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23748 _(ip_neighbor_add_del, \
23749 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23750 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23751 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23752 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23753 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23754 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23755 "[outer_vlan_id_any][inner_vlan_id_any]") \
23756 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23757 _(reset_fib, "vrf <n> [ipv6]") \
23758 _(dhcp_proxy_config, \
23759 "svr <v46-address> src <v46-address>\n" \
23760 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23761 _(dhcp_proxy_set_vss, \
23762 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23763 _(dhcp_proxy_dump, "ip6") \
23764 _(dhcp_client_config, \
23765 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23766 _(set_ip_flow_hash, \
23767 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23768 _(sw_interface_ip6_enable_disable, \
23769 "<intfc> | sw_if_index <id> enable | disable") \
23770 _(sw_interface_ip6_set_link_local_address, \
23771 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23772 _(ip6nd_proxy_add_del, \
23773 "<intfc> | sw_if_index <id> <ip6-address>") \
23774 _(ip6nd_proxy_dump, "") \
23775 _(sw_interface_ip6nd_ra_prefix, \
23776 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23777 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23778 "[nolink] [isno]") \
23779 _(sw_interface_ip6nd_ra_config, \
23780 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23781 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23782 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23783 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23784 _(l2_patch_add_del, \
23785 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23786 "enable | disable") \
23787 _(sr_localsid_add_del, \
23788 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23789 "fib-table <num> (end.psp) sw_if_index <num>") \
23790 _(classify_add_del_table, \
23791 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23792 " [del] [del-chain] mask <mask-value>\n" \
23793 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23794 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23795 _(classify_add_del_session, \
23796 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23797 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23798 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23799 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23800 _(classify_set_interface_ip_table, \
23801 "<intfc> | sw_if_index <nn> table <nn>") \
23802 _(classify_set_interface_l2_tables, \
23803 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23804 " [other-table <nn>]") \
23805 _(get_node_index, "node <node-name") \
23806 _(add_node_next, "node <node-name> next <next-node-name>") \
23807 _(l2tpv3_create_tunnel, \
23808 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23809 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23810 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23811 _(l2tpv3_set_tunnel_cookies, \
23812 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23813 "[new_remote_cookie <nn>]\n") \
23814 _(l2tpv3_interface_enable_disable, \
23815 "<intfc> | sw_if_index <nn> enable | disable") \
23816 _(l2tpv3_set_lookup_key, \
23817 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23818 _(sw_if_l2tpv3_tunnel_dump, "") \
23819 _(vxlan_offload_rx, \
23820 "hw { <interface name> | hw_if_index <nn>} " \
23821 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23822 _(vxlan_add_del_tunnel, \
23823 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23824 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23825 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23826 _(geneve_add_del_tunnel, \
23827 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23828 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23829 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23830 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23831 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23832 _(gre_add_del_tunnel, \
23833 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23834 "[teb | erspan <session-id>] [del]") \
23835 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23836 _(l2_fib_clear_table, "") \
23837 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23838 _(l2_interface_vlan_tag_rewrite, \
23839 "<intfc> | sw_if_index <nn> \n" \
23840 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23841 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23842 _(create_vhost_user_if, \
23843 "socket <filename> [server] [renumber <dev_instance>] " \
23844 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
23845 "[mac <mac_address>]") \
23846 _(modify_vhost_user_if, \
23847 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23848 "[server] [renumber <dev_instance>]") \
23849 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23850 _(sw_interface_vhost_user_dump, "") \
23851 _(show_version, "") \
23852 _(show_threads, "") \
23853 _(vxlan_gpe_add_del_tunnel, \
23854 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23855 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23856 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23857 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23858 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23859 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23860 _(interface_name_renumber, \
23861 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23862 _(input_acl_set_interface, \
23863 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23864 " [l2-table <nn>] [del]") \
23865 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23866 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23867 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23868 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23869 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23870 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23871 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23872 _(ip_dump, "ipv4 | ipv6") \
23873 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23874 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23876 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23877 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23878 " integ_alg <alg> integ_key <hex>") \
23879 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23880 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23881 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23882 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23883 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23884 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23885 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23886 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23887 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23888 " [instance <n>]") \
23889 _(ipsec_sa_dump, "[sa_id <n>]") \
23890 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23891 " <alg> <hex>\n") \
23892 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23893 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23894 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23895 "(auth_data 0x<data> | auth_data <data>)") \
23896 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23897 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23898 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23899 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23900 "(local|remote)") \
23901 _(ikev2_set_local_key, "file <absolute_file_path>") \
23902 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23903 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23904 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23905 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23906 _(ikev2_initiate_sa_init, "<profile_name>") \
23907 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23908 _(ikev2_initiate_del_child_sa, "<ispi>") \
23909 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23910 _(delete_loopback,"sw_if_index <nn>") \
23911 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23912 _(bd_ip_mac_dump, "[bd_id] <id>") \
23913 _(want_interface_events, "enable|disable") \
23914 _(want_stats,"enable|disable") \
23915 _(get_first_msg_id, "client <name>") \
23916 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23917 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23918 "fib-id <nn> [ip4][ip6][default]") \
23919 _(get_node_graph, " ") \
23920 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23921 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23922 _(ioam_disable, "") \
23923 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23924 " sw_if_index <sw_if_index> p <priority> " \
23925 "w <weight>] [del]") \
23926 _(one_add_del_locator, "locator-set <locator_name> " \
23927 "iface <intf> | sw_if_index <sw_if_index> " \
23928 "p <priority> w <weight> [del]") \
23929 _(one_add_del_local_eid,"vni <vni> eid " \
23930 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23931 "locator-set <locator_name> [del]" \
23932 "[key-id sha1|sha256 secret-key <secret-key>]")\
23933 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23934 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23935 _(one_enable_disable, "enable|disable") \
23936 _(one_map_register_enable_disable, "enable|disable") \
23937 _(one_map_register_fallback_threshold, "<value>") \
23938 _(one_rloc_probe_enable_disable, "enable|disable") \
23939 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23941 "rloc <locator> p <prio> " \
23942 "w <weight> [rloc <loc> ... ] " \
23943 "action <action> [del-all]") \
23944 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23946 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23947 _(one_use_petr, "ip-address> | disable") \
23948 _(one_map_request_mode, "src-dst|dst-only") \
23949 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23950 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23951 _(one_locator_set_dump, "[local | remote]") \
23952 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23953 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23954 "[local] | [remote]") \
23955 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23956 _(one_ndp_bd_get, "") \
23957 _(one_ndp_entries_get, "bd <bridge-domain>") \
23958 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23959 _(one_l2_arp_bd_get, "") \
23960 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23961 _(one_stats_enable_disable, "enable|disable") \
23962 _(show_one_stats_enable_disable, "") \
23963 _(one_eid_table_vni_dump, "") \
23964 _(one_eid_table_map_dump, "l2|l3") \
23965 _(one_map_resolver_dump, "") \
23966 _(one_map_server_dump, "") \
23967 _(one_adjacencies_get, "vni <vni>") \
23968 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23969 _(show_one_rloc_probe_state, "") \
23970 _(show_one_map_register_state, "") \
23971 _(show_one_status, "") \
23972 _(one_stats_dump, "") \
23973 _(one_stats_flush, "") \
23974 _(one_get_map_request_itr_rlocs, "") \
23975 _(one_map_register_set_ttl, "<ttl>") \
23976 _(one_set_transport_protocol, "udp|api") \
23977 _(one_get_transport_protocol, "") \
23978 _(one_enable_disable_xtr_mode, "enable|disable") \
23979 _(one_show_xtr_mode, "") \
23980 _(one_enable_disable_pitr_mode, "enable|disable") \
23981 _(one_show_pitr_mode, "") \
23982 _(one_enable_disable_petr_mode, "enable|disable") \
23983 _(one_show_petr_mode, "") \
23984 _(show_one_nsh_mapping, "") \
23985 _(show_one_pitr, "") \
23986 _(show_one_use_petr, "") \
23987 _(show_one_map_request_mode, "") \
23988 _(show_one_map_register_ttl, "") \
23989 _(show_one_map_register_fallback_threshold, "") \
23990 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23991 " sw_if_index <sw_if_index> p <priority> " \
23992 "w <weight>] [del]") \
23993 _(lisp_add_del_locator, "locator-set <locator_name> " \
23994 "iface <intf> | sw_if_index <sw_if_index> " \
23995 "p <priority> w <weight> [del]") \
23996 _(lisp_add_del_local_eid,"vni <vni> eid " \
23997 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23998 "locator-set <locator_name> [del]" \
23999 "[key-id sha1|sha256 secret-key <secret-key>]") \
24000 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
24001 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
24002 _(lisp_enable_disable, "enable|disable") \
24003 _(lisp_map_register_enable_disable, "enable|disable") \
24004 _(lisp_rloc_probe_enable_disable, "enable|disable") \
24005 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
24007 "rloc <locator> p <prio> " \
24008 "w <weight> [rloc <loc> ... ] " \
24009 "action <action> [del-all]") \
24010 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
24012 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
24013 _(lisp_use_petr, "<ip-address> | disable") \
24014 _(lisp_map_request_mode, "src-dst|dst-only") \
24015 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
24016 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
24017 _(lisp_locator_set_dump, "[local | remote]") \
24018 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
24019 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
24020 "[local] | [remote]") \
24021 _(lisp_eid_table_vni_dump, "") \
24022 _(lisp_eid_table_map_dump, "l2|l3") \
24023 _(lisp_map_resolver_dump, "") \
24024 _(lisp_map_server_dump, "") \
24025 _(lisp_adjacencies_get, "vni <vni>") \
24026 _(gpe_fwd_entry_vnis_get, "") \
24027 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
24028 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
24029 "[table <table-id>]") \
24030 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
24031 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
24032 _(gpe_set_encap_mode, "lisp|vxlan") \
24033 _(gpe_get_encap_mode, "") \
24034 _(lisp_gpe_add_del_iface, "up|down") \
24035 _(lisp_gpe_enable_disable, "enable|disable") \
24036 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
24037 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
24038 _(show_lisp_rloc_probe_state, "") \
24039 _(show_lisp_map_register_state, "") \
24040 _(show_lisp_status, "") \
24041 _(lisp_get_map_request_itr_rlocs, "") \
24042 _(show_lisp_pitr, "") \
24043 _(show_lisp_use_petr, "") \
24044 _(show_lisp_map_request_mode, "") \
24045 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
24046 _(af_packet_delete, "name <host interface name>") \
24047 _(af_packet_dump, "") \
24048 _(policer_add_del, "name <policer name> <params> [del]") \
24049 _(policer_dump, "[name <policer name>]") \
24050 _(policer_classify_set_interface, \
24051 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24052 " [l2-table <nn>] [del]") \
24053 _(policer_classify_dump, "type [ip4|ip6|l2]") \
24054 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
24055 "[master|slave]") \
24056 _(netmap_delete, "name <interface name>") \
24057 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
24058 _(mpls_fib_dump, "") \
24059 _(classify_table_ids, "") \
24060 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
24061 _(classify_table_info, "table_id <nn>") \
24062 _(classify_session_dump, "table_id <nn>") \
24063 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
24064 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
24065 "[template_interval <nn>] [udp_checksum]") \
24066 _(ipfix_exporter_dump, "") \
24067 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
24068 _(ipfix_classify_stream_dump, "") \
24069 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
24070 _(ipfix_classify_table_dump, "") \
24071 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
24072 _(sw_interface_span_dump, "[l2]") \
24073 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
24074 _(pg_create_interface, "if_id <nn>") \
24075 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
24076 _(pg_enable_disable, "[stream <id>] disable") \
24077 _(ip_source_and_port_range_check_add_del, \
24078 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
24079 _(ip_source_and_port_range_check_interface_add_del, \
24080 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
24081 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
24082 _(ipsec_gre_add_del_tunnel, \
24083 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
24084 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
24085 _(delete_subif,"<intfc> | sw_if_index <nn>") \
24086 _(l2_interface_pbb_tag_rewrite, \
24087 "<intfc> | sw_if_index <nn> \n" \
24088 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
24089 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
24090 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
24091 _(flow_classify_set_interface, \
24092 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
24093 _(flow_classify_dump, "type [ip4|ip6]") \
24094 _(ip_fib_dump, "") \
24095 _(ip_mfib_dump, "") \
24096 _(ip6_fib_dump, "") \
24097 _(ip6_mfib_dump, "") \
24098 _(feature_enable_disable, "arc_name <arc_name> " \
24099 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
24100 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
24102 _(l2_xconnect_dump, "") \
24103 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
24104 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
24105 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
24106 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
24107 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
24108 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
24109 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
24110 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
24111 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
24112 _(sock_init_shm, "size <nnn>") \
24113 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
24114 _(dns_enable_disable, "[enable][disable]") \
24115 _(dns_name_server_add_del, "<ip-address> [del]") \
24116 _(dns_resolve_name, "<hostname>") \
24117 _(dns_resolve_ip, "<ip4|ip6>") \
24118 _(dns_name_server_add_del, "<ip-address> [del]") \
24119 _(dns_resolve_name, "<hostname>") \
24120 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
24121 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
24122 _(session_rules_dump, "") \
24123 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
24124 _(output_acl_set_interface, \
24125 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24126 " [l2-table <nn>] [del]") \
24127 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
24129 /* List of command functions, CLI names map directly to functions */
24130 #define foreach_cli_function \
24131 _(comment, "usage: comment <ignore-rest-of-line>") \
24132 _(dump_interface_table, "usage: dump_interface_table") \
24133 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
24134 _(dump_ipv4_table, "usage: dump_ipv4_table") \
24135 _(dump_ipv6_table, "usage: dump_ipv6_table") \
24136 _(dump_stats_table, "usage: dump_stats_table") \
24137 _(dump_macro_table, "usage: dump_macro_table ") \
24138 _(dump_node_table, "usage: dump_node_table") \
24139 _(dump_msg_api_table, "usage: dump_msg_api_table") \
24140 _(get_msg_id, "usage: get_msg_id name_and_crc") \
24141 _(echo, "usage: echo <message>") \
24142 _(exec, "usage: exec <vpe-debug-CLI-command>") \
24143 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
24144 _(help, "usage: help") \
24145 _(q, "usage: quit") \
24146 _(quit, "usage: quit") \
24147 _(search_node_table, "usage: search_node_table <name>...") \
24148 _(set, "usage: set <variable-name> <value>") \
24149 _(script, "usage: script <file-name>") \
24150 _(statseg, "usage: statseg"); \
24151 _(unset, "usage: unset <variable-name>")
24154 static void vl_api_##n##_t_handler_uni \
24155 (vl_api_##n##_t * mp) \
24157 vat_main_t * vam = &vat_main; \
24158 if (vam->json_output) { \
24159 vl_api_##n##_t_handler_json(mp); \
24161 vl_api_##n##_t_handler(mp); \
24164 foreach_vpe_api_reply_msg;
24165 #if VPP_API_TEST_BUILTIN == 0
24166 foreach_standalone_reply_msg;
24171 vat_api_hookup (vat_main_t * vam)
24174 vl_msg_api_set_handlers(VL_API_##N, #n, \
24175 vl_api_##n##_t_handler_uni, \
24177 vl_api_##n##_t_endian, \
24178 vl_api_##n##_t_print, \
24179 sizeof(vl_api_##n##_t), 1);
24180 foreach_vpe_api_reply_msg;
24181 #if VPP_API_TEST_BUILTIN == 0
24182 foreach_standalone_reply_msg;
24186 #if (VPP_API_TEST_BUILTIN==0)
24187 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
24189 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
24191 vam->function_by_name = hash_create_string (0, sizeof (uword));
24193 vam->help_by_name = hash_create_string (0, sizeof (uword));
24196 /* API messages we can send */
24197 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
24198 foreach_vpe_api_msg;
24202 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24203 foreach_vpe_api_msg;
24206 /* CLI functions */
24207 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
24208 foreach_cli_function;
24212 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24213 foreach_cli_function;
24217 #if VPP_API_TEST_BUILTIN
24218 static clib_error_t *
24219 vat_api_hookup_shim (vlib_main_t * vm)
24221 vat_api_hookup (&vat_main);
24225 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
24229 * fd.io coding-style-patch-verification: ON
24232 * eval: (c-set-style "gnu")