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
92 vat_socket_connect (vat_main_t * vam)
95 vam->socket_client_main = &socket_client_main;
96 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
98 0 /* default socket rx, tx buffer */ )))
100 /* vpp expects the client index in network order */
101 vam->my_client_index = htonl (socket_client_main.client_index);
104 #else /* vpp built-in case, we don't do sockets... */
106 vat_socket_connect (vat_main_t * vam)
112 vl_socket_client_read (int wait)
118 vl_socket_client_write ()
124 vl_socket_client_msg_alloc (int nbytes)
132 vat_time_now (vat_main_t * vam)
134 #if VPP_API_TEST_BUILTIN
135 return vlib_time_now (vam->vlib_main);
137 return clib_time_now (&vam->clib_time);
142 errmsg (char *fmt, ...)
144 vat_main_t *vam = &vat_main;
149 s = va_format (0, fmt, &va);
154 #if VPP_API_TEST_BUILTIN
155 vlib_cli_output (vam->vlib_main, (char *) s);
158 if (vam->ifp != stdin)
159 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
160 vam->input_line_number);
161 fformat (vam->ofp, (char *) s);
169 #if VPP_API_TEST_BUILTIN == 0
171 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
173 vat_main_t *vam = va_arg (*args, vat_main_t *);
174 u32 *result = va_arg (*args, u32 *);
178 if (!unformat (input, "%s", &if_name))
181 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
189 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
194 /* Parse an IP4 address %d.%d.%d.%d. */
196 unformat_ip4_address (unformat_input_t * input, va_list * args)
198 u8 *result = va_arg (*args, u8 *);
201 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
204 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
216 unformat_ethernet_address (unformat_input_t * input, va_list * args)
218 u8 *result = va_arg (*args, u8 *);
221 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
222 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
226 for (i = 0; i < 6; i++)
227 if (a[i] >= (1 << 8))
230 for (i = 0; i < 6; i++)
236 /* Returns ethernet type as an int in host byte order. */
238 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
241 u16 *result = va_arg (*args, u16 *);
245 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
247 if (type >= (1 << 16))
255 /* Parse an IP6 address. */
257 unformat_ip6_address (unformat_input_t * input, va_list * args)
259 ip6_address_t *result = va_arg (*args, ip6_address_t *);
261 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
262 uword c, n_colon, double_colon_index;
264 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
265 double_colon_index = ARRAY_LEN (hex_quads);
266 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
269 if (c >= '0' && c <= '9')
271 else if (c >= 'a' && c <= 'f')
272 hex_digit = c + 10 - 'a';
273 else if (c >= 'A' && c <= 'F')
274 hex_digit = c + 10 - 'A';
275 else if (c == ':' && n_colon < 2)
279 unformat_put_input (input);
283 /* Too many hex quads. */
284 if (n_hex_quads >= ARRAY_LEN (hex_quads))
289 hex_quad = (hex_quad << 4) | hex_digit;
291 /* Hex quad must fit in 16 bits. */
292 if (n_hex_digits >= 4)
299 /* Save position of :: */
302 /* More than one :: ? */
303 if (double_colon_index < ARRAY_LEN (hex_quads))
305 double_colon_index = n_hex_quads;
308 if (n_colon > 0 && n_hex_digits > 0)
310 hex_quads[n_hex_quads++] = hex_quad;
316 if (n_hex_digits > 0)
317 hex_quads[n_hex_quads++] = hex_quad;
322 /* Expand :: to appropriate number of zero hex quads. */
323 if (double_colon_index < ARRAY_LEN (hex_quads))
325 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
327 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
328 hex_quads[n_zero + i] = hex_quads[i];
330 for (i = 0; i < n_zero; i++)
331 hex_quads[double_colon_index + i] = 0;
333 n_hex_quads = ARRAY_LEN (hex_quads);
336 /* Too few hex quads given. */
337 if (n_hex_quads < ARRAY_LEN (hex_quads))
340 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
341 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
348 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
350 u32 *r = va_arg (*args, u32 *);
353 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
354 foreach_ipsec_policy_action
362 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
364 u32 *r = va_arg (*args, u32 *);
367 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
368 foreach_ipsec_crypto_alg
376 format_ipsec_crypto_alg (u8 * s, va_list * args)
378 u32 i = va_arg (*args, u32);
383 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
384 foreach_ipsec_crypto_alg
387 return format (s, "unknown");
389 return format (s, "%s", t);
393 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
395 u32 *r = va_arg (*args, u32 *);
398 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
399 foreach_ipsec_integ_alg
407 format_ipsec_integ_alg (u8 * s, va_list * args)
409 u32 i = va_arg (*args, u32);
414 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
415 foreach_ipsec_integ_alg
418 return format (s, "unknown");
420 return format (s, "%s", t);
424 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
426 u32 *r = va_arg (*args, u32 *);
429 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
430 foreach_ikev2_auth_method
438 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
440 u32 *r = va_arg (*args, u32 *);
443 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
444 foreach_ikev2_id_type
450 #else /* VPP_API_TEST_BUILTIN == 1 */
452 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
454 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
455 vnet_main_t *vnm = vnet_get_main ();
456 u32 *result = va_arg (*args, u32 *);
458 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
462 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
464 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
465 vnet_main_t *vnm = vnet_get_main ();
466 u32 *result = va_arg (*args, u32 *);
468 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
471 #endif /* VPP_API_TEST_BUILTIN */
474 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
476 u8 *r = va_arg (*args, u8 *);
478 if (unformat (input, "kbps"))
479 *r = SSE2_QOS_RATE_KBPS;
480 else if (unformat (input, "pps"))
481 *r = SSE2_QOS_RATE_PPS;
488 unformat_policer_round_type (unformat_input_t * input, va_list * args)
490 u8 *r = va_arg (*args, u8 *);
492 if (unformat (input, "closest"))
493 *r = SSE2_QOS_ROUND_TO_CLOSEST;
494 else if (unformat (input, "up"))
495 *r = SSE2_QOS_ROUND_TO_UP;
496 else if (unformat (input, "down"))
497 *r = SSE2_QOS_ROUND_TO_DOWN;
504 unformat_policer_type (unformat_input_t * input, va_list * args)
506 u8 *r = va_arg (*args, u8 *);
508 if (unformat (input, "1r2c"))
509 *r = SSE2_QOS_POLICER_TYPE_1R2C;
510 else if (unformat (input, "1r3c"))
511 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
512 else if (unformat (input, "2r3c-2698"))
513 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
514 else if (unformat (input, "2r3c-4115"))
515 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
516 else if (unformat (input, "2r3c-mef5cf1"))
517 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
524 unformat_dscp (unformat_input_t * input, va_list * va)
526 u8 *r = va_arg (*va, u8 *);
529 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
538 unformat_policer_action_type (unformat_input_t * input, va_list * va)
540 sse2_qos_pol_action_params_st *a
541 = va_arg (*va, sse2_qos_pol_action_params_st *);
543 if (unformat (input, "drop"))
544 a->action_type = SSE2_QOS_ACTION_DROP;
545 else if (unformat (input, "transmit"))
546 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
547 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
548 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
555 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
557 u32 *r = va_arg (*va, u32 *);
560 if (unformat (input, "ip4"))
561 tid = POLICER_CLASSIFY_TABLE_IP4;
562 else if (unformat (input, "ip6"))
563 tid = POLICER_CLASSIFY_TABLE_IP6;
564 else if (unformat (input, "l2"))
565 tid = POLICER_CLASSIFY_TABLE_L2;
574 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
576 u32 *r = va_arg (*va, u32 *);
579 if (unformat (input, "ip4"))
580 tid = FLOW_CLASSIFY_TABLE_IP4;
581 else if (unformat (input, "ip6"))
582 tid = FLOW_CLASSIFY_TABLE_IP6;
590 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
591 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
592 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
593 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
595 #if (VPP_API_TEST_BUILTIN==0)
597 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
599 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
600 mfib_itf_attribute_t attr;
603 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
605 if (unformat (input, mfib_itf_flag_long_names[attr]))
606 *iflags |= (1 << attr);
608 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
610 if (unformat (input, mfib_itf_flag_names[attr]))
611 *iflags |= (1 << attr);
614 return (old == *iflags ? 0 : 1);
618 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
620 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
621 mfib_entry_attribute_t attr;
624 FOR_EACH_MFIB_ATTRIBUTE (attr)
626 if (unformat (input, mfib_flag_long_names[attr]))
627 *eflags |= (1 << attr);
629 FOR_EACH_MFIB_ATTRIBUTE (attr)
631 if (unformat (input, mfib_flag_names[attr]))
632 *eflags |= (1 << attr);
635 return (old == *eflags ? 0 : 1);
639 format_ip4_address (u8 * s, va_list * args)
641 u8 *a = va_arg (*args, u8 *);
642 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
646 format_ip6_address (u8 * s, va_list * args)
648 ip6_address_t *a = va_arg (*args, ip6_address_t *);
649 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
651 i_max_n_zero = ARRAY_LEN (a->as_u16);
653 i_first_zero = i_max_n_zero;
655 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
657 u32 is_zero = a->as_u16[i] == 0;
658 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
664 if ((!is_zero && n_zeros > max_n_zeros)
665 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
667 i_max_n_zero = i_first_zero;
668 max_n_zeros = n_zeros;
669 i_first_zero = ARRAY_LEN (a->as_u16);
674 last_double_colon = 0;
675 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
677 if (i == i_max_n_zero && max_n_zeros > 1)
679 s = format (s, "::");
680 i += max_n_zeros - 1;
681 last_double_colon = 1;
685 s = format (s, "%s%x",
686 (last_double_colon || i == 0) ? "" : ":",
687 clib_net_to_host_u16 (a->as_u16[i]));
688 last_double_colon = 0;
695 /* Format an IP46 address. */
697 format_ip46_address (u8 * s, va_list * args)
699 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
700 ip46_type_t type = va_arg (*args, ip46_type_t);
706 is_ip4 = ip46_address_is_ip4 (ip46);
717 format (s, "%U", format_ip4_address, &ip46->ip4) :
718 format (s, "%U", format_ip6_address, &ip46->ip6);
722 format_ethernet_address (u8 * s, va_list * args)
724 u8 *a = va_arg (*args, u8 *);
726 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
727 a[0], a[1], a[2], a[3], a[4], a[5]);
732 increment_v4_address (ip4_address_t * a)
736 v = ntohl (a->as_u32) + 1;
737 a->as_u32 = ntohl (v);
741 increment_v6_address (ip6_address_t * a)
745 v0 = clib_net_to_host_u64 (a->as_u64[0]);
746 v1 = clib_net_to_host_u64 (a->as_u64[1]);
751 a->as_u64[0] = clib_net_to_host_u64 (v0);
752 a->as_u64[1] = clib_net_to_host_u64 (v1);
756 increment_mac_address (u8 * mac)
758 u64 tmp = *((u64 *) mac);
759 tmp = clib_net_to_host_u64 (tmp);
760 tmp += 1 << 16; /* skip unused (least significant) octets */
761 tmp = clib_host_to_net_u64 (tmp);
763 clib_memcpy (mac, &tmp, 6);
766 static void vl_api_create_loopback_reply_t_handler
767 (vl_api_create_loopback_reply_t * mp)
769 vat_main_t *vam = &vat_main;
770 i32 retval = ntohl (mp->retval);
772 vam->retval = retval;
773 vam->regenerate_interface_table = 1;
774 vam->sw_if_index = ntohl (mp->sw_if_index);
775 vam->result_ready = 1;
778 static void vl_api_create_loopback_reply_t_handler_json
779 (vl_api_create_loopback_reply_t * mp)
781 vat_main_t *vam = &vat_main;
782 vat_json_node_t node;
784 vat_json_init_object (&node);
785 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
786 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
788 vat_json_print (vam->ofp, &node);
789 vat_json_free (&node);
790 vam->retval = ntohl (mp->retval);
791 vam->result_ready = 1;
794 static void vl_api_create_loopback_instance_reply_t_handler
795 (vl_api_create_loopback_instance_reply_t * mp)
797 vat_main_t *vam = &vat_main;
798 i32 retval = ntohl (mp->retval);
800 vam->retval = retval;
801 vam->regenerate_interface_table = 1;
802 vam->sw_if_index = ntohl (mp->sw_if_index);
803 vam->result_ready = 1;
806 static void vl_api_create_loopback_instance_reply_t_handler_json
807 (vl_api_create_loopback_instance_reply_t * mp)
809 vat_main_t *vam = &vat_main;
810 vat_json_node_t node;
812 vat_json_init_object (&node);
813 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
814 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
816 vat_json_print (vam->ofp, &node);
817 vat_json_free (&node);
818 vam->retval = ntohl (mp->retval);
819 vam->result_ready = 1;
822 static void vl_api_af_packet_create_reply_t_handler
823 (vl_api_af_packet_create_reply_t * mp)
825 vat_main_t *vam = &vat_main;
826 i32 retval = ntohl (mp->retval);
828 vam->retval = retval;
829 vam->regenerate_interface_table = 1;
830 vam->sw_if_index = ntohl (mp->sw_if_index);
831 vam->result_ready = 1;
834 static void vl_api_af_packet_create_reply_t_handler_json
835 (vl_api_af_packet_create_reply_t * mp)
837 vat_main_t *vam = &vat_main;
838 vat_json_node_t node;
840 vat_json_init_object (&node);
841 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
842 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
844 vat_json_print (vam->ofp, &node);
845 vat_json_free (&node);
847 vam->retval = ntohl (mp->retval);
848 vam->result_ready = 1;
851 static void vl_api_create_vlan_subif_reply_t_handler
852 (vl_api_create_vlan_subif_reply_t * mp)
854 vat_main_t *vam = &vat_main;
855 i32 retval = ntohl (mp->retval);
857 vam->retval = retval;
858 vam->regenerate_interface_table = 1;
859 vam->sw_if_index = ntohl (mp->sw_if_index);
860 vam->result_ready = 1;
863 static void vl_api_create_vlan_subif_reply_t_handler_json
864 (vl_api_create_vlan_subif_reply_t * mp)
866 vat_main_t *vam = &vat_main;
867 vat_json_node_t node;
869 vat_json_init_object (&node);
870 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
871 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
873 vat_json_print (vam->ofp, &node);
874 vat_json_free (&node);
876 vam->retval = ntohl (mp->retval);
877 vam->result_ready = 1;
880 static void vl_api_create_subif_reply_t_handler
881 (vl_api_create_subif_reply_t * mp)
883 vat_main_t *vam = &vat_main;
884 i32 retval = ntohl (mp->retval);
886 vam->retval = retval;
887 vam->regenerate_interface_table = 1;
888 vam->sw_if_index = ntohl (mp->sw_if_index);
889 vam->result_ready = 1;
892 static void vl_api_create_subif_reply_t_handler_json
893 (vl_api_create_subif_reply_t * mp)
895 vat_main_t *vam = &vat_main;
896 vat_json_node_t node;
898 vat_json_init_object (&node);
899 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
900 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
902 vat_json_print (vam->ofp, &node);
903 vat_json_free (&node);
905 vam->retval = ntohl (mp->retval);
906 vam->result_ready = 1;
909 static void vl_api_interface_name_renumber_reply_t_handler
910 (vl_api_interface_name_renumber_reply_t * mp)
912 vat_main_t *vam = &vat_main;
913 i32 retval = ntohl (mp->retval);
915 vam->retval = retval;
916 vam->regenerate_interface_table = 1;
917 vam->result_ready = 1;
920 static void vl_api_interface_name_renumber_reply_t_handler_json
921 (vl_api_interface_name_renumber_reply_t * mp)
923 vat_main_t *vam = &vat_main;
924 vat_json_node_t node;
926 vat_json_init_object (&node);
927 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
929 vat_json_print (vam->ofp, &node);
930 vat_json_free (&node);
932 vam->retval = ntohl (mp->retval);
933 vam->result_ready = 1;
937 * Special-case: build the interface table, maintain
938 * the next loopback sw_if_index vbl.
940 static void vl_api_sw_interface_details_t_handler
941 (vl_api_sw_interface_details_t * mp)
943 vat_main_t *vam = &vat_main;
944 u8 *s = format (0, "%s%c", mp->interface_name, 0);
946 hash_set_mem (vam->sw_if_index_by_interface_name, s,
947 ntohl (mp->sw_if_index));
949 /* In sub interface case, fill the sub interface table entry */
950 if (mp->sw_if_index != mp->sup_sw_if_index)
952 sw_interface_subif_t *sub = NULL;
954 vec_add2 (vam->sw_if_subif_table, sub, 1);
956 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
957 strncpy ((char *) sub->interface_name, (char *) s,
958 vec_len (sub->interface_name));
959 sub->sw_if_index = ntohl (mp->sw_if_index);
960 sub->sub_id = ntohl (mp->sub_id);
962 sub->sub_dot1ad = mp->sub_dot1ad;
963 sub->sub_number_of_tags = mp->sub_number_of_tags;
964 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
965 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
966 sub->sub_exact_match = mp->sub_exact_match;
967 sub->sub_default = mp->sub_default;
968 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
969 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
971 /* vlan tag rewrite */
972 sub->vtr_op = ntohl (mp->vtr_op);
973 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
974 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
975 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
979 static void vl_api_sw_interface_details_t_handler_json
980 (vl_api_sw_interface_details_t * mp)
982 vat_main_t *vam = &vat_main;
983 vat_json_node_t *node = NULL;
985 if (VAT_JSON_ARRAY != vam->json_tree.type)
987 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
988 vat_json_init_array (&vam->json_tree);
990 node = vat_json_array_add (&vam->json_tree);
992 vat_json_init_object (node);
993 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
994 vat_json_object_add_uint (node, "sup_sw_if_index",
995 ntohl (mp->sup_sw_if_index));
996 vat_json_object_add_uint (node, "l2_address_length",
997 ntohl (mp->l2_address_length));
998 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
999 sizeof (mp->l2_address));
1000 vat_json_object_add_string_copy (node, "interface_name",
1001 mp->interface_name);
1002 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
1003 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
1004 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1005 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1006 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1007 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1008 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
1009 vat_json_object_add_uint (node, "sub_number_of_tags",
1010 mp->sub_number_of_tags);
1011 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1012 ntohs (mp->sub_outer_vlan_id));
1013 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1014 ntohs (mp->sub_inner_vlan_id));
1015 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
1016 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
1017 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
1018 mp->sub_outer_vlan_id_any);
1019 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1020 mp->sub_inner_vlan_id_any);
1021 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1022 vat_json_object_add_uint (node, "vtr_push_dot1q",
1023 ntohl (mp->vtr_push_dot1q));
1024 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1025 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1028 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1030 format_ethernet_address,
1032 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1034 format_ethernet_address,
1036 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1037 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1041 #if VPP_API_TEST_BUILTIN == 0
1042 static void vl_api_sw_interface_event_t_handler
1043 (vl_api_sw_interface_event_t * mp)
1045 vat_main_t *vam = &vat_main;
1046 if (vam->interface_event_display)
1047 errmsg ("interface flags: sw_if_index %d %s %s",
1048 ntohl (mp->sw_if_index),
1049 mp->admin_up_down ? "admin-up" : "admin-down",
1050 mp->link_up_down ? "link-up" : "link-down");
1054 static void vl_api_sw_interface_event_t_handler_json
1055 (vl_api_sw_interface_event_t * mp)
1057 /* JSON output not supported */
1061 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1063 vat_main_t *vam = &vat_main;
1064 i32 retval = ntohl (mp->retval);
1066 vam->retval = retval;
1067 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1068 vam->result_ready = 1;
1072 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1074 vat_main_t *vam = &vat_main;
1075 vat_json_node_t node;
1076 api_main_t *am = &api_main;
1080 vat_json_init_object (&node);
1081 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1082 vat_json_object_add_uint (&node, "reply_in_shmem",
1083 ntohl (mp->reply_in_shmem));
1084 /* Toss the shared-memory original... */
1085 pthread_mutex_lock (&am->vlib_rp->mutex);
1086 oldheap = svm_push_data_heap (am->vlib_rp);
1088 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1091 svm_pop_heap (oldheap);
1092 pthread_mutex_unlock (&am->vlib_rp->mutex);
1094 vat_json_print (vam->ofp, &node);
1095 vat_json_free (&node);
1097 vam->retval = ntohl (mp->retval);
1098 vam->result_ready = 1;
1102 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1104 vat_main_t *vam = &vat_main;
1105 i32 retval = ntohl (mp->retval);
1106 u32 length = vl_api_string_len (&mp->reply);
1108 vec_reset_length (vam->cmd_reply);
1110 vam->retval = retval;
1113 vec_validate (vam->cmd_reply, length);
1114 clib_memcpy ((char *) (vam->cmd_reply),
1115 vl_api_from_api_string (&mp->reply), length);
1116 vam->cmd_reply[length] = 0;
1118 vam->result_ready = 1;
1122 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1124 vat_main_t *vam = &vat_main;
1125 vat_json_node_t node;
1127 vec_reset_length (vam->cmd_reply);
1129 vat_json_init_object (&node);
1130 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1131 vat_json_object_add_string_copy (&node, "reply",
1132 vl_api_from_api_string (&mp->reply));
1134 vat_json_print (vam->ofp, &node);
1135 vat_json_free (&node);
1137 vam->retval = ntohl (mp->retval);
1138 vam->result_ready = 1;
1141 static void vl_api_classify_add_del_table_reply_t_handler
1142 (vl_api_classify_add_del_table_reply_t * mp)
1144 vat_main_t *vam = &vat_main;
1145 i32 retval = ntohl (mp->retval);
1146 if (vam->async_mode)
1148 vam->async_errors += (retval < 0);
1152 vam->retval = retval;
1154 ((mp->new_table_index != 0xFFFFFFFF) ||
1155 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1156 (mp->match_n_vectors != 0xFFFFFFFF)))
1158 * Note: this is just barely thread-safe, depends on
1159 * the main thread spinning waiting for an answer...
1161 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1162 ntohl (mp->new_table_index),
1163 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1164 vam->result_ready = 1;
1168 static void vl_api_classify_add_del_table_reply_t_handler_json
1169 (vl_api_classify_add_del_table_reply_t * mp)
1171 vat_main_t *vam = &vat_main;
1172 vat_json_node_t node;
1174 vat_json_init_object (&node);
1175 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1176 vat_json_object_add_uint (&node, "new_table_index",
1177 ntohl (mp->new_table_index));
1178 vat_json_object_add_uint (&node, "skip_n_vectors",
1179 ntohl (mp->skip_n_vectors));
1180 vat_json_object_add_uint (&node, "match_n_vectors",
1181 ntohl (mp->match_n_vectors));
1183 vat_json_print (vam->ofp, &node);
1184 vat_json_free (&node);
1186 vam->retval = ntohl (mp->retval);
1187 vam->result_ready = 1;
1190 static void vl_api_get_node_index_reply_t_handler
1191 (vl_api_get_node_index_reply_t * mp)
1193 vat_main_t *vam = &vat_main;
1194 i32 retval = ntohl (mp->retval);
1195 if (vam->async_mode)
1197 vam->async_errors += (retval < 0);
1201 vam->retval = retval;
1203 errmsg ("node index %d", ntohl (mp->node_index));
1204 vam->result_ready = 1;
1208 static void vl_api_get_node_index_reply_t_handler_json
1209 (vl_api_get_node_index_reply_t * mp)
1211 vat_main_t *vam = &vat_main;
1212 vat_json_node_t node;
1214 vat_json_init_object (&node);
1215 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1216 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1218 vat_json_print (vam->ofp, &node);
1219 vat_json_free (&node);
1221 vam->retval = ntohl (mp->retval);
1222 vam->result_ready = 1;
1225 static void vl_api_get_next_index_reply_t_handler
1226 (vl_api_get_next_index_reply_t * mp)
1228 vat_main_t *vam = &vat_main;
1229 i32 retval = ntohl (mp->retval);
1230 if (vam->async_mode)
1232 vam->async_errors += (retval < 0);
1236 vam->retval = retval;
1238 errmsg ("next node index %d", ntohl (mp->next_index));
1239 vam->result_ready = 1;
1243 static void vl_api_get_next_index_reply_t_handler_json
1244 (vl_api_get_next_index_reply_t * mp)
1246 vat_main_t *vam = &vat_main;
1247 vat_json_node_t node;
1249 vat_json_init_object (&node);
1250 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1251 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1253 vat_json_print (vam->ofp, &node);
1254 vat_json_free (&node);
1256 vam->retval = ntohl (mp->retval);
1257 vam->result_ready = 1;
1260 static void vl_api_add_node_next_reply_t_handler
1261 (vl_api_add_node_next_reply_t * mp)
1263 vat_main_t *vam = &vat_main;
1264 i32 retval = ntohl (mp->retval);
1265 if (vam->async_mode)
1267 vam->async_errors += (retval < 0);
1271 vam->retval = retval;
1273 errmsg ("next index %d", ntohl (mp->next_index));
1274 vam->result_ready = 1;
1278 static void vl_api_add_node_next_reply_t_handler_json
1279 (vl_api_add_node_next_reply_t * mp)
1281 vat_main_t *vam = &vat_main;
1282 vat_json_node_t node;
1284 vat_json_init_object (&node);
1285 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1286 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1288 vat_json_print (vam->ofp, &node);
1289 vat_json_free (&node);
1291 vam->retval = ntohl (mp->retval);
1292 vam->result_ready = 1;
1295 static void vl_api_show_version_reply_t_handler
1296 (vl_api_show_version_reply_t * mp)
1298 vat_main_t *vam = &vat_main;
1299 i32 retval = ntohl (mp->retval);
1304 char *p = (char *) &mp->program;
1306 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1307 errmsg (" program: %s\n", s);
1311 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1312 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1313 errmsg (" version: %s\n", s);
1317 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1318 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1319 errmsg (" build date: %s\n", s);
1323 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1324 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1325 errmsg ("build directory: %s\n", s);
1328 vam->retval = retval;
1329 vam->result_ready = 1;
1332 static void vl_api_show_version_reply_t_handler_json
1333 (vl_api_show_version_reply_t * mp)
1335 vat_main_t *vam = &vat_main;
1336 vat_json_node_t node;
1338 vat_json_init_object (&node);
1339 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1340 char *p = (char *) &mp->program;
1341 vat_json_object_add_string_copy (&node, "program",
1342 vl_api_from_api_string ((vl_api_string_t *)
1344 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1345 vat_json_object_add_string_copy (&node, "version",
1346 vl_api_from_api_string ((vl_api_string_t *)
1348 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1349 vat_json_object_add_string_copy (&node, "build_date",
1350 vl_api_from_api_string ((vl_api_string_t *)
1352 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1353 vat_json_object_add_string_copy (&node, "build_directory",
1354 vl_api_from_api_string ((vl_api_string_t *)
1357 vat_json_print (vam->ofp, &node);
1358 vat_json_free (&node);
1360 vam->retval = ntohl (mp->retval);
1361 vam->result_ready = 1;
1364 static void vl_api_show_threads_reply_t_handler
1365 (vl_api_show_threads_reply_t * mp)
1367 vat_main_t *vam = &vat_main;
1368 i32 retval = ntohl (mp->retval);
1372 count = ntohl (mp->count);
1374 for (i = 0; i < count; i++)
1376 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1377 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1378 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1379 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1380 ntohl (mp->thread_data[i].cpu_socket));
1382 vam->retval = retval;
1383 vam->result_ready = 1;
1386 static void vl_api_show_threads_reply_t_handler_json
1387 (vl_api_show_threads_reply_t * mp)
1389 vat_main_t *vam = &vat_main;
1390 vat_json_node_t node;
1391 vl_api_thread_data_t *td;
1392 i32 retval = ntohl (mp->retval);
1396 count = ntohl (mp->count);
1398 vat_json_init_object (&node);
1399 vat_json_object_add_int (&node, "retval", retval);
1400 vat_json_object_add_uint (&node, "count", count);
1402 for (i = 0; i < count; i++)
1404 td = &mp->thread_data[i];
1405 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1406 vat_json_object_add_string_copy (&node, "name", td->name);
1407 vat_json_object_add_string_copy (&node, "type", td->type);
1408 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1409 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1410 vat_json_object_add_int (&node, "core", ntohl (td->id));
1411 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1414 vat_json_print (vam->ofp, &node);
1415 vat_json_free (&node);
1417 vam->retval = retval;
1418 vam->result_ready = 1;
1422 api_show_threads (vat_main_t * vam)
1424 vl_api_show_threads_t *mp;
1428 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1429 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1431 M (SHOW_THREADS, mp);
1439 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1441 u32 sw_if_index = ntohl (mp->sw_if_index);
1442 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1443 mp->mac_ip ? "mac/ip binding" : "address resolution",
1444 ntohl (mp->pid), format_ip4_address, &mp->address,
1445 format_ethernet_address, mp->new_mac, sw_if_index);
1449 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1451 /* JSON output not supported */
1455 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1457 u32 sw_if_index = ntohl (mp->sw_if_index);
1458 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1459 mp->mac_ip ? "mac/ip binding" : "address resolution",
1460 ntohl (mp->pid), format_ip6_address, mp->address,
1461 format_ethernet_address, mp->new_mac, sw_if_index);
1465 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1467 /* JSON output not supported */
1471 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1473 u32 n_macs = ntohl (mp->n_macs);
1474 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1475 ntohl (mp->pid), mp->client_index, n_macs);
1477 for (i = 0; i < n_macs; i++)
1479 vl_api_mac_entry_t *mac = &mp->mac[i];
1480 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1481 i + 1, ntohl (mac->sw_if_index),
1482 format_ethernet_address, mac->mac_addr, mac->action);
1489 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1491 /* JSON output not supported */
1494 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1495 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1498 * Special-case: build the bridge domain table, maintain
1499 * the next bd id vbl.
1501 static void vl_api_bridge_domain_details_t_handler
1502 (vl_api_bridge_domain_details_t * mp)
1504 vat_main_t *vam = &vat_main;
1505 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1508 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1509 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1511 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1512 ntohl (mp->bd_id), mp->learn, mp->forward,
1513 mp->flood, ntohl (mp->bvi_sw_if_index),
1514 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1518 vl_api_bridge_domain_sw_if_t *sw_ifs;
1519 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1522 sw_ifs = mp->sw_if_details;
1523 for (i = 0; i < n_sw_ifs; i++)
1529 sw_if_index = ntohl (sw_ifs->sw_if_index);
1532 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1534 if ((u32) p->value[0] == sw_if_index)
1536 sw_if_name = (u8 *)(p->key);
1541 print (vam->ofp, "%7d %3d %s", sw_if_index,
1542 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1543 "sw_if_index not found!");
1550 static void vl_api_bridge_domain_details_t_handler_json
1551 (vl_api_bridge_domain_details_t * mp)
1553 vat_main_t *vam = &vat_main;
1554 vat_json_node_t *node, *array = NULL;
1555 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1557 if (VAT_JSON_ARRAY != vam->json_tree.type)
1559 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1560 vat_json_init_array (&vam->json_tree);
1562 node = vat_json_array_add (&vam->json_tree);
1564 vat_json_init_object (node);
1565 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1566 vat_json_object_add_uint (node, "flood", mp->flood);
1567 vat_json_object_add_uint (node, "forward", mp->forward);
1568 vat_json_object_add_uint (node, "learn", mp->learn);
1569 vat_json_object_add_uint (node, "bvi_sw_if_index",
1570 ntohl (mp->bvi_sw_if_index));
1571 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1572 array = vat_json_object_add (node, "sw_if");
1573 vat_json_init_array (array);
1579 vl_api_bridge_domain_sw_if_t *sw_ifs;
1582 sw_ifs = mp->sw_if_details;
1583 for (i = 0; i < n_sw_ifs; i++)
1585 node = vat_json_array_add (array);
1586 vat_json_init_object (node);
1587 vat_json_object_add_uint (node, "sw_if_index",
1588 ntohl (sw_ifs->sw_if_index));
1589 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1595 static void vl_api_control_ping_reply_t_handler
1596 (vl_api_control_ping_reply_t * mp)
1598 vat_main_t *vam = &vat_main;
1599 i32 retval = ntohl (mp->retval);
1600 if (vam->async_mode)
1602 vam->async_errors += (retval < 0);
1606 vam->retval = retval;
1607 vam->result_ready = 1;
1609 if (vam->socket_client_main)
1610 vam->socket_client_main->control_pings_outstanding--;
1613 static void vl_api_control_ping_reply_t_handler_json
1614 (vl_api_control_ping_reply_t * mp)
1616 vat_main_t *vam = &vat_main;
1617 i32 retval = ntohl (mp->retval);
1619 if (VAT_JSON_NONE != vam->json_tree.type)
1621 vat_json_print (vam->ofp, &vam->json_tree);
1622 vat_json_free (&vam->json_tree);
1623 vam->json_tree.type = VAT_JSON_NONE;
1628 vat_json_init_array (&vam->json_tree);
1629 vat_json_print (vam->ofp, &vam->json_tree);
1630 vam->json_tree.type = VAT_JSON_NONE;
1633 vam->retval = retval;
1634 vam->result_ready = 1;
1638 vl_api_bridge_domain_set_mac_age_reply_t_handler
1639 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1641 vat_main_t *vam = &vat_main;
1642 i32 retval = ntohl (mp->retval);
1643 if (vam->async_mode)
1645 vam->async_errors += (retval < 0);
1649 vam->retval = retval;
1650 vam->result_ready = 1;
1654 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1655 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1657 vat_main_t *vam = &vat_main;
1658 vat_json_node_t node;
1660 vat_json_init_object (&node);
1661 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1663 vat_json_print (vam->ofp, &node);
1664 vat_json_free (&node);
1666 vam->retval = ntohl (mp->retval);
1667 vam->result_ready = 1;
1671 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1673 vat_main_t *vam = &vat_main;
1674 i32 retval = ntohl (mp->retval);
1675 if (vam->async_mode)
1677 vam->async_errors += (retval < 0);
1681 vam->retval = retval;
1682 vam->result_ready = 1;
1686 static void vl_api_l2_flags_reply_t_handler_json
1687 (vl_api_l2_flags_reply_t * mp)
1689 vat_main_t *vam = &vat_main;
1690 vat_json_node_t node;
1692 vat_json_init_object (&node);
1693 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1694 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1695 ntohl (mp->resulting_feature_bitmap));
1697 vat_json_print (vam->ofp, &node);
1698 vat_json_free (&node);
1700 vam->retval = ntohl (mp->retval);
1701 vam->result_ready = 1;
1704 static void vl_api_bridge_flags_reply_t_handler
1705 (vl_api_bridge_flags_reply_t * mp)
1707 vat_main_t *vam = &vat_main;
1708 i32 retval = ntohl (mp->retval);
1709 if (vam->async_mode)
1711 vam->async_errors += (retval < 0);
1715 vam->retval = retval;
1716 vam->result_ready = 1;
1720 static void vl_api_bridge_flags_reply_t_handler_json
1721 (vl_api_bridge_flags_reply_t * mp)
1723 vat_main_t *vam = &vat_main;
1724 vat_json_node_t node;
1726 vat_json_init_object (&node);
1727 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1728 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1729 ntohl (mp->resulting_feature_bitmap));
1731 vat_json_print (vam->ofp, &node);
1732 vat_json_free (&node);
1734 vam->retval = ntohl (mp->retval);
1735 vam->result_ready = 1;
1738 static void vl_api_tap_connect_reply_t_handler
1739 (vl_api_tap_connect_reply_t * mp)
1741 vat_main_t *vam = &vat_main;
1742 i32 retval = ntohl (mp->retval);
1743 if (vam->async_mode)
1745 vam->async_errors += (retval < 0);
1749 vam->retval = retval;
1750 vam->sw_if_index = ntohl (mp->sw_if_index);
1751 vam->result_ready = 1;
1756 static void vl_api_tap_connect_reply_t_handler_json
1757 (vl_api_tap_connect_reply_t * mp)
1759 vat_main_t *vam = &vat_main;
1760 vat_json_node_t node;
1762 vat_json_init_object (&node);
1763 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1764 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1766 vat_json_print (vam->ofp, &node);
1767 vat_json_free (&node);
1769 vam->retval = ntohl (mp->retval);
1770 vam->result_ready = 1;
1775 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1777 vat_main_t *vam = &vat_main;
1778 i32 retval = ntohl (mp->retval);
1779 if (vam->async_mode)
1781 vam->async_errors += (retval < 0);
1785 vam->retval = retval;
1786 vam->sw_if_index = ntohl (mp->sw_if_index);
1787 vam->result_ready = 1;
1791 static void vl_api_tap_modify_reply_t_handler_json
1792 (vl_api_tap_modify_reply_t * mp)
1794 vat_main_t *vam = &vat_main;
1795 vat_json_node_t node;
1797 vat_json_init_object (&node);
1798 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1799 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1801 vat_json_print (vam->ofp, &node);
1802 vat_json_free (&node);
1804 vam->retval = ntohl (mp->retval);
1805 vam->result_ready = 1;
1809 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1811 vat_main_t *vam = &vat_main;
1812 i32 retval = ntohl (mp->retval);
1813 if (vam->async_mode)
1815 vam->async_errors += (retval < 0);
1819 vam->retval = retval;
1820 vam->result_ready = 1;
1824 static void vl_api_tap_delete_reply_t_handler_json
1825 (vl_api_tap_delete_reply_t * mp)
1827 vat_main_t *vam = &vat_main;
1828 vat_json_node_t node;
1830 vat_json_init_object (&node);
1831 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1833 vat_json_print (vam->ofp, &node);
1834 vat_json_free (&node);
1836 vam->retval = ntohl (mp->retval);
1837 vam->result_ready = 1;
1841 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1843 vat_main_t *vam = &vat_main;
1844 i32 retval = ntohl (mp->retval);
1845 if (vam->async_mode)
1847 vam->async_errors += (retval < 0);
1851 vam->retval = retval;
1852 vam->sw_if_index = ntohl (mp->sw_if_index);
1853 vam->result_ready = 1;
1858 static void vl_api_tap_create_v2_reply_t_handler_json
1859 (vl_api_tap_create_v2_reply_t * mp)
1861 vat_main_t *vam = &vat_main;
1862 vat_json_node_t node;
1864 vat_json_init_object (&node);
1865 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1866 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1868 vat_json_print (vam->ofp, &node);
1869 vat_json_free (&node);
1871 vam->retval = ntohl (mp->retval);
1872 vam->result_ready = 1;
1877 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1879 vat_main_t *vam = &vat_main;
1880 i32 retval = ntohl (mp->retval);
1881 if (vam->async_mode)
1883 vam->async_errors += (retval < 0);
1887 vam->retval = retval;
1888 vam->result_ready = 1;
1892 static void vl_api_tap_delete_v2_reply_t_handler_json
1893 (vl_api_tap_delete_v2_reply_t * mp)
1895 vat_main_t *vam = &vat_main;
1896 vat_json_node_t node;
1898 vat_json_init_object (&node);
1899 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1901 vat_json_print (vam->ofp, &node);
1902 vat_json_free (&node);
1904 vam->retval = ntohl (mp->retval);
1905 vam->result_ready = 1;
1909 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1912 vat_main_t *vam = &vat_main;
1913 i32 retval = ntohl (mp->retval);
1914 if (vam->async_mode)
1916 vam->async_errors += (retval < 0);
1920 vam->retval = retval;
1921 vam->sw_if_index = ntohl (mp->sw_if_index);
1922 vam->result_ready = 1;
1926 static void vl_api_virtio_pci_create_reply_t_handler_json
1927 (vl_api_virtio_pci_create_reply_t * mp)
1929 vat_main_t *vam = &vat_main;
1930 vat_json_node_t node;
1932 vat_json_init_object (&node);
1933 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1934 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1936 vat_json_print (vam->ofp, &node);
1937 vat_json_free (&node);
1939 vam->retval = ntohl (mp->retval);
1940 vam->result_ready = 1;
1945 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1948 vat_main_t *vam = &vat_main;
1949 i32 retval = ntohl (mp->retval);
1950 if (vam->async_mode)
1952 vam->async_errors += (retval < 0);
1956 vam->retval = retval;
1957 vam->result_ready = 1;
1961 static void vl_api_virtio_pci_delete_reply_t_handler_json
1962 (vl_api_virtio_pci_delete_reply_t * mp)
1964 vat_main_t *vam = &vat_main;
1965 vat_json_node_t node;
1967 vat_json_init_object (&node);
1968 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1970 vat_json_print (vam->ofp, &node);
1971 vat_json_free (&node);
1973 vam->retval = ntohl (mp->retval);
1974 vam->result_ready = 1;
1978 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1980 vat_main_t *vam = &vat_main;
1981 i32 retval = ntohl (mp->retval);
1983 if (vam->async_mode)
1985 vam->async_errors += (retval < 0);
1989 vam->retval = retval;
1990 vam->sw_if_index = ntohl (mp->sw_if_index);
1991 vam->result_ready = 1;
1995 static void vl_api_bond_create_reply_t_handler_json
1996 (vl_api_bond_create_reply_t * mp)
1998 vat_main_t *vam = &vat_main;
1999 vat_json_node_t node;
2001 vat_json_init_object (&node);
2002 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2003 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2005 vat_json_print (vam->ofp, &node);
2006 vat_json_free (&node);
2008 vam->retval = ntohl (mp->retval);
2009 vam->result_ready = 1;
2013 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
2015 vat_main_t *vam = &vat_main;
2016 i32 retval = ntohl (mp->retval);
2018 if (vam->async_mode)
2020 vam->async_errors += (retval < 0);
2024 vam->retval = retval;
2025 vam->result_ready = 1;
2029 static void vl_api_bond_delete_reply_t_handler_json
2030 (vl_api_bond_delete_reply_t * mp)
2032 vat_main_t *vam = &vat_main;
2033 vat_json_node_t node;
2035 vat_json_init_object (&node);
2036 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2038 vat_json_print (vam->ofp, &node);
2039 vat_json_free (&node);
2041 vam->retval = ntohl (mp->retval);
2042 vam->result_ready = 1;
2046 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
2048 vat_main_t *vam = &vat_main;
2049 i32 retval = ntohl (mp->retval);
2051 if (vam->async_mode)
2053 vam->async_errors += (retval < 0);
2057 vam->retval = retval;
2058 vam->result_ready = 1;
2062 static void vl_api_bond_enslave_reply_t_handler_json
2063 (vl_api_bond_enslave_reply_t * mp)
2065 vat_main_t *vam = &vat_main;
2066 vat_json_node_t node;
2068 vat_json_init_object (&node);
2069 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2071 vat_json_print (vam->ofp, &node);
2072 vat_json_free (&node);
2074 vam->retval = ntohl (mp->retval);
2075 vam->result_ready = 1;
2079 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
2082 vat_main_t *vam = &vat_main;
2083 i32 retval = ntohl (mp->retval);
2085 if (vam->async_mode)
2087 vam->async_errors += (retval < 0);
2091 vam->retval = retval;
2092 vam->result_ready = 1;
2096 static void vl_api_bond_detach_slave_reply_t_handler_json
2097 (vl_api_bond_detach_slave_reply_t * mp)
2099 vat_main_t *vam = &vat_main;
2100 vat_json_node_t node;
2102 vat_json_init_object (&node);
2103 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2105 vat_json_print (vam->ofp, &node);
2106 vat_json_free (&node);
2108 vam->retval = ntohl (mp->retval);
2109 vam->result_ready = 1;
2112 static void vl_api_sw_interface_bond_details_t_handler
2113 (vl_api_sw_interface_bond_details_t * mp)
2115 vat_main_t *vam = &vat_main;
2118 "%-16s %-12d %-12U %-13U %-14u %-14u",
2119 mp->interface_name, ntohl (mp->sw_if_index),
2120 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2121 ntohl (mp->active_slaves), ntohl (mp->slaves));
2124 static void vl_api_sw_interface_bond_details_t_handler_json
2125 (vl_api_sw_interface_bond_details_t * mp)
2127 vat_main_t *vam = &vat_main;
2128 vat_json_node_t *node = NULL;
2130 if (VAT_JSON_ARRAY != vam->json_tree.type)
2132 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2133 vat_json_init_array (&vam->json_tree);
2135 node = vat_json_array_add (&vam->json_tree);
2137 vat_json_init_object (node);
2138 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2139 vat_json_object_add_string_copy (node, "interface_name",
2140 mp->interface_name);
2141 vat_json_object_add_uint (node, "mode", mp->mode);
2142 vat_json_object_add_uint (node, "load_balance", mp->lb);
2143 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2144 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2148 api_sw_interface_bond_dump (vat_main_t * vam)
2150 vl_api_sw_interface_bond_dump_t *mp;
2151 vl_api_control_ping_t *mp_ping;
2155 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2156 "interface name", "sw_if_index", "mode", "load balance",
2157 "active slaves", "slaves");
2159 /* Get list of bond interfaces */
2160 M (SW_INTERFACE_BOND_DUMP, mp);
2163 /* Use a control ping for synchronization */
2164 MPING (CONTROL_PING, mp_ping);
2171 static void vl_api_sw_interface_slave_details_t_handler
2172 (vl_api_sw_interface_slave_details_t * mp)
2174 vat_main_t *vam = &vat_main;
2177 "%-25s %-12d %-12d %d", mp->interface_name,
2178 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2181 static void vl_api_sw_interface_slave_details_t_handler_json
2182 (vl_api_sw_interface_slave_details_t * mp)
2184 vat_main_t *vam = &vat_main;
2185 vat_json_node_t *node = NULL;
2187 if (VAT_JSON_ARRAY != vam->json_tree.type)
2189 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2190 vat_json_init_array (&vam->json_tree);
2192 node = vat_json_array_add (&vam->json_tree);
2194 vat_json_init_object (node);
2195 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2196 vat_json_object_add_string_copy (node, "interface_name",
2197 mp->interface_name);
2198 vat_json_object_add_uint (node, "passive", mp->is_passive);
2199 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2203 api_sw_interface_slave_dump (vat_main_t * vam)
2205 unformat_input_t *i = vam->input;
2206 vl_api_sw_interface_slave_dump_t *mp;
2207 vl_api_control_ping_t *mp_ping;
2208 u32 sw_if_index = ~0;
2209 u8 sw_if_index_set = 0;
2212 /* Parse args required to build the message */
2213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2215 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2216 sw_if_index_set = 1;
2217 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2218 sw_if_index_set = 1;
2223 if (sw_if_index_set == 0)
2225 errmsg ("missing vpp interface name. ");
2230 "\n%-25s %-12s %-12s %s",
2231 "slave interface name", "sw_if_index", "passive", "long_timeout");
2233 /* Get list of bond interfaces */
2234 M (SW_INTERFACE_SLAVE_DUMP, mp);
2235 mp->sw_if_index = ntohl (sw_if_index);
2238 /* Use a control ping for synchronization */
2239 MPING (CONTROL_PING, mp_ping);
2246 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2247 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2249 vat_main_t *vam = &vat_main;
2250 i32 retval = ntohl (mp->retval);
2251 if (vam->async_mode)
2253 vam->async_errors += (retval < 0);
2257 vam->retval = retval;
2258 vam->sw_if_index = ntohl (mp->sw_if_index);
2259 vam->result_ready = 1;
2261 vam->regenerate_interface_table = 1;
2264 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2265 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2267 vat_main_t *vam = &vat_main;
2268 vat_json_node_t node;
2270 vat_json_init_object (&node);
2271 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2272 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2273 ntohl (mp->sw_if_index));
2275 vat_json_print (vam->ofp, &node);
2276 vat_json_free (&node);
2278 vam->retval = ntohl (mp->retval);
2279 vam->result_ready = 1;
2282 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2283 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2285 vat_main_t *vam = &vat_main;
2286 i32 retval = ntohl (mp->retval);
2287 if (vam->async_mode)
2289 vam->async_errors += (retval < 0);
2293 vam->retval = retval;
2294 vam->sw_if_index = ntohl (mp->sw_if_index);
2295 vam->result_ready = 1;
2299 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2300 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2302 vat_main_t *vam = &vat_main;
2303 vat_json_node_t node;
2305 vat_json_init_object (&node);
2306 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2307 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2309 vat_json_print (vam->ofp, &node);
2310 vat_json_free (&node);
2312 vam->retval = ntohl (mp->retval);
2313 vam->result_ready = 1;
2316 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2317 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2319 vat_main_t *vam = &vat_main;
2320 i32 retval = ntohl (mp->retval);
2321 if (vam->async_mode)
2323 vam->async_errors += (retval < 0);
2327 vam->retval = retval;
2328 vam->result_ready = 1;
2332 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2333 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2335 vat_main_t *vam = &vat_main;
2336 vat_json_node_t node;
2338 vat_json_init_object (&node);
2339 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2340 vat_json_object_add_uint (&node, "fwd_entry_index",
2341 clib_net_to_host_u32 (mp->fwd_entry_index));
2343 vat_json_print (vam->ofp, &node);
2344 vat_json_free (&node);
2346 vam->retval = ntohl (mp->retval);
2347 vam->result_ready = 1;
2351 format_lisp_transport_protocol (u8 * s, va_list * args)
2353 u32 proto = va_arg (*args, u32);
2358 return format (s, "udp");
2360 return format (s, "api");
2367 static void vl_api_one_get_transport_protocol_reply_t_handler
2368 (vl_api_one_get_transport_protocol_reply_t * mp)
2370 vat_main_t *vam = &vat_main;
2371 i32 retval = ntohl (mp->retval);
2372 if (vam->async_mode)
2374 vam->async_errors += (retval < 0);
2378 u32 proto = mp->protocol;
2379 print (vam->ofp, "Transport protocol: %U",
2380 format_lisp_transport_protocol, proto);
2381 vam->retval = retval;
2382 vam->result_ready = 1;
2386 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2387 (vl_api_one_get_transport_protocol_reply_t * mp)
2389 vat_main_t *vam = &vat_main;
2390 vat_json_node_t node;
2393 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2396 vat_json_init_object (&node);
2397 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2398 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2401 vat_json_print (vam->ofp, &node);
2402 vat_json_free (&node);
2404 vam->retval = ntohl (mp->retval);
2405 vam->result_ready = 1;
2408 static void vl_api_one_add_del_locator_set_reply_t_handler
2409 (vl_api_one_add_del_locator_set_reply_t * mp)
2411 vat_main_t *vam = &vat_main;
2412 i32 retval = ntohl (mp->retval);
2413 if (vam->async_mode)
2415 vam->async_errors += (retval < 0);
2419 vam->retval = retval;
2420 vam->result_ready = 1;
2424 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2425 (vl_api_one_add_del_locator_set_reply_t * mp)
2427 vat_main_t *vam = &vat_main;
2428 vat_json_node_t node;
2430 vat_json_init_object (&node);
2431 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2432 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2434 vat_json_print (vam->ofp, &node);
2435 vat_json_free (&node);
2437 vam->retval = ntohl (mp->retval);
2438 vam->result_ready = 1;
2441 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2442 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2444 vat_main_t *vam = &vat_main;
2445 i32 retval = ntohl (mp->retval);
2446 if (vam->async_mode)
2448 vam->async_errors += (retval < 0);
2452 vam->retval = retval;
2453 vam->sw_if_index = ntohl (mp->sw_if_index);
2454 vam->result_ready = 1;
2456 vam->regenerate_interface_table = 1;
2459 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2460 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2462 vat_main_t *vam = &vat_main;
2463 vat_json_node_t node;
2465 vat_json_init_object (&node);
2466 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2467 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2469 vat_json_print (vam->ofp, &node);
2470 vat_json_free (&node);
2472 vam->retval = ntohl (mp->retval);
2473 vam->result_ready = 1;
2476 static void vl_api_vxlan_offload_rx_reply_t_handler
2477 (vl_api_vxlan_offload_rx_reply_t * mp)
2479 vat_main_t *vam = &vat_main;
2480 i32 retval = ntohl (mp->retval);
2481 if (vam->async_mode)
2483 vam->async_errors += (retval < 0);
2487 vam->retval = retval;
2488 vam->result_ready = 1;
2492 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2493 (vl_api_vxlan_offload_rx_reply_t * mp)
2495 vat_main_t *vam = &vat_main;
2496 vat_json_node_t node;
2498 vat_json_init_object (&node);
2499 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2501 vat_json_print (vam->ofp, &node);
2502 vat_json_free (&node);
2504 vam->retval = ntohl (mp->retval);
2505 vam->result_ready = 1;
2508 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2509 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2511 vat_main_t *vam = &vat_main;
2512 i32 retval = ntohl (mp->retval);
2513 if (vam->async_mode)
2515 vam->async_errors += (retval < 0);
2519 vam->retval = retval;
2520 vam->sw_if_index = ntohl (mp->sw_if_index);
2521 vam->result_ready = 1;
2525 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2526 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2528 vat_main_t *vam = &vat_main;
2529 vat_json_node_t node;
2531 vat_json_init_object (&node);
2532 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2533 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2535 vat_json_print (vam->ofp, &node);
2536 vat_json_free (&node);
2538 vam->retval = ntohl (mp->retval);
2539 vam->result_ready = 1;
2542 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2543 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2545 vat_main_t *vam = &vat_main;
2546 i32 retval = ntohl (mp->retval);
2547 if (vam->async_mode)
2549 vam->async_errors += (retval < 0);
2553 vam->retval = retval;
2554 vam->sw_if_index = ntohl (mp->sw_if_index);
2555 vam->result_ready = 1;
2557 vam->regenerate_interface_table = 1;
2560 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2561 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2563 vat_main_t *vam = &vat_main;
2564 vat_json_node_t node;
2566 vat_json_init_object (&node);
2567 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2568 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2570 vat_json_print (vam->ofp, &node);
2571 vat_json_free (&node);
2573 vam->retval = ntohl (mp->retval);
2574 vam->result_ready = 1;
2577 static void vl_api_gre_add_del_tunnel_reply_t_handler
2578 (vl_api_gre_add_del_tunnel_reply_t * mp)
2580 vat_main_t *vam = &vat_main;
2581 i32 retval = ntohl (mp->retval);
2582 if (vam->async_mode)
2584 vam->async_errors += (retval < 0);
2588 vam->retval = retval;
2589 vam->sw_if_index = ntohl (mp->sw_if_index);
2590 vam->result_ready = 1;
2594 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2595 (vl_api_gre_add_del_tunnel_reply_t * mp)
2597 vat_main_t *vam = &vat_main;
2598 vat_json_node_t node;
2600 vat_json_init_object (&node);
2601 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2602 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2604 vat_json_print (vam->ofp, &node);
2605 vat_json_free (&node);
2607 vam->retval = ntohl (mp->retval);
2608 vam->result_ready = 1;
2611 static void vl_api_create_vhost_user_if_reply_t_handler
2612 (vl_api_create_vhost_user_if_reply_t * mp)
2614 vat_main_t *vam = &vat_main;
2615 i32 retval = ntohl (mp->retval);
2616 if (vam->async_mode)
2618 vam->async_errors += (retval < 0);
2622 vam->retval = retval;
2623 vam->sw_if_index = ntohl (mp->sw_if_index);
2624 vam->result_ready = 1;
2626 vam->regenerate_interface_table = 1;
2629 static void vl_api_create_vhost_user_if_reply_t_handler_json
2630 (vl_api_create_vhost_user_if_reply_t * mp)
2632 vat_main_t *vam = &vat_main;
2633 vat_json_node_t node;
2635 vat_json_init_object (&node);
2636 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2637 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2639 vat_json_print (vam->ofp, &node);
2640 vat_json_free (&node);
2642 vam->retval = ntohl (mp->retval);
2643 vam->result_ready = 1;
2646 static void vl_api_dns_resolve_name_reply_t_handler
2647 (vl_api_dns_resolve_name_reply_t * mp)
2649 vat_main_t *vam = &vat_main;
2650 i32 retval = ntohl (mp->retval);
2651 if (vam->async_mode)
2653 vam->async_errors += (retval < 0);
2657 vam->retval = retval;
2658 vam->result_ready = 1;
2663 clib_warning ("ip4 address %U", format_ip4_address,
2664 (ip4_address_t *) mp->ip4_address);
2666 clib_warning ("ip6 address %U", format_ip6_address,
2667 (ip6_address_t *) mp->ip6_address);
2670 clib_warning ("retval %d", retval);
2674 static void vl_api_dns_resolve_name_reply_t_handler_json
2675 (vl_api_dns_resolve_name_reply_t * mp)
2677 clib_warning ("not implemented");
2680 static void vl_api_dns_resolve_ip_reply_t_handler
2681 (vl_api_dns_resolve_ip_reply_t * mp)
2683 vat_main_t *vam = &vat_main;
2684 i32 retval = ntohl (mp->retval);
2685 if (vam->async_mode)
2687 vam->async_errors += (retval < 0);
2691 vam->retval = retval;
2692 vam->result_ready = 1;
2696 clib_warning ("canonical name %s", mp->name);
2699 clib_warning ("retval %d", retval);
2703 static void vl_api_dns_resolve_ip_reply_t_handler_json
2704 (vl_api_dns_resolve_ip_reply_t * mp)
2706 clib_warning ("not implemented");
2710 static void vl_api_ip_address_details_t_handler
2711 (vl_api_ip_address_details_t * mp)
2713 vat_main_t *vam = &vat_main;
2714 static ip_address_details_t empty_ip_address_details = { {0} };
2715 ip_address_details_t *address = NULL;
2716 ip_details_t *current_ip_details = NULL;
2717 ip_details_t *details = NULL;
2719 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2721 if (!details || vam->current_sw_if_index >= vec_len (details)
2722 || !details[vam->current_sw_if_index].present)
2724 errmsg ("ip address details arrived but not stored");
2725 errmsg ("ip_dump should be called first");
2729 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2731 #define addresses (current_ip_details->addr)
2733 vec_validate_init_empty (addresses, vec_len (addresses),
2734 empty_ip_address_details);
2736 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2738 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2739 address->prefix_length = mp->prefix_length;
2743 static void vl_api_ip_address_details_t_handler_json
2744 (vl_api_ip_address_details_t * mp)
2746 vat_main_t *vam = &vat_main;
2747 vat_json_node_t *node = NULL;
2748 struct in6_addr ip6;
2751 if (VAT_JSON_ARRAY != vam->json_tree.type)
2753 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2754 vat_json_init_array (&vam->json_tree);
2756 node = vat_json_array_add (&vam->json_tree);
2758 vat_json_init_object (node);
2761 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2762 vat_json_object_add_ip6 (node, "ip", ip6);
2766 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2767 vat_json_object_add_ip4 (node, "ip", ip4);
2769 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2773 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2775 vat_main_t *vam = &vat_main;
2776 static ip_details_t empty_ip_details = { 0 };
2777 ip_details_t *ip = NULL;
2778 u32 sw_if_index = ~0;
2780 sw_if_index = ntohl (mp->sw_if_index);
2782 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2783 sw_if_index, empty_ip_details);
2785 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2792 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2794 vat_main_t *vam = &vat_main;
2796 if (VAT_JSON_ARRAY != vam->json_tree.type)
2798 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2799 vat_json_init_array (&vam->json_tree);
2801 vat_json_array_add_uint (&vam->json_tree,
2802 clib_net_to_host_u32 (mp->sw_if_index));
2806 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2808 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2809 "router_addr %U host_mac %U",
2810 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2812 format_ip4_address, &mp->lease.host_address,
2813 format_ip4_address, &mp->lease.router_address,
2814 format_ethernet_address, mp->lease.host_mac);
2817 static void vl_api_dhcp_compl_event_t_handler_json
2818 (vl_api_dhcp_compl_event_t * mp)
2820 /* JSON output not supported */
2823 static void vl_api_get_first_msg_id_reply_t_handler
2824 (vl_api_get_first_msg_id_reply_t * mp)
2826 vat_main_t *vam = &vat_main;
2827 i32 retval = ntohl (mp->retval);
2829 if (vam->async_mode)
2831 vam->async_errors += (retval < 0);
2835 vam->retval = retval;
2836 vam->result_ready = 1;
2840 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2844 static void vl_api_get_first_msg_id_reply_t_handler_json
2845 (vl_api_get_first_msg_id_reply_t * mp)
2847 vat_main_t *vam = &vat_main;
2848 vat_json_node_t node;
2850 vat_json_init_object (&node);
2851 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2852 vat_json_object_add_uint (&node, "first_msg_id",
2853 (uint) ntohs (mp->first_msg_id));
2855 vat_json_print (vam->ofp, &node);
2856 vat_json_free (&node);
2858 vam->retval = ntohl (mp->retval);
2859 vam->result_ready = 1;
2862 static void vl_api_get_node_graph_reply_t_handler
2863 (vl_api_get_node_graph_reply_t * mp)
2865 vat_main_t *vam = &vat_main;
2866 api_main_t *am = &api_main;
2867 i32 retval = ntohl (mp->retval);
2868 u8 *pvt_copy, *reply;
2873 if (vam->async_mode)
2875 vam->async_errors += (retval < 0);
2879 vam->retval = retval;
2880 vam->result_ready = 1;
2883 /* "Should never happen..." */
2887 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2888 pvt_copy = vec_dup (reply);
2890 /* Toss the shared-memory original... */
2891 pthread_mutex_lock (&am->vlib_rp->mutex);
2892 oldheap = svm_push_data_heap (am->vlib_rp);
2896 svm_pop_heap (oldheap);
2897 pthread_mutex_unlock (&am->vlib_rp->mutex);
2899 if (vam->graph_nodes)
2901 hash_free (vam->graph_node_index_by_name);
2903 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2905 node = vam->graph_nodes[0][i];
2906 vec_free (node->name);
2907 vec_free (node->next_nodes);
2910 vec_free (vam->graph_nodes[0]);
2911 vec_free (vam->graph_nodes);
2914 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2915 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2916 vec_free (pvt_copy);
2918 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2920 node = vam->graph_nodes[0][i];
2921 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2925 static void vl_api_get_node_graph_reply_t_handler_json
2926 (vl_api_get_node_graph_reply_t * mp)
2928 vat_main_t *vam = &vat_main;
2929 api_main_t *am = &api_main;
2931 vat_json_node_t node;
2934 /* $$$$ make this real? */
2935 vat_json_init_object (&node);
2936 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2937 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2939 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2941 /* Toss the shared-memory original... */
2942 pthread_mutex_lock (&am->vlib_rp->mutex);
2943 oldheap = svm_push_data_heap (am->vlib_rp);
2947 svm_pop_heap (oldheap);
2948 pthread_mutex_unlock (&am->vlib_rp->mutex);
2950 vat_json_print (vam->ofp, &node);
2951 vat_json_free (&node);
2953 vam->retval = ntohl (mp->retval);
2954 vam->result_ready = 1;
2958 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2960 vat_main_t *vam = &vat_main;
2965 s = format (s, "%=16d%=16d%=16d",
2966 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2970 s = format (s, "%=16U%=16d%=16d",
2971 mp->is_ipv6 ? format_ip6_address :
2973 mp->ip_address, mp->priority, mp->weight);
2976 print (vam->ofp, "%v", s);
2981 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2983 vat_main_t *vam = &vat_main;
2984 vat_json_node_t *node = NULL;
2985 struct in6_addr ip6;
2988 if (VAT_JSON_ARRAY != vam->json_tree.type)
2990 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2991 vat_json_init_array (&vam->json_tree);
2993 node = vat_json_array_add (&vam->json_tree);
2994 vat_json_init_object (node);
2996 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2997 vat_json_object_add_uint (node, "priority", mp->priority);
2998 vat_json_object_add_uint (node, "weight", mp->weight);
3001 vat_json_object_add_uint (node, "sw_if_index",
3002 clib_net_to_host_u32 (mp->sw_if_index));
3007 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3008 vat_json_object_add_ip6 (node, "address", ip6);
3012 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3013 vat_json_object_add_ip4 (node, "address", ip4);
3019 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3022 vat_main_t *vam = &vat_main;
3025 ls_name = format (0, "%s", mp->ls_name);
3027 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3033 vl_api_one_locator_set_details_t_handler_json
3034 (vl_api_one_locator_set_details_t * mp)
3036 vat_main_t *vam = &vat_main;
3037 vat_json_node_t *node = 0;
3040 ls_name = format (0, "%s", mp->ls_name);
3041 vec_add1 (ls_name, 0);
3043 if (VAT_JSON_ARRAY != vam->json_tree.type)
3045 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3046 vat_json_init_array (&vam->json_tree);
3048 node = vat_json_array_add (&vam->json_tree);
3050 vat_json_init_object (node);
3051 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3052 vat_json_object_add_uint (node, "ls_index",
3053 clib_net_to_host_u32 (mp->ls_index));
3061 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3064 unformat_nsh_address (unformat_input_t * input, va_list * args)
3066 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3067 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3071 format_nsh_address_vat (u8 * s, va_list * args)
3073 nsh_t *a = va_arg (*args, nsh_t *);
3074 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3078 format_lisp_flat_eid (u8 * s, va_list * args)
3080 u32 type = va_arg (*args, u32);
3081 u8 *eid = va_arg (*args, u8 *);
3082 u32 eid_len = va_arg (*args, u32);
3087 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3089 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3091 return format (s, "%U", format_ethernet_address, eid);
3093 return format (s, "%U", format_nsh_address_vat, eid);
3099 format_lisp_eid_vat (u8 * s, va_list * args)
3101 u32 type = va_arg (*args, u32);
3102 u8 *eid = va_arg (*args, u8 *);
3103 u32 eid_len = va_arg (*args, u32);
3104 u8 *seid = va_arg (*args, u8 *);
3105 u32 seid_len = va_arg (*args, u32);
3106 u32 is_src_dst = va_arg (*args, u32);
3109 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3111 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3117 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3119 vat_main_t *vam = &vat_main;
3120 u8 *s = 0, *eid = 0;
3122 if (~0 == mp->locator_set_index)
3123 s = format (0, "action: %d", mp->action);
3125 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3127 eid = format (0, "%U", format_lisp_eid_vat,
3131 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3134 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3135 clib_net_to_host_u32 (mp->vni),
3137 mp->is_local ? "local" : "remote",
3138 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3139 clib_net_to_host_u16 (mp->key_id), mp->key);
3146 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3149 vat_main_t *vam = &vat_main;
3150 vat_json_node_t *node = 0;
3153 if (VAT_JSON_ARRAY != vam->json_tree.type)
3155 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3156 vat_json_init_array (&vam->json_tree);
3158 node = vat_json_array_add (&vam->json_tree);
3160 vat_json_init_object (node);
3161 if (~0 == mp->locator_set_index)
3162 vat_json_object_add_uint (node, "action", mp->action);
3164 vat_json_object_add_uint (node, "locator_set_index",
3165 clib_net_to_host_u32 (mp->locator_set_index));
3167 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3168 if (mp->eid_type == 3)
3170 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3171 vat_json_init_object (nsh_json);
3172 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3173 vat_json_object_add_uint (nsh_json, "spi",
3174 clib_net_to_host_u32 (nsh->spi));
3175 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3179 eid = format (0, "%U", format_lisp_eid_vat,
3183 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3185 vat_json_object_add_string_copy (node, "eid", eid);
3188 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3189 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3190 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3194 vat_json_object_add_uint (node, "key_id",
3195 clib_net_to_host_u16 (mp->key_id));
3196 vat_json_object_add_string_copy (node, "key", mp->key);
3201 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3203 vat_main_t *vam = &vat_main;
3204 u8 *seid = 0, *deid = 0;
3205 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3207 deid = format (0, "%U", format_lisp_eid_vat,
3208 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3210 seid = format (0, "%U", format_lisp_eid_vat,
3211 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3217 format_ip_address_fcn = format_ip4_address;
3219 format_ip_address_fcn = format_ip6_address;
3222 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3223 clib_net_to_host_u32 (mp->vni),
3225 format_ip_address_fcn, mp->lloc,
3226 format_ip_address_fcn, mp->rloc,
3227 clib_net_to_host_u32 (mp->pkt_count),
3228 clib_net_to_host_u32 (mp->bytes));
3235 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3237 struct in6_addr ip6;
3239 vat_main_t *vam = &vat_main;
3240 vat_json_node_t *node = 0;
3241 u8 *deid = 0, *seid = 0;
3243 if (VAT_JSON_ARRAY != vam->json_tree.type)
3245 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3246 vat_json_init_array (&vam->json_tree);
3248 node = vat_json_array_add (&vam->json_tree);
3250 vat_json_init_object (node);
3251 deid = format (0, "%U", format_lisp_eid_vat,
3252 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3254 seid = format (0, "%U", format_lisp_eid_vat,
3255 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3260 vat_json_object_add_string_copy (node, "seid", seid);
3261 vat_json_object_add_string_copy (node, "deid", deid);
3262 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3266 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3267 vat_json_object_add_ip4 (node, "lloc", ip4);
3268 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3269 vat_json_object_add_ip4 (node, "rloc", ip4);
3273 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3274 vat_json_object_add_ip6 (node, "lloc", ip6);
3275 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3276 vat_json_object_add_ip6 (node, "rloc", ip6);
3278 vat_json_object_add_uint (node, "pkt_count",
3279 clib_net_to_host_u32 (mp->pkt_count));
3280 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3287 vl_api_one_eid_table_map_details_t_handler
3288 (vl_api_one_eid_table_map_details_t * mp)
3290 vat_main_t *vam = &vat_main;
3292 u8 *line = format (0, "%=10d%=10d",
3293 clib_net_to_host_u32 (mp->vni),
3294 clib_net_to_host_u32 (mp->dp_table));
3295 print (vam->ofp, "%v", line);
3300 vl_api_one_eid_table_map_details_t_handler_json
3301 (vl_api_one_eid_table_map_details_t * mp)
3303 vat_main_t *vam = &vat_main;
3304 vat_json_node_t *node = NULL;
3306 if (VAT_JSON_ARRAY != vam->json_tree.type)
3308 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3309 vat_json_init_array (&vam->json_tree);
3311 node = vat_json_array_add (&vam->json_tree);
3312 vat_json_init_object (node);
3313 vat_json_object_add_uint (node, "dp_table",
3314 clib_net_to_host_u32 (mp->dp_table));
3315 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3319 vl_api_one_eid_table_vni_details_t_handler
3320 (vl_api_one_eid_table_vni_details_t * mp)
3322 vat_main_t *vam = &vat_main;
3324 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3325 print (vam->ofp, "%v", line);
3330 vl_api_one_eid_table_vni_details_t_handler_json
3331 (vl_api_one_eid_table_vni_details_t * mp)
3333 vat_main_t *vam = &vat_main;
3334 vat_json_node_t *node = NULL;
3336 if (VAT_JSON_ARRAY != vam->json_tree.type)
3338 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3339 vat_json_init_array (&vam->json_tree);
3341 node = vat_json_array_add (&vam->json_tree);
3342 vat_json_init_object (node);
3343 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3347 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3348 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3350 vat_main_t *vam = &vat_main;
3351 int retval = clib_net_to_host_u32 (mp->retval);
3353 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3354 print (vam->ofp, "fallback threshold value: %d", mp->value);
3356 vam->retval = retval;
3357 vam->result_ready = 1;
3361 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3362 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3364 vat_main_t *vam = &vat_main;
3365 vat_json_node_t _node, *node = &_node;
3366 int retval = clib_net_to_host_u32 (mp->retval);
3368 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3369 vat_json_init_object (node);
3370 vat_json_object_add_uint (node, "value", mp->value);
3372 vat_json_print (vam->ofp, node);
3373 vat_json_free (node);
3375 vam->retval = retval;
3376 vam->result_ready = 1;
3380 vl_api_show_one_map_register_state_reply_t_handler
3381 (vl_api_show_one_map_register_state_reply_t * mp)
3383 vat_main_t *vam = &vat_main;
3384 int retval = clib_net_to_host_u32 (mp->retval);
3386 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3388 vam->retval = retval;
3389 vam->result_ready = 1;
3393 vl_api_show_one_map_register_state_reply_t_handler_json
3394 (vl_api_show_one_map_register_state_reply_t * mp)
3396 vat_main_t *vam = &vat_main;
3397 vat_json_node_t _node, *node = &_node;
3398 int retval = clib_net_to_host_u32 (mp->retval);
3400 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3402 vat_json_init_object (node);
3403 vat_json_object_add_string_copy (node, "state", s);
3405 vat_json_print (vam->ofp, node);
3406 vat_json_free (node);
3408 vam->retval = retval;
3409 vam->result_ready = 1;
3414 vl_api_show_one_rloc_probe_state_reply_t_handler
3415 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3417 vat_main_t *vam = &vat_main;
3418 int retval = clib_net_to_host_u32 (mp->retval);
3423 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3425 vam->retval = retval;
3426 vam->result_ready = 1;
3430 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3431 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3433 vat_main_t *vam = &vat_main;
3434 vat_json_node_t _node, *node = &_node;
3435 int retval = clib_net_to_host_u32 (mp->retval);
3437 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3438 vat_json_init_object (node);
3439 vat_json_object_add_string_copy (node, "state", s);
3441 vat_json_print (vam->ofp, node);
3442 vat_json_free (node);
3444 vam->retval = retval;
3445 vam->result_ready = 1;
3450 vl_api_show_one_stats_enable_disable_reply_t_handler
3451 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3453 vat_main_t *vam = &vat_main;
3454 int retval = clib_net_to_host_u32 (mp->retval);
3459 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3461 vam->retval = retval;
3462 vam->result_ready = 1;
3466 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3467 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3469 vat_main_t *vam = &vat_main;
3470 vat_json_node_t _node, *node = &_node;
3471 int retval = clib_net_to_host_u32 (mp->retval);
3473 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3474 vat_json_init_object (node);
3475 vat_json_object_add_string_copy (node, "state", s);
3477 vat_json_print (vam->ofp, node);
3478 vat_json_free (node);
3480 vam->retval = retval;
3481 vam->result_ready = 1;
3486 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3488 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3489 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3490 e->vni = clib_net_to_host_u32 (e->vni);
3494 gpe_fwd_entries_get_reply_t_net_to_host
3495 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3499 mp->count = clib_net_to_host_u32 (mp->count);
3500 for (i = 0; i < mp->count; i++)
3502 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3507 format_gpe_encap_mode (u8 * s, va_list * args)
3509 u32 mode = va_arg (*args, u32);
3514 return format (s, "lisp");
3516 return format (s, "vxlan");
3522 vl_api_gpe_get_encap_mode_reply_t_handler
3523 (vl_api_gpe_get_encap_mode_reply_t * mp)
3525 vat_main_t *vam = &vat_main;
3527 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3528 vam->retval = ntohl (mp->retval);
3529 vam->result_ready = 1;
3533 vl_api_gpe_get_encap_mode_reply_t_handler_json
3534 (vl_api_gpe_get_encap_mode_reply_t * mp)
3536 vat_main_t *vam = &vat_main;
3537 vat_json_node_t node;
3539 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3540 vec_add1 (encap_mode, 0);
3542 vat_json_init_object (&node);
3543 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3545 vec_free (encap_mode);
3546 vat_json_print (vam->ofp, &node);
3547 vat_json_free (&node);
3549 vam->retval = ntohl (mp->retval);
3550 vam->result_ready = 1;
3554 vl_api_gpe_fwd_entry_path_details_t_handler
3555 (vl_api_gpe_fwd_entry_path_details_t * mp)
3557 vat_main_t *vam = &vat_main;
3558 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3560 if (mp->lcl_loc.is_ip4)
3561 format_ip_address_fcn = format_ip4_address;
3563 format_ip_address_fcn = format_ip6_address;
3565 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3566 format_ip_address_fcn, &mp->lcl_loc,
3567 format_ip_address_fcn, &mp->rmt_loc);
3571 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3573 struct in6_addr ip6;
3578 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3579 vat_json_object_add_ip4 (n, "address", ip4);
3583 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3584 vat_json_object_add_ip6 (n, "address", ip6);
3586 vat_json_object_add_uint (n, "weight", loc->weight);
3590 vl_api_gpe_fwd_entry_path_details_t_handler_json
3591 (vl_api_gpe_fwd_entry_path_details_t * mp)
3593 vat_main_t *vam = &vat_main;
3594 vat_json_node_t *node = NULL;
3595 vat_json_node_t *loc_node;
3597 if (VAT_JSON_ARRAY != vam->json_tree.type)
3599 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3600 vat_json_init_array (&vam->json_tree);
3602 node = vat_json_array_add (&vam->json_tree);
3603 vat_json_init_object (node);
3605 loc_node = vat_json_object_add (node, "local_locator");
3606 vat_json_init_object (loc_node);
3607 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3609 loc_node = vat_json_object_add (node, "remote_locator");
3610 vat_json_init_object (loc_node);
3611 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3615 vl_api_gpe_fwd_entries_get_reply_t_handler
3616 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3618 vat_main_t *vam = &vat_main;
3620 int retval = clib_net_to_host_u32 (mp->retval);
3621 vl_api_gpe_fwd_entry_t *e;
3626 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3628 for (i = 0; i < mp->count; i++)
3630 e = &mp->entries[i];
3631 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3632 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3633 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3637 vam->retval = retval;
3638 vam->result_ready = 1;
3642 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3643 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3646 vat_main_t *vam = &vat_main;
3647 vat_json_node_t *e = 0, root;
3649 int retval = clib_net_to_host_u32 (mp->retval);
3650 vl_api_gpe_fwd_entry_t *fwd;
3655 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3656 vat_json_init_array (&root);
3658 for (i = 0; i < mp->count; i++)
3660 e = vat_json_array_add (&root);
3661 fwd = &mp->entries[i];
3663 vat_json_init_object (e);
3664 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3665 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3666 vat_json_object_add_int (e, "vni", fwd->vni);
3667 vat_json_object_add_int (e, "action", fwd->action);
3669 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3670 fwd->leid_prefix_len);
3672 vat_json_object_add_string_copy (e, "leid", s);
3675 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3676 fwd->reid_prefix_len);
3678 vat_json_object_add_string_copy (e, "reid", s);
3682 vat_json_print (vam->ofp, &root);
3683 vat_json_free (&root);
3686 vam->retval = retval;
3687 vam->result_ready = 1;
3691 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3692 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3694 vat_main_t *vam = &vat_main;
3696 int retval = clib_net_to_host_u32 (mp->retval);
3697 vl_api_gpe_native_fwd_rpath_t *r;
3702 n = clib_net_to_host_u32 (mp->count);
3704 for (i = 0; i < n; i++)
3706 r = &mp->entries[i];
3707 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3708 clib_net_to_host_u32 (r->fib_index),
3709 clib_net_to_host_u32 (r->nh_sw_if_index),
3710 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3714 vam->retval = retval;
3715 vam->result_ready = 1;
3719 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3720 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3722 vat_main_t *vam = &vat_main;
3723 vat_json_node_t root, *e;
3725 int retval = clib_net_to_host_u32 (mp->retval);
3726 vl_api_gpe_native_fwd_rpath_t *r;
3732 n = clib_net_to_host_u32 (mp->count);
3733 vat_json_init_array (&root);
3735 for (i = 0; i < n; i++)
3737 e = vat_json_array_add (&root);
3738 vat_json_init_object (e);
3739 r = &mp->entries[i];
3741 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3744 vat_json_object_add_string_copy (e, "ip4", s);
3747 vat_json_object_add_uint (e, "fib_index",
3748 clib_net_to_host_u32 (r->fib_index));
3749 vat_json_object_add_uint (e, "nh_sw_if_index",
3750 clib_net_to_host_u32 (r->nh_sw_if_index));
3753 vat_json_print (vam->ofp, &root);
3754 vat_json_free (&root);
3757 vam->retval = retval;
3758 vam->result_ready = 1;
3762 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3763 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3765 vat_main_t *vam = &vat_main;
3767 int retval = clib_net_to_host_u32 (mp->retval);
3772 n = clib_net_to_host_u32 (mp->count);
3774 for (i = 0; i < n; i++)
3775 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3778 vam->retval = retval;
3779 vam->result_ready = 1;
3783 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3784 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3786 vat_main_t *vam = &vat_main;
3787 vat_json_node_t root;
3789 int retval = clib_net_to_host_u32 (mp->retval);
3794 n = clib_net_to_host_u32 (mp->count);
3795 vat_json_init_array (&root);
3797 for (i = 0; i < n; i++)
3798 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3800 vat_json_print (vam->ofp, &root);
3801 vat_json_free (&root);
3804 vam->retval = retval;
3805 vam->result_ready = 1;
3809 vl_api_one_ndp_entries_get_reply_t_handler
3810 (vl_api_one_ndp_entries_get_reply_t * mp)
3812 vat_main_t *vam = &vat_main;
3814 int retval = clib_net_to_host_u32 (mp->retval);
3819 n = clib_net_to_host_u32 (mp->count);
3821 for (i = 0; i < n; i++)
3822 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3823 format_ethernet_address, mp->entries[i].mac);
3826 vam->retval = retval;
3827 vam->result_ready = 1;
3831 vl_api_one_ndp_entries_get_reply_t_handler_json
3832 (vl_api_one_ndp_entries_get_reply_t * mp)
3835 vat_main_t *vam = &vat_main;
3836 vat_json_node_t *e = 0, root;
3838 int retval = clib_net_to_host_u32 (mp->retval);
3839 vl_api_one_ndp_entry_t *arp_entry;
3844 n = clib_net_to_host_u32 (mp->count);
3845 vat_json_init_array (&root);
3847 for (i = 0; i < n; i++)
3849 e = vat_json_array_add (&root);
3850 arp_entry = &mp->entries[i];
3852 vat_json_init_object (e);
3853 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3856 vat_json_object_add_string_copy (e, "mac", s);
3859 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3861 vat_json_object_add_string_copy (e, "ip6", s);
3865 vat_json_print (vam->ofp, &root);
3866 vat_json_free (&root);
3869 vam->retval = retval;
3870 vam->result_ready = 1;
3874 vl_api_one_l2_arp_entries_get_reply_t_handler
3875 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3877 vat_main_t *vam = &vat_main;
3879 int retval = clib_net_to_host_u32 (mp->retval);
3884 n = clib_net_to_host_u32 (mp->count);
3886 for (i = 0; i < n; i++)
3887 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3888 format_ethernet_address, mp->entries[i].mac);
3891 vam->retval = retval;
3892 vam->result_ready = 1;
3896 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3897 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3900 vat_main_t *vam = &vat_main;
3901 vat_json_node_t *e = 0, root;
3903 int retval = clib_net_to_host_u32 (mp->retval);
3904 vl_api_one_l2_arp_entry_t *arp_entry;
3909 n = clib_net_to_host_u32 (mp->count);
3910 vat_json_init_array (&root);
3912 for (i = 0; i < n; i++)
3914 e = vat_json_array_add (&root);
3915 arp_entry = &mp->entries[i];
3917 vat_json_init_object (e);
3918 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3921 vat_json_object_add_string_copy (e, "mac", s);
3924 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3926 vat_json_object_add_string_copy (e, "ip4", s);
3930 vat_json_print (vam->ofp, &root);
3931 vat_json_free (&root);
3934 vam->retval = retval;
3935 vam->result_ready = 1;
3939 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3941 vat_main_t *vam = &vat_main;
3943 int retval = clib_net_to_host_u32 (mp->retval);
3948 n = clib_net_to_host_u32 (mp->count);
3950 for (i = 0; i < n; i++)
3952 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3956 vam->retval = retval;
3957 vam->result_ready = 1;
3961 vl_api_one_ndp_bd_get_reply_t_handler_json
3962 (vl_api_one_ndp_bd_get_reply_t * mp)
3964 vat_main_t *vam = &vat_main;
3965 vat_json_node_t root;
3967 int retval = clib_net_to_host_u32 (mp->retval);
3972 n = clib_net_to_host_u32 (mp->count);
3973 vat_json_init_array (&root);
3975 for (i = 0; i < n; i++)
3977 vat_json_array_add_uint (&root,
3978 clib_net_to_host_u32 (mp->bridge_domains[i]));
3981 vat_json_print (vam->ofp, &root);
3982 vat_json_free (&root);
3985 vam->retval = retval;
3986 vam->result_ready = 1;
3990 vl_api_one_l2_arp_bd_get_reply_t_handler
3991 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3993 vat_main_t *vam = &vat_main;
3995 int retval = clib_net_to_host_u32 (mp->retval);
4000 n = clib_net_to_host_u32 (mp->count);
4002 for (i = 0; i < n; i++)
4004 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4008 vam->retval = retval;
4009 vam->result_ready = 1;
4013 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4014 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4016 vat_main_t *vam = &vat_main;
4017 vat_json_node_t root;
4019 int retval = clib_net_to_host_u32 (mp->retval);
4024 n = clib_net_to_host_u32 (mp->count);
4025 vat_json_init_array (&root);
4027 for (i = 0; i < n; i++)
4029 vat_json_array_add_uint (&root,
4030 clib_net_to_host_u32 (mp->bridge_domains[i]));
4033 vat_json_print (vam->ofp, &root);
4034 vat_json_free (&root);
4037 vam->retval = retval;
4038 vam->result_ready = 1;
4042 vl_api_one_adjacencies_get_reply_t_handler
4043 (vl_api_one_adjacencies_get_reply_t * mp)
4045 vat_main_t *vam = &vat_main;
4047 int retval = clib_net_to_host_u32 (mp->retval);
4048 vl_api_one_adjacency_t *a;
4053 n = clib_net_to_host_u32 (mp->count);
4055 for (i = 0; i < n; i++)
4057 a = &mp->adjacencies[i];
4058 print (vam->ofp, "%U %40U",
4059 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4060 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4064 vam->retval = retval;
4065 vam->result_ready = 1;
4069 vl_api_one_adjacencies_get_reply_t_handler_json
4070 (vl_api_one_adjacencies_get_reply_t * mp)
4073 vat_main_t *vam = &vat_main;
4074 vat_json_node_t *e = 0, root;
4076 int retval = clib_net_to_host_u32 (mp->retval);
4077 vl_api_one_adjacency_t *a;
4082 n = clib_net_to_host_u32 (mp->count);
4083 vat_json_init_array (&root);
4085 for (i = 0; i < n; i++)
4087 e = vat_json_array_add (&root);
4088 a = &mp->adjacencies[i];
4090 vat_json_init_object (e);
4091 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4092 a->leid_prefix_len);
4094 vat_json_object_add_string_copy (e, "leid", s);
4097 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4098 a->reid_prefix_len);
4100 vat_json_object_add_string_copy (e, "reid", s);
4104 vat_json_print (vam->ofp, &root);
4105 vat_json_free (&root);
4108 vam->retval = retval;
4109 vam->result_ready = 1;
4113 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4115 vat_main_t *vam = &vat_main;
4117 print (vam->ofp, "%=20U",
4118 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4123 vl_api_one_map_server_details_t_handler_json
4124 (vl_api_one_map_server_details_t * mp)
4126 vat_main_t *vam = &vat_main;
4127 vat_json_node_t *node = NULL;
4128 struct in6_addr ip6;
4131 if (VAT_JSON_ARRAY != vam->json_tree.type)
4133 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4134 vat_json_init_array (&vam->json_tree);
4136 node = vat_json_array_add (&vam->json_tree);
4138 vat_json_init_object (node);
4141 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4142 vat_json_object_add_ip6 (node, "map-server", ip6);
4146 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4147 vat_json_object_add_ip4 (node, "map-server", ip4);
4152 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4155 vat_main_t *vam = &vat_main;
4157 print (vam->ofp, "%=20U",
4158 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4163 vl_api_one_map_resolver_details_t_handler_json
4164 (vl_api_one_map_resolver_details_t * mp)
4166 vat_main_t *vam = &vat_main;
4167 vat_json_node_t *node = NULL;
4168 struct in6_addr ip6;
4171 if (VAT_JSON_ARRAY != vam->json_tree.type)
4173 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4174 vat_json_init_array (&vam->json_tree);
4176 node = vat_json_array_add (&vam->json_tree);
4178 vat_json_init_object (node);
4181 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4182 vat_json_object_add_ip6 (node, "map resolver", ip6);
4186 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4187 vat_json_object_add_ip4 (node, "map resolver", ip4);
4192 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4194 vat_main_t *vam = &vat_main;
4195 i32 retval = ntohl (mp->retval);
4199 print (vam->ofp, "feature: %s\ngpe: %s",
4200 mp->feature_status ? "enabled" : "disabled",
4201 mp->gpe_status ? "enabled" : "disabled");
4204 vam->retval = retval;
4205 vam->result_ready = 1;
4209 vl_api_show_one_status_reply_t_handler_json
4210 (vl_api_show_one_status_reply_t * mp)
4212 vat_main_t *vam = &vat_main;
4213 vat_json_node_t node;
4214 u8 *gpe_status = NULL;
4215 u8 *feature_status = NULL;
4217 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4218 feature_status = format (0, "%s",
4219 mp->feature_status ? "enabled" : "disabled");
4220 vec_add1 (gpe_status, 0);
4221 vec_add1 (feature_status, 0);
4223 vat_json_init_object (&node);
4224 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4225 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4227 vec_free (gpe_status);
4228 vec_free (feature_status);
4230 vat_json_print (vam->ofp, &node);
4231 vat_json_free (&node);
4233 vam->retval = ntohl (mp->retval);
4234 vam->result_ready = 1;
4238 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4239 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4241 vat_main_t *vam = &vat_main;
4242 i32 retval = ntohl (mp->retval);
4246 print (vam->ofp, "%=20s", mp->locator_set_name);
4249 vam->retval = retval;
4250 vam->result_ready = 1;
4254 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4255 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4257 vat_main_t *vam = &vat_main;
4258 vat_json_node_t *node = NULL;
4260 if (VAT_JSON_ARRAY != vam->json_tree.type)
4262 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4263 vat_json_init_array (&vam->json_tree);
4265 node = vat_json_array_add (&vam->json_tree);
4267 vat_json_init_object (node);
4268 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4270 vat_json_print (vam->ofp, node);
4271 vat_json_free (node);
4273 vam->retval = ntohl (mp->retval);
4274 vam->result_ready = 1;
4278 format_lisp_map_request_mode (u8 * s, va_list * args)
4280 u32 mode = va_arg (*args, u32);
4285 return format (0, "dst-only");
4287 return format (0, "src-dst");
4293 vl_api_show_one_map_request_mode_reply_t_handler
4294 (vl_api_show_one_map_request_mode_reply_t * mp)
4296 vat_main_t *vam = &vat_main;
4297 i32 retval = ntohl (mp->retval);
4301 u32 mode = mp->mode;
4302 print (vam->ofp, "map_request_mode: %U",
4303 format_lisp_map_request_mode, mode);
4306 vam->retval = retval;
4307 vam->result_ready = 1;
4311 vl_api_show_one_map_request_mode_reply_t_handler_json
4312 (vl_api_show_one_map_request_mode_reply_t * mp)
4314 vat_main_t *vam = &vat_main;
4315 vat_json_node_t node;
4320 s = format (0, "%U", format_lisp_map_request_mode, mode);
4323 vat_json_init_object (&node);
4324 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4325 vat_json_print (vam->ofp, &node);
4326 vat_json_free (&node);
4329 vam->retval = ntohl (mp->retval);
4330 vam->result_ready = 1;
4334 vl_api_one_show_xtr_mode_reply_t_handler
4335 (vl_api_one_show_xtr_mode_reply_t * mp)
4337 vat_main_t *vam = &vat_main;
4338 i32 retval = ntohl (mp->retval);
4342 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4345 vam->retval = retval;
4346 vam->result_ready = 1;
4350 vl_api_one_show_xtr_mode_reply_t_handler_json
4351 (vl_api_one_show_xtr_mode_reply_t * mp)
4353 vat_main_t *vam = &vat_main;
4354 vat_json_node_t node;
4357 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4358 vec_add1 (status, 0);
4360 vat_json_init_object (&node);
4361 vat_json_object_add_string_copy (&node, "status", status);
4365 vat_json_print (vam->ofp, &node);
4366 vat_json_free (&node);
4368 vam->retval = ntohl (mp->retval);
4369 vam->result_ready = 1;
4373 vl_api_one_show_pitr_mode_reply_t_handler
4374 (vl_api_one_show_pitr_mode_reply_t * mp)
4376 vat_main_t *vam = &vat_main;
4377 i32 retval = ntohl (mp->retval);
4381 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4384 vam->retval = retval;
4385 vam->result_ready = 1;
4389 vl_api_one_show_pitr_mode_reply_t_handler_json
4390 (vl_api_one_show_pitr_mode_reply_t * mp)
4392 vat_main_t *vam = &vat_main;
4393 vat_json_node_t node;
4396 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4397 vec_add1 (status, 0);
4399 vat_json_init_object (&node);
4400 vat_json_object_add_string_copy (&node, "status", status);
4404 vat_json_print (vam->ofp, &node);
4405 vat_json_free (&node);
4407 vam->retval = ntohl (mp->retval);
4408 vam->result_ready = 1;
4412 vl_api_one_show_petr_mode_reply_t_handler
4413 (vl_api_one_show_petr_mode_reply_t * mp)
4415 vat_main_t *vam = &vat_main;
4416 i32 retval = ntohl (mp->retval);
4420 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4423 vam->retval = retval;
4424 vam->result_ready = 1;
4428 vl_api_one_show_petr_mode_reply_t_handler_json
4429 (vl_api_one_show_petr_mode_reply_t * mp)
4431 vat_main_t *vam = &vat_main;
4432 vat_json_node_t node;
4435 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4436 vec_add1 (status, 0);
4438 vat_json_init_object (&node);
4439 vat_json_object_add_string_copy (&node, "status", status);
4443 vat_json_print (vam->ofp, &node);
4444 vat_json_free (&node);
4446 vam->retval = ntohl (mp->retval);
4447 vam->result_ready = 1;
4451 vl_api_show_one_use_petr_reply_t_handler
4452 (vl_api_show_one_use_petr_reply_t * mp)
4454 vat_main_t *vam = &vat_main;
4455 i32 retval = ntohl (mp->retval);
4459 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4462 print (vam->ofp, "Proxy-ETR address; %U",
4463 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4468 vam->retval = retval;
4469 vam->result_ready = 1;
4473 vl_api_show_one_use_petr_reply_t_handler_json
4474 (vl_api_show_one_use_petr_reply_t * mp)
4476 vat_main_t *vam = &vat_main;
4477 vat_json_node_t node;
4480 struct in6_addr ip6;
4482 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4483 vec_add1 (status, 0);
4485 vat_json_init_object (&node);
4486 vat_json_object_add_string_copy (&node, "status", status);
4491 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4492 vat_json_object_add_ip6 (&node, "address", ip6);
4496 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4497 vat_json_object_add_ip4 (&node, "address", ip4);
4503 vat_json_print (vam->ofp, &node);
4504 vat_json_free (&node);
4506 vam->retval = ntohl (mp->retval);
4507 vam->result_ready = 1;
4511 vl_api_show_one_nsh_mapping_reply_t_handler
4512 (vl_api_show_one_nsh_mapping_reply_t * mp)
4514 vat_main_t *vam = &vat_main;
4515 i32 retval = ntohl (mp->retval);
4519 print (vam->ofp, "%-20s%-16s",
4520 mp->is_set ? "set" : "not-set",
4521 mp->is_set ? (char *) mp->locator_set_name : "");
4524 vam->retval = retval;
4525 vam->result_ready = 1;
4529 vl_api_show_one_nsh_mapping_reply_t_handler_json
4530 (vl_api_show_one_nsh_mapping_reply_t * mp)
4532 vat_main_t *vam = &vat_main;
4533 vat_json_node_t node;
4536 status = format (0, "%s", mp->is_set ? "yes" : "no");
4537 vec_add1 (status, 0);
4539 vat_json_init_object (&node);
4540 vat_json_object_add_string_copy (&node, "is_set", status);
4543 vat_json_object_add_string_copy (&node, "locator_set",
4544 mp->locator_set_name);
4549 vat_json_print (vam->ofp, &node);
4550 vat_json_free (&node);
4552 vam->retval = ntohl (mp->retval);
4553 vam->result_ready = 1;
4557 vl_api_show_one_map_register_ttl_reply_t_handler
4558 (vl_api_show_one_map_register_ttl_reply_t * mp)
4560 vat_main_t *vam = &vat_main;
4561 i32 retval = ntohl (mp->retval);
4563 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4567 print (vam->ofp, "ttl: %u", mp->ttl);
4570 vam->retval = retval;
4571 vam->result_ready = 1;
4575 vl_api_show_one_map_register_ttl_reply_t_handler_json
4576 (vl_api_show_one_map_register_ttl_reply_t * mp)
4578 vat_main_t *vam = &vat_main;
4579 vat_json_node_t node;
4581 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4582 vat_json_init_object (&node);
4583 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4585 vat_json_print (vam->ofp, &node);
4586 vat_json_free (&node);
4588 vam->retval = ntohl (mp->retval);
4589 vam->result_ready = 1;
4593 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4595 vat_main_t *vam = &vat_main;
4596 i32 retval = ntohl (mp->retval);
4600 print (vam->ofp, "%-20s%-16s",
4601 mp->status ? "enabled" : "disabled",
4602 mp->status ? (char *) mp->locator_set_name : "");
4605 vam->retval = retval;
4606 vam->result_ready = 1;
4610 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4612 vat_main_t *vam = &vat_main;
4613 vat_json_node_t node;
4616 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4617 vec_add1 (status, 0);
4619 vat_json_init_object (&node);
4620 vat_json_object_add_string_copy (&node, "status", status);
4623 vat_json_object_add_string_copy (&node, "locator_set",
4624 mp->locator_set_name);
4629 vat_json_print (vam->ofp, &node);
4630 vat_json_free (&node);
4632 vam->retval = ntohl (mp->retval);
4633 vam->result_ready = 1;
4637 format_policer_type (u8 * s, va_list * va)
4639 u32 i = va_arg (*va, u32);
4641 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4642 s = format (s, "1r2c");
4643 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4644 s = format (s, "1r3c");
4645 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4646 s = format (s, "2r3c-2698");
4647 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4648 s = format (s, "2r3c-4115");
4649 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4650 s = format (s, "2r3c-mef5cf1");
4652 s = format (s, "ILLEGAL");
4657 format_policer_rate_type (u8 * s, va_list * va)
4659 u32 i = va_arg (*va, u32);
4661 if (i == SSE2_QOS_RATE_KBPS)
4662 s = format (s, "kbps");
4663 else if (i == SSE2_QOS_RATE_PPS)
4664 s = format (s, "pps");
4666 s = format (s, "ILLEGAL");
4671 format_policer_round_type (u8 * s, va_list * va)
4673 u32 i = va_arg (*va, u32);
4675 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4676 s = format (s, "closest");
4677 else if (i == SSE2_QOS_ROUND_TO_UP)
4678 s = format (s, "up");
4679 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4680 s = format (s, "down");
4682 s = format (s, "ILLEGAL");
4687 format_policer_action_type (u8 * s, va_list * va)
4689 u32 i = va_arg (*va, u32);
4691 if (i == SSE2_QOS_ACTION_DROP)
4692 s = format (s, "drop");
4693 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4694 s = format (s, "transmit");
4695 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4696 s = format (s, "mark-and-transmit");
4698 s = format (s, "ILLEGAL");
4703 format_dscp (u8 * s, va_list * va)
4705 u32 i = va_arg (*va, u32);
4710 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4714 return format (s, "ILLEGAL");
4716 s = format (s, "%s", t);
4721 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4723 vat_main_t *vam = &vat_main;
4724 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4726 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4727 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4729 conform_dscp_str = format (0, "");
4731 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4732 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4734 exceed_dscp_str = format (0, "");
4736 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4737 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4739 violate_dscp_str = format (0, "");
4741 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4742 "rate type %U, round type %U, %s rate, %s color-aware, "
4743 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4744 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4745 "conform action %U%s, exceed action %U%s, violate action %U%s",
4747 format_policer_type, mp->type,
4750 clib_net_to_host_u64 (mp->cb),
4751 clib_net_to_host_u64 (mp->eb),
4752 format_policer_rate_type, mp->rate_type,
4753 format_policer_round_type, mp->round_type,
4754 mp->single_rate ? "single" : "dual",
4755 mp->color_aware ? "is" : "not",
4756 ntohl (mp->cir_tokens_per_period),
4757 ntohl (mp->pir_tokens_per_period),
4759 ntohl (mp->current_limit),
4760 ntohl (mp->current_bucket),
4761 ntohl (mp->extended_limit),
4762 ntohl (mp->extended_bucket),
4763 clib_net_to_host_u64 (mp->last_update_time),
4764 format_policer_action_type, mp->conform_action_type,
4766 format_policer_action_type, mp->exceed_action_type,
4768 format_policer_action_type, mp->violate_action_type,
4771 vec_free (conform_dscp_str);
4772 vec_free (exceed_dscp_str);
4773 vec_free (violate_dscp_str);
4776 static void vl_api_policer_details_t_handler_json
4777 (vl_api_policer_details_t * mp)
4779 vat_main_t *vam = &vat_main;
4780 vat_json_node_t *node;
4781 u8 *rate_type_str, *round_type_str, *type_str;
4782 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4784 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4786 format (0, "%U", format_policer_round_type, mp->round_type);
4787 type_str = format (0, "%U", format_policer_type, mp->type);
4788 conform_action_str = format (0, "%U", format_policer_action_type,
4789 mp->conform_action_type);
4790 exceed_action_str = format (0, "%U", format_policer_action_type,
4791 mp->exceed_action_type);
4792 violate_action_str = format (0, "%U", format_policer_action_type,
4793 mp->violate_action_type);
4795 if (VAT_JSON_ARRAY != vam->json_tree.type)
4797 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4798 vat_json_init_array (&vam->json_tree);
4800 node = vat_json_array_add (&vam->json_tree);
4802 vat_json_init_object (node);
4803 vat_json_object_add_string_copy (node, "name", mp->name);
4804 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4805 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4806 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4807 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4808 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4809 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4810 vat_json_object_add_string_copy (node, "type", type_str);
4811 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4812 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4813 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4814 vat_json_object_add_uint (node, "cir_tokens_per_period",
4815 ntohl (mp->cir_tokens_per_period));
4816 vat_json_object_add_uint (node, "eir_tokens_per_period",
4817 ntohl (mp->pir_tokens_per_period));
4818 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4819 vat_json_object_add_uint (node, "current_bucket",
4820 ntohl (mp->current_bucket));
4821 vat_json_object_add_uint (node, "extended_limit",
4822 ntohl (mp->extended_limit));
4823 vat_json_object_add_uint (node, "extended_bucket",
4824 ntohl (mp->extended_bucket));
4825 vat_json_object_add_uint (node, "last_update_time",
4826 ntohl (mp->last_update_time));
4827 vat_json_object_add_string_copy (node, "conform_action",
4828 conform_action_str);
4829 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4831 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4832 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4833 vec_free (dscp_str);
4835 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4836 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4838 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4839 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4840 vec_free (dscp_str);
4842 vat_json_object_add_string_copy (node, "violate_action",
4843 violate_action_str);
4844 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4846 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4847 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4848 vec_free (dscp_str);
4851 vec_free (rate_type_str);
4852 vec_free (round_type_str);
4853 vec_free (type_str);
4854 vec_free (conform_action_str);
4855 vec_free (exceed_action_str);
4856 vec_free (violate_action_str);
4860 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4863 vat_main_t *vam = &vat_main;
4864 int i, count = ntohl (mp->count);
4867 print (vam->ofp, "classify table ids (%d) : ", count);
4868 for (i = 0; i < count; i++)
4870 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4871 print (vam->ofp, (i < count - 1) ? "," : "");
4873 vam->retval = ntohl (mp->retval);
4874 vam->result_ready = 1;
4878 vl_api_classify_table_ids_reply_t_handler_json
4879 (vl_api_classify_table_ids_reply_t * mp)
4881 vat_main_t *vam = &vat_main;
4882 int i, count = ntohl (mp->count);
4886 vat_json_node_t node;
4888 vat_json_init_object (&node);
4889 for (i = 0; i < count; i++)
4891 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4893 vat_json_print (vam->ofp, &node);
4894 vat_json_free (&node);
4896 vam->retval = ntohl (mp->retval);
4897 vam->result_ready = 1;
4901 vl_api_classify_table_by_interface_reply_t_handler
4902 (vl_api_classify_table_by_interface_reply_t * mp)
4904 vat_main_t *vam = &vat_main;
4907 table_id = ntohl (mp->l2_table_id);
4909 print (vam->ofp, "l2 table id : %d", table_id);
4911 print (vam->ofp, "l2 table id : No input ACL tables configured");
4912 table_id = ntohl (mp->ip4_table_id);
4914 print (vam->ofp, "ip4 table id : %d", table_id);
4916 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4917 table_id = ntohl (mp->ip6_table_id);
4919 print (vam->ofp, "ip6 table id : %d", table_id);
4921 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4922 vam->retval = ntohl (mp->retval);
4923 vam->result_ready = 1;
4927 vl_api_classify_table_by_interface_reply_t_handler_json
4928 (vl_api_classify_table_by_interface_reply_t * mp)
4930 vat_main_t *vam = &vat_main;
4931 vat_json_node_t node;
4933 vat_json_init_object (&node);
4935 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4936 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4937 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4939 vat_json_print (vam->ofp, &node);
4940 vat_json_free (&node);
4942 vam->retval = ntohl (mp->retval);
4943 vam->result_ready = 1;
4946 static void vl_api_policer_add_del_reply_t_handler
4947 (vl_api_policer_add_del_reply_t * mp)
4949 vat_main_t *vam = &vat_main;
4950 i32 retval = ntohl (mp->retval);
4951 if (vam->async_mode)
4953 vam->async_errors += (retval < 0);
4957 vam->retval = retval;
4958 vam->result_ready = 1;
4959 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4961 * Note: this is just barely thread-safe, depends on
4962 * the main thread spinning waiting for an answer...
4964 errmsg ("policer index %d", ntohl (mp->policer_index));
4968 static void vl_api_policer_add_del_reply_t_handler_json
4969 (vl_api_policer_add_del_reply_t * mp)
4971 vat_main_t *vam = &vat_main;
4972 vat_json_node_t node;
4974 vat_json_init_object (&node);
4975 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4976 vat_json_object_add_uint (&node, "policer_index",
4977 ntohl (mp->policer_index));
4979 vat_json_print (vam->ofp, &node);
4980 vat_json_free (&node);
4982 vam->retval = ntohl (mp->retval);
4983 vam->result_ready = 1;
4986 /* Format hex dump. */
4988 format_hex_bytes (u8 * s, va_list * va)
4990 u8 *bytes = va_arg (*va, u8 *);
4991 int n_bytes = va_arg (*va, int);
4994 /* Print short or long form depending on byte count. */
4995 uword short_form = n_bytes <= 32;
4996 u32 indent = format_get_indent (s);
5001 for (i = 0; i < n_bytes; i++)
5003 if (!short_form && (i % 32) == 0)
5004 s = format (s, "%08x: ", i);
5005 s = format (s, "%02x", bytes[i]);
5006 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5007 s = format (s, "\n%U", format_white_space, indent);
5014 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5017 vat_main_t *vam = &vat_main;
5018 i32 retval = ntohl (mp->retval);
5021 print (vam->ofp, "classify table info :");
5022 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5023 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5024 ntohl (mp->miss_next_index));
5025 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5026 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5027 ntohl (mp->match_n_vectors));
5028 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5029 ntohl (mp->mask_length));
5031 vam->retval = retval;
5032 vam->result_ready = 1;
5036 vl_api_classify_table_info_reply_t_handler_json
5037 (vl_api_classify_table_info_reply_t * mp)
5039 vat_main_t *vam = &vat_main;
5040 vat_json_node_t node;
5042 i32 retval = ntohl (mp->retval);
5045 vat_json_init_object (&node);
5047 vat_json_object_add_int (&node, "sessions",
5048 ntohl (mp->active_sessions));
5049 vat_json_object_add_int (&node, "nexttbl",
5050 ntohl (mp->next_table_index));
5051 vat_json_object_add_int (&node, "nextnode",
5052 ntohl (mp->miss_next_index));
5053 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5054 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5055 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5056 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5057 ntohl (mp->mask_length), 0);
5058 vat_json_object_add_string_copy (&node, "mask", s);
5060 vat_json_print (vam->ofp, &node);
5061 vat_json_free (&node);
5063 vam->retval = ntohl (mp->retval);
5064 vam->result_ready = 1;
5068 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5071 vat_main_t *vam = &vat_main;
5073 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5074 ntohl (mp->hit_next_index), ntohl (mp->advance),
5075 ntohl (mp->opaque_index));
5076 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5077 ntohl (mp->match_length));
5081 vl_api_classify_session_details_t_handler_json
5082 (vl_api_classify_session_details_t * mp)
5084 vat_main_t *vam = &vat_main;
5085 vat_json_node_t *node = NULL;
5087 if (VAT_JSON_ARRAY != vam->json_tree.type)
5089 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5090 vat_json_init_array (&vam->json_tree);
5092 node = vat_json_array_add (&vam->json_tree);
5094 vat_json_init_object (node);
5095 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5096 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5097 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5099 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5101 vat_json_object_add_string_copy (node, "match", s);
5104 static void vl_api_pg_create_interface_reply_t_handler
5105 (vl_api_pg_create_interface_reply_t * mp)
5107 vat_main_t *vam = &vat_main;
5109 vam->retval = ntohl (mp->retval);
5110 vam->result_ready = 1;
5113 static void vl_api_pg_create_interface_reply_t_handler_json
5114 (vl_api_pg_create_interface_reply_t * mp)
5116 vat_main_t *vam = &vat_main;
5117 vat_json_node_t node;
5119 i32 retval = ntohl (mp->retval);
5122 vat_json_init_object (&node);
5124 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5126 vat_json_print (vam->ofp, &node);
5127 vat_json_free (&node);
5129 vam->retval = ntohl (mp->retval);
5130 vam->result_ready = 1;
5133 static void vl_api_policer_classify_details_t_handler
5134 (vl_api_policer_classify_details_t * mp)
5136 vat_main_t *vam = &vat_main;
5138 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5139 ntohl (mp->table_index));
5142 static void vl_api_policer_classify_details_t_handler_json
5143 (vl_api_policer_classify_details_t * mp)
5145 vat_main_t *vam = &vat_main;
5146 vat_json_node_t *node;
5148 if (VAT_JSON_ARRAY != vam->json_tree.type)
5150 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5151 vat_json_init_array (&vam->json_tree);
5153 node = vat_json_array_add (&vam->json_tree);
5155 vat_json_init_object (node);
5156 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5157 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5160 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5161 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5163 vat_main_t *vam = &vat_main;
5164 i32 retval = ntohl (mp->retval);
5165 if (vam->async_mode)
5167 vam->async_errors += (retval < 0);
5171 vam->retval = retval;
5172 vam->sw_if_index = ntohl (mp->sw_if_index);
5173 vam->result_ready = 1;
5175 vam->regenerate_interface_table = 1;
5178 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5179 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5181 vat_main_t *vam = &vat_main;
5182 vat_json_node_t node;
5184 vat_json_init_object (&node);
5185 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5186 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5188 vat_json_print (vam->ofp, &node);
5189 vat_json_free (&node);
5191 vam->retval = ntohl (mp->retval);
5192 vam->result_ready = 1;
5195 static void vl_api_flow_classify_details_t_handler
5196 (vl_api_flow_classify_details_t * mp)
5198 vat_main_t *vam = &vat_main;
5200 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5201 ntohl (mp->table_index));
5204 static void vl_api_flow_classify_details_t_handler_json
5205 (vl_api_flow_classify_details_t * mp)
5207 vat_main_t *vam = &vat_main;
5208 vat_json_node_t *node;
5210 if (VAT_JSON_ARRAY != vam->json_tree.type)
5212 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5213 vat_json_init_array (&vam->json_tree);
5215 node = vat_json_array_add (&vam->json_tree);
5217 vat_json_init_object (node);
5218 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5219 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5222 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5223 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5224 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5225 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5226 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5227 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5228 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5229 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5230 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5231 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5234 * Generate boilerplate reply handlers, which
5235 * dig the return value out of the xxx_reply_t API message,
5236 * stick it into vam->retval, and set vam->result_ready
5238 * Could also do this by pointing N message decode slots at
5239 * a single function, but that could break in subtle ways.
5242 #define foreach_standard_reply_retval_handler \
5243 _(sw_interface_set_flags_reply) \
5244 _(sw_interface_add_del_address_reply) \
5245 _(sw_interface_set_rx_mode_reply) \
5246 _(sw_interface_set_rx_placement_reply) \
5247 _(sw_interface_set_table_reply) \
5248 _(sw_interface_set_mpls_enable_reply) \
5249 _(sw_interface_set_vpath_reply) \
5250 _(sw_interface_set_vxlan_bypass_reply) \
5251 _(sw_interface_set_geneve_bypass_reply) \
5252 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5253 _(sw_interface_set_l2_bridge_reply) \
5254 _(bridge_domain_add_del_reply) \
5255 _(sw_interface_set_l2_xconnect_reply) \
5256 _(l2fib_add_del_reply) \
5257 _(l2fib_flush_int_reply) \
5258 _(l2fib_flush_bd_reply) \
5259 _(ip_add_del_route_reply) \
5260 _(ip_table_add_del_reply) \
5261 _(ip_mroute_add_del_reply) \
5262 _(mpls_route_add_del_reply) \
5263 _(mpls_table_add_del_reply) \
5264 _(mpls_ip_bind_unbind_reply) \
5265 _(bier_route_add_del_reply) \
5266 _(bier_table_add_del_reply) \
5267 _(proxy_arp_add_del_reply) \
5268 _(proxy_arp_intfc_enable_disable_reply) \
5269 _(sw_interface_set_unnumbered_reply) \
5270 _(ip_neighbor_add_del_reply) \
5271 _(oam_add_del_reply) \
5272 _(reset_fib_reply) \
5273 _(dhcp_proxy_config_reply) \
5274 _(dhcp_proxy_set_vss_reply) \
5275 _(dhcp_client_config_reply) \
5276 _(set_ip_flow_hash_reply) \
5277 _(sw_interface_ip6_enable_disable_reply) \
5278 _(ip6nd_proxy_add_del_reply) \
5279 _(sw_interface_ip6nd_ra_prefix_reply) \
5280 _(sw_interface_ip6nd_ra_config_reply) \
5281 _(set_arp_neighbor_limit_reply) \
5282 _(l2_patch_add_del_reply) \
5283 _(sr_mpls_policy_add_reply) \
5284 _(sr_mpls_policy_mod_reply) \
5285 _(sr_mpls_policy_del_reply) \
5286 _(sr_policy_add_reply) \
5287 _(sr_policy_mod_reply) \
5288 _(sr_policy_del_reply) \
5289 _(sr_localsid_add_del_reply) \
5290 _(sr_steering_add_del_reply) \
5291 _(classify_add_del_session_reply) \
5292 _(classify_set_interface_ip_table_reply) \
5293 _(classify_set_interface_l2_tables_reply) \
5294 _(l2tpv3_set_tunnel_cookies_reply) \
5295 _(l2tpv3_interface_enable_disable_reply) \
5296 _(l2tpv3_set_lookup_key_reply) \
5297 _(l2_fib_clear_table_reply) \
5298 _(l2_interface_efp_filter_reply) \
5299 _(l2_interface_vlan_tag_rewrite_reply) \
5300 _(modify_vhost_user_if_reply) \
5301 _(delete_vhost_user_if_reply) \
5302 _(ip_probe_neighbor_reply) \
5303 _(ip_scan_neighbor_enable_disable_reply) \
5304 _(want_ip4_arp_events_reply) \
5305 _(want_ip6_nd_events_reply) \
5306 _(want_l2_macs_events_reply) \
5307 _(input_acl_set_interface_reply) \
5308 _(ipsec_spd_add_del_reply) \
5309 _(ipsec_interface_add_del_spd_reply) \
5310 _(ipsec_spd_add_del_entry_reply) \
5311 _(ipsec_sad_add_del_entry_reply) \
5312 _(ipsec_sa_set_key_reply) \
5313 _(ipsec_tunnel_if_add_del_reply) \
5314 _(ipsec_tunnel_if_set_key_reply) \
5315 _(ipsec_tunnel_if_set_sa_reply) \
5316 _(ikev2_profile_add_del_reply) \
5317 _(ikev2_profile_set_auth_reply) \
5318 _(ikev2_profile_set_id_reply) \
5319 _(ikev2_profile_set_ts_reply) \
5320 _(ikev2_set_local_key_reply) \
5321 _(ikev2_set_responder_reply) \
5322 _(ikev2_set_ike_transforms_reply) \
5323 _(ikev2_set_esp_transforms_reply) \
5324 _(ikev2_set_sa_lifetime_reply) \
5325 _(ikev2_initiate_sa_init_reply) \
5326 _(ikev2_initiate_del_ike_sa_reply) \
5327 _(ikev2_initiate_del_child_sa_reply) \
5328 _(ikev2_initiate_rekey_child_sa_reply) \
5329 _(delete_loopback_reply) \
5330 _(bd_ip_mac_add_del_reply) \
5331 _(bd_ip_mac_flush_reply) \
5332 _(want_interface_events_reply) \
5333 _(cop_interface_enable_disable_reply) \
5334 _(cop_whitelist_enable_disable_reply) \
5335 _(sw_interface_clear_stats_reply) \
5336 _(ioam_enable_reply) \
5337 _(ioam_disable_reply) \
5338 _(one_add_del_locator_reply) \
5339 _(one_add_del_local_eid_reply) \
5340 _(one_add_del_remote_mapping_reply) \
5341 _(one_add_del_adjacency_reply) \
5342 _(one_add_del_map_resolver_reply) \
5343 _(one_add_del_map_server_reply) \
5344 _(one_enable_disable_reply) \
5345 _(one_rloc_probe_enable_disable_reply) \
5346 _(one_map_register_enable_disable_reply) \
5347 _(one_map_register_set_ttl_reply) \
5348 _(one_set_transport_protocol_reply) \
5349 _(one_map_register_fallback_threshold_reply) \
5350 _(one_pitr_set_locator_set_reply) \
5351 _(one_map_request_mode_reply) \
5352 _(one_add_del_map_request_itr_rlocs_reply) \
5353 _(one_eid_table_add_del_map_reply) \
5354 _(one_use_petr_reply) \
5355 _(one_stats_enable_disable_reply) \
5356 _(one_add_del_l2_arp_entry_reply) \
5357 _(one_add_del_ndp_entry_reply) \
5358 _(one_stats_flush_reply) \
5359 _(one_enable_disable_xtr_mode_reply) \
5360 _(one_enable_disable_pitr_mode_reply) \
5361 _(one_enable_disable_petr_mode_reply) \
5362 _(gpe_enable_disable_reply) \
5363 _(gpe_set_encap_mode_reply) \
5364 _(gpe_add_del_iface_reply) \
5365 _(gpe_add_del_native_fwd_rpath_reply) \
5366 _(af_packet_delete_reply) \
5367 _(policer_classify_set_interface_reply) \
5368 _(netmap_create_reply) \
5369 _(netmap_delete_reply) \
5370 _(set_ipfix_exporter_reply) \
5371 _(set_ipfix_classify_stream_reply) \
5372 _(ipfix_classify_table_add_del_reply) \
5373 _(flow_classify_set_interface_reply) \
5374 _(sw_interface_span_enable_disable_reply) \
5375 _(pg_capture_reply) \
5376 _(pg_enable_disable_reply) \
5377 _(ip_source_and_port_range_check_add_del_reply) \
5378 _(ip_source_and_port_range_check_interface_add_del_reply)\
5379 _(delete_subif_reply) \
5380 _(l2_interface_pbb_tag_rewrite_reply) \
5382 _(feature_enable_disable_reply) \
5383 _(sw_interface_tag_add_del_reply) \
5384 _(hw_interface_set_mtu_reply) \
5385 _(p2p_ethernet_add_reply) \
5386 _(p2p_ethernet_del_reply) \
5387 _(lldp_config_reply) \
5388 _(sw_interface_set_lldp_reply) \
5389 _(tcp_configure_src_addresses_reply) \
5390 _(dns_enable_disable_reply) \
5391 _(dns_name_server_add_del_reply) \
5392 _(session_rule_add_del_reply) \
5393 _(ip_container_proxy_add_del_reply) \
5394 _(output_acl_set_interface_reply) \
5395 _(qos_record_enable_disable_reply)
5398 static void vl_api_##n##_t_handler \
5399 (vl_api_##n##_t * mp) \
5401 vat_main_t * vam = &vat_main; \
5402 i32 retval = ntohl(mp->retval); \
5403 if (vam->async_mode) { \
5404 vam->async_errors += (retval < 0); \
5406 vam->retval = retval; \
5407 vam->result_ready = 1; \
5410 foreach_standard_reply_retval_handler;
5414 static void vl_api_##n##_t_handler_json \
5415 (vl_api_##n##_t * mp) \
5417 vat_main_t * vam = &vat_main; \
5418 vat_json_node_t node; \
5419 vat_json_init_object(&node); \
5420 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5421 vat_json_print(vam->ofp, &node); \
5422 vam->retval = ntohl(mp->retval); \
5423 vam->result_ready = 1; \
5425 foreach_standard_reply_retval_handler;
5429 * Table of message reply handlers, must include boilerplate handlers
5433 #define foreach_vpe_api_reply_msg \
5434 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5435 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5436 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5437 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5438 _(CONTROL_PING_REPLY, control_ping_reply) \
5439 _(CLI_REPLY, cli_reply) \
5440 _(CLI_INBAND_REPLY, cli_inband_reply) \
5441 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5442 sw_interface_add_del_address_reply) \
5443 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5444 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5445 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5446 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5447 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5448 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5449 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5450 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5451 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5452 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5453 sw_interface_set_l2_xconnect_reply) \
5454 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5455 sw_interface_set_l2_bridge_reply) \
5456 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5457 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5458 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5459 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5460 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5461 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5462 _(L2_FLAGS_REPLY, l2_flags_reply) \
5463 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5464 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5465 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5466 _(TAP_DELETE_REPLY, tap_delete_reply) \
5467 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5468 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5469 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5470 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5471 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5472 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5473 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5474 _(BOND_CREATE_REPLY, bond_create_reply) \
5475 _(BOND_DELETE_REPLY, bond_delete_reply) \
5476 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5477 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5478 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5479 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5480 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5481 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5482 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5483 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5484 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5485 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5486 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5487 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5488 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5489 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5490 proxy_arp_intfc_enable_disable_reply) \
5491 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5492 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5493 sw_interface_set_unnumbered_reply) \
5494 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5495 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5496 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5497 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5498 _(RESET_FIB_REPLY, reset_fib_reply) \
5499 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5500 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5501 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5502 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5503 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5504 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5505 sw_interface_ip6_enable_disable_reply) \
5506 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5507 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5508 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5509 sw_interface_ip6nd_ra_prefix_reply) \
5510 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5511 sw_interface_ip6nd_ra_config_reply) \
5512 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5513 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5514 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5515 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5516 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5517 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5518 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5519 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5520 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5521 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5522 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5523 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5524 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5525 classify_set_interface_ip_table_reply) \
5526 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5527 classify_set_interface_l2_tables_reply) \
5528 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5529 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5530 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5531 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5532 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5533 l2tpv3_interface_enable_disable_reply) \
5534 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5535 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5536 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5537 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5538 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5539 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5540 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5541 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5542 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5543 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5544 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5545 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5546 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5547 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5548 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5549 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5550 _(SHOW_VERSION_REPLY, show_version_reply) \
5551 _(SHOW_THREADS_REPLY, show_threads_reply) \
5552 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5553 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5554 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5555 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5556 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5557 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5558 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5559 _(IP4_ARP_EVENT, ip4_arp_event) \
5560 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5561 _(IP6_ND_EVENT, ip6_nd_event) \
5562 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5563 _(L2_MACS_EVENT, l2_macs_event) \
5564 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5565 _(IP_ADDRESS_DETAILS, ip_address_details) \
5566 _(IP_DETAILS, ip_details) \
5567 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5568 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5569 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5570 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5571 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5572 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5573 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5574 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5575 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5576 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5577 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5578 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5579 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5580 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5581 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5582 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5583 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5584 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5585 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5586 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5587 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5588 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5589 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5590 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5591 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5592 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5593 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5594 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5595 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5596 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5597 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5598 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5599 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5600 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5601 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5602 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5603 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5604 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5605 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5606 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5607 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5608 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5609 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5610 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5611 one_map_register_enable_disable_reply) \
5612 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5613 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5614 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5615 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5616 one_map_register_fallback_threshold_reply) \
5617 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5618 one_rloc_probe_enable_disable_reply) \
5619 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5620 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5621 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5622 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5623 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5624 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5625 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5626 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5627 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5628 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5629 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5630 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5631 _(ONE_STATS_DETAILS, one_stats_details) \
5632 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5633 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5634 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5635 show_one_stats_enable_disable_reply) \
5636 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5637 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5638 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5639 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5640 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5641 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5642 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5643 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5644 one_enable_disable_pitr_mode_reply) \
5645 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5646 one_enable_disable_petr_mode_reply) \
5647 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5648 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5649 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5650 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5651 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5652 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5653 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5654 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5655 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5656 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5657 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5658 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5659 gpe_add_del_native_fwd_rpath_reply) \
5660 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5661 gpe_fwd_entry_path_details) \
5662 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5663 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5664 one_add_del_map_request_itr_rlocs_reply) \
5665 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5666 one_get_map_request_itr_rlocs_reply) \
5667 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5668 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5669 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5670 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5671 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5672 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5673 show_one_map_register_state_reply) \
5674 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5675 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5676 show_one_map_register_fallback_threshold_reply) \
5677 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5678 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5679 _(AF_PACKET_DETAILS, af_packet_details) \
5680 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5681 _(POLICER_DETAILS, policer_details) \
5682 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5683 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5684 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5685 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5686 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5687 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5688 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5689 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5690 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5691 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5692 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5693 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5694 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5695 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5696 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5697 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5698 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5699 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5700 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5701 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5702 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5703 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5704 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5705 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5706 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5707 ip_source_and_port_range_check_add_del_reply) \
5708 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5709 ip_source_and_port_range_check_interface_add_del_reply) \
5710 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5711 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5712 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5713 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5714 _(SET_PUNT_REPLY, set_punt_reply) \
5715 _(IP_FIB_DETAILS, ip_fib_details) \
5716 _(IP6_FIB_DETAILS, ip6_fib_details) \
5717 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5718 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5719 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5720 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5721 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5722 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5723 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5724 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5725 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5726 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5727 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5728 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5729 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5730 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5731 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5732 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5733 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5734 _(SESSION_RULES_DETAILS, session_rules_details) \
5735 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5736 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5737 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5739 #define foreach_standalone_reply_msg \
5740 _(SW_INTERFACE_EVENT, sw_interface_event)
5748 #define STR_VTR_OP_CASE(op) \
5749 case L2_VTR_ ## op: \
5753 str_vtr_op (u32 vtr_op)
5757 STR_VTR_OP_CASE (DISABLED);
5758 STR_VTR_OP_CASE (PUSH_1);
5759 STR_VTR_OP_CASE (PUSH_2);
5760 STR_VTR_OP_CASE (POP_1);
5761 STR_VTR_OP_CASE (POP_2);
5762 STR_VTR_OP_CASE (TRANSLATE_1_1);
5763 STR_VTR_OP_CASE (TRANSLATE_1_2);
5764 STR_VTR_OP_CASE (TRANSLATE_2_1);
5765 STR_VTR_OP_CASE (TRANSLATE_2_2);
5772 dump_sub_interface_table (vat_main_t * vam)
5774 const sw_interface_subif_t *sub = NULL;
5776 if (vam->json_output)
5779 ("JSON output supported only for VPE API calls and dump_stats_table");
5784 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5785 "Interface", "sw_if_index",
5786 "sub id", "dot1ad", "tags", "outer id",
5787 "inner id", "exact", "default", "outer any", "inner any");
5789 vec_foreach (sub, vam->sw_if_subif_table)
5792 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5793 sub->interface_name,
5795 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5796 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5797 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5798 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5799 if (sub->vtr_op != L2_VTR_DISABLED)
5802 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5803 "tag1: %d tag2: %d ]",
5804 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5805 sub->vtr_tag1, sub->vtr_tag2);
5813 name_sort_cmp (void *a1, void *a2)
5815 name_sort_t *n1 = a1;
5816 name_sort_t *n2 = a2;
5818 return strcmp ((char *) n1->name, (char *) n2->name);
5822 dump_interface_table (vat_main_t * vam)
5825 name_sort_t *nses = 0, *ns;
5827 if (vam->json_output)
5830 ("JSON output supported only for VPE API calls and dump_stats_table");
5835 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5837 vec_add2 (nses, ns, 1);
5838 ns->name = (u8 *)(p->key);
5839 ns->value = (u32) p->value[0];
5843 vec_sort_with_function (nses, name_sort_cmp);
5845 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5846 vec_foreach (ns, nses)
5848 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5855 dump_ip_table (vat_main_t * vam, int is_ipv6)
5857 const ip_details_t *det = NULL;
5858 const ip_address_details_t *address = NULL;
5861 print (vam->ofp, "%-12s", "sw_if_index");
5863 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5870 print (vam->ofp, "%-12d", i);
5871 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5876 vec_foreach (address, det->addr)
5880 is_ipv6 ? format_ip6_address : format_ip4_address,
5881 address->ip, address->prefix_length);
5889 dump_ipv4_table (vat_main_t * vam)
5891 if (vam->json_output)
5894 ("JSON output supported only for VPE API calls and dump_stats_table");
5898 return dump_ip_table (vam, 0);
5902 dump_ipv6_table (vat_main_t * vam)
5904 if (vam->json_output)
5907 ("JSON output supported only for VPE API calls and dump_stats_table");
5911 return dump_ip_table (vam, 1);
5915 * Pass CLI buffers directly in the CLI_INBAND API message,
5916 * instead of an additional shared memory area.
5919 exec_inband (vat_main_t * vam)
5921 vl_api_cli_inband_t *mp;
5922 unformat_input_t *i = vam->input;
5925 if (vec_len (i->buffer) == 0)
5928 if (vam->exec_mode == 0 && unformat (i, "mode"))
5933 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5940 * In order for the CLI command to work, it
5941 * must be a vector ending in \n, not a C-string ending
5944 u32 len = vec_len (vam->input->buffer);
5945 M2 (CLI_INBAND, mp, len);
5946 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5950 /* json responses may or may not include a useful reply... */
5951 if (vec_len (vam->cmd_reply))
5952 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5957 exec (vat_main_t * vam)
5959 return exec_inband (vam);
5963 api_create_loopback (vat_main_t * vam)
5965 unformat_input_t *i = vam->input;
5966 vl_api_create_loopback_t *mp;
5967 vl_api_create_loopback_instance_t *mp_lbi;
5970 u8 is_specified = 0;
5971 u32 user_instance = 0;
5974 clib_memset (mac_address, 0, sizeof (mac_address));
5976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5978 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5980 if (unformat (i, "instance %d", &user_instance))
5988 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5989 mp_lbi->is_specified = is_specified;
5991 mp_lbi->user_instance = htonl (user_instance);
5993 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5998 /* Construct the API message */
5999 M (CREATE_LOOPBACK, mp);
6001 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6010 api_delete_loopback (vat_main_t * vam)
6012 unformat_input_t *i = vam->input;
6013 vl_api_delete_loopback_t *mp;
6014 u32 sw_if_index = ~0;
6017 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6019 if (unformat (i, "sw_if_index %d", &sw_if_index))
6025 if (sw_if_index == ~0)
6027 errmsg ("missing sw_if_index");
6031 /* Construct the API message */
6032 M (DELETE_LOOPBACK, mp);
6033 mp->sw_if_index = ntohl (sw_if_index);
6041 api_want_interface_events (vat_main_t * vam)
6043 unformat_input_t *i = vam->input;
6044 vl_api_want_interface_events_t *mp;
6048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6050 if (unformat (i, "enable"))
6052 else if (unformat (i, "disable"))
6060 errmsg ("missing enable|disable");
6064 M (WANT_INTERFACE_EVENTS, mp);
6065 mp->enable_disable = enable;
6067 vam->interface_event_display = enable;
6075 /* Note: non-static, called once to set up the initial intfc table */
6077 api_sw_interface_dump (vat_main_t * vam)
6079 vl_api_sw_interface_dump_t *mp;
6080 vl_api_control_ping_t *mp_ping;
6082 name_sort_t *nses = 0, *ns;
6083 sw_interface_subif_t *sub = NULL;
6086 /* Toss the old name table */
6088 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6090 vec_add2 (nses, ns, 1);
6091 ns->name = (u8 *)(p->key);
6092 ns->value = (u32) p->value[0];
6096 hash_free (vam->sw_if_index_by_interface_name);
6098 vec_foreach (ns, nses) vec_free (ns->name);
6102 vec_foreach (sub, vam->sw_if_subif_table)
6104 vec_free (sub->interface_name);
6106 vec_free (vam->sw_if_subif_table);
6108 /* recreate the interface name hash table */
6109 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6112 * Ask for all interface names. Otherwise, the epic catalog of
6113 * name filters becomes ridiculously long, and vat ends up needing
6114 * to be taught about new interface types.
6116 M (SW_INTERFACE_DUMP, mp);
6119 /* Use a control ping for synchronization */
6120 MPING (CONTROL_PING, mp_ping);
6128 api_sw_interface_set_flags (vat_main_t * vam)
6130 unformat_input_t *i = vam->input;
6131 vl_api_sw_interface_set_flags_t *mp;
6133 u8 sw_if_index_set = 0;
6137 /* Parse args required to build the message */
6138 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6140 if (unformat (i, "admin-up"))
6142 else if (unformat (i, "admin-down"))
6145 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6146 sw_if_index_set = 1;
6147 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6148 sw_if_index_set = 1;
6153 if (sw_if_index_set == 0)
6155 errmsg ("missing interface name or sw_if_index");
6159 /* Construct the API message */
6160 M (SW_INTERFACE_SET_FLAGS, mp);
6161 mp->sw_if_index = ntohl (sw_if_index);
6162 mp->admin_up_down = admin_up;
6167 /* Wait for a reply, return the good/bad news... */
6173 api_sw_interface_set_rx_mode (vat_main_t * vam)
6175 unformat_input_t *i = vam->input;
6176 vl_api_sw_interface_set_rx_mode_t *mp;
6178 u8 sw_if_index_set = 0;
6180 u8 queue_id_valid = 0;
6182 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6184 /* Parse args required to build the message */
6185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6187 if (unformat (i, "queue %d", &queue_id))
6189 else if (unformat (i, "polling"))
6190 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6191 else if (unformat (i, "interrupt"))
6192 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6193 else if (unformat (i, "adaptive"))
6194 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6196 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6197 sw_if_index_set = 1;
6198 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6199 sw_if_index_set = 1;
6204 if (sw_if_index_set == 0)
6206 errmsg ("missing interface name or sw_if_index");
6209 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6211 errmsg ("missing rx-mode");
6215 /* Construct the API message */
6216 M (SW_INTERFACE_SET_RX_MODE, mp);
6217 mp->sw_if_index = ntohl (sw_if_index);
6219 mp->queue_id_valid = queue_id_valid;
6220 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6225 /* Wait for a reply, return the good/bad news... */
6231 api_sw_interface_set_rx_placement (vat_main_t * vam)
6233 unformat_input_t *i = vam->input;
6234 vl_api_sw_interface_set_rx_placement_t *mp;
6236 u8 sw_if_index_set = 0;
6239 u32 queue_id, thread_index;
6241 /* Parse args required to build the message */
6242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6244 if (unformat (i, "queue %d", &queue_id))
6246 else if (unformat (i, "main"))
6248 else if (unformat (i, "worker %d", &thread_index))
6251 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6252 sw_if_index_set = 1;
6253 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6254 sw_if_index_set = 1;
6259 if (sw_if_index_set == 0)
6261 errmsg ("missing interface name or sw_if_index");
6267 /* Construct the API message */
6268 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6269 mp->sw_if_index = ntohl (sw_if_index);
6270 mp->worker_id = ntohl (thread_index);
6271 mp->queue_id = ntohl (queue_id);
6272 mp->is_main = is_main;
6276 /* Wait for a reply, return the good/bad news... */
6281 static void vl_api_sw_interface_rx_placement_details_t_handler
6282 (vl_api_sw_interface_rx_placement_details_t * mp)
6284 vat_main_t *vam = &vat_main;
6285 u32 worker_id = ntohl (mp->worker_id);
6288 "\n%-11d %-11s %-6d %-5d %-9s",
6289 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6290 worker_id, ntohl (mp->queue_id),
6292 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6295 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6296 (vl_api_sw_interface_rx_placement_details_t * mp)
6298 vat_main_t *vam = &vat_main;
6299 vat_json_node_t *node = NULL;
6301 if (VAT_JSON_ARRAY != vam->json_tree.type)
6303 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6304 vat_json_init_array (&vam->json_tree);
6306 node = vat_json_array_add (&vam->json_tree);
6308 vat_json_init_object (node);
6309 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6310 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6311 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6312 vat_json_object_add_uint (node, "mode", mp->mode);
6316 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6318 unformat_input_t *i = vam->input;
6319 vl_api_sw_interface_rx_placement_dump_t *mp;
6320 vl_api_control_ping_t *mp_ping;
6323 u8 sw_if_index_set = 0;
6325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6327 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6329 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6336 "\n%-11s %-11s %-6s %-5s %-4s",
6337 "sw_if_index", "main/worker", "thread", "queue", "mode");
6339 /* Dump Interface rx placement */
6340 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6342 if (sw_if_index_set)
6343 mp->sw_if_index = htonl (sw_if_index);
6345 mp->sw_if_index = ~0;
6349 /* Use a control ping for synchronization */
6350 MPING (CONTROL_PING, mp_ping);
6358 api_sw_interface_clear_stats (vat_main_t * vam)
6360 unformat_input_t *i = vam->input;
6361 vl_api_sw_interface_clear_stats_t *mp;
6363 u8 sw_if_index_set = 0;
6366 /* Parse args required to build the message */
6367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6369 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6370 sw_if_index_set = 1;
6371 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6372 sw_if_index_set = 1;
6377 /* Construct the API message */
6378 M (SW_INTERFACE_CLEAR_STATS, mp);
6380 if (sw_if_index_set == 1)
6381 mp->sw_if_index = ntohl (sw_if_index);
6383 mp->sw_if_index = ~0;
6388 /* Wait for a reply, return the good/bad news... */
6394 api_sw_interface_add_del_address (vat_main_t * vam)
6396 unformat_input_t *i = vam->input;
6397 vl_api_sw_interface_add_del_address_t *mp;
6399 u8 sw_if_index_set = 0;
6400 u8 is_add = 1, del_all = 0;
6401 u32 address_length = 0;
6402 u8 v4_address_set = 0;
6403 u8 v6_address_set = 0;
6404 ip4_address_t v4address;
6405 ip6_address_t v6address;
6408 /* Parse args required to build the message */
6409 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6411 if (unformat (i, "del-all"))
6413 else if (unformat (i, "del"))
6416 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6417 sw_if_index_set = 1;
6418 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6419 sw_if_index_set = 1;
6420 else if (unformat (i, "%U/%d",
6421 unformat_ip4_address, &v4address, &address_length))
6423 else if (unformat (i, "%U/%d",
6424 unformat_ip6_address, &v6address, &address_length))
6430 if (sw_if_index_set == 0)
6432 errmsg ("missing interface name or sw_if_index");
6435 if (v4_address_set && v6_address_set)
6437 errmsg ("both v4 and v6 addresses set");
6440 if (!v4_address_set && !v6_address_set && !del_all)
6442 errmsg ("no addresses set");
6446 /* Construct the API message */
6447 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6449 mp->sw_if_index = ntohl (sw_if_index);
6450 mp->is_add = is_add;
6451 mp->del_all = del_all;
6455 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6459 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6461 mp->address_length = address_length;
6466 /* Wait for a reply, return good/bad news */
6472 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6474 unformat_input_t *i = vam->input;
6475 vl_api_sw_interface_set_mpls_enable_t *mp;
6477 u8 sw_if_index_set = 0;
6481 /* Parse args required to build the message */
6482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6484 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6485 sw_if_index_set = 1;
6486 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6487 sw_if_index_set = 1;
6488 else if (unformat (i, "disable"))
6490 else if (unformat (i, "dis"))
6496 if (sw_if_index_set == 0)
6498 errmsg ("missing interface name or sw_if_index");
6502 /* Construct the API message */
6503 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6505 mp->sw_if_index = ntohl (sw_if_index);
6506 mp->enable = enable;
6511 /* Wait for a reply... */
6517 api_sw_interface_set_table (vat_main_t * vam)
6519 unformat_input_t *i = vam->input;
6520 vl_api_sw_interface_set_table_t *mp;
6521 u32 sw_if_index, vrf_id = 0;
6522 u8 sw_if_index_set = 0;
6526 /* Parse args required to build the message */
6527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6529 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6530 sw_if_index_set = 1;
6531 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6532 sw_if_index_set = 1;
6533 else if (unformat (i, "vrf %d", &vrf_id))
6535 else if (unformat (i, "ipv6"))
6541 if (sw_if_index_set == 0)
6543 errmsg ("missing interface name or sw_if_index");
6547 /* Construct the API message */
6548 M (SW_INTERFACE_SET_TABLE, mp);
6550 mp->sw_if_index = ntohl (sw_if_index);
6551 mp->is_ipv6 = is_ipv6;
6552 mp->vrf_id = ntohl (vrf_id);
6557 /* Wait for a reply... */
6562 static void vl_api_sw_interface_get_table_reply_t_handler
6563 (vl_api_sw_interface_get_table_reply_t * mp)
6565 vat_main_t *vam = &vat_main;
6567 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6569 vam->retval = ntohl (mp->retval);
6570 vam->result_ready = 1;
6574 static void vl_api_sw_interface_get_table_reply_t_handler_json
6575 (vl_api_sw_interface_get_table_reply_t * mp)
6577 vat_main_t *vam = &vat_main;
6578 vat_json_node_t node;
6580 vat_json_init_object (&node);
6581 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6582 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6584 vat_json_print (vam->ofp, &node);
6585 vat_json_free (&node);
6587 vam->retval = ntohl (mp->retval);
6588 vam->result_ready = 1;
6592 api_sw_interface_get_table (vat_main_t * vam)
6594 unformat_input_t *i = vam->input;
6595 vl_api_sw_interface_get_table_t *mp;
6597 u8 sw_if_index_set = 0;
6601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6603 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6604 sw_if_index_set = 1;
6605 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6606 sw_if_index_set = 1;
6607 else if (unformat (i, "ipv6"))
6613 if (sw_if_index_set == 0)
6615 errmsg ("missing interface name or sw_if_index");
6619 M (SW_INTERFACE_GET_TABLE, mp);
6620 mp->sw_if_index = htonl (sw_if_index);
6621 mp->is_ipv6 = is_ipv6;
6629 api_sw_interface_set_vpath (vat_main_t * vam)
6631 unformat_input_t *i = vam->input;
6632 vl_api_sw_interface_set_vpath_t *mp;
6633 u32 sw_if_index = 0;
6634 u8 sw_if_index_set = 0;
6638 /* Parse args required to build the message */
6639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6641 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6642 sw_if_index_set = 1;
6643 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6644 sw_if_index_set = 1;
6645 else if (unformat (i, "enable"))
6647 else if (unformat (i, "disable"))
6653 if (sw_if_index_set == 0)
6655 errmsg ("missing interface name or sw_if_index");
6659 /* Construct the API message */
6660 M (SW_INTERFACE_SET_VPATH, mp);
6662 mp->sw_if_index = ntohl (sw_if_index);
6663 mp->enable = is_enable;
6668 /* Wait for a reply... */
6674 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6676 unformat_input_t *i = vam->input;
6677 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6678 u32 sw_if_index = 0;
6679 u8 sw_if_index_set = 0;
6684 /* Parse args required to build the message */
6685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6687 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6688 sw_if_index_set = 1;
6689 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6690 sw_if_index_set = 1;
6691 else if (unformat (i, "enable"))
6693 else if (unformat (i, "disable"))
6695 else if (unformat (i, "ip4"))
6697 else if (unformat (i, "ip6"))
6703 if (sw_if_index_set == 0)
6705 errmsg ("missing interface name or sw_if_index");
6709 /* Construct the API message */
6710 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6712 mp->sw_if_index = ntohl (sw_if_index);
6713 mp->enable = is_enable;
6714 mp->is_ipv6 = is_ipv6;
6719 /* Wait for a reply... */
6725 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6727 unformat_input_t *i = vam->input;
6728 vl_api_sw_interface_set_geneve_bypass_t *mp;
6729 u32 sw_if_index = 0;
6730 u8 sw_if_index_set = 0;
6735 /* Parse args required to build the message */
6736 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6738 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6739 sw_if_index_set = 1;
6740 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6741 sw_if_index_set = 1;
6742 else if (unformat (i, "enable"))
6744 else if (unformat (i, "disable"))
6746 else if (unformat (i, "ip4"))
6748 else if (unformat (i, "ip6"))
6754 if (sw_if_index_set == 0)
6756 errmsg ("missing interface name or sw_if_index");
6760 /* Construct the API message */
6761 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6763 mp->sw_if_index = ntohl (sw_if_index);
6764 mp->enable = is_enable;
6765 mp->is_ipv6 = is_ipv6;
6770 /* Wait for a reply... */
6776 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6778 unformat_input_t *i = vam->input;
6779 vl_api_sw_interface_set_l2_xconnect_t *mp;
6781 u8 rx_sw_if_index_set = 0;
6783 u8 tx_sw_if_index_set = 0;
6787 /* Parse args required to build the message */
6788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6790 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6791 rx_sw_if_index_set = 1;
6792 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6793 tx_sw_if_index_set = 1;
6794 else if (unformat (i, "rx"))
6796 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6798 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6800 rx_sw_if_index_set = 1;
6805 else if (unformat (i, "tx"))
6807 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6809 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6811 tx_sw_if_index_set = 1;
6816 else if (unformat (i, "enable"))
6818 else if (unformat (i, "disable"))
6824 if (rx_sw_if_index_set == 0)
6826 errmsg ("missing rx interface name or rx_sw_if_index");
6830 if (enable && (tx_sw_if_index_set == 0))
6832 errmsg ("missing tx interface name or tx_sw_if_index");
6836 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6838 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6839 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6840 mp->enable = enable;
6848 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6850 unformat_input_t *i = vam->input;
6851 vl_api_sw_interface_set_l2_bridge_t *mp;
6852 vl_api_l2_port_type_t port_type;
6854 u8 rx_sw_if_index_set = 0;
6861 port_type = L2_API_PORT_TYPE_NORMAL;
6863 /* Parse args required to build the message */
6864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6866 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6867 rx_sw_if_index_set = 1;
6868 else if (unformat (i, "bd_id %d", &bd_id))
6872 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6873 rx_sw_if_index_set = 1;
6874 else if (unformat (i, "shg %d", &shg))
6876 else if (unformat (i, "bvi"))
6877 port_type = L2_API_PORT_TYPE_BVI;
6878 else if (unformat (i, "uu-fwd"))
6879 port_type = L2_API_PORT_TYPE_UU_FWD;
6880 else if (unformat (i, "enable"))
6882 else if (unformat (i, "disable"))
6888 if (rx_sw_if_index_set == 0)
6890 errmsg ("missing rx interface name or sw_if_index");
6894 if (enable && (bd_id_set == 0))
6896 errmsg ("missing bridge domain");
6900 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6902 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6903 mp->bd_id = ntohl (bd_id);
6905 mp->port_type = ntohl (port_type);
6906 mp->enable = enable;
6914 api_bridge_domain_dump (vat_main_t * vam)
6916 unformat_input_t *i = vam->input;
6917 vl_api_bridge_domain_dump_t *mp;
6918 vl_api_control_ping_t *mp_ping;
6922 /* Parse args required to build the message */
6923 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6925 if (unformat (i, "bd_id %d", &bd_id))
6931 M (BRIDGE_DOMAIN_DUMP, mp);
6932 mp->bd_id = ntohl (bd_id);
6935 /* Use a control ping for synchronization */
6936 MPING (CONTROL_PING, mp_ping);
6944 api_bridge_domain_add_del (vat_main_t * vam)
6946 unformat_input_t *i = vam->input;
6947 vl_api_bridge_domain_add_del_t *mp;
6950 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6955 /* Parse args required to build the message */
6956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6958 if (unformat (i, "bd_id %d", &bd_id))
6960 else if (unformat (i, "flood %d", &flood))
6962 else if (unformat (i, "uu-flood %d", &uu_flood))
6964 else if (unformat (i, "forward %d", &forward))
6966 else if (unformat (i, "learn %d", &learn))
6968 else if (unformat (i, "arp-term %d", &arp_term))
6970 else if (unformat (i, "mac-age %d", &mac_age))
6972 else if (unformat (i, "bd-tag %s", &bd_tag))
6974 else if (unformat (i, "del"))
6977 flood = uu_flood = forward = learn = 0;
6985 errmsg ("missing bridge domain");
6992 errmsg ("mac age must be less than 256 ");
6997 if ((bd_tag) && (vec_len (bd_tag) > 63))
6999 errmsg ("bd-tag cannot be longer than 63");
7004 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7006 mp->bd_id = ntohl (bd_id);
7008 mp->uu_flood = uu_flood;
7009 mp->forward = forward;
7011 mp->arp_term = arp_term;
7012 mp->is_add = is_add;
7013 mp->mac_age = (u8) mac_age;
7016 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7017 mp->bd_tag[vec_len (bd_tag)] = 0;
7028 api_l2fib_flush_bd (vat_main_t * vam)
7030 unformat_input_t *i = vam->input;
7031 vl_api_l2fib_flush_bd_t *mp;
7035 /* Parse args required to build the message */
7036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7038 if (unformat (i, "bd_id %d", &bd_id));
7045 errmsg ("missing bridge domain");
7049 M (L2FIB_FLUSH_BD, mp);
7051 mp->bd_id = htonl (bd_id);
7059 api_l2fib_flush_int (vat_main_t * vam)
7061 unformat_input_t *i = vam->input;
7062 vl_api_l2fib_flush_int_t *mp;
7063 u32 sw_if_index = ~0;
7066 /* Parse args required to build the message */
7067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7069 if (unformat (i, "sw_if_index %d", &sw_if_index));
7071 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7076 if (sw_if_index == ~0)
7078 errmsg ("missing interface name or sw_if_index");
7082 M (L2FIB_FLUSH_INT, mp);
7084 mp->sw_if_index = ntohl (sw_if_index);
7092 api_l2fib_add_del (vat_main_t * vam)
7094 unformat_input_t *i = vam->input;
7095 vl_api_l2fib_add_del_t *mp;
7101 u32 sw_if_index = 0;
7102 u8 sw_if_index_set = 0;
7111 /* Parse args required to build the message */
7112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7114 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7116 else if (unformat (i, "bd_id %d", &bd_id))
7118 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7119 sw_if_index_set = 1;
7120 else if (unformat (i, "sw_if"))
7122 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7125 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7126 sw_if_index_set = 1;
7131 else if (unformat (i, "static"))
7133 else if (unformat (i, "filter"))
7138 else if (unformat (i, "bvi"))
7143 else if (unformat (i, "del"))
7145 else if (unformat (i, "count %d", &count))
7153 errmsg ("missing mac address");
7159 errmsg ("missing bridge domain");
7163 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7165 errmsg ("missing interface name or sw_if_index");
7171 /* Turn on async mode */
7172 vam->async_mode = 1;
7173 vam->async_errors = 0;
7174 before = vat_time_now (vam);
7177 for (j = 0; j < count; j++)
7179 M (L2FIB_ADD_DEL, mp);
7181 clib_memcpy (mp->mac, mac, 6);
7182 mp->bd_id = ntohl (bd_id);
7183 mp->is_add = is_add;
7184 mp->sw_if_index = ntohl (sw_if_index);
7188 mp->static_mac = static_mac;
7189 mp->filter_mac = filter_mac;
7190 mp->bvi_mac = bvi_mac;
7192 increment_mac_address (mac);
7199 vl_api_control_ping_t *mp_ping;
7202 /* Shut off async mode */
7203 vam->async_mode = 0;
7205 MPING (CONTROL_PING, mp_ping);
7208 timeout = vat_time_now (vam) + 1.0;
7209 while (vat_time_now (vam) < timeout)
7210 if (vam->result_ready == 1)
7215 if (vam->retval == -99)
7218 if (vam->async_errors > 0)
7220 errmsg ("%d asynchronous errors", vam->async_errors);
7223 vam->async_errors = 0;
7224 after = vat_time_now (vam);
7226 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7227 count, after - before, count / (after - before));
7233 /* Wait for a reply... */
7237 /* Return the good/bad news */
7238 return (vam->retval);
7242 api_bridge_domain_set_mac_age (vat_main_t * vam)
7244 unformat_input_t *i = vam->input;
7245 vl_api_bridge_domain_set_mac_age_t *mp;
7250 /* Parse args required to build the message */
7251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7253 if (unformat (i, "bd_id %d", &bd_id));
7254 else if (unformat (i, "mac-age %d", &mac_age));
7261 errmsg ("missing bridge domain");
7267 errmsg ("mac age must be less than 256 ");
7271 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7273 mp->bd_id = htonl (bd_id);
7274 mp->mac_age = (u8) mac_age;
7282 api_l2_flags (vat_main_t * vam)
7284 unformat_input_t *i = vam->input;
7285 vl_api_l2_flags_t *mp;
7288 u8 sw_if_index_set = 0;
7292 /* Parse args required to build the message */
7293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7295 if (unformat (i, "sw_if_index %d", &sw_if_index))
7296 sw_if_index_set = 1;
7297 else if (unformat (i, "sw_if"))
7299 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7302 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7303 sw_if_index_set = 1;
7308 else if (unformat (i, "learn"))
7310 else if (unformat (i, "forward"))
7312 else if (unformat (i, "flood"))
7314 else if (unformat (i, "uu-flood"))
7315 flags |= L2_UU_FLOOD;
7316 else if (unformat (i, "arp-term"))
7317 flags |= L2_ARP_TERM;
7318 else if (unformat (i, "off"))
7320 else if (unformat (i, "disable"))
7326 if (sw_if_index_set == 0)
7328 errmsg ("missing interface name or sw_if_index");
7334 mp->sw_if_index = ntohl (sw_if_index);
7335 mp->feature_bitmap = ntohl (flags);
7336 mp->is_set = is_set;
7344 api_bridge_flags (vat_main_t * vam)
7346 unformat_input_t *i = vam->input;
7347 vl_api_bridge_flags_t *mp;
7351 bd_flags_t flags = 0;
7354 /* Parse args required to build the message */
7355 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7357 if (unformat (i, "bd_id %d", &bd_id))
7359 else if (unformat (i, "learn"))
7360 flags |= BRIDGE_API_FLAG_LEARN;
7361 else if (unformat (i, "forward"))
7362 flags |= BRIDGE_API_FLAG_FWD;
7363 else if (unformat (i, "flood"))
7364 flags |= BRIDGE_API_FLAG_FLOOD;
7365 else if (unformat (i, "uu-flood"))
7366 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7367 else if (unformat (i, "arp-term"))
7368 flags |= BRIDGE_API_FLAG_ARP_TERM;
7369 else if (unformat (i, "off"))
7371 else if (unformat (i, "disable"))
7379 errmsg ("missing bridge domain");
7383 M (BRIDGE_FLAGS, mp);
7385 mp->bd_id = ntohl (bd_id);
7386 mp->flags = ntohl (flags);
7387 mp->is_set = is_set;
7395 api_bd_ip_mac_add_del (vat_main_t * vam)
7397 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7398 vl_api_mac_address_t mac = { 0 };
7399 unformat_input_t *i = vam->input;
7400 vl_api_bd_ip_mac_add_del_t *mp;
7412 /* Parse args required to build the message */
7413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7415 if (unformat (i, "bd_id %d", &bd_id))
7419 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7423 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7427 else if (unformat (i, "del"))
7435 errmsg ("missing bridge domain");
7438 else if (ip_set == 0)
7440 errmsg ("missing IP address");
7443 else if (mac_set == 0)
7445 errmsg ("missing MAC address");
7449 M (BD_IP_MAC_ADD_DEL, mp);
7451 mp->bd_id = ntohl (bd_id);
7452 mp->is_add = is_add;
7454 clib_memcpy (&mp->ip, &ip, sizeof (ip));
7455 clib_memcpy (&mp->mac, &mac, sizeof (mac));
7463 api_bd_ip_mac_flush (vat_main_t * vam)
7465 unformat_input_t *i = vam->input;
7466 vl_api_bd_ip_mac_flush_t *mp;
7471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7473 if (unformat (i, "bd_id %d", &bd_id))
7483 errmsg ("missing bridge domain");
7487 M (BD_IP_MAC_FLUSH, mp);
7489 mp->bd_id = ntohl (bd_id);
7496 static void vl_api_bd_ip_mac_details_t_handler
7497 (vl_api_bd_ip_mac_details_t * mp)
7499 vat_main_t *vam = &vat_main;
7504 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7507 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7510 "\n%-5d %-7s %-20U %-30s",
7511 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7512 format_ethernet_address, mp->mac_address, ip);
7517 static void vl_api_bd_ip_mac_details_t_handler_json
7518 (vl_api_bd_ip_mac_details_t * mp)
7520 vat_main_t *vam = &vat_main;
7521 vat_json_node_t *node = NULL;
7523 if (VAT_JSON_ARRAY != vam->json_tree.type)
7525 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7526 vat_json_init_array (&vam->json_tree);
7528 node = vat_json_array_add (&vam->json_tree);
7530 vat_json_init_object (node);
7531 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7532 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7533 vat_json_object_add_string_copy (node, "mac_address",
7534 format (0, "%U", format_ethernet_address,
7540 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7543 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7544 vat_json_object_add_string_copy (node, "ip_address", ip);
7549 api_bd_ip_mac_dump (vat_main_t * vam)
7551 unformat_input_t *i = vam->input;
7552 vl_api_bd_ip_mac_dump_t *mp;
7553 vl_api_control_ping_t *mp_ping;
7558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7560 if (unformat (i, "bd_id %d", &bd_id))
7569 "\n%-5s %-7s %-20s %-30s",
7570 "bd_id", "is_ipv6", "mac_address", "ip_address");
7572 /* Dump Bridge Domain Ip to Mac entries */
7573 M (BD_IP_MAC_DUMP, mp);
7576 mp->bd_id = htonl (bd_id);
7582 /* Use a control ping for synchronization */
7583 MPING (CONTROL_PING, mp_ping);
7591 api_tap_connect (vat_main_t * vam)
7593 unformat_input_t *i = vam->input;
7594 vl_api_tap_connect_t *mp;
7600 ip4_address_t ip4_address;
7602 int ip4_address_set = 0;
7603 ip6_address_t ip6_address;
7605 int ip6_address_set = 0;
7608 clib_memset (mac_address, 0, sizeof (mac_address));
7610 /* Parse args required to build the message */
7611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7613 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7617 else if (unformat (i, "random-mac"))
7619 else if (unformat (i, "tapname %s", &tap_name))
7621 else if (unformat (i, "tag %s", &tag))
7623 else if (unformat (i, "address %U/%d",
7624 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7625 ip4_address_set = 1;
7626 else if (unformat (i, "address %U/%d",
7627 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7628 ip6_address_set = 1;
7635 errmsg ("missing tap name");
7638 if (vec_len (tap_name) > 63)
7640 errmsg ("tap name too long");
7643 vec_add1 (tap_name, 0);
7645 if (vec_len (tag) > 63)
7647 errmsg ("tag too long");
7651 /* Construct the API message */
7652 M (TAP_CONNECT, mp);
7654 mp->use_random_mac = random_mac;
7655 clib_memcpy (mp->mac_address, mac_address, 6);
7656 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7658 clib_memcpy (mp->tag, tag, vec_len (tag));
7660 if (ip4_address_set)
7662 mp->ip4_address_set = 1;
7663 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7664 mp->ip4_mask_width = ip4_mask_width;
7666 if (ip6_address_set)
7668 mp->ip6_address_set = 1;
7669 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7670 mp->ip6_mask_width = ip6_mask_width;
7673 vec_free (tap_name);
7679 /* Wait for a reply... */
7685 api_tap_modify (vat_main_t * vam)
7687 unformat_input_t *i = vam->input;
7688 vl_api_tap_modify_t *mp;
7693 u32 sw_if_index = ~0;
7694 u8 sw_if_index_set = 0;
7697 clib_memset (mac_address, 0, sizeof (mac_address));
7699 /* Parse args required to build the message */
7700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7702 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7703 sw_if_index_set = 1;
7704 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7705 sw_if_index_set = 1;
7706 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7710 else if (unformat (i, "random-mac"))
7712 else if (unformat (i, "tapname %s", &tap_name))
7718 if (sw_if_index_set == 0)
7720 errmsg ("missing vpp interface name");
7725 errmsg ("missing tap name");
7728 if (vec_len (tap_name) > 63)
7730 errmsg ("tap name too long");
7732 vec_add1 (tap_name, 0);
7734 /* Construct the API message */
7737 mp->use_random_mac = random_mac;
7738 mp->sw_if_index = ntohl (sw_if_index);
7739 clib_memcpy (mp->mac_address, mac_address, 6);
7740 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7741 vec_free (tap_name);
7746 /* Wait for a reply... */
7752 api_tap_delete (vat_main_t * vam)
7754 unformat_input_t *i = vam->input;
7755 vl_api_tap_delete_t *mp;
7756 u32 sw_if_index = ~0;
7757 u8 sw_if_index_set = 0;
7760 /* Parse args required to build the message */
7761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7763 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7764 sw_if_index_set = 1;
7765 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7766 sw_if_index_set = 1;
7771 if (sw_if_index_set == 0)
7773 errmsg ("missing vpp interface name");
7777 /* Construct the API message */
7780 mp->sw_if_index = ntohl (sw_if_index);
7785 /* Wait for a reply... */
7791 api_tap_create_v2 (vat_main_t * vam)
7793 unformat_input_t *i = vam->input;
7794 vl_api_tap_create_v2_t *mp;
7798 u8 *host_if_name = 0;
7800 u8 host_mac_addr[6];
7801 u8 host_mac_addr_set = 0;
7802 u8 *host_bridge = 0;
7803 ip4_address_t host_ip4_addr;
7804 ip4_address_t host_ip4_gw;
7805 u8 host_ip4_gw_set = 0;
7806 u32 host_ip4_prefix_len = 0;
7807 ip6_address_t host_ip6_addr;
7808 ip6_address_t host_ip6_gw;
7809 u8 host_ip6_gw_set = 0;
7810 u32 host_ip6_prefix_len = 0;
7812 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7814 clib_memset (mac_address, 0, sizeof (mac_address));
7816 /* Parse args required to build the message */
7817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7819 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7823 else if (unformat (i, "id %u", &id))
7825 else if (unformat (i, "host-if-name %s", &host_if_name))
7827 else if (unformat (i, "host-ns %s", &host_ns))
7829 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7831 host_mac_addr_set = 1;
7832 else if (unformat (i, "host-bridge %s", &host_bridge))
7834 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7835 &host_ip4_addr, &host_ip4_prefix_len))
7837 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7838 &host_ip6_addr, &host_ip6_prefix_len))
7840 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7842 host_ip4_gw_set = 1;
7843 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7845 host_ip6_gw_set = 1;
7846 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7848 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7854 if (vec_len (host_if_name) > 63)
7856 errmsg ("tap name too long. ");
7859 if (vec_len (host_ns) > 63)
7861 errmsg ("host name space too long. ");
7864 if (vec_len (host_bridge) > 63)
7866 errmsg ("host bridge name too long. ");
7869 if (host_ip4_prefix_len > 32)
7871 errmsg ("host ip4 prefix length not valid. ");
7874 if (host_ip6_prefix_len > 128)
7876 errmsg ("host ip6 prefix length not valid. ");
7879 if (!is_pow2 (rx_ring_sz))
7881 errmsg ("rx ring size must be power of 2. ");
7884 if (rx_ring_sz > 32768)
7886 errmsg ("rx ring size must be 32768 or lower. ");
7889 if (!is_pow2 (tx_ring_sz))
7891 errmsg ("tx ring size must be power of 2. ");
7894 if (tx_ring_sz > 32768)
7896 errmsg ("tx ring size must be 32768 or lower. ");
7900 /* Construct the API message */
7901 M (TAP_CREATE_V2, mp);
7903 mp->use_random_mac = random_mac;
7905 mp->id = ntohl (id);
7906 mp->host_namespace_set = host_ns != 0;
7907 mp->host_bridge_set = host_bridge != 0;
7908 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7909 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7910 mp->rx_ring_sz = ntohs (rx_ring_sz);
7911 mp->tx_ring_sz = ntohs (tx_ring_sz);
7913 if (random_mac == 0)
7914 clib_memcpy (mp->mac_address, mac_address, 6);
7915 if (host_mac_addr_set)
7916 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7918 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7920 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7922 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7923 if (host_ip4_prefix_len)
7924 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7925 if (host_ip6_prefix_len)
7926 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7927 if (host_ip4_gw_set)
7928 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7929 if (host_ip6_gw_set)
7930 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7933 vec_free (host_if_name);
7934 vec_free (host_bridge);
7939 /* Wait for a reply... */
7945 api_tap_delete_v2 (vat_main_t * vam)
7947 unformat_input_t *i = vam->input;
7948 vl_api_tap_delete_v2_t *mp;
7949 u32 sw_if_index = ~0;
7950 u8 sw_if_index_set = 0;
7953 /* Parse args required to build the message */
7954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7956 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7957 sw_if_index_set = 1;
7958 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7959 sw_if_index_set = 1;
7964 if (sw_if_index_set == 0)
7966 errmsg ("missing vpp interface name. ");
7970 /* Construct the API message */
7971 M (TAP_DELETE_V2, mp);
7973 mp->sw_if_index = ntohl (sw_if_index);
7978 /* Wait for a reply... */
7984 unformat_pci_addr (unformat_input_t * input, va_list * args)
7993 addr = va_arg (*args, struct pci_addr_t *);
7996 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7999 addr->domain = x[0];
8002 addr->function = x[3];
8008 api_virtio_pci_create (vat_main_t * vam)
8010 unformat_input_t *i = vam->input;
8011 vl_api_virtio_pci_create_t *mp;
8015 u64 features = (u64) ~ (0ULL);
8016 u32 rx_ring_sz = 0, tx_ring_sz = 0;
8019 clib_memset (mac_address, 0, sizeof (mac_address));
8021 /* Parse args required to build the message */
8022 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8024 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8028 else if (unformat (i, "pci-addr %U", unformat_pci_addr, &pci_addr))
8030 else if (unformat (i, "features 0x%llx", &features))
8032 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
8034 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
8042 errmsg ("pci address must be non zero. ");
8045 if (!is_pow2 (rx_ring_sz))
8047 errmsg ("rx ring size must be power of 2. ");
8050 if (rx_ring_sz > 32768)
8052 errmsg ("rx ring size must be 32768 or lower. ");
8055 if (!is_pow2 (tx_ring_sz))
8057 errmsg ("tx ring size must be power of 2. ");
8060 if (tx_ring_sz > 32768)
8062 errmsg ("tx ring size must be 32768 or lower. ");
8066 /* Construct the API message */
8067 M (VIRTIO_PCI_CREATE, mp);
8069 mp->use_random_mac = random_mac;
8071 mp->pci_addr = htonl (pci_addr);
8072 mp->features = clib_host_to_net_u64 (features);
8073 mp->rx_ring_sz = htons (rx_ring_sz);
8074 mp->tx_ring_sz = htons (tx_ring_sz);
8076 if (random_mac == 0)
8077 clib_memcpy (mp->mac_address, mac_address, 6);
8082 /* Wait for a reply... */
8088 api_virtio_pci_delete (vat_main_t * vam)
8090 unformat_input_t *i = vam->input;
8091 vl_api_virtio_pci_delete_t *mp;
8092 u32 sw_if_index = ~0;
8093 u8 sw_if_index_set = 0;
8096 /* Parse args required to build the message */
8097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8099 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8100 sw_if_index_set = 1;
8101 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8102 sw_if_index_set = 1;
8107 if (sw_if_index_set == 0)
8109 errmsg ("missing vpp interface name. ");
8113 /* Construct the API message */
8114 M (VIRTIO_PCI_DELETE, mp);
8116 mp->sw_if_index = htonl (sw_if_index);
8121 /* Wait for a reply... */
8127 api_bond_create (vat_main_t * vam)
8129 unformat_input_t *i = vam->input;
8130 vl_api_bond_create_t *mp;
8139 clib_memset (mac_address, 0, sizeof (mac_address));
8142 /* Parse args required to build the message */
8143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8145 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8147 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8148 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8150 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8153 else if (unformat (i, "id %u", &id))
8159 if (mode_is_set == 0)
8161 errmsg ("Missing bond mode. ");
8165 /* Construct the API message */
8166 M (BOND_CREATE, mp);
8168 mp->use_custom_mac = custom_mac;
8172 mp->id = htonl (id);
8175 clib_memcpy (mp->mac_address, mac_address, 6);
8180 /* Wait for a reply... */
8186 api_bond_delete (vat_main_t * vam)
8188 unformat_input_t *i = vam->input;
8189 vl_api_bond_delete_t *mp;
8190 u32 sw_if_index = ~0;
8191 u8 sw_if_index_set = 0;
8194 /* Parse args required to build the message */
8195 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8197 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8198 sw_if_index_set = 1;
8199 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8200 sw_if_index_set = 1;
8205 if (sw_if_index_set == 0)
8207 errmsg ("missing vpp interface name. ");
8211 /* Construct the API message */
8212 M (BOND_DELETE, mp);
8214 mp->sw_if_index = ntohl (sw_if_index);
8219 /* Wait for a reply... */
8225 api_bond_enslave (vat_main_t * vam)
8227 unformat_input_t *i = vam->input;
8228 vl_api_bond_enslave_t *mp;
8229 u32 bond_sw_if_index;
8233 u32 bond_sw_if_index_is_set = 0;
8235 u8 sw_if_index_is_set = 0;
8237 /* Parse args required to build the message */
8238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8240 if (unformat (i, "sw_if_index %d", &sw_if_index))
8241 sw_if_index_is_set = 1;
8242 else if (unformat (i, "bond %u", &bond_sw_if_index))
8243 bond_sw_if_index_is_set = 1;
8244 else if (unformat (i, "passive %d", &is_passive))
8246 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8252 if (bond_sw_if_index_is_set == 0)
8254 errmsg ("Missing bond sw_if_index. ");
8257 if (sw_if_index_is_set == 0)
8259 errmsg ("Missing slave sw_if_index. ");
8263 /* Construct the API message */
8264 M (BOND_ENSLAVE, mp);
8266 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8267 mp->sw_if_index = ntohl (sw_if_index);
8268 mp->is_long_timeout = is_long_timeout;
8269 mp->is_passive = is_passive;
8274 /* Wait for a reply... */
8280 api_bond_detach_slave (vat_main_t * vam)
8282 unformat_input_t *i = vam->input;
8283 vl_api_bond_detach_slave_t *mp;
8284 u32 sw_if_index = ~0;
8285 u8 sw_if_index_set = 0;
8288 /* Parse args required to build the message */
8289 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8291 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8292 sw_if_index_set = 1;
8293 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8294 sw_if_index_set = 1;
8299 if (sw_if_index_set == 0)
8301 errmsg ("missing vpp interface name. ");
8305 /* Construct the API message */
8306 M (BOND_DETACH_SLAVE, mp);
8308 mp->sw_if_index = ntohl (sw_if_index);
8313 /* Wait for a reply... */
8319 api_ip_table_add_del (vat_main_t * vam)
8321 unformat_input_t *i = vam->input;
8322 vl_api_ip_table_add_del_t *mp;
8328 /* Parse args required to build the message */
8329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8331 if (unformat (i, "ipv6"))
8333 else if (unformat (i, "del"))
8335 else if (unformat (i, "add"))
8337 else if (unformat (i, "table %d", &table_id))
8341 clib_warning ("parse error '%U'", format_unformat_error, i);
8348 errmsg ("missing table-ID");
8352 /* Construct the API message */
8353 M (IP_TABLE_ADD_DEL, mp);
8355 mp->table_id = ntohl (table_id);
8356 mp->is_ipv6 = is_ipv6;
8357 mp->is_add = is_add;
8362 /* Wait for a reply... */
8369 api_ip_add_del_route (vat_main_t * vam)
8371 unformat_input_t *i = vam->input;
8372 vl_api_ip_add_del_route_t *mp;
8373 u32 sw_if_index = ~0, vrf_id = 0;
8375 u8 is_local = 0, is_drop = 0;
8376 u8 is_unreach = 0, is_prohibit = 0;
8378 u32 next_hop_weight = 1;
8379 u8 is_multipath = 0;
8381 u8 address_length_set = 0;
8382 u32 next_hop_table_id = 0;
8383 u32 resolve_attempts = 0;
8384 u32 dst_address_length = 0;
8385 u8 next_hop_set = 0;
8386 ip4_address_t v4_dst_address, v4_next_hop_address;
8387 ip6_address_t v6_dst_address, v6_next_hop_address;
8391 u32 random_add_del = 0;
8392 u32 *random_vector = 0;
8394 u32 random_seed = 0xdeaddabe;
8395 u32 classify_table_index = ~0;
8397 u8 resolve_host = 0, resolve_attached = 0;
8398 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8399 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8400 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8402 clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8403 clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8404 /* Parse args required to build the message */
8405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8407 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8409 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8411 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8416 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8421 else if (unformat (i, "/%d", &dst_address_length))
8423 address_length_set = 1;
8426 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8427 &v4_next_hop_address))
8431 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8432 &v6_next_hop_address))
8438 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8442 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8446 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8448 else if (unformat (i, "weight %d", &next_hop_weight))
8450 else if (unformat (i, "drop"))
8454 else if (unformat (i, "null-send-unreach"))
8458 else if (unformat (i, "null-send-prohibit"))
8462 else if (unformat (i, "local"))
8466 else if (unformat (i, "classify %d", &classify_table_index))
8470 else if (unformat (i, "del"))
8472 else if (unformat (i, "add"))
8474 else if (unformat (i, "resolve-via-host"))
8476 else if (unformat (i, "resolve-via-attached"))
8477 resolve_attached = 1;
8478 else if (unformat (i, "multipath"))
8480 else if (unformat (i, "vrf %d", &vrf_id))
8482 else if (unformat (i, "count %d", &count))
8484 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8486 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8488 else if (unformat (i, "out-label %d", &next_hop_out_label))
8490 vl_api_fib_mpls_label_t fib_label = {
8491 .label = ntohl (next_hop_out_label),
8495 vec_add1 (next_hop_out_label_stack, fib_label);
8497 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8499 else if (unformat (i, "random"))
8501 else if (unformat (i, "seed %d", &random_seed))
8505 clib_warning ("parse error '%U'", format_unformat_error, i);
8510 if (!next_hop_set && !is_drop && !is_local &&
8511 !is_classify && !is_unreach && !is_prohibit &&
8512 MPLS_LABEL_INVALID == next_hop_via_label)
8515 ("next hop / local / drop / unreach / prohibit / classify not set");
8519 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8521 errmsg ("next hop and next-hop via label set");
8524 if (address_set == 0)
8526 errmsg ("missing addresses");
8530 if (address_length_set == 0)
8532 errmsg ("missing address length");
8536 /* Generate a pile of unique, random routes */
8539 u32 this_random_address;
8540 random_hash = hash_create (count, sizeof (uword));
8542 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8543 for (j = 0; j <= count; j++)
8547 this_random_address = random_u32 (&random_seed);
8548 this_random_address =
8549 clib_host_to_net_u32 (this_random_address);
8551 while (hash_get (random_hash, this_random_address));
8552 vec_add1 (random_vector, this_random_address);
8553 hash_set (random_hash, this_random_address, 1);
8555 hash_free (random_hash);
8556 v4_dst_address.as_u32 = random_vector[0];
8561 /* Turn on async mode */
8562 vam->async_mode = 1;
8563 vam->async_errors = 0;
8564 before = vat_time_now (vam);
8567 for (j = 0; j < count; j++)
8569 /* Construct the API message */
8570 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8571 vec_len (next_hop_out_label_stack));
8573 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8574 mp->table_id = ntohl (vrf_id);
8576 mp->is_add = is_add;
8577 mp->is_drop = is_drop;
8578 mp->is_unreach = is_unreach;
8579 mp->is_prohibit = is_prohibit;
8580 mp->is_ipv6 = is_ipv6;
8581 mp->is_local = is_local;
8582 mp->is_classify = is_classify;
8583 mp->is_multipath = is_multipath;
8584 mp->is_resolve_host = resolve_host;
8585 mp->is_resolve_attached = resolve_attached;
8586 mp->next_hop_weight = next_hop_weight;
8587 mp->next_hop_preference = 0;
8588 mp->dst_address_length = dst_address_length;
8589 mp->next_hop_table_id = ntohl (next_hop_table_id);
8590 mp->classify_table_index = ntohl (classify_table_index);
8591 mp->next_hop_via_label = ntohl (next_hop_via_label);
8592 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8593 if (0 != mp->next_hop_n_out_labels)
8595 memcpy (mp->next_hop_out_label_stack,
8596 next_hop_out_label_stack,
8597 (vec_len (next_hop_out_label_stack) *
8598 sizeof (vl_api_fib_mpls_label_t)));
8599 vec_free (next_hop_out_label_stack);
8604 clib_memcpy (mp->dst_address, &v6_dst_address,
8605 sizeof (v6_dst_address));
8607 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8608 sizeof (v6_next_hop_address));
8609 increment_v6_address (&v6_dst_address);
8613 clib_memcpy (mp->dst_address, &v4_dst_address,
8614 sizeof (v4_dst_address));
8616 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8617 sizeof (v4_next_hop_address));
8619 v4_dst_address.as_u32 = random_vector[j + 1];
8621 increment_v4_address (&v4_dst_address);
8625 /* If we receive SIGTERM, stop now... */
8630 /* When testing multiple add/del ops, use a control-ping to sync */
8633 vl_api_control_ping_t *mp_ping;
8637 /* Shut off async mode */
8638 vam->async_mode = 0;
8640 MPING (CONTROL_PING, mp_ping);
8643 timeout = vat_time_now (vam) + 1.0;
8644 while (vat_time_now (vam) < timeout)
8645 if (vam->result_ready == 1)
8650 if (vam->retval == -99)
8653 if (vam->async_errors > 0)
8655 errmsg ("%d asynchronous errors", vam->async_errors);
8658 vam->async_errors = 0;
8659 after = vat_time_now (vam);
8661 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8665 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8666 count, after - before, count / (after - before));
8672 /* Wait for a reply... */
8677 /* Return the good/bad news */
8678 return (vam->retval);
8682 api_ip_mroute_add_del (vat_main_t * vam)
8684 unformat_input_t *i = vam->input;
8685 vl_api_ip_mroute_add_del_t *mp;
8686 u32 sw_if_index = ~0, vrf_id = 0;
8691 u32 grp_address_length = 0;
8692 ip4_address_t v4_grp_address, v4_src_address;
8693 ip6_address_t v6_grp_address, v6_src_address;
8694 mfib_itf_flags_t iflags = 0;
8695 mfib_entry_flags_t eflags = 0;
8698 /* Parse args required to build the message */
8699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8701 if (unformat (i, "sw_if_index %d", &sw_if_index))
8703 else if (unformat (i, "%U %U",
8704 unformat_ip4_address, &v4_src_address,
8705 unformat_ip4_address, &v4_grp_address))
8707 grp_address_length = 64;
8711 else if (unformat (i, "%U %U",
8712 unformat_ip6_address, &v6_src_address,
8713 unformat_ip6_address, &v6_grp_address))
8715 grp_address_length = 256;
8719 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8721 clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
8722 grp_address_length = 32;
8726 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8728 clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
8729 grp_address_length = 128;
8733 else if (unformat (i, "/%d", &grp_address_length))
8735 else if (unformat (i, "local"))
8739 else if (unformat (i, "del"))
8741 else if (unformat (i, "add"))
8743 else if (unformat (i, "vrf %d", &vrf_id))
8745 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8747 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8751 clib_warning ("parse error '%U'", format_unformat_error, i);
8756 if (address_set == 0)
8758 errmsg ("missing addresses\n");
8762 /* Construct the API message */
8763 M (IP_MROUTE_ADD_DEL, mp);
8765 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8766 mp->table_id = ntohl (vrf_id);
8768 mp->is_add = is_add;
8769 mp->is_ipv6 = is_ipv6;
8770 mp->is_local = is_local;
8771 mp->itf_flags = ntohl (iflags);
8772 mp->entry_flags = ntohl (eflags);
8773 mp->grp_address_length = grp_address_length;
8774 mp->grp_address_length = ntohs (mp->grp_address_length);
8778 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8779 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8783 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8784 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8790 /* Wait for a reply... */
8796 api_mpls_table_add_del (vat_main_t * vam)
8798 unformat_input_t *i = vam->input;
8799 vl_api_mpls_table_add_del_t *mp;
8804 /* Parse args required to build the message */
8805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8807 if (unformat (i, "table %d", &table_id))
8809 else if (unformat (i, "del"))
8811 else if (unformat (i, "add"))
8815 clib_warning ("parse error '%U'", format_unformat_error, i);
8822 errmsg ("missing table-ID");
8826 /* Construct the API message */
8827 M (MPLS_TABLE_ADD_DEL, mp);
8829 mp->mt_table_id = ntohl (table_id);
8830 mp->mt_is_add = is_add;
8835 /* Wait for a reply... */
8842 api_mpls_route_add_del (vat_main_t * vam)
8844 unformat_input_t *i = vam->input;
8845 vl_api_mpls_route_add_del_t *mp;
8846 u32 sw_if_index = ~0, table_id = 0;
8848 u32 next_hop_weight = 1;
8849 u8 is_multipath = 0;
8850 u32 next_hop_table_id = 0;
8851 u8 next_hop_set = 0;
8852 ip4_address_t v4_next_hop_address = {
8855 ip6_address_t v6_next_hop_address = { {0} };
8859 u32 classify_table_index = ~0;
8861 u8 resolve_host = 0, resolve_attached = 0;
8862 u8 is_interface_rx = 0;
8863 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8864 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8865 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8866 mpls_label_t local_label = MPLS_LABEL_INVALID;
8868 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
8870 /* Parse args required to build the message */
8871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8873 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8875 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8877 else if (unformat (i, "%d", &local_label))
8879 else if (unformat (i, "eos"))
8881 else if (unformat (i, "non-eos"))
8883 else if (unformat (i, "via %U", unformat_ip4_address,
8884 &v4_next_hop_address))
8887 next_hop_proto = DPO_PROTO_IP4;
8889 else if (unformat (i, "via %U", unformat_ip6_address,
8890 &v6_next_hop_address))
8893 next_hop_proto = DPO_PROTO_IP6;
8895 else if (unformat (i, "weight %d", &next_hop_weight))
8897 else if (unformat (i, "classify %d", &classify_table_index))
8901 else if (unformat (i, "del"))
8903 else if (unformat (i, "add"))
8905 else if (unformat (i, "resolve-via-host"))
8907 else if (unformat (i, "resolve-via-attached"))
8908 resolve_attached = 1;
8909 else if (unformat (i, "multipath"))
8911 else if (unformat (i, "count %d", &count))
8913 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
8916 next_hop_proto = DPO_PROTO_IP4;
8918 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
8921 next_hop_proto = DPO_PROTO_IP6;
8925 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
8929 next_hop_proto = DPO_PROTO_ETHERNET;
8930 is_interface_rx = 1;
8932 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
8935 next_hop_proto = DPO_PROTO_ETHERNET;
8936 is_interface_rx = 1;
8938 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
8940 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8942 else if (unformat (i, "out-label %d", &next_hop_out_label))
8944 vl_api_fib_mpls_label_t fib_label = {
8945 .label = ntohl (next_hop_out_label),
8949 vec_add1 (next_hop_out_label_stack, fib_label);
8953 clib_warning ("parse error '%U'", format_unformat_error, i);
8958 if (!next_hop_set && !is_classify)
8960 errmsg ("next hop / classify not set");
8964 if (MPLS_LABEL_INVALID == local_label)
8966 errmsg ("missing label");
8972 /* Turn on async mode */
8973 vam->async_mode = 1;
8974 vam->async_errors = 0;
8975 before = vat_time_now (vam);
8978 for (j = 0; j < count; j++)
8980 /* Construct the API message */
8981 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
8982 vec_len (next_hop_out_label_stack));
8984 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8985 mp->mr_table_id = ntohl (table_id);
8987 mp->mr_is_add = is_add;
8988 mp->mr_next_hop_proto = next_hop_proto;
8989 mp->mr_is_classify = is_classify;
8990 mp->mr_is_multipath = is_multipath;
8991 mp->mr_is_resolve_host = resolve_host;
8992 mp->mr_is_resolve_attached = resolve_attached;
8993 mp->mr_is_interface_rx = is_interface_rx;
8994 mp->mr_next_hop_weight = next_hop_weight;
8995 mp->mr_next_hop_preference = 0;
8996 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8997 mp->mr_classify_table_index = ntohl (classify_table_index);
8998 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8999 mp->mr_label = ntohl (local_label);
9000 mp->mr_eos = is_eos;
9002 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9003 if (0 != mp->mr_next_hop_n_out_labels)
9005 memcpy (mp->mr_next_hop_out_label_stack,
9006 next_hop_out_label_stack,
9007 vec_len (next_hop_out_label_stack) *
9008 sizeof (vl_api_fib_mpls_label_t));
9009 vec_free (next_hop_out_label_stack);
9014 if (DPO_PROTO_IP4 == next_hop_proto)
9016 clib_memcpy (mp->mr_next_hop,
9017 &v4_next_hop_address,
9018 sizeof (v4_next_hop_address));
9020 else if (DPO_PROTO_IP6 == next_hop_proto)
9023 clib_memcpy (mp->mr_next_hop,
9024 &v6_next_hop_address,
9025 sizeof (v6_next_hop_address));
9032 /* If we receive SIGTERM, stop now... */
9037 /* When testing multiple add/del ops, use a control-ping to sync */
9040 vl_api_control_ping_t *mp_ping;
9044 /* Shut off async mode */
9045 vam->async_mode = 0;
9047 MPING (CONTROL_PING, mp_ping);
9050 timeout = vat_time_now (vam) + 1.0;
9051 while (vat_time_now (vam) < timeout)
9052 if (vam->result_ready == 1)
9057 if (vam->retval == -99)
9060 if (vam->async_errors > 0)
9062 errmsg ("%d asynchronous errors", vam->async_errors);
9065 vam->async_errors = 0;
9066 after = vat_time_now (vam);
9068 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9072 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9073 count, after - before, count / (after - before));
9079 /* Wait for a reply... */
9084 /* Return the good/bad news */
9085 return (vam->retval);
9089 api_mpls_ip_bind_unbind (vat_main_t * vam)
9091 unformat_input_t *i = vam->input;
9092 vl_api_mpls_ip_bind_unbind_t *mp;
9093 u32 ip_table_id = 0;
9096 ip4_address_t v4_address;
9097 ip6_address_t v6_address;
9100 mpls_label_t local_label = MPLS_LABEL_INVALID;
9103 /* Parse args required to build the message */
9104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9106 if (unformat (i, "%U/%d", unformat_ip4_address,
9107 &v4_address, &address_length))
9112 else if (unformat (i, "%U/%d", unformat_ip6_address,
9113 &v6_address, &address_length))
9118 else if (unformat (i, "%d", &local_label))
9120 else if (unformat (i, "table-id %d", &ip_table_id))
9122 else if (unformat (i, "unbind"))
9124 else if (unformat (i, "bind"))
9128 clib_warning ("parse error '%U'", format_unformat_error, i);
9135 errmsg ("IP address not set");
9139 if (MPLS_LABEL_INVALID == local_label)
9141 errmsg ("missing label");
9145 /* Construct the API message */
9146 M (MPLS_IP_BIND_UNBIND, mp);
9148 mp->mb_is_bind = is_bind;
9149 mp->mb_is_ip4 = is_ip4;
9150 mp->mb_ip_table_id = ntohl (ip_table_id);
9151 mp->mb_mpls_table_id = 0;
9152 mp->mb_label = ntohl (local_label);
9153 mp->mb_address_length = address_length;
9156 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9158 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9163 /* Wait for a reply... */
9169 api_sr_mpls_policy_add (vat_main_t * vam)
9171 unformat_input_t *i = vam->input;
9172 vl_api_sr_mpls_policy_add_t *mp;
9178 u32 *segments = NULL;
9181 /* Parse args required to build the message */
9182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9184 if (unformat (i, "bsid %d", &bsid))
9186 else if (unformat (i, "weight %d", &weight))
9188 else if (unformat (i, "spray"))
9190 else if (unformat (i, "next %d", &sid))
9193 vec_add1 (segments, htonl (sid));
9197 clib_warning ("parse error '%U'", format_unformat_error, i);
9204 errmsg ("bsid not set");
9208 if (n_segments == 0)
9210 errmsg ("no sid in segment stack");
9214 /* Construct the API message */
9215 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
9217 mp->bsid = htonl (bsid);
9218 mp->weight = htonl (weight);
9220 mp->n_segments = n_segments;
9221 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
9222 vec_free (segments);
9227 /* Wait for a reply... */
9233 api_sr_mpls_policy_del (vat_main_t * vam)
9235 unformat_input_t *i = vam->input;
9236 vl_api_sr_mpls_policy_del_t *mp;
9240 /* Parse args required to build the message */
9241 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9243 if (unformat (i, "bsid %d", &bsid))
9247 clib_warning ("parse error '%U'", format_unformat_error, i);
9254 errmsg ("bsid not set");
9258 /* Construct the API message */
9259 M (SR_MPLS_POLICY_DEL, mp);
9261 mp->bsid = htonl (bsid);
9266 /* Wait for a reply... */
9272 api_bier_table_add_del (vat_main_t * vam)
9274 unformat_input_t *i = vam->input;
9275 vl_api_bier_table_add_del_t *mp;
9277 u32 set = 0, sub_domain = 0, hdr_len = 3;
9278 mpls_label_t local_label = MPLS_LABEL_INVALID;
9281 /* Parse args required to build the message */
9282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9284 if (unformat (i, "sub-domain %d", &sub_domain))
9286 else if (unformat (i, "set %d", &set))
9288 else if (unformat (i, "label %d", &local_label))
9290 else if (unformat (i, "hdr-len %d", &hdr_len))
9292 else if (unformat (i, "add"))
9294 else if (unformat (i, "del"))
9298 clib_warning ("parse error '%U'", format_unformat_error, i);
9303 if (MPLS_LABEL_INVALID == local_label)
9305 errmsg ("missing label\n");
9309 /* Construct the API message */
9310 M (BIER_TABLE_ADD_DEL, mp);
9312 mp->bt_is_add = is_add;
9313 mp->bt_label = ntohl (local_label);
9314 mp->bt_tbl_id.bt_set = set;
9315 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9316 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9321 /* Wait for a reply... */
9328 api_bier_route_add_del (vat_main_t * vam)
9330 unformat_input_t *i = vam->input;
9331 vl_api_bier_route_add_del_t *mp;
9333 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9334 ip4_address_t v4_next_hop_address;
9335 ip6_address_t v6_next_hop_address;
9336 u8 next_hop_set = 0;
9337 u8 next_hop_proto_is_ip4 = 1;
9338 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9341 /* Parse args required to build the message */
9342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9344 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9346 next_hop_proto_is_ip4 = 1;
9349 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9351 next_hop_proto_is_ip4 = 0;
9354 if (unformat (i, "sub-domain %d", &sub_domain))
9356 else if (unformat (i, "set %d", &set))
9358 else if (unformat (i, "hdr-len %d", &hdr_len))
9360 else if (unformat (i, "bp %d", &bp))
9362 else if (unformat (i, "add"))
9364 else if (unformat (i, "del"))
9366 else if (unformat (i, "out-label %d", &next_hop_out_label))
9370 clib_warning ("parse error '%U'", format_unformat_error, i);
9375 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9377 errmsg ("next hop / label set\n");
9382 errmsg ("bit=position not set\n");
9386 /* Construct the API message */
9387 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9389 mp->br_is_add = is_add;
9390 mp->br_tbl_id.bt_set = set;
9391 mp->br_tbl_id.bt_sub_domain = sub_domain;
9392 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9393 mp->br_bp = ntohs (bp);
9395 mp->br_paths[0].n_labels = 1;
9396 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9397 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9399 if (next_hop_proto_is_ip4)
9401 clib_memcpy (mp->br_paths[0].next_hop,
9402 &v4_next_hop_address, sizeof (v4_next_hop_address));
9406 clib_memcpy (mp->br_paths[0].next_hop,
9407 &v6_next_hop_address, sizeof (v6_next_hop_address));
9413 /* Wait for a reply... */
9420 api_proxy_arp_add_del (vat_main_t * vam)
9422 unformat_input_t *i = vam->input;
9423 vl_api_proxy_arp_add_del_t *mp;
9426 ip4_address_t lo, hi;
9430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9432 if (unformat (i, "vrf %d", &vrf_id))
9434 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9435 unformat_ip4_address, &hi))
9437 else if (unformat (i, "del"))
9441 clib_warning ("parse error '%U'", format_unformat_error, i);
9448 errmsg ("address range not set");
9452 M (PROXY_ARP_ADD_DEL, mp);
9454 mp->proxy.vrf_id = ntohl (vrf_id);
9455 mp->is_add = is_add;
9456 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9457 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9465 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9467 unformat_input_t *i = vam->input;
9468 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9471 u8 sw_if_index_set = 0;
9474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9476 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9477 sw_if_index_set = 1;
9478 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9479 sw_if_index_set = 1;
9480 else if (unformat (i, "enable"))
9482 else if (unformat (i, "disable"))
9486 clib_warning ("parse error '%U'", format_unformat_error, i);
9491 if (sw_if_index_set == 0)
9493 errmsg ("missing interface name or sw_if_index");
9497 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9499 mp->sw_if_index = ntohl (sw_if_index);
9500 mp->enable_disable = enable;
9508 api_mpls_tunnel_add_del (vat_main_t * vam)
9510 unformat_input_t *i = vam->input;
9511 vl_api_mpls_tunnel_add_del_t *mp;
9515 u32 sw_if_index = ~0;
9516 u32 next_hop_sw_if_index = ~0;
9517 u32 next_hop_proto_is_ip4 = 1;
9519 u32 next_hop_table_id = 0;
9520 ip4_address_t v4_next_hop_address = {
9523 ip6_address_t v6_next_hop_address = { {0} };
9524 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9525 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9526 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9531 if (unformat (i, "add"))
9535 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9537 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9539 else if (unformat (i, "via %U",
9540 unformat_ip4_address, &v4_next_hop_address))
9542 next_hop_proto_is_ip4 = 1;
9544 else if (unformat (i, "via %U",
9545 unformat_ip6_address, &v6_next_hop_address))
9547 next_hop_proto_is_ip4 = 0;
9549 else if (unformat (i, "via-label %d", &next_hop_via_label))
9553 (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
9555 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9557 else if (unformat (i, "l2-only"))
9559 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9561 else if (unformat (i, "out-label %d", &next_hop_out_label))
9563 vl_api_fib_mpls_label_t fib_label = {
9564 .label = ntohl (next_hop_out_label),
9568 vec_add1 (next_hop_out_label_stack, fib_label);
9572 clib_warning ("parse error '%U'", format_unformat_error, i);
9577 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9578 vec_len (next_hop_out_label_stack));
9580 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9581 mp->mt_sw_if_index = ntohl (sw_if_index);
9582 mp->mt_is_add = is_add;
9583 mp->mt_l2_only = l2_only;
9584 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9585 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9586 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9587 mp->mt_next_hop_weight = 1;
9588 mp->mt_next_hop_preference = 0;
9590 mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9592 if (0 != mp->mt_next_hop_n_out_labels)
9594 clib_memcpy (mp->mt_next_hop_out_label_stack,
9595 next_hop_out_label_stack,
9596 (vec_len (next_hop_out_label_stack) *
9597 sizeof (vl_api_fib_mpls_label_t)));
9598 vec_free (next_hop_out_label_stack);
9601 if (next_hop_proto_is_ip4)
9603 clib_memcpy (mp->mt_next_hop,
9604 &v4_next_hop_address, sizeof (v4_next_hop_address));
9608 clib_memcpy (mp->mt_next_hop,
9609 &v6_next_hop_address, sizeof (v6_next_hop_address));
9618 api_sw_interface_set_unnumbered (vat_main_t * vam)
9620 unformat_input_t *i = vam->input;
9621 vl_api_sw_interface_set_unnumbered_t *mp;
9623 u32 unnum_sw_index = ~0;
9625 u8 sw_if_index_set = 0;
9628 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9630 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9631 sw_if_index_set = 1;
9632 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9633 sw_if_index_set = 1;
9634 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9636 else if (unformat (i, "del"))
9640 clib_warning ("parse error '%U'", format_unformat_error, i);
9645 if (sw_if_index_set == 0)
9647 errmsg ("missing interface name or sw_if_index");
9651 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9653 mp->sw_if_index = ntohl (sw_if_index);
9654 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9655 mp->is_add = is_add;
9663 api_ip_neighbor_add_del (vat_main_t * vam)
9665 unformat_input_t *i = vam->input;
9666 vl_api_ip_neighbor_add_del_t *mp;
9668 u8 sw_if_index_set = 0;
9671 u8 is_no_fib_entry = 0;
9674 u8 v4_address_set = 0;
9675 u8 v6_address_set = 0;
9676 ip4_address_t v4address;
9677 ip6_address_t v6address;
9680 clib_memset (mac_address, 0, sizeof (mac_address));
9682 /* Parse args required to build the message */
9683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9685 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9689 else if (unformat (i, "del"))
9692 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9693 sw_if_index_set = 1;
9694 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9695 sw_if_index_set = 1;
9696 else if (unformat (i, "is_static"))
9698 else if (unformat (i, "no-fib-entry"))
9699 is_no_fib_entry = 1;
9700 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9702 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9706 clib_warning ("parse error '%U'", format_unformat_error, i);
9711 if (sw_if_index_set == 0)
9713 errmsg ("missing interface name or sw_if_index");
9716 if (v4_address_set && v6_address_set)
9718 errmsg ("both v4 and v6 addresses set");
9721 if (!v4_address_set && !v6_address_set)
9723 errmsg ("no address set");
9727 /* Construct the API message */
9728 M (IP_NEIGHBOR_ADD_DEL, mp);
9730 mp->sw_if_index = ntohl (sw_if_index);
9731 mp->is_add = is_add;
9732 mp->is_static = is_static;
9733 mp->is_no_adj_fib = is_no_fib_entry;
9735 clib_memcpy (mp->mac_address, mac_address, 6);
9739 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9743 /* mp->is_ipv6 = 0; via clib_memset in M macro above */
9744 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9750 /* Wait for a reply, return good/bad news */
9756 api_create_vlan_subif (vat_main_t * vam)
9758 unformat_input_t *i = vam->input;
9759 vl_api_create_vlan_subif_t *mp;
9761 u8 sw_if_index_set = 0;
9766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9768 if (unformat (i, "sw_if_index %d", &sw_if_index))
9769 sw_if_index_set = 1;
9771 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9772 sw_if_index_set = 1;
9773 else if (unformat (i, "vlan %d", &vlan_id))
9777 clib_warning ("parse error '%U'", format_unformat_error, i);
9782 if (sw_if_index_set == 0)
9784 errmsg ("missing interface name or sw_if_index");
9788 if (vlan_id_set == 0)
9790 errmsg ("missing vlan_id");
9793 M (CREATE_VLAN_SUBIF, mp);
9795 mp->sw_if_index = ntohl (sw_if_index);
9796 mp->vlan_id = ntohl (vlan_id);
9803 #define foreach_create_subif_bit \
9810 _(outer_vlan_id_any) \
9811 _(inner_vlan_id_any)
9814 api_create_subif (vat_main_t * vam)
9816 unformat_input_t *i = vam->input;
9817 vl_api_create_subif_t *mp;
9819 u8 sw_if_index_set = 0;
9826 u32 exact_match = 0;
9827 u32 default_sub = 0;
9828 u32 outer_vlan_id_any = 0;
9829 u32 inner_vlan_id_any = 0;
9831 u16 outer_vlan_id = 0;
9832 u16 inner_vlan_id = 0;
9835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9837 if (unformat (i, "sw_if_index %d", &sw_if_index))
9838 sw_if_index_set = 1;
9840 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9841 sw_if_index_set = 1;
9842 else if (unformat (i, "sub_id %d", &sub_id))
9844 else if (unformat (i, "outer_vlan_id %d", &tmp))
9845 outer_vlan_id = tmp;
9846 else if (unformat (i, "inner_vlan_id %d", &tmp))
9847 inner_vlan_id = tmp;
9849 #define _(a) else if (unformat (i, #a)) a = 1 ;
9850 foreach_create_subif_bit
9854 clib_warning ("parse error '%U'", format_unformat_error, i);
9859 if (sw_if_index_set == 0)
9861 errmsg ("missing interface name or sw_if_index");
9865 if (sub_id_set == 0)
9867 errmsg ("missing sub_id");
9870 M (CREATE_SUBIF, mp);
9872 mp->sw_if_index = ntohl (sw_if_index);
9873 mp->sub_id = ntohl (sub_id);
9875 #define _(a) mp->a = a;
9876 foreach_create_subif_bit;
9879 mp->outer_vlan_id = ntohs (outer_vlan_id);
9880 mp->inner_vlan_id = ntohs (inner_vlan_id);
9888 api_oam_add_del (vat_main_t * vam)
9890 unformat_input_t *i = vam->input;
9891 vl_api_oam_add_del_t *mp;
9894 ip4_address_t src, dst;
9899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9901 if (unformat (i, "vrf %d", &vrf_id))
9903 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9905 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9907 else if (unformat (i, "del"))
9911 clib_warning ("parse error '%U'", format_unformat_error, i);
9918 errmsg ("missing src addr");
9924 errmsg ("missing dst addr");
9928 M (OAM_ADD_DEL, mp);
9930 mp->vrf_id = ntohl (vrf_id);
9931 mp->is_add = is_add;
9932 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9933 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9941 api_reset_fib (vat_main_t * vam)
9943 unformat_input_t *i = vam->input;
9944 vl_api_reset_fib_t *mp;
9950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9952 if (unformat (i, "vrf %d", &vrf_id))
9954 else if (unformat (i, "ipv6"))
9958 clib_warning ("parse error '%U'", format_unformat_error, i);
9963 if (vrf_id_set == 0)
9965 errmsg ("missing vrf id");
9971 mp->vrf_id = ntohl (vrf_id);
9972 mp->is_ipv6 = is_ipv6;
9980 api_dhcp_proxy_config (vat_main_t * vam)
9982 unformat_input_t *i = vam->input;
9983 vl_api_dhcp_proxy_config_t *mp;
9985 u32 server_vrf_id = 0;
9987 u8 v4_address_set = 0;
9988 u8 v6_address_set = 0;
9989 ip4_address_t v4address;
9990 ip6_address_t v6address;
9991 u8 v4_src_address_set = 0;
9992 u8 v6_src_address_set = 0;
9993 ip4_address_t v4srcaddress;
9994 ip6_address_t v6srcaddress;
9997 /* Parse args required to build the message */
9998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10000 if (unformat (i, "del"))
10002 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
10004 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
10006 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
10007 v4_address_set = 1;
10008 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
10009 v6_address_set = 1;
10010 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
10011 v4_src_address_set = 1;
10012 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
10013 v6_src_address_set = 1;
10018 if (v4_address_set && v6_address_set)
10020 errmsg ("both v4 and v6 server addresses set");
10023 if (!v4_address_set && !v6_address_set)
10025 errmsg ("no server addresses set");
10029 if (v4_src_address_set && v6_src_address_set)
10031 errmsg ("both v4 and v6 src addresses set");
10034 if (!v4_src_address_set && !v6_src_address_set)
10036 errmsg ("no src addresses set");
10040 if (!(v4_src_address_set && v4_address_set) &&
10041 !(v6_src_address_set && v6_address_set))
10043 errmsg ("no matching server and src addresses set");
10047 /* Construct the API message */
10048 M (DHCP_PROXY_CONFIG, mp);
10050 mp->is_add = is_add;
10051 mp->rx_vrf_id = ntohl (rx_vrf_id);
10052 mp->server_vrf_id = ntohl (server_vrf_id);
10053 if (v6_address_set)
10056 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
10057 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
10061 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
10062 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
10068 /* Wait for a reply, return good/bad news */
10073 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
10074 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
10077 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
10079 vat_main_t *vam = &vat_main;
10080 u32 i, count = mp->count;
10081 vl_api_dhcp_server_t *s;
10085 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10086 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10087 ntohl (mp->rx_vrf_id),
10088 format_ip6_address, mp->dhcp_src_address,
10089 mp->vss_type, mp->vss_vpn_ascii_id,
10090 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10093 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10094 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10095 ntohl (mp->rx_vrf_id),
10096 format_ip4_address, mp->dhcp_src_address,
10097 mp->vss_type, mp->vss_vpn_ascii_id,
10098 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10100 for (i = 0; i < count; i++)
10102 s = &mp->servers[i];
10106 " Server Table-ID %d, Server Address %U",
10107 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
10110 " Server Table-ID %d, Server Address %U",
10111 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
10115 static void vl_api_dhcp_proxy_details_t_handler_json
10116 (vl_api_dhcp_proxy_details_t * mp)
10118 vat_main_t *vam = &vat_main;
10119 vat_json_node_t *node = NULL;
10120 u32 i, count = mp->count;
10121 struct in_addr ip4;
10122 struct in6_addr ip6;
10123 vl_api_dhcp_server_t *s;
10125 if (VAT_JSON_ARRAY != vam->json_tree.type)
10127 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10128 vat_json_init_array (&vam->json_tree);
10130 node = vat_json_array_add (&vam->json_tree);
10132 vat_json_init_object (node);
10133 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
10134 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
10135 sizeof (mp->vss_type));
10136 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
10137 mp->vss_vpn_ascii_id);
10138 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
10139 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10143 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10144 vat_json_object_add_ip6 (node, "src_address", ip6);
10148 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10149 vat_json_object_add_ip4 (node, "src_address", ip4);
10152 for (i = 0; i < count; i++)
10154 s = &mp->servers[i];
10156 vat_json_object_add_uint (node, "server-table-id",
10157 ntohl (s->server_vrf_id));
10161 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10162 vat_json_object_add_ip4 (node, "src_address", ip4);
10166 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10167 vat_json_object_add_ip6 (node, "server_address", ip6);
10173 api_dhcp_proxy_dump (vat_main_t * vam)
10175 unformat_input_t *i = vam->input;
10176 vl_api_control_ping_t *mp_ping;
10177 vl_api_dhcp_proxy_dump_t *mp;
10181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10183 if (unformat (i, "ipv6"))
10187 clib_warning ("parse error '%U'", format_unformat_error, i);
10192 M (DHCP_PROXY_DUMP, mp);
10194 mp->is_ip6 = is_ipv6;
10197 /* Use a control ping for synchronization */
10198 MPING (CONTROL_PING, mp_ping);
10206 api_dhcp_proxy_set_vss (vat_main_t * vam)
10208 unformat_input_t *i = vam->input;
10209 vl_api_dhcp_proxy_set_vss_t *mp;
10213 u8 vss_type = VSS_TYPE_DEFAULT;
10214 u8 *vpn_ascii_id = 0;
10219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10221 if (unformat (i, "tbl_id %d", &tbl_id))
10223 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10224 vss_type = VSS_TYPE_ASCII;
10225 else if (unformat (i, "fib_id %d", &fib_id))
10226 vss_type = VSS_TYPE_VPN_ID;
10227 else if (unformat (i, "oui %d", &oui))
10228 vss_type = VSS_TYPE_VPN_ID;
10229 else if (unformat (i, "ipv6"))
10231 else if (unformat (i, "del"))
10239 errmsg ("missing tbl_id ");
10240 vec_free (vpn_ascii_id);
10244 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10246 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10247 vec_free (vpn_ascii_id);
10251 M (DHCP_PROXY_SET_VSS, mp);
10252 mp->tbl_id = ntohl (tbl_id);
10253 mp->vss_type = vss_type;
10256 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10257 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10259 mp->vpn_index = ntohl (fib_id);
10260 mp->oui = ntohl (oui);
10261 mp->is_ipv6 = is_ipv6;
10262 mp->is_add = is_add;
10267 vec_free (vpn_ascii_id);
10272 api_dhcp_client_config (vat_main_t * vam)
10274 unformat_input_t *i = vam->input;
10275 vl_api_dhcp_client_config_t *mp;
10277 u8 sw_if_index_set = 0;
10280 u8 disable_event = 0;
10283 /* Parse args required to build the message */
10284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10286 if (unformat (i, "del"))
10289 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10290 sw_if_index_set = 1;
10291 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10292 sw_if_index_set = 1;
10293 else if (unformat (i, "hostname %s", &hostname))
10295 else if (unformat (i, "disable_event"))
10301 if (sw_if_index_set == 0)
10303 errmsg ("missing interface name or sw_if_index");
10307 if (vec_len (hostname) > 63)
10309 errmsg ("hostname too long");
10311 vec_add1 (hostname, 0);
10313 /* Construct the API message */
10314 M (DHCP_CLIENT_CONFIG, mp);
10316 mp->is_add = is_add;
10317 mp->client.sw_if_index = htonl (sw_if_index);
10318 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10319 vec_free (hostname);
10320 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10321 mp->client.pid = htonl (getpid ());
10326 /* Wait for a reply, return good/bad news */
10332 api_set_ip_flow_hash (vat_main_t * vam)
10334 unformat_input_t *i = vam->input;
10335 vl_api_set_ip_flow_hash_t *mp;
10347 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10349 if (unformat (i, "vrf %d", &vrf_id))
10351 else if (unformat (i, "ipv6"))
10353 else if (unformat (i, "src"))
10355 else if (unformat (i, "dst"))
10357 else if (unformat (i, "sport"))
10359 else if (unformat (i, "dport"))
10361 else if (unformat (i, "proto"))
10363 else if (unformat (i, "reverse"))
10368 clib_warning ("parse error '%U'", format_unformat_error, i);
10373 if (vrf_id_set == 0)
10375 errmsg ("missing vrf id");
10379 M (SET_IP_FLOW_HASH, mp);
10385 mp->reverse = reverse;
10386 mp->vrf_id = ntohl (vrf_id);
10387 mp->is_ipv6 = is_ipv6;
10395 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10397 unformat_input_t *i = vam->input;
10398 vl_api_sw_interface_ip6_enable_disable_t *mp;
10400 u8 sw_if_index_set = 0;
10404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10406 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10407 sw_if_index_set = 1;
10408 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10409 sw_if_index_set = 1;
10410 else if (unformat (i, "enable"))
10412 else if (unformat (i, "disable"))
10416 clib_warning ("parse error '%U'", format_unformat_error, i);
10421 if (sw_if_index_set == 0)
10423 errmsg ("missing interface name or sw_if_index");
10427 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10429 mp->sw_if_index = ntohl (sw_if_index);
10430 mp->enable = enable;
10438 api_ip6nd_proxy_add_del (vat_main_t * vam)
10440 unformat_input_t *i = vam->input;
10441 vl_api_ip6nd_proxy_add_del_t *mp;
10442 u32 sw_if_index = ~0;
10443 u8 v6_address_set = 0;
10444 ip6_address_t v6address;
10448 /* Parse args required to build the message */
10449 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10451 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10453 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10455 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10456 v6_address_set = 1;
10457 if (unformat (i, "del"))
10461 clib_warning ("parse error '%U'", format_unformat_error, i);
10466 if (sw_if_index == ~0)
10468 errmsg ("missing interface name or sw_if_index");
10471 if (!v6_address_set)
10473 errmsg ("no address set");
10477 /* Construct the API message */
10478 M (IP6ND_PROXY_ADD_DEL, mp);
10480 mp->is_del = is_del;
10481 mp->sw_if_index = ntohl (sw_if_index);
10482 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10487 /* Wait for a reply, return good/bad news */
10493 api_ip6nd_proxy_dump (vat_main_t * vam)
10495 vl_api_ip6nd_proxy_dump_t *mp;
10496 vl_api_control_ping_t *mp_ping;
10499 M (IP6ND_PROXY_DUMP, mp);
10503 /* Use a control ping for synchronization */
10504 MPING (CONTROL_PING, mp_ping);
10511 static void vl_api_ip6nd_proxy_details_t_handler
10512 (vl_api_ip6nd_proxy_details_t * mp)
10514 vat_main_t *vam = &vat_main;
10516 print (vam->ofp, "host %U sw_if_index %d",
10517 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10520 static void vl_api_ip6nd_proxy_details_t_handler_json
10521 (vl_api_ip6nd_proxy_details_t * mp)
10523 vat_main_t *vam = &vat_main;
10524 struct in6_addr ip6;
10525 vat_json_node_t *node = NULL;
10527 if (VAT_JSON_ARRAY != vam->json_tree.type)
10529 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10530 vat_json_init_array (&vam->json_tree);
10532 node = vat_json_array_add (&vam->json_tree);
10534 vat_json_init_object (node);
10535 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10537 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10538 vat_json_object_add_ip6 (node, "host", ip6);
10542 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10544 unformat_input_t *i = vam->input;
10545 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10547 u8 sw_if_index_set = 0;
10548 u32 address_length = 0;
10549 u8 v6_address_set = 0;
10550 ip6_address_t v6address;
10551 u8 use_default = 0;
10552 u8 no_advertise = 0;
10554 u8 no_autoconfig = 0;
10557 u32 val_lifetime = 0;
10558 u32 pref_lifetime = 0;
10561 /* Parse args required to build the message */
10562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10564 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10565 sw_if_index_set = 1;
10566 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10567 sw_if_index_set = 1;
10568 else if (unformat (i, "%U/%d",
10569 unformat_ip6_address, &v6address, &address_length))
10570 v6_address_set = 1;
10571 else if (unformat (i, "val_life %d", &val_lifetime))
10573 else if (unformat (i, "pref_life %d", &pref_lifetime))
10575 else if (unformat (i, "def"))
10577 else if (unformat (i, "noadv"))
10579 else if (unformat (i, "offl"))
10581 else if (unformat (i, "noauto"))
10583 else if (unformat (i, "nolink"))
10585 else if (unformat (i, "isno"))
10589 clib_warning ("parse error '%U'", format_unformat_error, i);
10594 if (sw_if_index_set == 0)
10596 errmsg ("missing interface name or sw_if_index");
10599 if (!v6_address_set)
10601 errmsg ("no address set");
10605 /* Construct the API message */
10606 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10608 mp->sw_if_index = ntohl (sw_if_index);
10609 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10610 mp->address_length = address_length;
10611 mp->use_default = use_default;
10612 mp->no_advertise = no_advertise;
10613 mp->off_link = off_link;
10614 mp->no_autoconfig = no_autoconfig;
10615 mp->no_onlink = no_onlink;
10617 mp->val_lifetime = ntohl (val_lifetime);
10618 mp->pref_lifetime = ntohl (pref_lifetime);
10623 /* Wait for a reply, return good/bad news */
10629 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10631 unformat_input_t *i = vam->input;
10632 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10634 u8 sw_if_index_set = 0;
10639 u8 send_unicast = 0;
10642 u8 default_router = 0;
10643 u32 max_interval = 0;
10644 u32 min_interval = 0;
10646 u32 initial_count = 0;
10647 u32 initial_interval = 0;
10651 /* Parse args required to build the message */
10652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10654 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10655 sw_if_index_set = 1;
10656 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10657 sw_if_index_set = 1;
10658 else if (unformat (i, "maxint %d", &max_interval))
10660 else if (unformat (i, "minint %d", &min_interval))
10662 else if (unformat (i, "life %d", &lifetime))
10664 else if (unformat (i, "count %d", &initial_count))
10666 else if (unformat (i, "interval %d", &initial_interval))
10668 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10670 else if (unformat (i, "managed"))
10672 else if (unformat (i, "other"))
10674 else if (unformat (i, "ll"))
10676 else if (unformat (i, "send"))
10678 else if (unformat (i, "cease"))
10680 else if (unformat (i, "isno"))
10682 else if (unformat (i, "def"))
10683 default_router = 1;
10686 clib_warning ("parse error '%U'", format_unformat_error, i);
10691 if (sw_if_index_set == 0)
10693 errmsg ("missing interface name or sw_if_index");
10697 /* Construct the API message */
10698 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10700 mp->sw_if_index = ntohl (sw_if_index);
10701 mp->max_interval = ntohl (max_interval);
10702 mp->min_interval = ntohl (min_interval);
10703 mp->lifetime = ntohl (lifetime);
10704 mp->initial_count = ntohl (initial_count);
10705 mp->initial_interval = ntohl (initial_interval);
10706 mp->suppress = suppress;
10707 mp->managed = managed;
10709 mp->ll_option = ll_option;
10710 mp->send_unicast = send_unicast;
10713 mp->default_router = default_router;
10718 /* Wait for a reply, return good/bad news */
10724 api_set_arp_neighbor_limit (vat_main_t * vam)
10726 unformat_input_t *i = vam->input;
10727 vl_api_set_arp_neighbor_limit_t *mp;
10733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10735 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10737 else if (unformat (i, "ipv6"))
10741 clib_warning ("parse error '%U'", format_unformat_error, i);
10746 if (limit_set == 0)
10748 errmsg ("missing limit value");
10752 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10754 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10755 mp->is_ipv6 = is_ipv6;
10763 api_l2_patch_add_del (vat_main_t * vam)
10765 unformat_input_t *i = vam->input;
10766 vl_api_l2_patch_add_del_t *mp;
10767 u32 rx_sw_if_index;
10768 u8 rx_sw_if_index_set = 0;
10769 u32 tx_sw_if_index;
10770 u8 tx_sw_if_index_set = 0;
10774 /* Parse args required to build the message */
10775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10777 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10778 rx_sw_if_index_set = 1;
10779 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10780 tx_sw_if_index_set = 1;
10781 else if (unformat (i, "rx"))
10783 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10785 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10787 rx_sw_if_index_set = 1;
10792 else if (unformat (i, "tx"))
10794 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10796 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10798 tx_sw_if_index_set = 1;
10803 else if (unformat (i, "del"))
10809 if (rx_sw_if_index_set == 0)
10811 errmsg ("missing rx interface name or rx_sw_if_index");
10815 if (tx_sw_if_index_set == 0)
10817 errmsg ("missing tx interface name or tx_sw_if_index");
10821 M (L2_PATCH_ADD_DEL, mp);
10823 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10824 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10825 mp->is_add = is_add;
10833 u8 localsid_addr[16];
10842 api_sr_localsid_add_del (vat_main_t * vam)
10844 unformat_input_t *i = vam->input;
10845 vl_api_sr_localsid_add_del_t *mp;
10848 ip6_address_t localsid;
10852 u32 fib_table = ~(u32) 0;
10853 ip6_address_t nh_addr6;
10854 ip4_address_t nh_addr4;
10855 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10856 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10858 bool nexthop_set = 0;
10862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10864 if (unformat (i, "del"))
10866 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10867 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10869 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10871 else if (unformat (i, "behavior %u", &behavior));
10872 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10873 else if (unformat (i, "fib-table %u", &fib_table));
10874 else if (unformat (i, "end.psp %u", &behavior));
10879 M (SR_LOCALSID_ADD_DEL, mp);
10881 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10884 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10885 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10887 mp->behavior = behavior;
10888 mp->sw_if_index = ntohl (sw_if_index);
10889 mp->fib_table = ntohl (fib_table);
10890 mp->end_psp = end_psp;
10891 mp->is_del = is_del;
10899 api_ioam_enable (vat_main_t * vam)
10901 unformat_input_t *input = vam->input;
10902 vl_api_ioam_enable_t *mp;
10904 int has_trace_option = 0;
10905 int has_pot_option = 0;
10906 int has_seqno_option = 0;
10907 int has_analyse_option = 0;
10910 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10912 if (unformat (input, "trace"))
10913 has_trace_option = 1;
10914 else if (unformat (input, "pot"))
10915 has_pot_option = 1;
10916 else if (unformat (input, "seqno"))
10917 has_seqno_option = 1;
10918 else if (unformat (input, "analyse"))
10919 has_analyse_option = 1;
10923 M (IOAM_ENABLE, mp);
10924 mp->id = htons (id);
10925 mp->seqno = has_seqno_option;
10926 mp->analyse = has_analyse_option;
10927 mp->pot_enable = has_pot_option;
10928 mp->trace_enable = has_trace_option;
10937 api_ioam_disable (vat_main_t * vam)
10939 vl_api_ioam_disable_t *mp;
10942 M (IOAM_DISABLE, mp);
10948 #define foreach_tcp_proto_field \
10952 #define foreach_udp_proto_field \
10956 #define foreach_ip4_proto_field \
10968 u16 src_port, dst_port;
10971 #if VPP_API_TEST_BUILTIN == 0
10973 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10975 u8 **maskp = va_arg (*args, u8 **);
10977 u8 found_something = 0;
10980 #define _(a) u8 a=0;
10981 foreach_tcp_proto_field;
10984 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10987 #define _(a) else if (unformat (input, #a)) a=1;
10988 foreach_tcp_proto_field
10994 #define _(a) found_something += a;
10995 foreach_tcp_proto_field;
10998 if (found_something == 0)
11001 vec_validate (mask, sizeof (*tcp) - 1);
11003 tcp = (tcp_header_t *) mask;
11005 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
11006 foreach_tcp_proto_field;
11014 unformat_udp_mask (unformat_input_t * input, va_list * args)
11016 u8 **maskp = va_arg (*args, u8 **);
11018 u8 found_something = 0;
11021 #define _(a) u8 a=0;
11022 foreach_udp_proto_field;
11025 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11028 #define _(a) else if (unformat (input, #a)) a=1;
11029 foreach_udp_proto_field
11035 #define _(a) found_something += a;
11036 foreach_udp_proto_field;
11039 if (found_something == 0)
11042 vec_validate (mask, sizeof (*udp) - 1);
11044 udp = (udp_header_t *) mask;
11046 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
11047 foreach_udp_proto_field;
11055 unformat_l4_mask (unformat_input_t * input, va_list * args)
11057 u8 **maskp = va_arg (*args, u8 **);
11058 u16 src_port = 0, dst_port = 0;
11059 tcpudp_header_t *tcpudp;
11061 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11063 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
11065 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
11067 else if (unformat (input, "src_port"))
11069 else if (unformat (input, "dst_port"))
11075 if (!src_port && !dst_port)
11079 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
11081 tcpudp = (tcpudp_header_t *) mask;
11082 tcpudp->src_port = src_port;
11083 tcpudp->dst_port = dst_port;
11091 unformat_ip4_mask (unformat_input_t * input, va_list * args)
11093 u8 **maskp = va_arg (*args, u8 **);
11095 u8 found_something = 0;
11098 #define _(a) u8 a=0;
11099 foreach_ip4_proto_field;
11105 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11107 if (unformat (input, "version"))
11109 else if (unformat (input, "hdr_length"))
11111 else if (unformat (input, "src"))
11113 else if (unformat (input, "dst"))
11115 else if (unformat (input, "proto"))
11118 #define _(a) else if (unformat (input, #a)) a=1;
11119 foreach_ip4_proto_field
11125 #define _(a) found_something += a;
11126 foreach_ip4_proto_field;
11129 if (found_something == 0)
11132 vec_validate (mask, sizeof (*ip) - 1);
11134 ip = (ip4_header_t *) mask;
11136 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
11137 foreach_ip4_proto_field;
11140 ip->ip_version_and_header_length = 0;
11143 ip->ip_version_and_header_length |= 0xF0;
11146 ip->ip_version_and_header_length |= 0x0F;
11152 #define foreach_ip6_proto_field \
11155 _(payload_length) \
11160 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11162 u8 **maskp = va_arg (*args, u8 **);
11164 u8 found_something = 0;
11166 u32 ip_version_traffic_class_and_flow_label;
11168 #define _(a) u8 a=0;
11169 foreach_ip6_proto_field;
11172 u8 traffic_class = 0;
11175 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11177 if (unformat (input, "version"))
11179 else if (unformat (input, "traffic-class"))
11181 else if (unformat (input, "flow-label"))
11183 else if (unformat (input, "src"))
11185 else if (unformat (input, "dst"))
11187 else if (unformat (input, "proto"))
11190 #define _(a) else if (unformat (input, #a)) a=1;
11191 foreach_ip6_proto_field
11197 #define _(a) found_something += a;
11198 foreach_ip6_proto_field;
11201 if (found_something == 0)
11204 vec_validate (mask, sizeof (*ip) - 1);
11206 ip = (ip6_header_t *) mask;
11208 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
11209 foreach_ip6_proto_field;
11212 ip_version_traffic_class_and_flow_label = 0;
11215 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11218 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11221 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11223 ip->ip_version_traffic_class_and_flow_label =
11224 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11231 unformat_l3_mask (unformat_input_t * input, va_list * args)
11233 u8 **maskp = va_arg (*args, u8 **);
11235 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11237 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11239 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11248 unformat_l2_mask (unformat_input_t * input, va_list * args)
11250 u8 **maskp = va_arg (*args, u8 **);
11257 u8 ignore_tag1 = 0;
11258 u8 ignore_tag2 = 0;
11265 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11267 if (unformat (input, "src"))
11269 else if (unformat (input, "dst"))
11271 else if (unformat (input, "proto"))
11273 else if (unformat (input, "tag1"))
11275 else if (unformat (input, "tag2"))
11277 else if (unformat (input, "ignore-tag1"))
11279 else if (unformat (input, "ignore-tag2"))
11281 else if (unformat (input, "cos1"))
11283 else if (unformat (input, "cos2"))
11285 else if (unformat (input, "dot1q"))
11287 else if (unformat (input, "dot1ad"))
11292 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11293 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11296 if (tag1 || ignore_tag1 || cos1 || dot1q)
11298 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11301 vec_validate (mask, len - 1);
11304 clib_memset (mask, 0xff, 6);
11307 clib_memset (mask + 6, 0xff, 6);
11309 if (tag2 || dot1ad)
11311 /* inner vlan tag */
11320 mask[21] = mask[20] = 0xff;
11341 mask[16] = mask[17] = 0xff;
11351 mask[12] = mask[13] = 0xff;
11358 unformat_classify_mask (unformat_input_t * input, va_list * args)
11360 u8 **maskp = va_arg (*args, u8 **);
11361 u32 *skipp = va_arg (*args, u32 *);
11362 u32 *matchp = va_arg (*args, u32 *);
11370 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11372 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11374 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11376 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11378 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11392 if (mask || l2 || l3 || l4)
11394 if (l2 || l3 || l4)
11396 /* "With a free Ethernet header in every package" */
11398 vec_validate (l2, 13);
11402 vec_append (mask, l3);
11407 vec_append (mask, l4);
11412 /* Scan forward looking for the first significant mask octet */
11413 for (i = 0; i < vec_len (mask); i++)
11417 /* compute (skip, match) params */
11418 *skipp = i / sizeof (u32x4);
11419 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11421 /* Pad mask to an even multiple of the vector size */
11422 while (vec_len (mask) % sizeof (u32x4))
11423 vec_add1 (mask, 0);
11425 match = vec_len (mask) / sizeof (u32x4);
11427 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11429 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11430 if (*tmp || *(tmp + 1))
11435 clib_warning ("BUG: match 0");
11437 _vec_len (mask) = match * sizeof (u32x4);
11447 #endif /* VPP_API_TEST_BUILTIN */
11449 #define foreach_l2_next \
11451 _(ethernet, ETHERNET_INPUT) \
11452 _(ip4, IP4_INPUT) \
11456 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11458 u32 *miss_next_indexp = va_arg (*args, u32 *);
11459 u32 next_index = 0;
11463 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11467 if (unformat (input, "%d", &tmp))
11476 *miss_next_indexp = next_index;
11480 #define foreach_ip_next \
11483 _(rewrite, REWRITE)
11486 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11488 u32 *miss_next_indexp = va_arg (*args, u32 *);
11489 u32 next_index = 0;
11493 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11497 if (unformat (input, "%d", &tmp))
11506 *miss_next_indexp = next_index;
11510 #define foreach_acl_next \
11514 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11516 u32 *miss_next_indexp = va_arg (*args, u32 *);
11517 u32 next_index = 0;
11521 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11525 if (unformat (input, "permit"))
11530 else if (unformat (input, "%d", &tmp))
11539 *miss_next_indexp = next_index;
11544 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11546 u32 *r = va_arg (*args, u32 *);
11548 if (unformat (input, "conform-color"))
11549 *r = POLICE_CONFORM;
11550 else if (unformat (input, "exceed-color"))
11551 *r = POLICE_EXCEED;
11559 api_classify_add_del_table (vat_main_t * vam)
11561 unformat_input_t *i = vam->input;
11562 vl_api_classify_add_del_table_t *mp;
11569 u32 table_index = ~0;
11570 u32 next_table_index = ~0;
11571 u32 miss_next_index = ~0;
11572 u32 memory_size = 32 << 20;
11574 u32 current_data_flag = 0;
11575 int current_data_offset = 0;
11578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11580 if (unformat (i, "del"))
11582 else if (unformat (i, "del-chain"))
11587 else if (unformat (i, "buckets %d", &nbuckets))
11589 else if (unformat (i, "memory_size %d", &memory_size))
11591 else if (unformat (i, "skip %d", &skip))
11593 else if (unformat (i, "match %d", &match))
11595 else if (unformat (i, "table %d", &table_index))
11597 else if (unformat (i, "mask %U", unformat_classify_mask,
11598 &mask, &skip, &match))
11600 else if (unformat (i, "next-table %d", &next_table_index))
11602 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11605 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11608 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11611 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11613 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11619 if (is_add && mask == 0)
11621 errmsg ("Mask required");
11625 if (is_add && skip == ~0)
11627 errmsg ("skip count required");
11631 if (is_add && match == ~0)
11633 errmsg ("match count required");
11637 if (!is_add && table_index == ~0)
11639 errmsg ("table index required for delete");
11643 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11645 mp->is_add = is_add;
11646 mp->del_chain = del_chain;
11647 mp->table_index = ntohl (table_index);
11648 mp->nbuckets = ntohl (nbuckets);
11649 mp->memory_size = ntohl (memory_size);
11650 mp->skip_n_vectors = ntohl (skip);
11651 mp->match_n_vectors = ntohl (match);
11652 mp->next_table_index = ntohl (next_table_index);
11653 mp->miss_next_index = ntohl (miss_next_index);
11654 mp->current_data_flag = ntohl (current_data_flag);
11655 mp->current_data_offset = ntohl (current_data_offset);
11656 mp->mask_len = ntohl (vec_len (mask));
11657 clib_memcpy (mp->mask, mask, vec_len (mask));
11666 #if VPP_API_TEST_BUILTIN == 0
11668 unformat_l4_match (unformat_input_t * input, va_list * args)
11670 u8 **matchp = va_arg (*args, u8 **);
11672 u8 *proto_header = 0;
11678 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11680 if (unformat (input, "src_port %d", &src_port))
11682 else if (unformat (input, "dst_port %d", &dst_port))
11688 h.src_port = clib_host_to_net_u16 (src_port);
11689 h.dst_port = clib_host_to_net_u16 (dst_port);
11690 vec_validate (proto_header, sizeof (h) - 1);
11691 memcpy (proto_header, &h, sizeof (h));
11693 *matchp = proto_header;
11699 unformat_ip4_match (unformat_input_t * input, va_list * args)
11701 u8 **matchp = va_arg (*args, u8 **);
11706 int hdr_length = 0;
11707 u32 hdr_length_val;
11708 int src = 0, dst = 0;
11709 ip4_address_t src_val, dst_val;
11716 int fragment_id = 0;
11717 u32 fragment_id_val;
11723 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11725 if (unformat (input, "version %d", &version_val))
11727 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11729 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11731 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11733 else if (unformat (input, "proto %d", &proto_val))
11735 else if (unformat (input, "tos %d", &tos_val))
11737 else if (unformat (input, "length %d", &length_val))
11739 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11741 else if (unformat (input, "ttl %d", &ttl_val))
11743 else if (unformat (input, "checksum %d", &checksum_val))
11749 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11750 + ttl + checksum == 0)
11754 * Aligned because we use the real comparison functions
11756 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11758 ip = (ip4_header_t *) match;
11760 /* These are realistically matched in practice */
11762 ip->src_address.as_u32 = src_val.as_u32;
11765 ip->dst_address.as_u32 = dst_val.as_u32;
11768 ip->protocol = proto_val;
11771 /* These are not, but they're included for completeness */
11773 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11776 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11782 ip->length = clib_host_to_net_u16 (length_val);
11788 ip->checksum = clib_host_to_net_u16 (checksum_val);
11795 unformat_ip6_match (unformat_input_t * input, va_list * args)
11797 u8 **matchp = va_arg (*args, u8 **);
11802 u8 traffic_class = 0;
11803 u32 traffic_class_val = 0;
11806 int src = 0, dst = 0;
11807 ip6_address_t src_val, dst_val;
11810 int payload_length = 0;
11811 u32 payload_length_val;
11814 u32 ip_version_traffic_class_and_flow_label;
11816 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11818 if (unformat (input, "version %d", &version_val))
11820 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11822 else if (unformat (input, "flow_label %d", &flow_label_val))
11824 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11826 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11828 else if (unformat (input, "proto %d", &proto_val))
11830 else if (unformat (input, "payload_length %d", &payload_length_val))
11831 payload_length = 1;
11832 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11838 if (version + traffic_class + flow_label + src + dst + proto +
11839 payload_length + hop_limit == 0)
11843 * Aligned because we use the real comparison functions
11845 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11847 ip = (ip6_header_t *) match;
11850 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11853 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11856 ip->protocol = proto_val;
11858 ip_version_traffic_class_and_flow_label = 0;
11861 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11864 ip_version_traffic_class_and_flow_label |=
11865 (traffic_class_val & 0xFF) << 20;
11868 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11870 ip->ip_version_traffic_class_and_flow_label =
11871 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11873 if (payload_length)
11874 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11877 ip->hop_limit = hop_limit_val;
11884 unformat_l3_match (unformat_input_t * input, va_list * args)
11886 u8 **matchp = va_arg (*args, u8 **);
11888 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11890 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11892 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11901 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11903 u8 *tagp = va_arg (*args, u8 *);
11906 if (unformat (input, "%d", &tag))
11908 tagp[0] = (tag >> 8) & 0x0F;
11909 tagp[1] = tag & 0xFF;
11917 unformat_l2_match (unformat_input_t * input, va_list * args)
11919 u8 **matchp = va_arg (*args, u8 **);
11932 u8 ignore_tag1 = 0;
11933 u8 ignore_tag2 = 0;
11939 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11941 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11944 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11946 else if (unformat (input, "proto %U",
11947 unformat_ethernet_type_host_byte_order, &proto_val))
11949 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11951 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11953 else if (unformat (input, "ignore-tag1"))
11955 else if (unformat (input, "ignore-tag2"))
11957 else if (unformat (input, "cos1 %d", &cos1_val))
11959 else if (unformat (input, "cos2 %d", &cos2_val))
11964 if ((src + dst + proto + tag1 + tag2 +
11965 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11968 if (tag1 || ignore_tag1 || cos1)
11970 if (tag2 || ignore_tag2 || cos2)
11973 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11976 clib_memcpy (match, dst_val, 6);
11979 clib_memcpy (match + 6, src_val, 6);
11983 /* inner vlan tag */
11984 match[19] = tag2_val[1];
11985 match[18] = tag2_val[0];
11987 match[18] |= (cos2_val & 0x7) << 5;
11990 match[21] = proto_val & 0xff;
11991 match[20] = proto_val >> 8;
11995 match[15] = tag1_val[1];
11996 match[14] = tag1_val[0];
11999 match[14] |= (cos1_val & 0x7) << 5;
12005 match[15] = tag1_val[1];
12006 match[14] = tag1_val[0];
12009 match[17] = proto_val & 0xff;
12010 match[16] = proto_val >> 8;
12013 match[14] |= (cos1_val & 0x7) << 5;
12019 match[18] |= (cos2_val & 0x7) << 5;
12021 match[14] |= (cos1_val & 0x7) << 5;
12024 match[13] = proto_val & 0xff;
12025 match[12] = proto_val >> 8;
12033 unformat_qos_source (unformat_input_t * input, va_list * args)
12035 int *qs = va_arg (*args, int *);
12037 if (unformat (input, "ip"))
12038 *qs = QOS_SOURCE_IP;
12039 else if (unformat (input, "mpls"))
12040 *qs = QOS_SOURCE_MPLS;
12041 else if (unformat (input, "ext"))
12042 *qs = QOS_SOURCE_EXT;
12043 else if (unformat (input, "vlan"))
12044 *qs = QOS_SOURCE_VLAN;
12053 api_unformat_classify_match (unformat_input_t * input, va_list * args)
12055 u8 **matchp = va_arg (*args, u8 **);
12056 u32 skip_n_vectors = va_arg (*args, u32);
12057 u32 match_n_vectors = va_arg (*args, u32);
12064 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12066 if (unformat (input, "hex %U", unformat_hex_string, &match))
12068 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
12070 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
12072 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
12086 if (match || l2 || l3 || l4)
12088 if (l2 || l3 || l4)
12090 /* "Win a free Ethernet header in every packet" */
12092 vec_validate_aligned (l2, 13, sizeof (u32x4));
12096 vec_append_aligned (match, l3, sizeof (u32x4));
12101 vec_append_aligned (match, l4, sizeof (u32x4));
12106 /* Make sure the vector is big enough even if key is all 0's */
12107 vec_validate_aligned
12108 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12111 /* Set size, include skipped vectors */
12112 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12123 api_classify_add_del_session (vat_main_t * vam)
12125 unformat_input_t *i = vam->input;
12126 vl_api_classify_add_del_session_t *mp;
12128 u32 table_index = ~0;
12129 u32 hit_next_index = ~0;
12130 u32 opaque_index = ~0;
12133 u32 skip_n_vectors = 0;
12134 u32 match_n_vectors = 0;
12140 * Warning: you have to supply skip_n and match_n
12141 * because the API client cant simply look at the classify
12145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12147 if (unformat (i, "del"))
12149 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12152 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12155 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12158 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12160 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12162 else if (unformat (i, "opaque-index %d", &opaque_index))
12164 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12166 else if (unformat (i, "match_n %d", &match_n_vectors))
12168 else if (unformat (i, "match %U", api_unformat_classify_match,
12169 &match, skip_n_vectors, match_n_vectors))
12171 else if (unformat (i, "advance %d", &advance))
12173 else if (unformat (i, "table-index %d", &table_index))
12175 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12177 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12179 else if (unformat (i, "action %d", &action))
12181 else if (unformat (i, "metadata %d", &metadata))
12187 if (table_index == ~0)
12189 errmsg ("Table index required");
12193 if (is_add && match == 0)
12195 errmsg ("Match value required");
12199 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12201 mp->is_add = is_add;
12202 mp->table_index = ntohl (table_index);
12203 mp->hit_next_index = ntohl (hit_next_index);
12204 mp->opaque_index = ntohl (opaque_index);
12205 mp->advance = ntohl (advance);
12206 mp->action = action;
12207 mp->metadata = ntohl (metadata);
12208 mp->match_len = ntohl (vec_len (match));
12209 clib_memcpy (mp->match, match, vec_len (match));
12218 api_classify_set_interface_ip_table (vat_main_t * vam)
12220 unformat_input_t *i = vam->input;
12221 vl_api_classify_set_interface_ip_table_t *mp;
12223 int sw_if_index_set;
12224 u32 table_index = ~0;
12228 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12230 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12231 sw_if_index_set = 1;
12232 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12233 sw_if_index_set = 1;
12234 else if (unformat (i, "table %d", &table_index))
12238 clib_warning ("parse error '%U'", format_unformat_error, i);
12243 if (sw_if_index_set == 0)
12245 errmsg ("missing interface name or sw_if_index");
12250 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12252 mp->sw_if_index = ntohl (sw_if_index);
12253 mp->table_index = ntohl (table_index);
12254 mp->is_ipv6 = is_ipv6;
12262 api_classify_set_interface_l2_tables (vat_main_t * vam)
12264 unformat_input_t *i = vam->input;
12265 vl_api_classify_set_interface_l2_tables_t *mp;
12267 int sw_if_index_set;
12268 u32 ip4_table_index = ~0;
12269 u32 ip6_table_index = ~0;
12270 u32 other_table_index = ~0;
12274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12276 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12277 sw_if_index_set = 1;
12278 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12279 sw_if_index_set = 1;
12280 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12282 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12284 else if (unformat (i, "other-table %d", &other_table_index))
12286 else if (unformat (i, "is-input %d", &is_input))
12290 clib_warning ("parse error '%U'", format_unformat_error, i);
12295 if (sw_if_index_set == 0)
12297 errmsg ("missing interface name or sw_if_index");
12302 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12304 mp->sw_if_index = ntohl (sw_if_index);
12305 mp->ip4_table_index = ntohl (ip4_table_index);
12306 mp->ip6_table_index = ntohl (ip6_table_index);
12307 mp->other_table_index = ntohl (other_table_index);
12308 mp->is_input = (u8) is_input;
12316 api_set_ipfix_exporter (vat_main_t * vam)
12318 unformat_input_t *i = vam->input;
12319 vl_api_set_ipfix_exporter_t *mp;
12320 ip4_address_t collector_address;
12321 u8 collector_address_set = 0;
12322 u32 collector_port = ~0;
12323 ip4_address_t src_address;
12324 u8 src_address_set = 0;
12327 u32 template_interval = ~0;
12328 u8 udp_checksum = 0;
12331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12333 if (unformat (i, "collector_address %U", unformat_ip4_address,
12334 &collector_address))
12335 collector_address_set = 1;
12336 else if (unformat (i, "collector_port %d", &collector_port))
12338 else if (unformat (i, "src_address %U", unformat_ip4_address,
12340 src_address_set = 1;
12341 else if (unformat (i, "vrf_id %d", &vrf_id))
12343 else if (unformat (i, "path_mtu %d", &path_mtu))
12345 else if (unformat (i, "template_interval %d", &template_interval))
12347 else if (unformat (i, "udp_checksum"))
12353 if (collector_address_set == 0)
12355 errmsg ("collector_address required");
12359 if (src_address_set == 0)
12361 errmsg ("src_address required");
12365 M (SET_IPFIX_EXPORTER, mp);
12367 memcpy (mp->collector_address, collector_address.data,
12368 sizeof (collector_address.data));
12369 mp->collector_port = htons ((u16) collector_port);
12370 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12371 mp->vrf_id = htonl (vrf_id);
12372 mp->path_mtu = htonl (path_mtu);
12373 mp->template_interval = htonl (template_interval);
12374 mp->udp_checksum = udp_checksum;
12382 api_set_ipfix_classify_stream (vat_main_t * vam)
12384 unformat_input_t *i = vam->input;
12385 vl_api_set_ipfix_classify_stream_t *mp;
12387 u32 src_port = UDP_DST_PORT_ipfix;
12390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12392 if (unformat (i, "domain %d", &domain_id))
12394 else if (unformat (i, "src_port %d", &src_port))
12398 errmsg ("unknown input `%U'", format_unformat_error, i);
12403 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12405 mp->domain_id = htonl (domain_id);
12406 mp->src_port = htons ((u16) src_port);
12414 api_ipfix_classify_table_add_del (vat_main_t * vam)
12416 unformat_input_t *i = vam->input;
12417 vl_api_ipfix_classify_table_add_del_t *mp;
12419 u32 classify_table_index = ~0;
12421 u8 transport_protocol = 255;
12424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12426 if (unformat (i, "add"))
12428 else if (unformat (i, "del"))
12430 else if (unformat (i, "table %d", &classify_table_index))
12432 else if (unformat (i, "ip4"))
12434 else if (unformat (i, "ip6"))
12436 else if (unformat (i, "tcp"))
12437 transport_protocol = 6;
12438 else if (unformat (i, "udp"))
12439 transport_protocol = 17;
12442 errmsg ("unknown input `%U'", format_unformat_error, i);
12449 errmsg ("expecting: add|del");
12452 if (classify_table_index == ~0)
12454 errmsg ("classifier table not specified");
12457 if (ip_version == 0)
12459 errmsg ("IP version not specified");
12463 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12465 mp->is_add = is_add;
12466 mp->table_id = htonl (classify_table_index);
12467 mp->ip_version = ip_version;
12468 mp->transport_protocol = transport_protocol;
12476 api_get_node_index (vat_main_t * vam)
12478 unformat_input_t *i = vam->input;
12479 vl_api_get_node_index_t *mp;
12483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12485 if (unformat (i, "node %s", &name))
12492 errmsg ("node name required");
12495 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12497 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12501 M (GET_NODE_INDEX, mp);
12502 clib_memcpy (mp->node_name, name, vec_len (name));
12511 api_get_next_index (vat_main_t * vam)
12513 unformat_input_t *i = vam->input;
12514 vl_api_get_next_index_t *mp;
12515 u8 *node_name = 0, *next_node_name = 0;
12518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12520 if (unformat (i, "node-name %s", &node_name))
12522 else if (unformat (i, "next-node-name %s", &next_node_name))
12526 if (node_name == 0)
12528 errmsg ("node name required");
12531 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12533 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12537 if (next_node_name == 0)
12539 errmsg ("next node name required");
12542 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12544 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12548 M (GET_NEXT_INDEX, mp);
12549 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12550 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12551 vec_free (node_name);
12552 vec_free (next_node_name);
12560 api_add_node_next (vat_main_t * vam)
12562 unformat_input_t *i = vam->input;
12563 vl_api_add_node_next_t *mp;
12568 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12570 if (unformat (i, "node %s", &name))
12572 else if (unformat (i, "next %s", &next))
12579 errmsg ("node name required");
12582 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12584 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12589 errmsg ("next node required");
12592 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12594 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12598 M (ADD_NODE_NEXT, mp);
12599 clib_memcpy (mp->node_name, name, vec_len (name));
12600 clib_memcpy (mp->next_name, next, vec_len (next));
12610 api_l2tpv3_create_tunnel (vat_main_t * vam)
12612 unformat_input_t *i = vam->input;
12613 ip6_address_t client_address, our_address;
12614 int client_address_set = 0;
12615 int our_address_set = 0;
12616 u32 local_session_id = 0;
12617 u32 remote_session_id = 0;
12618 u64 local_cookie = 0;
12619 u64 remote_cookie = 0;
12620 u8 l2_sublayer_present = 0;
12621 vl_api_l2tpv3_create_tunnel_t *mp;
12624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12626 if (unformat (i, "client_address %U", unformat_ip6_address,
12628 client_address_set = 1;
12629 else if (unformat (i, "our_address %U", unformat_ip6_address,
12631 our_address_set = 1;
12632 else if (unformat (i, "local_session_id %d", &local_session_id))
12634 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12636 else if (unformat (i, "local_cookie %lld", &local_cookie))
12638 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12640 else if (unformat (i, "l2-sublayer-present"))
12641 l2_sublayer_present = 1;
12646 if (client_address_set == 0)
12648 errmsg ("client_address required");
12652 if (our_address_set == 0)
12654 errmsg ("our_address required");
12658 M (L2TPV3_CREATE_TUNNEL, mp);
12660 clib_memcpy (mp->client_address, client_address.as_u8,
12661 sizeof (mp->client_address));
12663 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12665 mp->local_session_id = ntohl (local_session_id);
12666 mp->remote_session_id = ntohl (remote_session_id);
12667 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12668 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12669 mp->l2_sublayer_present = l2_sublayer_present;
12678 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12680 unformat_input_t *i = vam->input;
12682 u8 sw_if_index_set = 0;
12683 u64 new_local_cookie = 0;
12684 u64 new_remote_cookie = 0;
12685 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12690 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12691 sw_if_index_set = 1;
12692 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12693 sw_if_index_set = 1;
12694 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12696 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12702 if (sw_if_index_set == 0)
12704 errmsg ("missing interface name or sw_if_index");
12708 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12710 mp->sw_if_index = ntohl (sw_if_index);
12711 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12712 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12720 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12722 unformat_input_t *i = vam->input;
12723 vl_api_l2tpv3_interface_enable_disable_t *mp;
12725 u8 sw_if_index_set = 0;
12726 u8 enable_disable = 1;
12729 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12731 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12732 sw_if_index_set = 1;
12733 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12734 sw_if_index_set = 1;
12735 else if (unformat (i, "enable"))
12736 enable_disable = 1;
12737 else if (unformat (i, "disable"))
12738 enable_disable = 0;
12743 if (sw_if_index_set == 0)
12745 errmsg ("missing interface name or sw_if_index");
12749 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12751 mp->sw_if_index = ntohl (sw_if_index);
12752 mp->enable_disable = enable_disable;
12760 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12762 unformat_input_t *i = vam->input;
12763 vl_api_l2tpv3_set_lookup_key_t *mp;
12767 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12769 if (unformat (i, "lookup_v6_src"))
12770 key = L2T_LOOKUP_SRC_ADDRESS;
12771 else if (unformat (i, "lookup_v6_dst"))
12772 key = L2T_LOOKUP_DST_ADDRESS;
12773 else if (unformat (i, "lookup_session_id"))
12774 key = L2T_LOOKUP_SESSION_ID;
12779 if (key == (u8) ~ 0)
12781 errmsg ("l2tp session lookup key unset");
12785 M (L2TPV3_SET_LOOKUP_KEY, mp);
12794 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12795 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12797 vat_main_t *vam = &vat_main;
12799 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12800 format_ip6_address, mp->our_address,
12801 format_ip6_address, mp->client_address,
12802 clib_net_to_host_u32 (mp->sw_if_index));
12805 " local cookies %016llx %016llx remote cookie %016llx",
12806 clib_net_to_host_u64 (mp->local_cookie[0]),
12807 clib_net_to_host_u64 (mp->local_cookie[1]),
12808 clib_net_to_host_u64 (mp->remote_cookie));
12810 print (vam->ofp, " local session-id %d remote session-id %d",
12811 clib_net_to_host_u32 (mp->local_session_id),
12812 clib_net_to_host_u32 (mp->remote_session_id));
12814 print (vam->ofp, " l2 specific sublayer %s\n",
12815 mp->l2_sublayer_present ? "preset" : "absent");
12819 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12820 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12822 vat_main_t *vam = &vat_main;
12823 vat_json_node_t *node = NULL;
12824 struct in6_addr addr;
12826 if (VAT_JSON_ARRAY != vam->json_tree.type)
12828 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12829 vat_json_init_array (&vam->json_tree);
12831 node = vat_json_array_add (&vam->json_tree);
12833 vat_json_init_object (node);
12835 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12836 vat_json_object_add_ip6 (node, "our_address", addr);
12837 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12838 vat_json_object_add_ip6 (node, "client_address", addr);
12840 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12841 vat_json_init_array (lc);
12842 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12843 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12844 vat_json_object_add_uint (node, "remote_cookie",
12845 clib_net_to_host_u64 (mp->remote_cookie));
12847 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12848 vat_json_object_add_uint (node, "local_session_id",
12849 clib_net_to_host_u32 (mp->local_session_id));
12850 vat_json_object_add_uint (node, "remote_session_id",
12851 clib_net_to_host_u32 (mp->remote_session_id));
12852 vat_json_object_add_string_copy (node, "l2_sublayer",
12853 mp->l2_sublayer_present ? (u8 *) "present"
12854 : (u8 *) "absent");
12858 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12860 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12861 vl_api_control_ping_t *mp_ping;
12864 /* Get list of l2tpv3-tunnel interfaces */
12865 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12868 /* Use a control ping for synchronization */
12869 MPING (CONTROL_PING, mp_ping);
12877 static void vl_api_sw_interface_tap_details_t_handler
12878 (vl_api_sw_interface_tap_details_t * mp)
12880 vat_main_t *vam = &vat_main;
12882 print (vam->ofp, "%-16s %d",
12883 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12886 static void vl_api_sw_interface_tap_details_t_handler_json
12887 (vl_api_sw_interface_tap_details_t * mp)
12889 vat_main_t *vam = &vat_main;
12890 vat_json_node_t *node = NULL;
12892 if (VAT_JSON_ARRAY != vam->json_tree.type)
12894 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12895 vat_json_init_array (&vam->json_tree);
12897 node = vat_json_array_add (&vam->json_tree);
12899 vat_json_init_object (node);
12900 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12901 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12905 api_sw_interface_tap_dump (vat_main_t * vam)
12907 vl_api_sw_interface_tap_dump_t *mp;
12908 vl_api_control_ping_t *mp_ping;
12911 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12912 /* Get list of tap interfaces */
12913 M (SW_INTERFACE_TAP_DUMP, mp);
12916 /* Use a control ping for synchronization */
12917 MPING (CONTROL_PING, mp_ping);
12924 static void vl_api_sw_interface_tap_v2_details_t_handler
12925 (vl_api_sw_interface_tap_v2_details_t * mp)
12927 vat_main_t *vam = &vat_main;
12929 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12930 mp->host_ip4_prefix_len);
12931 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12932 mp->host_ip6_prefix_len);
12935 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12936 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12937 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12938 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12939 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12945 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12946 (vl_api_sw_interface_tap_v2_details_t * mp)
12948 vat_main_t *vam = &vat_main;
12949 vat_json_node_t *node = NULL;
12951 if (VAT_JSON_ARRAY != vam->json_tree.type)
12953 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12954 vat_json_init_array (&vam->json_tree);
12956 node = vat_json_array_add (&vam->json_tree);
12958 vat_json_init_object (node);
12959 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12960 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12961 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12962 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12963 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12964 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12965 vat_json_object_add_string_copy (node, "host_mac_addr",
12966 format (0, "%U", format_ethernet_address,
12967 &mp->host_mac_addr));
12968 vat_json_object_add_string_copy (node, "host_namespace",
12969 mp->host_namespace);
12970 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12971 vat_json_object_add_string_copy (node, "host_ip4_addr",
12972 format (0, "%U/%d", format_ip4_address,
12974 mp->host_ip4_prefix_len));
12975 vat_json_object_add_string_copy (node, "host_ip6_addr",
12976 format (0, "%U/%d", format_ip6_address,
12978 mp->host_ip6_prefix_len));
12983 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12985 vl_api_sw_interface_tap_v2_dump_t *mp;
12986 vl_api_control_ping_t *mp_ping;
12990 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12991 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12992 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12995 /* Get list of tap interfaces */
12996 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12999 /* Use a control ping for synchronization */
13000 MPING (CONTROL_PING, mp_ping);
13007 static void vl_api_sw_interface_virtio_pci_details_t_handler
13008 (vl_api_sw_interface_virtio_pci_details_t * mp)
13010 vat_main_t *vam = &vat_main;
13024 addr.as_u32 = ntohl (mp->pci_addr);
13025 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
13026 addr.slot, addr.function);
13029 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
13030 pci_addr, ntohl (mp->sw_if_index),
13031 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
13032 format_ethernet_address, mp->mac_addr,
13033 clib_net_to_host_u64 (mp->features));
13034 vec_free (pci_addr);
13037 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
13038 (vl_api_sw_interface_virtio_pci_details_t * mp)
13040 vat_main_t *vam = &vat_main;
13041 vat_json_node_t *node = NULL;
13043 if (VAT_JSON_ARRAY != vam->json_tree.type)
13045 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13046 vat_json_init_array (&vam->json_tree);
13048 node = vat_json_array_add (&vam->json_tree);
13050 vat_json_init_object (node);
13051 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
13052 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13053 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
13054 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
13055 vat_json_object_add_uint (node, "features",
13056 clib_net_to_host_u64 (mp->features));
13057 vat_json_object_add_string_copy (node, "mac_addr",
13058 format (0, "%U", format_ethernet_address,
13063 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
13065 vl_api_sw_interface_virtio_pci_dump_t *mp;
13066 vl_api_control_ping_t *mp_ping;
13070 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
13071 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
13072 "mac_addr", "features");
13074 /* Get list of tap interfaces */
13075 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
13078 /* Use a control ping for synchronization */
13079 MPING (CONTROL_PING, mp_ping);
13087 api_vxlan_offload_rx (vat_main_t * vam)
13089 unformat_input_t *line_input = vam->input;
13090 vl_api_vxlan_offload_rx_t *mp;
13091 u32 hw_if_index = ~0, rx_if_index = ~0;
13095 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13097 if (unformat (line_input, "del"))
13099 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
13102 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
13104 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
13107 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
13111 errmsg ("parse error '%U'", format_unformat_error, line_input);
13116 if (hw_if_index == ~0)
13118 errmsg ("no hw interface");
13122 if (rx_if_index == ~0)
13124 errmsg ("no rx tunnel");
13128 M (VXLAN_OFFLOAD_RX, mp);
13130 mp->hw_if_index = ntohl (hw_if_index);
13131 mp->sw_if_index = ntohl (rx_if_index);
13132 mp->enable = is_add;
13139 static uword unformat_vxlan_decap_next
13140 (unformat_input_t * input, va_list * args)
13142 u32 *result = va_arg (*args, u32 *);
13145 if (unformat (input, "l2"))
13146 *result = VXLAN_INPUT_NEXT_L2_INPUT;
13147 else if (unformat (input, "%d", &tmp))
13155 api_vxlan_add_del_tunnel (vat_main_t * vam)
13157 unformat_input_t *line_input = vam->input;
13158 vl_api_vxlan_add_del_tunnel_t *mp;
13159 ip46_address_t src, dst;
13161 u8 ipv4_set = 0, ipv6_set = 0;
13166 u32 mcast_sw_if_index = ~0;
13167 u32 encap_vrf_id = 0;
13168 u32 decap_next_index = ~0;
13172 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13173 clib_memset (&src, 0, sizeof src);
13174 clib_memset (&dst, 0, sizeof dst);
13176 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13178 if (unformat (line_input, "del"))
13180 else if (unformat (line_input, "instance %d", &instance))
13183 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13189 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13195 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13201 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13206 else if (unformat (line_input, "group %U %U",
13207 unformat_ip4_address, &dst.ip4,
13208 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13210 grp_set = dst_set = 1;
13213 else if (unformat (line_input, "group %U",
13214 unformat_ip4_address, &dst.ip4))
13216 grp_set = dst_set = 1;
13219 else if (unformat (line_input, "group %U %U",
13220 unformat_ip6_address, &dst.ip6,
13221 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13223 grp_set = dst_set = 1;
13226 else if (unformat (line_input, "group %U",
13227 unformat_ip6_address, &dst.ip6))
13229 grp_set = dst_set = 1;
13233 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13235 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13237 else if (unformat (line_input, "decap-next %U",
13238 unformat_vxlan_decap_next, &decap_next_index))
13240 else if (unformat (line_input, "vni %d", &vni))
13244 errmsg ("parse error '%U'", format_unformat_error, line_input);
13251 errmsg ("tunnel src address not specified");
13256 errmsg ("tunnel dst address not specified");
13260 if (grp_set && !ip46_address_is_multicast (&dst))
13262 errmsg ("tunnel group address not multicast");
13265 if (grp_set && mcast_sw_if_index == ~0)
13267 errmsg ("tunnel nonexistent multicast device");
13270 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13272 errmsg ("tunnel dst address must be unicast");
13277 if (ipv4_set && ipv6_set)
13279 errmsg ("both IPv4 and IPv6 addresses specified");
13283 if ((vni == 0) || (vni >> 24))
13285 errmsg ("vni not specified or out of range");
13289 M (VXLAN_ADD_DEL_TUNNEL, mp);
13293 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13294 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13298 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13299 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13302 mp->instance = htonl (instance);
13303 mp->encap_vrf_id = ntohl (encap_vrf_id);
13304 mp->decap_next_index = ntohl (decap_next_index);
13305 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13306 mp->vni = ntohl (vni);
13307 mp->is_add = is_add;
13308 mp->is_ipv6 = ipv6_set;
13315 static void vl_api_vxlan_tunnel_details_t_handler
13316 (vl_api_vxlan_tunnel_details_t * mp)
13318 vat_main_t *vam = &vat_main;
13319 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13320 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13322 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13323 ntohl (mp->sw_if_index),
13324 ntohl (mp->instance),
13325 format_ip46_address, &src, IP46_TYPE_ANY,
13326 format_ip46_address, &dst, IP46_TYPE_ANY,
13327 ntohl (mp->encap_vrf_id),
13328 ntohl (mp->decap_next_index), ntohl (mp->vni),
13329 ntohl (mp->mcast_sw_if_index));
13332 static void vl_api_vxlan_tunnel_details_t_handler_json
13333 (vl_api_vxlan_tunnel_details_t * mp)
13335 vat_main_t *vam = &vat_main;
13336 vat_json_node_t *node = NULL;
13338 if (VAT_JSON_ARRAY != vam->json_tree.type)
13340 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13341 vat_json_init_array (&vam->json_tree);
13343 node = vat_json_array_add (&vam->json_tree);
13345 vat_json_init_object (node);
13346 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13348 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13352 struct in6_addr ip6;
13354 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13355 vat_json_object_add_ip6 (node, "src_address", ip6);
13356 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13357 vat_json_object_add_ip6 (node, "dst_address", ip6);
13361 struct in_addr ip4;
13363 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13364 vat_json_object_add_ip4 (node, "src_address", ip4);
13365 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13366 vat_json_object_add_ip4 (node, "dst_address", ip4);
13368 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13369 vat_json_object_add_uint (node, "decap_next_index",
13370 ntohl (mp->decap_next_index));
13371 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13372 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13373 vat_json_object_add_uint (node, "mcast_sw_if_index",
13374 ntohl (mp->mcast_sw_if_index));
13378 api_vxlan_tunnel_dump (vat_main_t * vam)
13380 unformat_input_t *i = vam->input;
13381 vl_api_vxlan_tunnel_dump_t *mp;
13382 vl_api_control_ping_t *mp_ping;
13384 u8 sw_if_index_set = 0;
13387 /* Parse args required to build the message */
13388 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13390 if (unformat (i, "sw_if_index %d", &sw_if_index))
13391 sw_if_index_set = 1;
13396 if (sw_if_index_set == 0)
13401 if (!vam->json_output)
13403 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13404 "sw_if_index", "instance", "src_address", "dst_address",
13405 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13408 /* Get list of vxlan-tunnel interfaces */
13409 M (VXLAN_TUNNEL_DUMP, mp);
13411 mp->sw_if_index = htonl (sw_if_index);
13415 /* Use a control ping for synchronization */
13416 MPING (CONTROL_PING, mp_ping);
13423 static uword unformat_geneve_decap_next
13424 (unformat_input_t * input, va_list * args)
13426 u32 *result = va_arg (*args, u32 *);
13429 if (unformat (input, "l2"))
13430 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13431 else if (unformat (input, "%d", &tmp))
13439 api_geneve_add_del_tunnel (vat_main_t * vam)
13441 unformat_input_t *line_input = vam->input;
13442 vl_api_geneve_add_del_tunnel_t *mp;
13443 ip46_address_t src, dst;
13445 u8 ipv4_set = 0, ipv6_set = 0;
13449 u32 mcast_sw_if_index = ~0;
13450 u32 encap_vrf_id = 0;
13451 u32 decap_next_index = ~0;
13455 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13456 clib_memset (&src, 0, sizeof src);
13457 clib_memset (&dst, 0, sizeof dst);
13459 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13461 if (unformat (line_input, "del"))
13464 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13470 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13476 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13482 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13487 else if (unformat (line_input, "group %U %U",
13488 unformat_ip4_address, &dst.ip4,
13489 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13491 grp_set = dst_set = 1;
13494 else if (unformat (line_input, "group %U",
13495 unformat_ip4_address, &dst.ip4))
13497 grp_set = dst_set = 1;
13500 else if (unformat (line_input, "group %U %U",
13501 unformat_ip6_address, &dst.ip6,
13502 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13504 grp_set = dst_set = 1;
13507 else if (unformat (line_input, "group %U",
13508 unformat_ip6_address, &dst.ip6))
13510 grp_set = dst_set = 1;
13514 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13516 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13518 else if (unformat (line_input, "decap-next %U",
13519 unformat_geneve_decap_next, &decap_next_index))
13521 else if (unformat (line_input, "vni %d", &vni))
13525 errmsg ("parse error '%U'", format_unformat_error, line_input);
13532 errmsg ("tunnel src address not specified");
13537 errmsg ("tunnel dst address not specified");
13541 if (grp_set && !ip46_address_is_multicast (&dst))
13543 errmsg ("tunnel group address not multicast");
13546 if (grp_set && mcast_sw_if_index == ~0)
13548 errmsg ("tunnel nonexistent multicast device");
13551 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13553 errmsg ("tunnel dst address must be unicast");
13558 if (ipv4_set && ipv6_set)
13560 errmsg ("both IPv4 and IPv6 addresses specified");
13564 if ((vni == 0) || (vni >> 24))
13566 errmsg ("vni not specified or out of range");
13570 M (GENEVE_ADD_DEL_TUNNEL, mp);
13574 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13575 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13579 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13580 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13582 mp->encap_vrf_id = ntohl (encap_vrf_id);
13583 mp->decap_next_index = ntohl (decap_next_index);
13584 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13585 mp->vni = ntohl (vni);
13586 mp->is_add = is_add;
13587 mp->is_ipv6 = ipv6_set;
13594 static void vl_api_geneve_tunnel_details_t_handler
13595 (vl_api_geneve_tunnel_details_t * mp)
13597 vat_main_t *vam = &vat_main;
13598 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13599 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13601 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13602 ntohl (mp->sw_if_index),
13603 format_ip46_address, &src, IP46_TYPE_ANY,
13604 format_ip46_address, &dst, IP46_TYPE_ANY,
13605 ntohl (mp->encap_vrf_id),
13606 ntohl (mp->decap_next_index), ntohl (mp->vni),
13607 ntohl (mp->mcast_sw_if_index));
13610 static void vl_api_geneve_tunnel_details_t_handler_json
13611 (vl_api_geneve_tunnel_details_t * mp)
13613 vat_main_t *vam = &vat_main;
13614 vat_json_node_t *node = NULL;
13616 if (VAT_JSON_ARRAY != vam->json_tree.type)
13618 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13619 vat_json_init_array (&vam->json_tree);
13621 node = vat_json_array_add (&vam->json_tree);
13623 vat_json_init_object (node);
13624 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13627 struct in6_addr ip6;
13629 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13630 vat_json_object_add_ip6 (node, "src_address", ip6);
13631 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13632 vat_json_object_add_ip6 (node, "dst_address", ip6);
13636 struct in_addr ip4;
13638 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13639 vat_json_object_add_ip4 (node, "src_address", ip4);
13640 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13641 vat_json_object_add_ip4 (node, "dst_address", ip4);
13643 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13644 vat_json_object_add_uint (node, "decap_next_index",
13645 ntohl (mp->decap_next_index));
13646 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13647 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13648 vat_json_object_add_uint (node, "mcast_sw_if_index",
13649 ntohl (mp->mcast_sw_if_index));
13653 api_geneve_tunnel_dump (vat_main_t * vam)
13655 unformat_input_t *i = vam->input;
13656 vl_api_geneve_tunnel_dump_t *mp;
13657 vl_api_control_ping_t *mp_ping;
13659 u8 sw_if_index_set = 0;
13662 /* Parse args required to build the message */
13663 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13665 if (unformat (i, "sw_if_index %d", &sw_if_index))
13666 sw_if_index_set = 1;
13671 if (sw_if_index_set == 0)
13676 if (!vam->json_output)
13678 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13679 "sw_if_index", "local_address", "remote_address",
13680 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13683 /* Get list of geneve-tunnel interfaces */
13684 M (GENEVE_TUNNEL_DUMP, mp);
13686 mp->sw_if_index = htonl (sw_if_index);
13690 /* Use a control ping for synchronization */
13691 M (CONTROL_PING, mp_ping);
13699 api_gre_add_del_tunnel (vat_main_t * vam)
13701 unformat_input_t *line_input = vam->input;
13702 vl_api_gre_add_del_tunnel_t *mp;
13703 ip4_address_t src4, dst4;
13704 ip6_address_t src6, dst6;
13708 u8 t_type = GRE_TUNNEL_TYPE_L3;
13711 u32 outer_fib_id = 0;
13712 u32 session_id = 0;
13716 clib_memset (&src4, 0, sizeof src4);
13717 clib_memset (&dst4, 0, sizeof dst4);
13718 clib_memset (&src6, 0, sizeof src6);
13719 clib_memset (&dst6, 0, sizeof dst6);
13721 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13723 if (unformat (line_input, "del"))
13725 else if (unformat (line_input, "instance %d", &instance))
13727 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13732 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13737 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13742 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13747 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13749 else if (unformat (line_input, "teb"))
13750 t_type = GRE_TUNNEL_TYPE_TEB;
13751 else if (unformat (line_input, "erspan %d", &session_id))
13752 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13755 errmsg ("parse error '%U'", format_unformat_error, line_input);
13762 errmsg ("tunnel src address not specified");
13767 errmsg ("tunnel dst address not specified");
13770 if (ipv4_set && ipv6_set)
13772 errmsg ("both IPv4 and IPv6 addresses specified");
13777 M (GRE_ADD_DEL_TUNNEL, mp);
13781 clib_memcpy (&mp->src_address, &src4, 4);
13782 clib_memcpy (&mp->dst_address, &dst4, 4);
13786 clib_memcpy (&mp->src_address, &src6, 16);
13787 clib_memcpy (&mp->dst_address, &dst6, 16);
13789 mp->instance = htonl (instance);
13790 mp->outer_fib_id = htonl (outer_fib_id);
13791 mp->is_add = is_add;
13792 mp->session_id = htons ((u16) session_id);
13793 mp->tunnel_type = t_type;
13794 mp->is_ipv6 = ipv6_set;
13801 static void vl_api_gre_tunnel_details_t_handler
13802 (vl_api_gre_tunnel_details_t * mp)
13804 vat_main_t *vam = &vat_main;
13805 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13806 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13808 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13809 ntohl (mp->sw_if_index),
13810 ntohl (mp->instance),
13811 format_ip46_address, &src, IP46_TYPE_ANY,
13812 format_ip46_address, &dst, IP46_TYPE_ANY,
13813 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13816 static void vl_api_gre_tunnel_details_t_handler_json
13817 (vl_api_gre_tunnel_details_t * mp)
13819 vat_main_t *vam = &vat_main;
13820 vat_json_node_t *node = NULL;
13821 struct in_addr ip4;
13822 struct in6_addr ip6;
13824 if (VAT_JSON_ARRAY != vam->json_tree.type)
13826 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13827 vat_json_init_array (&vam->json_tree);
13829 node = vat_json_array_add (&vam->json_tree);
13831 vat_json_init_object (node);
13832 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13833 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13836 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13837 vat_json_object_add_ip4 (node, "src_address", ip4);
13838 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13839 vat_json_object_add_ip4 (node, "dst_address", ip4);
13843 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13844 vat_json_object_add_ip6 (node, "src_address", ip6);
13845 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13846 vat_json_object_add_ip6 (node, "dst_address", ip6);
13848 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13849 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13850 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13851 vat_json_object_add_uint (node, "session_id", mp->session_id);
13855 api_gre_tunnel_dump (vat_main_t * vam)
13857 unformat_input_t *i = vam->input;
13858 vl_api_gre_tunnel_dump_t *mp;
13859 vl_api_control_ping_t *mp_ping;
13861 u8 sw_if_index_set = 0;
13864 /* Parse args required to build the message */
13865 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13867 if (unformat (i, "sw_if_index %d", &sw_if_index))
13868 sw_if_index_set = 1;
13873 if (sw_if_index_set == 0)
13878 if (!vam->json_output)
13880 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13881 "sw_if_index", "instance", "src_address", "dst_address",
13882 "tunnel_type", "outer_fib_id", "session_id");
13885 /* Get list of gre-tunnel interfaces */
13886 M (GRE_TUNNEL_DUMP, mp);
13888 mp->sw_if_index = htonl (sw_if_index);
13892 /* Use a control ping for synchronization */
13893 MPING (CONTROL_PING, mp_ping);
13901 api_l2_fib_clear_table (vat_main_t * vam)
13903 // unformat_input_t * i = vam->input;
13904 vl_api_l2_fib_clear_table_t *mp;
13907 M (L2_FIB_CLEAR_TABLE, mp);
13915 api_l2_interface_efp_filter (vat_main_t * vam)
13917 unformat_input_t *i = vam->input;
13918 vl_api_l2_interface_efp_filter_t *mp;
13921 u8 sw_if_index_set = 0;
13924 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13926 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13927 sw_if_index_set = 1;
13928 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13929 sw_if_index_set = 1;
13930 else if (unformat (i, "enable"))
13932 else if (unformat (i, "disable"))
13936 clib_warning ("parse error '%U'", format_unformat_error, i);
13941 if (sw_if_index_set == 0)
13943 errmsg ("missing sw_if_index");
13947 M (L2_INTERFACE_EFP_FILTER, mp);
13949 mp->sw_if_index = ntohl (sw_if_index);
13950 mp->enable_disable = enable;
13957 #define foreach_vtr_op \
13958 _("disable", L2_VTR_DISABLED) \
13959 _("push-1", L2_VTR_PUSH_1) \
13960 _("push-2", L2_VTR_PUSH_2) \
13961 _("pop-1", L2_VTR_POP_1) \
13962 _("pop-2", L2_VTR_POP_2) \
13963 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13964 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13965 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13966 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13969 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13971 unformat_input_t *i = vam->input;
13972 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13974 u8 sw_if_index_set = 0;
13977 u32 push_dot1q = 1;
13982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13984 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13985 sw_if_index_set = 1;
13986 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13987 sw_if_index_set = 1;
13988 else if (unformat (i, "vtr_op %d", &vtr_op))
13990 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13993 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13995 else if (unformat (i, "tag1 %d", &tag1))
13997 else if (unformat (i, "tag2 %d", &tag2))
14001 clib_warning ("parse error '%U'", format_unformat_error, i);
14006 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
14008 errmsg ("missing vtr operation or sw_if_index");
14012 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
14013 mp->sw_if_index = ntohl (sw_if_index);
14014 mp->vtr_op = ntohl (vtr_op);
14015 mp->push_dot1q = ntohl (push_dot1q);
14016 mp->tag1 = ntohl (tag1);
14017 mp->tag2 = ntohl (tag2);
14025 api_create_vhost_user_if (vat_main_t * vam)
14027 unformat_input_t *i = vam->input;
14028 vl_api_create_vhost_user_if_t *mp;
14031 u8 file_name_set = 0;
14032 u32 custom_dev_instance = ~0;
14034 u8 use_custom_mac = 0;
14035 u8 disable_mrg_rxbuf = 0;
14036 u8 disable_indirect_desc = 0;
14040 /* Shut up coverity */
14041 clib_memset (hwaddr, 0, sizeof (hwaddr));
14043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14045 if (unformat (i, "socket %s", &file_name))
14049 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14051 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
14052 use_custom_mac = 1;
14053 else if (unformat (i, "server"))
14055 else if (unformat (i, "disable_mrg_rxbuf"))
14056 disable_mrg_rxbuf = 1;
14057 else if (unformat (i, "disable_indirect_desc"))
14058 disable_indirect_desc = 1;
14059 else if (unformat (i, "tag %s", &tag))
14065 if (file_name_set == 0)
14067 errmsg ("missing socket file name");
14071 if (vec_len (file_name) > 255)
14073 errmsg ("socket file name too long");
14076 vec_add1 (file_name, 0);
14078 M (CREATE_VHOST_USER_IF, mp);
14080 mp->is_server = is_server;
14081 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
14082 mp->disable_indirect_desc = disable_indirect_desc;
14083 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14084 vec_free (file_name);
14085 if (custom_dev_instance != ~0)
14088 mp->custom_dev_instance = ntohl (custom_dev_instance);
14091 mp->use_custom_mac = use_custom_mac;
14092 clib_memcpy (mp->mac_address, hwaddr, 6);
14094 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
14103 api_modify_vhost_user_if (vat_main_t * vam)
14105 unformat_input_t *i = vam->input;
14106 vl_api_modify_vhost_user_if_t *mp;
14109 u8 file_name_set = 0;
14110 u32 custom_dev_instance = ~0;
14111 u8 sw_if_index_set = 0;
14112 u32 sw_if_index = (u32) ~ 0;
14115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14117 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14118 sw_if_index_set = 1;
14119 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14120 sw_if_index_set = 1;
14121 else if (unformat (i, "socket %s", &file_name))
14125 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
14127 else if (unformat (i, "server"))
14133 if (sw_if_index_set == 0)
14135 errmsg ("missing sw_if_index or interface name");
14139 if (file_name_set == 0)
14141 errmsg ("missing socket file name");
14145 if (vec_len (file_name) > 255)
14147 errmsg ("socket file name too long");
14150 vec_add1 (file_name, 0);
14152 M (MODIFY_VHOST_USER_IF, mp);
14154 mp->sw_if_index = ntohl (sw_if_index);
14155 mp->is_server = is_server;
14156 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
14157 vec_free (file_name);
14158 if (custom_dev_instance != ~0)
14161 mp->custom_dev_instance = ntohl (custom_dev_instance);
14170 api_delete_vhost_user_if (vat_main_t * vam)
14172 unformat_input_t *i = vam->input;
14173 vl_api_delete_vhost_user_if_t *mp;
14174 u32 sw_if_index = ~0;
14175 u8 sw_if_index_set = 0;
14178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14180 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14181 sw_if_index_set = 1;
14182 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14183 sw_if_index_set = 1;
14188 if (sw_if_index_set == 0)
14190 errmsg ("missing sw_if_index or interface name");
14195 M (DELETE_VHOST_USER_IF, mp);
14197 mp->sw_if_index = ntohl (sw_if_index);
14204 static void vl_api_sw_interface_vhost_user_details_t_handler
14205 (vl_api_sw_interface_vhost_user_details_t * mp)
14207 vat_main_t *vam = &vat_main;
14209 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14210 (char *) mp->interface_name,
14211 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14212 clib_net_to_host_u64 (mp->features), mp->is_server,
14213 ntohl (mp->num_regions), (char *) mp->sock_filename);
14214 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14217 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14218 (vl_api_sw_interface_vhost_user_details_t * mp)
14220 vat_main_t *vam = &vat_main;
14221 vat_json_node_t *node = NULL;
14223 if (VAT_JSON_ARRAY != vam->json_tree.type)
14225 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14226 vat_json_init_array (&vam->json_tree);
14228 node = vat_json_array_add (&vam->json_tree);
14230 vat_json_init_object (node);
14231 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14232 vat_json_object_add_string_copy (node, "interface_name",
14233 mp->interface_name);
14234 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14235 ntohl (mp->virtio_net_hdr_sz));
14236 vat_json_object_add_uint (node, "features",
14237 clib_net_to_host_u64 (mp->features));
14238 vat_json_object_add_uint (node, "is_server", mp->is_server);
14239 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14240 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14241 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14245 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14247 vl_api_sw_interface_vhost_user_dump_t *mp;
14248 vl_api_control_ping_t *mp_ping;
14251 "Interface name idx hdr_sz features server regions filename");
14253 /* Get list of vhost-user interfaces */
14254 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14257 /* Use a control ping for synchronization */
14258 MPING (CONTROL_PING, mp_ping);
14266 api_show_version (vat_main_t * vam)
14268 vl_api_show_version_t *mp;
14271 M (SHOW_VERSION, mp);
14280 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14282 unformat_input_t *line_input = vam->input;
14283 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14284 ip4_address_t local4, remote4;
14285 ip6_address_t local6, remote6;
14287 u8 ipv4_set = 0, ipv6_set = 0;
14291 u32 mcast_sw_if_index = ~0;
14292 u32 encap_vrf_id = 0;
14293 u32 decap_vrf_id = 0;
14299 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14300 clib_memset (&local4, 0, sizeof local4);
14301 clib_memset (&remote4, 0, sizeof remote4);
14302 clib_memset (&local6, 0, sizeof local6);
14303 clib_memset (&remote6, 0, sizeof remote6);
14305 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14307 if (unformat (line_input, "del"))
14309 else if (unformat (line_input, "local %U",
14310 unformat_ip4_address, &local4))
14315 else if (unformat (line_input, "remote %U",
14316 unformat_ip4_address, &remote4))
14321 else if (unformat (line_input, "local %U",
14322 unformat_ip6_address, &local6))
14327 else if (unformat (line_input, "remote %U",
14328 unformat_ip6_address, &remote6))
14333 else if (unformat (line_input, "group %U %U",
14334 unformat_ip4_address, &remote4,
14335 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14337 grp_set = remote_set = 1;
14340 else if (unformat (line_input, "group %U",
14341 unformat_ip4_address, &remote4))
14343 grp_set = remote_set = 1;
14346 else if (unformat (line_input, "group %U %U",
14347 unformat_ip6_address, &remote6,
14348 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14350 grp_set = remote_set = 1;
14353 else if (unformat (line_input, "group %U",
14354 unformat_ip6_address, &remote6))
14356 grp_set = remote_set = 1;
14360 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14362 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14364 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14366 else if (unformat (line_input, "vni %d", &vni))
14368 else if (unformat (line_input, "next-ip4"))
14370 else if (unformat (line_input, "next-ip6"))
14372 else if (unformat (line_input, "next-ethernet"))
14374 else if (unformat (line_input, "next-nsh"))
14378 errmsg ("parse error '%U'", format_unformat_error, line_input);
14383 if (local_set == 0)
14385 errmsg ("tunnel local address not specified");
14388 if (remote_set == 0)
14390 errmsg ("tunnel remote address not specified");
14393 if (grp_set && mcast_sw_if_index == ~0)
14395 errmsg ("tunnel nonexistent multicast device");
14398 if (ipv4_set && ipv6_set)
14400 errmsg ("both IPv4 and IPv6 addresses specified");
14406 errmsg ("vni not specified");
14410 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14415 clib_memcpy (&mp->local, &local6, sizeof (local6));
14416 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14420 clib_memcpy (&mp->local, &local4, sizeof (local4));
14421 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14424 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14425 mp->encap_vrf_id = ntohl (encap_vrf_id);
14426 mp->decap_vrf_id = ntohl (decap_vrf_id);
14427 mp->protocol = protocol;
14428 mp->vni = ntohl (vni);
14429 mp->is_add = is_add;
14430 mp->is_ipv6 = ipv6_set;
14437 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14438 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14440 vat_main_t *vam = &vat_main;
14441 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14442 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14444 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14445 ntohl (mp->sw_if_index),
14446 format_ip46_address, &local, IP46_TYPE_ANY,
14447 format_ip46_address, &remote, IP46_TYPE_ANY,
14448 ntohl (mp->vni), mp->protocol,
14449 ntohl (mp->mcast_sw_if_index),
14450 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14454 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14455 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14457 vat_main_t *vam = &vat_main;
14458 vat_json_node_t *node = NULL;
14459 struct in_addr ip4;
14460 struct in6_addr ip6;
14462 if (VAT_JSON_ARRAY != vam->json_tree.type)
14464 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14465 vat_json_init_array (&vam->json_tree);
14467 node = vat_json_array_add (&vam->json_tree);
14469 vat_json_init_object (node);
14470 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14473 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14474 vat_json_object_add_ip6 (node, "local", ip6);
14475 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14476 vat_json_object_add_ip6 (node, "remote", ip6);
14480 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14481 vat_json_object_add_ip4 (node, "local", ip4);
14482 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14483 vat_json_object_add_ip4 (node, "remote", ip4);
14485 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14486 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14487 vat_json_object_add_uint (node, "mcast_sw_if_index",
14488 ntohl (mp->mcast_sw_if_index));
14489 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14490 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14491 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14495 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14497 unformat_input_t *i = vam->input;
14498 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14499 vl_api_control_ping_t *mp_ping;
14501 u8 sw_if_index_set = 0;
14504 /* Parse args required to build the message */
14505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14507 if (unformat (i, "sw_if_index %d", &sw_if_index))
14508 sw_if_index_set = 1;
14513 if (sw_if_index_set == 0)
14518 if (!vam->json_output)
14520 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14521 "sw_if_index", "local", "remote", "vni",
14522 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14525 /* Get list of vxlan-tunnel interfaces */
14526 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14528 mp->sw_if_index = htonl (sw_if_index);
14532 /* Use a control ping for synchronization */
14533 MPING (CONTROL_PING, mp_ping);
14540 static void vl_api_l2_fib_table_details_t_handler
14541 (vl_api_l2_fib_table_details_t * mp)
14543 vat_main_t *vam = &vat_main;
14545 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14547 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14548 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14552 static void vl_api_l2_fib_table_details_t_handler_json
14553 (vl_api_l2_fib_table_details_t * mp)
14555 vat_main_t *vam = &vat_main;
14556 vat_json_node_t *node = NULL;
14558 if (VAT_JSON_ARRAY != vam->json_tree.type)
14560 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14561 vat_json_init_array (&vam->json_tree);
14563 node = vat_json_array_add (&vam->json_tree);
14565 vat_json_init_object (node);
14566 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14567 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14568 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14569 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14570 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14571 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14575 api_l2_fib_table_dump (vat_main_t * vam)
14577 unformat_input_t *i = vam->input;
14578 vl_api_l2_fib_table_dump_t *mp;
14579 vl_api_control_ping_t *mp_ping;
14584 /* Parse args required to build the message */
14585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14587 if (unformat (i, "bd_id %d", &bd_id))
14593 if (bd_id_set == 0)
14595 errmsg ("missing bridge domain");
14599 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14601 /* Get list of l2 fib entries */
14602 M (L2_FIB_TABLE_DUMP, mp);
14604 mp->bd_id = ntohl (bd_id);
14607 /* Use a control ping for synchronization */
14608 MPING (CONTROL_PING, mp_ping);
14617 api_interface_name_renumber (vat_main_t * vam)
14619 unformat_input_t *line_input = vam->input;
14620 vl_api_interface_name_renumber_t *mp;
14621 u32 sw_if_index = ~0;
14622 u32 new_show_dev_instance = ~0;
14625 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14627 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14630 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14632 else if (unformat (line_input, "new_show_dev_instance %d",
14633 &new_show_dev_instance))
14639 if (sw_if_index == ~0)
14641 errmsg ("missing interface name or sw_if_index");
14645 if (new_show_dev_instance == ~0)
14647 errmsg ("missing new_show_dev_instance");
14651 M (INTERFACE_NAME_RENUMBER, mp);
14653 mp->sw_if_index = ntohl (sw_if_index);
14654 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14662 api_ip_probe_neighbor (vat_main_t * vam)
14664 unformat_input_t *i = vam->input;
14665 vl_api_ip_probe_neighbor_t *mp;
14673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14675 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14677 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14679 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14681 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14692 errmsg ("missing interface");
14698 errmsg ("missing addresses");
14702 M (IP_PROBE_NEIGHBOR, mp);
14704 mp->sw_if_index = ntohl (sw_if_index);
14705 mp->is_ipv6 = is_ipv6;
14706 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14714 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14716 unformat_input_t *i = vam->input;
14717 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14718 u8 mode = IP_SCAN_V46_NEIGHBORS;
14719 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14724 if (unformat (i, "ip4"))
14725 mode = IP_SCAN_V4_NEIGHBORS;
14726 else if (unformat (i, "ip6"))
14727 mode = IP_SCAN_V6_NEIGHBORS;
14728 if (unformat (i, "both"))
14729 mode = IP_SCAN_V46_NEIGHBORS;
14730 else if (unformat (i, "disable"))
14731 mode = IP_SCAN_DISABLED;
14732 else if (unformat (i, "interval %d", &interval))
14734 else if (unformat (i, "max-time %d", &time))
14736 else if (unformat (i, "max-update %d", &update))
14738 else if (unformat (i, "delay %d", &delay))
14740 else if (unformat (i, "stale %d", &stale))
14746 if (interval > 255)
14748 errmsg ("interval cannot exceed 255 minutes.");
14753 errmsg ("max-time cannot exceed 255 usec.");
14758 errmsg ("max-update cannot exceed 255.");
14763 errmsg ("delay cannot exceed 255 msec.");
14768 errmsg ("stale cannot exceed 255 minutes.");
14772 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14774 mp->scan_interval = interval;
14775 mp->max_proc_time = time;
14776 mp->max_update = update;
14777 mp->scan_int_delay = delay;
14778 mp->stale_threshold = stale;
14786 api_want_ip4_arp_events (vat_main_t * vam)
14788 unformat_input_t *line_input = vam->input;
14789 vl_api_want_ip4_arp_events_t *mp;
14790 ip4_address_t address;
14791 int address_set = 0;
14792 u32 enable_disable = 1;
14795 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14797 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14799 else if (unformat (line_input, "del"))
14800 enable_disable = 0;
14805 if (address_set == 0)
14807 errmsg ("missing addresses");
14811 M (WANT_IP4_ARP_EVENTS, mp);
14812 mp->enable_disable = enable_disable;
14813 mp->pid = htonl (getpid ());
14814 mp->address = address.as_u32;
14822 api_want_ip6_nd_events (vat_main_t * vam)
14824 unformat_input_t *line_input = vam->input;
14825 vl_api_want_ip6_nd_events_t *mp;
14826 ip6_address_t address;
14827 int address_set = 0;
14828 u32 enable_disable = 1;
14831 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14833 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14835 else if (unformat (line_input, "del"))
14836 enable_disable = 0;
14841 if (address_set == 0)
14843 errmsg ("missing addresses");
14847 M (WANT_IP6_ND_EVENTS, mp);
14848 mp->enable_disable = enable_disable;
14849 mp->pid = htonl (getpid ());
14850 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14858 api_want_l2_macs_events (vat_main_t * vam)
14860 unformat_input_t *line_input = vam->input;
14861 vl_api_want_l2_macs_events_t *mp;
14862 u8 enable_disable = 1;
14863 u32 scan_delay = 0;
14864 u32 max_macs_in_event = 0;
14865 u32 learn_limit = 0;
14868 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14870 if (unformat (line_input, "learn-limit %d", &learn_limit))
14872 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14874 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14876 else if (unformat (line_input, "disable"))
14877 enable_disable = 0;
14882 M (WANT_L2_MACS_EVENTS, mp);
14883 mp->enable_disable = enable_disable;
14884 mp->pid = htonl (getpid ());
14885 mp->learn_limit = htonl (learn_limit);
14886 mp->scan_delay = (u8) scan_delay;
14887 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14894 api_input_acl_set_interface (vat_main_t * vam)
14896 unformat_input_t *i = vam->input;
14897 vl_api_input_acl_set_interface_t *mp;
14899 int sw_if_index_set;
14900 u32 ip4_table_index = ~0;
14901 u32 ip6_table_index = ~0;
14902 u32 l2_table_index = ~0;
14906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14908 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14909 sw_if_index_set = 1;
14910 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14911 sw_if_index_set = 1;
14912 else if (unformat (i, "del"))
14914 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14916 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14918 else if (unformat (i, "l2-table %d", &l2_table_index))
14922 clib_warning ("parse error '%U'", format_unformat_error, i);
14927 if (sw_if_index_set == 0)
14929 errmsg ("missing interface name or sw_if_index");
14933 M (INPUT_ACL_SET_INTERFACE, mp);
14935 mp->sw_if_index = ntohl (sw_if_index);
14936 mp->ip4_table_index = ntohl (ip4_table_index);
14937 mp->ip6_table_index = ntohl (ip6_table_index);
14938 mp->l2_table_index = ntohl (l2_table_index);
14939 mp->is_add = is_add;
14947 api_output_acl_set_interface (vat_main_t * vam)
14949 unformat_input_t *i = vam->input;
14950 vl_api_output_acl_set_interface_t *mp;
14952 int sw_if_index_set;
14953 u32 ip4_table_index = ~0;
14954 u32 ip6_table_index = ~0;
14955 u32 l2_table_index = ~0;
14959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14961 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14962 sw_if_index_set = 1;
14963 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14964 sw_if_index_set = 1;
14965 else if (unformat (i, "del"))
14967 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14969 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14971 else if (unformat (i, "l2-table %d", &l2_table_index))
14975 clib_warning ("parse error '%U'", format_unformat_error, i);
14980 if (sw_if_index_set == 0)
14982 errmsg ("missing interface name or sw_if_index");
14986 M (OUTPUT_ACL_SET_INTERFACE, mp);
14988 mp->sw_if_index = ntohl (sw_if_index);
14989 mp->ip4_table_index = ntohl (ip4_table_index);
14990 mp->ip6_table_index = ntohl (ip6_table_index);
14991 mp->l2_table_index = ntohl (l2_table_index);
14992 mp->is_add = is_add;
15000 api_ip_address_dump (vat_main_t * vam)
15002 unformat_input_t *i = vam->input;
15003 vl_api_ip_address_dump_t *mp;
15004 vl_api_control_ping_t *mp_ping;
15005 u32 sw_if_index = ~0;
15006 u8 sw_if_index_set = 0;
15011 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15013 if (unformat (i, "sw_if_index %d", &sw_if_index))
15014 sw_if_index_set = 1;
15016 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15017 sw_if_index_set = 1;
15018 else if (unformat (i, "ipv4"))
15020 else if (unformat (i, "ipv6"))
15026 if (ipv4_set && ipv6_set)
15028 errmsg ("ipv4 and ipv6 flags cannot be both set");
15032 if ((!ipv4_set) && (!ipv6_set))
15034 errmsg ("no ipv4 nor ipv6 flag set");
15038 if (sw_if_index_set == 0)
15040 errmsg ("missing interface name or sw_if_index");
15044 vam->current_sw_if_index = sw_if_index;
15045 vam->is_ipv6 = ipv6_set;
15047 M (IP_ADDRESS_DUMP, mp);
15048 mp->sw_if_index = ntohl (sw_if_index);
15049 mp->is_ipv6 = ipv6_set;
15052 /* Use a control ping for synchronization */
15053 MPING (CONTROL_PING, mp_ping);
15061 api_ip_dump (vat_main_t * vam)
15063 vl_api_ip_dump_t *mp;
15064 vl_api_control_ping_t *mp_ping;
15065 unformat_input_t *in = vam->input;
15072 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
15074 if (unformat (in, "ipv4"))
15076 else if (unformat (in, "ipv6"))
15082 if (ipv4_set && ipv6_set)
15084 errmsg ("ipv4 and ipv6 flags cannot be both set");
15088 if ((!ipv4_set) && (!ipv6_set))
15090 errmsg ("no ipv4 nor ipv6 flag set");
15094 is_ipv6 = ipv6_set;
15095 vam->is_ipv6 = is_ipv6;
15097 /* free old data */
15098 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
15100 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
15102 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
15105 mp->is_ipv6 = ipv6_set;
15108 /* Use a control ping for synchronization */
15109 MPING (CONTROL_PING, mp_ping);
15117 api_ipsec_spd_add_del (vat_main_t * vam)
15119 unformat_input_t *i = vam->input;
15120 vl_api_ipsec_spd_add_del_t *mp;
15125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15127 if (unformat (i, "spd_id %d", &spd_id))
15129 else if (unformat (i, "del"))
15133 clib_warning ("parse error '%U'", format_unformat_error, i);
15139 errmsg ("spd_id must be set");
15143 M (IPSEC_SPD_ADD_DEL, mp);
15145 mp->spd_id = ntohl (spd_id);
15146 mp->is_add = is_add;
15154 api_ipsec_interface_add_del_spd (vat_main_t * vam)
15156 unformat_input_t *i = vam->input;
15157 vl_api_ipsec_interface_add_del_spd_t *mp;
15159 u8 sw_if_index_set = 0;
15160 u32 spd_id = (u32) ~ 0;
15164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15166 if (unformat (i, "del"))
15168 else if (unformat (i, "spd_id %d", &spd_id))
15171 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15172 sw_if_index_set = 1;
15173 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15174 sw_if_index_set = 1;
15177 clib_warning ("parse error '%U'", format_unformat_error, i);
15183 if (spd_id == (u32) ~ 0)
15185 errmsg ("spd_id must be set");
15189 if (sw_if_index_set == 0)
15191 errmsg ("missing interface name or sw_if_index");
15195 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15197 mp->spd_id = ntohl (spd_id);
15198 mp->sw_if_index = ntohl (sw_if_index);
15199 mp->is_add = is_add;
15207 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15209 unformat_input_t *i = vam->input;
15210 vl_api_ipsec_spd_add_del_entry_t *mp;
15211 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15212 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15214 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15215 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15216 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15217 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15220 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15221 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15222 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15223 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15224 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15225 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15229 if (unformat (i, "del"))
15231 if (unformat (i, "outbound"))
15233 if (unformat (i, "inbound"))
15235 else if (unformat (i, "spd_id %d", &spd_id))
15237 else if (unformat (i, "sa_id %d", &sa_id))
15239 else if (unformat (i, "priority %d", &priority))
15241 else if (unformat (i, "protocol %d", &protocol))
15243 else if (unformat (i, "lport_start %d", &lport_start))
15245 else if (unformat (i, "lport_stop %d", &lport_stop))
15247 else if (unformat (i, "rport_start %d", &rport_start))
15249 else if (unformat (i, "rport_stop %d", &rport_stop))
15253 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15259 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15266 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15272 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15279 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15285 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15292 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15298 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15304 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15306 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15308 clib_warning ("unsupported action: 'resolve'");
15314 clib_warning ("parse error '%U'", format_unformat_error, i);
15320 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15322 mp->spd_id = ntohl (spd_id);
15323 mp->priority = ntohl (priority);
15324 mp->is_outbound = is_outbound;
15326 mp->is_ipv6 = is_ipv6;
15327 if (is_ipv6 || is_ip_any)
15329 clib_memcpy (mp->remote_address_start, &raddr6_start,
15330 sizeof (ip6_address_t));
15331 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15332 sizeof (ip6_address_t));
15333 clib_memcpy (mp->local_address_start, &laddr6_start,
15334 sizeof (ip6_address_t));
15335 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15336 sizeof (ip6_address_t));
15340 clib_memcpy (mp->remote_address_start, &raddr4_start,
15341 sizeof (ip4_address_t));
15342 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15343 sizeof (ip4_address_t));
15344 clib_memcpy (mp->local_address_start, &laddr4_start,
15345 sizeof (ip4_address_t));
15346 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15347 sizeof (ip4_address_t));
15349 mp->protocol = (u8) protocol;
15350 mp->local_port_start = ntohs ((u16) lport_start);
15351 mp->local_port_stop = ntohs ((u16) lport_stop);
15352 mp->remote_port_start = ntohs ((u16) rport_start);
15353 mp->remote_port_stop = ntohs ((u16) rport_stop);
15354 mp->policy = (u8) policy;
15355 mp->sa_id = ntohl (sa_id);
15356 mp->is_add = is_add;
15357 mp->is_ip_any = is_ip_any;
15364 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15366 unformat_input_t *i = vam->input;
15367 vl_api_ipsec_sad_add_del_entry_t *mp;
15368 u32 sad_id = 0, spi = 0;
15369 u8 *ck = 0, *ik = 0;
15372 u8 protocol = IPSEC_PROTOCOL_AH;
15373 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15374 u32 crypto_alg = 0, integ_alg = 0;
15375 ip4_address_t tun_src4;
15376 ip4_address_t tun_dst4;
15377 ip6_address_t tun_src6;
15378 ip6_address_t tun_dst6;
15381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15383 if (unformat (i, "del"))
15385 else if (unformat (i, "sad_id %d", &sad_id))
15387 else if (unformat (i, "spi %d", &spi))
15389 else if (unformat (i, "esp"))
15390 protocol = IPSEC_PROTOCOL_ESP;
15391 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15394 is_tunnel_ipv6 = 0;
15396 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15399 is_tunnel_ipv6 = 0;
15401 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15404 is_tunnel_ipv6 = 1;
15406 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15409 is_tunnel_ipv6 = 1;
15413 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15415 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15417 clib_warning ("unsupported crypto-alg: '%U'",
15418 format_ipsec_crypto_alg, crypto_alg);
15422 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15426 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15428 if (integ_alg >= IPSEC_INTEG_N_ALG)
15430 clib_warning ("unsupported integ-alg: '%U'",
15431 format_ipsec_integ_alg, integ_alg);
15435 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15439 clib_warning ("parse error '%U'", format_unformat_error, i);
15445 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15447 mp->sad_id = ntohl (sad_id);
15448 mp->is_add = is_add;
15449 mp->protocol = protocol;
15450 mp->spi = ntohl (spi);
15451 mp->is_tunnel = is_tunnel;
15452 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15453 mp->crypto_algorithm = crypto_alg;
15454 mp->integrity_algorithm = integ_alg;
15455 mp->crypto_key_length = vec_len (ck);
15456 mp->integrity_key_length = vec_len (ik);
15458 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15459 mp->crypto_key_length = sizeof (mp->crypto_key);
15461 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15462 mp->integrity_key_length = sizeof (mp->integrity_key);
15465 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15467 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15471 if (is_tunnel_ipv6)
15473 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15474 sizeof (ip6_address_t));
15475 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15476 sizeof (ip6_address_t));
15480 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15481 sizeof (ip4_address_t));
15482 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15483 sizeof (ip4_address_t));
15493 api_ipsec_sa_set_key (vat_main_t * vam)
15495 unformat_input_t *i = vam->input;
15496 vl_api_ipsec_sa_set_key_t *mp;
15498 u8 *ck = 0, *ik = 0;
15501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15503 if (unformat (i, "sa_id %d", &sa_id))
15505 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15507 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15511 clib_warning ("parse error '%U'", format_unformat_error, i);
15516 M (IPSEC_SA_SET_KEY, mp);
15518 mp->sa_id = ntohl (sa_id);
15519 mp->crypto_key_length = vec_len (ck);
15520 mp->integrity_key_length = vec_len (ik);
15522 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15523 mp->crypto_key_length = sizeof (mp->crypto_key);
15525 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15526 mp->integrity_key_length = sizeof (mp->integrity_key);
15529 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15531 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15539 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15541 unformat_input_t *i = vam->input;
15542 vl_api_ipsec_tunnel_if_add_del_t *mp;
15543 u32 local_spi = 0, remote_spi = 0;
15544 u32 crypto_alg = 0, integ_alg = 0;
15545 u8 *lck = NULL, *rck = NULL;
15546 u8 *lik = NULL, *rik = NULL;
15547 ip4_address_t local_ip = { {0} };
15548 ip4_address_t remote_ip = { {0} };
15551 u8 anti_replay = 0;
15556 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15558 if (unformat (i, "del"))
15560 else if (unformat (i, "esn"))
15562 else if (unformat (i, "anti_replay"))
15564 else if (unformat (i, "local_spi %d", &local_spi))
15566 else if (unformat (i, "remote_spi %d", &remote_spi))
15568 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15570 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15572 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15575 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15577 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15579 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15583 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15585 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15587 errmsg ("unsupported crypto-alg: '%U'\n",
15588 format_ipsec_crypto_alg, crypto_alg);
15594 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15596 if (integ_alg >= IPSEC_INTEG_N_ALG)
15598 errmsg ("unsupported integ-alg: '%U'\n",
15599 format_ipsec_integ_alg, integ_alg);
15603 else if (unformat (i, "instance %u", &instance))
15607 errmsg ("parse error '%U'\n", format_unformat_error, i);
15612 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15614 mp->is_add = is_add;
15616 mp->anti_replay = anti_replay;
15618 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15619 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15621 mp->local_spi = htonl (local_spi);
15622 mp->remote_spi = htonl (remote_spi);
15623 mp->crypto_alg = (u8) crypto_alg;
15625 mp->local_crypto_key_len = 0;
15628 mp->local_crypto_key_len = vec_len (lck);
15629 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15630 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15631 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15634 mp->remote_crypto_key_len = 0;
15637 mp->remote_crypto_key_len = vec_len (rck);
15638 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15639 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15640 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15643 mp->integ_alg = (u8) integ_alg;
15645 mp->local_integ_key_len = 0;
15648 mp->local_integ_key_len = vec_len (lik);
15649 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15650 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15651 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15654 mp->remote_integ_key_len = 0;
15657 mp->remote_integ_key_len = vec_len (rik);
15658 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15659 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15660 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15665 mp->renumber = renumber;
15666 mp->show_instance = ntohl (instance);
15675 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15677 vat_main_t *vam = &vat_main;
15679 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15680 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15681 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15682 "tunnel_src_addr %U tunnel_dst_addr %U "
15683 "salt %u seq_outbound %lu last_seq_inbound %lu "
15684 "replay_window %lu total_data_size %lu\n",
15685 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15687 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15688 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15689 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15690 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15691 mp->tunnel_src_addr,
15692 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15693 mp->tunnel_dst_addr,
15695 clib_net_to_host_u64 (mp->seq_outbound),
15696 clib_net_to_host_u64 (mp->last_seq_inbound),
15697 clib_net_to_host_u64 (mp->replay_window),
15698 clib_net_to_host_u64 (mp->total_data_size));
15701 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15702 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15704 static void vl_api_ipsec_sa_details_t_handler_json
15705 (vl_api_ipsec_sa_details_t * mp)
15707 vat_main_t *vam = &vat_main;
15708 vat_json_node_t *node = NULL;
15709 struct in_addr src_ip4, dst_ip4;
15710 struct in6_addr src_ip6, dst_ip6;
15712 if (VAT_JSON_ARRAY != vam->json_tree.type)
15714 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15715 vat_json_init_array (&vam->json_tree);
15717 node = vat_json_array_add (&vam->json_tree);
15719 vat_json_init_object (node);
15720 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15721 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15722 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15723 vat_json_object_add_uint (node, "proto", mp->protocol);
15724 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15725 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15726 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15727 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15728 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15729 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15730 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15731 mp->crypto_key_len);
15732 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15733 mp->integ_key_len);
15734 if (mp->is_tunnel_ip6)
15736 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15737 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15738 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15739 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15743 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15744 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15745 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15746 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15748 vat_json_object_add_uint (node, "replay_window",
15749 clib_net_to_host_u64 (mp->replay_window));
15750 vat_json_object_add_uint (node, "total_data_size",
15751 clib_net_to_host_u64 (mp->total_data_size));
15756 api_ipsec_sa_dump (vat_main_t * vam)
15758 unformat_input_t *i = vam->input;
15759 vl_api_ipsec_sa_dump_t *mp;
15760 vl_api_control_ping_t *mp_ping;
15764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15766 if (unformat (i, "sa_id %d", &sa_id))
15770 clib_warning ("parse error '%U'", format_unformat_error, i);
15775 M (IPSEC_SA_DUMP, mp);
15777 mp->sa_id = ntohl (sa_id);
15781 /* Use a control ping for synchronization */
15782 M (CONTROL_PING, mp_ping);
15790 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15792 unformat_input_t *i = vam->input;
15793 vl_api_ipsec_tunnel_if_set_key_t *mp;
15794 u32 sw_if_index = ~0;
15795 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15802 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15805 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15806 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15808 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15809 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15810 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15811 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15813 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15814 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15815 else if (unformat (i, "%U", unformat_hex_string, &key))
15819 clib_warning ("parse error '%U'", format_unformat_error, i);
15824 if (sw_if_index == ~0)
15826 errmsg ("interface must be specified");
15830 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15832 errmsg ("key type must be specified");
15838 errmsg ("algorithm must be specified");
15842 if (vec_len (key) == 0)
15844 errmsg ("key must be specified");
15848 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15850 mp->sw_if_index = htonl (sw_if_index);
15852 mp->key_type = key_type;
15853 mp->key_len = vec_len (key);
15854 clib_memcpy (mp->key, key, vec_len (key));
15863 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15865 unformat_input_t *i = vam->input;
15866 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15867 u32 sw_if_index = ~0;
15869 u8 is_outbound = (u8) ~ 0;
15872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15874 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15876 else if (unformat (i, "sa_id %d", &sa_id))
15878 else if (unformat (i, "outbound"))
15880 else if (unformat (i, "inbound"))
15884 clib_warning ("parse error '%U'", format_unformat_error, i);
15889 if (sw_if_index == ~0)
15891 errmsg ("interface must be specified");
15897 errmsg ("SA ID must be specified");
15901 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15903 mp->sw_if_index = htonl (sw_if_index);
15904 mp->sa_id = htonl (sa_id);
15905 mp->is_outbound = is_outbound;
15914 api_ikev2_profile_add_del (vat_main_t * vam)
15916 unformat_input_t *i = vam->input;
15917 vl_api_ikev2_profile_add_del_t *mp;
15922 const char *valid_chars = "a-zA-Z0-9_";
15924 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15926 if (unformat (i, "del"))
15928 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15929 vec_add1 (name, 0);
15932 errmsg ("parse error '%U'", format_unformat_error, i);
15937 if (!vec_len (name))
15939 errmsg ("profile name must be specified");
15943 if (vec_len (name) > 64)
15945 errmsg ("profile name too long");
15949 M (IKEV2_PROFILE_ADD_DEL, mp);
15951 clib_memcpy (mp->name, name, vec_len (name));
15952 mp->is_add = is_add;
15961 api_ikev2_profile_set_auth (vat_main_t * vam)
15963 unformat_input_t *i = vam->input;
15964 vl_api_ikev2_profile_set_auth_t *mp;
15967 u32 auth_method = 0;
15971 const char *valid_chars = "a-zA-Z0-9_";
15973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15975 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15976 vec_add1 (name, 0);
15977 else if (unformat (i, "auth_method %U",
15978 unformat_ikev2_auth_method, &auth_method))
15980 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15982 else if (unformat (i, "auth_data %v", &data))
15986 errmsg ("parse error '%U'", format_unformat_error, i);
15991 if (!vec_len (name))
15993 errmsg ("profile name must be specified");
15997 if (vec_len (name) > 64)
15999 errmsg ("profile name too long");
16003 if (!vec_len (data))
16005 errmsg ("auth_data must be specified");
16011 errmsg ("auth_method must be specified");
16015 M (IKEV2_PROFILE_SET_AUTH, mp);
16017 mp->is_hex = is_hex;
16018 mp->auth_method = (u8) auth_method;
16019 mp->data_len = vec_len (data);
16020 clib_memcpy (mp->name, name, vec_len (name));
16021 clib_memcpy (mp->data, data, vec_len (data));
16031 api_ikev2_profile_set_id (vat_main_t * vam)
16033 unformat_input_t *i = vam->input;
16034 vl_api_ikev2_profile_set_id_t *mp;
16042 const char *valid_chars = "a-zA-Z0-9_";
16044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16046 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16047 vec_add1 (name, 0);
16048 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
16050 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
16052 data = vec_new (u8, 4);
16053 clib_memcpy (data, ip4.as_u8, 4);
16055 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
16057 else if (unformat (i, "id_data %v", &data))
16059 else if (unformat (i, "local"))
16061 else if (unformat (i, "remote"))
16065 errmsg ("parse error '%U'", format_unformat_error, i);
16070 if (!vec_len (name))
16072 errmsg ("profile name must be specified");
16076 if (vec_len (name) > 64)
16078 errmsg ("profile name too long");
16082 if (!vec_len (data))
16084 errmsg ("id_data must be specified");
16090 errmsg ("id_type must be specified");
16094 M (IKEV2_PROFILE_SET_ID, mp);
16096 mp->is_local = is_local;
16097 mp->id_type = (u8) id_type;
16098 mp->data_len = vec_len (data);
16099 clib_memcpy (mp->name, name, vec_len (name));
16100 clib_memcpy (mp->data, data, vec_len (data));
16110 api_ikev2_profile_set_ts (vat_main_t * vam)
16112 unformat_input_t *i = vam->input;
16113 vl_api_ikev2_profile_set_ts_t *mp;
16116 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
16117 ip4_address_t start_addr, end_addr;
16119 const char *valid_chars = "a-zA-Z0-9_";
16122 start_addr.as_u32 = 0;
16123 end_addr.as_u32 = (u32) ~ 0;
16125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16127 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
16128 vec_add1 (name, 0);
16129 else if (unformat (i, "protocol %d", &proto))
16131 else if (unformat (i, "start_port %d", &start_port))
16133 else if (unformat (i, "end_port %d", &end_port))
16136 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
16138 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
16140 else if (unformat (i, "local"))
16142 else if (unformat (i, "remote"))
16146 errmsg ("parse error '%U'", format_unformat_error, i);
16151 if (!vec_len (name))
16153 errmsg ("profile name must be specified");
16157 if (vec_len (name) > 64)
16159 errmsg ("profile name too long");
16163 M (IKEV2_PROFILE_SET_TS, mp);
16165 mp->is_local = is_local;
16166 mp->proto = (u8) proto;
16167 mp->start_port = (u16) start_port;
16168 mp->end_port = (u16) end_port;
16169 mp->start_addr = start_addr.as_u32;
16170 mp->end_addr = end_addr.as_u32;
16171 clib_memcpy (mp->name, name, vec_len (name));
16180 api_ikev2_set_local_key (vat_main_t * vam)
16182 unformat_input_t *i = vam->input;
16183 vl_api_ikev2_set_local_key_t *mp;
16187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16189 if (unformat (i, "file %v", &file))
16190 vec_add1 (file, 0);
16193 errmsg ("parse error '%U'", format_unformat_error, i);
16198 if (!vec_len (file))
16200 errmsg ("RSA key file must be specified");
16204 if (vec_len (file) > 256)
16206 errmsg ("file name too long");
16210 M (IKEV2_SET_LOCAL_KEY, mp);
16212 clib_memcpy (mp->key_file, file, vec_len (file));
16221 api_ikev2_set_responder (vat_main_t * vam)
16223 unformat_input_t *i = vam->input;
16224 vl_api_ikev2_set_responder_t *mp;
16227 u32 sw_if_index = ~0;
16228 ip4_address_t address;
16230 const char *valid_chars = "a-zA-Z0-9_";
16232 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16235 (i, "%U interface %d address %U", unformat_token, valid_chars,
16236 &name, &sw_if_index, unformat_ip4_address, &address))
16237 vec_add1 (name, 0);
16240 errmsg ("parse error '%U'", format_unformat_error, i);
16245 if (!vec_len (name))
16247 errmsg ("profile name must be specified");
16251 if (vec_len (name) > 64)
16253 errmsg ("profile name too long");
16257 M (IKEV2_SET_RESPONDER, mp);
16259 clib_memcpy (mp->name, name, vec_len (name));
16262 mp->sw_if_index = sw_if_index;
16263 clib_memcpy (mp->address, &address, sizeof (address));
16271 api_ikev2_set_ike_transforms (vat_main_t * vam)
16273 unformat_input_t *i = vam->input;
16274 vl_api_ikev2_set_ike_transforms_t *mp;
16277 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16279 const char *valid_chars = "a-zA-Z0-9_";
16281 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16283 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16284 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16285 vec_add1 (name, 0);
16288 errmsg ("parse error '%U'", format_unformat_error, i);
16293 if (!vec_len (name))
16295 errmsg ("profile name must be specified");
16299 if (vec_len (name) > 64)
16301 errmsg ("profile name too long");
16305 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16307 clib_memcpy (mp->name, name, vec_len (name));
16309 mp->crypto_alg = crypto_alg;
16310 mp->crypto_key_size = crypto_key_size;
16311 mp->integ_alg = integ_alg;
16312 mp->dh_group = dh_group;
16321 api_ikev2_set_esp_transforms (vat_main_t * vam)
16323 unformat_input_t *i = vam->input;
16324 vl_api_ikev2_set_esp_transforms_t *mp;
16327 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16329 const char *valid_chars = "a-zA-Z0-9_";
16331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16333 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16334 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16335 vec_add1 (name, 0);
16338 errmsg ("parse error '%U'", format_unformat_error, i);
16343 if (!vec_len (name))
16345 errmsg ("profile name must be specified");
16349 if (vec_len (name) > 64)
16351 errmsg ("profile name too long");
16355 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16357 clib_memcpy (mp->name, name, vec_len (name));
16359 mp->crypto_alg = crypto_alg;
16360 mp->crypto_key_size = crypto_key_size;
16361 mp->integ_alg = integ_alg;
16362 mp->dh_group = dh_group;
16370 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16372 unformat_input_t *i = vam->input;
16373 vl_api_ikev2_set_sa_lifetime_t *mp;
16376 u64 lifetime, lifetime_maxdata;
16377 u32 lifetime_jitter, handover;
16379 const char *valid_chars = "a-zA-Z0-9_";
16381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16383 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16384 &lifetime, &lifetime_jitter, &handover,
16385 &lifetime_maxdata))
16386 vec_add1 (name, 0);
16389 errmsg ("parse error '%U'", format_unformat_error, i);
16394 if (!vec_len (name))
16396 errmsg ("profile name must be specified");
16400 if (vec_len (name) > 64)
16402 errmsg ("profile name too long");
16406 M (IKEV2_SET_SA_LIFETIME, mp);
16408 clib_memcpy (mp->name, name, vec_len (name));
16410 mp->lifetime = lifetime;
16411 mp->lifetime_jitter = lifetime_jitter;
16412 mp->handover = handover;
16413 mp->lifetime_maxdata = lifetime_maxdata;
16421 api_ikev2_initiate_sa_init (vat_main_t * vam)
16423 unformat_input_t *i = vam->input;
16424 vl_api_ikev2_initiate_sa_init_t *mp;
16428 const char *valid_chars = "a-zA-Z0-9_";
16430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16432 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16433 vec_add1 (name, 0);
16436 errmsg ("parse error '%U'", format_unformat_error, i);
16441 if (!vec_len (name))
16443 errmsg ("profile name must be specified");
16447 if (vec_len (name) > 64)
16449 errmsg ("profile name too long");
16453 M (IKEV2_INITIATE_SA_INIT, mp);
16455 clib_memcpy (mp->name, name, vec_len (name));
16464 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16466 unformat_input_t *i = vam->input;
16467 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16472 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16474 if (unformat (i, "%lx", &ispi))
16478 errmsg ("parse error '%U'", format_unformat_error, i);
16483 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16493 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16495 unformat_input_t *i = vam->input;
16496 vl_api_ikev2_initiate_del_child_sa_t *mp;
16501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16503 if (unformat (i, "%x", &ispi))
16507 errmsg ("parse error '%U'", format_unformat_error, i);
16512 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16522 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16524 unformat_input_t *i = vam->input;
16525 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16532 if (unformat (i, "%x", &ispi))
16536 errmsg ("parse error '%U'", format_unformat_error, i);
16541 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16551 api_get_first_msg_id (vat_main_t * vam)
16553 vl_api_get_first_msg_id_t *mp;
16554 unformat_input_t *i = vam->input;
16559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16561 if (unformat (i, "client %s", &name))
16569 errmsg ("missing client name");
16572 vec_add1 (name, 0);
16574 if (vec_len (name) > 63)
16576 errmsg ("client name too long");
16580 M (GET_FIRST_MSG_ID, mp);
16581 clib_memcpy (mp->name, name, vec_len (name));
16588 api_cop_interface_enable_disable (vat_main_t * vam)
16590 unformat_input_t *line_input = vam->input;
16591 vl_api_cop_interface_enable_disable_t *mp;
16592 u32 sw_if_index = ~0;
16593 u8 enable_disable = 1;
16596 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16598 if (unformat (line_input, "disable"))
16599 enable_disable = 0;
16600 if (unformat (line_input, "enable"))
16601 enable_disable = 1;
16602 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16603 vam, &sw_if_index))
16605 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16611 if (sw_if_index == ~0)
16613 errmsg ("missing interface name or sw_if_index");
16617 /* Construct the API message */
16618 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16619 mp->sw_if_index = ntohl (sw_if_index);
16620 mp->enable_disable = enable_disable;
16624 /* Wait for the reply */
16630 api_cop_whitelist_enable_disable (vat_main_t * vam)
16632 unformat_input_t *line_input = vam->input;
16633 vl_api_cop_whitelist_enable_disable_t *mp;
16634 u32 sw_if_index = ~0;
16635 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16639 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16641 if (unformat (line_input, "ip4"))
16643 else if (unformat (line_input, "ip6"))
16645 else if (unformat (line_input, "default"))
16647 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16648 vam, &sw_if_index))
16650 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16652 else if (unformat (line_input, "fib-id %d", &fib_id))
16658 if (sw_if_index == ~0)
16660 errmsg ("missing interface name or sw_if_index");
16664 /* Construct the API message */
16665 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16666 mp->sw_if_index = ntohl (sw_if_index);
16667 mp->fib_id = ntohl (fib_id);
16670 mp->default_cop = default_cop;
16674 /* Wait for the reply */
16680 api_get_node_graph (vat_main_t * vam)
16682 vl_api_get_node_graph_t *mp;
16685 M (GET_NODE_GRAPH, mp);
16689 /* Wait for the reply */
16695 /** Used for parsing LISP eids */
16696 typedef CLIB_PACKED(struct{
16697 u8 addr[16]; /**< eid address */
16698 u32 len; /**< prefix length if IP */
16699 u8 type; /**< type of eid */
16704 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16706 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16708 clib_memset (a, 0, sizeof (a[0]));
16710 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16712 a->type = 0; /* ipv4 type */
16714 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16716 a->type = 1; /* ipv6 type */
16718 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16720 a->type = 2; /* mac type */
16722 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16724 a->type = 3; /* NSH type */
16725 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16726 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16733 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16742 lisp_eid_size_vat (u8 type)
16759 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16761 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16765 api_one_add_del_locator_set (vat_main_t * vam)
16767 unformat_input_t *input = vam->input;
16768 vl_api_one_add_del_locator_set_t *mp;
16770 u8 *locator_set_name = NULL;
16771 u8 locator_set_name_set = 0;
16772 vl_api_local_locator_t locator, *locators = 0;
16773 u32 sw_if_index, priority, weight;
16777 /* Parse args required to build the message */
16778 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16780 if (unformat (input, "del"))
16784 else if (unformat (input, "locator-set %s", &locator_set_name))
16786 locator_set_name_set = 1;
16788 else if (unformat (input, "sw_if_index %u p %u w %u",
16789 &sw_if_index, &priority, &weight))
16791 locator.sw_if_index = htonl (sw_if_index);
16792 locator.priority = priority;
16793 locator.weight = weight;
16794 vec_add1 (locators, locator);
16798 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16799 &sw_if_index, &priority, &weight))
16801 locator.sw_if_index = htonl (sw_if_index);
16802 locator.priority = priority;
16803 locator.weight = weight;
16804 vec_add1 (locators, locator);
16810 if (locator_set_name_set == 0)
16812 errmsg ("missing locator-set name");
16813 vec_free (locators);
16817 if (vec_len (locator_set_name) > 64)
16819 errmsg ("locator-set name too long");
16820 vec_free (locator_set_name);
16821 vec_free (locators);
16824 vec_add1 (locator_set_name, 0);
16826 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16828 /* Construct the API message */
16829 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16831 mp->is_add = is_add;
16832 clib_memcpy (mp->locator_set_name, locator_set_name,
16833 vec_len (locator_set_name));
16834 vec_free (locator_set_name);
16836 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16838 clib_memcpy (mp->locators, locators, data_len);
16839 vec_free (locators);
16844 /* Wait for a reply... */
16849 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16852 api_one_add_del_locator (vat_main_t * vam)
16854 unformat_input_t *input = vam->input;
16855 vl_api_one_add_del_locator_t *mp;
16856 u32 tmp_if_index = ~0;
16857 u32 sw_if_index = ~0;
16858 u8 sw_if_index_set = 0;
16859 u8 sw_if_index_if_name_set = 0;
16861 u8 priority_set = 0;
16865 u8 *locator_set_name = NULL;
16866 u8 locator_set_name_set = 0;
16869 /* Parse args required to build the message */
16870 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16872 if (unformat (input, "del"))
16876 else if (unformat (input, "locator-set %s", &locator_set_name))
16878 locator_set_name_set = 1;
16880 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16883 sw_if_index_if_name_set = 1;
16884 sw_if_index = tmp_if_index;
16886 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16888 sw_if_index_set = 1;
16889 sw_if_index = tmp_if_index;
16891 else if (unformat (input, "p %d", &priority))
16895 else if (unformat (input, "w %d", &weight))
16903 if (locator_set_name_set == 0)
16905 errmsg ("missing locator-set name");
16909 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16911 errmsg ("missing sw_if_index");
16912 vec_free (locator_set_name);
16916 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16918 errmsg ("cannot use both params interface name and sw_if_index");
16919 vec_free (locator_set_name);
16923 if (priority_set == 0)
16925 errmsg ("missing locator-set priority");
16926 vec_free (locator_set_name);
16930 if (weight_set == 0)
16932 errmsg ("missing locator-set weight");
16933 vec_free (locator_set_name);
16937 if (vec_len (locator_set_name) > 64)
16939 errmsg ("locator-set name too long");
16940 vec_free (locator_set_name);
16943 vec_add1 (locator_set_name, 0);
16945 /* Construct the API message */
16946 M (ONE_ADD_DEL_LOCATOR, mp);
16948 mp->is_add = is_add;
16949 mp->sw_if_index = ntohl (sw_if_index);
16950 mp->priority = priority;
16951 mp->weight = weight;
16952 clib_memcpy (mp->locator_set_name, locator_set_name,
16953 vec_len (locator_set_name));
16954 vec_free (locator_set_name);
16959 /* Wait for a reply... */
16964 #define api_lisp_add_del_locator api_one_add_del_locator
16967 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16969 u32 *key_id = va_arg (*args, u32 *);
16972 if (unformat (input, "%s", &s))
16974 if (!strcmp ((char *) s, "sha1"))
16975 key_id[0] = HMAC_SHA_1_96;
16976 else if (!strcmp ((char *) s, "sha256"))
16977 key_id[0] = HMAC_SHA_256_128;
16980 clib_warning ("invalid key_id: '%s'", s);
16981 key_id[0] = HMAC_NO_KEY;
16992 api_one_add_del_local_eid (vat_main_t * vam)
16994 unformat_input_t *input = vam->input;
16995 vl_api_one_add_del_local_eid_t *mp;
16998 lisp_eid_vat_t _eid, *eid = &_eid;
16999 u8 *locator_set_name = 0;
17000 u8 locator_set_name_set = 0;
17006 /* Parse args required to build the message */
17007 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17009 if (unformat (input, "del"))
17013 else if (unformat (input, "vni %d", &vni))
17017 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17021 else if (unformat (input, "locator-set %s", &locator_set_name))
17023 locator_set_name_set = 1;
17025 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17027 else if (unformat (input, "secret-key %_%v%_", &key))
17033 if (locator_set_name_set == 0)
17035 errmsg ("missing locator-set name");
17041 errmsg ("EID address not set!");
17042 vec_free (locator_set_name);
17046 if (key && (0 == key_id))
17048 errmsg ("invalid key_id!");
17052 if (vec_len (key) > 64)
17054 errmsg ("key too long");
17059 if (vec_len (locator_set_name) > 64)
17061 errmsg ("locator-set name too long");
17062 vec_free (locator_set_name);
17065 vec_add1 (locator_set_name, 0);
17067 /* Construct the API message */
17068 M (ONE_ADD_DEL_LOCAL_EID, mp);
17070 mp->is_add = is_add;
17071 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17072 mp->eid_type = eid->type;
17073 mp->prefix_len = eid->len;
17074 mp->vni = clib_host_to_net_u32 (vni);
17075 mp->key_id = clib_host_to_net_u16 (key_id);
17076 clib_memcpy (mp->locator_set_name, locator_set_name,
17077 vec_len (locator_set_name));
17078 clib_memcpy (mp->key, key, vec_len (key));
17080 vec_free (locator_set_name);
17086 /* Wait for a reply... */
17091 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17094 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17096 u32 dp_table = 0, vni = 0;;
17097 unformat_input_t *input = vam->input;
17098 vl_api_gpe_add_del_fwd_entry_t *mp;
17100 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17101 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17102 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17103 u32 action = ~0, w;
17104 ip4_address_t rmt_rloc4, lcl_rloc4;
17105 ip6_address_t rmt_rloc6, lcl_rloc6;
17106 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17109 clib_memset (&rloc, 0, sizeof (rloc));
17111 /* Parse args required to build the message */
17112 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17114 if (unformat (input, "del"))
17116 else if (unformat (input, "add"))
17118 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17122 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17126 else if (unformat (input, "vrf %d", &dp_table))
17128 else if (unformat (input, "bd %d", &dp_table))
17130 else if (unformat (input, "vni %d", &vni))
17132 else if (unformat (input, "w %d", &w))
17136 errmsg ("No RLOC configured for setting priority/weight!");
17139 curr_rloc->weight = w;
17141 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17142 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17146 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17148 vec_add1 (lcl_locs, rloc);
17150 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17151 vec_add1 (rmt_locs, rloc);
17152 /* weight saved in rmt loc */
17153 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17155 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17156 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17159 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17161 vec_add1 (lcl_locs, rloc);
17163 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17164 vec_add1 (rmt_locs, rloc);
17165 /* weight saved in rmt loc */
17166 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17168 else if (unformat (input, "action %d", &action))
17174 clib_warning ("parse error '%U'", format_unformat_error, input);
17181 errmsg ("remote eid addresses not set");
17185 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17187 errmsg ("eid types don't match");
17191 if (0 == rmt_locs && (u32) ~ 0 == action)
17193 errmsg ("action not set for negative mapping");
17197 /* Construct the API message */
17198 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17199 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17201 mp->is_add = is_add;
17202 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17203 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17204 mp->eid_type = rmt_eid->type;
17205 mp->dp_table = clib_host_to_net_u32 (dp_table);
17206 mp->vni = clib_host_to_net_u32 (vni);
17207 mp->rmt_len = rmt_eid->len;
17208 mp->lcl_len = lcl_eid->len;
17209 mp->action = action;
17211 if (0 != rmt_locs && 0 != lcl_locs)
17213 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17214 clib_memcpy (mp->locs, lcl_locs,
17215 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17217 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17218 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17219 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17221 vec_free (lcl_locs);
17222 vec_free (rmt_locs);
17227 /* Wait for a reply... */
17233 api_one_add_del_map_server (vat_main_t * vam)
17235 unformat_input_t *input = vam->input;
17236 vl_api_one_add_del_map_server_t *mp;
17240 ip4_address_t ipv4;
17241 ip6_address_t ipv6;
17244 /* Parse args required to build the message */
17245 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17247 if (unformat (input, "del"))
17251 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17255 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17263 if (ipv4_set && ipv6_set)
17265 errmsg ("both eid v4 and v6 addresses set");
17269 if (!ipv4_set && !ipv6_set)
17271 errmsg ("eid addresses not set");
17275 /* Construct the API message */
17276 M (ONE_ADD_DEL_MAP_SERVER, mp);
17278 mp->is_add = is_add;
17282 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17287 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17293 /* Wait for a reply... */
17298 #define api_lisp_add_del_map_server api_one_add_del_map_server
17301 api_one_add_del_map_resolver (vat_main_t * vam)
17303 unformat_input_t *input = vam->input;
17304 vl_api_one_add_del_map_resolver_t *mp;
17308 ip4_address_t ipv4;
17309 ip6_address_t ipv6;
17312 /* Parse args required to build the message */
17313 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17315 if (unformat (input, "del"))
17319 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17323 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17331 if (ipv4_set && ipv6_set)
17333 errmsg ("both eid v4 and v6 addresses set");
17337 if (!ipv4_set && !ipv6_set)
17339 errmsg ("eid addresses not set");
17343 /* Construct the API message */
17344 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17346 mp->is_add = is_add;
17350 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17355 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17361 /* Wait for a reply... */
17366 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17369 api_lisp_gpe_enable_disable (vat_main_t * vam)
17371 unformat_input_t *input = vam->input;
17372 vl_api_gpe_enable_disable_t *mp;
17377 /* Parse args required to build the message */
17378 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17380 if (unformat (input, "enable"))
17385 else if (unformat (input, "disable"))
17396 errmsg ("Value not set");
17400 /* Construct the API message */
17401 M (GPE_ENABLE_DISABLE, mp);
17408 /* Wait for a reply... */
17414 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17416 unformat_input_t *input = vam->input;
17417 vl_api_one_rloc_probe_enable_disable_t *mp;
17422 /* Parse args required to build the message */
17423 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17425 if (unformat (input, "enable"))
17430 else if (unformat (input, "disable"))
17438 errmsg ("Value not set");
17442 /* Construct the API message */
17443 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17445 mp->is_enabled = is_en;
17450 /* Wait for a reply... */
17455 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17458 api_one_map_register_enable_disable (vat_main_t * vam)
17460 unformat_input_t *input = vam->input;
17461 vl_api_one_map_register_enable_disable_t *mp;
17466 /* Parse args required to build the message */
17467 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17469 if (unformat (input, "enable"))
17474 else if (unformat (input, "disable"))
17482 errmsg ("Value not set");
17486 /* Construct the API message */
17487 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17489 mp->is_enabled = is_en;
17494 /* Wait for a reply... */
17499 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17502 api_one_enable_disable (vat_main_t * vam)
17504 unformat_input_t *input = vam->input;
17505 vl_api_one_enable_disable_t *mp;
17510 /* Parse args required to build the message */
17511 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17513 if (unformat (input, "enable"))
17518 else if (unformat (input, "disable"))
17528 errmsg ("Value not set");
17532 /* Construct the API message */
17533 M (ONE_ENABLE_DISABLE, mp);
17540 /* Wait for a reply... */
17545 #define api_lisp_enable_disable api_one_enable_disable
17548 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17550 unformat_input_t *input = vam->input;
17551 vl_api_one_enable_disable_xtr_mode_t *mp;
17556 /* Parse args required to build the message */
17557 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17559 if (unformat (input, "enable"))
17564 else if (unformat (input, "disable"))
17574 errmsg ("Value not set");
17578 /* Construct the API message */
17579 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17586 /* Wait for a reply... */
17592 api_one_show_xtr_mode (vat_main_t * vam)
17594 vl_api_one_show_xtr_mode_t *mp;
17597 /* Construct the API message */
17598 M (ONE_SHOW_XTR_MODE, mp);
17603 /* Wait for a reply... */
17609 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17611 unformat_input_t *input = vam->input;
17612 vl_api_one_enable_disable_pitr_mode_t *mp;
17617 /* Parse args required to build the message */
17618 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17620 if (unformat (input, "enable"))
17625 else if (unformat (input, "disable"))
17635 errmsg ("Value not set");
17639 /* Construct the API message */
17640 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17647 /* Wait for a reply... */
17653 api_one_show_pitr_mode (vat_main_t * vam)
17655 vl_api_one_show_pitr_mode_t *mp;
17658 /* Construct the API message */
17659 M (ONE_SHOW_PITR_MODE, mp);
17664 /* Wait for a reply... */
17670 api_one_enable_disable_petr_mode (vat_main_t * vam)
17672 unformat_input_t *input = vam->input;
17673 vl_api_one_enable_disable_petr_mode_t *mp;
17678 /* Parse args required to build the message */
17679 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17681 if (unformat (input, "enable"))
17686 else if (unformat (input, "disable"))
17696 errmsg ("Value not set");
17700 /* Construct the API message */
17701 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17708 /* Wait for a reply... */
17714 api_one_show_petr_mode (vat_main_t * vam)
17716 vl_api_one_show_petr_mode_t *mp;
17719 /* Construct the API message */
17720 M (ONE_SHOW_PETR_MODE, mp);
17725 /* Wait for a reply... */
17731 api_show_one_map_register_state (vat_main_t * vam)
17733 vl_api_show_one_map_register_state_t *mp;
17736 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17741 /* wait for reply */
17746 #define api_show_lisp_map_register_state api_show_one_map_register_state
17749 api_show_one_rloc_probe_state (vat_main_t * vam)
17751 vl_api_show_one_rloc_probe_state_t *mp;
17754 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17759 /* wait for reply */
17764 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17767 api_one_add_del_ndp_entry (vat_main_t * vam)
17769 vl_api_one_add_del_ndp_entry_t *mp;
17770 unformat_input_t *input = vam->input;
17775 u8 mac[6] = { 0, };
17776 u8 ip6[16] = { 0, };
17780 /* Parse args required to build the message */
17781 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17783 if (unformat (input, "del"))
17785 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17787 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17789 else if (unformat (input, "bd %d", &bd))
17793 errmsg ("parse error '%U'", format_unformat_error, input);
17798 if (!bd_set || !ip_set || (!mac_set && is_add))
17800 errmsg ("Missing BD, IP or MAC!");
17804 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17805 mp->is_add = is_add;
17806 clib_memcpy (mp->mac, mac, 6);
17807 mp->bd = clib_host_to_net_u32 (bd);
17808 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17813 /* wait for reply */
17819 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17821 vl_api_one_add_del_l2_arp_entry_t *mp;
17822 unformat_input_t *input = vam->input;
17827 u8 mac[6] = { 0, };
17828 u32 ip4 = 0, bd = ~0;
17831 /* Parse args required to build the message */
17832 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17834 if (unformat (input, "del"))
17836 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17838 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17840 else if (unformat (input, "bd %d", &bd))
17844 errmsg ("parse error '%U'", format_unformat_error, input);
17849 if (!bd_set || !ip_set || (!mac_set && is_add))
17851 errmsg ("Missing BD, IP or MAC!");
17855 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17856 mp->is_add = is_add;
17857 clib_memcpy (mp->mac, mac, 6);
17858 mp->bd = clib_host_to_net_u32 (bd);
17864 /* wait for reply */
17870 api_one_ndp_bd_get (vat_main_t * vam)
17872 vl_api_one_ndp_bd_get_t *mp;
17875 M (ONE_NDP_BD_GET, mp);
17880 /* wait for reply */
17886 api_one_ndp_entries_get (vat_main_t * vam)
17888 vl_api_one_ndp_entries_get_t *mp;
17889 unformat_input_t *input = vam->input;
17894 /* Parse args required to build the message */
17895 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17897 if (unformat (input, "bd %d", &bd))
17901 errmsg ("parse error '%U'", format_unformat_error, input);
17908 errmsg ("Expected bridge domain!");
17912 M (ONE_NDP_ENTRIES_GET, mp);
17913 mp->bd = clib_host_to_net_u32 (bd);
17918 /* wait for reply */
17924 api_one_l2_arp_bd_get (vat_main_t * vam)
17926 vl_api_one_l2_arp_bd_get_t *mp;
17929 M (ONE_L2_ARP_BD_GET, mp);
17934 /* wait for reply */
17940 api_one_l2_arp_entries_get (vat_main_t * vam)
17942 vl_api_one_l2_arp_entries_get_t *mp;
17943 unformat_input_t *input = vam->input;
17948 /* Parse args required to build the message */
17949 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17951 if (unformat (input, "bd %d", &bd))
17955 errmsg ("parse error '%U'", format_unformat_error, input);
17962 errmsg ("Expected bridge domain!");
17966 M (ONE_L2_ARP_ENTRIES_GET, mp);
17967 mp->bd = clib_host_to_net_u32 (bd);
17972 /* wait for reply */
17978 api_one_stats_enable_disable (vat_main_t * vam)
17980 vl_api_one_stats_enable_disable_t *mp;
17981 unformat_input_t *input = vam->input;
17986 /* Parse args required to build the message */
17987 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17989 if (unformat (input, "enable"))
17994 else if (unformat (input, "disable"))
18004 errmsg ("Value not set");
18008 M (ONE_STATS_ENABLE_DISABLE, mp);
18014 /* wait for reply */
18020 api_show_one_stats_enable_disable (vat_main_t * vam)
18022 vl_api_show_one_stats_enable_disable_t *mp;
18025 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18030 /* wait for reply */
18036 api_show_one_map_request_mode (vat_main_t * vam)
18038 vl_api_show_one_map_request_mode_t *mp;
18041 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18046 /* wait for reply */
18051 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18054 api_one_map_request_mode (vat_main_t * vam)
18056 unformat_input_t *input = vam->input;
18057 vl_api_one_map_request_mode_t *mp;
18061 /* Parse args required to build the message */
18062 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18064 if (unformat (input, "dst-only"))
18066 else if (unformat (input, "src-dst"))
18070 errmsg ("parse error '%U'", format_unformat_error, input);
18075 M (ONE_MAP_REQUEST_MODE, mp);
18082 /* wait for reply */
18087 #define api_lisp_map_request_mode api_one_map_request_mode
18090 * Enable/disable ONE proxy ITR.
18092 * @param vam vpp API test context
18093 * @return return code
18096 api_one_pitr_set_locator_set (vat_main_t * vam)
18098 u8 ls_name_set = 0;
18099 unformat_input_t *input = vam->input;
18100 vl_api_one_pitr_set_locator_set_t *mp;
18105 /* Parse args required to build the message */
18106 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18108 if (unformat (input, "del"))
18110 else if (unformat (input, "locator-set %s", &ls_name))
18114 errmsg ("parse error '%U'", format_unformat_error, input);
18121 errmsg ("locator-set name not set!");
18125 M (ONE_PITR_SET_LOCATOR_SET, mp);
18127 mp->is_add = is_add;
18128 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18129 vec_free (ls_name);
18134 /* wait for reply */
18139 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18142 api_one_nsh_set_locator_set (vat_main_t * vam)
18144 u8 ls_name_set = 0;
18145 unformat_input_t *input = vam->input;
18146 vl_api_one_nsh_set_locator_set_t *mp;
18151 /* Parse args required to build the message */
18152 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18154 if (unformat (input, "del"))
18156 else if (unformat (input, "ls %s", &ls_name))
18160 errmsg ("parse error '%U'", format_unformat_error, input);
18165 if (!ls_name_set && is_add)
18167 errmsg ("locator-set name not set!");
18171 M (ONE_NSH_SET_LOCATOR_SET, mp);
18173 mp->is_add = is_add;
18174 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18175 vec_free (ls_name);
18180 /* wait for reply */
18186 api_show_one_pitr (vat_main_t * vam)
18188 vl_api_show_one_pitr_t *mp;
18191 if (!vam->json_output)
18193 print (vam->ofp, "%=20s", "lisp status:");
18196 M (SHOW_ONE_PITR, mp);
18200 /* Wait for a reply... */
18205 #define api_show_lisp_pitr api_show_one_pitr
18208 api_one_use_petr (vat_main_t * vam)
18210 unformat_input_t *input = vam->input;
18211 vl_api_one_use_petr_t *mp;
18216 clib_memset (&ip, 0, sizeof (ip));
18218 /* Parse args required to build the message */
18219 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18221 if (unformat (input, "disable"))
18224 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18227 ip_addr_version (&ip) = IP4;
18230 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18233 ip_addr_version (&ip) = IP6;
18237 errmsg ("parse error '%U'", format_unformat_error, input);
18242 M (ONE_USE_PETR, mp);
18244 mp->is_add = is_add;
18247 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18249 clib_memcpy (mp->address, &ip, 4);
18251 clib_memcpy (mp->address, &ip, 16);
18257 /* wait for reply */
18262 #define api_lisp_use_petr api_one_use_petr
18265 api_show_one_nsh_mapping (vat_main_t * vam)
18267 vl_api_show_one_use_petr_t *mp;
18270 if (!vam->json_output)
18272 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18275 M (SHOW_ONE_NSH_MAPPING, mp);
18279 /* Wait for a reply... */
18285 api_show_one_use_petr (vat_main_t * vam)
18287 vl_api_show_one_use_petr_t *mp;
18290 if (!vam->json_output)
18292 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18295 M (SHOW_ONE_USE_PETR, mp);
18299 /* Wait for a reply... */
18304 #define api_show_lisp_use_petr api_show_one_use_petr
18307 * Add/delete mapping between vni and vrf
18310 api_one_eid_table_add_del_map (vat_main_t * vam)
18312 unformat_input_t *input = vam->input;
18313 vl_api_one_eid_table_add_del_map_t *mp;
18314 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18315 u32 vni, vrf, bd_index;
18318 /* Parse args required to build the message */
18319 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18321 if (unformat (input, "del"))
18323 else if (unformat (input, "vrf %d", &vrf))
18325 else if (unformat (input, "bd_index %d", &bd_index))
18327 else if (unformat (input, "vni %d", &vni))
18333 if (!vni_set || (!vrf_set && !bd_index_set))
18335 errmsg ("missing arguments!");
18339 if (vrf_set && bd_index_set)
18341 errmsg ("error: both vrf and bd entered!");
18345 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18347 mp->is_add = is_add;
18348 mp->vni = htonl (vni);
18349 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18350 mp->is_l2 = bd_index_set;
18355 /* wait for reply */
18360 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18363 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18365 u32 *action = va_arg (*args, u32 *);
18368 if (unformat (input, "%s", &s))
18370 if (!strcmp ((char *) s, "no-action"))
18372 else if (!strcmp ((char *) s, "natively-forward"))
18374 else if (!strcmp ((char *) s, "send-map-request"))
18376 else if (!strcmp ((char *) s, "drop"))
18380 clib_warning ("invalid action: '%s'", s);
18392 * Add/del remote mapping to/from ONE control plane
18394 * @param vam vpp API test context
18395 * @return return code
18398 api_one_add_del_remote_mapping (vat_main_t * vam)
18400 unformat_input_t *input = vam->input;
18401 vl_api_one_add_del_remote_mapping_t *mp;
18403 lisp_eid_vat_t _eid, *eid = &_eid;
18404 lisp_eid_vat_t _seid, *seid = &_seid;
18405 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18406 u32 action = ~0, p, w, data_len;
18407 ip4_address_t rloc4;
18408 ip6_address_t rloc6;
18409 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18412 clib_memset (&rloc, 0, sizeof (rloc));
18414 /* Parse args required to build the message */
18415 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18417 if (unformat (input, "del-all"))
18421 else if (unformat (input, "del"))
18425 else if (unformat (input, "add"))
18429 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18433 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18437 else if (unformat (input, "vni %d", &vni))
18441 else if (unformat (input, "p %d w %d", &p, &w))
18445 errmsg ("No RLOC configured for setting priority/weight!");
18448 curr_rloc->priority = p;
18449 curr_rloc->weight = w;
18451 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18454 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18455 vec_add1 (rlocs, rloc);
18456 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18458 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18461 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18462 vec_add1 (rlocs, rloc);
18463 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18465 else if (unformat (input, "action %U",
18466 unformat_negative_mapping_action, &action))
18472 clib_warning ("parse error '%U'", format_unformat_error, input);
18479 errmsg ("missing params!");
18483 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18485 errmsg ("no action set for negative map-reply!");
18489 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18491 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18492 mp->is_add = is_add;
18493 mp->vni = htonl (vni);
18494 mp->action = (u8) action;
18495 mp->is_src_dst = seid_set;
18496 mp->eid_len = eid->len;
18497 mp->seid_len = seid->len;
18498 mp->del_all = del_all;
18499 mp->eid_type = eid->type;
18500 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18501 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18503 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18504 clib_memcpy (mp->rlocs, rlocs, data_len);
18510 /* Wait for a reply... */
18515 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18518 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18519 * forwarding entries in data-plane accordingly.
18521 * @param vam vpp API test context
18522 * @return return code
18525 api_one_add_del_adjacency (vat_main_t * vam)
18527 unformat_input_t *input = vam->input;
18528 vl_api_one_add_del_adjacency_t *mp;
18530 ip4_address_t leid4, reid4;
18531 ip6_address_t leid6, reid6;
18532 u8 reid_mac[6] = { 0 };
18533 u8 leid_mac[6] = { 0 };
18534 u8 reid_type, leid_type;
18535 u32 leid_len = 0, reid_len = 0, len;
18539 leid_type = reid_type = (u8) ~ 0;
18541 /* Parse args required to build the message */
18542 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18544 if (unformat (input, "del"))
18548 else if (unformat (input, "add"))
18552 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18555 reid_type = 0; /* ipv4 */
18558 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18561 reid_type = 1; /* ipv6 */
18564 else if (unformat (input, "reid %U", unformat_ethernet_address,
18567 reid_type = 2; /* mac */
18569 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18572 leid_type = 0; /* ipv4 */
18575 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18578 leid_type = 1; /* ipv6 */
18581 else if (unformat (input, "leid %U", unformat_ethernet_address,
18584 leid_type = 2; /* mac */
18586 else if (unformat (input, "vni %d", &vni))
18592 errmsg ("parse error '%U'", format_unformat_error, input);
18597 if ((u8) ~ 0 == reid_type)
18599 errmsg ("missing params!");
18603 if (leid_type != reid_type)
18605 errmsg ("remote and local EIDs are of different types!");
18609 M (ONE_ADD_DEL_ADJACENCY, mp);
18610 mp->is_add = is_add;
18611 mp->vni = htonl (vni);
18612 mp->leid_len = leid_len;
18613 mp->reid_len = reid_len;
18614 mp->eid_type = reid_type;
18616 switch (mp->eid_type)
18619 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18620 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18623 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18624 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18627 clib_memcpy (mp->leid, leid_mac, 6);
18628 clib_memcpy (mp->reid, reid_mac, 6);
18631 errmsg ("unknown EID type %d!", mp->eid_type);
18638 /* Wait for a reply... */
18643 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18646 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18648 u32 *mode = va_arg (*args, u32 *);
18650 if (unformat (input, "lisp"))
18652 else if (unformat (input, "vxlan"))
18661 api_gpe_get_encap_mode (vat_main_t * vam)
18663 vl_api_gpe_get_encap_mode_t *mp;
18666 /* Construct the API message */
18667 M (GPE_GET_ENCAP_MODE, mp);
18672 /* Wait for a reply... */
18678 api_gpe_set_encap_mode (vat_main_t * vam)
18680 unformat_input_t *input = vam->input;
18681 vl_api_gpe_set_encap_mode_t *mp;
18685 /* Parse args required to build the message */
18686 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18688 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18694 /* Construct the API message */
18695 M (GPE_SET_ENCAP_MODE, mp);
18702 /* Wait for a reply... */
18708 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18710 unformat_input_t *input = vam->input;
18711 vl_api_gpe_add_del_iface_t *mp;
18712 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18713 u32 dp_table = 0, vni = 0;
18716 /* Parse args required to build the message */
18717 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18719 if (unformat (input, "up"))
18724 else if (unformat (input, "down"))
18729 else if (unformat (input, "table_id %d", &dp_table))
18733 else if (unformat (input, "bd_id %d", &dp_table))
18738 else if (unformat (input, "vni %d", &vni))
18746 if (action_set == 0)
18748 errmsg ("Action not set");
18751 if (dp_table_set == 0 || vni_set == 0)
18753 errmsg ("vni and dp_table must be set");
18757 /* Construct the API message */
18758 M (GPE_ADD_DEL_IFACE, mp);
18760 mp->is_add = is_add;
18761 mp->dp_table = clib_host_to_net_u32 (dp_table);
18763 mp->vni = clib_host_to_net_u32 (vni);
18768 /* Wait for a reply... */
18774 api_one_map_register_fallback_threshold (vat_main_t * vam)
18776 unformat_input_t *input = vam->input;
18777 vl_api_one_map_register_fallback_threshold_t *mp;
18782 /* Parse args required to build the message */
18783 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18785 if (unformat (input, "%u", &value))
18789 clib_warning ("parse error '%U'", format_unformat_error, input);
18796 errmsg ("fallback threshold value is missing!");
18800 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18801 mp->value = clib_host_to_net_u32 (value);
18806 /* Wait for a reply... */
18812 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18814 vl_api_show_one_map_register_fallback_threshold_t *mp;
18817 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18822 /* Wait for a reply... */
18828 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18830 u32 *proto = va_arg (*args, u32 *);
18832 if (unformat (input, "udp"))
18834 else if (unformat (input, "api"))
18843 api_one_set_transport_protocol (vat_main_t * vam)
18845 unformat_input_t *input = vam->input;
18846 vl_api_one_set_transport_protocol_t *mp;
18851 /* Parse args required to build the message */
18852 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18854 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18858 clib_warning ("parse error '%U'", format_unformat_error, input);
18865 errmsg ("Transport protocol missing!");
18869 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18870 mp->protocol = (u8) protocol;
18875 /* Wait for a reply... */
18881 api_one_get_transport_protocol (vat_main_t * vam)
18883 vl_api_one_get_transport_protocol_t *mp;
18886 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18891 /* Wait for a reply... */
18897 api_one_map_register_set_ttl (vat_main_t * vam)
18899 unformat_input_t *input = vam->input;
18900 vl_api_one_map_register_set_ttl_t *mp;
18905 /* Parse args required to build the message */
18906 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18908 if (unformat (input, "%u", &ttl))
18912 clib_warning ("parse error '%U'", format_unformat_error, input);
18919 errmsg ("TTL value missing!");
18923 M (ONE_MAP_REGISTER_SET_TTL, mp);
18924 mp->ttl = clib_host_to_net_u32 (ttl);
18929 /* Wait for a reply... */
18935 api_show_one_map_register_ttl (vat_main_t * vam)
18937 vl_api_show_one_map_register_ttl_t *mp;
18940 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18945 /* Wait for a reply... */
18951 * Add/del map request itr rlocs from ONE control plane and updates
18953 * @param vam vpp API test context
18954 * @return return code
18957 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18959 unformat_input_t *input = vam->input;
18960 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18961 u8 *locator_set_name = 0;
18962 u8 locator_set_name_set = 0;
18966 /* Parse args required to build the message */
18967 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18969 if (unformat (input, "del"))
18973 else if (unformat (input, "%_%v%_", &locator_set_name))
18975 locator_set_name_set = 1;
18979 clib_warning ("parse error '%U'", format_unformat_error, input);
18984 if (is_add && !locator_set_name_set)
18986 errmsg ("itr-rloc is not set!");
18990 if (is_add && vec_len (locator_set_name) > 64)
18992 errmsg ("itr-rloc locator-set name too long");
18993 vec_free (locator_set_name);
18997 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18998 mp->is_add = is_add;
19001 clib_memcpy (mp->locator_set_name, locator_set_name,
19002 vec_len (locator_set_name));
19006 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19008 vec_free (locator_set_name);
19013 /* Wait for a reply... */
19018 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19021 api_one_locator_dump (vat_main_t * vam)
19023 unformat_input_t *input = vam->input;
19024 vl_api_one_locator_dump_t *mp;
19025 vl_api_control_ping_t *mp_ping;
19026 u8 is_index_set = 0, is_name_set = 0;
19031 /* Parse args required to build the message */
19032 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19034 if (unformat (input, "ls_name %_%v%_", &ls_name))
19038 else if (unformat (input, "ls_index %d", &ls_index))
19044 errmsg ("parse error '%U'", format_unformat_error, input);
19049 if (!is_index_set && !is_name_set)
19051 errmsg ("error: expected one of index or name!");
19055 if (is_index_set && is_name_set)
19057 errmsg ("error: only one param expected!");
19061 if (vec_len (ls_name) > 62)
19063 errmsg ("error: locator set name too long!");
19067 if (!vam->json_output)
19069 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19072 M (ONE_LOCATOR_DUMP, mp);
19073 mp->is_index_set = is_index_set;
19076 mp->ls_index = clib_host_to_net_u32 (ls_index);
19079 vec_add1 (ls_name, 0);
19080 strncpy ((char *) mp->ls_name, (char *) ls_name,
19081 sizeof (mp->ls_name) - 1);
19087 /* Use a control ping for synchronization */
19088 MPING (CONTROL_PING, mp_ping);
19091 /* Wait for a reply... */
19096 #define api_lisp_locator_dump api_one_locator_dump
19099 api_one_locator_set_dump (vat_main_t * vam)
19101 vl_api_one_locator_set_dump_t *mp;
19102 vl_api_control_ping_t *mp_ping;
19103 unformat_input_t *input = vam->input;
19107 /* Parse args required to build the message */
19108 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19110 if (unformat (input, "local"))
19114 else if (unformat (input, "remote"))
19120 errmsg ("parse error '%U'", format_unformat_error, input);
19125 if (!vam->json_output)
19127 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19130 M (ONE_LOCATOR_SET_DUMP, mp);
19132 mp->filter = filter;
19137 /* Use a control ping for synchronization */
19138 MPING (CONTROL_PING, mp_ping);
19141 /* Wait for a reply... */
19146 #define api_lisp_locator_set_dump api_one_locator_set_dump
19149 api_one_eid_table_map_dump (vat_main_t * vam)
19153 unformat_input_t *input = vam->input;
19154 vl_api_one_eid_table_map_dump_t *mp;
19155 vl_api_control_ping_t *mp_ping;
19158 /* Parse args required to build the message */
19159 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19161 if (unformat (input, "l2"))
19166 else if (unformat (input, "l3"))
19173 errmsg ("parse error '%U'", format_unformat_error, input);
19180 errmsg ("expected one of 'l2' or 'l3' parameter!");
19184 if (!vam->json_output)
19186 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19189 M (ONE_EID_TABLE_MAP_DUMP, mp);
19195 /* Use a control ping for synchronization */
19196 MPING (CONTROL_PING, mp_ping);
19199 /* Wait for a reply... */
19204 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19207 api_one_eid_table_vni_dump (vat_main_t * vam)
19209 vl_api_one_eid_table_vni_dump_t *mp;
19210 vl_api_control_ping_t *mp_ping;
19213 if (!vam->json_output)
19215 print (vam->ofp, "VNI");
19218 M (ONE_EID_TABLE_VNI_DUMP, mp);
19223 /* Use a control ping for synchronization */
19224 MPING (CONTROL_PING, mp_ping);
19227 /* Wait for a reply... */
19232 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19235 api_one_eid_table_dump (vat_main_t * vam)
19237 unformat_input_t *i = vam->input;
19238 vl_api_one_eid_table_dump_t *mp;
19239 vl_api_control_ping_t *mp_ping;
19240 struct in_addr ip4;
19241 struct in6_addr ip6;
19243 u8 eid_type = ~0, eid_set = 0;
19244 u32 prefix_length = ~0, t, vni = 0;
19247 lisp_nsh_api_t nsh;
19249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19251 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19257 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19263 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19268 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19273 else if (unformat (i, "vni %d", &t))
19277 else if (unformat (i, "local"))
19281 else if (unformat (i, "remote"))
19287 errmsg ("parse error '%U'", format_unformat_error, i);
19292 if (!vam->json_output)
19294 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19295 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19298 M (ONE_EID_TABLE_DUMP, mp);
19300 mp->filter = filter;
19304 mp->vni = htonl (vni);
19305 mp->eid_type = eid_type;
19309 mp->prefix_length = prefix_length;
19310 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19313 mp->prefix_length = prefix_length;
19314 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19317 clib_memcpy (mp->eid, mac, sizeof (mac));
19320 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19323 errmsg ("unknown EID type %d!", eid_type);
19331 /* Use a control ping for synchronization */
19332 MPING (CONTROL_PING, mp_ping);
19335 /* Wait for a reply... */
19340 #define api_lisp_eid_table_dump api_one_eid_table_dump
19343 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19345 unformat_input_t *i = vam->input;
19346 vl_api_gpe_fwd_entries_get_t *mp;
19351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19353 if (unformat (i, "vni %d", &vni))
19359 errmsg ("parse error '%U'", format_unformat_error, i);
19366 errmsg ("vni not set!");
19370 if (!vam->json_output)
19372 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19376 M (GPE_FWD_ENTRIES_GET, mp);
19377 mp->vni = clib_host_to_net_u32 (vni);
19382 /* Wait for a reply... */
19387 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19388 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19389 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19390 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19391 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19392 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19393 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19394 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19397 api_one_adjacencies_get (vat_main_t * vam)
19399 unformat_input_t *i = vam->input;
19400 vl_api_one_adjacencies_get_t *mp;
19405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19407 if (unformat (i, "vni %d", &vni))
19413 errmsg ("parse error '%U'", format_unformat_error, i);
19420 errmsg ("vni not set!");
19424 if (!vam->json_output)
19426 print (vam->ofp, "%s %40s", "leid", "reid");
19429 M (ONE_ADJACENCIES_GET, mp);
19430 mp->vni = clib_host_to_net_u32 (vni);
19435 /* Wait for a reply... */
19440 #define api_lisp_adjacencies_get api_one_adjacencies_get
19443 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19445 unformat_input_t *i = vam->input;
19446 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19448 u8 ip_family_set = 0, is_ip4 = 1;
19450 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19452 if (unformat (i, "ip4"))
19457 else if (unformat (i, "ip6"))
19464 errmsg ("parse error '%U'", format_unformat_error, i);
19469 if (!ip_family_set)
19471 errmsg ("ip family not set!");
19475 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19476 mp->is_ip4 = is_ip4;
19481 /* Wait for a reply... */
19487 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19489 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19492 if (!vam->json_output)
19494 print (vam->ofp, "VNIs");
19497 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19502 /* Wait for a reply... */
19508 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19510 unformat_input_t *i = vam->input;
19511 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19513 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19514 struct in_addr ip4;
19515 struct in6_addr ip6;
19516 u32 table_id = 0, nh_sw_if_index = ~0;
19518 clib_memset (&ip4, 0, sizeof (ip4));
19519 clib_memset (&ip6, 0, sizeof (ip6));
19521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19523 if (unformat (i, "del"))
19525 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19526 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19531 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19532 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19537 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19541 nh_sw_if_index = ~0;
19543 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19547 nh_sw_if_index = ~0;
19549 else if (unformat (i, "table %d", &table_id))
19553 errmsg ("parse error '%U'", format_unformat_error, i);
19560 errmsg ("nh addr not set!");
19564 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19565 mp->is_add = is_add;
19566 mp->table_id = clib_host_to_net_u32 (table_id);
19567 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19568 mp->is_ip4 = is_ip4;
19570 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19572 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19577 /* Wait for a reply... */
19583 api_one_map_server_dump (vat_main_t * vam)
19585 vl_api_one_map_server_dump_t *mp;
19586 vl_api_control_ping_t *mp_ping;
19589 if (!vam->json_output)
19591 print (vam->ofp, "%=20s", "Map server");
19594 M (ONE_MAP_SERVER_DUMP, mp);
19598 /* Use a control ping for synchronization */
19599 MPING (CONTROL_PING, mp_ping);
19602 /* Wait for a reply... */
19607 #define api_lisp_map_server_dump api_one_map_server_dump
19610 api_one_map_resolver_dump (vat_main_t * vam)
19612 vl_api_one_map_resolver_dump_t *mp;
19613 vl_api_control_ping_t *mp_ping;
19616 if (!vam->json_output)
19618 print (vam->ofp, "%=20s", "Map resolver");
19621 M (ONE_MAP_RESOLVER_DUMP, mp);
19625 /* Use a control ping for synchronization */
19626 MPING (CONTROL_PING, mp_ping);
19629 /* Wait for a reply... */
19634 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19637 api_one_stats_flush (vat_main_t * vam)
19639 vl_api_one_stats_flush_t *mp;
19642 M (ONE_STATS_FLUSH, mp);
19649 api_one_stats_dump (vat_main_t * vam)
19651 vl_api_one_stats_dump_t *mp;
19652 vl_api_control_ping_t *mp_ping;
19655 M (ONE_STATS_DUMP, mp);
19659 /* Use a control ping for synchronization */
19660 MPING (CONTROL_PING, mp_ping);
19663 /* Wait for a reply... */
19669 api_show_one_status (vat_main_t * vam)
19671 vl_api_show_one_status_t *mp;
19674 if (!vam->json_output)
19676 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19679 M (SHOW_ONE_STATUS, mp);
19682 /* Wait for a reply... */
19687 #define api_show_lisp_status api_show_one_status
19690 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19692 vl_api_gpe_fwd_entry_path_dump_t *mp;
19693 vl_api_control_ping_t *mp_ping;
19694 unformat_input_t *i = vam->input;
19695 u32 fwd_entry_index = ~0;
19698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19700 if (unformat (i, "index %d", &fwd_entry_index))
19706 if (~0 == fwd_entry_index)
19708 errmsg ("no index specified!");
19712 if (!vam->json_output)
19714 print (vam->ofp, "first line");
19717 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19721 /* Use a control ping for synchronization */
19722 MPING (CONTROL_PING, mp_ping);
19725 /* Wait for a reply... */
19731 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19733 vl_api_one_get_map_request_itr_rlocs_t *mp;
19736 if (!vam->json_output)
19738 print (vam->ofp, "%=20s", "itr-rlocs:");
19741 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19744 /* Wait for a reply... */
19749 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19752 api_af_packet_create (vat_main_t * vam)
19754 unformat_input_t *i = vam->input;
19755 vl_api_af_packet_create_t *mp;
19756 u8 *host_if_name = 0;
19758 u8 random_hw_addr = 1;
19761 clib_memset (hw_addr, 0, sizeof (hw_addr));
19763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19765 if (unformat (i, "name %s", &host_if_name))
19766 vec_add1 (host_if_name, 0);
19767 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19768 random_hw_addr = 0;
19773 if (!vec_len (host_if_name))
19775 errmsg ("host-interface name must be specified");
19779 if (vec_len (host_if_name) > 64)
19781 errmsg ("host-interface name too long");
19785 M (AF_PACKET_CREATE, mp);
19787 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19788 clib_memcpy (mp->hw_addr, hw_addr, 6);
19789 mp->use_random_hw_addr = random_hw_addr;
19790 vec_free (host_if_name);
19798 fprintf (vam->ofp ? vam->ofp : stderr,
19799 " new sw_if_index = %d\n", vam->sw_if_index);
19806 api_af_packet_delete (vat_main_t * vam)
19808 unformat_input_t *i = vam->input;
19809 vl_api_af_packet_delete_t *mp;
19810 u8 *host_if_name = 0;
19813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19815 if (unformat (i, "name %s", &host_if_name))
19816 vec_add1 (host_if_name, 0);
19821 if (!vec_len (host_if_name))
19823 errmsg ("host-interface name must be specified");
19827 if (vec_len (host_if_name) > 64)
19829 errmsg ("host-interface name too long");
19833 M (AF_PACKET_DELETE, mp);
19835 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19836 vec_free (host_if_name);
19843 static void vl_api_af_packet_details_t_handler
19844 (vl_api_af_packet_details_t * mp)
19846 vat_main_t *vam = &vat_main;
19848 print (vam->ofp, "%-16s %d",
19849 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19852 static void vl_api_af_packet_details_t_handler_json
19853 (vl_api_af_packet_details_t * mp)
19855 vat_main_t *vam = &vat_main;
19856 vat_json_node_t *node = NULL;
19858 if (VAT_JSON_ARRAY != vam->json_tree.type)
19860 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19861 vat_json_init_array (&vam->json_tree);
19863 node = vat_json_array_add (&vam->json_tree);
19865 vat_json_init_object (node);
19866 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19867 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19871 api_af_packet_dump (vat_main_t * vam)
19873 vl_api_af_packet_dump_t *mp;
19874 vl_api_control_ping_t *mp_ping;
19877 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19878 /* Get list of tap interfaces */
19879 M (AF_PACKET_DUMP, mp);
19882 /* Use a control ping for synchronization */
19883 MPING (CONTROL_PING, mp_ping);
19891 api_policer_add_del (vat_main_t * vam)
19893 unformat_input_t *i = vam->input;
19894 vl_api_policer_add_del_t *mp;
19904 u8 color_aware = 0;
19905 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19908 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19909 conform_action.dscp = 0;
19910 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19911 exceed_action.dscp = 0;
19912 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19913 violate_action.dscp = 0;
19915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19917 if (unformat (i, "del"))
19919 else if (unformat (i, "name %s", &name))
19920 vec_add1 (name, 0);
19921 else if (unformat (i, "cir %u", &cir))
19923 else if (unformat (i, "eir %u", &eir))
19925 else if (unformat (i, "cb %u", &cb))
19927 else if (unformat (i, "eb %u", &eb))
19929 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19932 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19935 else if (unformat (i, "type %U", unformat_policer_type, &type))
19937 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19940 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19943 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19946 else if (unformat (i, "color-aware"))
19952 if (!vec_len (name))
19954 errmsg ("policer name must be specified");
19958 if (vec_len (name) > 64)
19960 errmsg ("policer name too long");
19964 M (POLICER_ADD_DEL, mp);
19966 clib_memcpy (mp->name, name, vec_len (name));
19968 mp->is_add = is_add;
19969 mp->cir = ntohl (cir);
19970 mp->eir = ntohl (eir);
19971 mp->cb = clib_net_to_host_u64 (cb);
19972 mp->eb = clib_net_to_host_u64 (eb);
19973 mp->rate_type = rate_type;
19974 mp->round_type = round_type;
19976 mp->conform_action_type = conform_action.action_type;
19977 mp->conform_dscp = conform_action.dscp;
19978 mp->exceed_action_type = exceed_action.action_type;
19979 mp->exceed_dscp = exceed_action.dscp;
19980 mp->violate_action_type = violate_action.action_type;
19981 mp->violate_dscp = violate_action.dscp;
19982 mp->color_aware = color_aware;
19990 api_policer_dump (vat_main_t * vam)
19992 unformat_input_t *i = vam->input;
19993 vl_api_policer_dump_t *mp;
19994 vl_api_control_ping_t *mp_ping;
19995 u8 *match_name = 0;
19996 u8 match_name_valid = 0;
19999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20001 if (unformat (i, "name %s", &match_name))
20003 vec_add1 (match_name, 0);
20004 match_name_valid = 1;
20010 M (POLICER_DUMP, mp);
20011 mp->match_name_valid = match_name_valid;
20012 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
20013 vec_free (match_name);
20017 /* Use a control ping for synchronization */
20018 MPING (CONTROL_PING, mp_ping);
20021 /* Wait for a reply... */
20027 api_policer_classify_set_interface (vat_main_t * vam)
20029 unformat_input_t *i = vam->input;
20030 vl_api_policer_classify_set_interface_t *mp;
20032 int sw_if_index_set;
20033 u32 ip4_table_index = ~0;
20034 u32 ip6_table_index = ~0;
20035 u32 l2_table_index = ~0;
20039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20041 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20042 sw_if_index_set = 1;
20043 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20044 sw_if_index_set = 1;
20045 else if (unformat (i, "del"))
20047 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20049 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20051 else if (unformat (i, "l2-table %d", &l2_table_index))
20055 clib_warning ("parse error '%U'", format_unformat_error, i);
20060 if (sw_if_index_set == 0)
20062 errmsg ("missing interface name or sw_if_index");
20066 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20068 mp->sw_if_index = ntohl (sw_if_index);
20069 mp->ip4_table_index = ntohl (ip4_table_index);
20070 mp->ip6_table_index = ntohl (ip6_table_index);
20071 mp->l2_table_index = ntohl (l2_table_index);
20072 mp->is_add = is_add;
20080 api_policer_classify_dump (vat_main_t * vam)
20082 unformat_input_t *i = vam->input;
20083 vl_api_policer_classify_dump_t *mp;
20084 vl_api_control_ping_t *mp_ping;
20085 u8 type = POLICER_CLASSIFY_N_TABLES;
20088 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20092 errmsg ("classify table type must be specified");
20096 if (!vam->json_output)
20098 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20101 M (POLICER_CLASSIFY_DUMP, mp);
20106 /* Use a control ping for synchronization */
20107 MPING (CONTROL_PING, mp_ping);
20110 /* Wait for a reply... */
20116 api_netmap_create (vat_main_t * vam)
20118 unformat_input_t *i = vam->input;
20119 vl_api_netmap_create_t *mp;
20122 u8 random_hw_addr = 1;
20127 clib_memset (hw_addr, 0, sizeof (hw_addr));
20129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20131 if (unformat (i, "name %s", &if_name))
20132 vec_add1 (if_name, 0);
20133 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20134 random_hw_addr = 0;
20135 else if (unformat (i, "pipe"))
20137 else if (unformat (i, "master"))
20139 else if (unformat (i, "slave"))
20145 if (!vec_len (if_name))
20147 errmsg ("interface name must be specified");
20151 if (vec_len (if_name) > 64)
20153 errmsg ("interface name too long");
20157 M (NETMAP_CREATE, mp);
20159 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20160 clib_memcpy (mp->hw_addr, hw_addr, 6);
20161 mp->use_random_hw_addr = random_hw_addr;
20162 mp->is_pipe = is_pipe;
20163 mp->is_master = is_master;
20164 vec_free (if_name);
20172 api_netmap_delete (vat_main_t * vam)
20174 unformat_input_t *i = vam->input;
20175 vl_api_netmap_delete_t *mp;
20179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20181 if (unformat (i, "name %s", &if_name))
20182 vec_add1 (if_name, 0);
20187 if (!vec_len (if_name))
20189 errmsg ("interface name must be specified");
20193 if (vec_len (if_name) > 64)
20195 errmsg ("interface name too long");
20199 M (NETMAP_DELETE, mp);
20201 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20202 vec_free (if_name);
20210 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20212 if (fp->afi == IP46_TYPE_IP6)
20214 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20215 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20216 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
20217 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20218 format_ip6_address, fp->next_hop);
20219 else if (fp->afi == IP46_TYPE_IP4)
20221 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20222 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20223 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
20224 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20225 format_ip4_address, fp->next_hop);
20229 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20230 vl_api_fib_path_t * fp)
20232 struct in_addr ip4;
20233 struct in6_addr ip6;
20235 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20236 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20237 vat_json_object_add_uint (node, "is_local", fp->is_local);
20238 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20239 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20240 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20241 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20242 if (fp->afi == IP46_TYPE_IP4)
20244 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20245 vat_json_object_add_ip4 (node, "next_hop", ip4);
20247 else if (fp->afi == IP46_TYPE_IP6)
20249 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20250 vat_json_object_add_ip6 (node, "next_hop", ip6);
20255 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20257 vat_main_t *vam = &vat_main;
20258 int count = ntohl (mp->mt_count);
20259 vl_api_fib_path_t *fp;
20262 print (vam->ofp, "[%d]: sw_if_index %d via:",
20263 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20265 for (i = 0; i < count; i++)
20267 vl_api_mpls_fib_path_print (vam, fp);
20271 print (vam->ofp, "");
20274 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20275 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20278 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20280 vat_main_t *vam = &vat_main;
20281 vat_json_node_t *node = NULL;
20282 int count = ntohl (mp->mt_count);
20283 vl_api_fib_path_t *fp;
20286 if (VAT_JSON_ARRAY != vam->json_tree.type)
20288 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20289 vat_json_init_array (&vam->json_tree);
20291 node = vat_json_array_add (&vam->json_tree);
20293 vat_json_init_object (node);
20294 vat_json_object_add_uint (node, "tunnel_index",
20295 ntohl (mp->mt_tunnel_index));
20296 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20298 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20301 for (i = 0; i < count; i++)
20303 vl_api_mpls_fib_path_json_print (node, fp);
20309 api_mpls_tunnel_dump (vat_main_t * vam)
20311 vl_api_mpls_tunnel_dump_t *mp;
20312 vl_api_control_ping_t *mp_ping;
20313 u32 sw_if_index = ~0;
20316 /* Parse args required to build the message */
20317 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20319 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
20323 print (vam->ofp, " sw_if_index %d", sw_if_index);
20325 M (MPLS_TUNNEL_DUMP, mp);
20326 mp->sw_if_index = htonl (sw_if_index);
20329 /* Use a control ping for synchronization */
20330 MPING (CONTROL_PING, mp_ping);
20337 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20338 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20342 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20344 vat_main_t *vam = &vat_main;
20345 int count = ntohl (mp->count);
20346 vl_api_fib_path_t *fp;
20350 "table-id %d, label %u, ess_bit %u",
20351 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20353 for (i = 0; i < count; i++)
20355 vl_api_mpls_fib_path_print (vam, fp);
20360 static void vl_api_mpls_fib_details_t_handler_json
20361 (vl_api_mpls_fib_details_t * mp)
20363 vat_main_t *vam = &vat_main;
20364 int count = ntohl (mp->count);
20365 vat_json_node_t *node = NULL;
20366 vl_api_fib_path_t *fp;
20369 if (VAT_JSON_ARRAY != vam->json_tree.type)
20371 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20372 vat_json_init_array (&vam->json_tree);
20374 node = vat_json_array_add (&vam->json_tree);
20376 vat_json_init_object (node);
20377 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20378 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20379 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20380 vat_json_object_add_uint (node, "path_count", count);
20382 for (i = 0; i < count; i++)
20384 vl_api_mpls_fib_path_json_print (node, fp);
20390 api_mpls_fib_dump (vat_main_t * vam)
20392 vl_api_mpls_fib_dump_t *mp;
20393 vl_api_control_ping_t *mp_ping;
20396 M (MPLS_FIB_DUMP, mp);
20399 /* Use a control ping for synchronization */
20400 MPING (CONTROL_PING, mp_ping);
20407 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20408 #define vl_api_ip_fib_details_t_print vl_noop_handler
20411 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20413 vat_main_t *vam = &vat_main;
20414 int count = ntohl (mp->count);
20415 vl_api_fib_path_t *fp;
20419 "table-id %d, prefix %U/%d stats-index %d",
20420 ntohl (mp->table_id), format_ip4_address, mp->address,
20421 mp->address_length, ntohl (mp->stats_index));
20423 for (i = 0; i < count; i++)
20425 if (fp->afi == IP46_TYPE_IP6)
20427 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20428 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20429 "next_hop_table %d",
20430 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20431 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20432 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20433 else if (fp->afi == IP46_TYPE_IP4)
20435 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20436 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20437 "next_hop_table %d",
20438 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20439 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20440 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20445 static void vl_api_ip_fib_details_t_handler_json
20446 (vl_api_ip_fib_details_t * mp)
20448 vat_main_t *vam = &vat_main;
20449 int count = ntohl (mp->count);
20450 vat_json_node_t *node = NULL;
20451 struct in_addr ip4;
20452 struct in6_addr ip6;
20453 vl_api_fib_path_t *fp;
20456 if (VAT_JSON_ARRAY != vam->json_tree.type)
20458 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20459 vat_json_init_array (&vam->json_tree);
20461 node = vat_json_array_add (&vam->json_tree);
20463 vat_json_init_object (node);
20464 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20465 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20466 vat_json_object_add_ip4 (node, "prefix", ip4);
20467 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20468 vat_json_object_add_uint (node, "path_count", count);
20470 for (i = 0; i < count; i++)
20472 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20473 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20474 vat_json_object_add_uint (node, "is_local", fp->is_local);
20475 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20476 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20477 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20478 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20479 if (fp->afi == IP46_TYPE_IP4)
20481 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20482 vat_json_object_add_ip4 (node, "next_hop", ip4);
20484 else if (fp->afi == IP46_TYPE_IP6)
20486 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20487 vat_json_object_add_ip6 (node, "next_hop", ip6);
20493 api_ip_fib_dump (vat_main_t * vam)
20495 vl_api_ip_fib_dump_t *mp;
20496 vl_api_control_ping_t *mp_ping;
20499 M (IP_FIB_DUMP, mp);
20502 /* Use a control ping for synchronization */
20503 MPING (CONTROL_PING, mp_ping);
20511 api_ip_mfib_dump (vat_main_t * vam)
20513 vl_api_ip_mfib_dump_t *mp;
20514 vl_api_control_ping_t *mp_ping;
20517 M (IP_MFIB_DUMP, mp);
20520 /* Use a control ping for synchronization */
20521 MPING (CONTROL_PING, mp_ping);
20528 static void vl_api_ip_neighbor_details_t_handler
20529 (vl_api_ip_neighbor_details_t * mp)
20531 vat_main_t *vam = &vat_main;
20533 print (vam->ofp, "%c %U %U",
20534 (mp->is_static) ? 'S' : 'D',
20535 format_ethernet_address, &mp->mac_address,
20536 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20540 static void vl_api_ip_neighbor_details_t_handler_json
20541 (vl_api_ip_neighbor_details_t * mp)
20544 vat_main_t *vam = &vat_main;
20545 vat_json_node_t *node;
20546 struct in_addr ip4;
20547 struct in6_addr ip6;
20549 if (VAT_JSON_ARRAY != vam->json_tree.type)
20551 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20552 vat_json_init_array (&vam->json_tree);
20554 node = vat_json_array_add (&vam->json_tree);
20556 vat_json_init_object (node);
20557 vat_json_object_add_string_copy (node, "flag",
20558 (mp->is_static) ? (u8 *) "static" : (u8 *)
20561 vat_json_object_add_string_copy (node, "link_layer",
20562 format (0, "%U", format_ethernet_address,
20563 &mp->mac_address));
20567 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20568 vat_json_object_add_ip6 (node, "ip_address", ip6);
20572 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20573 vat_json_object_add_ip4 (node, "ip_address", ip4);
20578 api_ip_neighbor_dump (vat_main_t * vam)
20580 unformat_input_t *i = vam->input;
20581 vl_api_ip_neighbor_dump_t *mp;
20582 vl_api_control_ping_t *mp_ping;
20584 u32 sw_if_index = ~0;
20587 /* Parse args required to build the message */
20588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20590 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20592 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20594 else if (unformat (i, "ip6"))
20600 if (sw_if_index == ~0)
20602 errmsg ("missing interface name or sw_if_index");
20606 M (IP_NEIGHBOR_DUMP, mp);
20607 mp->is_ipv6 = (u8) is_ipv6;
20608 mp->sw_if_index = ntohl (sw_if_index);
20611 /* Use a control ping for synchronization */
20612 MPING (CONTROL_PING, mp_ping);
20619 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20620 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20623 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20625 vat_main_t *vam = &vat_main;
20626 int count = ntohl (mp->count);
20627 vl_api_fib_path_t *fp;
20631 "table-id %d, prefix %U/%d stats-index %d",
20632 ntohl (mp->table_id), format_ip6_address, mp->address,
20633 mp->address_length, ntohl (mp->stats_index));
20635 for (i = 0; i < count; i++)
20637 if (fp->afi == IP46_TYPE_IP6)
20639 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20640 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20641 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20642 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20643 format_ip6_address, fp->next_hop);
20644 else if (fp->afi == IP46_TYPE_IP4)
20646 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20647 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20648 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20649 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20650 format_ip4_address, fp->next_hop);
20655 static void vl_api_ip6_fib_details_t_handler_json
20656 (vl_api_ip6_fib_details_t * mp)
20658 vat_main_t *vam = &vat_main;
20659 int count = ntohl (mp->count);
20660 vat_json_node_t *node = NULL;
20661 struct in_addr ip4;
20662 struct in6_addr ip6;
20663 vl_api_fib_path_t *fp;
20666 if (VAT_JSON_ARRAY != vam->json_tree.type)
20668 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20669 vat_json_init_array (&vam->json_tree);
20671 node = vat_json_array_add (&vam->json_tree);
20673 vat_json_init_object (node);
20674 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20675 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20676 vat_json_object_add_ip6 (node, "prefix", ip6);
20677 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20678 vat_json_object_add_uint (node, "path_count", count);
20680 for (i = 0; i < count; i++)
20682 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20683 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20684 vat_json_object_add_uint (node, "is_local", fp->is_local);
20685 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20686 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20687 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20688 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20689 if (fp->afi == IP46_TYPE_IP4)
20691 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20692 vat_json_object_add_ip4 (node, "next_hop", ip4);
20694 else if (fp->afi == IP46_TYPE_IP6)
20696 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20697 vat_json_object_add_ip6 (node, "next_hop", ip6);
20703 api_ip6_fib_dump (vat_main_t * vam)
20705 vl_api_ip6_fib_dump_t *mp;
20706 vl_api_control_ping_t *mp_ping;
20709 M (IP6_FIB_DUMP, mp);
20712 /* Use a control ping for synchronization */
20713 MPING (CONTROL_PING, mp_ping);
20721 api_ip6_mfib_dump (vat_main_t * vam)
20723 vl_api_ip6_mfib_dump_t *mp;
20724 vl_api_control_ping_t *mp_ping;
20727 M (IP6_MFIB_DUMP, mp);
20730 /* Use a control ping for synchronization */
20731 MPING (CONTROL_PING, mp_ping);
20739 api_classify_table_ids (vat_main_t * vam)
20741 vl_api_classify_table_ids_t *mp;
20744 /* Construct the API message */
20745 M (CLASSIFY_TABLE_IDS, mp);
20754 api_classify_table_by_interface (vat_main_t * vam)
20756 unformat_input_t *input = vam->input;
20757 vl_api_classify_table_by_interface_t *mp;
20759 u32 sw_if_index = ~0;
20761 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20763 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20765 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20770 if (sw_if_index == ~0)
20772 errmsg ("missing interface name or sw_if_index");
20776 /* Construct the API message */
20777 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20779 mp->sw_if_index = ntohl (sw_if_index);
20787 api_classify_table_info (vat_main_t * vam)
20789 unformat_input_t *input = vam->input;
20790 vl_api_classify_table_info_t *mp;
20794 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20796 if (unformat (input, "table_id %d", &table_id))
20801 if (table_id == ~0)
20803 errmsg ("missing table id");
20807 /* Construct the API message */
20808 M (CLASSIFY_TABLE_INFO, mp);
20810 mp->table_id = ntohl (table_id);
20818 api_classify_session_dump (vat_main_t * vam)
20820 unformat_input_t *input = vam->input;
20821 vl_api_classify_session_dump_t *mp;
20822 vl_api_control_ping_t *mp_ping;
20826 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20828 if (unformat (input, "table_id %d", &table_id))
20833 if (table_id == ~0)
20835 errmsg ("missing table id");
20839 /* Construct the API message */
20840 M (CLASSIFY_SESSION_DUMP, mp);
20842 mp->table_id = ntohl (table_id);
20845 /* Use a control ping for synchronization */
20846 MPING (CONTROL_PING, mp_ping);
20854 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20856 vat_main_t *vam = &vat_main;
20858 print (vam->ofp, "collector_address %U, collector_port %d, "
20859 "src_address %U, vrf_id %d, path_mtu %u, "
20860 "template_interval %u, udp_checksum %d",
20861 format_ip4_address, mp->collector_address,
20862 ntohs (mp->collector_port),
20863 format_ip4_address, mp->src_address,
20864 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20865 ntohl (mp->template_interval), mp->udp_checksum);
20868 vam->result_ready = 1;
20872 vl_api_ipfix_exporter_details_t_handler_json
20873 (vl_api_ipfix_exporter_details_t * mp)
20875 vat_main_t *vam = &vat_main;
20876 vat_json_node_t node;
20877 struct in_addr collector_address;
20878 struct in_addr src_address;
20880 vat_json_init_object (&node);
20881 clib_memcpy (&collector_address, &mp->collector_address,
20882 sizeof (collector_address));
20883 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20884 vat_json_object_add_uint (&node, "collector_port",
20885 ntohs (mp->collector_port));
20886 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20887 vat_json_object_add_ip4 (&node, "src_address", src_address);
20888 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20889 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20890 vat_json_object_add_uint (&node, "template_interval",
20891 ntohl (mp->template_interval));
20892 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20894 vat_json_print (vam->ofp, &node);
20895 vat_json_free (&node);
20897 vam->result_ready = 1;
20901 api_ipfix_exporter_dump (vat_main_t * vam)
20903 vl_api_ipfix_exporter_dump_t *mp;
20906 /* Construct the API message */
20907 M (IPFIX_EXPORTER_DUMP, mp);
20916 api_ipfix_classify_stream_dump (vat_main_t * vam)
20918 vl_api_ipfix_classify_stream_dump_t *mp;
20921 /* Construct the API message */
20922 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20933 vl_api_ipfix_classify_stream_details_t_handler
20934 (vl_api_ipfix_classify_stream_details_t * mp)
20936 vat_main_t *vam = &vat_main;
20937 print (vam->ofp, "domain_id %d, src_port %d",
20938 ntohl (mp->domain_id), ntohs (mp->src_port));
20940 vam->result_ready = 1;
20944 vl_api_ipfix_classify_stream_details_t_handler_json
20945 (vl_api_ipfix_classify_stream_details_t * mp)
20947 vat_main_t *vam = &vat_main;
20948 vat_json_node_t node;
20950 vat_json_init_object (&node);
20951 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20952 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20954 vat_json_print (vam->ofp, &node);
20955 vat_json_free (&node);
20957 vam->result_ready = 1;
20961 api_ipfix_classify_table_dump (vat_main_t * vam)
20963 vl_api_ipfix_classify_table_dump_t *mp;
20964 vl_api_control_ping_t *mp_ping;
20967 if (!vam->json_output)
20969 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20970 "transport_protocol");
20973 /* Construct the API message */
20974 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20979 /* Use a control ping for synchronization */
20980 MPING (CONTROL_PING, mp_ping);
20988 vl_api_ipfix_classify_table_details_t_handler
20989 (vl_api_ipfix_classify_table_details_t * mp)
20991 vat_main_t *vam = &vat_main;
20992 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20993 mp->transport_protocol);
20997 vl_api_ipfix_classify_table_details_t_handler_json
20998 (vl_api_ipfix_classify_table_details_t * mp)
21000 vat_json_node_t *node = NULL;
21001 vat_main_t *vam = &vat_main;
21003 if (VAT_JSON_ARRAY != vam->json_tree.type)
21005 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21006 vat_json_init_array (&vam->json_tree);
21009 node = vat_json_array_add (&vam->json_tree);
21010 vat_json_init_object (node);
21012 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
21013 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
21014 vat_json_object_add_uint (node, "transport_protocol",
21015 mp->transport_protocol);
21019 api_sw_interface_span_enable_disable (vat_main_t * vam)
21021 unformat_input_t *i = vam->input;
21022 vl_api_sw_interface_span_enable_disable_t *mp;
21023 u32 src_sw_if_index = ~0;
21024 u32 dst_sw_if_index = ~0;
21029 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21032 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21034 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21038 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21040 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21042 else if (unformat (i, "disable"))
21044 else if (unformat (i, "rx"))
21046 else if (unformat (i, "tx"))
21048 else if (unformat (i, "both"))
21050 else if (unformat (i, "l2"))
21056 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21058 mp->sw_if_index_from = htonl (src_sw_if_index);
21059 mp->sw_if_index_to = htonl (dst_sw_if_index);
21069 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21072 vat_main_t *vam = &vat_main;
21073 u8 *sw_if_from_name = 0;
21074 u8 *sw_if_to_name = 0;
21075 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21076 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21077 char *states[] = { "none", "rx", "tx", "both" };
21081 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21083 if ((u32) p->value[0] == sw_if_index_from)
21085 sw_if_from_name = (u8 *)(p->key);
21089 if ((u32) p->value[0] == sw_if_index_to)
21091 sw_if_to_name = (u8 *)(p->key);
21092 if (sw_if_from_name)
21097 print (vam->ofp, "%20s => %20s (%s) %s",
21098 sw_if_from_name, sw_if_to_name, states[mp->state],
21099 mp->is_l2 ? "l2" : "device");
21103 vl_api_sw_interface_span_details_t_handler_json
21104 (vl_api_sw_interface_span_details_t * mp)
21106 vat_main_t *vam = &vat_main;
21107 vat_json_node_t *node = NULL;
21108 u8 *sw_if_from_name = 0;
21109 u8 *sw_if_to_name = 0;
21110 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21111 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21115 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21117 if ((u32) p->value[0] == sw_if_index_from)
21119 sw_if_from_name = (u8 *)(p->key);
21123 if ((u32) p->value[0] == sw_if_index_to)
21125 sw_if_to_name = (u8 *)(p->key);
21126 if (sw_if_from_name)
21132 if (VAT_JSON_ARRAY != vam->json_tree.type)
21134 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21135 vat_json_init_array (&vam->json_tree);
21137 node = vat_json_array_add (&vam->json_tree);
21139 vat_json_init_object (node);
21140 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21141 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21142 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21143 if (0 != sw_if_to_name)
21145 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21147 vat_json_object_add_uint (node, "state", mp->state);
21148 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21152 api_sw_interface_span_dump (vat_main_t * vam)
21154 unformat_input_t *input = vam->input;
21155 vl_api_sw_interface_span_dump_t *mp;
21156 vl_api_control_ping_t *mp_ping;
21160 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21162 if (unformat (input, "l2"))
21168 M (SW_INTERFACE_SPAN_DUMP, mp);
21172 /* Use a control ping for synchronization */
21173 MPING (CONTROL_PING, mp_ping);
21181 api_pg_create_interface (vat_main_t * vam)
21183 unformat_input_t *input = vam->input;
21184 vl_api_pg_create_interface_t *mp;
21188 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21190 if (unformat (input, "if_id %d", &if_id))
21197 errmsg ("missing pg interface index");
21201 /* Construct the API message */
21202 M (PG_CREATE_INTERFACE, mp);
21204 mp->interface_id = ntohl (if_id);
21212 api_pg_capture (vat_main_t * vam)
21214 unformat_input_t *input = vam->input;
21215 vl_api_pg_capture_t *mp;
21220 u8 pcap_file_set = 0;
21223 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21225 if (unformat (input, "if_id %d", &if_id))
21227 else if (unformat (input, "pcap %s", &pcap_file))
21229 else if (unformat (input, "count %d", &count))
21231 else if (unformat (input, "disable"))
21238 errmsg ("missing pg interface index");
21241 if (pcap_file_set > 0)
21243 if (vec_len (pcap_file) > 255)
21245 errmsg ("pcap file name is too long");
21250 u32 name_len = vec_len (pcap_file);
21251 /* Construct the API message */
21252 M (PG_CAPTURE, mp);
21254 mp->interface_id = ntohl (if_id);
21255 mp->is_enabled = enable;
21256 mp->count = ntohl (count);
21257 mp->pcap_name_length = ntohl (name_len);
21258 if (pcap_file_set != 0)
21260 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21262 vec_free (pcap_file);
21270 api_pg_enable_disable (vat_main_t * vam)
21272 unformat_input_t *input = vam->input;
21273 vl_api_pg_enable_disable_t *mp;
21276 u8 stream_name_set = 0;
21277 u8 *stream_name = 0;
21279 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21281 if (unformat (input, "stream %s", &stream_name))
21282 stream_name_set = 1;
21283 else if (unformat (input, "disable"))
21289 if (stream_name_set > 0)
21291 if (vec_len (stream_name) > 255)
21293 errmsg ("stream name too long");
21298 u32 name_len = vec_len (stream_name);
21299 /* Construct the API message */
21300 M (PG_ENABLE_DISABLE, mp);
21302 mp->is_enabled = enable;
21303 if (stream_name_set != 0)
21305 mp->stream_name_length = ntohl (name_len);
21306 clib_memcpy (mp->stream_name, stream_name, name_len);
21308 vec_free (stream_name);
21316 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21318 unformat_input_t *input = vam->input;
21319 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21321 u16 *low_ports = 0;
21322 u16 *high_ports = 0;
21325 ip4_address_t ip4_addr;
21326 ip6_address_t ip6_addr;
21335 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21337 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21343 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21348 else if (unformat (input, "vrf %d", &vrf_id))
21350 else if (unformat (input, "del"))
21352 else if (unformat (input, "port %d", &tmp))
21354 if (tmp == 0 || tmp > 65535)
21356 errmsg ("port %d out of range", tmp);
21360 this_hi = this_low + 1;
21361 vec_add1 (low_ports, this_low);
21362 vec_add1 (high_ports, this_hi);
21364 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21366 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21368 errmsg ("incorrect range parameters");
21372 /* Note: in debug CLI +1 is added to high before
21373 passing to real fn that does "the work"
21374 (ip_source_and_port_range_check_add_del).
21375 This fn is a wrapper around the binary API fn a
21376 control plane will call, which expects this increment
21377 to have occurred. Hence letting the binary API control
21378 plane fn do the increment for consistency between VAT
21379 and other control planes.
21382 vec_add1 (low_ports, this_low);
21383 vec_add1 (high_ports, this_hi);
21389 if (prefix_set == 0)
21391 errmsg ("<address>/<mask> not specified");
21397 errmsg ("VRF ID required, not specified");
21404 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21408 if (vec_len (low_ports) == 0)
21410 errmsg ("At least one port or port range required");
21414 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21416 mp->is_add = is_add;
21421 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21426 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21429 mp->mask_length = length;
21430 mp->number_of_ranges = vec_len (low_ports);
21432 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21433 vec_free (low_ports);
21435 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21436 vec_free (high_ports);
21438 mp->vrf_id = ntohl (vrf_id);
21446 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21448 unformat_input_t *input = vam->input;
21449 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21450 u32 sw_if_index = ~0;
21452 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21453 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21457 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21459 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21461 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21463 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21465 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21467 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21469 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21471 else if (unformat (input, "del"))
21477 if (sw_if_index == ~0)
21479 errmsg ("Interface required but not specified");
21485 errmsg ("VRF ID required but not specified");
21489 if (tcp_out_vrf_id == 0
21490 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21493 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21497 /* Construct the API message */
21498 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21500 mp->sw_if_index = ntohl (sw_if_index);
21501 mp->is_add = is_add;
21502 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21503 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21504 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21505 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21510 /* Wait for a reply... */
21516 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21518 unformat_input_t *i = vam->input;
21519 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21520 u32 local_sa_id = 0;
21521 u32 remote_sa_id = 0;
21522 ip4_address_t src_address;
21523 ip4_address_t dst_address;
21527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21529 if (unformat (i, "local_sa %d", &local_sa_id))
21531 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21533 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21535 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21537 else if (unformat (i, "del"))
21541 clib_warning ("parse error '%U'", format_unformat_error, i);
21546 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21548 mp->local_sa_id = ntohl (local_sa_id);
21549 mp->remote_sa_id = ntohl (remote_sa_id);
21550 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21551 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21552 mp->is_add = is_add;
21560 api_set_punt (vat_main_t * vam)
21562 unformat_input_t *i = vam->input;
21563 vl_api_set_punt_t *mp;
21570 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21572 if (unformat (i, "ip %d", &ipv))
21574 else if (unformat (i, "protocol %d", &protocol))
21576 else if (unformat (i, "port %d", &port))
21578 else if (unformat (i, "del"))
21582 clib_warning ("parse error '%U'", format_unformat_error, i);
21589 mp->is_add = (u8) is_add;
21590 mp->punt.ipv = (u8) ipv;
21591 mp->punt.l4_protocol = (u8) protocol;
21592 mp->punt.l4_port = htons ((u16) port);
21599 static void vl_api_ipsec_gre_tunnel_details_t_handler
21600 (vl_api_ipsec_gre_tunnel_details_t * mp)
21602 vat_main_t *vam = &vat_main;
21604 print (vam->ofp, "%11d%15U%15U%14d%14d",
21605 ntohl (mp->sw_if_index),
21606 format_ip4_address, &mp->src_address,
21607 format_ip4_address, &mp->dst_address,
21608 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21611 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21612 (vl_api_ipsec_gre_tunnel_details_t * mp)
21614 vat_main_t *vam = &vat_main;
21615 vat_json_node_t *node = NULL;
21616 struct in_addr ip4;
21618 if (VAT_JSON_ARRAY != vam->json_tree.type)
21620 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21621 vat_json_init_array (&vam->json_tree);
21623 node = vat_json_array_add (&vam->json_tree);
21625 vat_json_init_object (node);
21626 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21627 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21628 vat_json_object_add_ip4 (node, "src_address", ip4);
21629 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21630 vat_json_object_add_ip4 (node, "dst_address", ip4);
21631 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21632 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21636 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21638 unformat_input_t *i = vam->input;
21639 vl_api_ipsec_gre_tunnel_dump_t *mp;
21640 vl_api_control_ping_t *mp_ping;
21642 u8 sw_if_index_set = 0;
21645 /* Parse args required to build the message */
21646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21648 if (unformat (i, "sw_if_index %d", &sw_if_index))
21649 sw_if_index_set = 1;
21654 if (sw_if_index_set == 0)
21659 if (!vam->json_output)
21661 print (vam->ofp, "%11s%15s%15s%14s%14s",
21662 "sw_if_index", "src_address", "dst_address",
21663 "local_sa_id", "remote_sa_id");
21666 /* Get list of gre-tunnel interfaces */
21667 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21669 mp->sw_if_index = htonl (sw_if_index);
21673 /* Use a control ping for synchronization */
21674 MPING (CONTROL_PING, mp_ping);
21682 api_delete_subif (vat_main_t * vam)
21684 unformat_input_t *i = vam->input;
21685 vl_api_delete_subif_t *mp;
21686 u32 sw_if_index = ~0;
21689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21691 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21693 if (unformat (i, "sw_if_index %d", &sw_if_index))
21699 if (sw_if_index == ~0)
21701 errmsg ("missing sw_if_index");
21705 /* Construct the API message */
21706 M (DELETE_SUBIF, mp);
21707 mp->sw_if_index = ntohl (sw_if_index);
21714 #define foreach_pbb_vtr_op \
21715 _("disable", L2_VTR_DISABLED) \
21716 _("pop", L2_VTR_POP_2) \
21717 _("push", L2_VTR_PUSH_2)
21720 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21722 unformat_input_t *i = vam->input;
21723 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21724 u32 sw_if_index = ~0, vtr_op = ~0;
21725 u16 outer_tag = ~0;
21726 u8 dmac[6], smac[6];
21727 u8 dmac_set = 0, smac_set = 0;
21733 /* Shut up coverity */
21734 clib_memset (dmac, 0, sizeof (dmac));
21735 clib_memset (smac, 0, sizeof (smac));
21737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21739 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21741 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21743 else if (unformat (i, "vtr_op %d", &vtr_op))
21745 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21748 else if (unformat (i, "translate_pbb_stag"))
21750 if (unformat (i, "%d", &tmp))
21752 vtr_op = L2_VTR_TRANSLATE_2_1;
21758 ("translate_pbb_stag operation requires outer tag definition");
21762 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21764 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21766 else if (unformat (i, "sid %d", &sid))
21768 else if (unformat (i, "vlanid %d", &tmp))
21772 clib_warning ("parse error '%U'", format_unformat_error, i);
21777 if ((sw_if_index == ~0) || (vtr_op == ~0))
21779 errmsg ("missing sw_if_index or vtr operation");
21782 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21783 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21786 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21790 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21791 mp->sw_if_index = ntohl (sw_if_index);
21792 mp->vtr_op = ntohl (vtr_op);
21793 mp->outer_tag = ntohs (outer_tag);
21794 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21795 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21796 mp->b_vlanid = ntohs (vlanid);
21797 mp->i_sid = ntohl (sid);
21805 api_flow_classify_set_interface (vat_main_t * vam)
21807 unformat_input_t *i = vam->input;
21808 vl_api_flow_classify_set_interface_t *mp;
21810 int sw_if_index_set;
21811 u32 ip4_table_index = ~0;
21812 u32 ip6_table_index = ~0;
21816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21818 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21819 sw_if_index_set = 1;
21820 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21821 sw_if_index_set = 1;
21822 else if (unformat (i, "del"))
21824 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21826 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21830 clib_warning ("parse error '%U'", format_unformat_error, i);
21835 if (sw_if_index_set == 0)
21837 errmsg ("missing interface name or sw_if_index");
21841 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21843 mp->sw_if_index = ntohl (sw_if_index);
21844 mp->ip4_table_index = ntohl (ip4_table_index);
21845 mp->ip6_table_index = ntohl (ip6_table_index);
21846 mp->is_add = is_add;
21854 api_flow_classify_dump (vat_main_t * vam)
21856 unformat_input_t *i = vam->input;
21857 vl_api_flow_classify_dump_t *mp;
21858 vl_api_control_ping_t *mp_ping;
21859 u8 type = FLOW_CLASSIFY_N_TABLES;
21862 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21866 errmsg ("classify table type must be specified");
21870 if (!vam->json_output)
21872 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21875 M (FLOW_CLASSIFY_DUMP, mp);
21880 /* Use a control ping for synchronization */
21881 MPING (CONTROL_PING, mp_ping);
21884 /* Wait for a reply... */
21890 api_feature_enable_disable (vat_main_t * vam)
21892 unformat_input_t *i = vam->input;
21893 vl_api_feature_enable_disable_t *mp;
21895 u8 *feature_name = 0;
21896 u32 sw_if_index = ~0;
21900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21902 if (unformat (i, "arc_name %s", &arc_name))
21904 else if (unformat (i, "feature_name %s", &feature_name))
21907 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21909 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21911 else if (unformat (i, "disable"))
21919 errmsg ("missing arc name");
21922 if (vec_len (arc_name) > 63)
21924 errmsg ("arc name too long");
21927 if (feature_name == 0)
21929 errmsg ("missing feature name");
21932 if (vec_len (feature_name) > 63)
21934 errmsg ("feature name too long");
21937 if (sw_if_index == ~0)
21939 errmsg ("missing interface name or sw_if_index");
21943 /* Construct the API message */
21944 M (FEATURE_ENABLE_DISABLE, mp);
21945 mp->sw_if_index = ntohl (sw_if_index);
21946 mp->enable = enable;
21947 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21948 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21949 vec_free (arc_name);
21950 vec_free (feature_name);
21958 api_sw_interface_tag_add_del (vat_main_t * vam)
21960 unformat_input_t *i = vam->input;
21961 vl_api_sw_interface_tag_add_del_t *mp;
21962 u32 sw_if_index = ~0;
21967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21969 if (unformat (i, "tag %s", &tag))
21971 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21973 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21975 else if (unformat (i, "del"))
21981 if (sw_if_index == ~0)
21983 errmsg ("missing interface name or sw_if_index");
21987 if (enable && (tag == 0))
21989 errmsg ("no tag specified");
21993 /* Construct the API message */
21994 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21995 mp->sw_if_index = ntohl (sw_if_index);
21996 mp->is_add = enable;
21998 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
22006 static void vl_api_l2_xconnect_details_t_handler
22007 (vl_api_l2_xconnect_details_t * mp)
22009 vat_main_t *vam = &vat_main;
22011 print (vam->ofp, "%15d%15d",
22012 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
22015 static void vl_api_l2_xconnect_details_t_handler_json
22016 (vl_api_l2_xconnect_details_t * mp)
22018 vat_main_t *vam = &vat_main;
22019 vat_json_node_t *node = NULL;
22021 if (VAT_JSON_ARRAY != vam->json_tree.type)
22023 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22024 vat_json_init_array (&vam->json_tree);
22026 node = vat_json_array_add (&vam->json_tree);
22028 vat_json_init_object (node);
22029 vat_json_object_add_uint (node, "rx_sw_if_index",
22030 ntohl (mp->rx_sw_if_index));
22031 vat_json_object_add_uint (node, "tx_sw_if_index",
22032 ntohl (mp->tx_sw_if_index));
22036 api_l2_xconnect_dump (vat_main_t * vam)
22038 vl_api_l2_xconnect_dump_t *mp;
22039 vl_api_control_ping_t *mp_ping;
22042 if (!vam->json_output)
22044 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22047 M (L2_XCONNECT_DUMP, mp);
22051 /* Use a control ping for synchronization */
22052 MPING (CONTROL_PING, mp_ping);
22060 api_hw_interface_set_mtu (vat_main_t * vam)
22062 unformat_input_t *i = vam->input;
22063 vl_api_hw_interface_set_mtu_t *mp;
22064 u32 sw_if_index = ~0;
22068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22070 if (unformat (i, "mtu %d", &mtu))
22072 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22074 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22080 if (sw_if_index == ~0)
22082 errmsg ("missing interface name or sw_if_index");
22088 errmsg ("no mtu specified");
22092 /* Construct the API message */
22093 M (HW_INTERFACE_SET_MTU, mp);
22094 mp->sw_if_index = ntohl (sw_if_index);
22095 mp->mtu = ntohs ((u16) mtu);
22103 api_p2p_ethernet_add (vat_main_t * vam)
22105 unformat_input_t *i = vam->input;
22106 vl_api_p2p_ethernet_add_t *mp;
22107 u32 parent_if_index = ~0;
22113 clib_memset (remote_mac, 0, sizeof (remote_mac));
22114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22116 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22118 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22122 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22124 else if (unformat (i, "sub_id %d", &sub_id))
22128 clib_warning ("parse error '%U'", format_unformat_error, i);
22133 if (parent_if_index == ~0)
22135 errmsg ("missing interface name or sw_if_index");
22140 errmsg ("missing remote mac address");
22145 errmsg ("missing sub-interface id");
22149 M (P2P_ETHERNET_ADD, mp);
22150 mp->parent_if_index = ntohl (parent_if_index);
22151 mp->subif_id = ntohl (sub_id);
22152 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22160 api_p2p_ethernet_del (vat_main_t * vam)
22162 unformat_input_t *i = vam->input;
22163 vl_api_p2p_ethernet_del_t *mp;
22164 u32 parent_if_index = ~0;
22169 clib_memset (remote_mac, 0, sizeof (remote_mac));
22170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22172 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22174 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22178 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22182 clib_warning ("parse error '%U'", format_unformat_error, i);
22187 if (parent_if_index == ~0)
22189 errmsg ("missing interface name or sw_if_index");
22194 errmsg ("missing remote mac address");
22198 M (P2P_ETHERNET_DEL, mp);
22199 mp->parent_if_index = ntohl (parent_if_index);
22200 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22208 api_lldp_config (vat_main_t * vam)
22210 unformat_input_t *i = vam->input;
22211 vl_api_lldp_config_t *mp;
22213 int tx_interval = 0;
22214 u8 *sys_name = NULL;
22217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22219 if (unformat (i, "system-name %s", &sys_name))
22221 else if (unformat (i, "tx-hold %d", &tx_hold))
22223 else if (unformat (i, "tx-interval %d", &tx_interval))
22227 clib_warning ("parse error '%U'", format_unformat_error, i);
22232 vec_add1 (sys_name, 0);
22234 M (LLDP_CONFIG, mp);
22235 mp->tx_hold = htonl (tx_hold);
22236 mp->tx_interval = htonl (tx_interval);
22237 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22238 vec_free (sys_name);
22246 api_sw_interface_set_lldp (vat_main_t * vam)
22248 unformat_input_t *i = vam->input;
22249 vl_api_sw_interface_set_lldp_t *mp;
22250 u32 sw_if_index = ~0;
22252 u8 *port_desc = NULL, *mgmt_oid = NULL;
22253 ip4_address_t ip4_addr;
22254 ip6_address_t ip6_addr;
22257 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
22258 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
22260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22262 if (unformat (i, "disable"))
22265 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22267 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22269 else if (unformat (i, "port-desc %s", &port_desc))
22271 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22273 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22275 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22281 if (sw_if_index == ~0)
22283 errmsg ("missing interface name or sw_if_index");
22287 /* Construct the API message */
22288 vec_add1 (port_desc, 0);
22289 vec_add1 (mgmt_oid, 0);
22290 M (SW_INTERFACE_SET_LLDP, mp);
22291 mp->sw_if_index = ntohl (sw_if_index);
22292 mp->enable = enable;
22293 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22294 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22295 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22296 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22297 vec_free (port_desc);
22298 vec_free (mgmt_oid);
22306 api_tcp_configure_src_addresses (vat_main_t * vam)
22308 vl_api_tcp_configure_src_addresses_t *mp;
22309 unformat_input_t *i = vam->input;
22310 ip4_address_t v4first, v4last;
22311 ip6_address_t v6first, v6last;
22316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22318 if (unformat (i, "%U - %U",
22319 unformat_ip4_address, &v4first,
22320 unformat_ip4_address, &v4last))
22324 errmsg ("one range per message (range already set)");
22329 else if (unformat (i, "%U - %U",
22330 unformat_ip6_address, &v6first,
22331 unformat_ip6_address, &v6last))
22335 errmsg ("one range per message (range already set)");
22340 else if (unformat (i, "vrf %d", &vrf_id))
22346 if (range_set == 0)
22348 errmsg ("address range not set");
22352 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22353 mp->vrf_id = ntohl (vrf_id);
22355 if (range_set == 2)
22358 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22359 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22364 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22365 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22372 static void vl_api_app_namespace_add_del_reply_t_handler
22373 (vl_api_app_namespace_add_del_reply_t * mp)
22375 vat_main_t *vam = &vat_main;
22376 i32 retval = ntohl (mp->retval);
22377 if (vam->async_mode)
22379 vam->async_errors += (retval < 0);
22383 vam->retval = retval;
22385 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22386 vam->result_ready = 1;
22390 static void vl_api_app_namespace_add_del_reply_t_handler_json
22391 (vl_api_app_namespace_add_del_reply_t * mp)
22393 vat_main_t *vam = &vat_main;
22394 vat_json_node_t node;
22396 vat_json_init_object (&node);
22397 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22398 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22400 vat_json_print (vam->ofp, &node);
22401 vat_json_free (&node);
22403 vam->retval = ntohl (mp->retval);
22404 vam->result_ready = 1;
22408 api_app_namespace_add_del (vat_main_t * vam)
22410 vl_api_app_namespace_add_del_t *mp;
22411 unformat_input_t *i = vam->input;
22412 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22413 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22419 if (unformat (i, "id %_%v%_", &ns_id))
22421 else if (unformat (i, "secret %lu", &secret))
22423 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22424 sw_if_index_set = 1;
22425 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22427 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22432 if (!ns_id || !secret_set || !sw_if_index_set)
22434 errmsg ("namespace id, secret and sw_if_index must be set");
22437 if (vec_len (ns_id) > 64)
22439 errmsg ("namespace id too long");
22442 M (APP_NAMESPACE_ADD_DEL, mp);
22444 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22445 mp->namespace_id_len = vec_len (ns_id);
22446 mp->secret = clib_host_to_net_u64 (secret);
22447 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22448 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22449 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22457 api_sock_init_shm (vat_main_t * vam)
22459 #if VPP_API_TEST_BUILTIN == 0
22460 unformat_input_t *i = vam->input;
22461 vl_api_shm_elem_config_t *config = 0;
22462 u64 size = 64 << 20;
22465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22467 if (unformat (i, "size %U", unformat_memory_size, &size))
22474 * Canned custom ring allocator config.
22475 * Should probably parse all of this
22477 vec_validate (config, 6);
22478 config[0].type = VL_API_VLIB_RING;
22479 config[0].size = 256;
22480 config[0].count = 32;
22482 config[1].type = VL_API_VLIB_RING;
22483 config[1].size = 1024;
22484 config[1].count = 16;
22486 config[2].type = VL_API_VLIB_RING;
22487 config[2].size = 4096;
22488 config[2].count = 2;
22490 config[3].type = VL_API_CLIENT_RING;
22491 config[3].size = 256;
22492 config[3].count = 32;
22494 config[4].type = VL_API_CLIENT_RING;
22495 config[4].size = 1024;
22496 config[4].count = 16;
22498 config[5].type = VL_API_CLIENT_RING;
22499 config[5].size = 4096;
22500 config[5].count = 2;
22502 config[6].type = VL_API_QUEUE;
22503 config[6].count = 128;
22504 config[6].size = sizeof (uword);
22506 rv = vl_socket_client_init_shm (config);
22508 vam->client_index_invalid = 1;
22516 api_dns_enable_disable (vat_main_t * vam)
22518 unformat_input_t *line_input = vam->input;
22519 vl_api_dns_enable_disable_t *mp;
22520 u8 enable_disable = 1;
22523 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22525 if (unformat (line_input, "disable"))
22526 enable_disable = 0;
22527 if (unformat (line_input, "enable"))
22528 enable_disable = 1;
22533 /* Construct the API message */
22534 M (DNS_ENABLE_DISABLE, mp);
22535 mp->enable = enable_disable;
22539 /* Wait for the reply */
22545 api_dns_resolve_name (vat_main_t * vam)
22547 unformat_input_t *line_input = vam->input;
22548 vl_api_dns_resolve_name_t *mp;
22552 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22554 if (unformat (line_input, "%s", &name))
22560 if (vec_len (name) > 127)
22562 errmsg ("name too long");
22566 /* Construct the API message */
22567 M (DNS_RESOLVE_NAME, mp);
22568 memcpy (mp->name, name, vec_len (name));
22573 /* Wait for the reply */
22579 api_dns_resolve_ip (vat_main_t * vam)
22581 unformat_input_t *line_input = vam->input;
22582 vl_api_dns_resolve_ip_t *mp;
22584 ip4_address_t addr4;
22585 ip6_address_t addr6;
22588 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22590 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22592 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22600 errmsg ("missing address");
22604 /* Construct the API message */
22605 M (DNS_RESOLVE_IP, mp);
22606 mp->is_ip6 = is_ip6;
22608 memcpy (mp->address, &addr6, sizeof (addr6));
22610 memcpy (mp->address, &addr4, sizeof (addr4));
22614 /* Wait for the reply */
22620 api_dns_name_server_add_del (vat_main_t * vam)
22622 unformat_input_t *i = vam->input;
22623 vl_api_dns_name_server_add_del_t *mp;
22625 ip6_address_t ip6_server;
22626 ip4_address_t ip4_server;
22631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22633 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22635 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22637 else if (unformat (i, "del"))
22641 clib_warning ("parse error '%U'", format_unformat_error, i);
22646 if (ip4_set && ip6_set)
22648 errmsg ("Only one server address allowed per message");
22651 if ((ip4_set + ip6_set) == 0)
22653 errmsg ("Server address required");
22657 /* Construct the API message */
22658 M (DNS_NAME_SERVER_ADD_DEL, mp);
22662 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22667 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22671 mp->is_add = is_add;
22676 /* Wait for a reply, return good/bad news */
22682 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22684 vat_main_t *vam = &vat_main;
22689 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22690 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22691 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22692 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22693 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22694 clib_net_to_host_u32 (mp->action_index), mp->tag);
22699 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22700 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22701 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22702 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22703 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22704 clib_net_to_host_u32 (mp->action_index), mp->tag);
22709 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22712 vat_main_t *vam = &vat_main;
22713 vat_json_node_t *node = NULL;
22714 struct in6_addr ip6;
22715 struct in_addr ip4;
22717 if (VAT_JSON_ARRAY != vam->json_tree.type)
22719 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22720 vat_json_init_array (&vam->json_tree);
22722 node = vat_json_array_add (&vam->json_tree);
22723 vat_json_init_object (node);
22725 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22726 vat_json_object_add_uint (node, "appns_index",
22727 clib_net_to_host_u32 (mp->appns_index));
22728 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22729 vat_json_object_add_uint (node, "scope", mp->scope);
22730 vat_json_object_add_uint (node, "action_index",
22731 clib_net_to_host_u32 (mp->action_index));
22732 vat_json_object_add_uint (node, "lcl_port",
22733 clib_net_to_host_u16 (mp->lcl_port));
22734 vat_json_object_add_uint (node, "rmt_port",
22735 clib_net_to_host_u16 (mp->rmt_port));
22736 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22737 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22738 vat_json_object_add_string_copy (node, "tag", mp->tag);
22741 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22742 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22743 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22744 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22748 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22749 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22750 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22751 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22756 api_session_rule_add_del (vat_main_t * vam)
22758 vl_api_session_rule_add_del_t *mp;
22759 unformat_input_t *i = vam->input;
22760 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22761 u32 appns_index = 0, scope = 0;
22762 ip4_address_t lcl_ip4, rmt_ip4;
22763 ip6_address_t lcl_ip6, rmt_ip6;
22764 u8 is_ip4 = 1, conn_set = 0;
22765 u8 is_add = 1, *tag = 0;
22768 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22770 if (unformat (i, "del"))
22772 else if (unformat (i, "add"))
22774 else if (unformat (i, "proto tcp"))
22776 else if (unformat (i, "proto udp"))
22778 else if (unformat (i, "appns %d", &appns_index))
22780 else if (unformat (i, "scope %d", &scope))
22782 else if (unformat (i, "tag %_%v%_", &tag))
22786 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22787 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22795 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22796 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22802 else if (unformat (i, "action %d", &action))
22807 if (proto == ~0 || !conn_set || action == ~0)
22809 errmsg ("transport proto, connection and action must be set");
22815 errmsg ("scope should be 0-3");
22819 M (SESSION_RULE_ADD_DEL, mp);
22821 mp->is_ip4 = is_ip4;
22822 mp->transport_proto = proto;
22823 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22824 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22825 mp->lcl_plen = lcl_plen;
22826 mp->rmt_plen = rmt_plen;
22827 mp->action_index = clib_host_to_net_u32 (action);
22828 mp->appns_index = clib_host_to_net_u32 (appns_index);
22830 mp->is_add = is_add;
22833 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22834 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22838 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22839 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22843 clib_memcpy (mp->tag, tag, vec_len (tag));
22853 api_session_rules_dump (vat_main_t * vam)
22855 vl_api_session_rules_dump_t *mp;
22856 vl_api_control_ping_t *mp_ping;
22859 if (!vam->json_output)
22861 print (vam->ofp, "%=20s", "Session Rules");
22864 M (SESSION_RULES_DUMP, mp);
22868 /* Use a control ping for synchronization */
22869 MPING (CONTROL_PING, mp_ping);
22872 /* Wait for a reply... */
22878 api_ip_container_proxy_add_del (vat_main_t * vam)
22880 vl_api_ip_container_proxy_add_del_t *mp;
22881 unformat_input_t *i = vam->input;
22882 u32 plen = ~0, sw_if_index = ~0;
22889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22891 if (unformat (i, "del"))
22893 else if (unformat (i, "add"))
22895 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22900 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22905 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22910 if (sw_if_index == ~0 || plen == ~0)
22912 errmsg ("address and sw_if_index must be set");
22916 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22918 mp->is_ip4 = is_ip4;
22919 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22921 mp->is_add = is_add;
22923 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22925 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22933 api_qos_record_enable_disable (vat_main_t * vam)
22935 unformat_input_t *i = vam->input;
22936 vl_api_qos_record_enable_disable_t *mp;
22937 u32 sw_if_index, qs = 0xff;
22938 u8 sw_if_index_set = 0;
22942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22944 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22945 sw_if_index_set = 1;
22946 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22947 sw_if_index_set = 1;
22948 else if (unformat (i, "%U", unformat_qos_source, &qs))
22950 else if (unformat (i, "disable"))
22954 clib_warning ("parse error '%U'", format_unformat_error, i);
22959 if (sw_if_index_set == 0)
22961 errmsg ("missing interface name or sw_if_index");
22966 errmsg ("input location must be specified");
22970 M (QOS_RECORD_ENABLE_DISABLE, mp);
22972 mp->sw_if_index = ntohl (sw_if_index);
22973 mp->input_source = qs;
22974 mp->enable = enable;
22983 q_or_quit (vat_main_t * vam)
22985 #if VPP_API_TEST_BUILTIN == 0
22986 longjmp (vam->jump_buf, 1);
22988 return 0; /* not so much */
22992 q (vat_main_t * vam)
22994 return q_or_quit (vam);
22998 quit (vat_main_t * vam)
23000 return q_or_quit (vam);
23004 comment (vat_main_t * vam)
23010 statseg (vat_main_t * vam)
23012 ssvm_private_t *ssvmp = &vam->stat_segment;
23013 ssvm_shared_header_t *shared_header = ssvmp->sh;
23014 vlib_counter_t **counters;
23015 u64 thread0_index1_packets;
23016 u64 thread0_index1_bytes;
23017 f64 vector_rate, input_rate;
23020 uword *counter_vector_by_name;
23021 if (vam->stat_segment_lockp == 0)
23023 errmsg ("Stat segment not mapped...");
23027 /* look up "/if/rx for sw_if_index 1 as a test */
23029 clib_spinlock_lock (vam->stat_segment_lockp);
23031 counter_vector_by_name = (uword *) shared_header->opaque[1];
23033 p = hash_get_mem (counter_vector_by_name, "/if/rx");
23036 clib_spinlock_unlock (vam->stat_segment_lockp);
23037 errmsg ("/if/tx not found?");
23041 /* Fish per-thread vector of combined counters from shared memory */
23042 counters = (vlib_counter_t **) p[0];
23044 if (vec_len (counters[0]) < 2)
23046 clib_spinlock_unlock (vam->stat_segment_lockp);
23047 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
23051 /* Read thread 0 sw_if_index 1 counter */
23052 thread0_index1_packets = counters[0][1].packets;
23053 thread0_index1_bytes = counters[0][1].bytes;
23055 p = hash_get_mem (counter_vector_by_name, "vector_rate");
23058 clib_spinlock_unlock (vam->stat_segment_lockp);
23059 errmsg ("vector_rate not found?");
23063 vector_rate = *(f64 *) (p[0]);
23064 p = hash_get_mem (counter_vector_by_name, "input_rate");
23067 clib_spinlock_unlock (vam->stat_segment_lockp);
23068 errmsg ("input_rate not found?");
23071 input_rate = *(f64 *) (p[0]);
23073 clib_spinlock_unlock (vam->stat_segment_lockp);
23075 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
23076 vector_rate, input_rate);
23077 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
23078 thread0_index1_packets, thread0_index1_bytes);
23084 cmd_cmp (void *a1, void *a2)
23089 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23093 help (vat_main_t * vam)
23098 unformat_input_t *i = vam->input;
23101 if (unformat (i, "%s", &name))
23105 vec_add1 (name, 0);
23107 hs = hash_get_mem (vam->help_by_name, name);
23109 print (vam->ofp, "usage: %s %s", name, hs[0]);
23111 print (vam->ofp, "No such msg / command '%s'", name);
23116 print (vam->ofp, "Help is available for the following:");
23119 hash_foreach_pair (p, vam->function_by_name,
23121 vec_add1 (cmds, (u8 *)(p->key));
23125 vec_sort_with_function (cmds, cmd_cmp);
23127 for (j = 0; j < vec_len (cmds); j++)
23128 print (vam->ofp, "%s", cmds[j]);
23135 set (vat_main_t * vam)
23137 u8 *name = 0, *value = 0;
23138 unformat_input_t *i = vam->input;
23140 if (unformat (i, "%s", &name))
23142 /* The input buffer is a vector, not a string. */
23143 value = vec_dup (i->buffer);
23144 vec_delete (value, i->index, 0);
23145 /* Almost certainly has a trailing newline */
23146 if (value[vec_len (value) - 1] == '\n')
23147 value[vec_len (value) - 1] = 0;
23148 /* Make sure it's a proper string, one way or the other */
23149 vec_add1 (value, 0);
23150 (void) clib_macro_set_value (&vam->macro_main,
23151 (char *) name, (char *) value);
23154 errmsg ("usage: set <name> <value>");
23162 unset (vat_main_t * vam)
23166 if (unformat (vam->input, "%s", &name))
23167 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23168 errmsg ("unset: %s wasn't set", name);
23181 macro_sort_cmp (void *a1, void *a2)
23183 macro_sort_t *s1 = a1;
23184 macro_sort_t *s2 = a2;
23186 return strcmp ((char *) (s1->name), (char *) (s2->name));
23190 dump_macro_table (vat_main_t * vam)
23192 macro_sort_t *sort_me = 0, *sm;
23197 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23199 vec_add2 (sort_me, sm, 1);
23200 sm->name = (u8 *)(p->key);
23201 sm->value = (u8 *) (p->value[0]);
23205 vec_sort_with_function (sort_me, macro_sort_cmp);
23207 if (vec_len (sort_me))
23208 print (vam->ofp, "%-15s%s", "Name", "Value");
23210 print (vam->ofp, "The macro table is empty...");
23212 for (i = 0; i < vec_len (sort_me); i++)
23213 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23218 dump_node_table (vat_main_t * vam)
23221 vlib_node_t *node, *next_node;
23223 if (vec_len (vam->graph_nodes) == 0)
23225 print (vam->ofp, "Node table empty, issue get_node_graph...");
23229 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
23231 node = vam->graph_nodes[0][i];
23232 print (vam->ofp, "[%d] %s", i, node->name);
23233 for (j = 0; j < vec_len (node->next_nodes); j++)
23235 if (node->next_nodes[j] != ~0)
23237 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23238 print (vam->ofp, " [%d] %s", j, next_node->name);
23246 value_sort_cmp (void *a1, void *a2)
23248 name_sort_t *n1 = a1;
23249 name_sort_t *n2 = a2;
23251 if (n1->value < n2->value)
23253 if (n1->value > n2->value)
23260 dump_msg_api_table (vat_main_t * vam)
23262 api_main_t *am = &api_main;
23263 name_sort_t *nses = 0, *ns;
23268 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23270 vec_add2 (nses, ns, 1);
23271 ns->name = (u8 *)(hp->key);
23272 ns->value = (u32) hp->value[0];
23276 vec_sort_with_function (nses, value_sort_cmp);
23278 for (i = 0; i < vec_len (nses); i++)
23279 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23285 get_msg_id (vat_main_t * vam)
23290 if (unformat (vam->input, "%s", &name_and_crc))
23292 message_index = vl_msg_api_get_msg_index (name_and_crc);
23293 if (message_index == ~0)
23295 print (vam->ofp, " '%s' not found", name_and_crc);
23298 print (vam->ofp, " '%s' has message index %d",
23299 name_and_crc, message_index);
23302 errmsg ("name_and_crc required...");
23307 search_node_table (vat_main_t * vam)
23309 unformat_input_t *line_input = vam->input;
23312 vlib_node_t *node, *next_node;
23315 if (vam->graph_node_index_by_name == 0)
23317 print (vam->ofp, "Node table empty, issue get_node_graph...");
23321 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23323 if (unformat (line_input, "%s", &node_to_find))
23325 vec_add1 (node_to_find, 0);
23326 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23329 print (vam->ofp, "%s not found...", node_to_find);
23332 node = vam->graph_nodes[0][p[0]];
23333 print (vam->ofp, "[%d] %s", p[0], node->name);
23334 for (j = 0; j < vec_len (node->next_nodes); j++)
23336 if (node->next_nodes[j] != ~0)
23338 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23339 print (vam->ofp, " [%d] %s", j, next_node->name);
23346 clib_warning ("parse error '%U'", format_unformat_error,
23352 vec_free (node_to_find);
23361 script (vat_main_t * vam)
23363 #if (VPP_API_TEST_BUILTIN==0)
23365 char *save_current_file;
23366 unformat_input_t save_input;
23367 jmp_buf save_jump_buf;
23368 u32 save_line_number;
23370 FILE *new_fp, *save_ifp;
23372 if (unformat (vam->input, "%s", &s))
23374 new_fp = fopen ((char *) s, "r");
23377 errmsg ("Couldn't open script file %s", s);
23384 errmsg ("Missing script name");
23388 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23389 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23390 save_ifp = vam->ifp;
23391 save_line_number = vam->input_line_number;
23392 save_current_file = (char *) vam->current_file;
23394 vam->input_line_number = 0;
23396 vam->current_file = s;
23399 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23400 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23401 vam->ifp = save_ifp;
23402 vam->input_line_number = save_line_number;
23403 vam->current_file = (u8 *) save_current_file;
23408 clib_warning ("use the exec command...");
23414 echo (vat_main_t * vam)
23416 print (vam->ofp, "%v", vam->input->buffer);
23420 /* List of API message constructors, CLI names map to api_xxx */
23421 #define foreach_vpe_api_msg \
23422 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23423 _(sw_interface_dump,"") \
23424 _(sw_interface_set_flags, \
23425 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23426 _(sw_interface_add_del_address, \
23427 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23428 _(sw_interface_set_rx_mode, \
23429 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23430 _(sw_interface_set_rx_placement, \
23431 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
23432 _(sw_interface_rx_placement_dump, \
23433 "[<intfc> | sw_if_index <id>]") \
23434 _(sw_interface_set_table, \
23435 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23436 _(sw_interface_set_mpls_enable, \
23437 "<intfc> | sw_if_index [disable | dis]") \
23438 _(sw_interface_set_vpath, \
23439 "<intfc> | sw_if_index <id> enable | disable") \
23440 _(sw_interface_set_vxlan_bypass, \
23441 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23442 _(sw_interface_set_geneve_bypass, \
23443 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23444 _(sw_interface_set_l2_xconnect, \
23445 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23446 "enable | disable") \
23447 _(sw_interface_set_l2_bridge, \
23448 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23449 "[shg <split-horizon-group>] [bvi]\n" \
23450 "enable | disable") \
23451 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23452 _(bridge_domain_add_del, \
23453 "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") \
23454 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23456 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23457 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23458 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23460 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23462 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23464 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23466 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23468 "<vpp-if-name> | sw_if_index <id>") \
23469 _(sw_interface_tap_dump, "") \
23471 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23473 "<vpp-if-name> | sw_if_index <id>") \
23474 _(sw_interface_tap_v2_dump, "") \
23475 _(virtio_pci_create, \
23476 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [tx-ring-size <num> [rx-ring-size <num>] [features <hex-value>]") \
23477 _(virtio_pci_delete, \
23478 "<vpp-if-name> | sw_if_index <id>") \
23479 _(sw_interface_virtio_pci_dump, "") \
23481 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23482 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
23485 "<vpp-if-name> | sw_if_index <id>") \
23487 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23488 _(bond_detach_slave, \
23489 "sw_if_index <n>") \
23490 _(sw_interface_bond_dump, "") \
23491 _(sw_interface_slave_dump, \
23492 "<vpp-if-name> | sw_if_index <id>") \
23493 _(ip_table_add_del, \
23494 "table <n> [ipv6] [add | del]\n") \
23495 _(ip_add_del_route, \
23496 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
23497 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
23498 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
23499 "[multipath] [count <n>] [del]") \
23500 _(ip_mroute_add_del, \
23501 "<src> <grp>/<mask> [table-id <n>]\n" \
23502 "[<intfc> | sw_if_index <id>] [local] [del]") \
23503 _(mpls_table_add_del, \
23504 "table <n> [add | del]\n") \
23505 _(mpls_route_add_del, \
23506 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
23507 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
23508 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
23509 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
23510 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
23511 "[count <n>] [del]") \
23512 _(mpls_ip_bind_unbind, \
23513 "<label> <addr/len>") \
23514 _(mpls_tunnel_add_del, \
23515 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
23516 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
23517 "[l2-only] [out-label <n>]") \
23518 _(sr_mpls_policy_add, \
23519 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
23520 _(sr_mpls_policy_del, \
23522 _(bier_table_add_del, \
23523 "<label> <sub-domain> <set> <bsl> [del]") \
23524 _(bier_route_add_del, \
23525 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23526 "[<intfc> | sw_if_index <id>]" \
23527 "[weight <n>] [del] [multipath]") \
23528 _(proxy_arp_add_del, \
23529 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23530 _(proxy_arp_intfc_enable_disable, \
23531 "<intfc> | sw_if_index <id> enable | disable") \
23532 _(sw_interface_set_unnumbered, \
23533 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23534 _(ip_neighbor_add_del, \
23535 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23536 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23537 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23538 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23539 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23540 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23541 "[outer_vlan_id_any][inner_vlan_id_any]") \
23542 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23543 _(reset_fib, "vrf <n> [ipv6]") \
23544 _(dhcp_proxy_config, \
23545 "svr <v46-address> src <v46-address>\n" \
23546 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23547 _(dhcp_proxy_set_vss, \
23548 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23549 _(dhcp_proxy_dump, "ip6") \
23550 _(dhcp_client_config, \
23551 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23552 _(set_ip_flow_hash, \
23553 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23554 _(sw_interface_ip6_enable_disable, \
23555 "<intfc> | sw_if_index <id> enable | disable") \
23556 _(ip6nd_proxy_add_del, \
23557 "<intfc> | sw_if_index <id> <ip6-address>") \
23558 _(ip6nd_proxy_dump, "") \
23559 _(sw_interface_ip6nd_ra_prefix, \
23560 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23561 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23562 "[nolink] [isno]") \
23563 _(sw_interface_ip6nd_ra_config, \
23564 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23565 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23566 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23567 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23568 _(l2_patch_add_del, \
23569 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23570 "enable | disable") \
23571 _(sr_localsid_add_del, \
23572 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23573 "fib-table <num> (end.psp) sw_if_index <num>") \
23574 _(classify_add_del_table, \
23575 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23576 " [del] [del-chain] mask <mask-value>\n" \
23577 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23578 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23579 _(classify_add_del_session, \
23580 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23581 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23582 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23583 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23584 _(classify_set_interface_ip_table, \
23585 "<intfc> | sw_if_index <nn> table <nn>") \
23586 _(classify_set_interface_l2_tables, \
23587 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23588 " [other-table <nn>]") \
23589 _(get_node_index, "node <node-name") \
23590 _(add_node_next, "node <node-name> next <next-node-name>") \
23591 _(l2tpv3_create_tunnel, \
23592 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23593 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23594 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23595 _(l2tpv3_set_tunnel_cookies, \
23596 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23597 "[new_remote_cookie <nn>]\n") \
23598 _(l2tpv3_interface_enable_disable, \
23599 "<intfc> | sw_if_index <nn> enable | disable") \
23600 _(l2tpv3_set_lookup_key, \
23601 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23602 _(sw_if_l2tpv3_tunnel_dump, "") \
23603 _(vxlan_offload_rx, \
23604 "hw { <interface name> | hw_if_index <nn>} " \
23605 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23606 _(vxlan_add_del_tunnel, \
23607 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23608 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23609 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23610 _(geneve_add_del_tunnel, \
23611 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23612 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23613 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23614 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23615 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23616 _(gre_add_del_tunnel, \
23617 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23618 "[teb | erspan <session-id>] [del]") \
23619 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23620 _(l2_fib_clear_table, "") \
23621 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23622 _(l2_interface_vlan_tag_rewrite, \
23623 "<intfc> | sw_if_index <nn> \n" \
23624 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23625 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23626 _(create_vhost_user_if, \
23627 "socket <filename> [server] [renumber <dev_instance>] " \
23628 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
23629 "[mac <mac_address>]") \
23630 _(modify_vhost_user_if, \
23631 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23632 "[server] [renumber <dev_instance>]") \
23633 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23634 _(sw_interface_vhost_user_dump, "") \
23635 _(show_version, "") \
23636 _(show_threads, "") \
23637 _(vxlan_gpe_add_del_tunnel, \
23638 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23639 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23640 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23641 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23642 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23643 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23644 _(interface_name_renumber, \
23645 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23646 _(input_acl_set_interface, \
23647 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23648 " [l2-table <nn>] [del]") \
23649 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23650 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23651 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23652 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23653 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23654 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23655 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23656 _(ip_dump, "ipv4 | ipv6") \
23657 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23658 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23660 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23661 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23662 " integ_alg <alg> integ_key <hex>") \
23663 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23664 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23665 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23666 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23667 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23668 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23669 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23670 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23671 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23672 " [instance <n>]") \
23673 _(ipsec_sa_dump, "[sa_id <n>]") \
23674 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23675 " <alg> <hex>\n") \
23676 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23677 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23678 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23679 "(auth_data 0x<data> | auth_data <data>)") \
23680 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23681 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23682 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23683 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23684 "(local|remote)") \
23685 _(ikev2_set_local_key, "file <absolute_file_path>") \
23686 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23687 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23688 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23689 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23690 _(ikev2_initiate_sa_init, "<profile_name>") \
23691 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23692 _(ikev2_initiate_del_child_sa, "<ispi>") \
23693 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23694 _(delete_loopback,"sw_if_index <nn>") \
23695 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23696 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
23697 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
23698 _(want_interface_events, "enable|disable") \
23699 _(get_first_msg_id, "client <name>") \
23700 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23701 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23702 "fib-id <nn> [ip4][ip6][default]") \
23703 _(get_node_graph, " ") \
23704 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23705 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23706 _(ioam_disable, "") \
23707 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23708 " sw_if_index <sw_if_index> p <priority> " \
23709 "w <weight>] [del]") \
23710 _(one_add_del_locator, "locator-set <locator_name> " \
23711 "iface <intf> | sw_if_index <sw_if_index> " \
23712 "p <priority> w <weight> [del]") \
23713 _(one_add_del_local_eid,"vni <vni> eid " \
23714 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23715 "locator-set <locator_name> [del]" \
23716 "[key-id sha1|sha256 secret-key <secret-key>]")\
23717 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23718 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23719 _(one_enable_disable, "enable|disable") \
23720 _(one_map_register_enable_disable, "enable|disable") \
23721 _(one_map_register_fallback_threshold, "<value>") \
23722 _(one_rloc_probe_enable_disable, "enable|disable") \
23723 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23725 "rloc <locator> p <prio> " \
23726 "w <weight> [rloc <loc> ... ] " \
23727 "action <action> [del-all]") \
23728 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23730 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23731 _(one_use_petr, "ip-address> | disable") \
23732 _(one_map_request_mode, "src-dst|dst-only") \
23733 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23734 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23735 _(one_locator_set_dump, "[local | remote]") \
23736 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23737 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23738 "[local] | [remote]") \
23739 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23740 _(one_ndp_bd_get, "") \
23741 _(one_ndp_entries_get, "bd <bridge-domain>") \
23742 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23743 _(one_l2_arp_bd_get, "") \
23744 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23745 _(one_stats_enable_disable, "enable|disable") \
23746 _(show_one_stats_enable_disable, "") \
23747 _(one_eid_table_vni_dump, "") \
23748 _(one_eid_table_map_dump, "l2|l3") \
23749 _(one_map_resolver_dump, "") \
23750 _(one_map_server_dump, "") \
23751 _(one_adjacencies_get, "vni <vni>") \
23752 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23753 _(show_one_rloc_probe_state, "") \
23754 _(show_one_map_register_state, "") \
23755 _(show_one_status, "") \
23756 _(one_stats_dump, "") \
23757 _(one_stats_flush, "") \
23758 _(one_get_map_request_itr_rlocs, "") \
23759 _(one_map_register_set_ttl, "<ttl>") \
23760 _(one_set_transport_protocol, "udp|api") \
23761 _(one_get_transport_protocol, "") \
23762 _(one_enable_disable_xtr_mode, "enable|disable") \
23763 _(one_show_xtr_mode, "") \
23764 _(one_enable_disable_pitr_mode, "enable|disable") \
23765 _(one_show_pitr_mode, "") \
23766 _(one_enable_disable_petr_mode, "enable|disable") \
23767 _(one_show_petr_mode, "") \
23768 _(show_one_nsh_mapping, "") \
23769 _(show_one_pitr, "") \
23770 _(show_one_use_petr, "") \
23771 _(show_one_map_request_mode, "") \
23772 _(show_one_map_register_ttl, "") \
23773 _(show_one_map_register_fallback_threshold, "") \
23774 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23775 " sw_if_index <sw_if_index> p <priority> " \
23776 "w <weight>] [del]") \
23777 _(lisp_add_del_locator, "locator-set <locator_name> " \
23778 "iface <intf> | sw_if_index <sw_if_index> " \
23779 "p <priority> w <weight> [del]") \
23780 _(lisp_add_del_local_eid,"vni <vni> eid " \
23781 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23782 "locator-set <locator_name> [del]" \
23783 "[key-id sha1|sha256 secret-key <secret-key>]") \
23784 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23785 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23786 _(lisp_enable_disable, "enable|disable") \
23787 _(lisp_map_register_enable_disable, "enable|disable") \
23788 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23789 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23791 "rloc <locator> p <prio> " \
23792 "w <weight> [rloc <loc> ... ] " \
23793 "action <action> [del-all]") \
23794 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23796 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23797 _(lisp_use_petr, "<ip-address> | disable") \
23798 _(lisp_map_request_mode, "src-dst|dst-only") \
23799 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23800 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23801 _(lisp_locator_set_dump, "[local | remote]") \
23802 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23803 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23804 "[local] | [remote]") \
23805 _(lisp_eid_table_vni_dump, "") \
23806 _(lisp_eid_table_map_dump, "l2|l3") \
23807 _(lisp_map_resolver_dump, "") \
23808 _(lisp_map_server_dump, "") \
23809 _(lisp_adjacencies_get, "vni <vni>") \
23810 _(gpe_fwd_entry_vnis_get, "") \
23811 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23812 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23813 "[table <table-id>]") \
23814 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23815 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23816 _(gpe_set_encap_mode, "lisp|vxlan") \
23817 _(gpe_get_encap_mode, "") \
23818 _(lisp_gpe_add_del_iface, "up|down") \
23819 _(lisp_gpe_enable_disable, "enable|disable") \
23820 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23821 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23822 _(show_lisp_rloc_probe_state, "") \
23823 _(show_lisp_map_register_state, "") \
23824 _(show_lisp_status, "") \
23825 _(lisp_get_map_request_itr_rlocs, "") \
23826 _(show_lisp_pitr, "") \
23827 _(show_lisp_use_petr, "") \
23828 _(show_lisp_map_request_mode, "") \
23829 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23830 _(af_packet_delete, "name <host interface name>") \
23831 _(af_packet_dump, "") \
23832 _(policer_add_del, "name <policer name> <params> [del]") \
23833 _(policer_dump, "[name <policer name>]") \
23834 _(policer_classify_set_interface, \
23835 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23836 " [l2-table <nn>] [del]") \
23837 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23838 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23839 "[master|slave]") \
23840 _(netmap_delete, "name <interface name>") \
23841 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23842 _(mpls_fib_dump, "") \
23843 _(classify_table_ids, "") \
23844 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23845 _(classify_table_info, "table_id <nn>") \
23846 _(classify_session_dump, "table_id <nn>") \
23847 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23848 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23849 "[template_interval <nn>] [udp_checksum]") \
23850 _(ipfix_exporter_dump, "") \
23851 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23852 _(ipfix_classify_stream_dump, "") \
23853 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23854 _(ipfix_classify_table_dump, "") \
23855 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23856 _(sw_interface_span_dump, "[l2]") \
23857 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23858 _(pg_create_interface, "if_id <nn>") \
23859 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23860 _(pg_enable_disable, "[stream <id>] disable") \
23861 _(ip_source_and_port_range_check_add_del, \
23862 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23863 _(ip_source_and_port_range_check_interface_add_del, \
23864 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23865 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23866 _(ipsec_gre_add_del_tunnel, \
23867 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23868 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23869 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23870 _(l2_interface_pbb_tag_rewrite, \
23871 "<intfc> | sw_if_index <nn> \n" \
23872 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23873 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23874 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23875 _(flow_classify_set_interface, \
23876 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23877 _(flow_classify_dump, "type [ip4|ip6]") \
23878 _(ip_fib_dump, "") \
23879 _(ip_mfib_dump, "") \
23880 _(ip6_fib_dump, "") \
23881 _(ip6_mfib_dump, "") \
23882 _(feature_enable_disable, "arc_name <arc_name> " \
23883 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23884 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23886 _(l2_xconnect_dump, "") \
23887 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
23888 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23889 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23890 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23891 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23892 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23893 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23894 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23895 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23896 _(sock_init_shm, "size <nnn>") \
23897 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23898 _(dns_enable_disable, "[enable][disable]") \
23899 _(dns_name_server_add_del, "<ip-address> [del]") \
23900 _(dns_resolve_name, "<hostname>") \
23901 _(dns_resolve_ip, "<ip4|ip6>") \
23902 _(dns_name_server_add_del, "<ip-address> [del]") \
23903 _(dns_resolve_name, "<hostname>") \
23904 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23905 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23906 _(session_rules_dump, "") \
23907 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23908 _(output_acl_set_interface, \
23909 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23910 " [l2-table <nn>] [del]") \
23911 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
23913 /* List of command functions, CLI names map directly to functions */
23914 #define foreach_cli_function \
23915 _(comment, "usage: comment <ignore-rest-of-line>") \
23916 _(dump_interface_table, "usage: dump_interface_table") \
23917 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23918 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23919 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23920 _(dump_macro_table, "usage: dump_macro_table ") \
23921 _(dump_node_table, "usage: dump_node_table") \
23922 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23923 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23924 _(echo, "usage: echo <message>") \
23925 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23926 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23927 _(help, "usage: help") \
23928 _(q, "usage: quit") \
23929 _(quit, "usage: quit") \
23930 _(search_node_table, "usage: search_node_table <name>...") \
23931 _(set, "usage: set <variable-name> <value>") \
23932 _(script, "usage: script <file-name>") \
23933 _(statseg, "usage: statseg"); \
23934 _(unset, "usage: unset <variable-name>")
23937 static void vl_api_##n##_t_handler_uni \
23938 (vl_api_##n##_t * mp) \
23940 vat_main_t * vam = &vat_main; \
23941 if (vam->json_output) { \
23942 vl_api_##n##_t_handler_json(mp); \
23944 vl_api_##n##_t_handler(mp); \
23947 foreach_vpe_api_reply_msg;
23948 #if VPP_API_TEST_BUILTIN == 0
23949 foreach_standalone_reply_msg;
23954 vat_api_hookup (vat_main_t * vam)
23957 vl_msg_api_set_handlers(VL_API_##N, #n, \
23958 vl_api_##n##_t_handler_uni, \
23960 vl_api_##n##_t_endian, \
23961 vl_api_##n##_t_print, \
23962 sizeof(vl_api_##n##_t), 1);
23963 foreach_vpe_api_reply_msg;
23964 #if VPP_API_TEST_BUILTIN == 0
23965 foreach_standalone_reply_msg;
23969 #if (VPP_API_TEST_BUILTIN==0)
23970 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23972 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23974 vam->function_by_name = hash_create_string (0, sizeof (uword));
23976 vam->help_by_name = hash_create_string (0, sizeof (uword));
23979 /* API messages we can send */
23980 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23981 foreach_vpe_api_msg;
23985 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23986 foreach_vpe_api_msg;
23989 /* CLI functions */
23990 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23991 foreach_cli_function;
23995 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23996 foreach_cli_function;
24000 #if VPP_API_TEST_BUILTIN
24001 static clib_error_t *
24002 vat_api_hookup_shim (vlib_main_t * vm)
24004 vat_api_hookup (&vat_main);
24008 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
24012 * fd.io coding-style-patch-verification: ON
24015 * eval: (c-set-style "gnu")