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 = vl_api_string_len (&mp->reply);
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),
1117 vl_api_from_api_string (&mp->reply), length);
1118 vam->cmd_reply[length] = 0;
1120 vam->result_ready = 1;
1124 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1126 vat_main_t *vam = &vat_main;
1127 vat_json_node_t node;
1129 vec_reset_length (vam->cmd_reply);
1131 vat_json_init_object (&node);
1132 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1133 vat_json_object_add_string_copy (&node, "reply",
1134 vl_api_from_api_string (&mp->reply));
1136 vat_json_print (vam->ofp, &node);
1137 vat_json_free (&node);
1139 vam->retval = ntohl (mp->retval);
1140 vam->result_ready = 1;
1143 static void vl_api_classify_add_del_table_reply_t_handler
1144 (vl_api_classify_add_del_table_reply_t * mp)
1146 vat_main_t *vam = &vat_main;
1147 i32 retval = ntohl (mp->retval);
1148 if (vam->async_mode)
1150 vam->async_errors += (retval < 0);
1154 vam->retval = retval;
1156 ((mp->new_table_index != 0xFFFFFFFF) ||
1157 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1158 (mp->match_n_vectors != 0xFFFFFFFF)))
1160 * Note: this is just barely thread-safe, depends on
1161 * the main thread spinning waiting for an answer...
1163 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1164 ntohl (mp->new_table_index),
1165 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1166 vam->result_ready = 1;
1170 static void vl_api_classify_add_del_table_reply_t_handler_json
1171 (vl_api_classify_add_del_table_reply_t * mp)
1173 vat_main_t *vam = &vat_main;
1174 vat_json_node_t node;
1176 vat_json_init_object (&node);
1177 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1178 vat_json_object_add_uint (&node, "new_table_index",
1179 ntohl (mp->new_table_index));
1180 vat_json_object_add_uint (&node, "skip_n_vectors",
1181 ntohl (mp->skip_n_vectors));
1182 vat_json_object_add_uint (&node, "match_n_vectors",
1183 ntohl (mp->match_n_vectors));
1185 vat_json_print (vam->ofp, &node);
1186 vat_json_free (&node);
1188 vam->retval = ntohl (mp->retval);
1189 vam->result_ready = 1;
1192 static void vl_api_get_node_index_reply_t_handler
1193 (vl_api_get_node_index_reply_t * mp)
1195 vat_main_t *vam = &vat_main;
1196 i32 retval = ntohl (mp->retval);
1197 if (vam->async_mode)
1199 vam->async_errors += (retval < 0);
1203 vam->retval = retval;
1205 errmsg ("node index %d", ntohl (mp->node_index));
1206 vam->result_ready = 1;
1210 static void vl_api_get_node_index_reply_t_handler_json
1211 (vl_api_get_node_index_reply_t * mp)
1213 vat_main_t *vam = &vat_main;
1214 vat_json_node_t node;
1216 vat_json_init_object (&node);
1217 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1218 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1220 vat_json_print (vam->ofp, &node);
1221 vat_json_free (&node);
1223 vam->retval = ntohl (mp->retval);
1224 vam->result_ready = 1;
1227 static void vl_api_get_next_index_reply_t_handler
1228 (vl_api_get_next_index_reply_t * mp)
1230 vat_main_t *vam = &vat_main;
1231 i32 retval = ntohl (mp->retval);
1232 if (vam->async_mode)
1234 vam->async_errors += (retval < 0);
1238 vam->retval = retval;
1240 errmsg ("next node index %d", ntohl (mp->next_index));
1241 vam->result_ready = 1;
1245 static void vl_api_get_next_index_reply_t_handler_json
1246 (vl_api_get_next_index_reply_t * mp)
1248 vat_main_t *vam = &vat_main;
1249 vat_json_node_t node;
1251 vat_json_init_object (&node);
1252 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1253 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1255 vat_json_print (vam->ofp, &node);
1256 vat_json_free (&node);
1258 vam->retval = ntohl (mp->retval);
1259 vam->result_ready = 1;
1262 static void vl_api_add_node_next_reply_t_handler
1263 (vl_api_add_node_next_reply_t * mp)
1265 vat_main_t *vam = &vat_main;
1266 i32 retval = ntohl (mp->retval);
1267 if (vam->async_mode)
1269 vam->async_errors += (retval < 0);
1273 vam->retval = retval;
1275 errmsg ("next index %d", ntohl (mp->next_index));
1276 vam->result_ready = 1;
1280 static void vl_api_add_node_next_reply_t_handler_json
1281 (vl_api_add_node_next_reply_t * mp)
1283 vat_main_t *vam = &vat_main;
1284 vat_json_node_t node;
1286 vat_json_init_object (&node);
1287 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1288 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1290 vat_json_print (vam->ofp, &node);
1291 vat_json_free (&node);
1293 vam->retval = ntohl (mp->retval);
1294 vam->result_ready = 1;
1297 static void vl_api_show_version_reply_t_handler
1298 (vl_api_show_version_reply_t * mp)
1300 vat_main_t *vam = &vat_main;
1301 i32 retval = ntohl (mp->retval);
1306 char *p = (char *) &mp->program;
1308 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1309 errmsg (" program: %s\n", s);
1313 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1314 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1315 errmsg (" version: %s\n", s);
1319 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1320 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1321 errmsg (" build date: %s\n", s);
1325 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1326 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1327 errmsg ("build directory: %s\n", s);
1330 vam->retval = retval;
1331 vam->result_ready = 1;
1334 static void vl_api_show_version_reply_t_handler_json
1335 (vl_api_show_version_reply_t * mp)
1337 vat_main_t *vam = &vat_main;
1338 vat_json_node_t node;
1340 vat_json_init_object (&node);
1341 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1342 char *p = (char *) &mp->program;
1343 vat_json_object_add_string_copy (&node, "program",
1344 vl_api_from_api_string ((vl_api_string_t *)
1346 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1347 vat_json_object_add_string_copy (&node, "version",
1348 vl_api_from_api_string ((vl_api_string_t *)
1350 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1351 vat_json_object_add_string_copy (&node, "build_date",
1352 vl_api_from_api_string ((vl_api_string_t *)
1354 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1355 vat_json_object_add_string_copy (&node, "build_directory",
1356 vl_api_from_api_string ((vl_api_string_t *)
1359 vat_json_print (vam->ofp, &node);
1360 vat_json_free (&node);
1362 vam->retval = ntohl (mp->retval);
1363 vam->result_ready = 1;
1366 static void vl_api_show_threads_reply_t_handler
1367 (vl_api_show_threads_reply_t * mp)
1369 vat_main_t *vam = &vat_main;
1370 i32 retval = ntohl (mp->retval);
1374 count = ntohl (mp->count);
1376 for (i = 0; i < count; i++)
1378 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1379 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1380 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1381 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1382 ntohl (mp->thread_data[i].cpu_socket));
1384 vam->retval = retval;
1385 vam->result_ready = 1;
1388 static void vl_api_show_threads_reply_t_handler_json
1389 (vl_api_show_threads_reply_t * mp)
1391 vat_main_t *vam = &vat_main;
1392 vat_json_node_t node;
1393 vl_api_thread_data_t *td;
1394 i32 retval = ntohl (mp->retval);
1398 count = ntohl (mp->count);
1400 vat_json_init_object (&node);
1401 vat_json_object_add_int (&node, "retval", retval);
1402 vat_json_object_add_uint (&node, "count", count);
1404 for (i = 0; i < count; i++)
1406 td = &mp->thread_data[i];
1407 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1408 vat_json_object_add_string_copy (&node, "name", td->name);
1409 vat_json_object_add_string_copy (&node, "type", td->type);
1410 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1411 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1412 vat_json_object_add_int (&node, "core", ntohl (td->id));
1413 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1416 vat_json_print (vam->ofp, &node);
1417 vat_json_free (&node);
1419 vam->retval = retval;
1420 vam->result_ready = 1;
1424 api_show_threads (vat_main_t * vam)
1426 vl_api_show_threads_t *mp;
1430 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1431 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1433 M (SHOW_THREADS, mp);
1441 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1443 u32 sw_if_index = ntohl (mp->sw_if_index);
1444 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1445 mp->mac_ip ? "mac/ip binding" : "address resolution",
1446 ntohl (mp->pid), format_ip4_address, &mp->address,
1447 format_ethernet_address, mp->new_mac, sw_if_index);
1451 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1453 /* JSON output not supported */
1457 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1459 u32 sw_if_index = ntohl (mp->sw_if_index);
1460 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1461 mp->mac_ip ? "mac/ip binding" : "address resolution",
1462 ntohl (mp->pid), format_ip6_address, mp->address,
1463 format_ethernet_address, mp->new_mac, sw_if_index);
1467 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1469 /* JSON output not supported */
1473 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1475 u32 n_macs = ntohl (mp->n_macs);
1476 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1477 ntohl (mp->pid), mp->client_index, n_macs);
1479 for (i = 0; i < n_macs; i++)
1481 vl_api_mac_entry_t *mac = &mp->mac[i];
1482 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1483 i + 1, ntohl (mac->sw_if_index),
1484 format_ethernet_address, mac->mac_addr, mac->action);
1491 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1493 /* JSON output not supported */
1496 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1497 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1500 * Special-case: build the bridge domain table, maintain
1501 * the next bd id vbl.
1503 static void vl_api_bridge_domain_details_t_handler
1504 (vl_api_bridge_domain_details_t * mp)
1506 vat_main_t *vam = &vat_main;
1507 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1510 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1511 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1513 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1514 ntohl (mp->bd_id), mp->learn, mp->forward,
1515 mp->flood, ntohl (mp->bvi_sw_if_index),
1516 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1520 vl_api_bridge_domain_sw_if_t *sw_ifs;
1521 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1524 sw_ifs = mp->sw_if_details;
1525 for (i = 0; i < n_sw_ifs; i++)
1531 sw_if_index = ntohl (sw_ifs->sw_if_index);
1534 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1536 if ((u32) p->value[0] == sw_if_index)
1538 sw_if_name = (u8 *)(p->key);
1543 print (vam->ofp, "%7d %3d %s", sw_if_index,
1544 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1545 "sw_if_index not found!");
1552 static void vl_api_bridge_domain_details_t_handler_json
1553 (vl_api_bridge_domain_details_t * mp)
1555 vat_main_t *vam = &vat_main;
1556 vat_json_node_t *node, *array = NULL;
1557 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1559 if (VAT_JSON_ARRAY != vam->json_tree.type)
1561 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1562 vat_json_init_array (&vam->json_tree);
1564 node = vat_json_array_add (&vam->json_tree);
1566 vat_json_init_object (node);
1567 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1568 vat_json_object_add_uint (node, "flood", mp->flood);
1569 vat_json_object_add_uint (node, "forward", mp->forward);
1570 vat_json_object_add_uint (node, "learn", mp->learn);
1571 vat_json_object_add_uint (node, "bvi_sw_if_index",
1572 ntohl (mp->bvi_sw_if_index));
1573 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1574 array = vat_json_object_add (node, "sw_if");
1575 vat_json_init_array (array);
1581 vl_api_bridge_domain_sw_if_t *sw_ifs;
1584 sw_ifs = mp->sw_if_details;
1585 for (i = 0; i < n_sw_ifs; i++)
1587 node = vat_json_array_add (array);
1588 vat_json_init_object (node);
1589 vat_json_object_add_uint (node, "sw_if_index",
1590 ntohl (sw_ifs->sw_if_index));
1591 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1597 static void vl_api_control_ping_reply_t_handler
1598 (vl_api_control_ping_reply_t * mp)
1600 vat_main_t *vam = &vat_main;
1601 i32 retval = ntohl (mp->retval);
1602 if (vam->async_mode)
1604 vam->async_errors += (retval < 0);
1608 vam->retval = retval;
1609 vam->result_ready = 1;
1611 if (vam->socket_client_main)
1612 vam->socket_client_main->control_pings_outstanding--;
1615 static void vl_api_control_ping_reply_t_handler_json
1616 (vl_api_control_ping_reply_t * mp)
1618 vat_main_t *vam = &vat_main;
1619 i32 retval = ntohl (mp->retval);
1621 if (VAT_JSON_NONE != vam->json_tree.type)
1623 vat_json_print (vam->ofp, &vam->json_tree);
1624 vat_json_free (&vam->json_tree);
1625 vam->json_tree.type = VAT_JSON_NONE;
1630 vat_json_init_array (&vam->json_tree);
1631 vat_json_print (vam->ofp, &vam->json_tree);
1632 vam->json_tree.type = VAT_JSON_NONE;
1635 vam->retval = retval;
1636 vam->result_ready = 1;
1640 vl_api_bridge_domain_set_mac_age_reply_t_handler
1641 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1643 vat_main_t *vam = &vat_main;
1644 i32 retval = ntohl (mp->retval);
1645 if (vam->async_mode)
1647 vam->async_errors += (retval < 0);
1651 vam->retval = retval;
1652 vam->result_ready = 1;
1656 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1657 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1659 vat_main_t *vam = &vat_main;
1660 vat_json_node_t node;
1662 vat_json_init_object (&node);
1663 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1665 vat_json_print (vam->ofp, &node);
1666 vat_json_free (&node);
1668 vam->retval = ntohl (mp->retval);
1669 vam->result_ready = 1;
1673 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1675 vat_main_t *vam = &vat_main;
1676 i32 retval = ntohl (mp->retval);
1677 if (vam->async_mode)
1679 vam->async_errors += (retval < 0);
1683 vam->retval = retval;
1684 vam->result_ready = 1;
1688 static void vl_api_l2_flags_reply_t_handler_json
1689 (vl_api_l2_flags_reply_t * mp)
1691 vat_main_t *vam = &vat_main;
1692 vat_json_node_t node;
1694 vat_json_init_object (&node);
1695 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1696 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1697 ntohl (mp->resulting_feature_bitmap));
1699 vat_json_print (vam->ofp, &node);
1700 vat_json_free (&node);
1702 vam->retval = ntohl (mp->retval);
1703 vam->result_ready = 1;
1706 static void vl_api_bridge_flags_reply_t_handler
1707 (vl_api_bridge_flags_reply_t * mp)
1709 vat_main_t *vam = &vat_main;
1710 i32 retval = ntohl (mp->retval);
1711 if (vam->async_mode)
1713 vam->async_errors += (retval < 0);
1717 vam->retval = retval;
1718 vam->result_ready = 1;
1722 static void vl_api_bridge_flags_reply_t_handler_json
1723 (vl_api_bridge_flags_reply_t * mp)
1725 vat_main_t *vam = &vat_main;
1726 vat_json_node_t node;
1728 vat_json_init_object (&node);
1729 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1730 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1731 ntohl (mp->resulting_feature_bitmap));
1733 vat_json_print (vam->ofp, &node);
1734 vat_json_free (&node);
1736 vam->retval = ntohl (mp->retval);
1737 vam->result_ready = 1;
1740 static void vl_api_tap_connect_reply_t_handler
1741 (vl_api_tap_connect_reply_t * mp)
1743 vat_main_t *vam = &vat_main;
1744 i32 retval = ntohl (mp->retval);
1745 if (vam->async_mode)
1747 vam->async_errors += (retval < 0);
1751 vam->retval = retval;
1752 vam->sw_if_index = ntohl (mp->sw_if_index);
1753 vam->result_ready = 1;
1758 static void vl_api_tap_connect_reply_t_handler_json
1759 (vl_api_tap_connect_reply_t * mp)
1761 vat_main_t *vam = &vat_main;
1762 vat_json_node_t node;
1764 vat_json_init_object (&node);
1765 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1766 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1768 vat_json_print (vam->ofp, &node);
1769 vat_json_free (&node);
1771 vam->retval = ntohl (mp->retval);
1772 vam->result_ready = 1;
1777 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1779 vat_main_t *vam = &vat_main;
1780 i32 retval = ntohl (mp->retval);
1781 if (vam->async_mode)
1783 vam->async_errors += (retval < 0);
1787 vam->retval = retval;
1788 vam->sw_if_index = ntohl (mp->sw_if_index);
1789 vam->result_ready = 1;
1793 static void vl_api_tap_modify_reply_t_handler_json
1794 (vl_api_tap_modify_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));
1801 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1803 vat_json_print (vam->ofp, &node);
1804 vat_json_free (&node);
1806 vam->retval = ntohl (mp->retval);
1807 vam->result_ready = 1;
1811 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1813 vat_main_t *vam = &vat_main;
1814 i32 retval = ntohl (mp->retval);
1815 if (vam->async_mode)
1817 vam->async_errors += (retval < 0);
1821 vam->retval = retval;
1822 vam->result_ready = 1;
1826 static void vl_api_tap_delete_reply_t_handler_json
1827 (vl_api_tap_delete_reply_t * mp)
1829 vat_main_t *vam = &vat_main;
1830 vat_json_node_t node;
1832 vat_json_init_object (&node);
1833 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1835 vat_json_print (vam->ofp, &node);
1836 vat_json_free (&node);
1838 vam->retval = ntohl (mp->retval);
1839 vam->result_ready = 1;
1843 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1845 vat_main_t *vam = &vat_main;
1846 i32 retval = ntohl (mp->retval);
1847 if (vam->async_mode)
1849 vam->async_errors += (retval < 0);
1853 vam->retval = retval;
1854 vam->sw_if_index = ntohl (mp->sw_if_index);
1855 vam->result_ready = 1;
1860 static void vl_api_tap_create_v2_reply_t_handler_json
1861 (vl_api_tap_create_v2_reply_t * mp)
1863 vat_main_t *vam = &vat_main;
1864 vat_json_node_t node;
1866 vat_json_init_object (&node);
1867 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1868 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1870 vat_json_print (vam->ofp, &node);
1871 vat_json_free (&node);
1873 vam->retval = ntohl (mp->retval);
1874 vam->result_ready = 1;
1879 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1881 vat_main_t *vam = &vat_main;
1882 i32 retval = ntohl (mp->retval);
1883 if (vam->async_mode)
1885 vam->async_errors += (retval < 0);
1889 vam->retval = retval;
1890 vam->result_ready = 1;
1894 static void vl_api_tap_delete_v2_reply_t_handler_json
1895 (vl_api_tap_delete_v2_reply_t * mp)
1897 vat_main_t *vam = &vat_main;
1898 vat_json_node_t node;
1900 vat_json_init_object (&node);
1901 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1903 vat_json_print (vam->ofp, &node);
1904 vat_json_free (&node);
1906 vam->retval = ntohl (mp->retval);
1907 vam->result_ready = 1;
1911 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1913 vat_main_t *vam = &vat_main;
1914 i32 retval = ntohl (mp->retval);
1916 if (vam->async_mode)
1918 vam->async_errors += (retval < 0);
1922 vam->retval = retval;
1923 vam->sw_if_index = ntohl (mp->sw_if_index);
1924 vam->result_ready = 1;
1928 static void vl_api_bond_create_reply_t_handler_json
1929 (vl_api_bond_create_reply_t * mp)
1931 vat_main_t *vam = &vat_main;
1932 vat_json_node_t node;
1934 vat_json_init_object (&node);
1935 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1936 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
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_delete_reply_t_handler (vl_api_bond_delete_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_delete_reply_t_handler_json
1963 (vl_api_bond_delete_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_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1981 vat_main_t *vam = &vat_main;
1982 i32 retval = ntohl (mp->retval);
1984 if (vam->async_mode)
1986 vam->async_errors += (retval < 0);
1990 vam->retval = retval;
1991 vam->result_ready = 1;
1995 static void vl_api_bond_enslave_reply_t_handler_json
1996 (vl_api_bond_enslave_reply_t * mp)
1998 vat_main_t *vam = &vat_main;
1999 vat_json_node_t node;
2001 vat_json_init_object (&node);
2002 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2004 vat_json_print (vam->ofp, &node);
2005 vat_json_free (&node);
2007 vam->retval = ntohl (mp->retval);
2008 vam->result_ready = 1;
2012 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
2015 vat_main_t *vam = &vat_main;
2016 i32 retval = ntohl (mp->retval);
2018 if (vam->async_mode)
2020 vam->async_errors += (retval < 0);
2024 vam->retval = retval;
2025 vam->result_ready = 1;
2029 static void vl_api_bond_detach_slave_reply_t_handler_json
2030 (vl_api_bond_detach_slave_reply_t * mp)
2032 vat_main_t *vam = &vat_main;
2033 vat_json_node_t node;
2035 vat_json_init_object (&node);
2036 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2038 vat_json_print (vam->ofp, &node);
2039 vat_json_free (&node);
2041 vam->retval = ntohl (mp->retval);
2042 vam->result_ready = 1;
2045 static void vl_api_sw_interface_bond_details_t_handler
2046 (vl_api_sw_interface_bond_details_t * mp)
2048 vat_main_t *vam = &vat_main;
2051 "%-16s %-12d %-12U %-13U %-14u %-14u",
2052 mp->interface_name, ntohl (mp->sw_if_index),
2053 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2054 ntohl (mp->active_slaves), ntohl (mp->slaves));
2057 static void vl_api_sw_interface_bond_details_t_handler_json
2058 (vl_api_sw_interface_bond_details_t * mp)
2060 vat_main_t *vam = &vat_main;
2061 vat_json_node_t *node = NULL;
2063 if (VAT_JSON_ARRAY != vam->json_tree.type)
2065 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2066 vat_json_init_array (&vam->json_tree);
2068 node = vat_json_array_add (&vam->json_tree);
2070 vat_json_init_object (node);
2071 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2072 vat_json_object_add_string_copy (node, "interface_name",
2073 mp->interface_name);
2074 vat_json_object_add_uint (node, "mode", mp->mode);
2075 vat_json_object_add_uint (node, "load_balance", mp->lb);
2076 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2077 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2081 api_sw_interface_bond_dump (vat_main_t * vam)
2083 vl_api_sw_interface_bond_dump_t *mp;
2084 vl_api_control_ping_t *mp_ping;
2088 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2089 "interface name", "sw_if_index", "mode", "load balance",
2090 "active slaves", "slaves");
2092 /* Get list of bond interfaces */
2093 M (SW_INTERFACE_BOND_DUMP, mp);
2096 /* Use a control ping for synchronization */
2097 MPING (CONTROL_PING, mp_ping);
2104 static void vl_api_sw_interface_slave_details_t_handler
2105 (vl_api_sw_interface_slave_details_t * mp)
2107 vat_main_t *vam = &vat_main;
2110 "%-25s %-12d %-12d %d", mp->interface_name,
2111 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2114 static void vl_api_sw_interface_slave_details_t_handler_json
2115 (vl_api_sw_interface_slave_details_t * mp)
2117 vat_main_t *vam = &vat_main;
2118 vat_json_node_t *node = NULL;
2120 if (VAT_JSON_ARRAY != vam->json_tree.type)
2122 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2123 vat_json_init_array (&vam->json_tree);
2125 node = vat_json_array_add (&vam->json_tree);
2127 vat_json_init_object (node);
2128 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2129 vat_json_object_add_string_copy (node, "interface_name",
2130 mp->interface_name);
2131 vat_json_object_add_uint (node, "passive", mp->is_passive);
2132 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2136 api_sw_interface_slave_dump (vat_main_t * vam)
2138 unformat_input_t *i = vam->input;
2139 vl_api_sw_interface_slave_dump_t *mp;
2140 vl_api_control_ping_t *mp_ping;
2141 u32 sw_if_index = ~0;
2142 u8 sw_if_index_set = 0;
2145 /* Parse args required to build the message */
2146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2148 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2149 sw_if_index_set = 1;
2150 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2151 sw_if_index_set = 1;
2156 if (sw_if_index_set == 0)
2158 errmsg ("missing vpp interface name. ");
2163 "\n%-25s %-12s %-12s %s",
2164 "slave interface name", "sw_if_index", "passive", "long_timeout");
2166 /* Get list of bond interfaces */
2167 M (SW_INTERFACE_SLAVE_DUMP, mp);
2168 mp->sw_if_index = ntohl (sw_if_index);
2171 /* Use a control ping for synchronization */
2172 MPING (CONTROL_PING, mp_ping);
2179 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2180 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2182 vat_main_t *vam = &vat_main;
2183 i32 retval = ntohl (mp->retval);
2184 if (vam->async_mode)
2186 vam->async_errors += (retval < 0);
2190 vam->retval = retval;
2191 vam->sw_if_index = ntohl (mp->sw_if_index);
2192 vam->result_ready = 1;
2194 vam->regenerate_interface_table = 1;
2197 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2198 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2200 vat_main_t *vam = &vat_main;
2201 vat_json_node_t node;
2203 vat_json_init_object (&node);
2204 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2205 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2206 ntohl (mp->sw_if_index));
2208 vat_json_print (vam->ofp, &node);
2209 vat_json_free (&node);
2211 vam->retval = ntohl (mp->retval);
2212 vam->result_ready = 1;
2215 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2216 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2218 vat_main_t *vam = &vat_main;
2219 i32 retval = ntohl (mp->retval);
2220 if (vam->async_mode)
2222 vam->async_errors += (retval < 0);
2226 vam->retval = retval;
2227 vam->sw_if_index = ntohl (mp->sw_if_index);
2228 vam->result_ready = 1;
2232 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2233 (vl_api_l2tpv3_create_tunnel_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, "sw_if_index", ntohl (mp->sw_if_index));
2242 vat_json_print (vam->ofp, &node);
2243 vat_json_free (&node);
2245 vam->retval = ntohl (mp->retval);
2246 vam->result_ready = 1;
2249 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2250 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2252 vat_main_t *vam = &vat_main;
2253 i32 retval = ntohl (mp->retval);
2254 if (vam->async_mode)
2256 vam->async_errors += (retval < 0);
2260 vam->retval = retval;
2261 vam->result_ready = 1;
2265 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2266 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2268 vat_main_t *vam = &vat_main;
2269 vat_json_node_t node;
2271 vat_json_init_object (&node);
2272 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2273 vat_json_object_add_uint (&node, "fwd_entry_index",
2274 clib_net_to_host_u32 (mp->fwd_entry_index));
2276 vat_json_print (vam->ofp, &node);
2277 vat_json_free (&node);
2279 vam->retval = ntohl (mp->retval);
2280 vam->result_ready = 1;
2284 format_lisp_transport_protocol (u8 * s, va_list * args)
2286 u32 proto = va_arg (*args, u32);
2291 return format (s, "udp");
2293 return format (s, "api");
2300 static void vl_api_one_get_transport_protocol_reply_t_handler
2301 (vl_api_one_get_transport_protocol_reply_t * mp)
2303 vat_main_t *vam = &vat_main;
2304 i32 retval = ntohl (mp->retval);
2305 if (vam->async_mode)
2307 vam->async_errors += (retval < 0);
2311 u32 proto = mp->protocol;
2312 print (vam->ofp, "Transport protocol: %U",
2313 format_lisp_transport_protocol, proto);
2314 vam->retval = retval;
2315 vam->result_ready = 1;
2319 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2320 (vl_api_one_get_transport_protocol_reply_t * mp)
2322 vat_main_t *vam = &vat_main;
2323 vat_json_node_t node;
2326 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2329 vat_json_init_object (&node);
2330 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2331 vat_json_object_add_string_copy (&node, "transport-protocol", s);
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_one_add_del_locator_set_reply_t_handler
2342 (vl_api_one_add_del_locator_set_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->result_ready = 1;
2357 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2358 (vl_api_one_add_del_locator_set_reply_t * mp)
2360 vat_main_t *vam = &vat_main;
2361 vat_json_node_t node;
2363 vat_json_init_object (&node);
2364 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2365 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2367 vat_json_print (vam->ofp, &node);
2368 vat_json_free (&node);
2370 vam->retval = ntohl (mp->retval);
2371 vam->result_ready = 1;
2374 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2375 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2377 vat_main_t *vam = &vat_main;
2378 i32 retval = ntohl (mp->retval);
2379 if (vam->async_mode)
2381 vam->async_errors += (retval < 0);
2385 vam->retval = retval;
2386 vam->sw_if_index = ntohl (mp->sw_if_index);
2387 vam->result_ready = 1;
2389 vam->regenerate_interface_table = 1;
2392 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2393 (vl_api_vxlan_add_del_tunnel_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));
2400 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2402 vat_json_print (vam->ofp, &node);
2403 vat_json_free (&node);
2405 vam->retval = ntohl (mp->retval);
2406 vam->result_ready = 1;
2409 static void vl_api_vxlan_offload_rx_reply_t_handler
2410 (vl_api_vxlan_offload_rx_reply_t * mp)
2412 vat_main_t *vam = &vat_main;
2413 i32 retval = ntohl (mp->retval);
2414 if (vam->async_mode)
2416 vam->async_errors += (retval < 0);
2420 vam->retval = retval;
2421 vam->result_ready = 1;
2425 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2426 (vl_api_vxlan_offload_rx_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));
2434 vat_json_print (vam->ofp, &node);
2435 vat_json_free (&node);
2437 vam->retval = ntohl (mp->retval);
2438 vam->result_ready = 1;
2441 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2442 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2444 vat_main_t *vam = &vat_main;
2445 i32 retval = ntohl (mp->retval);
2446 if (vam->async_mode)
2448 vam->async_errors += (retval < 0);
2452 vam->retval = retval;
2453 vam->sw_if_index = ntohl (mp->sw_if_index);
2454 vam->result_ready = 1;
2458 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2459 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2461 vat_main_t *vam = &vat_main;
2462 vat_json_node_t node;
2464 vat_json_init_object (&node);
2465 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2466 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2468 vat_json_print (vam->ofp, &node);
2469 vat_json_free (&node);
2471 vam->retval = ntohl (mp->retval);
2472 vam->result_ready = 1;
2475 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2476 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2478 vat_main_t *vam = &vat_main;
2479 i32 retval = ntohl (mp->retval);
2480 if (vam->async_mode)
2482 vam->async_errors += (retval < 0);
2486 vam->retval = retval;
2487 vam->sw_if_index = ntohl (mp->sw_if_index);
2488 vam->result_ready = 1;
2490 vam->regenerate_interface_table = 1;
2493 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2494 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2496 vat_main_t *vam = &vat_main;
2497 vat_json_node_t node;
2499 vat_json_init_object (&node);
2500 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2501 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2503 vat_json_print (vam->ofp, &node);
2504 vat_json_free (&node);
2506 vam->retval = ntohl (mp->retval);
2507 vam->result_ready = 1;
2510 static void vl_api_gre_add_del_tunnel_reply_t_handler
2511 (vl_api_gre_add_del_tunnel_reply_t * mp)
2513 vat_main_t *vam = &vat_main;
2514 i32 retval = ntohl (mp->retval);
2515 if (vam->async_mode)
2517 vam->async_errors += (retval < 0);
2521 vam->retval = retval;
2522 vam->sw_if_index = ntohl (mp->sw_if_index);
2523 vam->result_ready = 1;
2527 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2528 (vl_api_gre_add_del_tunnel_reply_t * mp)
2530 vat_main_t *vam = &vat_main;
2531 vat_json_node_t node;
2533 vat_json_init_object (&node);
2534 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2535 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2537 vat_json_print (vam->ofp, &node);
2538 vat_json_free (&node);
2540 vam->retval = ntohl (mp->retval);
2541 vam->result_ready = 1;
2544 static void vl_api_create_vhost_user_if_reply_t_handler
2545 (vl_api_create_vhost_user_if_reply_t * mp)
2547 vat_main_t *vam = &vat_main;
2548 i32 retval = ntohl (mp->retval);
2549 if (vam->async_mode)
2551 vam->async_errors += (retval < 0);
2555 vam->retval = retval;
2556 vam->sw_if_index = ntohl (mp->sw_if_index);
2557 vam->result_ready = 1;
2559 vam->regenerate_interface_table = 1;
2562 static void vl_api_create_vhost_user_if_reply_t_handler_json
2563 (vl_api_create_vhost_user_if_reply_t * mp)
2565 vat_main_t *vam = &vat_main;
2566 vat_json_node_t node;
2568 vat_json_init_object (&node);
2569 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2570 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2572 vat_json_print (vam->ofp, &node);
2573 vat_json_free (&node);
2575 vam->retval = ntohl (mp->retval);
2576 vam->result_ready = 1;
2579 static void vl_api_dns_resolve_name_reply_t_handler
2580 (vl_api_dns_resolve_name_reply_t * mp)
2582 vat_main_t *vam = &vat_main;
2583 i32 retval = ntohl (mp->retval);
2584 if (vam->async_mode)
2586 vam->async_errors += (retval < 0);
2590 vam->retval = retval;
2591 vam->result_ready = 1;
2596 clib_warning ("ip4 address %U", format_ip4_address,
2597 (ip4_address_t *) mp->ip4_address);
2599 clib_warning ("ip6 address %U", format_ip6_address,
2600 (ip6_address_t *) mp->ip6_address);
2603 clib_warning ("retval %d", retval);
2607 static void vl_api_dns_resolve_name_reply_t_handler_json
2608 (vl_api_dns_resolve_name_reply_t * mp)
2610 clib_warning ("not implemented");
2613 static void vl_api_dns_resolve_ip_reply_t_handler
2614 (vl_api_dns_resolve_ip_reply_t * mp)
2616 vat_main_t *vam = &vat_main;
2617 i32 retval = ntohl (mp->retval);
2618 if (vam->async_mode)
2620 vam->async_errors += (retval < 0);
2624 vam->retval = retval;
2625 vam->result_ready = 1;
2629 clib_warning ("canonical name %s", mp->name);
2632 clib_warning ("retval %d", retval);
2636 static void vl_api_dns_resolve_ip_reply_t_handler_json
2637 (vl_api_dns_resolve_ip_reply_t * mp)
2639 clib_warning ("not implemented");
2643 static void vl_api_ip_address_details_t_handler
2644 (vl_api_ip_address_details_t * mp)
2646 vat_main_t *vam = &vat_main;
2647 static ip_address_details_t empty_ip_address_details = { {0} };
2648 ip_address_details_t *address = NULL;
2649 ip_details_t *current_ip_details = NULL;
2650 ip_details_t *details = NULL;
2652 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2654 if (!details || vam->current_sw_if_index >= vec_len (details)
2655 || !details[vam->current_sw_if_index].present)
2657 errmsg ("ip address details arrived but not stored");
2658 errmsg ("ip_dump should be called first");
2662 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2664 #define addresses (current_ip_details->addr)
2666 vec_validate_init_empty (addresses, vec_len (addresses),
2667 empty_ip_address_details);
2669 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2671 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2672 address->prefix_length = mp->prefix_length;
2676 static void vl_api_ip_address_details_t_handler_json
2677 (vl_api_ip_address_details_t * mp)
2679 vat_main_t *vam = &vat_main;
2680 vat_json_node_t *node = NULL;
2681 struct in6_addr ip6;
2684 if (VAT_JSON_ARRAY != vam->json_tree.type)
2686 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2687 vat_json_init_array (&vam->json_tree);
2689 node = vat_json_array_add (&vam->json_tree);
2691 vat_json_init_object (node);
2694 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2695 vat_json_object_add_ip6 (node, "ip", ip6);
2699 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2700 vat_json_object_add_ip4 (node, "ip", ip4);
2702 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2706 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2708 vat_main_t *vam = &vat_main;
2709 static ip_details_t empty_ip_details = { 0 };
2710 ip_details_t *ip = NULL;
2711 u32 sw_if_index = ~0;
2713 sw_if_index = ntohl (mp->sw_if_index);
2715 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2716 sw_if_index, empty_ip_details);
2718 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2725 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2727 vat_main_t *vam = &vat_main;
2729 if (VAT_JSON_ARRAY != vam->json_tree.type)
2731 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2732 vat_json_init_array (&vam->json_tree);
2734 vat_json_array_add_uint (&vam->json_tree,
2735 clib_net_to_host_u32 (mp->sw_if_index));
2739 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2741 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2742 "router_addr %U host_mac %U",
2743 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2745 format_ip4_address, &mp->lease.host_address,
2746 format_ip4_address, &mp->lease.router_address,
2747 format_ethernet_address, mp->lease.host_mac);
2750 static void vl_api_dhcp_compl_event_t_handler_json
2751 (vl_api_dhcp_compl_event_t * mp)
2753 /* JSON output not supported */
2757 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2760 vat_main_t *vam = &vat_main;
2761 static u64 default_counter = 0;
2763 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2765 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2766 sw_if_index, default_counter);
2767 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2771 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2772 interface_counter_t counter)
2774 vat_main_t *vam = &vat_main;
2775 static interface_counter_t default_counter = { 0, };
2777 vec_validate_init_empty (vam->combined_interface_counters,
2778 vnet_counter_type, NULL);
2779 vec_validate_init_empty (vam->combined_interface_counters
2780 [vnet_counter_type], sw_if_index, default_counter);
2781 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2784 static void vl_api_vnet_interface_simple_counters_t_handler
2785 (vl_api_vnet_interface_simple_counters_t * mp)
2790 static void vl_api_vnet_interface_combined_counters_t_handler
2791 (vl_api_vnet_interface_combined_counters_t * mp)
2796 static void vl_api_vnet_interface_simple_counters_t_handler_json
2797 (vl_api_vnet_interface_simple_counters_t * mp)
2802 u32 first_sw_if_index;
2805 count = ntohl (mp->count);
2806 first_sw_if_index = ntohl (mp->first_sw_if_index);
2808 v_packets = (u64 *) & mp->data;
2809 for (i = 0; i < count; i++)
2811 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2812 set_simple_interface_counter (mp->vnet_counter_type,
2813 first_sw_if_index + i, packets);
2818 static void vl_api_vnet_interface_combined_counters_t_handler_json
2819 (vl_api_vnet_interface_combined_counters_t * mp)
2821 interface_counter_t counter;
2823 u32 first_sw_if_index;
2827 count = ntohl (mp->count);
2828 first_sw_if_index = ntohl (mp->first_sw_if_index);
2830 v = (vlib_counter_t *) & mp->data;
2831 for (i = 0; i < count; i++)
2834 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2836 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2837 set_combined_interface_counter (mp->vnet_counter_type,
2838 first_sw_if_index + i, counter);
2844 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2846 vat_main_t *vam = &vat_main;
2849 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2851 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2860 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2862 vat_main_t *vam = &vat_main;
2865 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2867 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2875 static void vl_api_vnet_ip4_fib_counters_t_handler
2876 (vl_api_vnet_ip4_fib_counters_t * mp)
2881 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2882 (vl_api_vnet_ip4_fib_counters_t * mp)
2884 vat_main_t *vam = &vat_main;
2885 vl_api_ip4_fib_counter_t *v;
2886 ip4_fib_counter_t *counter;
2893 vrf_id = ntohl (mp->vrf_id);
2894 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2895 if (~0 == vrf_index)
2897 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2898 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2899 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2900 vec_validate (vam->ip4_fib_counters, vrf_index);
2901 vam->ip4_fib_counters[vrf_index] = NULL;
2904 vec_free (vam->ip4_fib_counters[vrf_index]);
2905 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2906 count = ntohl (mp->count);
2907 for (i = 0; i < count; i++)
2909 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2910 counter = &vam->ip4_fib_counters[vrf_index][i];
2911 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2912 counter->address = ip4;
2913 counter->address_length = v->address_length;
2914 counter->packets = clib_net_to_host_u64 (v->packets);
2915 counter->bytes = clib_net_to_host_u64 (v->bytes);
2920 static void vl_api_vnet_ip4_nbr_counters_t_handler
2921 (vl_api_vnet_ip4_nbr_counters_t * mp)
2926 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2927 (vl_api_vnet_ip4_nbr_counters_t * mp)
2929 vat_main_t *vam = &vat_main;
2930 vl_api_ip4_nbr_counter_t *v;
2931 ip4_nbr_counter_t *counter;
2936 sw_if_index = ntohl (mp->sw_if_index);
2937 count = ntohl (mp->count);
2938 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2941 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2943 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2944 for (i = 0; i < count; i++)
2946 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2947 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2948 counter->address.s_addr = v->address;
2949 counter->packets = clib_net_to_host_u64 (v->packets);
2950 counter->bytes = clib_net_to_host_u64 (v->bytes);
2951 counter->linkt = v->link_type;
2956 static void vl_api_vnet_ip6_fib_counters_t_handler
2957 (vl_api_vnet_ip6_fib_counters_t * mp)
2962 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2963 (vl_api_vnet_ip6_fib_counters_t * mp)
2965 vat_main_t *vam = &vat_main;
2966 vl_api_ip6_fib_counter_t *v;
2967 ip6_fib_counter_t *counter;
2968 struct in6_addr ip6;
2974 vrf_id = ntohl (mp->vrf_id);
2975 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2976 if (~0 == vrf_index)
2978 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2979 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2980 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2981 vec_validate (vam->ip6_fib_counters, vrf_index);
2982 vam->ip6_fib_counters[vrf_index] = NULL;
2985 vec_free (vam->ip6_fib_counters[vrf_index]);
2986 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2987 count = ntohl (mp->count);
2988 for (i = 0; i < count; i++)
2990 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2991 counter = &vam->ip6_fib_counters[vrf_index][i];
2992 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2993 counter->address = ip6;
2994 counter->address_length = v->address_length;
2995 counter->packets = clib_net_to_host_u64 (v->packets);
2996 counter->bytes = clib_net_to_host_u64 (v->bytes);
3001 static void vl_api_vnet_ip6_nbr_counters_t_handler
3002 (vl_api_vnet_ip6_nbr_counters_t * mp)
3007 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
3008 (vl_api_vnet_ip6_nbr_counters_t * mp)
3010 vat_main_t *vam = &vat_main;
3011 vl_api_ip6_nbr_counter_t *v;
3012 ip6_nbr_counter_t *counter;
3013 struct in6_addr ip6;
3018 sw_if_index = ntohl (mp->sw_if_index);
3019 count = ntohl (mp->count);
3020 vec_validate (vam->ip6_nbr_counters, sw_if_index);
3023 vec_free (vam->ip6_nbr_counters[sw_if_index]);
3025 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
3026 for (i = 0; i < count; i++)
3028 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
3029 counter = &vam->ip6_nbr_counters[sw_if_index][i];
3030 clib_memcpy (&ip6, &v->address, sizeof (ip6));
3031 counter->address = ip6;
3032 counter->packets = clib_net_to_host_u64 (v->packets);
3033 counter->bytes = clib_net_to_host_u64 (v->bytes);
3038 static void vl_api_get_first_msg_id_reply_t_handler
3039 (vl_api_get_first_msg_id_reply_t * mp)
3041 vat_main_t *vam = &vat_main;
3042 i32 retval = ntohl (mp->retval);
3044 if (vam->async_mode)
3046 vam->async_errors += (retval < 0);
3050 vam->retval = retval;
3051 vam->result_ready = 1;
3055 errmsg ("first message id %d", ntohs (mp->first_msg_id));
3059 static void vl_api_get_first_msg_id_reply_t_handler_json
3060 (vl_api_get_first_msg_id_reply_t * mp)
3062 vat_main_t *vam = &vat_main;
3063 vat_json_node_t node;
3065 vat_json_init_object (&node);
3066 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3067 vat_json_object_add_uint (&node, "first_msg_id",
3068 (uint) ntohs (mp->first_msg_id));
3070 vat_json_print (vam->ofp, &node);
3071 vat_json_free (&node);
3073 vam->retval = ntohl (mp->retval);
3074 vam->result_ready = 1;
3077 static void vl_api_get_node_graph_reply_t_handler
3078 (vl_api_get_node_graph_reply_t * mp)
3080 vat_main_t *vam = &vat_main;
3081 api_main_t *am = &api_main;
3082 i32 retval = ntohl (mp->retval);
3083 u8 *pvt_copy, *reply;
3088 if (vam->async_mode)
3090 vam->async_errors += (retval < 0);
3094 vam->retval = retval;
3095 vam->result_ready = 1;
3098 /* "Should never happen..." */
3102 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3103 pvt_copy = vec_dup (reply);
3105 /* Toss the shared-memory original... */
3106 pthread_mutex_lock (&am->vlib_rp->mutex);
3107 oldheap = svm_push_data_heap (am->vlib_rp);
3111 svm_pop_heap (oldheap);
3112 pthread_mutex_unlock (&am->vlib_rp->mutex);
3114 if (vam->graph_nodes)
3116 hash_free (vam->graph_node_index_by_name);
3118 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3120 node = vam->graph_nodes[0][i];
3121 vec_free (node->name);
3122 vec_free (node->next_nodes);
3125 vec_free (vam->graph_nodes[0]);
3126 vec_free (vam->graph_nodes);
3129 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3130 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3131 vec_free (pvt_copy);
3133 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3135 node = vam->graph_nodes[0][i];
3136 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3140 static void vl_api_get_node_graph_reply_t_handler_json
3141 (vl_api_get_node_graph_reply_t * mp)
3143 vat_main_t *vam = &vat_main;
3144 api_main_t *am = &api_main;
3146 vat_json_node_t node;
3149 /* $$$$ make this real? */
3150 vat_json_init_object (&node);
3151 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3152 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3154 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3156 /* Toss the shared-memory original... */
3157 pthread_mutex_lock (&am->vlib_rp->mutex);
3158 oldheap = svm_push_data_heap (am->vlib_rp);
3162 svm_pop_heap (oldheap);
3163 pthread_mutex_unlock (&am->vlib_rp->mutex);
3165 vat_json_print (vam->ofp, &node);
3166 vat_json_free (&node);
3168 vam->retval = ntohl (mp->retval);
3169 vam->result_ready = 1;
3173 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3175 vat_main_t *vam = &vat_main;
3180 s = format (s, "%=16d%=16d%=16d",
3181 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3185 s = format (s, "%=16U%=16d%=16d",
3186 mp->is_ipv6 ? format_ip6_address :
3188 mp->ip_address, mp->priority, mp->weight);
3191 print (vam->ofp, "%v", s);
3196 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3198 vat_main_t *vam = &vat_main;
3199 vat_json_node_t *node = NULL;
3200 struct in6_addr ip6;
3203 if (VAT_JSON_ARRAY != vam->json_tree.type)
3205 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3206 vat_json_init_array (&vam->json_tree);
3208 node = vat_json_array_add (&vam->json_tree);
3209 vat_json_init_object (node);
3211 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3212 vat_json_object_add_uint (node, "priority", mp->priority);
3213 vat_json_object_add_uint (node, "weight", mp->weight);
3216 vat_json_object_add_uint (node, "sw_if_index",
3217 clib_net_to_host_u32 (mp->sw_if_index));
3222 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3223 vat_json_object_add_ip6 (node, "address", ip6);
3227 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3228 vat_json_object_add_ip4 (node, "address", ip4);
3234 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3237 vat_main_t *vam = &vat_main;
3240 ls_name = format (0, "%s", mp->ls_name);
3242 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3248 vl_api_one_locator_set_details_t_handler_json
3249 (vl_api_one_locator_set_details_t * mp)
3251 vat_main_t *vam = &vat_main;
3252 vat_json_node_t *node = 0;
3255 ls_name = format (0, "%s", mp->ls_name);
3256 vec_add1 (ls_name, 0);
3258 if (VAT_JSON_ARRAY != vam->json_tree.type)
3260 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3261 vat_json_init_array (&vam->json_tree);
3263 node = vat_json_array_add (&vam->json_tree);
3265 vat_json_init_object (node);
3266 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3267 vat_json_object_add_uint (node, "ls_index",
3268 clib_net_to_host_u32 (mp->ls_index));
3276 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3279 unformat_nsh_address (unformat_input_t * input, va_list * args)
3281 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3282 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3286 format_nsh_address_vat (u8 * s, va_list * args)
3288 nsh_t *a = va_arg (*args, nsh_t *);
3289 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3293 format_lisp_flat_eid (u8 * s, va_list * args)
3295 u32 type = va_arg (*args, u32);
3296 u8 *eid = va_arg (*args, u8 *);
3297 u32 eid_len = va_arg (*args, u32);
3302 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3304 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3306 return format (s, "%U", format_ethernet_address, eid);
3308 return format (s, "%U", format_nsh_address_vat, eid);
3314 format_lisp_eid_vat (u8 * s, va_list * args)
3316 u32 type = va_arg (*args, u32);
3317 u8 *eid = va_arg (*args, u8 *);
3318 u32 eid_len = va_arg (*args, u32);
3319 u8 *seid = va_arg (*args, u8 *);
3320 u32 seid_len = va_arg (*args, u32);
3321 u32 is_src_dst = va_arg (*args, u32);
3324 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3326 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3332 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3334 vat_main_t *vam = &vat_main;
3335 u8 *s = 0, *eid = 0;
3337 if (~0 == mp->locator_set_index)
3338 s = format (0, "action: %d", mp->action);
3340 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3342 eid = format (0, "%U", format_lisp_eid_vat,
3346 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3349 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3350 clib_net_to_host_u32 (mp->vni),
3352 mp->is_local ? "local" : "remote",
3353 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3354 clib_net_to_host_u16 (mp->key_id), mp->key);
3361 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3364 vat_main_t *vam = &vat_main;
3365 vat_json_node_t *node = 0;
3368 if (VAT_JSON_ARRAY != vam->json_tree.type)
3370 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3371 vat_json_init_array (&vam->json_tree);
3373 node = vat_json_array_add (&vam->json_tree);
3375 vat_json_init_object (node);
3376 if (~0 == mp->locator_set_index)
3377 vat_json_object_add_uint (node, "action", mp->action);
3379 vat_json_object_add_uint (node, "locator_set_index",
3380 clib_net_to_host_u32 (mp->locator_set_index));
3382 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3383 if (mp->eid_type == 3)
3385 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3386 vat_json_init_object (nsh_json);
3387 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3388 vat_json_object_add_uint (nsh_json, "spi",
3389 clib_net_to_host_u32 (nsh->spi));
3390 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3394 eid = format (0, "%U", format_lisp_eid_vat,
3398 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3400 vat_json_object_add_string_copy (node, "eid", eid);
3403 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3404 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3405 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3409 vat_json_object_add_uint (node, "key_id",
3410 clib_net_to_host_u16 (mp->key_id));
3411 vat_json_object_add_string_copy (node, "key", mp->key);
3416 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3418 vat_main_t *vam = &vat_main;
3419 u8 *seid = 0, *deid = 0;
3420 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3422 deid = format (0, "%U", format_lisp_eid_vat,
3423 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3425 seid = format (0, "%U", format_lisp_eid_vat,
3426 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3432 format_ip_address_fcn = format_ip4_address;
3434 format_ip_address_fcn = format_ip6_address;
3437 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3438 clib_net_to_host_u32 (mp->vni),
3440 format_ip_address_fcn, mp->lloc,
3441 format_ip_address_fcn, mp->rloc,
3442 clib_net_to_host_u32 (mp->pkt_count),
3443 clib_net_to_host_u32 (mp->bytes));
3450 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3452 struct in6_addr ip6;
3454 vat_main_t *vam = &vat_main;
3455 vat_json_node_t *node = 0;
3456 u8 *deid = 0, *seid = 0;
3458 if (VAT_JSON_ARRAY != vam->json_tree.type)
3460 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3461 vat_json_init_array (&vam->json_tree);
3463 node = vat_json_array_add (&vam->json_tree);
3465 vat_json_init_object (node);
3466 deid = format (0, "%U", format_lisp_eid_vat,
3467 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3469 seid = format (0, "%U", format_lisp_eid_vat,
3470 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3475 vat_json_object_add_string_copy (node, "seid", seid);
3476 vat_json_object_add_string_copy (node, "deid", deid);
3477 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3481 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3482 vat_json_object_add_ip4 (node, "lloc", ip4);
3483 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3484 vat_json_object_add_ip4 (node, "rloc", ip4);
3488 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3489 vat_json_object_add_ip6 (node, "lloc", ip6);
3490 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3491 vat_json_object_add_ip6 (node, "rloc", ip6);
3493 vat_json_object_add_uint (node, "pkt_count",
3494 clib_net_to_host_u32 (mp->pkt_count));
3495 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3502 vl_api_one_eid_table_map_details_t_handler
3503 (vl_api_one_eid_table_map_details_t * mp)
3505 vat_main_t *vam = &vat_main;
3507 u8 *line = format (0, "%=10d%=10d",
3508 clib_net_to_host_u32 (mp->vni),
3509 clib_net_to_host_u32 (mp->dp_table));
3510 print (vam->ofp, "%v", line);
3515 vl_api_one_eid_table_map_details_t_handler_json
3516 (vl_api_one_eid_table_map_details_t * mp)
3518 vat_main_t *vam = &vat_main;
3519 vat_json_node_t *node = NULL;
3521 if (VAT_JSON_ARRAY != vam->json_tree.type)
3523 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3524 vat_json_init_array (&vam->json_tree);
3526 node = vat_json_array_add (&vam->json_tree);
3527 vat_json_init_object (node);
3528 vat_json_object_add_uint (node, "dp_table",
3529 clib_net_to_host_u32 (mp->dp_table));
3530 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3534 vl_api_one_eid_table_vni_details_t_handler
3535 (vl_api_one_eid_table_vni_details_t * mp)
3537 vat_main_t *vam = &vat_main;
3539 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3540 print (vam->ofp, "%v", line);
3545 vl_api_one_eid_table_vni_details_t_handler_json
3546 (vl_api_one_eid_table_vni_details_t * mp)
3548 vat_main_t *vam = &vat_main;
3549 vat_json_node_t *node = NULL;
3551 if (VAT_JSON_ARRAY != vam->json_tree.type)
3553 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3554 vat_json_init_array (&vam->json_tree);
3556 node = vat_json_array_add (&vam->json_tree);
3557 vat_json_init_object (node);
3558 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3562 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3563 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3565 vat_main_t *vam = &vat_main;
3566 int retval = clib_net_to_host_u32 (mp->retval);
3568 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3569 print (vam->ofp, "fallback threshold value: %d", mp->value);
3571 vam->retval = retval;
3572 vam->result_ready = 1;
3576 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3577 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3579 vat_main_t *vam = &vat_main;
3580 vat_json_node_t _node, *node = &_node;
3581 int retval = clib_net_to_host_u32 (mp->retval);
3583 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3584 vat_json_init_object (node);
3585 vat_json_object_add_uint (node, "value", mp->value);
3587 vat_json_print (vam->ofp, node);
3588 vat_json_free (node);
3590 vam->retval = retval;
3591 vam->result_ready = 1;
3595 vl_api_show_one_map_register_state_reply_t_handler
3596 (vl_api_show_one_map_register_state_reply_t * mp)
3598 vat_main_t *vam = &vat_main;
3599 int retval = clib_net_to_host_u32 (mp->retval);
3601 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3603 vam->retval = retval;
3604 vam->result_ready = 1;
3608 vl_api_show_one_map_register_state_reply_t_handler_json
3609 (vl_api_show_one_map_register_state_reply_t * mp)
3611 vat_main_t *vam = &vat_main;
3612 vat_json_node_t _node, *node = &_node;
3613 int retval = clib_net_to_host_u32 (mp->retval);
3615 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3617 vat_json_init_object (node);
3618 vat_json_object_add_string_copy (node, "state", s);
3620 vat_json_print (vam->ofp, node);
3621 vat_json_free (node);
3623 vam->retval = retval;
3624 vam->result_ready = 1;
3629 vl_api_show_one_rloc_probe_state_reply_t_handler
3630 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3632 vat_main_t *vam = &vat_main;
3633 int retval = clib_net_to_host_u32 (mp->retval);
3638 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3640 vam->retval = retval;
3641 vam->result_ready = 1;
3645 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3646 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3648 vat_main_t *vam = &vat_main;
3649 vat_json_node_t _node, *node = &_node;
3650 int retval = clib_net_to_host_u32 (mp->retval);
3652 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3653 vat_json_init_object (node);
3654 vat_json_object_add_string_copy (node, "state", s);
3656 vat_json_print (vam->ofp, node);
3657 vat_json_free (node);
3659 vam->retval = retval;
3660 vam->result_ready = 1;
3665 vl_api_show_one_stats_enable_disable_reply_t_handler
3666 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3668 vat_main_t *vam = &vat_main;
3669 int retval = clib_net_to_host_u32 (mp->retval);
3674 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3676 vam->retval = retval;
3677 vam->result_ready = 1;
3681 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3682 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3684 vat_main_t *vam = &vat_main;
3685 vat_json_node_t _node, *node = &_node;
3686 int retval = clib_net_to_host_u32 (mp->retval);
3688 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3689 vat_json_init_object (node);
3690 vat_json_object_add_string_copy (node, "state", s);
3692 vat_json_print (vam->ofp, node);
3693 vat_json_free (node);
3695 vam->retval = retval;
3696 vam->result_ready = 1;
3701 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3703 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3704 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3705 e->vni = clib_net_to_host_u32 (e->vni);
3709 gpe_fwd_entries_get_reply_t_net_to_host
3710 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3714 mp->count = clib_net_to_host_u32 (mp->count);
3715 for (i = 0; i < mp->count; i++)
3717 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3722 format_gpe_encap_mode (u8 * s, va_list * args)
3724 u32 mode = va_arg (*args, u32);
3729 return format (s, "lisp");
3731 return format (s, "vxlan");
3737 vl_api_gpe_get_encap_mode_reply_t_handler
3738 (vl_api_gpe_get_encap_mode_reply_t * mp)
3740 vat_main_t *vam = &vat_main;
3742 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3743 vam->retval = ntohl (mp->retval);
3744 vam->result_ready = 1;
3748 vl_api_gpe_get_encap_mode_reply_t_handler_json
3749 (vl_api_gpe_get_encap_mode_reply_t * mp)
3751 vat_main_t *vam = &vat_main;
3752 vat_json_node_t node;
3754 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3755 vec_add1 (encap_mode, 0);
3757 vat_json_init_object (&node);
3758 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3760 vec_free (encap_mode);
3761 vat_json_print (vam->ofp, &node);
3762 vat_json_free (&node);
3764 vam->retval = ntohl (mp->retval);
3765 vam->result_ready = 1;
3769 vl_api_gpe_fwd_entry_path_details_t_handler
3770 (vl_api_gpe_fwd_entry_path_details_t * mp)
3772 vat_main_t *vam = &vat_main;
3773 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3775 if (mp->lcl_loc.is_ip4)
3776 format_ip_address_fcn = format_ip4_address;
3778 format_ip_address_fcn = format_ip6_address;
3780 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3781 format_ip_address_fcn, &mp->lcl_loc,
3782 format_ip_address_fcn, &mp->rmt_loc);
3786 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3788 struct in6_addr ip6;
3793 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3794 vat_json_object_add_ip4 (n, "address", ip4);
3798 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3799 vat_json_object_add_ip6 (n, "address", ip6);
3801 vat_json_object_add_uint (n, "weight", loc->weight);
3805 vl_api_gpe_fwd_entry_path_details_t_handler_json
3806 (vl_api_gpe_fwd_entry_path_details_t * mp)
3808 vat_main_t *vam = &vat_main;
3809 vat_json_node_t *node = NULL;
3810 vat_json_node_t *loc_node;
3812 if (VAT_JSON_ARRAY != vam->json_tree.type)
3814 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3815 vat_json_init_array (&vam->json_tree);
3817 node = vat_json_array_add (&vam->json_tree);
3818 vat_json_init_object (node);
3820 loc_node = vat_json_object_add (node, "local_locator");
3821 vat_json_init_object (loc_node);
3822 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3824 loc_node = vat_json_object_add (node, "remote_locator");
3825 vat_json_init_object (loc_node);
3826 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3830 vl_api_gpe_fwd_entries_get_reply_t_handler
3831 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3833 vat_main_t *vam = &vat_main;
3835 int retval = clib_net_to_host_u32 (mp->retval);
3836 vl_api_gpe_fwd_entry_t *e;
3841 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3843 for (i = 0; i < mp->count; i++)
3845 e = &mp->entries[i];
3846 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3847 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3848 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3852 vam->retval = retval;
3853 vam->result_ready = 1;
3857 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3858 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3861 vat_main_t *vam = &vat_main;
3862 vat_json_node_t *e = 0, root;
3864 int retval = clib_net_to_host_u32 (mp->retval);
3865 vl_api_gpe_fwd_entry_t *fwd;
3870 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3871 vat_json_init_array (&root);
3873 for (i = 0; i < mp->count; i++)
3875 e = vat_json_array_add (&root);
3876 fwd = &mp->entries[i];
3878 vat_json_init_object (e);
3879 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3880 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3881 vat_json_object_add_int (e, "vni", fwd->vni);
3882 vat_json_object_add_int (e, "action", fwd->action);
3884 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3885 fwd->leid_prefix_len);
3887 vat_json_object_add_string_copy (e, "leid", s);
3890 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3891 fwd->reid_prefix_len);
3893 vat_json_object_add_string_copy (e, "reid", s);
3897 vat_json_print (vam->ofp, &root);
3898 vat_json_free (&root);
3901 vam->retval = retval;
3902 vam->result_ready = 1;
3906 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3907 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3909 vat_main_t *vam = &vat_main;
3911 int retval = clib_net_to_host_u32 (mp->retval);
3912 vl_api_gpe_native_fwd_rpath_t *r;
3917 n = clib_net_to_host_u32 (mp->count);
3919 for (i = 0; i < n; i++)
3921 r = &mp->entries[i];
3922 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3923 clib_net_to_host_u32 (r->fib_index),
3924 clib_net_to_host_u32 (r->nh_sw_if_index),
3925 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3929 vam->retval = retval;
3930 vam->result_ready = 1;
3934 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3935 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3937 vat_main_t *vam = &vat_main;
3938 vat_json_node_t root, *e;
3940 int retval = clib_net_to_host_u32 (mp->retval);
3941 vl_api_gpe_native_fwd_rpath_t *r;
3947 n = clib_net_to_host_u32 (mp->count);
3948 vat_json_init_array (&root);
3950 for (i = 0; i < n; i++)
3952 e = vat_json_array_add (&root);
3953 vat_json_init_object (e);
3954 r = &mp->entries[i];
3956 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3959 vat_json_object_add_string_copy (e, "ip4", s);
3962 vat_json_object_add_uint (e, "fib_index",
3963 clib_net_to_host_u32 (r->fib_index));
3964 vat_json_object_add_uint (e, "nh_sw_if_index",
3965 clib_net_to_host_u32 (r->nh_sw_if_index));
3968 vat_json_print (vam->ofp, &root);
3969 vat_json_free (&root);
3972 vam->retval = retval;
3973 vam->result_ready = 1;
3977 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3978 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3980 vat_main_t *vam = &vat_main;
3982 int retval = clib_net_to_host_u32 (mp->retval);
3987 n = clib_net_to_host_u32 (mp->count);
3989 for (i = 0; i < n; i++)
3990 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3993 vam->retval = retval;
3994 vam->result_ready = 1;
3998 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3999 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
4001 vat_main_t *vam = &vat_main;
4002 vat_json_node_t root;
4004 int retval = clib_net_to_host_u32 (mp->retval);
4009 n = clib_net_to_host_u32 (mp->count);
4010 vat_json_init_array (&root);
4012 for (i = 0; i < n; i++)
4013 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
4015 vat_json_print (vam->ofp, &root);
4016 vat_json_free (&root);
4019 vam->retval = retval;
4020 vam->result_ready = 1;
4024 vl_api_one_ndp_entries_get_reply_t_handler
4025 (vl_api_one_ndp_entries_get_reply_t * mp)
4027 vat_main_t *vam = &vat_main;
4029 int retval = clib_net_to_host_u32 (mp->retval);
4034 n = clib_net_to_host_u32 (mp->count);
4036 for (i = 0; i < n; i++)
4037 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
4038 format_ethernet_address, mp->entries[i].mac);
4041 vam->retval = retval;
4042 vam->result_ready = 1;
4046 vl_api_one_ndp_entries_get_reply_t_handler_json
4047 (vl_api_one_ndp_entries_get_reply_t * mp)
4050 vat_main_t *vam = &vat_main;
4051 vat_json_node_t *e = 0, root;
4053 int retval = clib_net_to_host_u32 (mp->retval);
4054 vl_api_one_ndp_entry_t *arp_entry;
4059 n = clib_net_to_host_u32 (mp->count);
4060 vat_json_init_array (&root);
4062 for (i = 0; i < n; i++)
4064 e = vat_json_array_add (&root);
4065 arp_entry = &mp->entries[i];
4067 vat_json_init_object (e);
4068 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4071 vat_json_object_add_string_copy (e, "mac", s);
4074 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
4076 vat_json_object_add_string_copy (e, "ip6", s);
4080 vat_json_print (vam->ofp, &root);
4081 vat_json_free (&root);
4084 vam->retval = retval;
4085 vam->result_ready = 1;
4089 vl_api_one_l2_arp_entries_get_reply_t_handler
4090 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4092 vat_main_t *vam = &vat_main;
4094 int retval = clib_net_to_host_u32 (mp->retval);
4099 n = clib_net_to_host_u32 (mp->count);
4101 for (i = 0; i < n; i++)
4102 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
4103 format_ethernet_address, mp->entries[i].mac);
4106 vam->retval = retval;
4107 vam->result_ready = 1;
4111 vl_api_one_l2_arp_entries_get_reply_t_handler_json
4112 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4115 vat_main_t *vam = &vat_main;
4116 vat_json_node_t *e = 0, root;
4118 int retval = clib_net_to_host_u32 (mp->retval);
4119 vl_api_one_l2_arp_entry_t *arp_entry;
4124 n = clib_net_to_host_u32 (mp->count);
4125 vat_json_init_array (&root);
4127 for (i = 0; i < n; i++)
4129 e = vat_json_array_add (&root);
4130 arp_entry = &mp->entries[i];
4132 vat_json_init_object (e);
4133 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4136 vat_json_object_add_string_copy (e, "mac", s);
4139 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4141 vat_json_object_add_string_copy (e, "ip4", s);
4145 vat_json_print (vam->ofp, &root);
4146 vat_json_free (&root);
4149 vam->retval = retval;
4150 vam->result_ready = 1;
4154 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4156 vat_main_t *vam = &vat_main;
4158 int retval = clib_net_to_host_u32 (mp->retval);
4163 n = clib_net_to_host_u32 (mp->count);
4165 for (i = 0; i < n; i++)
4167 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4171 vam->retval = retval;
4172 vam->result_ready = 1;
4176 vl_api_one_ndp_bd_get_reply_t_handler_json
4177 (vl_api_one_ndp_bd_get_reply_t * mp)
4179 vat_main_t *vam = &vat_main;
4180 vat_json_node_t root;
4182 int retval = clib_net_to_host_u32 (mp->retval);
4187 n = clib_net_to_host_u32 (mp->count);
4188 vat_json_init_array (&root);
4190 for (i = 0; i < n; i++)
4192 vat_json_array_add_uint (&root,
4193 clib_net_to_host_u32 (mp->bridge_domains[i]));
4196 vat_json_print (vam->ofp, &root);
4197 vat_json_free (&root);
4200 vam->retval = retval;
4201 vam->result_ready = 1;
4205 vl_api_one_l2_arp_bd_get_reply_t_handler
4206 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4208 vat_main_t *vam = &vat_main;
4210 int retval = clib_net_to_host_u32 (mp->retval);
4215 n = clib_net_to_host_u32 (mp->count);
4217 for (i = 0; i < n; i++)
4219 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4223 vam->retval = retval;
4224 vam->result_ready = 1;
4228 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4229 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4231 vat_main_t *vam = &vat_main;
4232 vat_json_node_t root;
4234 int retval = clib_net_to_host_u32 (mp->retval);
4239 n = clib_net_to_host_u32 (mp->count);
4240 vat_json_init_array (&root);
4242 for (i = 0; i < n; i++)
4244 vat_json_array_add_uint (&root,
4245 clib_net_to_host_u32 (mp->bridge_domains[i]));
4248 vat_json_print (vam->ofp, &root);
4249 vat_json_free (&root);
4252 vam->retval = retval;
4253 vam->result_ready = 1;
4257 vl_api_one_adjacencies_get_reply_t_handler
4258 (vl_api_one_adjacencies_get_reply_t * mp)
4260 vat_main_t *vam = &vat_main;
4262 int retval = clib_net_to_host_u32 (mp->retval);
4263 vl_api_one_adjacency_t *a;
4268 n = clib_net_to_host_u32 (mp->count);
4270 for (i = 0; i < n; i++)
4272 a = &mp->adjacencies[i];
4273 print (vam->ofp, "%U %40U",
4274 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4275 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4279 vam->retval = retval;
4280 vam->result_ready = 1;
4284 vl_api_one_adjacencies_get_reply_t_handler_json
4285 (vl_api_one_adjacencies_get_reply_t * mp)
4288 vat_main_t *vam = &vat_main;
4289 vat_json_node_t *e = 0, root;
4291 int retval = clib_net_to_host_u32 (mp->retval);
4292 vl_api_one_adjacency_t *a;
4297 n = clib_net_to_host_u32 (mp->count);
4298 vat_json_init_array (&root);
4300 for (i = 0; i < n; i++)
4302 e = vat_json_array_add (&root);
4303 a = &mp->adjacencies[i];
4305 vat_json_init_object (e);
4306 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4307 a->leid_prefix_len);
4309 vat_json_object_add_string_copy (e, "leid", s);
4312 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4313 a->reid_prefix_len);
4315 vat_json_object_add_string_copy (e, "reid", s);
4319 vat_json_print (vam->ofp, &root);
4320 vat_json_free (&root);
4323 vam->retval = retval;
4324 vam->result_ready = 1;
4328 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4330 vat_main_t *vam = &vat_main;
4332 print (vam->ofp, "%=20U",
4333 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4338 vl_api_one_map_server_details_t_handler_json
4339 (vl_api_one_map_server_details_t * mp)
4341 vat_main_t *vam = &vat_main;
4342 vat_json_node_t *node = NULL;
4343 struct in6_addr ip6;
4346 if (VAT_JSON_ARRAY != vam->json_tree.type)
4348 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4349 vat_json_init_array (&vam->json_tree);
4351 node = vat_json_array_add (&vam->json_tree);
4353 vat_json_init_object (node);
4356 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4357 vat_json_object_add_ip6 (node, "map-server", ip6);
4361 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4362 vat_json_object_add_ip4 (node, "map-server", ip4);
4367 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4370 vat_main_t *vam = &vat_main;
4372 print (vam->ofp, "%=20U",
4373 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4378 vl_api_one_map_resolver_details_t_handler_json
4379 (vl_api_one_map_resolver_details_t * mp)
4381 vat_main_t *vam = &vat_main;
4382 vat_json_node_t *node = NULL;
4383 struct in6_addr ip6;
4386 if (VAT_JSON_ARRAY != vam->json_tree.type)
4388 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4389 vat_json_init_array (&vam->json_tree);
4391 node = vat_json_array_add (&vam->json_tree);
4393 vat_json_init_object (node);
4396 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4397 vat_json_object_add_ip6 (node, "map resolver", ip6);
4401 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4402 vat_json_object_add_ip4 (node, "map resolver", ip4);
4407 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4409 vat_main_t *vam = &vat_main;
4410 i32 retval = ntohl (mp->retval);
4414 print (vam->ofp, "feature: %s\ngpe: %s",
4415 mp->feature_status ? "enabled" : "disabled",
4416 mp->gpe_status ? "enabled" : "disabled");
4419 vam->retval = retval;
4420 vam->result_ready = 1;
4424 vl_api_show_one_status_reply_t_handler_json
4425 (vl_api_show_one_status_reply_t * mp)
4427 vat_main_t *vam = &vat_main;
4428 vat_json_node_t node;
4429 u8 *gpe_status = NULL;
4430 u8 *feature_status = NULL;
4432 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4433 feature_status = format (0, "%s",
4434 mp->feature_status ? "enabled" : "disabled");
4435 vec_add1 (gpe_status, 0);
4436 vec_add1 (feature_status, 0);
4438 vat_json_init_object (&node);
4439 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4440 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4442 vec_free (gpe_status);
4443 vec_free (feature_status);
4445 vat_json_print (vam->ofp, &node);
4446 vat_json_free (&node);
4448 vam->retval = ntohl (mp->retval);
4449 vam->result_ready = 1;
4453 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4454 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4456 vat_main_t *vam = &vat_main;
4457 i32 retval = ntohl (mp->retval);
4461 print (vam->ofp, "%=20s", mp->locator_set_name);
4464 vam->retval = retval;
4465 vam->result_ready = 1;
4469 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4470 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4472 vat_main_t *vam = &vat_main;
4473 vat_json_node_t *node = NULL;
4475 if (VAT_JSON_ARRAY != vam->json_tree.type)
4477 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4478 vat_json_init_array (&vam->json_tree);
4480 node = vat_json_array_add (&vam->json_tree);
4482 vat_json_init_object (node);
4483 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4485 vat_json_print (vam->ofp, node);
4486 vat_json_free (node);
4488 vam->retval = ntohl (mp->retval);
4489 vam->result_ready = 1;
4493 format_lisp_map_request_mode (u8 * s, va_list * args)
4495 u32 mode = va_arg (*args, u32);
4500 return format (0, "dst-only");
4502 return format (0, "src-dst");
4508 vl_api_show_one_map_request_mode_reply_t_handler
4509 (vl_api_show_one_map_request_mode_reply_t * mp)
4511 vat_main_t *vam = &vat_main;
4512 i32 retval = ntohl (mp->retval);
4516 u32 mode = mp->mode;
4517 print (vam->ofp, "map_request_mode: %U",
4518 format_lisp_map_request_mode, mode);
4521 vam->retval = retval;
4522 vam->result_ready = 1;
4526 vl_api_show_one_map_request_mode_reply_t_handler_json
4527 (vl_api_show_one_map_request_mode_reply_t * mp)
4529 vat_main_t *vam = &vat_main;
4530 vat_json_node_t node;
4535 s = format (0, "%U", format_lisp_map_request_mode, mode);
4538 vat_json_init_object (&node);
4539 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4540 vat_json_print (vam->ofp, &node);
4541 vat_json_free (&node);
4544 vam->retval = ntohl (mp->retval);
4545 vam->result_ready = 1;
4549 vl_api_one_show_xtr_mode_reply_t_handler
4550 (vl_api_one_show_xtr_mode_reply_t * mp)
4552 vat_main_t *vam = &vat_main;
4553 i32 retval = ntohl (mp->retval);
4557 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4560 vam->retval = retval;
4561 vam->result_ready = 1;
4565 vl_api_one_show_xtr_mode_reply_t_handler_json
4566 (vl_api_one_show_xtr_mode_reply_t * mp)
4568 vat_main_t *vam = &vat_main;
4569 vat_json_node_t node;
4572 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4573 vec_add1 (status, 0);
4575 vat_json_init_object (&node);
4576 vat_json_object_add_string_copy (&node, "status", status);
4580 vat_json_print (vam->ofp, &node);
4581 vat_json_free (&node);
4583 vam->retval = ntohl (mp->retval);
4584 vam->result_ready = 1;
4588 vl_api_one_show_pitr_mode_reply_t_handler
4589 (vl_api_one_show_pitr_mode_reply_t * mp)
4591 vat_main_t *vam = &vat_main;
4592 i32 retval = ntohl (mp->retval);
4596 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4599 vam->retval = retval;
4600 vam->result_ready = 1;
4604 vl_api_one_show_pitr_mode_reply_t_handler_json
4605 (vl_api_one_show_pitr_mode_reply_t * mp)
4607 vat_main_t *vam = &vat_main;
4608 vat_json_node_t node;
4611 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4612 vec_add1 (status, 0);
4614 vat_json_init_object (&node);
4615 vat_json_object_add_string_copy (&node, "status", status);
4619 vat_json_print (vam->ofp, &node);
4620 vat_json_free (&node);
4622 vam->retval = ntohl (mp->retval);
4623 vam->result_ready = 1;
4627 vl_api_one_show_petr_mode_reply_t_handler
4628 (vl_api_one_show_petr_mode_reply_t * mp)
4630 vat_main_t *vam = &vat_main;
4631 i32 retval = ntohl (mp->retval);
4635 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4638 vam->retval = retval;
4639 vam->result_ready = 1;
4643 vl_api_one_show_petr_mode_reply_t_handler_json
4644 (vl_api_one_show_petr_mode_reply_t * mp)
4646 vat_main_t *vam = &vat_main;
4647 vat_json_node_t node;
4650 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4651 vec_add1 (status, 0);
4653 vat_json_init_object (&node);
4654 vat_json_object_add_string_copy (&node, "status", status);
4658 vat_json_print (vam->ofp, &node);
4659 vat_json_free (&node);
4661 vam->retval = ntohl (mp->retval);
4662 vam->result_ready = 1;
4666 vl_api_show_one_use_petr_reply_t_handler
4667 (vl_api_show_one_use_petr_reply_t * mp)
4669 vat_main_t *vam = &vat_main;
4670 i32 retval = ntohl (mp->retval);
4674 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4677 print (vam->ofp, "Proxy-ETR address; %U",
4678 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4683 vam->retval = retval;
4684 vam->result_ready = 1;
4688 vl_api_show_one_use_petr_reply_t_handler_json
4689 (vl_api_show_one_use_petr_reply_t * mp)
4691 vat_main_t *vam = &vat_main;
4692 vat_json_node_t node;
4695 struct in6_addr ip6;
4697 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4698 vec_add1 (status, 0);
4700 vat_json_init_object (&node);
4701 vat_json_object_add_string_copy (&node, "status", status);
4706 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4707 vat_json_object_add_ip6 (&node, "address", ip6);
4711 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4712 vat_json_object_add_ip4 (&node, "address", ip4);
4718 vat_json_print (vam->ofp, &node);
4719 vat_json_free (&node);
4721 vam->retval = ntohl (mp->retval);
4722 vam->result_ready = 1;
4726 vl_api_show_one_nsh_mapping_reply_t_handler
4727 (vl_api_show_one_nsh_mapping_reply_t * mp)
4729 vat_main_t *vam = &vat_main;
4730 i32 retval = ntohl (mp->retval);
4734 print (vam->ofp, "%-20s%-16s",
4735 mp->is_set ? "set" : "not-set",
4736 mp->is_set ? (char *) mp->locator_set_name : "");
4739 vam->retval = retval;
4740 vam->result_ready = 1;
4744 vl_api_show_one_nsh_mapping_reply_t_handler_json
4745 (vl_api_show_one_nsh_mapping_reply_t * mp)
4747 vat_main_t *vam = &vat_main;
4748 vat_json_node_t node;
4751 status = format (0, "%s", mp->is_set ? "yes" : "no");
4752 vec_add1 (status, 0);
4754 vat_json_init_object (&node);
4755 vat_json_object_add_string_copy (&node, "is_set", status);
4758 vat_json_object_add_string_copy (&node, "locator_set",
4759 mp->locator_set_name);
4764 vat_json_print (vam->ofp, &node);
4765 vat_json_free (&node);
4767 vam->retval = ntohl (mp->retval);
4768 vam->result_ready = 1;
4772 vl_api_show_one_map_register_ttl_reply_t_handler
4773 (vl_api_show_one_map_register_ttl_reply_t * mp)
4775 vat_main_t *vam = &vat_main;
4776 i32 retval = ntohl (mp->retval);
4778 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4782 print (vam->ofp, "ttl: %u", mp->ttl);
4785 vam->retval = retval;
4786 vam->result_ready = 1;
4790 vl_api_show_one_map_register_ttl_reply_t_handler_json
4791 (vl_api_show_one_map_register_ttl_reply_t * mp)
4793 vat_main_t *vam = &vat_main;
4794 vat_json_node_t node;
4796 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4797 vat_json_init_object (&node);
4798 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4800 vat_json_print (vam->ofp, &node);
4801 vat_json_free (&node);
4803 vam->retval = ntohl (mp->retval);
4804 vam->result_ready = 1;
4808 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4810 vat_main_t *vam = &vat_main;
4811 i32 retval = ntohl (mp->retval);
4815 print (vam->ofp, "%-20s%-16s",
4816 mp->status ? "enabled" : "disabled",
4817 mp->status ? (char *) mp->locator_set_name : "");
4820 vam->retval = retval;
4821 vam->result_ready = 1;
4825 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4827 vat_main_t *vam = &vat_main;
4828 vat_json_node_t node;
4831 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4832 vec_add1 (status, 0);
4834 vat_json_init_object (&node);
4835 vat_json_object_add_string_copy (&node, "status", status);
4838 vat_json_object_add_string_copy (&node, "locator_set",
4839 mp->locator_set_name);
4844 vat_json_print (vam->ofp, &node);
4845 vat_json_free (&node);
4847 vam->retval = ntohl (mp->retval);
4848 vam->result_ready = 1;
4852 format_policer_type (u8 * s, va_list * va)
4854 u32 i = va_arg (*va, u32);
4856 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4857 s = format (s, "1r2c");
4858 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4859 s = format (s, "1r3c");
4860 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4861 s = format (s, "2r3c-2698");
4862 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4863 s = format (s, "2r3c-4115");
4864 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4865 s = format (s, "2r3c-mef5cf1");
4867 s = format (s, "ILLEGAL");
4872 format_policer_rate_type (u8 * s, va_list * va)
4874 u32 i = va_arg (*va, u32);
4876 if (i == SSE2_QOS_RATE_KBPS)
4877 s = format (s, "kbps");
4878 else if (i == SSE2_QOS_RATE_PPS)
4879 s = format (s, "pps");
4881 s = format (s, "ILLEGAL");
4886 format_policer_round_type (u8 * s, va_list * va)
4888 u32 i = va_arg (*va, u32);
4890 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4891 s = format (s, "closest");
4892 else if (i == SSE2_QOS_ROUND_TO_UP)
4893 s = format (s, "up");
4894 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4895 s = format (s, "down");
4897 s = format (s, "ILLEGAL");
4902 format_policer_action_type (u8 * s, va_list * va)
4904 u32 i = va_arg (*va, u32);
4906 if (i == SSE2_QOS_ACTION_DROP)
4907 s = format (s, "drop");
4908 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4909 s = format (s, "transmit");
4910 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4911 s = format (s, "mark-and-transmit");
4913 s = format (s, "ILLEGAL");
4918 format_dscp (u8 * s, va_list * va)
4920 u32 i = va_arg (*va, u32);
4925 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4929 return format (s, "ILLEGAL");
4931 s = format (s, "%s", t);
4936 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4938 vat_main_t *vam = &vat_main;
4939 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4941 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4942 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4944 conform_dscp_str = format (0, "");
4946 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4947 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4949 exceed_dscp_str = format (0, "");
4951 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4952 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4954 violate_dscp_str = format (0, "");
4956 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4957 "rate type %U, round type %U, %s rate, %s color-aware, "
4958 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4959 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4960 "conform action %U%s, exceed action %U%s, violate action %U%s",
4962 format_policer_type, mp->type,
4965 clib_net_to_host_u64 (mp->cb),
4966 clib_net_to_host_u64 (mp->eb),
4967 format_policer_rate_type, mp->rate_type,
4968 format_policer_round_type, mp->round_type,
4969 mp->single_rate ? "single" : "dual",
4970 mp->color_aware ? "is" : "not",
4971 ntohl (mp->cir_tokens_per_period),
4972 ntohl (mp->pir_tokens_per_period),
4974 ntohl (mp->current_limit),
4975 ntohl (mp->current_bucket),
4976 ntohl (mp->extended_limit),
4977 ntohl (mp->extended_bucket),
4978 clib_net_to_host_u64 (mp->last_update_time),
4979 format_policer_action_type, mp->conform_action_type,
4981 format_policer_action_type, mp->exceed_action_type,
4983 format_policer_action_type, mp->violate_action_type,
4986 vec_free (conform_dscp_str);
4987 vec_free (exceed_dscp_str);
4988 vec_free (violate_dscp_str);
4991 static void vl_api_policer_details_t_handler_json
4992 (vl_api_policer_details_t * mp)
4994 vat_main_t *vam = &vat_main;
4995 vat_json_node_t *node;
4996 u8 *rate_type_str, *round_type_str, *type_str;
4997 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4999 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
5001 format (0, "%U", format_policer_round_type, mp->round_type);
5002 type_str = format (0, "%U", format_policer_type, mp->type);
5003 conform_action_str = format (0, "%U", format_policer_action_type,
5004 mp->conform_action_type);
5005 exceed_action_str = format (0, "%U", format_policer_action_type,
5006 mp->exceed_action_type);
5007 violate_action_str = format (0, "%U", format_policer_action_type,
5008 mp->violate_action_type);
5010 if (VAT_JSON_ARRAY != vam->json_tree.type)
5012 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5013 vat_json_init_array (&vam->json_tree);
5015 node = vat_json_array_add (&vam->json_tree);
5017 vat_json_init_object (node);
5018 vat_json_object_add_string_copy (node, "name", mp->name);
5019 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
5020 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
5021 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
5022 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
5023 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
5024 vat_json_object_add_string_copy (node, "round_type", round_type_str);
5025 vat_json_object_add_string_copy (node, "type", type_str);
5026 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
5027 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
5028 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
5029 vat_json_object_add_uint (node, "cir_tokens_per_period",
5030 ntohl (mp->cir_tokens_per_period));
5031 vat_json_object_add_uint (node, "eir_tokens_per_period",
5032 ntohl (mp->pir_tokens_per_period));
5033 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
5034 vat_json_object_add_uint (node, "current_bucket",
5035 ntohl (mp->current_bucket));
5036 vat_json_object_add_uint (node, "extended_limit",
5037 ntohl (mp->extended_limit));
5038 vat_json_object_add_uint (node, "extended_bucket",
5039 ntohl (mp->extended_bucket));
5040 vat_json_object_add_uint (node, "last_update_time",
5041 ntohl (mp->last_update_time));
5042 vat_json_object_add_string_copy (node, "conform_action",
5043 conform_action_str);
5044 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5046 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
5047 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
5048 vec_free (dscp_str);
5050 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
5051 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5053 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
5054 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
5055 vec_free (dscp_str);
5057 vat_json_object_add_string_copy (node, "violate_action",
5058 violate_action_str);
5059 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5061 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
5062 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
5063 vec_free (dscp_str);
5066 vec_free (rate_type_str);
5067 vec_free (round_type_str);
5068 vec_free (type_str);
5069 vec_free (conform_action_str);
5070 vec_free (exceed_action_str);
5071 vec_free (violate_action_str);
5075 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
5078 vat_main_t *vam = &vat_main;
5079 int i, count = ntohl (mp->count);
5082 print (vam->ofp, "classify table ids (%d) : ", count);
5083 for (i = 0; i < count; i++)
5085 print (vam->ofp, "%d", ntohl (mp->ids[i]));
5086 print (vam->ofp, (i < count - 1) ? "," : "");
5088 vam->retval = ntohl (mp->retval);
5089 vam->result_ready = 1;
5093 vl_api_classify_table_ids_reply_t_handler_json
5094 (vl_api_classify_table_ids_reply_t * mp)
5096 vat_main_t *vam = &vat_main;
5097 int i, count = ntohl (mp->count);
5101 vat_json_node_t node;
5103 vat_json_init_object (&node);
5104 for (i = 0; i < count; i++)
5106 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
5108 vat_json_print (vam->ofp, &node);
5109 vat_json_free (&node);
5111 vam->retval = ntohl (mp->retval);
5112 vam->result_ready = 1;
5116 vl_api_classify_table_by_interface_reply_t_handler
5117 (vl_api_classify_table_by_interface_reply_t * mp)
5119 vat_main_t *vam = &vat_main;
5122 table_id = ntohl (mp->l2_table_id);
5124 print (vam->ofp, "l2 table id : %d", table_id);
5126 print (vam->ofp, "l2 table id : No input ACL tables configured");
5127 table_id = ntohl (mp->ip4_table_id);
5129 print (vam->ofp, "ip4 table id : %d", table_id);
5131 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5132 table_id = ntohl (mp->ip6_table_id);
5134 print (vam->ofp, "ip6 table id : %d", table_id);
5136 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5137 vam->retval = ntohl (mp->retval);
5138 vam->result_ready = 1;
5142 vl_api_classify_table_by_interface_reply_t_handler_json
5143 (vl_api_classify_table_by_interface_reply_t * mp)
5145 vat_main_t *vam = &vat_main;
5146 vat_json_node_t node;
5148 vat_json_init_object (&node);
5150 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5151 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5152 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5154 vat_json_print (vam->ofp, &node);
5155 vat_json_free (&node);
5157 vam->retval = ntohl (mp->retval);
5158 vam->result_ready = 1;
5161 static void vl_api_policer_add_del_reply_t_handler
5162 (vl_api_policer_add_del_reply_t * mp)
5164 vat_main_t *vam = &vat_main;
5165 i32 retval = ntohl (mp->retval);
5166 if (vam->async_mode)
5168 vam->async_errors += (retval < 0);
5172 vam->retval = retval;
5173 vam->result_ready = 1;
5174 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5176 * Note: this is just barely thread-safe, depends on
5177 * the main thread spinning waiting for an answer...
5179 errmsg ("policer index %d", ntohl (mp->policer_index));
5183 static void vl_api_policer_add_del_reply_t_handler_json
5184 (vl_api_policer_add_del_reply_t * mp)
5186 vat_main_t *vam = &vat_main;
5187 vat_json_node_t node;
5189 vat_json_init_object (&node);
5190 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5191 vat_json_object_add_uint (&node, "policer_index",
5192 ntohl (mp->policer_index));
5194 vat_json_print (vam->ofp, &node);
5195 vat_json_free (&node);
5197 vam->retval = ntohl (mp->retval);
5198 vam->result_ready = 1;
5201 /* Format hex dump. */
5203 format_hex_bytes (u8 * s, va_list * va)
5205 u8 *bytes = va_arg (*va, u8 *);
5206 int n_bytes = va_arg (*va, int);
5209 /* Print short or long form depending on byte count. */
5210 uword short_form = n_bytes <= 32;
5211 u32 indent = format_get_indent (s);
5216 for (i = 0; i < n_bytes; i++)
5218 if (!short_form && (i % 32) == 0)
5219 s = format (s, "%08x: ", i);
5220 s = format (s, "%02x", bytes[i]);
5221 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5222 s = format (s, "\n%U", format_white_space, indent);
5229 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5232 vat_main_t *vam = &vat_main;
5233 i32 retval = ntohl (mp->retval);
5236 print (vam->ofp, "classify table info :");
5237 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5238 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5239 ntohl (mp->miss_next_index));
5240 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5241 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5242 ntohl (mp->match_n_vectors));
5243 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5244 ntohl (mp->mask_length));
5246 vam->retval = retval;
5247 vam->result_ready = 1;
5251 vl_api_classify_table_info_reply_t_handler_json
5252 (vl_api_classify_table_info_reply_t * mp)
5254 vat_main_t *vam = &vat_main;
5255 vat_json_node_t node;
5257 i32 retval = ntohl (mp->retval);
5260 vat_json_init_object (&node);
5262 vat_json_object_add_int (&node, "sessions",
5263 ntohl (mp->active_sessions));
5264 vat_json_object_add_int (&node, "nexttbl",
5265 ntohl (mp->next_table_index));
5266 vat_json_object_add_int (&node, "nextnode",
5267 ntohl (mp->miss_next_index));
5268 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5269 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5270 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5271 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5272 ntohl (mp->mask_length), 0);
5273 vat_json_object_add_string_copy (&node, "mask", s);
5275 vat_json_print (vam->ofp, &node);
5276 vat_json_free (&node);
5278 vam->retval = ntohl (mp->retval);
5279 vam->result_ready = 1;
5283 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5286 vat_main_t *vam = &vat_main;
5288 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5289 ntohl (mp->hit_next_index), ntohl (mp->advance),
5290 ntohl (mp->opaque_index));
5291 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5292 ntohl (mp->match_length));
5296 vl_api_classify_session_details_t_handler_json
5297 (vl_api_classify_session_details_t * mp)
5299 vat_main_t *vam = &vat_main;
5300 vat_json_node_t *node = NULL;
5302 if (VAT_JSON_ARRAY != vam->json_tree.type)
5304 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5305 vat_json_init_array (&vam->json_tree);
5307 node = vat_json_array_add (&vam->json_tree);
5309 vat_json_init_object (node);
5310 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5311 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5312 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5314 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5316 vat_json_object_add_string_copy (node, "match", s);
5319 static void vl_api_pg_create_interface_reply_t_handler
5320 (vl_api_pg_create_interface_reply_t * mp)
5322 vat_main_t *vam = &vat_main;
5324 vam->retval = ntohl (mp->retval);
5325 vam->result_ready = 1;
5328 static void vl_api_pg_create_interface_reply_t_handler_json
5329 (vl_api_pg_create_interface_reply_t * mp)
5331 vat_main_t *vam = &vat_main;
5332 vat_json_node_t node;
5334 i32 retval = ntohl (mp->retval);
5337 vat_json_init_object (&node);
5339 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5341 vat_json_print (vam->ofp, &node);
5342 vat_json_free (&node);
5344 vam->retval = ntohl (mp->retval);
5345 vam->result_ready = 1;
5348 static void vl_api_policer_classify_details_t_handler
5349 (vl_api_policer_classify_details_t * mp)
5351 vat_main_t *vam = &vat_main;
5353 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5354 ntohl (mp->table_index));
5357 static void vl_api_policer_classify_details_t_handler_json
5358 (vl_api_policer_classify_details_t * mp)
5360 vat_main_t *vam = &vat_main;
5361 vat_json_node_t *node;
5363 if (VAT_JSON_ARRAY != vam->json_tree.type)
5365 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5366 vat_json_init_array (&vam->json_tree);
5368 node = vat_json_array_add (&vam->json_tree);
5370 vat_json_init_object (node);
5371 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5372 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5375 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5376 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5378 vat_main_t *vam = &vat_main;
5379 i32 retval = ntohl (mp->retval);
5380 if (vam->async_mode)
5382 vam->async_errors += (retval < 0);
5386 vam->retval = retval;
5387 vam->sw_if_index = ntohl (mp->sw_if_index);
5388 vam->result_ready = 1;
5390 vam->regenerate_interface_table = 1;
5393 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5394 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5396 vat_main_t *vam = &vat_main;
5397 vat_json_node_t node;
5399 vat_json_init_object (&node);
5400 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5401 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5403 vat_json_print (vam->ofp, &node);
5404 vat_json_free (&node);
5406 vam->retval = ntohl (mp->retval);
5407 vam->result_ready = 1;
5410 static void vl_api_flow_classify_details_t_handler
5411 (vl_api_flow_classify_details_t * mp)
5413 vat_main_t *vam = &vat_main;
5415 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5416 ntohl (mp->table_index));
5419 static void vl_api_flow_classify_details_t_handler_json
5420 (vl_api_flow_classify_details_t * mp)
5422 vat_main_t *vam = &vat_main;
5423 vat_json_node_t *node;
5425 if (VAT_JSON_ARRAY != vam->json_tree.type)
5427 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5428 vat_json_init_array (&vam->json_tree);
5430 node = vat_json_array_add (&vam->json_tree);
5432 vat_json_init_object (node);
5433 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5434 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5437 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5438 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5439 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5440 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5441 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5442 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5443 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5444 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5445 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5446 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5447 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5448 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5449 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5450 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5451 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5452 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5453 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5454 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5455 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5456 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5457 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5458 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5461 * Generate boilerplate reply handlers, which
5462 * dig the return value out of the xxx_reply_t API message,
5463 * stick it into vam->retval, and set vam->result_ready
5465 * Could also do this by pointing N message decode slots at
5466 * a single function, but that could break in subtle ways.
5469 #define foreach_standard_reply_retval_handler \
5470 _(sw_interface_set_flags_reply) \
5471 _(sw_interface_add_del_address_reply) \
5472 _(sw_interface_set_rx_mode_reply) \
5473 _(sw_interface_set_rx_placement_reply) \
5474 _(sw_interface_set_table_reply) \
5475 _(sw_interface_set_mpls_enable_reply) \
5476 _(sw_interface_set_vpath_reply) \
5477 _(sw_interface_set_vxlan_bypass_reply) \
5478 _(sw_interface_set_geneve_bypass_reply) \
5479 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5480 _(sw_interface_set_l2_bridge_reply) \
5481 _(bridge_domain_add_del_reply) \
5482 _(sw_interface_set_l2_xconnect_reply) \
5483 _(l2fib_add_del_reply) \
5484 _(l2fib_flush_int_reply) \
5485 _(l2fib_flush_bd_reply) \
5486 _(ip_add_del_route_reply) \
5487 _(ip_table_add_del_reply) \
5488 _(ip_mroute_add_del_reply) \
5489 _(mpls_route_add_del_reply) \
5490 _(mpls_table_add_del_reply) \
5491 _(mpls_ip_bind_unbind_reply) \
5492 _(bier_route_add_del_reply) \
5493 _(bier_table_add_del_reply) \
5494 _(proxy_arp_add_del_reply) \
5495 _(proxy_arp_intfc_enable_disable_reply) \
5496 _(sw_interface_set_unnumbered_reply) \
5497 _(ip_neighbor_add_del_reply) \
5498 _(oam_add_del_reply) \
5499 _(reset_fib_reply) \
5500 _(dhcp_proxy_config_reply) \
5501 _(dhcp_proxy_set_vss_reply) \
5502 _(dhcp_client_config_reply) \
5503 _(set_ip_flow_hash_reply) \
5504 _(sw_interface_ip6_enable_disable_reply) \
5505 _(ip6nd_proxy_add_del_reply) \
5506 _(sw_interface_ip6nd_ra_prefix_reply) \
5507 _(sw_interface_ip6nd_ra_config_reply) \
5508 _(set_arp_neighbor_limit_reply) \
5509 _(l2_patch_add_del_reply) \
5510 _(sr_mpls_policy_add_reply) \
5511 _(sr_mpls_policy_mod_reply) \
5512 _(sr_mpls_policy_del_reply) \
5513 _(sr_policy_add_reply) \
5514 _(sr_policy_mod_reply) \
5515 _(sr_policy_del_reply) \
5516 _(sr_localsid_add_del_reply) \
5517 _(sr_steering_add_del_reply) \
5518 _(classify_add_del_session_reply) \
5519 _(classify_set_interface_ip_table_reply) \
5520 _(classify_set_interface_l2_tables_reply) \
5521 _(l2tpv3_set_tunnel_cookies_reply) \
5522 _(l2tpv3_interface_enable_disable_reply) \
5523 _(l2tpv3_set_lookup_key_reply) \
5524 _(l2_fib_clear_table_reply) \
5525 _(l2_interface_efp_filter_reply) \
5526 _(l2_interface_vlan_tag_rewrite_reply) \
5527 _(modify_vhost_user_if_reply) \
5528 _(delete_vhost_user_if_reply) \
5529 _(ip_probe_neighbor_reply) \
5530 _(ip_scan_neighbor_enable_disable_reply) \
5531 _(want_ip4_arp_events_reply) \
5532 _(want_ip6_nd_events_reply) \
5533 _(want_l2_macs_events_reply) \
5534 _(input_acl_set_interface_reply) \
5535 _(ipsec_spd_add_del_reply) \
5536 _(ipsec_interface_add_del_spd_reply) \
5537 _(ipsec_spd_add_del_entry_reply) \
5538 _(ipsec_sad_add_del_entry_reply) \
5539 _(ipsec_sa_set_key_reply) \
5540 _(ipsec_tunnel_if_add_del_reply) \
5541 _(ipsec_tunnel_if_set_key_reply) \
5542 _(ipsec_tunnel_if_set_sa_reply) \
5543 _(ikev2_profile_add_del_reply) \
5544 _(ikev2_profile_set_auth_reply) \
5545 _(ikev2_profile_set_id_reply) \
5546 _(ikev2_profile_set_ts_reply) \
5547 _(ikev2_set_local_key_reply) \
5548 _(ikev2_set_responder_reply) \
5549 _(ikev2_set_ike_transforms_reply) \
5550 _(ikev2_set_esp_transforms_reply) \
5551 _(ikev2_set_sa_lifetime_reply) \
5552 _(ikev2_initiate_sa_init_reply) \
5553 _(ikev2_initiate_del_ike_sa_reply) \
5554 _(ikev2_initiate_del_child_sa_reply) \
5555 _(ikev2_initiate_rekey_child_sa_reply) \
5556 _(delete_loopback_reply) \
5557 _(bd_ip_mac_add_del_reply) \
5558 _(want_interface_events_reply) \
5559 _(want_stats_reply) \
5560 _(cop_interface_enable_disable_reply) \
5561 _(cop_whitelist_enable_disable_reply) \
5562 _(sw_interface_clear_stats_reply) \
5563 _(ioam_enable_reply) \
5564 _(ioam_disable_reply) \
5565 _(one_add_del_locator_reply) \
5566 _(one_add_del_local_eid_reply) \
5567 _(one_add_del_remote_mapping_reply) \
5568 _(one_add_del_adjacency_reply) \
5569 _(one_add_del_map_resolver_reply) \
5570 _(one_add_del_map_server_reply) \
5571 _(one_enable_disable_reply) \
5572 _(one_rloc_probe_enable_disable_reply) \
5573 _(one_map_register_enable_disable_reply) \
5574 _(one_map_register_set_ttl_reply) \
5575 _(one_set_transport_protocol_reply) \
5576 _(one_map_register_fallback_threshold_reply) \
5577 _(one_pitr_set_locator_set_reply) \
5578 _(one_map_request_mode_reply) \
5579 _(one_add_del_map_request_itr_rlocs_reply) \
5580 _(one_eid_table_add_del_map_reply) \
5581 _(one_use_petr_reply) \
5582 _(one_stats_enable_disable_reply) \
5583 _(one_add_del_l2_arp_entry_reply) \
5584 _(one_add_del_ndp_entry_reply) \
5585 _(one_stats_flush_reply) \
5586 _(one_enable_disable_xtr_mode_reply) \
5587 _(one_enable_disable_pitr_mode_reply) \
5588 _(one_enable_disable_petr_mode_reply) \
5589 _(gpe_enable_disable_reply) \
5590 _(gpe_set_encap_mode_reply) \
5591 _(gpe_add_del_iface_reply) \
5592 _(gpe_add_del_native_fwd_rpath_reply) \
5593 _(af_packet_delete_reply) \
5594 _(policer_classify_set_interface_reply) \
5595 _(netmap_create_reply) \
5596 _(netmap_delete_reply) \
5597 _(set_ipfix_exporter_reply) \
5598 _(set_ipfix_classify_stream_reply) \
5599 _(ipfix_classify_table_add_del_reply) \
5600 _(flow_classify_set_interface_reply) \
5601 _(sw_interface_span_enable_disable_reply) \
5602 _(pg_capture_reply) \
5603 _(pg_enable_disable_reply) \
5604 _(ip_source_and_port_range_check_add_del_reply) \
5605 _(ip_source_and_port_range_check_interface_add_del_reply)\
5606 _(delete_subif_reply) \
5607 _(l2_interface_pbb_tag_rewrite_reply) \
5609 _(feature_enable_disable_reply) \
5610 _(sw_interface_tag_add_del_reply) \
5611 _(hw_interface_set_mtu_reply) \
5612 _(p2p_ethernet_add_reply) \
5613 _(p2p_ethernet_del_reply) \
5614 _(lldp_config_reply) \
5615 _(sw_interface_set_lldp_reply) \
5616 _(tcp_configure_src_addresses_reply) \
5617 _(dns_enable_disable_reply) \
5618 _(dns_name_server_add_del_reply) \
5619 _(session_rule_add_del_reply) \
5620 _(ip_container_proxy_add_del_reply) \
5621 _(output_acl_set_interface_reply) \
5622 _(qos_record_enable_disable_reply)
5625 static void vl_api_##n##_t_handler \
5626 (vl_api_##n##_t * mp) \
5628 vat_main_t * vam = &vat_main; \
5629 i32 retval = ntohl(mp->retval); \
5630 if (vam->async_mode) { \
5631 vam->async_errors += (retval < 0); \
5633 vam->retval = retval; \
5634 vam->result_ready = 1; \
5637 foreach_standard_reply_retval_handler;
5641 static void vl_api_##n##_t_handler_json \
5642 (vl_api_##n##_t * mp) \
5644 vat_main_t * vam = &vat_main; \
5645 vat_json_node_t node; \
5646 vat_json_init_object(&node); \
5647 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5648 vat_json_print(vam->ofp, &node); \
5649 vam->retval = ntohl(mp->retval); \
5650 vam->result_ready = 1; \
5652 foreach_standard_reply_retval_handler;
5656 * Table of message reply handlers, must include boilerplate handlers
5660 #define foreach_vpe_api_reply_msg \
5661 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5662 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5663 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5664 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5665 _(CONTROL_PING_REPLY, control_ping_reply) \
5666 _(CLI_REPLY, cli_reply) \
5667 _(CLI_INBAND_REPLY, cli_inband_reply) \
5668 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5669 sw_interface_add_del_address_reply) \
5670 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5671 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5672 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5673 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5674 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5675 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5676 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5677 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5678 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5679 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5680 sw_interface_set_l2_xconnect_reply) \
5681 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5682 sw_interface_set_l2_bridge_reply) \
5683 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5684 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5685 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5686 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5687 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5688 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5689 _(L2_FLAGS_REPLY, l2_flags_reply) \
5690 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5691 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5692 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5693 _(TAP_DELETE_REPLY, tap_delete_reply) \
5694 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5695 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5696 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5697 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5698 _(BOND_CREATE_REPLY, bond_create_reply) \
5699 _(BOND_DELETE_REPLY, bond_delete_reply) \
5700 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5701 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5702 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5703 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5704 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5705 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5706 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5707 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5708 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5709 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5710 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5711 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5712 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5713 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5714 proxy_arp_intfc_enable_disable_reply) \
5715 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5716 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5717 sw_interface_set_unnumbered_reply) \
5718 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5719 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5720 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5721 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5722 _(RESET_FIB_REPLY, reset_fib_reply) \
5723 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5724 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5725 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5726 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5727 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5728 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5729 sw_interface_ip6_enable_disable_reply) \
5730 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5731 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5732 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5733 sw_interface_ip6nd_ra_prefix_reply) \
5734 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5735 sw_interface_ip6nd_ra_config_reply) \
5736 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5737 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5738 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5739 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5740 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5741 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5742 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5743 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5744 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5745 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5746 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5747 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5748 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5749 classify_set_interface_ip_table_reply) \
5750 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5751 classify_set_interface_l2_tables_reply) \
5752 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5753 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5754 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5755 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5756 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5757 l2tpv3_interface_enable_disable_reply) \
5758 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5759 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5760 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5761 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5762 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5763 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5764 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5765 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5766 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5767 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5768 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5769 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5770 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5771 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5772 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5773 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5774 _(SHOW_VERSION_REPLY, show_version_reply) \
5775 _(SHOW_THREADS_REPLY, show_threads_reply) \
5776 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5777 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5778 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5779 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5780 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5781 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5782 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5783 _(IP4_ARP_EVENT, ip4_arp_event) \
5784 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5785 _(IP6_ND_EVENT, ip6_nd_event) \
5786 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5787 _(L2_MACS_EVENT, l2_macs_event) \
5788 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5789 _(IP_ADDRESS_DETAILS, ip_address_details) \
5790 _(IP_DETAILS, ip_details) \
5791 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5792 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5793 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5794 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5795 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5796 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5797 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5798 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5799 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5800 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5801 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5802 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5803 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5804 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5805 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5806 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5807 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5808 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5809 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5810 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5811 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5812 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5813 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5814 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5815 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5816 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5817 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5818 _(WANT_STATS_REPLY, want_stats_reply) \
5819 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5820 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5821 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5822 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5823 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5824 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5825 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5826 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5827 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5828 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5829 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5830 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5831 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5832 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5833 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5834 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5835 one_map_register_enable_disable_reply) \
5836 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5837 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5838 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5839 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5840 one_map_register_fallback_threshold_reply) \
5841 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5842 one_rloc_probe_enable_disable_reply) \
5843 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5844 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5845 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5846 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5847 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5848 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5849 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5850 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5851 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5852 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5853 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5854 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5855 _(ONE_STATS_DETAILS, one_stats_details) \
5856 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5857 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5858 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5859 show_one_stats_enable_disable_reply) \
5860 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5861 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5862 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5863 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5864 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5865 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5866 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5867 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5868 one_enable_disable_pitr_mode_reply) \
5869 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5870 one_enable_disable_petr_mode_reply) \
5871 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5872 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5873 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5874 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5875 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5876 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5877 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5878 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5879 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5880 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5881 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5882 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5883 gpe_add_del_native_fwd_rpath_reply) \
5884 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5885 gpe_fwd_entry_path_details) \
5886 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5887 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5888 one_add_del_map_request_itr_rlocs_reply) \
5889 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5890 one_get_map_request_itr_rlocs_reply) \
5891 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5892 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5893 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5894 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5895 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5896 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5897 show_one_map_register_state_reply) \
5898 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5899 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5900 show_one_map_register_fallback_threshold_reply) \
5901 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5902 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5903 _(AF_PACKET_DETAILS, af_packet_details) \
5904 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5905 _(POLICER_DETAILS, policer_details) \
5906 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5907 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5908 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5909 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5910 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5911 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5912 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5913 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5914 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5915 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5916 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5917 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5918 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5919 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5920 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5921 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5922 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5923 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5924 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5925 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5926 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5927 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5928 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5929 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5930 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5931 ip_source_and_port_range_check_add_del_reply) \
5932 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5933 ip_source_and_port_range_check_interface_add_del_reply) \
5934 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5935 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5936 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5937 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5938 _(SET_PUNT_REPLY, set_punt_reply) \
5939 _(IP_FIB_DETAILS, ip_fib_details) \
5940 _(IP6_FIB_DETAILS, ip6_fib_details) \
5941 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5942 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5943 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5944 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5945 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5946 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5947 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5948 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5949 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5950 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5951 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5952 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5953 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5954 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5955 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5956 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5957 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5958 _(SESSION_RULES_DETAILS, session_rules_details) \
5959 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5960 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5961 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5963 #define foreach_standalone_reply_msg \
5964 _(SW_INTERFACE_EVENT, sw_interface_event) \
5965 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5966 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5967 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5968 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5969 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5970 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5978 #define STR_VTR_OP_CASE(op) \
5979 case L2_VTR_ ## op: \
5983 str_vtr_op (u32 vtr_op)
5987 STR_VTR_OP_CASE (DISABLED);
5988 STR_VTR_OP_CASE (PUSH_1);
5989 STR_VTR_OP_CASE (PUSH_2);
5990 STR_VTR_OP_CASE (POP_1);
5991 STR_VTR_OP_CASE (POP_2);
5992 STR_VTR_OP_CASE (TRANSLATE_1_1);
5993 STR_VTR_OP_CASE (TRANSLATE_1_2);
5994 STR_VTR_OP_CASE (TRANSLATE_2_1);
5995 STR_VTR_OP_CASE (TRANSLATE_2_2);
6002 dump_sub_interface_table (vat_main_t * vam)
6004 const sw_interface_subif_t *sub = NULL;
6006 if (vam->json_output)
6009 ("JSON output supported only for VPE API calls and dump_stats_table");
6014 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
6015 "Interface", "sw_if_index",
6016 "sub id", "dot1ad", "tags", "outer id",
6017 "inner id", "exact", "default", "outer any", "inner any");
6019 vec_foreach (sub, vam->sw_if_subif_table)
6022 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
6023 sub->interface_name,
6025 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
6026 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
6027 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
6028 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
6029 if (sub->vtr_op != L2_VTR_DISABLED)
6032 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
6033 "tag1: %d tag2: %d ]",
6034 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
6035 sub->vtr_tag1, sub->vtr_tag2);
6043 name_sort_cmp (void *a1, void *a2)
6045 name_sort_t *n1 = a1;
6046 name_sort_t *n2 = a2;
6048 return strcmp ((char *) n1->name, (char *) n2->name);
6052 dump_interface_table (vat_main_t * vam)
6055 name_sort_t *nses = 0, *ns;
6057 if (vam->json_output)
6060 ("JSON output supported only for VPE API calls and dump_stats_table");
6065 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6067 vec_add2 (nses, ns, 1);
6068 ns->name = (u8 *)(p->key);
6069 ns->value = (u32) p->value[0];
6073 vec_sort_with_function (nses, name_sort_cmp);
6075 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
6076 vec_foreach (ns, nses)
6078 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6085 dump_ip_table (vat_main_t * vam, int is_ipv6)
6087 const ip_details_t *det = NULL;
6088 const ip_address_details_t *address = NULL;
6091 print (vam->ofp, "%-12s", "sw_if_index");
6093 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6100 print (vam->ofp, "%-12d", i);
6101 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6106 vec_foreach (address, det->addr)
6110 is_ipv6 ? format_ip6_address : format_ip4_address,
6111 address->ip, address->prefix_length);
6119 dump_ipv4_table (vat_main_t * vam)
6121 if (vam->json_output)
6124 ("JSON output supported only for VPE API calls and dump_stats_table");
6128 return dump_ip_table (vam, 0);
6132 dump_ipv6_table (vat_main_t * vam)
6134 if (vam->json_output)
6137 ("JSON output supported only for VPE API calls and dump_stats_table");
6141 return dump_ip_table (vam, 1);
6145 counter_type_to_str (u8 counter_type, u8 is_combined)
6149 switch (counter_type)
6151 case VNET_INTERFACE_COUNTER_DROP:
6153 case VNET_INTERFACE_COUNTER_PUNT:
6155 case VNET_INTERFACE_COUNTER_IP4:
6157 case VNET_INTERFACE_COUNTER_IP6:
6159 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6161 case VNET_INTERFACE_COUNTER_RX_MISS:
6163 case VNET_INTERFACE_COUNTER_RX_ERROR:
6165 case VNET_INTERFACE_COUNTER_TX_ERROR:
6168 return "INVALID-COUNTER-TYPE";
6173 switch (counter_type)
6175 case VNET_INTERFACE_COUNTER_RX:
6177 case VNET_INTERFACE_COUNTER_TX:
6180 return "INVALID-COUNTER-TYPE";
6186 dump_stats_table (vat_main_t * vam)
6188 vat_json_node_t node;
6189 vat_json_node_t *msg_array;
6190 vat_json_node_t *msg;
6191 vat_json_node_t *counter_array;
6192 vat_json_node_t *counter;
6193 interface_counter_t c;
6195 ip4_fib_counter_t *c4;
6196 ip6_fib_counter_t *c6;
6197 ip4_nbr_counter_t *n4;
6198 ip6_nbr_counter_t *n6;
6201 if (!vam->json_output)
6203 clib_warning ("dump_stats_table supported only in JSON format");
6207 vat_json_init_object (&node);
6209 /* interface counters */
6210 msg_array = vat_json_object_add (&node, "interface_counters");
6211 vat_json_init_array (msg_array);
6212 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6214 msg = vat_json_array_add (msg_array);
6215 vat_json_init_object (msg);
6216 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6217 (u8 *) counter_type_to_str (i, 0));
6218 vat_json_object_add_int (msg, "is_combined", 0);
6219 counter_array = vat_json_object_add (msg, "data");
6220 vat_json_init_array (counter_array);
6221 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6223 packets = vam->simple_interface_counters[i][j];
6224 vat_json_array_add_uint (counter_array, packets);
6227 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6229 msg = vat_json_array_add (msg_array);
6230 vat_json_init_object (msg);
6231 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6232 (u8 *) counter_type_to_str (i, 1));
6233 vat_json_object_add_int (msg, "is_combined", 1);
6234 counter_array = vat_json_object_add (msg, "data");
6235 vat_json_init_array (counter_array);
6236 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6238 c = vam->combined_interface_counters[i][j];
6239 counter = vat_json_array_add (counter_array);
6240 vat_json_init_object (counter);
6241 vat_json_object_add_uint (counter, "packets", c.packets);
6242 vat_json_object_add_uint (counter, "bytes", c.bytes);
6246 /* ip4 fib counters */
6247 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6248 vat_json_init_array (msg_array);
6249 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6251 msg = vat_json_array_add (msg_array);
6252 vat_json_init_object (msg);
6253 vat_json_object_add_uint (msg, "vrf_id",
6254 vam->ip4_fib_counters_vrf_id_by_index[i]);
6255 counter_array = vat_json_object_add (msg, "c");
6256 vat_json_init_array (counter_array);
6257 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6259 counter = vat_json_array_add (counter_array);
6260 vat_json_init_object (counter);
6261 c4 = &vam->ip4_fib_counters[i][j];
6262 vat_json_object_add_ip4 (counter, "address", c4->address);
6263 vat_json_object_add_uint (counter, "address_length",
6264 c4->address_length);
6265 vat_json_object_add_uint (counter, "packets", c4->packets);
6266 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6270 /* ip6 fib counters */
6271 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6272 vat_json_init_array (msg_array);
6273 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6275 msg = vat_json_array_add (msg_array);
6276 vat_json_init_object (msg);
6277 vat_json_object_add_uint (msg, "vrf_id",
6278 vam->ip6_fib_counters_vrf_id_by_index[i]);
6279 counter_array = vat_json_object_add (msg, "c");
6280 vat_json_init_array (counter_array);
6281 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6283 counter = vat_json_array_add (counter_array);
6284 vat_json_init_object (counter);
6285 c6 = &vam->ip6_fib_counters[i][j];
6286 vat_json_object_add_ip6 (counter, "address", c6->address);
6287 vat_json_object_add_uint (counter, "address_length",
6288 c6->address_length);
6289 vat_json_object_add_uint (counter, "packets", c6->packets);
6290 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6294 /* ip4 nbr counters */
6295 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6296 vat_json_init_array (msg_array);
6297 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6299 msg = vat_json_array_add (msg_array);
6300 vat_json_init_object (msg);
6301 vat_json_object_add_uint (msg, "sw_if_index", i);
6302 counter_array = vat_json_object_add (msg, "c");
6303 vat_json_init_array (counter_array);
6304 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6306 counter = vat_json_array_add (counter_array);
6307 vat_json_init_object (counter);
6308 n4 = &vam->ip4_nbr_counters[i][j];
6309 vat_json_object_add_ip4 (counter, "address", n4->address);
6310 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6311 vat_json_object_add_uint (counter, "packets", n4->packets);
6312 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6316 /* ip6 nbr counters */
6317 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6318 vat_json_init_array (msg_array);
6319 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6321 msg = vat_json_array_add (msg_array);
6322 vat_json_init_object (msg);
6323 vat_json_object_add_uint (msg, "sw_if_index", i);
6324 counter_array = vat_json_object_add (msg, "c");
6325 vat_json_init_array (counter_array);
6326 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6328 counter = vat_json_array_add (counter_array);
6329 vat_json_init_object (counter);
6330 n6 = &vam->ip6_nbr_counters[i][j];
6331 vat_json_object_add_ip6 (counter, "address", n6->address);
6332 vat_json_object_add_uint (counter, "packets", n6->packets);
6333 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6337 vat_json_print (vam->ofp, &node);
6338 vat_json_free (&node);
6344 * Pass CLI buffers directly in the CLI_INBAND API message,
6345 * instead of an additional shared memory area.
6348 exec_inband (vat_main_t * vam)
6350 vl_api_cli_inband_t *mp;
6351 unformat_input_t *i = vam->input;
6354 if (vec_len (i->buffer) == 0)
6357 if (vam->exec_mode == 0 && unformat (i, "mode"))
6362 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6369 * In order for the CLI command to work, it
6370 * must be a vector ending in \n, not a C-string ending
6373 u32 len = vec_len (vam->input->buffer);
6374 M2 (CLI_INBAND, mp, len);
6375 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
6379 /* json responses may or may not include a useful reply... */
6380 if (vec_len (vam->cmd_reply))
6381 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6386 exec (vat_main_t * vam)
6388 return exec_inband (vam);
6392 api_create_loopback (vat_main_t * vam)
6394 unformat_input_t *i = vam->input;
6395 vl_api_create_loopback_t *mp;
6396 vl_api_create_loopback_instance_t *mp_lbi;
6399 u8 is_specified = 0;
6400 u32 user_instance = 0;
6403 clib_memset (mac_address, 0, sizeof (mac_address));
6405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6407 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6409 if (unformat (i, "instance %d", &user_instance))
6417 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6418 mp_lbi->is_specified = is_specified;
6420 mp_lbi->user_instance = htonl (user_instance);
6422 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6427 /* Construct the API message */
6428 M (CREATE_LOOPBACK, mp);
6430 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6439 api_delete_loopback (vat_main_t * vam)
6441 unformat_input_t *i = vam->input;
6442 vl_api_delete_loopback_t *mp;
6443 u32 sw_if_index = ~0;
6446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6448 if (unformat (i, "sw_if_index %d", &sw_if_index))
6454 if (sw_if_index == ~0)
6456 errmsg ("missing sw_if_index");
6460 /* Construct the API message */
6461 M (DELETE_LOOPBACK, mp);
6462 mp->sw_if_index = ntohl (sw_if_index);
6470 api_want_stats (vat_main_t * vam)
6472 unformat_input_t *i = vam->input;
6473 vl_api_want_stats_t *mp;
6477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6479 if (unformat (i, "enable"))
6481 else if (unformat (i, "disable"))
6489 errmsg ("missing enable|disable");
6494 mp->enable_disable = enable;
6502 api_want_interface_events (vat_main_t * vam)
6504 unformat_input_t *i = vam->input;
6505 vl_api_want_interface_events_t *mp;
6509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6511 if (unformat (i, "enable"))
6513 else if (unformat (i, "disable"))
6521 errmsg ("missing enable|disable");
6525 M (WANT_INTERFACE_EVENTS, mp);
6526 mp->enable_disable = enable;
6528 vam->interface_event_display = enable;
6536 /* Note: non-static, called once to set up the initial intfc table */
6538 api_sw_interface_dump (vat_main_t * vam)
6540 vl_api_sw_interface_dump_t *mp;
6541 vl_api_control_ping_t *mp_ping;
6543 name_sort_t *nses = 0, *ns;
6544 sw_interface_subif_t *sub = NULL;
6547 /* Toss the old name table */
6549 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6551 vec_add2 (nses, ns, 1);
6552 ns->name = (u8 *)(p->key);
6553 ns->value = (u32) p->value[0];
6557 hash_free (vam->sw_if_index_by_interface_name);
6559 vec_foreach (ns, nses) vec_free (ns->name);
6563 vec_foreach (sub, vam->sw_if_subif_table)
6565 vec_free (sub->interface_name);
6567 vec_free (vam->sw_if_subif_table);
6569 /* recreate the interface name hash table */
6570 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6573 * Ask for all interface names. Otherwise, the epic catalog of
6574 * name filters becomes ridiculously long, and vat ends up needing
6575 * to be taught about new interface types.
6577 M (SW_INTERFACE_DUMP, mp);
6580 /* Use a control ping for synchronization */
6581 MPING (CONTROL_PING, mp_ping);
6589 api_sw_interface_set_flags (vat_main_t * vam)
6591 unformat_input_t *i = vam->input;
6592 vl_api_sw_interface_set_flags_t *mp;
6594 u8 sw_if_index_set = 0;
6598 /* Parse args required to build the message */
6599 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6601 if (unformat (i, "admin-up"))
6603 else if (unformat (i, "admin-down"))
6606 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6607 sw_if_index_set = 1;
6608 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6609 sw_if_index_set = 1;
6614 if (sw_if_index_set == 0)
6616 errmsg ("missing interface name or sw_if_index");
6620 /* Construct the API message */
6621 M (SW_INTERFACE_SET_FLAGS, mp);
6622 mp->sw_if_index = ntohl (sw_if_index);
6623 mp->admin_up_down = admin_up;
6628 /* Wait for a reply, return the good/bad news... */
6634 api_sw_interface_set_rx_mode (vat_main_t * vam)
6636 unformat_input_t *i = vam->input;
6637 vl_api_sw_interface_set_rx_mode_t *mp;
6639 u8 sw_if_index_set = 0;
6641 u8 queue_id_valid = 0;
6643 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6645 /* Parse args required to build the message */
6646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6648 if (unformat (i, "queue %d", &queue_id))
6650 else if (unformat (i, "polling"))
6651 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6652 else if (unformat (i, "interrupt"))
6653 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6654 else if (unformat (i, "adaptive"))
6655 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6657 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6658 sw_if_index_set = 1;
6659 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6660 sw_if_index_set = 1;
6665 if (sw_if_index_set == 0)
6667 errmsg ("missing interface name or sw_if_index");
6670 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6672 errmsg ("missing rx-mode");
6676 /* Construct the API message */
6677 M (SW_INTERFACE_SET_RX_MODE, mp);
6678 mp->sw_if_index = ntohl (sw_if_index);
6680 mp->queue_id_valid = queue_id_valid;
6681 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6686 /* Wait for a reply, return the good/bad news... */
6692 api_sw_interface_set_rx_placement (vat_main_t * vam)
6694 unformat_input_t *i = vam->input;
6695 vl_api_sw_interface_set_rx_placement_t *mp;
6697 u8 sw_if_index_set = 0;
6700 u32 queue_id, thread_index;
6702 /* Parse args required to build the message */
6703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6705 if (unformat (i, "queue %d", &queue_id))
6707 else if (unformat (i, "main"))
6709 else if (unformat (i, "worker %d", &thread_index))
6712 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6713 sw_if_index_set = 1;
6714 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6715 sw_if_index_set = 1;
6720 if (sw_if_index_set == 0)
6722 errmsg ("missing interface name or sw_if_index");
6728 /* Construct the API message */
6729 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6730 mp->sw_if_index = ntohl (sw_if_index);
6731 mp->worker_id = ntohl (thread_index);
6732 mp->queue_id = ntohl (queue_id);
6733 mp->is_main = is_main;
6737 /* Wait for a reply, return the good/bad news... */
6742 static void vl_api_sw_interface_rx_placement_details_t_handler
6743 (vl_api_sw_interface_rx_placement_details_t * mp)
6745 vat_main_t *vam = &vat_main;
6746 u32 worker_id = ntohl (mp->worker_id);
6749 "\n%-11d %-11s %-6d %-5d %-9s",
6750 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6751 worker_id, ntohl (mp->queue_id),
6753 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6756 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6757 (vl_api_sw_interface_rx_placement_details_t * mp)
6759 vat_main_t *vam = &vat_main;
6760 vat_json_node_t *node = NULL;
6762 if (VAT_JSON_ARRAY != vam->json_tree.type)
6764 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6765 vat_json_init_array (&vam->json_tree);
6767 node = vat_json_array_add (&vam->json_tree);
6769 vat_json_init_object (node);
6770 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6771 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6772 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6773 vat_json_object_add_uint (node, "mode", mp->mode);
6777 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6779 unformat_input_t *i = vam->input;
6780 vl_api_sw_interface_rx_placement_dump_t *mp;
6781 vl_api_control_ping_t *mp_ping;
6784 u8 sw_if_index_set = 0;
6786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6788 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6790 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6797 "\n%-11s %-11s %-6s %-5s %-4s",
6798 "sw_if_index", "main/worker", "thread", "queue", "mode");
6800 /* Dump Interface rx placement */
6801 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6803 if (sw_if_index_set)
6804 mp->sw_if_index = htonl (sw_if_index);
6806 mp->sw_if_index = ~0;
6810 /* Use a control ping for synchronization */
6811 MPING (CONTROL_PING, mp_ping);
6819 api_sw_interface_clear_stats (vat_main_t * vam)
6821 unformat_input_t *i = vam->input;
6822 vl_api_sw_interface_clear_stats_t *mp;
6824 u8 sw_if_index_set = 0;
6827 /* Parse args required to build the message */
6828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6830 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6831 sw_if_index_set = 1;
6832 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6833 sw_if_index_set = 1;
6838 /* Construct the API message */
6839 M (SW_INTERFACE_CLEAR_STATS, mp);
6841 if (sw_if_index_set == 1)
6842 mp->sw_if_index = ntohl (sw_if_index);
6844 mp->sw_if_index = ~0;
6849 /* Wait for a reply, return the good/bad news... */
6855 api_sw_interface_add_del_address (vat_main_t * vam)
6857 unformat_input_t *i = vam->input;
6858 vl_api_sw_interface_add_del_address_t *mp;
6860 u8 sw_if_index_set = 0;
6861 u8 is_add = 1, del_all = 0;
6862 u32 address_length = 0;
6863 u8 v4_address_set = 0;
6864 u8 v6_address_set = 0;
6865 ip4_address_t v4address;
6866 ip6_address_t v6address;
6869 /* Parse args required to build the message */
6870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6872 if (unformat (i, "del-all"))
6874 else if (unformat (i, "del"))
6877 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6878 sw_if_index_set = 1;
6879 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6880 sw_if_index_set = 1;
6881 else if (unformat (i, "%U/%d",
6882 unformat_ip4_address, &v4address, &address_length))
6884 else if (unformat (i, "%U/%d",
6885 unformat_ip6_address, &v6address, &address_length))
6891 if (sw_if_index_set == 0)
6893 errmsg ("missing interface name or sw_if_index");
6896 if (v4_address_set && v6_address_set)
6898 errmsg ("both v4 and v6 addresses set");
6901 if (!v4_address_set && !v6_address_set && !del_all)
6903 errmsg ("no addresses set");
6907 /* Construct the API message */
6908 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6910 mp->sw_if_index = ntohl (sw_if_index);
6911 mp->is_add = is_add;
6912 mp->del_all = del_all;
6916 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6920 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6922 mp->address_length = address_length;
6927 /* Wait for a reply, return good/bad news */
6933 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6935 unformat_input_t *i = vam->input;
6936 vl_api_sw_interface_set_mpls_enable_t *mp;
6938 u8 sw_if_index_set = 0;
6942 /* Parse args required to build the message */
6943 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6945 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6946 sw_if_index_set = 1;
6947 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6948 sw_if_index_set = 1;
6949 else if (unformat (i, "disable"))
6951 else if (unformat (i, "dis"))
6957 if (sw_if_index_set == 0)
6959 errmsg ("missing interface name or sw_if_index");
6963 /* Construct the API message */
6964 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6966 mp->sw_if_index = ntohl (sw_if_index);
6967 mp->enable = enable;
6972 /* Wait for a reply... */
6978 api_sw_interface_set_table (vat_main_t * vam)
6980 unformat_input_t *i = vam->input;
6981 vl_api_sw_interface_set_table_t *mp;
6982 u32 sw_if_index, vrf_id = 0;
6983 u8 sw_if_index_set = 0;
6987 /* Parse args required to build the message */
6988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6990 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6991 sw_if_index_set = 1;
6992 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6993 sw_if_index_set = 1;
6994 else if (unformat (i, "vrf %d", &vrf_id))
6996 else if (unformat (i, "ipv6"))
7002 if (sw_if_index_set == 0)
7004 errmsg ("missing interface name or sw_if_index");
7008 /* Construct the API message */
7009 M (SW_INTERFACE_SET_TABLE, mp);
7011 mp->sw_if_index = ntohl (sw_if_index);
7012 mp->is_ipv6 = is_ipv6;
7013 mp->vrf_id = ntohl (vrf_id);
7018 /* Wait for a reply... */
7023 static void vl_api_sw_interface_get_table_reply_t_handler
7024 (vl_api_sw_interface_get_table_reply_t * mp)
7026 vat_main_t *vam = &vat_main;
7028 print (vam->ofp, "%d", ntohl (mp->vrf_id));
7030 vam->retval = ntohl (mp->retval);
7031 vam->result_ready = 1;
7035 static void vl_api_sw_interface_get_table_reply_t_handler_json
7036 (vl_api_sw_interface_get_table_reply_t * mp)
7038 vat_main_t *vam = &vat_main;
7039 vat_json_node_t node;
7041 vat_json_init_object (&node);
7042 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
7043 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
7045 vat_json_print (vam->ofp, &node);
7046 vat_json_free (&node);
7048 vam->retval = ntohl (mp->retval);
7049 vam->result_ready = 1;
7053 api_sw_interface_get_table (vat_main_t * vam)
7055 unformat_input_t *i = vam->input;
7056 vl_api_sw_interface_get_table_t *mp;
7058 u8 sw_if_index_set = 0;
7062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7064 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7065 sw_if_index_set = 1;
7066 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7067 sw_if_index_set = 1;
7068 else if (unformat (i, "ipv6"))
7074 if (sw_if_index_set == 0)
7076 errmsg ("missing interface name or sw_if_index");
7080 M (SW_INTERFACE_GET_TABLE, mp);
7081 mp->sw_if_index = htonl (sw_if_index);
7082 mp->is_ipv6 = is_ipv6;
7090 api_sw_interface_set_vpath (vat_main_t * vam)
7092 unformat_input_t *i = vam->input;
7093 vl_api_sw_interface_set_vpath_t *mp;
7094 u32 sw_if_index = 0;
7095 u8 sw_if_index_set = 0;
7099 /* Parse args required to build the message */
7100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7102 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7103 sw_if_index_set = 1;
7104 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7105 sw_if_index_set = 1;
7106 else if (unformat (i, "enable"))
7108 else if (unformat (i, "disable"))
7114 if (sw_if_index_set == 0)
7116 errmsg ("missing interface name or sw_if_index");
7120 /* Construct the API message */
7121 M (SW_INTERFACE_SET_VPATH, mp);
7123 mp->sw_if_index = ntohl (sw_if_index);
7124 mp->enable = is_enable;
7129 /* Wait for a reply... */
7135 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
7137 unformat_input_t *i = vam->input;
7138 vl_api_sw_interface_set_vxlan_bypass_t *mp;
7139 u32 sw_if_index = 0;
7140 u8 sw_if_index_set = 0;
7145 /* Parse args required to build the message */
7146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7148 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7149 sw_if_index_set = 1;
7150 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7151 sw_if_index_set = 1;
7152 else if (unformat (i, "enable"))
7154 else if (unformat (i, "disable"))
7156 else if (unformat (i, "ip4"))
7158 else if (unformat (i, "ip6"))
7164 if (sw_if_index_set == 0)
7166 errmsg ("missing interface name or sw_if_index");
7170 /* Construct the API message */
7171 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
7173 mp->sw_if_index = ntohl (sw_if_index);
7174 mp->enable = is_enable;
7175 mp->is_ipv6 = is_ipv6;
7180 /* Wait for a reply... */
7186 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
7188 unformat_input_t *i = vam->input;
7189 vl_api_sw_interface_set_geneve_bypass_t *mp;
7190 u32 sw_if_index = 0;
7191 u8 sw_if_index_set = 0;
7196 /* Parse args required to build the message */
7197 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7199 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7200 sw_if_index_set = 1;
7201 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7202 sw_if_index_set = 1;
7203 else if (unformat (i, "enable"))
7205 else if (unformat (i, "disable"))
7207 else if (unformat (i, "ip4"))
7209 else if (unformat (i, "ip6"))
7215 if (sw_if_index_set == 0)
7217 errmsg ("missing interface name or sw_if_index");
7221 /* Construct the API message */
7222 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7224 mp->sw_if_index = ntohl (sw_if_index);
7225 mp->enable = is_enable;
7226 mp->is_ipv6 = is_ipv6;
7231 /* Wait for a reply... */
7237 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7239 unformat_input_t *i = vam->input;
7240 vl_api_sw_interface_set_l2_xconnect_t *mp;
7242 u8 rx_sw_if_index_set = 0;
7244 u8 tx_sw_if_index_set = 0;
7248 /* Parse args required to build the message */
7249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7251 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7252 rx_sw_if_index_set = 1;
7253 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7254 tx_sw_if_index_set = 1;
7255 else if (unformat (i, "rx"))
7257 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7259 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7261 rx_sw_if_index_set = 1;
7266 else if (unformat (i, "tx"))
7268 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7270 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7272 tx_sw_if_index_set = 1;
7277 else if (unformat (i, "enable"))
7279 else if (unformat (i, "disable"))
7285 if (rx_sw_if_index_set == 0)
7287 errmsg ("missing rx interface name or rx_sw_if_index");
7291 if (enable && (tx_sw_if_index_set == 0))
7293 errmsg ("missing tx interface name or tx_sw_if_index");
7297 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7299 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7300 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7301 mp->enable = enable;
7309 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7311 unformat_input_t *i = vam->input;
7312 vl_api_sw_interface_set_l2_bridge_t *mp;
7313 vl_api_l2_port_type_t port_type;
7315 u8 rx_sw_if_index_set = 0;
7322 port_type = L2_API_PORT_TYPE_NORMAL;
7324 /* Parse args required to build the message */
7325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7327 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7328 rx_sw_if_index_set = 1;
7329 else if (unformat (i, "bd_id %d", &bd_id))
7333 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7334 rx_sw_if_index_set = 1;
7335 else if (unformat (i, "shg %d", &shg))
7337 else if (unformat (i, "bvi"))
7338 port_type = L2_API_PORT_TYPE_BVI;
7339 else if (unformat (i, "uu-fwd"))
7340 port_type = L2_API_PORT_TYPE_UU_FWD;
7341 else if (unformat (i, "enable"))
7343 else if (unformat (i, "disable"))
7349 if (rx_sw_if_index_set == 0)
7351 errmsg ("missing rx interface name or sw_if_index");
7355 if (enable && (bd_id_set == 0))
7357 errmsg ("missing bridge domain");
7361 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7363 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7364 mp->bd_id = ntohl (bd_id);
7366 mp->port_type = ntohl (port_type);
7367 mp->enable = enable;
7375 api_bridge_domain_dump (vat_main_t * vam)
7377 unformat_input_t *i = vam->input;
7378 vl_api_bridge_domain_dump_t *mp;
7379 vl_api_control_ping_t *mp_ping;
7383 /* Parse args required to build the message */
7384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7386 if (unformat (i, "bd_id %d", &bd_id))
7392 M (BRIDGE_DOMAIN_DUMP, mp);
7393 mp->bd_id = ntohl (bd_id);
7396 /* Use a control ping for synchronization */
7397 MPING (CONTROL_PING, mp_ping);
7405 api_bridge_domain_add_del (vat_main_t * vam)
7407 unformat_input_t *i = vam->input;
7408 vl_api_bridge_domain_add_del_t *mp;
7411 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7416 /* Parse args required to build the message */
7417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7419 if (unformat (i, "bd_id %d", &bd_id))
7421 else if (unformat (i, "flood %d", &flood))
7423 else if (unformat (i, "uu-flood %d", &uu_flood))
7425 else if (unformat (i, "forward %d", &forward))
7427 else if (unformat (i, "learn %d", &learn))
7429 else if (unformat (i, "arp-term %d", &arp_term))
7431 else if (unformat (i, "mac-age %d", &mac_age))
7433 else if (unformat (i, "bd-tag %s", &bd_tag))
7435 else if (unformat (i, "del"))
7438 flood = uu_flood = forward = learn = 0;
7446 errmsg ("missing bridge domain");
7453 errmsg ("mac age must be less than 256 ");
7458 if ((bd_tag) && (vec_len (bd_tag) > 63))
7460 errmsg ("bd-tag cannot be longer than 63");
7465 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7467 mp->bd_id = ntohl (bd_id);
7469 mp->uu_flood = uu_flood;
7470 mp->forward = forward;
7472 mp->arp_term = arp_term;
7473 mp->is_add = is_add;
7474 mp->mac_age = (u8) mac_age;
7477 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7478 mp->bd_tag[vec_len (bd_tag)] = 0;
7489 api_l2fib_flush_bd (vat_main_t * vam)
7491 unformat_input_t *i = vam->input;
7492 vl_api_l2fib_flush_bd_t *mp;
7496 /* Parse args required to build the message */
7497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7499 if (unformat (i, "bd_id %d", &bd_id));
7506 errmsg ("missing bridge domain");
7510 M (L2FIB_FLUSH_BD, mp);
7512 mp->bd_id = htonl (bd_id);
7520 api_l2fib_flush_int (vat_main_t * vam)
7522 unformat_input_t *i = vam->input;
7523 vl_api_l2fib_flush_int_t *mp;
7524 u32 sw_if_index = ~0;
7527 /* Parse args required to build the message */
7528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7530 if (unformat (i, "sw_if_index %d", &sw_if_index));
7532 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7537 if (sw_if_index == ~0)
7539 errmsg ("missing interface name or sw_if_index");
7543 M (L2FIB_FLUSH_INT, mp);
7545 mp->sw_if_index = ntohl (sw_if_index);
7553 api_l2fib_add_del (vat_main_t * vam)
7555 unformat_input_t *i = vam->input;
7556 vl_api_l2fib_add_del_t *mp;
7562 u32 sw_if_index = 0;
7563 u8 sw_if_index_set = 0;
7572 /* Parse args required to build the message */
7573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7575 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7577 else if (unformat (i, "bd_id %d", &bd_id))
7579 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7580 sw_if_index_set = 1;
7581 else if (unformat (i, "sw_if"))
7583 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7586 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7587 sw_if_index_set = 1;
7592 else if (unformat (i, "static"))
7594 else if (unformat (i, "filter"))
7599 else if (unformat (i, "bvi"))
7604 else if (unformat (i, "del"))
7606 else if (unformat (i, "count %d", &count))
7614 errmsg ("missing mac address");
7620 errmsg ("missing bridge domain");
7624 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7626 errmsg ("missing interface name or sw_if_index");
7632 /* Turn on async mode */
7633 vam->async_mode = 1;
7634 vam->async_errors = 0;
7635 before = vat_time_now (vam);
7638 for (j = 0; j < count; j++)
7640 M (L2FIB_ADD_DEL, mp);
7642 clib_memcpy (mp->mac, mac, 6);
7643 mp->bd_id = ntohl (bd_id);
7644 mp->is_add = is_add;
7645 mp->sw_if_index = ntohl (sw_if_index);
7649 mp->static_mac = static_mac;
7650 mp->filter_mac = filter_mac;
7651 mp->bvi_mac = bvi_mac;
7653 increment_mac_address (mac);
7660 vl_api_control_ping_t *mp_ping;
7663 /* Shut off async mode */
7664 vam->async_mode = 0;
7666 MPING (CONTROL_PING, mp_ping);
7669 timeout = vat_time_now (vam) + 1.0;
7670 while (vat_time_now (vam) < timeout)
7671 if (vam->result_ready == 1)
7676 if (vam->retval == -99)
7679 if (vam->async_errors > 0)
7681 errmsg ("%d asynchronous errors", vam->async_errors);
7684 vam->async_errors = 0;
7685 after = vat_time_now (vam);
7687 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7688 count, after - before, count / (after - before));
7694 /* Wait for a reply... */
7698 /* Return the good/bad news */
7699 return (vam->retval);
7703 api_bridge_domain_set_mac_age (vat_main_t * vam)
7705 unformat_input_t *i = vam->input;
7706 vl_api_bridge_domain_set_mac_age_t *mp;
7711 /* Parse args required to build the message */
7712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7714 if (unformat (i, "bd_id %d", &bd_id));
7715 else if (unformat (i, "mac-age %d", &mac_age));
7722 errmsg ("missing bridge domain");
7728 errmsg ("mac age must be less than 256 ");
7732 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7734 mp->bd_id = htonl (bd_id);
7735 mp->mac_age = (u8) mac_age;
7743 api_l2_flags (vat_main_t * vam)
7745 unformat_input_t *i = vam->input;
7746 vl_api_l2_flags_t *mp;
7749 u8 sw_if_index_set = 0;
7753 /* Parse args required to build the message */
7754 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7756 if (unformat (i, "sw_if_index %d", &sw_if_index))
7757 sw_if_index_set = 1;
7758 else if (unformat (i, "sw_if"))
7760 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7763 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7764 sw_if_index_set = 1;
7769 else if (unformat (i, "learn"))
7771 else if (unformat (i, "forward"))
7773 else if (unformat (i, "flood"))
7775 else if (unformat (i, "uu-flood"))
7776 flags |= L2_UU_FLOOD;
7777 else if (unformat (i, "arp-term"))
7778 flags |= L2_ARP_TERM;
7779 else if (unformat (i, "off"))
7781 else if (unformat (i, "disable"))
7787 if (sw_if_index_set == 0)
7789 errmsg ("missing interface name or sw_if_index");
7795 mp->sw_if_index = ntohl (sw_if_index);
7796 mp->feature_bitmap = ntohl (flags);
7797 mp->is_set = is_set;
7805 api_bridge_flags (vat_main_t * vam)
7807 unformat_input_t *i = vam->input;
7808 vl_api_bridge_flags_t *mp;
7812 bd_flags_t flags = 0;
7815 /* Parse args required to build the message */
7816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7818 if (unformat (i, "bd_id %d", &bd_id))
7820 else if (unformat (i, "learn"))
7821 flags |= BRIDGE_API_FLAG_LEARN;
7822 else if (unformat (i, "forward"))
7823 flags |= BRIDGE_API_FLAG_FWD;
7824 else if (unformat (i, "flood"))
7825 flags |= BRIDGE_API_FLAG_FLOOD;
7826 else if (unformat (i, "uu-flood"))
7827 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7828 else if (unformat (i, "arp-term"))
7829 flags |= BRIDGE_API_FLAG_ARP_TERM;
7830 else if (unformat (i, "off"))
7832 else if (unformat (i, "disable"))
7840 errmsg ("missing bridge domain");
7844 M (BRIDGE_FLAGS, mp);
7846 mp->bd_id = ntohl (bd_id);
7847 mp->flags = ntohl (flags);
7848 mp->is_set = is_set;
7856 api_bd_ip_mac_add_del (vat_main_t * vam)
7858 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7859 vl_api_mac_address_t mac = VL_API_ZERO_MAC_ADDRESS;
7860 unformat_input_t *i = vam->input;
7861 vl_api_bd_ip_mac_add_del_t *mp;
7873 /* Parse args required to build the message */
7874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7876 if (unformat (i, "bd_id %d", &bd_id))
7880 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7884 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7888 else if (unformat (i, "del"))
7896 errmsg ("missing bridge domain");
7899 else if (ip_set == 0)
7901 errmsg ("missing IP address");
7904 else if (mac_set == 0)
7906 errmsg ("missing MAC address");
7910 M (BD_IP_MAC_ADD_DEL, mp);
7912 mp->bd_id = ntohl (bd_id);
7913 mp->is_add = is_add;
7915 clib_memcpy (&mp->ip, &ip, sizeof (ip));
7916 clib_memcpy (&mp->mac, &mac, sizeof (mac));
7923 static void vl_api_bd_ip_mac_details_t_handler
7924 (vl_api_bd_ip_mac_details_t * mp)
7926 vat_main_t *vam = &vat_main;
7931 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7934 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7937 "\n%-5d %-7s %-20U %-30s",
7938 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7939 format_ethernet_address, mp->mac_address, ip);
7944 static void vl_api_bd_ip_mac_details_t_handler_json
7945 (vl_api_bd_ip_mac_details_t * mp)
7947 vat_main_t *vam = &vat_main;
7948 vat_json_node_t *node = NULL;
7950 if (VAT_JSON_ARRAY != vam->json_tree.type)
7952 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7953 vat_json_init_array (&vam->json_tree);
7955 node = vat_json_array_add (&vam->json_tree);
7957 vat_json_init_object (node);
7958 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7959 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7960 vat_json_object_add_string_copy (node, "mac_address",
7961 format (0, "%U", format_ethernet_address,
7967 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7970 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7971 vat_json_object_add_string_copy (node, "ip_address", ip);
7976 api_bd_ip_mac_dump (vat_main_t * vam)
7978 unformat_input_t *i = vam->input;
7979 vl_api_bd_ip_mac_dump_t *mp;
7980 vl_api_control_ping_t *mp_ping;
7985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7987 if (unformat (i, "bd_id %d", &bd_id))
7996 "\n%-5s %-7s %-20s %-30s",
7997 "bd_id", "is_ipv6", "mac_address", "ip_address");
7999 /* Dump Bridge Domain Ip to Mac entries */
8000 M (BD_IP_MAC_DUMP, mp);
8003 mp->bd_id = htonl (bd_id);
8009 /* Use a control ping for synchronization */
8010 MPING (CONTROL_PING, mp_ping);
8018 api_tap_connect (vat_main_t * vam)
8020 unformat_input_t *i = vam->input;
8021 vl_api_tap_connect_t *mp;
8027 ip4_address_t ip4_address;
8029 int ip4_address_set = 0;
8030 ip6_address_t ip6_address;
8032 int ip6_address_set = 0;
8035 clib_memset (mac_address, 0, sizeof (mac_address));
8037 /* Parse args required to build the message */
8038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8040 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8044 else if (unformat (i, "random-mac"))
8046 else if (unformat (i, "tapname %s", &tap_name))
8048 else if (unformat (i, "tag %s", &tag))
8050 else if (unformat (i, "address %U/%d",
8051 unformat_ip4_address, &ip4_address, &ip4_mask_width))
8052 ip4_address_set = 1;
8053 else if (unformat (i, "address %U/%d",
8054 unformat_ip6_address, &ip6_address, &ip6_mask_width))
8055 ip6_address_set = 1;
8062 errmsg ("missing tap name");
8065 if (vec_len (tap_name) > 63)
8067 errmsg ("tap name too long");
8070 vec_add1 (tap_name, 0);
8072 if (vec_len (tag) > 63)
8074 errmsg ("tag too long");
8078 /* Construct the API message */
8079 M (TAP_CONNECT, mp);
8081 mp->use_random_mac = random_mac;
8082 clib_memcpy (mp->mac_address, mac_address, 6);
8083 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8085 clib_memcpy (mp->tag, tag, vec_len (tag));
8087 if (ip4_address_set)
8089 mp->ip4_address_set = 1;
8090 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
8091 mp->ip4_mask_width = ip4_mask_width;
8093 if (ip6_address_set)
8095 mp->ip6_address_set = 1;
8096 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
8097 mp->ip6_mask_width = ip6_mask_width;
8100 vec_free (tap_name);
8106 /* Wait for a reply... */
8112 api_tap_modify (vat_main_t * vam)
8114 unformat_input_t *i = vam->input;
8115 vl_api_tap_modify_t *mp;
8120 u32 sw_if_index = ~0;
8121 u8 sw_if_index_set = 0;
8124 clib_memset (mac_address, 0, sizeof (mac_address));
8126 /* Parse args required to build the message */
8127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8129 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8130 sw_if_index_set = 1;
8131 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8132 sw_if_index_set = 1;
8133 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8137 else if (unformat (i, "random-mac"))
8139 else if (unformat (i, "tapname %s", &tap_name))
8145 if (sw_if_index_set == 0)
8147 errmsg ("missing vpp interface name");
8152 errmsg ("missing tap name");
8155 if (vec_len (tap_name) > 63)
8157 errmsg ("tap name too long");
8159 vec_add1 (tap_name, 0);
8161 /* Construct the API message */
8164 mp->use_random_mac = random_mac;
8165 mp->sw_if_index = ntohl (sw_if_index);
8166 clib_memcpy (mp->mac_address, mac_address, 6);
8167 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8168 vec_free (tap_name);
8173 /* Wait for a reply... */
8179 api_tap_delete (vat_main_t * vam)
8181 unformat_input_t *i = vam->input;
8182 vl_api_tap_delete_t *mp;
8183 u32 sw_if_index = ~0;
8184 u8 sw_if_index_set = 0;
8187 /* Parse args required to build the message */
8188 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8190 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8191 sw_if_index_set = 1;
8192 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8193 sw_if_index_set = 1;
8198 if (sw_if_index_set == 0)
8200 errmsg ("missing vpp interface name");
8204 /* Construct the API message */
8207 mp->sw_if_index = ntohl (sw_if_index);
8212 /* Wait for a reply... */
8218 api_tap_create_v2 (vat_main_t * vam)
8220 unformat_input_t *i = vam->input;
8221 vl_api_tap_create_v2_t *mp;
8225 u8 *host_if_name = 0;
8227 u8 host_mac_addr[6];
8228 u8 host_mac_addr_set = 0;
8229 u8 *host_bridge = 0;
8230 ip4_address_t host_ip4_addr;
8231 ip4_address_t host_ip4_gw;
8232 u8 host_ip4_gw_set = 0;
8233 u32 host_ip4_prefix_len = 0;
8234 ip6_address_t host_ip6_addr;
8235 ip6_address_t host_ip6_gw;
8236 u8 host_ip6_gw_set = 0;
8237 u32 host_ip6_prefix_len = 0;
8239 u32 rx_ring_sz = 0, tx_ring_sz = 0;
8241 clib_memset (mac_address, 0, sizeof (mac_address));
8243 /* Parse args required to build the message */
8244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8246 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8250 else if (unformat (i, "id %u", &id))
8252 else if (unformat (i, "host-if-name %s", &host_if_name))
8254 else if (unformat (i, "host-ns %s", &host_ns))
8256 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8258 host_mac_addr_set = 1;
8259 else if (unformat (i, "host-bridge %s", &host_bridge))
8261 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8262 &host_ip4_addr, &host_ip4_prefix_len))
8264 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8265 &host_ip6_addr, &host_ip6_prefix_len))
8267 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8269 host_ip4_gw_set = 1;
8270 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8272 host_ip6_gw_set = 1;
8273 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8275 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8281 if (vec_len (host_if_name) > 63)
8283 errmsg ("tap name too long. ");
8286 if (vec_len (host_ns) > 63)
8288 errmsg ("host name space too long. ");
8291 if (vec_len (host_bridge) > 63)
8293 errmsg ("host bridge name too long. ");
8296 if (host_ip4_prefix_len > 32)
8298 errmsg ("host ip4 prefix length not valid. ");
8301 if (host_ip6_prefix_len > 128)
8303 errmsg ("host ip6 prefix length not valid. ");
8306 if (!is_pow2 (rx_ring_sz))
8308 errmsg ("rx ring size must be power of 2. ");
8311 if (rx_ring_sz > 32768)
8313 errmsg ("rx ring size must be 32768 or lower. ");
8316 if (!is_pow2 (tx_ring_sz))
8318 errmsg ("tx ring size must be power of 2. ");
8321 if (tx_ring_sz > 32768)
8323 errmsg ("tx ring size must be 32768 or lower. ");
8327 /* Construct the API message */
8328 M (TAP_CREATE_V2, mp);
8330 mp->use_random_mac = random_mac;
8332 mp->id = ntohl (id);
8333 mp->host_namespace_set = host_ns != 0;
8334 mp->host_bridge_set = host_bridge != 0;
8335 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8336 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8337 mp->rx_ring_sz = ntohs (rx_ring_sz);
8338 mp->tx_ring_sz = ntohs (tx_ring_sz);
8340 if (random_mac == 0)
8341 clib_memcpy (mp->mac_address, mac_address, 6);
8342 if (host_mac_addr_set)
8343 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8345 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8347 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8349 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8350 if (host_ip4_prefix_len)
8351 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8352 if (host_ip6_prefix_len)
8353 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8354 if (host_ip4_gw_set)
8355 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8356 if (host_ip6_gw_set)
8357 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8360 vec_free (host_if_name);
8361 vec_free (host_bridge);
8366 /* Wait for a reply... */
8372 api_tap_delete_v2 (vat_main_t * vam)
8374 unformat_input_t *i = vam->input;
8375 vl_api_tap_delete_v2_t *mp;
8376 u32 sw_if_index = ~0;
8377 u8 sw_if_index_set = 0;
8380 /* Parse args required to build the message */
8381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8383 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8384 sw_if_index_set = 1;
8385 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8386 sw_if_index_set = 1;
8391 if (sw_if_index_set == 0)
8393 errmsg ("missing vpp interface name. ");
8397 /* Construct the API message */
8398 M (TAP_DELETE_V2, mp);
8400 mp->sw_if_index = ntohl (sw_if_index);
8405 /* Wait for a reply... */
8411 api_bond_create (vat_main_t * vam)
8413 unformat_input_t *i = vam->input;
8414 vl_api_bond_create_t *mp;
8422 clib_memset (mac_address, 0, sizeof (mac_address));
8425 /* Parse args required to build the message */
8426 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8428 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8430 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8431 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8433 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8440 if (mode_is_set == 0)
8442 errmsg ("Missing bond mode. ");
8446 /* Construct the API message */
8447 M (BOND_CREATE, mp);
8449 mp->use_custom_mac = custom_mac;
8455 clib_memcpy (mp->mac_address, mac_address, 6);
8460 /* Wait for a reply... */
8466 api_bond_delete (vat_main_t * vam)
8468 unformat_input_t *i = vam->input;
8469 vl_api_bond_delete_t *mp;
8470 u32 sw_if_index = ~0;
8471 u8 sw_if_index_set = 0;
8474 /* Parse args required to build the message */
8475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8477 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8478 sw_if_index_set = 1;
8479 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8480 sw_if_index_set = 1;
8485 if (sw_if_index_set == 0)
8487 errmsg ("missing vpp interface name. ");
8491 /* Construct the API message */
8492 M (BOND_DELETE, mp);
8494 mp->sw_if_index = ntohl (sw_if_index);
8499 /* Wait for a reply... */
8505 api_bond_enslave (vat_main_t * vam)
8507 unformat_input_t *i = vam->input;
8508 vl_api_bond_enslave_t *mp;
8509 u32 bond_sw_if_index;
8513 u32 bond_sw_if_index_is_set = 0;
8515 u8 sw_if_index_is_set = 0;
8517 /* Parse args required to build the message */
8518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8520 if (unformat (i, "sw_if_index %d", &sw_if_index))
8521 sw_if_index_is_set = 1;
8522 else if (unformat (i, "bond %u", &bond_sw_if_index))
8523 bond_sw_if_index_is_set = 1;
8524 else if (unformat (i, "passive %d", &is_passive))
8526 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8532 if (bond_sw_if_index_is_set == 0)
8534 errmsg ("Missing bond sw_if_index. ");
8537 if (sw_if_index_is_set == 0)
8539 errmsg ("Missing slave sw_if_index. ");
8543 /* Construct the API message */
8544 M (BOND_ENSLAVE, mp);
8546 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8547 mp->sw_if_index = ntohl (sw_if_index);
8548 mp->is_long_timeout = is_long_timeout;
8549 mp->is_passive = is_passive;
8554 /* Wait for a reply... */
8560 api_bond_detach_slave (vat_main_t * vam)
8562 unformat_input_t *i = vam->input;
8563 vl_api_bond_detach_slave_t *mp;
8564 u32 sw_if_index = ~0;
8565 u8 sw_if_index_set = 0;
8568 /* Parse args required to build the message */
8569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8571 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8572 sw_if_index_set = 1;
8573 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8574 sw_if_index_set = 1;
8579 if (sw_if_index_set == 0)
8581 errmsg ("missing vpp interface name. ");
8585 /* Construct the API message */
8586 M (BOND_DETACH_SLAVE, mp);
8588 mp->sw_if_index = ntohl (sw_if_index);
8593 /* Wait for a reply... */
8599 api_ip_table_add_del (vat_main_t * vam)
8601 unformat_input_t *i = vam->input;
8602 vl_api_ip_table_add_del_t *mp;
8608 /* Parse args required to build the message */
8609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8611 if (unformat (i, "ipv6"))
8613 else if (unformat (i, "del"))
8615 else if (unformat (i, "add"))
8617 else if (unformat (i, "table %d", &table_id))
8621 clib_warning ("parse error '%U'", format_unformat_error, i);
8628 errmsg ("missing table-ID");
8632 /* Construct the API message */
8633 M (IP_TABLE_ADD_DEL, mp);
8635 mp->table_id = ntohl (table_id);
8636 mp->is_ipv6 = is_ipv6;
8637 mp->is_add = is_add;
8642 /* Wait for a reply... */
8649 api_ip_add_del_route (vat_main_t * vam)
8651 unformat_input_t *i = vam->input;
8652 vl_api_ip_add_del_route_t *mp;
8653 u32 sw_if_index = ~0, vrf_id = 0;
8655 u8 is_local = 0, is_drop = 0;
8656 u8 is_unreach = 0, is_prohibit = 0;
8658 u32 next_hop_weight = 1;
8659 u8 is_multipath = 0;
8661 u8 address_length_set = 0;
8662 u32 next_hop_table_id = 0;
8663 u32 resolve_attempts = 0;
8664 u32 dst_address_length = 0;
8665 u8 next_hop_set = 0;
8666 ip4_address_t v4_dst_address, v4_next_hop_address;
8667 ip6_address_t v6_dst_address, v6_next_hop_address;
8671 u32 random_add_del = 0;
8672 u32 *random_vector = 0;
8674 u32 random_seed = 0xdeaddabe;
8675 u32 classify_table_index = ~0;
8677 u8 resolve_host = 0, resolve_attached = 0;
8678 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8679 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8680 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8682 clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8683 clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8684 /* Parse args required to build the message */
8685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8687 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8689 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8691 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8696 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8701 else if (unformat (i, "/%d", &dst_address_length))
8703 address_length_set = 1;
8706 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8707 &v4_next_hop_address))
8711 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8712 &v6_next_hop_address))
8718 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8722 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8726 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8728 else if (unformat (i, "weight %d", &next_hop_weight))
8730 else if (unformat (i, "drop"))
8734 else if (unformat (i, "null-send-unreach"))
8738 else if (unformat (i, "null-send-prohibit"))
8742 else if (unformat (i, "local"))
8746 else if (unformat (i, "classify %d", &classify_table_index))
8750 else if (unformat (i, "del"))
8752 else if (unformat (i, "add"))
8754 else if (unformat (i, "resolve-via-host"))
8756 else if (unformat (i, "resolve-via-attached"))
8757 resolve_attached = 1;
8758 else if (unformat (i, "multipath"))
8760 else if (unformat (i, "vrf %d", &vrf_id))
8762 else if (unformat (i, "count %d", &count))
8764 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8766 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8768 else if (unformat (i, "out-label %d", &next_hop_out_label))
8770 vl_api_fib_mpls_label_t fib_label = {
8771 .label = ntohl (next_hop_out_label),
8775 vec_add1 (next_hop_out_label_stack, fib_label);
8777 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8779 else if (unformat (i, "random"))
8781 else if (unformat (i, "seed %d", &random_seed))
8785 clib_warning ("parse error '%U'", format_unformat_error, i);
8790 if (!next_hop_set && !is_drop && !is_local &&
8791 !is_classify && !is_unreach && !is_prohibit &&
8792 MPLS_LABEL_INVALID == next_hop_via_label)
8795 ("next hop / local / drop / unreach / prohibit / classify not set");
8799 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8801 errmsg ("next hop and next-hop via label set");
8804 if (address_set == 0)
8806 errmsg ("missing addresses");
8810 if (address_length_set == 0)
8812 errmsg ("missing address length");
8816 /* Generate a pile of unique, random routes */
8819 u32 this_random_address;
8820 random_hash = hash_create (count, sizeof (uword));
8822 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8823 for (j = 0; j <= count; j++)
8827 this_random_address = random_u32 (&random_seed);
8828 this_random_address =
8829 clib_host_to_net_u32 (this_random_address);
8831 while (hash_get (random_hash, this_random_address));
8832 vec_add1 (random_vector, this_random_address);
8833 hash_set (random_hash, this_random_address, 1);
8835 hash_free (random_hash);
8836 v4_dst_address.as_u32 = random_vector[0];
8841 /* Turn on async mode */
8842 vam->async_mode = 1;
8843 vam->async_errors = 0;
8844 before = vat_time_now (vam);
8847 for (j = 0; j < count; j++)
8849 /* Construct the API message */
8850 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8851 vec_len (next_hop_out_label_stack));
8853 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8854 mp->table_id = ntohl (vrf_id);
8856 mp->is_add = is_add;
8857 mp->is_drop = is_drop;
8858 mp->is_unreach = is_unreach;
8859 mp->is_prohibit = is_prohibit;
8860 mp->is_ipv6 = is_ipv6;
8861 mp->is_local = is_local;
8862 mp->is_classify = is_classify;
8863 mp->is_multipath = is_multipath;
8864 mp->is_resolve_host = resolve_host;
8865 mp->is_resolve_attached = resolve_attached;
8866 mp->next_hop_weight = next_hop_weight;
8867 mp->next_hop_preference = 0;
8868 mp->dst_address_length = dst_address_length;
8869 mp->next_hop_table_id = ntohl (next_hop_table_id);
8870 mp->classify_table_index = ntohl (classify_table_index);
8871 mp->next_hop_via_label = ntohl (next_hop_via_label);
8872 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8873 if (0 != mp->next_hop_n_out_labels)
8875 memcpy (mp->next_hop_out_label_stack,
8876 next_hop_out_label_stack,
8877 (vec_len (next_hop_out_label_stack) *
8878 sizeof (vl_api_fib_mpls_label_t)));
8879 vec_free (next_hop_out_label_stack);
8884 clib_memcpy (mp->dst_address, &v6_dst_address,
8885 sizeof (v6_dst_address));
8887 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8888 sizeof (v6_next_hop_address));
8889 increment_v6_address (&v6_dst_address);
8893 clib_memcpy (mp->dst_address, &v4_dst_address,
8894 sizeof (v4_dst_address));
8896 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8897 sizeof (v4_next_hop_address));
8899 v4_dst_address.as_u32 = random_vector[j + 1];
8901 increment_v4_address (&v4_dst_address);
8905 /* If we receive SIGTERM, stop now... */
8910 /* When testing multiple add/del ops, use a control-ping to sync */
8913 vl_api_control_ping_t *mp_ping;
8917 /* Shut off async mode */
8918 vam->async_mode = 0;
8920 MPING (CONTROL_PING, mp_ping);
8923 timeout = vat_time_now (vam) + 1.0;
8924 while (vat_time_now (vam) < timeout)
8925 if (vam->result_ready == 1)
8930 if (vam->retval == -99)
8933 if (vam->async_errors > 0)
8935 errmsg ("%d asynchronous errors", vam->async_errors);
8938 vam->async_errors = 0;
8939 after = vat_time_now (vam);
8941 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8945 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8946 count, after - before, count / (after - before));
8952 /* Wait for a reply... */
8957 /* Return the good/bad news */
8958 return (vam->retval);
8962 api_ip_mroute_add_del (vat_main_t * vam)
8964 unformat_input_t *i = vam->input;
8965 vl_api_ip_mroute_add_del_t *mp;
8966 u32 sw_if_index = ~0, vrf_id = 0;
8971 u32 grp_address_length = 0;
8972 ip4_address_t v4_grp_address, v4_src_address;
8973 ip6_address_t v6_grp_address, v6_src_address;
8974 mfib_itf_flags_t iflags = 0;
8975 mfib_entry_flags_t eflags = 0;
8978 /* Parse args required to build the message */
8979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8981 if (unformat (i, "sw_if_index %d", &sw_if_index))
8983 else if (unformat (i, "%U %U",
8984 unformat_ip4_address, &v4_src_address,
8985 unformat_ip4_address, &v4_grp_address))
8987 grp_address_length = 64;
8991 else if (unformat (i, "%U %U",
8992 unformat_ip6_address, &v6_src_address,
8993 unformat_ip6_address, &v6_grp_address))
8995 grp_address_length = 256;
8999 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
9001 clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
9002 grp_address_length = 32;
9006 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
9008 clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
9009 grp_address_length = 128;
9013 else if (unformat (i, "/%d", &grp_address_length))
9015 else if (unformat (i, "local"))
9019 else if (unformat (i, "del"))
9021 else if (unformat (i, "add"))
9023 else if (unformat (i, "vrf %d", &vrf_id))
9025 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
9027 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
9031 clib_warning ("parse error '%U'", format_unformat_error, i);
9036 if (address_set == 0)
9038 errmsg ("missing addresses\n");
9042 /* Construct the API message */
9043 M (IP_MROUTE_ADD_DEL, mp);
9045 mp->next_hop_sw_if_index = ntohl (sw_if_index);
9046 mp->table_id = ntohl (vrf_id);
9048 mp->is_add = is_add;
9049 mp->is_ipv6 = is_ipv6;
9050 mp->is_local = is_local;
9051 mp->itf_flags = ntohl (iflags);
9052 mp->entry_flags = ntohl (eflags);
9053 mp->grp_address_length = grp_address_length;
9054 mp->grp_address_length = ntohs (mp->grp_address_length);
9058 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
9059 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
9063 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
9064 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
9070 /* Wait for a reply... */
9076 api_mpls_table_add_del (vat_main_t * vam)
9078 unformat_input_t *i = vam->input;
9079 vl_api_mpls_table_add_del_t *mp;
9084 /* Parse args required to build the message */
9085 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9087 if (unformat (i, "table %d", &table_id))
9089 else if (unformat (i, "del"))
9091 else if (unformat (i, "add"))
9095 clib_warning ("parse error '%U'", format_unformat_error, i);
9102 errmsg ("missing table-ID");
9106 /* Construct the API message */
9107 M (MPLS_TABLE_ADD_DEL, mp);
9109 mp->mt_table_id = ntohl (table_id);
9110 mp->mt_is_add = is_add;
9115 /* Wait for a reply... */
9122 api_mpls_route_add_del (vat_main_t * vam)
9124 unformat_input_t *i = vam->input;
9125 vl_api_mpls_route_add_del_t *mp;
9126 u32 sw_if_index = ~0, table_id = 0;
9128 u32 next_hop_weight = 1;
9129 u8 is_multipath = 0;
9130 u32 next_hop_table_id = 0;
9131 u8 next_hop_set = 0;
9132 ip4_address_t v4_next_hop_address = {
9135 ip6_address_t v6_next_hop_address = { {0} };
9139 u32 classify_table_index = ~0;
9141 u8 resolve_host = 0, resolve_attached = 0;
9142 u8 is_interface_rx = 0;
9143 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9144 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9145 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9146 mpls_label_t local_label = MPLS_LABEL_INVALID;
9148 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
9150 /* Parse args required to build the message */
9151 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9153 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9155 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9157 else if (unformat (i, "%d", &local_label))
9159 else if (unformat (i, "eos"))
9161 else if (unformat (i, "non-eos"))
9163 else if (unformat (i, "via %U", unformat_ip4_address,
9164 &v4_next_hop_address))
9167 next_hop_proto = DPO_PROTO_IP4;
9169 else if (unformat (i, "via %U", unformat_ip6_address,
9170 &v6_next_hop_address))
9173 next_hop_proto = DPO_PROTO_IP6;
9175 else if (unformat (i, "weight %d", &next_hop_weight))
9177 else if (unformat (i, "classify %d", &classify_table_index))
9181 else if (unformat (i, "del"))
9183 else if (unformat (i, "add"))
9185 else if (unformat (i, "resolve-via-host"))
9187 else if (unformat (i, "resolve-via-attached"))
9188 resolve_attached = 1;
9189 else if (unformat (i, "multipath"))
9191 else if (unformat (i, "count %d", &count))
9193 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
9196 next_hop_proto = DPO_PROTO_IP4;
9198 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
9201 next_hop_proto = DPO_PROTO_IP6;
9205 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
9209 next_hop_proto = DPO_PROTO_ETHERNET;
9210 is_interface_rx = 1;
9212 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
9215 next_hop_proto = DPO_PROTO_ETHERNET;
9216 is_interface_rx = 1;
9218 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
9220 else if (unformat (i, "via via-label %d", &next_hop_via_label))
9222 else if (unformat (i, "out-label %d", &next_hop_out_label))
9224 vl_api_fib_mpls_label_t fib_label = {
9225 .label = ntohl (next_hop_out_label),
9229 vec_add1 (next_hop_out_label_stack, fib_label);
9233 clib_warning ("parse error '%U'", format_unformat_error, i);
9238 if (!next_hop_set && !is_classify)
9240 errmsg ("next hop / classify not set");
9244 if (MPLS_LABEL_INVALID == local_label)
9246 errmsg ("missing label");
9252 /* Turn on async mode */
9253 vam->async_mode = 1;
9254 vam->async_errors = 0;
9255 before = vat_time_now (vam);
9258 for (j = 0; j < count; j++)
9260 /* Construct the API message */
9261 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9262 vec_len (next_hop_out_label_stack));
9264 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
9265 mp->mr_table_id = ntohl (table_id);
9267 mp->mr_is_add = is_add;
9268 mp->mr_next_hop_proto = next_hop_proto;
9269 mp->mr_is_classify = is_classify;
9270 mp->mr_is_multipath = is_multipath;
9271 mp->mr_is_resolve_host = resolve_host;
9272 mp->mr_is_resolve_attached = resolve_attached;
9273 mp->mr_is_interface_rx = is_interface_rx;
9274 mp->mr_next_hop_weight = next_hop_weight;
9275 mp->mr_next_hop_preference = 0;
9276 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
9277 mp->mr_classify_table_index = ntohl (classify_table_index);
9278 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
9279 mp->mr_label = ntohl (local_label);
9280 mp->mr_eos = is_eos;
9282 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9283 if (0 != mp->mr_next_hop_n_out_labels)
9285 memcpy (mp->mr_next_hop_out_label_stack,
9286 next_hop_out_label_stack,
9287 vec_len (next_hop_out_label_stack) *
9288 sizeof (vl_api_fib_mpls_label_t));
9289 vec_free (next_hop_out_label_stack);
9294 if (DPO_PROTO_IP4 == next_hop_proto)
9296 clib_memcpy (mp->mr_next_hop,
9297 &v4_next_hop_address,
9298 sizeof (v4_next_hop_address));
9300 else if (DPO_PROTO_IP6 == next_hop_proto)
9303 clib_memcpy (mp->mr_next_hop,
9304 &v6_next_hop_address,
9305 sizeof (v6_next_hop_address));
9312 /* If we receive SIGTERM, stop now... */
9317 /* When testing multiple add/del ops, use a control-ping to sync */
9320 vl_api_control_ping_t *mp_ping;
9324 /* Shut off async mode */
9325 vam->async_mode = 0;
9327 MPING (CONTROL_PING, mp_ping);
9330 timeout = vat_time_now (vam) + 1.0;
9331 while (vat_time_now (vam) < timeout)
9332 if (vam->result_ready == 1)
9337 if (vam->retval == -99)
9340 if (vam->async_errors > 0)
9342 errmsg ("%d asynchronous errors", vam->async_errors);
9345 vam->async_errors = 0;
9346 after = vat_time_now (vam);
9348 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9352 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9353 count, after - before, count / (after - before));
9359 /* Wait for a reply... */
9364 /* Return the good/bad news */
9365 return (vam->retval);
9369 api_mpls_ip_bind_unbind (vat_main_t * vam)
9371 unformat_input_t *i = vam->input;
9372 vl_api_mpls_ip_bind_unbind_t *mp;
9373 u32 ip_table_id = 0;
9376 ip4_address_t v4_address;
9377 ip6_address_t v6_address;
9380 mpls_label_t local_label = MPLS_LABEL_INVALID;
9383 /* Parse args required to build the message */
9384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9386 if (unformat (i, "%U/%d", unformat_ip4_address,
9387 &v4_address, &address_length))
9392 else if (unformat (i, "%U/%d", unformat_ip6_address,
9393 &v6_address, &address_length))
9398 else if (unformat (i, "%d", &local_label))
9400 else if (unformat (i, "table-id %d", &ip_table_id))
9402 else if (unformat (i, "unbind"))
9404 else if (unformat (i, "bind"))
9408 clib_warning ("parse error '%U'", format_unformat_error, i);
9415 errmsg ("IP address not set");
9419 if (MPLS_LABEL_INVALID == local_label)
9421 errmsg ("missing label");
9425 /* Construct the API message */
9426 M (MPLS_IP_BIND_UNBIND, mp);
9428 mp->mb_is_bind = is_bind;
9429 mp->mb_is_ip4 = is_ip4;
9430 mp->mb_ip_table_id = ntohl (ip_table_id);
9431 mp->mb_mpls_table_id = 0;
9432 mp->mb_label = ntohl (local_label);
9433 mp->mb_address_length = address_length;
9436 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9438 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9443 /* Wait for a reply... */
9449 api_sr_mpls_policy_add (vat_main_t * vam)
9451 unformat_input_t *i = vam->input;
9452 vl_api_sr_mpls_policy_add_t *mp;
9458 u32 *segments = NULL;
9461 /* Parse args required to build the message */
9462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9464 if (unformat (i, "bsid %d", &bsid))
9466 else if (unformat (i, "weight %d", &weight))
9468 else if (unformat (i, "spray"))
9470 else if (unformat (i, "next %d", &sid))
9473 vec_add1 (segments, htonl (sid));
9477 clib_warning ("parse error '%U'", format_unformat_error, i);
9484 errmsg ("bsid not set");
9488 if (n_segments == 0)
9490 errmsg ("no sid in segment stack");
9494 /* Construct the API message */
9495 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
9497 mp->bsid = htonl (bsid);
9498 mp->weight = htonl (weight);
9500 mp->n_segments = n_segments;
9501 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
9502 vec_free (segments);
9507 /* Wait for a reply... */
9513 api_sr_mpls_policy_del (vat_main_t * vam)
9515 unformat_input_t *i = vam->input;
9516 vl_api_sr_mpls_policy_del_t *mp;
9520 /* Parse args required to build the message */
9521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9523 if (unformat (i, "bsid %d", &bsid))
9527 clib_warning ("parse error '%U'", format_unformat_error, i);
9534 errmsg ("bsid not set");
9538 /* Construct the API message */
9539 M (SR_MPLS_POLICY_DEL, mp);
9541 mp->bsid = htonl (bsid);
9546 /* Wait for a reply... */
9552 api_bier_table_add_del (vat_main_t * vam)
9554 unformat_input_t *i = vam->input;
9555 vl_api_bier_table_add_del_t *mp;
9557 u32 set = 0, sub_domain = 0, hdr_len = 3;
9558 mpls_label_t local_label = MPLS_LABEL_INVALID;
9561 /* Parse args required to build the message */
9562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9564 if (unformat (i, "sub-domain %d", &sub_domain))
9566 else if (unformat (i, "set %d", &set))
9568 else if (unformat (i, "label %d", &local_label))
9570 else if (unformat (i, "hdr-len %d", &hdr_len))
9572 else if (unformat (i, "add"))
9574 else if (unformat (i, "del"))
9578 clib_warning ("parse error '%U'", format_unformat_error, i);
9583 if (MPLS_LABEL_INVALID == local_label)
9585 errmsg ("missing label\n");
9589 /* Construct the API message */
9590 M (BIER_TABLE_ADD_DEL, mp);
9592 mp->bt_is_add = is_add;
9593 mp->bt_label = ntohl (local_label);
9594 mp->bt_tbl_id.bt_set = set;
9595 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9596 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9601 /* Wait for a reply... */
9608 api_bier_route_add_del (vat_main_t * vam)
9610 unformat_input_t *i = vam->input;
9611 vl_api_bier_route_add_del_t *mp;
9613 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9614 ip4_address_t v4_next_hop_address;
9615 ip6_address_t v6_next_hop_address;
9616 u8 next_hop_set = 0;
9617 u8 next_hop_proto_is_ip4 = 1;
9618 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9621 /* Parse args required to build the message */
9622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9624 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9626 next_hop_proto_is_ip4 = 1;
9629 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9631 next_hop_proto_is_ip4 = 0;
9634 if (unformat (i, "sub-domain %d", &sub_domain))
9636 else if (unformat (i, "set %d", &set))
9638 else if (unformat (i, "hdr-len %d", &hdr_len))
9640 else if (unformat (i, "bp %d", &bp))
9642 else if (unformat (i, "add"))
9644 else if (unformat (i, "del"))
9646 else if (unformat (i, "out-label %d", &next_hop_out_label))
9650 clib_warning ("parse error '%U'", format_unformat_error, i);
9655 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9657 errmsg ("next hop / label set\n");
9662 errmsg ("bit=position not set\n");
9666 /* Construct the API message */
9667 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9669 mp->br_is_add = is_add;
9670 mp->br_tbl_id.bt_set = set;
9671 mp->br_tbl_id.bt_sub_domain = sub_domain;
9672 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9673 mp->br_bp = ntohs (bp);
9675 mp->br_paths[0].n_labels = 1;
9676 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9677 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9679 if (next_hop_proto_is_ip4)
9681 clib_memcpy (mp->br_paths[0].next_hop,
9682 &v4_next_hop_address, sizeof (v4_next_hop_address));
9686 clib_memcpy (mp->br_paths[0].next_hop,
9687 &v6_next_hop_address, sizeof (v6_next_hop_address));
9693 /* Wait for a reply... */
9700 api_proxy_arp_add_del (vat_main_t * vam)
9702 unformat_input_t *i = vam->input;
9703 vl_api_proxy_arp_add_del_t *mp;
9706 ip4_address_t lo, hi;
9710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9712 if (unformat (i, "vrf %d", &vrf_id))
9714 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9715 unformat_ip4_address, &hi))
9717 else if (unformat (i, "del"))
9721 clib_warning ("parse error '%U'", format_unformat_error, i);
9728 errmsg ("address range not set");
9732 M (PROXY_ARP_ADD_DEL, mp);
9734 mp->proxy.vrf_id = ntohl (vrf_id);
9735 mp->is_add = is_add;
9736 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9737 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9745 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9747 unformat_input_t *i = vam->input;
9748 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9751 u8 sw_if_index_set = 0;
9754 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9756 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9757 sw_if_index_set = 1;
9758 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9759 sw_if_index_set = 1;
9760 else if (unformat (i, "enable"))
9762 else if (unformat (i, "disable"))
9766 clib_warning ("parse error '%U'", format_unformat_error, i);
9771 if (sw_if_index_set == 0)
9773 errmsg ("missing interface name or sw_if_index");
9777 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9779 mp->sw_if_index = ntohl (sw_if_index);
9780 mp->enable_disable = enable;
9788 api_mpls_tunnel_add_del (vat_main_t * vam)
9790 unformat_input_t *i = vam->input;
9791 vl_api_mpls_tunnel_add_del_t *mp;
9795 u32 sw_if_index = ~0;
9796 u32 next_hop_sw_if_index = ~0;
9797 u32 next_hop_proto_is_ip4 = 1;
9799 u32 next_hop_table_id = 0;
9800 ip4_address_t v4_next_hop_address = {
9803 ip6_address_t v6_next_hop_address = { {0} };
9804 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9805 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9806 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9811 if (unformat (i, "add"))
9815 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9817 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9819 else if (unformat (i, "via %U",
9820 unformat_ip4_address, &v4_next_hop_address))
9822 next_hop_proto_is_ip4 = 1;
9824 else if (unformat (i, "via %U",
9825 unformat_ip6_address, &v6_next_hop_address))
9827 next_hop_proto_is_ip4 = 0;
9829 else if (unformat (i, "via-label %d", &next_hop_via_label))
9833 (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
9835 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9837 else if (unformat (i, "l2-only"))
9839 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9841 else if (unformat (i, "out-label %d", &next_hop_out_label))
9843 vl_api_fib_mpls_label_t fib_label = {
9844 .label = ntohl (next_hop_out_label),
9848 vec_add1 (next_hop_out_label_stack, fib_label);
9852 clib_warning ("parse error '%U'", format_unformat_error, i);
9857 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9858 vec_len (next_hop_out_label_stack));
9860 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9861 mp->mt_sw_if_index = ntohl (sw_if_index);
9862 mp->mt_is_add = is_add;
9863 mp->mt_l2_only = l2_only;
9864 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9865 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9866 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9867 mp->mt_next_hop_weight = 1;
9868 mp->mt_next_hop_preference = 0;
9870 mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9872 if (0 != mp->mt_next_hop_n_out_labels)
9874 clib_memcpy (mp->mt_next_hop_out_label_stack,
9875 next_hop_out_label_stack,
9876 (vec_len (next_hop_out_label_stack) *
9877 sizeof (vl_api_fib_mpls_label_t)));
9878 vec_free (next_hop_out_label_stack);
9881 if (next_hop_proto_is_ip4)
9883 clib_memcpy (mp->mt_next_hop,
9884 &v4_next_hop_address, sizeof (v4_next_hop_address));
9888 clib_memcpy (mp->mt_next_hop,
9889 &v6_next_hop_address, sizeof (v6_next_hop_address));
9898 api_sw_interface_set_unnumbered (vat_main_t * vam)
9900 unformat_input_t *i = vam->input;
9901 vl_api_sw_interface_set_unnumbered_t *mp;
9903 u32 unnum_sw_index = ~0;
9905 u8 sw_if_index_set = 0;
9908 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9910 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9911 sw_if_index_set = 1;
9912 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9913 sw_if_index_set = 1;
9914 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9916 else if (unformat (i, "del"))
9920 clib_warning ("parse error '%U'", format_unformat_error, i);
9925 if (sw_if_index_set == 0)
9927 errmsg ("missing interface name or sw_if_index");
9931 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9933 mp->sw_if_index = ntohl (sw_if_index);
9934 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9935 mp->is_add = is_add;
9943 api_ip_neighbor_add_del (vat_main_t * vam)
9945 unformat_input_t *i = vam->input;
9946 vl_api_ip_neighbor_add_del_t *mp;
9948 u8 sw_if_index_set = 0;
9951 u8 is_no_fib_entry = 0;
9954 u8 v4_address_set = 0;
9955 u8 v6_address_set = 0;
9956 ip4_address_t v4address;
9957 ip6_address_t v6address;
9960 clib_memset (mac_address, 0, sizeof (mac_address));
9962 /* Parse args required to build the message */
9963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9965 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9969 else if (unformat (i, "del"))
9972 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9973 sw_if_index_set = 1;
9974 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9975 sw_if_index_set = 1;
9976 else if (unformat (i, "is_static"))
9978 else if (unformat (i, "no-fib-entry"))
9979 is_no_fib_entry = 1;
9980 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9982 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9986 clib_warning ("parse error '%U'", format_unformat_error, i);
9991 if (sw_if_index_set == 0)
9993 errmsg ("missing interface name or sw_if_index");
9996 if (v4_address_set && v6_address_set)
9998 errmsg ("both v4 and v6 addresses set");
10001 if (!v4_address_set && !v6_address_set)
10003 errmsg ("no address set");
10007 /* Construct the API message */
10008 M (IP_NEIGHBOR_ADD_DEL, mp);
10010 mp->sw_if_index = ntohl (sw_if_index);
10011 mp->is_add = is_add;
10012 mp->is_static = is_static;
10013 mp->is_no_adj_fib = is_no_fib_entry;
10015 clib_memcpy (mp->mac_address, mac_address, 6);
10016 if (v6_address_set)
10019 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
10023 /* mp->is_ipv6 = 0; via clib_memset in M macro above */
10024 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
10030 /* Wait for a reply, return good/bad news */
10036 api_create_vlan_subif (vat_main_t * vam)
10038 unformat_input_t *i = vam->input;
10039 vl_api_create_vlan_subif_t *mp;
10041 u8 sw_if_index_set = 0;
10043 u8 vlan_id_set = 0;
10046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10048 if (unformat (i, "sw_if_index %d", &sw_if_index))
10049 sw_if_index_set = 1;
10051 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10052 sw_if_index_set = 1;
10053 else if (unformat (i, "vlan %d", &vlan_id))
10057 clib_warning ("parse error '%U'", format_unformat_error, i);
10062 if (sw_if_index_set == 0)
10064 errmsg ("missing interface name or sw_if_index");
10068 if (vlan_id_set == 0)
10070 errmsg ("missing vlan_id");
10073 M (CREATE_VLAN_SUBIF, mp);
10075 mp->sw_if_index = ntohl (sw_if_index);
10076 mp->vlan_id = ntohl (vlan_id);
10083 #define foreach_create_subif_bit \
10090 _(outer_vlan_id_any) \
10091 _(inner_vlan_id_any)
10094 api_create_subif (vat_main_t * vam)
10096 unformat_input_t *i = vam->input;
10097 vl_api_create_subif_t *mp;
10099 u8 sw_if_index_set = 0;
10106 u32 exact_match = 0;
10107 u32 default_sub = 0;
10108 u32 outer_vlan_id_any = 0;
10109 u32 inner_vlan_id_any = 0;
10111 u16 outer_vlan_id = 0;
10112 u16 inner_vlan_id = 0;
10115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10117 if (unformat (i, "sw_if_index %d", &sw_if_index))
10118 sw_if_index_set = 1;
10120 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10121 sw_if_index_set = 1;
10122 else if (unformat (i, "sub_id %d", &sub_id))
10124 else if (unformat (i, "outer_vlan_id %d", &tmp))
10125 outer_vlan_id = tmp;
10126 else if (unformat (i, "inner_vlan_id %d", &tmp))
10127 inner_vlan_id = tmp;
10129 #define _(a) else if (unformat (i, #a)) a = 1 ;
10130 foreach_create_subif_bit
10134 clib_warning ("parse error '%U'", format_unformat_error, i);
10139 if (sw_if_index_set == 0)
10141 errmsg ("missing interface name or sw_if_index");
10145 if (sub_id_set == 0)
10147 errmsg ("missing sub_id");
10150 M (CREATE_SUBIF, mp);
10152 mp->sw_if_index = ntohl (sw_if_index);
10153 mp->sub_id = ntohl (sub_id);
10155 #define _(a) mp->a = a;
10156 foreach_create_subif_bit;
10159 mp->outer_vlan_id = ntohs (outer_vlan_id);
10160 mp->inner_vlan_id = ntohs (inner_vlan_id);
10168 api_oam_add_del (vat_main_t * vam)
10170 unformat_input_t *i = vam->input;
10171 vl_api_oam_add_del_t *mp;
10174 ip4_address_t src, dst;
10179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10181 if (unformat (i, "vrf %d", &vrf_id))
10183 else if (unformat (i, "src %U", unformat_ip4_address, &src))
10185 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
10187 else if (unformat (i, "del"))
10191 clib_warning ("parse error '%U'", format_unformat_error, i);
10198 errmsg ("missing src addr");
10204 errmsg ("missing dst addr");
10208 M (OAM_ADD_DEL, mp);
10210 mp->vrf_id = ntohl (vrf_id);
10211 mp->is_add = is_add;
10212 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
10213 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
10221 api_reset_fib (vat_main_t * vam)
10223 unformat_input_t *i = vam->input;
10224 vl_api_reset_fib_t *mp;
10230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10232 if (unformat (i, "vrf %d", &vrf_id))
10234 else if (unformat (i, "ipv6"))
10238 clib_warning ("parse error '%U'", format_unformat_error, i);
10243 if (vrf_id_set == 0)
10245 errmsg ("missing vrf id");
10251 mp->vrf_id = ntohl (vrf_id);
10252 mp->is_ipv6 = is_ipv6;
10260 api_dhcp_proxy_config (vat_main_t * vam)
10262 unformat_input_t *i = vam->input;
10263 vl_api_dhcp_proxy_config_t *mp;
10265 u32 server_vrf_id = 0;
10267 u8 v4_address_set = 0;
10268 u8 v6_address_set = 0;
10269 ip4_address_t v4address;
10270 ip6_address_t v6address;
10271 u8 v4_src_address_set = 0;
10272 u8 v6_src_address_set = 0;
10273 ip4_address_t v4srcaddress;
10274 ip6_address_t v6srcaddress;
10277 /* Parse args required to build the message */
10278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10280 if (unformat (i, "del"))
10282 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
10284 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
10286 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
10287 v4_address_set = 1;
10288 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
10289 v6_address_set = 1;
10290 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
10291 v4_src_address_set = 1;
10292 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
10293 v6_src_address_set = 1;
10298 if (v4_address_set && v6_address_set)
10300 errmsg ("both v4 and v6 server addresses set");
10303 if (!v4_address_set && !v6_address_set)
10305 errmsg ("no server addresses set");
10309 if (v4_src_address_set && v6_src_address_set)
10311 errmsg ("both v4 and v6 src addresses set");
10314 if (!v4_src_address_set && !v6_src_address_set)
10316 errmsg ("no src addresses set");
10320 if (!(v4_src_address_set && v4_address_set) &&
10321 !(v6_src_address_set && v6_address_set))
10323 errmsg ("no matching server and src addresses set");
10327 /* Construct the API message */
10328 M (DHCP_PROXY_CONFIG, mp);
10330 mp->is_add = is_add;
10331 mp->rx_vrf_id = ntohl (rx_vrf_id);
10332 mp->server_vrf_id = ntohl (server_vrf_id);
10333 if (v6_address_set)
10336 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
10337 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
10341 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
10342 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
10348 /* Wait for a reply, return good/bad news */
10353 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
10354 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
10357 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
10359 vat_main_t *vam = &vat_main;
10360 u32 i, count = mp->count;
10361 vl_api_dhcp_server_t *s;
10365 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10366 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10367 ntohl (mp->rx_vrf_id),
10368 format_ip6_address, mp->dhcp_src_address,
10369 mp->vss_type, mp->vss_vpn_ascii_id,
10370 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10373 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10374 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10375 ntohl (mp->rx_vrf_id),
10376 format_ip4_address, mp->dhcp_src_address,
10377 mp->vss_type, mp->vss_vpn_ascii_id,
10378 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10380 for (i = 0; i < count; i++)
10382 s = &mp->servers[i];
10386 " Server Table-ID %d, Server Address %U",
10387 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
10390 " Server Table-ID %d, Server Address %U",
10391 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
10395 static void vl_api_dhcp_proxy_details_t_handler_json
10396 (vl_api_dhcp_proxy_details_t * mp)
10398 vat_main_t *vam = &vat_main;
10399 vat_json_node_t *node = NULL;
10400 u32 i, count = mp->count;
10401 struct in_addr ip4;
10402 struct in6_addr ip6;
10403 vl_api_dhcp_server_t *s;
10405 if (VAT_JSON_ARRAY != vam->json_tree.type)
10407 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10408 vat_json_init_array (&vam->json_tree);
10410 node = vat_json_array_add (&vam->json_tree);
10412 vat_json_init_object (node);
10413 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
10414 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
10415 sizeof (mp->vss_type));
10416 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
10417 mp->vss_vpn_ascii_id);
10418 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
10419 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10423 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10424 vat_json_object_add_ip6 (node, "src_address", ip6);
10428 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10429 vat_json_object_add_ip4 (node, "src_address", ip4);
10432 for (i = 0; i < count; i++)
10434 s = &mp->servers[i];
10436 vat_json_object_add_uint (node, "server-table-id",
10437 ntohl (s->server_vrf_id));
10441 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10442 vat_json_object_add_ip4 (node, "src_address", ip4);
10446 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10447 vat_json_object_add_ip6 (node, "server_address", ip6);
10453 api_dhcp_proxy_dump (vat_main_t * vam)
10455 unformat_input_t *i = vam->input;
10456 vl_api_control_ping_t *mp_ping;
10457 vl_api_dhcp_proxy_dump_t *mp;
10461 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10463 if (unformat (i, "ipv6"))
10467 clib_warning ("parse error '%U'", format_unformat_error, i);
10472 M (DHCP_PROXY_DUMP, mp);
10474 mp->is_ip6 = is_ipv6;
10477 /* Use a control ping for synchronization */
10478 MPING (CONTROL_PING, mp_ping);
10486 api_dhcp_proxy_set_vss (vat_main_t * vam)
10488 unformat_input_t *i = vam->input;
10489 vl_api_dhcp_proxy_set_vss_t *mp;
10493 u8 vss_type = VSS_TYPE_DEFAULT;
10494 u8 *vpn_ascii_id = 0;
10499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10501 if (unformat (i, "tbl_id %d", &tbl_id))
10503 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10504 vss_type = VSS_TYPE_ASCII;
10505 else if (unformat (i, "fib_id %d", &fib_id))
10506 vss_type = VSS_TYPE_VPN_ID;
10507 else if (unformat (i, "oui %d", &oui))
10508 vss_type = VSS_TYPE_VPN_ID;
10509 else if (unformat (i, "ipv6"))
10511 else if (unformat (i, "del"))
10519 errmsg ("missing tbl_id ");
10520 vec_free (vpn_ascii_id);
10524 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10526 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10527 vec_free (vpn_ascii_id);
10531 M (DHCP_PROXY_SET_VSS, mp);
10532 mp->tbl_id = ntohl (tbl_id);
10533 mp->vss_type = vss_type;
10536 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10537 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10539 mp->vpn_index = ntohl (fib_id);
10540 mp->oui = ntohl (oui);
10541 mp->is_ipv6 = is_ipv6;
10542 mp->is_add = is_add;
10547 vec_free (vpn_ascii_id);
10552 api_dhcp_client_config (vat_main_t * vam)
10554 unformat_input_t *i = vam->input;
10555 vl_api_dhcp_client_config_t *mp;
10557 u8 sw_if_index_set = 0;
10560 u8 disable_event = 0;
10563 /* Parse args required to build the message */
10564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10566 if (unformat (i, "del"))
10569 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10570 sw_if_index_set = 1;
10571 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10572 sw_if_index_set = 1;
10573 else if (unformat (i, "hostname %s", &hostname))
10575 else if (unformat (i, "disable_event"))
10581 if (sw_if_index_set == 0)
10583 errmsg ("missing interface name or sw_if_index");
10587 if (vec_len (hostname) > 63)
10589 errmsg ("hostname too long");
10591 vec_add1 (hostname, 0);
10593 /* Construct the API message */
10594 M (DHCP_CLIENT_CONFIG, mp);
10596 mp->is_add = is_add;
10597 mp->client.sw_if_index = htonl (sw_if_index);
10598 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10599 vec_free (hostname);
10600 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10601 mp->client.pid = htonl (getpid ());
10606 /* Wait for a reply, return good/bad news */
10612 api_set_ip_flow_hash (vat_main_t * vam)
10614 unformat_input_t *i = vam->input;
10615 vl_api_set_ip_flow_hash_t *mp;
10627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10629 if (unformat (i, "vrf %d", &vrf_id))
10631 else if (unformat (i, "ipv6"))
10633 else if (unformat (i, "src"))
10635 else if (unformat (i, "dst"))
10637 else if (unformat (i, "sport"))
10639 else if (unformat (i, "dport"))
10641 else if (unformat (i, "proto"))
10643 else if (unformat (i, "reverse"))
10648 clib_warning ("parse error '%U'", format_unformat_error, i);
10653 if (vrf_id_set == 0)
10655 errmsg ("missing vrf id");
10659 M (SET_IP_FLOW_HASH, mp);
10665 mp->reverse = reverse;
10666 mp->vrf_id = ntohl (vrf_id);
10667 mp->is_ipv6 = is_ipv6;
10675 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10677 unformat_input_t *i = vam->input;
10678 vl_api_sw_interface_ip6_enable_disable_t *mp;
10680 u8 sw_if_index_set = 0;
10684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10686 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10687 sw_if_index_set = 1;
10688 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10689 sw_if_index_set = 1;
10690 else if (unformat (i, "enable"))
10692 else if (unformat (i, "disable"))
10696 clib_warning ("parse error '%U'", format_unformat_error, i);
10701 if (sw_if_index_set == 0)
10703 errmsg ("missing interface name or sw_if_index");
10707 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10709 mp->sw_if_index = ntohl (sw_if_index);
10710 mp->enable = enable;
10718 api_ip6nd_proxy_add_del (vat_main_t * vam)
10720 unformat_input_t *i = vam->input;
10721 vl_api_ip6nd_proxy_add_del_t *mp;
10722 u32 sw_if_index = ~0;
10723 u8 v6_address_set = 0;
10724 ip6_address_t v6address;
10728 /* Parse args required to build the message */
10729 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10731 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10733 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10735 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10736 v6_address_set = 1;
10737 if (unformat (i, "del"))
10741 clib_warning ("parse error '%U'", format_unformat_error, i);
10746 if (sw_if_index == ~0)
10748 errmsg ("missing interface name or sw_if_index");
10751 if (!v6_address_set)
10753 errmsg ("no address set");
10757 /* Construct the API message */
10758 M (IP6ND_PROXY_ADD_DEL, mp);
10760 mp->is_del = is_del;
10761 mp->sw_if_index = ntohl (sw_if_index);
10762 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10767 /* Wait for a reply, return good/bad news */
10773 api_ip6nd_proxy_dump (vat_main_t * vam)
10775 vl_api_ip6nd_proxy_dump_t *mp;
10776 vl_api_control_ping_t *mp_ping;
10779 M (IP6ND_PROXY_DUMP, mp);
10783 /* Use a control ping for synchronization */
10784 MPING (CONTROL_PING, mp_ping);
10791 static void vl_api_ip6nd_proxy_details_t_handler
10792 (vl_api_ip6nd_proxy_details_t * mp)
10794 vat_main_t *vam = &vat_main;
10796 print (vam->ofp, "host %U sw_if_index %d",
10797 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10800 static void vl_api_ip6nd_proxy_details_t_handler_json
10801 (vl_api_ip6nd_proxy_details_t * mp)
10803 vat_main_t *vam = &vat_main;
10804 struct in6_addr ip6;
10805 vat_json_node_t *node = NULL;
10807 if (VAT_JSON_ARRAY != vam->json_tree.type)
10809 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10810 vat_json_init_array (&vam->json_tree);
10812 node = vat_json_array_add (&vam->json_tree);
10814 vat_json_init_object (node);
10815 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10817 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10818 vat_json_object_add_ip6 (node, "host", ip6);
10822 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10824 unformat_input_t *i = vam->input;
10825 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10827 u8 sw_if_index_set = 0;
10828 u32 address_length = 0;
10829 u8 v6_address_set = 0;
10830 ip6_address_t v6address;
10831 u8 use_default = 0;
10832 u8 no_advertise = 0;
10834 u8 no_autoconfig = 0;
10837 u32 val_lifetime = 0;
10838 u32 pref_lifetime = 0;
10841 /* Parse args required to build the message */
10842 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10844 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10845 sw_if_index_set = 1;
10846 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10847 sw_if_index_set = 1;
10848 else if (unformat (i, "%U/%d",
10849 unformat_ip6_address, &v6address, &address_length))
10850 v6_address_set = 1;
10851 else if (unformat (i, "val_life %d", &val_lifetime))
10853 else if (unformat (i, "pref_life %d", &pref_lifetime))
10855 else if (unformat (i, "def"))
10857 else if (unformat (i, "noadv"))
10859 else if (unformat (i, "offl"))
10861 else if (unformat (i, "noauto"))
10863 else if (unformat (i, "nolink"))
10865 else if (unformat (i, "isno"))
10869 clib_warning ("parse error '%U'", format_unformat_error, i);
10874 if (sw_if_index_set == 0)
10876 errmsg ("missing interface name or sw_if_index");
10879 if (!v6_address_set)
10881 errmsg ("no address set");
10885 /* Construct the API message */
10886 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10888 mp->sw_if_index = ntohl (sw_if_index);
10889 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10890 mp->address_length = address_length;
10891 mp->use_default = use_default;
10892 mp->no_advertise = no_advertise;
10893 mp->off_link = off_link;
10894 mp->no_autoconfig = no_autoconfig;
10895 mp->no_onlink = no_onlink;
10897 mp->val_lifetime = ntohl (val_lifetime);
10898 mp->pref_lifetime = ntohl (pref_lifetime);
10903 /* Wait for a reply, return good/bad news */
10909 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10911 unformat_input_t *i = vam->input;
10912 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10914 u8 sw_if_index_set = 0;
10919 u8 send_unicast = 0;
10922 u8 default_router = 0;
10923 u32 max_interval = 0;
10924 u32 min_interval = 0;
10926 u32 initial_count = 0;
10927 u32 initial_interval = 0;
10931 /* Parse args required to build the message */
10932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10934 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10935 sw_if_index_set = 1;
10936 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10937 sw_if_index_set = 1;
10938 else if (unformat (i, "maxint %d", &max_interval))
10940 else if (unformat (i, "minint %d", &min_interval))
10942 else if (unformat (i, "life %d", &lifetime))
10944 else if (unformat (i, "count %d", &initial_count))
10946 else if (unformat (i, "interval %d", &initial_interval))
10948 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10950 else if (unformat (i, "managed"))
10952 else if (unformat (i, "other"))
10954 else if (unformat (i, "ll"))
10956 else if (unformat (i, "send"))
10958 else if (unformat (i, "cease"))
10960 else if (unformat (i, "isno"))
10962 else if (unformat (i, "def"))
10963 default_router = 1;
10966 clib_warning ("parse error '%U'", format_unformat_error, i);
10971 if (sw_if_index_set == 0)
10973 errmsg ("missing interface name or sw_if_index");
10977 /* Construct the API message */
10978 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10980 mp->sw_if_index = ntohl (sw_if_index);
10981 mp->max_interval = ntohl (max_interval);
10982 mp->min_interval = ntohl (min_interval);
10983 mp->lifetime = ntohl (lifetime);
10984 mp->initial_count = ntohl (initial_count);
10985 mp->initial_interval = ntohl (initial_interval);
10986 mp->suppress = suppress;
10987 mp->managed = managed;
10989 mp->ll_option = ll_option;
10990 mp->send_unicast = send_unicast;
10993 mp->default_router = default_router;
10998 /* Wait for a reply, return good/bad news */
11004 api_set_arp_neighbor_limit (vat_main_t * vam)
11006 unformat_input_t *i = vam->input;
11007 vl_api_set_arp_neighbor_limit_t *mp;
11013 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11015 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
11017 else if (unformat (i, "ipv6"))
11021 clib_warning ("parse error '%U'", format_unformat_error, i);
11026 if (limit_set == 0)
11028 errmsg ("missing limit value");
11032 M (SET_ARP_NEIGHBOR_LIMIT, mp);
11034 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
11035 mp->is_ipv6 = is_ipv6;
11043 api_l2_patch_add_del (vat_main_t * vam)
11045 unformat_input_t *i = vam->input;
11046 vl_api_l2_patch_add_del_t *mp;
11047 u32 rx_sw_if_index;
11048 u8 rx_sw_if_index_set = 0;
11049 u32 tx_sw_if_index;
11050 u8 tx_sw_if_index_set = 0;
11054 /* Parse args required to build the message */
11055 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11057 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
11058 rx_sw_if_index_set = 1;
11059 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
11060 tx_sw_if_index_set = 1;
11061 else if (unformat (i, "rx"))
11063 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11065 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
11067 rx_sw_if_index_set = 1;
11072 else if (unformat (i, "tx"))
11074 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11076 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
11078 tx_sw_if_index_set = 1;
11083 else if (unformat (i, "del"))
11089 if (rx_sw_if_index_set == 0)
11091 errmsg ("missing rx interface name or rx_sw_if_index");
11095 if (tx_sw_if_index_set == 0)
11097 errmsg ("missing tx interface name or tx_sw_if_index");
11101 M (L2_PATCH_ADD_DEL, mp);
11103 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
11104 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
11105 mp->is_add = is_add;
11113 u8 localsid_addr[16];
11122 api_sr_localsid_add_del (vat_main_t * vam)
11124 unformat_input_t *i = vam->input;
11125 vl_api_sr_localsid_add_del_t *mp;
11128 ip6_address_t localsid;
11132 u32 fib_table = ~(u32) 0;
11133 ip6_address_t nh_addr6;
11134 ip4_address_t nh_addr4;
11135 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
11136 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
11138 bool nexthop_set = 0;
11142 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11144 if (unformat (i, "del"))
11146 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
11147 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
11149 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
11151 else if (unformat (i, "behavior %u", &behavior));
11152 else if (unformat (i, "sw_if_index %u", &sw_if_index));
11153 else if (unformat (i, "fib-table %u", &fib_table));
11154 else if (unformat (i, "end.psp %u", &behavior));
11159 M (SR_LOCALSID_ADD_DEL, mp);
11161 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
11164 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
11165 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
11167 mp->behavior = behavior;
11168 mp->sw_if_index = ntohl (sw_if_index);
11169 mp->fib_table = ntohl (fib_table);
11170 mp->end_psp = end_psp;
11171 mp->is_del = is_del;
11179 api_ioam_enable (vat_main_t * vam)
11181 unformat_input_t *input = vam->input;
11182 vl_api_ioam_enable_t *mp;
11184 int has_trace_option = 0;
11185 int has_pot_option = 0;
11186 int has_seqno_option = 0;
11187 int has_analyse_option = 0;
11190 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11192 if (unformat (input, "trace"))
11193 has_trace_option = 1;
11194 else if (unformat (input, "pot"))
11195 has_pot_option = 1;
11196 else if (unformat (input, "seqno"))
11197 has_seqno_option = 1;
11198 else if (unformat (input, "analyse"))
11199 has_analyse_option = 1;
11203 M (IOAM_ENABLE, mp);
11204 mp->id = htons (id);
11205 mp->seqno = has_seqno_option;
11206 mp->analyse = has_analyse_option;
11207 mp->pot_enable = has_pot_option;
11208 mp->trace_enable = has_trace_option;
11217 api_ioam_disable (vat_main_t * vam)
11219 vl_api_ioam_disable_t *mp;
11222 M (IOAM_DISABLE, mp);
11228 #define foreach_tcp_proto_field \
11232 #define foreach_udp_proto_field \
11236 #define foreach_ip4_proto_field \
11248 u16 src_port, dst_port;
11251 #if VPP_API_TEST_BUILTIN == 0
11253 unformat_tcp_mask (unformat_input_t * input, va_list * args)
11255 u8 **maskp = va_arg (*args, u8 **);
11257 u8 found_something = 0;
11260 #define _(a) u8 a=0;
11261 foreach_tcp_proto_field;
11264 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11267 #define _(a) else if (unformat (input, #a)) a=1;
11268 foreach_tcp_proto_field
11274 #define _(a) found_something += a;
11275 foreach_tcp_proto_field;
11278 if (found_something == 0)
11281 vec_validate (mask, sizeof (*tcp) - 1);
11283 tcp = (tcp_header_t *) mask;
11285 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
11286 foreach_tcp_proto_field;
11294 unformat_udp_mask (unformat_input_t * input, va_list * args)
11296 u8 **maskp = va_arg (*args, u8 **);
11298 u8 found_something = 0;
11301 #define _(a) u8 a=0;
11302 foreach_udp_proto_field;
11305 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11308 #define _(a) else if (unformat (input, #a)) a=1;
11309 foreach_udp_proto_field
11315 #define _(a) found_something += a;
11316 foreach_udp_proto_field;
11319 if (found_something == 0)
11322 vec_validate (mask, sizeof (*udp) - 1);
11324 udp = (udp_header_t *) mask;
11326 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
11327 foreach_udp_proto_field;
11335 unformat_l4_mask (unformat_input_t * input, va_list * args)
11337 u8 **maskp = va_arg (*args, u8 **);
11338 u16 src_port = 0, dst_port = 0;
11339 tcpudp_header_t *tcpudp;
11341 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11343 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
11345 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
11347 else if (unformat (input, "src_port"))
11349 else if (unformat (input, "dst_port"))
11355 if (!src_port && !dst_port)
11359 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
11361 tcpudp = (tcpudp_header_t *) mask;
11362 tcpudp->src_port = src_port;
11363 tcpudp->dst_port = dst_port;
11371 unformat_ip4_mask (unformat_input_t * input, va_list * args)
11373 u8 **maskp = va_arg (*args, u8 **);
11375 u8 found_something = 0;
11378 #define _(a) u8 a=0;
11379 foreach_ip4_proto_field;
11385 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11387 if (unformat (input, "version"))
11389 else if (unformat (input, "hdr_length"))
11391 else if (unformat (input, "src"))
11393 else if (unformat (input, "dst"))
11395 else if (unformat (input, "proto"))
11398 #define _(a) else if (unformat (input, #a)) a=1;
11399 foreach_ip4_proto_field
11405 #define _(a) found_something += a;
11406 foreach_ip4_proto_field;
11409 if (found_something == 0)
11412 vec_validate (mask, sizeof (*ip) - 1);
11414 ip = (ip4_header_t *) mask;
11416 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
11417 foreach_ip4_proto_field;
11420 ip->ip_version_and_header_length = 0;
11423 ip->ip_version_and_header_length |= 0xF0;
11426 ip->ip_version_and_header_length |= 0x0F;
11432 #define foreach_ip6_proto_field \
11435 _(payload_length) \
11440 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11442 u8 **maskp = va_arg (*args, u8 **);
11444 u8 found_something = 0;
11446 u32 ip_version_traffic_class_and_flow_label;
11448 #define _(a) u8 a=0;
11449 foreach_ip6_proto_field;
11452 u8 traffic_class = 0;
11455 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11457 if (unformat (input, "version"))
11459 else if (unformat (input, "traffic-class"))
11461 else if (unformat (input, "flow-label"))
11463 else if (unformat (input, "src"))
11465 else if (unformat (input, "dst"))
11467 else if (unformat (input, "proto"))
11470 #define _(a) else if (unformat (input, #a)) a=1;
11471 foreach_ip6_proto_field
11477 #define _(a) found_something += a;
11478 foreach_ip6_proto_field;
11481 if (found_something == 0)
11484 vec_validate (mask, sizeof (*ip) - 1);
11486 ip = (ip6_header_t *) mask;
11488 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
11489 foreach_ip6_proto_field;
11492 ip_version_traffic_class_and_flow_label = 0;
11495 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11498 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11501 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11503 ip->ip_version_traffic_class_and_flow_label =
11504 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11511 unformat_l3_mask (unformat_input_t * input, va_list * args)
11513 u8 **maskp = va_arg (*args, u8 **);
11515 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11517 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11519 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11528 unformat_l2_mask (unformat_input_t * input, va_list * args)
11530 u8 **maskp = va_arg (*args, u8 **);
11537 u8 ignore_tag1 = 0;
11538 u8 ignore_tag2 = 0;
11545 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11547 if (unformat (input, "src"))
11549 else if (unformat (input, "dst"))
11551 else if (unformat (input, "proto"))
11553 else if (unformat (input, "tag1"))
11555 else if (unformat (input, "tag2"))
11557 else if (unformat (input, "ignore-tag1"))
11559 else if (unformat (input, "ignore-tag2"))
11561 else if (unformat (input, "cos1"))
11563 else if (unformat (input, "cos2"))
11565 else if (unformat (input, "dot1q"))
11567 else if (unformat (input, "dot1ad"))
11572 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11573 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11576 if (tag1 || ignore_tag1 || cos1 || dot1q)
11578 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11581 vec_validate (mask, len - 1);
11584 clib_memset (mask, 0xff, 6);
11587 clib_memset (mask + 6, 0xff, 6);
11589 if (tag2 || dot1ad)
11591 /* inner vlan tag */
11600 mask[21] = mask[20] = 0xff;
11621 mask[16] = mask[17] = 0xff;
11631 mask[12] = mask[13] = 0xff;
11638 unformat_classify_mask (unformat_input_t * input, va_list * args)
11640 u8 **maskp = va_arg (*args, u8 **);
11641 u32 *skipp = va_arg (*args, u32 *);
11642 u32 *matchp = va_arg (*args, u32 *);
11650 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11652 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11654 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11656 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11658 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11672 if (mask || l2 || l3 || l4)
11674 if (l2 || l3 || l4)
11676 /* "With a free Ethernet header in every package" */
11678 vec_validate (l2, 13);
11682 vec_append (mask, l3);
11687 vec_append (mask, l4);
11692 /* Scan forward looking for the first significant mask octet */
11693 for (i = 0; i < vec_len (mask); i++)
11697 /* compute (skip, match) params */
11698 *skipp = i / sizeof (u32x4);
11699 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11701 /* Pad mask to an even multiple of the vector size */
11702 while (vec_len (mask) % sizeof (u32x4))
11703 vec_add1 (mask, 0);
11705 match = vec_len (mask) / sizeof (u32x4);
11707 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11709 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11710 if (*tmp || *(tmp + 1))
11715 clib_warning ("BUG: match 0");
11717 _vec_len (mask) = match * sizeof (u32x4);
11727 #endif /* VPP_API_TEST_BUILTIN */
11729 #define foreach_l2_next \
11731 _(ethernet, ETHERNET_INPUT) \
11732 _(ip4, IP4_INPUT) \
11736 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11738 u32 *miss_next_indexp = va_arg (*args, u32 *);
11739 u32 next_index = 0;
11743 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11747 if (unformat (input, "%d", &tmp))
11756 *miss_next_indexp = next_index;
11760 #define foreach_ip_next \
11763 _(rewrite, REWRITE)
11766 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11768 u32 *miss_next_indexp = va_arg (*args, u32 *);
11769 u32 next_index = 0;
11773 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11777 if (unformat (input, "%d", &tmp))
11786 *miss_next_indexp = next_index;
11790 #define foreach_acl_next \
11794 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11796 u32 *miss_next_indexp = va_arg (*args, u32 *);
11797 u32 next_index = 0;
11801 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11805 if (unformat (input, "permit"))
11810 else if (unformat (input, "%d", &tmp))
11819 *miss_next_indexp = next_index;
11824 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11826 u32 *r = va_arg (*args, u32 *);
11828 if (unformat (input, "conform-color"))
11829 *r = POLICE_CONFORM;
11830 else if (unformat (input, "exceed-color"))
11831 *r = POLICE_EXCEED;
11839 api_classify_add_del_table (vat_main_t * vam)
11841 unformat_input_t *i = vam->input;
11842 vl_api_classify_add_del_table_t *mp;
11849 u32 table_index = ~0;
11850 u32 next_table_index = ~0;
11851 u32 miss_next_index = ~0;
11852 u32 memory_size = 32 << 20;
11854 u32 current_data_flag = 0;
11855 int current_data_offset = 0;
11858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11860 if (unformat (i, "del"))
11862 else if (unformat (i, "del-chain"))
11867 else if (unformat (i, "buckets %d", &nbuckets))
11869 else if (unformat (i, "memory_size %d", &memory_size))
11871 else if (unformat (i, "skip %d", &skip))
11873 else if (unformat (i, "match %d", &match))
11875 else if (unformat (i, "table %d", &table_index))
11877 else if (unformat (i, "mask %U", unformat_classify_mask,
11878 &mask, &skip, &match))
11880 else if (unformat (i, "next-table %d", &next_table_index))
11882 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11885 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11888 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11891 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11893 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11899 if (is_add && mask == 0)
11901 errmsg ("Mask required");
11905 if (is_add && skip == ~0)
11907 errmsg ("skip count required");
11911 if (is_add && match == ~0)
11913 errmsg ("match count required");
11917 if (!is_add && table_index == ~0)
11919 errmsg ("table index required for delete");
11923 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11925 mp->is_add = is_add;
11926 mp->del_chain = del_chain;
11927 mp->table_index = ntohl (table_index);
11928 mp->nbuckets = ntohl (nbuckets);
11929 mp->memory_size = ntohl (memory_size);
11930 mp->skip_n_vectors = ntohl (skip);
11931 mp->match_n_vectors = ntohl (match);
11932 mp->next_table_index = ntohl (next_table_index);
11933 mp->miss_next_index = ntohl (miss_next_index);
11934 mp->current_data_flag = ntohl (current_data_flag);
11935 mp->current_data_offset = ntohl (current_data_offset);
11936 mp->mask_len = ntohl (vec_len (mask));
11937 clib_memcpy (mp->mask, mask, vec_len (mask));
11946 #if VPP_API_TEST_BUILTIN == 0
11948 unformat_l4_match (unformat_input_t * input, va_list * args)
11950 u8 **matchp = va_arg (*args, u8 **);
11952 u8 *proto_header = 0;
11958 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11960 if (unformat (input, "src_port %d", &src_port))
11962 else if (unformat (input, "dst_port %d", &dst_port))
11968 h.src_port = clib_host_to_net_u16 (src_port);
11969 h.dst_port = clib_host_to_net_u16 (dst_port);
11970 vec_validate (proto_header, sizeof (h) - 1);
11971 memcpy (proto_header, &h, sizeof (h));
11973 *matchp = proto_header;
11979 unformat_ip4_match (unformat_input_t * input, va_list * args)
11981 u8 **matchp = va_arg (*args, u8 **);
11986 int hdr_length = 0;
11987 u32 hdr_length_val;
11988 int src = 0, dst = 0;
11989 ip4_address_t src_val, dst_val;
11996 int fragment_id = 0;
11997 u32 fragment_id_val;
12003 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12005 if (unformat (input, "version %d", &version_val))
12007 else if (unformat (input, "hdr_length %d", &hdr_length_val))
12009 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
12011 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
12013 else if (unformat (input, "proto %d", &proto_val))
12015 else if (unformat (input, "tos %d", &tos_val))
12017 else if (unformat (input, "length %d", &length_val))
12019 else if (unformat (input, "fragment_id %d", &fragment_id_val))
12021 else if (unformat (input, "ttl %d", &ttl_val))
12023 else if (unformat (input, "checksum %d", &checksum_val))
12029 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
12030 + ttl + checksum == 0)
12034 * Aligned because we use the real comparison functions
12036 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12038 ip = (ip4_header_t *) match;
12040 /* These are realistically matched in practice */
12042 ip->src_address.as_u32 = src_val.as_u32;
12045 ip->dst_address.as_u32 = dst_val.as_u32;
12048 ip->protocol = proto_val;
12051 /* These are not, but they're included for completeness */
12053 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
12056 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
12062 ip->length = clib_host_to_net_u16 (length_val);
12068 ip->checksum = clib_host_to_net_u16 (checksum_val);
12075 unformat_ip6_match (unformat_input_t * input, va_list * args)
12077 u8 **matchp = va_arg (*args, u8 **);
12082 u8 traffic_class = 0;
12083 u32 traffic_class_val = 0;
12086 int src = 0, dst = 0;
12087 ip6_address_t src_val, dst_val;
12090 int payload_length = 0;
12091 u32 payload_length_val;
12094 u32 ip_version_traffic_class_and_flow_label;
12096 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12098 if (unformat (input, "version %d", &version_val))
12100 else if (unformat (input, "traffic_class %d", &traffic_class_val))
12102 else if (unformat (input, "flow_label %d", &flow_label_val))
12104 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
12106 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
12108 else if (unformat (input, "proto %d", &proto_val))
12110 else if (unformat (input, "payload_length %d", &payload_length_val))
12111 payload_length = 1;
12112 else if (unformat (input, "hop_limit %d", &hop_limit_val))
12118 if (version + traffic_class + flow_label + src + dst + proto +
12119 payload_length + hop_limit == 0)
12123 * Aligned because we use the real comparison functions
12125 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12127 ip = (ip6_header_t *) match;
12130 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
12133 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
12136 ip->protocol = proto_val;
12138 ip_version_traffic_class_and_flow_label = 0;
12141 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
12144 ip_version_traffic_class_and_flow_label |=
12145 (traffic_class_val & 0xFF) << 20;
12148 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
12150 ip->ip_version_traffic_class_and_flow_label =
12151 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
12153 if (payload_length)
12154 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
12157 ip->hop_limit = hop_limit_val;
12164 unformat_l3_match (unformat_input_t * input, va_list * args)
12166 u8 **matchp = va_arg (*args, u8 **);
12168 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12170 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
12172 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
12181 unformat_vlan_tag (unformat_input_t * input, va_list * args)
12183 u8 *tagp = va_arg (*args, u8 *);
12186 if (unformat (input, "%d", &tag))
12188 tagp[0] = (tag >> 8) & 0x0F;
12189 tagp[1] = tag & 0xFF;
12197 unformat_l2_match (unformat_input_t * input, va_list * args)
12199 u8 **matchp = va_arg (*args, u8 **);
12212 u8 ignore_tag1 = 0;
12213 u8 ignore_tag2 = 0;
12219 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12221 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
12224 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
12226 else if (unformat (input, "proto %U",
12227 unformat_ethernet_type_host_byte_order, &proto_val))
12229 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
12231 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
12233 else if (unformat (input, "ignore-tag1"))
12235 else if (unformat (input, "ignore-tag2"))
12237 else if (unformat (input, "cos1 %d", &cos1_val))
12239 else if (unformat (input, "cos2 %d", &cos2_val))
12244 if ((src + dst + proto + tag1 + tag2 +
12245 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
12248 if (tag1 || ignore_tag1 || cos1)
12250 if (tag2 || ignore_tag2 || cos2)
12253 vec_validate_aligned (match, len - 1, sizeof (u32x4));
12256 clib_memcpy (match, dst_val, 6);
12259 clib_memcpy (match + 6, src_val, 6);
12263 /* inner vlan tag */
12264 match[19] = tag2_val[1];
12265 match[18] = tag2_val[0];
12267 match[18] |= (cos2_val & 0x7) << 5;
12270 match[21] = proto_val & 0xff;
12271 match[20] = proto_val >> 8;
12275 match[15] = tag1_val[1];
12276 match[14] = tag1_val[0];
12279 match[14] |= (cos1_val & 0x7) << 5;
12285 match[15] = tag1_val[1];
12286 match[14] = tag1_val[0];
12289 match[17] = proto_val & 0xff;
12290 match[16] = proto_val >> 8;
12293 match[14] |= (cos1_val & 0x7) << 5;
12299 match[18] |= (cos2_val & 0x7) << 5;
12301 match[14] |= (cos1_val & 0x7) << 5;
12304 match[13] = proto_val & 0xff;
12305 match[12] = proto_val >> 8;
12313 unformat_qos_source (unformat_input_t * input, va_list * args)
12315 int *qs = va_arg (*args, int *);
12317 if (unformat (input, "ip"))
12318 *qs = QOS_SOURCE_IP;
12319 else if (unformat (input, "mpls"))
12320 *qs = QOS_SOURCE_MPLS;
12321 else if (unformat (input, "ext"))
12322 *qs = QOS_SOURCE_EXT;
12323 else if (unformat (input, "vlan"))
12324 *qs = QOS_SOURCE_VLAN;
12333 api_unformat_classify_match (unformat_input_t * input, va_list * args)
12335 u8 **matchp = va_arg (*args, u8 **);
12336 u32 skip_n_vectors = va_arg (*args, u32);
12337 u32 match_n_vectors = va_arg (*args, u32);
12344 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12346 if (unformat (input, "hex %U", unformat_hex_string, &match))
12348 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
12350 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
12352 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
12366 if (match || l2 || l3 || l4)
12368 if (l2 || l3 || l4)
12370 /* "Win a free Ethernet header in every packet" */
12372 vec_validate_aligned (l2, 13, sizeof (u32x4));
12376 vec_append_aligned (match, l3, sizeof (u32x4));
12381 vec_append_aligned (match, l4, sizeof (u32x4));
12386 /* Make sure the vector is big enough even if key is all 0's */
12387 vec_validate_aligned
12388 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12391 /* Set size, include skipped vectors */
12392 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12403 api_classify_add_del_session (vat_main_t * vam)
12405 unformat_input_t *i = vam->input;
12406 vl_api_classify_add_del_session_t *mp;
12408 u32 table_index = ~0;
12409 u32 hit_next_index = ~0;
12410 u32 opaque_index = ~0;
12413 u32 skip_n_vectors = 0;
12414 u32 match_n_vectors = 0;
12420 * Warning: you have to supply skip_n and match_n
12421 * because the API client cant simply look at the classify
12425 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12427 if (unformat (i, "del"))
12429 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12432 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12435 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12438 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12440 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12442 else if (unformat (i, "opaque-index %d", &opaque_index))
12444 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12446 else if (unformat (i, "match_n %d", &match_n_vectors))
12448 else if (unformat (i, "match %U", api_unformat_classify_match,
12449 &match, skip_n_vectors, match_n_vectors))
12451 else if (unformat (i, "advance %d", &advance))
12453 else if (unformat (i, "table-index %d", &table_index))
12455 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12457 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12459 else if (unformat (i, "action %d", &action))
12461 else if (unformat (i, "metadata %d", &metadata))
12467 if (table_index == ~0)
12469 errmsg ("Table index required");
12473 if (is_add && match == 0)
12475 errmsg ("Match value required");
12479 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12481 mp->is_add = is_add;
12482 mp->table_index = ntohl (table_index);
12483 mp->hit_next_index = ntohl (hit_next_index);
12484 mp->opaque_index = ntohl (opaque_index);
12485 mp->advance = ntohl (advance);
12486 mp->action = action;
12487 mp->metadata = ntohl (metadata);
12488 mp->match_len = ntohl (vec_len (match));
12489 clib_memcpy (mp->match, match, vec_len (match));
12498 api_classify_set_interface_ip_table (vat_main_t * vam)
12500 unformat_input_t *i = vam->input;
12501 vl_api_classify_set_interface_ip_table_t *mp;
12503 int sw_if_index_set;
12504 u32 table_index = ~0;
12508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12510 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12511 sw_if_index_set = 1;
12512 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12513 sw_if_index_set = 1;
12514 else if (unformat (i, "table %d", &table_index))
12518 clib_warning ("parse error '%U'", format_unformat_error, i);
12523 if (sw_if_index_set == 0)
12525 errmsg ("missing interface name or sw_if_index");
12530 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12532 mp->sw_if_index = ntohl (sw_if_index);
12533 mp->table_index = ntohl (table_index);
12534 mp->is_ipv6 = is_ipv6;
12542 api_classify_set_interface_l2_tables (vat_main_t * vam)
12544 unformat_input_t *i = vam->input;
12545 vl_api_classify_set_interface_l2_tables_t *mp;
12547 int sw_if_index_set;
12548 u32 ip4_table_index = ~0;
12549 u32 ip6_table_index = ~0;
12550 u32 other_table_index = ~0;
12554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12556 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12557 sw_if_index_set = 1;
12558 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12559 sw_if_index_set = 1;
12560 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12562 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12564 else if (unformat (i, "other-table %d", &other_table_index))
12566 else if (unformat (i, "is-input %d", &is_input))
12570 clib_warning ("parse error '%U'", format_unformat_error, i);
12575 if (sw_if_index_set == 0)
12577 errmsg ("missing interface name or sw_if_index");
12582 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12584 mp->sw_if_index = ntohl (sw_if_index);
12585 mp->ip4_table_index = ntohl (ip4_table_index);
12586 mp->ip6_table_index = ntohl (ip6_table_index);
12587 mp->other_table_index = ntohl (other_table_index);
12588 mp->is_input = (u8) is_input;
12596 api_set_ipfix_exporter (vat_main_t * vam)
12598 unformat_input_t *i = vam->input;
12599 vl_api_set_ipfix_exporter_t *mp;
12600 ip4_address_t collector_address;
12601 u8 collector_address_set = 0;
12602 u32 collector_port = ~0;
12603 ip4_address_t src_address;
12604 u8 src_address_set = 0;
12607 u32 template_interval = ~0;
12608 u8 udp_checksum = 0;
12611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12613 if (unformat (i, "collector_address %U", unformat_ip4_address,
12614 &collector_address))
12615 collector_address_set = 1;
12616 else if (unformat (i, "collector_port %d", &collector_port))
12618 else if (unformat (i, "src_address %U", unformat_ip4_address,
12620 src_address_set = 1;
12621 else if (unformat (i, "vrf_id %d", &vrf_id))
12623 else if (unformat (i, "path_mtu %d", &path_mtu))
12625 else if (unformat (i, "template_interval %d", &template_interval))
12627 else if (unformat (i, "udp_checksum"))
12633 if (collector_address_set == 0)
12635 errmsg ("collector_address required");
12639 if (src_address_set == 0)
12641 errmsg ("src_address required");
12645 M (SET_IPFIX_EXPORTER, mp);
12647 memcpy (mp->collector_address, collector_address.data,
12648 sizeof (collector_address.data));
12649 mp->collector_port = htons ((u16) collector_port);
12650 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12651 mp->vrf_id = htonl (vrf_id);
12652 mp->path_mtu = htonl (path_mtu);
12653 mp->template_interval = htonl (template_interval);
12654 mp->udp_checksum = udp_checksum;
12662 api_set_ipfix_classify_stream (vat_main_t * vam)
12664 unformat_input_t *i = vam->input;
12665 vl_api_set_ipfix_classify_stream_t *mp;
12667 u32 src_port = UDP_DST_PORT_ipfix;
12670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12672 if (unformat (i, "domain %d", &domain_id))
12674 else if (unformat (i, "src_port %d", &src_port))
12678 errmsg ("unknown input `%U'", format_unformat_error, i);
12683 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12685 mp->domain_id = htonl (domain_id);
12686 mp->src_port = htons ((u16) src_port);
12694 api_ipfix_classify_table_add_del (vat_main_t * vam)
12696 unformat_input_t *i = vam->input;
12697 vl_api_ipfix_classify_table_add_del_t *mp;
12699 u32 classify_table_index = ~0;
12701 u8 transport_protocol = 255;
12704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12706 if (unformat (i, "add"))
12708 else if (unformat (i, "del"))
12710 else if (unformat (i, "table %d", &classify_table_index))
12712 else if (unformat (i, "ip4"))
12714 else if (unformat (i, "ip6"))
12716 else if (unformat (i, "tcp"))
12717 transport_protocol = 6;
12718 else if (unformat (i, "udp"))
12719 transport_protocol = 17;
12722 errmsg ("unknown input `%U'", format_unformat_error, i);
12729 errmsg ("expecting: add|del");
12732 if (classify_table_index == ~0)
12734 errmsg ("classifier table not specified");
12737 if (ip_version == 0)
12739 errmsg ("IP version not specified");
12743 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12745 mp->is_add = is_add;
12746 mp->table_id = htonl (classify_table_index);
12747 mp->ip_version = ip_version;
12748 mp->transport_protocol = transport_protocol;
12756 api_get_node_index (vat_main_t * vam)
12758 unformat_input_t *i = vam->input;
12759 vl_api_get_node_index_t *mp;
12763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12765 if (unformat (i, "node %s", &name))
12772 errmsg ("node name required");
12775 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12777 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12781 M (GET_NODE_INDEX, mp);
12782 clib_memcpy (mp->node_name, name, vec_len (name));
12791 api_get_next_index (vat_main_t * vam)
12793 unformat_input_t *i = vam->input;
12794 vl_api_get_next_index_t *mp;
12795 u8 *node_name = 0, *next_node_name = 0;
12798 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12800 if (unformat (i, "node-name %s", &node_name))
12802 else if (unformat (i, "next-node-name %s", &next_node_name))
12806 if (node_name == 0)
12808 errmsg ("node name required");
12811 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12813 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12817 if (next_node_name == 0)
12819 errmsg ("next node name required");
12822 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12824 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12828 M (GET_NEXT_INDEX, mp);
12829 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12830 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12831 vec_free (node_name);
12832 vec_free (next_node_name);
12840 api_add_node_next (vat_main_t * vam)
12842 unformat_input_t *i = vam->input;
12843 vl_api_add_node_next_t *mp;
12848 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12850 if (unformat (i, "node %s", &name))
12852 else if (unformat (i, "next %s", &next))
12859 errmsg ("node name required");
12862 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12864 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12869 errmsg ("next node required");
12872 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12874 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12878 M (ADD_NODE_NEXT, mp);
12879 clib_memcpy (mp->node_name, name, vec_len (name));
12880 clib_memcpy (mp->next_name, next, vec_len (next));
12890 api_l2tpv3_create_tunnel (vat_main_t * vam)
12892 unformat_input_t *i = vam->input;
12893 ip6_address_t client_address, our_address;
12894 int client_address_set = 0;
12895 int our_address_set = 0;
12896 u32 local_session_id = 0;
12897 u32 remote_session_id = 0;
12898 u64 local_cookie = 0;
12899 u64 remote_cookie = 0;
12900 u8 l2_sublayer_present = 0;
12901 vl_api_l2tpv3_create_tunnel_t *mp;
12904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12906 if (unformat (i, "client_address %U", unformat_ip6_address,
12908 client_address_set = 1;
12909 else if (unformat (i, "our_address %U", unformat_ip6_address,
12911 our_address_set = 1;
12912 else if (unformat (i, "local_session_id %d", &local_session_id))
12914 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12916 else if (unformat (i, "local_cookie %lld", &local_cookie))
12918 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12920 else if (unformat (i, "l2-sublayer-present"))
12921 l2_sublayer_present = 1;
12926 if (client_address_set == 0)
12928 errmsg ("client_address required");
12932 if (our_address_set == 0)
12934 errmsg ("our_address required");
12938 M (L2TPV3_CREATE_TUNNEL, mp);
12940 clib_memcpy (mp->client_address, client_address.as_u8,
12941 sizeof (mp->client_address));
12943 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12945 mp->local_session_id = ntohl (local_session_id);
12946 mp->remote_session_id = ntohl (remote_session_id);
12947 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12948 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12949 mp->l2_sublayer_present = l2_sublayer_present;
12958 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12960 unformat_input_t *i = vam->input;
12962 u8 sw_if_index_set = 0;
12963 u64 new_local_cookie = 0;
12964 u64 new_remote_cookie = 0;
12965 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12970 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12971 sw_if_index_set = 1;
12972 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12973 sw_if_index_set = 1;
12974 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12976 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12982 if (sw_if_index_set == 0)
12984 errmsg ("missing interface name or sw_if_index");
12988 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12990 mp->sw_if_index = ntohl (sw_if_index);
12991 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12992 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
13000 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
13002 unformat_input_t *i = vam->input;
13003 vl_api_l2tpv3_interface_enable_disable_t *mp;
13005 u8 sw_if_index_set = 0;
13006 u8 enable_disable = 1;
13009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13011 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13012 sw_if_index_set = 1;
13013 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13014 sw_if_index_set = 1;
13015 else if (unformat (i, "enable"))
13016 enable_disable = 1;
13017 else if (unformat (i, "disable"))
13018 enable_disable = 0;
13023 if (sw_if_index_set == 0)
13025 errmsg ("missing interface name or sw_if_index");
13029 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
13031 mp->sw_if_index = ntohl (sw_if_index);
13032 mp->enable_disable = enable_disable;
13040 api_l2tpv3_set_lookup_key (vat_main_t * vam)
13042 unformat_input_t *i = vam->input;
13043 vl_api_l2tpv3_set_lookup_key_t *mp;
13047 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13049 if (unformat (i, "lookup_v6_src"))
13050 key = L2T_LOOKUP_SRC_ADDRESS;
13051 else if (unformat (i, "lookup_v6_dst"))
13052 key = L2T_LOOKUP_DST_ADDRESS;
13053 else if (unformat (i, "lookup_session_id"))
13054 key = L2T_LOOKUP_SESSION_ID;
13059 if (key == (u8) ~ 0)
13061 errmsg ("l2tp session lookup key unset");
13065 M (L2TPV3_SET_LOOKUP_KEY, mp);
13074 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
13075 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13077 vat_main_t *vam = &vat_main;
13079 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
13080 format_ip6_address, mp->our_address,
13081 format_ip6_address, mp->client_address,
13082 clib_net_to_host_u32 (mp->sw_if_index));
13085 " local cookies %016llx %016llx remote cookie %016llx",
13086 clib_net_to_host_u64 (mp->local_cookie[0]),
13087 clib_net_to_host_u64 (mp->local_cookie[1]),
13088 clib_net_to_host_u64 (mp->remote_cookie));
13090 print (vam->ofp, " local session-id %d remote session-id %d",
13091 clib_net_to_host_u32 (mp->local_session_id),
13092 clib_net_to_host_u32 (mp->remote_session_id));
13094 print (vam->ofp, " l2 specific sublayer %s\n",
13095 mp->l2_sublayer_present ? "preset" : "absent");
13099 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
13100 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13102 vat_main_t *vam = &vat_main;
13103 vat_json_node_t *node = NULL;
13104 struct in6_addr addr;
13106 if (VAT_JSON_ARRAY != vam->json_tree.type)
13108 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13109 vat_json_init_array (&vam->json_tree);
13111 node = vat_json_array_add (&vam->json_tree);
13113 vat_json_init_object (node);
13115 clib_memcpy (&addr, mp->our_address, sizeof (addr));
13116 vat_json_object_add_ip6 (node, "our_address", addr);
13117 clib_memcpy (&addr, mp->client_address, sizeof (addr));
13118 vat_json_object_add_ip6 (node, "client_address", addr);
13120 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
13121 vat_json_init_array (lc);
13122 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
13123 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
13124 vat_json_object_add_uint (node, "remote_cookie",
13125 clib_net_to_host_u64 (mp->remote_cookie));
13127 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
13128 vat_json_object_add_uint (node, "local_session_id",
13129 clib_net_to_host_u32 (mp->local_session_id));
13130 vat_json_object_add_uint (node, "remote_session_id",
13131 clib_net_to_host_u32 (mp->remote_session_id));
13132 vat_json_object_add_string_copy (node, "l2_sublayer",
13133 mp->l2_sublayer_present ? (u8 *) "present"
13134 : (u8 *) "absent");
13138 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
13140 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
13141 vl_api_control_ping_t *mp_ping;
13144 /* Get list of l2tpv3-tunnel interfaces */
13145 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
13148 /* Use a control ping for synchronization */
13149 MPING (CONTROL_PING, mp_ping);
13157 static void vl_api_sw_interface_tap_details_t_handler
13158 (vl_api_sw_interface_tap_details_t * mp)
13160 vat_main_t *vam = &vat_main;
13162 print (vam->ofp, "%-16s %d",
13163 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
13166 static void vl_api_sw_interface_tap_details_t_handler_json
13167 (vl_api_sw_interface_tap_details_t * mp)
13169 vat_main_t *vam = &vat_main;
13170 vat_json_node_t *node = NULL;
13172 if (VAT_JSON_ARRAY != vam->json_tree.type)
13174 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13175 vat_json_init_array (&vam->json_tree);
13177 node = vat_json_array_add (&vam->json_tree);
13179 vat_json_init_object (node);
13180 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13181 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13185 api_sw_interface_tap_dump (vat_main_t * vam)
13187 vl_api_sw_interface_tap_dump_t *mp;
13188 vl_api_control_ping_t *mp_ping;
13191 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
13192 /* Get list of tap interfaces */
13193 M (SW_INTERFACE_TAP_DUMP, mp);
13196 /* Use a control ping for synchronization */
13197 MPING (CONTROL_PING, mp_ping);
13204 static void vl_api_sw_interface_tap_v2_details_t_handler
13205 (vl_api_sw_interface_tap_v2_details_t * mp)
13207 vat_main_t *vam = &vat_main;
13209 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
13210 mp->host_ip4_prefix_len);
13211 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
13212 mp->host_ip6_prefix_len);
13215 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
13216 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
13217 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
13218 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
13219 mp->host_bridge, ip4, ip6);
13225 static void vl_api_sw_interface_tap_v2_details_t_handler_json
13226 (vl_api_sw_interface_tap_v2_details_t * mp)
13228 vat_main_t *vam = &vat_main;
13229 vat_json_node_t *node = NULL;
13231 if (VAT_JSON_ARRAY != vam->json_tree.type)
13233 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13234 vat_json_init_array (&vam->json_tree);
13236 node = vat_json_array_add (&vam->json_tree);
13238 vat_json_init_object (node);
13239 vat_json_object_add_uint (node, "id", ntohl (mp->id));
13240 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13241 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13242 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
13243 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
13244 vat_json_object_add_string_copy (node, "host_mac_addr",
13245 format (0, "%U", format_ethernet_address,
13246 &mp->host_mac_addr));
13247 vat_json_object_add_string_copy (node, "host_namespace",
13248 mp->host_namespace);
13249 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
13250 vat_json_object_add_string_copy (node, "host_ip4_addr",
13251 format (0, "%U/%d", format_ip4_address,
13253 mp->host_ip4_prefix_len));
13254 vat_json_object_add_string_copy (node, "host_ip6_addr",
13255 format (0, "%U/%d", format_ip6_address,
13257 mp->host_ip6_prefix_len));
13262 api_sw_interface_tap_v2_dump (vat_main_t * vam)
13264 vl_api_sw_interface_tap_v2_dump_t *mp;
13265 vl_api_control_ping_t *mp_ping;
13269 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
13270 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
13271 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
13274 /* Get list of tap interfaces */
13275 M (SW_INTERFACE_TAP_V2_DUMP, mp);
13278 /* Use a control ping for synchronization */
13279 MPING (CONTROL_PING, mp_ping);
13287 api_vxlan_offload_rx (vat_main_t * vam)
13289 unformat_input_t *line_input = vam->input;
13290 vl_api_vxlan_offload_rx_t *mp;
13291 u32 hw_if_index = ~0, rx_if_index = ~0;
13295 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13297 if (unformat (line_input, "del"))
13299 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
13302 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
13304 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
13307 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
13311 errmsg ("parse error '%U'", format_unformat_error, line_input);
13316 if (hw_if_index == ~0)
13318 errmsg ("no hw interface");
13322 if (rx_if_index == ~0)
13324 errmsg ("no rx tunnel");
13328 M (VXLAN_OFFLOAD_RX, mp);
13330 mp->hw_if_index = ntohl (hw_if_index);
13331 mp->sw_if_index = ntohl (rx_if_index);
13332 mp->enable = is_add;
13339 static uword unformat_vxlan_decap_next
13340 (unformat_input_t * input, va_list * args)
13342 u32 *result = va_arg (*args, u32 *);
13345 if (unformat (input, "l2"))
13346 *result = VXLAN_INPUT_NEXT_L2_INPUT;
13347 else if (unformat (input, "%d", &tmp))
13355 api_vxlan_add_del_tunnel (vat_main_t * vam)
13357 unformat_input_t *line_input = vam->input;
13358 vl_api_vxlan_add_del_tunnel_t *mp;
13359 ip46_address_t src, dst;
13361 u8 ipv4_set = 0, ipv6_set = 0;
13366 u32 mcast_sw_if_index = ~0;
13367 u32 encap_vrf_id = 0;
13368 u32 decap_next_index = ~0;
13372 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13373 clib_memset (&src, 0, sizeof src);
13374 clib_memset (&dst, 0, sizeof dst);
13376 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13378 if (unformat (line_input, "del"))
13380 else if (unformat (line_input, "instance %d", &instance))
13383 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13389 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13395 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13401 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13406 else if (unformat (line_input, "group %U %U",
13407 unformat_ip4_address, &dst.ip4,
13408 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13410 grp_set = dst_set = 1;
13413 else if (unformat (line_input, "group %U",
13414 unformat_ip4_address, &dst.ip4))
13416 grp_set = dst_set = 1;
13419 else if (unformat (line_input, "group %U %U",
13420 unformat_ip6_address, &dst.ip6,
13421 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13423 grp_set = dst_set = 1;
13426 else if (unformat (line_input, "group %U",
13427 unformat_ip6_address, &dst.ip6))
13429 grp_set = dst_set = 1;
13433 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13435 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13437 else if (unformat (line_input, "decap-next %U",
13438 unformat_vxlan_decap_next, &decap_next_index))
13440 else if (unformat (line_input, "vni %d", &vni))
13444 errmsg ("parse error '%U'", format_unformat_error, line_input);
13451 errmsg ("tunnel src address not specified");
13456 errmsg ("tunnel dst address not specified");
13460 if (grp_set && !ip46_address_is_multicast (&dst))
13462 errmsg ("tunnel group address not multicast");
13465 if (grp_set && mcast_sw_if_index == ~0)
13467 errmsg ("tunnel nonexistent multicast device");
13470 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13472 errmsg ("tunnel dst address must be unicast");
13477 if (ipv4_set && ipv6_set)
13479 errmsg ("both IPv4 and IPv6 addresses specified");
13483 if ((vni == 0) || (vni >> 24))
13485 errmsg ("vni not specified or out of range");
13489 M (VXLAN_ADD_DEL_TUNNEL, mp);
13493 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13494 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13498 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13499 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13502 mp->instance = htonl (instance);
13503 mp->encap_vrf_id = ntohl (encap_vrf_id);
13504 mp->decap_next_index = ntohl (decap_next_index);
13505 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13506 mp->vni = ntohl (vni);
13507 mp->is_add = is_add;
13508 mp->is_ipv6 = ipv6_set;
13515 static void vl_api_vxlan_tunnel_details_t_handler
13516 (vl_api_vxlan_tunnel_details_t * mp)
13518 vat_main_t *vam = &vat_main;
13519 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13520 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13522 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13523 ntohl (mp->sw_if_index),
13524 ntohl (mp->instance),
13525 format_ip46_address, &src, IP46_TYPE_ANY,
13526 format_ip46_address, &dst, IP46_TYPE_ANY,
13527 ntohl (mp->encap_vrf_id),
13528 ntohl (mp->decap_next_index), ntohl (mp->vni),
13529 ntohl (mp->mcast_sw_if_index));
13532 static void vl_api_vxlan_tunnel_details_t_handler_json
13533 (vl_api_vxlan_tunnel_details_t * mp)
13535 vat_main_t *vam = &vat_main;
13536 vat_json_node_t *node = NULL;
13538 if (VAT_JSON_ARRAY != vam->json_tree.type)
13540 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13541 vat_json_init_array (&vam->json_tree);
13543 node = vat_json_array_add (&vam->json_tree);
13545 vat_json_init_object (node);
13546 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13548 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13552 struct in6_addr ip6;
13554 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13555 vat_json_object_add_ip6 (node, "src_address", ip6);
13556 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13557 vat_json_object_add_ip6 (node, "dst_address", ip6);
13561 struct in_addr ip4;
13563 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13564 vat_json_object_add_ip4 (node, "src_address", ip4);
13565 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13566 vat_json_object_add_ip4 (node, "dst_address", ip4);
13568 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13569 vat_json_object_add_uint (node, "decap_next_index",
13570 ntohl (mp->decap_next_index));
13571 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13572 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13573 vat_json_object_add_uint (node, "mcast_sw_if_index",
13574 ntohl (mp->mcast_sw_if_index));
13578 api_vxlan_tunnel_dump (vat_main_t * vam)
13580 unformat_input_t *i = vam->input;
13581 vl_api_vxlan_tunnel_dump_t *mp;
13582 vl_api_control_ping_t *mp_ping;
13584 u8 sw_if_index_set = 0;
13587 /* Parse args required to build the message */
13588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13590 if (unformat (i, "sw_if_index %d", &sw_if_index))
13591 sw_if_index_set = 1;
13596 if (sw_if_index_set == 0)
13601 if (!vam->json_output)
13603 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13604 "sw_if_index", "instance", "src_address", "dst_address",
13605 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13608 /* Get list of vxlan-tunnel interfaces */
13609 M (VXLAN_TUNNEL_DUMP, mp);
13611 mp->sw_if_index = htonl (sw_if_index);
13615 /* Use a control ping for synchronization */
13616 MPING (CONTROL_PING, mp_ping);
13623 static uword unformat_geneve_decap_next
13624 (unformat_input_t * input, va_list * args)
13626 u32 *result = va_arg (*args, u32 *);
13629 if (unformat (input, "l2"))
13630 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13631 else if (unformat (input, "%d", &tmp))
13639 api_geneve_add_del_tunnel (vat_main_t * vam)
13641 unformat_input_t *line_input = vam->input;
13642 vl_api_geneve_add_del_tunnel_t *mp;
13643 ip46_address_t src, dst;
13645 u8 ipv4_set = 0, ipv6_set = 0;
13649 u32 mcast_sw_if_index = ~0;
13650 u32 encap_vrf_id = 0;
13651 u32 decap_next_index = ~0;
13655 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13656 clib_memset (&src, 0, sizeof src);
13657 clib_memset (&dst, 0, sizeof dst);
13659 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13661 if (unformat (line_input, "del"))
13664 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13670 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13676 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13682 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13687 else if (unformat (line_input, "group %U %U",
13688 unformat_ip4_address, &dst.ip4,
13689 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13691 grp_set = dst_set = 1;
13694 else if (unformat (line_input, "group %U",
13695 unformat_ip4_address, &dst.ip4))
13697 grp_set = dst_set = 1;
13700 else if (unformat (line_input, "group %U %U",
13701 unformat_ip6_address, &dst.ip6,
13702 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13704 grp_set = dst_set = 1;
13707 else if (unformat (line_input, "group %U",
13708 unformat_ip6_address, &dst.ip6))
13710 grp_set = dst_set = 1;
13714 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13716 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13718 else if (unformat (line_input, "decap-next %U",
13719 unformat_geneve_decap_next, &decap_next_index))
13721 else if (unformat (line_input, "vni %d", &vni))
13725 errmsg ("parse error '%U'", format_unformat_error, line_input);
13732 errmsg ("tunnel src address not specified");
13737 errmsg ("tunnel dst address not specified");
13741 if (grp_set && !ip46_address_is_multicast (&dst))
13743 errmsg ("tunnel group address not multicast");
13746 if (grp_set && mcast_sw_if_index == ~0)
13748 errmsg ("tunnel nonexistent multicast device");
13751 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13753 errmsg ("tunnel dst address must be unicast");
13758 if (ipv4_set && ipv6_set)
13760 errmsg ("both IPv4 and IPv6 addresses specified");
13764 if ((vni == 0) || (vni >> 24))
13766 errmsg ("vni not specified or out of range");
13770 M (GENEVE_ADD_DEL_TUNNEL, mp);
13774 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13775 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13779 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13780 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13782 mp->encap_vrf_id = ntohl (encap_vrf_id);
13783 mp->decap_next_index = ntohl (decap_next_index);
13784 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13785 mp->vni = ntohl (vni);
13786 mp->is_add = is_add;
13787 mp->is_ipv6 = ipv6_set;
13794 static void vl_api_geneve_tunnel_details_t_handler
13795 (vl_api_geneve_tunnel_details_t * mp)
13797 vat_main_t *vam = &vat_main;
13798 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13799 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13801 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13802 ntohl (mp->sw_if_index),
13803 format_ip46_address, &src, IP46_TYPE_ANY,
13804 format_ip46_address, &dst, IP46_TYPE_ANY,
13805 ntohl (mp->encap_vrf_id),
13806 ntohl (mp->decap_next_index), ntohl (mp->vni),
13807 ntohl (mp->mcast_sw_if_index));
13810 static void vl_api_geneve_tunnel_details_t_handler_json
13811 (vl_api_geneve_tunnel_details_t * mp)
13813 vat_main_t *vam = &vat_main;
13814 vat_json_node_t *node = NULL;
13816 if (VAT_JSON_ARRAY != vam->json_tree.type)
13818 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13819 vat_json_init_array (&vam->json_tree);
13821 node = vat_json_array_add (&vam->json_tree);
13823 vat_json_init_object (node);
13824 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13827 struct in6_addr ip6;
13829 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13830 vat_json_object_add_ip6 (node, "src_address", ip6);
13831 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13832 vat_json_object_add_ip6 (node, "dst_address", ip6);
13836 struct in_addr ip4;
13838 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13839 vat_json_object_add_ip4 (node, "src_address", ip4);
13840 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13841 vat_json_object_add_ip4 (node, "dst_address", ip4);
13843 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13844 vat_json_object_add_uint (node, "decap_next_index",
13845 ntohl (mp->decap_next_index));
13846 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13847 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13848 vat_json_object_add_uint (node, "mcast_sw_if_index",
13849 ntohl (mp->mcast_sw_if_index));
13853 api_geneve_tunnel_dump (vat_main_t * vam)
13855 unformat_input_t *i = vam->input;
13856 vl_api_geneve_tunnel_dump_t *mp;
13857 vl_api_control_ping_t *mp_ping;
13859 u8 sw_if_index_set = 0;
13862 /* Parse args required to build the message */
13863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13865 if (unformat (i, "sw_if_index %d", &sw_if_index))
13866 sw_if_index_set = 1;
13871 if (sw_if_index_set == 0)
13876 if (!vam->json_output)
13878 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13879 "sw_if_index", "local_address", "remote_address",
13880 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13883 /* Get list of geneve-tunnel interfaces */
13884 M (GENEVE_TUNNEL_DUMP, mp);
13886 mp->sw_if_index = htonl (sw_if_index);
13890 /* Use a control ping for synchronization */
13891 M (CONTROL_PING, mp_ping);
13899 api_gre_add_del_tunnel (vat_main_t * vam)
13901 unformat_input_t *line_input = vam->input;
13902 vl_api_gre_add_del_tunnel_t *mp;
13903 ip4_address_t src4, dst4;
13904 ip6_address_t src6, dst6;
13908 u8 t_type = GRE_TUNNEL_TYPE_L3;
13911 u32 outer_fib_id = 0;
13912 u32 session_id = 0;
13916 clib_memset (&src4, 0, sizeof src4);
13917 clib_memset (&dst4, 0, sizeof dst4);
13918 clib_memset (&src6, 0, sizeof src6);
13919 clib_memset (&dst6, 0, sizeof dst6);
13921 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13923 if (unformat (line_input, "del"))
13925 else if (unformat (line_input, "instance %d", &instance))
13927 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13932 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13937 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13942 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13947 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13949 else if (unformat (line_input, "teb"))
13950 t_type = GRE_TUNNEL_TYPE_TEB;
13951 else if (unformat (line_input, "erspan %d", &session_id))
13952 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13955 errmsg ("parse error '%U'", format_unformat_error, line_input);
13962 errmsg ("tunnel src address not specified");
13967 errmsg ("tunnel dst address not specified");
13970 if (ipv4_set && ipv6_set)
13972 errmsg ("both IPv4 and IPv6 addresses specified");
13977 M (GRE_ADD_DEL_TUNNEL, mp);
13981 clib_memcpy (&mp->src_address, &src4, 4);
13982 clib_memcpy (&mp->dst_address, &dst4, 4);
13986 clib_memcpy (&mp->src_address, &src6, 16);
13987 clib_memcpy (&mp->dst_address, &dst6, 16);
13989 mp->instance = htonl (instance);
13990 mp->outer_fib_id = htonl (outer_fib_id);
13991 mp->is_add = is_add;
13992 mp->session_id = htons ((u16) session_id);
13993 mp->tunnel_type = t_type;
13994 mp->is_ipv6 = ipv6_set;
14001 static void vl_api_gre_tunnel_details_t_handler
14002 (vl_api_gre_tunnel_details_t * mp)
14004 vat_main_t *vam = &vat_main;
14005 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
14006 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
14008 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
14009 ntohl (mp->sw_if_index),
14010 ntohl (mp->instance),
14011 format_ip46_address, &src, IP46_TYPE_ANY,
14012 format_ip46_address, &dst, IP46_TYPE_ANY,
14013 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
14016 static void vl_api_gre_tunnel_details_t_handler_json
14017 (vl_api_gre_tunnel_details_t * mp)
14019 vat_main_t *vam = &vat_main;
14020 vat_json_node_t *node = NULL;
14021 struct in_addr ip4;
14022 struct in6_addr ip6;
14024 if (VAT_JSON_ARRAY != vam->json_tree.type)
14026 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14027 vat_json_init_array (&vam->json_tree);
14029 node = vat_json_array_add (&vam->json_tree);
14031 vat_json_init_object (node);
14032 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14033 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
14036 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
14037 vat_json_object_add_ip4 (node, "src_address", ip4);
14038 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
14039 vat_json_object_add_ip4 (node, "dst_address", ip4);
14043 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
14044 vat_json_object_add_ip6 (node, "src_address", ip6);
14045 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
14046 vat_json_object_add_ip6 (node, "dst_address", ip6);
14048 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
14049 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
14050 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
14051 vat_json_object_add_uint (node, "session_id", mp->session_id);
14055 api_gre_tunnel_dump (vat_main_t * vam)
14057 unformat_input_t *i = vam->input;
14058 vl_api_gre_tunnel_dump_t *mp;
14059 vl_api_control_ping_t *mp_ping;
14061 u8 sw_if_index_set = 0;
14064 /* Parse args required to build the message */
14065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14067 if (unformat (i, "sw_if_index %d", &sw_if_index))
14068 sw_if_index_set = 1;
14073 if (sw_if_index_set == 0)
14078 if (!vam->json_output)
14080 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
14081 "sw_if_index", "instance", "src_address", "dst_address",
14082 "tunnel_type", "outer_fib_id", "session_id");
14085 /* Get list of gre-tunnel interfaces */
14086 M (GRE_TUNNEL_DUMP, mp);
14088 mp->sw_if_index = htonl (sw_if_index);
14092 /* Use a control ping for synchronization */
14093 MPING (CONTROL_PING, mp_ping);
14101 api_l2_fib_clear_table (vat_main_t * vam)
14103 // unformat_input_t * i = vam->input;
14104 vl_api_l2_fib_clear_table_t *mp;
14107 M (L2_FIB_CLEAR_TABLE, mp);
14115 api_l2_interface_efp_filter (vat_main_t * vam)
14117 unformat_input_t *i = vam->input;
14118 vl_api_l2_interface_efp_filter_t *mp;
14121 u8 sw_if_index_set = 0;
14124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14126 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14127 sw_if_index_set = 1;
14128 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14129 sw_if_index_set = 1;
14130 else if (unformat (i, "enable"))
14132 else if (unformat (i, "disable"))
14136 clib_warning ("parse error '%U'", format_unformat_error, i);
14141 if (sw_if_index_set == 0)
14143 errmsg ("missing sw_if_index");
14147 M (L2_INTERFACE_EFP_FILTER, mp);
14149 mp->sw_if_index = ntohl (sw_if_index);
14150 mp->enable_disable = enable;
14157 #define foreach_vtr_op \
14158 _("disable", L2_VTR_DISABLED) \
14159 _("push-1", L2_VTR_PUSH_1) \
14160 _("push-2", L2_VTR_PUSH_2) \
14161 _("pop-1", L2_VTR_POP_1) \
14162 _("pop-2", L2_VTR_POP_2) \
14163 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
14164 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
14165 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
14166 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
14169 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
14171 unformat_input_t *i = vam->input;
14172 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
14174 u8 sw_if_index_set = 0;
14177 u32 push_dot1q = 1;
14182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14184 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14185 sw_if_index_set = 1;
14186 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14187 sw_if_index_set = 1;
14188 else if (unformat (i, "vtr_op %d", &vtr_op))
14190 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
14193 else if (unformat (i, "push_dot1q %d", &push_dot1q))
14195 else if (unformat (i, "tag1 %d", &tag1))
14197 else if (unformat (i, "tag2 %d", &tag2))
14201 clib_warning ("parse error '%U'", format_unformat_error, i);
14206 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
14208 errmsg ("missing vtr operation or sw_if_index");
14212 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
14213 mp->sw_if_index = ntohl (sw_if_index);
14214 mp->vtr_op = ntohl (vtr_op);
14215 mp->push_dot1q = ntohl (push_dot1q);
14216 mp->tag1 = ntohl (tag1);
14217 mp->tag2 = ntohl (tag2);
14225 api_create_vhost_user_if (vat_main_t * vam)
14227 unformat_input_t *i = vam->input;
14228 vl_api_create_vhost_user_if_t *mp;
14231 u8 file_name_set = 0;
14232 u32 custom_dev_instance = ~0;
14234 u8 use_custom_mac = 0;
14235 u8 disable_mrg_rxbuf = 0;
14236 u8 disable_indirect_desc = 0;
14240 /* Shut up coverity */
14241 clib_memset (hwaddr, 0, sizeof (hwaddr));
14243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14245 if (unformat (i, "socket %s", &file_name))
14249 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14251 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
14252 use_custom_mac = 1;
14253 else if (unformat (i, "server"))
14255 else if (unformat (i, "disable_mrg_rxbuf"))
14256 disable_mrg_rxbuf = 1;
14257 else if (unformat (i, "disable_indirect_desc"))
14258 disable_indirect_desc = 1;
14259 else if (unformat (i, "tag %s", &tag))
14265 if (file_name_set == 0)
14267 errmsg ("missing socket file name");
14271 if (vec_len (file_name) > 255)
14273 errmsg ("socket file name too long");
14276 vec_add1 (file_name, 0);
14278 M (CREATE_VHOST_USER_IF, mp);
14280 mp->is_server = is_server;
14281 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
14282 mp->disable_indirect_desc = disable_indirect_desc;
14283 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14284 vec_free (file_name);
14285 if (custom_dev_instance != ~0)
14288 mp->custom_dev_instance = ntohl (custom_dev_instance);
14291 mp->use_custom_mac = use_custom_mac;
14292 clib_memcpy (mp->mac_address, hwaddr, 6);
14294 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
14303 api_modify_vhost_user_if (vat_main_t * vam)
14305 unformat_input_t *i = vam->input;
14306 vl_api_modify_vhost_user_if_t *mp;
14309 u8 file_name_set = 0;
14310 u32 custom_dev_instance = ~0;
14311 u8 sw_if_index_set = 0;
14312 u32 sw_if_index = (u32) ~ 0;
14315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14317 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14318 sw_if_index_set = 1;
14319 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14320 sw_if_index_set = 1;
14321 else if (unformat (i, "socket %s", &file_name))
14325 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14327 else if (unformat (i, "server"))
14333 if (sw_if_index_set == 0)
14335 errmsg ("missing sw_if_index or interface name");
14339 if (file_name_set == 0)
14341 errmsg ("missing socket file name");
14345 if (vec_len (file_name) > 255)
14347 errmsg ("socket file name too long");
14350 vec_add1 (file_name, 0);
14352 M (MODIFY_VHOST_USER_IF, mp);
14354 mp->sw_if_index = ntohl (sw_if_index);
14355 mp->is_server = is_server;
14356 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14357 vec_free (file_name);
14358 if (custom_dev_instance != ~0)
14361 mp->custom_dev_instance = ntohl (custom_dev_instance);
14370 api_delete_vhost_user_if (vat_main_t * vam)
14372 unformat_input_t *i = vam->input;
14373 vl_api_delete_vhost_user_if_t *mp;
14374 u32 sw_if_index = ~0;
14375 u8 sw_if_index_set = 0;
14378 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14380 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14381 sw_if_index_set = 1;
14382 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14383 sw_if_index_set = 1;
14388 if (sw_if_index_set == 0)
14390 errmsg ("missing sw_if_index or interface name");
14395 M (DELETE_VHOST_USER_IF, mp);
14397 mp->sw_if_index = ntohl (sw_if_index);
14404 static void vl_api_sw_interface_vhost_user_details_t_handler
14405 (vl_api_sw_interface_vhost_user_details_t * mp)
14407 vat_main_t *vam = &vat_main;
14409 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14410 (char *) mp->interface_name,
14411 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14412 clib_net_to_host_u64 (mp->features), mp->is_server,
14413 ntohl (mp->num_regions), (char *) mp->sock_filename);
14414 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14417 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14418 (vl_api_sw_interface_vhost_user_details_t * mp)
14420 vat_main_t *vam = &vat_main;
14421 vat_json_node_t *node = NULL;
14423 if (VAT_JSON_ARRAY != vam->json_tree.type)
14425 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14426 vat_json_init_array (&vam->json_tree);
14428 node = vat_json_array_add (&vam->json_tree);
14430 vat_json_init_object (node);
14431 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14432 vat_json_object_add_string_copy (node, "interface_name",
14433 mp->interface_name);
14434 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14435 ntohl (mp->virtio_net_hdr_sz));
14436 vat_json_object_add_uint (node, "features",
14437 clib_net_to_host_u64 (mp->features));
14438 vat_json_object_add_uint (node, "is_server", mp->is_server);
14439 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14440 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14441 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14445 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14447 vl_api_sw_interface_vhost_user_dump_t *mp;
14448 vl_api_control_ping_t *mp_ping;
14451 "Interface name idx hdr_sz features server regions filename");
14453 /* Get list of vhost-user interfaces */
14454 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14457 /* Use a control ping for synchronization */
14458 MPING (CONTROL_PING, mp_ping);
14466 api_show_version (vat_main_t * vam)
14468 vl_api_show_version_t *mp;
14471 M (SHOW_VERSION, mp);
14480 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14482 unformat_input_t *line_input = vam->input;
14483 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14484 ip4_address_t local4, remote4;
14485 ip6_address_t local6, remote6;
14487 u8 ipv4_set = 0, ipv6_set = 0;
14491 u32 mcast_sw_if_index = ~0;
14492 u32 encap_vrf_id = 0;
14493 u32 decap_vrf_id = 0;
14499 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14500 clib_memset (&local4, 0, sizeof local4);
14501 clib_memset (&remote4, 0, sizeof remote4);
14502 clib_memset (&local6, 0, sizeof local6);
14503 clib_memset (&remote6, 0, sizeof remote6);
14505 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14507 if (unformat (line_input, "del"))
14509 else if (unformat (line_input, "local %U",
14510 unformat_ip4_address, &local4))
14515 else if (unformat (line_input, "remote %U",
14516 unformat_ip4_address, &remote4))
14521 else if (unformat (line_input, "local %U",
14522 unformat_ip6_address, &local6))
14527 else if (unformat (line_input, "remote %U",
14528 unformat_ip6_address, &remote6))
14533 else if (unformat (line_input, "group %U %U",
14534 unformat_ip4_address, &remote4,
14535 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14537 grp_set = remote_set = 1;
14540 else if (unformat (line_input, "group %U",
14541 unformat_ip4_address, &remote4))
14543 grp_set = remote_set = 1;
14546 else if (unformat (line_input, "group %U %U",
14547 unformat_ip6_address, &remote6,
14548 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14550 grp_set = remote_set = 1;
14553 else if (unformat (line_input, "group %U",
14554 unformat_ip6_address, &remote6))
14556 grp_set = remote_set = 1;
14560 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14562 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14564 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14566 else if (unformat (line_input, "vni %d", &vni))
14568 else if (unformat (line_input, "next-ip4"))
14570 else if (unformat (line_input, "next-ip6"))
14572 else if (unformat (line_input, "next-ethernet"))
14574 else if (unformat (line_input, "next-nsh"))
14578 errmsg ("parse error '%U'", format_unformat_error, line_input);
14583 if (local_set == 0)
14585 errmsg ("tunnel local address not specified");
14588 if (remote_set == 0)
14590 errmsg ("tunnel remote address not specified");
14593 if (grp_set && mcast_sw_if_index == ~0)
14595 errmsg ("tunnel nonexistent multicast device");
14598 if (ipv4_set && ipv6_set)
14600 errmsg ("both IPv4 and IPv6 addresses specified");
14606 errmsg ("vni not specified");
14610 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14615 clib_memcpy (&mp->local, &local6, sizeof (local6));
14616 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14620 clib_memcpy (&mp->local, &local4, sizeof (local4));
14621 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14624 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14625 mp->encap_vrf_id = ntohl (encap_vrf_id);
14626 mp->decap_vrf_id = ntohl (decap_vrf_id);
14627 mp->protocol = protocol;
14628 mp->vni = ntohl (vni);
14629 mp->is_add = is_add;
14630 mp->is_ipv6 = ipv6_set;
14637 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14638 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14640 vat_main_t *vam = &vat_main;
14641 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14642 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14644 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14645 ntohl (mp->sw_if_index),
14646 format_ip46_address, &local, IP46_TYPE_ANY,
14647 format_ip46_address, &remote, IP46_TYPE_ANY,
14648 ntohl (mp->vni), mp->protocol,
14649 ntohl (mp->mcast_sw_if_index),
14650 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14654 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14655 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14657 vat_main_t *vam = &vat_main;
14658 vat_json_node_t *node = NULL;
14659 struct in_addr ip4;
14660 struct in6_addr ip6;
14662 if (VAT_JSON_ARRAY != vam->json_tree.type)
14664 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14665 vat_json_init_array (&vam->json_tree);
14667 node = vat_json_array_add (&vam->json_tree);
14669 vat_json_init_object (node);
14670 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14673 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14674 vat_json_object_add_ip6 (node, "local", ip6);
14675 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14676 vat_json_object_add_ip6 (node, "remote", ip6);
14680 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14681 vat_json_object_add_ip4 (node, "local", ip4);
14682 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14683 vat_json_object_add_ip4 (node, "remote", ip4);
14685 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14686 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14687 vat_json_object_add_uint (node, "mcast_sw_if_index",
14688 ntohl (mp->mcast_sw_if_index));
14689 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14690 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14691 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14695 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14697 unformat_input_t *i = vam->input;
14698 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14699 vl_api_control_ping_t *mp_ping;
14701 u8 sw_if_index_set = 0;
14704 /* Parse args required to build the message */
14705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14707 if (unformat (i, "sw_if_index %d", &sw_if_index))
14708 sw_if_index_set = 1;
14713 if (sw_if_index_set == 0)
14718 if (!vam->json_output)
14720 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14721 "sw_if_index", "local", "remote", "vni",
14722 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14725 /* Get list of vxlan-tunnel interfaces */
14726 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14728 mp->sw_if_index = htonl (sw_if_index);
14732 /* Use a control ping for synchronization */
14733 MPING (CONTROL_PING, mp_ping);
14740 static void vl_api_l2_fib_table_details_t_handler
14741 (vl_api_l2_fib_table_details_t * mp)
14743 vat_main_t *vam = &vat_main;
14745 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14747 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14748 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14752 static void vl_api_l2_fib_table_details_t_handler_json
14753 (vl_api_l2_fib_table_details_t * mp)
14755 vat_main_t *vam = &vat_main;
14756 vat_json_node_t *node = NULL;
14758 if (VAT_JSON_ARRAY != vam->json_tree.type)
14760 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14761 vat_json_init_array (&vam->json_tree);
14763 node = vat_json_array_add (&vam->json_tree);
14765 vat_json_init_object (node);
14766 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14767 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14768 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14769 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14770 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14771 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14775 api_l2_fib_table_dump (vat_main_t * vam)
14777 unformat_input_t *i = vam->input;
14778 vl_api_l2_fib_table_dump_t *mp;
14779 vl_api_control_ping_t *mp_ping;
14784 /* Parse args required to build the message */
14785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14787 if (unformat (i, "bd_id %d", &bd_id))
14793 if (bd_id_set == 0)
14795 errmsg ("missing bridge domain");
14799 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14801 /* Get list of l2 fib entries */
14802 M (L2_FIB_TABLE_DUMP, mp);
14804 mp->bd_id = ntohl (bd_id);
14807 /* Use a control ping for synchronization */
14808 MPING (CONTROL_PING, mp_ping);
14817 api_interface_name_renumber (vat_main_t * vam)
14819 unformat_input_t *line_input = vam->input;
14820 vl_api_interface_name_renumber_t *mp;
14821 u32 sw_if_index = ~0;
14822 u32 new_show_dev_instance = ~0;
14825 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14827 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14830 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14832 else if (unformat (line_input, "new_show_dev_instance %d",
14833 &new_show_dev_instance))
14839 if (sw_if_index == ~0)
14841 errmsg ("missing interface name or sw_if_index");
14845 if (new_show_dev_instance == ~0)
14847 errmsg ("missing new_show_dev_instance");
14851 M (INTERFACE_NAME_RENUMBER, mp);
14853 mp->sw_if_index = ntohl (sw_if_index);
14854 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14862 api_ip_probe_neighbor (vat_main_t * vam)
14864 unformat_input_t *i = vam->input;
14865 vl_api_ip_probe_neighbor_t *mp;
14873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14875 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14877 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14879 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14881 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14892 errmsg ("missing interface");
14898 errmsg ("missing addresses");
14902 M (IP_PROBE_NEIGHBOR, mp);
14904 mp->sw_if_index = ntohl (sw_if_index);
14905 mp->is_ipv6 = is_ipv6;
14906 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14914 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14916 unformat_input_t *i = vam->input;
14917 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14918 u8 mode = IP_SCAN_V46_NEIGHBORS;
14919 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14924 if (unformat (i, "ip4"))
14925 mode = IP_SCAN_V4_NEIGHBORS;
14926 else if (unformat (i, "ip6"))
14927 mode = IP_SCAN_V6_NEIGHBORS;
14928 if (unformat (i, "both"))
14929 mode = IP_SCAN_V46_NEIGHBORS;
14930 else if (unformat (i, "disable"))
14931 mode = IP_SCAN_DISABLED;
14932 else if (unformat (i, "interval %d", &interval))
14934 else if (unformat (i, "max-time %d", &time))
14936 else if (unformat (i, "max-update %d", &update))
14938 else if (unformat (i, "delay %d", &delay))
14940 else if (unformat (i, "stale %d", &stale))
14946 if (interval > 255)
14948 errmsg ("interval cannot exceed 255 minutes.");
14953 errmsg ("max-time cannot exceed 255 usec.");
14958 errmsg ("max-update cannot exceed 255.");
14963 errmsg ("delay cannot exceed 255 msec.");
14968 errmsg ("stale cannot exceed 255 minutes.");
14972 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14974 mp->scan_interval = interval;
14975 mp->max_proc_time = time;
14976 mp->max_update = update;
14977 mp->scan_int_delay = delay;
14978 mp->stale_threshold = stale;
14986 api_want_ip4_arp_events (vat_main_t * vam)
14988 unformat_input_t *line_input = vam->input;
14989 vl_api_want_ip4_arp_events_t *mp;
14990 ip4_address_t address;
14991 int address_set = 0;
14992 u32 enable_disable = 1;
14995 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14997 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14999 else if (unformat (line_input, "del"))
15000 enable_disable = 0;
15005 if (address_set == 0)
15007 errmsg ("missing addresses");
15011 M (WANT_IP4_ARP_EVENTS, mp);
15012 mp->enable_disable = enable_disable;
15013 mp->pid = htonl (getpid ());
15014 mp->address = address.as_u32;
15022 api_want_ip6_nd_events (vat_main_t * vam)
15024 unformat_input_t *line_input = vam->input;
15025 vl_api_want_ip6_nd_events_t *mp;
15026 ip6_address_t address;
15027 int address_set = 0;
15028 u32 enable_disable = 1;
15031 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15033 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
15035 else if (unformat (line_input, "del"))
15036 enable_disable = 0;
15041 if (address_set == 0)
15043 errmsg ("missing addresses");
15047 M (WANT_IP6_ND_EVENTS, mp);
15048 mp->enable_disable = enable_disable;
15049 mp->pid = htonl (getpid ());
15050 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
15058 api_want_l2_macs_events (vat_main_t * vam)
15060 unformat_input_t *line_input = vam->input;
15061 vl_api_want_l2_macs_events_t *mp;
15062 u8 enable_disable = 1;
15063 u32 scan_delay = 0;
15064 u32 max_macs_in_event = 0;
15065 u32 learn_limit = 0;
15068 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15070 if (unformat (line_input, "learn-limit %d", &learn_limit))
15072 else if (unformat (line_input, "scan-delay %d", &scan_delay))
15074 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
15076 else if (unformat (line_input, "disable"))
15077 enable_disable = 0;
15082 M (WANT_L2_MACS_EVENTS, mp);
15083 mp->enable_disable = enable_disable;
15084 mp->pid = htonl (getpid ());
15085 mp->learn_limit = htonl (learn_limit);
15086 mp->scan_delay = (u8) scan_delay;
15087 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
15094 api_input_acl_set_interface (vat_main_t * vam)
15096 unformat_input_t *i = vam->input;
15097 vl_api_input_acl_set_interface_t *mp;
15099 int sw_if_index_set;
15100 u32 ip4_table_index = ~0;
15101 u32 ip6_table_index = ~0;
15102 u32 l2_table_index = ~0;
15106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15108 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15109 sw_if_index_set = 1;
15110 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15111 sw_if_index_set = 1;
15112 else if (unformat (i, "del"))
15114 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15116 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15118 else if (unformat (i, "l2-table %d", &l2_table_index))
15122 clib_warning ("parse error '%U'", format_unformat_error, i);
15127 if (sw_if_index_set == 0)
15129 errmsg ("missing interface name or sw_if_index");
15133 M (INPUT_ACL_SET_INTERFACE, mp);
15135 mp->sw_if_index = ntohl (sw_if_index);
15136 mp->ip4_table_index = ntohl (ip4_table_index);
15137 mp->ip6_table_index = ntohl (ip6_table_index);
15138 mp->l2_table_index = ntohl (l2_table_index);
15139 mp->is_add = is_add;
15147 api_output_acl_set_interface (vat_main_t * vam)
15149 unformat_input_t *i = vam->input;
15150 vl_api_output_acl_set_interface_t *mp;
15152 int sw_if_index_set;
15153 u32 ip4_table_index = ~0;
15154 u32 ip6_table_index = ~0;
15155 u32 l2_table_index = ~0;
15159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15161 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15162 sw_if_index_set = 1;
15163 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15164 sw_if_index_set = 1;
15165 else if (unformat (i, "del"))
15167 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15169 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15171 else if (unformat (i, "l2-table %d", &l2_table_index))
15175 clib_warning ("parse error '%U'", format_unformat_error, i);
15180 if (sw_if_index_set == 0)
15182 errmsg ("missing interface name or sw_if_index");
15186 M (OUTPUT_ACL_SET_INTERFACE, mp);
15188 mp->sw_if_index = ntohl (sw_if_index);
15189 mp->ip4_table_index = ntohl (ip4_table_index);
15190 mp->ip6_table_index = ntohl (ip6_table_index);
15191 mp->l2_table_index = ntohl (l2_table_index);
15192 mp->is_add = is_add;
15200 api_ip_address_dump (vat_main_t * vam)
15202 unformat_input_t *i = vam->input;
15203 vl_api_ip_address_dump_t *mp;
15204 vl_api_control_ping_t *mp_ping;
15205 u32 sw_if_index = ~0;
15206 u8 sw_if_index_set = 0;
15211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15213 if (unformat (i, "sw_if_index %d", &sw_if_index))
15214 sw_if_index_set = 1;
15216 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15217 sw_if_index_set = 1;
15218 else if (unformat (i, "ipv4"))
15220 else if (unformat (i, "ipv6"))
15226 if (ipv4_set && ipv6_set)
15228 errmsg ("ipv4 and ipv6 flags cannot be both set");
15232 if ((!ipv4_set) && (!ipv6_set))
15234 errmsg ("no ipv4 nor ipv6 flag set");
15238 if (sw_if_index_set == 0)
15240 errmsg ("missing interface name or sw_if_index");
15244 vam->current_sw_if_index = sw_if_index;
15245 vam->is_ipv6 = ipv6_set;
15247 M (IP_ADDRESS_DUMP, mp);
15248 mp->sw_if_index = ntohl (sw_if_index);
15249 mp->is_ipv6 = ipv6_set;
15252 /* Use a control ping for synchronization */
15253 MPING (CONTROL_PING, mp_ping);
15261 api_ip_dump (vat_main_t * vam)
15263 vl_api_ip_dump_t *mp;
15264 vl_api_control_ping_t *mp_ping;
15265 unformat_input_t *in = vam->input;
15272 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
15274 if (unformat (in, "ipv4"))
15276 else if (unformat (in, "ipv6"))
15282 if (ipv4_set && ipv6_set)
15284 errmsg ("ipv4 and ipv6 flags cannot be both set");
15288 if ((!ipv4_set) && (!ipv6_set))
15290 errmsg ("no ipv4 nor ipv6 flag set");
15294 is_ipv6 = ipv6_set;
15295 vam->is_ipv6 = is_ipv6;
15297 /* free old data */
15298 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
15300 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
15302 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
15305 mp->is_ipv6 = ipv6_set;
15308 /* Use a control ping for synchronization */
15309 MPING (CONTROL_PING, mp_ping);
15317 api_ipsec_spd_add_del (vat_main_t * vam)
15319 unformat_input_t *i = vam->input;
15320 vl_api_ipsec_spd_add_del_t *mp;
15325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15327 if (unformat (i, "spd_id %d", &spd_id))
15329 else if (unformat (i, "del"))
15333 clib_warning ("parse error '%U'", format_unformat_error, i);
15339 errmsg ("spd_id must be set");
15343 M (IPSEC_SPD_ADD_DEL, mp);
15345 mp->spd_id = ntohl (spd_id);
15346 mp->is_add = is_add;
15354 api_ipsec_interface_add_del_spd (vat_main_t * vam)
15356 unformat_input_t *i = vam->input;
15357 vl_api_ipsec_interface_add_del_spd_t *mp;
15359 u8 sw_if_index_set = 0;
15360 u32 spd_id = (u32) ~ 0;
15364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15366 if (unformat (i, "del"))
15368 else if (unformat (i, "spd_id %d", &spd_id))
15371 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15372 sw_if_index_set = 1;
15373 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15374 sw_if_index_set = 1;
15377 clib_warning ("parse error '%U'", format_unformat_error, i);
15383 if (spd_id == (u32) ~ 0)
15385 errmsg ("spd_id must be set");
15389 if (sw_if_index_set == 0)
15391 errmsg ("missing interface name or sw_if_index");
15395 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15397 mp->spd_id = ntohl (spd_id);
15398 mp->sw_if_index = ntohl (sw_if_index);
15399 mp->is_add = is_add;
15407 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15409 unformat_input_t *i = vam->input;
15410 vl_api_ipsec_spd_add_del_entry_t *mp;
15411 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15412 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15414 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15415 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15416 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15417 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15420 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15421 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15422 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15423 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15424 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15425 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15427 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15429 if (unformat (i, "del"))
15431 if (unformat (i, "outbound"))
15433 if (unformat (i, "inbound"))
15435 else if (unformat (i, "spd_id %d", &spd_id))
15437 else if (unformat (i, "sa_id %d", &sa_id))
15439 else if (unformat (i, "priority %d", &priority))
15441 else if (unformat (i, "protocol %d", &protocol))
15443 else if (unformat (i, "lport_start %d", &lport_start))
15445 else if (unformat (i, "lport_stop %d", &lport_stop))
15447 else if (unformat (i, "rport_start %d", &rport_start))
15449 else if (unformat (i, "rport_stop %d", &rport_stop))
15453 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15459 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15466 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15472 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15479 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15485 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15492 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15498 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15504 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15506 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15508 clib_warning ("unsupported action: 'resolve'");
15514 clib_warning ("parse error '%U'", format_unformat_error, i);
15520 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15522 mp->spd_id = ntohl (spd_id);
15523 mp->priority = ntohl (priority);
15524 mp->is_outbound = is_outbound;
15526 mp->is_ipv6 = is_ipv6;
15527 if (is_ipv6 || is_ip_any)
15529 clib_memcpy (mp->remote_address_start, &raddr6_start,
15530 sizeof (ip6_address_t));
15531 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15532 sizeof (ip6_address_t));
15533 clib_memcpy (mp->local_address_start, &laddr6_start,
15534 sizeof (ip6_address_t));
15535 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15536 sizeof (ip6_address_t));
15540 clib_memcpy (mp->remote_address_start, &raddr4_start,
15541 sizeof (ip4_address_t));
15542 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15543 sizeof (ip4_address_t));
15544 clib_memcpy (mp->local_address_start, &laddr4_start,
15545 sizeof (ip4_address_t));
15546 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15547 sizeof (ip4_address_t));
15549 mp->protocol = (u8) protocol;
15550 mp->local_port_start = ntohs ((u16) lport_start);
15551 mp->local_port_stop = ntohs ((u16) lport_stop);
15552 mp->remote_port_start = ntohs ((u16) rport_start);
15553 mp->remote_port_stop = ntohs ((u16) rport_stop);
15554 mp->policy = (u8) policy;
15555 mp->sa_id = ntohl (sa_id);
15556 mp->is_add = is_add;
15557 mp->is_ip_any = is_ip_any;
15564 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15566 unformat_input_t *i = vam->input;
15567 vl_api_ipsec_sad_add_del_entry_t *mp;
15568 u32 sad_id = 0, spi = 0;
15569 u8 *ck = 0, *ik = 0;
15572 u8 protocol = IPSEC_PROTOCOL_AH;
15573 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15574 u32 crypto_alg = 0, integ_alg = 0;
15575 ip4_address_t tun_src4;
15576 ip4_address_t tun_dst4;
15577 ip6_address_t tun_src6;
15578 ip6_address_t tun_dst6;
15581 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15583 if (unformat (i, "del"))
15585 else if (unformat (i, "sad_id %d", &sad_id))
15587 else if (unformat (i, "spi %d", &spi))
15589 else if (unformat (i, "esp"))
15590 protocol = IPSEC_PROTOCOL_ESP;
15591 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15594 is_tunnel_ipv6 = 0;
15596 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15599 is_tunnel_ipv6 = 0;
15601 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15604 is_tunnel_ipv6 = 1;
15606 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15609 is_tunnel_ipv6 = 1;
15613 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15615 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15617 clib_warning ("unsupported crypto-alg: '%U'",
15618 format_ipsec_crypto_alg, crypto_alg);
15622 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15626 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15628 if (integ_alg >= IPSEC_INTEG_N_ALG)
15630 clib_warning ("unsupported integ-alg: '%U'",
15631 format_ipsec_integ_alg, integ_alg);
15635 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15639 clib_warning ("parse error '%U'", format_unformat_error, i);
15645 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15647 mp->sad_id = ntohl (sad_id);
15648 mp->is_add = is_add;
15649 mp->protocol = protocol;
15650 mp->spi = ntohl (spi);
15651 mp->is_tunnel = is_tunnel;
15652 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15653 mp->crypto_algorithm = crypto_alg;
15654 mp->integrity_algorithm = integ_alg;
15655 mp->crypto_key_length = vec_len (ck);
15656 mp->integrity_key_length = vec_len (ik);
15658 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15659 mp->crypto_key_length = sizeof (mp->crypto_key);
15661 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15662 mp->integrity_key_length = sizeof (mp->integrity_key);
15665 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15667 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15671 if (is_tunnel_ipv6)
15673 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15674 sizeof (ip6_address_t));
15675 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15676 sizeof (ip6_address_t));
15680 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15681 sizeof (ip4_address_t));
15682 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15683 sizeof (ip4_address_t));
15693 api_ipsec_sa_set_key (vat_main_t * vam)
15695 unformat_input_t *i = vam->input;
15696 vl_api_ipsec_sa_set_key_t *mp;
15698 u8 *ck = 0, *ik = 0;
15701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15703 if (unformat (i, "sa_id %d", &sa_id))
15705 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15707 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15711 clib_warning ("parse error '%U'", format_unformat_error, i);
15716 M (IPSEC_SA_SET_KEY, mp);
15718 mp->sa_id = ntohl (sa_id);
15719 mp->crypto_key_length = vec_len (ck);
15720 mp->integrity_key_length = vec_len (ik);
15722 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15723 mp->crypto_key_length = sizeof (mp->crypto_key);
15725 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15726 mp->integrity_key_length = sizeof (mp->integrity_key);
15729 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15731 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15739 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15741 unformat_input_t *i = vam->input;
15742 vl_api_ipsec_tunnel_if_add_del_t *mp;
15743 u32 local_spi = 0, remote_spi = 0;
15744 u32 crypto_alg = 0, integ_alg = 0;
15745 u8 *lck = NULL, *rck = NULL;
15746 u8 *lik = NULL, *rik = NULL;
15747 ip4_address_t local_ip = { {0} };
15748 ip4_address_t remote_ip = { {0} };
15751 u8 anti_replay = 0;
15756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15758 if (unformat (i, "del"))
15760 else if (unformat (i, "esn"))
15762 else if (unformat (i, "anti_replay"))
15764 else if (unformat (i, "local_spi %d", &local_spi))
15766 else if (unformat (i, "remote_spi %d", &remote_spi))
15768 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15770 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15772 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15775 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15777 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15779 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15783 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15785 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15787 errmsg ("unsupported crypto-alg: '%U'\n",
15788 format_ipsec_crypto_alg, crypto_alg);
15794 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15796 if (integ_alg >= IPSEC_INTEG_N_ALG)
15798 errmsg ("unsupported integ-alg: '%U'\n",
15799 format_ipsec_integ_alg, integ_alg);
15803 else if (unformat (i, "instance %u", &instance))
15807 errmsg ("parse error '%U'\n", format_unformat_error, i);
15812 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15814 mp->is_add = is_add;
15816 mp->anti_replay = anti_replay;
15818 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15819 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15821 mp->local_spi = htonl (local_spi);
15822 mp->remote_spi = htonl (remote_spi);
15823 mp->crypto_alg = (u8) crypto_alg;
15825 mp->local_crypto_key_len = 0;
15828 mp->local_crypto_key_len = vec_len (lck);
15829 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15830 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15831 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15834 mp->remote_crypto_key_len = 0;
15837 mp->remote_crypto_key_len = vec_len (rck);
15838 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15839 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15840 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15843 mp->integ_alg = (u8) integ_alg;
15845 mp->local_integ_key_len = 0;
15848 mp->local_integ_key_len = vec_len (lik);
15849 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15850 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15851 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15854 mp->remote_integ_key_len = 0;
15857 mp->remote_integ_key_len = vec_len (rik);
15858 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15859 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15860 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15865 mp->renumber = renumber;
15866 mp->show_instance = ntohl (instance);
15875 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15877 vat_main_t *vam = &vat_main;
15879 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15880 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15881 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15882 "tunnel_src_addr %U tunnel_dst_addr %U "
15883 "salt %u seq_outbound %lu last_seq_inbound %lu "
15884 "replay_window %lu total_data_size %lu\n",
15885 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15887 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15888 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15889 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15890 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15891 mp->tunnel_src_addr,
15892 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15893 mp->tunnel_dst_addr,
15895 clib_net_to_host_u64 (mp->seq_outbound),
15896 clib_net_to_host_u64 (mp->last_seq_inbound),
15897 clib_net_to_host_u64 (mp->replay_window),
15898 clib_net_to_host_u64 (mp->total_data_size));
15901 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15902 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15904 static void vl_api_ipsec_sa_details_t_handler_json
15905 (vl_api_ipsec_sa_details_t * mp)
15907 vat_main_t *vam = &vat_main;
15908 vat_json_node_t *node = NULL;
15909 struct in_addr src_ip4, dst_ip4;
15910 struct in6_addr src_ip6, dst_ip6;
15912 if (VAT_JSON_ARRAY != vam->json_tree.type)
15914 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15915 vat_json_init_array (&vam->json_tree);
15917 node = vat_json_array_add (&vam->json_tree);
15919 vat_json_init_object (node);
15920 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15921 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15922 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15923 vat_json_object_add_uint (node, "proto", mp->protocol);
15924 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15925 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15926 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15927 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15928 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15929 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15930 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15931 mp->crypto_key_len);
15932 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15933 mp->integ_key_len);
15934 if (mp->is_tunnel_ip6)
15936 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15937 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15938 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15939 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15943 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15944 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15945 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15946 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15948 vat_json_object_add_uint (node, "replay_window",
15949 clib_net_to_host_u64 (mp->replay_window));
15950 vat_json_object_add_uint (node, "total_data_size",
15951 clib_net_to_host_u64 (mp->total_data_size));
15956 api_ipsec_sa_dump (vat_main_t * vam)
15958 unformat_input_t *i = vam->input;
15959 vl_api_ipsec_sa_dump_t *mp;
15960 vl_api_control_ping_t *mp_ping;
15964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15966 if (unformat (i, "sa_id %d", &sa_id))
15970 clib_warning ("parse error '%U'", format_unformat_error, i);
15975 M (IPSEC_SA_DUMP, mp);
15977 mp->sa_id = ntohl (sa_id);
15981 /* Use a control ping for synchronization */
15982 M (CONTROL_PING, mp_ping);
15990 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15992 unformat_input_t *i = vam->input;
15993 vl_api_ipsec_tunnel_if_set_key_t *mp;
15994 u32 sw_if_index = ~0;
15995 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
16000 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16002 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16005 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
16006 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
16008 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
16009 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
16010 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
16011 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
16013 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
16014 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
16015 else if (unformat (i, "%U", unformat_hex_string, &key))
16019 clib_warning ("parse error '%U'", format_unformat_error, i);
16024 if (sw_if_index == ~0)
16026 errmsg ("interface must be specified");
16030 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
16032 errmsg ("key type must be specified");
16038 errmsg ("algorithm must be specified");
16042 if (vec_len (key) == 0)
16044 errmsg ("key must be specified");
16048 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
16050 mp->sw_if_index = htonl (sw_if_index);
16052 mp->key_type = key_type;
16053 mp->key_len = vec_len (key);
16054 clib_memcpy (mp->key, key, vec_len (key));
16063 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
16065 unformat_input_t *i = vam->input;
16066 vl_api_ipsec_tunnel_if_set_sa_t *mp;
16067 u32 sw_if_index = ~0;
16069 u8 is_outbound = (u8) ~ 0;
16072 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16074 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16076 else if (unformat (i, "sa_id %d", &sa_id))
16078 else if (unformat (i, "outbound"))
16080 else if (unformat (i, "inbound"))
16084 clib_warning ("parse error '%U'", format_unformat_error, i);
16089 if (sw_if_index == ~0)
16091 errmsg ("interface must be specified");
16097 errmsg ("SA ID must be specified");
16101 M (IPSEC_TUNNEL_IF_SET_SA, mp);
16103 mp->sw_if_index = htonl (sw_if_index);
16104 mp->sa_id = htonl (sa_id);
16105 mp->is_outbound = is_outbound;
16114 api_ikev2_profile_add_del (vat_main_t * vam)
16116 unformat_input_t *i = vam->input;
16117 vl_api_ikev2_profile_add_del_t *mp;
16122 const char *valid_chars = "a-zA-Z0-9_";
16124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16126 if (unformat (i, "del"))
16128 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16129 vec_add1 (name, 0);
16132 errmsg ("parse error '%U'", format_unformat_error, i);
16137 if (!vec_len (name))
16139 errmsg ("profile name must be specified");
16143 if (vec_len (name) > 64)
16145 errmsg ("profile name too long");
16149 M (IKEV2_PROFILE_ADD_DEL, mp);
16151 clib_memcpy (mp->name, name, vec_len (name));
16152 mp->is_add = is_add;
16161 api_ikev2_profile_set_auth (vat_main_t * vam)
16163 unformat_input_t *i = vam->input;
16164 vl_api_ikev2_profile_set_auth_t *mp;
16167 u32 auth_method = 0;
16171 const char *valid_chars = "a-zA-Z0-9_";
16173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16175 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16176 vec_add1 (name, 0);
16177 else if (unformat (i, "auth_method %U",
16178 unformat_ikev2_auth_method, &auth_method))
16180 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
16182 else if (unformat (i, "auth_data %v", &data))
16186 errmsg ("parse error '%U'", format_unformat_error, i);
16191 if (!vec_len (name))
16193 errmsg ("profile name must be specified");
16197 if (vec_len (name) > 64)
16199 errmsg ("profile name too long");
16203 if (!vec_len (data))
16205 errmsg ("auth_data must be specified");
16211 errmsg ("auth_method must be specified");
16215 M (IKEV2_PROFILE_SET_AUTH, mp);
16217 mp->is_hex = is_hex;
16218 mp->auth_method = (u8) auth_method;
16219 mp->data_len = vec_len (data);
16220 clib_memcpy (mp->name, name, vec_len (name));
16221 clib_memcpy (mp->data, data, vec_len (data));
16231 api_ikev2_profile_set_id (vat_main_t * vam)
16233 unformat_input_t *i = vam->input;
16234 vl_api_ikev2_profile_set_id_t *mp;
16242 const char *valid_chars = "a-zA-Z0-9_";
16244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16246 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16247 vec_add1 (name, 0);
16248 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
16250 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
16252 data = vec_new (u8, 4);
16253 clib_memcpy (data, ip4.as_u8, 4);
16255 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
16257 else if (unformat (i, "id_data %v", &data))
16259 else if (unformat (i, "local"))
16261 else if (unformat (i, "remote"))
16265 errmsg ("parse error '%U'", format_unformat_error, i);
16270 if (!vec_len (name))
16272 errmsg ("profile name must be specified");
16276 if (vec_len (name) > 64)
16278 errmsg ("profile name too long");
16282 if (!vec_len (data))
16284 errmsg ("id_data must be specified");
16290 errmsg ("id_type must be specified");
16294 M (IKEV2_PROFILE_SET_ID, mp);
16296 mp->is_local = is_local;
16297 mp->id_type = (u8) id_type;
16298 mp->data_len = vec_len (data);
16299 clib_memcpy (mp->name, name, vec_len (name));
16300 clib_memcpy (mp->data, data, vec_len (data));
16310 api_ikev2_profile_set_ts (vat_main_t * vam)
16312 unformat_input_t *i = vam->input;
16313 vl_api_ikev2_profile_set_ts_t *mp;
16316 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
16317 ip4_address_t start_addr, end_addr;
16319 const char *valid_chars = "a-zA-Z0-9_";
16322 start_addr.as_u32 = 0;
16323 end_addr.as_u32 = (u32) ~ 0;
16325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16327 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16328 vec_add1 (name, 0);
16329 else if (unformat (i, "protocol %d", &proto))
16331 else if (unformat (i, "start_port %d", &start_port))
16333 else if (unformat (i, "end_port %d", &end_port))
16336 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
16338 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
16340 else if (unformat (i, "local"))
16342 else if (unformat (i, "remote"))
16346 errmsg ("parse error '%U'", format_unformat_error, i);
16351 if (!vec_len (name))
16353 errmsg ("profile name must be specified");
16357 if (vec_len (name) > 64)
16359 errmsg ("profile name too long");
16363 M (IKEV2_PROFILE_SET_TS, mp);
16365 mp->is_local = is_local;
16366 mp->proto = (u8) proto;
16367 mp->start_port = (u16) start_port;
16368 mp->end_port = (u16) end_port;
16369 mp->start_addr = start_addr.as_u32;
16370 mp->end_addr = end_addr.as_u32;
16371 clib_memcpy (mp->name, name, vec_len (name));
16380 api_ikev2_set_local_key (vat_main_t * vam)
16382 unformat_input_t *i = vam->input;
16383 vl_api_ikev2_set_local_key_t *mp;
16387 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16389 if (unformat (i, "file %v", &file))
16390 vec_add1 (file, 0);
16393 errmsg ("parse error '%U'", format_unformat_error, i);
16398 if (!vec_len (file))
16400 errmsg ("RSA key file must be specified");
16404 if (vec_len (file) > 256)
16406 errmsg ("file name too long");
16410 M (IKEV2_SET_LOCAL_KEY, mp);
16412 clib_memcpy (mp->key_file, file, vec_len (file));
16421 api_ikev2_set_responder (vat_main_t * vam)
16423 unformat_input_t *i = vam->input;
16424 vl_api_ikev2_set_responder_t *mp;
16427 u32 sw_if_index = ~0;
16428 ip4_address_t address;
16430 const char *valid_chars = "a-zA-Z0-9_";
16432 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16435 (i, "%U interface %d address %U", unformat_token, valid_chars,
16436 &name, &sw_if_index, unformat_ip4_address, &address))
16437 vec_add1 (name, 0);
16440 errmsg ("parse error '%U'", format_unformat_error, i);
16445 if (!vec_len (name))
16447 errmsg ("profile name must be specified");
16451 if (vec_len (name) > 64)
16453 errmsg ("profile name too long");
16457 M (IKEV2_SET_RESPONDER, mp);
16459 clib_memcpy (mp->name, name, vec_len (name));
16462 mp->sw_if_index = sw_if_index;
16463 clib_memcpy (mp->address, &address, sizeof (address));
16471 api_ikev2_set_ike_transforms (vat_main_t * vam)
16473 unformat_input_t *i = vam->input;
16474 vl_api_ikev2_set_ike_transforms_t *mp;
16477 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16479 const char *valid_chars = "a-zA-Z0-9_";
16481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16483 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16484 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16485 vec_add1 (name, 0);
16488 errmsg ("parse error '%U'", format_unformat_error, i);
16493 if (!vec_len (name))
16495 errmsg ("profile name must be specified");
16499 if (vec_len (name) > 64)
16501 errmsg ("profile name too long");
16505 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16507 clib_memcpy (mp->name, name, vec_len (name));
16509 mp->crypto_alg = crypto_alg;
16510 mp->crypto_key_size = crypto_key_size;
16511 mp->integ_alg = integ_alg;
16512 mp->dh_group = dh_group;
16521 api_ikev2_set_esp_transforms (vat_main_t * vam)
16523 unformat_input_t *i = vam->input;
16524 vl_api_ikev2_set_esp_transforms_t *mp;
16527 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16529 const char *valid_chars = "a-zA-Z0-9_";
16531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16533 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16534 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16535 vec_add1 (name, 0);
16538 errmsg ("parse error '%U'", format_unformat_error, i);
16543 if (!vec_len (name))
16545 errmsg ("profile name must be specified");
16549 if (vec_len (name) > 64)
16551 errmsg ("profile name too long");
16555 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16557 clib_memcpy (mp->name, name, vec_len (name));
16559 mp->crypto_alg = crypto_alg;
16560 mp->crypto_key_size = crypto_key_size;
16561 mp->integ_alg = integ_alg;
16562 mp->dh_group = dh_group;
16570 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16572 unformat_input_t *i = vam->input;
16573 vl_api_ikev2_set_sa_lifetime_t *mp;
16576 u64 lifetime, lifetime_maxdata;
16577 u32 lifetime_jitter, handover;
16579 const char *valid_chars = "a-zA-Z0-9_";
16581 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16583 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16584 &lifetime, &lifetime_jitter, &handover,
16585 &lifetime_maxdata))
16586 vec_add1 (name, 0);
16589 errmsg ("parse error '%U'", format_unformat_error, i);
16594 if (!vec_len (name))
16596 errmsg ("profile name must be specified");
16600 if (vec_len (name) > 64)
16602 errmsg ("profile name too long");
16606 M (IKEV2_SET_SA_LIFETIME, mp);
16608 clib_memcpy (mp->name, name, vec_len (name));
16610 mp->lifetime = lifetime;
16611 mp->lifetime_jitter = lifetime_jitter;
16612 mp->handover = handover;
16613 mp->lifetime_maxdata = lifetime_maxdata;
16621 api_ikev2_initiate_sa_init (vat_main_t * vam)
16623 unformat_input_t *i = vam->input;
16624 vl_api_ikev2_initiate_sa_init_t *mp;
16628 const char *valid_chars = "a-zA-Z0-9_";
16630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16632 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16633 vec_add1 (name, 0);
16636 errmsg ("parse error '%U'", format_unformat_error, i);
16641 if (!vec_len (name))
16643 errmsg ("profile name must be specified");
16647 if (vec_len (name) > 64)
16649 errmsg ("profile name too long");
16653 M (IKEV2_INITIATE_SA_INIT, mp);
16655 clib_memcpy (mp->name, name, vec_len (name));
16664 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16666 unformat_input_t *i = vam->input;
16667 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16674 if (unformat (i, "%lx", &ispi))
16678 errmsg ("parse error '%U'", format_unformat_error, i);
16683 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16693 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16695 unformat_input_t *i = vam->input;
16696 vl_api_ikev2_initiate_del_child_sa_t *mp;
16701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16703 if (unformat (i, "%x", &ispi))
16707 errmsg ("parse error '%U'", format_unformat_error, i);
16712 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16722 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16724 unformat_input_t *i = vam->input;
16725 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16730 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16732 if (unformat (i, "%x", &ispi))
16736 errmsg ("parse error '%U'", format_unformat_error, i);
16741 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16751 api_get_first_msg_id (vat_main_t * vam)
16753 vl_api_get_first_msg_id_t *mp;
16754 unformat_input_t *i = vam->input;
16759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16761 if (unformat (i, "client %s", &name))
16769 errmsg ("missing client name");
16772 vec_add1 (name, 0);
16774 if (vec_len (name) > 63)
16776 errmsg ("client name too long");
16780 M (GET_FIRST_MSG_ID, mp);
16781 clib_memcpy (mp->name, name, vec_len (name));
16788 api_cop_interface_enable_disable (vat_main_t * vam)
16790 unformat_input_t *line_input = vam->input;
16791 vl_api_cop_interface_enable_disable_t *mp;
16792 u32 sw_if_index = ~0;
16793 u8 enable_disable = 1;
16796 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16798 if (unformat (line_input, "disable"))
16799 enable_disable = 0;
16800 if (unformat (line_input, "enable"))
16801 enable_disable = 1;
16802 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16803 vam, &sw_if_index))
16805 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16811 if (sw_if_index == ~0)
16813 errmsg ("missing interface name or sw_if_index");
16817 /* Construct the API message */
16818 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16819 mp->sw_if_index = ntohl (sw_if_index);
16820 mp->enable_disable = enable_disable;
16824 /* Wait for the reply */
16830 api_cop_whitelist_enable_disable (vat_main_t * vam)
16832 unformat_input_t *line_input = vam->input;
16833 vl_api_cop_whitelist_enable_disable_t *mp;
16834 u32 sw_if_index = ~0;
16835 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16839 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16841 if (unformat (line_input, "ip4"))
16843 else if (unformat (line_input, "ip6"))
16845 else if (unformat (line_input, "default"))
16847 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16848 vam, &sw_if_index))
16850 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16852 else if (unformat (line_input, "fib-id %d", &fib_id))
16858 if (sw_if_index == ~0)
16860 errmsg ("missing interface name or sw_if_index");
16864 /* Construct the API message */
16865 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16866 mp->sw_if_index = ntohl (sw_if_index);
16867 mp->fib_id = ntohl (fib_id);
16870 mp->default_cop = default_cop;
16874 /* Wait for the reply */
16880 api_get_node_graph (vat_main_t * vam)
16882 vl_api_get_node_graph_t *mp;
16885 M (GET_NODE_GRAPH, mp);
16889 /* Wait for the reply */
16895 /** Used for parsing LISP eids */
16896 typedef CLIB_PACKED(struct{
16897 u8 addr[16]; /**< eid address */
16898 u32 len; /**< prefix length if IP */
16899 u8 type; /**< type of eid */
16904 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16906 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16908 clib_memset (a, 0, sizeof (a[0]));
16910 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16912 a->type = 0; /* ipv4 type */
16914 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16916 a->type = 1; /* ipv6 type */
16918 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16920 a->type = 2; /* mac type */
16922 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16924 a->type = 3; /* NSH type */
16925 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16926 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16933 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16942 lisp_eid_size_vat (u8 type)
16959 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16961 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16965 api_one_add_del_locator_set (vat_main_t * vam)
16967 unformat_input_t *input = vam->input;
16968 vl_api_one_add_del_locator_set_t *mp;
16970 u8 *locator_set_name = NULL;
16971 u8 locator_set_name_set = 0;
16972 vl_api_local_locator_t locator, *locators = 0;
16973 u32 sw_if_index, priority, weight;
16977 /* Parse args required to build the message */
16978 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16980 if (unformat (input, "del"))
16984 else if (unformat (input, "locator-set %s", &locator_set_name))
16986 locator_set_name_set = 1;
16988 else if (unformat (input, "sw_if_index %u p %u w %u",
16989 &sw_if_index, &priority, &weight))
16991 locator.sw_if_index = htonl (sw_if_index);
16992 locator.priority = priority;
16993 locator.weight = weight;
16994 vec_add1 (locators, locator);
16998 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16999 &sw_if_index, &priority, &weight))
17001 locator.sw_if_index = htonl (sw_if_index);
17002 locator.priority = priority;
17003 locator.weight = weight;
17004 vec_add1 (locators, locator);
17010 if (locator_set_name_set == 0)
17012 errmsg ("missing locator-set name");
17013 vec_free (locators);
17017 if (vec_len (locator_set_name) > 64)
17019 errmsg ("locator-set name too long");
17020 vec_free (locator_set_name);
17021 vec_free (locators);
17024 vec_add1 (locator_set_name, 0);
17026 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
17028 /* Construct the API message */
17029 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
17031 mp->is_add = is_add;
17032 clib_memcpy (mp->locator_set_name, locator_set_name,
17033 vec_len (locator_set_name));
17034 vec_free (locator_set_name);
17036 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
17038 clib_memcpy (mp->locators, locators, data_len);
17039 vec_free (locators);
17044 /* Wait for a reply... */
17049 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
17052 api_one_add_del_locator (vat_main_t * vam)
17054 unformat_input_t *input = vam->input;
17055 vl_api_one_add_del_locator_t *mp;
17056 u32 tmp_if_index = ~0;
17057 u32 sw_if_index = ~0;
17058 u8 sw_if_index_set = 0;
17059 u8 sw_if_index_if_name_set = 0;
17061 u8 priority_set = 0;
17065 u8 *locator_set_name = NULL;
17066 u8 locator_set_name_set = 0;
17069 /* Parse args required to build the message */
17070 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17072 if (unformat (input, "del"))
17076 else if (unformat (input, "locator-set %s", &locator_set_name))
17078 locator_set_name_set = 1;
17080 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
17083 sw_if_index_if_name_set = 1;
17084 sw_if_index = tmp_if_index;
17086 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
17088 sw_if_index_set = 1;
17089 sw_if_index = tmp_if_index;
17091 else if (unformat (input, "p %d", &priority))
17095 else if (unformat (input, "w %d", &weight))
17103 if (locator_set_name_set == 0)
17105 errmsg ("missing locator-set name");
17109 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
17111 errmsg ("missing sw_if_index");
17112 vec_free (locator_set_name);
17116 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
17118 errmsg ("cannot use both params interface name and sw_if_index");
17119 vec_free (locator_set_name);
17123 if (priority_set == 0)
17125 errmsg ("missing locator-set priority");
17126 vec_free (locator_set_name);
17130 if (weight_set == 0)
17132 errmsg ("missing locator-set weight");
17133 vec_free (locator_set_name);
17137 if (vec_len (locator_set_name) > 64)
17139 errmsg ("locator-set name too long");
17140 vec_free (locator_set_name);
17143 vec_add1 (locator_set_name, 0);
17145 /* Construct the API message */
17146 M (ONE_ADD_DEL_LOCATOR, mp);
17148 mp->is_add = is_add;
17149 mp->sw_if_index = ntohl (sw_if_index);
17150 mp->priority = priority;
17151 mp->weight = weight;
17152 clib_memcpy (mp->locator_set_name, locator_set_name,
17153 vec_len (locator_set_name));
17154 vec_free (locator_set_name);
17159 /* Wait for a reply... */
17164 #define api_lisp_add_del_locator api_one_add_del_locator
17167 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
17169 u32 *key_id = va_arg (*args, u32 *);
17172 if (unformat (input, "%s", &s))
17174 if (!strcmp ((char *) s, "sha1"))
17175 key_id[0] = HMAC_SHA_1_96;
17176 else if (!strcmp ((char *) s, "sha256"))
17177 key_id[0] = HMAC_SHA_256_128;
17180 clib_warning ("invalid key_id: '%s'", s);
17181 key_id[0] = HMAC_NO_KEY;
17192 api_one_add_del_local_eid (vat_main_t * vam)
17194 unformat_input_t *input = vam->input;
17195 vl_api_one_add_del_local_eid_t *mp;
17198 lisp_eid_vat_t _eid, *eid = &_eid;
17199 u8 *locator_set_name = 0;
17200 u8 locator_set_name_set = 0;
17206 /* Parse args required to build the message */
17207 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17209 if (unformat (input, "del"))
17213 else if (unformat (input, "vni %d", &vni))
17217 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17221 else if (unformat (input, "locator-set %s", &locator_set_name))
17223 locator_set_name_set = 1;
17225 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17227 else if (unformat (input, "secret-key %_%v%_", &key))
17233 if (locator_set_name_set == 0)
17235 errmsg ("missing locator-set name");
17241 errmsg ("EID address not set!");
17242 vec_free (locator_set_name);
17246 if (key && (0 == key_id))
17248 errmsg ("invalid key_id!");
17252 if (vec_len (key) > 64)
17254 errmsg ("key too long");
17259 if (vec_len (locator_set_name) > 64)
17261 errmsg ("locator-set name too long");
17262 vec_free (locator_set_name);
17265 vec_add1 (locator_set_name, 0);
17267 /* Construct the API message */
17268 M (ONE_ADD_DEL_LOCAL_EID, mp);
17270 mp->is_add = is_add;
17271 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17272 mp->eid_type = eid->type;
17273 mp->prefix_len = eid->len;
17274 mp->vni = clib_host_to_net_u32 (vni);
17275 mp->key_id = clib_host_to_net_u16 (key_id);
17276 clib_memcpy (mp->locator_set_name, locator_set_name,
17277 vec_len (locator_set_name));
17278 clib_memcpy (mp->key, key, vec_len (key));
17280 vec_free (locator_set_name);
17286 /* Wait for a reply... */
17291 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17294 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17296 u32 dp_table = 0, vni = 0;;
17297 unformat_input_t *input = vam->input;
17298 vl_api_gpe_add_del_fwd_entry_t *mp;
17300 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17301 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17302 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17303 u32 action = ~0, w;
17304 ip4_address_t rmt_rloc4, lcl_rloc4;
17305 ip6_address_t rmt_rloc6, lcl_rloc6;
17306 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17309 clib_memset (&rloc, 0, sizeof (rloc));
17311 /* Parse args required to build the message */
17312 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17314 if (unformat (input, "del"))
17316 else if (unformat (input, "add"))
17318 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17322 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17326 else if (unformat (input, "vrf %d", &dp_table))
17328 else if (unformat (input, "bd %d", &dp_table))
17330 else if (unformat (input, "vni %d", &vni))
17332 else if (unformat (input, "w %d", &w))
17336 errmsg ("No RLOC configured for setting priority/weight!");
17339 curr_rloc->weight = w;
17341 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17342 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17346 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17348 vec_add1 (lcl_locs, rloc);
17350 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17351 vec_add1 (rmt_locs, rloc);
17352 /* weight saved in rmt loc */
17353 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17355 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17356 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17359 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17361 vec_add1 (lcl_locs, rloc);
17363 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17364 vec_add1 (rmt_locs, rloc);
17365 /* weight saved in rmt loc */
17366 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17368 else if (unformat (input, "action %d", &action))
17374 clib_warning ("parse error '%U'", format_unformat_error, input);
17381 errmsg ("remote eid addresses not set");
17385 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17387 errmsg ("eid types don't match");
17391 if (0 == rmt_locs && (u32) ~ 0 == action)
17393 errmsg ("action not set for negative mapping");
17397 /* Construct the API message */
17398 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17399 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17401 mp->is_add = is_add;
17402 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17403 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17404 mp->eid_type = rmt_eid->type;
17405 mp->dp_table = clib_host_to_net_u32 (dp_table);
17406 mp->vni = clib_host_to_net_u32 (vni);
17407 mp->rmt_len = rmt_eid->len;
17408 mp->lcl_len = lcl_eid->len;
17409 mp->action = action;
17411 if (0 != rmt_locs && 0 != lcl_locs)
17413 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17414 clib_memcpy (mp->locs, lcl_locs,
17415 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17417 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17418 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17419 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17421 vec_free (lcl_locs);
17422 vec_free (rmt_locs);
17427 /* Wait for a reply... */
17433 api_one_add_del_map_server (vat_main_t * vam)
17435 unformat_input_t *input = vam->input;
17436 vl_api_one_add_del_map_server_t *mp;
17440 ip4_address_t ipv4;
17441 ip6_address_t ipv6;
17444 /* Parse args required to build the message */
17445 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17447 if (unformat (input, "del"))
17451 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17455 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17463 if (ipv4_set && ipv6_set)
17465 errmsg ("both eid v4 and v6 addresses set");
17469 if (!ipv4_set && !ipv6_set)
17471 errmsg ("eid addresses not set");
17475 /* Construct the API message */
17476 M (ONE_ADD_DEL_MAP_SERVER, mp);
17478 mp->is_add = is_add;
17482 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17487 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17493 /* Wait for a reply... */
17498 #define api_lisp_add_del_map_server api_one_add_del_map_server
17501 api_one_add_del_map_resolver (vat_main_t * vam)
17503 unformat_input_t *input = vam->input;
17504 vl_api_one_add_del_map_resolver_t *mp;
17508 ip4_address_t ipv4;
17509 ip6_address_t ipv6;
17512 /* Parse args required to build the message */
17513 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17515 if (unformat (input, "del"))
17519 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17523 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17531 if (ipv4_set && ipv6_set)
17533 errmsg ("both eid v4 and v6 addresses set");
17537 if (!ipv4_set && !ipv6_set)
17539 errmsg ("eid addresses not set");
17543 /* Construct the API message */
17544 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17546 mp->is_add = is_add;
17550 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17555 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17561 /* Wait for a reply... */
17566 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17569 api_lisp_gpe_enable_disable (vat_main_t * vam)
17571 unformat_input_t *input = vam->input;
17572 vl_api_gpe_enable_disable_t *mp;
17577 /* Parse args required to build the message */
17578 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17580 if (unformat (input, "enable"))
17585 else if (unformat (input, "disable"))
17596 errmsg ("Value not set");
17600 /* Construct the API message */
17601 M (GPE_ENABLE_DISABLE, mp);
17608 /* Wait for a reply... */
17614 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17616 unformat_input_t *input = vam->input;
17617 vl_api_one_rloc_probe_enable_disable_t *mp;
17622 /* Parse args required to build the message */
17623 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17625 if (unformat (input, "enable"))
17630 else if (unformat (input, "disable"))
17638 errmsg ("Value not set");
17642 /* Construct the API message */
17643 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17645 mp->is_enabled = is_en;
17650 /* Wait for a reply... */
17655 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17658 api_one_map_register_enable_disable (vat_main_t * vam)
17660 unformat_input_t *input = vam->input;
17661 vl_api_one_map_register_enable_disable_t *mp;
17666 /* Parse args required to build the message */
17667 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17669 if (unformat (input, "enable"))
17674 else if (unformat (input, "disable"))
17682 errmsg ("Value not set");
17686 /* Construct the API message */
17687 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17689 mp->is_enabled = is_en;
17694 /* Wait for a reply... */
17699 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17702 api_one_enable_disable (vat_main_t * vam)
17704 unformat_input_t *input = vam->input;
17705 vl_api_one_enable_disable_t *mp;
17710 /* Parse args required to build the message */
17711 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17713 if (unformat (input, "enable"))
17718 else if (unformat (input, "disable"))
17728 errmsg ("Value not set");
17732 /* Construct the API message */
17733 M (ONE_ENABLE_DISABLE, mp);
17740 /* Wait for a reply... */
17745 #define api_lisp_enable_disable api_one_enable_disable
17748 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17750 unformat_input_t *input = vam->input;
17751 vl_api_one_enable_disable_xtr_mode_t *mp;
17756 /* Parse args required to build the message */
17757 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17759 if (unformat (input, "enable"))
17764 else if (unformat (input, "disable"))
17774 errmsg ("Value not set");
17778 /* Construct the API message */
17779 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17786 /* Wait for a reply... */
17792 api_one_show_xtr_mode (vat_main_t * vam)
17794 vl_api_one_show_xtr_mode_t *mp;
17797 /* Construct the API message */
17798 M (ONE_SHOW_XTR_MODE, mp);
17803 /* Wait for a reply... */
17809 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17811 unformat_input_t *input = vam->input;
17812 vl_api_one_enable_disable_pitr_mode_t *mp;
17817 /* Parse args required to build the message */
17818 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17820 if (unformat (input, "enable"))
17825 else if (unformat (input, "disable"))
17835 errmsg ("Value not set");
17839 /* Construct the API message */
17840 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17847 /* Wait for a reply... */
17853 api_one_show_pitr_mode (vat_main_t * vam)
17855 vl_api_one_show_pitr_mode_t *mp;
17858 /* Construct the API message */
17859 M (ONE_SHOW_PITR_MODE, mp);
17864 /* Wait for a reply... */
17870 api_one_enable_disable_petr_mode (vat_main_t * vam)
17872 unformat_input_t *input = vam->input;
17873 vl_api_one_enable_disable_petr_mode_t *mp;
17878 /* Parse args required to build the message */
17879 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17881 if (unformat (input, "enable"))
17886 else if (unformat (input, "disable"))
17896 errmsg ("Value not set");
17900 /* Construct the API message */
17901 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17908 /* Wait for a reply... */
17914 api_one_show_petr_mode (vat_main_t * vam)
17916 vl_api_one_show_petr_mode_t *mp;
17919 /* Construct the API message */
17920 M (ONE_SHOW_PETR_MODE, mp);
17925 /* Wait for a reply... */
17931 api_show_one_map_register_state (vat_main_t * vam)
17933 vl_api_show_one_map_register_state_t *mp;
17936 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17941 /* wait for reply */
17946 #define api_show_lisp_map_register_state api_show_one_map_register_state
17949 api_show_one_rloc_probe_state (vat_main_t * vam)
17951 vl_api_show_one_rloc_probe_state_t *mp;
17954 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17959 /* wait for reply */
17964 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17967 api_one_add_del_ndp_entry (vat_main_t * vam)
17969 vl_api_one_add_del_ndp_entry_t *mp;
17970 unformat_input_t *input = vam->input;
17975 u8 mac[6] = { 0, };
17976 u8 ip6[16] = { 0, };
17980 /* Parse args required to build the message */
17981 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17983 if (unformat (input, "del"))
17985 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17987 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17989 else if (unformat (input, "bd %d", &bd))
17993 errmsg ("parse error '%U'", format_unformat_error, input);
17998 if (!bd_set || !ip_set || (!mac_set && is_add))
18000 errmsg ("Missing BD, IP or MAC!");
18004 M (ONE_ADD_DEL_NDP_ENTRY, mp);
18005 mp->is_add = is_add;
18006 clib_memcpy (mp->mac, mac, 6);
18007 mp->bd = clib_host_to_net_u32 (bd);
18008 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
18013 /* wait for reply */
18019 api_one_add_del_l2_arp_entry (vat_main_t * vam)
18021 vl_api_one_add_del_l2_arp_entry_t *mp;
18022 unformat_input_t *input = vam->input;
18027 u8 mac[6] = { 0, };
18028 u32 ip4 = 0, bd = ~0;
18031 /* Parse args required to build the message */
18032 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18034 if (unformat (input, "del"))
18036 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
18038 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
18040 else if (unformat (input, "bd %d", &bd))
18044 errmsg ("parse error '%U'", format_unformat_error, input);
18049 if (!bd_set || !ip_set || (!mac_set && is_add))
18051 errmsg ("Missing BD, IP or MAC!");
18055 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
18056 mp->is_add = is_add;
18057 clib_memcpy (mp->mac, mac, 6);
18058 mp->bd = clib_host_to_net_u32 (bd);
18064 /* wait for reply */
18070 api_one_ndp_bd_get (vat_main_t * vam)
18072 vl_api_one_ndp_bd_get_t *mp;
18075 M (ONE_NDP_BD_GET, mp);
18080 /* wait for reply */
18086 api_one_ndp_entries_get (vat_main_t * vam)
18088 vl_api_one_ndp_entries_get_t *mp;
18089 unformat_input_t *input = vam->input;
18094 /* Parse args required to build the message */
18095 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18097 if (unformat (input, "bd %d", &bd))
18101 errmsg ("parse error '%U'", format_unformat_error, input);
18108 errmsg ("Expected bridge domain!");
18112 M (ONE_NDP_ENTRIES_GET, mp);
18113 mp->bd = clib_host_to_net_u32 (bd);
18118 /* wait for reply */
18124 api_one_l2_arp_bd_get (vat_main_t * vam)
18126 vl_api_one_l2_arp_bd_get_t *mp;
18129 M (ONE_L2_ARP_BD_GET, mp);
18134 /* wait for reply */
18140 api_one_l2_arp_entries_get (vat_main_t * vam)
18142 vl_api_one_l2_arp_entries_get_t *mp;
18143 unformat_input_t *input = vam->input;
18148 /* Parse args required to build the message */
18149 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18151 if (unformat (input, "bd %d", &bd))
18155 errmsg ("parse error '%U'", format_unformat_error, input);
18162 errmsg ("Expected bridge domain!");
18166 M (ONE_L2_ARP_ENTRIES_GET, mp);
18167 mp->bd = clib_host_to_net_u32 (bd);
18172 /* wait for reply */
18178 api_one_stats_enable_disable (vat_main_t * vam)
18180 vl_api_one_stats_enable_disable_t *mp;
18181 unformat_input_t *input = vam->input;
18186 /* Parse args required to build the message */
18187 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18189 if (unformat (input, "enable"))
18194 else if (unformat (input, "disable"))
18204 errmsg ("Value not set");
18208 M (ONE_STATS_ENABLE_DISABLE, mp);
18214 /* wait for reply */
18220 api_show_one_stats_enable_disable (vat_main_t * vam)
18222 vl_api_show_one_stats_enable_disable_t *mp;
18225 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18230 /* wait for reply */
18236 api_show_one_map_request_mode (vat_main_t * vam)
18238 vl_api_show_one_map_request_mode_t *mp;
18241 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18246 /* wait for reply */
18251 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18254 api_one_map_request_mode (vat_main_t * vam)
18256 unformat_input_t *input = vam->input;
18257 vl_api_one_map_request_mode_t *mp;
18261 /* Parse args required to build the message */
18262 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18264 if (unformat (input, "dst-only"))
18266 else if (unformat (input, "src-dst"))
18270 errmsg ("parse error '%U'", format_unformat_error, input);
18275 M (ONE_MAP_REQUEST_MODE, mp);
18282 /* wait for reply */
18287 #define api_lisp_map_request_mode api_one_map_request_mode
18290 * Enable/disable ONE proxy ITR.
18292 * @param vam vpp API test context
18293 * @return return code
18296 api_one_pitr_set_locator_set (vat_main_t * vam)
18298 u8 ls_name_set = 0;
18299 unformat_input_t *input = vam->input;
18300 vl_api_one_pitr_set_locator_set_t *mp;
18305 /* Parse args required to build the message */
18306 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18308 if (unformat (input, "del"))
18310 else if (unformat (input, "locator-set %s", &ls_name))
18314 errmsg ("parse error '%U'", format_unformat_error, input);
18321 errmsg ("locator-set name not set!");
18325 M (ONE_PITR_SET_LOCATOR_SET, mp);
18327 mp->is_add = is_add;
18328 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18329 vec_free (ls_name);
18334 /* wait for reply */
18339 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18342 api_one_nsh_set_locator_set (vat_main_t * vam)
18344 u8 ls_name_set = 0;
18345 unformat_input_t *input = vam->input;
18346 vl_api_one_nsh_set_locator_set_t *mp;
18351 /* Parse args required to build the message */
18352 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18354 if (unformat (input, "del"))
18356 else if (unformat (input, "ls %s", &ls_name))
18360 errmsg ("parse error '%U'", format_unformat_error, input);
18365 if (!ls_name_set && is_add)
18367 errmsg ("locator-set name not set!");
18371 M (ONE_NSH_SET_LOCATOR_SET, mp);
18373 mp->is_add = is_add;
18374 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18375 vec_free (ls_name);
18380 /* wait for reply */
18386 api_show_one_pitr (vat_main_t * vam)
18388 vl_api_show_one_pitr_t *mp;
18391 if (!vam->json_output)
18393 print (vam->ofp, "%=20s", "lisp status:");
18396 M (SHOW_ONE_PITR, mp);
18400 /* Wait for a reply... */
18405 #define api_show_lisp_pitr api_show_one_pitr
18408 api_one_use_petr (vat_main_t * vam)
18410 unformat_input_t *input = vam->input;
18411 vl_api_one_use_petr_t *mp;
18416 clib_memset (&ip, 0, sizeof (ip));
18418 /* Parse args required to build the message */
18419 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18421 if (unformat (input, "disable"))
18424 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18427 ip_addr_version (&ip) = IP4;
18430 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18433 ip_addr_version (&ip) = IP6;
18437 errmsg ("parse error '%U'", format_unformat_error, input);
18442 M (ONE_USE_PETR, mp);
18444 mp->is_add = is_add;
18447 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18449 clib_memcpy (mp->address, &ip, 4);
18451 clib_memcpy (mp->address, &ip, 16);
18457 /* wait for reply */
18462 #define api_lisp_use_petr api_one_use_petr
18465 api_show_one_nsh_mapping (vat_main_t * vam)
18467 vl_api_show_one_use_petr_t *mp;
18470 if (!vam->json_output)
18472 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18475 M (SHOW_ONE_NSH_MAPPING, mp);
18479 /* Wait for a reply... */
18485 api_show_one_use_petr (vat_main_t * vam)
18487 vl_api_show_one_use_petr_t *mp;
18490 if (!vam->json_output)
18492 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18495 M (SHOW_ONE_USE_PETR, mp);
18499 /* Wait for a reply... */
18504 #define api_show_lisp_use_petr api_show_one_use_petr
18507 * Add/delete mapping between vni and vrf
18510 api_one_eid_table_add_del_map (vat_main_t * vam)
18512 unformat_input_t *input = vam->input;
18513 vl_api_one_eid_table_add_del_map_t *mp;
18514 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18515 u32 vni, vrf, bd_index;
18518 /* Parse args required to build the message */
18519 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18521 if (unformat (input, "del"))
18523 else if (unformat (input, "vrf %d", &vrf))
18525 else if (unformat (input, "bd_index %d", &bd_index))
18527 else if (unformat (input, "vni %d", &vni))
18533 if (!vni_set || (!vrf_set && !bd_index_set))
18535 errmsg ("missing arguments!");
18539 if (vrf_set && bd_index_set)
18541 errmsg ("error: both vrf and bd entered!");
18545 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18547 mp->is_add = is_add;
18548 mp->vni = htonl (vni);
18549 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18550 mp->is_l2 = bd_index_set;
18555 /* wait for reply */
18560 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18563 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18565 u32 *action = va_arg (*args, u32 *);
18568 if (unformat (input, "%s", &s))
18570 if (!strcmp ((char *) s, "no-action"))
18572 else if (!strcmp ((char *) s, "natively-forward"))
18574 else if (!strcmp ((char *) s, "send-map-request"))
18576 else if (!strcmp ((char *) s, "drop"))
18580 clib_warning ("invalid action: '%s'", s);
18592 * Add/del remote mapping to/from ONE control plane
18594 * @param vam vpp API test context
18595 * @return return code
18598 api_one_add_del_remote_mapping (vat_main_t * vam)
18600 unformat_input_t *input = vam->input;
18601 vl_api_one_add_del_remote_mapping_t *mp;
18603 lisp_eid_vat_t _eid, *eid = &_eid;
18604 lisp_eid_vat_t _seid, *seid = &_seid;
18605 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18606 u32 action = ~0, p, w, data_len;
18607 ip4_address_t rloc4;
18608 ip6_address_t rloc6;
18609 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18612 clib_memset (&rloc, 0, sizeof (rloc));
18614 /* Parse args required to build the message */
18615 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18617 if (unformat (input, "del-all"))
18621 else if (unformat (input, "del"))
18625 else if (unformat (input, "add"))
18629 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18633 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18637 else if (unformat (input, "vni %d", &vni))
18641 else if (unformat (input, "p %d w %d", &p, &w))
18645 errmsg ("No RLOC configured for setting priority/weight!");
18648 curr_rloc->priority = p;
18649 curr_rloc->weight = w;
18651 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18654 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18655 vec_add1 (rlocs, rloc);
18656 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18658 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18661 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18662 vec_add1 (rlocs, rloc);
18663 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18665 else if (unformat (input, "action %U",
18666 unformat_negative_mapping_action, &action))
18672 clib_warning ("parse error '%U'", format_unformat_error, input);
18679 errmsg ("missing params!");
18683 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18685 errmsg ("no action set for negative map-reply!");
18689 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18691 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18692 mp->is_add = is_add;
18693 mp->vni = htonl (vni);
18694 mp->action = (u8) action;
18695 mp->is_src_dst = seid_set;
18696 mp->eid_len = eid->len;
18697 mp->seid_len = seid->len;
18698 mp->del_all = del_all;
18699 mp->eid_type = eid->type;
18700 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18701 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18703 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18704 clib_memcpy (mp->rlocs, rlocs, data_len);
18710 /* Wait for a reply... */
18715 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18718 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18719 * forwarding entries in data-plane accordingly.
18721 * @param vam vpp API test context
18722 * @return return code
18725 api_one_add_del_adjacency (vat_main_t * vam)
18727 unformat_input_t *input = vam->input;
18728 vl_api_one_add_del_adjacency_t *mp;
18730 ip4_address_t leid4, reid4;
18731 ip6_address_t leid6, reid6;
18732 u8 reid_mac[6] = { 0 };
18733 u8 leid_mac[6] = { 0 };
18734 u8 reid_type, leid_type;
18735 u32 leid_len = 0, reid_len = 0, len;
18739 leid_type = reid_type = (u8) ~ 0;
18741 /* Parse args required to build the message */
18742 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18744 if (unformat (input, "del"))
18748 else if (unformat (input, "add"))
18752 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18755 reid_type = 0; /* ipv4 */
18758 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18761 reid_type = 1; /* ipv6 */
18764 else if (unformat (input, "reid %U", unformat_ethernet_address,
18767 reid_type = 2; /* mac */
18769 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18772 leid_type = 0; /* ipv4 */
18775 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18778 leid_type = 1; /* ipv6 */
18781 else if (unformat (input, "leid %U", unformat_ethernet_address,
18784 leid_type = 2; /* mac */
18786 else if (unformat (input, "vni %d", &vni))
18792 errmsg ("parse error '%U'", format_unformat_error, input);
18797 if ((u8) ~ 0 == reid_type)
18799 errmsg ("missing params!");
18803 if (leid_type != reid_type)
18805 errmsg ("remote and local EIDs are of different types!");
18809 M (ONE_ADD_DEL_ADJACENCY, mp);
18810 mp->is_add = is_add;
18811 mp->vni = htonl (vni);
18812 mp->leid_len = leid_len;
18813 mp->reid_len = reid_len;
18814 mp->eid_type = reid_type;
18816 switch (mp->eid_type)
18819 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18820 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18823 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18824 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18827 clib_memcpy (mp->leid, leid_mac, 6);
18828 clib_memcpy (mp->reid, reid_mac, 6);
18831 errmsg ("unknown EID type %d!", mp->eid_type);
18838 /* Wait for a reply... */
18843 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18846 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18848 u32 *mode = va_arg (*args, u32 *);
18850 if (unformat (input, "lisp"))
18852 else if (unformat (input, "vxlan"))
18861 api_gpe_get_encap_mode (vat_main_t * vam)
18863 vl_api_gpe_get_encap_mode_t *mp;
18866 /* Construct the API message */
18867 M (GPE_GET_ENCAP_MODE, mp);
18872 /* Wait for a reply... */
18878 api_gpe_set_encap_mode (vat_main_t * vam)
18880 unformat_input_t *input = vam->input;
18881 vl_api_gpe_set_encap_mode_t *mp;
18885 /* Parse args required to build the message */
18886 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18888 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18894 /* Construct the API message */
18895 M (GPE_SET_ENCAP_MODE, mp);
18902 /* Wait for a reply... */
18908 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18910 unformat_input_t *input = vam->input;
18911 vl_api_gpe_add_del_iface_t *mp;
18912 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18913 u32 dp_table = 0, vni = 0;
18916 /* Parse args required to build the message */
18917 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18919 if (unformat (input, "up"))
18924 else if (unformat (input, "down"))
18929 else if (unformat (input, "table_id %d", &dp_table))
18933 else if (unformat (input, "bd_id %d", &dp_table))
18938 else if (unformat (input, "vni %d", &vni))
18946 if (action_set == 0)
18948 errmsg ("Action not set");
18951 if (dp_table_set == 0 || vni_set == 0)
18953 errmsg ("vni and dp_table must be set");
18957 /* Construct the API message */
18958 M (GPE_ADD_DEL_IFACE, mp);
18960 mp->is_add = is_add;
18961 mp->dp_table = clib_host_to_net_u32 (dp_table);
18963 mp->vni = clib_host_to_net_u32 (vni);
18968 /* Wait for a reply... */
18974 api_one_map_register_fallback_threshold (vat_main_t * vam)
18976 unformat_input_t *input = vam->input;
18977 vl_api_one_map_register_fallback_threshold_t *mp;
18982 /* Parse args required to build the message */
18983 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18985 if (unformat (input, "%u", &value))
18989 clib_warning ("parse error '%U'", format_unformat_error, input);
18996 errmsg ("fallback threshold value is missing!");
19000 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
19001 mp->value = clib_host_to_net_u32 (value);
19006 /* Wait for a reply... */
19012 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
19014 vl_api_show_one_map_register_fallback_threshold_t *mp;
19017 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
19022 /* Wait for a reply... */
19028 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
19030 u32 *proto = va_arg (*args, u32 *);
19032 if (unformat (input, "udp"))
19034 else if (unformat (input, "api"))
19043 api_one_set_transport_protocol (vat_main_t * vam)
19045 unformat_input_t *input = vam->input;
19046 vl_api_one_set_transport_protocol_t *mp;
19051 /* Parse args required to build the message */
19052 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19054 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
19058 clib_warning ("parse error '%U'", format_unformat_error, input);
19065 errmsg ("Transport protocol missing!");
19069 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
19070 mp->protocol = (u8) protocol;
19075 /* Wait for a reply... */
19081 api_one_get_transport_protocol (vat_main_t * vam)
19083 vl_api_one_get_transport_protocol_t *mp;
19086 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
19091 /* Wait for a reply... */
19097 api_one_map_register_set_ttl (vat_main_t * vam)
19099 unformat_input_t *input = vam->input;
19100 vl_api_one_map_register_set_ttl_t *mp;
19105 /* Parse args required to build the message */
19106 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19108 if (unformat (input, "%u", &ttl))
19112 clib_warning ("parse error '%U'", format_unformat_error, input);
19119 errmsg ("TTL value missing!");
19123 M (ONE_MAP_REGISTER_SET_TTL, mp);
19124 mp->ttl = clib_host_to_net_u32 (ttl);
19129 /* Wait for a reply... */
19135 api_show_one_map_register_ttl (vat_main_t * vam)
19137 vl_api_show_one_map_register_ttl_t *mp;
19140 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
19145 /* Wait for a reply... */
19151 * Add/del map request itr rlocs from ONE control plane and updates
19153 * @param vam vpp API test context
19154 * @return return code
19157 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
19159 unformat_input_t *input = vam->input;
19160 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
19161 u8 *locator_set_name = 0;
19162 u8 locator_set_name_set = 0;
19166 /* Parse args required to build the message */
19167 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19169 if (unformat (input, "del"))
19173 else if (unformat (input, "%_%v%_", &locator_set_name))
19175 locator_set_name_set = 1;
19179 clib_warning ("parse error '%U'", format_unformat_error, input);
19184 if (is_add && !locator_set_name_set)
19186 errmsg ("itr-rloc is not set!");
19190 if (is_add && vec_len (locator_set_name) > 64)
19192 errmsg ("itr-rloc locator-set name too long");
19193 vec_free (locator_set_name);
19197 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
19198 mp->is_add = is_add;
19201 clib_memcpy (mp->locator_set_name, locator_set_name,
19202 vec_len (locator_set_name));
19206 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19208 vec_free (locator_set_name);
19213 /* Wait for a reply... */
19218 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19221 api_one_locator_dump (vat_main_t * vam)
19223 unformat_input_t *input = vam->input;
19224 vl_api_one_locator_dump_t *mp;
19225 vl_api_control_ping_t *mp_ping;
19226 u8 is_index_set = 0, is_name_set = 0;
19231 /* Parse args required to build the message */
19232 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19234 if (unformat (input, "ls_name %_%v%_", &ls_name))
19238 else if (unformat (input, "ls_index %d", &ls_index))
19244 errmsg ("parse error '%U'", format_unformat_error, input);
19249 if (!is_index_set && !is_name_set)
19251 errmsg ("error: expected one of index or name!");
19255 if (is_index_set && is_name_set)
19257 errmsg ("error: only one param expected!");
19261 if (vec_len (ls_name) > 62)
19263 errmsg ("error: locator set name too long!");
19267 if (!vam->json_output)
19269 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19272 M (ONE_LOCATOR_DUMP, mp);
19273 mp->is_index_set = is_index_set;
19276 mp->ls_index = clib_host_to_net_u32 (ls_index);
19279 vec_add1 (ls_name, 0);
19280 strncpy ((char *) mp->ls_name, (char *) ls_name,
19281 sizeof (mp->ls_name) - 1);
19287 /* Use a control ping for synchronization */
19288 MPING (CONTROL_PING, mp_ping);
19291 /* Wait for a reply... */
19296 #define api_lisp_locator_dump api_one_locator_dump
19299 api_one_locator_set_dump (vat_main_t * vam)
19301 vl_api_one_locator_set_dump_t *mp;
19302 vl_api_control_ping_t *mp_ping;
19303 unformat_input_t *input = vam->input;
19307 /* Parse args required to build the message */
19308 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19310 if (unformat (input, "local"))
19314 else if (unformat (input, "remote"))
19320 errmsg ("parse error '%U'", format_unformat_error, input);
19325 if (!vam->json_output)
19327 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19330 M (ONE_LOCATOR_SET_DUMP, mp);
19332 mp->filter = filter;
19337 /* Use a control ping for synchronization */
19338 MPING (CONTROL_PING, mp_ping);
19341 /* Wait for a reply... */
19346 #define api_lisp_locator_set_dump api_one_locator_set_dump
19349 api_one_eid_table_map_dump (vat_main_t * vam)
19353 unformat_input_t *input = vam->input;
19354 vl_api_one_eid_table_map_dump_t *mp;
19355 vl_api_control_ping_t *mp_ping;
19358 /* Parse args required to build the message */
19359 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19361 if (unformat (input, "l2"))
19366 else if (unformat (input, "l3"))
19373 errmsg ("parse error '%U'", format_unformat_error, input);
19380 errmsg ("expected one of 'l2' or 'l3' parameter!");
19384 if (!vam->json_output)
19386 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19389 M (ONE_EID_TABLE_MAP_DUMP, mp);
19395 /* Use a control ping for synchronization */
19396 MPING (CONTROL_PING, mp_ping);
19399 /* Wait for a reply... */
19404 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19407 api_one_eid_table_vni_dump (vat_main_t * vam)
19409 vl_api_one_eid_table_vni_dump_t *mp;
19410 vl_api_control_ping_t *mp_ping;
19413 if (!vam->json_output)
19415 print (vam->ofp, "VNI");
19418 M (ONE_EID_TABLE_VNI_DUMP, mp);
19423 /* Use a control ping for synchronization */
19424 MPING (CONTROL_PING, mp_ping);
19427 /* Wait for a reply... */
19432 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19435 api_one_eid_table_dump (vat_main_t * vam)
19437 unformat_input_t *i = vam->input;
19438 vl_api_one_eid_table_dump_t *mp;
19439 vl_api_control_ping_t *mp_ping;
19440 struct in_addr ip4;
19441 struct in6_addr ip6;
19443 u8 eid_type = ~0, eid_set = 0;
19444 u32 prefix_length = ~0, t, vni = 0;
19447 lisp_nsh_api_t nsh;
19449 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19451 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19457 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19463 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19468 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19473 else if (unformat (i, "vni %d", &t))
19477 else if (unformat (i, "local"))
19481 else if (unformat (i, "remote"))
19487 errmsg ("parse error '%U'", format_unformat_error, i);
19492 if (!vam->json_output)
19494 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19495 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19498 M (ONE_EID_TABLE_DUMP, mp);
19500 mp->filter = filter;
19504 mp->vni = htonl (vni);
19505 mp->eid_type = eid_type;
19509 mp->prefix_length = prefix_length;
19510 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19513 mp->prefix_length = prefix_length;
19514 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19517 clib_memcpy (mp->eid, mac, sizeof (mac));
19520 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19523 errmsg ("unknown EID type %d!", eid_type);
19531 /* Use a control ping for synchronization */
19532 MPING (CONTROL_PING, mp_ping);
19535 /* Wait for a reply... */
19540 #define api_lisp_eid_table_dump api_one_eid_table_dump
19543 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19545 unformat_input_t *i = vam->input;
19546 vl_api_gpe_fwd_entries_get_t *mp;
19551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19553 if (unformat (i, "vni %d", &vni))
19559 errmsg ("parse error '%U'", format_unformat_error, i);
19566 errmsg ("vni not set!");
19570 if (!vam->json_output)
19572 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19576 M (GPE_FWD_ENTRIES_GET, mp);
19577 mp->vni = clib_host_to_net_u32 (vni);
19582 /* Wait for a reply... */
19587 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19588 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19589 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19590 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19591 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19592 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19593 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19594 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19597 api_one_adjacencies_get (vat_main_t * vam)
19599 unformat_input_t *i = vam->input;
19600 vl_api_one_adjacencies_get_t *mp;
19605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19607 if (unformat (i, "vni %d", &vni))
19613 errmsg ("parse error '%U'", format_unformat_error, i);
19620 errmsg ("vni not set!");
19624 if (!vam->json_output)
19626 print (vam->ofp, "%s %40s", "leid", "reid");
19629 M (ONE_ADJACENCIES_GET, mp);
19630 mp->vni = clib_host_to_net_u32 (vni);
19635 /* Wait for a reply... */
19640 #define api_lisp_adjacencies_get api_one_adjacencies_get
19643 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19645 unformat_input_t *i = vam->input;
19646 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19648 u8 ip_family_set = 0, is_ip4 = 1;
19650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19652 if (unformat (i, "ip4"))
19657 else if (unformat (i, "ip6"))
19664 errmsg ("parse error '%U'", format_unformat_error, i);
19669 if (!ip_family_set)
19671 errmsg ("ip family not set!");
19675 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19676 mp->is_ip4 = is_ip4;
19681 /* Wait for a reply... */
19687 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19689 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19692 if (!vam->json_output)
19694 print (vam->ofp, "VNIs");
19697 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19702 /* Wait for a reply... */
19708 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19710 unformat_input_t *i = vam->input;
19711 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19713 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19714 struct in_addr ip4;
19715 struct in6_addr ip6;
19716 u32 table_id = 0, nh_sw_if_index = ~0;
19718 clib_memset (&ip4, 0, sizeof (ip4));
19719 clib_memset (&ip6, 0, sizeof (ip6));
19721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19723 if (unformat (i, "del"))
19725 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19726 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19731 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19732 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19737 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19741 nh_sw_if_index = ~0;
19743 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19747 nh_sw_if_index = ~0;
19749 else if (unformat (i, "table %d", &table_id))
19753 errmsg ("parse error '%U'", format_unformat_error, i);
19760 errmsg ("nh addr not set!");
19764 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19765 mp->is_add = is_add;
19766 mp->table_id = clib_host_to_net_u32 (table_id);
19767 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19768 mp->is_ip4 = is_ip4;
19770 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19772 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19777 /* Wait for a reply... */
19783 api_one_map_server_dump (vat_main_t * vam)
19785 vl_api_one_map_server_dump_t *mp;
19786 vl_api_control_ping_t *mp_ping;
19789 if (!vam->json_output)
19791 print (vam->ofp, "%=20s", "Map server");
19794 M (ONE_MAP_SERVER_DUMP, mp);
19798 /* Use a control ping for synchronization */
19799 MPING (CONTROL_PING, mp_ping);
19802 /* Wait for a reply... */
19807 #define api_lisp_map_server_dump api_one_map_server_dump
19810 api_one_map_resolver_dump (vat_main_t * vam)
19812 vl_api_one_map_resolver_dump_t *mp;
19813 vl_api_control_ping_t *mp_ping;
19816 if (!vam->json_output)
19818 print (vam->ofp, "%=20s", "Map resolver");
19821 M (ONE_MAP_RESOLVER_DUMP, mp);
19825 /* Use a control ping for synchronization */
19826 MPING (CONTROL_PING, mp_ping);
19829 /* Wait for a reply... */
19834 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19837 api_one_stats_flush (vat_main_t * vam)
19839 vl_api_one_stats_flush_t *mp;
19842 M (ONE_STATS_FLUSH, mp);
19849 api_one_stats_dump (vat_main_t * vam)
19851 vl_api_one_stats_dump_t *mp;
19852 vl_api_control_ping_t *mp_ping;
19855 M (ONE_STATS_DUMP, mp);
19859 /* Use a control ping for synchronization */
19860 MPING (CONTROL_PING, mp_ping);
19863 /* Wait for a reply... */
19869 api_show_one_status (vat_main_t * vam)
19871 vl_api_show_one_status_t *mp;
19874 if (!vam->json_output)
19876 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19879 M (SHOW_ONE_STATUS, mp);
19882 /* Wait for a reply... */
19887 #define api_show_lisp_status api_show_one_status
19890 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19892 vl_api_gpe_fwd_entry_path_dump_t *mp;
19893 vl_api_control_ping_t *mp_ping;
19894 unformat_input_t *i = vam->input;
19895 u32 fwd_entry_index = ~0;
19898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19900 if (unformat (i, "index %d", &fwd_entry_index))
19906 if (~0 == fwd_entry_index)
19908 errmsg ("no index specified!");
19912 if (!vam->json_output)
19914 print (vam->ofp, "first line");
19917 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19921 /* Use a control ping for synchronization */
19922 MPING (CONTROL_PING, mp_ping);
19925 /* Wait for a reply... */
19931 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19933 vl_api_one_get_map_request_itr_rlocs_t *mp;
19936 if (!vam->json_output)
19938 print (vam->ofp, "%=20s", "itr-rlocs:");
19941 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19944 /* Wait for a reply... */
19949 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19952 api_af_packet_create (vat_main_t * vam)
19954 unformat_input_t *i = vam->input;
19955 vl_api_af_packet_create_t *mp;
19956 u8 *host_if_name = 0;
19958 u8 random_hw_addr = 1;
19961 clib_memset (hw_addr, 0, sizeof (hw_addr));
19963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19965 if (unformat (i, "name %s", &host_if_name))
19966 vec_add1 (host_if_name, 0);
19967 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19968 random_hw_addr = 0;
19973 if (!vec_len (host_if_name))
19975 errmsg ("host-interface name must be specified");
19979 if (vec_len (host_if_name) > 64)
19981 errmsg ("host-interface name too long");
19985 M (AF_PACKET_CREATE, mp);
19987 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19988 clib_memcpy (mp->hw_addr, hw_addr, 6);
19989 mp->use_random_hw_addr = random_hw_addr;
19990 vec_free (host_if_name);
19998 fprintf (vam->ofp ? vam->ofp : stderr,
19999 " new sw_if_index = %d\n", vam->sw_if_index);
20006 api_af_packet_delete (vat_main_t * vam)
20008 unformat_input_t *i = vam->input;
20009 vl_api_af_packet_delete_t *mp;
20010 u8 *host_if_name = 0;
20013 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20015 if (unformat (i, "name %s", &host_if_name))
20016 vec_add1 (host_if_name, 0);
20021 if (!vec_len (host_if_name))
20023 errmsg ("host-interface name must be specified");
20027 if (vec_len (host_if_name) > 64)
20029 errmsg ("host-interface name too long");
20033 M (AF_PACKET_DELETE, mp);
20035 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
20036 vec_free (host_if_name);
20043 static void vl_api_af_packet_details_t_handler
20044 (vl_api_af_packet_details_t * mp)
20046 vat_main_t *vam = &vat_main;
20048 print (vam->ofp, "%-16s %d",
20049 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
20052 static void vl_api_af_packet_details_t_handler_json
20053 (vl_api_af_packet_details_t * mp)
20055 vat_main_t *vam = &vat_main;
20056 vat_json_node_t *node = NULL;
20058 if (VAT_JSON_ARRAY != vam->json_tree.type)
20060 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20061 vat_json_init_array (&vam->json_tree);
20063 node = vat_json_array_add (&vam->json_tree);
20065 vat_json_init_object (node);
20066 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20067 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
20071 api_af_packet_dump (vat_main_t * vam)
20073 vl_api_af_packet_dump_t *mp;
20074 vl_api_control_ping_t *mp_ping;
20077 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
20078 /* Get list of tap interfaces */
20079 M (AF_PACKET_DUMP, mp);
20082 /* Use a control ping for synchronization */
20083 MPING (CONTROL_PING, mp_ping);
20091 api_policer_add_del (vat_main_t * vam)
20093 unformat_input_t *i = vam->input;
20094 vl_api_policer_add_del_t *mp;
20104 u8 color_aware = 0;
20105 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
20108 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
20109 conform_action.dscp = 0;
20110 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
20111 exceed_action.dscp = 0;
20112 violate_action.action_type = SSE2_QOS_ACTION_DROP;
20113 violate_action.dscp = 0;
20115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20117 if (unformat (i, "del"))
20119 else if (unformat (i, "name %s", &name))
20120 vec_add1 (name, 0);
20121 else if (unformat (i, "cir %u", &cir))
20123 else if (unformat (i, "eir %u", &eir))
20125 else if (unformat (i, "cb %u", &cb))
20127 else if (unformat (i, "eb %u", &eb))
20129 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
20132 else if (unformat (i, "round_type %U", unformat_policer_round_type,
20135 else if (unformat (i, "type %U", unformat_policer_type, &type))
20137 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
20140 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
20143 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
20146 else if (unformat (i, "color-aware"))
20152 if (!vec_len (name))
20154 errmsg ("policer name must be specified");
20158 if (vec_len (name) > 64)
20160 errmsg ("policer name too long");
20164 M (POLICER_ADD_DEL, mp);
20166 clib_memcpy (mp->name, name, vec_len (name));
20168 mp->is_add = is_add;
20169 mp->cir = ntohl (cir);
20170 mp->eir = ntohl (eir);
20171 mp->cb = clib_net_to_host_u64 (cb);
20172 mp->eb = clib_net_to_host_u64 (eb);
20173 mp->rate_type = rate_type;
20174 mp->round_type = round_type;
20176 mp->conform_action_type = conform_action.action_type;
20177 mp->conform_dscp = conform_action.dscp;
20178 mp->exceed_action_type = exceed_action.action_type;
20179 mp->exceed_dscp = exceed_action.dscp;
20180 mp->violate_action_type = violate_action.action_type;
20181 mp->violate_dscp = violate_action.dscp;
20182 mp->color_aware = color_aware;
20190 api_policer_dump (vat_main_t * vam)
20192 unformat_input_t *i = vam->input;
20193 vl_api_policer_dump_t *mp;
20194 vl_api_control_ping_t *mp_ping;
20195 u8 *match_name = 0;
20196 u8 match_name_valid = 0;
20199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20201 if (unformat (i, "name %s", &match_name))
20203 vec_add1 (match_name, 0);
20204 match_name_valid = 1;
20210 M (POLICER_DUMP, mp);
20211 mp->match_name_valid = match_name_valid;
20212 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
20213 vec_free (match_name);
20217 /* Use a control ping for synchronization */
20218 MPING (CONTROL_PING, mp_ping);
20221 /* Wait for a reply... */
20227 api_policer_classify_set_interface (vat_main_t * vam)
20229 unformat_input_t *i = vam->input;
20230 vl_api_policer_classify_set_interface_t *mp;
20232 int sw_if_index_set;
20233 u32 ip4_table_index = ~0;
20234 u32 ip6_table_index = ~0;
20235 u32 l2_table_index = ~0;
20239 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20241 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20242 sw_if_index_set = 1;
20243 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20244 sw_if_index_set = 1;
20245 else if (unformat (i, "del"))
20247 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20249 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20251 else if (unformat (i, "l2-table %d", &l2_table_index))
20255 clib_warning ("parse error '%U'", format_unformat_error, i);
20260 if (sw_if_index_set == 0)
20262 errmsg ("missing interface name or sw_if_index");
20266 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20268 mp->sw_if_index = ntohl (sw_if_index);
20269 mp->ip4_table_index = ntohl (ip4_table_index);
20270 mp->ip6_table_index = ntohl (ip6_table_index);
20271 mp->l2_table_index = ntohl (l2_table_index);
20272 mp->is_add = is_add;
20280 api_policer_classify_dump (vat_main_t * vam)
20282 unformat_input_t *i = vam->input;
20283 vl_api_policer_classify_dump_t *mp;
20284 vl_api_control_ping_t *mp_ping;
20285 u8 type = POLICER_CLASSIFY_N_TABLES;
20288 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20292 errmsg ("classify table type must be specified");
20296 if (!vam->json_output)
20298 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20301 M (POLICER_CLASSIFY_DUMP, mp);
20306 /* Use a control ping for synchronization */
20307 MPING (CONTROL_PING, mp_ping);
20310 /* Wait for a reply... */
20316 api_netmap_create (vat_main_t * vam)
20318 unformat_input_t *i = vam->input;
20319 vl_api_netmap_create_t *mp;
20322 u8 random_hw_addr = 1;
20327 clib_memset (hw_addr, 0, sizeof (hw_addr));
20329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20331 if (unformat (i, "name %s", &if_name))
20332 vec_add1 (if_name, 0);
20333 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20334 random_hw_addr = 0;
20335 else if (unformat (i, "pipe"))
20337 else if (unformat (i, "master"))
20339 else if (unformat (i, "slave"))
20345 if (!vec_len (if_name))
20347 errmsg ("interface name must be specified");
20351 if (vec_len (if_name) > 64)
20353 errmsg ("interface name too long");
20357 M (NETMAP_CREATE, mp);
20359 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20360 clib_memcpy (mp->hw_addr, hw_addr, 6);
20361 mp->use_random_hw_addr = random_hw_addr;
20362 mp->is_pipe = is_pipe;
20363 mp->is_master = is_master;
20364 vec_free (if_name);
20372 api_netmap_delete (vat_main_t * vam)
20374 unformat_input_t *i = vam->input;
20375 vl_api_netmap_delete_t *mp;
20379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20381 if (unformat (i, "name %s", &if_name))
20382 vec_add1 (if_name, 0);
20387 if (!vec_len (if_name))
20389 errmsg ("interface name must be specified");
20393 if (vec_len (if_name) > 64)
20395 errmsg ("interface name too long");
20399 M (NETMAP_DELETE, mp);
20401 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20402 vec_free (if_name);
20410 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20412 if (fp->afi == IP46_TYPE_IP6)
20414 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20415 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20416 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
20417 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20418 format_ip6_address, fp->next_hop);
20419 else if (fp->afi == IP46_TYPE_IP4)
20421 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20422 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20423 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
20424 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20425 format_ip4_address, fp->next_hop);
20429 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20430 vl_api_fib_path_t * fp)
20432 struct in_addr ip4;
20433 struct in6_addr ip6;
20435 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20436 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20437 vat_json_object_add_uint (node, "is_local", fp->is_local);
20438 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20439 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20440 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20441 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20442 if (fp->afi == IP46_TYPE_IP4)
20444 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20445 vat_json_object_add_ip4 (node, "next_hop", ip4);
20447 else if (fp->afi == IP46_TYPE_IP6)
20449 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20450 vat_json_object_add_ip6 (node, "next_hop", ip6);
20455 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20457 vat_main_t *vam = &vat_main;
20458 int count = ntohl (mp->mt_count);
20459 vl_api_fib_path_t *fp;
20462 print (vam->ofp, "[%d]: sw_if_index %d via:",
20463 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20465 for (i = 0; i < count; i++)
20467 vl_api_mpls_fib_path_print (vam, fp);
20471 print (vam->ofp, "");
20474 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20475 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20478 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20480 vat_main_t *vam = &vat_main;
20481 vat_json_node_t *node = NULL;
20482 int count = ntohl (mp->mt_count);
20483 vl_api_fib_path_t *fp;
20486 if (VAT_JSON_ARRAY != vam->json_tree.type)
20488 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20489 vat_json_init_array (&vam->json_tree);
20491 node = vat_json_array_add (&vam->json_tree);
20493 vat_json_init_object (node);
20494 vat_json_object_add_uint (node, "tunnel_index",
20495 ntohl (mp->mt_tunnel_index));
20496 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20498 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20501 for (i = 0; i < count; i++)
20503 vl_api_mpls_fib_path_json_print (node, fp);
20509 api_mpls_tunnel_dump (vat_main_t * vam)
20511 vl_api_mpls_tunnel_dump_t *mp;
20512 vl_api_control_ping_t *mp_ping;
20513 u32 sw_if_index = ~0;
20516 /* Parse args required to build the message */
20517 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20519 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
20523 print (vam->ofp, " sw_if_index %d", sw_if_index);
20525 M (MPLS_TUNNEL_DUMP, mp);
20526 mp->sw_if_index = htonl (sw_if_index);
20529 /* Use a control ping for synchronization */
20530 MPING (CONTROL_PING, mp_ping);
20537 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20538 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20542 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20544 vat_main_t *vam = &vat_main;
20545 int count = ntohl (mp->count);
20546 vl_api_fib_path_t *fp;
20550 "table-id %d, label %u, ess_bit %u",
20551 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20553 for (i = 0; i < count; i++)
20555 vl_api_mpls_fib_path_print (vam, fp);
20560 static void vl_api_mpls_fib_details_t_handler_json
20561 (vl_api_mpls_fib_details_t * mp)
20563 vat_main_t *vam = &vat_main;
20564 int count = ntohl (mp->count);
20565 vat_json_node_t *node = NULL;
20566 vl_api_fib_path_t *fp;
20569 if (VAT_JSON_ARRAY != vam->json_tree.type)
20571 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20572 vat_json_init_array (&vam->json_tree);
20574 node = vat_json_array_add (&vam->json_tree);
20576 vat_json_init_object (node);
20577 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20578 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20579 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20580 vat_json_object_add_uint (node, "path_count", count);
20582 for (i = 0; i < count; i++)
20584 vl_api_mpls_fib_path_json_print (node, fp);
20590 api_mpls_fib_dump (vat_main_t * vam)
20592 vl_api_mpls_fib_dump_t *mp;
20593 vl_api_control_ping_t *mp_ping;
20596 M (MPLS_FIB_DUMP, mp);
20599 /* Use a control ping for synchronization */
20600 MPING (CONTROL_PING, mp_ping);
20607 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20608 #define vl_api_ip_fib_details_t_print vl_noop_handler
20611 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20613 vat_main_t *vam = &vat_main;
20614 int count = ntohl (mp->count);
20615 vl_api_fib_path_t *fp;
20619 "table-id %d, prefix %U/%d stats-index %d",
20620 ntohl (mp->table_id), format_ip4_address, mp->address,
20621 mp->address_length, ntohl (mp->stats_index));
20623 for (i = 0; i < count; i++)
20625 if (fp->afi == IP46_TYPE_IP6)
20627 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20628 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20629 "next_hop_table %d",
20630 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20631 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20632 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20633 else if (fp->afi == IP46_TYPE_IP4)
20635 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20636 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20637 "next_hop_table %d",
20638 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20639 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20640 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20645 static void vl_api_ip_fib_details_t_handler_json
20646 (vl_api_ip_fib_details_t * mp)
20648 vat_main_t *vam = &vat_main;
20649 int count = ntohl (mp->count);
20650 vat_json_node_t *node = NULL;
20651 struct in_addr ip4;
20652 struct in6_addr ip6;
20653 vl_api_fib_path_t *fp;
20656 if (VAT_JSON_ARRAY != vam->json_tree.type)
20658 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20659 vat_json_init_array (&vam->json_tree);
20661 node = vat_json_array_add (&vam->json_tree);
20663 vat_json_init_object (node);
20664 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20665 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20666 vat_json_object_add_ip4 (node, "prefix", ip4);
20667 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20668 vat_json_object_add_uint (node, "path_count", count);
20670 for (i = 0; i < count; i++)
20672 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20673 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20674 vat_json_object_add_uint (node, "is_local", fp->is_local);
20675 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20676 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20677 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20678 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20679 if (fp->afi == IP46_TYPE_IP4)
20681 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20682 vat_json_object_add_ip4 (node, "next_hop", ip4);
20684 else if (fp->afi == IP46_TYPE_IP6)
20686 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20687 vat_json_object_add_ip6 (node, "next_hop", ip6);
20693 api_ip_fib_dump (vat_main_t * vam)
20695 vl_api_ip_fib_dump_t *mp;
20696 vl_api_control_ping_t *mp_ping;
20699 M (IP_FIB_DUMP, mp);
20702 /* Use a control ping for synchronization */
20703 MPING (CONTROL_PING, mp_ping);
20711 api_ip_mfib_dump (vat_main_t * vam)
20713 vl_api_ip_mfib_dump_t *mp;
20714 vl_api_control_ping_t *mp_ping;
20717 M (IP_MFIB_DUMP, mp);
20720 /* Use a control ping for synchronization */
20721 MPING (CONTROL_PING, mp_ping);
20728 static void vl_api_ip_neighbor_details_t_handler
20729 (vl_api_ip_neighbor_details_t * mp)
20731 vat_main_t *vam = &vat_main;
20733 print (vam->ofp, "%c %U %U",
20734 (mp->is_static) ? 'S' : 'D',
20735 format_ethernet_address, &mp->mac_address,
20736 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20740 static void vl_api_ip_neighbor_details_t_handler_json
20741 (vl_api_ip_neighbor_details_t * mp)
20744 vat_main_t *vam = &vat_main;
20745 vat_json_node_t *node;
20746 struct in_addr ip4;
20747 struct in6_addr ip6;
20749 if (VAT_JSON_ARRAY != vam->json_tree.type)
20751 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20752 vat_json_init_array (&vam->json_tree);
20754 node = vat_json_array_add (&vam->json_tree);
20756 vat_json_init_object (node);
20757 vat_json_object_add_string_copy (node, "flag",
20758 (mp->is_static) ? (u8 *) "static" : (u8 *)
20761 vat_json_object_add_string_copy (node, "link_layer",
20762 format (0, "%U", format_ethernet_address,
20763 &mp->mac_address));
20767 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20768 vat_json_object_add_ip6 (node, "ip_address", ip6);
20772 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20773 vat_json_object_add_ip4 (node, "ip_address", ip4);
20778 api_ip_neighbor_dump (vat_main_t * vam)
20780 unformat_input_t *i = vam->input;
20781 vl_api_ip_neighbor_dump_t *mp;
20782 vl_api_control_ping_t *mp_ping;
20784 u32 sw_if_index = ~0;
20787 /* Parse args required to build the message */
20788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20790 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20792 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20794 else if (unformat (i, "ip6"))
20800 if (sw_if_index == ~0)
20802 errmsg ("missing interface name or sw_if_index");
20806 M (IP_NEIGHBOR_DUMP, mp);
20807 mp->is_ipv6 = (u8) is_ipv6;
20808 mp->sw_if_index = ntohl (sw_if_index);
20811 /* Use a control ping for synchronization */
20812 MPING (CONTROL_PING, mp_ping);
20819 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20820 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20823 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20825 vat_main_t *vam = &vat_main;
20826 int count = ntohl (mp->count);
20827 vl_api_fib_path_t *fp;
20831 "table-id %d, prefix %U/%d stats-index %d",
20832 ntohl (mp->table_id), format_ip6_address, mp->address,
20833 mp->address_length, ntohl (mp->stats_index));
20835 for (i = 0; i < count; i++)
20837 if (fp->afi == IP46_TYPE_IP6)
20839 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20840 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20841 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20842 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20843 format_ip6_address, fp->next_hop);
20844 else if (fp->afi == IP46_TYPE_IP4)
20846 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20847 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20848 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20849 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20850 format_ip4_address, fp->next_hop);
20855 static void vl_api_ip6_fib_details_t_handler_json
20856 (vl_api_ip6_fib_details_t * mp)
20858 vat_main_t *vam = &vat_main;
20859 int count = ntohl (mp->count);
20860 vat_json_node_t *node = NULL;
20861 struct in_addr ip4;
20862 struct in6_addr ip6;
20863 vl_api_fib_path_t *fp;
20866 if (VAT_JSON_ARRAY != vam->json_tree.type)
20868 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20869 vat_json_init_array (&vam->json_tree);
20871 node = vat_json_array_add (&vam->json_tree);
20873 vat_json_init_object (node);
20874 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20875 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20876 vat_json_object_add_ip6 (node, "prefix", ip6);
20877 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20878 vat_json_object_add_uint (node, "path_count", count);
20880 for (i = 0; i < count; i++)
20882 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20883 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20884 vat_json_object_add_uint (node, "is_local", fp->is_local);
20885 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20886 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20887 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20888 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20889 if (fp->afi == IP46_TYPE_IP4)
20891 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20892 vat_json_object_add_ip4 (node, "next_hop", ip4);
20894 else if (fp->afi == IP46_TYPE_IP6)
20896 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20897 vat_json_object_add_ip6 (node, "next_hop", ip6);
20903 api_ip6_fib_dump (vat_main_t * vam)
20905 vl_api_ip6_fib_dump_t *mp;
20906 vl_api_control_ping_t *mp_ping;
20909 M (IP6_FIB_DUMP, mp);
20912 /* Use a control ping for synchronization */
20913 MPING (CONTROL_PING, mp_ping);
20921 api_ip6_mfib_dump (vat_main_t * vam)
20923 vl_api_ip6_mfib_dump_t *mp;
20924 vl_api_control_ping_t *mp_ping;
20927 M (IP6_MFIB_DUMP, mp);
20930 /* Use a control ping for synchronization */
20931 MPING (CONTROL_PING, mp_ping);
20939 api_classify_table_ids (vat_main_t * vam)
20941 vl_api_classify_table_ids_t *mp;
20944 /* Construct the API message */
20945 M (CLASSIFY_TABLE_IDS, mp);
20954 api_classify_table_by_interface (vat_main_t * vam)
20956 unformat_input_t *input = vam->input;
20957 vl_api_classify_table_by_interface_t *mp;
20959 u32 sw_if_index = ~0;
20961 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20963 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20965 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20970 if (sw_if_index == ~0)
20972 errmsg ("missing interface name or sw_if_index");
20976 /* Construct the API message */
20977 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20979 mp->sw_if_index = ntohl (sw_if_index);
20987 api_classify_table_info (vat_main_t * vam)
20989 unformat_input_t *input = vam->input;
20990 vl_api_classify_table_info_t *mp;
20994 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20996 if (unformat (input, "table_id %d", &table_id))
21001 if (table_id == ~0)
21003 errmsg ("missing table id");
21007 /* Construct the API message */
21008 M (CLASSIFY_TABLE_INFO, mp);
21010 mp->table_id = ntohl (table_id);
21018 api_classify_session_dump (vat_main_t * vam)
21020 unformat_input_t *input = vam->input;
21021 vl_api_classify_session_dump_t *mp;
21022 vl_api_control_ping_t *mp_ping;
21026 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21028 if (unformat (input, "table_id %d", &table_id))
21033 if (table_id == ~0)
21035 errmsg ("missing table id");
21039 /* Construct the API message */
21040 M (CLASSIFY_SESSION_DUMP, mp);
21042 mp->table_id = ntohl (table_id);
21045 /* Use a control ping for synchronization */
21046 MPING (CONTROL_PING, mp_ping);
21054 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
21056 vat_main_t *vam = &vat_main;
21058 print (vam->ofp, "collector_address %U, collector_port %d, "
21059 "src_address %U, vrf_id %d, path_mtu %u, "
21060 "template_interval %u, udp_checksum %d",
21061 format_ip4_address, mp->collector_address,
21062 ntohs (mp->collector_port),
21063 format_ip4_address, mp->src_address,
21064 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
21065 ntohl (mp->template_interval), mp->udp_checksum);
21068 vam->result_ready = 1;
21072 vl_api_ipfix_exporter_details_t_handler_json
21073 (vl_api_ipfix_exporter_details_t * mp)
21075 vat_main_t *vam = &vat_main;
21076 vat_json_node_t node;
21077 struct in_addr collector_address;
21078 struct in_addr src_address;
21080 vat_json_init_object (&node);
21081 clib_memcpy (&collector_address, &mp->collector_address,
21082 sizeof (collector_address));
21083 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
21084 vat_json_object_add_uint (&node, "collector_port",
21085 ntohs (mp->collector_port));
21086 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
21087 vat_json_object_add_ip4 (&node, "src_address", src_address);
21088 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
21089 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
21090 vat_json_object_add_uint (&node, "template_interval",
21091 ntohl (mp->template_interval));
21092 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
21094 vat_json_print (vam->ofp, &node);
21095 vat_json_free (&node);
21097 vam->result_ready = 1;
21101 api_ipfix_exporter_dump (vat_main_t * vam)
21103 vl_api_ipfix_exporter_dump_t *mp;
21106 /* Construct the API message */
21107 M (IPFIX_EXPORTER_DUMP, mp);
21116 api_ipfix_classify_stream_dump (vat_main_t * vam)
21118 vl_api_ipfix_classify_stream_dump_t *mp;
21121 /* Construct the API message */
21122 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
21133 vl_api_ipfix_classify_stream_details_t_handler
21134 (vl_api_ipfix_classify_stream_details_t * mp)
21136 vat_main_t *vam = &vat_main;
21137 print (vam->ofp, "domain_id %d, src_port %d",
21138 ntohl (mp->domain_id), ntohs (mp->src_port));
21140 vam->result_ready = 1;
21144 vl_api_ipfix_classify_stream_details_t_handler_json
21145 (vl_api_ipfix_classify_stream_details_t * mp)
21147 vat_main_t *vam = &vat_main;
21148 vat_json_node_t node;
21150 vat_json_init_object (&node);
21151 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
21152 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
21154 vat_json_print (vam->ofp, &node);
21155 vat_json_free (&node);
21157 vam->result_ready = 1;
21161 api_ipfix_classify_table_dump (vat_main_t * vam)
21163 vl_api_ipfix_classify_table_dump_t *mp;
21164 vl_api_control_ping_t *mp_ping;
21167 if (!vam->json_output)
21169 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
21170 "transport_protocol");
21173 /* Construct the API message */
21174 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
21179 /* Use a control ping for synchronization */
21180 MPING (CONTROL_PING, mp_ping);
21188 vl_api_ipfix_classify_table_details_t_handler
21189 (vl_api_ipfix_classify_table_details_t * mp)
21191 vat_main_t *vam = &vat_main;
21192 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
21193 mp->transport_protocol);
21197 vl_api_ipfix_classify_table_details_t_handler_json
21198 (vl_api_ipfix_classify_table_details_t * mp)
21200 vat_json_node_t *node = NULL;
21201 vat_main_t *vam = &vat_main;
21203 if (VAT_JSON_ARRAY != vam->json_tree.type)
21205 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21206 vat_json_init_array (&vam->json_tree);
21209 node = vat_json_array_add (&vam->json_tree);
21210 vat_json_init_object (node);
21212 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
21213 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
21214 vat_json_object_add_uint (node, "transport_protocol",
21215 mp->transport_protocol);
21219 api_sw_interface_span_enable_disable (vat_main_t * vam)
21221 unformat_input_t *i = vam->input;
21222 vl_api_sw_interface_span_enable_disable_t *mp;
21223 u32 src_sw_if_index = ~0;
21224 u32 dst_sw_if_index = ~0;
21229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21232 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21234 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21238 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21240 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21242 else if (unformat (i, "disable"))
21244 else if (unformat (i, "rx"))
21246 else if (unformat (i, "tx"))
21248 else if (unformat (i, "both"))
21250 else if (unformat (i, "l2"))
21256 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21258 mp->sw_if_index_from = htonl (src_sw_if_index);
21259 mp->sw_if_index_to = htonl (dst_sw_if_index);
21269 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21272 vat_main_t *vam = &vat_main;
21273 u8 *sw_if_from_name = 0;
21274 u8 *sw_if_to_name = 0;
21275 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21276 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21277 char *states[] = { "none", "rx", "tx", "both" };
21281 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21283 if ((u32) p->value[0] == sw_if_index_from)
21285 sw_if_from_name = (u8 *)(p->key);
21289 if ((u32) p->value[0] == sw_if_index_to)
21291 sw_if_to_name = (u8 *)(p->key);
21292 if (sw_if_from_name)
21297 print (vam->ofp, "%20s => %20s (%s) %s",
21298 sw_if_from_name, sw_if_to_name, states[mp->state],
21299 mp->is_l2 ? "l2" : "device");
21303 vl_api_sw_interface_span_details_t_handler_json
21304 (vl_api_sw_interface_span_details_t * mp)
21306 vat_main_t *vam = &vat_main;
21307 vat_json_node_t *node = NULL;
21308 u8 *sw_if_from_name = 0;
21309 u8 *sw_if_to_name = 0;
21310 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21311 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21315 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21317 if ((u32) p->value[0] == sw_if_index_from)
21319 sw_if_from_name = (u8 *)(p->key);
21323 if ((u32) p->value[0] == sw_if_index_to)
21325 sw_if_to_name = (u8 *)(p->key);
21326 if (sw_if_from_name)
21332 if (VAT_JSON_ARRAY != vam->json_tree.type)
21334 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21335 vat_json_init_array (&vam->json_tree);
21337 node = vat_json_array_add (&vam->json_tree);
21339 vat_json_init_object (node);
21340 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21341 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21342 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21343 if (0 != sw_if_to_name)
21345 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21347 vat_json_object_add_uint (node, "state", mp->state);
21348 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21352 api_sw_interface_span_dump (vat_main_t * vam)
21354 unformat_input_t *input = vam->input;
21355 vl_api_sw_interface_span_dump_t *mp;
21356 vl_api_control_ping_t *mp_ping;
21360 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21362 if (unformat (input, "l2"))
21368 M (SW_INTERFACE_SPAN_DUMP, mp);
21372 /* Use a control ping for synchronization */
21373 MPING (CONTROL_PING, mp_ping);
21381 api_pg_create_interface (vat_main_t * vam)
21383 unformat_input_t *input = vam->input;
21384 vl_api_pg_create_interface_t *mp;
21388 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21390 if (unformat (input, "if_id %d", &if_id))
21397 errmsg ("missing pg interface index");
21401 /* Construct the API message */
21402 M (PG_CREATE_INTERFACE, mp);
21404 mp->interface_id = ntohl (if_id);
21412 api_pg_capture (vat_main_t * vam)
21414 unformat_input_t *input = vam->input;
21415 vl_api_pg_capture_t *mp;
21420 u8 pcap_file_set = 0;
21423 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21425 if (unformat (input, "if_id %d", &if_id))
21427 else if (unformat (input, "pcap %s", &pcap_file))
21429 else if (unformat (input, "count %d", &count))
21431 else if (unformat (input, "disable"))
21438 errmsg ("missing pg interface index");
21441 if (pcap_file_set > 0)
21443 if (vec_len (pcap_file) > 255)
21445 errmsg ("pcap file name is too long");
21450 u32 name_len = vec_len (pcap_file);
21451 /* Construct the API message */
21452 M (PG_CAPTURE, mp);
21454 mp->interface_id = ntohl (if_id);
21455 mp->is_enabled = enable;
21456 mp->count = ntohl (count);
21457 mp->pcap_name_length = ntohl (name_len);
21458 if (pcap_file_set != 0)
21460 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21462 vec_free (pcap_file);
21470 api_pg_enable_disable (vat_main_t * vam)
21472 unformat_input_t *input = vam->input;
21473 vl_api_pg_enable_disable_t *mp;
21476 u8 stream_name_set = 0;
21477 u8 *stream_name = 0;
21479 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21481 if (unformat (input, "stream %s", &stream_name))
21482 stream_name_set = 1;
21483 else if (unformat (input, "disable"))
21489 if (stream_name_set > 0)
21491 if (vec_len (stream_name) > 255)
21493 errmsg ("stream name too long");
21498 u32 name_len = vec_len (stream_name);
21499 /* Construct the API message */
21500 M (PG_ENABLE_DISABLE, mp);
21502 mp->is_enabled = enable;
21503 if (stream_name_set != 0)
21505 mp->stream_name_length = ntohl (name_len);
21506 clib_memcpy (mp->stream_name, stream_name, name_len);
21508 vec_free (stream_name);
21516 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21518 unformat_input_t *input = vam->input;
21519 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21521 u16 *low_ports = 0;
21522 u16 *high_ports = 0;
21525 ip4_address_t ip4_addr;
21526 ip6_address_t ip6_addr;
21535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21537 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21543 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21548 else if (unformat (input, "vrf %d", &vrf_id))
21550 else if (unformat (input, "del"))
21552 else if (unformat (input, "port %d", &tmp))
21554 if (tmp == 0 || tmp > 65535)
21556 errmsg ("port %d out of range", tmp);
21560 this_hi = this_low + 1;
21561 vec_add1 (low_ports, this_low);
21562 vec_add1 (high_ports, this_hi);
21564 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21566 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21568 errmsg ("incorrect range parameters");
21572 /* Note: in debug CLI +1 is added to high before
21573 passing to real fn that does "the work"
21574 (ip_source_and_port_range_check_add_del).
21575 This fn is a wrapper around the binary API fn a
21576 control plane will call, which expects this increment
21577 to have occurred. Hence letting the binary API control
21578 plane fn do the increment for consistency between VAT
21579 and other control planes.
21582 vec_add1 (low_ports, this_low);
21583 vec_add1 (high_ports, this_hi);
21589 if (prefix_set == 0)
21591 errmsg ("<address>/<mask> not specified");
21597 errmsg ("VRF ID required, not specified");
21604 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21608 if (vec_len (low_ports) == 0)
21610 errmsg ("At least one port or port range required");
21614 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21616 mp->is_add = is_add;
21621 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21626 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21629 mp->mask_length = length;
21630 mp->number_of_ranges = vec_len (low_ports);
21632 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21633 vec_free (low_ports);
21635 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21636 vec_free (high_ports);
21638 mp->vrf_id = ntohl (vrf_id);
21646 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21648 unformat_input_t *input = vam->input;
21649 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21650 u32 sw_if_index = ~0;
21652 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21653 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21657 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21659 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21661 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21663 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21665 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21667 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21669 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21671 else if (unformat (input, "del"))
21677 if (sw_if_index == ~0)
21679 errmsg ("Interface required but not specified");
21685 errmsg ("VRF ID required but not specified");
21689 if (tcp_out_vrf_id == 0
21690 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21693 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21697 /* Construct the API message */
21698 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21700 mp->sw_if_index = ntohl (sw_if_index);
21701 mp->is_add = is_add;
21702 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21703 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21704 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21705 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21710 /* Wait for a reply... */
21716 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21718 unformat_input_t *i = vam->input;
21719 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21720 u32 local_sa_id = 0;
21721 u32 remote_sa_id = 0;
21722 ip4_address_t src_address;
21723 ip4_address_t dst_address;
21727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21729 if (unformat (i, "local_sa %d", &local_sa_id))
21731 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21733 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21735 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21737 else if (unformat (i, "del"))
21741 clib_warning ("parse error '%U'", format_unformat_error, i);
21746 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21748 mp->local_sa_id = ntohl (local_sa_id);
21749 mp->remote_sa_id = ntohl (remote_sa_id);
21750 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21751 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21752 mp->is_add = is_add;
21760 api_set_punt (vat_main_t * vam)
21762 unformat_input_t *i = vam->input;
21763 vl_api_set_punt_t *mp;
21770 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21772 if (unformat (i, "ip %d", &ipv))
21774 else if (unformat (i, "protocol %d", &protocol))
21776 else if (unformat (i, "port %d", &port))
21778 else if (unformat (i, "del"))
21782 clib_warning ("parse error '%U'", format_unformat_error, i);
21789 mp->is_add = (u8) is_add;
21790 mp->punt.ipv = (u8) ipv;
21791 mp->punt.l4_protocol = (u8) protocol;
21792 mp->punt.l4_port = htons ((u16) port);
21799 static void vl_api_ipsec_gre_tunnel_details_t_handler
21800 (vl_api_ipsec_gre_tunnel_details_t * mp)
21802 vat_main_t *vam = &vat_main;
21804 print (vam->ofp, "%11d%15U%15U%14d%14d",
21805 ntohl (mp->sw_if_index),
21806 format_ip4_address, &mp->src_address,
21807 format_ip4_address, &mp->dst_address,
21808 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21811 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21812 (vl_api_ipsec_gre_tunnel_details_t * mp)
21814 vat_main_t *vam = &vat_main;
21815 vat_json_node_t *node = NULL;
21816 struct in_addr ip4;
21818 if (VAT_JSON_ARRAY != vam->json_tree.type)
21820 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21821 vat_json_init_array (&vam->json_tree);
21823 node = vat_json_array_add (&vam->json_tree);
21825 vat_json_init_object (node);
21826 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21827 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21828 vat_json_object_add_ip4 (node, "src_address", ip4);
21829 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21830 vat_json_object_add_ip4 (node, "dst_address", ip4);
21831 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21832 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21836 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21838 unformat_input_t *i = vam->input;
21839 vl_api_ipsec_gre_tunnel_dump_t *mp;
21840 vl_api_control_ping_t *mp_ping;
21842 u8 sw_if_index_set = 0;
21845 /* Parse args required to build the message */
21846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21848 if (unformat (i, "sw_if_index %d", &sw_if_index))
21849 sw_if_index_set = 1;
21854 if (sw_if_index_set == 0)
21859 if (!vam->json_output)
21861 print (vam->ofp, "%11s%15s%15s%14s%14s",
21862 "sw_if_index", "src_address", "dst_address",
21863 "local_sa_id", "remote_sa_id");
21866 /* Get list of gre-tunnel interfaces */
21867 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21869 mp->sw_if_index = htonl (sw_if_index);
21873 /* Use a control ping for synchronization */
21874 MPING (CONTROL_PING, mp_ping);
21882 api_delete_subif (vat_main_t * vam)
21884 unformat_input_t *i = vam->input;
21885 vl_api_delete_subif_t *mp;
21886 u32 sw_if_index = ~0;
21889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21891 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21893 if (unformat (i, "sw_if_index %d", &sw_if_index))
21899 if (sw_if_index == ~0)
21901 errmsg ("missing sw_if_index");
21905 /* Construct the API message */
21906 M (DELETE_SUBIF, mp);
21907 mp->sw_if_index = ntohl (sw_if_index);
21914 #define foreach_pbb_vtr_op \
21915 _("disable", L2_VTR_DISABLED) \
21916 _("pop", L2_VTR_POP_2) \
21917 _("push", L2_VTR_PUSH_2)
21920 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21922 unformat_input_t *i = vam->input;
21923 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21924 u32 sw_if_index = ~0, vtr_op = ~0;
21925 u16 outer_tag = ~0;
21926 u8 dmac[6], smac[6];
21927 u8 dmac_set = 0, smac_set = 0;
21933 /* Shut up coverity */
21934 clib_memset (dmac, 0, sizeof (dmac));
21935 clib_memset (smac, 0, sizeof (smac));
21937 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21939 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21941 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21943 else if (unformat (i, "vtr_op %d", &vtr_op))
21945 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21948 else if (unformat (i, "translate_pbb_stag"))
21950 if (unformat (i, "%d", &tmp))
21952 vtr_op = L2_VTR_TRANSLATE_2_1;
21958 ("translate_pbb_stag operation requires outer tag definition");
21962 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21964 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21966 else if (unformat (i, "sid %d", &sid))
21968 else if (unformat (i, "vlanid %d", &tmp))
21972 clib_warning ("parse error '%U'", format_unformat_error, i);
21977 if ((sw_if_index == ~0) || (vtr_op == ~0))
21979 errmsg ("missing sw_if_index or vtr operation");
21982 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21983 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21986 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21990 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21991 mp->sw_if_index = ntohl (sw_if_index);
21992 mp->vtr_op = ntohl (vtr_op);
21993 mp->outer_tag = ntohs (outer_tag);
21994 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21995 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21996 mp->b_vlanid = ntohs (vlanid);
21997 mp->i_sid = ntohl (sid);
22005 api_flow_classify_set_interface (vat_main_t * vam)
22007 unformat_input_t *i = vam->input;
22008 vl_api_flow_classify_set_interface_t *mp;
22010 int sw_if_index_set;
22011 u32 ip4_table_index = ~0;
22012 u32 ip6_table_index = ~0;
22016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22018 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22019 sw_if_index_set = 1;
22020 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22021 sw_if_index_set = 1;
22022 else if (unformat (i, "del"))
22024 else if (unformat (i, "ip4-table %d", &ip4_table_index))
22026 else if (unformat (i, "ip6-table %d", &ip6_table_index))
22030 clib_warning ("parse error '%U'", format_unformat_error, i);
22035 if (sw_if_index_set == 0)
22037 errmsg ("missing interface name or sw_if_index");
22041 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
22043 mp->sw_if_index = ntohl (sw_if_index);
22044 mp->ip4_table_index = ntohl (ip4_table_index);
22045 mp->ip6_table_index = ntohl (ip6_table_index);
22046 mp->is_add = is_add;
22054 api_flow_classify_dump (vat_main_t * vam)
22056 unformat_input_t *i = vam->input;
22057 vl_api_flow_classify_dump_t *mp;
22058 vl_api_control_ping_t *mp_ping;
22059 u8 type = FLOW_CLASSIFY_N_TABLES;
22062 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
22066 errmsg ("classify table type must be specified");
22070 if (!vam->json_output)
22072 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
22075 M (FLOW_CLASSIFY_DUMP, mp);
22080 /* Use a control ping for synchronization */
22081 MPING (CONTROL_PING, mp_ping);
22084 /* Wait for a reply... */
22090 api_feature_enable_disable (vat_main_t * vam)
22092 unformat_input_t *i = vam->input;
22093 vl_api_feature_enable_disable_t *mp;
22095 u8 *feature_name = 0;
22096 u32 sw_if_index = ~0;
22100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22102 if (unformat (i, "arc_name %s", &arc_name))
22104 else if (unformat (i, "feature_name %s", &feature_name))
22107 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22109 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22111 else if (unformat (i, "disable"))
22119 errmsg ("missing arc name");
22122 if (vec_len (arc_name) > 63)
22124 errmsg ("arc name too long");
22127 if (feature_name == 0)
22129 errmsg ("missing feature name");
22132 if (vec_len (feature_name) > 63)
22134 errmsg ("feature name too long");
22137 if (sw_if_index == ~0)
22139 errmsg ("missing interface name or sw_if_index");
22143 /* Construct the API message */
22144 M (FEATURE_ENABLE_DISABLE, mp);
22145 mp->sw_if_index = ntohl (sw_if_index);
22146 mp->enable = enable;
22147 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
22148 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
22149 vec_free (arc_name);
22150 vec_free (feature_name);
22158 api_sw_interface_tag_add_del (vat_main_t * vam)
22160 unformat_input_t *i = vam->input;
22161 vl_api_sw_interface_tag_add_del_t *mp;
22162 u32 sw_if_index = ~0;
22167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22169 if (unformat (i, "tag %s", &tag))
22171 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22173 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22175 else if (unformat (i, "del"))
22181 if (sw_if_index == ~0)
22183 errmsg ("missing interface name or sw_if_index");
22187 if (enable && (tag == 0))
22189 errmsg ("no tag specified");
22193 /* Construct the API message */
22194 M (SW_INTERFACE_TAG_ADD_DEL, mp);
22195 mp->sw_if_index = ntohl (sw_if_index);
22196 mp->is_add = enable;
22198 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
22206 static void vl_api_l2_xconnect_details_t_handler
22207 (vl_api_l2_xconnect_details_t * mp)
22209 vat_main_t *vam = &vat_main;
22211 print (vam->ofp, "%15d%15d",
22212 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
22215 static void vl_api_l2_xconnect_details_t_handler_json
22216 (vl_api_l2_xconnect_details_t * mp)
22218 vat_main_t *vam = &vat_main;
22219 vat_json_node_t *node = NULL;
22221 if (VAT_JSON_ARRAY != vam->json_tree.type)
22223 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22224 vat_json_init_array (&vam->json_tree);
22226 node = vat_json_array_add (&vam->json_tree);
22228 vat_json_init_object (node);
22229 vat_json_object_add_uint (node, "rx_sw_if_index",
22230 ntohl (mp->rx_sw_if_index));
22231 vat_json_object_add_uint (node, "tx_sw_if_index",
22232 ntohl (mp->tx_sw_if_index));
22236 api_l2_xconnect_dump (vat_main_t * vam)
22238 vl_api_l2_xconnect_dump_t *mp;
22239 vl_api_control_ping_t *mp_ping;
22242 if (!vam->json_output)
22244 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22247 M (L2_XCONNECT_DUMP, mp);
22251 /* Use a control ping for synchronization */
22252 MPING (CONTROL_PING, mp_ping);
22260 api_hw_interface_set_mtu (vat_main_t * vam)
22262 unformat_input_t *i = vam->input;
22263 vl_api_hw_interface_set_mtu_t *mp;
22264 u32 sw_if_index = ~0;
22268 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22270 if (unformat (i, "mtu %d", &mtu))
22272 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22274 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22280 if (sw_if_index == ~0)
22282 errmsg ("missing interface name or sw_if_index");
22288 errmsg ("no mtu specified");
22292 /* Construct the API message */
22293 M (HW_INTERFACE_SET_MTU, mp);
22294 mp->sw_if_index = ntohl (sw_if_index);
22295 mp->mtu = ntohs ((u16) mtu);
22303 api_p2p_ethernet_add (vat_main_t * vam)
22305 unformat_input_t *i = vam->input;
22306 vl_api_p2p_ethernet_add_t *mp;
22307 u32 parent_if_index = ~0;
22313 clib_memset (remote_mac, 0, sizeof (remote_mac));
22314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22316 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22318 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22322 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22324 else if (unformat (i, "sub_id %d", &sub_id))
22328 clib_warning ("parse error '%U'", format_unformat_error, i);
22333 if (parent_if_index == ~0)
22335 errmsg ("missing interface name or sw_if_index");
22340 errmsg ("missing remote mac address");
22345 errmsg ("missing sub-interface id");
22349 M (P2P_ETHERNET_ADD, mp);
22350 mp->parent_if_index = ntohl (parent_if_index);
22351 mp->subif_id = ntohl (sub_id);
22352 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22360 api_p2p_ethernet_del (vat_main_t * vam)
22362 unformat_input_t *i = vam->input;
22363 vl_api_p2p_ethernet_del_t *mp;
22364 u32 parent_if_index = ~0;
22369 clib_memset (remote_mac, 0, sizeof (remote_mac));
22370 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22372 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22374 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22378 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22382 clib_warning ("parse error '%U'", format_unformat_error, i);
22387 if (parent_if_index == ~0)
22389 errmsg ("missing interface name or sw_if_index");
22394 errmsg ("missing remote mac address");
22398 M (P2P_ETHERNET_DEL, mp);
22399 mp->parent_if_index = ntohl (parent_if_index);
22400 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22408 api_lldp_config (vat_main_t * vam)
22410 unformat_input_t *i = vam->input;
22411 vl_api_lldp_config_t *mp;
22413 int tx_interval = 0;
22414 u8 *sys_name = NULL;
22417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22419 if (unformat (i, "system-name %s", &sys_name))
22421 else if (unformat (i, "tx-hold %d", &tx_hold))
22423 else if (unformat (i, "tx-interval %d", &tx_interval))
22427 clib_warning ("parse error '%U'", format_unformat_error, i);
22432 vec_add1 (sys_name, 0);
22434 M (LLDP_CONFIG, mp);
22435 mp->tx_hold = htonl (tx_hold);
22436 mp->tx_interval = htonl (tx_interval);
22437 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22438 vec_free (sys_name);
22446 api_sw_interface_set_lldp (vat_main_t * vam)
22448 unformat_input_t *i = vam->input;
22449 vl_api_sw_interface_set_lldp_t *mp;
22450 u32 sw_if_index = ~0;
22452 u8 *port_desc = NULL, *mgmt_oid = NULL;
22453 ip4_address_t ip4_addr;
22454 ip6_address_t ip6_addr;
22457 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
22458 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
22460 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22462 if (unformat (i, "disable"))
22465 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22467 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22469 else if (unformat (i, "port-desc %s", &port_desc))
22471 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22473 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22475 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22481 if (sw_if_index == ~0)
22483 errmsg ("missing interface name or sw_if_index");
22487 /* Construct the API message */
22488 vec_add1 (port_desc, 0);
22489 vec_add1 (mgmt_oid, 0);
22490 M (SW_INTERFACE_SET_LLDP, mp);
22491 mp->sw_if_index = ntohl (sw_if_index);
22492 mp->enable = enable;
22493 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22494 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22495 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22496 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22497 vec_free (port_desc);
22498 vec_free (mgmt_oid);
22506 api_tcp_configure_src_addresses (vat_main_t * vam)
22508 vl_api_tcp_configure_src_addresses_t *mp;
22509 unformat_input_t *i = vam->input;
22510 ip4_address_t v4first, v4last;
22511 ip6_address_t v6first, v6last;
22516 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22518 if (unformat (i, "%U - %U",
22519 unformat_ip4_address, &v4first,
22520 unformat_ip4_address, &v4last))
22524 errmsg ("one range per message (range already set)");
22529 else if (unformat (i, "%U - %U",
22530 unformat_ip6_address, &v6first,
22531 unformat_ip6_address, &v6last))
22535 errmsg ("one range per message (range already set)");
22540 else if (unformat (i, "vrf %d", &vrf_id))
22546 if (range_set == 0)
22548 errmsg ("address range not set");
22552 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22553 mp->vrf_id = ntohl (vrf_id);
22555 if (range_set == 2)
22558 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22559 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22564 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22565 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22572 static void vl_api_app_namespace_add_del_reply_t_handler
22573 (vl_api_app_namespace_add_del_reply_t * mp)
22575 vat_main_t *vam = &vat_main;
22576 i32 retval = ntohl (mp->retval);
22577 if (vam->async_mode)
22579 vam->async_errors += (retval < 0);
22583 vam->retval = retval;
22585 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22586 vam->result_ready = 1;
22590 static void vl_api_app_namespace_add_del_reply_t_handler_json
22591 (vl_api_app_namespace_add_del_reply_t * mp)
22593 vat_main_t *vam = &vat_main;
22594 vat_json_node_t node;
22596 vat_json_init_object (&node);
22597 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22598 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22600 vat_json_print (vam->ofp, &node);
22601 vat_json_free (&node);
22603 vam->retval = ntohl (mp->retval);
22604 vam->result_ready = 1;
22608 api_app_namespace_add_del (vat_main_t * vam)
22610 vl_api_app_namespace_add_del_t *mp;
22611 unformat_input_t *i = vam->input;
22612 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22613 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22617 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22619 if (unformat (i, "id %_%v%_", &ns_id))
22621 else if (unformat (i, "secret %lu", &secret))
22623 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22624 sw_if_index_set = 1;
22625 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22627 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22632 if (!ns_id || !secret_set || !sw_if_index_set)
22634 errmsg ("namespace id, secret and sw_if_index must be set");
22637 if (vec_len (ns_id) > 64)
22639 errmsg ("namespace id too long");
22642 M (APP_NAMESPACE_ADD_DEL, mp);
22644 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22645 mp->namespace_id_len = vec_len (ns_id);
22646 mp->secret = clib_host_to_net_u64 (secret);
22647 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22648 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22649 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22657 api_sock_init_shm (vat_main_t * vam)
22659 #if VPP_API_TEST_BUILTIN == 0
22660 unformat_input_t *i = vam->input;
22661 vl_api_shm_elem_config_t *config = 0;
22662 u64 size = 64 << 20;
22665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22667 if (unformat (i, "size %U", unformat_memory_size, &size))
22674 * Canned custom ring allocator config.
22675 * Should probably parse all of this
22677 vec_validate (config, 6);
22678 config[0].type = VL_API_VLIB_RING;
22679 config[0].size = 256;
22680 config[0].count = 32;
22682 config[1].type = VL_API_VLIB_RING;
22683 config[1].size = 1024;
22684 config[1].count = 16;
22686 config[2].type = VL_API_VLIB_RING;
22687 config[2].size = 4096;
22688 config[2].count = 2;
22690 config[3].type = VL_API_CLIENT_RING;
22691 config[3].size = 256;
22692 config[3].count = 32;
22694 config[4].type = VL_API_CLIENT_RING;
22695 config[4].size = 1024;
22696 config[4].count = 16;
22698 config[5].type = VL_API_CLIENT_RING;
22699 config[5].size = 4096;
22700 config[5].count = 2;
22702 config[6].type = VL_API_QUEUE;
22703 config[6].count = 128;
22704 config[6].size = sizeof (uword);
22706 rv = vl_socket_client_init_shm (config);
22708 vam->client_index_invalid = 1;
22716 api_dns_enable_disable (vat_main_t * vam)
22718 unformat_input_t *line_input = vam->input;
22719 vl_api_dns_enable_disable_t *mp;
22720 u8 enable_disable = 1;
22723 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22725 if (unformat (line_input, "disable"))
22726 enable_disable = 0;
22727 if (unformat (line_input, "enable"))
22728 enable_disable = 1;
22733 /* Construct the API message */
22734 M (DNS_ENABLE_DISABLE, mp);
22735 mp->enable = enable_disable;
22739 /* Wait for the reply */
22745 api_dns_resolve_name (vat_main_t * vam)
22747 unformat_input_t *line_input = vam->input;
22748 vl_api_dns_resolve_name_t *mp;
22752 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22754 if (unformat (line_input, "%s", &name))
22760 if (vec_len (name) > 127)
22762 errmsg ("name too long");
22766 /* Construct the API message */
22767 M (DNS_RESOLVE_NAME, mp);
22768 memcpy (mp->name, name, vec_len (name));
22773 /* Wait for the reply */
22779 api_dns_resolve_ip (vat_main_t * vam)
22781 unformat_input_t *line_input = vam->input;
22782 vl_api_dns_resolve_ip_t *mp;
22784 ip4_address_t addr4;
22785 ip6_address_t addr6;
22788 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22790 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22792 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22800 errmsg ("missing address");
22804 /* Construct the API message */
22805 M (DNS_RESOLVE_IP, mp);
22806 mp->is_ip6 = is_ip6;
22808 memcpy (mp->address, &addr6, sizeof (addr6));
22810 memcpy (mp->address, &addr4, sizeof (addr4));
22814 /* Wait for the reply */
22820 api_dns_name_server_add_del (vat_main_t * vam)
22822 unformat_input_t *i = vam->input;
22823 vl_api_dns_name_server_add_del_t *mp;
22825 ip6_address_t ip6_server;
22826 ip4_address_t ip4_server;
22831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22833 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22835 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22837 else if (unformat (i, "del"))
22841 clib_warning ("parse error '%U'", format_unformat_error, i);
22846 if (ip4_set && ip6_set)
22848 errmsg ("Only one server address allowed per message");
22851 if ((ip4_set + ip6_set) == 0)
22853 errmsg ("Server address required");
22857 /* Construct the API message */
22858 M (DNS_NAME_SERVER_ADD_DEL, mp);
22862 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22867 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22871 mp->is_add = is_add;
22876 /* Wait for a reply, return good/bad news */
22882 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22884 vat_main_t *vam = &vat_main;
22889 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22890 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22891 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22892 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22893 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22894 clib_net_to_host_u32 (mp->action_index), mp->tag);
22899 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22900 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22901 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22902 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22903 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22904 clib_net_to_host_u32 (mp->action_index), mp->tag);
22909 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22912 vat_main_t *vam = &vat_main;
22913 vat_json_node_t *node = NULL;
22914 struct in6_addr ip6;
22915 struct in_addr ip4;
22917 if (VAT_JSON_ARRAY != vam->json_tree.type)
22919 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22920 vat_json_init_array (&vam->json_tree);
22922 node = vat_json_array_add (&vam->json_tree);
22923 vat_json_init_object (node);
22925 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22926 vat_json_object_add_uint (node, "appns_index",
22927 clib_net_to_host_u32 (mp->appns_index));
22928 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22929 vat_json_object_add_uint (node, "scope", mp->scope);
22930 vat_json_object_add_uint (node, "action_index",
22931 clib_net_to_host_u32 (mp->action_index));
22932 vat_json_object_add_uint (node, "lcl_port",
22933 clib_net_to_host_u16 (mp->lcl_port));
22934 vat_json_object_add_uint (node, "rmt_port",
22935 clib_net_to_host_u16 (mp->rmt_port));
22936 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22937 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22938 vat_json_object_add_string_copy (node, "tag", mp->tag);
22941 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22942 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22943 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22944 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22948 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22949 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22950 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22951 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22956 api_session_rule_add_del (vat_main_t * vam)
22958 vl_api_session_rule_add_del_t *mp;
22959 unformat_input_t *i = vam->input;
22960 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22961 u32 appns_index = 0, scope = 0;
22962 ip4_address_t lcl_ip4, rmt_ip4;
22963 ip6_address_t lcl_ip6, rmt_ip6;
22964 u8 is_ip4 = 1, conn_set = 0;
22965 u8 is_add = 1, *tag = 0;
22968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22970 if (unformat (i, "del"))
22972 else if (unformat (i, "add"))
22974 else if (unformat (i, "proto tcp"))
22976 else if (unformat (i, "proto udp"))
22978 else if (unformat (i, "appns %d", &appns_index))
22980 else if (unformat (i, "scope %d", &scope))
22982 else if (unformat (i, "tag %_%v%_", &tag))
22986 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22987 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22995 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22996 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
23002 else if (unformat (i, "action %d", &action))
23007 if (proto == ~0 || !conn_set || action == ~0)
23009 errmsg ("transport proto, connection and action must be set");
23015 errmsg ("scope should be 0-3");
23019 M (SESSION_RULE_ADD_DEL, mp);
23021 mp->is_ip4 = is_ip4;
23022 mp->transport_proto = proto;
23023 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
23024 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
23025 mp->lcl_plen = lcl_plen;
23026 mp->rmt_plen = rmt_plen;
23027 mp->action_index = clib_host_to_net_u32 (action);
23028 mp->appns_index = clib_host_to_net_u32 (appns_index);
23030 mp->is_add = is_add;
23033 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
23034 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
23038 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
23039 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
23043 clib_memcpy (mp->tag, tag, vec_len (tag));
23053 api_session_rules_dump (vat_main_t * vam)
23055 vl_api_session_rules_dump_t *mp;
23056 vl_api_control_ping_t *mp_ping;
23059 if (!vam->json_output)
23061 print (vam->ofp, "%=20s", "Session Rules");
23064 M (SESSION_RULES_DUMP, mp);
23068 /* Use a control ping for synchronization */
23069 MPING (CONTROL_PING, mp_ping);
23072 /* Wait for a reply... */
23078 api_ip_container_proxy_add_del (vat_main_t * vam)
23080 vl_api_ip_container_proxy_add_del_t *mp;
23081 unformat_input_t *i = vam->input;
23082 u32 plen = ~0, sw_if_index = ~0;
23089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23091 if (unformat (i, "del"))
23093 else if (unformat (i, "add"))
23095 if (unformat (i, "%U", unformat_ip4_address, &ip4))
23100 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
23105 else if (unformat (i, "sw_if_index %u", &sw_if_index))
23110 if (sw_if_index == ~0 || plen == ~0)
23112 errmsg ("address and sw_if_index must be set");
23116 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
23118 mp->is_ip4 = is_ip4;
23119 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
23121 mp->is_add = is_add;
23123 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
23125 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
23133 api_qos_record_enable_disable (vat_main_t * vam)
23135 unformat_input_t *i = vam->input;
23136 vl_api_qos_record_enable_disable_t *mp;
23137 u32 sw_if_index, qs = 0xff;
23138 u8 sw_if_index_set = 0;
23142 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23144 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
23145 sw_if_index_set = 1;
23146 else if (unformat (i, "sw_if_index %d", &sw_if_index))
23147 sw_if_index_set = 1;
23148 else if (unformat (i, "%U", unformat_qos_source, &qs))
23150 else if (unformat (i, "disable"))
23154 clib_warning ("parse error '%U'", format_unformat_error, i);
23159 if (sw_if_index_set == 0)
23161 errmsg ("missing interface name or sw_if_index");
23166 errmsg ("input location must be specified");
23170 M (QOS_RECORD_ENABLE_DISABLE, mp);
23172 mp->sw_if_index = ntohl (sw_if_index);
23173 mp->input_source = qs;
23174 mp->enable = enable;
23183 q_or_quit (vat_main_t * vam)
23185 #if VPP_API_TEST_BUILTIN == 0
23186 longjmp (vam->jump_buf, 1);
23188 return 0; /* not so much */
23192 q (vat_main_t * vam)
23194 return q_or_quit (vam);
23198 quit (vat_main_t * vam)
23200 return q_or_quit (vam);
23204 comment (vat_main_t * vam)
23210 statseg (vat_main_t * vam)
23212 ssvm_private_t *ssvmp = &vam->stat_segment;
23213 ssvm_shared_header_t *shared_header = ssvmp->sh;
23214 vlib_counter_t **counters;
23215 u64 thread0_index1_packets;
23216 u64 thread0_index1_bytes;
23217 f64 vector_rate, input_rate;
23220 uword *counter_vector_by_name;
23221 if (vam->stat_segment_lockp == 0)
23223 errmsg ("Stat segment not mapped...");
23227 /* look up "/if/rx for sw_if_index 1 as a test */
23229 clib_spinlock_lock (vam->stat_segment_lockp);
23231 counter_vector_by_name = (uword *) shared_header->opaque[1];
23233 p = hash_get_mem (counter_vector_by_name, "/if/rx");
23236 clib_spinlock_unlock (vam->stat_segment_lockp);
23237 errmsg ("/if/tx not found?");
23241 /* Fish per-thread vector of combined counters from shared memory */
23242 counters = (vlib_counter_t **) p[0];
23244 if (vec_len (counters[0]) < 2)
23246 clib_spinlock_unlock (vam->stat_segment_lockp);
23247 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
23251 /* Read thread 0 sw_if_index 1 counter */
23252 thread0_index1_packets = counters[0][1].packets;
23253 thread0_index1_bytes = counters[0][1].bytes;
23255 p = hash_get_mem (counter_vector_by_name, "vector_rate");
23258 clib_spinlock_unlock (vam->stat_segment_lockp);
23259 errmsg ("vector_rate not found?");
23263 vector_rate = *(f64 *) (p[0]);
23264 p = hash_get_mem (counter_vector_by_name, "input_rate");
23267 clib_spinlock_unlock (vam->stat_segment_lockp);
23268 errmsg ("input_rate not found?");
23271 input_rate = *(f64 *) (p[0]);
23273 clib_spinlock_unlock (vam->stat_segment_lockp);
23275 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
23276 vector_rate, input_rate);
23277 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
23278 thread0_index1_packets, thread0_index1_bytes);
23284 cmd_cmp (void *a1, void *a2)
23289 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23293 help (vat_main_t * vam)
23298 unformat_input_t *i = vam->input;
23301 if (unformat (i, "%s", &name))
23305 vec_add1 (name, 0);
23307 hs = hash_get_mem (vam->help_by_name, name);
23309 print (vam->ofp, "usage: %s %s", name, hs[0]);
23311 print (vam->ofp, "No such msg / command '%s'", name);
23316 print (vam->ofp, "Help is available for the following:");
23319 hash_foreach_pair (p, vam->function_by_name,
23321 vec_add1 (cmds, (u8 *)(p->key));
23325 vec_sort_with_function (cmds, cmd_cmp);
23327 for (j = 0; j < vec_len (cmds); j++)
23328 print (vam->ofp, "%s", cmds[j]);
23335 set (vat_main_t * vam)
23337 u8 *name = 0, *value = 0;
23338 unformat_input_t *i = vam->input;
23340 if (unformat (i, "%s", &name))
23342 /* The input buffer is a vector, not a string. */
23343 value = vec_dup (i->buffer);
23344 vec_delete (value, i->index, 0);
23345 /* Almost certainly has a trailing newline */
23346 if (value[vec_len (value) - 1] == '\n')
23347 value[vec_len (value) - 1] = 0;
23348 /* Make sure it's a proper string, one way or the other */
23349 vec_add1 (value, 0);
23350 (void) clib_macro_set_value (&vam->macro_main,
23351 (char *) name, (char *) value);
23354 errmsg ("usage: set <name> <value>");
23362 unset (vat_main_t * vam)
23366 if (unformat (vam->input, "%s", &name))
23367 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23368 errmsg ("unset: %s wasn't set", name);
23381 macro_sort_cmp (void *a1, void *a2)
23383 macro_sort_t *s1 = a1;
23384 macro_sort_t *s2 = a2;
23386 return strcmp ((char *) (s1->name), (char *) (s2->name));
23390 dump_macro_table (vat_main_t * vam)
23392 macro_sort_t *sort_me = 0, *sm;
23397 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23399 vec_add2 (sort_me, sm, 1);
23400 sm->name = (u8 *)(p->key);
23401 sm->value = (u8 *) (p->value[0]);
23405 vec_sort_with_function (sort_me, macro_sort_cmp);
23407 if (vec_len (sort_me))
23408 print (vam->ofp, "%-15s%s", "Name", "Value");
23410 print (vam->ofp, "The macro table is empty...");
23412 for (i = 0; i < vec_len (sort_me); i++)
23413 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23418 dump_node_table (vat_main_t * vam)
23421 vlib_node_t *node, *next_node;
23423 if (vec_len (vam->graph_nodes) == 0)
23425 print (vam->ofp, "Node table empty, issue get_node_graph...");
23429 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
23431 node = vam->graph_nodes[0][i];
23432 print (vam->ofp, "[%d] %s", i, node->name);
23433 for (j = 0; j < vec_len (node->next_nodes); j++)
23435 if (node->next_nodes[j] != ~0)
23437 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23438 print (vam->ofp, " [%d] %s", j, next_node->name);
23446 value_sort_cmp (void *a1, void *a2)
23448 name_sort_t *n1 = a1;
23449 name_sort_t *n2 = a2;
23451 if (n1->value < n2->value)
23453 if (n1->value > n2->value)
23460 dump_msg_api_table (vat_main_t * vam)
23462 api_main_t *am = &api_main;
23463 name_sort_t *nses = 0, *ns;
23468 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23470 vec_add2 (nses, ns, 1);
23471 ns->name = (u8 *)(hp->key);
23472 ns->value = (u32) hp->value[0];
23476 vec_sort_with_function (nses, value_sort_cmp);
23478 for (i = 0; i < vec_len (nses); i++)
23479 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23485 get_msg_id (vat_main_t * vam)
23490 if (unformat (vam->input, "%s", &name_and_crc))
23492 message_index = vl_msg_api_get_msg_index (name_and_crc);
23493 if (message_index == ~0)
23495 print (vam->ofp, " '%s' not found", name_and_crc);
23498 print (vam->ofp, " '%s' has message index %d",
23499 name_and_crc, message_index);
23502 errmsg ("name_and_crc required...");
23507 search_node_table (vat_main_t * vam)
23509 unformat_input_t *line_input = vam->input;
23512 vlib_node_t *node, *next_node;
23515 if (vam->graph_node_index_by_name == 0)
23517 print (vam->ofp, "Node table empty, issue get_node_graph...");
23521 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23523 if (unformat (line_input, "%s", &node_to_find))
23525 vec_add1 (node_to_find, 0);
23526 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23529 print (vam->ofp, "%s not found...", node_to_find);
23532 node = vam->graph_nodes[0][p[0]];
23533 print (vam->ofp, "[%d] %s", p[0], node->name);
23534 for (j = 0; j < vec_len (node->next_nodes); j++)
23536 if (node->next_nodes[j] != ~0)
23538 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23539 print (vam->ofp, " [%d] %s", j, next_node->name);
23546 clib_warning ("parse error '%U'", format_unformat_error,
23552 vec_free (node_to_find);
23561 script (vat_main_t * vam)
23563 #if (VPP_API_TEST_BUILTIN==0)
23565 char *save_current_file;
23566 unformat_input_t save_input;
23567 jmp_buf save_jump_buf;
23568 u32 save_line_number;
23570 FILE *new_fp, *save_ifp;
23572 if (unformat (vam->input, "%s", &s))
23574 new_fp = fopen ((char *) s, "r");
23577 errmsg ("Couldn't open script file %s", s);
23584 errmsg ("Missing script name");
23588 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23589 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23590 save_ifp = vam->ifp;
23591 save_line_number = vam->input_line_number;
23592 save_current_file = (char *) vam->current_file;
23594 vam->input_line_number = 0;
23596 vam->current_file = s;
23599 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23600 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23601 vam->ifp = save_ifp;
23602 vam->input_line_number = save_line_number;
23603 vam->current_file = (u8 *) save_current_file;
23608 clib_warning ("use the exec command...");
23614 echo (vat_main_t * vam)
23616 print (vam->ofp, "%v", vam->input->buffer);
23620 /* List of API message constructors, CLI names map to api_xxx */
23621 #define foreach_vpe_api_msg \
23622 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23623 _(sw_interface_dump,"") \
23624 _(sw_interface_set_flags, \
23625 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23626 _(sw_interface_add_del_address, \
23627 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23628 _(sw_interface_set_rx_mode, \
23629 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23630 _(sw_interface_set_rx_placement, \
23631 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
23632 _(sw_interface_rx_placement_dump, \
23633 "[<intfc> | sw_if_index <id>]") \
23634 _(sw_interface_set_table, \
23635 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23636 _(sw_interface_set_mpls_enable, \
23637 "<intfc> | sw_if_index [disable | dis]") \
23638 _(sw_interface_set_vpath, \
23639 "<intfc> | sw_if_index <id> enable | disable") \
23640 _(sw_interface_set_vxlan_bypass, \
23641 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23642 _(sw_interface_set_geneve_bypass, \
23643 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23644 _(sw_interface_set_l2_xconnect, \
23645 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23646 "enable | disable") \
23647 _(sw_interface_set_l2_bridge, \
23648 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23649 "[shg <split-horizon-group>] [bvi]\n" \
23650 "enable | disable") \
23651 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23652 _(bridge_domain_add_del, \
23653 "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") \
23654 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23656 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23657 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23658 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23660 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23662 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23664 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23666 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23668 "<vpp-if-name> | sw_if_index <id>") \
23669 _(sw_interface_tap_dump, "") \
23671 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23673 "<vpp-if-name> | sw_if_index <id>") \
23674 _(sw_interface_tap_v2_dump, "") \
23676 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23677 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23679 "<vpp-if-name> | sw_if_index <id>") \
23681 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23682 _(bond_detach_slave, \
23683 "sw_if_index <n>") \
23684 _(sw_interface_bond_dump, "") \
23685 _(sw_interface_slave_dump, \
23686 "<vpp-if-name> | sw_if_index <id>") \
23687 _(ip_table_add_del, \
23688 "table <n> [ipv6] [add | del]\n") \
23689 _(ip_add_del_route, \
23690 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
23691 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
23692 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
23693 "[multipath] [count <n>] [del]") \
23694 _(ip_mroute_add_del, \
23695 "<src> <grp>/<mask> [table-id <n>]\n" \
23696 "[<intfc> | sw_if_index <id>] [local] [del]") \
23697 _(mpls_table_add_del, \
23698 "table <n> [add | del]\n") \
23699 _(mpls_route_add_del, \
23700 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
23701 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
23702 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
23703 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
23704 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
23705 "[count <n>] [del]") \
23706 _(mpls_ip_bind_unbind, \
23707 "<label> <addr/len>") \
23708 _(mpls_tunnel_add_del, \
23709 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
23710 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
23711 "[l2-only] [out-label <n>]") \
23712 _(sr_mpls_policy_add, \
23713 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
23714 _(sr_mpls_policy_del, \
23716 _(bier_table_add_del, \
23717 "<label> <sub-domain> <set> <bsl> [del]") \
23718 _(bier_route_add_del, \
23719 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23720 "[<intfc> | sw_if_index <id>]" \
23721 "[weight <n>] [del] [multipath]") \
23722 _(proxy_arp_add_del, \
23723 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23724 _(proxy_arp_intfc_enable_disable, \
23725 "<intfc> | sw_if_index <id> enable | disable") \
23726 _(sw_interface_set_unnumbered, \
23727 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23728 _(ip_neighbor_add_del, \
23729 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23730 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23731 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23732 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23733 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23734 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23735 "[outer_vlan_id_any][inner_vlan_id_any]") \
23736 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23737 _(reset_fib, "vrf <n> [ipv6]") \
23738 _(dhcp_proxy_config, \
23739 "svr <v46-address> src <v46-address>\n" \
23740 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23741 _(dhcp_proxy_set_vss, \
23742 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23743 _(dhcp_proxy_dump, "ip6") \
23744 _(dhcp_client_config, \
23745 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23746 _(set_ip_flow_hash, \
23747 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23748 _(sw_interface_ip6_enable_disable, \
23749 "<intfc> | sw_if_index <id> enable | disable") \
23750 _(ip6nd_proxy_add_del, \
23751 "<intfc> | sw_if_index <id> <ip6-address>") \
23752 _(ip6nd_proxy_dump, "") \
23753 _(sw_interface_ip6nd_ra_prefix, \
23754 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23755 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23756 "[nolink] [isno]") \
23757 _(sw_interface_ip6nd_ra_config, \
23758 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23759 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23760 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23761 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23762 _(l2_patch_add_del, \
23763 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23764 "enable | disable") \
23765 _(sr_localsid_add_del, \
23766 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23767 "fib-table <num> (end.psp) sw_if_index <num>") \
23768 _(classify_add_del_table, \
23769 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23770 " [del] [del-chain] mask <mask-value>\n" \
23771 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23772 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23773 _(classify_add_del_session, \
23774 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23775 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23776 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23777 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23778 _(classify_set_interface_ip_table, \
23779 "<intfc> | sw_if_index <nn> table <nn>") \
23780 _(classify_set_interface_l2_tables, \
23781 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23782 " [other-table <nn>]") \
23783 _(get_node_index, "node <node-name") \
23784 _(add_node_next, "node <node-name> next <next-node-name>") \
23785 _(l2tpv3_create_tunnel, \
23786 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23787 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23788 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23789 _(l2tpv3_set_tunnel_cookies, \
23790 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23791 "[new_remote_cookie <nn>]\n") \
23792 _(l2tpv3_interface_enable_disable, \
23793 "<intfc> | sw_if_index <nn> enable | disable") \
23794 _(l2tpv3_set_lookup_key, \
23795 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23796 _(sw_if_l2tpv3_tunnel_dump, "") \
23797 _(vxlan_offload_rx, \
23798 "hw { <interface name> | hw_if_index <nn>} " \
23799 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23800 _(vxlan_add_del_tunnel, \
23801 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23802 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23803 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23804 _(geneve_add_del_tunnel, \
23805 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23806 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23807 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23808 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23809 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23810 _(gre_add_del_tunnel, \
23811 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23812 "[teb | erspan <session-id>] [del]") \
23813 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23814 _(l2_fib_clear_table, "") \
23815 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23816 _(l2_interface_vlan_tag_rewrite, \
23817 "<intfc> | sw_if_index <nn> \n" \
23818 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23819 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23820 _(create_vhost_user_if, \
23821 "socket <filename> [server] [renumber <dev_instance>] " \
23822 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
23823 "[mac <mac_address>]") \
23824 _(modify_vhost_user_if, \
23825 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23826 "[server] [renumber <dev_instance>]") \
23827 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23828 _(sw_interface_vhost_user_dump, "") \
23829 _(show_version, "") \
23830 _(show_threads, "") \
23831 _(vxlan_gpe_add_del_tunnel, \
23832 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23833 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23834 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23835 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23836 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23837 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23838 _(interface_name_renumber, \
23839 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23840 _(input_acl_set_interface, \
23841 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23842 " [l2-table <nn>] [del]") \
23843 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23844 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23845 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23846 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23847 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23848 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23849 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23850 _(ip_dump, "ipv4 | ipv6") \
23851 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23852 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23854 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23855 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23856 " integ_alg <alg> integ_key <hex>") \
23857 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23858 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23859 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23860 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23861 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23862 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23863 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23864 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23865 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23866 " [instance <n>]") \
23867 _(ipsec_sa_dump, "[sa_id <n>]") \
23868 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23869 " <alg> <hex>\n") \
23870 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23871 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23872 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23873 "(auth_data 0x<data> | auth_data <data>)") \
23874 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23875 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23876 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23877 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23878 "(local|remote)") \
23879 _(ikev2_set_local_key, "file <absolute_file_path>") \
23880 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23881 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23882 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23883 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23884 _(ikev2_initiate_sa_init, "<profile_name>") \
23885 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23886 _(ikev2_initiate_del_child_sa, "<ispi>") \
23887 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23888 _(delete_loopback,"sw_if_index <nn>") \
23889 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23890 _(bd_ip_mac_dump, "[bd_id] <id>") \
23891 _(want_interface_events, "enable|disable") \
23892 _(want_stats,"enable|disable") \
23893 _(get_first_msg_id, "client <name>") \
23894 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23895 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23896 "fib-id <nn> [ip4][ip6][default]") \
23897 _(get_node_graph, " ") \
23898 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23899 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23900 _(ioam_disable, "") \
23901 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23902 " sw_if_index <sw_if_index> p <priority> " \
23903 "w <weight>] [del]") \
23904 _(one_add_del_locator, "locator-set <locator_name> " \
23905 "iface <intf> | sw_if_index <sw_if_index> " \
23906 "p <priority> w <weight> [del]") \
23907 _(one_add_del_local_eid,"vni <vni> eid " \
23908 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23909 "locator-set <locator_name> [del]" \
23910 "[key-id sha1|sha256 secret-key <secret-key>]")\
23911 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23912 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23913 _(one_enable_disable, "enable|disable") \
23914 _(one_map_register_enable_disable, "enable|disable") \
23915 _(one_map_register_fallback_threshold, "<value>") \
23916 _(one_rloc_probe_enable_disable, "enable|disable") \
23917 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23919 "rloc <locator> p <prio> " \
23920 "w <weight> [rloc <loc> ... ] " \
23921 "action <action> [del-all]") \
23922 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23924 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23925 _(one_use_petr, "ip-address> | disable") \
23926 _(one_map_request_mode, "src-dst|dst-only") \
23927 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23928 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23929 _(one_locator_set_dump, "[local | remote]") \
23930 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23931 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23932 "[local] | [remote]") \
23933 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23934 _(one_ndp_bd_get, "") \
23935 _(one_ndp_entries_get, "bd <bridge-domain>") \
23936 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23937 _(one_l2_arp_bd_get, "") \
23938 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23939 _(one_stats_enable_disable, "enable|disable") \
23940 _(show_one_stats_enable_disable, "") \
23941 _(one_eid_table_vni_dump, "") \
23942 _(one_eid_table_map_dump, "l2|l3") \
23943 _(one_map_resolver_dump, "") \
23944 _(one_map_server_dump, "") \
23945 _(one_adjacencies_get, "vni <vni>") \
23946 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23947 _(show_one_rloc_probe_state, "") \
23948 _(show_one_map_register_state, "") \
23949 _(show_one_status, "") \
23950 _(one_stats_dump, "") \
23951 _(one_stats_flush, "") \
23952 _(one_get_map_request_itr_rlocs, "") \
23953 _(one_map_register_set_ttl, "<ttl>") \
23954 _(one_set_transport_protocol, "udp|api") \
23955 _(one_get_transport_protocol, "") \
23956 _(one_enable_disable_xtr_mode, "enable|disable") \
23957 _(one_show_xtr_mode, "") \
23958 _(one_enable_disable_pitr_mode, "enable|disable") \
23959 _(one_show_pitr_mode, "") \
23960 _(one_enable_disable_petr_mode, "enable|disable") \
23961 _(one_show_petr_mode, "") \
23962 _(show_one_nsh_mapping, "") \
23963 _(show_one_pitr, "") \
23964 _(show_one_use_petr, "") \
23965 _(show_one_map_request_mode, "") \
23966 _(show_one_map_register_ttl, "") \
23967 _(show_one_map_register_fallback_threshold, "") \
23968 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23969 " sw_if_index <sw_if_index> p <priority> " \
23970 "w <weight>] [del]") \
23971 _(lisp_add_del_locator, "locator-set <locator_name> " \
23972 "iface <intf> | sw_if_index <sw_if_index> " \
23973 "p <priority> w <weight> [del]") \
23974 _(lisp_add_del_local_eid,"vni <vni> eid " \
23975 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23976 "locator-set <locator_name> [del]" \
23977 "[key-id sha1|sha256 secret-key <secret-key>]") \
23978 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23979 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23980 _(lisp_enable_disable, "enable|disable") \
23981 _(lisp_map_register_enable_disable, "enable|disable") \
23982 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23983 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23985 "rloc <locator> p <prio> " \
23986 "w <weight> [rloc <loc> ... ] " \
23987 "action <action> [del-all]") \
23988 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23990 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23991 _(lisp_use_petr, "<ip-address> | disable") \
23992 _(lisp_map_request_mode, "src-dst|dst-only") \
23993 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23994 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23995 _(lisp_locator_set_dump, "[local | remote]") \
23996 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23997 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23998 "[local] | [remote]") \
23999 _(lisp_eid_table_vni_dump, "") \
24000 _(lisp_eid_table_map_dump, "l2|l3") \
24001 _(lisp_map_resolver_dump, "") \
24002 _(lisp_map_server_dump, "") \
24003 _(lisp_adjacencies_get, "vni <vni>") \
24004 _(gpe_fwd_entry_vnis_get, "") \
24005 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
24006 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
24007 "[table <table-id>]") \
24008 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
24009 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
24010 _(gpe_set_encap_mode, "lisp|vxlan") \
24011 _(gpe_get_encap_mode, "") \
24012 _(lisp_gpe_add_del_iface, "up|down") \
24013 _(lisp_gpe_enable_disable, "enable|disable") \
24014 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
24015 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
24016 _(show_lisp_rloc_probe_state, "") \
24017 _(show_lisp_map_register_state, "") \
24018 _(show_lisp_status, "") \
24019 _(lisp_get_map_request_itr_rlocs, "") \
24020 _(show_lisp_pitr, "") \
24021 _(show_lisp_use_petr, "") \
24022 _(show_lisp_map_request_mode, "") \
24023 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
24024 _(af_packet_delete, "name <host interface name>") \
24025 _(af_packet_dump, "") \
24026 _(policer_add_del, "name <policer name> <params> [del]") \
24027 _(policer_dump, "[name <policer name>]") \
24028 _(policer_classify_set_interface, \
24029 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24030 " [l2-table <nn>] [del]") \
24031 _(policer_classify_dump, "type [ip4|ip6|l2]") \
24032 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
24033 "[master|slave]") \
24034 _(netmap_delete, "name <interface name>") \
24035 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
24036 _(mpls_fib_dump, "") \
24037 _(classify_table_ids, "") \
24038 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
24039 _(classify_table_info, "table_id <nn>") \
24040 _(classify_session_dump, "table_id <nn>") \
24041 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
24042 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
24043 "[template_interval <nn>] [udp_checksum]") \
24044 _(ipfix_exporter_dump, "") \
24045 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
24046 _(ipfix_classify_stream_dump, "") \
24047 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
24048 _(ipfix_classify_table_dump, "") \
24049 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
24050 _(sw_interface_span_dump, "[l2]") \
24051 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
24052 _(pg_create_interface, "if_id <nn>") \
24053 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
24054 _(pg_enable_disable, "[stream <id>] disable") \
24055 _(ip_source_and_port_range_check_add_del, \
24056 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
24057 _(ip_source_and_port_range_check_interface_add_del, \
24058 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
24059 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
24060 _(ipsec_gre_add_del_tunnel, \
24061 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
24062 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
24063 _(delete_subif,"<intfc> | sw_if_index <nn>") \
24064 _(l2_interface_pbb_tag_rewrite, \
24065 "<intfc> | sw_if_index <nn> \n" \
24066 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
24067 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
24068 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
24069 _(flow_classify_set_interface, \
24070 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
24071 _(flow_classify_dump, "type [ip4|ip6]") \
24072 _(ip_fib_dump, "") \
24073 _(ip_mfib_dump, "") \
24074 _(ip6_fib_dump, "") \
24075 _(ip6_mfib_dump, "") \
24076 _(feature_enable_disable, "arc_name <arc_name> " \
24077 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
24078 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
24080 _(l2_xconnect_dump, "") \
24081 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
24082 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
24083 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
24084 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
24085 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
24086 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
24087 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
24088 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
24089 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
24090 _(sock_init_shm, "size <nnn>") \
24091 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
24092 _(dns_enable_disable, "[enable][disable]") \
24093 _(dns_name_server_add_del, "<ip-address> [del]") \
24094 _(dns_resolve_name, "<hostname>") \
24095 _(dns_resolve_ip, "<ip4|ip6>") \
24096 _(dns_name_server_add_del, "<ip-address> [del]") \
24097 _(dns_resolve_name, "<hostname>") \
24098 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
24099 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
24100 _(session_rules_dump, "") \
24101 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
24102 _(output_acl_set_interface, \
24103 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24104 " [l2-table <nn>] [del]") \
24105 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
24107 /* List of command functions, CLI names map directly to functions */
24108 #define foreach_cli_function \
24109 _(comment, "usage: comment <ignore-rest-of-line>") \
24110 _(dump_interface_table, "usage: dump_interface_table") \
24111 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
24112 _(dump_ipv4_table, "usage: dump_ipv4_table") \
24113 _(dump_ipv6_table, "usage: dump_ipv6_table") \
24114 _(dump_stats_table, "usage: dump_stats_table") \
24115 _(dump_macro_table, "usage: dump_macro_table ") \
24116 _(dump_node_table, "usage: dump_node_table") \
24117 _(dump_msg_api_table, "usage: dump_msg_api_table") \
24118 _(get_msg_id, "usage: get_msg_id name_and_crc") \
24119 _(echo, "usage: echo <message>") \
24120 _(exec, "usage: exec <vpe-debug-CLI-command>") \
24121 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
24122 _(help, "usage: help") \
24123 _(q, "usage: quit") \
24124 _(quit, "usage: quit") \
24125 _(search_node_table, "usage: search_node_table <name>...") \
24126 _(set, "usage: set <variable-name> <value>") \
24127 _(script, "usage: script <file-name>") \
24128 _(statseg, "usage: statseg"); \
24129 _(unset, "usage: unset <variable-name>")
24132 static void vl_api_##n##_t_handler_uni \
24133 (vl_api_##n##_t * mp) \
24135 vat_main_t * vam = &vat_main; \
24136 if (vam->json_output) { \
24137 vl_api_##n##_t_handler_json(mp); \
24139 vl_api_##n##_t_handler(mp); \
24142 foreach_vpe_api_reply_msg;
24143 #if VPP_API_TEST_BUILTIN == 0
24144 foreach_standalone_reply_msg;
24149 vat_api_hookup (vat_main_t * vam)
24152 vl_msg_api_set_handlers(VL_API_##N, #n, \
24153 vl_api_##n##_t_handler_uni, \
24155 vl_api_##n##_t_endian, \
24156 vl_api_##n##_t_print, \
24157 sizeof(vl_api_##n##_t), 1);
24158 foreach_vpe_api_reply_msg;
24159 #if VPP_API_TEST_BUILTIN == 0
24160 foreach_standalone_reply_msg;
24164 #if (VPP_API_TEST_BUILTIN==0)
24165 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
24167 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
24169 vam->function_by_name = hash_create_string (0, sizeof (uword));
24171 vam->help_by_name = hash_create_string (0, sizeof (uword));
24174 /* API messages we can send */
24175 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
24176 foreach_vpe_api_msg;
24180 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24181 foreach_vpe_api_msg;
24184 /* CLI functions */
24185 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
24186 foreach_cli_function;
24190 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24191 foreach_cli_function;
24195 #if VPP_API_TEST_BUILTIN
24196 static clib_error_t *
24197 vat_api_hookup_shim (vlib_main_t * vm)
24199 vat_api_hookup (&vat_main);
24203 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
24207 * fd.io coding-style-patch-verification: ON
24210 * eval: (c-set-style "gnu")