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);
1305 char *p = (char *) &mp->program;
1306 errmsg (" program: %s\n",
1307 vl_api_from_api_string ((vl_api_string_t *) p));
1308 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1309 errmsg (" version: %s\n",
1310 vl_api_from_api_string ((vl_api_string_t *) p));
1311 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1312 errmsg (" build date: %s\n",
1313 vl_api_from_api_string ((vl_api_string_t *) p));
1314 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1315 errmsg ("build directory: %s\n",
1316 vl_api_from_api_string ((vl_api_string_t *) p));
1318 vam->retval = retval;
1319 vam->result_ready = 1;
1322 static void vl_api_show_version_reply_t_handler_json
1323 (vl_api_show_version_reply_t * mp)
1325 vat_main_t *vam = &vat_main;
1326 vat_json_node_t node;
1328 vat_json_init_object (&node);
1329 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1330 char *p = (char *) &mp->program;
1331 vat_json_object_add_string_copy (&node, "program",
1332 vl_api_from_api_string ((vl_api_string_t *)
1334 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1335 vat_json_object_add_string_copy (&node, "version",
1336 vl_api_from_api_string ((vl_api_string_t *)
1338 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1339 vat_json_object_add_string_copy (&node, "build_date",
1340 vl_api_from_api_string ((vl_api_string_t *)
1342 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1343 vat_json_object_add_string_copy (&node, "build_directory",
1344 vl_api_from_api_string ((vl_api_string_t *)
1347 vat_json_print (vam->ofp, &node);
1348 vat_json_free (&node);
1350 vam->retval = ntohl (mp->retval);
1351 vam->result_ready = 1;
1354 static void vl_api_show_threads_reply_t_handler
1355 (vl_api_show_threads_reply_t * mp)
1357 vat_main_t *vam = &vat_main;
1358 i32 retval = ntohl (mp->retval);
1362 count = ntohl (mp->count);
1364 for (i = 0; i < count; i++)
1366 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1367 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1368 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1369 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1370 ntohl (mp->thread_data[i].cpu_socket));
1372 vam->retval = retval;
1373 vam->result_ready = 1;
1376 static void vl_api_show_threads_reply_t_handler_json
1377 (vl_api_show_threads_reply_t * mp)
1379 vat_main_t *vam = &vat_main;
1380 vat_json_node_t node;
1381 vl_api_thread_data_t *td;
1382 i32 retval = ntohl (mp->retval);
1386 count = ntohl (mp->count);
1388 vat_json_init_object (&node);
1389 vat_json_object_add_int (&node, "retval", retval);
1390 vat_json_object_add_uint (&node, "count", count);
1392 for (i = 0; i < count; i++)
1394 td = &mp->thread_data[i];
1395 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1396 vat_json_object_add_string_copy (&node, "name", td->name);
1397 vat_json_object_add_string_copy (&node, "type", td->type);
1398 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1399 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1400 vat_json_object_add_int (&node, "core", ntohl (td->id));
1401 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1404 vat_json_print (vam->ofp, &node);
1405 vat_json_free (&node);
1407 vam->retval = retval;
1408 vam->result_ready = 1;
1412 api_show_threads (vat_main_t * vam)
1414 vl_api_show_threads_t *mp;
1418 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1419 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1421 M (SHOW_THREADS, mp);
1429 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1431 u32 sw_if_index = ntohl (mp->sw_if_index);
1432 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1433 mp->mac_ip ? "mac/ip binding" : "address resolution",
1434 ntohl (mp->pid), format_ip4_address, &mp->address,
1435 format_ethernet_address, mp->new_mac, sw_if_index);
1439 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1441 /* JSON output not supported */
1445 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1447 u32 sw_if_index = ntohl (mp->sw_if_index);
1448 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1449 mp->mac_ip ? "mac/ip binding" : "address resolution",
1450 ntohl (mp->pid), format_ip6_address, mp->address,
1451 format_ethernet_address, mp->new_mac, sw_if_index);
1455 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1457 /* JSON output not supported */
1461 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1463 u32 n_macs = ntohl (mp->n_macs);
1464 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1465 ntohl (mp->pid), mp->client_index, n_macs);
1467 for (i = 0; i < n_macs; i++)
1469 vl_api_mac_entry_t *mac = &mp->mac[i];
1470 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1471 i + 1, ntohl (mac->sw_if_index),
1472 format_ethernet_address, mac->mac_addr, mac->action);
1479 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1481 /* JSON output not supported */
1484 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1485 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1488 * Special-case: build the bridge domain table, maintain
1489 * the next bd id vbl.
1491 static void vl_api_bridge_domain_details_t_handler
1492 (vl_api_bridge_domain_details_t * mp)
1494 vat_main_t *vam = &vat_main;
1495 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1498 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1499 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1501 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1502 ntohl (mp->bd_id), mp->learn, mp->forward,
1503 mp->flood, ntohl (mp->bvi_sw_if_index),
1504 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1508 vl_api_bridge_domain_sw_if_t *sw_ifs;
1509 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1512 sw_ifs = mp->sw_if_details;
1513 for (i = 0; i < n_sw_ifs; i++)
1519 sw_if_index = ntohl (sw_ifs->sw_if_index);
1522 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1524 if ((u32) p->value[0] == sw_if_index)
1526 sw_if_name = (u8 *)(p->key);
1531 print (vam->ofp, "%7d %3d %s", sw_if_index,
1532 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1533 "sw_if_index not found!");
1540 static void vl_api_bridge_domain_details_t_handler_json
1541 (vl_api_bridge_domain_details_t * mp)
1543 vat_main_t *vam = &vat_main;
1544 vat_json_node_t *node, *array = NULL;
1545 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1547 if (VAT_JSON_ARRAY != vam->json_tree.type)
1549 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1550 vat_json_init_array (&vam->json_tree);
1552 node = vat_json_array_add (&vam->json_tree);
1554 vat_json_init_object (node);
1555 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1556 vat_json_object_add_uint (node, "flood", mp->flood);
1557 vat_json_object_add_uint (node, "forward", mp->forward);
1558 vat_json_object_add_uint (node, "learn", mp->learn);
1559 vat_json_object_add_uint (node, "bvi_sw_if_index",
1560 ntohl (mp->bvi_sw_if_index));
1561 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1562 array = vat_json_object_add (node, "sw_if");
1563 vat_json_init_array (array);
1569 vl_api_bridge_domain_sw_if_t *sw_ifs;
1572 sw_ifs = mp->sw_if_details;
1573 for (i = 0; i < n_sw_ifs; i++)
1575 node = vat_json_array_add (array);
1576 vat_json_init_object (node);
1577 vat_json_object_add_uint (node, "sw_if_index",
1578 ntohl (sw_ifs->sw_if_index));
1579 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1585 static void vl_api_control_ping_reply_t_handler
1586 (vl_api_control_ping_reply_t * mp)
1588 vat_main_t *vam = &vat_main;
1589 i32 retval = ntohl (mp->retval);
1590 if (vam->async_mode)
1592 vam->async_errors += (retval < 0);
1596 vam->retval = retval;
1597 vam->result_ready = 1;
1599 if (vam->socket_client_main)
1600 vam->socket_client_main->control_pings_outstanding--;
1603 static void vl_api_control_ping_reply_t_handler_json
1604 (vl_api_control_ping_reply_t * mp)
1606 vat_main_t *vam = &vat_main;
1607 i32 retval = ntohl (mp->retval);
1609 if (VAT_JSON_NONE != vam->json_tree.type)
1611 vat_json_print (vam->ofp, &vam->json_tree);
1612 vat_json_free (&vam->json_tree);
1613 vam->json_tree.type = VAT_JSON_NONE;
1618 vat_json_init_array (&vam->json_tree);
1619 vat_json_print (vam->ofp, &vam->json_tree);
1620 vam->json_tree.type = VAT_JSON_NONE;
1623 vam->retval = retval;
1624 vam->result_ready = 1;
1628 vl_api_bridge_domain_set_mac_age_reply_t_handler
1629 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1631 vat_main_t *vam = &vat_main;
1632 i32 retval = ntohl (mp->retval);
1633 if (vam->async_mode)
1635 vam->async_errors += (retval < 0);
1639 vam->retval = retval;
1640 vam->result_ready = 1;
1644 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1645 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1647 vat_main_t *vam = &vat_main;
1648 vat_json_node_t node;
1650 vat_json_init_object (&node);
1651 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1653 vat_json_print (vam->ofp, &node);
1654 vat_json_free (&node);
1656 vam->retval = ntohl (mp->retval);
1657 vam->result_ready = 1;
1661 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1663 vat_main_t *vam = &vat_main;
1664 i32 retval = ntohl (mp->retval);
1665 if (vam->async_mode)
1667 vam->async_errors += (retval < 0);
1671 vam->retval = retval;
1672 vam->result_ready = 1;
1676 static void vl_api_l2_flags_reply_t_handler_json
1677 (vl_api_l2_flags_reply_t * mp)
1679 vat_main_t *vam = &vat_main;
1680 vat_json_node_t node;
1682 vat_json_init_object (&node);
1683 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1684 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1685 ntohl (mp->resulting_feature_bitmap));
1687 vat_json_print (vam->ofp, &node);
1688 vat_json_free (&node);
1690 vam->retval = ntohl (mp->retval);
1691 vam->result_ready = 1;
1694 static void vl_api_bridge_flags_reply_t_handler
1695 (vl_api_bridge_flags_reply_t * mp)
1697 vat_main_t *vam = &vat_main;
1698 i32 retval = ntohl (mp->retval);
1699 if (vam->async_mode)
1701 vam->async_errors += (retval < 0);
1705 vam->retval = retval;
1706 vam->result_ready = 1;
1710 static void vl_api_bridge_flags_reply_t_handler_json
1711 (vl_api_bridge_flags_reply_t * mp)
1713 vat_main_t *vam = &vat_main;
1714 vat_json_node_t node;
1716 vat_json_init_object (&node);
1717 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1718 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1719 ntohl (mp->resulting_feature_bitmap));
1721 vat_json_print (vam->ofp, &node);
1722 vat_json_free (&node);
1724 vam->retval = ntohl (mp->retval);
1725 vam->result_ready = 1;
1728 static void vl_api_tap_connect_reply_t_handler
1729 (vl_api_tap_connect_reply_t * mp)
1731 vat_main_t *vam = &vat_main;
1732 i32 retval = ntohl (mp->retval);
1733 if (vam->async_mode)
1735 vam->async_errors += (retval < 0);
1739 vam->retval = retval;
1740 vam->sw_if_index = ntohl (mp->sw_if_index);
1741 vam->result_ready = 1;
1746 static void vl_api_tap_connect_reply_t_handler_json
1747 (vl_api_tap_connect_reply_t * mp)
1749 vat_main_t *vam = &vat_main;
1750 vat_json_node_t node;
1752 vat_json_init_object (&node);
1753 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1754 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1756 vat_json_print (vam->ofp, &node);
1757 vat_json_free (&node);
1759 vam->retval = ntohl (mp->retval);
1760 vam->result_ready = 1;
1765 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1767 vat_main_t *vam = &vat_main;
1768 i32 retval = ntohl (mp->retval);
1769 if (vam->async_mode)
1771 vam->async_errors += (retval < 0);
1775 vam->retval = retval;
1776 vam->sw_if_index = ntohl (mp->sw_if_index);
1777 vam->result_ready = 1;
1781 static void vl_api_tap_modify_reply_t_handler_json
1782 (vl_api_tap_modify_reply_t * mp)
1784 vat_main_t *vam = &vat_main;
1785 vat_json_node_t node;
1787 vat_json_init_object (&node);
1788 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1789 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1791 vat_json_print (vam->ofp, &node);
1792 vat_json_free (&node);
1794 vam->retval = ntohl (mp->retval);
1795 vam->result_ready = 1;
1799 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1801 vat_main_t *vam = &vat_main;
1802 i32 retval = ntohl (mp->retval);
1803 if (vam->async_mode)
1805 vam->async_errors += (retval < 0);
1809 vam->retval = retval;
1810 vam->result_ready = 1;
1814 static void vl_api_tap_delete_reply_t_handler_json
1815 (vl_api_tap_delete_reply_t * mp)
1817 vat_main_t *vam = &vat_main;
1818 vat_json_node_t node;
1820 vat_json_init_object (&node);
1821 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1823 vat_json_print (vam->ofp, &node);
1824 vat_json_free (&node);
1826 vam->retval = ntohl (mp->retval);
1827 vam->result_ready = 1;
1831 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1833 vat_main_t *vam = &vat_main;
1834 i32 retval = ntohl (mp->retval);
1835 if (vam->async_mode)
1837 vam->async_errors += (retval < 0);
1841 vam->retval = retval;
1842 vam->sw_if_index = ntohl (mp->sw_if_index);
1843 vam->result_ready = 1;
1848 static void vl_api_tap_create_v2_reply_t_handler_json
1849 (vl_api_tap_create_v2_reply_t * mp)
1851 vat_main_t *vam = &vat_main;
1852 vat_json_node_t node;
1854 vat_json_init_object (&node);
1855 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1856 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1858 vat_json_print (vam->ofp, &node);
1859 vat_json_free (&node);
1861 vam->retval = ntohl (mp->retval);
1862 vam->result_ready = 1;
1867 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1869 vat_main_t *vam = &vat_main;
1870 i32 retval = ntohl (mp->retval);
1871 if (vam->async_mode)
1873 vam->async_errors += (retval < 0);
1877 vam->retval = retval;
1878 vam->result_ready = 1;
1882 static void vl_api_tap_delete_v2_reply_t_handler_json
1883 (vl_api_tap_delete_v2_reply_t * mp)
1885 vat_main_t *vam = &vat_main;
1886 vat_json_node_t node;
1888 vat_json_init_object (&node);
1889 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1891 vat_json_print (vam->ofp, &node);
1892 vat_json_free (&node);
1894 vam->retval = ntohl (mp->retval);
1895 vam->result_ready = 1;
1899 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1901 vat_main_t *vam = &vat_main;
1902 i32 retval = ntohl (mp->retval);
1904 if (vam->async_mode)
1906 vam->async_errors += (retval < 0);
1910 vam->retval = retval;
1911 vam->sw_if_index = ntohl (mp->sw_if_index);
1912 vam->result_ready = 1;
1916 static void vl_api_bond_create_reply_t_handler_json
1917 (vl_api_bond_create_reply_t * mp)
1919 vat_main_t *vam = &vat_main;
1920 vat_json_node_t node;
1922 vat_json_init_object (&node);
1923 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1924 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1926 vat_json_print (vam->ofp, &node);
1927 vat_json_free (&node);
1929 vam->retval = ntohl (mp->retval);
1930 vam->result_ready = 1;
1934 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1936 vat_main_t *vam = &vat_main;
1937 i32 retval = ntohl (mp->retval);
1939 if (vam->async_mode)
1941 vam->async_errors += (retval < 0);
1945 vam->retval = retval;
1946 vam->result_ready = 1;
1950 static void vl_api_bond_delete_reply_t_handler_json
1951 (vl_api_bond_delete_reply_t * mp)
1953 vat_main_t *vam = &vat_main;
1954 vat_json_node_t node;
1956 vat_json_init_object (&node);
1957 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1959 vat_json_print (vam->ofp, &node);
1960 vat_json_free (&node);
1962 vam->retval = ntohl (mp->retval);
1963 vam->result_ready = 1;
1967 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1969 vat_main_t *vam = &vat_main;
1970 i32 retval = ntohl (mp->retval);
1972 if (vam->async_mode)
1974 vam->async_errors += (retval < 0);
1978 vam->retval = retval;
1979 vam->result_ready = 1;
1983 static void vl_api_bond_enslave_reply_t_handler_json
1984 (vl_api_bond_enslave_reply_t * mp)
1986 vat_main_t *vam = &vat_main;
1987 vat_json_node_t node;
1989 vat_json_init_object (&node);
1990 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1992 vat_json_print (vam->ofp, &node);
1993 vat_json_free (&node);
1995 vam->retval = ntohl (mp->retval);
1996 vam->result_ready = 1;
2000 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
2003 vat_main_t *vam = &vat_main;
2004 i32 retval = ntohl (mp->retval);
2006 if (vam->async_mode)
2008 vam->async_errors += (retval < 0);
2012 vam->retval = retval;
2013 vam->result_ready = 1;
2017 static void vl_api_bond_detach_slave_reply_t_handler_json
2018 (vl_api_bond_detach_slave_reply_t * mp)
2020 vat_main_t *vam = &vat_main;
2021 vat_json_node_t node;
2023 vat_json_init_object (&node);
2024 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2026 vat_json_print (vam->ofp, &node);
2027 vat_json_free (&node);
2029 vam->retval = ntohl (mp->retval);
2030 vam->result_ready = 1;
2033 static void vl_api_sw_interface_bond_details_t_handler
2034 (vl_api_sw_interface_bond_details_t * mp)
2036 vat_main_t *vam = &vat_main;
2039 "%-16s %-12d %-12U %-13U %-14u %-14u",
2040 mp->interface_name, ntohl (mp->sw_if_index),
2041 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2042 ntohl (mp->active_slaves), ntohl (mp->slaves));
2045 static void vl_api_sw_interface_bond_details_t_handler_json
2046 (vl_api_sw_interface_bond_details_t * mp)
2048 vat_main_t *vam = &vat_main;
2049 vat_json_node_t *node = NULL;
2051 if (VAT_JSON_ARRAY != vam->json_tree.type)
2053 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2054 vat_json_init_array (&vam->json_tree);
2056 node = vat_json_array_add (&vam->json_tree);
2058 vat_json_init_object (node);
2059 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2060 vat_json_object_add_string_copy (node, "interface_name",
2061 mp->interface_name);
2062 vat_json_object_add_uint (node, "mode", mp->mode);
2063 vat_json_object_add_uint (node, "load_balance", mp->lb);
2064 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2065 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2069 api_sw_interface_bond_dump (vat_main_t * vam)
2071 vl_api_sw_interface_bond_dump_t *mp;
2072 vl_api_control_ping_t *mp_ping;
2076 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2077 "interface name", "sw_if_index", "mode", "load balance",
2078 "active slaves", "slaves");
2080 /* Get list of bond interfaces */
2081 M (SW_INTERFACE_BOND_DUMP, mp);
2084 /* Use a control ping for synchronization */
2085 MPING (CONTROL_PING, mp_ping);
2092 static void vl_api_sw_interface_slave_details_t_handler
2093 (vl_api_sw_interface_slave_details_t * mp)
2095 vat_main_t *vam = &vat_main;
2098 "%-25s %-12d %-12d %d", mp->interface_name,
2099 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2102 static void vl_api_sw_interface_slave_details_t_handler_json
2103 (vl_api_sw_interface_slave_details_t * mp)
2105 vat_main_t *vam = &vat_main;
2106 vat_json_node_t *node = NULL;
2108 if (VAT_JSON_ARRAY != vam->json_tree.type)
2110 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2111 vat_json_init_array (&vam->json_tree);
2113 node = vat_json_array_add (&vam->json_tree);
2115 vat_json_init_object (node);
2116 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2117 vat_json_object_add_string_copy (node, "interface_name",
2118 mp->interface_name);
2119 vat_json_object_add_uint (node, "passive", mp->is_passive);
2120 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2124 api_sw_interface_slave_dump (vat_main_t * vam)
2126 unformat_input_t *i = vam->input;
2127 vl_api_sw_interface_slave_dump_t *mp;
2128 vl_api_control_ping_t *mp_ping;
2129 u32 sw_if_index = ~0;
2130 u8 sw_if_index_set = 0;
2133 /* Parse args required to build the message */
2134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2136 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2137 sw_if_index_set = 1;
2138 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2139 sw_if_index_set = 1;
2144 if (sw_if_index_set == 0)
2146 errmsg ("missing vpp interface name. ");
2151 "\n%-25s %-12s %-12s %s",
2152 "slave interface name", "sw_if_index", "passive", "long_timeout");
2154 /* Get list of bond interfaces */
2155 M (SW_INTERFACE_SLAVE_DUMP, mp);
2156 mp->sw_if_index = ntohl (sw_if_index);
2159 /* Use a control ping for synchronization */
2160 MPING (CONTROL_PING, mp_ping);
2167 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2168 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2170 vat_main_t *vam = &vat_main;
2171 i32 retval = ntohl (mp->retval);
2172 if (vam->async_mode)
2174 vam->async_errors += (retval < 0);
2178 vam->retval = retval;
2179 vam->sw_if_index = ntohl (mp->sw_if_index);
2180 vam->result_ready = 1;
2182 vam->regenerate_interface_table = 1;
2185 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2186 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2188 vat_main_t *vam = &vat_main;
2189 vat_json_node_t node;
2191 vat_json_init_object (&node);
2192 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2193 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2194 ntohl (mp->sw_if_index));
2196 vat_json_print (vam->ofp, &node);
2197 vat_json_free (&node);
2199 vam->retval = ntohl (mp->retval);
2200 vam->result_ready = 1;
2203 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2204 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2206 vat_main_t *vam = &vat_main;
2207 i32 retval = ntohl (mp->retval);
2208 if (vam->async_mode)
2210 vam->async_errors += (retval < 0);
2214 vam->retval = retval;
2215 vam->sw_if_index = ntohl (mp->sw_if_index);
2216 vam->result_ready = 1;
2220 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2221 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2223 vat_main_t *vam = &vat_main;
2224 vat_json_node_t node;
2226 vat_json_init_object (&node);
2227 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2228 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2230 vat_json_print (vam->ofp, &node);
2231 vat_json_free (&node);
2233 vam->retval = ntohl (mp->retval);
2234 vam->result_ready = 1;
2237 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2238 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2240 vat_main_t *vam = &vat_main;
2241 i32 retval = ntohl (mp->retval);
2242 if (vam->async_mode)
2244 vam->async_errors += (retval < 0);
2248 vam->retval = retval;
2249 vam->result_ready = 1;
2253 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2254 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2256 vat_main_t *vam = &vat_main;
2257 vat_json_node_t node;
2259 vat_json_init_object (&node);
2260 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2261 vat_json_object_add_uint (&node, "fwd_entry_index",
2262 clib_net_to_host_u32 (mp->fwd_entry_index));
2264 vat_json_print (vam->ofp, &node);
2265 vat_json_free (&node);
2267 vam->retval = ntohl (mp->retval);
2268 vam->result_ready = 1;
2272 format_lisp_transport_protocol (u8 * s, va_list * args)
2274 u32 proto = va_arg (*args, u32);
2279 return format (s, "udp");
2281 return format (s, "api");
2288 static void vl_api_one_get_transport_protocol_reply_t_handler
2289 (vl_api_one_get_transport_protocol_reply_t * mp)
2291 vat_main_t *vam = &vat_main;
2292 i32 retval = ntohl (mp->retval);
2293 if (vam->async_mode)
2295 vam->async_errors += (retval < 0);
2299 u32 proto = mp->protocol;
2300 print (vam->ofp, "Transport protocol: %U",
2301 format_lisp_transport_protocol, proto);
2302 vam->retval = retval;
2303 vam->result_ready = 1;
2307 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2308 (vl_api_one_get_transport_protocol_reply_t * mp)
2310 vat_main_t *vam = &vat_main;
2311 vat_json_node_t node;
2314 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2317 vat_json_init_object (&node);
2318 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2319 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2322 vat_json_print (vam->ofp, &node);
2323 vat_json_free (&node);
2325 vam->retval = ntohl (mp->retval);
2326 vam->result_ready = 1;
2329 static void vl_api_one_add_del_locator_set_reply_t_handler
2330 (vl_api_one_add_del_locator_set_reply_t * mp)
2332 vat_main_t *vam = &vat_main;
2333 i32 retval = ntohl (mp->retval);
2334 if (vam->async_mode)
2336 vam->async_errors += (retval < 0);
2340 vam->retval = retval;
2341 vam->result_ready = 1;
2345 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2346 (vl_api_one_add_del_locator_set_reply_t * mp)
2348 vat_main_t *vam = &vat_main;
2349 vat_json_node_t node;
2351 vat_json_init_object (&node);
2352 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2353 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2355 vat_json_print (vam->ofp, &node);
2356 vat_json_free (&node);
2358 vam->retval = ntohl (mp->retval);
2359 vam->result_ready = 1;
2362 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2363 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2365 vat_main_t *vam = &vat_main;
2366 i32 retval = ntohl (mp->retval);
2367 if (vam->async_mode)
2369 vam->async_errors += (retval < 0);
2373 vam->retval = retval;
2374 vam->sw_if_index = ntohl (mp->sw_if_index);
2375 vam->result_ready = 1;
2377 vam->regenerate_interface_table = 1;
2380 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2381 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2383 vat_main_t *vam = &vat_main;
2384 vat_json_node_t node;
2386 vat_json_init_object (&node);
2387 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2388 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2390 vat_json_print (vam->ofp, &node);
2391 vat_json_free (&node);
2393 vam->retval = ntohl (mp->retval);
2394 vam->result_ready = 1;
2397 static void vl_api_vxlan_offload_rx_reply_t_handler
2398 (vl_api_vxlan_offload_rx_reply_t * mp)
2400 vat_main_t *vam = &vat_main;
2401 i32 retval = ntohl (mp->retval);
2402 if (vam->async_mode)
2404 vam->async_errors += (retval < 0);
2408 vam->retval = retval;
2409 vam->result_ready = 1;
2413 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2414 (vl_api_vxlan_offload_rx_reply_t * mp)
2416 vat_main_t *vam = &vat_main;
2417 vat_json_node_t node;
2419 vat_json_init_object (&node);
2420 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2422 vat_json_print (vam->ofp, &node);
2423 vat_json_free (&node);
2425 vam->retval = ntohl (mp->retval);
2426 vam->result_ready = 1;
2429 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2430 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2432 vat_main_t *vam = &vat_main;
2433 i32 retval = ntohl (mp->retval);
2434 if (vam->async_mode)
2436 vam->async_errors += (retval < 0);
2440 vam->retval = retval;
2441 vam->sw_if_index = ntohl (mp->sw_if_index);
2442 vam->result_ready = 1;
2446 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2447 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2449 vat_main_t *vam = &vat_main;
2450 vat_json_node_t node;
2452 vat_json_init_object (&node);
2453 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2454 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2456 vat_json_print (vam->ofp, &node);
2457 vat_json_free (&node);
2459 vam->retval = ntohl (mp->retval);
2460 vam->result_ready = 1;
2463 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2464 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2466 vat_main_t *vam = &vat_main;
2467 i32 retval = ntohl (mp->retval);
2468 if (vam->async_mode)
2470 vam->async_errors += (retval < 0);
2474 vam->retval = retval;
2475 vam->sw_if_index = ntohl (mp->sw_if_index);
2476 vam->result_ready = 1;
2478 vam->regenerate_interface_table = 1;
2481 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2482 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2484 vat_main_t *vam = &vat_main;
2485 vat_json_node_t node;
2487 vat_json_init_object (&node);
2488 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2489 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2491 vat_json_print (vam->ofp, &node);
2492 vat_json_free (&node);
2494 vam->retval = ntohl (mp->retval);
2495 vam->result_ready = 1;
2498 static void vl_api_gre_add_del_tunnel_reply_t_handler
2499 (vl_api_gre_add_del_tunnel_reply_t * mp)
2501 vat_main_t *vam = &vat_main;
2502 i32 retval = ntohl (mp->retval);
2503 if (vam->async_mode)
2505 vam->async_errors += (retval < 0);
2509 vam->retval = retval;
2510 vam->sw_if_index = ntohl (mp->sw_if_index);
2511 vam->result_ready = 1;
2515 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2516 (vl_api_gre_add_del_tunnel_reply_t * mp)
2518 vat_main_t *vam = &vat_main;
2519 vat_json_node_t node;
2521 vat_json_init_object (&node);
2522 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2523 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2525 vat_json_print (vam->ofp, &node);
2526 vat_json_free (&node);
2528 vam->retval = ntohl (mp->retval);
2529 vam->result_ready = 1;
2532 static void vl_api_create_vhost_user_if_reply_t_handler
2533 (vl_api_create_vhost_user_if_reply_t * mp)
2535 vat_main_t *vam = &vat_main;
2536 i32 retval = ntohl (mp->retval);
2537 if (vam->async_mode)
2539 vam->async_errors += (retval < 0);
2543 vam->retval = retval;
2544 vam->sw_if_index = ntohl (mp->sw_if_index);
2545 vam->result_ready = 1;
2547 vam->regenerate_interface_table = 1;
2550 static void vl_api_create_vhost_user_if_reply_t_handler_json
2551 (vl_api_create_vhost_user_if_reply_t * mp)
2553 vat_main_t *vam = &vat_main;
2554 vat_json_node_t node;
2556 vat_json_init_object (&node);
2557 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2558 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2560 vat_json_print (vam->ofp, &node);
2561 vat_json_free (&node);
2563 vam->retval = ntohl (mp->retval);
2564 vam->result_ready = 1;
2567 static void vl_api_dns_resolve_name_reply_t_handler
2568 (vl_api_dns_resolve_name_reply_t * mp)
2570 vat_main_t *vam = &vat_main;
2571 i32 retval = ntohl (mp->retval);
2572 if (vam->async_mode)
2574 vam->async_errors += (retval < 0);
2578 vam->retval = retval;
2579 vam->result_ready = 1;
2584 clib_warning ("ip4 address %U", format_ip4_address,
2585 (ip4_address_t *) mp->ip4_address);
2587 clib_warning ("ip6 address %U", format_ip6_address,
2588 (ip6_address_t *) mp->ip6_address);
2591 clib_warning ("retval %d", retval);
2595 static void vl_api_dns_resolve_name_reply_t_handler_json
2596 (vl_api_dns_resolve_name_reply_t * mp)
2598 clib_warning ("not implemented");
2601 static void vl_api_dns_resolve_ip_reply_t_handler
2602 (vl_api_dns_resolve_ip_reply_t * mp)
2604 vat_main_t *vam = &vat_main;
2605 i32 retval = ntohl (mp->retval);
2606 if (vam->async_mode)
2608 vam->async_errors += (retval < 0);
2612 vam->retval = retval;
2613 vam->result_ready = 1;
2617 clib_warning ("canonical name %s", mp->name);
2620 clib_warning ("retval %d", retval);
2624 static void vl_api_dns_resolve_ip_reply_t_handler_json
2625 (vl_api_dns_resolve_ip_reply_t * mp)
2627 clib_warning ("not implemented");
2631 static void vl_api_ip_address_details_t_handler
2632 (vl_api_ip_address_details_t * mp)
2634 vat_main_t *vam = &vat_main;
2635 static ip_address_details_t empty_ip_address_details = { {0} };
2636 ip_address_details_t *address = NULL;
2637 ip_details_t *current_ip_details = NULL;
2638 ip_details_t *details = NULL;
2640 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2642 if (!details || vam->current_sw_if_index >= vec_len (details)
2643 || !details[vam->current_sw_if_index].present)
2645 errmsg ("ip address details arrived but not stored");
2646 errmsg ("ip_dump should be called first");
2650 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2652 #define addresses (current_ip_details->addr)
2654 vec_validate_init_empty (addresses, vec_len (addresses),
2655 empty_ip_address_details);
2657 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2659 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2660 address->prefix_length = mp->prefix_length;
2664 static void vl_api_ip_address_details_t_handler_json
2665 (vl_api_ip_address_details_t * mp)
2667 vat_main_t *vam = &vat_main;
2668 vat_json_node_t *node = NULL;
2669 struct in6_addr ip6;
2672 if (VAT_JSON_ARRAY != vam->json_tree.type)
2674 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2675 vat_json_init_array (&vam->json_tree);
2677 node = vat_json_array_add (&vam->json_tree);
2679 vat_json_init_object (node);
2682 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2683 vat_json_object_add_ip6 (node, "ip", ip6);
2687 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2688 vat_json_object_add_ip4 (node, "ip", ip4);
2690 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2694 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2696 vat_main_t *vam = &vat_main;
2697 static ip_details_t empty_ip_details = { 0 };
2698 ip_details_t *ip = NULL;
2699 u32 sw_if_index = ~0;
2701 sw_if_index = ntohl (mp->sw_if_index);
2703 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2704 sw_if_index, empty_ip_details);
2706 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2713 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2715 vat_main_t *vam = &vat_main;
2717 if (VAT_JSON_ARRAY != vam->json_tree.type)
2719 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2720 vat_json_init_array (&vam->json_tree);
2722 vat_json_array_add_uint (&vam->json_tree,
2723 clib_net_to_host_u32 (mp->sw_if_index));
2727 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2729 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2730 "router_addr %U host_mac %U",
2731 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2733 format_ip4_address, &mp->lease.host_address,
2734 format_ip4_address, &mp->lease.router_address,
2735 format_ethernet_address, mp->lease.host_mac);
2738 static void vl_api_dhcp_compl_event_t_handler_json
2739 (vl_api_dhcp_compl_event_t * mp)
2741 /* JSON output not supported */
2745 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2748 vat_main_t *vam = &vat_main;
2749 static u64 default_counter = 0;
2751 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2753 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2754 sw_if_index, default_counter);
2755 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2759 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2760 interface_counter_t counter)
2762 vat_main_t *vam = &vat_main;
2763 static interface_counter_t default_counter = { 0, };
2765 vec_validate_init_empty (vam->combined_interface_counters,
2766 vnet_counter_type, NULL);
2767 vec_validate_init_empty (vam->combined_interface_counters
2768 [vnet_counter_type], sw_if_index, default_counter);
2769 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2772 static void vl_api_vnet_interface_simple_counters_t_handler
2773 (vl_api_vnet_interface_simple_counters_t * mp)
2778 static void vl_api_vnet_interface_combined_counters_t_handler
2779 (vl_api_vnet_interface_combined_counters_t * mp)
2784 static void vl_api_vnet_interface_simple_counters_t_handler_json
2785 (vl_api_vnet_interface_simple_counters_t * mp)
2790 u32 first_sw_if_index;
2793 count = ntohl (mp->count);
2794 first_sw_if_index = ntohl (mp->first_sw_if_index);
2796 v_packets = (u64 *) & mp->data;
2797 for (i = 0; i < count; i++)
2799 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2800 set_simple_interface_counter (mp->vnet_counter_type,
2801 first_sw_if_index + i, packets);
2806 static void vl_api_vnet_interface_combined_counters_t_handler_json
2807 (vl_api_vnet_interface_combined_counters_t * mp)
2809 interface_counter_t counter;
2811 u32 first_sw_if_index;
2815 count = ntohl (mp->count);
2816 first_sw_if_index = ntohl (mp->first_sw_if_index);
2818 v = (vlib_counter_t *) & mp->data;
2819 for (i = 0; i < count; i++)
2822 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2824 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2825 set_combined_interface_counter (mp->vnet_counter_type,
2826 first_sw_if_index + i, counter);
2832 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2834 vat_main_t *vam = &vat_main;
2837 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2839 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2848 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2850 vat_main_t *vam = &vat_main;
2853 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2855 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2863 static void vl_api_vnet_ip4_fib_counters_t_handler
2864 (vl_api_vnet_ip4_fib_counters_t * mp)
2869 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2870 (vl_api_vnet_ip4_fib_counters_t * mp)
2872 vat_main_t *vam = &vat_main;
2873 vl_api_ip4_fib_counter_t *v;
2874 ip4_fib_counter_t *counter;
2881 vrf_id = ntohl (mp->vrf_id);
2882 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2883 if (~0 == vrf_index)
2885 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2886 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2887 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2888 vec_validate (vam->ip4_fib_counters, vrf_index);
2889 vam->ip4_fib_counters[vrf_index] = NULL;
2892 vec_free (vam->ip4_fib_counters[vrf_index]);
2893 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2894 count = ntohl (mp->count);
2895 for (i = 0; i < count; i++)
2897 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2898 counter = &vam->ip4_fib_counters[vrf_index][i];
2899 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2900 counter->address = ip4;
2901 counter->address_length = v->address_length;
2902 counter->packets = clib_net_to_host_u64 (v->packets);
2903 counter->bytes = clib_net_to_host_u64 (v->bytes);
2908 static void vl_api_vnet_ip4_nbr_counters_t_handler
2909 (vl_api_vnet_ip4_nbr_counters_t * mp)
2914 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2915 (vl_api_vnet_ip4_nbr_counters_t * mp)
2917 vat_main_t *vam = &vat_main;
2918 vl_api_ip4_nbr_counter_t *v;
2919 ip4_nbr_counter_t *counter;
2924 sw_if_index = ntohl (mp->sw_if_index);
2925 count = ntohl (mp->count);
2926 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2929 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2931 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2932 for (i = 0; i < count; i++)
2934 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2935 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2936 counter->address.s_addr = v->address;
2937 counter->packets = clib_net_to_host_u64 (v->packets);
2938 counter->bytes = clib_net_to_host_u64 (v->bytes);
2939 counter->linkt = v->link_type;
2944 static void vl_api_vnet_ip6_fib_counters_t_handler
2945 (vl_api_vnet_ip6_fib_counters_t * mp)
2950 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2951 (vl_api_vnet_ip6_fib_counters_t * mp)
2953 vat_main_t *vam = &vat_main;
2954 vl_api_ip6_fib_counter_t *v;
2955 ip6_fib_counter_t *counter;
2956 struct in6_addr ip6;
2962 vrf_id = ntohl (mp->vrf_id);
2963 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2964 if (~0 == vrf_index)
2966 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2967 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2968 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2969 vec_validate (vam->ip6_fib_counters, vrf_index);
2970 vam->ip6_fib_counters[vrf_index] = NULL;
2973 vec_free (vam->ip6_fib_counters[vrf_index]);
2974 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2975 count = ntohl (mp->count);
2976 for (i = 0; i < count; i++)
2978 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2979 counter = &vam->ip6_fib_counters[vrf_index][i];
2980 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2981 counter->address = ip6;
2982 counter->address_length = v->address_length;
2983 counter->packets = clib_net_to_host_u64 (v->packets);
2984 counter->bytes = clib_net_to_host_u64 (v->bytes);
2989 static void vl_api_vnet_ip6_nbr_counters_t_handler
2990 (vl_api_vnet_ip6_nbr_counters_t * mp)
2995 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2996 (vl_api_vnet_ip6_nbr_counters_t * mp)
2998 vat_main_t *vam = &vat_main;
2999 vl_api_ip6_nbr_counter_t *v;
3000 ip6_nbr_counter_t *counter;
3001 struct in6_addr ip6;
3006 sw_if_index = ntohl (mp->sw_if_index);
3007 count = ntohl (mp->count);
3008 vec_validate (vam->ip6_nbr_counters, sw_if_index);
3011 vec_free (vam->ip6_nbr_counters[sw_if_index]);
3013 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
3014 for (i = 0; i < count; i++)
3016 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
3017 counter = &vam->ip6_nbr_counters[sw_if_index][i];
3018 clib_memcpy (&ip6, &v->address, sizeof (ip6));
3019 counter->address = ip6;
3020 counter->packets = clib_net_to_host_u64 (v->packets);
3021 counter->bytes = clib_net_to_host_u64 (v->bytes);
3026 static void vl_api_get_first_msg_id_reply_t_handler
3027 (vl_api_get_first_msg_id_reply_t * mp)
3029 vat_main_t *vam = &vat_main;
3030 i32 retval = ntohl (mp->retval);
3032 if (vam->async_mode)
3034 vam->async_errors += (retval < 0);
3038 vam->retval = retval;
3039 vam->result_ready = 1;
3043 errmsg ("first message id %d", ntohs (mp->first_msg_id));
3047 static void vl_api_get_first_msg_id_reply_t_handler_json
3048 (vl_api_get_first_msg_id_reply_t * mp)
3050 vat_main_t *vam = &vat_main;
3051 vat_json_node_t node;
3053 vat_json_init_object (&node);
3054 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3055 vat_json_object_add_uint (&node, "first_msg_id",
3056 (uint) ntohs (mp->first_msg_id));
3058 vat_json_print (vam->ofp, &node);
3059 vat_json_free (&node);
3061 vam->retval = ntohl (mp->retval);
3062 vam->result_ready = 1;
3065 static void vl_api_get_node_graph_reply_t_handler
3066 (vl_api_get_node_graph_reply_t * mp)
3068 vat_main_t *vam = &vat_main;
3069 api_main_t *am = &api_main;
3070 i32 retval = ntohl (mp->retval);
3071 u8 *pvt_copy, *reply;
3076 if (vam->async_mode)
3078 vam->async_errors += (retval < 0);
3082 vam->retval = retval;
3083 vam->result_ready = 1;
3086 /* "Should never happen..." */
3090 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3091 pvt_copy = vec_dup (reply);
3093 /* Toss the shared-memory original... */
3094 pthread_mutex_lock (&am->vlib_rp->mutex);
3095 oldheap = svm_push_data_heap (am->vlib_rp);
3099 svm_pop_heap (oldheap);
3100 pthread_mutex_unlock (&am->vlib_rp->mutex);
3102 if (vam->graph_nodes)
3104 hash_free (vam->graph_node_index_by_name);
3106 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3108 node = vam->graph_nodes[0][i];
3109 vec_free (node->name);
3110 vec_free (node->next_nodes);
3113 vec_free (vam->graph_nodes[0]);
3114 vec_free (vam->graph_nodes);
3117 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3118 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3119 vec_free (pvt_copy);
3121 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3123 node = vam->graph_nodes[0][i];
3124 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3128 static void vl_api_get_node_graph_reply_t_handler_json
3129 (vl_api_get_node_graph_reply_t * mp)
3131 vat_main_t *vam = &vat_main;
3132 api_main_t *am = &api_main;
3134 vat_json_node_t node;
3137 /* $$$$ make this real? */
3138 vat_json_init_object (&node);
3139 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3140 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3142 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3144 /* Toss the shared-memory original... */
3145 pthread_mutex_lock (&am->vlib_rp->mutex);
3146 oldheap = svm_push_data_heap (am->vlib_rp);
3150 svm_pop_heap (oldheap);
3151 pthread_mutex_unlock (&am->vlib_rp->mutex);
3153 vat_json_print (vam->ofp, &node);
3154 vat_json_free (&node);
3156 vam->retval = ntohl (mp->retval);
3157 vam->result_ready = 1;
3161 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3163 vat_main_t *vam = &vat_main;
3168 s = format (s, "%=16d%=16d%=16d",
3169 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3173 s = format (s, "%=16U%=16d%=16d",
3174 mp->is_ipv6 ? format_ip6_address :
3176 mp->ip_address, mp->priority, mp->weight);
3179 print (vam->ofp, "%v", s);
3184 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3186 vat_main_t *vam = &vat_main;
3187 vat_json_node_t *node = NULL;
3188 struct in6_addr ip6;
3191 if (VAT_JSON_ARRAY != vam->json_tree.type)
3193 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3194 vat_json_init_array (&vam->json_tree);
3196 node = vat_json_array_add (&vam->json_tree);
3197 vat_json_init_object (node);
3199 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3200 vat_json_object_add_uint (node, "priority", mp->priority);
3201 vat_json_object_add_uint (node, "weight", mp->weight);
3204 vat_json_object_add_uint (node, "sw_if_index",
3205 clib_net_to_host_u32 (mp->sw_if_index));
3210 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3211 vat_json_object_add_ip6 (node, "address", ip6);
3215 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3216 vat_json_object_add_ip4 (node, "address", ip4);
3222 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3225 vat_main_t *vam = &vat_main;
3228 ls_name = format (0, "%s", mp->ls_name);
3230 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3236 vl_api_one_locator_set_details_t_handler_json
3237 (vl_api_one_locator_set_details_t * mp)
3239 vat_main_t *vam = &vat_main;
3240 vat_json_node_t *node = 0;
3243 ls_name = format (0, "%s", mp->ls_name);
3244 vec_add1 (ls_name, 0);
3246 if (VAT_JSON_ARRAY != vam->json_tree.type)
3248 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3249 vat_json_init_array (&vam->json_tree);
3251 node = vat_json_array_add (&vam->json_tree);
3253 vat_json_init_object (node);
3254 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3255 vat_json_object_add_uint (node, "ls_index",
3256 clib_net_to_host_u32 (mp->ls_index));
3264 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3267 unformat_nsh_address (unformat_input_t * input, va_list * args)
3269 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3270 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3274 format_nsh_address_vat (u8 * s, va_list * args)
3276 nsh_t *a = va_arg (*args, nsh_t *);
3277 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3281 format_lisp_flat_eid (u8 * s, va_list * args)
3283 u32 type = va_arg (*args, u32);
3284 u8 *eid = va_arg (*args, u8 *);
3285 u32 eid_len = va_arg (*args, u32);
3290 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3292 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3294 return format (s, "%U", format_ethernet_address, eid);
3296 return format (s, "%U", format_nsh_address_vat, eid);
3302 format_lisp_eid_vat (u8 * s, va_list * args)
3304 u32 type = va_arg (*args, u32);
3305 u8 *eid = va_arg (*args, u8 *);
3306 u32 eid_len = va_arg (*args, u32);
3307 u8 *seid = va_arg (*args, u8 *);
3308 u32 seid_len = va_arg (*args, u32);
3309 u32 is_src_dst = va_arg (*args, u32);
3312 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3314 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3320 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3322 vat_main_t *vam = &vat_main;
3323 u8 *s = 0, *eid = 0;
3325 if (~0 == mp->locator_set_index)
3326 s = format (0, "action: %d", mp->action);
3328 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3330 eid = format (0, "%U", format_lisp_eid_vat,
3334 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3337 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3338 clib_net_to_host_u32 (mp->vni),
3340 mp->is_local ? "local" : "remote",
3341 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3342 clib_net_to_host_u16 (mp->key_id), mp->key);
3349 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3352 vat_main_t *vam = &vat_main;
3353 vat_json_node_t *node = 0;
3356 if (VAT_JSON_ARRAY != vam->json_tree.type)
3358 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3359 vat_json_init_array (&vam->json_tree);
3361 node = vat_json_array_add (&vam->json_tree);
3363 vat_json_init_object (node);
3364 if (~0 == mp->locator_set_index)
3365 vat_json_object_add_uint (node, "action", mp->action);
3367 vat_json_object_add_uint (node, "locator_set_index",
3368 clib_net_to_host_u32 (mp->locator_set_index));
3370 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3371 if (mp->eid_type == 3)
3373 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3374 vat_json_init_object (nsh_json);
3375 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3376 vat_json_object_add_uint (nsh_json, "spi",
3377 clib_net_to_host_u32 (nsh->spi));
3378 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3382 eid = format (0, "%U", format_lisp_eid_vat,
3386 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3388 vat_json_object_add_string_copy (node, "eid", eid);
3391 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3392 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3393 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3397 vat_json_object_add_uint (node, "key_id",
3398 clib_net_to_host_u16 (mp->key_id));
3399 vat_json_object_add_string_copy (node, "key", mp->key);
3404 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3406 vat_main_t *vam = &vat_main;
3407 u8 *seid = 0, *deid = 0;
3408 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3410 deid = format (0, "%U", format_lisp_eid_vat,
3411 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3413 seid = format (0, "%U", format_lisp_eid_vat,
3414 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3420 format_ip_address_fcn = format_ip4_address;
3422 format_ip_address_fcn = format_ip6_address;
3425 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3426 clib_net_to_host_u32 (mp->vni),
3428 format_ip_address_fcn, mp->lloc,
3429 format_ip_address_fcn, mp->rloc,
3430 clib_net_to_host_u32 (mp->pkt_count),
3431 clib_net_to_host_u32 (mp->bytes));
3438 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3440 struct in6_addr ip6;
3442 vat_main_t *vam = &vat_main;
3443 vat_json_node_t *node = 0;
3444 u8 *deid = 0, *seid = 0;
3446 if (VAT_JSON_ARRAY != vam->json_tree.type)
3448 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3449 vat_json_init_array (&vam->json_tree);
3451 node = vat_json_array_add (&vam->json_tree);
3453 vat_json_init_object (node);
3454 deid = format (0, "%U", format_lisp_eid_vat,
3455 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3457 seid = format (0, "%U", format_lisp_eid_vat,
3458 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3463 vat_json_object_add_string_copy (node, "seid", seid);
3464 vat_json_object_add_string_copy (node, "deid", deid);
3465 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3469 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3470 vat_json_object_add_ip4 (node, "lloc", ip4);
3471 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3472 vat_json_object_add_ip4 (node, "rloc", ip4);
3476 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3477 vat_json_object_add_ip6 (node, "lloc", ip6);
3478 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3479 vat_json_object_add_ip6 (node, "rloc", ip6);
3481 vat_json_object_add_uint (node, "pkt_count",
3482 clib_net_to_host_u32 (mp->pkt_count));
3483 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3490 vl_api_one_eid_table_map_details_t_handler
3491 (vl_api_one_eid_table_map_details_t * mp)
3493 vat_main_t *vam = &vat_main;
3495 u8 *line = format (0, "%=10d%=10d",
3496 clib_net_to_host_u32 (mp->vni),
3497 clib_net_to_host_u32 (mp->dp_table));
3498 print (vam->ofp, "%v", line);
3503 vl_api_one_eid_table_map_details_t_handler_json
3504 (vl_api_one_eid_table_map_details_t * mp)
3506 vat_main_t *vam = &vat_main;
3507 vat_json_node_t *node = NULL;
3509 if (VAT_JSON_ARRAY != vam->json_tree.type)
3511 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3512 vat_json_init_array (&vam->json_tree);
3514 node = vat_json_array_add (&vam->json_tree);
3515 vat_json_init_object (node);
3516 vat_json_object_add_uint (node, "dp_table",
3517 clib_net_to_host_u32 (mp->dp_table));
3518 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3522 vl_api_one_eid_table_vni_details_t_handler
3523 (vl_api_one_eid_table_vni_details_t * mp)
3525 vat_main_t *vam = &vat_main;
3527 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3528 print (vam->ofp, "%v", line);
3533 vl_api_one_eid_table_vni_details_t_handler_json
3534 (vl_api_one_eid_table_vni_details_t * mp)
3536 vat_main_t *vam = &vat_main;
3537 vat_json_node_t *node = NULL;
3539 if (VAT_JSON_ARRAY != vam->json_tree.type)
3541 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3542 vat_json_init_array (&vam->json_tree);
3544 node = vat_json_array_add (&vam->json_tree);
3545 vat_json_init_object (node);
3546 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3550 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3551 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3553 vat_main_t *vam = &vat_main;
3554 int retval = clib_net_to_host_u32 (mp->retval);
3556 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3557 print (vam->ofp, "fallback threshold value: %d", mp->value);
3559 vam->retval = retval;
3560 vam->result_ready = 1;
3564 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3565 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3567 vat_main_t *vam = &vat_main;
3568 vat_json_node_t _node, *node = &_node;
3569 int retval = clib_net_to_host_u32 (mp->retval);
3571 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3572 vat_json_init_object (node);
3573 vat_json_object_add_uint (node, "value", mp->value);
3575 vat_json_print (vam->ofp, node);
3576 vat_json_free (node);
3578 vam->retval = retval;
3579 vam->result_ready = 1;
3583 vl_api_show_one_map_register_state_reply_t_handler
3584 (vl_api_show_one_map_register_state_reply_t * mp)
3586 vat_main_t *vam = &vat_main;
3587 int retval = clib_net_to_host_u32 (mp->retval);
3589 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3591 vam->retval = retval;
3592 vam->result_ready = 1;
3596 vl_api_show_one_map_register_state_reply_t_handler_json
3597 (vl_api_show_one_map_register_state_reply_t * mp)
3599 vat_main_t *vam = &vat_main;
3600 vat_json_node_t _node, *node = &_node;
3601 int retval = clib_net_to_host_u32 (mp->retval);
3603 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3605 vat_json_init_object (node);
3606 vat_json_object_add_string_copy (node, "state", s);
3608 vat_json_print (vam->ofp, node);
3609 vat_json_free (node);
3611 vam->retval = retval;
3612 vam->result_ready = 1;
3617 vl_api_show_one_rloc_probe_state_reply_t_handler
3618 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3620 vat_main_t *vam = &vat_main;
3621 int retval = clib_net_to_host_u32 (mp->retval);
3626 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3628 vam->retval = retval;
3629 vam->result_ready = 1;
3633 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3634 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3636 vat_main_t *vam = &vat_main;
3637 vat_json_node_t _node, *node = &_node;
3638 int retval = clib_net_to_host_u32 (mp->retval);
3640 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3641 vat_json_init_object (node);
3642 vat_json_object_add_string_copy (node, "state", s);
3644 vat_json_print (vam->ofp, node);
3645 vat_json_free (node);
3647 vam->retval = retval;
3648 vam->result_ready = 1;
3653 vl_api_show_one_stats_enable_disable_reply_t_handler
3654 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3656 vat_main_t *vam = &vat_main;
3657 int retval = clib_net_to_host_u32 (mp->retval);
3662 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3664 vam->retval = retval;
3665 vam->result_ready = 1;
3669 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3670 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3672 vat_main_t *vam = &vat_main;
3673 vat_json_node_t _node, *node = &_node;
3674 int retval = clib_net_to_host_u32 (mp->retval);
3676 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3677 vat_json_init_object (node);
3678 vat_json_object_add_string_copy (node, "state", s);
3680 vat_json_print (vam->ofp, node);
3681 vat_json_free (node);
3683 vam->retval = retval;
3684 vam->result_ready = 1;
3689 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3691 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3692 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3693 e->vni = clib_net_to_host_u32 (e->vni);
3697 gpe_fwd_entries_get_reply_t_net_to_host
3698 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3702 mp->count = clib_net_to_host_u32 (mp->count);
3703 for (i = 0; i < mp->count; i++)
3705 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3710 format_gpe_encap_mode (u8 * s, va_list * args)
3712 u32 mode = va_arg (*args, u32);
3717 return format (s, "lisp");
3719 return format (s, "vxlan");
3725 vl_api_gpe_get_encap_mode_reply_t_handler
3726 (vl_api_gpe_get_encap_mode_reply_t * mp)
3728 vat_main_t *vam = &vat_main;
3730 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3731 vam->retval = ntohl (mp->retval);
3732 vam->result_ready = 1;
3736 vl_api_gpe_get_encap_mode_reply_t_handler_json
3737 (vl_api_gpe_get_encap_mode_reply_t * mp)
3739 vat_main_t *vam = &vat_main;
3740 vat_json_node_t node;
3742 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3743 vec_add1 (encap_mode, 0);
3745 vat_json_init_object (&node);
3746 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3748 vec_free (encap_mode);
3749 vat_json_print (vam->ofp, &node);
3750 vat_json_free (&node);
3752 vam->retval = ntohl (mp->retval);
3753 vam->result_ready = 1;
3757 vl_api_gpe_fwd_entry_path_details_t_handler
3758 (vl_api_gpe_fwd_entry_path_details_t * mp)
3760 vat_main_t *vam = &vat_main;
3761 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3763 if (mp->lcl_loc.is_ip4)
3764 format_ip_address_fcn = format_ip4_address;
3766 format_ip_address_fcn = format_ip6_address;
3768 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3769 format_ip_address_fcn, &mp->lcl_loc,
3770 format_ip_address_fcn, &mp->rmt_loc);
3774 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3776 struct in6_addr ip6;
3781 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3782 vat_json_object_add_ip4 (n, "address", ip4);
3786 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3787 vat_json_object_add_ip6 (n, "address", ip6);
3789 vat_json_object_add_uint (n, "weight", loc->weight);
3793 vl_api_gpe_fwd_entry_path_details_t_handler_json
3794 (vl_api_gpe_fwd_entry_path_details_t * mp)
3796 vat_main_t *vam = &vat_main;
3797 vat_json_node_t *node = NULL;
3798 vat_json_node_t *loc_node;
3800 if (VAT_JSON_ARRAY != vam->json_tree.type)
3802 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3803 vat_json_init_array (&vam->json_tree);
3805 node = vat_json_array_add (&vam->json_tree);
3806 vat_json_init_object (node);
3808 loc_node = vat_json_object_add (node, "local_locator");
3809 vat_json_init_object (loc_node);
3810 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3812 loc_node = vat_json_object_add (node, "remote_locator");
3813 vat_json_init_object (loc_node);
3814 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3818 vl_api_gpe_fwd_entries_get_reply_t_handler
3819 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3821 vat_main_t *vam = &vat_main;
3823 int retval = clib_net_to_host_u32 (mp->retval);
3824 vl_api_gpe_fwd_entry_t *e;
3829 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3831 for (i = 0; i < mp->count; i++)
3833 e = &mp->entries[i];
3834 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3835 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3836 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3840 vam->retval = retval;
3841 vam->result_ready = 1;
3845 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3846 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3849 vat_main_t *vam = &vat_main;
3850 vat_json_node_t *e = 0, root;
3852 int retval = clib_net_to_host_u32 (mp->retval);
3853 vl_api_gpe_fwd_entry_t *fwd;
3858 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3859 vat_json_init_array (&root);
3861 for (i = 0; i < mp->count; i++)
3863 e = vat_json_array_add (&root);
3864 fwd = &mp->entries[i];
3866 vat_json_init_object (e);
3867 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3868 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3869 vat_json_object_add_int (e, "vni", fwd->vni);
3870 vat_json_object_add_int (e, "action", fwd->action);
3872 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3873 fwd->leid_prefix_len);
3875 vat_json_object_add_string_copy (e, "leid", s);
3878 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3879 fwd->reid_prefix_len);
3881 vat_json_object_add_string_copy (e, "reid", s);
3885 vat_json_print (vam->ofp, &root);
3886 vat_json_free (&root);
3889 vam->retval = retval;
3890 vam->result_ready = 1;
3894 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3895 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3897 vat_main_t *vam = &vat_main;
3899 int retval = clib_net_to_host_u32 (mp->retval);
3900 vl_api_gpe_native_fwd_rpath_t *r;
3905 n = clib_net_to_host_u32 (mp->count);
3907 for (i = 0; i < n; i++)
3909 r = &mp->entries[i];
3910 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3911 clib_net_to_host_u32 (r->fib_index),
3912 clib_net_to_host_u32 (r->nh_sw_if_index),
3913 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3917 vam->retval = retval;
3918 vam->result_ready = 1;
3922 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3923 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3925 vat_main_t *vam = &vat_main;
3926 vat_json_node_t root, *e;
3928 int retval = clib_net_to_host_u32 (mp->retval);
3929 vl_api_gpe_native_fwd_rpath_t *r;
3935 n = clib_net_to_host_u32 (mp->count);
3936 vat_json_init_array (&root);
3938 for (i = 0; i < n; i++)
3940 e = vat_json_array_add (&root);
3941 vat_json_init_object (e);
3942 r = &mp->entries[i];
3944 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3947 vat_json_object_add_string_copy (e, "ip4", s);
3950 vat_json_object_add_uint (e, "fib_index",
3951 clib_net_to_host_u32 (r->fib_index));
3952 vat_json_object_add_uint (e, "nh_sw_if_index",
3953 clib_net_to_host_u32 (r->nh_sw_if_index));
3956 vat_json_print (vam->ofp, &root);
3957 vat_json_free (&root);
3960 vam->retval = retval;
3961 vam->result_ready = 1;
3965 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3966 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3968 vat_main_t *vam = &vat_main;
3970 int retval = clib_net_to_host_u32 (mp->retval);
3975 n = clib_net_to_host_u32 (mp->count);
3977 for (i = 0; i < n; i++)
3978 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3981 vam->retval = retval;
3982 vam->result_ready = 1;
3986 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3987 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3989 vat_main_t *vam = &vat_main;
3990 vat_json_node_t root;
3992 int retval = clib_net_to_host_u32 (mp->retval);
3997 n = clib_net_to_host_u32 (mp->count);
3998 vat_json_init_array (&root);
4000 for (i = 0; i < n; i++)
4001 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
4003 vat_json_print (vam->ofp, &root);
4004 vat_json_free (&root);
4007 vam->retval = retval;
4008 vam->result_ready = 1;
4012 vl_api_one_ndp_entries_get_reply_t_handler
4013 (vl_api_one_ndp_entries_get_reply_t * mp)
4015 vat_main_t *vam = &vat_main;
4017 int retval = clib_net_to_host_u32 (mp->retval);
4022 n = clib_net_to_host_u32 (mp->count);
4024 for (i = 0; i < n; i++)
4025 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
4026 format_ethernet_address, mp->entries[i].mac);
4029 vam->retval = retval;
4030 vam->result_ready = 1;
4034 vl_api_one_ndp_entries_get_reply_t_handler_json
4035 (vl_api_one_ndp_entries_get_reply_t * mp)
4038 vat_main_t *vam = &vat_main;
4039 vat_json_node_t *e = 0, root;
4041 int retval = clib_net_to_host_u32 (mp->retval);
4042 vl_api_one_ndp_entry_t *arp_entry;
4047 n = clib_net_to_host_u32 (mp->count);
4048 vat_json_init_array (&root);
4050 for (i = 0; i < n; i++)
4052 e = vat_json_array_add (&root);
4053 arp_entry = &mp->entries[i];
4055 vat_json_init_object (e);
4056 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4059 vat_json_object_add_string_copy (e, "mac", s);
4062 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
4064 vat_json_object_add_string_copy (e, "ip6", s);
4068 vat_json_print (vam->ofp, &root);
4069 vat_json_free (&root);
4072 vam->retval = retval;
4073 vam->result_ready = 1;
4077 vl_api_one_l2_arp_entries_get_reply_t_handler
4078 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4080 vat_main_t *vam = &vat_main;
4082 int retval = clib_net_to_host_u32 (mp->retval);
4087 n = clib_net_to_host_u32 (mp->count);
4089 for (i = 0; i < n; i++)
4090 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
4091 format_ethernet_address, mp->entries[i].mac);
4094 vam->retval = retval;
4095 vam->result_ready = 1;
4099 vl_api_one_l2_arp_entries_get_reply_t_handler_json
4100 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4103 vat_main_t *vam = &vat_main;
4104 vat_json_node_t *e = 0, root;
4106 int retval = clib_net_to_host_u32 (mp->retval);
4107 vl_api_one_l2_arp_entry_t *arp_entry;
4112 n = clib_net_to_host_u32 (mp->count);
4113 vat_json_init_array (&root);
4115 for (i = 0; i < n; i++)
4117 e = vat_json_array_add (&root);
4118 arp_entry = &mp->entries[i];
4120 vat_json_init_object (e);
4121 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4124 vat_json_object_add_string_copy (e, "mac", s);
4127 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4129 vat_json_object_add_string_copy (e, "ip4", s);
4133 vat_json_print (vam->ofp, &root);
4134 vat_json_free (&root);
4137 vam->retval = retval;
4138 vam->result_ready = 1;
4142 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4144 vat_main_t *vam = &vat_main;
4146 int retval = clib_net_to_host_u32 (mp->retval);
4151 n = clib_net_to_host_u32 (mp->count);
4153 for (i = 0; i < n; i++)
4155 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4159 vam->retval = retval;
4160 vam->result_ready = 1;
4164 vl_api_one_ndp_bd_get_reply_t_handler_json
4165 (vl_api_one_ndp_bd_get_reply_t * mp)
4167 vat_main_t *vam = &vat_main;
4168 vat_json_node_t root;
4170 int retval = clib_net_to_host_u32 (mp->retval);
4175 n = clib_net_to_host_u32 (mp->count);
4176 vat_json_init_array (&root);
4178 for (i = 0; i < n; i++)
4180 vat_json_array_add_uint (&root,
4181 clib_net_to_host_u32 (mp->bridge_domains[i]));
4184 vat_json_print (vam->ofp, &root);
4185 vat_json_free (&root);
4188 vam->retval = retval;
4189 vam->result_ready = 1;
4193 vl_api_one_l2_arp_bd_get_reply_t_handler
4194 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4196 vat_main_t *vam = &vat_main;
4198 int retval = clib_net_to_host_u32 (mp->retval);
4203 n = clib_net_to_host_u32 (mp->count);
4205 for (i = 0; i < n; i++)
4207 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4211 vam->retval = retval;
4212 vam->result_ready = 1;
4216 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4217 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4219 vat_main_t *vam = &vat_main;
4220 vat_json_node_t root;
4222 int retval = clib_net_to_host_u32 (mp->retval);
4227 n = clib_net_to_host_u32 (mp->count);
4228 vat_json_init_array (&root);
4230 for (i = 0; i < n; i++)
4232 vat_json_array_add_uint (&root,
4233 clib_net_to_host_u32 (mp->bridge_domains[i]));
4236 vat_json_print (vam->ofp, &root);
4237 vat_json_free (&root);
4240 vam->retval = retval;
4241 vam->result_ready = 1;
4245 vl_api_one_adjacencies_get_reply_t_handler
4246 (vl_api_one_adjacencies_get_reply_t * mp)
4248 vat_main_t *vam = &vat_main;
4250 int retval = clib_net_to_host_u32 (mp->retval);
4251 vl_api_one_adjacency_t *a;
4256 n = clib_net_to_host_u32 (mp->count);
4258 for (i = 0; i < n; i++)
4260 a = &mp->adjacencies[i];
4261 print (vam->ofp, "%U %40U",
4262 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4263 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4267 vam->retval = retval;
4268 vam->result_ready = 1;
4272 vl_api_one_adjacencies_get_reply_t_handler_json
4273 (vl_api_one_adjacencies_get_reply_t * mp)
4276 vat_main_t *vam = &vat_main;
4277 vat_json_node_t *e = 0, root;
4279 int retval = clib_net_to_host_u32 (mp->retval);
4280 vl_api_one_adjacency_t *a;
4285 n = clib_net_to_host_u32 (mp->count);
4286 vat_json_init_array (&root);
4288 for (i = 0; i < n; i++)
4290 e = vat_json_array_add (&root);
4291 a = &mp->adjacencies[i];
4293 vat_json_init_object (e);
4294 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4295 a->leid_prefix_len);
4297 vat_json_object_add_string_copy (e, "leid", s);
4300 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4301 a->reid_prefix_len);
4303 vat_json_object_add_string_copy (e, "reid", s);
4307 vat_json_print (vam->ofp, &root);
4308 vat_json_free (&root);
4311 vam->retval = retval;
4312 vam->result_ready = 1;
4316 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4318 vat_main_t *vam = &vat_main;
4320 print (vam->ofp, "%=20U",
4321 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4326 vl_api_one_map_server_details_t_handler_json
4327 (vl_api_one_map_server_details_t * mp)
4329 vat_main_t *vam = &vat_main;
4330 vat_json_node_t *node = NULL;
4331 struct in6_addr ip6;
4334 if (VAT_JSON_ARRAY != vam->json_tree.type)
4336 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4337 vat_json_init_array (&vam->json_tree);
4339 node = vat_json_array_add (&vam->json_tree);
4341 vat_json_init_object (node);
4344 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4345 vat_json_object_add_ip6 (node, "map-server", ip6);
4349 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4350 vat_json_object_add_ip4 (node, "map-server", ip4);
4355 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4358 vat_main_t *vam = &vat_main;
4360 print (vam->ofp, "%=20U",
4361 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4366 vl_api_one_map_resolver_details_t_handler_json
4367 (vl_api_one_map_resolver_details_t * mp)
4369 vat_main_t *vam = &vat_main;
4370 vat_json_node_t *node = NULL;
4371 struct in6_addr ip6;
4374 if (VAT_JSON_ARRAY != vam->json_tree.type)
4376 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4377 vat_json_init_array (&vam->json_tree);
4379 node = vat_json_array_add (&vam->json_tree);
4381 vat_json_init_object (node);
4384 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4385 vat_json_object_add_ip6 (node, "map resolver", ip6);
4389 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4390 vat_json_object_add_ip4 (node, "map resolver", ip4);
4395 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4397 vat_main_t *vam = &vat_main;
4398 i32 retval = ntohl (mp->retval);
4402 print (vam->ofp, "feature: %s\ngpe: %s",
4403 mp->feature_status ? "enabled" : "disabled",
4404 mp->gpe_status ? "enabled" : "disabled");
4407 vam->retval = retval;
4408 vam->result_ready = 1;
4412 vl_api_show_one_status_reply_t_handler_json
4413 (vl_api_show_one_status_reply_t * mp)
4415 vat_main_t *vam = &vat_main;
4416 vat_json_node_t node;
4417 u8 *gpe_status = NULL;
4418 u8 *feature_status = NULL;
4420 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4421 feature_status = format (0, "%s",
4422 mp->feature_status ? "enabled" : "disabled");
4423 vec_add1 (gpe_status, 0);
4424 vec_add1 (feature_status, 0);
4426 vat_json_init_object (&node);
4427 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4428 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4430 vec_free (gpe_status);
4431 vec_free (feature_status);
4433 vat_json_print (vam->ofp, &node);
4434 vat_json_free (&node);
4436 vam->retval = ntohl (mp->retval);
4437 vam->result_ready = 1;
4441 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4442 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4444 vat_main_t *vam = &vat_main;
4445 i32 retval = ntohl (mp->retval);
4449 print (vam->ofp, "%=20s", mp->locator_set_name);
4452 vam->retval = retval;
4453 vam->result_ready = 1;
4457 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4458 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4460 vat_main_t *vam = &vat_main;
4461 vat_json_node_t *node = NULL;
4463 if (VAT_JSON_ARRAY != vam->json_tree.type)
4465 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4466 vat_json_init_array (&vam->json_tree);
4468 node = vat_json_array_add (&vam->json_tree);
4470 vat_json_init_object (node);
4471 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4473 vat_json_print (vam->ofp, node);
4474 vat_json_free (node);
4476 vam->retval = ntohl (mp->retval);
4477 vam->result_ready = 1;
4481 format_lisp_map_request_mode (u8 * s, va_list * args)
4483 u32 mode = va_arg (*args, u32);
4488 return format (0, "dst-only");
4490 return format (0, "src-dst");
4496 vl_api_show_one_map_request_mode_reply_t_handler
4497 (vl_api_show_one_map_request_mode_reply_t * mp)
4499 vat_main_t *vam = &vat_main;
4500 i32 retval = ntohl (mp->retval);
4504 u32 mode = mp->mode;
4505 print (vam->ofp, "map_request_mode: %U",
4506 format_lisp_map_request_mode, mode);
4509 vam->retval = retval;
4510 vam->result_ready = 1;
4514 vl_api_show_one_map_request_mode_reply_t_handler_json
4515 (vl_api_show_one_map_request_mode_reply_t * mp)
4517 vat_main_t *vam = &vat_main;
4518 vat_json_node_t node;
4523 s = format (0, "%U", format_lisp_map_request_mode, mode);
4526 vat_json_init_object (&node);
4527 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4528 vat_json_print (vam->ofp, &node);
4529 vat_json_free (&node);
4532 vam->retval = ntohl (mp->retval);
4533 vam->result_ready = 1;
4537 vl_api_one_show_xtr_mode_reply_t_handler
4538 (vl_api_one_show_xtr_mode_reply_t * mp)
4540 vat_main_t *vam = &vat_main;
4541 i32 retval = ntohl (mp->retval);
4545 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4548 vam->retval = retval;
4549 vam->result_ready = 1;
4553 vl_api_one_show_xtr_mode_reply_t_handler_json
4554 (vl_api_one_show_xtr_mode_reply_t * mp)
4556 vat_main_t *vam = &vat_main;
4557 vat_json_node_t node;
4560 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4561 vec_add1 (status, 0);
4563 vat_json_init_object (&node);
4564 vat_json_object_add_string_copy (&node, "status", status);
4568 vat_json_print (vam->ofp, &node);
4569 vat_json_free (&node);
4571 vam->retval = ntohl (mp->retval);
4572 vam->result_ready = 1;
4576 vl_api_one_show_pitr_mode_reply_t_handler
4577 (vl_api_one_show_pitr_mode_reply_t * mp)
4579 vat_main_t *vam = &vat_main;
4580 i32 retval = ntohl (mp->retval);
4584 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4587 vam->retval = retval;
4588 vam->result_ready = 1;
4592 vl_api_one_show_pitr_mode_reply_t_handler_json
4593 (vl_api_one_show_pitr_mode_reply_t * mp)
4595 vat_main_t *vam = &vat_main;
4596 vat_json_node_t node;
4599 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4600 vec_add1 (status, 0);
4602 vat_json_init_object (&node);
4603 vat_json_object_add_string_copy (&node, "status", status);
4607 vat_json_print (vam->ofp, &node);
4608 vat_json_free (&node);
4610 vam->retval = ntohl (mp->retval);
4611 vam->result_ready = 1;
4615 vl_api_one_show_petr_mode_reply_t_handler
4616 (vl_api_one_show_petr_mode_reply_t * mp)
4618 vat_main_t *vam = &vat_main;
4619 i32 retval = ntohl (mp->retval);
4623 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4626 vam->retval = retval;
4627 vam->result_ready = 1;
4631 vl_api_one_show_petr_mode_reply_t_handler_json
4632 (vl_api_one_show_petr_mode_reply_t * mp)
4634 vat_main_t *vam = &vat_main;
4635 vat_json_node_t node;
4638 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4639 vec_add1 (status, 0);
4641 vat_json_init_object (&node);
4642 vat_json_object_add_string_copy (&node, "status", status);
4646 vat_json_print (vam->ofp, &node);
4647 vat_json_free (&node);
4649 vam->retval = ntohl (mp->retval);
4650 vam->result_ready = 1;
4654 vl_api_show_one_use_petr_reply_t_handler
4655 (vl_api_show_one_use_petr_reply_t * mp)
4657 vat_main_t *vam = &vat_main;
4658 i32 retval = ntohl (mp->retval);
4662 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4665 print (vam->ofp, "Proxy-ETR address; %U",
4666 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4671 vam->retval = retval;
4672 vam->result_ready = 1;
4676 vl_api_show_one_use_petr_reply_t_handler_json
4677 (vl_api_show_one_use_petr_reply_t * mp)
4679 vat_main_t *vam = &vat_main;
4680 vat_json_node_t node;
4683 struct in6_addr ip6;
4685 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4686 vec_add1 (status, 0);
4688 vat_json_init_object (&node);
4689 vat_json_object_add_string_copy (&node, "status", status);
4694 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4695 vat_json_object_add_ip6 (&node, "address", ip6);
4699 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4700 vat_json_object_add_ip4 (&node, "address", ip4);
4706 vat_json_print (vam->ofp, &node);
4707 vat_json_free (&node);
4709 vam->retval = ntohl (mp->retval);
4710 vam->result_ready = 1;
4714 vl_api_show_one_nsh_mapping_reply_t_handler
4715 (vl_api_show_one_nsh_mapping_reply_t * mp)
4717 vat_main_t *vam = &vat_main;
4718 i32 retval = ntohl (mp->retval);
4722 print (vam->ofp, "%-20s%-16s",
4723 mp->is_set ? "set" : "not-set",
4724 mp->is_set ? (char *) mp->locator_set_name : "");
4727 vam->retval = retval;
4728 vam->result_ready = 1;
4732 vl_api_show_one_nsh_mapping_reply_t_handler_json
4733 (vl_api_show_one_nsh_mapping_reply_t * mp)
4735 vat_main_t *vam = &vat_main;
4736 vat_json_node_t node;
4739 status = format (0, "%s", mp->is_set ? "yes" : "no");
4740 vec_add1 (status, 0);
4742 vat_json_init_object (&node);
4743 vat_json_object_add_string_copy (&node, "is_set", status);
4746 vat_json_object_add_string_copy (&node, "locator_set",
4747 mp->locator_set_name);
4752 vat_json_print (vam->ofp, &node);
4753 vat_json_free (&node);
4755 vam->retval = ntohl (mp->retval);
4756 vam->result_ready = 1;
4760 vl_api_show_one_map_register_ttl_reply_t_handler
4761 (vl_api_show_one_map_register_ttl_reply_t * mp)
4763 vat_main_t *vam = &vat_main;
4764 i32 retval = ntohl (mp->retval);
4766 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4770 print (vam->ofp, "ttl: %u", mp->ttl);
4773 vam->retval = retval;
4774 vam->result_ready = 1;
4778 vl_api_show_one_map_register_ttl_reply_t_handler_json
4779 (vl_api_show_one_map_register_ttl_reply_t * mp)
4781 vat_main_t *vam = &vat_main;
4782 vat_json_node_t node;
4784 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4785 vat_json_init_object (&node);
4786 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4788 vat_json_print (vam->ofp, &node);
4789 vat_json_free (&node);
4791 vam->retval = ntohl (mp->retval);
4792 vam->result_ready = 1;
4796 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4798 vat_main_t *vam = &vat_main;
4799 i32 retval = ntohl (mp->retval);
4803 print (vam->ofp, "%-20s%-16s",
4804 mp->status ? "enabled" : "disabled",
4805 mp->status ? (char *) mp->locator_set_name : "");
4808 vam->retval = retval;
4809 vam->result_ready = 1;
4813 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4815 vat_main_t *vam = &vat_main;
4816 vat_json_node_t node;
4819 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4820 vec_add1 (status, 0);
4822 vat_json_init_object (&node);
4823 vat_json_object_add_string_copy (&node, "status", status);
4826 vat_json_object_add_string_copy (&node, "locator_set",
4827 mp->locator_set_name);
4832 vat_json_print (vam->ofp, &node);
4833 vat_json_free (&node);
4835 vam->retval = ntohl (mp->retval);
4836 vam->result_ready = 1;
4840 format_policer_type (u8 * s, va_list * va)
4842 u32 i = va_arg (*va, u32);
4844 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4845 s = format (s, "1r2c");
4846 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4847 s = format (s, "1r3c");
4848 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4849 s = format (s, "2r3c-2698");
4850 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4851 s = format (s, "2r3c-4115");
4852 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4853 s = format (s, "2r3c-mef5cf1");
4855 s = format (s, "ILLEGAL");
4860 format_policer_rate_type (u8 * s, va_list * va)
4862 u32 i = va_arg (*va, u32);
4864 if (i == SSE2_QOS_RATE_KBPS)
4865 s = format (s, "kbps");
4866 else if (i == SSE2_QOS_RATE_PPS)
4867 s = format (s, "pps");
4869 s = format (s, "ILLEGAL");
4874 format_policer_round_type (u8 * s, va_list * va)
4876 u32 i = va_arg (*va, u32);
4878 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4879 s = format (s, "closest");
4880 else if (i == SSE2_QOS_ROUND_TO_UP)
4881 s = format (s, "up");
4882 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4883 s = format (s, "down");
4885 s = format (s, "ILLEGAL");
4890 format_policer_action_type (u8 * s, va_list * va)
4892 u32 i = va_arg (*va, u32);
4894 if (i == SSE2_QOS_ACTION_DROP)
4895 s = format (s, "drop");
4896 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4897 s = format (s, "transmit");
4898 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4899 s = format (s, "mark-and-transmit");
4901 s = format (s, "ILLEGAL");
4906 format_dscp (u8 * s, va_list * va)
4908 u32 i = va_arg (*va, u32);
4913 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4917 return format (s, "ILLEGAL");
4919 s = format (s, "%s", t);
4924 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4926 vat_main_t *vam = &vat_main;
4927 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4929 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4930 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4932 conform_dscp_str = format (0, "");
4934 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4935 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4937 exceed_dscp_str = format (0, "");
4939 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4940 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4942 violate_dscp_str = format (0, "");
4944 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4945 "rate type %U, round type %U, %s rate, %s color-aware, "
4946 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4947 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4948 "conform action %U%s, exceed action %U%s, violate action %U%s",
4950 format_policer_type, mp->type,
4953 clib_net_to_host_u64 (mp->cb),
4954 clib_net_to_host_u64 (mp->eb),
4955 format_policer_rate_type, mp->rate_type,
4956 format_policer_round_type, mp->round_type,
4957 mp->single_rate ? "single" : "dual",
4958 mp->color_aware ? "is" : "not",
4959 ntohl (mp->cir_tokens_per_period),
4960 ntohl (mp->pir_tokens_per_period),
4962 ntohl (mp->current_limit),
4963 ntohl (mp->current_bucket),
4964 ntohl (mp->extended_limit),
4965 ntohl (mp->extended_bucket),
4966 clib_net_to_host_u64 (mp->last_update_time),
4967 format_policer_action_type, mp->conform_action_type,
4969 format_policer_action_type, mp->exceed_action_type,
4971 format_policer_action_type, mp->violate_action_type,
4974 vec_free (conform_dscp_str);
4975 vec_free (exceed_dscp_str);
4976 vec_free (violate_dscp_str);
4979 static void vl_api_policer_details_t_handler_json
4980 (vl_api_policer_details_t * mp)
4982 vat_main_t *vam = &vat_main;
4983 vat_json_node_t *node;
4984 u8 *rate_type_str, *round_type_str, *type_str;
4985 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4987 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4989 format (0, "%U", format_policer_round_type, mp->round_type);
4990 type_str = format (0, "%U", format_policer_type, mp->type);
4991 conform_action_str = format (0, "%U", format_policer_action_type,
4992 mp->conform_action_type);
4993 exceed_action_str = format (0, "%U", format_policer_action_type,
4994 mp->exceed_action_type);
4995 violate_action_str = format (0, "%U", format_policer_action_type,
4996 mp->violate_action_type);
4998 if (VAT_JSON_ARRAY != vam->json_tree.type)
5000 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5001 vat_json_init_array (&vam->json_tree);
5003 node = vat_json_array_add (&vam->json_tree);
5005 vat_json_init_object (node);
5006 vat_json_object_add_string_copy (node, "name", mp->name);
5007 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
5008 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
5009 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
5010 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
5011 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
5012 vat_json_object_add_string_copy (node, "round_type", round_type_str);
5013 vat_json_object_add_string_copy (node, "type", type_str);
5014 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
5015 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
5016 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
5017 vat_json_object_add_uint (node, "cir_tokens_per_period",
5018 ntohl (mp->cir_tokens_per_period));
5019 vat_json_object_add_uint (node, "eir_tokens_per_period",
5020 ntohl (mp->pir_tokens_per_period));
5021 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
5022 vat_json_object_add_uint (node, "current_bucket",
5023 ntohl (mp->current_bucket));
5024 vat_json_object_add_uint (node, "extended_limit",
5025 ntohl (mp->extended_limit));
5026 vat_json_object_add_uint (node, "extended_bucket",
5027 ntohl (mp->extended_bucket));
5028 vat_json_object_add_uint (node, "last_update_time",
5029 ntohl (mp->last_update_time));
5030 vat_json_object_add_string_copy (node, "conform_action",
5031 conform_action_str);
5032 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5034 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
5035 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
5036 vec_free (dscp_str);
5038 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
5039 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5041 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
5042 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
5043 vec_free (dscp_str);
5045 vat_json_object_add_string_copy (node, "violate_action",
5046 violate_action_str);
5047 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5049 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
5050 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
5051 vec_free (dscp_str);
5054 vec_free (rate_type_str);
5055 vec_free (round_type_str);
5056 vec_free (type_str);
5057 vec_free (conform_action_str);
5058 vec_free (exceed_action_str);
5059 vec_free (violate_action_str);
5063 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
5066 vat_main_t *vam = &vat_main;
5067 int i, count = ntohl (mp->count);
5070 print (vam->ofp, "classify table ids (%d) : ", count);
5071 for (i = 0; i < count; i++)
5073 print (vam->ofp, "%d", ntohl (mp->ids[i]));
5074 print (vam->ofp, (i < count - 1) ? "," : "");
5076 vam->retval = ntohl (mp->retval);
5077 vam->result_ready = 1;
5081 vl_api_classify_table_ids_reply_t_handler_json
5082 (vl_api_classify_table_ids_reply_t * mp)
5084 vat_main_t *vam = &vat_main;
5085 int i, count = ntohl (mp->count);
5089 vat_json_node_t node;
5091 vat_json_init_object (&node);
5092 for (i = 0; i < count; i++)
5094 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
5096 vat_json_print (vam->ofp, &node);
5097 vat_json_free (&node);
5099 vam->retval = ntohl (mp->retval);
5100 vam->result_ready = 1;
5104 vl_api_classify_table_by_interface_reply_t_handler
5105 (vl_api_classify_table_by_interface_reply_t * mp)
5107 vat_main_t *vam = &vat_main;
5110 table_id = ntohl (mp->l2_table_id);
5112 print (vam->ofp, "l2 table id : %d", table_id);
5114 print (vam->ofp, "l2 table id : No input ACL tables configured");
5115 table_id = ntohl (mp->ip4_table_id);
5117 print (vam->ofp, "ip4 table id : %d", table_id);
5119 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5120 table_id = ntohl (mp->ip6_table_id);
5122 print (vam->ofp, "ip6 table id : %d", table_id);
5124 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5125 vam->retval = ntohl (mp->retval);
5126 vam->result_ready = 1;
5130 vl_api_classify_table_by_interface_reply_t_handler_json
5131 (vl_api_classify_table_by_interface_reply_t * mp)
5133 vat_main_t *vam = &vat_main;
5134 vat_json_node_t node;
5136 vat_json_init_object (&node);
5138 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5139 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5140 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5142 vat_json_print (vam->ofp, &node);
5143 vat_json_free (&node);
5145 vam->retval = ntohl (mp->retval);
5146 vam->result_ready = 1;
5149 static void vl_api_policer_add_del_reply_t_handler
5150 (vl_api_policer_add_del_reply_t * mp)
5152 vat_main_t *vam = &vat_main;
5153 i32 retval = ntohl (mp->retval);
5154 if (vam->async_mode)
5156 vam->async_errors += (retval < 0);
5160 vam->retval = retval;
5161 vam->result_ready = 1;
5162 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5164 * Note: this is just barely thread-safe, depends on
5165 * the main thread spinning waiting for an answer...
5167 errmsg ("policer index %d", ntohl (mp->policer_index));
5171 static void vl_api_policer_add_del_reply_t_handler_json
5172 (vl_api_policer_add_del_reply_t * mp)
5174 vat_main_t *vam = &vat_main;
5175 vat_json_node_t node;
5177 vat_json_init_object (&node);
5178 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5179 vat_json_object_add_uint (&node, "policer_index",
5180 ntohl (mp->policer_index));
5182 vat_json_print (vam->ofp, &node);
5183 vat_json_free (&node);
5185 vam->retval = ntohl (mp->retval);
5186 vam->result_ready = 1;
5189 /* Format hex dump. */
5191 format_hex_bytes (u8 * s, va_list * va)
5193 u8 *bytes = va_arg (*va, u8 *);
5194 int n_bytes = va_arg (*va, int);
5197 /* Print short or long form depending on byte count. */
5198 uword short_form = n_bytes <= 32;
5199 u32 indent = format_get_indent (s);
5204 for (i = 0; i < n_bytes; i++)
5206 if (!short_form && (i % 32) == 0)
5207 s = format (s, "%08x: ", i);
5208 s = format (s, "%02x", bytes[i]);
5209 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5210 s = format (s, "\n%U", format_white_space, indent);
5217 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5220 vat_main_t *vam = &vat_main;
5221 i32 retval = ntohl (mp->retval);
5224 print (vam->ofp, "classify table info :");
5225 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5226 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5227 ntohl (mp->miss_next_index));
5228 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5229 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5230 ntohl (mp->match_n_vectors));
5231 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5232 ntohl (mp->mask_length));
5234 vam->retval = retval;
5235 vam->result_ready = 1;
5239 vl_api_classify_table_info_reply_t_handler_json
5240 (vl_api_classify_table_info_reply_t * mp)
5242 vat_main_t *vam = &vat_main;
5243 vat_json_node_t node;
5245 i32 retval = ntohl (mp->retval);
5248 vat_json_init_object (&node);
5250 vat_json_object_add_int (&node, "sessions",
5251 ntohl (mp->active_sessions));
5252 vat_json_object_add_int (&node, "nexttbl",
5253 ntohl (mp->next_table_index));
5254 vat_json_object_add_int (&node, "nextnode",
5255 ntohl (mp->miss_next_index));
5256 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5257 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5258 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5259 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5260 ntohl (mp->mask_length), 0);
5261 vat_json_object_add_string_copy (&node, "mask", s);
5263 vat_json_print (vam->ofp, &node);
5264 vat_json_free (&node);
5266 vam->retval = ntohl (mp->retval);
5267 vam->result_ready = 1;
5271 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5274 vat_main_t *vam = &vat_main;
5276 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5277 ntohl (mp->hit_next_index), ntohl (mp->advance),
5278 ntohl (mp->opaque_index));
5279 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5280 ntohl (mp->match_length));
5284 vl_api_classify_session_details_t_handler_json
5285 (vl_api_classify_session_details_t * mp)
5287 vat_main_t *vam = &vat_main;
5288 vat_json_node_t *node = NULL;
5290 if (VAT_JSON_ARRAY != vam->json_tree.type)
5292 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5293 vat_json_init_array (&vam->json_tree);
5295 node = vat_json_array_add (&vam->json_tree);
5297 vat_json_init_object (node);
5298 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5299 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5300 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5302 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5304 vat_json_object_add_string_copy (node, "match", s);
5307 static void vl_api_pg_create_interface_reply_t_handler
5308 (vl_api_pg_create_interface_reply_t * mp)
5310 vat_main_t *vam = &vat_main;
5312 vam->retval = ntohl (mp->retval);
5313 vam->result_ready = 1;
5316 static void vl_api_pg_create_interface_reply_t_handler_json
5317 (vl_api_pg_create_interface_reply_t * mp)
5319 vat_main_t *vam = &vat_main;
5320 vat_json_node_t node;
5322 i32 retval = ntohl (mp->retval);
5325 vat_json_init_object (&node);
5327 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5329 vat_json_print (vam->ofp, &node);
5330 vat_json_free (&node);
5332 vam->retval = ntohl (mp->retval);
5333 vam->result_ready = 1;
5336 static void vl_api_policer_classify_details_t_handler
5337 (vl_api_policer_classify_details_t * mp)
5339 vat_main_t *vam = &vat_main;
5341 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5342 ntohl (mp->table_index));
5345 static void vl_api_policer_classify_details_t_handler_json
5346 (vl_api_policer_classify_details_t * mp)
5348 vat_main_t *vam = &vat_main;
5349 vat_json_node_t *node;
5351 if (VAT_JSON_ARRAY != vam->json_tree.type)
5353 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5354 vat_json_init_array (&vam->json_tree);
5356 node = vat_json_array_add (&vam->json_tree);
5358 vat_json_init_object (node);
5359 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5360 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5363 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5364 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5366 vat_main_t *vam = &vat_main;
5367 i32 retval = ntohl (mp->retval);
5368 if (vam->async_mode)
5370 vam->async_errors += (retval < 0);
5374 vam->retval = retval;
5375 vam->sw_if_index = ntohl (mp->sw_if_index);
5376 vam->result_ready = 1;
5378 vam->regenerate_interface_table = 1;
5381 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5382 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5384 vat_main_t *vam = &vat_main;
5385 vat_json_node_t node;
5387 vat_json_init_object (&node);
5388 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5389 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5391 vat_json_print (vam->ofp, &node);
5392 vat_json_free (&node);
5394 vam->retval = ntohl (mp->retval);
5395 vam->result_ready = 1;
5398 static void vl_api_flow_classify_details_t_handler
5399 (vl_api_flow_classify_details_t * mp)
5401 vat_main_t *vam = &vat_main;
5403 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5404 ntohl (mp->table_index));
5407 static void vl_api_flow_classify_details_t_handler_json
5408 (vl_api_flow_classify_details_t * mp)
5410 vat_main_t *vam = &vat_main;
5411 vat_json_node_t *node;
5413 if (VAT_JSON_ARRAY != vam->json_tree.type)
5415 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5416 vat_json_init_array (&vam->json_tree);
5418 node = vat_json_array_add (&vam->json_tree);
5420 vat_json_init_object (node);
5421 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5422 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5425 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5426 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5427 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5428 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5429 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5430 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5431 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5432 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5433 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5434 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5435 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5436 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5437 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5438 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5439 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5440 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5441 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5442 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5443 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5444 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5445 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5446 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5449 * Generate boilerplate reply handlers, which
5450 * dig the return value out of the xxx_reply_t API message,
5451 * stick it into vam->retval, and set vam->result_ready
5453 * Could also do this by pointing N message decode slots at
5454 * a single function, but that could break in subtle ways.
5457 #define foreach_standard_reply_retval_handler \
5458 _(sw_interface_set_flags_reply) \
5459 _(sw_interface_add_del_address_reply) \
5460 _(sw_interface_set_rx_mode_reply) \
5461 _(sw_interface_set_rx_placement_reply) \
5462 _(sw_interface_set_table_reply) \
5463 _(sw_interface_set_mpls_enable_reply) \
5464 _(sw_interface_set_vpath_reply) \
5465 _(sw_interface_set_vxlan_bypass_reply) \
5466 _(sw_interface_set_geneve_bypass_reply) \
5467 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5468 _(sw_interface_set_l2_bridge_reply) \
5469 _(bridge_domain_add_del_reply) \
5470 _(sw_interface_set_l2_xconnect_reply) \
5471 _(l2fib_add_del_reply) \
5472 _(l2fib_flush_int_reply) \
5473 _(l2fib_flush_bd_reply) \
5474 _(ip_add_del_route_reply) \
5475 _(ip_table_add_del_reply) \
5476 _(ip_mroute_add_del_reply) \
5477 _(mpls_route_add_del_reply) \
5478 _(mpls_table_add_del_reply) \
5479 _(mpls_ip_bind_unbind_reply) \
5480 _(bier_route_add_del_reply) \
5481 _(bier_table_add_del_reply) \
5482 _(proxy_arp_add_del_reply) \
5483 _(proxy_arp_intfc_enable_disable_reply) \
5484 _(sw_interface_set_unnumbered_reply) \
5485 _(ip_neighbor_add_del_reply) \
5486 _(oam_add_del_reply) \
5487 _(reset_fib_reply) \
5488 _(dhcp_proxy_config_reply) \
5489 _(dhcp_proxy_set_vss_reply) \
5490 _(dhcp_client_config_reply) \
5491 _(set_ip_flow_hash_reply) \
5492 _(sw_interface_ip6_enable_disable_reply) \
5493 _(ip6nd_proxy_add_del_reply) \
5494 _(sw_interface_ip6nd_ra_prefix_reply) \
5495 _(sw_interface_ip6nd_ra_config_reply) \
5496 _(set_arp_neighbor_limit_reply) \
5497 _(l2_patch_add_del_reply) \
5498 _(sr_mpls_policy_add_reply) \
5499 _(sr_mpls_policy_mod_reply) \
5500 _(sr_mpls_policy_del_reply) \
5501 _(sr_policy_add_reply) \
5502 _(sr_policy_mod_reply) \
5503 _(sr_policy_del_reply) \
5504 _(sr_localsid_add_del_reply) \
5505 _(sr_steering_add_del_reply) \
5506 _(classify_add_del_session_reply) \
5507 _(classify_set_interface_ip_table_reply) \
5508 _(classify_set_interface_l2_tables_reply) \
5509 _(l2tpv3_set_tunnel_cookies_reply) \
5510 _(l2tpv3_interface_enable_disable_reply) \
5511 _(l2tpv3_set_lookup_key_reply) \
5512 _(l2_fib_clear_table_reply) \
5513 _(l2_interface_efp_filter_reply) \
5514 _(l2_interface_vlan_tag_rewrite_reply) \
5515 _(modify_vhost_user_if_reply) \
5516 _(delete_vhost_user_if_reply) \
5517 _(ip_probe_neighbor_reply) \
5518 _(ip_scan_neighbor_enable_disable_reply) \
5519 _(want_ip4_arp_events_reply) \
5520 _(want_ip6_nd_events_reply) \
5521 _(want_l2_macs_events_reply) \
5522 _(input_acl_set_interface_reply) \
5523 _(ipsec_spd_add_del_reply) \
5524 _(ipsec_interface_add_del_spd_reply) \
5525 _(ipsec_spd_add_del_entry_reply) \
5526 _(ipsec_sad_add_del_entry_reply) \
5527 _(ipsec_sa_set_key_reply) \
5528 _(ipsec_tunnel_if_add_del_reply) \
5529 _(ipsec_tunnel_if_set_key_reply) \
5530 _(ipsec_tunnel_if_set_sa_reply) \
5531 _(ikev2_profile_add_del_reply) \
5532 _(ikev2_profile_set_auth_reply) \
5533 _(ikev2_profile_set_id_reply) \
5534 _(ikev2_profile_set_ts_reply) \
5535 _(ikev2_set_local_key_reply) \
5536 _(ikev2_set_responder_reply) \
5537 _(ikev2_set_ike_transforms_reply) \
5538 _(ikev2_set_esp_transforms_reply) \
5539 _(ikev2_set_sa_lifetime_reply) \
5540 _(ikev2_initiate_sa_init_reply) \
5541 _(ikev2_initiate_del_ike_sa_reply) \
5542 _(ikev2_initiate_del_child_sa_reply) \
5543 _(ikev2_initiate_rekey_child_sa_reply) \
5544 _(delete_loopback_reply) \
5545 _(bd_ip_mac_add_del_reply) \
5546 _(want_interface_events_reply) \
5547 _(want_stats_reply) \
5548 _(cop_interface_enable_disable_reply) \
5549 _(cop_whitelist_enable_disable_reply) \
5550 _(sw_interface_clear_stats_reply) \
5551 _(ioam_enable_reply) \
5552 _(ioam_disable_reply) \
5553 _(one_add_del_locator_reply) \
5554 _(one_add_del_local_eid_reply) \
5555 _(one_add_del_remote_mapping_reply) \
5556 _(one_add_del_adjacency_reply) \
5557 _(one_add_del_map_resolver_reply) \
5558 _(one_add_del_map_server_reply) \
5559 _(one_enable_disable_reply) \
5560 _(one_rloc_probe_enable_disable_reply) \
5561 _(one_map_register_enable_disable_reply) \
5562 _(one_map_register_set_ttl_reply) \
5563 _(one_set_transport_protocol_reply) \
5564 _(one_map_register_fallback_threshold_reply) \
5565 _(one_pitr_set_locator_set_reply) \
5566 _(one_map_request_mode_reply) \
5567 _(one_add_del_map_request_itr_rlocs_reply) \
5568 _(one_eid_table_add_del_map_reply) \
5569 _(one_use_petr_reply) \
5570 _(one_stats_enable_disable_reply) \
5571 _(one_add_del_l2_arp_entry_reply) \
5572 _(one_add_del_ndp_entry_reply) \
5573 _(one_stats_flush_reply) \
5574 _(one_enable_disable_xtr_mode_reply) \
5575 _(one_enable_disable_pitr_mode_reply) \
5576 _(one_enable_disable_petr_mode_reply) \
5577 _(gpe_enable_disable_reply) \
5578 _(gpe_set_encap_mode_reply) \
5579 _(gpe_add_del_iface_reply) \
5580 _(gpe_add_del_native_fwd_rpath_reply) \
5581 _(af_packet_delete_reply) \
5582 _(policer_classify_set_interface_reply) \
5583 _(netmap_create_reply) \
5584 _(netmap_delete_reply) \
5585 _(set_ipfix_exporter_reply) \
5586 _(set_ipfix_classify_stream_reply) \
5587 _(ipfix_classify_table_add_del_reply) \
5588 _(flow_classify_set_interface_reply) \
5589 _(sw_interface_span_enable_disable_reply) \
5590 _(pg_capture_reply) \
5591 _(pg_enable_disable_reply) \
5592 _(ip_source_and_port_range_check_add_del_reply) \
5593 _(ip_source_and_port_range_check_interface_add_del_reply)\
5594 _(delete_subif_reply) \
5595 _(l2_interface_pbb_tag_rewrite_reply) \
5597 _(feature_enable_disable_reply) \
5598 _(sw_interface_tag_add_del_reply) \
5599 _(hw_interface_set_mtu_reply) \
5600 _(p2p_ethernet_add_reply) \
5601 _(p2p_ethernet_del_reply) \
5602 _(lldp_config_reply) \
5603 _(sw_interface_set_lldp_reply) \
5604 _(tcp_configure_src_addresses_reply) \
5605 _(dns_enable_disable_reply) \
5606 _(dns_name_server_add_del_reply) \
5607 _(session_rule_add_del_reply) \
5608 _(ip_container_proxy_add_del_reply) \
5609 _(output_acl_set_interface_reply) \
5610 _(qos_record_enable_disable_reply)
5613 static void vl_api_##n##_t_handler \
5614 (vl_api_##n##_t * mp) \
5616 vat_main_t * vam = &vat_main; \
5617 i32 retval = ntohl(mp->retval); \
5618 if (vam->async_mode) { \
5619 vam->async_errors += (retval < 0); \
5621 vam->retval = retval; \
5622 vam->result_ready = 1; \
5625 foreach_standard_reply_retval_handler;
5629 static void vl_api_##n##_t_handler_json \
5630 (vl_api_##n##_t * mp) \
5632 vat_main_t * vam = &vat_main; \
5633 vat_json_node_t node; \
5634 vat_json_init_object(&node); \
5635 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5636 vat_json_print(vam->ofp, &node); \
5637 vam->retval = ntohl(mp->retval); \
5638 vam->result_ready = 1; \
5640 foreach_standard_reply_retval_handler;
5644 * Table of message reply handlers, must include boilerplate handlers
5648 #define foreach_vpe_api_reply_msg \
5649 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5650 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5651 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5652 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5653 _(CONTROL_PING_REPLY, control_ping_reply) \
5654 _(CLI_REPLY, cli_reply) \
5655 _(CLI_INBAND_REPLY, cli_inband_reply) \
5656 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5657 sw_interface_add_del_address_reply) \
5658 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5659 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5660 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5661 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5662 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5663 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5664 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5665 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5666 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5667 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5668 sw_interface_set_l2_xconnect_reply) \
5669 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5670 sw_interface_set_l2_bridge_reply) \
5671 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5672 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5673 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5674 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5675 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5676 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5677 _(L2_FLAGS_REPLY, l2_flags_reply) \
5678 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5679 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5680 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5681 _(TAP_DELETE_REPLY, tap_delete_reply) \
5682 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5683 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5684 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5685 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5686 _(BOND_CREATE_REPLY, bond_create_reply) \
5687 _(BOND_DELETE_REPLY, bond_delete_reply) \
5688 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5689 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5690 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5691 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5692 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5693 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5694 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5695 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5696 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5697 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5698 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5699 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5700 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5701 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5702 proxy_arp_intfc_enable_disable_reply) \
5703 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5704 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5705 sw_interface_set_unnumbered_reply) \
5706 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5707 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5708 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5709 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5710 _(RESET_FIB_REPLY, reset_fib_reply) \
5711 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5712 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5713 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5714 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5715 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5716 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5717 sw_interface_ip6_enable_disable_reply) \
5718 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5719 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5720 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5721 sw_interface_ip6nd_ra_prefix_reply) \
5722 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5723 sw_interface_ip6nd_ra_config_reply) \
5724 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5725 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5726 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5727 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5728 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5729 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5730 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5731 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5732 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5733 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5734 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5735 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5736 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5737 classify_set_interface_ip_table_reply) \
5738 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5739 classify_set_interface_l2_tables_reply) \
5740 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5741 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5742 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5743 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5744 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5745 l2tpv3_interface_enable_disable_reply) \
5746 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5747 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5748 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5749 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5750 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5751 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5752 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5753 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5754 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5755 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5756 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5757 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5758 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5759 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5760 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5761 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5762 _(SHOW_VERSION_REPLY, show_version_reply) \
5763 _(SHOW_THREADS_REPLY, show_threads_reply) \
5764 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5765 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5766 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5767 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5768 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5769 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5770 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5771 _(IP4_ARP_EVENT, ip4_arp_event) \
5772 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5773 _(IP6_ND_EVENT, ip6_nd_event) \
5774 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5775 _(L2_MACS_EVENT, l2_macs_event) \
5776 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5777 _(IP_ADDRESS_DETAILS, ip_address_details) \
5778 _(IP_DETAILS, ip_details) \
5779 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5780 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5781 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5782 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5783 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5784 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5785 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5786 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5787 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5788 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5789 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5790 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5791 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5792 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5793 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5794 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5795 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5796 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5797 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5798 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5799 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5800 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5801 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5802 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5803 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5804 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5805 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5806 _(WANT_STATS_REPLY, want_stats_reply) \
5807 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5808 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5809 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5810 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5811 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5812 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5813 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5814 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5815 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5816 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5817 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5818 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5819 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5820 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5821 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5822 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5823 one_map_register_enable_disable_reply) \
5824 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5825 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5826 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5827 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5828 one_map_register_fallback_threshold_reply) \
5829 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5830 one_rloc_probe_enable_disable_reply) \
5831 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5832 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5833 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5834 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5835 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5836 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5837 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5838 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5839 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5840 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5841 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5842 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5843 _(ONE_STATS_DETAILS, one_stats_details) \
5844 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5845 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5846 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5847 show_one_stats_enable_disable_reply) \
5848 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5849 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5850 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5851 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5852 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5853 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5854 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5855 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5856 one_enable_disable_pitr_mode_reply) \
5857 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5858 one_enable_disable_petr_mode_reply) \
5859 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5860 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5861 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5862 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5863 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5864 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5865 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5866 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5867 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5868 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5869 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5870 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5871 gpe_add_del_native_fwd_rpath_reply) \
5872 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5873 gpe_fwd_entry_path_details) \
5874 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5875 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5876 one_add_del_map_request_itr_rlocs_reply) \
5877 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5878 one_get_map_request_itr_rlocs_reply) \
5879 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5880 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5881 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5882 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5883 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5884 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5885 show_one_map_register_state_reply) \
5886 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5887 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5888 show_one_map_register_fallback_threshold_reply) \
5889 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5890 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5891 _(AF_PACKET_DETAILS, af_packet_details) \
5892 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5893 _(POLICER_DETAILS, policer_details) \
5894 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5895 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5896 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5897 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5898 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5899 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5900 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5901 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5902 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5903 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5904 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5905 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5906 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5907 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5908 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5909 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5910 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5911 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5912 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5913 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5914 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5915 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5916 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5917 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5918 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5919 ip_source_and_port_range_check_add_del_reply) \
5920 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5921 ip_source_and_port_range_check_interface_add_del_reply) \
5922 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5923 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5924 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5925 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5926 _(SET_PUNT_REPLY, set_punt_reply) \
5927 _(IP_FIB_DETAILS, ip_fib_details) \
5928 _(IP6_FIB_DETAILS, ip6_fib_details) \
5929 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5930 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5931 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5932 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5933 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5934 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5935 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5936 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5937 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5938 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5939 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5940 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5941 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5942 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5943 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5944 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5945 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5946 _(SESSION_RULES_DETAILS, session_rules_details) \
5947 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5948 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5949 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5951 #define foreach_standalone_reply_msg \
5952 _(SW_INTERFACE_EVENT, sw_interface_event) \
5953 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5954 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5955 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5956 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5957 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5958 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5966 #define STR_VTR_OP_CASE(op) \
5967 case L2_VTR_ ## op: \
5971 str_vtr_op (u32 vtr_op)
5975 STR_VTR_OP_CASE (DISABLED);
5976 STR_VTR_OP_CASE (PUSH_1);
5977 STR_VTR_OP_CASE (PUSH_2);
5978 STR_VTR_OP_CASE (POP_1);
5979 STR_VTR_OP_CASE (POP_2);
5980 STR_VTR_OP_CASE (TRANSLATE_1_1);
5981 STR_VTR_OP_CASE (TRANSLATE_1_2);
5982 STR_VTR_OP_CASE (TRANSLATE_2_1);
5983 STR_VTR_OP_CASE (TRANSLATE_2_2);
5990 dump_sub_interface_table (vat_main_t * vam)
5992 const sw_interface_subif_t *sub = NULL;
5994 if (vam->json_output)
5997 ("JSON output supported only for VPE API calls and dump_stats_table");
6002 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
6003 "Interface", "sw_if_index",
6004 "sub id", "dot1ad", "tags", "outer id",
6005 "inner id", "exact", "default", "outer any", "inner any");
6007 vec_foreach (sub, vam->sw_if_subif_table)
6010 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
6011 sub->interface_name,
6013 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
6014 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
6015 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
6016 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
6017 if (sub->vtr_op != L2_VTR_DISABLED)
6020 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
6021 "tag1: %d tag2: %d ]",
6022 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
6023 sub->vtr_tag1, sub->vtr_tag2);
6031 name_sort_cmp (void *a1, void *a2)
6033 name_sort_t *n1 = a1;
6034 name_sort_t *n2 = a2;
6036 return strcmp ((char *) n1->name, (char *) n2->name);
6040 dump_interface_table (vat_main_t * vam)
6043 name_sort_t *nses = 0, *ns;
6045 if (vam->json_output)
6048 ("JSON output supported only for VPE API calls and dump_stats_table");
6053 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6055 vec_add2 (nses, ns, 1);
6056 ns->name = (u8 *)(p->key);
6057 ns->value = (u32) p->value[0];
6061 vec_sort_with_function (nses, name_sort_cmp);
6063 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
6064 vec_foreach (ns, nses)
6066 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6073 dump_ip_table (vat_main_t * vam, int is_ipv6)
6075 const ip_details_t *det = NULL;
6076 const ip_address_details_t *address = NULL;
6079 print (vam->ofp, "%-12s", "sw_if_index");
6081 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6088 print (vam->ofp, "%-12d", i);
6089 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6094 vec_foreach (address, det->addr)
6098 is_ipv6 ? format_ip6_address : format_ip4_address,
6099 address->ip, address->prefix_length);
6107 dump_ipv4_table (vat_main_t * vam)
6109 if (vam->json_output)
6112 ("JSON output supported only for VPE API calls and dump_stats_table");
6116 return dump_ip_table (vam, 0);
6120 dump_ipv6_table (vat_main_t * vam)
6122 if (vam->json_output)
6125 ("JSON output supported only for VPE API calls and dump_stats_table");
6129 return dump_ip_table (vam, 1);
6133 counter_type_to_str (u8 counter_type, u8 is_combined)
6137 switch (counter_type)
6139 case VNET_INTERFACE_COUNTER_DROP:
6141 case VNET_INTERFACE_COUNTER_PUNT:
6143 case VNET_INTERFACE_COUNTER_IP4:
6145 case VNET_INTERFACE_COUNTER_IP6:
6147 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6149 case VNET_INTERFACE_COUNTER_RX_MISS:
6151 case VNET_INTERFACE_COUNTER_RX_ERROR:
6153 case VNET_INTERFACE_COUNTER_TX_ERROR:
6156 return "INVALID-COUNTER-TYPE";
6161 switch (counter_type)
6163 case VNET_INTERFACE_COUNTER_RX:
6165 case VNET_INTERFACE_COUNTER_TX:
6168 return "INVALID-COUNTER-TYPE";
6174 dump_stats_table (vat_main_t * vam)
6176 vat_json_node_t node;
6177 vat_json_node_t *msg_array;
6178 vat_json_node_t *msg;
6179 vat_json_node_t *counter_array;
6180 vat_json_node_t *counter;
6181 interface_counter_t c;
6183 ip4_fib_counter_t *c4;
6184 ip6_fib_counter_t *c6;
6185 ip4_nbr_counter_t *n4;
6186 ip6_nbr_counter_t *n6;
6189 if (!vam->json_output)
6191 clib_warning ("dump_stats_table supported only in JSON format");
6195 vat_json_init_object (&node);
6197 /* interface counters */
6198 msg_array = vat_json_object_add (&node, "interface_counters");
6199 vat_json_init_array (msg_array);
6200 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6202 msg = vat_json_array_add (msg_array);
6203 vat_json_init_object (msg);
6204 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6205 (u8 *) counter_type_to_str (i, 0));
6206 vat_json_object_add_int (msg, "is_combined", 0);
6207 counter_array = vat_json_object_add (msg, "data");
6208 vat_json_init_array (counter_array);
6209 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6211 packets = vam->simple_interface_counters[i][j];
6212 vat_json_array_add_uint (counter_array, packets);
6215 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6217 msg = vat_json_array_add (msg_array);
6218 vat_json_init_object (msg);
6219 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6220 (u8 *) counter_type_to_str (i, 1));
6221 vat_json_object_add_int (msg, "is_combined", 1);
6222 counter_array = vat_json_object_add (msg, "data");
6223 vat_json_init_array (counter_array);
6224 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6226 c = vam->combined_interface_counters[i][j];
6227 counter = vat_json_array_add (counter_array);
6228 vat_json_init_object (counter);
6229 vat_json_object_add_uint (counter, "packets", c.packets);
6230 vat_json_object_add_uint (counter, "bytes", c.bytes);
6234 /* ip4 fib counters */
6235 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6236 vat_json_init_array (msg_array);
6237 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6239 msg = vat_json_array_add (msg_array);
6240 vat_json_init_object (msg);
6241 vat_json_object_add_uint (msg, "vrf_id",
6242 vam->ip4_fib_counters_vrf_id_by_index[i]);
6243 counter_array = vat_json_object_add (msg, "c");
6244 vat_json_init_array (counter_array);
6245 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6247 counter = vat_json_array_add (counter_array);
6248 vat_json_init_object (counter);
6249 c4 = &vam->ip4_fib_counters[i][j];
6250 vat_json_object_add_ip4 (counter, "address", c4->address);
6251 vat_json_object_add_uint (counter, "address_length",
6252 c4->address_length);
6253 vat_json_object_add_uint (counter, "packets", c4->packets);
6254 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6258 /* ip6 fib counters */
6259 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6260 vat_json_init_array (msg_array);
6261 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6263 msg = vat_json_array_add (msg_array);
6264 vat_json_init_object (msg);
6265 vat_json_object_add_uint (msg, "vrf_id",
6266 vam->ip6_fib_counters_vrf_id_by_index[i]);
6267 counter_array = vat_json_object_add (msg, "c");
6268 vat_json_init_array (counter_array);
6269 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6271 counter = vat_json_array_add (counter_array);
6272 vat_json_init_object (counter);
6273 c6 = &vam->ip6_fib_counters[i][j];
6274 vat_json_object_add_ip6 (counter, "address", c6->address);
6275 vat_json_object_add_uint (counter, "address_length",
6276 c6->address_length);
6277 vat_json_object_add_uint (counter, "packets", c6->packets);
6278 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6282 /* ip4 nbr counters */
6283 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6284 vat_json_init_array (msg_array);
6285 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6287 msg = vat_json_array_add (msg_array);
6288 vat_json_init_object (msg);
6289 vat_json_object_add_uint (msg, "sw_if_index", i);
6290 counter_array = vat_json_object_add (msg, "c");
6291 vat_json_init_array (counter_array);
6292 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6294 counter = vat_json_array_add (counter_array);
6295 vat_json_init_object (counter);
6296 n4 = &vam->ip4_nbr_counters[i][j];
6297 vat_json_object_add_ip4 (counter, "address", n4->address);
6298 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6299 vat_json_object_add_uint (counter, "packets", n4->packets);
6300 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6304 /* ip6 nbr counters */
6305 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6306 vat_json_init_array (msg_array);
6307 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6309 msg = vat_json_array_add (msg_array);
6310 vat_json_init_object (msg);
6311 vat_json_object_add_uint (msg, "sw_if_index", i);
6312 counter_array = vat_json_object_add (msg, "c");
6313 vat_json_init_array (counter_array);
6314 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6316 counter = vat_json_array_add (counter_array);
6317 vat_json_init_object (counter);
6318 n6 = &vam->ip6_nbr_counters[i][j];
6319 vat_json_object_add_ip6 (counter, "address", n6->address);
6320 vat_json_object_add_uint (counter, "packets", n6->packets);
6321 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6325 vat_json_print (vam->ofp, &node);
6326 vat_json_free (&node);
6332 * Pass CLI buffers directly in the CLI_INBAND API message,
6333 * instead of an additional shared memory area.
6336 exec_inband (vat_main_t * vam)
6338 vl_api_cli_inband_t *mp;
6339 unformat_input_t *i = vam->input;
6342 if (vec_len (i->buffer) == 0)
6345 if (vam->exec_mode == 0 && unformat (i, "mode"))
6350 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6357 * In order for the CLI command to work, it
6358 * must be a vector ending in \n, not a C-string ending
6361 u32 len = vec_len (vam->input->buffer);
6362 M2 (CLI_INBAND, mp, len);
6363 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
6367 /* json responses may or may not include a useful reply... */
6368 if (vec_len (vam->cmd_reply))
6369 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6374 exec (vat_main_t * vam)
6376 return exec_inband (vam);
6380 api_create_loopback (vat_main_t * vam)
6382 unformat_input_t *i = vam->input;
6383 vl_api_create_loopback_t *mp;
6384 vl_api_create_loopback_instance_t *mp_lbi;
6387 u8 is_specified = 0;
6388 u32 user_instance = 0;
6391 clib_memset (mac_address, 0, sizeof (mac_address));
6393 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6395 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6397 if (unformat (i, "instance %d", &user_instance))
6405 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6406 mp_lbi->is_specified = is_specified;
6408 mp_lbi->user_instance = htonl (user_instance);
6410 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6415 /* Construct the API message */
6416 M (CREATE_LOOPBACK, mp);
6418 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6427 api_delete_loopback (vat_main_t * vam)
6429 unformat_input_t *i = vam->input;
6430 vl_api_delete_loopback_t *mp;
6431 u32 sw_if_index = ~0;
6434 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6436 if (unformat (i, "sw_if_index %d", &sw_if_index))
6442 if (sw_if_index == ~0)
6444 errmsg ("missing sw_if_index");
6448 /* Construct the API message */
6449 M (DELETE_LOOPBACK, mp);
6450 mp->sw_if_index = ntohl (sw_if_index);
6458 api_want_stats (vat_main_t * vam)
6460 unformat_input_t *i = vam->input;
6461 vl_api_want_stats_t *mp;
6465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6467 if (unformat (i, "enable"))
6469 else if (unformat (i, "disable"))
6477 errmsg ("missing enable|disable");
6482 mp->enable_disable = enable;
6490 api_want_interface_events (vat_main_t * vam)
6492 unformat_input_t *i = vam->input;
6493 vl_api_want_interface_events_t *mp;
6497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6499 if (unformat (i, "enable"))
6501 else if (unformat (i, "disable"))
6509 errmsg ("missing enable|disable");
6513 M (WANT_INTERFACE_EVENTS, mp);
6514 mp->enable_disable = enable;
6516 vam->interface_event_display = enable;
6524 /* Note: non-static, called once to set up the initial intfc table */
6526 api_sw_interface_dump (vat_main_t * vam)
6528 vl_api_sw_interface_dump_t *mp;
6529 vl_api_control_ping_t *mp_ping;
6531 name_sort_t *nses = 0, *ns;
6532 sw_interface_subif_t *sub = NULL;
6535 /* Toss the old name table */
6537 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6539 vec_add2 (nses, ns, 1);
6540 ns->name = (u8 *)(p->key);
6541 ns->value = (u32) p->value[0];
6545 hash_free (vam->sw_if_index_by_interface_name);
6547 vec_foreach (ns, nses) vec_free (ns->name);
6551 vec_foreach (sub, vam->sw_if_subif_table)
6553 vec_free (sub->interface_name);
6555 vec_free (vam->sw_if_subif_table);
6557 /* recreate the interface name hash table */
6558 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6561 * Ask for all interface names. Otherwise, the epic catalog of
6562 * name filters becomes ridiculously long, and vat ends up needing
6563 * to be taught about new interface types.
6565 M (SW_INTERFACE_DUMP, mp);
6568 /* Use a control ping for synchronization */
6569 MPING (CONTROL_PING, mp_ping);
6577 api_sw_interface_set_flags (vat_main_t * vam)
6579 unformat_input_t *i = vam->input;
6580 vl_api_sw_interface_set_flags_t *mp;
6582 u8 sw_if_index_set = 0;
6586 /* Parse args required to build the message */
6587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6589 if (unformat (i, "admin-up"))
6591 else if (unformat (i, "admin-down"))
6594 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6595 sw_if_index_set = 1;
6596 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6597 sw_if_index_set = 1;
6602 if (sw_if_index_set == 0)
6604 errmsg ("missing interface name or sw_if_index");
6608 /* Construct the API message */
6609 M (SW_INTERFACE_SET_FLAGS, mp);
6610 mp->sw_if_index = ntohl (sw_if_index);
6611 mp->admin_up_down = admin_up;
6616 /* Wait for a reply, return the good/bad news... */
6622 api_sw_interface_set_rx_mode (vat_main_t * vam)
6624 unformat_input_t *i = vam->input;
6625 vl_api_sw_interface_set_rx_mode_t *mp;
6627 u8 sw_if_index_set = 0;
6629 u8 queue_id_valid = 0;
6631 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6633 /* Parse args required to build the message */
6634 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6636 if (unformat (i, "queue %d", &queue_id))
6638 else if (unformat (i, "polling"))
6639 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6640 else if (unformat (i, "interrupt"))
6641 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6642 else if (unformat (i, "adaptive"))
6643 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6645 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6646 sw_if_index_set = 1;
6647 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6648 sw_if_index_set = 1;
6653 if (sw_if_index_set == 0)
6655 errmsg ("missing interface name or sw_if_index");
6658 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6660 errmsg ("missing rx-mode");
6664 /* Construct the API message */
6665 M (SW_INTERFACE_SET_RX_MODE, mp);
6666 mp->sw_if_index = ntohl (sw_if_index);
6668 mp->queue_id_valid = queue_id_valid;
6669 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6674 /* Wait for a reply, return the good/bad news... */
6680 api_sw_interface_set_rx_placement (vat_main_t * vam)
6682 unformat_input_t *i = vam->input;
6683 vl_api_sw_interface_set_rx_placement_t *mp;
6685 u8 sw_if_index_set = 0;
6688 u32 queue_id, thread_index;
6690 /* Parse args required to build the message */
6691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6693 if (unformat (i, "queue %d", &queue_id))
6695 else if (unformat (i, "main"))
6697 else if (unformat (i, "worker %d", &thread_index))
6700 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6701 sw_if_index_set = 1;
6702 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6703 sw_if_index_set = 1;
6708 if (sw_if_index_set == 0)
6710 errmsg ("missing interface name or sw_if_index");
6716 /* Construct the API message */
6717 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6718 mp->sw_if_index = ntohl (sw_if_index);
6719 mp->worker_id = ntohl (thread_index);
6720 mp->queue_id = ntohl (queue_id);
6721 mp->is_main = is_main;
6725 /* Wait for a reply, return the good/bad news... */
6730 static void vl_api_sw_interface_rx_placement_details_t_handler
6731 (vl_api_sw_interface_rx_placement_details_t * mp)
6733 vat_main_t *vam = &vat_main;
6734 u32 worker_id = ntohl (mp->worker_id);
6737 "\n%-11d %-11s %-6d %-5d %-9s",
6738 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6739 worker_id, ntohl (mp->queue_id),
6741 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6744 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6745 (vl_api_sw_interface_rx_placement_details_t * mp)
6747 vat_main_t *vam = &vat_main;
6748 vat_json_node_t *node = NULL;
6750 if (VAT_JSON_ARRAY != vam->json_tree.type)
6752 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6753 vat_json_init_array (&vam->json_tree);
6755 node = vat_json_array_add (&vam->json_tree);
6757 vat_json_init_object (node);
6758 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6759 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6760 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6761 vat_json_object_add_uint (node, "mode", mp->mode);
6765 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6767 unformat_input_t *i = vam->input;
6768 vl_api_sw_interface_rx_placement_dump_t *mp;
6769 vl_api_control_ping_t *mp_ping;
6772 u8 sw_if_index_set = 0;
6774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6776 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6778 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6785 "\n%-11s %-11s %-6s %-5s %-4s",
6786 "sw_if_index", "main/worker", "thread", "queue", "mode");
6788 /* Dump Interface rx placement */
6789 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6791 if (sw_if_index_set)
6792 mp->sw_if_index = htonl (sw_if_index);
6794 mp->sw_if_index = ~0;
6798 /* Use a control ping for synchronization */
6799 MPING (CONTROL_PING, mp_ping);
6807 api_sw_interface_clear_stats (vat_main_t * vam)
6809 unformat_input_t *i = vam->input;
6810 vl_api_sw_interface_clear_stats_t *mp;
6812 u8 sw_if_index_set = 0;
6815 /* Parse args required to build the message */
6816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6818 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6819 sw_if_index_set = 1;
6820 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6821 sw_if_index_set = 1;
6826 /* Construct the API message */
6827 M (SW_INTERFACE_CLEAR_STATS, mp);
6829 if (sw_if_index_set == 1)
6830 mp->sw_if_index = ntohl (sw_if_index);
6832 mp->sw_if_index = ~0;
6837 /* Wait for a reply, return the good/bad news... */
6843 api_sw_interface_add_del_address (vat_main_t * vam)
6845 unformat_input_t *i = vam->input;
6846 vl_api_sw_interface_add_del_address_t *mp;
6848 u8 sw_if_index_set = 0;
6849 u8 is_add = 1, del_all = 0;
6850 u32 address_length = 0;
6851 u8 v4_address_set = 0;
6852 u8 v6_address_set = 0;
6853 ip4_address_t v4address;
6854 ip6_address_t v6address;
6857 /* Parse args required to build the message */
6858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6860 if (unformat (i, "del-all"))
6862 else if (unformat (i, "del"))
6865 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6866 sw_if_index_set = 1;
6867 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6868 sw_if_index_set = 1;
6869 else if (unformat (i, "%U/%d",
6870 unformat_ip4_address, &v4address, &address_length))
6872 else if (unformat (i, "%U/%d",
6873 unformat_ip6_address, &v6address, &address_length))
6879 if (sw_if_index_set == 0)
6881 errmsg ("missing interface name or sw_if_index");
6884 if (v4_address_set && v6_address_set)
6886 errmsg ("both v4 and v6 addresses set");
6889 if (!v4_address_set && !v6_address_set && !del_all)
6891 errmsg ("no addresses set");
6895 /* Construct the API message */
6896 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6898 mp->sw_if_index = ntohl (sw_if_index);
6899 mp->is_add = is_add;
6900 mp->del_all = del_all;
6904 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6908 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6910 mp->address_length = address_length;
6915 /* Wait for a reply, return good/bad news */
6921 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6923 unformat_input_t *i = vam->input;
6924 vl_api_sw_interface_set_mpls_enable_t *mp;
6926 u8 sw_if_index_set = 0;
6930 /* Parse args required to build the message */
6931 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6933 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6934 sw_if_index_set = 1;
6935 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6936 sw_if_index_set = 1;
6937 else if (unformat (i, "disable"))
6939 else if (unformat (i, "dis"))
6945 if (sw_if_index_set == 0)
6947 errmsg ("missing interface name or sw_if_index");
6951 /* Construct the API message */
6952 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6954 mp->sw_if_index = ntohl (sw_if_index);
6955 mp->enable = enable;
6960 /* Wait for a reply... */
6966 api_sw_interface_set_table (vat_main_t * vam)
6968 unformat_input_t *i = vam->input;
6969 vl_api_sw_interface_set_table_t *mp;
6970 u32 sw_if_index, vrf_id = 0;
6971 u8 sw_if_index_set = 0;
6975 /* Parse args required to build the message */
6976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6978 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6979 sw_if_index_set = 1;
6980 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6981 sw_if_index_set = 1;
6982 else if (unformat (i, "vrf %d", &vrf_id))
6984 else if (unformat (i, "ipv6"))
6990 if (sw_if_index_set == 0)
6992 errmsg ("missing interface name or sw_if_index");
6996 /* Construct the API message */
6997 M (SW_INTERFACE_SET_TABLE, mp);
6999 mp->sw_if_index = ntohl (sw_if_index);
7000 mp->is_ipv6 = is_ipv6;
7001 mp->vrf_id = ntohl (vrf_id);
7006 /* Wait for a reply... */
7011 static void vl_api_sw_interface_get_table_reply_t_handler
7012 (vl_api_sw_interface_get_table_reply_t * mp)
7014 vat_main_t *vam = &vat_main;
7016 print (vam->ofp, "%d", ntohl (mp->vrf_id));
7018 vam->retval = ntohl (mp->retval);
7019 vam->result_ready = 1;
7023 static void vl_api_sw_interface_get_table_reply_t_handler_json
7024 (vl_api_sw_interface_get_table_reply_t * mp)
7026 vat_main_t *vam = &vat_main;
7027 vat_json_node_t node;
7029 vat_json_init_object (&node);
7030 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
7031 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
7033 vat_json_print (vam->ofp, &node);
7034 vat_json_free (&node);
7036 vam->retval = ntohl (mp->retval);
7037 vam->result_ready = 1;
7041 api_sw_interface_get_table (vat_main_t * vam)
7043 unformat_input_t *i = vam->input;
7044 vl_api_sw_interface_get_table_t *mp;
7046 u8 sw_if_index_set = 0;
7050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7052 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7053 sw_if_index_set = 1;
7054 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7055 sw_if_index_set = 1;
7056 else if (unformat (i, "ipv6"))
7062 if (sw_if_index_set == 0)
7064 errmsg ("missing interface name or sw_if_index");
7068 M (SW_INTERFACE_GET_TABLE, mp);
7069 mp->sw_if_index = htonl (sw_if_index);
7070 mp->is_ipv6 = is_ipv6;
7078 api_sw_interface_set_vpath (vat_main_t * vam)
7080 unformat_input_t *i = vam->input;
7081 vl_api_sw_interface_set_vpath_t *mp;
7082 u32 sw_if_index = 0;
7083 u8 sw_if_index_set = 0;
7087 /* Parse args required to build the message */
7088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7090 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7091 sw_if_index_set = 1;
7092 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7093 sw_if_index_set = 1;
7094 else if (unformat (i, "enable"))
7096 else if (unformat (i, "disable"))
7102 if (sw_if_index_set == 0)
7104 errmsg ("missing interface name or sw_if_index");
7108 /* Construct the API message */
7109 M (SW_INTERFACE_SET_VPATH, mp);
7111 mp->sw_if_index = ntohl (sw_if_index);
7112 mp->enable = is_enable;
7117 /* Wait for a reply... */
7123 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
7125 unformat_input_t *i = vam->input;
7126 vl_api_sw_interface_set_vxlan_bypass_t *mp;
7127 u32 sw_if_index = 0;
7128 u8 sw_if_index_set = 0;
7133 /* Parse args required to build the message */
7134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7136 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7137 sw_if_index_set = 1;
7138 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7139 sw_if_index_set = 1;
7140 else if (unformat (i, "enable"))
7142 else if (unformat (i, "disable"))
7144 else if (unformat (i, "ip4"))
7146 else if (unformat (i, "ip6"))
7152 if (sw_if_index_set == 0)
7154 errmsg ("missing interface name or sw_if_index");
7158 /* Construct the API message */
7159 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
7161 mp->sw_if_index = ntohl (sw_if_index);
7162 mp->enable = is_enable;
7163 mp->is_ipv6 = is_ipv6;
7168 /* Wait for a reply... */
7174 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
7176 unformat_input_t *i = vam->input;
7177 vl_api_sw_interface_set_geneve_bypass_t *mp;
7178 u32 sw_if_index = 0;
7179 u8 sw_if_index_set = 0;
7184 /* Parse args required to build the message */
7185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7187 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7188 sw_if_index_set = 1;
7189 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7190 sw_if_index_set = 1;
7191 else if (unformat (i, "enable"))
7193 else if (unformat (i, "disable"))
7195 else if (unformat (i, "ip4"))
7197 else if (unformat (i, "ip6"))
7203 if (sw_if_index_set == 0)
7205 errmsg ("missing interface name or sw_if_index");
7209 /* Construct the API message */
7210 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7212 mp->sw_if_index = ntohl (sw_if_index);
7213 mp->enable = is_enable;
7214 mp->is_ipv6 = is_ipv6;
7219 /* Wait for a reply... */
7225 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7227 unformat_input_t *i = vam->input;
7228 vl_api_sw_interface_set_l2_xconnect_t *mp;
7230 u8 rx_sw_if_index_set = 0;
7232 u8 tx_sw_if_index_set = 0;
7236 /* Parse args required to build the message */
7237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7239 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7240 rx_sw_if_index_set = 1;
7241 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7242 tx_sw_if_index_set = 1;
7243 else if (unformat (i, "rx"))
7245 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7247 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7249 rx_sw_if_index_set = 1;
7254 else if (unformat (i, "tx"))
7256 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7258 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7260 tx_sw_if_index_set = 1;
7265 else if (unformat (i, "enable"))
7267 else if (unformat (i, "disable"))
7273 if (rx_sw_if_index_set == 0)
7275 errmsg ("missing rx interface name or rx_sw_if_index");
7279 if (enable && (tx_sw_if_index_set == 0))
7281 errmsg ("missing tx interface name or tx_sw_if_index");
7285 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7287 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7288 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7289 mp->enable = enable;
7297 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7299 unformat_input_t *i = vam->input;
7300 vl_api_sw_interface_set_l2_bridge_t *mp;
7301 vl_api_l2_port_type_t port_type;
7303 u8 rx_sw_if_index_set = 0;
7310 port_type = L2_API_PORT_TYPE_NORMAL;
7312 /* Parse args required to build the message */
7313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7315 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7316 rx_sw_if_index_set = 1;
7317 else if (unformat (i, "bd_id %d", &bd_id))
7321 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7322 rx_sw_if_index_set = 1;
7323 else if (unformat (i, "shg %d", &shg))
7325 else if (unformat (i, "bvi"))
7326 port_type = L2_API_PORT_TYPE_BVI;
7327 else if (unformat (i, "uu-fwd"))
7328 port_type = L2_API_PORT_TYPE_UU_FWD;
7329 else if (unformat (i, "enable"))
7331 else if (unformat (i, "disable"))
7337 if (rx_sw_if_index_set == 0)
7339 errmsg ("missing rx interface name or sw_if_index");
7343 if (enable && (bd_id_set == 0))
7345 errmsg ("missing bridge domain");
7349 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7351 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7352 mp->bd_id = ntohl (bd_id);
7354 mp->port_type = ntohl (port_type);
7355 mp->enable = enable;
7363 api_bridge_domain_dump (vat_main_t * vam)
7365 unformat_input_t *i = vam->input;
7366 vl_api_bridge_domain_dump_t *mp;
7367 vl_api_control_ping_t *mp_ping;
7371 /* Parse args required to build the message */
7372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7374 if (unformat (i, "bd_id %d", &bd_id))
7380 M (BRIDGE_DOMAIN_DUMP, mp);
7381 mp->bd_id = ntohl (bd_id);
7384 /* Use a control ping for synchronization */
7385 MPING (CONTROL_PING, mp_ping);
7393 api_bridge_domain_add_del (vat_main_t * vam)
7395 unformat_input_t *i = vam->input;
7396 vl_api_bridge_domain_add_del_t *mp;
7399 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7404 /* Parse args required to build the message */
7405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7407 if (unformat (i, "bd_id %d", &bd_id))
7409 else if (unformat (i, "flood %d", &flood))
7411 else if (unformat (i, "uu-flood %d", &uu_flood))
7413 else if (unformat (i, "forward %d", &forward))
7415 else if (unformat (i, "learn %d", &learn))
7417 else if (unformat (i, "arp-term %d", &arp_term))
7419 else if (unformat (i, "mac-age %d", &mac_age))
7421 else if (unformat (i, "bd-tag %s", &bd_tag))
7423 else if (unformat (i, "del"))
7426 flood = uu_flood = forward = learn = 0;
7434 errmsg ("missing bridge domain");
7441 errmsg ("mac age must be less than 256 ");
7446 if ((bd_tag) && (vec_len (bd_tag) > 63))
7448 errmsg ("bd-tag cannot be longer than 63");
7453 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7455 mp->bd_id = ntohl (bd_id);
7457 mp->uu_flood = uu_flood;
7458 mp->forward = forward;
7460 mp->arp_term = arp_term;
7461 mp->is_add = is_add;
7462 mp->mac_age = (u8) mac_age;
7465 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7466 mp->bd_tag[vec_len (bd_tag)] = 0;
7477 api_l2fib_flush_bd (vat_main_t * vam)
7479 unformat_input_t *i = vam->input;
7480 vl_api_l2fib_flush_bd_t *mp;
7484 /* Parse args required to build the message */
7485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7487 if (unformat (i, "bd_id %d", &bd_id));
7494 errmsg ("missing bridge domain");
7498 M (L2FIB_FLUSH_BD, mp);
7500 mp->bd_id = htonl (bd_id);
7508 api_l2fib_flush_int (vat_main_t * vam)
7510 unformat_input_t *i = vam->input;
7511 vl_api_l2fib_flush_int_t *mp;
7512 u32 sw_if_index = ~0;
7515 /* Parse args required to build the message */
7516 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7518 if (unformat (i, "sw_if_index %d", &sw_if_index));
7520 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7525 if (sw_if_index == ~0)
7527 errmsg ("missing interface name or sw_if_index");
7531 M (L2FIB_FLUSH_INT, mp);
7533 mp->sw_if_index = ntohl (sw_if_index);
7541 api_l2fib_add_del (vat_main_t * vam)
7543 unformat_input_t *i = vam->input;
7544 vl_api_l2fib_add_del_t *mp;
7550 u32 sw_if_index = 0;
7551 u8 sw_if_index_set = 0;
7560 /* Parse args required to build the message */
7561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7563 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7565 else if (unformat (i, "bd_id %d", &bd_id))
7567 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7568 sw_if_index_set = 1;
7569 else if (unformat (i, "sw_if"))
7571 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7574 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7575 sw_if_index_set = 1;
7580 else if (unformat (i, "static"))
7582 else if (unformat (i, "filter"))
7587 else if (unformat (i, "bvi"))
7592 else if (unformat (i, "del"))
7594 else if (unformat (i, "count %d", &count))
7602 errmsg ("missing mac address");
7608 errmsg ("missing bridge domain");
7612 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7614 errmsg ("missing interface name or sw_if_index");
7620 /* Turn on async mode */
7621 vam->async_mode = 1;
7622 vam->async_errors = 0;
7623 before = vat_time_now (vam);
7626 for (j = 0; j < count; j++)
7628 M (L2FIB_ADD_DEL, mp);
7630 clib_memcpy (mp->mac, mac, 6);
7631 mp->bd_id = ntohl (bd_id);
7632 mp->is_add = is_add;
7633 mp->sw_if_index = ntohl (sw_if_index);
7637 mp->static_mac = static_mac;
7638 mp->filter_mac = filter_mac;
7639 mp->bvi_mac = bvi_mac;
7641 increment_mac_address (mac);
7648 vl_api_control_ping_t *mp_ping;
7651 /* Shut off async mode */
7652 vam->async_mode = 0;
7654 MPING (CONTROL_PING, mp_ping);
7657 timeout = vat_time_now (vam) + 1.0;
7658 while (vat_time_now (vam) < timeout)
7659 if (vam->result_ready == 1)
7664 if (vam->retval == -99)
7667 if (vam->async_errors > 0)
7669 errmsg ("%d asynchronous errors", vam->async_errors);
7672 vam->async_errors = 0;
7673 after = vat_time_now (vam);
7675 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7676 count, after - before, count / (after - before));
7682 /* Wait for a reply... */
7686 /* Return the good/bad news */
7687 return (vam->retval);
7691 api_bridge_domain_set_mac_age (vat_main_t * vam)
7693 unformat_input_t *i = vam->input;
7694 vl_api_bridge_domain_set_mac_age_t *mp;
7699 /* Parse args required to build the message */
7700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7702 if (unformat (i, "bd_id %d", &bd_id));
7703 else if (unformat (i, "mac-age %d", &mac_age));
7710 errmsg ("missing bridge domain");
7716 errmsg ("mac age must be less than 256 ");
7720 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7722 mp->bd_id = htonl (bd_id);
7723 mp->mac_age = (u8) mac_age;
7731 api_l2_flags (vat_main_t * vam)
7733 unformat_input_t *i = vam->input;
7734 vl_api_l2_flags_t *mp;
7737 u8 sw_if_index_set = 0;
7741 /* Parse args required to build the message */
7742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7744 if (unformat (i, "sw_if_index %d", &sw_if_index))
7745 sw_if_index_set = 1;
7746 else if (unformat (i, "sw_if"))
7748 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7751 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7752 sw_if_index_set = 1;
7757 else if (unformat (i, "learn"))
7759 else if (unformat (i, "forward"))
7761 else if (unformat (i, "flood"))
7763 else if (unformat (i, "uu-flood"))
7764 flags |= L2_UU_FLOOD;
7765 else if (unformat (i, "arp-term"))
7766 flags |= L2_ARP_TERM;
7767 else if (unformat (i, "off"))
7769 else if (unformat (i, "disable"))
7775 if (sw_if_index_set == 0)
7777 errmsg ("missing interface name or sw_if_index");
7783 mp->sw_if_index = ntohl (sw_if_index);
7784 mp->feature_bitmap = ntohl (flags);
7785 mp->is_set = is_set;
7793 api_bridge_flags (vat_main_t * vam)
7795 unformat_input_t *i = vam->input;
7796 vl_api_bridge_flags_t *mp;
7800 bd_flags_t flags = 0;
7803 /* Parse args required to build the message */
7804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7806 if (unformat (i, "bd_id %d", &bd_id))
7808 else if (unformat (i, "learn"))
7809 flags |= BRIDGE_API_FLAG_LEARN;
7810 else if (unformat (i, "forward"))
7811 flags |= BRIDGE_API_FLAG_FWD;
7812 else if (unformat (i, "flood"))
7813 flags |= BRIDGE_API_FLAG_FLOOD;
7814 else if (unformat (i, "uu-flood"))
7815 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7816 else if (unformat (i, "arp-term"))
7817 flags |= BRIDGE_API_FLAG_ARP_TERM;
7818 else if (unformat (i, "off"))
7820 else if (unformat (i, "disable"))
7828 errmsg ("missing bridge domain");
7832 M (BRIDGE_FLAGS, mp);
7834 mp->bd_id = ntohl (bd_id);
7835 mp->flags = ntohl (flags);
7836 mp->is_set = is_set;
7844 api_bd_ip_mac_add_del (vat_main_t * vam)
7846 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7847 vl_api_mac_address_t mac = VL_API_ZERO_MAC_ADDRESS;
7848 unformat_input_t *i = vam->input;
7849 vl_api_bd_ip_mac_add_del_t *mp;
7861 /* Parse args required to build the message */
7862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7864 if (unformat (i, "bd_id %d", &bd_id))
7868 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7872 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7876 else if (unformat (i, "del"))
7884 errmsg ("missing bridge domain");
7887 else if (ip_set == 0)
7889 errmsg ("missing IP address");
7892 else if (mac_set == 0)
7894 errmsg ("missing MAC address");
7898 M (BD_IP_MAC_ADD_DEL, mp);
7900 mp->bd_id = ntohl (bd_id);
7901 mp->is_add = is_add;
7903 clib_memcpy (&mp->ip, &ip, sizeof (ip));
7904 clib_memcpy (&mp->mac, &mac, sizeof (mac));
7911 static void vl_api_bd_ip_mac_details_t_handler
7912 (vl_api_bd_ip_mac_details_t * mp)
7914 vat_main_t *vam = &vat_main;
7919 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7922 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7925 "\n%-5d %-7s %-20U %-30s",
7926 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7927 format_ethernet_address, mp->mac_address, ip);
7932 static void vl_api_bd_ip_mac_details_t_handler_json
7933 (vl_api_bd_ip_mac_details_t * mp)
7935 vat_main_t *vam = &vat_main;
7936 vat_json_node_t *node = NULL;
7938 if (VAT_JSON_ARRAY != vam->json_tree.type)
7940 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7941 vat_json_init_array (&vam->json_tree);
7943 node = vat_json_array_add (&vam->json_tree);
7945 vat_json_init_object (node);
7946 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7947 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7948 vat_json_object_add_string_copy (node, "mac_address",
7949 format (0, "%U", format_ethernet_address,
7955 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7958 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7959 vat_json_object_add_string_copy (node, "ip_address", ip);
7964 api_bd_ip_mac_dump (vat_main_t * vam)
7966 unformat_input_t *i = vam->input;
7967 vl_api_bd_ip_mac_dump_t *mp;
7968 vl_api_control_ping_t *mp_ping;
7973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7975 if (unformat (i, "bd_id %d", &bd_id))
7984 "\n%-5s %-7s %-20s %-30s",
7985 "bd_id", "is_ipv6", "mac_address", "ip_address");
7987 /* Dump Bridge Domain Ip to Mac entries */
7988 M (BD_IP_MAC_DUMP, mp);
7991 mp->bd_id = htonl (bd_id);
7997 /* Use a control ping for synchronization */
7998 MPING (CONTROL_PING, mp_ping);
8006 api_tap_connect (vat_main_t * vam)
8008 unformat_input_t *i = vam->input;
8009 vl_api_tap_connect_t *mp;
8015 ip4_address_t ip4_address;
8017 int ip4_address_set = 0;
8018 ip6_address_t ip6_address;
8020 int ip6_address_set = 0;
8023 clib_memset (mac_address, 0, sizeof (mac_address));
8025 /* Parse args required to build the message */
8026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8028 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8032 else if (unformat (i, "random-mac"))
8034 else if (unformat (i, "tapname %s", &tap_name))
8036 else if (unformat (i, "tag %s", &tag))
8038 else if (unformat (i, "address %U/%d",
8039 unformat_ip4_address, &ip4_address, &ip4_mask_width))
8040 ip4_address_set = 1;
8041 else if (unformat (i, "address %U/%d",
8042 unformat_ip6_address, &ip6_address, &ip6_mask_width))
8043 ip6_address_set = 1;
8050 errmsg ("missing tap name");
8053 if (vec_len (tap_name) > 63)
8055 errmsg ("tap name too long");
8058 vec_add1 (tap_name, 0);
8060 if (vec_len (tag) > 63)
8062 errmsg ("tag too long");
8066 /* Construct the API message */
8067 M (TAP_CONNECT, mp);
8069 mp->use_random_mac = random_mac;
8070 clib_memcpy (mp->mac_address, mac_address, 6);
8071 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8073 clib_memcpy (mp->tag, tag, vec_len (tag));
8075 if (ip4_address_set)
8077 mp->ip4_address_set = 1;
8078 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
8079 mp->ip4_mask_width = ip4_mask_width;
8081 if (ip6_address_set)
8083 mp->ip6_address_set = 1;
8084 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
8085 mp->ip6_mask_width = ip6_mask_width;
8088 vec_free (tap_name);
8094 /* Wait for a reply... */
8100 api_tap_modify (vat_main_t * vam)
8102 unformat_input_t *i = vam->input;
8103 vl_api_tap_modify_t *mp;
8108 u32 sw_if_index = ~0;
8109 u8 sw_if_index_set = 0;
8112 clib_memset (mac_address, 0, sizeof (mac_address));
8114 /* Parse args required to build the message */
8115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8117 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8118 sw_if_index_set = 1;
8119 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8120 sw_if_index_set = 1;
8121 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8125 else if (unformat (i, "random-mac"))
8127 else if (unformat (i, "tapname %s", &tap_name))
8133 if (sw_if_index_set == 0)
8135 errmsg ("missing vpp interface name");
8140 errmsg ("missing tap name");
8143 if (vec_len (tap_name) > 63)
8145 errmsg ("tap name too long");
8147 vec_add1 (tap_name, 0);
8149 /* Construct the API message */
8152 mp->use_random_mac = random_mac;
8153 mp->sw_if_index = ntohl (sw_if_index);
8154 clib_memcpy (mp->mac_address, mac_address, 6);
8155 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
8156 vec_free (tap_name);
8161 /* Wait for a reply... */
8167 api_tap_delete (vat_main_t * vam)
8169 unformat_input_t *i = vam->input;
8170 vl_api_tap_delete_t *mp;
8171 u32 sw_if_index = ~0;
8172 u8 sw_if_index_set = 0;
8175 /* Parse args required to build the message */
8176 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8178 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8179 sw_if_index_set = 1;
8180 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8181 sw_if_index_set = 1;
8186 if (sw_if_index_set == 0)
8188 errmsg ("missing vpp interface name");
8192 /* Construct the API message */
8195 mp->sw_if_index = ntohl (sw_if_index);
8200 /* Wait for a reply... */
8206 api_tap_create_v2 (vat_main_t * vam)
8208 unformat_input_t *i = vam->input;
8209 vl_api_tap_create_v2_t *mp;
8213 u8 *host_if_name = 0;
8215 u8 host_mac_addr[6];
8216 u8 host_mac_addr_set = 0;
8217 u8 *host_bridge = 0;
8218 ip4_address_t host_ip4_addr;
8219 ip4_address_t host_ip4_gw;
8220 u8 host_ip4_gw_set = 0;
8221 u32 host_ip4_prefix_len = 0;
8222 ip6_address_t host_ip6_addr;
8223 ip6_address_t host_ip6_gw;
8224 u8 host_ip6_gw_set = 0;
8225 u32 host_ip6_prefix_len = 0;
8227 u32 rx_ring_sz = 0, tx_ring_sz = 0;
8229 clib_memset (mac_address, 0, sizeof (mac_address));
8231 /* Parse args required to build the message */
8232 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8234 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8238 else if (unformat (i, "id %u", &id))
8240 else if (unformat (i, "host-if-name %s", &host_if_name))
8242 else if (unformat (i, "host-ns %s", &host_ns))
8244 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8246 host_mac_addr_set = 1;
8247 else if (unformat (i, "host-bridge %s", &host_bridge))
8249 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8250 &host_ip4_addr, &host_ip4_prefix_len))
8252 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8253 &host_ip6_addr, &host_ip6_prefix_len))
8255 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8257 host_ip4_gw_set = 1;
8258 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8260 host_ip6_gw_set = 1;
8261 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8263 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8269 if (vec_len (host_if_name) > 63)
8271 errmsg ("tap name too long. ");
8274 if (vec_len (host_ns) > 63)
8276 errmsg ("host name space too long. ");
8279 if (vec_len (host_bridge) > 63)
8281 errmsg ("host bridge name too long. ");
8284 if (host_ip4_prefix_len > 32)
8286 errmsg ("host ip4 prefix length not valid. ");
8289 if (host_ip6_prefix_len > 128)
8291 errmsg ("host ip6 prefix length not valid. ");
8294 if (!is_pow2 (rx_ring_sz))
8296 errmsg ("rx ring size must be power of 2. ");
8299 if (rx_ring_sz > 32768)
8301 errmsg ("rx ring size must be 32768 or lower. ");
8304 if (!is_pow2 (tx_ring_sz))
8306 errmsg ("tx ring size must be power of 2. ");
8309 if (tx_ring_sz > 32768)
8311 errmsg ("tx ring size must be 32768 or lower. ");
8315 /* Construct the API message */
8316 M (TAP_CREATE_V2, mp);
8318 mp->use_random_mac = random_mac;
8320 mp->id = ntohl (id);
8321 mp->host_namespace_set = host_ns != 0;
8322 mp->host_bridge_set = host_bridge != 0;
8323 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8324 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8325 mp->rx_ring_sz = ntohs (rx_ring_sz);
8326 mp->tx_ring_sz = ntohs (tx_ring_sz);
8328 if (random_mac == 0)
8329 clib_memcpy (mp->mac_address, mac_address, 6);
8330 if (host_mac_addr_set)
8331 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8333 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8335 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8337 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8338 if (host_ip4_prefix_len)
8339 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8340 if (host_ip6_prefix_len)
8341 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8342 if (host_ip4_gw_set)
8343 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8344 if (host_ip6_gw_set)
8345 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8348 vec_free (host_if_name);
8349 vec_free (host_bridge);
8354 /* Wait for a reply... */
8360 api_tap_delete_v2 (vat_main_t * vam)
8362 unformat_input_t *i = vam->input;
8363 vl_api_tap_delete_v2_t *mp;
8364 u32 sw_if_index = ~0;
8365 u8 sw_if_index_set = 0;
8368 /* Parse args required to build the message */
8369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8371 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8372 sw_if_index_set = 1;
8373 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8374 sw_if_index_set = 1;
8379 if (sw_if_index_set == 0)
8381 errmsg ("missing vpp interface name. ");
8385 /* Construct the API message */
8386 M (TAP_DELETE_V2, mp);
8388 mp->sw_if_index = ntohl (sw_if_index);
8393 /* Wait for a reply... */
8399 api_bond_create (vat_main_t * vam)
8401 unformat_input_t *i = vam->input;
8402 vl_api_bond_create_t *mp;
8410 clib_memset (mac_address, 0, sizeof (mac_address));
8413 /* Parse args required to build the message */
8414 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8416 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8418 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8419 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8421 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8428 if (mode_is_set == 0)
8430 errmsg ("Missing bond mode. ");
8434 /* Construct the API message */
8435 M (BOND_CREATE, mp);
8437 mp->use_custom_mac = custom_mac;
8443 clib_memcpy (mp->mac_address, mac_address, 6);
8448 /* Wait for a reply... */
8454 api_bond_delete (vat_main_t * vam)
8456 unformat_input_t *i = vam->input;
8457 vl_api_bond_delete_t *mp;
8458 u32 sw_if_index = ~0;
8459 u8 sw_if_index_set = 0;
8462 /* Parse args required to build the message */
8463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8465 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8466 sw_if_index_set = 1;
8467 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8468 sw_if_index_set = 1;
8473 if (sw_if_index_set == 0)
8475 errmsg ("missing vpp interface name. ");
8479 /* Construct the API message */
8480 M (BOND_DELETE, mp);
8482 mp->sw_if_index = ntohl (sw_if_index);
8487 /* Wait for a reply... */
8493 api_bond_enslave (vat_main_t * vam)
8495 unformat_input_t *i = vam->input;
8496 vl_api_bond_enslave_t *mp;
8497 u32 bond_sw_if_index;
8501 u32 bond_sw_if_index_is_set = 0;
8503 u8 sw_if_index_is_set = 0;
8505 /* Parse args required to build the message */
8506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8508 if (unformat (i, "sw_if_index %d", &sw_if_index))
8509 sw_if_index_is_set = 1;
8510 else if (unformat (i, "bond %u", &bond_sw_if_index))
8511 bond_sw_if_index_is_set = 1;
8512 else if (unformat (i, "passive %d", &is_passive))
8514 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8520 if (bond_sw_if_index_is_set == 0)
8522 errmsg ("Missing bond sw_if_index. ");
8525 if (sw_if_index_is_set == 0)
8527 errmsg ("Missing slave sw_if_index. ");
8531 /* Construct the API message */
8532 M (BOND_ENSLAVE, mp);
8534 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8535 mp->sw_if_index = ntohl (sw_if_index);
8536 mp->is_long_timeout = is_long_timeout;
8537 mp->is_passive = is_passive;
8542 /* Wait for a reply... */
8548 api_bond_detach_slave (vat_main_t * vam)
8550 unformat_input_t *i = vam->input;
8551 vl_api_bond_detach_slave_t *mp;
8552 u32 sw_if_index = ~0;
8553 u8 sw_if_index_set = 0;
8556 /* Parse args required to build the message */
8557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8559 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8560 sw_if_index_set = 1;
8561 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8562 sw_if_index_set = 1;
8567 if (sw_if_index_set == 0)
8569 errmsg ("missing vpp interface name. ");
8573 /* Construct the API message */
8574 M (BOND_DETACH_SLAVE, mp);
8576 mp->sw_if_index = ntohl (sw_if_index);
8581 /* Wait for a reply... */
8587 api_ip_table_add_del (vat_main_t * vam)
8589 unformat_input_t *i = vam->input;
8590 vl_api_ip_table_add_del_t *mp;
8596 /* Parse args required to build the message */
8597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8599 if (unformat (i, "ipv6"))
8601 else if (unformat (i, "del"))
8603 else if (unformat (i, "add"))
8605 else if (unformat (i, "table %d", &table_id))
8609 clib_warning ("parse error '%U'", format_unformat_error, i);
8616 errmsg ("missing table-ID");
8620 /* Construct the API message */
8621 M (IP_TABLE_ADD_DEL, mp);
8623 mp->table_id = ntohl (table_id);
8624 mp->is_ipv6 = is_ipv6;
8625 mp->is_add = is_add;
8630 /* Wait for a reply... */
8637 api_ip_add_del_route (vat_main_t * vam)
8639 unformat_input_t *i = vam->input;
8640 vl_api_ip_add_del_route_t *mp;
8641 u32 sw_if_index = ~0, vrf_id = 0;
8643 u8 is_local = 0, is_drop = 0;
8644 u8 is_unreach = 0, is_prohibit = 0;
8646 u32 next_hop_weight = 1;
8647 u8 is_multipath = 0;
8649 u8 address_length_set = 0;
8650 u32 next_hop_table_id = 0;
8651 u32 resolve_attempts = 0;
8652 u32 dst_address_length = 0;
8653 u8 next_hop_set = 0;
8654 ip4_address_t v4_dst_address, v4_next_hop_address;
8655 ip6_address_t v6_dst_address, v6_next_hop_address;
8659 u32 random_add_del = 0;
8660 u32 *random_vector = 0;
8662 u32 random_seed = 0xdeaddabe;
8663 u32 classify_table_index = ~0;
8665 u8 resolve_host = 0, resolve_attached = 0;
8666 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8667 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8668 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8670 clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8671 clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8672 /* Parse args required to build the message */
8673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8675 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8677 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8679 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8684 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8689 else if (unformat (i, "/%d", &dst_address_length))
8691 address_length_set = 1;
8694 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8695 &v4_next_hop_address))
8699 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8700 &v6_next_hop_address))
8706 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8710 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8714 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8716 else if (unformat (i, "weight %d", &next_hop_weight))
8718 else if (unformat (i, "drop"))
8722 else if (unformat (i, "null-send-unreach"))
8726 else if (unformat (i, "null-send-prohibit"))
8730 else if (unformat (i, "local"))
8734 else if (unformat (i, "classify %d", &classify_table_index))
8738 else if (unformat (i, "del"))
8740 else if (unformat (i, "add"))
8742 else if (unformat (i, "resolve-via-host"))
8744 else if (unformat (i, "resolve-via-attached"))
8745 resolve_attached = 1;
8746 else if (unformat (i, "multipath"))
8748 else if (unformat (i, "vrf %d", &vrf_id))
8750 else if (unformat (i, "count %d", &count))
8752 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8754 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8756 else if (unformat (i, "out-label %d", &next_hop_out_label))
8758 vl_api_fib_mpls_label_t fib_label = {
8759 .label = ntohl (next_hop_out_label),
8763 vec_add1 (next_hop_out_label_stack, fib_label);
8765 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8767 else if (unformat (i, "random"))
8769 else if (unformat (i, "seed %d", &random_seed))
8773 clib_warning ("parse error '%U'", format_unformat_error, i);
8778 if (!next_hop_set && !is_drop && !is_local &&
8779 !is_classify && !is_unreach && !is_prohibit &&
8780 MPLS_LABEL_INVALID == next_hop_via_label)
8783 ("next hop / local / drop / unreach / prohibit / classify not set");
8787 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8789 errmsg ("next hop and next-hop via label set");
8792 if (address_set == 0)
8794 errmsg ("missing addresses");
8798 if (address_length_set == 0)
8800 errmsg ("missing address length");
8804 /* Generate a pile of unique, random routes */
8807 u32 this_random_address;
8808 random_hash = hash_create (count, sizeof (uword));
8810 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8811 for (j = 0; j <= count; j++)
8815 this_random_address = random_u32 (&random_seed);
8816 this_random_address =
8817 clib_host_to_net_u32 (this_random_address);
8819 while (hash_get (random_hash, this_random_address));
8820 vec_add1 (random_vector, this_random_address);
8821 hash_set (random_hash, this_random_address, 1);
8823 hash_free (random_hash);
8824 v4_dst_address.as_u32 = random_vector[0];
8829 /* Turn on async mode */
8830 vam->async_mode = 1;
8831 vam->async_errors = 0;
8832 before = vat_time_now (vam);
8835 for (j = 0; j < count; j++)
8837 /* Construct the API message */
8838 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8839 vec_len (next_hop_out_label_stack));
8841 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8842 mp->table_id = ntohl (vrf_id);
8844 mp->is_add = is_add;
8845 mp->is_drop = is_drop;
8846 mp->is_unreach = is_unreach;
8847 mp->is_prohibit = is_prohibit;
8848 mp->is_ipv6 = is_ipv6;
8849 mp->is_local = is_local;
8850 mp->is_classify = is_classify;
8851 mp->is_multipath = is_multipath;
8852 mp->is_resolve_host = resolve_host;
8853 mp->is_resolve_attached = resolve_attached;
8854 mp->next_hop_weight = next_hop_weight;
8855 mp->next_hop_preference = 0;
8856 mp->dst_address_length = dst_address_length;
8857 mp->next_hop_table_id = ntohl (next_hop_table_id);
8858 mp->classify_table_index = ntohl (classify_table_index);
8859 mp->next_hop_via_label = ntohl (next_hop_via_label);
8860 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8861 if (0 != mp->next_hop_n_out_labels)
8863 memcpy (mp->next_hop_out_label_stack,
8864 next_hop_out_label_stack,
8865 (vec_len (next_hop_out_label_stack) *
8866 sizeof (vl_api_fib_mpls_label_t)));
8867 vec_free (next_hop_out_label_stack);
8872 clib_memcpy (mp->dst_address, &v6_dst_address,
8873 sizeof (v6_dst_address));
8875 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8876 sizeof (v6_next_hop_address));
8877 increment_v6_address (&v6_dst_address);
8881 clib_memcpy (mp->dst_address, &v4_dst_address,
8882 sizeof (v4_dst_address));
8884 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8885 sizeof (v4_next_hop_address));
8887 v4_dst_address.as_u32 = random_vector[j + 1];
8889 increment_v4_address (&v4_dst_address);
8893 /* If we receive SIGTERM, stop now... */
8898 /* When testing multiple add/del ops, use a control-ping to sync */
8901 vl_api_control_ping_t *mp_ping;
8905 /* Shut off async mode */
8906 vam->async_mode = 0;
8908 MPING (CONTROL_PING, mp_ping);
8911 timeout = vat_time_now (vam) + 1.0;
8912 while (vat_time_now (vam) < timeout)
8913 if (vam->result_ready == 1)
8918 if (vam->retval == -99)
8921 if (vam->async_errors > 0)
8923 errmsg ("%d asynchronous errors", vam->async_errors);
8926 vam->async_errors = 0;
8927 after = vat_time_now (vam);
8929 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8933 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8934 count, after - before, count / (after - before));
8940 /* Wait for a reply... */
8945 /* Return the good/bad news */
8946 return (vam->retval);
8950 api_ip_mroute_add_del (vat_main_t * vam)
8952 unformat_input_t *i = vam->input;
8953 vl_api_ip_mroute_add_del_t *mp;
8954 u32 sw_if_index = ~0, vrf_id = 0;
8959 u32 grp_address_length = 0;
8960 ip4_address_t v4_grp_address, v4_src_address;
8961 ip6_address_t v6_grp_address, v6_src_address;
8962 mfib_itf_flags_t iflags = 0;
8963 mfib_entry_flags_t eflags = 0;
8966 /* Parse args required to build the message */
8967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8969 if (unformat (i, "sw_if_index %d", &sw_if_index))
8971 else if (unformat (i, "%U %U",
8972 unformat_ip4_address, &v4_src_address,
8973 unformat_ip4_address, &v4_grp_address))
8975 grp_address_length = 64;
8979 else if (unformat (i, "%U %U",
8980 unformat_ip6_address, &v6_src_address,
8981 unformat_ip6_address, &v6_grp_address))
8983 grp_address_length = 256;
8987 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8989 clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
8990 grp_address_length = 32;
8994 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8996 clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
8997 grp_address_length = 128;
9001 else if (unformat (i, "/%d", &grp_address_length))
9003 else if (unformat (i, "local"))
9007 else if (unformat (i, "del"))
9009 else if (unformat (i, "add"))
9011 else if (unformat (i, "vrf %d", &vrf_id))
9013 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
9015 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
9019 clib_warning ("parse error '%U'", format_unformat_error, i);
9024 if (address_set == 0)
9026 errmsg ("missing addresses\n");
9030 /* Construct the API message */
9031 M (IP_MROUTE_ADD_DEL, mp);
9033 mp->next_hop_sw_if_index = ntohl (sw_if_index);
9034 mp->table_id = ntohl (vrf_id);
9036 mp->is_add = is_add;
9037 mp->is_ipv6 = is_ipv6;
9038 mp->is_local = is_local;
9039 mp->itf_flags = ntohl (iflags);
9040 mp->entry_flags = ntohl (eflags);
9041 mp->grp_address_length = grp_address_length;
9042 mp->grp_address_length = ntohs (mp->grp_address_length);
9046 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
9047 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
9051 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
9052 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
9058 /* Wait for a reply... */
9064 api_mpls_table_add_del (vat_main_t * vam)
9066 unformat_input_t *i = vam->input;
9067 vl_api_mpls_table_add_del_t *mp;
9072 /* Parse args required to build the message */
9073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9075 if (unformat (i, "table %d", &table_id))
9077 else if (unformat (i, "del"))
9079 else if (unformat (i, "add"))
9083 clib_warning ("parse error '%U'", format_unformat_error, i);
9090 errmsg ("missing table-ID");
9094 /* Construct the API message */
9095 M (MPLS_TABLE_ADD_DEL, mp);
9097 mp->mt_table_id = ntohl (table_id);
9098 mp->mt_is_add = is_add;
9103 /* Wait for a reply... */
9110 api_mpls_route_add_del (vat_main_t * vam)
9112 unformat_input_t *i = vam->input;
9113 vl_api_mpls_route_add_del_t *mp;
9114 u32 sw_if_index = ~0, table_id = 0;
9116 u32 next_hop_weight = 1;
9117 u8 is_multipath = 0;
9118 u32 next_hop_table_id = 0;
9119 u8 next_hop_set = 0;
9120 ip4_address_t v4_next_hop_address = {
9123 ip6_address_t v6_next_hop_address = { {0} };
9127 u32 classify_table_index = ~0;
9129 u8 resolve_host = 0, resolve_attached = 0;
9130 u8 is_interface_rx = 0;
9131 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9132 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9133 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9134 mpls_label_t local_label = MPLS_LABEL_INVALID;
9136 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
9138 /* Parse args required to build the message */
9139 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9141 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9143 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9145 else if (unformat (i, "%d", &local_label))
9147 else if (unformat (i, "eos"))
9149 else if (unformat (i, "non-eos"))
9151 else if (unformat (i, "via %U", unformat_ip4_address,
9152 &v4_next_hop_address))
9155 next_hop_proto = DPO_PROTO_IP4;
9157 else if (unformat (i, "via %U", unformat_ip6_address,
9158 &v6_next_hop_address))
9161 next_hop_proto = DPO_PROTO_IP6;
9163 else if (unformat (i, "weight %d", &next_hop_weight))
9165 else if (unformat (i, "classify %d", &classify_table_index))
9169 else if (unformat (i, "del"))
9171 else if (unformat (i, "add"))
9173 else if (unformat (i, "resolve-via-host"))
9175 else if (unformat (i, "resolve-via-attached"))
9176 resolve_attached = 1;
9177 else if (unformat (i, "multipath"))
9179 else if (unformat (i, "count %d", &count))
9181 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
9184 next_hop_proto = DPO_PROTO_IP4;
9186 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
9189 next_hop_proto = DPO_PROTO_IP6;
9193 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
9197 next_hop_proto = DPO_PROTO_ETHERNET;
9198 is_interface_rx = 1;
9200 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
9203 next_hop_proto = DPO_PROTO_ETHERNET;
9204 is_interface_rx = 1;
9206 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
9208 else if (unformat (i, "via via-label %d", &next_hop_via_label))
9210 else if (unformat (i, "out-label %d", &next_hop_out_label))
9212 vl_api_fib_mpls_label_t fib_label = {
9213 .label = ntohl (next_hop_out_label),
9217 vec_add1 (next_hop_out_label_stack, fib_label);
9221 clib_warning ("parse error '%U'", format_unformat_error, i);
9226 if (!next_hop_set && !is_classify)
9228 errmsg ("next hop / classify not set");
9232 if (MPLS_LABEL_INVALID == local_label)
9234 errmsg ("missing label");
9240 /* Turn on async mode */
9241 vam->async_mode = 1;
9242 vam->async_errors = 0;
9243 before = vat_time_now (vam);
9246 for (j = 0; j < count; j++)
9248 /* Construct the API message */
9249 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9250 vec_len (next_hop_out_label_stack));
9252 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
9253 mp->mr_table_id = ntohl (table_id);
9255 mp->mr_is_add = is_add;
9256 mp->mr_next_hop_proto = next_hop_proto;
9257 mp->mr_is_classify = is_classify;
9258 mp->mr_is_multipath = is_multipath;
9259 mp->mr_is_resolve_host = resolve_host;
9260 mp->mr_is_resolve_attached = resolve_attached;
9261 mp->mr_is_interface_rx = is_interface_rx;
9262 mp->mr_next_hop_weight = next_hop_weight;
9263 mp->mr_next_hop_preference = 0;
9264 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
9265 mp->mr_classify_table_index = ntohl (classify_table_index);
9266 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
9267 mp->mr_label = ntohl (local_label);
9268 mp->mr_eos = is_eos;
9270 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9271 if (0 != mp->mr_next_hop_n_out_labels)
9273 memcpy (mp->mr_next_hop_out_label_stack,
9274 next_hop_out_label_stack,
9275 vec_len (next_hop_out_label_stack) *
9276 sizeof (vl_api_fib_mpls_label_t));
9277 vec_free (next_hop_out_label_stack);
9282 if (DPO_PROTO_IP4 == next_hop_proto)
9284 clib_memcpy (mp->mr_next_hop,
9285 &v4_next_hop_address,
9286 sizeof (v4_next_hop_address));
9288 else if (DPO_PROTO_IP6 == next_hop_proto)
9291 clib_memcpy (mp->mr_next_hop,
9292 &v6_next_hop_address,
9293 sizeof (v6_next_hop_address));
9300 /* If we receive SIGTERM, stop now... */
9305 /* When testing multiple add/del ops, use a control-ping to sync */
9308 vl_api_control_ping_t *mp_ping;
9312 /* Shut off async mode */
9313 vam->async_mode = 0;
9315 MPING (CONTROL_PING, mp_ping);
9318 timeout = vat_time_now (vam) + 1.0;
9319 while (vat_time_now (vam) < timeout)
9320 if (vam->result_ready == 1)
9325 if (vam->retval == -99)
9328 if (vam->async_errors > 0)
9330 errmsg ("%d asynchronous errors", vam->async_errors);
9333 vam->async_errors = 0;
9334 after = vat_time_now (vam);
9336 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9340 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9341 count, after - before, count / (after - before));
9347 /* Wait for a reply... */
9352 /* Return the good/bad news */
9353 return (vam->retval);
9357 api_mpls_ip_bind_unbind (vat_main_t * vam)
9359 unformat_input_t *i = vam->input;
9360 vl_api_mpls_ip_bind_unbind_t *mp;
9361 u32 ip_table_id = 0;
9364 ip4_address_t v4_address;
9365 ip6_address_t v6_address;
9368 mpls_label_t local_label = MPLS_LABEL_INVALID;
9371 /* Parse args required to build the message */
9372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9374 if (unformat (i, "%U/%d", unformat_ip4_address,
9375 &v4_address, &address_length))
9380 else if (unformat (i, "%U/%d", unformat_ip6_address,
9381 &v6_address, &address_length))
9386 else if (unformat (i, "%d", &local_label))
9388 else if (unformat (i, "table-id %d", &ip_table_id))
9390 else if (unformat (i, "unbind"))
9392 else if (unformat (i, "bind"))
9396 clib_warning ("parse error '%U'", format_unformat_error, i);
9403 errmsg ("IP address not set");
9407 if (MPLS_LABEL_INVALID == local_label)
9409 errmsg ("missing label");
9413 /* Construct the API message */
9414 M (MPLS_IP_BIND_UNBIND, mp);
9416 mp->mb_is_bind = is_bind;
9417 mp->mb_is_ip4 = is_ip4;
9418 mp->mb_ip_table_id = ntohl (ip_table_id);
9419 mp->mb_mpls_table_id = 0;
9420 mp->mb_label = ntohl (local_label);
9421 mp->mb_address_length = address_length;
9424 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9426 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9431 /* Wait for a reply... */
9437 api_sr_mpls_policy_add (vat_main_t * vam)
9439 unformat_input_t *i = vam->input;
9440 vl_api_sr_mpls_policy_add_t *mp;
9446 u32 *segments = NULL;
9449 /* Parse args required to build the message */
9450 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9452 if (unformat (i, "bsid %d", &bsid))
9454 else if (unformat (i, "weight %d", &weight))
9456 else if (unformat (i, "spray"))
9458 else if (unformat (i, "next %d", &sid))
9461 vec_add1 (segments, htonl (sid));
9465 clib_warning ("parse error '%U'", format_unformat_error, i);
9472 errmsg ("bsid not set");
9476 if (n_segments == 0)
9478 errmsg ("no sid in segment stack");
9482 /* Construct the API message */
9483 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
9485 mp->bsid = htonl (bsid);
9486 mp->weight = htonl (weight);
9488 mp->n_segments = n_segments;
9489 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
9490 vec_free (segments);
9495 /* Wait for a reply... */
9501 api_sr_mpls_policy_del (vat_main_t * vam)
9503 unformat_input_t *i = vam->input;
9504 vl_api_sr_mpls_policy_del_t *mp;
9508 /* Parse args required to build the message */
9509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9511 if (unformat (i, "bsid %d", &bsid))
9515 clib_warning ("parse error '%U'", format_unformat_error, i);
9522 errmsg ("bsid not set");
9526 /* Construct the API message */
9527 M (SR_MPLS_POLICY_DEL, mp);
9529 mp->bsid = htonl (bsid);
9534 /* Wait for a reply... */
9540 api_bier_table_add_del (vat_main_t * vam)
9542 unformat_input_t *i = vam->input;
9543 vl_api_bier_table_add_del_t *mp;
9545 u32 set = 0, sub_domain = 0, hdr_len = 3;
9546 mpls_label_t local_label = MPLS_LABEL_INVALID;
9549 /* Parse args required to build the message */
9550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9552 if (unformat (i, "sub-domain %d", &sub_domain))
9554 else if (unformat (i, "set %d", &set))
9556 else if (unformat (i, "label %d", &local_label))
9558 else if (unformat (i, "hdr-len %d", &hdr_len))
9560 else if (unformat (i, "add"))
9562 else if (unformat (i, "del"))
9566 clib_warning ("parse error '%U'", format_unformat_error, i);
9571 if (MPLS_LABEL_INVALID == local_label)
9573 errmsg ("missing label\n");
9577 /* Construct the API message */
9578 M (BIER_TABLE_ADD_DEL, mp);
9580 mp->bt_is_add = is_add;
9581 mp->bt_label = ntohl (local_label);
9582 mp->bt_tbl_id.bt_set = set;
9583 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9584 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9589 /* Wait for a reply... */
9596 api_bier_route_add_del (vat_main_t * vam)
9598 unformat_input_t *i = vam->input;
9599 vl_api_bier_route_add_del_t *mp;
9601 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9602 ip4_address_t v4_next_hop_address;
9603 ip6_address_t v6_next_hop_address;
9604 u8 next_hop_set = 0;
9605 u8 next_hop_proto_is_ip4 = 1;
9606 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9609 /* Parse args required to build the message */
9610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9612 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9614 next_hop_proto_is_ip4 = 1;
9617 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9619 next_hop_proto_is_ip4 = 0;
9622 if (unformat (i, "sub-domain %d", &sub_domain))
9624 else if (unformat (i, "set %d", &set))
9626 else if (unformat (i, "hdr-len %d", &hdr_len))
9628 else if (unformat (i, "bp %d", &bp))
9630 else if (unformat (i, "add"))
9632 else if (unformat (i, "del"))
9634 else if (unformat (i, "out-label %d", &next_hop_out_label))
9638 clib_warning ("parse error '%U'", format_unformat_error, i);
9643 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9645 errmsg ("next hop / label set\n");
9650 errmsg ("bit=position not set\n");
9654 /* Construct the API message */
9655 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9657 mp->br_is_add = is_add;
9658 mp->br_tbl_id.bt_set = set;
9659 mp->br_tbl_id.bt_sub_domain = sub_domain;
9660 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9661 mp->br_bp = ntohs (bp);
9663 mp->br_paths[0].n_labels = 1;
9664 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9665 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9667 if (next_hop_proto_is_ip4)
9669 clib_memcpy (mp->br_paths[0].next_hop,
9670 &v4_next_hop_address, sizeof (v4_next_hop_address));
9674 clib_memcpy (mp->br_paths[0].next_hop,
9675 &v6_next_hop_address, sizeof (v6_next_hop_address));
9681 /* Wait for a reply... */
9688 api_proxy_arp_add_del (vat_main_t * vam)
9690 unformat_input_t *i = vam->input;
9691 vl_api_proxy_arp_add_del_t *mp;
9694 ip4_address_t lo, hi;
9698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9700 if (unformat (i, "vrf %d", &vrf_id))
9702 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9703 unformat_ip4_address, &hi))
9705 else if (unformat (i, "del"))
9709 clib_warning ("parse error '%U'", format_unformat_error, i);
9716 errmsg ("address range not set");
9720 M (PROXY_ARP_ADD_DEL, mp);
9722 mp->proxy.vrf_id = ntohl (vrf_id);
9723 mp->is_add = is_add;
9724 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9725 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9733 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9735 unformat_input_t *i = vam->input;
9736 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9739 u8 sw_if_index_set = 0;
9742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9744 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9745 sw_if_index_set = 1;
9746 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9747 sw_if_index_set = 1;
9748 else if (unformat (i, "enable"))
9750 else if (unformat (i, "disable"))
9754 clib_warning ("parse error '%U'", format_unformat_error, i);
9759 if (sw_if_index_set == 0)
9761 errmsg ("missing interface name or sw_if_index");
9765 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9767 mp->sw_if_index = ntohl (sw_if_index);
9768 mp->enable_disable = enable;
9776 api_mpls_tunnel_add_del (vat_main_t * vam)
9778 unformat_input_t *i = vam->input;
9779 vl_api_mpls_tunnel_add_del_t *mp;
9783 u32 sw_if_index = ~0;
9784 u32 next_hop_sw_if_index = ~0;
9785 u32 next_hop_proto_is_ip4 = 1;
9787 u32 next_hop_table_id = 0;
9788 ip4_address_t v4_next_hop_address = {
9791 ip6_address_t v6_next_hop_address = { {0} };
9792 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9793 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9794 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9797 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9799 if (unformat (i, "add"))
9803 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9805 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9807 else if (unformat (i, "via %U",
9808 unformat_ip4_address, &v4_next_hop_address))
9810 next_hop_proto_is_ip4 = 1;
9812 else if (unformat (i, "via %U",
9813 unformat_ip6_address, &v6_next_hop_address))
9815 next_hop_proto_is_ip4 = 0;
9817 else if (unformat (i, "via-label %d", &next_hop_via_label))
9821 (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
9823 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9825 else if (unformat (i, "l2-only"))
9827 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9829 else if (unformat (i, "out-label %d", &next_hop_out_label))
9831 vl_api_fib_mpls_label_t fib_label = {
9832 .label = ntohl (next_hop_out_label),
9836 vec_add1 (next_hop_out_label_stack, fib_label);
9840 clib_warning ("parse error '%U'", format_unformat_error, i);
9845 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9846 vec_len (next_hop_out_label_stack));
9848 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9849 mp->mt_sw_if_index = ntohl (sw_if_index);
9850 mp->mt_is_add = is_add;
9851 mp->mt_l2_only = l2_only;
9852 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9853 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9854 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9855 mp->mt_next_hop_weight = 1;
9856 mp->mt_next_hop_preference = 0;
9858 mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9860 if (0 != mp->mt_next_hop_n_out_labels)
9862 clib_memcpy (mp->mt_next_hop_out_label_stack,
9863 next_hop_out_label_stack,
9864 (vec_len (next_hop_out_label_stack) *
9865 sizeof (vl_api_fib_mpls_label_t)));
9866 vec_free (next_hop_out_label_stack);
9869 if (next_hop_proto_is_ip4)
9871 clib_memcpy (mp->mt_next_hop,
9872 &v4_next_hop_address, sizeof (v4_next_hop_address));
9876 clib_memcpy (mp->mt_next_hop,
9877 &v6_next_hop_address, sizeof (v6_next_hop_address));
9886 api_sw_interface_set_unnumbered (vat_main_t * vam)
9888 unformat_input_t *i = vam->input;
9889 vl_api_sw_interface_set_unnumbered_t *mp;
9891 u32 unnum_sw_index = ~0;
9893 u8 sw_if_index_set = 0;
9896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9898 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9899 sw_if_index_set = 1;
9900 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9901 sw_if_index_set = 1;
9902 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9904 else if (unformat (i, "del"))
9908 clib_warning ("parse error '%U'", format_unformat_error, i);
9913 if (sw_if_index_set == 0)
9915 errmsg ("missing interface name or sw_if_index");
9919 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9921 mp->sw_if_index = ntohl (sw_if_index);
9922 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9923 mp->is_add = is_add;
9931 api_ip_neighbor_add_del (vat_main_t * vam)
9933 unformat_input_t *i = vam->input;
9934 vl_api_ip_neighbor_add_del_t *mp;
9936 u8 sw_if_index_set = 0;
9939 u8 is_no_fib_entry = 0;
9942 u8 v4_address_set = 0;
9943 u8 v6_address_set = 0;
9944 ip4_address_t v4address;
9945 ip6_address_t v6address;
9948 clib_memset (mac_address, 0, sizeof (mac_address));
9950 /* Parse args required to build the message */
9951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9953 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9957 else if (unformat (i, "del"))
9960 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9961 sw_if_index_set = 1;
9962 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9963 sw_if_index_set = 1;
9964 else if (unformat (i, "is_static"))
9966 else if (unformat (i, "no-fib-entry"))
9967 is_no_fib_entry = 1;
9968 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9970 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9974 clib_warning ("parse error '%U'", format_unformat_error, i);
9979 if (sw_if_index_set == 0)
9981 errmsg ("missing interface name or sw_if_index");
9984 if (v4_address_set && v6_address_set)
9986 errmsg ("both v4 and v6 addresses set");
9989 if (!v4_address_set && !v6_address_set)
9991 errmsg ("no address set");
9995 /* Construct the API message */
9996 M (IP_NEIGHBOR_ADD_DEL, mp);
9998 mp->sw_if_index = ntohl (sw_if_index);
9999 mp->is_add = is_add;
10000 mp->is_static = is_static;
10001 mp->is_no_adj_fib = is_no_fib_entry;
10003 clib_memcpy (mp->mac_address, mac_address, 6);
10004 if (v6_address_set)
10007 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
10011 /* mp->is_ipv6 = 0; via clib_memset in M macro above */
10012 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
10018 /* Wait for a reply, return good/bad news */
10024 api_create_vlan_subif (vat_main_t * vam)
10026 unformat_input_t *i = vam->input;
10027 vl_api_create_vlan_subif_t *mp;
10029 u8 sw_if_index_set = 0;
10031 u8 vlan_id_set = 0;
10034 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10036 if (unformat (i, "sw_if_index %d", &sw_if_index))
10037 sw_if_index_set = 1;
10039 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10040 sw_if_index_set = 1;
10041 else if (unformat (i, "vlan %d", &vlan_id))
10045 clib_warning ("parse error '%U'", format_unformat_error, i);
10050 if (sw_if_index_set == 0)
10052 errmsg ("missing interface name or sw_if_index");
10056 if (vlan_id_set == 0)
10058 errmsg ("missing vlan_id");
10061 M (CREATE_VLAN_SUBIF, mp);
10063 mp->sw_if_index = ntohl (sw_if_index);
10064 mp->vlan_id = ntohl (vlan_id);
10071 #define foreach_create_subif_bit \
10078 _(outer_vlan_id_any) \
10079 _(inner_vlan_id_any)
10082 api_create_subif (vat_main_t * vam)
10084 unformat_input_t *i = vam->input;
10085 vl_api_create_subif_t *mp;
10087 u8 sw_if_index_set = 0;
10094 u32 exact_match = 0;
10095 u32 default_sub = 0;
10096 u32 outer_vlan_id_any = 0;
10097 u32 inner_vlan_id_any = 0;
10099 u16 outer_vlan_id = 0;
10100 u16 inner_vlan_id = 0;
10103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10105 if (unformat (i, "sw_if_index %d", &sw_if_index))
10106 sw_if_index_set = 1;
10108 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10109 sw_if_index_set = 1;
10110 else if (unformat (i, "sub_id %d", &sub_id))
10112 else if (unformat (i, "outer_vlan_id %d", &tmp))
10113 outer_vlan_id = tmp;
10114 else if (unformat (i, "inner_vlan_id %d", &tmp))
10115 inner_vlan_id = tmp;
10117 #define _(a) else if (unformat (i, #a)) a = 1 ;
10118 foreach_create_subif_bit
10122 clib_warning ("parse error '%U'", format_unformat_error, i);
10127 if (sw_if_index_set == 0)
10129 errmsg ("missing interface name or sw_if_index");
10133 if (sub_id_set == 0)
10135 errmsg ("missing sub_id");
10138 M (CREATE_SUBIF, mp);
10140 mp->sw_if_index = ntohl (sw_if_index);
10141 mp->sub_id = ntohl (sub_id);
10143 #define _(a) mp->a = a;
10144 foreach_create_subif_bit;
10147 mp->outer_vlan_id = ntohs (outer_vlan_id);
10148 mp->inner_vlan_id = ntohs (inner_vlan_id);
10156 api_oam_add_del (vat_main_t * vam)
10158 unformat_input_t *i = vam->input;
10159 vl_api_oam_add_del_t *mp;
10162 ip4_address_t src, dst;
10167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10169 if (unformat (i, "vrf %d", &vrf_id))
10171 else if (unformat (i, "src %U", unformat_ip4_address, &src))
10173 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
10175 else if (unformat (i, "del"))
10179 clib_warning ("parse error '%U'", format_unformat_error, i);
10186 errmsg ("missing src addr");
10192 errmsg ("missing dst addr");
10196 M (OAM_ADD_DEL, mp);
10198 mp->vrf_id = ntohl (vrf_id);
10199 mp->is_add = is_add;
10200 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
10201 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
10209 api_reset_fib (vat_main_t * vam)
10211 unformat_input_t *i = vam->input;
10212 vl_api_reset_fib_t *mp;
10218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10220 if (unformat (i, "vrf %d", &vrf_id))
10222 else if (unformat (i, "ipv6"))
10226 clib_warning ("parse error '%U'", format_unformat_error, i);
10231 if (vrf_id_set == 0)
10233 errmsg ("missing vrf id");
10239 mp->vrf_id = ntohl (vrf_id);
10240 mp->is_ipv6 = is_ipv6;
10248 api_dhcp_proxy_config (vat_main_t * vam)
10250 unformat_input_t *i = vam->input;
10251 vl_api_dhcp_proxy_config_t *mp;
10253 u32 server_vrf_id = 0;
10255 u8 v4_address_set = 0;
10256 u8 v6_address_set = 0;
10257 ip4_address_t v4address;
10258 ip6_address_t v6address;
10259 u8 v4_src_address_set = 0;
10260 u8 v6_src_address_set = 0;
10261 ip4_address_t v4srcaddress;
10262 ip6_address_t v6srcaddress;
10265 /* Parse args required to build the message */
10266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10268 if (unformat (i, "del"))
10270 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
10272 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
10274 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
10275 v4_address_set = 1;
10276 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
10277 v6_address_set = 1;
10278 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
10279 v4_src_address_set = 1;
10280 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
10281 v6_src_address_set = 1;
10286 if (v4_address_set && v6_address_set)
10288 errmsg ("both v4 and v6 server addresses set");
10291 if (!v4_address_set && !v6_address_set)
10293 errmsg ("no server addresses set");
10297 if (v4_src_address_set && v6_src_address_set)
10299 errmsg ("both v4 and v6 src addresses set");
10302 if (!v4_src_address_set && !v6_src_address_set)
10304 errmsg ("no src addresses set");
10308 if (!(v4_src_address_set && v4_address_set) &&
10309 !(v6_src_address_set && v6_address_set))
10311 errmsg ("no matching server and src addresses set");
10315 /* Construct the API message */
10316 M (DHCP_PROXY_CONFIG, mp);
10318 mp->is_add = is_add;
10319 mp->rx_vrf_id = ntohl (rx_vrf_id);
10320 mp->server_vrf_id = ntohl (server_vrf_id);
10321 if (v6_address_set)
10324 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
10325 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
10329 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
10330 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
10336 /* Wait for a reply, return good/bad news */
10341 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
10342 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
10345 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
10347 vat_main_t *vam = &vat_main;
10348 u32 i, count = mp->count;
10349 vl_api_dhcp_server_t *s;
10353 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10354 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10355 ntohl (mp->rx_vrf_id),
10356 format_ip6_address, mp->dhcp_src_address,
10357 mp->vss_type, mp->vss_vpn_ascii_id,
10358 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10361 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10362 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10363 ntohl (mp->rx_vrf_id),
10364 format_ip4_address, mp->dhcp_src_address,
10365 mp->vss_type, mp->vss_vpn_ascii_id,
10366 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10368 for (i = 0; i < count; i++)
10370 s = &mp->servers[i];
10374 " Server Table-ID %d, Server Address %U",
10375 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
10378 " Server Table-ID %d, Server Address %U",
10379 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
10383 static void vl_api_dhcp_proxy_details_t_handler_json
10384 (vl_api_dhcp_proxy_details_t * mp)
10386 vat_main_t *vam = &vat_main;
10387 vat_json_node_t *node = NULL;
10388 u32 i, count = mp->count;
10389 struct in_addr ip4;
10390 struct in6_addr ip6;
10391 vl_api_dhcp_server_t *s;
10393 if (VAT_JSON_ARRAY != vam->json_tree.type)
10395 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10396 vat_json_init_array (&vam->json_tree);
10398 node = vat_json_array_add (&vam->json_tree);
10400 vat_json_init_object (node);
10401 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
10402 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
10403 sizeof (mp->vss_type));
10404 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
10405 mp->vss_vpn_ascii_id);
10406 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
10407 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10411 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10412 vat_json_object_add_ip6 (node, "src_address", ip6);
10416 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10417 vat_json_object_add_ip4 (node, "src_address", ip4);
10420 for (i = 0; i < count; i++)
10422 s = &mp->servers[i];
10424 vat_json_object_add_uint (node, "server-table-id",
10425 ntohl (s->server_vrf_id));
10429 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10430 vat_json_object_add_ip4 (node, "src_address", ip4);
10434 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10435 vat_json_object_add_ip6 (node, "server_address", ip6);
10441 api_dhcp_proxy_dump (vat_main_t * vam)
10443 unformat_input_t *i = vam->input;
10444 vl_api_control_ping_t *mp_ping;
10445 vl_api_dhcp_proxy_dump_t *mp;
10449 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10451 if (unformat (i, "ipv6"))
10455 clib_warning ("parse error '%U'", format_unformat_error, i);
10460 M (DHCP_PROXY_DUMP, mp);
10462 mp->is_ip6 = is_ipv6;
10465 /* Use a control ping for synchronization */
10466 MPING (CONTROL_PING, mp_ping);
10474 api_dhcp_proxy_set_vss (vat_main_t * vam)
10476 unformat_input_t *i = vam->input;
10477 vl_api_dhcp_proxy_set_vss_t *mp;
10481 u8 vss_type = VSS_TYPE_DEFAULT;
10482 u8 *vpn_ascii_id = 0;
10487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10489 if (unformat (i, "tbl_id %d", &tbl_id))
10491 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10492 vss_type = VSS_TYPE_ASCII;
10493 else if (unformat (i, "fib_id %d", &fib_id))
10494 vss_type = VSS_TYPE_VPN_ID;
10495 else if (unformat (i, "oui %d", &oui))
10496 vss_type = VSS_TYPE_VPN_ID;
10497 else if (unformat (i, "ipv6"))
10499 else if (unformat (i, "del"))
10507 errmsg ("missing tbl_id ");
10508 vec_free (vpn_ascii_id);
10512 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10514 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10515 vec_free (vpn_ascii_id);
10519 M (DHCP_PROXY_SET_VSS, mp);
10520 mp->tbl_id = ntohl (tbl_id);
10521 mp->vss_type = vss_type;
10524 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10525 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10527 mp->vpn_index = ntohl (fib_id);
10528 mp->oui = ntohl (oui);
10529 mp->is_ipv6 = is_ipv6;
10530 mp->is_add = is_add;
10535 vec_free (vpn_ascii_id);
10540 api_dhcp_client_config (vat_main_t * vam)
10542 unformat_input_t *i = vam->input;
10543 vl_api_dhcp_client_config_t *mp;
10545 u8 sw_if_index_set = 0;
10548 u8 disable_event = 0;
10551 /* Parse args required to build the message */
10552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10554 if (unformat (i, "del"))
10557 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10558 sw_if_index_set = 1;
10559 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10560 sw_if_index_set = 1;
10561 else if (unformat (i, "hostname %s", &hostname))
10563 else if (unformat (i, "disable_event"))
10569 if (sw_if_index_set == 0)
10571 errmsg ("missing interface name or sw_if_index");
10575 if (vec_len (hostname) > 63)
10577 errmsg ("hostname too long");
10579 vec_add1 (hostname, 0);
10581 /* Construct the API message */
10582 M (DHCP_CLIENT_CONFIG, mp);
10584 mp->is_add = is_add;
10585 mp->client.sw_if_index = htonl (sw_if_index);
10586 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10587 vec_free (hostname);
10588 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10589 mp->client.pid = htonl (getpid ());
10594 /* Wait for a reply, return good/bad news */
10600 api_set_ip_flow_hash (vat_main_t * vam)
10602 unformat_input_t *i = vam->input;
10603 vl_api_set_ip_flow_hash_t *mp;
10615 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10617 if (unformat (i, "vrf %d", &vrf_id))
10619 else if (unformat (i, "ipv6"))
10621 else if (unformat (i, "src"))
10623 else if (unformat (i, "dst"))
10625 else if (unformat (i, "sport"))
10627 else if (unformat (i, "dport"))
10629 else if (unformat (i, "proto"))
10631 else if (unformat (i, "reverse"))
10636 clib_warning ("parse error '%U'", format_unformat_error, i);
10641 if (vrf_id_set == 0)
10643 errmsg ("missing vrf id");
10647 M (SET_IP_FLOW_HASH, mp);
10653 mp->reverse = reverse;
10654 mp->vrf_id = ntohl (vrf_id);
10655 mp->is_ipv6 = is_ipv6;
10663 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10665 unformat_input_t *i = vam->input;
10666 vl_api_sw_interface_ip6_enable_disable_t *mp;
10668 u8 sw_if_index_set = 0;
10672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10674 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10675 sw_if_index_set = 1;
10676 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10677 sw_if_index_set = 1;
10678 else if (unformat (i, "enable"))
10680 else if (unformat (i, "disable"))
10684 clib_warning ("parse error '%U'", format_unformat_error, i);
10689 if (sw_if_index_set == 0)
10691 errmsg ("missing interface name or sw_if_index");
10695 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10697 mp->sw_if_index = ntohl (sw_if_index);
10698 mp->enable = enable;
10706 api_ip6nd_proxy_add_del (vat_main_t * vam)
10708 unformat_input_t *i = vam->input;
10709 vl_api_ip6nd_proxy_add_del_t *mp;
10710 u32 sw_if_index = ~0;
10711 u8 v6_address_set = 0;
10712 ip6_address_t v6address;
10716 /* Parse args required to build the message */
10717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10719 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10721 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10723 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10724 v6_address_set = 1;
10725 if (unformat (i, "del"))
10729 clib_warning ("parse error '%U'", format_unformat_error, i);
10734 if (sw_if_index == ~0)
10736 errmsg ("missing interface name or sw_if_index");
10739 if (!v6_address_set)
10741 errmsg ("no address set");
10745 /* Construct the API message */
10746 M (IP6ND_PROXY_ADD_DEL, mp);
10748 mp->is_del = is_del;
10749 mp->sw_if_index = ntohl (sw_if_index);
10750 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10755 /* Wait for a reply, return good/bad news */
10761 api_ip6nd_proxy_dump (vat_main_t * vam)
10763 vl_api_ip6nd_proxy_dump_t *mp;
10764 vl_api_control_ping_t *mp_ping;
10767 M (IP6ND_PROXY_DUMP, mp);
10771 /* Use a control ping for synchronization */
10772 MPING (CONTROL_PING, mp_ping);
10779 static void vl_api_ip6nd_proxy_details_t_handler
10780 (vl_api_ip6nd_proxy_details_t * mp)
10782 vat_main_t *vam = &vat_main;
10784 print (vam->ofp, "host %U sw_if_index %d",
10785 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10788 static void vl_api_ip6nd_proxy_details_t_handler_json
10789 (vl_api_ip6nd_proxy_details_t * mp)
10791 vat_main_t *vam = &vat_main;
10792 struct in6_addr ip6;
10793 vat_json_node_t *node = NULL;
10795 if (VAT_JSON_ARRAY != vam->json_tree.type)
10797 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10798 vat_json_init_array (&vam->json_tree);
10800 node = vat_json_array_add (&vam->json_tree);
10802 vat_json_init_object (node);
10803 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10805 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10806 vat_json_object_add_ip6 (node, "host", ip6);
10810 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10812 unformat_input_t *i = vam->input;
10813 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10815 u8 sw_if_index_set = 0;
10816 u32 address_length = 0;
10817 u8 v6_address_set = 0;
10818 ip6_address_t v6address;
10819 u8 use_default = 0;
10820 u8 no_advertise = 0;
10822 u8 no_autoconfig = 0;
10825 u32 val_lifetime = 0;
10826 u32 pref_lifetime = 0;
10829 /* Parse args required to build the message */
10830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10832 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10833 sw_if_index_set = 1;
10834 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10835 sw_if_index_set = 1;
10836 else if (unformat (i, "%U/%d",
10837 unformat_ip6_address, &v6address, &address_length))
10838 v6_address_set = 1;
10839 else if (unformat (i, "val_life %d", &val_lifetime))
10841 else if (unformat (i, "pref_life %d", &pref_lifetime))
10843 else if (unformat (i, "def"))
10845 else if (unformat (i, "noadv"))
10847 else if (unformat (i, "offl"))
10849 else if (unformat (i, "noauto"))
10851 else if (unformat (i, "nolink"))
10853 else if (unformat (i, "isno"))
10857 clib_warning ("parse error '%U'", format_unformat_error, i);
10862 if (sw_if_index_set == 0)
10864 errmsg ("missing interface name or sw_if_index");
10867 if (!v6_address_set)
10869 errmsg ("no address set");
10873 /* Construct the API message */
10874 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10876 mp->sw_if_index = ntohl (sw_if_index);
10877 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10878 mp->address_length = address_length;
10879 mp->use_default = use_default;
10880 mp->no_advertise = no_advertise;
10881 mp->off_link = off_link;
10882 mp->no_autoconfig = no_autoconfig;
10883 mp->no_onlink = no_onlink;
10885 mp->val_lifetime = ntohl (val_lifetime);
10886 mp->pref_lifetime = ntohl (pref_lifetime);
10891 /* Wait for a reply, return good/bad news */
10897 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10899 unformat_input_t *i = vam->input;
10900 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10902 u8 sw_if_index_set = 0;
10907 u8 send_unicast = 0;
10910 u8 default_router = 0;
10911 u32 max_interval = 0;
10912 u32 min_interval = 0;
10914 u32 initial_count = 0;
10915 u32 initial_interval = 0;
10919 /* Parse args required to build the message */
10920 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10922 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10923 sw_if_index_set = 1;
10924 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10925 sw_if_index_set = 1;
10926 else if (unformat (i, "maxint %d", &max_interval))
10928 else if (unformat (i, "minint %d", &min_interval))
10930 else if (unformat (i, "life %d", &lifetime))
10932 else if (unformat (i, "count %d", &initial_count))
10934 else if (unformat (i, "interval %d", &initial_interval))
10936 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10938 else if (unformat (i, "managed"))
10940 else if (unformat (i, "other"))
10942 else if (unformat (i, "ll"))
10944 else if (unformat (i, "send"))
10946 else if (unformat (i, "cease"))
10948 else if (unformat (i, "isno"))
10950 else if (unformat (i, "def"))
10951 default_router = 1;
10954 clib_warning ("parse error '%U'", format_unformat_error, i);
10959 if (sw_if_index_set == 0)
10961 errmsg ("missing interface name or sw_if_index");
10965 /* Construct the API message */
10966 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10968 mp->sw_if_index = ntohl (sw_if_index);
10969 mp->max_interval = ntohl (max_interval);
10970 mp->min_interval = ntohl (min_interval);
10971 mp->lifetime = ntohl (lifetime);
10972 mp->initial_count = ntohl (initial_count);
10973 mp->initial_interval = ntohl (initial_interval);
10974 mp->suppress = suppress;
10975 mp->managed = managed;
10977 mp->ll_option = ll_option;
10978 mp->send_unicast = send_unicast;
10981 mp->default_router = default_router;
10986 /* Wait for a reply, return good/bad news */
10992 api_set_arp_neighbor_limit (vat_main_t * vam)
10994 unformat_input_t *i = vam->input;
10995 vl_api_set_arp_neighbor_limit_t *mp;
11001 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11003 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
11005 else if (unformat (i, "ipv6"))
11009 clib_warning ("parse error '%U'", format_unformat_error, i);
11014 if (limit_set == 0)
11016 errmsg ("missing limit value");
11020 M (SET_ARP_NEIGHBOR_LIMIT, mp);
11022 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
11023 mp->is_ipv6 = is_ipv6;
11031 api_l2_patch_add_del (vat_main_t * vam)
11033 unformat_input_t *i = vam->input;
11034 vl_api_l2_patch_add_del_t *mp;
11035 u32 rx_sw_if_index;
11036 u8 rx_sw_if_index_set = 0;
11037 u32 tx_sw_if_index;
11038 u8 tx_sw_if_index_set = 0;
11042 /* Parse args required to build the message */
11043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11045 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
11046 rx_sw_if_index_set = 1;
11047 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
11048 tx_sw_if_index_set = 1;
11049 else if (unformat (i, "rx"))
11051 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11053 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
11055 rx_sw_if_index_set = 1;
11060 else if (unformat (i, "tx"))
11062 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11064 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
11066 tx_sw_if_index_set = 1;
11071 else if (unformat (i, "del"))
11077 if (rx_sw_if_index_set == 0)
11079 errmsg ("missing rx interface name or rx_sw_if_index");
11083 if (tx_sw_if_index_set == 0)
11085 errmsg ("missing tx interface name or tx_sw_if_index");
11089 M (L2_PATCH_ADD_DEL, mp);
11091 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
11092 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
11093 mp->is_add = is_add;
11101 u8 localsid_addr[16];
11110 api_sr_localsid_add_del (vat_main_t * vam)
11112 unformat_input_t *i = vam->input;
11113 vl_api_sr_localsid_add_del_t *mp;
11116 ip6_address_t localsid;
11120 u32 fib_table = ~(u32) 0;
11121 ip6_address_t nh_addr6;
11122 ip4_address_t nh_addr4;
11123 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
11124 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
11126 bool nexthop_set = 0;
11130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11132 if (unformat (i, "del"))
11134 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
11135 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
11137 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
11139 else if (unformat (i, "behavior %u", &behavior));
11140 else if (unformat (i, "sw_if_index %u", &sw_if_index));
11141 else if (unformat (i, "fib-table %u", &fib_table));
11142 else if (unformat (i, "end.psp %u", &behavior));
11147 M (SR_LOCALSID_ADD_DEL, mp);
11149 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
11152 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
11153 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
11155 mp->behavior = behavior;
11156 mp->sw_if_index = ntohl (sw_if_index);
11157 mp->fib_table = ntohl (fib_table);
11158 mp->end_psp = end_psp;
11159 mp->is_del = is_del;
11167 api_ioam_enable (vat_main_t * vam)
11169 unformat_input_t *input = vam->input;
11170 vl_api_ioam_enable_t *mp;
11172 int has_trace_option = 0;
11173 int has_pot_option = 0;
11174 int has_seqno_option = 0;
11175 int has_analyse_option = 0;
11178 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11180 if (unformat (input, "trace"))
11181 has_trace_option = 1;
11182 else if (unformat (input, "pot"))
11183 has_pot_option = 1;
11184 else if (unformat (input, "seqno"))
11185 has_seqno_option = 1;
11186 else if (unformat (input, "analyse"))
11187 has_analyse_option = 1;
11191 M (IOAM_ENABLE, mp);
11192 mp->id = htons (id);
11193 mp->seqno = has_seqno_option;
11194 mp->analyse = has_analyse_option;
11195 mp->pot_enable = has_pot_option;
11196 mp->trace_enable = has_trace_option;
11205 api_ioam_disable (vat_main_t * vam)
11207 vl_api_ioam_disable_t *mp;
11210 M (IOAM_DISABLE, mp);
11216 #define foreach_tcp_proto_field \
11220 #define foreach_udp_proto_field \
11224 #define foreach_ip4_proto_field \
11236 u16 src_port, dst_port;
11239 #if VPP_API_TEST_BUILTIN == 0
11241 unformat_tcp_mask (unformat_input_t * input, va_list * args)
11243 u8 **maskp = va_arg (*args, u8 **);
11245 u8 found_something = 0;
11248 #define _(a) u8 a=0;
11249 foreach_tcp_proto_field;
11252 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11255 #define _(a) else if (unformat (input, #a)) a=1;
11256 foreach_tcp_proto_field
11262 #define _(a) found_something += a;
11263 foreach_tcp_proto_field;
11266 if (found_something == 0)
11269 vec_validate (mask, sizeof (*tcp) - 1);
11271 tcp = (tcp_header_t *) mask;
11273 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
11274 foreach_tcp_proto_field;
11282 unformat_udp_mask (unformat_input_t * input, va_list * args)
11284 u8 **maskp = va_arg (*args, u8 **);
11286 u8 found_something = 0;
11289 #define _(a) u8 a=0;
11290 foreach_udp_proto_field;
11293 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11296 #define _(a) else if (unformat (input, #a)) a=1;
11297 foreach_udp_proto_field
11303 #define _(a) found_something += a;
11304 foreach_udp_proto_field;
11307 if (found_something == 0)
11310 vec_validate (mask, sizeof (*udp) - 1);
11312 udp = (udp_header_t *) mask;
11314 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
11315 foreach_udp_proto_field;
11323 unformat_l4_mask (unformat_input_t * input, va_list * args)
11325 u8 **maskp = va_arg (*args, u8 **);
11326 u16 src_port = 0, dst_port = 0;
11327 tcpudp_header_t *tcpudp;
11329 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11331 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
11333 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
11335 else if (unformat (input, "src_port"))
11337 else if (unformat (input, "dst_port"))
11343 if (!src_port && !dst_port)
11347 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
11349 tcpudp = (tcpudp_header_t *) mask;
11350 tcpudp->src_port = src_port;
11351 tcpudp->dst_port = dst_port;
11359 unformat_ip4_mask (unformat_input_t * input, va_list * args)
11361 u8 **maskp = va_arg (*args, u8 **);
11363 u8 found_something = 0;
11366 #define _(a) u8 a=0;
11367 foreach_ip4_proto_field;
11373 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11375 if (unformat (input, "version"))
11377 else if (unformat (input, "hdr_length"))
11379 else if (unformat (input, "src"))
11381 else if (unformat (input, "dst"))
11383 else if (unformat (input, "proto"))
11386 #define _(a) else if (unformat (input, #a)) a=1;
11387 foreach_ip4_proto_field
11393 #define _(a) found_something += a;
11394 foreach_ip4_proto_field;
11397 if (found_something == 0)
11400 vec_validate (mask, sizeof (*ip) - 1);
11402 ip = (ip4_header_t *) mask;
11404 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
11405 foreach_ip4_proto_field;
11408 ip->ip_version_and_header_length = 0;
11411 ip->ip_version_and_header_length |= 0xF0;
11414 ip->ip_version_and_header_length |= 0x0F;
11420 #define foreach_ip6_proto_field \
11423 _(payload_length) \
11428 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11430 u8 **maskp = va_arg (*args, u8 **);
11432 u8 found_something = 0;
11434 u32 ip_version_traffic_class_and_flow_label;
11436 #define _(a) u8 a=0;
11437 foreach_ip6_proto_field;
11440 u8 traffic_class = 0;
11443 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11445 if (unformat (input, "version"))
11447 else if (unformat (input, "traffic-class"))
11449 else if (unformat (input, "flow-label"))
11451 else if (unformat (input, "src"))
11453 else if (unformat (input, "dst"))
11455 else if (unformat (input, "proto"))
11458 #define _(a) else if (unformat (input, #a)) a=1;
11459 foreach_ip6_proto_field
11465 #define _(a) found_something += a;
11466 foreach_ip6_proto_field;
11469 if (found_something == 0)
11472 vec_validate (mask, sizeof (*ip) - 1);
11474 ip = (ip6_header_t *) mask;
11476 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
11477 foreach_ip6_proto_field;
11480 ip_version_traffic_class_and_flow_label = 0;
11483 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11486 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11489 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11491 ip->ip_version_traffic_class_and_flow_label =
11492 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11499 unformat_l3_mask (unformat_input_t * input, va_list * args)
11501 u8 **maskp = va_arg (*args, u8 **);
11503 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11505 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11507 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11516 unformat_l2_mask (unformat_input_t * input, va_list * args)
11518 u8 **maskp = va_arg (*args, u8 **);
11525 u8 ignore_tag1 = 0;
11526 u8 ignore_tag2 = 0;
11533 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11535 if (unformat (input, "src"))
11537 else if (unformat (input, "dst"))
11539 else if (unformat (input, "proto"))
11541 else if (unformat (input, "tag1"))
11543 else if (unformat (input, "tag2"))
11545 else if (unformat (input, "ignore-tag1"))
11547 else if (unformat (input, "ignore-tag2"))
11549 else if (unformat (input, "cos1"))
11551 else if (unformat (input, "cos2"))
11553 else if (unformat (input, "dot1q"))
11555 else if (unformat (input, "dot1ad"))
11560 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11561 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11564 if (tag1 || ignore_tag1 || cos1 || dot1q)
11566 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11569 vec_validate (mask, len - 1);
11572 clib_memset (mask, 0xff, 6);
11575 clib_memset (mask + 6, 0xff, 6);
11577 if (tag2 || dot1ad)
11579 /* inner vlan tag */
11588 mask[21] = mask[20] = 0xff;
11609 mask[16] = mask[17] = 0xff;
11619 mask[12] = mask[13] = 0xff;
11626 unformat_classify_mask (unformat_input_t * input, va_list * args)
11628 u8 **maskp = va_arg (*args, u8 **);
11629 u32 *skipp = va_arg (*args, u32 *);
11630 u32 *matchp = va_arg (*args, u32 *);
11638 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11640 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11642 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11644 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11646 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11660 if (mask || l2 || l3 || l4)
11662 if (l2 || l3 || l4)
11664 /* "With a free Ethernet header in every package" */
11666 vec_validate (l2, 13);
11670 vec_append (mask, l3);
11675 vec_append (mask, l4);
11680 /* Scan forward looking for the first significant mask octet */
11681 for (i = 0; i < vec_len (mask); i++)
11685 /* compute (skip, match) params */
11686 *skipp = i / sizeof (u32x4);
11687 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11689 /* Pad mask to an even multiple of the vector size */
11690 while (vec_len (mask) % sizeof (u32x4))
11691 vec_add1 (mask, 0);
11693 match = vec_len (mask) / sizeof (u32x4);
11695 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11697 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11698 if (*tmp || *(tmp + 1))
11703 clib_warning ("BUG: match 0");
11705 _vec_len (mask) = match * sizeof (u32x4);
11715 #endif /* VPP_API_TEST_BUILTIN */
11717 #define foreach_l2_next \
11719 _(ethernet, ETHERNET_INPUT) \
11720 _(ip4, IP4_INPUT) \
11724 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11726 u32 *miss_next_indexp = va_arg (*args, u32 *);
11727 u32 next_index = 0;
11731 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11735 if (unformat (input, "%d", &tmp))
11744 *miss_next_indexp = next_index;
11748 #define foreach_ip_next \
11751 _(rewrite, REWRITE)
11754 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11756 u32 *miss_next_indexp = va_arg (*args, u32 *);
11757 u32 next_index = 0;
11761 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11765 if (unformat (input, "%d", &tmp))
11774 *miss_next_indexp = next_index;
11778 #define foreach_acl_next \
11782 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11784 u32 *miss_next_indexp = va_arg (*args, u32 *);
11785 u32 next_index = 0;
11789 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11793 if (unformat (input, "permit"))
11798 else if (unformat (input, "%d", &tmp))
11807 *miss_next_indexp = next_index;
11812 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11814 u32 *r = va_arg (*args, u32 *);
11816 if (unformat (input, "conform-color"))
11817 *r = POLICE_CONFORM;
11818 else if (unformat (input, "exceed-color"))
11819 *r = POLICE_EXCEED;
11827 api_classify_add_del_table (vat_main_t * vam)
11829 unformat_input_t *i = vam->input;
11830 vl_api_classify_add_del_table_t *mp;
11837 u32 table_index = ~0;
11838 u32 next_table_index = ~0;
11839 u32 miss_next_index = ~0;
11840 u32 memory_size = 32 << 20;
11842 u32 current_data_flag = 0;
11843 int current_data_offset = 0;
11846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11848 if (unformat (i, "del"))
11850 else if (unformat (i, "del-chain"))
11855 else if (unformat (i, "buckets %d", &nbuckets))
11857 else if (unformat (i, "memory_size %d", &memory_size))
11859 else if (unformat (i, "skip %d", &skip))
11861 else if (unformat (i, "match %d", &match))
11863 else if (unformat (i, "table %d", &table_index))
11865 else if (unformat (i, "mask %U", unformat_classify_mask,
11866 &mask, &skip, &match))
11868 else if (unformat (i, "next-table %d", &next_table_index))
11870 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11873 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11876 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11879 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11881 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11887 if (is_add && mask == 0)
11889 errmsg ("Mask required");
11893 if (is_add && skip == ~0)
11895 errmsg ("skip count required");
11899 if (is_add && match == ~0)
11901 errmsg ("match count required");
11905 if (!is_add && table_index == ~0)
11907 errmsg ("table index required for delete");
11911 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11913 mp->is_add = is_add;
11914 mp->del_chain = del_chain;
11915 mp->table_index = ntohl (table_index);
11916 mp->nbuckets = ntohl (nbuckets);
11917 mp->memory_size = ntohl (memory_size);
11918 mp->skip_n_vectors = ntohl (skip);
11919 mp->match_n_vectors = ntohl (match);
11920 mp->next_table_index = ntohl (next_table_index);
11921 mp->miss_next_index = ntohl (miss_next_index);
11922 mp->current_data_flag = ntohl (current_data_flag);
11923 mp->current_data_offset = ntohl (current_data_offset);
11924 mp->mask_len = ntohl (vec_len (mask));
11925 clib_memcpy (mp->mask, mask, vec_len (mask));
11934 #if VPP_API_TEST_BUILTIN == 0
11936 unformat_l4_match (unformat_input_t * input, va_list * args)
11938 u8 **matchp = va_arg (*args, u8 **);
11940 u8 *proto_header = 0;
11946 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11948 if (unformat (input, "src_port %d", &src_port))
11950 else if (unformat (input, "dst_port %d", &dst_port))
11956 h.src_port = clib_host_to_net_u16 (src_port);
11957 h.dst_port = clib_host_to_net_u16 (dst_port);
11958 vec_validate (proto_header, sizeof (h) - 1);
11959 memcpy (proto_header, &h, sizeof (h));
11961 *matchp = proto_header;
11967 unformat_ip4_match (unformat_input_t * input, va_list * args)
11969 u8 **matchp = va_arg (*args, u8 **);
11974 int hdr_length = 0;
11975 u32 hdr_length_val;
11976 int src = 0, dst = 0;
11977 ip4_address_t src_val, dst_val;
11984 int fragment_id = 0;
11985 u32 fragment_id_val;
11991 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11993 if (unformat (input, "version %d", &version_val))
11995 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11997 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11999 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
12001 else if (unformat (input, "proto %d", &proto_val))
12003 else if (unformat (input, "tos %d", &tos_val))
12005 else if (unformat (input, "length %d", &length_val))
12007 else if (unformat (input, "fragment_id %d", &fragment_id_val))
12009 else if (unformat (input, "ttl %d", &ttl_val))
12011 else if (unformat (input, "checksum %d", &checksum_val))
12017 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
12018 + ttl + checksum == 0)
12022 * Aligned because we use the real comparison functions
12024 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12026 ip = (ip4_header_t *) match;
12028 /* These are realistically matched in practice */
12030 ip->src_address.as_u32 = src_val.as_u32;
12033 ip->dst_address.as_u32 = dst_val.as_u32;
12036 ip->protocol = proto_val;
12039 /* These are not, but they're included for completeness */
12041 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
12044 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
12050 ip->length = clib_host_to_net_u16 (length_val);
12056 ip->checksum = clib_host_to_net_u16 (checksum_val);
12063 unformat_ip6_match (unformat_input_t * input, va_list * args)
12065 u8 **matchp = va_arg (*args, u8 **);
12070 u8 traffic_class = 0;
12071 u32 traffic_class_val = 0;
12074 int src = 0, dst = 0;
12075 ip6_address_t src_val, dst_val;
12078 int payload_length = 0;
12079 u32 payload_length_val;
12082 u32 ip_version_traffic_class_and_flow_label;
12084 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12086 if (unformat (input, "version %d", &version_val))
12088 else if (unformat (input, "traffic_class %d", &traffic_class_val))
12090 else if (unformat (input, "flow_label %d", &flow_label_val))
12092 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
12094 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
12096 else if (unformat (input, "proto %d", &proto_val))
12098 else if (unformat (input, "payload_length %d", &payload_length_val))
12099 payload_length = 1;
12100 else if (unformat (input, "hop_limit %d", &hop_limit_val))
12106 if (version + traffic_class + flow_label + src + dst + proto +
12107 payload_length + hop_limit == 0)
12111 * Aligned because we use the real comparison functions
12113 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
12115 ip = (ip6_header_t *) match;
12118 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
12121 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
12124 ip->protocol = proto_val;
12126 ip_version_traffic_class_and_flow_label = 0;
12129 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
12132 ip_version_traffic_class_and_flow_label |=
12133 (traffic_class_val & 0xFF) << 20;
12136 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
12138 ip->ip_version_traffic_class_and_flow_label =
12139 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
12141 if (payload_length)
12142 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
12145 ip->hop_limit = hop_limit_val;
12152 unformat_l3_match (unformat_input_t * input, va_list * args)
12154 u8 **matchp = va_arg (*args, u8 **);
12156 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12158 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
12160 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
12169 unformat_vlan_tag (unformat_input_t * input, va_list * args)
12171 u8 *tagp = va_arg (*args, u8 *);
12174 if (unformat (input, "%d", &tag))
12176 tagp[0] = (tag >> 8) & 0x0F;
12177 tagp[1] = tag & 0xFF;
12185 unformat_l2_match (unformat_input_t * input, va_list * args)
12187 u8 **matchp = va_arg (*args, u8 **);
12200 u8 ignore_tag1 = 0;
12201 u8 ignore_tag2 = 0;
12207 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12209 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
12212 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
12214 else if (unformat (input, "proto %U",
12215 unformat_ethernet_type_host_byte_order, &proto_val))
12217 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
12219 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
12221 else if (unformat (input, "ignore-tag1"))
12223 else if (unformat (input, "ignore-tag2"))
12225 else if (unformat (input, "cos1 %d", &cos1_val))
12227 else if (unformat (input, "cos2 %d", &cos2_val))
12232 if ((src + dst + proto + tag1 + tag2 +
12233 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
12236 if (tag1 || ignore_tag1 || cos1)
12238 if (tag2 || ignore_tag2 || cos2)
12241 vec_validate_aligned (match, len - 1, sizeof (u32x4));
12244 clib_memcpy (match, dst_val, 6);
12247 clib_memcpy (match + 6, src_val, 6);
12251 /* inner vlan tag */
12252 match[19] = tag2_val[1];
12253 match[18] = tag2_val[0];
12255 match[18] |= (cos2_val & 0x7) << 5;
12258 match[21] = proto_val & 0xff;
12259 match[20] = proto_val >> 8;
12263 match[15] = tag1_val[1];
12264 match[14] = tag1_val[0];
12267 match[14] |= (cos1_val & 0x7) << 5;
12273 match[15] = tag1_val[1];
12274 match[14] = tag1_val[0];
12277 match[17] = proto_val & 0xff;
12278 match[16] = proto_val >> 8;
12281 match[14] |= (cos1_val & 0x7) << 5;
12287 match[18] |= (cos2_val & 0x7) << 5;
12289 match[14] |= (cos1_val & 0x7) << 5;
12292 match[13] = proto_val & 0xff;
12293 match[12] = proto_val >> 8;
12301 unformat_qos_source (unformat_input_t * input, va_list * args)
12303 int *qs = va_arg (*args, int *);
12305 if (unformat (input, "ip"))
12306 *qs = QOS_SOURCE_IP;
12307 else if (unformat (input, "mpls"))
12308 *qs = QOS_SOURCE_MPLS;
12309 else if (unformat (input, "ext"))
12310 *qs = QOS_SOURCE_EXT;
12311 else if (unformat (input, "vlan"))
12312 *qs = QOS_SOURCE_VLAN;
12321 api_unformat_classify_match (unformat_input_t * input, va_list * args)
12323 u8 **matchp = va_arg (*args, u8 **);
12324 u32 skip_n_vectors = va_arg (*args, u32);
12325 u32 match_n_vectors = va_arg (*args, u32);
12332 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12334 if (unformat (input, "hex %U", unformat_hex_string, &match))
12336 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
12338 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
12340 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
12354 if (match || l2 || l3 || l4)
12356 if (l2 || l3 || l4)
12358 /* "Win a free Ethernet header in every packet" */
12360 vec_validate_aligned (l2, 13, sizeof (u32x4));
12364 vec_append_aligned (match, l3, sizeof (u32x4));
12369 vec_append_aligned (match, l4, sizeof (u32x4));
12374 /* Make sure the vector is big enough even if key is all 0's */
12375 vec_validate_aligned
12376 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12379 /* Set size, include skipped vectors */
12380 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12391 api_classify_add_del_session (vat_main_t * vam)
12393 unformat_input_t *i = vam->input;
12394 vl_api_classify_add_del_session_t *mp;
12396 u32 table_index = ~0;
12397 u32 hit_next_index = ~0;
12398 u32 opaque_index = ~0;
12401 u32 skip_n_vectors = 0;
12402 u32 match_n_vectors = 0;
12408 * Warning: you have to supply skip_n and match_n
12409 * because the API client cant simply look at the classify
12413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12415 if (unformat (i, "del"))
12417 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12420 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12423 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12426 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12428 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12430 else if (unformat (i, "opaque-index %d", &opaque_index))
12432 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12434 else if (unformat (i, "match_n %d", &match_n_vectors))
12436 else if (unformat (i, "match %U", api_unformat_classify_match,
12437 &match, skip_n_vectors, match_n_vectors))
12439 else if (unformat (i, "advance %d", &advance))
12441 else if (unformat (i, "table-index %d", &table_index))
12443 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12445 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12447 else if (unformat (i, "action %d", &action))
12449 else if (unformat (i, "metadata %d", &metadata))
12455 if (table_index == ~0)
12457 errmsg ("Table index required");
12461 if (is_add && match == 0)
12463 errmsg ("Match value required");
12467 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12469 mp->is_add = is_add;
12470 mp->table_index = ntohl (table_index);
12471 mp->hit_next_index = ntohl (hit_next_index);
12472 mp->opaque_index = ntohl (opaque_index);
12473 mp->advance = ntohl (advance);
12474 mp->action = action;
12475 mp->metadata = ntohl (metadata);
12476 mp->match_len = ntohl (vec_len (match));
12477 clib_memcpy (mp->match, match, vec_len (match));
12486 api_classify_set_interface_ip_table (vat_main_t * vam)
12488 unformat_input_t *i = vam->input;
12489 vl_api_classify_set_interface_ip_table_t *mp;
12491 int sw_if_index_set;
12492 u32 table_index = ~0;
12496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12498 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12499 sw_if_index_set = 1;
12500 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12501 sw_if_index_set = 1;
12502 else if (unformat (i, "table %d", &table_index))
12506 clib_warning ("parse error '%U'", format_unformat_error, i);
12511 if (sw_if_index_set == 0)
12513 errmsg ("missing interface name or sw_if_index");
12518 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12520 mp->sw_if_index = ntohl (sw_if_index);
12521 mp->table_index = ntohl (table_index);
12522 mp->is_ipv6 = is_ipv6;
12530 api_classify_set_interface_l2_tables (vat_main_t * vam)
12532 unformat_input_t *i = vam->input;
12533 vl_api_classify_set_interface_l2_tables_t *mp;
12535 int sw_if_index_set;
12536 u32 ip4_table_index = ~0;
12537 u32 ip6_table_index = ~0;
12538 u32 other_table_index = ~0;
12542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12544 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12545 sw_if_index_set = 1;
12546 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12547 sw_if_index_set = 1;
12548 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12550 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12552 else if (unformat (i, "other-table %d", &other_table_index))
12554 else if (unformat (i, "is-input %d", &is_input))
12558 clib_warning ("parse error '%U'", format_unformat_error, i);
12563 if (sw_if_index_set == 0)
12565 errmsg ("missing interface name or sw_if_index");
12570 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12572 mp->sw_if_index = ntohl (sw_if_index);
12573 mp->ip4_table_index = ntohl (ip4_table_index);
12574 mp->ip6_table_index = ntohl (ip6_table_index);
12575 mp->other_table_index = ntohl (other_table_index);
12576 mp->is_input = (u8) is_input;
12584 api_set_ipfix_exporter (vat_main_t * vam)
12586 unformat_input_t *i = vam->input;
12587 vl_api_set_ipfix_exporter_t *mp;
12588 ip4_address_t collector_address;
12589 u8 collector_address_set = 0;
12590 u32 collector_port = ~0;
12591 ip4_address_t src_address;
12592 u8 src_address_set = 0;
12595 u32 template_interval = ~0;
12596 u8 udp_checksum = 0;
12599 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12601 if (unformat (i, "collector_address %U", unformat_ip4_address,
12602 &collector_address))
12603 collector_address_set = 1;
12604 else if (unformat (i, "collector_port %d", &collector_port))
12606 else if (unformat (i, "src_address %U", unformat_ip4_address,
12608 src_address_set = 1;
12609 else if (unformat (i, "vrf_id %d", &vrf_id))
12611 else if (unformat (i, "path_mtu %d", &path_mtu))
12613 else if (unformat (i, "template_interval %d", &template_interval))
12615 else if (unformat (i, "udp_checksum"))
12621 if (collector_address_set == 0)
12623 errmsg ("collector_address required");
12627 if (src_address_set == 0)
12629 errmsg ("src_address required");
12633 M (SET_IPFIX_EXPORTER, mp);
12635 memcpy (mp->collector_address, collector_address.data,
12636 sizeof (collector_address.data));
12637 mp->collector_port = htons ((u16) collector_port);
12638 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12639 mp->vrf_id = htonl (vrf_id);
12640 mp->path_mtu = htonl (path_mtu);
12641 mp->template_interval = htonl (template_interval);
12642 mp->udp_checksum = udp_checksum;
12650 api_set_ipfix_classify_stream (vat_main_t * vam)
12652 unformat_input_t *i = vam->input;
12653 vl_api_set_ipfix_classify_stream_t *mp;
12655 u32 src_port = UDP_DST_PORT_ipfix;
12658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12660 if (unformat (i, "domain %d", &domain_id))
12662 else if (unformat (i, "src_port %d", &src_port))
12666 errmsg ("unknown input `%U'", format_unformat_error, i);
12671 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12673 mp->domain_id = htonl (domain_id);
12674 mp->src_port = htons ((u16) src_port);
12682 api_ipfix_classify_table_add_del (vat_main_t * vam)
12684 unformat_input_t *i = vam->input;
12685 vl_api_ipfix_classify_table_add_del_t *mp;
12687 u32 classify_table_index = ~0;
12689 u8 transport_protocol = 255;
12692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12694 if (unformat (i, "add"))
12696 else if (unformat (i, "del"))
12698 else if (unformat (i, "table %d", &classify_table_index))
12700 else if (unformat (i, "ip4"))
12702 else if (unformat (i, "ip6"))
12704 else if (unformat (i, "tcp"))
12705 transport_protocol = 6;
12706 else if (unformat (i, "udp"))
12707 transport_protocol = 17;
12710 errmsg ("unknown input `%U'", format_unformat_error, i);
12717 errmsg ("expecting: add|del");
12720 if (classify_table_index == ~0)
12722 errmsg ("classifier table not specified");
12725 if (ip_version == 0)
12727 errmsg ("IP version not specified");
12731 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12733 mp->is_add = is_add;
12734 mp->table_id = htonl (classify_table_index);
12735 mp->ip_version = ip_version;
12736 mp->transport_protocol = transport_protocol;
12744 api_get_node_index (vat_main_t * vam)
12746 unformat_input_t *i = vam->input;
12747 vl_api_get_node_index_t *mp;
12751 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12753 if (unformat (i, "node %s", &name))
12760 errmsg ("node name required");
12763 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12765 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12769 M (GET_NODE_INDEX, mp);
12770 clib_memcpy (mp->node_name, name, vec_len (name));
12779 api_get_next_index (vat_main_t * vam)
12781 unformat_input_t *i = vam->input;
12782 vl_api_get_next_index_t *mp;
12783 u8 *node_name = 0, *next_node_name = 0;
12786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12788 if (unformat (i, "node-name %s", &node_name))
12790 else if (unformat (i, "next-node-name %s", &next_node_name))
12794 if (node_name == 0)
12796 errmsg ("node name required");
12799 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12801 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12805 if (next_node_name == 0)
12807 errmsg ("next node name required");
12810 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12812 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12816 M (GET_NEXT_INDEX, mp);
12817 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12818 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12819 vec_free (node_name);
12820 vec_free (next_node_name);
12828 api_add_node_next (vat_main_t * vam)
12830 unformat_input_t *i = vam->input;
12831 vl_api_add_node_next_t *mp;
12836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12838 if (unformat (i, "node %s", &name))
12840 else if (unformat (i, "next %s", &next))
12847 errmsg ("node name required");
12850 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12852 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12857 errmsg ("next node required");
12860 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12862 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12866 M (ADD_NODE_NEXT, mp);
12867 clib_memcpy (mp->node_name, name, vec_len (name));
12868 clib_memcpy (mp->next_name, next, vec_len (next));
12878 api_l2tpv3_create_tunnel (vat_main_t * vam)
12880 unformat_input_t *i = vam->input;
12881 ip6_address_t client_address, our_address;
12882 int client_address_set = 0;
12883 int our_address_set = 0;
12884 u32 local_session_id = 0;
12885 u32 remote_session_id = 0;
12886 u64 local_cookie = 0;
12887 u64 remote_cookie = 0;
12888 u8 l2_sublayer_present = 0;
12889 vl_api_l2tpv3_create_tunnel_t *mp;
12892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12894 if (unformat (i, "client_address %U", unformat_ip6_address,
12896 client_address_set = 1;
12897 else if (unformat (i, "our_address %U", unformat_ip6_address,
12899 our_address_set = 1;
12900 else if (unformat (i, "local_session_id %d", &local_session_id))
12902 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12904 else if (unformat (i, "local_cookie %lld", &local_cookie))
12906 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12908 else if (unformat (i, "l2-sublayer-present"))
12909 l2_sublayer_present = 1;
12914 if (client_address_set == 0)
12916 errmsg ("client_address required");
12920 if (our_address_set == 0)
12922 errmsg ("our_address required");
12926 M (L2TPV3_CREATE_TUNNEL, mp);
12928 clib_memcpy (mp->client_address, client_address.as_u8,
12929 sizeof (mp->client_address));
12931 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12933 mp->local_session_id = ntohl (local_session_id);
12934 mp->remote_session_id = ntohl (remote_session_id);
12935 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12936 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12937 mp->l2_sublayer_present = l2_sublayer_present;
12946 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12948 unformat_input_t *i = vam->input;
12950 u8 sw_if_index_set = 0;
12951 u64 new_local_cookie = 0;
12952 u64 new_remote_cookie = 0;
12953 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12958 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12959 sw_if_index_set = 1;
12960 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12961 sw_if_index_set = 1;
12962 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12964 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12970 if (sw_if_index_set == 0)
12972 errmsg ("missing interface name or sw_if_index");
12976 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12978 mp->sw_if_index = ntohl (sw_if_index);
12979 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12980 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12988 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12990 unformat_input_t *i = vam->input;
12991 vl_api_l2tpv3_interface_enable_disable_t *mp;
12993 u8 sw_if_index_set = 0;
12994 u8 enable_disable = 1;
12997 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12999 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13000 sw_if_index_set = 1;
13001 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13002 sw_if_index_set = 1;
13003 else if (unformat (i, "enable"))
13004 enable_disable = 1;
13005 else if (unformat (i, "disable"))
13006 enable_disable = 0;
13011 if (sw_if_index_set == 0)
13013 errmsg ("missing interface name or sw_if_index");
13017 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
13019 mp->sw_if_index = ntohl (sw_if_index);
13020 mp->enable_disable = enable_disable;
13028 api_l2tpv3_set_lookup_key (vat_main_t * vam)
13030 unformat_input_t *i = vam->input;
13031 vl_api_l2tpv3_set_lookup_key_t *mp;
13035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13037 if (unformat (i, "lookup_v6_src"))
13038 key = L2T_LOOKUP_SRC_ADDRESS;
13039 else if (unformat (i, "lookup_v6_dst"))
13040 key = L2T_LOOKUP_DST_ADDRESS;
13041 else if (unformat (i, "lookup_session_id"))
13042 key = L2T_LOOKUP_SESSION_ID;
13047 if (key == (u8) ~ 0)
13049 errmsg ("l2tp session lookup key unset");
13053 M (L2TPV3_SET_LOOKUP_KEY, mp);
13062 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
13063 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13065 vat_main_t *vam = &vat_main;
13067 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
13068 format_ip6_address, mp->our_address,
13069 format_ip6_address, mp->client_address,
13070 clib_net_to_host_u32 (mp->sw_if_index));
13073 " local cookies %016llx %016llx remote cookie %016llx",
13074 clib_net_to_host_u64 (mp->local_cookie[0]),
13075 clib_net_to_host_u64 (mp->local_cookie[1]),
13076 clib_net_to_host_u64 (mp->remote_cookie));
13078 print (vam->ofp, " local session-id %d remote session-id %d",
13079 clib_net_to_host_u32 (mp->local_session_id),
13080 clib_net_to_host_u32 (mp->remote_session_id));
13082 print (vam->ofp, " l2 specific sublayer %s\n",
13083 mp->l2_sublayer_present ? "preset" : "absent");
13087 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
13088 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
13090 vat_main_t *vam = &vat_main;
13091 vat_json_node_t *node = NULL;
13092 struct in6_addr addr;
13094 if (VAT_JSON_ARRAY != vam->json_tree.type)
13096 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13097 vat_json_init_array (&vam->json_tree);
13099 node = vat_json_array_add (&vam->json_tree);
13101 vat_json_init_object (node);
13103 clib_memcpy (&addr, mp->our_address, sizeof (addr));
13104 vat_json_object_add_ip6 (node, "our_address", addr);
13105 clib_memcpy (&addr, mp->client_address, sizeof (addr));
13106 vat_json_object_add_ip6 (node, "client_address", addr);
13108 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
13109 vat_json_init_array (lc);
13110 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
13111 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
13112 vat_json_object_add_uint (node, "remote_cookie",
13113 clib_net_to_host_u64 (mp->remote_cookie));
13115 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
13116 vat_json_object_add_uint (node, "local_session_id",
13117 clib_net_to_host_u32 (mp->local_session_id));
13118 vat_json_object_add_uint (node, "remote_session_id",
13119 clib_net_to_host_u32 (mp->remote_session_id));
13120 vat_json_object_add_string_copy (node, "l2_sublayer",
13121 mp->l2_sublayer_present ? (u8 *) "present"
13122 : (u8 *) "absent");
13126 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
13128 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
13129 vl_api_control_ping_t *mp_ping;
13132 /* Get list of l2tpv3-tunnel interfaces */
13133 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
13136 /* Use a control ping for synchronization */
13137 MPING (CONTROL_PING, mp_ping);
13145 static void vl_api_sw_interface_tap_details_t_handler
13146 (vl_api_sw_interface_tap_details_t * mp)
13148 vat_main_t *vam = &vat_main;
13150 print (vam->ofp, "%-16s %d",
13151 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
13154 static void vl_api_sw_interface_tap_details_t_handler_json
13155 (vl_api_sw_interface_tap_details_t * mp)
13157 vat_main_t *vam = &vat_main;
13158 vat_json_node_t *node = NULL;
13160 if (VAT_JSON_ARRAY != vam->json_tree.type)
13162 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13163 vat_json_init_array (&vam->json_tree);
13165 node = vat_json_array_add (&vam->json_tree);
13167 vat_json_init_object (node);
13168 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13169 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13173 api_sw_interface_tap_dump (vat_main_t * vam)
13175 vl_api_sw_interface_tap_dump_t *mp;
13176 vl_api_control_ping_t *mp_ping;
13179 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
13180 /* Get list of tap interfaces */
13181 M (SW_INTERFACE_TAP_DUMP, mp);
13184 /* Use a control ping for synchronization */
13185 MPING (CONTROL_PING, mp_ping);
13192 static void vl_api_sw_interface_tap_v2_details_t_handler
13193 (vl_api_sw_interface_tap_v2_details_t * mp)
13195 vat_main_t *vam = &vat_main;
13197 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
13198 mp->host_ip4_prefix_len);
13199 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
13200 mp->host_ip6_prefix_len);
13203 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
13204 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
13205 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
13206 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
13207 mp->host_bridge, ip4, ip6);
13213 static void vl_api_sw_interface_tap_v2_details_t_handler_json
13214 (vl_api_sw_interface_tap_v2_details_t * mp)
13216 vat_main_t *vam = &vat_main;
13217 vat_json_node_t *node = NULL;
13219 if (VAT_JSON_ARRAY != vam->json_tree.type)
13221 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13222 vat_json_init_array (&vam->json_tree);
13224 node = vat_json_array_add (&vam->json_tree);
13226 vat_json_init_object (node);
13227 vat_json_object_add_uint (node, "id", ntohl (mp->id));
13228 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13229 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
13230 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
13231 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
13232 vat_json_object_add_string_copy (node, "host_mac_addr",
13233 format (0, "%U", format_ethernet_address,
13234 &mp->host_mac_addr));
13235 vat_json_object_add_string_copy (node, "host_namespace",
13236 mp->host_namespace);
13237 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
13238 vat_json_object_add_string_copy (node, "host_ip4_addr",
13239 format (0, "%U/%d", format_ip4_address,
13241 mp->host_ip4_prefix_len));
13242 vat_json_object_add_string_copy (node, "host_ip6_addr",
13243 format (0, "%U/%d", format_ip6_address,
13245 mp->host_ip6_prefix_len));
13250 api_sw_interface_tap_v2_dump (vat_main_t * vam)
13252 vl_api_sw_interface_tap_v2_dump_t *mp;
13253 vl_api_control_ping_t *mp_ping;
13257 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
13258 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
13259 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
13262 /* Get list of tap interfaces */
13263 M (SW_INTERFACE_TAP_V2_DUMP, mp);
13266 /* Use a control ping for synchronization */
13267 MPING (CONTROL_PING, mp_ping);
13275 api_vxlan_offload_rx (vat_main_t * vam)
13277 unformat_input_t *line_input = vam->input;
13278 vl_api_vxlan_offload_rx_t *mp;
13279 u32 hw_if_index = ~0, rx_if_index = ~0;
13283 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13285 if (unformat (line_input, "del"))
13287 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
13290 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
13292 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
13295 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
13299 errmsg ("parse error '%U'", format_unformat_error, line_input);
13304 if (hw_if_index == ~0)
13306 errmsg ("no hw interface");
13310 if (rx_if_index == ~0)
13312 errmsg ("no rx tunnel");
13316 M (VXLAN_OFFLOAD_RX, mp);
13318 mp->hw_if_index = ntohl (hw_if_index);
13319 mp->sw_if_index = ntohl (rx_if_index);
13320 mp->enable = is_add;
13327 static uword unformat_vxlan_decap_next
13328 (unformat_input_t * input, va_list * args)
13330 u32 *result = va_arg (*args, u32 *);
13333 if (unformat (input, "l2"))
13334 *result = VXLAN_INPUT_NEXT_L2_INPUT;
13335 else if (unformat (input, "%d", &tmp))
13343 api_vxlan_add_del_tunnel (vat_main_t * vam)
13345 unformat_input_t *line_input = vam->input;
13346 vl_api_vxlan_add_del_tunnel_t *mp;
13347 ip46_address_t src, dst;
13349 u8 ipv4_set = 0, ipv6_set = 0;
13354 u32 mcast_sw_if_index = ~0;
13355 u32 encap_vrf_id = 0;
13356 u32 decap_next_index = ~0;
13360 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13361 clib_memset (&src, 0, sizeof src);
13362 clib_memset (&dst, 0, sizeof dst);
13364 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13366 if (unformat (line_input, "del"))
13368 else if (unformat (line_input, "instance %d", &instance))
13371 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13377 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13383 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13389 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13394 else if (unformat (line_input, "group %U %U",
13395 unformat_ip4_address, &dst.ip4,
13396 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13398 grp_set = dst_set = 1;
13401 else if (unformat (line_input, "group %U",
13402 unformat_ip4_address, &dst.ip4))
13404 grp_set = dst_set = 1;
13407 else if (unformat (line_input, "group %U %U",
13408 unformat_ip6_address, &dst.ip6,
13409 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13411 grp_set = dst_set = 1;
13414 else if (unformat (line_input, "group %U",
13415 unformat_ip6_address, &dst.ip6))
13417 grp_set = dst_set = 1;
13421 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13423 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13425 else if (unformat (line_input, "decap-next %U",
13426 unformat_vxlan_decap_next, &decap_next_index))
13428 else if (unformat (line_input, "vni %d", &vni))
13432 errmsg ("parse error '%U'", format_unformat_error, line_input);
13439 errmsg ("tunnel src address not specified");
13444 errmsg ("tunnel dst address not specified");
13448 if (grp_set && !ip46_address_is_multicast (&dst))
13450 errmsg ("tunnel group address not multicast");
13453 if (grp_set && mcast_sw_if_index == ~0)
13455 errmsg ("tunnel nonexistent multicast device");
13458 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13460 errmsg ("tunnel dst address must be unicast");
13465 if (ipv4_set && ipv6_set)
13467 errmsg ("both IPv4 and IPv6 addresses specified");
13471 if ((vni == 0) || (vni >> 24))
13473 errmsg ("vni not specified or out of range");
13477 M (VXLAN_ADD_DEL_TUNNEL, mp);
13481 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13482 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13486 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13487 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13490 mp->instance = htonl (instance);
13491 mp->encap_vrf_id = ntohl (encap_vrf_id);
13492 mp->decap_next_index = ntohl (decap_next_index);
13493 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13494 mp->vni = ntohl (vni);
13495 mp->is_add = is_add;
13496 mp->is_ipv6 = ipv6_set;
13503 static void vl_api_vxlan_tunnel_details_t_handler
13504 (vl_api_vxlan_tunnel_details_t * mp)
13506 vat_main_t *vam = &vat_main;
13507 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13508 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13510 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13511 ntohl (mp->sw_if_index),
13512 ntohl (mp->instance),
13513 format_ip46_address, &src, IP46_TYPE_ANY,
13514 format_ip46_address, &dst, IP46_TYPE_ANY,
13515 ntohl (mp->encap_vrf_id),
13516 ntohl (mp->decap_next_index), ntohl (mp->vni),
13517 ntohl (mp->mcast_sw_if_index));
13520 static void vl_api_vxlan_tunnel_details_t_handler_json
13521 (vl_api_vxlan_tunnel_details_t * mp)
13523 vat_main_t *vam = &vat_main;
13524 vat_json_node_t *node = NULL;
13526 if (VAT_JSON_ARRAY != vam->json_tree.type)
13528 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13529 vat_json_init_array (&vam->json_tree);
13531 node = vat_json_array_add (&vam->json_tree);
13533 vat_json_init_object (node);
13534 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13536 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13540 struct in6_addr ip6;
13542 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13543 vat_json_object_add_ip6 (node, "src_address", ip6);
13544 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13545 vat_json_object_add_ip6 (node, "dst_address", ip6);
13549 struct in_addr ip4;
13551 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13552 vat_json_object_add_ip4 (node, "src_address", ip4);
13553 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13554 vat_json_object_add_ip4 (node, "dst_address", ip4);
13556 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13557 vat_json_object_add_uint (node, "decap_next_index",
13558 ntohl (mp->decap_next_index));
13559 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13560 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13561 vat_json_object_add_uint (node, "mcast_sw_if_index",
13562 ntohl (mp->mcast_sw_if_index));
13566 api_vxlan_tunnel_dump (vat_main_t * vam)
13568 unformat_input_t *i = vam->input;
13569 vl_api_vxlan_tunnel_dump_t *mp;
13570 vl_api_control_ping_t *mp_ping;
13572 u8 sw_if_index_set = 0;
13575 /* Parse args required to build the message */
13576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13578 if (unformat (i, "sw_if_index %d", &sw_if_index))
13579 sw_if_index_set = 1;
13584 if (sw_if_index_set == 0)
13589 if (!vam->json_output)
13591 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13592 "sw_if_index", "instance", "src_address", "dst_address",
13593 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13596 /* Get list of vxlan-tunnel interfaces */
13597 M (VXLAN_TUNNEL_DUMP, mp);
13599 mp->sw_if_index = htonl (sw_if_index);
13603 /* Use a control ping for synchronization */
13604 MPING (CONTROL_PING, mp_ping);
13611 static uword unformat_geneve_decap_next
13612 (unformat_input_t * input, va_list * args)
13614 u32 *result = va_arg (*args, u32 *);
13617 if (unformat (input, "l2"))
13618 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13619 else if (unformat (input, "%d", &tmp))
13627 api_geneve_add_del_tunnel (vat_main_t * vam)
13629 unformat_input_t *line_input = vam->input;
13630 vl_api_geneve_add_del_tunnel_t *mp;
13631 ip46_address_t src, dst;
13633 u8 ipv4_set = 0, ipv6_set = 0;
13637 u32 mcast_sw_if_index = ~0;
13638 u32 encap_vrf_id = 0;
13639 u32 decap_next_index = ~0;
13643 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13644 clib_memset (&src, 0, sizeof src);
13645 clib_memset (&dst, 0, sizeof dst);
13647 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13649 if (unformat (line_input, "del"))
13652 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13658 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13664 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13670 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13675 else if (unformat (line_input, "group %U %U",
13676 unformat_ip4_address, &dst.ip4,
13677 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13679 grp_set = dst_set = 1;
13682 else if (unformat (line_input, "group %U",
13683 unformat_ip4_address, &dst.ip4))
13685 grp_set = dst_set = 1;
13688 else if (unformat (line_input, "group %U %U",
13689 unformat_ip6_address, &dst.ip6,
13690 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13692 grp_set = dst_set = 1;
13695 else if (unformat (line_input, "group %U",
13696 unformat_ip6_address, &dst.ip6))
13698 grp_set = dst_set = 1;
13702 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13704 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13706 else if (unformat (line_input, "decap-next %U",
13707 unformat_geneve_decap_next, &decap_next_index))
13709 else if (unformat (line_input, "vni %d", &vni))
13713 errmsg ("parse error '%U'", format_unformat_error, line_input);
13720 errmsg ("tunnel src address not specified");
13725 errmsg ("tunnel dst address not specified");
13729 if (grp_set && !ip46_address_is_multicast (&dst))
13731 errmsg ("tunnel group address not multicast");
13734 if (grp_set && mcast_sw_if_index == ~0)
13736 errmsg ("tunnel nonexistent multicast device");
13739 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13741 errmsg ("tunnel dst address must be unicast");
13746 if (ipv4_set && ipv6_set)
13748 errmsg ("both IPv4 and IPv6 addresses specified");
13752 if ((vni == 0) || (vni >> 24))
13754 errmsg ("vni not specified or out of range");
13758 M (GENEVE_ADD_DEL_TUNNEL, mp);
13762 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13763 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13767 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13768 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13770 mp->encap_vrf_id = ntohl (encap_vrf_id);
13771 mp->decap_next_index = ntohl (decap_next_index);
13772 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13773 mp->vni = ntohl (vni);
13774 mp->is_add = is_add;
13775 mp->is_ipv6 = ipv6_set;
13782 static void vl_api_geneve_tunnel_details_t_handler
13783 (vl_api_geneve_tunnel_details_t * mp)
13785 vat_main_t *vam = &vat_main;
13786 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13787 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13789 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13790 ntohl (mp->sw_if_index),
13791 format_ip46_address, &src, IP46_TYPE_ANY,
13792 format_ip46_address, &dst, IP46_TYPE_ANY,
13793 ntohl (mp->encap_vrf_id),
13794 ntohl (mp->decap_next_index), ntohl (mp->vni),
13795 ntohl (mp->mcast_sw_if_index));
13798 static void vl_api_geneve_tunnel_details_t_handler_json
13799 (vl_api_geneve_tunnel_details_t * mp)
13801 vat_main_t *vam = &vat_main;
13802 vat_json_node_t *node = NULL;
13804 if (VAT_JSON_ARRAY != vam->json_tree.type)
13806 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13807 vat_json_init_array (&vam->json_tree);
13809 node = vat_json_array_add (&vam->json_tree);
13811 vat_json_init_object (node);
13812 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13815 struct in6_addr ip6;
13817 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13818 vat_json_object_add_ip6 (node, "src_address", ip6);
13819 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13820 vat_json_object_add_ip6 (node, "dst_address", ip6);
13824 struct in_addr ip4;
13826 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13827 vat_json_object_add_ip4 (node, "src_address", ip4);
13828 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13829 vat_json_object_add_ip4 (node, "dst_address", ip4);
13831 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13832 vat_json_object_add_uint (node, "decap_next_index",
13833 ntohl (mp->decap_next_index));
13834 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13835 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13836 vat_json_object_add_uint (node, "mcast_sw_if_index",
13837 ntohl (mp->mcast_sw_if_index));
13841 api_geneve_tunnel_dump (vat_main_t * vam)
13843 unformat_input_t *i = vam->input;
13844 vl_api_geneve_tunnel_dump_t *mp;
13845 vl_api_control_ping_t *mp_ping;
13847 u8 sw_if_index_set = 0;
13850 /* Parse args required to build the message */
13851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13853 if (unformat (i, "sw_if_index %d", &sw_if_index))
13854 sw_if_index_set = 1;
13859 if (sw_if_index_set == 0)
13864 if (!vam->json_output)
13866 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13867 "sw_if_index", "local_address", "remote_address",
13868 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13871 /* Get list of geneve-tunnel interfaces */
13872 M (GENEVE_TUNNEL_DUMP, mp);
13874 mp->sw_if_index = htonl (sw_if_index);
13878 /* Use a control ping for synchronization */
13879 M (CONTROL_PING, mp_ping);
13887 api_gre_add_del_tunnel (vat_main_t * vam)
13889 unformat_input_t *line_input = vam->input;
13890 vl_api_gre_add_del_tunnel_t *mp;
13891 ip4_address_t src4, dst4;
13892 ip6_address_t src6, dst6;
13896 u8 t_type = GRE_TUNNEL_TYPE_L3;
13899 u32 outer_fib_id = 0;
13900 u32 session_id = 0;
13904 clib_memset (&src4, 0, sizeof src4);
13905 clib_memset (&dst4, 0, sizeof dst4);
13906 clib_memset (&src6, 0, sizeof src6);
13907 clib_memset (&dst6, 0, sizeof dst6);
13909 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13911 if (unformat (line_input, "del"))
13913 else if (unformat (line_input, "instance %d", &instance))
13915 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13920 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13925 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13930 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13935 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13937 else if (unformat (line_input, "teb"))
13938 t_type = GRE_TUNNEL_TYPE_TEB;
13939 else if (unformat (line_input, "erspan %d", &session_id))
13940 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13943 errmsg ("parse error '%U'", format_unformat_error, line_input);
13950 errmsg ("tunnel src address not specified");
13955 errmsg ("tunnel dst address not specified");
13958 if (ipv4_set && ipv6_set)
13960 errmsg ("both IPv4 and IPv6 addresses specified");
13965 M (GRE_ADD_DEL_TUNNEL, mp);
13969 clib_memcpy (&mp->src_address, &src4, 4);
13970 clib_memcpy (&mp->dst_address, &dst4, 4);
13974 clib_memcpy (&mp->src_address, &src6, 16);
13975 clib_memcpy (&mp->dst_address, &dst6, 16);
13977 mp->instance = htonl (instance);
13978 mp->outer_fib_id = htonl (outer_fib_id);
13979 mp->is_add = is_add;
13980 mp->session_id = htons ((u16) session_id);
13981 mp->tunnel_type = t_type;
13982 mp->is_ipv6 = ipv6_set;
13989 static void vl_api_gre_tunnel_details_t_handler
13990 (vl_api_gre_tunnel_details_t * mp)
13992 vat_main_t *vam = &vat_main;
13993 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13994 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13996 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13997 ntohl (mp->sw_if_index),
13998 ntohl (mp->instance),
13999 format_ip46_address, &src, IP46_TYPE_ANY,
14000 format_ip46_address, &dst, IP46_TYPE_ANY,
14001 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
14004 static void vl_api_gre_tunnel_details_t_handler_json
14005 (vl_api_gre_tunnel_details_t * mp)
14007 vat_main_t *vam = &vat_main;
14008 vat_json_node_t *node = NULL;
14009 struct in_addr ip4;
14010 struct in6_addr ip6;
14012 if (VAT_JSON_ARRAY != vam->json_tree.type)
14014 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14015 vat_json_init_array (&vam->json_tree);
14017 node = vat_json_array_add (&vam->json_tree);
14019 vat_json_init_object (node);
14020 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14021 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
14024 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
14025 vat_json_object_add_ip4 (node, "src_address", ip4);
14026 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
14027 vat_json_object_add_ip4 (node, "dst_address", ip4);
14031 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
14032 vat_json_object_add_ip6 (node, "src_address", ip6);
14033 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
14034 vat_json_object_add_ip6 (node, "dst_address", ip6);
14036 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
14037 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
14038 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
14039 vat_json_object_add_uint (node, "session_id", mp->session_id);
14043 api_gre_tunnel_dump (vat_main_t * vam)
14045 unformat_input_t *i = vam->input;
14046 vl_api_gre_tunnel_dump_t *mp;
14047 vl_api_control_ping_t *mp_ping;
14049 u8 sw_if_index_set = 0;
14052 /* Parse args required to build the message */
14053 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14055 if (unformat (i, "sw_if_index %d", &sw_if_index))
14056 sw_if_index_set = 1;
14061 if (sw_if_index_set == 0)
14066 if (!vam->json_output)
14068 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
14069 "sw_if_index", "instance", "src_address", "dst_address",
14070 "tunnel_type", "outer_fib_id", "session_id");
14073 /* Get list of gre-tunnel interfaces */
14074 M (GRE_TUNNEL_DUMP, mp);
14076 mp->sw_if_index = htonl (sw_if_index);
14080 /* Use a control ping for synchronization */
14081 MPING (CONTROL_PING, mp_ping);
14089 api_l2_fib_clear_table (vat_main_t * vam)
14091 // unformat_input_t * i = vam->input;
14092 vl_api_l2_fib_clear_table_t *mp;
14095 M (L2_FIB_CLEAR_TABLE, mp);
14103 api_l2_interface_efp_filter (vat_main_t * vam)
14105 unformat_input_t *i = vam->input;
14106 vl_api_l2_interface_efp_filter_t *mp;
14109 u8 sw_if_index_set = 0;
14112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14114 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14115 sw_if_index_set = 1;
14116 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14117 sw_if_index_set = 1;
14118 else if (unformat (i, "enable"))
14120 else if (unformat (i, "disable"))
14124 clib_warning ("parse error '%U'", format_unformat_error, i);
14129 if (sw_if_index_set == 0)
14131 errmsg ("missing sw_if_index");
14135 M (L2_INTERFACE_EFP_FILTER, mp);
14137 mp->sw_if_index = ntohl (sw_if_index);
14138 mp->enable_disable = enable;
14145 #define foreach_vtr_op \
14146 _("disable", L2_VTR_DISABLED) \
14147 _("push-1", L2_VTR_PUSH_1) \
14148 _("push-2", L2_VTR_PUSH_2) \
14149 _("pop-1", L2_VTR_POP_1) \
14150 _("pop-2", L2_VTR_POP_2) \
14151 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
14152 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
14153 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
14154 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
14157 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
14159 unformat_input_t *i = vam->input;
14160 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
14162 u8 sw_if_index_set = 0;
14165 u32 push_dot1q = 1;
14170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14172 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14173 sw_if_index_set = 1;
14174 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14175 sw_if_index_set = 1;
14176 else if (unformat (i, "vtr_op %d", &vtr_op))
14178 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
14181 else if (unformat (i, "push_dot1q %d", &push_dot1q))
14183 else if (unformat (i, "tag1 %d", &tag1))
14185 else if (unformat (i, "tag2 %d", &tag2))
14189 clib_warning ("parse error '%U'", format_unformat_error, i);
14194 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
14196 errmsg ("missing vtr operation or sw_if_index");
14200 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
14201 mp->sw_if_index = ntohl (sw_if_index);
14202 mp->vtr_op = ntohl (vtr_op);
14203 mp->push_dot1q = ntohl (push_dot1q);
14204 mp->tag1 = ntohl (tag1);
14205 mp->tag2 = ntohl (tag2);
14213 api_create_vhost_user_if (vat_main_t * vam)
14215 unformat_input_t *i = vam->input;
14216 vl_api_create_vhost_user_if_t *mp;
14219 u8 file_name_set = 0;
14220 u32 custom_dev_instance = ~0;
14222 u8 use_custom_mac = 0;
14223 u8 disable_mrg_rxbuf = 0;
14224 u8 disable_indirect_desc = 0;
14228 /* Shut up coverity */
14229 clib_memset (hwaddr, 0, sizeof (hwaddr));
14231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14233 if (unformat (i, "socket %s", &file_name))
14237 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14239 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
14240 use_custom_mac = 1;
14241 else if (unformat (i, "server"))
14243 else if (unformat (i, "disable_mrg_rxbuf"))
14244 disable_mrg_rxbuf = 1;
14245 else if (unformat (i, "disable_indirect_desc"))
14246 disable_indirect_desc = 1;
14247 else if (unformat (i, "tag %s", &tag))
14253 if (file_name_set == 0)
14255 errmsg ("missing socket file name");
14259 if (vec_len (file_name) > 255)
14261 errmsg ("socket file name too long");
14264 vec_add1 (file_name, 0);
14266 M (CREATE_VHOST_USER_IF, mp);
14268 mp->is_server = is_server;
14269 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
14270 mp->disable_indirect_desc = disable_indirect_desc;
14271 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14272 vec_free (file_name);
14273 if (custom_dev_instance != ~0)
14276 mp->custom_dev_instance = ntohl (custom_dev_instance);
14279 mp->use_custom_mac = use_custom_mac;
14280 clib_memcpy (mp->mac_address, hwaddr, 6);
14282 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
14291 api_modify_vhost_user_if (vat_main_t * vam)
14293 unformat_input_t *i = vam->input;
14294 vl_api_modify_vhost_user_if_t *mp;
14297 u8 file_name_set = 0;
14298 u32 custom_dev_instance = ~0;
14299 u8 sw_if_index_set = 0;
14300 u32 sw_if_index = (u32) ~ 0;
14303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14305 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14306 sw_if_index_set = 1;
14307 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14308 sw_if_index_set = 1;
14309 else if (unformat (i, "socket %s", &file_name))
14313 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14315 else if (unformat (i, "server"))
14321 if (sw_if_index_set == 0)
14323 errmsg ("missing sw_if_index or interface name");
14327 if (file_name_set == 0)
14329 errmsg ("missing socket file name");
14333 if (vec_len (file_name) > 255)
14335 errmsg ("socket file name too long");
14338 vec_add1 (file_name, 0);
14340 M (MODIFY_VHOST_USER_IF, mp);
14342 mp->sw_if_index = ntohl (sw_if_index);
14343 mp->is_server = is_server;
14344 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14345 vec_free (file_name);
14346 if (custom_dev_instance != ~0)
14349 mp->custom_dev_instance = ntohl (custom_dev_instance);
14358 api_delete_vhost_user_if (vat_main_t * vam)
14360 unformat_input_t *i = vam->input;
14361 vl_api_delete_vhost_user_if_t *mp;
14362 u32 sw_if_index = ~0;
14363 u8 sw_if_index_set = 0;
14366 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14368 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14369 sw_if_index_set = 1;
14370 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14371 sw_if_index_set = 1;
14376 if (sw_if_index_set == 0)
14378 errmsg ("missing sw_if_index or interface name");
14383 M (DELETE_VHOST_USER_IF, mp);
14385 mp->sw_if_index = ntohl (sw_if_index);
14392 static void vl_api_sw_interface_vhost_user_details_t_handler
14393 (vl_api_sw_interface_vhost_user_details_t * mp)
14395 vat_main_t *vam = &vat_main;
14397 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14398 (char *) mp->interface_name,
14399 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14400 clib_net_to_host_u64 (mp->features), mp->is_server,
14401 ntohl (mp->num_regions), (char *) mp->sock_filename);
14402 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14405 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14406 (vl_api_sw_interface_vhost_user_details_t * mp)
14408 vat_main_t *vam = &vat_main;
14409 vat_json_node_t *node = NULL;
14411 if (VAT_JSON_ARRAY != vam->json_tree.type)
14413 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14414 vat_json_init_array (&vam->json_tree);
14416 node = vat_json_array_add (&vam->json_tree);
14418 vat_json_init_object (node);
14419 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14420 vat_json_object_add_string_copy (node, "interface_name",
14421 mp->interface_name);
14422 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14423 ntohl (mp->virtio_net_hdr_sz));
14424 vat_json_object_add_uint (node, "features",
14425 clib_net_to_host_u64 (mp->features));
14426 vat_json_object_add_uint (node, "is_server", mp->is_server);
14427 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14428 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14429 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14433 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14435 vl_api_sw_interface_vhost_user_dump_t *mp;
14436 vl_api_control_ping_t *mp_ping;
14439 "Interface name idx hdr_sz features server regions filename");
14441 /* Get list of vhost-user interfaces */
14442 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14445 /* Use a control ping for synchronization */
14446 MPING (CONTROL_PING, mp_ping);
14454 api_show_version (vat_main_t * vam)
14456 vl_api_show_version_t *mp;
14459 M (SHOW_VERSION, mp);
14468 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14470 unformat_input_t *line_input = vam->input;
14471 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14472 ip4_address_t local4, remote4;
14473 ip6_address_t local6, remote6;
14475 u8 ipv4_set = 0, ipv6_set = 0;
14479 u32 mcast_sw_if_index = ~0;
14480 u32 encap_vrf_id = 0;
14481 u32 decap_vrf_id = 0;
14487 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14488 clib_memset (&local4, 0, sizeof local4);
14489 clib_memset (&remote4, 0, sizeof remote4);
14490 clib_memset (&local6, 0, sizeof local6);
14491 clib_memset (&remote6, 0, sizeof remote6);
14493 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14495 if (unformat (line_input, "del"))
14497 else if (unformat (line_input, "local %U",
14498 unformat_ip4_address, &local4))
14503 else if (unformat (line_input, "remote %U",
14504 unformat_ip4_address, &remote4))
14509 else if (unformat (line_input, "local %U",
14510 unformat_ip6_address, &local6))
14515 else if (unformat (line_input, "remote %U",
14516 unformat_ip6_address, &remote6))
14521 else if (unformat (line_input, "group %U %U",
14522 unformat_ip4_address, &remote4,
14523 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14525 grp_set = remote_set = 1;
14528 else if (unformat (line_input, "group %U",
14529 unformat_ip4_address, &remote4))
14531 grp_set = remote_set = 1;
14534 else if (unformat (line_input, "group %U %U",
14535 unformat_ip6_address, &remote6,
14536 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14538 grp_set = remote_set = 1;
14541 else if (unformat (line_input, "group %U",
14542 unformat_ip6_address, &remote6))
14544 grp_set = remote_set = 1;
14548 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14550 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14552 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14554 else if (unformat (line_input, "vni %d", &vni))
14556 else if (unformat (line_input, "next-ip4"))
14558 else if (unformat (line_input, "next-ip6"))
14560 else if (unformat (line_input, "next-ethernet"))
14562 else if (unformat (line_input, "next-nsh"))
14566 errmsg ("parse error '%U'", format_unformat_error, line_input);
14571 if (local_set == 0)
14573 errmsg ("tunnel local address not specified");
14576 if (remote_set == 0)
14578 errmsg ("tunnel remote address not specified");
14581 if (grp_set && mcast_sw_if_index == ~0)
14583 errmsg ("tunnel nonexistent multicast device");
14586 if (ipv4_set && ipv6_set)
14588 errmsg ("both IPv4 and IPv6 addresses specified");
14594 errmsg ("vni not specified");
14598 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14603 clib_memcpy (&mp->local, &local6, sizeof (local6));
14604 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14608 clib_memcpy (&mp->local, &local4, sizeof (local4));
14609 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14612 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14613 mp->encap_vrf_id = ntohl (encap_vrf_id);
14614 mp->decap_vrf_id = ntohl (decap_vrf_id);
14615 mp->protocol = protocol;
14616 mp->vni = ntohl (vni);
14617 mp->is_add = is_add;
14618 mp->is_ipv6 = ipv6_set;
14625 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14626 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14628 vat_main_t *vam = &vat_main;
14629 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14630 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14632 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14633 ntohl (mp->sw_if_index),
14634 format_ip46_address, &local, IP46_TYPE_ANY,
14635 format_ip46_address, &remote, IP46_TYPE_ANY,
14636 ntohl (mp->vni), mp->protocol,
14637 ntohl (mp->mcast_sw_if_index),
14638 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14642 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14643 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14645 vat_main_t *vam = &vat_main;
14646 vat_json_node_t *node = NULL;
14647 struct in_addr ip4;
14648 struct in6_addr ip6;
14650 if (VAT_JSON_ARRAY != vam->json_tree.type)
14652 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14653 vat_json_init_array (&vam->json_tree);
14655 node = vat_json_array_add (&vam->json_tree);
14657 vat_json_init_object (node);
14658 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14661 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14662 vat_json_object_add_ip6 (node, "local", ip6);
14663 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14664 vat_json_object_add_ip6 (node, "remote", ip6);
14668 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14669 vat_json_object_add_ip4 (node, "local", ip4);
14670 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14671 vat_json_object_add_ip4 (node, "remote", ip4);
14673 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14674 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14675 vat_json_object_add_uint (node, "mcast_sw_if_index",
14676 ntohl (mp->mcast_sw_if_index));
14677 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14678 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14679 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14683 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14685 unformat_input_t *i = vam->input;
14686 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14687 vl_api_control_ping_t *mp_ping;
14689 u8 sw_if_index_set = 0;
14692 /* Parse args required to build the message */
14693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14695 if (unformat (i, "sw_if_index %d", &sw_if_index))
14696 sw_if_index_set = 1;
14701 if (sw_if_index_set == 0)
14706 if (!vam->json_output)
14708 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14709 "sw_if_index", "local", "remote", "vni",
14710 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14713 /* Get list of vxlan-tunnel interfaces */
14714 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14716 mp->sw_if_index = htonl (sw_if_index);
14720 /* Use a control ping for synchronization */
14721 MPING (CONTROL_PING, mp_ping);
14728 static void vl_api_l2_fib_table_details_t_handler
14729 (vl_api_l2_fib_table_details_t * mp)
14731 vat_main_t *vam = &vat_main;
14733 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14735 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14736 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14740 static void vl_api_l2_fib_table_details_t_handler_json
14741 (vl_api_l2_fib_table_details_t * mp)
14743 vat_main_t *vam = &vat_main;
14744 vat_json_node_t *node = NULL;
14746 if (VAT_JSON_ARRAY != vam->json_tree.type)
14748 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14749 vat_json_init_array (&vam->json_tree);
14751 node = vat_json_array_add (&vam->json_tree);
14753 vat_json_init_object (node);
14754 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14755 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14756 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14757 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14758 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14759 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14763 api_l2_fib_table_dump (vat_main_t * vam)
14765 unformat_input_t *i = vam->input;
14766 vl_api_l2_fib_table_dump_t *mp;
14767 vl_api_control_ping_t *mp_ping;
14772 /* Parse args required to build the message */
14773 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14775 if (unformat (i, "bd_id %d", &bd_id))
14781 if (bd_id_set == 0)
14783 errmsg ("missing bridge domain");
14787 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14789 /* Get list of l2 fib entries */
14790 M (L2_FIB_TABLE_DUMP, mp);
14792 mp->bd_id = ntohl (bd_id);
14795 /* Use a control ping for synchronization */
14796 MPING (CONTROL_PING, mp_ping);
14805 api_interface_name_renumber (vat_main_t * vam)
14807 unformat_input_t *line_input = vam->input;
14808 vl_api_interface_name_renumber_t *mp;
14809 u32 sw_if_index = ~0;
14810 u32 new_show_dev_instance = ~0;
14813 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14815 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14818 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14820 else if (unformat (line_input, "new_show_dev_instance %d",
14821 &new_show_dev_instance))
14827 if (sw_if_index == ~0)
14829 errmsg ("missing interface name or sw_if_index");
14833 if (new_show_dev_instance == ~0)
14835 errmsg ("missing new_show_dev_instance");
14839 M (INTERFACE_NAME_RENUMBER, mp);
14841 mp->sw_if_index = ntohl (sw_if_index);
14842 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14850 api_ip_probe_neighbor (vat_main_t * vam)
14852 unformat_input_t *i = vam->input;
14853 vl_api_ip_probe_neighbor_t *mp;
14861 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14863 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14865 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14867 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14869 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14880 errmsg ("missing interface");
14886 errmsg ("missing addresses");
14890 M (IP_PROBE_NEIGHBOR, mp);
14892 mp->sw_if_index = ntohl (sw_if_index);
14893 mp->is_ipv6 = is_ipv6;
14894 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14902 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14904 unformat_input_t *i = vam->input;
14905 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14906 u8 mode = IP_SCAN_V46_NEIGHBORS;
14907 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14912 if (unformat (i, "ip4"))
14913 mode = IP_SCAN_V4_NEIGHBORS;
14914 else if (unformat (i, "ip6"))
14915 mode = IP_SCAN_V6_NEIGHBORS;
14916 if (unformat (i, "both"))
14917 mode = IP_SCAN_V46_NEIGHBORS;
14918 else if (unformat (i, "disable"))
14919 mode = IP_SCAN_DISABLED;
14920 else if (unformat (i, "interval %d", &interval))
14922 else if (unformat (i, "max-time %d", &time))
14924 else if (unformat (i, "max-update %d", &update))
14926 else if (unformat (i, "delay %d", &delay))
14928 else if (unformat (i, "stale %d", &stale))
14934 if (interval > 255)
14936 errmsg ("interval cannot exceed 255 minutes.");
14941 errmsg ("max-time cannot exceed 255 usec.");
14946 errmsg ("max-update cannot exceed 255.");
14951 errmsg ("delay cannot exceed 255 msec.");
14956 errmsg ("stale cannot exceed 255 minutes.");
14960 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14962 mp->scan_interval = interval;
14963 mp->max_proc_time = time;
14964 mp->max_update = update;
14965 mp->scan_int_delay = delay;
14966 mp->stale_threshold = stale;
14974 api_want_ip4_arp_events (vat_main_t * vam)
14976 unformat_input_t *line_input = vam->input;
14977 vl_api_want_ip4_arp_events_t *mp;
14978 ip4_address_t address;
14979 int address_set = 0;
14980 u32 enable_disable = 1;
14983 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14985 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14987 else if (unformat (line_input, "del"))
14988 enable_disable = 0;
14993 if (address_set == 0)
14995 errmsg ("missing addresses");
14999 M (WANT_IP4_ARP_EVENTS, mp);
15000 mp->enable_disable = enable_disable;
15001 mp->pid = htonl (getpid ());
15002 mp->address = address.as_u32;
15010 api_want_ip6_nd_events (vat_main_t * vam)
15012 unformat_input_t *line_input = vam->input;
15013 vl_api_want_ip6_nd_events_t *mp;
15014 ip6_address_t address;
15015 int address_set = 0;
15016 u32 enable_disable = 1;
15019 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15021 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
15023 else if (unformat (line_input, "del"))
15024 enable_disable = 0;
15029 if (address_set == 0)
15031 errmsg ("missing addresses");
15035 M (WANT_IP6_ND_EVENTS, mp);
15036 mp->enable_disable = enable_disable;
15037 mp->pid = htonl (getpid ());
15038 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
15046 api_want_l2_macs_events (vat_main_t * vam)
15048 unformat_input_t *line_input = vam->input;
15049 vl_api_want_l2_macs_events_t *mp;
15050 u8 enable_disable = 1;
15051 u32 scan_delay = 0;
15052 u32 max_macs_in_event = 0;
15053 u32 learn_limit = 0;
15056 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15058 if (unformat (line_input, "learn-limit %d", &learn_limit))
15060 else if (unformat (line_input, "scan-delay %d", &scan_delay))
15062 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
15064 else if (unformat (line_input, "disable"))
15065 enable_disable = 0;
15070 M (WANT_L2_MACS_EVENTS, mp);
15071 mp->enable_disable = enable_disable;
15072 mp->pid = htonl (getpid ());
15073 mp->learn_limit = htonl (learn_limit);
15074 mp->scan_delay = (u8) scan_delay;
15075 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
15082 api_input_acl_set_interface (vat_main_t * vam)
15084 unformat_input_t *i = vam->input;
15085 vl_api_input_acl_set_interface_t *mp;
15087 int sw_if_index_set;
15088 u32 ip4_table_index = ~0;
15089 u32 ip6_table_index = ~0;
15090 u32 l2_table_index = ~0;
15094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15096 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15097 sw_if_index_set = 1;
15098 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15099 sw_if_index_set = 1;
15100 else if (unformat (i, "del"))
15102 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15104 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15106 else if (unformat (i, "l2-table %d", &l2_table_index))
15110 clib_warning ("parse error '%U'", format_unformat_error, i);
15115 if (sw_if_index_set == 0)
15117 errmsg ("missing interface name or sw_if_index");
15121 M (INPUT_ACL_SET_INTERFACE, mp);
15123 mp->sw_if_index = ntohl (sw_if_index);
15124 mp->ip4_table_index = ntohl (ip4_table_index);
15125 mp->ip6_table_index = ntohl (ip6_table_index);
15126 mp->l2_table_index = ntohl (l2_table_index);
15127 mp->is_add = is_add;
15135 api_output_acl_set_interface (vat_main_t * vam)
15137 unformat_input_t *i = vam->input;
15138 vl_api_output_acl_set_interface_t *mp;
15140 int sw_if_index_set;
15141 u32 ip4_table_index = ~0;
15142 u32 ip6_table_index = ~0;
15143 u32 l2_table_index = ~0;
15147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15149 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15150 sw_if_index_set = 1;
15151 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15152 sw_if_index_set = 1;
15153 else if (unformat (i, "del"))
15155 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15157 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15159 else if (unformat (i, "l2-table %d", &l2_table_index))
15163 clib_warning ("parse error '%U'", format_unformat_error, i);
15168 if (sw_if_index_set == 0)
15170 errmsg ("missing interface name or sw_if_index");
15174 M (OUTPUT_ACL_SET_INTERFACE, mp);
15176 mp->sw_if_index = ntohl (sw_if_index);
15177 mp->ip4_table_index = ntohl (ip4_table_index);
15178 mp->ip6_table_index = ntohl (ip6_table_index);
15179 mp->l2_table_index = ntohl (l2_table_index);
15180 mp->is_add = is_add;
15188 api_ip_address_dump (vat_main_t * vam)
15190 unformat_input_t *i = vam->input;
15191 vl_api_ip_address_dump_t *mp;
15192 vl_api_control_ping_t *mp_ping;
15193 u32 sw_if_index = ~0;
15194 u8 sw_if_index_set = 0;
15199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15201 if (unformat (i, "sw_if_index %d", &sw_if_index))
15202 sw_if_index_set = 1;
15204 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15205 sw_if_index_set = 1;
15206 else if (unformat (i, "ipv4"))
15208 else if (unformat (i, "ipv6"))
15214 if (ipv4_set && ipv6_set)
15216 errmsg ("ipv4 and ipv6 flags cannot be both set");
15220 if ((!ipv4_set) && (!ipv6_set))
15222 errmsg ("no ipv4 nor ipv6 flag set");
15226 if (sw_if_index_set == 0)
15228 errmsg ("missing interface name or sw_if_index");
15232 vam->current_sw_if_index = sw_if_index;
15233 vam->is_ipv6 = ipv6_set;
15235 M (IP_ADDRESS_DUMP, mp);
15236 mp->sw_if_index = ntohl (sw_if_index);
15237 mp->is_ipv6 = ipv6_set;
15240 /* Use a control ping for synchronization */
15241 MPING (CONTROL_PING, mp_ping);
15249 api_ip_dump (vat_main_t * vam)
15251 vl_api_ip_dump_t *mp;
15252 vl_api_control_ping_t *mp_ping;
15253 unformat_input_t *in = vam->input;
15260 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
15262 if (unformat (in, "ipv4"))
15264 else if (unformat (in, "ipv6"))
15270 if (ipv4_set && ipv6_set)
15272 errmsg ("ipv4 and ipv6 flags cannot be both set");
15276 if ((!ipv4_set) && (!ipv6_set))
15278 errmsg ("no ipv4 nor ipv6 flag set");
15282 is_ipv6 = ipv6_set;
15283 vam->is_ipv6 = is_ipv6;
15285 /* free old data */
15286 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
15288 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
15290 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
15293 mp->is_ipv6 = ipv6_set;
15296 /* Use a control ping for synchronization */
15297 MPING (CONTROL_PING, mp_ping);
15305 api_ipsec_spd_add_del (vat_main_t * vam)
15307 unformat_input_t *i = vam->input;
15308 vl_api_ipsec_spd_add_del_t *mp;
15313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15315 if (unformat (i, "spd_id %d", &spd_id))
15317 else if (unformat (i, "del"))
15321 clib_warning ("parse error '%U'", format_unformat_error, i);
15327 errmsg ("spd_id must be set");
15331 M (IPSEC_SPD_ADD_DEL, mp);
15333 mp->spd_id = ntohl (spd_id);
15334 mp->is_add = is_add;
15342 api_ipsec_interface_add_del_spd (vat_main_t * vam)
15344 unformat_input_t *i = vam->input;
15345 vl_api_ipsec_interface_add_del_spd_t *mp;
15347 u8 sw_if_index_set = 0;
15348 u32 spd_id = (u32) ~ 0;
15352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15354 if (unformat (i, "del"))
15356 else if (unformat (i, "spd_id %d", &spd_id))
15359 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15360 sw_if_index_set = 1;
15361 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15362 sw_if_index_set = 1;
15365 clib_warning ("parse error '%U'", format_unformat_error, i);
15371 if (spd_id == (u32) ~ 0)
15373 errmsg ("spd_id must be set");
15377 if (sw_if_index_set == 0)
15379 errmsg ("missing interface name or sw_if_index");
15383 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15385 mp->spd_id = ntohl (spd_id);
15386 mp->sw_if_index = ntohl (sw_if_index);
15387 mp->is_add = is_add;
15395 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15397 unformat_input_t *i = vam->input;
15398 vl_api_ipsec_spd_add_del_entry_t *mp;
15399 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15400 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15402 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15403 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15404 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15405 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15408 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15409 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15410 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15411 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15412 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15413 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15417 if (unformat (i, "del"))
15419 if (unformat (i, "outbound"))
15421 if (unformat (i, "inbound"))
15423 else if (unformat (i, "spd_id %d", &spd_id))
15425 else if (unformat (i, "sa_id %d", &sa_id))
15427 else if (unformat (i, "priority %d", &priority))
15429 else if (unformat (i, "protocol %d", &protocol))
15431 else if (unformat (i, "lport_start %d", &lport_start))
15433 else if (unformat (i, "lport_stop %d", &lport_stop))
15435 else if (unformat (i, "rport_start %d", &rport_start))
15437 else if (unformat (i, "rport_stop %d", &rport_stop))
15441 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15447 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15454 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15460 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15467 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15473 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15480 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15486 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15492 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15494 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15496 clib_warning ("unsupported action: 'resolve'");
15502 clib_warning ("parse error '%U'", format_unformat_error, i);
15508 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15510 mp->spd_id = ntohl (spd_id);
15511 mp->priority = ntohl (priority);
15512 mp->is_outbound = is_outbound;
15514 mp->is_ipv6 = is_ipv6;
15515 if (is_ipv6 || is_ip_any)
15517 clib_memcpy (mp->remote_address_start, &raddr6_start,
15518 sizeof (ip6_address_t));
15519 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15520 sizeof (ip6_address_t));
15521 clib_memcpy (mp->local_address_start, &laddr6_start,
15522 sizeof (ip6_address_t));
15523 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15524 sizeof (ip6_address_t));
15528 clib_memcpy (mp->remote_address_start, &raddr4_start,
15529 sizeof (ip4_address_t));
15530 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15531 sizeof (ip4_address_t));
15532 clib_memcpy (mp->local_address_start, &laddr4_start,
15533 sizeof (ip4_address_t));
15534 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15535 sizeof (ip4_address_t));
15537 mp->protocol = (u8) protocol;
15538 mp->local_port_start = ntohs ((u16) lport_start);
15539 mp->local_port_stop = ntohs ((u16) lport_stop);
15540 mp->remote_port_start = ntohs ((u16) rport_start);
15541 mp->remote_port_stop = ntohs ((u16) rport_stop);
15542 mp->policy = (u8) policy;
15543 mp->sa_id = ntohl (sa_id);
15544 mp->is_add = is_add;
15545 mp->is_ip_any = is_ip_any;
15552 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15554 unformat_input_t *i = vam->input;
15555 vl_api_ipsec_sad_add_del_entry_t *mp;
15556 u32 sad_id = 0, spi = 0;
15557 u8 *ck = 0, *ik = 0;
15560 u8 protocol = IPSEC_PROTOCOL_AH;
15561 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15562 u32 crypto_alg = 0, integ_alg = 0;
15563 ip4_address_t tun_src4;
15564 ip4_address_t tun_dst4;
15565 ip6_address_t tun_src6;
15566 ip6_address_t tun_dst6;
15569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15571 if (unformat (i, "del"))
15573 else if (unformat (i, "sad_id %d", &sad_id))
15575 else if (unformat (i, "spi %d", &spi))
15577 else if (unformat (i, "esp"))
15578 protocol = IPSEC_PROTOCOL_ESP;
15579 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15582 is_tunnel_ipv6 = 0;
15584 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15587 is_tunnel_ipv6 = 0;
15589 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15592 is_tunnel_ipv6 = 1;
15594 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15597 is_tunnel_ipv6 = 1;
15601 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15603 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15605 clib_warning ("unsupported crypto-alg: '%U'",
15606 format_ipsec_crypto_alg, crypto_alg);
15610 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15614 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15616 if (integ_alg >= IPSEC_INTEG_N_ALG)
15618 clib_warning ("unsupported integ-alg: '%U'",
15619 format_ipsec_integ_alg, integ_alg);
15623 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15627 clib_warning ("parse error '%U'", format_unformat_error, i);
15633 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15635 mp->sad_id = ntohl (sad_id);
15636 mp->is_add = is_add;
15637 mp->protocol = protocol;
15638 mp->spi = ntohl (spi);
15639 mp->is_tunnel = is_tunnel;
15640 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15641 mp->crypto_algorithm = crypto_alg;
15642 mp->integrity_algorithm = integ_alg;
15643 mp->crypto_key_length = vec_len (ck);
15644 mp->integrity_key_length = vec_len (ik);
15646 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15647 mp->crypto_key_length = sizeof (mp->crypto_key);
15649 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15650 mp->integrity_key_length = sizeof (mp->integrity_key);
15653 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15655 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15659 if (is_tunnel_ipv6)
15661 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15662 sizeof (ip6_address_t));
15663 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15664 sizeof (ip6_address_t));
15668 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15669 sizeof (ip4_address_t));
15670 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15671 sizeof (ip4_address_t));
15681 api_ipsec_sa_set_key (vat_main_t * vam)
15683 unformat_input_t *i = vam->input;
15684 vl_api_ipsec_sa_set_key_t *mp;
15686 u8 *ck = 0, *ik = 0;
15689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15691 if (unformat (i, "sa_id %d", &sa_id))
15693 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15695 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15699 clib_warning ("parse error '%U'", format_unformat_error, i);
15704 M (IPSEC_SA_SET_KEY, mp);
15706 mp->sa_id = ntohl (sa_id);
15707 mp->crypto_key_length = vec_len (ck);
15708 mp->integrity_key_length = vec_len (ik);
15710 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15711 mp->crypto_key_length = sizeof (mp->crypto_key);
15713 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15714 mp->integrity_key_length = sizeof (mp->integrity_key);
15717 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15719 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15727 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15729 unformat_input_t *i = vam->input;
15730 vl_api_ipsec_tunnel_if_add_del_t *mp;
15731 u32 local_spi = 0, remote_spi = 0;
15732 u32 crypto_alg = 0, integ_alg = 0;
15733 u8 *lck = NULL, *rck = NULL;
15734 u8 *lik = NULL, *rik = NULL;
15735 ip4_address_t local_ip = { {0} };
15736 ip4_address_t remote_ip = { {0} };
15739 u8 anti_replay = 0;
15744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15746 if (unformat (i, "del"))
15748 else if (unformat (i, "esn"))
15750 else if (unformat (i, "anti_replay"))
15752 else if (unformat (i, "local_spi %d", &local_spi))
15754 else if (unformat (i, "remote_spi %d", &remote_spi))
15756 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15758 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15760 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15763 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15765 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15767 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15771 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15773 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15775 errmsg ("unsupported crypto-alg: '%U'\n",
15776 format_ipsec_crypto_alg, crypto_alg);
15782 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15784 if (integ_alg >= IPSEC_INTEG_N_ALG)
15786 errmsg ("unsupported integ-alg: '%U'\n",
15787 format_ipsec_integ_alg, integ_alg);
15791 else if (unformat (i, "instance %u", &instance))
15795 errmsg ("parse error '%U'\n", format_unformat_error, i);
15800 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15802 mp->is_add = is_add;
15804 mp->anti_replay = anti_replay;
15806 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15807 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15809 mp->local_spi = htonl (local_spi);
15810 mp->remote_spi = htonl (remote_spi);
15811 mp->crypto_alg = (u8) crypto_alg;
15813 mp->local_crypto_key_len = 0;
15816 mp->local_crypto_key_len = vec_len (lck);
15817 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15818 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15819 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15822 mp->remote_crypto_key_len = 0;
15825 mp->remote_crypto_key_len = vec_len (rck);
15826 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15827 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15828 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15831 mp->integ_alg = (u8) integ_alg;
15833 mp->local_integ_key_len = 0;
15836 mp->local_integ_key_len = vec_len (lik);
15837 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15838 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15839 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15842 mp->remote_integ_key_len = 0;
15845 mp->remote_integ_key_len = vec_len (rik);
15846 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15847 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15848 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15853 mp->renumber = renumber;
15854 mp->show_instance = ntohl (instance);
15863 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15865 vat_main_t *vam = &vat_main;
15867 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15868 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15869 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15870 "tunnel_src_addr %U tunnel_dst_addr %U "
15871 "salt %u seq_outbound %lu last_seq_inbound %lu "
15872 "replay_window %lu total_data_size %lu\n",
15873 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15875 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15876 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15877 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15878 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15879 mp->tunnel_src_addr,
15880 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15881 mp->tunnel_dst_addr,
15883 clib_net_to_host_u64 (mp->seq_outbound),
15884 clib_net_to_host_u64 (mp->last_seq_inbound),
15885 clib_net_to_host_u64 (mp->replay_window),
15886 clib_net_to_host_u64 (mp->total_data_size));
15889 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15890 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15892 static void vl_api_ipsec_sa_details_t_handler_json
15893 (vl_api_ipsec_sa_details_t * mp)
15895 vat_main_t *vam = &vat_main;
15896 vat_json_node_t *node = NULL;
15897 struct in_addr src_ip4, dst_ip4;
15898 struct in6_addr src_ip6, dst_ip6;
15900 if (VAT_JSON_ARRAY != vam->json_tree.type)
15902 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15903 vat_json_init_array (&vam->json_tree);
15905 node = vat_json_array_add (&vam->json_tree);
15907 vat_json_init_object (node);
15908 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15909 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15910 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15911 vat_json_object_add_uint (node, "proto", mp->protocol);
15912 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15913 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15914 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15915 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15916 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15917 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15918 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15919 mp->crypto_key_len);
15920 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15921 mp->integ_key_len);
15922 if (mp->is_tunnel_ip6)
15924 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15925 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15926 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15927 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15931 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15932 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15933 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15934 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15936 vat_json_object_add_uint (node, "replay_window",
15937 clib_net_to_host_u64 (mp->replay_window));
15938 vat_json_object_add_uint (node, "total_data_size",
15939 clib_net_to_host_u64 (mp->total_data_size));
15944 api_ipsec_sa_dump (vat_main_t * vam)
15946 unformat_input_t *i = vam->input;
15947 vl_api_ipsec_sa_dump_t *mp;
15948 vl_api_control_ping_t *mp_ping;
15952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15954 if (unformat (i, "sa_id %d", &sa_id))
15958 clib_warning ("parse error '%U'", format_unformat_error, i);
15963 M (IPSEC_SA_DUMP, mp);
15965 mp->sa_id = ntohl (sa_id);
15969 /* Use a control ping for synchronization */
15970 M (CONTROL_PING, mp_ping);
15978 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15980 unformat_input_t *i = vam->input;
15981 vl_api_ipsec_tunnel_if_set_key_t *mp;
15982 u32 sw_if_index = ~0;
15983 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15990 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15993 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15994 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15996 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15997 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15998 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15999 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
16001 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
16002 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
16003 else if (unformat (i, "%U", unformat_hex_string, &key))
16007 clib_warning ("parse error '%U'", format_unformat_error, i);
16012 if (sw_if_index == ~0)
16014 errmsg ("interface must be specified");
16018 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
16020 errmsg ("key type must be specified");
16026 errmsg ("algorithm must be specified");
16030 if (vec_len (key) == 0)
16032 errmsg ("key must be specified");
16036 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
16038 mp->sw_if_index = htonl (sw_if_index);
16040 mp->key_type = key_type;
16041 mp->key_len = vec_len (key);
16042 clib_memcpy (mp->key, key, vec_len (key));
16051 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
16053 unformat_input_t *i = vam->input;
16054 vl_api_ipsec_tunnel_if_set_sa_t *mp;
16055 u32 sw_if_index = ~0;
16057 u8 is_outbound = (u8) ~ 0;
16060 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16062 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16064 else if (unformat (i, "sa_id %d", &sa_id))
16066 else if (unformat (i, "outbound"))
16068 else if (unformat (i, "inbound"))
16072 clib_warning ("parse error '%U'", format_unformat_error, i);
16077 if (sw_if_index == ~0)
16079 errmsg ("interface must be specified");
16085 errmsg ("SA ID must be specified");
16089 M (IPSEC_TUNNEL_IF_SET_SA, mp);
16091 mp->sw_if_index = htonl (sw_if_index);
16092 mp->sa_id = htonl (sa_id);
16093 mp->is_outbound = is_outbound;
16102 api_ikev2_profile_add_del (vat_main_t * vam)
16104 unformat_input_t *i = vam->input;
16105 vl_api_ikev2_profile_add_del_t *mp;
16110 const char *valid_chars = "a-zA-Z0-9_";
16112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16114 if (unformat (i, "del"))
16116 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16117 vec_add1 (name, 0);
16120 errmsg ("parse error '%U'", format_unformat_error, i);
16125 if (!vec_len (name))
16127 errmsg ("profile name must be specified");
16131 if (vec_len (name) > 64)
16133 errmsg ("profile name too long");
16137 M (IKEV2_PROFILE_ADD_DEL, mp);
16139 clib_memcpy (mp->name, name, vec_len (name));
16140 mp->is_add = is_add;
16149 api_ikev2_profile_set_auth (vat_main_t * vam)
16151 unformat_input_t *i = vam->input;
16152 vl_api_ikev2_profile_set_auth_t *mp;
16155 u32 auth_method = 0;
16159 const char *valid_chars = "a-zA-Z0-9_";
16161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16163 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16164 vec_add1 (name, 0);
16165 else if (unformat (i, "auth_method %U",
16166 unformat_ikev2_auth_method, &auth_method))
16168 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
16170 else if (unformat (i, "auth_data %v", &data))
16174 errmsg ("parse error '%U'", format_unformat_error, i);
16179 if (!vec_len (name))
16181 errmsg ("profile name must be specified");
16185 if (vec_len (name) > 64)
16187 errmsg ("profile name too long");
16191 if (!vec_len (data))
16193 errmsg ("auth_data must be specified");
16199 errmsg ("auth_method must be specified");
16203 M (IKEV2_PROFILE_SET_AUTH, mp);
16205 mp->is_hex = is_hex;
16206 mp->auth_method = (u8) auth_method;
16207 mp->data_len = vec_len (data);
16208 clib_memcpy (mp->name, name, vec_len (name));
16209 clib_memcpy (mp->data, data, vec_len (data));
16219 api_ikev2_profile_set_id (vat_main_t * vam)
16221 unformat_input_t *i = vam->input;
16222 vl_api_ikev2_profile_set_id_t *mp;
16230 const char *valid_chars = "a-zA-Z0-9_";
16232 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16234 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16235 vec_add1 (name, 0);
16236 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
16238 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
16240 data = vec_new (u8, 4);
16241 clib_memcpy (data, ip4.as_u8, 4);
16243 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
16245 else if (unformat (i, "id_data %v", &data))
16247 else if (unformat (i, "local"))
16249 else if (unformat (i, "remote"))
16253 errmsg ("parse error '%U'", format_unformat_error, i);
16258 if (!vec_len (name))
16260 errmsg ("profile name must be specified");
16264 if (vec_len (name) > 64)
16266 errmsg ("profile name too long");
16270 if (!vec_len (data))
16272 errmsg ("id_data must be specified");
16278 errmsg ("id_type must be specified");
16282 M (IKEV2_PROFILE_SET_ID, mp);
16284 mp->is_local = is_local;
16285 mp->id_type = (u8) id_type;
16286 mp->data_len = vec_len (data);
16287 clib_memcpy (mp->name, name, vec_len (name));
16288 clib_memcpy (mp->data, data, vec_len (data));
16298 api_ikev2_profile_set_ts (vat_main_t * vam)
16300 unformat_input_t *i = vam->input;
16301 vl_api_ikev2_profile_set_ts_t *mp;
16304 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
16305 ip4_address_t start_addr, end_addr;
16307 const char *valid_chars = "a-zA-Z0-9_";
16310 start_addr.as_u32 = 0;
16311 end_addr.as_u32 = (u32) ~ 0;
16313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16315 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16316 vec_add1 (name, 0);
16317 else if (unformat (i, "protocol %d", &proto))
16319 else if (unformat (i, "start_port %d", &start_port))
16321 else if (unformat (i, "end_port %d", &end_port))
16324 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
16326 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
16328 else if (unformat (i, "local"))
16330 else if (unformat (i, "remote"))
16334 errmsg ("parse error '%U'", format_unformat_error, i);
16339 if (!vec_len (name))
16341 errmsg ("profile name must be specified");
16345 if (vec_len (name) > 64)
16347 errmsg ("profile name too long");
16351 M (IKEV2_PROFILE_SET_TS, mp);
16353 mp->is_local = is_local;
16354 mp->proto = (u8) proto;
16355 mp->start_port = (u16) start_port;
16356 mp->end_port = (u16) end_port;
16357 mp->start_addr = start_addr.as_u32;
16358 mp->end_addr = end_addr.as_u32;
16359 clib_memcpy (mp->name, name, vec_len (name));
16368 api_ikev2_set_local_key (vat_main_t * vam)
16370 unformat_input_t *i = vam->input;
16371 vl_api_ikev2_set_local_key_t *mp;
16375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16377 if (unformat (i, "file %v", &file))
16378 vec_add1 (file, 0);
16381 errmsg ("parse error '%U'", format_unformat_error, i);
16386 if (!vec_len (file))
16388 errmsg ("RSA key file must be specified");
16392 if (vec_len (file) > 256)
16394 errmsg ("file name too long");
16398 M (IKEV2_SET_LOCAL_KEY, mp);
16400 clib_memcpy (mp->key_file, file, vec_len (file));
16409 api_ikev2_set_responder (vat_main_t * vam)
16411 unformat_input_t *i = vam->input;
16412 vl_api_ikev2_set_responder_t *mp;
16415 u32 sw_if_index = ~0;
16416 ip4_address_t address;
16418 const char *valid_chars = "a-zA-Z0-9_";
16420 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16423 (i, "%U interface %d address %U", unformat_token, valid_chars,
16424 &name, &sw_if_index, unformat_ip4_address, &address))
16425 vec_add1 (name, 0);
16428 errmsg ("parse error '%U'", format_unformat_error, i);
16433 if (!vec_len (name))
16435 errmsg ("profile name must be specified");
16439 if (vec_len (name) > 64)
16441 errmsg ("profile name too long");
16445 M (IKEV2_SET_RESPONDER, mp);
16447 clib_memcpy (mp->name, name, vec_len (name));
16450 mp->sw_if_index = sw_if_index;
16451 clib_memcpy (mp->address, &address, sizeof (address));
16459 api_ikev2_set_ike_transforms (vat_main_t * vam)
16461 unformat_input_t *i = vam->input;
16462 vl_api_ikev2_set_ike_transforms_t *mp;
16465 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16467 const char *valid_chars = "a-zA-Z0-9_";
16469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16471 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16472 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16473 vec_add1 (name, 0);
16476 errmsg ("parse error '%U'", format_unformat_error, i);
16481 if (!vec_len (name))
16483 errmsg ("profile name must be specified");
16487 if (vec_len (name) > 64)
16489 errmsg ("profile name too long");
16493 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16495 clib_memcpy (mp->name, name, vec_len (name));
16497 mp->crypto_alg = crypto_alg;
16498 mp->crypto_key_size = crypto_key_size;
16499 mp->integ_alg = integ_alg;
16500 mp->dh_group = dh_group;
16509 api_ikev2_set_esp_transforms (vat_main_t * vam)
16511 unformat_input_t *i = vam->input;
16512 vl_api_ikev2_set_esp_transforms_t *mp;
16515 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16517 const char *valid_chars = "a-zA-Z0-9_";
16519 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16521 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16522 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16523 vec_add1 (name, 0);
16526 errmsg ("parse error '%U'", format_unformat_error, i);
16531 if (!vec_len (name))
16533 errmsg ("profile name must be specified");
16537 if (vec_len (name) > 64)
16539 errmsg ("profile name too long");
16543 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16545 clib_memcpy (mp->name, name, vec_len (name));
16547 mp->crypto_alg = crypto_alg;
16548 mp->crypto_key_size = crypto_key_size;
16549 mp->integ_alg = integ_alg;
16550 mp->dh_group = dh_group;
16558 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16560 unformat_input_t *i = vam->input;
16561 vl_api_ikev2_set_sa_lifetime_t *mp;
16564 u64 lifetime, lifetime_maxdata;
16565 u32 lifetime_jitter, handover;
16567 const char *valid_chars = "a-zA-Z0-9_";
16569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16571 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16572 &lifetime, &lifetime_jitter, &handover,
16573 &lifetime_maxdata))
16574 vec_add1 (name, 0);
16577 errmsg ("parse error '%U'", format_unformat_error, i);
16582 if (!vec_len (name))
16584 errmsg ("profile name must be specified");
16588 if (vec_len (name) > 64)
16590 errmsg ("profile name too long");
16594 M (IKEV2_SET_SA_LIFETIME, mp);
16596 clib_memcpy (mp->name, name, vec_len (name));
16598 mp->lifetime = lifetime;
16599 mp->lifetime_jitter = lifetime_jitter;
16600 mp->handover = handover;
16601 mp->lifetime_maxdata = lifetime_maxdata;
16609 api_ikev2_initiate_sa_init (vat_main_t * vam)
16611 unformat_input_t *i = vam->input;
16612 vl_api_ikev2_initiate_sa_init_t *mp;
16616 const char *valid_chars = "a-zA-Z0-9_";
16618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16620 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16621 vec_add1 (name, 0);
16624 errmsg ("parse error '%U'", format_unformat_error, i);
16629 if (!vec_len (name))
16631 errmsg ("profile name must be specified");
16635 if (vec_len (name) > 64)
16637 errmsg ("profile name too long");
16641 M (IKEV2_INITIATE_SA_INIT, mp);
16643 clib_memcpy (mp->name, name, vec_len (name));
16652 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16654 unformat_input_t *i = vam->input;
16655 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16660 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16662 if (unformat (i, "%lx", &ispi))
16666 errmsg ("parse error '%U'", format_unformat_error, i);
16671 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16681 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16683 unformat_input_t *i = vam->input;
16684 vl_api_ikev2_initiate_del_child_sa_t *mp;
16689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16691 if (unformat (i, "%x", &ispi))
16695 errmsg ("parse error '%U'", format_unformat_error, i);
16700 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16710 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16712 unformat_input_t *i = vam->input;
16713 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16720 if (unformat (i, "%x", &ispi))
16724 errmsg ("parse error '%U'", format_unformat_error, i);
16729 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16739 api_get_first_msg_id (vat_main_t * vam)
16741 vl_api_get_first_msg_id_t *mp;
16742 unformat_input_t *i = vam->input;
16747 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16749 if (unformat (i, "client %s", &name))
16757 errmsg ("missing client name");
16760 vec_add1 (name, 0);
16762 if (vec_len (name) > 63)
16764 errmsg ("client name too long");
16768 M (GET_FIRST_MSG_ID, mp);
16769 clib_memcpy (mp->name, name, vec_len (name));
16776 api_cop_interface_enable_disable (vat_main_t * vam)
16778 unformat_input_t *line_input = vam->input;
16779 vl_api_cop_interface_enable_disable_t *mp;
16780 u32 sw_if_index = ~0;
16781 u8 enable_disable = 1;
16784 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16786 if (unformat (line_input, "disable"))
16787 enable_disable = 0;
16788 if (unformat (line_input, "enable"))
16789 enable_disable = 1;
16790 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16791 vam, &sw_if_index))
16793 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16799 if (sw_if_index == ~0)
16801 errmsg ("missing interface name or sw_if_index");
16805 /* Construct the API message */
16806 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16807 mp->sw_if_index = ntohl (sw_if_index);
16808 mp->enable_disable = enable_disable;
16812 /* Wait for the reply */
16818 api_cop_whitelist_enable_disable (vat_main_t * vam)
16820 unformat_input_t *line_input = vam->input;
16821 vl_api_cop_whitelist_enable_disable_t *mp;
16822 u32 sw_if_index = ~0;
16823 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16827 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16829 if (unformat (line_input, "ip4"))
16831 else if (unformat (line_input, "ip6"))
16833 else if (unformat (line_input, "default"))
16835 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16836 vam, &sw_if_index))
16838 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16840 else if (unformat (line_input, "fib-id %d", &fib_id))
16846 if (sw_if_index == ~0)
16848 errmsg ("missing interface name or sw_if_index");
16852 /* Construct the API message */
16853 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16854 mp->sw_if_index = ntohl (sw_if_index);
16855 mp->fib_id = ntohl (fib_id);
16858 mp->default_cop = default_cop;
16862 /* Wait for the reply */
16868 api_get_node_graph (vat_main_t * vam)
16870 vl_api_get_node_graph_t *mp;
16873 M (GET_NODE_GRAPH, mp);
16877 /* Wait for the reply */
16883 /** Used for parsing LISP eids */
16884 typedef CLIB_PACKED(struct{
16885 u8 addr[16]; /**< eid address */
16886 u32 len; /**< prefix length if IP */
16887 u8 type; /**< type of eid */
16892 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16894 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16896 clib_memset (a, 0, sizeof (a[0]));
16898 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16900 a->type = 0; /* ipv4 type */
16902 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16904 a->type = 1; /* ipv6 type */
16906 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16908 a->type = 2; /* mac type */
16910 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16912 a->type = 3; /* NSH type */
16913 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16914 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16921 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16930 lisp_eid_size_vat (u8 type)
16947 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16949 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16953 api_one_add_del_locator_set (vat_main_t * vam)
16955 unformat_input_t *input = vam->input;
16956 vl_api_one_add_del_locator_set_t *mp;
16958 u8 *locator_set_name = NULL;
16959 u8 locator_set_name_set = 0;
16960 vl_api_local_locator_t locator, *locators = 0;
16961 u32 sw_if_index, priority, weight;
16965 /* Parse args required to build the message */
16966 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16968 if (unformat (input, "del"))
16972 else if (unformat (input, "locator-set %s", &locator_set_name))
16974 locator_set_name_set = 1;
16976 else if (unformat (input, "sw_if_index %u p %u w %u",
16977 &sw_if_index, &priority, &weight))
16979 locator.sw_if_index = htonl (sw_if_index);
16980 locator.priority = priority;
16981 locator.weight = weight;
16982 vec_add1 (locators, locator);
16986 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16987 &sw_if_index, &priority, &weight))
16989 locator.sw_if_index = htonl (sw_if_index);
16990 locator.priority = priority;
16991 locator.weight = weight;
16992 vec_add1 (locators, locator);
16998 if (locator_set_name_set == 0)
17000 errmsg ("missing locator-set name");
17001 vec_free (locators);
17005 if (vec_len (locator_set_name) > 64)
17007 errmsg ("locator-set name too long");
17008 vec_free (locator_set_name);
17009 vec_free (locators);
17012 vec_add1 (locator_set_name, 0);
17014 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
17016 /* Construct the API message */
17017 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
17019 mp->is_add = is_add;
17020 clib_memcpy (mp->locator_set_name, locator_set_name,
17021 vec_len (locator_set_name));
17022 vec_free (locator_set_name);
17024 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
17026 clib_memcpy (mp->locators, locators, data_len);
17027 vec_free (locators);
17032 /* Wait for a reply... */
17037 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
17040 api_one_add_del_locator (vat_main_t * vam)
17042 unformat_input_t *input = vam->input;
17043 vl_api_one_add_del_locator_t *mp;
17044 u32 tmp_if_index = ~0;
17045 u32 sw_if_index = ~0;
17046 u8 sw_if_index_set = 0;
17047 u8 sw_if_index_if_name_set = 0;
17049 u8 priority_set = 0;
17053 u8 *locator_set_name = NULL;
17054 u8 locator_set_name_set = 0;
17057 /* Parse args required to build the message */
17058 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17060 if (unformat (input, "del"))
17064 else if (unformat (input, "locator-set %s", &locator_set_name))
17066 locator_set_name_set = 1;
17068 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
17071 sw_if_index_if_name_set = 1;
17072 sw_if_index = tmp_if_index;
17074 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
17076 sw_if_index_set = 1;
17077 sw_if_index = tmp_if_index;
17079 else if (unformat (input, "p %d", &priority))
17083 else if (unformat (input, "w %d", &weight))
17091 if (locator_set_name_set == 0)
17093 errmsg ("missing locator-set name");
17097 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
17099 errmsg ("missing sw_if_index");
17100 vec_free (locator_set_name);
17104 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
17106 errmsg ("cannot use both params interface name and sw_if_index");
17107 vec_free (locator_set_name);
17111 if (priority_set == 0)
17113 errmsg ("missing locator-set priority");
17114 vec_free (locator_set_name);
17118 if (weight_set == 0)
17120 errmsg ("missing locator-set weight");
17121 vec_free (locator_set_name);
17125 if (vec_len (locator_set_name) > 64)
17127 errmsg ("locator-set name too long");
17128 vec_free (locator_set_name);
17131 vec_add1 (locator_set_name, 0);
17133 /* Construct the API message */
17134 M (ONE_ADD_DEL_LOCATOR, mp);
17136 mp->is_add = is_add;
17137 mp->sw_if_index = ntohl (sw_if_index);
17138 mp->priority = priority;
17139 mp->weight = weight;
17140 clib_memcpy (mp->locator_set_name, locator_set_name,
17141 vec_len (locator_set_name));
17142 vec_free (locator_set_name);
17147 /* Wait for a reply... */
17152 #define api_lisp_add_del_locator api_one_add_del_locator
17155 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
17157 u32 *key_id = va_arg (*args, u32 *);
17160 if (unformat (input, "%s", &s))
17162 if (!strcmp ((char *) s, "sha1"))
17163 key_id[0] = HMAC_SHA_1_96;
17164 else if (!strcmp ((char *) s, "sha256"))
17165 key_id[0] = HMAC_SHA_256_128;
17168 clib_warning ("invalid key_id: '%s'", s);
17169 key_id[0] = HMAC_NO_KEY;
17180 api_one_add_del_local_eid (vat_main_t * vam)
17182 unformat_input_t *input = vam->input;
17183 vl_api_one_add_del_local_eid_t *mp;
17186 lisp_eid_vat_t _eid, *eid = &_eid;
17187 u8 *locator_set_name = 0;
17188 u8 locator_set_name_set = 0;
17194 /* Parse args required to build the message */
17195 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17197 if (unformat (input, "del"))
17201 else if (unformat (input, "vni %d", &vni))
17205 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17209 else if (unformat (input, "locator-set %s", &locator_set_name))
17211 locator_set_name_set = 1;
17213 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17215 else if (unformat (input, "secret-key %_%v%_", &key))
17221 if (locator_set_name_set == 0)
17223 errmsg ("missing locator-set name");
17229 errmsg ("EID address not set!");
17230 vec_free (locator_set_name);
17234 if (key && (0 == key_id))
17236 errmsg ("invalid key_id!");
17240 if (vec_len (key) > 64)
17242 errmsg ("key too long");
17247 if (vec_len (locator_set_name) > 64)
17249 errmsg ("locator-set name too long");
17250 vec_free (locator_set_name);
17253 vec_add1 (locator_set_name, 0);
17255 /* Construct the API message */
17256 M (ONE_ADD_DEL_LOCAL_EID, mp);
17258 mp->is_add = is_add;
17259 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17260 mp->eid_type = eid->type;
17261 mp->prefix_len = eid->len;
17262 mp->vni = clib_host_to_net_u32 (vni);
17263 mp->key_id = clib_host_to_net_u16 (key_id);
17264 clib_memcpy (mp->locator_set_name, locator_set_name,
17265 vec_len (locator_set_name));
17266 clib_memcpy (mp->key, key, vec_len (key));
17268 vec_free (locator_set_name);
17274 /* Wait for a reply... */
17279 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17282 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17284 u32 dp_table = 0, vni = 0;;
17285 unformat_input_t *input = vam->input;
17286 vl_api_gpe_add_del_fwd_entry_t *mp;
17288 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17289 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17290 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17291 u32 action = ~0, w;
17292 ip4_address_t rmt_rloc4, lcl_rloc4;
17293 ip6_address_t rmt_rloc6, lcl_rloc6;
17294 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17297 clib_memset (&rloc, 0, sizeof (rloc));
17299 /* Parse args required to build the message */
17300 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17302 if (unformat (input, "del"))
17304 else if (unformat (input, "add"))
17306 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17310 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17314 else if (unformat (input, "vrf %d", &dp_table))
17316 else if (unformat (input, "bd %d", &dp_table))
17318 else if (unformat (input, "vni %d", &vni))
17320 else if (unformat (input, "w %d", &w))
17324 errmsg ("No RLOC configured for setting priority/weight!");
17327 curr_rloc->weight = w;
17329 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17330 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17334 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17336 vec_add1 (lcl_locs, rloc);
17338 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17339 vec_add1 (rmt_locs, rloc);
17340 /* weight saved in rmt loc */
17341 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17343 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17344 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17347 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17349 vec_add1 (lcl_locs, rloc);
17351 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17352 vec_add1 (rmt_locs, rloc);
17353 /* weight saved in rmt loc */
17354 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17356 else if (unformat (input, "action %d", &action))
17362 clib_warning ("parse error '%U'", format_unformat_error, input);
17369 errmsg ("remote eid addresses not set");
17373 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17375 errmsg ("eid types don't match");
17379 if (0 == rmt_locs && (u32) ~ 0 == action)
17381 errmsg ("action not set for negative mapping");
17385 /* Construct the API message */
17386 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17387 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17389 mp->is_add = is_add;
17390 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17391 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17392 mp->eid_type = rmt_eid->type;
17393 mp->dp_table = clib_host_to_net_u32 (dp_table);
17394 mp->vni = clib_host_to_net_u32 (vni);
17395 mp->rmt_len = rmt_eid->len;
17396 mp->lcl_len = lcl_eid->len;
17397 mp->action = action;
17399 if (0 != rmt_locs && 0 != lcl_locs)
17401 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17402 clib_memcpy (mp->locs, lcl_locs,
17403 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17405 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17406 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17407 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17409 vec_free (lcl_locs);
17410 vec_free (rmt_locs);
17415 /* Wait for a reply... */
17421 api_one_add_del_map_server (vat_main_t * vam)
17423 unformat_input_t *input = vam->input;
17424 vl_api_one_add_del_map_server_t *mp;
17428 ip4_address_t ipv4;
17429 ip6_address_t ipv6;
17432 /* Parse args required to build the message */
17433 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17435 if (unformat (input, "del"))
17439 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17443 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17451 if (ipv4_set && ipv6_set)
17453 errmsg ("both eid v4 and v6 addresses set");
17457 if (!ipv4_set && !ipv6_set)
17459 errmsg ("eid addresses not set");
17463 /* Construct the API message */
17464 M (ONE_ADD_DEL_MAP_SERVER, mp);
17466 mp->is_add = is_add;
17470 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17475 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17481 /* Wait for a reply... */
17486 #define api_lisp_add_del_map_server api_one_add_del_map_server
17489 api_one_add_del_map_resolver (vat_main_t * vam)
17491 unformat_input_t *input = vam->input;
17492 vl_api_one_add_del_map_resolver_t *mp;
17496 ip4_address_t ipv4;
17497 ip6_address_t ipv6;
17500 /* Parse args required to build the message */
17501 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17503 if (unformat (input, "del"))
17507 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17511 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17519 if (ipv4_set && ipv6_set)
17521 errmsg ("both eid v4 and v6 addresses set");
17525 if (!ipv4_set && !ipv6_set)
17527 errmsg ("eid addresses not set");
17531 /* Construct the API message */
17532 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17534 mp->is_add = is_add;
17538 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17543 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17549 /* Wait for a reply... */
17554 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17557 api_lisp_gpe_enable_disable (vat_main_t * vam)
17559 unformat_input_t *input = vam->input;
17560 vl_api_gpe_enable_disable_t *mp;
17565 /* Parse args required to build the message */
17566 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17568 if (unformat (input, "enable"))
17573 else if (unformat (input, "disable"))
17584 errmsg ("Value not set");
17588 /* Construct the API message */
17589 M (GPE_ENABLE_DISABLE, mp);
17596 /* Wait for a reply... */
17602 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17604 unformat_input_t *input = vam->input;
17605 vl_api_one_rloc_probe_enable_disable_t *mp;
17610 /* Parse args required to build the message */
17611 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17613 if (unformat (input, "enable"))
17618 else if (unformat (input, "disable"))
17626 errmsg ("Value not set");
17630 /* Construct the API message */
17631 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17633 mp->is_enabled = is_en;
17638 /* Wait for a reply... */
17643 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17646 api_one_map_register_enable_disable (vat_main_t * vam)
17648 unformat_input_t *input = vam->input;
17649 vl_api_one_map_register_enable_disable_t *mp;
17654 /* Parse args required to build the message */
17655 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17657 if (unformat (input, "enable"))
17662 else if (unformat (input, "disable"))
17670 errmsg ("Value not set");
17674 /* Construct the API message */
17675 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17677 mp->is_enabled = is_en;
17682 /* Wait for a reply... */
17687 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17690 api_one_enable_disable (vat_main_t * vam)
17692 unformat_input_t *input = vam->input;
17693 vl_api_one_enable_disable_t *mp;
17698 /* Parse args required to build the message */
17699 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17701 if (unformat (input, "enable"))
17706 else if (unformat (input, "disable"))
17716 errmsg ("Value not set");
17720 /* Construct the API message */
17721 M (ONE_ENABLE_DISABLE, mp);
17728 /* Wait for a reply... */
17733 #define api_lisp_enable_disable api_one_enable_disable
17736 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17738 unformat_input_t *input = vam->input;
17739 vl_api_one_enable_disable_xtr_mode_t *mp;
17744 /* Parse args required to build the message */
17745 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17747 if (unformat (input, "enable"))
17752 else if (unformat (input, "disable"))
17762 errmsg ("Value not set");
17766 /* Construct the API message */
17767 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17774 /* Wait for a reply... */
17780 api_one_show_xtr_mode (vat_main_t * vam)
17782 vl_api_one_show_xtr_mode_t *mp;
17785 /* Construct the API message */
17786 M (ONE_SHOW_XTR_MODE, mp);
17791 /* Wait for a reply... */
17797 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17799 unformat_input_t *input = vam->input;
17800 vl_api_one_enable_disable_pitr_mode_t *mp;
17805 /* Parse args required to build the message */
17806 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17808 if (unformat (input, "enable"))
17813 else if (unformat (input, "disable"))
17823 errmsg ("Value not set");
17827 /* Construct the API message */
17828 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17835 /* Wait for a reply... */
17841 api_one_show_pitr_mode (vat_main_t * vam)
17843 vl_api_one_show_pitr_mode_t *mp;
17846 /* Construct the API message */
17847 M (ONE_SHOW_PITR_MODE, mp);
17852 /* Wait for a reply... */
17858 api_one_enable_disable_petr_mode (vat_main_t * vam)
17860 unformat_input_t *input = vam->input;
17861 vl_api_one_enable_disable_petr_mode_t *mp;
17866 /* Parse args required to build the message */
17867 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17869 if (unformat (input, "enable"))
17874 else if (unformat (input, "disable"))
17884 errmsg ("Value not set");
17888 /* Construct the API message */
17889 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17896 /* Wait for a reply... */
17902 api_one_show_petr_mode (vat_main_t * vam)
17904 vl_api_one_show_petr_mode_t *mp;
17907 /* Construct the API message */
17908 M (ONE_SHOW_PETR_MODE, mp);
17913 /* Wait for a reply... */
17919 api_show_one_map_register_state (vat_main_t * vam)
17921 vl_api_show_one_map_register_state_t *mp;
17924 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17929 /* wait for reply */
17934 #define api_show_lisp_map_register_state api_show_one_map_register_state
17937 api_show_one_rloc_probe_state (vat_main_t * vam)
17939 vl_api_show_one_rloc_probe_state_t *mp;
17942 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17947 /* wait for reply */
17952 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17955 api_one_add_del_ndp_entry (vat_main_t * vam)
17957 vl_api_one_add_del_ndp_entry_t *mp;
17958 unformat_input_t *input = vam->input;
17963 u8 mac[6] = { 0, };
17964 u8 ip6[16] = { 0, };
17968 /* Parse args required to build the message */
17969 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17971 if (unformat (input, "del"))
17973 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17975 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17977 else if (unformat (input, "bd %d", &bd))
17981 errmsg ("parse error '%U'", format_unformat_error, input);
17986 if (!bd_set || !ip_set || (!mac_set && is_add))
17988 errmsg ("Missing BD, IP or MAC!");
17992 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17993 mp->is_add = is_add;
17994 clib_memcpy (mp->mac, mac, 6);
17995 mp->bd = clib_host_to_net_u32 (bd);
17996 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
18001 /* wait for reply */
18007 api_one_add_del_l2_arp_entry (vat_main_t * vam)
18009 vl_api_one_add_del_l2_arp_entry_t *mp;
18010 unformat_input_t *input = vam->input;
18015 u8 mac[6] = { 0, };
18016 u32 ip4 = 0, bd = ~0;
18019 /* Parse args required to build the message */
18020 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18022 if (unformat (input, "del"))
18024 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
18026 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
18028 else if (unformat (input, "bd %d", &bd))
18032 errmsg ("parse error '%U'", format_unformat_error, input);
18037 if (!bd_set || !ip_set || (!mac_set && is_add))
18039 errmsg ("Missing BD, IP or MAC!");
18043 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
18044 mp->is_add = is_add;
18045 clib_memcpy (mp->mac, mac, 6);
18046 mp->bd = clib_host_to_net_u32 (bd);
18052 /* wait for reply */
18058 api_one_ndp_bd_get (vat_main_t * vam)
18060 vl_api_one_ndp_bd_get_t *mp;
18063 M (ONE_NDP_BD_GET, mp);
18068 /* wait for reply */
18074 api_one_ndp_entries_get (vat_main_t * vam)
18076 vl_api_one_ndp_entries_get_t *mp;
18077 unformat_input_t *input = vam->input;
18082 /* Parse args required to build the message */
18083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18085 if (unformat (input, "bd %d", &bd))
18089 errmsg ("parse error '%U'", format_unformat_error, input);
18096 errmsg ("Expected bridge domain!");
18100 M (ONE_NDP_ENTRIES_GET, mp);
18101 mp->bd = clib_host_to_net_u32 (bd);
18106 /* wait for reply */
18112 api_one_l2_arp_bd_get (vat_main_t * vam)
18114 vl_api_one_l2_arp_bd_get_t *mp;
18117 M (ONE_L2_ARP_BD_GET, mp);
18122 /* wait for reply */
18128 api_one_l2_arp_entries_get (vat_main_t * vam)
18130 vl_api_one_l2_arp_entries_get_t *mp;
18131 unformat_input_t *input = vam->input;
18136 /* Parse args required to build the message */
18137 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18139 if (unformat (input, "bd %d", &bd))
18143 errmsg ("parse error '%U'", format_unformat_error, input);
18150 errmsg ("Expected bridge domain!");
18154 M (ONE_L2_ARP_ENTRIES_GET, mp);
18155 mp->bd = clib_host_to_net_u32 (bd);
18160 /* wait for reply */
18166 api_one_stats_enable_disable (vat_main_t * vam)
18168 vl_api_one_stats_enable_disable_t *mp;
18169 unformat_input_t *input = vam->input;
18174 /* Parse args required to build the message */
18175 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18177 if (unformat (input, "enable"))
18182 else if (unformat (input, "disable"))
18192 errmsg ("Value not set");
18196 M (ONE_STATS_ENABLE_DISABLE, mp);
18202 /* wait for reply */
18208 api_show_one_stats_enable_disable (vat_main_t * vam)
18210 vl_api_show_one_stats_enable_disable_t *mp;
18213 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18218 /* wait for reply */
18224 api_show_one_map_request_mode (vat_main_t * vam)
18226 vl_api_show_one_map_request_mode_t *mp;
18229 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18234 /* wait for reply */
18239 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18242 api_one_map_request_mode (vat_main_t * vam)
18244 unformat_input_t *input = vam->input;
18245 vl_api_one_map_request_mode_t *mp;
18249 /* Parse args required to build the message */
18250 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18252 if (unformat (input, "dst-only"))
18254 else if (unformat (input, "src-dst"))
18258 errmsg ("parse error '%U'", format_unformat_error, input);
18263 M (ONE_MAP_REQUEST_MODE, mp);
18270 /* wait for reply */
18275 #define api_lisp_map_request_mode api_one_map_request_mode
18278 * Enable/disable ONE proxy ITR.
18280 * @param vam vpp API test context
18281 * @return return code
18284 api_one_pitr_set_locator_set (vat_main_t * vam)
18286 u8 ls_name_set = 0;
18287 unformat_input_t *input = vam->input;
18288 vl_api_one_pitr_set_locator_set_t *mp;
18293 /* Parse args required to build the message */
18294 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18296 if (unformat (input, "del"))
18298 else if (unformat (input, "locator-set %s", &ls_name))
18302 errmsg ("parse error '%U'", format_unformat_error, input);
18309 errmsg ("locator-set name not set!");
18313 M (ONE_PITR_SET_LOCATOR_SET, mp);
18315 mp->is_add = is_add;
18316 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18317 vec_free (ls_name);
18322 /* wait for reply */
18327 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18330 api_one_nsh_set_locator_set (vat_main_t * vam)
18332 u8 ls_name_set = 0;
18333 unformat_input_t *input = vam->input;
18334 vl_api_one_nsh_set_locator_set_t *mp;
18339 /* Parse args required to build the message */
18340 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18342 if (unformat (input, "del"))
18344 else if (unformat (input, "ls %s", &ls_name))
18348 errmsg ("parse error '%U'", format_unformat_error, input);
18353 if (!ls_name_set && is_add)
18355 errmsg ("locator-set name not set!");
18359 M (ONE_NSH_SET_LOCATOR_SET, mp);
18361 mp->is_add = is_add;
18362 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18363 vec_free (ls_name);
18368 /* wait for reply */
18374 api_show_one_pitr (vat_main_t * vam)
18376 vl_api_show_one_pitr_t *mp;
18379 if (!vam->json_output)
18381 print (vam->ofp, "%=20s", "lisp status:");
18384 M (SHOW_ONE_PITR, mp);
18388 /* Wait for a reply... */
18393 #define api_show_lisp_pitr api_show_one_pitr
18396 api_one_use_petr (vat_main_t * vam)
18398 unformat_input_t *input = vam->input;
18399 vl_api_one_use_petr_t *mp;
18404 clib_memset (&ip, 0, sizeof (ip));
18406 /* Parse args required to build the message */
18407 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18409 if (unformat (input, "disable"))
18412 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18415 ip_addr_version (&ip) = IP4;
18418 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18421 ip_addr_version (&ip) = IP6;
18425 errmsg ("parse error '%U'", format_unformat_error, input);
18430 M (ONE_USE_PETR, mp);
18432 mp->is_add = is_add;
18435 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18437 clib_memcpy (mp->address, &ip, 4);
18439 clib_memcpy (mp->address, &ip, 16);
18445 /* wait for reply */
18450 #define api_lisp_use_petr api_one_use_petr
18453 api_show_one_nsh_mapping (vat_main_t * vam)
18455 vl_api_show_one_use_petr_t *mp;
18458 if (!vam->json_output)
18460 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18463 M (SHOW_ONE_NSH_MAPPING, mp);
18467 /* Wait for a reply... */
18473 api_show_one_use_petr (vat_main_t * vam)
18475 vl_api_show_one_use_petr_t *mp;
18478 if (!vam->json_output)
18480 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18483 M (SHOW_ONE_USE_PETR, mp);
18487 /* Wait for a reply... */
18492 #define api_show_lisp_use_petr api_show_one_use_petr
18495 * Add/delete mapping between vni and vrf
18498 api_one_eid_table_add_del_map (vat_main_t * vam)
18500 unformat_input_t *input = vam->input;
18501 vl_api_one_eid_table_add_del_map_t *mp;
18502 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18503 u32 vni, vrf, bd_index;
18506 /* Parse args required to build the message */
18507 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18509 if (unformat (input, "del"))
18511 else if (unformat (input, "vrf %d", &vrf))
18513 else if (unformat (input, "bd_index %d", &bd_index))
18515 else if (unformat (input, "vni %d", &vni))
18521 if (!vni_set || (!vrf_set && !bd_index_set))
18523 errmsg ("missing arguments!");
18527 if (vrf_set && bd_index_set)
18529 errmsg ("error: both vrf and bd entered!");
18533 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18535 mp->is_add = is_add;
18536 mp->vni = htonl (vni);
18537 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18538 mp->is_l2 = bd_index_set;
18543 /* wait for reply */
18548 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18551 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18553 u32 *action = va_arg (*args, u32 *);
18556 if (unformat (input, "%s", &s))
18558 if (!strcmp ((char *) s, "no-action"))
18560 else if (!strcmp ((char *) s, "natively-forward"))
18562 else if (!strcmp ((char *) s, "send-map-request"))
18564 else if (!strcmp ((char *) s, "drop"))
18568 clib_warning ("invalid action: '%s'", s);
18580 * Add/del remote mapping to/from ONE control plane
18582 * @param vam vpp API test context
18583 * @return return code
18586 api_one_add_del_remote_mapping (vat_main_t * vam)
18588 unformat_input_t *input = vam->input;
18589 vl_api_one_add_del_remote_mapping_t *mp;
18591 lisp_eid_vat_t _eid, *eid = &_eid;
18592 lisp_eid_vat_t _seid, *seid = &_seid;
18593 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18594 u32 action = ~0, p, w, data_len;
18595 ip4_address_t rloc4;
18596 ip6_address_t rloc6;
18597 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18600 clib_memset (&rloc, 0, sizeof (rloc));
18602 /* Parse args required to build the message */
18603 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18605 if (unformat (input, "del-all"))
18609 else if (unformat (input, "del"))
18613 else if (unformat (input, "add"))
18617 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18621 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18625 else if (unformat (input, "vni %d", &vni))
18629 else if (unformat (input, "p %d w %d", &p, &w))
18633 errmsg ("No RLOC configured for setting priority/weight!");
18636 curr_rloc->priority = p;
18637 curr_rloc->weight = w;
18639 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18642 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18643 vec_add1 (rlocs, rloc);
18644 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18646 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18649 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18650 vec_add1 (rlocs, rloc);
18651 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18653 else if (unformat (input, "action %U",
18654 unformat_negative_mapping_action, &action))
18660 clib_warning ("parse error '%U'", format_unformat_error, input);
18667 errmsg ("missing params!");
18671 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18673 errmsg ("no action set for negative map-reply!");
18677 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18679 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18680 mp->is_add = is_add;
18681 mp->vni = htonl (vni);
18682 mp->action = (u8) action;
18683 mp->is_src_dst = seid_set;
18684 mp->eid_len = eid->len;
18685 mp->seid_len = seid->len;
18686 mp->del_all = del_all;
18687 mp->eid_type = eid->type;
18688 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18689 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18691 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18692 clib_memcpy (mp->rlocs, rlocs, data_len);
18698 /* Wait for a reply... */
18703 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18706 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18707 * forwarding entries in data-plane accordingly.
18709 * @param vam vpp API test context
18710 * @return return code
18713 api_one_add_del_adjacency (vat_main_t * vam)
18715 unformat_input_t *input = vam->input;
18716 vl_api_one_add_del_adjacency_t *mp;
18718 ip4_address_t leid4, reid4;
18719 ip6_address_t leid6, reid6;
18720 u8 reid_mac[6] = { 0 };
18721 u8 leid_mac[6] = { 0 };
18722 u8 reid_type, leid_type;
18723 u32 leid_len = 0, reid_len = 0, len;
18727 leid_type = reid_type = (u8) ~ 0;
18729 /* Parse args required to build the message */
18730 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18732 if (unformat (input, "del"))
18736 else if (unformat (input, "add"))
18740 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18743 reid_type = 0; /* ipv4 */
18746 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18749 reid_type = 1; /* ipv6 */
18752 else if (unformat (input, "reid %U", unformat_ethernet_address,
18755 reid_type = 2; /* mac */
18757 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18760 leid_type = 0; /* ipv4 */
18763 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18766 leid_type = 1; /* ipv6 */
18769 else if (unformat (input, "leid %U", unformat_ethernet_address,
18772 leid_type = 2; /* mac */
18774 else if (unformat (input, "vni %d", &vni))
18780 errmsg ("parse error '%U'", format_unformat_error, input);
18785 if ((u8) ~ 0 == reid_type)
18787 errmsg ("missing params!");
18791 if (leid_type != reid_type)
18793 errmsg ("remote and local EIDs are of different types!");
18797 M (ONE_ADD_DEL_ADJACENCY, mp);
18798 mp->is_add = is_add;
18799 mp->vni = htonl (vni);
18800 mp->leid_len = leid_len;
18801 mp->reid_len = reid_len;
18802 mp->eid_type = reid_type;
18804 switch (mp->eid_type)
18807 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18808 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18811 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18812 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18815 clib_memcpy (mp->leid, leid_mac, 6);
18816 clib_memcpy (mp->reid, reid_mac, 6);
18819 errmsg ("unknown EID type %d!", mp->eid_type);
18826 /* Wait for a reply... */
18831 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18834 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18836 u32 *mode = va_arg (*args, u32 *);
18838 if (unformat (input, "lisp"))
18840 else if (unformat (input, "vxlan"))
18849 api_gpe_get_encap_mode (vat_main_t * vam)
18851 vl_api_gpe_get_encap_mode_t *mp;
18854 /* Construct the API message */
18855 M (GPE_GET_ENCAP_MODE, mp);
18860 /* Wait for a reply... */
18866 api_gpe_set_encap_mode (vat_main_t * vam)
18868 unformat_input_t *input = vam->input;
18869 vl_api_gpe_set_encap_mode_t *mp;
18873 /* Parse args required to build the message */
18874 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18876 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18882 /* Construct the API message */
18883 M (GPE_SET_ENCAP_MODE, mp);
18890 /* Wait for a reply... */
18896 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18898 unformat_input_t *input = vam->input;
18899 vl_api_gpe_add_del_iface_t *mp;
18900 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18901 u32 dp_table = 0, vni = 0;
18904 /* Parse args required to build the message */
18905 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18907 if (unformat (input, "up"))
18912 else if (unformat (input, "down"))
18917 else if (unformat (input, "table_id %d", &dp_table))
18921 else if (unformat (input, "bd_id %d", &dp_table))
18926 else if (unformat (input, "vni %d", &vni))
18934 if (action_set == 0)
18936 errmsg ("Action not set");
18939 if (dp_table_set == 0 || vni_set == 0)
18941 errmsg ("vni and dp_table must be set");
18945 /* Construct the API message */
18946 M (GPE_ADD_DEL_IFACE, mp);
18948 mp->is_add = is_add;
18949 mp->dp_table = clib_host_to_net_u32 (dp_table);
18951 mp->vni = clib_host_to_net_u32 (vni);
18956 /* Wait for a reply... */
18962 api_one_map_register_fallback_threshold (vat_main_t * vam)
18964 unformat_input_t *input = vam->input;
18965 vl_api_one_map_register_fallback_threshold_t *mp;
18970 /* Parse args required to build the message */
18971 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18973 if (unformat (input, "%u", &value))
18977 clib_warning ("parse error '%U'", format_unformat_error, input);
18984 errmsg ("fallback threshold value is missing!");
18988 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18989 mp->value = clib_host_to_net_u32 (value);
18994 /* Wait for a reply... */
19000 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
19002 vl_api_show_one_map_register_fallback_threshold_t *mp;
19005 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
19010 /* Wait for a reply... */
19016 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
19018 u32 *proto = va_arg (*args, u32 *);
19020 if (unformat (input, "udp"))
19022 else if (unformat (input, "api"))
19031 api_one_set_transport_protocol (vat_main_t * vam)
19033 unformat_input_t *input = vam->input;
19034 vl_api_one_set_transport_protocol_t *mp;
19039 /* Parse args required to build the message */
19040 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19042 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
19046 clib_warning ("parse error '%U'", format_unformat_error, input);
19053 errmsg ("Transport protocol missing!");
19057 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
19058 mp->protocol = (u8) protocol;
19063 /* Wait for a reply... */
19069 api_one_get_transport_protocol (vat_main_t * vam)
19071 vl_api_one_get_transport_protocol_t *mp;
19074 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
19079 /* Wait for a reply... */
19085 api_one_map_register_set_ttl (vat_main_t * vam)
19087 unformat_input_t *input = vam->input;
19088 vl_api_one_map_register_set_ttl_t *mp;
19093 /* Parse args required to build the message */
19094 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19096 if (unformat (input, "%u", &ttl))
19100 clib_warning ("parse error '%U'", format_unformat_error, input);
19107 errmsg ("TTL value missing!");
19111 M (ONE_MAP_REGISTER_SET_TTL, mp);
19112 mp->ttl = clib_host_to_net_u32 (ttl);
19117 /* Wait for a reply... */
19123 api_show_one_map_register_ttl (vat_main_t * vam)
19125 vl_api_show_one_map_register_ttl_t *mp;
19128 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
19133 /* Wait for a reply... */
19139 * Add/del map request itr rlocs from ONE control plane and updates
19141 * @param vam vpp API test context
19142 * @return return code
19145 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
19147 unformat_input_t *input = vam->input;
19148 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
19149 u8 *locator_set_name = 0;
19150 u8 locator_set_name_set = 0;
19154 /* Parse args required to build the message */
19155 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19157 if (unformat (input, "del"))
19161 else if (unformat (input, "%_%v%_", &locator_set_name))
19163 locator_set_name_set = 1;
19167 clib_warning ("parse error '%U'", format_unformat_error, input);
19172 if (is_add && !locator_set_name_set)
19174 errmsg ("itr-rloc is not set!");
19178 if (is_add && vec_len (locator_set_name) > 64)
19180 errmsg ("itr-rloc locator-set name too long");
19181 vec_free (locator_set_name);
19185 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
19186 mp->is_add = is_add;
19189 clib_memcpy (mp->locator_set_name, locator_set_name,
19190 vec_len (locator_set_name));
19194 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19196 vec_free (locator_set_name);
19201 /* Wait for a reply... */
19206 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19209 api_one_locator_dump (vat_main_t * vam)
19211 unformat_input_t *input = vam->input;
19212 vl_api_one_locator_dump_t *mp;
19213 vl_api_control_ping_t *mp_ping;
19214 u8 is_index_set = 0, is_name_set = 0;
19219 /* Parse args required to build the message */
19220 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19222 if (unformat (input, "ls_name %_%v%_", &ls_name))
19226 else if (unformat (input, "ls_index %d", &ls_index))
19232 errmsg ("parse error '%U'", format_unformat_error, input);
19237 if (!is_index_set && !is_name_set)
19239 errmsg ("error: expected one of index or name!");
19243 if (is_index_set && is_name_set)
19245 errmsg ("error: only one param expected!");
19249 if (vec_len (ls_name) > 62)
19251 errmsg ("error: locator set name too long!");
19255 if (!vam->json_output)
19257 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19260 M (ONE_LOCATOR_DUMP, mp);
19261 mp->is_index_set = is_index_set;
19264 mp->ls_index = clib_host_to_net_u32 (ls_index);
19267 vec_add1 (ls_name, 0);
19268 strncpy ((char *) mp->ls_name, (char *) ls_name,
19269 sizeof (mp->ls_name) - 1);
19275 /* Use a control ping for synchronization */
19276 MPING (CONTROL_PING, mp_ping);
19279 /* Wait for a reply... */
19284 #define api_lisp_locator_dump api_one_locator_dump
19287 api_one_locator_set_dump (vat_main_t * vam)
19289 vl_api_one_locator_set_dump_t *mp;
19290 vl_api_control_ping_t *mp_ping;
19291 unformat_input_t *input = vam->input;
19295 /* Parse args required to build the message */
19296 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19298 if (unformat (input, "local"))
19302 else if (unformat (input, "remote"))
19308 errmsg ("parse error '%U'", format_unformat_error, input);
19313 if (!vam->json_output)
19315 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19318 M (ONE_LOCATOR_SET_DUMP, mp);
19320 mp->filter = filter;
19325 /* Use a control ping for synchronization */
19326 MPING (CONTROL_PING, mp_ping);
19329 /* Wait for a reply... */
19334 #define api_lisp_locator_set_dump api_one_locator_set_dump
19337 api_one_eid_table_map_dump (vat_main_t * vam)
19341 unformat_input_t *input = vam->input;
19342 vl_api_one_eid_table_map_dump_t *mp;
19343 vl_api_control_ping_t *mp_ping;
19346 /* Parse args required to build the message */
19347 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19349 if (unformat (input, "l2"))
19354 else if (unformat (input, "l3"))
19361 errmsg ("parse error '%U'", format_unformat_error, input);
19368 errmsg ("expected one of 'l2' or 'l3' parameter!");
19372 if (!vam->json_output)
19374 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19377 M (ONE_EID_TABLE_MAP_DUMP, mp);
19383 /* Use a control ping for synchronization */
19384 MPING (CONTROL_PING, mp_ping);
19387 /* Wait for a reply... */
19392 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19395 api_one_eid_table_vni_dump (vat_main_t * vam)
19397 vl_api_one_eid_table_vni_dump_t *mp;
19398 vl_api_control_ping_t *mp_ping;
19401 if (!vam->json_output)
19403 print (vam->ofp, "VNI");
19406 M (ONE_EID_TABLE_VNI_DUMP, mp);
19411 /* Use a control ping for synchronization */
19412 MPING (CONTROL_PING, mp_ping);
19415 /* Wait for a reply... */
19420 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19423 api_one_eid_table_dump (vat_main_t * vam)
19425 unformat_input_t *i = vam->input;
19426 vl_api_one_eid_table_dump_t *mp;
19427 vl_api_control_ping_t *mp_ping;
19428 struct in_addr ip4;
19429 struct in6_addr ip6;
19431 u8 eid_type = ~0, eid_set = 0;
19432 u32 prefix_length = ~0, t, vni = 0;
19435 lisp_nsh_api_t nsh;
19437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19439 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19445 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19451 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19456 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19461 else if (unformat (i, "vni %d", &t))
19465 else if (unformat (i, "local"))
19469 else if (unformat (i, "remote"))
19475 errmsg ("parse error '%U'", format_unformat_error, i);
19480 if (!vam->json_output)
19482 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19483 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19486 M (ONE_EID_TABLE_DUMP, mp);
19488 mp->filter = filter;
19492 mp->vni = htonl (vni);
19493 mp->eid_type = eid_type;
19497 mp->prefix_length = prefix_length;
19498 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19501 mp->prefix_length = prefix_length;
19502 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19505 clib_memcpy (mp->eid, mac, sizeof (mac));
19508 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19511 errmsg ("unknown EID type %d!", eid_type);
19519 /* Use a control ping for synchronization */
19520 MPING (CONTROL_PING, mp_ping);
19523 /* Wait for a reply... */
19528 #define api_lisp_eid_table_dump api_one_eid_table_dump
19531 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19533 unformat_input_t *i = vam->input;
19534 vl_api_gpe_fwd_entries_get_t *mp;
19539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19541 if (unformat (i, "vni %d", &vni))
19547 errmsg ("parse error '%U'", format_unformat_error, i);
19554 errmsg ("vni not set!");
19558 if (!vam->json_output)
19560 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19564 M (GPE_FWD_ENTRIES_GET, mp);
19565 mp->vni = clib_host_to_net_u32 (vni);
19570 /* Wait for a reply... */
19575 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19576 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19577 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19578 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19579 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19580 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19581 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19582 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19585 api_one_adjacencies_get (vat_main_t * vam)
19587 unformat_input_t *i = vam->input;
19588 vl_api_one_adjacencies_get_t *mp;
19593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19595 if (unformat (i, "vni %d", &vni))
19601 errmsg ("parse error '%U'", format_unformat_error, i);
19608 errmsg ("vni not set!");
19612 if (!vam->json_output)
19614 print (vam->ofp, "%s %40s", "leid", "reid");
19617 M (ONE_ADJACENCIES_GET, mp);
19618 mp->vni = clib_host_to_net_u32 (vni);
19623 /* Wait for a reply... */
19628 #define api_lisp_adjacencies_get api_one_adjacencies_get
19631 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19633 unformat_input_t *i = vam->input;
19634 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19636 u8 ip_family_set = 0, is_ip4 = 1;
19638 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19640 if (unformat (i, "ip4"))
19645 else if (unformat (i, "ip6"))
19652 errmsg ("parse error '%U'", format_unformat_error, i);
19657 if (!ip_family_set)
19659 errmsg ("ip family not set!");
19663 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19664 mp->is_ip4 = is_ip4;
19669 /* Wait for a reply... */
19675 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19677 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19680 if (!vam->json_output)
19682 print (vam->ofp, "VNIs");
19685 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19690 /* Wait for a reply... */
19696 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19698 unformat_input_t *i = vam->input;
19699 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19701 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19702 struct in_addr ip4;
19703 struct in6_addr ip6;
19704 u32 table_id = 0, nh_sw_if_index = ~0;
19706 clib_memset (&ip4, 0, sizeof (ip4));
19707 clib_memset (&ip6, 0, sizeof (ip6));
19709 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19711 if (unformat (i, "del"))
19713 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19714 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19719 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19720 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19725 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19729 nh_sw_if_index = ~0;
19731 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19735 nh_sw_if_index = ~0;
19737 else if (unformat (i, "table %d", &table_id))
19741 errmsg ("parse error '%U'", format_unformat_error, i);
19748 errmsg ("nh addr not set!");
19752 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19753 mp->is_add = is_add;
19754 mp->table_id = clib_host_to_net_u32 (table_id);
19755 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19756 mp->is_ip4 = is_ip4;
19758 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19760 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19765 /* Wait for a reply... */
19771 api_one_map_server_dump (vat_main_t * vam)
19773 vl_api_one_map_server_dump_t *mp;
19774 vl_api_control_ping_t *mp_ping;
19777 if (!vam->json_output)
19779 print (vam->ofp, "%=20s", "Map server");
19782 M (ONE_MAP_SERVER_DUMP, mp);
19786 /* Use a control ping for synchronization */
19787 MPING (CONTROL_PING, mp_ping);
19790 /* Wait for a reply... */
19795 #define api_lisp_map_server_dump api_one_map_server_dump
19798 api_one_map_resolver_dump (vat_main_t * vam)
19800 vl_api_one_map_resolver_dump_t *mp;
19801 vl_api_control_ping_t *mp_ping;
19804 if (!vam->json_output)
19806 print (vam->ofp, "%=20s", "Map resolver");
19809 M (ONE_MAP_RESOLVER_DUMP, mp);
19813 /* Use a control ping for synchronization */
19814 MPING (CONTROL_PING, mp_ping);
19817 /* Wait for a reply... */
19822 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19825 api_one_stats_flush (vat_main_t * vam)
19827 vl_api_one_stats_flush_t *mp;
19830 M (ONE_STATS_FLUSH, mp);
19837 api_one_stats_dump (vat_main_t * vam)
19839 vl_api_one_stats_dump_t *mp;
19840 vl_api_control_ping_t *mp_ping;
19843 M (ONE_STATS_DUMP, mp);
19847 /* Use a control ping for synchronization */
19848 MPING (CONTROL_PING, mp_ping);
19851 /* Wait for a reply... */
19857 api_show_one_status (vat_main_t * vam)
19859 vl_api_show_one_status_t *mp;
19862 if (!vam->json_output)
19864 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19867 M (SHOW_ONE_STATUS, mp);
19870 /* Wait for a reply... */
19875 #define api_show_lisp_status api_show_one_status
19878 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19880 vl_api_gpe_fwd_entry_path_dump_t *mp;
19881 vl_api_control_ping_t *mp_ping;
19882 unformat_input_t *i = vam->input;
19883 u32 fwd_entry_index = ~0;
19886 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19888 if (unformat (i, "index %d", &fwd_entry_index))
19894 if (~0 == fwd_entry_index)
19896 errmsg ("no index specified!");
19900 if (!vam->json_output)
19902 print (vam->ofp, "first line");
19905 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19909 /* Use a control ping for synchronization */
19910 MPING (CONTROL_PING, mp_ping);
19913 /* Wait for a reply... */
19919 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19921 vl_api_one_get_map_request_itr_rlocs_t *mp;
19924 if (!vam->json_output)
19926 print (vam->ofp, "%=20s", "itr-rlocs:");
19929 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19932 /* Wait for a reply... */
19937 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19940 api_af_packet_create (vat_main_t * vam)
19942 unformat_input_t *i = vam->input;
19943 vl_api_af_packet_create_t *mp;
19944 u8 *host_if_name = 0;
19946 u8 random_hw_addr = 1;
19949 clib_memset (hw_addr, 0, sizeof (hw_addr));
19951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19953 if (unformat (i, "name %s", &host_if_name))
19954 vec_add1 (host_if_name, 0);
19955 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19956 random_hw_addr = 0;
19961 if (!vec_len (host_if_name))
19963 errmsg ("host-interface name must be specified");
19967 if (vec_len (host_if_name) > 64)
19969 errmsg ("host-interface name too long");
19973 M (AF_PACKET_CREATE, mp);
19975 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19976 clib_memcpy (mp->hw_addr, hw_addr, 6);
19977 mp->use_random_hw_addr = random_hw_addr;
19978 vec_free (host_if_name);
19986 fprintf (vam->ofp ? vam->ofp : stderr,
19987 " new sw_if_index = %d\n", vam->sw_if_index);
19994 api_af_packet_delete (vat_main_t * vam)
19996 unformat_input_t *i = vam->input;
19997 vl_api_af_packet_delete_t *mp;
19998 u8 *host_if_name = 0;
20001 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20003 if (unformat (i, "name %s", &host_if_name))
20004 vec_add1 (host_if_name, 0);
20009 if (!vec_len (host_if_name))
20011 errmsg ("host-interface name must be specified");
20015 if (vec_len (host_if_name) > 64)
20017 errmsg ("host-interface name too long");
20021 M (AF_PACKET_DELETE, mp);
20023 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
20024 vec_free (host_if_name);
20031 static void vl_api_af_packet_details_t_handler
20032 (vl_api_af_packet_details_t * mp)
20034 vat_main_t *vam = &vat_main;
20036 print (vam->ofp, "%-16s %d",
20037 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
20040 static void vl_api_af_packet_details_t_handler_json
20041 (vl_api_af_packet_details_t * mp)
20043 vat_main_t *vam = &vat_main;
20044 vat_json_node_t *node = NULL;
20046 if (VAT_JSON_ARRAY != vam->json_tree.type)
20048 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20049 vat_json_init_array (&vam->json_tree);
20051 node = vat_json_array_add (&vam->json_tree);
20053 vat_json_init_object (node);
20054 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20055 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
20059 api_af_packet_dump (vat_main_t * vam)
20061 vl_api_af_packet_dump_t *mp;
20062 vl_api_control_ping_t *mp_ping;
20065 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
20066 /* Get list of tap interfaces */
20067 M (AF_PACKET_DUMP, mp);
20070 /* Use a control ping for synchronization */
20071 MPING (CONTROL_PING, mp_ping);
20079 api_policer_add_del (vat_main_t * vam)
20081 unformat_input_t *i = vam->input;
20082 vl_api_policer_add_del_t *mp;
20092 u8 color_aware = 0;
20093 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
20096 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
20097 conform_action.dscp = 0;
20098 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
20099 exceed_action.dscp = 0;
20100 violate_action.action_type = SSE2_QOS_ACTION_DROP;
20101 violate_action.dscp = 0;
20103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20105 if (unformat (i, "del"))
20107 else if (unformat (i, "name %s", &name))
20108 vec_add1 (name, 0);
20109 else if (unformat (i, "cir %u", &cir))
20111 else if (unformat (i, "eir %u", &eir))
20113 else if (unformat (i, "cb %u", &cb))
20115 else if (unformat (i, "eb %u", &eb))
20117 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
20120 else if (unformat (i, "round_type %U", unformat_policer_round_type,
20123 else if (unformat (i, "type %U", unformat_policer_type, &type))
20125 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
20128 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
20131 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
20134 else if (unformat (i, "color-aware"))
20140 if (!vec_len (name))
20142 errmsg ("policer name must be specified");
20146 if (vec_len (name) > 64)
20148 errmsg ("policer name too long");
20152 M (POLICER_ADD_DEL, mp);
20154 clib_memcpy (mp->name, name, vec_len (name));
20156 mp->is_add = is_add;
20157 mp->cir = ntohl (cir);
20158 mp->eir = ntohl (eir);
20159 mp->cb = clib_net_to_host_u64 (cb);
20160 mp->eb = clib_net_to_host_u64 (eb);
20161 mp->rate_type = rate_type;
20162 mp->round_type = round_type;
20164 mp->conform_action_type = conform_action.action_type;
20165 mp->conform_dscp = conform_action.dscp;
20166 mp->exceed_action_type = exceed_action.action_type;
20167 mp->exceed_dscp = exceed_action.dscp;
20168 mp->violate_action_type = violate_action.action_type;
20169 mp->violate_dscp = violate_action.dscp;
20170 mp->color_aware = color_aware;
20178 api_policer_dump (vat_main_t * vam)
20180 unformat_input_t *i = vam->input;
20181 vl_api_policer_dump_t *mp;
20182 vl_api_control_ping_t *mp_ping;
20183 u8 *match_name = 0;
20184 u8 match_name_valid = 0;
20187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20189 if (unformat (i, "name %s", &match_name))
20191 vec_add1 (match_name, 0);
20192 match_name_valid = 1;
20198 M (POLICER_DUMP, mp);
20199 mp->match_name_valid = match_name_valid;
20200 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
20201 vec_free (match_name);
20205 /* Use a control ping for synchronization */
20206 MPING (CONTROL_PING, mp_ping);
20209 /* Wait for a reply... */
20215 api_policer_classify_set_interface (vat_main_t * vam)
20217 unformat_input_t *i = vam->input;
20218 vl_api_policer_classify_set_interface_t *mp;
20220 int sw_if_index_set;
20221 u32 ip4_table_index = ~0;
20222 u32 ip6_table_index = ~0;
20223 u32 l2_table_index = ~0;
20227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20229 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20230 sw_if_index_set = 1;
20231 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20232 sw_if_index_set = 1;
20233 else if (unformat (i, "del"))
20235 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20237 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20239 else if (unformat (i, "l2-table %d", &l2_table_index))
20243 clib_warning ("parse error '%U'", format_unformat_error, i);
20248 if (sw_if_index_set == 0)
20250 errmsg ("missing interface name or sw_if_index");
20254 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20256 mp->sw_if_index = ntohl (sw_if_index);
20257 mp->ip4_table_index = ntohl (ip4_table_index);
20258 mp->ip6_table_index = ntohl (ip6_table_index);
20259 mp->l2_table_index = ntohl (l2_table_index);
20260 mp->is_add = is_add;
20268 api_policer_classify_dump (vat_main_t * vam)
20270 unformat_input_t *i = vam->input;
20271 vl_api_policer_classify_dump_t *mp;
20272 vl_api_control_ping_t *mp_ping;
20273 u8 type = POLICER_CLASSIFY_N_TABLES;
20276 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20280 errmsg ("classify table type must be specified");
20284 if (!vam->json_output)
20286 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20289 M (POLICER_CLASSIFY_DUMP, mp);
20294 /* Use a control ping for synchronization */
20295 MPING (CONTROL_PING, mp_ping);
20298 /* Wait for a reply... */
20304 api_netmap_create (vat_main_t * vam)
20306 unformat_input_t *i = vam->input;
20307 vl_api_netmap_create_t *mp;
20310 u8 random_hw_addr = 1;
20315 clib_memset (hw_addr, 0, sizeof (hw_addr));
20317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20319 if (unformat (i, "name %s", &if_name))
20320 vec_add1 (if_name, 0);
20321 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20322 random_hw_addr = 0;
20323 else if (unformat (i, "pipe"))
20325 else if (unformat (i, "master"))
20327 else if (unformat (i, "slave"))
20333 if (!vec_len (if_name))
20335 errmsg ("interface name must be specified");
20339 if (vec_len (if_name) > 64)
20341 errmsg ("interface name too long");
20345 M (NETMAP_CREATE, mp);
20347 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20348 clib_memcpy (mp->hw_addr, hw_addr, 6);
20349 mp->use_random_hw_addr = random_hw_addr;
20350 mp->is_pipe = is_pipe;
20351 mp->is_master = is_master;
20352 vec_free (if_name);
20360 api_netmap_delete (vat_main_t * vam)
20362 unformat_input_t *i = vam->input;
20363 vl_api_netmap_delete_t *mp;
20367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20369 if (unformat (i, "name %s", &if_name))
20370 vec_add1 (if_name, 0);
20375 if (!vec_len (if_name))
20377 errmsg ("interface name must be specified");
20381 if (vec_len (if_name) > 64)
20383 errmsg ("interface name too long");
20387 M (NETMAP_DELETE, mp);
20389 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20390 vec_free (if_name);
20398 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20400 if (fp->afi == IP46_TYPE_IP6)
20402 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20403 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20404 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
20405 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20406 format_ip6_address, fp->next_hop);
20407 else if (fp->afi == IP46_TYPE_IP4)
20409 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20410 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20411 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
20412 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20413 format_ip4_address, fp->next_hop);
20417 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20418 vl_api_fib_path_t * fp)
20420 struct in_addr ip4;
20421 struct in6_addr ip6;
20423 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20424 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20425 vat_json_object_add_uint (node, "is_local", fp->is_local);
20426 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20427 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20428 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20429 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20430 if (fp->afi == IP46_TYPE_IP4)
20432 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20433 vat_json_object_add_ip4 (node, "next_hop", ip4);
20435 else if (fp->afi == IP46_TYPE_IP6)
20437 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20438 vat_json_object_add_ip6 (node, "next_hop", ip6);
20443 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20445 vat_main_t *vam = &vat_main;
20446 int count = ntohl (mp->mt_count);
20447 vl_api_fib_path_t *fp;
20450 print (vam->ofp, "[%d]: sw_if_index %d via:",
20451 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20453 for (i = 0; i < count; i++)
20455 vl_api_mpls_fib_path_print (vam, fp);
20459 print (vam->ofp, "");
20462 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20463 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20466 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20468 vat_main_t *vam = &vat_main;
20469 vat_json_node_t *node = NULL;
20470 int count = ntohl (mp->mt_count);
20471 vl_api_fib_path_t *fp;
20474 if (VAT_JSON_ARRAY != vam->json_tree.type)
20476 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20477 vat_json_init_array (&vam->json_tree);
20479 node = vat_json_array_add (&vam->json_tree);
20481 vat_json_init_object (node);
20482 vat_json_object_add_uint (node, "tunnel_index",
20483 ntohl (mp->mt_tunnel_index));
20484 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20486 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20489 for (i = 0; i < count; i++)
20491 vl_api_mpls_fib_path_json_print (node, fp);
20497 api_mpls_tunnel_dump (vat_main_t * vam)
20499 vl_api_mpls_tunnel_dump_t *mp;
20500 vl_api_control_ping_t *mp_ping;
20501 u32 sw_if_index = ~0;
20504 /* Parse args required to build the message */
20505 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20507 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
20511 print (vam->ofp, " sw_if_index %d", sw_if_index);
20513 M (MPLS_TUNNEL_DUMP, mp);
20514 mp->sw_if_index = htonl (sw_if_index);
20517 /* Use a control ping for synchronization */
20518 MPING (CONTROL_PING, mp_ping);
20525 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20526 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20530 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20532 vat_main_t *vam = &vat_main;
20533 int count = ntohl (mp->count);
20534 vl_api_fib_path_t *fp;
20538 "table-id %d, label %u, ess_bit %u",
20539 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20541 for (i = 0; i < count; i++)
20543 vl_api_mpls_fib_path_print (vam, fp);
20548 static void vl_api_mpls_fib_details_t_handler_json
20549 (vl_api_mpls_fib_details_t * mp)
20551 vat_main_t *vam = &vat_main;
20552 int count = ntohl (mp->count);
20553 vat_json_node_t *node = NULL;
20554 vl_api_fib_path_t *fp;
20557 if (VAT_JSON_ARRAY != vam->json_tree.type)
20559 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20560 vat_json_init_array (&vam->json_tree);
20562 node = vat_json_array_add (&vam->json_tree);
20564 vat_json_init_object (node);
20565 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20566 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20567 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20568 vat_json_object_add_uint (node, "path_count", count);
20570 for (i = 0; i < count; i++)
20572 vl_api_mpls_fib_path_json_print (node, fp);
20578 api_mpls_fib_dump (vat_main_t * vam)
20580 vl_api_mpls_fib_dump_t *mp;
20581 vl_api_control_ping_t *mp_ping;
20584 M (MPLS_FIB_DUMP, mp);
20587 /* Use a control ping for synchronization */
20588 MPING (CONTROL_PING, mp_ping);
20595 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20596 #define vl_api_ip_fib_details_t_print vl_noop_handler
20599 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20601 vat_main_t *vam = &vat_main;
20602 int count = ntohl (mp->count);
20603 vl_api_fib_path_t *fp;
20607 "table-id %d, prefix %U/%d stats-index %d",
20608 ntohl (mp->table_id), format_ip4_address, mp->address,
20609 mp->address_length, ntohl (mp->stats_index));
20611 for (i = 0; i < count; i++)
20613 if (fp->afi == IP46_TYPE_IP6)
20615 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20616 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20617 "next_hop_table %d",
20618 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20619 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20620 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20621 else if (fp->afi == IP46_TYPE_IP4)
20623 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20624 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20625 "next_hop_table %d",
20626 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20627 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20628 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20633 static void vl_api_ip_fib_details_t_handler_json
20634 (vl_api_ip_fib_details_t * mp)
20636 vat_main_t *vam = &vat_main;
20637 int count = ntohl (mp->count);
20638 vat_json_node_t *node = NULL;
20639 struct in_addr ip4;
20640 struct in6_addr ip6;
20641 vl_api_fib_path_t *fp;
20644 if (VAT_JSON_ARRAY != vam->json_tree.type)
20646 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20647 vat_json_init_array (&vam->json_tree);
20649 node = vat_json_array_add (&vam->json_tree);
20651 vat_json_init_object (node);
20652 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20653 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20654 vat_json_object_add_ip4 (node, "prefix", ip4);
20655 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20656 vat_json_object_add_uint (node, "path_count", count);
20658 for (i = 0; i < count; i++)
20660 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20661 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20662 vat_json_object_add_uint (node, "is_local", fp->is_local);
20663 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20664 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20665 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20666 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20667 if (fp->afi == IP46_TYPE_IP4)
20669 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20670 vat_json_object_add_ip4 (node, "next_hop", ip4);
20672 else if (fp->afi == IP46_TYPE_IP6)
20674 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20675 vat_json_object_add_ip6 (node, "next_hop", ip6);
20681 api_ip_fib_dump (vat_main_t * vam)
20683 vl_api_ip_fib_dump_t *mp;
20684 vl_api_control_ping_t *mp_ping;
20687 M (IP_FIB_DUMP, mp);
20690 /* Use a control ping for synchronization */
20691 MPING (CONTROL_PING, mp_ping);
20699 api_ip_mfib_dump (vat_main_t * vam)
20701 vl_api_ip_mfib_dump_t *mp;
20702 vl_api_control_ping_t *mp_ping;
20705 M (IP_MFIB_DUMP, mp);
20708 /* Use a control ping for synchronization */
20709 MPING (CONTROL_PING, mp_ping);
20716 static void vl_api_ip_neighbor_details_t_handler
20717 (vl_api_ip_neighbor_details_t * mp)
20719 vat_main_t *vam = &vat_main;
20721 print (vam->ofp, "%c %U %U",
20722 (mp->is_static) ? 'S' : 'D',
20723 format_ethernet_address, &mp->mac_address,
20724 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20728 static void vl_api_ip_neighbor_details_t_handler_json
20729 (vl_api_ip_neighbor_details_t * mp)
20732 vat_main_t *vam = &vat_main;
20733 vat_json_node_t *node;
20734 struct in_addr ip4;
20735 struct in6_addr ip6;
20737 if (VAT_JSON_ARRAY != vam->json_tree.type)
20739 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20740 vat_json_init_array (&vam->json_tree);
20742 node = vat_json_array_add (&vam->json_tree);
20744 vat_json_init_object (node);
20745 vat_json_object_add_string_copy (node, "flag",
20746 (mp->is_static) ? (u8 *) "static" : (u8 *)
20749 vat_json_object_add_string_copy (node, "link_layer",
20750 format (0, "%U", format_ethernet_address,
20751 &mp->mac_address));
20755 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20756 vat_json_object_add_ip6 (node, "ip_address", ip6);
20760 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20761 vat_json_object_add_ip4 (node, "ip_address", ip4);
20766 api_ip_neighbor_dump (vat_main_t * vam)
20768 unformat_input_t *i = vam->input;
20769 vl_api_ip_neighbor_dump_t *mp;
20770 vl_api_control_ping_t *mp_ping;
20772 u32 sw_if_index = ~0;
20775 /* Parse args required to build the message */
20776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20778 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20780 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20782 else if (unformat (i, "ip6"))
20788 if (sw_if_index == ~0)
20790 errmsg ("missing interface name or sw_if_index");
20794 M (IP_NEIGHBOR_DUMP, mp);
20795 mp->is_ipv6 = (u8) is_ipv6;
20796 mp->sw_if_index = ntohl (sw_if_index);
20799 /* Use a control ping for synchronization */
20800 MPING (CONTROL_PING, mp_ping);
20807 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20808 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20811 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20813 vat_main_t *vam = &vat_main;
20814 int count = ntohl (mp->count);
20815 vl_api_fib_path_t *fp;
20819 "table-id %d, prefix %U/%d stats-index %d",
20820 ntohl (mp->table_id), format_ip6_address, mp->address,
20821 mp->address_length, ntohl (mp->stats_index));
20823 for (i = 0; i < count; i++)
20825 if (fp->afi == IP46_TYPE_IP6)
20827 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20828 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20829 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20830 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20831 format_ip6_address, fp->next_hop);
20832 else if (fp->afi == IP46_TYPE_IP4)
20834 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20835 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20836 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20837 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20838 format_ip4_address, fp->next_hop);
20843 static void vl_api_ip6_fib_details_t_handler_json
20844 (vl_api_ip6_fib_details_t * mp)
20846 vat_main_t *vam = &vat_main;
20847 int count = ntohl (mp->count);
20848 vat_json_node_t *node = NULL;
20849 struct in_addr ip4;
20850 struct in6_addr ip6;
20851 vl_api_fib_path_t *fp;
20854 if (VAT_JSON_ARRAY != vam->json_tree.type)
20856 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20857 vat_json_init_array (&vam->json_tree);
20859 node = vat_json_array_add (&vam->json_tree);
20861 vat_json_init_object (node);
20862 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20863 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20864 vat_json_object_add_ip6 (node, "prefix", ip6);
20865 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20866 vat_json_object_add_uint (node, "path_count", count);
20868 for (i = 0; i < count; i++)
20870 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20871 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20872 vat_json_object_add_uint (node, "is_local", fp->is_local);
20873 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20874 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20875 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20876 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20877 if (fp->afi == IP46_TYPE_IP4)
20879 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20880 vat_json_object_add_ip4 (node, "next_hop", ip4);
20882 else if (fp->afi == IP46_TYPE_IP6)
20884 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20885 vat_json_object_add_ip6 (node, "next_hop", ip6);
20891 api_ip6_fib_dump (vat_main_t * vam)
20893 vl_api_ip6_fib_dump_t *mp;
20894 vl_api_control_ping_t *mp_ping;
20897 M (IP6_FIB_DUMP, mp);
20900 /* Use a control ping for synchronization */
20901 MPING (CONTROL_PING, mp_ping);
20909 api_ip6_mfib_dump (vat_main_t * vam)
20911 vl_api_ip6_mfib_dump_t *mp;
20912 vl_api_control_ping_t *mp_ping;
20915 M (IP6_MFIB_DUMP, mp);
20918 /* Use a control ping for synchronization */
20919 MPING (CONTROL_PING, mp_ping);
20927 api_classify_table_ids (vat_main_t * vam)
20929 vl_api_classify_table_ids_t *mp;
20932 /* Construct the API message */
20933 M (CLASSIFY_TABLE_IDS, mp);
20942 api_classify_table_by_interface (vat_main_t * vam)
20944 unformat_input_t *input = vam->input;
20945 vl_api_classify_table_by_interface_t *mp;
20947 u32 sw_if_index = ~0;
20949 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20951 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20953 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20958 if (sw_if_index == ~0)
20960 errmsg ("missing interface name or sw_if_index");
20964 /* Construct the API message */
20965 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20967 mp->sw_if_index = ntohl (sw_if_index);
20975 api_classify_table_info (vat_main_t * vam)
20977 unformat_input_t *input = vam->input;
20978 vl_api_classify_table_info_t *mp;
20982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20984 if (unformat (input, "table_id %d", &table_id))
20989 if (table_id == ~0)
20991 errmsg ("missing table id");
20995 /* Construct the API message */
20996 M (CLASSIFY_TABLE_INFO, mp);
20998 mp->table_id = ntohl (table_id);
21006 api_classify_session_dump (vat_main_t * vam)
21008 unformat_input_t *input = vam->input;
21009 vl_api_classify_session_dump_t *mp;
21010 vl_api_control_ping_t *mp_ping;
21014 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21016 if (unformat (input, "table_id %d", &table_id))
21021 if (table_id == ~0)
21023 errmsg ("missing table id");
21027 /* Construct the API message */
21028 M (CLASSIFY_SESSION_DUMP, mp);
21030 mp->table_id = ntohl (table_id);
21033 /* Use a control ping for synchronization */
21034 MPING (CONTROL_PING, mp_ping);
21042 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
21044 vat_main_t *vam = &vat_main;
21046 print (vam->ofp, "collector_address %U, collector_port %d, "
21047 "src_address %U, vrf_id %d, path_mtu %u, "
21048 "template_interval %u, udp_checksum %d",
21049 format_ip4_address, mp->collector_address,
21050 ntohs (mp->collector_port),
21051 format_ip4_address, mp->src_address,
21052 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
21053 ntohl (mp->template_interval), mp->udp_checksum);
21056 vam->result_ready = 1;
21060 vl_api_ipfix_exporter_details_t_handler_json
21061 (vl_api_ipfix_exporter_details_t * mp)
21063 vat_main_t *vam = &vat_main;
21064 vat_json_node_t node;
21065 struct in_addr collector_address;
21066 struct in_addr src_address;
21068 vat_json_init_object (&node);
21069 clib_memcpy (&collector_address, &mp->collector_address,
21070 sizeof (collector_address));
21071 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
21072 vat_json_object_add_uint (&node, "collector_port",
21073 ntohs (mp->collector_port));
21074 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
21075 vat_json_object_add_ip4 (&node, "src_address", src_address);
21076 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
21077 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
21078 vat_json_object_add_uint (&node, "template_interval",
21079 ntohl (mp->template_interval));
21080 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
21082 vat_json_print (vam->ofp, &node);
21083 vat_json_free (&node);
21085 vam->result_ready = 1;
21089 api_ipfix_exporter_dump (vat_main_t * vam)
21091 vl_api_ipfix_exporter_dump_t *mp;
21094 /* Construct the API message */
21095 M (IPFIX_EXPORTER_DUMP, mp);
21104 api_ipfix_classify_stream_dump (vat_main_t * vam)
21106 vl_api_ipfix_classify_stream_dump_t *mp;
21109 /* Construct the API message */
21110 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
21121 vl_api_ipfix_classify_stream_details_t_handler
21122 (vl_api_ipfix_classify_stream_details_t * mp)
21124 vat_main_t *vam = &vat_main;
21125 print (vam->ofp, "domain_id %d, src_port %d",
21126 ntohl (mp->domain_id), ntohs (mp->src_port));
21128 vam->result_ready = 1;
21132 vl_api_ipfix_classify_stream_details_t_handler_json
21133 (vl_api_ipfix_classify_stream_details_t * mp)
21135 vat_main_t *vam = &vat_main;
21136 vat_json_node_t node;
21138 vat_json_init_object (&node);
21139 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
21140 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
21142 vat_json_print (vam->ofp, &node);
21143 vat_json_free (&node);
21145 vam->result_ready = 1;
21149 api_ipfix_classify_table_dump (vat_main_t * vam)
21151 vl_api_ipfix_classify_table_dump_t *mp;
21152 vl_api_control_ping_t *mp_ping;
21155 if (!vam->json_output)
21157 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
21158 "transport_protocol");
21161 /* Construct the API message */
21162 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
21167 /* Use a control ping for synchronization */
21168 MPING (CONTROL_PING, mp_ping);
21176 vl_api_ipfix_classify_table_details_t_handler
21177 (vl_api_ipfix_classify_table_details_t * mp)
21179 vat_main_t *vam = &vat_main;
21180 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
21181 mp->transport_protocol);
21185 vl_api_ipfix_classify_table_details_t_handler_json
21186 (vl_api_ipfix_classify_table_details_t * mp)
21188 vat_json_node_t *node = NULL;
21189 vat_main_t *vam = &vat_main;
21191 if (VAT_JSON_ARRAY != vam->json_tree.type)
21193 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21194 vat_json_init_array (&vam->json_tree);
21197 node = vat_json_array_add (&vam->json_tree);
21198 vat_json_init_object (node);
21200 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
21201 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
21202 vat_json_object_add_uint (node, "transport_protocol",
21203 mp->transport_protocol);
21207 api_sw_interface_span_enable_disable (vat_main_t * vam)
21209 unformat_input_t *i = vam->input;
21210 vl_api_sw_interface_span_enable_disable_t *mp;
21211 u32 src_sw_if_index = ~0;
21212 u32 dst_sw_if_index = ~0;
21217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21220 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21222 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21226 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21228 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21230 else if (unformat (i, "disable"))
21232 else if (unformat (i, "rx"))
21234 else if (unformat (i, "tx"))
21236 else if (unformat (i, "both"))
21238 else if (unformat (i, "l2"))
21244 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21246 mp->sw_if_index_from = htonl (src_sw_if_index);
21247 mp->sw_if_index_to = htonl (dst_sw_if_index);
21257 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21260 vat_main_t *vam = &vat_main;
21261 u8 *sw_if_from_name = 0;
21262 u8 *sw_if_to_name = 0;
21263 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21264 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21265 char *states[] = { "none", "rx", "tx", "both" };
21269 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21271 if ((u32) p->value[0] == sw_if_index_from)
21273 sw_if_from_name = (u8 *)(p->key);
21277 if ((u32) p->value[0] == sw_if_index_to)
21279 sw_if_to_name = (u8 *)(p->key);
21280 if (sw_if_from_name)
21285 print (vam->ofp, "%20s => %20s (%s) %s",
21286 sw_if_from_name, sw_if_to_name, states[mp->state],
21287 mp->is_l2 ? "l2" : "device");
21291 vl_api_sw_interface_span_details_t_handler_json
21292 (vl_api_sw_interface_span_details_t * mp)
21294 vat_main_t *vam = &vat_main;
21295 vat_json_node_t *node = NULL;
21296 u8 *sw_if_from_name = 0;
21297 u8 *sw_if_to_name = 0;
21298 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21299 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21303 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21305 if ((u32) p->value[0] == sw_if_index_from)
21307 sw_if_from_name = (u8 *)(p->key);
21311 if ((u32) p->value[0] == sw_if_index_to)
21313 sw_if_to_name = (u8 *)(p->key);
21314 if (sw_if_from_name)
21320 if (VAT_JSON_ARRAY != vam->json_tree.type)
21322 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21323 vat_json_init_array (&vam->json_tree);
21325 node = vat_json_array_add (&vam->json_tree);
21327 vat_json_init_object (node);
21328 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21329 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21330 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21331 if (0 != sw_if_to_name)
21333 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21335 vat_json_object_add_uint (node, "state", mp->state);
21336 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21340 api_sw_interface_span_dump (vat_main_t * vam)
21342 unformat_input_t *input = vam->input;
21343 vl_api_sw_interface_span_dump_t *mp;
21344 vl_api_control_ping_t *mp_ping;
21348 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21350 if (unformat (input, "l2"))
21356 M (SW_INTERFACE_SPAN_DUMP, mp);
21360 /* Use a control ping for synchronization */
21361 MPING (CONTROL_PING, mp_ping);
21369 api_pg_create_interface (vat_main_t * vam)
21371 unformat_input_t *input = vam->input;
21372 vl_api_pg_create_interface_t *mp;
21376 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21378 if (unformat (input, "if_id %d", &if_id))
21385 errmsg ("missing pg interface index");
21389 /* Construct the API message */
21390 M (PG_CREATE_INTERFACE, mp);
21392 mp->interface_id = ntohl (if_id);
21400 api_pg_capture (vat_main_t * vam)
21402 unformat_input_t *input = vam->input;
21403 vl_api_pg_capture_t *mp;
21408 u8 pcap_file_set = 0;
21411 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21413 if (unformat (input, "if_id %d", &if_id))
21415 else if (unformat (input, "pcap %s", &pcap_file))
21417 else if (unformat (input, "count %d", &count))
21419 else if (unformat (input, "disable"))
21426 errmsg ("missing pg interface index");
21429 if (pcap_file_set > 0)
21431 if (vec_len (pcap_file) > 255)
21433 errmsg ("pcap file name is too long");
21438 u32 name_len = vec_len (pcap_file);
21439 /* Construct the API message */
21440 M (PG_CAPTURE, mp);
21442 mp->interface_id = ntohl (if_id);
21443 mp->is_enabled = enable;
21444 mp->count = ntohl (count);
21445 mp->pcap_name_length = ntohl (name_len);
21446 if (pcap_file_set != 0)
21448 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21450 vec_free (pcap_file);
21458 api_pg_enable_disable (vat_main_t * vam)
21460 unformat_input_t *input = vam->input;
21461 vl_api_pg_enable_disable_t *mp;
21464 u8 stream_name_set = 0;
21465 u8 *stream_name = 0;
21467 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21469 if (unformat (input, "stream %s", &stream_name))
21470 stream_name_set = 1;
21471 else if (unformat (input, "disable"))
21477 if (stream_name_set > 0)
21479 if (vec_len (stream_name) > 255)
21481 errmsg ("stream name too long");
21486 u32 name_len = vec_len (stream_name);
21487 /* Construct the API message */
21488 M (PG_ENABLE_DISABLE, mp);
21490 mp->is_enabled = enable;
21491 if (stream_name_set != 0)
21493 mp->stream_name_length = ntohl (name_len);
21494 clib_memcpy (mp->stream_name, stream_name, name_len);
21496 vec_free (stream_name);
21504 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21506 unformat_input_t *input = vam->input;
21507 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21509 u16 *low_ports = 0;
21510 u16 *high_ports = 0;
21513 ip4_address_t ip4_addr;
21514 ip6_address_t ip6_addr;
21523 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21525 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21531 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21536 else if (unformat (input, "vrf %d", &vrf_id))
21538 else if (unformat (input, "del"))
21540 else if (unformat (input, "port %d", &tmp))
21542 if (tmp == 0 || tmp > 65535)
21544 errmsg ("port %d out of range", tmp);
21548 this_hi = this_low + 1;
21549 vec_add1 (low_ports, this_low);
21550 vec_add1 (high_ports, this_hi);
21552 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21554 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21556 errmsg ("incorrect range parameters");
21560 /* Note: in debug CLI +1 is added to high before
21561 passing to real fn that does "the work"
21562 (ip_source_and_port_range_check_add_del).
21563 This fn is a wrapper around the binary API fn a
21564 control plane will call, which expects this increment
21565 to have occurred. Hence letting the binary API control
21566 plane fn do the increment for consistency between VAT
21567 and other control planes.
21570 vec_add1 (low_ports, this_low);
21571 vec_add1 (high_ports, this_hi);
21577 if (prefix_set == 0)
21579 errmsg ("<address>/<mask> not specified");
21585 errmsg ("VRF ID required, not specified");
21592 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21596 if (vec_len (low_ports) == 0)
21598 errmsg ("At least one port or port range required");
21602 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21604 mp->is_add = is_add;
21609 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21614 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21617 mp->mask_length = length;
21618 mp->number_of_ranges = vec_len (low_ports);
21620 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21621 vec_free (low_ports);
21623 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21624 vec_free (high_ports);
21626 mp->vrf_id = ntohl (vrf_id);
21634 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21636 unformat_input_t *input = vam->input;
21637 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21638 u32 sw_if_index = ~0;
21640 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21641 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21645 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21647 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21649 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21651 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21653 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21655 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21657 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21659 else if (unformat (input, "del"))
21665 if (sw_if_index == ~0)
21667 errmsg ("Interface required but not specified");
21673 errmsg ("VRF ID required but not specified");
21677 if (tcp_out_vrf_id == 0
21678 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21681 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21685 /* Construct the API message */
21686 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21688 mp->sw_if_index = ntohl (sw_if_index);
21689 mp->is_add = is_add;
21690 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21691 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21692 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21693 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21698 /* Wait for a reply... */
21704 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21706 unformat_input_t *i = vam->input;
21707 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21708 u32 local_sa_id = 0;
21709 u32 remote_sa_id = 0;
21710 ip4_address_t src_address;
21711 ip4_address_t dst_address;
21715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21717 if (unformat (i, "local_sa %d", &local_sa_id))
21719 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21721 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21723 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21725 else if (unformat (i, "del"))
21729 clib_warning ("parse error '%U'", format_unformat_error, i);
21734 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21736 mp->local_sa_id = ntohl (local_sa_id);
21737 mp->remote_sa_id = ntohl (remote_sa_id);
21738 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21739 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21740 mp->is_add = is_add;
21748 api_set_punt (vat_main_t * vam)
21750 unformat_input_t *i = vam->input;
21751 vl_api_set_punt_t *mp;
21758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21760 if (unformat (i, "ip %d", &ipv))
21762 else if (unformat (i, "protocol %d", &protocol))
21764 else if (unformat (i, "port %d", &port))
21766 else if (unformat (i, "del"))
21770 clib_warning ("parse error '%U'", format_unformat_error, i);
21777 mp->is_add = (u8) is_add;
21778 mp->punt.ipv = (u8) ipv;
21779 mp->punt.l4_protocol = (u8) protocol;
21780 mp->punt.l4_port = htons ((u16) port);
21787 static void vl_api_ipsec_gre_tunnel_details_t_handler
21788 (vl_api_ipsec_gre_tunnel_details_t * mp)
21790 vat_main_t *vam = &vat_main;
21792 print (vam->ofp, "%11d%15U%15U%14d%14d",
21793 ntohl (mp->sw_if_index),
21794 format_ip4_address, &mp->src_address,
21795 format_ip4_address, &mp->dst_address,
21796 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21799 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21800 (vl_api_ipsec_gre_tunnel_details_t * mp)
21802 vat_main_t *vam = &vat_main;
21803 vat_json_node_t *node = NULL;
21804 struct in_addr ip4;
21806 if (VAT_JSON_ARRAY != vam->json_tree.type)
21808 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21809 vat_json_init_array (&vam->json_tree);
21811 node = vat_json_array_add (&vam->json_tree);
21813 vat_json_init_object (node);
21814 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21815 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21816 vat_json_object_add_ip4 (node, "src_address", ip4);
21817 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21818 vat_json_object_add_ip4 (node, "dst_address", ip4);
21819 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21820 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21824 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21826 unformat_input_t *i = vam->input;
21827 vl_api_ipsec_gre_tunnel_dump_t *mp;
21828 vl_api_control_ping_t *mp_ping;
21830 u8 sw_if_index_set = 0;
21833 /* Parse args required to build the message */
21834 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21836 if (unformat (i, "sw_if_index %d", &sw_if_index))
21837 sw_if_index_set = 1;
21842 if (sw_if_index_set == 0)
21847 if (!vam->json_output)
21849 print (vam->ofp, "%11s%15s%15s%14s%14s",
21850 "sw_if_index", "src_address", "dst_address",
21851 "local_sa_id", "remote_sa_id");
21854 /* Get list of gre-tunnel interfaces */
21855 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21857 mp->sw_if_index = htonl (sw_if_index);
21861 /* Use a control ping for synchronization */
21862 MPING (CONTROL_PING, mp_ping);
21870 api_delete_subif (vat_main_t * vam)
21872 unformat_input_t *i = vam->input;
21873 vl_api_delete_subif_t *mp;
21874 u32 sw_if_index = ~0;
21877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21879 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21881 if (unformat (i, "sw_if_index %d", &sw_if_index))
21887 if (sw_if_index == ~0)
21889 errmsg ("missing sw_if_index");
21893 /* Construct the API message */
21894 M (DELETE_SUBIF, mp);
21895 mp->sw_if_index = ntohl (sw_if_index);
21902 #define foreach_pbb_vtr_op \
21903 _("disable", L2_VTR_DISABLED) \
21904 _("pop", L2_VTR_POP_2) \
21905 _("push", L2_VTR_PUSH_2)
21908 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21910 unformat_input_t *i = vam->input;
21911 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21912 u32 sw_if_index = ~0, vtr_op = ~0;
21913 u16 outer_tag = ~0;
21914 u8 dmac[6], smac[6];
21915 u8 dmac_set = 0, smac_set = 0;
21921 /* Shut up coverity */
21922 clib_memset (dmac, 0, sizeof (dmac));
21923 clib_memset (smac, 0, sizeof (smac));
21925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21927 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21929 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21931 else if (unformat (i, "vtr_op %d", &vtr_op))
21933 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21936 else if (unformat (i, "translate_pbb_stag"))
21938 if (unformat (i, "%d", &tmp))
21940 vtr_op = L2_VTR_TRANSLATE_2_1;
21946 ("translate_pbb_stag operation requires outer tag definition");
21950 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21952 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21954 else if (unformat (i, "sid %d", &sid))
21956 else if (unformat (i, "vlanid %d", &tmp))
21960 clib_warning ("parse error '%U'", format_unformat_error, i);
21965 if ((sw_if_index == ~0) || (vtr_op == ~0))
21967 errmsg ("missing sw_if_index or vtr operation");
21970 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21971 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21974 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21978 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21979 mp->sw_if_index = ntohl (sw_if_index);
21980 mp->vtr_op = ntohl (vtr_op);
21981 mp->outer_tag = ntohs (outer_tag);
21982 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21983 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21984 mp->b_vlanid = ntohs (vlanid);
21985 mp->i_sid = ntohl (sid);
21993 api_flow_classify_set_interface (vat_main_t * vam)
21995 unformat_input_t *i = vam->input;
21996 vl_api_flow_classify_set_interface_t *mp;
21998 int sw_if_index_set;
21999 u32 ip4_table_index = ~0;
22000 u32 ip6_table_index = ~0;
22004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22006 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22007 sw_if_index_set = 1;
22008 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22009 sw_if_index_set = 1;
22010 else if (unformat (i, "del"))
22012 else if (unformat (i, "ip4-table %d", &ip4_table_index))
22014 else if (unformat (i, "ip6-table %d", &ip6_table_index))
22018 clib_warning ("parse error '%U'", format_unformat_error, i);
22023 if (sw_if_index_set == 0)
22025 errmsg ("missing interface name or sw_if_index");
22029 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
22031 mp->sw_if_index = ntohl (sw_if_index);
22032 mp->ip4_table_index = ntohl (ip4_table_index);
22033 mp->ip6_table_index = ntohl (ip6_table_index);
22034 mp->is_add = is_add;
22042 api_flow_classify_dump (vat_main_t * vam)
22044 unformat_input_t *i = vam->input;
22045 vl_api_flow_classify_dump_t *mp;
22046 vl_api_control_ping_t *mp_ping;
22047 u8 type = FLOW_CLASSIFY_N_TABLES;
22050 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
22054 errmsg ("classify table type must be specified");
22058 if (!vam->json_output)
22060 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
22063 M (FLOW_CLASSIFY_DUMP, mp);
22068 /* Use a control ping for synchronization */
22069 MPING (CONTROL_PING, mp_ping);
22072 /* Wait for a reply... */
22078 api_feature_enable_disable (vat_main_t * vam)
22080 unformat_input_t *i = vam->input;
22081 vl_api_feature_enable_disable_t *mp;
22083 u8 *feature_name = 0;
22084 u32 sw_if_index = ~0;
22088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22090 if (unformat (i, "arc_name %s", &arc_name))
22092 else if (unformat (i, "feature_name %s", &feature_name))
22095 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22097 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22099 else if (unformat (i, "disable"))
22107 errmsg ("missing arc name");
22110 if (vec_len (arc_name) > 63)
22112 errmsg ("arc name too long");
22115 if (feature_name == 0)
22117 errmsg ("missing feature name");
22120 if (vec_len (feature_name) > 63)
22122 errmsg ("feature name too long");
22125 if (sw_if_index == ~0)
22127 errmsg ("missing interface name or sw_if_index");
22131 /* Construct the API message */
22132 M (FEATURE_ENABLE_DISABLE, mp);
22133 mp->sw_if_index = ntohl (sw_if_index);
22134 mp->enable = enable;
22135 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
22136 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
22137 vec_free (arc_name);
22138 vec_free (feature_name);
22146 api_sw_interface_tag_add_del (vat_main_t * vam)
22148 unformat_input_t *i = vam->input;
22149 vl_api_sw_interface_tag_add_del_t *mp;
22150 u32 sw_if_index = ~0;
22155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22157 if (unformat (i, "tag %s", &tag))
22159 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22161 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22163 else if (unformat (i, "del"))
22169 if (sw_if_index == ~0)
22171 errmsg ("missing interface name or sw_if_index");
22175 if (enable && (tag == 0))
22177 errmsg ("no tag specified");
22181 /* Construct the API message */
22182 M (SW_INTERFACE_TAG_ADD_DEL, mp);
22183 mp->sw_if_index = ntohl (sw_if_index);
22184 mp->is_add = enable;
22186 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
22194 static void vl_api_l2_xconnect_details_t_handler
22195 (vl_api_l2_xconnect_details_t * mp)
22197 vat_main_t *vam = &vat_main;
22199 print (vam->ofp, "%15d%15d",
22200 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
22203 static void vl_api_l2_xconnect_details_t_handler_json
22204 (vl_api_l2_xconnect_details_t * mp)
22206 vat_main_t *vam = &vat_main;
22207 vat_json_node_t *node = NULL;
22209 if (VAT_JSON_ARRAY != vam->json_tree.type)
22211 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22212 vat_json_init_array (&vam->json_tree);
22214 node = vat_json_array_add (&vam->json_tree);
22216 vat_json_init_object (node);
22217 vat_json_object_add_uint (node, "rx_sw_if_index",
22218 ntohl (mp->rx_sw_if_index));
22219 vat_json_object_add_uint (node, "tx_sw_if_index",
22220 ntohl (mp->tx_sw_if_index));
22224 api_l2_xconnect_dump (vat_main_t * vam)
22226 vl_api_l2_xconnect_dump_t *mp;
22227 vl_api_control_ping_t *mp_ping;
22230 if (!vam->json_output)
22232 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22235 M (L2_XCONNECT_DUMP, mp);
22239 /* Use a control ping for synchronization */
22240 MPING (CONTROL_PING, mp_ping);
22248 api_hw_interface_set_mtu (vat_main_t * vam)
22250 unformat_input_t *i = vam->input;
22251 vl_api_hw_interface_set_mtu_t *mp;
22252 u32 sw_if_index = ~0;
22256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22258 if (unformat (i, "mtu %d", &mtu))
22260 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22262 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22268 if (sw_if_index == ~0)
22270 errmsg ("missing interface name or sw_if_index");
22276 errmsg ("no mtu specified");
22280 /* Construct the API message */
22281 M (HW_INTERFACE_SET_MTU, mp);
22282 mp->sw_if_index = ntohl (sw_if_index);
22283 mp->mtu = ntohs ((u16) mtu);
22291 api_p2p_ethernet_add (vat_main_t * vam)
22293 unformat_input_t *i = vam->input;
22294 vl_api_p2p_ethernet_add_t *mp;
22295 u32 parent_if_index = ~0;
22301 clib_memset (remote_mac, 0, sizeof (remote_mac));
22302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22304 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22306 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22310 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22312 else if (unformat (i, "sub_id %d", &sub_id))
22316 clib_warning ("parse error '%U'", format_unformat_error, i);
22321 if (parent_if_index == ~0)
22323 errmsg ("missing interface name or sw_if_index");
22328 errmsg ("missing remote mac address");
22333 errmsg ("missing sub-interface id");
22337 M (P2P_ETHERNET_ADD, mp);
22338 mp->parent_if_index = ntohl (parent_if_index);
22339 mp->subif_id = ntohl (sub_id);
22340 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22348 api_p2p_ethernet_del (vat_main_t * vam)
22350 unformat_input_t *i = vam->input;
22351 vl_api_p2p_ethernet_del_t *mp;
22352 u32 parent_if_index = ~0;
22357 clib_memset (remote_mac, 0, sizeof (remote_mac));
22358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22360 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22362 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22366 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22370 clib_warning ("parse error '%U'", format_unformat_error, i);
22375 if (parent_if_index == ~0)
22377 errmsg ("missing interface name or sw_if_index");
22382 errmsg ("missing remote mac address");
22386 M (P2P_ETHERNET_DEL, mp);
22387 mp->parent_if_index = ntohl (parent_if_index);
22388 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22396 api_lldp_config (vat_main_t * vam)
22398 unformat_input_t *i = vam->input;
22399 vl_api_lldp_config_t *mp;
22401 int tx_interval = 0;
22402 u8 *sys_name = NULL;
22405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22407 if (unformat (i, "system-name %s", &sys_name))
22409 else if (unformat (i, "tx-hold %d", &tx_hold))
22411 else if (unformat (i, "tx-interval %d", &tx_interval))
22415 clib_warning ("parse error '%U'", format_unformat_error, i);
22420 vec_add1 (sys_name, 0);
22422 M (LLDP_CONFIG, mp);
22423 mp->tx_hold = htonl (tx_hold);
22424 mp->tx_interval = htonl (tx_interval);
22425 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22426 vec_free (sys_name);
22434 api_sw_interface_set_lldp (vat_main_t * vam)
22436 unformat_input_t *i = vam->input;
22437 vl_api_sw_interface_set_lldp_t *mp;
22438 u32 sw_if_index = ~0;
22440 u8 *port_desc = NULL, *mgmt_oid = NULL;
22441 ip4_address_t ip4_addr;
22442 ip6_address_t ip6_addr;
22445 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
22446 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
22448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22450 if (unformat (i, "disable"))
22453 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22455 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22457 else if (unformat (i, "port-desc %s", &port_desc))
22459 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22461 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22463 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22469 if (sw_if_index == ~0)
22471 errmsg ("missing interface name or sw_if_index");
22475 /* Construct the API message */
22476 vec_add1 (port_desc, 0);
22477 vec_add1 (mgmt_oid, 0);
22478 M (SW_INTERFACE_SET_LLDP, mp);
22479 mp->sw_if_index = ntohl (sw_if_index);
22480 mp->enable = enable;
22481 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22482 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22483 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22484 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22485 vec_free (port_desc);
22486 vec_free (mgmt_oid);
22494 api_tcp_configure_src_addresses (vat_main_t * vam)
22496 vl_api_tcp_configure_src_addresses_t *mp;
22497 unformat_input_t *i = vam->input;
22498 ip4_address_t v4first, v4last;
22499 ip6_address_t v6first, v6last;
22504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22506 if (unformat (i, "%U - %U",
22507 unformat_ip4_address, &v4first,
22508 unformat_ip4_address, &v4last))
22512 errmsg ("one range per message (range already set)");
22517 else if (unformat (i, "%U - %U",
22518 unformat_ip6_address, &v6first,
22519 unformat_ip6_address, &v6last))
22523 errmsg ("one range per message (range already set)");
22528 else if (unformat (i, "vrf %d", &vrf_id))
22534 if (range_set == 0)
22536 errmsg ("address range not set");
22540 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22541 mp->vrf_id = ntohl (vrf_id);
22543 if (range_set == 2)
22546 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22547 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22552 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22553 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22560 static void vl_api_app_namespace_add_del_reply_t_handler
22561 (vl_api_app_namespace_add_del_reply_t * mp)
22563 vat_main_t *vam = &vat_main;
22564 i32 retval = ntohl (mp->retval);
22565 if (vam->async_mode)
22567 vam->async_errors += (retval < 0);
22571 vam->retval = retval;
22573 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22574 vam->result_ready = 1;
22578 static void vl_api_app_namespace_add_del_reply_t_handler_json
22579 (vl_api_app_namespace_add_del_reply_t * mp)
22581 vat_main_t *vam = &vat_main;
22582 vat_json_node_t node;
22584 vat_json_init_object (&node);
22585 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22586 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22588 vat_json_print (vam->ofp, &node);
22589 vat_json_free (&node);
22591 vam->retval = ntohl (mp->retval);
22592 vam->result_ready = 1;
22596 api_app_namespace_add_del (vat_main_t * vam)
22598 vl_api_app_namespace_add_del_t *mp;
22599 unformat_input_t *i = vam->input;
22600 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22601 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22607 if (unformat (i, "id %_%v%_", &ns_id))
22609 else if (unformat (i, "secret %lu", &secret))
22611 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22612 sw_if_index_set = 1;
22613 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22615 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22620 if (!ns_id || !secret_set || !sw_if_index_set)
22622 errmsg ("namespace id, secret and sw_if_index must be set");
22625 if (vec_len (ns_id) > 64)
22627 errmsg ("namespace id too long");
22630 M (APP_NAMESPACE_ADD_DEL, mp);
22632 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22633 mp->namespace_id_len = vec_len (ns_id);
22634 mp->secret = clib_host_to_net_u64 (secret);
22635 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22636 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22637 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22645 api_sock_init_shm (vat_main_t * vam)
22647 #if VPP_API_TEST_BUILTIN == 0
22648 unformat_input_t *i = vam->input;
22649 vl_api_shm_elem_config_t *config = 0;
22650 u64 size = 64 << 20;
22653 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22655 if (unformat (i, "size %U", unformat_memory_size, &size))
22662 * Canned custom ring allocator config.
22663 * Should probably parse all of this
22665 vec_validate (config, 6);
22666 config[0].type = VL_API_VLIB_RING;
22667 config[0].size = 256;
22668 config[0].count = 32;
22670 config[1].type = VL_API_VLIB_RING;
22671 config[1].size = 1024;
22672 config[1].count = 16;
22674 config[2].type = VL_API_VLIB_RING;
22675 config[2].size = 4096;
22676 config[2].count = 2;
22678 config[3].type = VL_API_CLIENT_RING;
22679 config[3].size = 256;
22680 config[3].count = 32;
22682 config[4].type = VL_API_CLIENT_RING;
22683 config[4].size = 1024;
22684 config[4].count = 16;
22686 config[5].type = VL_API_CLIENT_RING;
22687 config[5].size = 4096;
22688 config[5].count = 2;
22690 config[6].type = VL_API_QUEUE;
22691 config[6].count = 128;
22692 config[6].size = sizeof (uword);
22694 rv = vl_socket_client_init_shm (config);
22696 vam->client_index_invalid = 1;
22704 api_dns_enable_disable (vat_main_t * vam)
22706 unformat_input_t *line_input = vam->input;
22707 vl_api_dns_enable_disable_t *mp;
22708 u8 enable_disable = 1;
22711 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22713 if (unformat (line_input, "disable"))
22714 enable_disable = 0;
22715 if (unformat (line_input, "enable"))
22716 enable_disable = 1;
22721 /* Construct the API message */
22722 M (DNS_ENABLE_DISABLE, mp);
22723 mp->enable = enable_disable;
22727 /* Wait for the reply */
22733 api_dns_resolve_name (vat_main_t * vam)
22735 unformat_input_t *line_input = vam->input;
22736 vl_api_dns_resolve_name_t *mp;
22740 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22742 if (unformat (line_input, "%s", &name))
22748 if (vec_len (name) > 127)
22750 errmsg ("name too long");
22754 /* Construct the API message */
22755 M (DNS_RESOLVE_NAME, mp);
22756 memcpy (mp->name, name, vec_len (name));
22761 /* Wait for the reply */
22767 api_dns_resolve_ip (vat_main_t * vam)
22769 unformat_input_t *line_input = vam->input;
22770 vl_api_dns_resolve_ip_t *mp;
22772 ip4_address_t addr4;
22773 ip6_address_t addr6;
22776 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22778 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22780 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22788 errmsg ("missing address");
22792 /* Construct the API message */
22793 M (DNS_RESOLVE_IP, mp);
22794 mp->is_ip6 = is_ip6;
22796 memcpy (mp->address, &addr6, sizeof (addr6));
22798 memcpy (mp->address, &addr4, sizeof (addr4));
22802 /* Wait for the reply */
22808 api_dns_name_server_add_del (vat_main_t * vam)
22810 unformat_input_t *i = vam->input;
22811 vl_api_dns_name_server_add_del_t *mp;
22813 ip6_address_t ip6_server;
22814 ip4_address_t ip4_server;
22819 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22821 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22823 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22825 else if (unformat (i, "del"))
22829 clib_warning ("parse error '%U'", format_unformat_error, i);
22834 if (ip4_set && ip6_set)
22836 errmsg ("Only one server address allowed per message");
22839 if ((ip4_set + ip6_set) == 0)
22841 errmsg ("Server address required");
22845 /* Construct the API message */
22846 M (DNS_NAME_SERVER_ADD_DEL, mp);
22850 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22855 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22859 mp->is_add = is_add;
22864 /* Wait for a reply, return good/bad news */
22870 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22872 vat_main_t *vam = &vat_main;
22877 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22878 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22879 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22880 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22881 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22882 clib_net_to_host_u32 (mp->action_index), mp->tag);
22887 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22888 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22889 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22890 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22891 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22892 clib_net_to_host_u32 (mp->action_index), mp->tag);
22897 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22900 vat_main_t *vam = &vat_main;
22901 vat_json_node_t *node = NULL;
22902 struct in6_addr ip6;
22903 struct in_addr ip4;
22905 if (VAT_JSON_ARRAY != vam->json_tree.type)
22907 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22908 vat_json_init_array (&vam->json_tree);
22910 node = vat_json_array_add (&vam->json_tree);
22911 vat_json_init_object (node);
22913 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22914 vat_json_object_add_uint (node, "appns_index",
22915 clib_net_to_host_u32 (mp->appns_index));
22916 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22917 vat_json_object_add_uint (node, "scope", mp->scope);
22918 vat_json_object_add_uint (node, "action_index",
22919 clib_net_to_host_u32 (mp->action_index));
22920 vat_json_object_add_uint (node, "lcl_port",
22921 clib_net_to_host_u16 (mp->lcl_port));
22922 vat_json_object_add_uint (node, "rmt_port",
22923 clib_net_to_host_u16 (mp->rmt_port));
22924 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22925 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22926 vat_json_object_add_string_copy (node, "tag", mp->tag);
22929 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22930 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22931 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22932 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22936 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22937 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22938 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22939 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22944 api_session_rule_add_del (vat_main_t * vam)
22946 vl_api_session_rule_add_del_t *mp;
22947 unformat_input_t *i = vam->input;
22948 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22949 u32 appns_index = 0, scope = 0;
22950 ip4_address_t lcl_ip4, rmt_ip4;
22951 ip6_address_t lcl_ip6, rmt_ip6;
22952 u8 is_ip4 = 1, conn_set = 0;
22953 u8 is_add = 1, *tag = 0;
22956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22958 if (unformat (i, "del"))
22960 else if (unformat (i, "add"))
22962 else if (unformat (i, "proto tcp"))
22964 else if (unformat (i, "proto udp"))
22966 else if (unformat (i, "appns %d", &appns_index))
22968 else if (unformat (i, "scope %d", &scope))
22970 else if (unformat (i, "tag %_%v%_", &tag))
22974 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22975 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22983 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22984 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22990 else if (unformat (i, "action %d", &action))
22995 if (proto == ~0 || !conn_set || action == ~0)
22997 errmsg ("transport proto, connection and action must be set");
23003 errmsg ("scope should be 0-3");
23007 M (SESSION_RULE_ADD_DEL, mp);
23009 mp->is_ip4 = is_ip4;
23010 mp->transport_proto = proto;
23011 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
23012 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
23013 mp->lcl_plen = lcl_plen;
23014 mp->rmt_plen = rmt_plen;
23015 mp->action_index = clib_host_to_net_u32 (action);
23016 mp->appns_index = clib_host_to_net_u32 (appns_index);
23018 mp->is_add = is_add;
23021 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
23022 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
23026 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
23027 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
23031 clib_memcpy (mp->tag, tag, vec_len (tag));
23041 api_session_rules_dump (vat_main_t * vam)
23043 vl_api_session_rules_dump_t *mp;
23044 vl_api_control_ping_t *mp_ping;
23047 if (!vam->json_output)
23049 print (vam->ofp, "%=20s", "Session Rules");
23052 M (SESSION_RULES_DUMP, mp);
23056 /* Use a control ping for synchronization */
23057 MPING (CONTROL_PING, mp_ping);
23060 /* Wait for a reply... */
23066 api_ip_container_proxy_add_del (vat_main_t * vam)
23068 vl_api_ip_container_proxy_add_del_t *mp;
23069 unformat_input_t *i = vam->input;
23070 u32 plen = ~0, sw_if_index = ~0;
23077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23079 if (unformat (i, "del"))
23081 else if (unformat (i, "add"))
23083 if (unformat (i, "%U", unformat_ip4_address, &ip4))
23088 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
23093 else if (unformat (i, "sw_if_index %u", &sw_if_index))
23098 if (sw_if_index == ~0 || plen == ~0)
23100 errmsg ("address and sw_if_index must be set");
23104 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
23106 mp->is_ip4 = is_ip4;
23107 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
23109 mp->is_add = is_add;
23111 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
23113 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
23121 api_qos_record_enable_disable (vat_main_t * vam)
23123 unformat_input_t *i = vam->input;
23124 vl_api_qos_record_enable_disable_t *mp;
23125 u32 sw_if_index, qs = 0xff;
23126 u8 sw_if_index_set = 0;
23130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23132 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
23133 sw_if_index_set = 1;
23134 else if (unformat (i, "sw_if_index %d", &sw_if_index))
23135 sw_if_index_set = 1;
23136 else if (unformat (i, "%U", unformat_qos_source, &qs))
23138 else if (unformat (i, "disable"))
23142 clib_warning ("parse error '%U'", format_unformat_error, i);
23147 if (sw_if_index_set == 0)
23149 errmsg ("missing interface name or sw_if_index");
23154 errmsg ("input location must be specified");
23158 M (QOS_RECORD_ENABLE_DISABLE, mp);
23160 mp->sw_if_index = ntohl (sw_if_index);
23161 mp->input_source = qs;
23162 mp->enable = enable;
23171 q_or_quit (vat_main_t * vam)
23173 #if VPP_API_TEST_BUILTIN == 0
23174 longjmp (vam->jump_buf, 1);
23176 return 0; /* not so much */
23180 q (vat_main_t * vam)
23182 return q_or_quit (vam);
23186 quit (vat_main_t * vam)
23188 return q_or_quit (vam);
23192 comment (vat_main_t * vam)
23198 statseg (vat_main_t * vam)
23200 ssvm_private_t *ssvmp = &vam->stat_segment;
23201 ssvm_shared_header_t *shared_header = ssvmp->sh;
23202 vlib_counter_t **counters;
23203 u64 thread0_index1_packets;
23204 u64 thread0_index1_bytes;
23205 f64 vector_rate, input_rate;
23208 uword *counter_vector_by_name;
23209 if (vam->stat_segment_lockp == 0)
23211 errmsg ("Stat segment not mapped...");
23215 /* look up "/if/rx for sw_if_index 1 as a test */
23217 clib_spinlock_lock (vam->stat_segment_lockp);
23219 counter_vector_by_name = (uword *) shared_header->opaque[1];
23221 p = hash_get_mem (counter_vector_by_name, "/if/rx");
23224 clib_spinlock_unlock (vam->stat_segment_lockp);
23225 errmsg ("/if/tx not found?");
23229 /* Fish per-thread vector of combined counters from shared memory */
23230 counters = (vlib_counter_t **) p[0];
23232 if (vec_len (counters[0]) < 2)
23234 clib_spinlock_unlock (vam->stat_segment_lockp);
23235 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
23239 /* Read thread 0 sw_if_index 1 counter */
23240 thread0_index1_packets = counters[0][1].packets;
23241 thread0_index1_bytes = counters[0][1].bytes;
23243 p = hash_get_mem (counter_vector_by_name, "vector_rate");
23246 clib_spinlock_unlock (vam->stat_segment_lockp);
23247 errmsg ("vector_rate not found?");
23251 vector_rate = *(f64 *) (p[0]);
23252 p = hash_get_mem (counter_vector_by_name, "input_rate");
23255 clib_spinlock_unlock (vam->stat_segment_lockp);
23256 errmsg ("input_rate not found?");
23259 input_rate = *(f64 *) (p[0]);
23261 clib_spinlock_unlock (vam->stat_segment_lockp);
23263 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
23264 vector_rate, input_rate);
23265 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
23266 thread0_index1_packets, thread0_index1_bytes);
23272 cmd_cmp (void *a1, void *a2)
23277 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23281 help (vat_main_t * vam)
23286 unformat_input_t *i = vam->input;
23289 if (unformat (i, "%s", &name))
23293 vec_add1 (name, 0);
23295 hs = hash_get_mem (vam->help_by_name, name);
23297 print (vam->ofp, "usage: %s %s", name, hs[0]);
23299 print (vam->ofp, "No such msg / command '%s'", name);
23304 print (vam->ofp, "Help is available for the following:");
23307 hash_foreach_pair (p, vam->function_by_name,
23309 vec_add1 (cmds, (u8 *)(p->key));
23313 vec_sort_with_function (cmds, cmd_cmp);
23315 for (j = 0; j < vec_len (cmds); j++)
23316 print (vam->ofp, "%s", cmds[j]);
23323 set (vat_main_t * vam)
23325 u8 *name = 0, *value = 0;
23326 unformat_input_t *i = vam->input;
23328 if (unformat (i, "%s", &name))
23330 /* The input buffer is a vector, not a string. */
23331 value = vec_dup (i->buffer);
23332 vec_delete (value, i->index, 0);
23333 /* Almost certainly has a trailing newline */
23334 if (value[vec_len (value) - 1] == '\n')
23335 value[vec_len (value) - 1] = 0;
23336 /* Make sure it's a proper string, one way or the other */
23337 vec_add1 (value, 0);
23338 (void) clib_macro_set_value (&vam->macro_main,
23339 (char *) name, (char *) value);
23342 errmsg ("usage: set <name> <value>");
23350 unset (vat_main_t * vam)
23354 if (unformat (vam->input, "%s", &name))
23355 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23356 errmsg ("unset: %s wasn't set", name);
23369 macro_sort_cmp (void *a1, void *a2)
23371 macro_sort_t *s1 = a1;
23372 macro_sort_t *s2 = a2;
23374 return strcmp ((char *) (s1->name), (char *) (s2->name));
23378 dump_macro_table (vat_main_t * vam)
23380 macro_sort_t *sort_me = 0, *sm;
23385 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23387 vec_add2 (sort_me, sm, 1);
23388 sm->name = (u8 *)(p->key);
23389 sm->value = (u8 *) (p->value[0]);
23393 vec_sort_with_function (sort_me, macro_sort_cmp);
23395 if (vec_len (sort_me))
23396 print (vam->ofp, "%-15s%s", "Name", "Value");
23398 print (vam->ofp, "The macro table is empty...");
23400 for (i = 0; i < vec_len (sort_me); i++)
23401 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23406 dump_node_table (vat_main_t * vam)
23409 vlib_node_t *node, *next_node;
23411 if (vec_len (vam->graph_nodes) == 0)
23413 print (vam->ofp, "Node table empty, issue get_node_graph...");
23417 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
23419 node = vam->graph_nodes[0][i];
23420 print (vam->ofp, "[%d] %s", i, node->name);
23421 for (j = 0; j < vec_len (node->next_nodes); j++)
23423 if (node->next_nodes[j] != ~0)
23425 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23426 print (vam->ofp, " [%d] %s", j, next_node->name);
23434 value_sort_cmp (void *a1, void *a2)
23436 name_sort_t *n1 = a1;
23437 name_sort_t *n2 = a2;
23439 if (n1->value < n2->value)
23441 if (n1->value > n2->value)
23448 dump_msg_api_table (vat_main_t * vam)
23450 api_main_t *am = &api_main;
23451 name_sort_t *nses = 0, *ns;
23456 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23458 vec_add2 (nses, ns, 1);
23459 ns->name = (u8 *)(hp->key);
23460 ns->value = (u32) hp->value[0];
23464 vec_sort_with_function (nses, value_sort_cmp);
23466 for (i = 0; i < vec_len (nses); i++)
23467 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23473 get_msg_id (vat_main_t * vam)
23478 if (unformat (vam->input, "%s", &name_and_crc))
23480 message_index = vl_msg_api_get_msg_index (name_and_crc);
23481 if (message_index == ~0)
23483 print (vam->ofp, " '%s' not found", name_and_crc);
23486 print (vam->ofp, " '%s' has message index %d",
23487 name_and_crc, message_index);
23490 errmsg ("name_and_crc required...");
23495 search_node_table (vat_main_t * vam)
23497 unformat_input_t *line_input = vam->input;
23500 vlib_node_t *node, *next_node;
23503 if (vam->graph_node_index_by_name == 0)
23505 print (vam->ofp, "Node table empty, issue get_node_graph...");
23509 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23511 if (unformat (line_input, "%s", &node_to_find))
23513 vec_add1 (node_to_find, 0);
23514 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23517 print (vam->ofp, "%s not found...", node_to_find);
23520 node = vam->graph_nodes[0][p[0]];
23521 print (vam->ofp, "[%d] %s", p[0], node->name);
23522 for (j = 0; j < vec_len (node->next_nodes); j++)
23524 if (node->next_nodes[j] != ~0)
23526 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23527 print (vam->ofp, " [%d] %s", j, next_node->name);
23534 clib_warning ("parse error '%U'", format_unformat_error,
23540 vec_free (node_to_find);
23549 script (vat_main_t * vam)
23551 #if (VPP_API_TEST_BUILTIN==0)
23553 char *save_current_file;
23554 unformat_input_t save_input;
23555 jmp_buf save_jump_buf;
23556 u32 save_line_number;
23558 FILE *new_fp, *save_ifp;
23560 if (unformat (vam->input, "%s", &s))
23562 new_fp = fopen ((char *) s, "r");
23565 errmsg ("Couldn't open script file %s", s);
23572 errmsg ("Missing script name");
23576 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23577 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23578 save_ifp = vam->ifp;
23579 save_line_number = vam->input_line_number;
23580 save_current_file = (char *) vam->current_file;
23582 vam->input_line_number = 0;
23584 vam->current_file = s;
23587 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23588 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23589 vam->ifp = save_ifp;
23590 vam->input_line_number = save_line_number;
23591 vam->current_file = (u8 *) save_current_file;
23596 clib_warning ("use the exec command...");
23602 echo (vat_main_t * vam)
23604 print (vam->ofp, "%v", vam->input->buffer);
23608 /* List of API message constructors, CLI names map to api_xxx */
23609 #define foreach_vpe_api_msg \
23610 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23611 _(sw_interface_dump,"") \
23612 _(sw_interface_set_flags, \
23613 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23614 _(sw_interface_add_del_address, \
23615 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23616 _(sw_interface_set_rx_mode, \
23617 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23618 _(sw_interface_set_rx_placement, \
23619 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
23620 _(sw_interface_rx_placement_dump, \
23621 "[<intfc> | sw_if_index <id>]") \
23622 _(sw_interface_set_table, \
23623 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23624 _(sw_interface_set_mpls_enable, \
23625 "<intfc> | sw_if_index [disable | dis]") \
23626 _(sw_interface_set_vpath, \
23627 "<intfc> | sw_if_index <id> enable | disable") \
23628 _(sw_interface_set_vxlan_bypass, \
23629 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23630 _(sw_interface_set_geneve_bypass, \
23631 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23632 _(sw_interface_set_l2_xconnect, \
23633 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23634 "enable | disable") \
23635 _(sw_interface_set_l2_bridge, \
23636 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23637 "[shg <split-horizon-group>] [bvi]\n" \
23638 "enable | disable") \
23639 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23640 _(bridge_domain_add_del, \
23641 "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") \
23642 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23644 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23645 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23646 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23648 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23650 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23652 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23654 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23656 "<vpp-if-name> | sw_if_index <id>") \
23657 _(sw_interface_tap_dump, "") \
23659 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23661 "<vpp-if-name> | sw_if_index <id>") \
23662 _(sw_interface_tap_v2_dump, "") \
23664 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23665 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23667 "<vpp-if-name> | sw_if_index <id>") \
23669 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23670 _(bond_detach_slave, \
23671 "sw_if_index <n>") \
23672 _(sw_interface_bond_dump, "") \
23673 _(sw_interface_slave_dump, \
23674 "<vpp-if-name> | sw_if_index <id>") \
23675 _(ip_table_add_del, \
23676 "table <n> [ipv6] [add | del]\n") \
23677 _(ip_add_del_route, \
23678 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
23679 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
23680 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
23681 "[multipath] [count <n>] [del]") \
23682 _(ip_mroute_add_del, \
23683 "<src> <grp>/<mask> [table-id <n>]\n" \
23684 "[<intfc> | sw_if_index <id>] [local] [del]") \
23685 _(mpls_table_add_del, \
23686 "table <n> [add | del]\n") \
23687 _(mpls_route_add_del, \
23688 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
23689 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
23690 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
23691 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
23692 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
23693 "[count <n>] [del]") \
23694 _(mpls_ip_bind_unbind, \
23695 "<label> <addr/len>") \
23696 _(mpls_tunnel_add_del, \
23697 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
23698 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
23699 "[l2-only] [out-label <n>]") \
23700 _(sr_mpls_policy_add, \
23701 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
23702 _(sr_mpls_policy_del, \
23704 _(bier_table_add_del, \
23705 "<label> <sub-domain> <set> <bsl> [del]") \
23706 _(bier_route_add_del, \
23707 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23708 "[<intfc> | sw_if_index <id>]" \
23709 "[weight <n>] [del] [multipath]") \
23710 _(proxy_arp_add_del, \
23711 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23712 _(proxy_arp_intfc_enable_disable, \
23713 "<intfc> | sw_if_index <id> enable | disable") \
23714 _(sw_interface_set_unnumbered, \
23715 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23716 _(ip_neighbor_add_del, \
23717 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23718 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23719 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23720 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23721 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23722 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23723 "[outer_vlan_id_any][inner_vlan_id_any]") \
23724 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23725 _(reset_fib, "vrf <n> [ipv6]") \
23726 _(dhcp_proxy_config, \
23727 "svr <v46-address> src <v46-address>\n" \
23728 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23729 _(dhcp_proxy_set_vss, \
23730 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23731 _(dhcp_proxy_dump, "ip6") \
23732 _(dhcp_client_config, \
23733 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23734 _(set_ip_flow_hash, \
23735 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23736 _(sw_interface_ip6_enable_disable, \
23737 "<intfc> | sw_if_index <id> enable | disable") \
23738 _(ip6nd_proxy_add_del, \
23739 "<intfc> | sw_if_index <id> <ip6-address>") \
23740 _(ip6nd_proxy_dump, "") \
23741 _(sw_interface_ip6nd_ra_prefix, \
23742 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23743 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23744 "[nolink] [isno]") \
23745 _(sw_interface_ip6nd_ra_config, \
23746 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23747 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23748 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23749 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23750 _(l2_patch_add_del, \
23751 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23752 "enable | disable") \
23753 _(sr_localsid_add_del, \
23754 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23755 "fib-table <num> (end.psp) sw_if_index <num>") \
23756 _(classify_add_del_table, \
23757 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23758 " [del] [del-chain] mask <mask-value>\n" \
23759 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23760 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23761 _(classify_add_del_session, \
23762 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23763 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23764 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23765 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23766 _(classify_set_interface_ip_table, \
23767 "<intfc> | sw_if_index <nn> table <nn>") \
23768 _(classify_set_interface_l2_tables, \
23769 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23770 " [other-table <nn>]") \
23771 _(get_node_index, "node <node-name") \
23772 _(add_node_next, "node <node-name> next <next-node-name>") \
23773 _(l2tpv3_create_tunnel, \
23774 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23775 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23776 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23777 _(l2tpv3_set_tunnel_cookies, \
23778 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23779 "[new_remote_cookie <nn>]\n") \
23780 _(l2tpv3_interface_enable_disable, \
23781 "<intfc> | sw_if_index <nn> enable | disable") \
23782 _(l2tpv3_set_lookup_key, \
23783 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23784 _(sw_if_l2tpv3_tunnel_dump, "") \
23785 _(vxlan_offload_rx, \
23786 "hw { <interface name> | hw_if_index <nn>} " \
23787 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23788 _(vxlan_add_del_tunnel, \
23789 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23790 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23791 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23792 _(geneve_add_del_tunnel, \
23793 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23794 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23795 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23796 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23797 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23798 _(gre_add_del_tunnel, \
23799 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23800 "[teb | erspan <session-id>] [del]") \
23801 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23802 _(l2_fib_clear_table, "") \
23803 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23804 _(l2_interface_vlan_tag_rewrite, \
23805 "<intfc> | sw_if_index <nn> \n" \
23806 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23807 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23808 _(create_vhost_user_if, \
23809 "socket <filename> [server] [renumber <dev_instance>] " \
23810 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
23811 "[mac <mac_address>]") \
23812 _(modify_vhost_user_if, \
23813 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23814 "[server] [renumber <dev_instance>]") \
23815 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23816 _(sw_interface_vhost_user_dump, "") \
23817 _(show_version, "") \
23818 _(show_threads, "") \
23819 _(vxlan_gpe_add_del_tunnel, \
23820 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23821 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23822 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23823 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23824 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23825 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23826 _(interface_name_renumber, \
23827 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23828 _(input_acl_set_interface, \
23829 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23830 " [l2-table <nn>] [del]") \
23831 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23832 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23833 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23834 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23835 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23836 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23837 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23838 _(ip_dump, "ipv4 | ipv6") \
23839 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23840 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23842 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23843 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23844 " integ_alg <alg> integ_key <hex>") \
23845 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23846 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23847 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23848 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23849 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23850 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23851 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23852 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23853 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23854 " [instance <n>]") \
23855 _(ipsec_sa_dump, "[sa_id <n>]") \
23856 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23857 " <alg> <hex>\n") \
23858 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23859 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23860 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23861 "(auth_data 0x<data> | auth_data <data>)") \
23862 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23863 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23864 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23865 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23866 "(local|remote)") \
23867 _(ikev2_set_local_key, "file <absolute_file_path>") \
23868 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23869 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23870 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23871 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23872 _(ikev2_initiate_sa_init, "<profile_name>") \
23873 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23874 _(ikev2_initiate_del_child_sa, "<ispi>") \
23875 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23876 _(delete_loopback,"sw_if_index <nn>") \
23877 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23878 _(bd_ip_mac_dump, "[bd_id] <id>") \
23879 _(want_interface_events, "enable|disable") \
23880 _(want_stats,"enable|disable") \
23881 _(get_first_msg_id, "client <name>") \
23882 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23883 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23884 "fib-id <nn> [ip4][ip6][default]") \
23885 _(get_node_graph, " ") \
23886 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23887 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23888 _(ioam_disable, "") \
23889 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23890 " sw_if_index <sw_if_index> p <priority> " \
23891 "w <weight>] [del]") \
23892 _(one_add_del_locator, "locator-set <locator_name> " \
23893 "iface <intf> | sw_if_index <sw_if_index> " \
23894 "p <priority> w <weight> [del]") \
23895 _(one_add_del_local_eid,"vni <vni> eid " \
23896 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23897 "locator-set <locator_name> [del]" \
23898 "[key-id sha1|sha256 secret-key <secret-key>]")\
23899 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23900 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23901 _(one_enable_disable, "enable|disable") \
23902 _(one_map_register_enable_disable, "enable|disable") \
23903 _(one_map_register_fallback_threshold, "<value>") \
23904 _(one_rloc_probe_enable_disable, "enable|disable") \
23905 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23907 "rloc <locator> p <prio> " \
23908 "w <weight> [rloc <loc> ... ] " \
23909 "action <action> [del-all]") \
23910 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23912 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23913 _(one_use_petr, "ip-address> | disable") \
23914 _(one_map_request_mode, "src-dst|dst-only") \
23915 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23916 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23917 _(one_locator_set_dump, "[local | remote]") \
23918 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23919 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23920 "[local] | [remote]") \
23921 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23922 _(one_ndp_bd_get, "") \
23923 _(one_ndp_entries_get, "bd <bridge-domain>") \
23924 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23925 _(one_l2_arp_bd_get, "") \
23926 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23927 _(one_stats_enable_disable, "enable|disable") \
23928 _(show_one_stats_enable_disable, "") \
23929 _(one_eid_table_vni_dump, "") \
23930 _(one_eid_table_map_dump, "l2|l3") \
23931 _(one_map_resolver_dump, "") \
23932 _(one_map_server_dump, "") \
23933 _(one_adjacencies_get, "vni <vni>") \
23934 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23935 _(show_one_rloc_probe_state, "") \
23936 _(show_one_map_register_state, "") \
23937 _(show_one_status, "") \
23938 _(one_stats_dump, "") \
23939 _(one_stats_flush, "") \
23940 _(one_get_map_request_itr_rlocs, "") \
23941 _(one_map_register_set_ttl, "<ttl>") \
23942 _(one_set_transport_protocol, "udp|api") \
23943 _(one_get_transport_protocol, "") \
23944 _(one_enable_disable_xtr_mode, "enable|disable") \
23945 _(one_show_xtr_mode, "") \
23946 _(one_enable_disable_pitr_mode, "enable|disable") \
23947 _(one_show_pitr_mode, "") \
23948 _(one_enable_disable_petr_mode, "enable|disable") \
23949 _(one_show_petr_mode, "") \
23950 _(show_one_nsh_mapping, "") \
23951 _(show_one_pitr, "") \
23952 _(show_one_use_petr, "") \
23953 _(show_one_map_request_mode, "") \
23954 _(show_one_map_register_ttl, "") \
23955 _(show_one_map_register_fallback_threshold, "") \
23956 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23957 " sw_if_index <sw_if_index> p <priority> " \
23958 "w <weight>] [del]") \
23959 _(lisp_add_del_locator, "locator-set <locator_name> " \
23960 "iface <intf> | sw_if_index <sw_if_index> " \
23961 "p <priority> w <weight> [del]") \
23962 _(lisp_add_del_local_eid,"vni <vni> eid " \
23963 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23964 "locator-set <locator_name> [del]" \
23965 "[key-id sha1|sha256 secret-key <secret-key>]") \
23966 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23967 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23968 _(lisp_enable_disable, "enable|disable") \
23969 _(lisp_map_register_enable_disable, "enable|disable") \
23970 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23971 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23973 "rloc <locator> p <prio> " \
23974 "w <weight> [rloc <loc> ... ] " \
23975 "action <action> [del-all]") \
23976 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23978 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23979 _(lisp_use_petr, "<ip-address> | disable") \
23980 _(lisp_map_request_mode, "src-dst|dst-only") \
23981 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23982 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23983 _(lisp_locator_set_dump, "[local | remote]") \
23984 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23985 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23986 "[local] | [remote]") \
23987 _(lisp_eid_table_vni_dump, "") \
23988 _(lisp_eid_table_map_dump, "l2|l3") \
23989 _(lisp_map_resolver_dump, "") \
23990 _(lisp_map_server_dump, "") \
23991 _(lisp_adjacencies_get, "vni <vni>") \
23992 _(gpe_fwd_entry_vnis_get, "") \
23993 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23994 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23995 "[table <table-id>]") \
23996 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23997 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23998 _(gpe_set_encap_mode, "lisp|vxlan") \
23999 _(gpe_get_encap_mode, "") \
24000 _(lisp_gpe_add_del_iface, "up|down") \
24001 _(lisp_gpe_enable_disable, "enable|disable") \
24002 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
24003 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
24004 _(show_lisp_rloc_probe_state, "") \
24005 _(show_lisp_map_register_state, "") \
24006 _(show_lisp_status, "") \
24007 _(lisp_get_map_request_itr_rlocs, "") \
24008 _(show_lisp_pitr, "") \
24009 _(show_lisp_use_petr, "") \
24010 _(show_lisp_map_request_mode, "") \
24011 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
24012 _(af_packet_delete, "name <host interface name>") \
24013 _(af_packet_dump, "") \
24014 _(policer_add_del, "name <policer name> <params> [del]") \
24015 _(policer_dump, "[name <policer name>]") \
24016 _(policer_classify_set_interface, \
24017 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24018 " [l2-table <nn>] [del]") \
24019 _(policer_classify_dump, "type [ip4|ip6|l2]") \
24020 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
24021 "[master|slave]") \
24022 _(netmap_delete, "name <interface name>") \
24023 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
24024 _(mpls_fib_dump, "") \
24025 _(classify_table_ids, "") \
24026 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
24027 _(classify_table_info, "table_id <nn>") \
24028 _(classify_session_dump, "table_id <nn>") \
24029 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
24030 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
24031 "[template_interval <nn>] [udp_checksum]") \
24032 _(ipfix_exporter_dump, "") \
24033 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
24034 _(ipfix_classify_stream_dump, "") \
24035 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
24036 _(ipfix_classify_table_dump, "") \
24037 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
24038 _(sw_interface_span_dump, "[l2]") \
24039 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
24040 _(pg_create_interface, "if_id <nn>") \
24041 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
24042 _(pg_enable_disable, "[stream <id>] disable") \
24043 _(ip_source_and_port_range_check_add_del, \
24044 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
24045 _(ip_source_and_port_range_check_interface_add_del, \
24046 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
24047 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
24048 _(ipsec_gre_add_del_tunnel, \
24049 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
24050 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
24051 _(delete_subif,"<intfc> | sw_if_index <nn>") \
24052 _(l2_interface_pbb_tag_rewrite, \
24053 "<intfc> | sw_if_index <nn> \n" \
24054 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
24055 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
24056 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
24057 _(flow_classify_set_interface, \
24058 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
24059 _(flow_classify_dump, "type [ip4|ip6]") \
24060 _(ip_fib_dump, "") \
24061 _(ip_mfib_dump, "") \
24062 _(ip6_fib_dump, "") \
24063 _(ip6_mfib_dump, "") \
24064 _(feature_enable_disable, "arc_name <arc_name> " \
24065 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
24066 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
24068 _(l2_xconnect_dump, "") \
24069 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
24070 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
24071 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
24072 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
24073 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
24074 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
24075 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
24076 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
24077 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
24078 _(sock_init_shm, "size <nnn>") \
24079 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
24080 _(dns_enable_disable, "[enable][disable]") \
24081 _(dns_name_server_add_del, "<ip-address> [del]") \
24082 _(dns_resolve_name, "<hostname>") \
24083 _(dns_resolve_ip, "<ip4|ip6>") \
24084 _(dns_name_server_add_del, "<ip-address> [del]") \
24085 _(dns_resolve_name, "<hostname>") \
24086 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
24087 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
24088 _(session_rules_dump, "") \
24089 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
24090 _(output_acl_set_interface, \
24091 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24092 " [l2-table <nn>] [del]") \
24093 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
24095 /* List of command functions, CLI names map directly to functions */
24096 #define foreach_cli_function \
24097 _(comment, "usage: comment <ignore-rest-of-line>") \
24098 _(dump_interface_table, "usage: dump_interface_table") \
24099 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
24100 _(dump_ipv4_table, "usage: dump_ipv4_table") \
24101 _(dump_ipv6_table, "usage: dump_ipv6_table") \
24102 _(dump_stats_table, "usage: dump_stats_table") \
24103 _(dump_macro_table, "usage: dump_macro_table ") \
24104 _(dump_node_table, "usage: dump_node_table") \
24105 _(dump_msg_api_table, "usage: dump_msg_api_table") \
24106 _(get_msg_id, "usage: get_msg_id name_and_crc") \
24107 _(echo, "usage: echo <message>") \
24108 _(exec, "usage: exec <vpe-debug-CLI-command>") \
24109 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
24110 _(help, "usage: help") \
24111 _(q, "usage: quit") \
24112 _(quit, "usage: quit") \
24113 _(search_node_table, "usage: search_node_table <name>...") \
24114 _(set, "usage: set <variable-name> <value>") \
24115 _(script, "usage: script <file-name>") \
24116 _(statseg, "usage: statseg"); \
24117 _(unset, "usage: unset <variable-name>")
24120 static void vl_api_##n##_t_handler_uni \
24121 (vl_api_##n##_t * mp) \
24123 vat_main_t * vam = &vat_main; \
24124 if (vam->json_output) { \
24125 vl_api_##n##_t_handler_json(mp); \
24127 vl_api_##n##_t_handler(mp); \
24130 foreach_vpe_api_reply_msg;
24131 #if VPP_API_TEST_BUILTIN == 0
24132 foreach_standalone_reply_msg;
24137 vat_api_hookup (vat_main_t * vam)
24140 vl_msg_api_set_handlers(VL_API_##N, #n, \
24141 vl_api_##n##_t_handler_uni, \
24143 vl_api_##n##_t_endian, \
24144 vl_api_##n##_t_print, \
24145 sizeof(vl_api_##n##_t), 1);
24146 foreach_vpe_api_reply_msg;
24147 #if VPP_API_TEST_BUILTIN == 0
24148 foreach_standalone_reply_msg;
24152 #if (VPP_API_TEST_BUILTIN==0)
24153 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
24155 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
24157 vam->function_by_name = hash_create_string (0, sizeof (uword));
24159 vam->help_by_name = hash_create_string (0, sizeof (uword));
24162 /* API messages we can send */
24163 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
24164 foreach_vpe_api_msg;
24168 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24169 foreach_vpe_api_msg;
24172 /* CLI functions */
24173 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
24174 foreach_cli_function;
24178 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24179 foreach_cli_function;
24183 #if VPP_API_TEST_BUILTIN
24184 static clib_error_t *
24185 vat_api_hookup_shim (vlib_main_t * vm)
24187 vat_api_hookup (&vat_main);
24191 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
24195 * fd.io coding-style-patch-verification: ON
24198 * eval: (c-set-style "gnu")