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;
1739 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_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_create_v2_reply_t_handler_json
1757 (vl_api_tap_create_v2_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_delete_v2_reply_t_handler (vl_api_tap_delete_v2_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->result_ready = 1;
1790 static void vl_api_tap_delete_v2_reply_t_handler_json
1791 (vl_api_tap_delete_v2_reply_t * mp)
1793 vat_main_t *vam = &vat_main;
1794 vat_json_node_t node;
1796 vat_json_init_object (&node);
1797 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1799 vat_json_print (vam->ofp, &node);
1800 vat_json_free (&node);
1802 vam->retval = ntohl (mp->retval);
1803 vam->result_ready = 1;
1807 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1810 vat_main_t *vam = &vat_main;
1811 i32 retval = ntohl (mp->retval);
1812 if (vam->async_mode)
1814 vam->async_errors += (retval < 0);
1818 vam->retval = retval;
1819 vam->sw_if_index = ntohl (mp->sw_if_index);
1820 vam->result_ready = 1;
1824 static void vl_api_virtio_pci_create_reply_t_handler_json
1825 (vl_api_virtio_pci_create_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));
1832 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1834 vat_json_print (vam->ofp, &node);
1835 vat_json_free (&node);
1837 vam->retval = ntohl (mp->retval);
1838 vam->result_ready = 1;
1843 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1846 vat_main_t *vam = &vat_main;
1847 i32 retval = ntohl (mp->retval);
1848 if (vam->async_mode)
1850 vam->async_errors += (retval < 0);
1854 vam->retval = retval;
1855 vam->result_ready = 1;
1859 static void vl_api_virtio_pci_delete_reply_t_handler_json
1860 (vl_api_virtio_pci_delete_reply_t * mp)
1862 vat_main_t *vam = &vat_main;
1863 vat_json_node_t node;
1865 vat_json_init_object (&node);
1866 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1868 vat_json_print (vam->ofp, &node);
1869 vat_json_free (&node);
1871 vam->retval = ntohl (mp->retval);
1872 vam->result_ready = 1;
1876 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1878 vat_main_t *vam = &vat_main;
1879 i32 retval = ntohl (mp->retval);
1881 if (vam->async_mode)
1883 vam->async_errors += (retval < 0);
1887 vam->retval = retval;
1888 vam->sw_if_index = ntohl (mp->sw_if_index);
1889 vam->result_ready = 1;
1893 static void vl_api_bond_create_reply_t_handler_json
1894 (vl_api_bond_create_reply_t * mp)
1896 vat_main_t *vam = &vat_main;
1897 vat_json_node_t node;
1899 vat_json_init_object (&node);
1900 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1901 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1903 vat_json_print (vam->ofp, &node);
1904 vat_json_free (&node);
1906 vam->retval = ntohl (mp->retval);
1907 vam->result_ready = 1;
1911 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1913 vat_main_t *vam = &vat_main;
1914 i32 retval = ntohl (mp->retval);
1916 if (vam->async_mode)
1918 vam->async_errors += (retval < 0);
1922 vam->retval = retval;
1923 vam->result_ready = 1;
1927 static void vl_api_bond_delete_reply_t_handler_json
1928 (vl_api_bond_delete_reply_t * mp)
1930 vat_main_t *vam = &vat_main;
1931 vat_json_node_t node;
1933 vat_json_init_object (&node);
1934 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1936 vat_json_print (vam->ofp, &node);
1937 vat_json_free (&node);
1939 vam->retval = ntohl (mp->retval);
1940 vam->result_ready = 1;
1944 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1946 vat_main_t *vam = &vat_main;
1947 i32 retval = ntohl (mp->retval);
1949 if (vam->async_mode)
1951 vam->async_errors += (retval < 0);
1955 vam->retval = retval;
1956 vam->result_ready = 1;
1960 static void vl_api_bond_enslave_reply_t_handler_json
1961 (vl_api_bond_enslave_reply_t * mp)
1963 vat_main_t *vam = &vat_main;
1964 vat_json_node_t node;
1966 vat_json_init_object (&node);
1967 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1969 vat_json_print (vam->ofp, &node);
1970 vat_json_free (&node);
1972 vam->retval = ntohl (mp->retval);
1973 vam->result_ready = 1;
1977 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
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->result_ready = 1;
1994 static void vl_api_bond_detach_slave_reply_t_handler_json
1995 (vl_api_bond_detach_slave_reply_t * mp)
1997 vat_main_t *vam = &vat_main;
1998 vat_json_node_t node;
2000 vat_json_init_object (&node);
2001 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2003 vat_json_print (vam->ofp, &node);
2004 vat_json_free (&node);
2006 vam->retval = ntohl (mp->retval);
2007 vam->result_ready = 1;
2010 static void vl_api_sw_interface_bond_details_t_handler
2011 (vl_api_sw_interface_bond_details_t * mp)
2013 vat_main_t *vam = &vat_main;
2016 "%-16s %-12d %-12U %-13U %-14u %-14u",
2017 mp->interface_name, ntohl (mp->sw_if_index),
2018 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2019 ntohl (mp->active_slaves), ntohl (mp->slaves));
2022 static void vl_api_sw_interface_bond_details_t_handler_json
2023 (vl_api_sw_interface_bond_details_t * mp)
2025 vat_main_t *vam = &vat_main;
2026 vat_json_node_t *node = NULL;
2028 if (VAT_JSON_ARRAY != vam->json_tree.type)
2030 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2031 vat_json_init_array (&vam->json_tree);
2033 node = vat_json_array_add (&vam->json_tree);
2035 vat_json_init_object (node);
2036 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2037 vat_json_object_add_string_copy (node, "interface_name",
2038 mp->interface_name);
2039 vat_json_object_add_uint (node, "mode", mp->mode);
2040 vat_json_object_add_uint (node, "load_balance", mp->lb);
2041 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2042 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2046 api_sw_interface_bond_dump (vat_main_t * vam)
2048 vl_api_sw_interface_bond_dump_t *mp;
2049 vl_api_control_ping_t *mp_ping;
2053 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2054 "interface name", "sw_if_index", "mode", "load balance",
2055 "active slaves", "slaves");
2057 /* Get list of bond interfaces */
2058 M (SW_INTERFACE_BOND_DUMP, mp);
2061 /* Use a control ping for synchronization */
2062 MPING (CONTROL_PING, mp_ping);
2069 static void vl_api_sw_interface_slave_details_t_handler
2070 (vl_api_sw_interface_slave_details_t * mp)
2072 vat_main_t *vam = &vat_main;
2075 "%-25s %-12d %-12d %d", mp->interface_name,
2076 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2079 static void vl_api_sw_interface_slave_details_t_handler_json
2080 (vl_api_sw_interface_slave_details_t * mp)
2082 vat_main_t *vam = &vat_main;
2083 vat_json_node_t *node = NULL;
2085 if (VAT_JSON_ARRAY != vam->json_tree.type)
2087 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2088 vat_json_init_array (&vam->json_tree);
2090 node = vat_json_array_add (&vam->json_tree);
2092 vat_json_init_object (node);
2093 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2094 vat_json_object_add_string_copy (node, "interface_name",
2095 mp->interface_name);
2096 vat_json_object_add_uint (node, "passive", mp->is_passive);
2097 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2101 api_sw_interface_slave_dump (vat_main_t * vam)
2103 unformat_input_t *i = vam->input;
2104 vl_api_sw_interface_slave_dump_t *mp;
2105 vl_api_control_ping_t *mp_ping;
2106 u32 sw_if_index = ~0;
2107 u8 sw_if_index_set = 0;
2110 /* Parse args required to build the message */
2111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2113 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2114 sw_if_index_set = 1;
2115 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2116 sw_if_index_set = 1;
2121 if (sw_if_index_set == 0)
2123 errmsg ("missing vpp interface name. ");
2128 "\n%-25s %-12s %-12s %s",
2129 "slave interface name", "sw_if_index", "passive", "long_timeout");
2131 /* Get list of bond interfaces */
2132 M (SW_INTERFACE_SLAVE_DUMP, mp);
2133 mp->sw_if_index = ntohl (sw_if_index);
2136 /* Use a control ping for synchronization */
2137 MPING (CONTROL_PING, mp_ping);
2144 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2145 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2147 vat_main_t *vam = &vat_main;
2148 i32 retval = ntohl (mp->retval);
2149 if (vam->async_mode)
2151 vam->async_errors += (retval < 0);
2155 vam->retval = retval;
2156 vam->sw_if_index = ntohl (mp->sw_if_index);
2157 vam->result_ready = 1;
2159 vam->regenerate_interface_table = 1;
2162 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2163 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2165 vat_main_t *vam = &vat_main;
2166 vat_json_node_t node;
2168 vat_json_init_object (&node);
2169 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2170 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2171 ntohl (mp->sw_if_index));
2173 vat_json_print (vam->ofp, &node);
2174 vat_json_free (&node);
2176 vam->retval = ntohl (mp->retval);
2177 vam->result_ready = 1;
2180 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2181 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2183 vat_main_t *vam = &vat_main;
2184 i32 retval = ntohl (mp->retval);
2185 if (vam->async_mode)
2187 vam->async_errors += (retval < 0);
2191 vam->retval = retval;
2192 vam->sw_if_index = ntohl (mp->sw_if_index);
2193 vam->result_ready = 1;
2197 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2198 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2200 vat_main_t *vam = &vat_main;
2201 vat_json_node_t node;
2203 vat_json_init_object (&node);
2204 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2205 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2207 vat_json_print (vam->ofp, &node);
2208 vat_json_free (&node);
2210 vam->retval = ntohl (mp->retval);
2211 vam->result_ready = 1;
2214 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2215 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2217 vat_main_t *vam = &vat_main;
2218 i32 retval = ntohl (mp->retval);
2219 if (vam->async_mode)
2221 vam->async_errors += (retval < 0);
2225 vam->retval = retval;
2226 vam->result_ready = 1;
2230 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2231 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2233 vat_main_t *vam = &vat_main;
2234 vat_json_node_t node;
2236 vat_json_init_object (&node);
2237 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2238 vat_json_object_add_uint (&node, "fwd_entry_index",
2239 clib_net_to_host_u32 (mp->fwd_entry_index));
2241 vat_json_print (vam->ofp, &node);
2242 vat_json_free (&node);
2244 vam->retval = ntohl (mp->retval);
2245 vam->result_ready = 1;
2249 format_lisp_transport_protocol (u8 * s, va_list * args)
2251 u32 proto = va_arg (*args, u32);
2256 return format (s, "udp");
2258 return format (s, "api");
2265 static void vl_api_one_get_transport_protocol_reply_t_handler
2266 (vl_api_one_get_transport_protocol_reply_t * mp)
2268 vat_main_t *vam = &vat_main;
2269 i32 retval = ntohl (mp->retval);
2270 if (vam->async_mode)
2272 vam->async_errors += (retval < 0);
2276 u32 proto = mp->protocol;
2277 print (vam->ofp, "Transport protocol: %U",
2278 format_lisp_transport_protocol, proto);
2279 vam->retval = retval;
2280 vam->result_ready = 1;
2284 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2285 (vl_api_one_get_transport_protocol_reply_t * mp)
2287 vat_main_t *vam = &vat_main;
2288 vat_json_node_t node;
2291 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2294 vat_json_init_object (&node);
2295 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2296 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2299 vat_json_print (vam->ofp, &node);
2300 vat_json_free (&node);
2302 vam->retval = ntohl (mp->retval);
2303 vam->result_ready = 1;
2306 static void vl_api_one_add_del_locator_set_reply_t_handler
2307 (vl_api_one_add_del_locator_set_reply_t * mp)
2309 vat_main_t *vam = &vat_main;
2310 i32 retval = ntohl (mp->retval);
2311 if (vam->async_mode)
2313 vam->async_errors += (retval < 0);
2317 vam->retval = retval;
2318 vam->result_ready = 1;
2322 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2323 (vl_api_one_add_del_locator_set_reply_t * mp)
2325 vat_main_t *vam = &vat_main;
2326 vat_json_node_t node;
2328 vat_json_init_object (&node);
2329 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2330 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2332 vat_json_print (vam->ofp, &node);
2333 vat_json_free (&node);
2335 vam->retval = ntohl (mp->retval);
2336 vam->result_ready = 1;
2339 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2340 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2342 vat_main_t *vam = &vat_main;
2343 i32 retval = ntohl (mp->retval);
2344 if (vam->async_mode)
2346 vam->async_errors += (retval < 0);
2350 vam->retval = retval;
2351 vam->sw_if_index = ntohl (mp->sw_if_index);
2352 vam->result_ready = 1;
2354 vam->regenerate_interface_table = 1;
2357 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2358 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2360 vat_main_t *vam = &vat_main;
2361 vat_json_node_t node;
2363 vat_json_init_object (&node);
2364 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2365 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2367 vat_json_print (vam->ofp, &node);
2368 vat_json_free (&node);
2370 vam->retval = ntohl (mp->retval);
2371 vam->result_ready = 1;
2374 static void vl_api_vxlan_offload_rx_reply_t_handler
2375 (vl_api_vxlan_offload_rx_reply_t * mp)
2377 vat_main_t *vam = &vat_main;
2378 i32 retval = ntohl (mp->retval);
2379 if (vam->async_mode)
2381 vam->async_errors += (retval < 0);
2385 vam->retval = retval;
2386 vam->result_ready = 1;
2390 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2391 (vl_api_vxlan_offload_rx_reply_t * mp)
2393 vat_main_t *vam = &vat_main;
2394 vat_json_node_t node;
2396 vat_json_init_object (&node);
2397 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2399 vat_json_print (vam->ofp, &node);
2400 vat_json_free (&node);
2402 vam->retval = ntohl (mp->retval);
2403 vam->result_ready = 1;
2406 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2407 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2409 vat_main_t *vam = &vat_main;
2410 i32 retval = ntohl (mp->retval);
2411 if (vam->async_mode)
2413 vam->async_errors += (retval < 0);
2417 vam->retval = retval;
2418 vam->sw_if_index = ntohl (mp->sw_if_index);
2419 vam->result_ready = 1;
2423 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2424 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2426 vat_main_t *vam = &vat_main;
2427 vat_json_node_t node;
2429 vat_json_init_object (&node);
2430 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2431 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2433 vat_json_print (vam->ofp, &node);
2434 vat_json_free (&node);
2436 vam->retval = ntohl (mp->retval);
2437 vam->result_ready = 1;
2440 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2441 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2443 vat_main_t *vam = &vat_main;
2444 i32 retval = ntohl (mp->retval);
2445 if (vam->async_mode)
2447 vam->async_errors += (retval < 0);
2451 vam->retval = retval;
2452 vam->sw_if_index = ntohl (mp->sw_if_index);
2453 vam->result_ready = 1;
2455 vam->regenerate_interface_table = 1;
2458 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2459 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2461 vat_main_t *vam = &vat_main;
2462 vat_json_node_t node;
2464 vat_json_init_object (&node);
2465 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2466 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2468 vat_json_print (vam->ofp, &node);
2469 vat_json_free (&node);
2471 vam->retval = ntohl (mp->retval);
2472 vam->result_ready = 1;
2475 static void vl_api_gre_add_del_tunnel_reply_t_handler
2476 (vl_api_gre_add_del_tunnel_reply_t * mp)
2478 vat_main_t *vam = &vat_main;
2479 i32 retval = ntohl (mp->retval);
2480 if (vam->async_mode)
2482 vam->async_errors += (retval < 0);
2486 vam->retval = retval;
2487 vam->sw_if_index = ntohl (mp->sw_if_index);
2488 vam->result_ready = 1;
2492 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2493 (vl_api_gre_add_del_tunnel_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));
2500 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2502 vat_json_print (vam->ofp, &node);
2503 vat_json_free (&node);
2505 vam->retval = ntohl (mp->retval);
2506 vam->result_ready = 1;
2509 static void vl_api_create_vhost_user_if_reply_t_handler
2510 (vl_api_create_vhost_user_if_reply_t * mp)
2512 vat_main_t *vam = &vat_main;
2513 i32 retval = ntohl (mp->retval);
2514 if (vam->async_mode)
2516 vam->async_errors += (retval < 0);
2520 vam->retval = retval;
2521 vam->sw_if_index = ntohl (mp->sw_if_index);
2522 vam->result_ready = 1;
2524 vam->regenerate_interface_table = 1;
2527 static void vl_api_create_vhost_user_if_reply_t_handler_json
2528 (vl_api_create_vhost_user_if_reply_t * mp)
2530 vat_main_t *vam = &vat_main;
2531 vat_json_node_t node;
2533 vat_json_init_object (&node);
2534 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2535 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2537 vat_json_print (vam->ofp, &node);
2538 vat_json_free (&node);
2540 vam->retval = ntohl (mp->retval);
2541 vam->result_ready = 1;
2544 static void vl_api_dns_resolve_name_reply_t_handler
2545 (vl_api_dns_resolve_name_reply_t * mp)
2547 vat_main_t *vam = &vat_main;
2548 i32 retval = ntohl (mp->retval);
2549 if (vam->async_mode)
2551 vam->async_errors += (retval < 0);
2555 vam->retval = retval;
2556 vam->result_ready = 1;
2561 clib_warning ("ip4 address %U", format_ip4_address,
2562 (ip4_address_t *) mp->ip4_address);
2564 clib_warning ("ip6 address %U", format_ip6_address,
2565 (ip6_address_t *) mp->ip6_address);
2568 clib_warning ("retval %d", retval);
2572 static void vl_api_dns_resolve_name_reply_t_handler_json
2573 (vl_api_dns_resolve_name_reply_t * mp)
2575 clib_warning ("not implemented");
2578 static void vl_api_dns_resolve_ip_reply_t_handler
2579 (vl_api_dns_resolve_ip_reply_t * mp)
2581 vat_main_t *vam = &vat_main;
2582 i32 retval = ntohl (mp->retval);
2583 if (vam->async_mode)
2585 vam->async_errors += (retval < 0);
2589 vam->retval = retval;
2590 vam->result_ready = 1;
2594 clib_warning ("canonical name %s", mp->name);
2597 clib_warning ("retval %d", retval);
2601 static void vl_api_dns_resolve_ip_reply_t_handler_json
2602 (vl_api_dns_resolve_ip_reply_t * mp)
2604 clib_warning ("not implemented");
2608 static void vl_api_ip_address_details_t_handler
2609 (vl_api_ip_address_details_t * mp)
2611 vat_main_t *vam = &vat_main;
2612 static ip_address_details_t empty_ip_address_details = { {0} };
2613 ip_address_details_t *address = NULL;
2614 ip_details_t *current_ip_details = NULL;
2615 ip_details_t *details = NULL;
2617 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2619 if (!details || vam->current_sw_if_index >= vec_len (details)
2620 || !details[vam->current_sw_if_index].present)
2622 errmsg ("ip address details arrived but not stored");
2623 errmsg ("ip_dump should be called first");
2627 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2629 #define addresses (current_ip_details->addr)
2631 vec_validate_init_empty (addresses, vec_len (addresses),
2632 empty_ip_address_details);
2634 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2636 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2637 address->prefix_length = mp->prefix_length;
2641 static void vl_api_ip_address_details_t_handler_json
2642 (vl_api_ip_address_details_t * mp)
2644 vat_main_t *vam = &vat_main;
2645 vat_json_node_t *node = NULL;
2646 struct in6_addr ip6;
2649 if (VAT_JSON_ARRAY != vam->json_tree.type)
2651 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2652 vat_json_init_array (&vam->json_tree);
2654 node = vat_json_array_add (&vam->json_tree);
2656 vat_json_init_object (node);
2659 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2660 vat_json_object_add_ip6 (node, "ip", ip6);
2664 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2665 vat_json_object_add_ip4 (node, "ip", ip4);
2667 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2671 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2673 vat_main_t *vam = &vat_main;
2674 static ip_details_t empty_ip_details = { 0 };
2675 ip_details_t *ip = NULL;
2676 u32 sw_if_index = ~0;
2678 sw_if_index = ntohl (mp->sw_if_index);
2680 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2681 sw_if_index, empty_ip_details);
2683 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2690 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2692 vat_main_t *vam = &vat_main;
2694 if (VAT_JSON_ARRAY != vam->json_tree.type)
2696 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2697 vat_json_init_array (&vam->json_tree);
2699 vat_json_array_add_uint (&vam->json_tree,
2700 clib_net_to_host_u32 (mp->sw_if_index));
2704 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2706 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2707 "router_addr %U host_mac %U",
2708 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2710 format_ip4_address, &mp->lease.host_address,
2711 format_ip4_address, &mp->lease.router_address,
2712 format_ethernet_address, mp->lease.host_mac);
2715 static void vl_api_dhcp_compl_event_t_handler_json
2716 (vl_api_dhcp_compl_event_t * mp)
2718 /* JSON output not supported */
2721 static void vl_api_get_first_msg_id_reply_t_handler
2722 (vl_api_get_first_msg_id_reply_t * mp)
2724 vat_main_t *vam = &vat_main;
2725 i32 retval = ntohl (mp->retval);
2727 if (vam->async_mode)
2729 vam->async_errors += (retval < 0);
2733 vam->retval = retval;
2734 vam->result_ready = 1;
2738 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2742 static void vl_api_get_first_msg_id_reply_t_handler_json
2743 (vl_api_get_first_msg_id_reply_t * mp)
2745 vat_main_t *vam = &vat_main;
2746 vat_json_node_t node;
2748 vat_json_init_object (&node);
2749 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2750 vat_json_object_add_uint (&node, "first_msg_id",
2751 (uint) ntohs (mp->first_msg_id));
2753 vat_json_print (vam->ofp, &node);
2754 vat_json_free (&node);
2756 vam->retval = ntohl (mp->retval);
2757 vam->result_ready = 1;
2760 static void vl_api_get_node_graph_reply_t_handler
2761 (vl_api_get_node_graph_reply_t * mp)
2763 vat_main_t *vam = &vat_main;
2764 api_main_t *am = &api_main;
2765 i32 retval = ntohl (mp->retval);
2766 u8 *pvt_copy, *reply;
2771 if (vam->async_mode)
2773 vam->async_errors += (retval < 0);
2777 vam->retval = retval;
2778 vam->result_ready = 1;
2781 /* "Should never happen..." */
2785 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2786 pvt_copy = vec_dup (reply);
2788 /* Toss the shared-memory original... */
2789 pthread_mutex_lock (&am->vlib_rp->mutex);
2790 oldheap = svm_push_data_heap (am->vlib_rp);
2794 svm_pop_heap (oldheap);
2795 pthread_mutex_unlock (&am->vlib_rp->mutex);
2797 if (vam->graph_nodes)
2799 hash_free (vam->graph_node_index_by_name);
2801 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2803 node = vam->graph_nodes[0][i];
2804 vec_free (node->name);
2805 vec_free (node->next_nodes);
2808 vec_free (vam->graph_nodes[0]);
2809 vec_free (vam->graph_nodes);
2812 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2813 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2814 vec_free (pvt_copy);
2816 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2818 node = vam->graph_nodes[0][i];
2819 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2823 static void vl_api_get_node_graph_reply_t_handler_json
2824 (vl_api_get_node_graph_reply_t * mp)
2826 vat_main_t *vam = &vat_main;
2827 api_main_t *am = &api_main;
2829 vat_json_node_t node;
2832 /* $$$$ make this real? */
2833 vat_json_init_object (&node);
2834 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2835 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2837 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2839 /* Toss the shared-memory original... */
2840 pthread_mutex_lock (&am->vlib_rp->mutex);
2841 oldheap = svm_push_data_heap (am->vlib_rp);
2845 svm_pop_heap (oldheap);
2846 pthread_mutex_unlock (&am->vlib_rp->mutex);
2848 vat_json_print (vam->ofp, &node);
2849 vat_json_free (&node);
2851 vam->retval = ntohl (mp->retval);
2852 vam->result_ready = 1;
2856 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2858 vat_main_t *vam = &vat_main;
2863 s = format (s, "%=16d%=16d%=16d",
2864 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2868 s = format (s, "%=16U%=16d%=16d",
2869 mp->is_ipv6 ? format_ip6_address :
2871 mp->ip_address, mp->priority, mp->weight);
2874 print (vam->ofp, "%v", s);
2879 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2881 vat_main_t *vam = &vat_main;
2882 vat_json_node_t *node = NULL;
2883 struct in6_addr ip6;
2886 if (VAT_JSON_ARRAY != vam->json_tree.type)
2888 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2889 vat_json_init_array (&vam->json_tree);
2891 node = vat_json_array_add (&vam->json_tree);
2892 vat_json_init_object (node);
2894 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2895 vat_json_object_add_uint (node, "priority", mp->priority);
2896 vat_json_object_add_uint (node, "weight", mp->weight);
2899 vat_json_object_add_uint (node, "sw_if_index",
2900 clib_net_to_host_u32 (mp->sw_if_index));
2905 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2906 vat_json_object_add_ip6 (node, "address", ip6);
2910 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2911 vat_json_object_add_ip4 (node, "address", ip4);
2917 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2920 vat_main_t *vam = &vat_main;
2923 ls_name = format (0, "%s", mp->ls_name);
2925 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2931 vl_api_one_locator_set_details_t_handler_json
2932 (vl_api_one_locator_set_details_t * mp)
2934 vat_main_t *vam = &vat_main;
2935 vat_json_node_t *node = 0;
2938 ls_name = format (0, "%s", mp->ls_name);
2939 vec_add1 (ls_name, 0);
2941 if (VAT_JSON_ARRAY != vam->json_tree.type)
2943 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2944 vat_json_init_array (&vam->json_tree);
2946 node = vat_json_array_add (&vam->json_tree);
2948 vat_json_init_object (node);
2949 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2950 vat_json_object_add_uint (node, "ls_index",
2951 clib_net_to_host_u32 (mp->ls_index));
2959 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2962 unformat_nsh_address (unformat_input_t * input, va_list * args)
2964 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2965 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2969 format_nsh_address_vat (u8 * s, va_list * args)
2971 nsh_t *a = va_arg (*args, nsh_t *);
2972 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2976 format_lisp_flat_eid (u8 * s, va_list * args)
2978 u32 type = va_arg (*args, u32);
2979 u8 *eid = va_arg (*args, u8 *);
2980 u32 eid_len = va_arg (*args, u32);
2985 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2987 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2989 return format (s, "%U", format_ethernet_address, eid);
2991 return format (s, "%U", format_nsh_address_vat, eid);
2997 format_lisp_eid_vat (u8 * s, va_list * args)
2999 u32 type = va_arg (*args, u32);
3000 u8 *eid = va_arg (*args, u8 *);
3001 u32 eid_len = va_arg (*args, u32);
3002 u8 *seid = va_arg (*args, u8 *);
3003 u32 seid_len = va_arg (*args, u32);
3004 u32 is_src_dst = va_arg (*args, u32);
3007 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3009 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3015 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3017 vat_main_t *vam = &vat_main;
3018 u8 *s = 0, *eid = 0;
3020 if (~0 == mp->locator_set_index)
3021 s = format (0, "action: %d", mp->action);
3023 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3025 eid = format (0, "%U", format_lisp_eid_vat,
3029 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3032 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3033 clib_net_to_host_u32 (mp->vni),
3035 mp->is_local ? "local" : "remote",
3036 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3037 clib_net_to_host_u16 (mp->key_id), mp->key);
3044 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3047 vat_main_t *vam = &vat_main;
3048 vat_json_node_t *node = 0;
3051 if (VAT_JSON_ARRAY != vam->json_tree.type)
3053 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3054 vat_json_init_array (&vam->json_tree);
3056 node = vat_json_array_add (&vam->json_tree);
3058 vat_json_init_object (node);
3059 if (~0 == mp->locator_set_index)
3060 vat_json_object_add_uint (node, "action", mp->action);
3062 vat_json_object_add_uint (node, "locator_set_index",
3063 clib_net_to_host_u32 (mp->locator_set_index));
3065 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3066 if (mp->eid_type == 3)
3068 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3069 vat_json_init_object (nsh_json);
3070 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3071 vat_json_object_add_uint (nsh_json, "spi",
3072 clib_net_to_host_u32 (nsh->spi));
3073 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3077 eid = format (0, "%U", format_lisp_eid_vat,
3081 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3083 vat_json_object_add_string_copy (node, "eid", eid);
3086 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3087 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3088 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3092 vat_json_object_add_uint (node, "key_id",
3093 clib_net_to_host_u16 (mp->key_id));
3094 vat_json_object_add_string_copy (node, "key", mp->key);
3099 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3101 vat_main_t *vam = &vat_main;
3102 u8 *seid = 0, *deid = 0;
3103 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3105 deid = format (0, "%U", format_lisp_eid_vat,
3106 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3108 seid = format (0, "%U", format_lisp_eid_vat,
3109 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3115 format_ip_address_fcn = format_ip4_address;
3117 format_ip_address_fcn = format_ip6_address;
3120 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3121 clib_net_to_host_u32 (mp->vni),
3123 format_ip_address_fcn, mp->lloc,
3124 format_ip_address_fcn, mp->rloc,
3125 clib_net_to_host_u32 (mp->pkt_count),
3126 clib_net_to_host_u32 (mp->bytes));
3133 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3135 struct in6_addr ip6;
3137 vat_main_t *vam = &vat_main;
3138 vat_json_node_t *node = 0;
3139 u8 *deid = 0, *seid = 0;
3141 if (VAT_JSON_ARRAY != vam->json_tree.type)
3143 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3144 vat_json_init_array (&vam->json_tree);
3146 node = vat_json_array_add (&vam->json_tree);
3148 vat_json_init_object (node);
3149 deid = format (0, "%U", format_lisp_eid_vat,
3150 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3152 seid = format (0, "%U", format_lisp_eid_vat,
3153 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3158 vat_json_object_add_string_copy (node, "seid", seid);
3159 vat_json_object_add_string_copy (node, "deid", deid);
3160 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3164 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3165 vat_json_object_add_ip4 (node, "lloc", ip4);
3166 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3167 vat_json_object_add_ip4 (node, "rloc", ip4);
3171 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3172 vat_json_object_add_ip6 (node, "lloc", ip6);
3173 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3174 vat_json_object_add_ip6 (node, "rloc", ip6);
3176 vat_json_object_add_uint (node, "pkt_count",
3177 clib_net_to_host_u32 (mp->pkt_count));
3178 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3185 vl_api_one_eid_table_map_details_t_handler
3186 (vl_api_one_eid_table_map_details_t * mp)
3188 vat_main_t *vam = &vat_main;
3190 u8 *line = format (0, "%=10d%=10d",
3191 clib_net_to_host_u32 (mp->vni),
3192 clib_net_to_host_u32 (mp->dp_table));
3193 print (vam->ofp, "%v", line);
3198 vl_api_one_eid_table_map_details_t_handler_json
3199 (vl_api_one_eid_table_map_details_t * mp)
3201 vat_main_t *vam = &vat_main;
3202 vat_json_node_t *node = NULL;
3204 if (VAT_JSON_ARRAY != vam->json_tree.type)
3206 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3207 vat_json_init_array (&vam->json_tree);
3209 node = vat_json_array_add (&vam->json_tree);
3210 vat_json_init_object (node);
3211 vat_json_object_add_uint (node, "dp_table",
3212 clib_net_to_host_u32 (mp->dp_table));
3213 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3217 vl_api_one_eid_table_vni_details_t_handler
3218 (vl_api_one_eid_table_vni_details_t * mp)
3220 vat_main_t *vam = &vat_main;
3222 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3223 print (vam->ofp, "%v", line);
3228 vl_api_one_eid_table_vni_details_t_handler_json
3229 (vl_api_one_eid_table_vni_details_t * mp)
3231 vat_main_t *vam = &vat_main;
3232 vat_json_node_t *node = NULL;
3234 if (VAT_JSON_ARRAY != vam->json_tree.type)
3236 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3237 vat_json_init_array (&vam->json_tree);
3239 node = vat_json_array_add (&vam->json_tree);
3240 vat_json_init_object (node);
3241 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3245 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3246 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3248 vat_main_t *vam = &vat_main;
3249 int retval = clib_net_to_host_u32 (mp->retval);
3251 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3252 print (vam->ofp, "fallback threshold value: %d", mp->value);
3254 vam->retval = retval;
3255 vam->result_ready = 1;
3259 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3260 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3262 vat_main_t *vam = &vat_main;
3263 vat_json_node_t _node, *node = &_node;
3264 int retval = clib_net_to_host_u32 (mp->retval);
3266 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3267 vat_json_init_object (node);
3268 vat_json_object_add_uint (node, "value", mp->value);
3270 vat_json_print (vam->ofp, node);
3271 vat_json_free (node);
3273 vam->retval = retval;
3274 vam->result_ready = 1;
3278 vl_api_show_one_map_register_state_reply_t_handler
3279 (vl_api_show_one_map_register_state_reply_t * mp)
3281 vat_main_t *vam = &vat_main;
3282 int retval = clib_net_to_host_u32 (mp->retval);
3284 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3286 vam->retval = retval;
3287 vam->result_ready = 1;
3291 vl_api_show_one_map_register_state_reply_t_handler_json
3292 (vl_api_show_one_map_register_state_reply_t * mp)
3294 vat_main_t *vam = &vat_main;
3295 vat_json_node_t _node, *node = &_node;
3296 int retval = clib_net_to_host_u32 (mp->retval);
3298 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3300 vat_json_init_object (node);
3301 vat_json_object_add_string_copy (node, "state", s);
3303 vat_json_print (vam->ofp, node);
3304 vat_json_free (node);
3306 vam->retval = retval;
3307 vam->result_ready = 1;
3312 vl_api_show_one_rloc_probe_state_reply_t_handler
3313 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3315 vat_main_t *vam = &vat_main;
3316 int retval = clib_net_to_host_u32 (mp->retval);
3321 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3323 vam->retval = retval;
3324 vam->result_ready = 1;
3328 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3329 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3331 vat_main_t *vam = &vat_main;
3332 vat_json_node_t _node, *node = &_node;
3333 int retval = clib_net_to_host_u32 (mp->retval);
3335 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3336 vat_json_init_object (node);
3337 vat_json_object_add_string_copy (node, "state", s);
3339 vat_json_print (vam->ofp, node);
3340 vat_json_free (node);
3342 vam->retval = retval;
3343 vam->result_ready = 1;
3348 vl_api_show_one_stats_enable_disable_reply_t_handler
3349 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3351 vat_main_t *vam = &vat_main;
3352 int retval = clib_net_to_host_u32 (mp->retval);
3357 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3359 vam->retval = retval;
3360 vam->result_ready = 1;
3364 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3365 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3367 vat_main_t *vam = &vat_main;
3368 vat_json_node_t _node, *node = &_node;
3369 int retval = clib_net_to_host_u32 (mp->retval);
3371 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3372 vat_json_init_object (node);
3373 vat_json_object_add_string_copy (node, "state", s);
3375 vat_json_print (vam->ofp, node);
3376 vat_json_free (node);
3378 vam->retval = retval;
3379 vam->result_ready = 1;
3384 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3386 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3387 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3388 e->vni = clib_net_to_host_u32 (e->vni);
3392 gpe_fwd_entries_get_reply_t_net_to_host
3393 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3397 mp->count = clib_net_to_host_u32 (mp->count);
3398 for (i = 0; i < mp->count; i++)
3400 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3405 format_gpe_encap_mode (u8 * s, va_list * args)
3407 u32 mode = va_arg (*args, u32);
3412 return format (s, "lisp");
3414 return format (s, "vxlan");
3420 vl_api_gpe_get_encap_mode_reply_t_handler
3421 (vl_api_gpe_get_encap_mode_reply_t * mp)
3423 vat_main_t *vam = &vat_main;
3425 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3426 vam->retval = ntohl (mp->retval);
3427 vam->result_ready = 1;
3431 vl_api_gpe_get_encap_mode_reply_t_handler_json
3432 (vl_api_gpe_get_encap_mode_reply_t * mp)
3434 vat_main_t *vam = &vat_main;
3435 vat_json_node_t node;
3437 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3438 vec_add1 (encap_mode, 0);
3440 vat_json_init_object (&node);
3441 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3443 vec_free (encap_mode);
3444 vat_json_print (vam->ofp, &node);
3445 vat_json_free (&node);
3447 vam->retval = ntohl (mp->retval);
3448 vam->result_ready = 1;
3452 vl_api_gpe_fwd_entry_path_details_t_handler
3453 (vl_api_gpe_fwd_entry_path_details_t * mp)
3455 vat_main_t *vam = &vat_main;
3456 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3458 if (mp->lcl_loc.is_ip4)
3459 format_ip_address_fcn = format_ip4_address;
3461 format_ip_address_fcn = format_ip6_address;
3463 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3464 format_ip_address_fcn, &mp->lcl_loc,
3465 format_ip_address_fcn, &mp->rmt_loc);
3469 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3471 struct in6_addr ip6;
3476 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3477 vat_json_object_add_ip4 (n, "address", ip4);
3481 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3482 vat_json_object_add_ip6 (n, "address", ip6);
3484 vat_json_object_add_uint (n, "weight", loc->weight);
3488 vl_api_gpe_fwd_entry_path_details_t_handler_json
3489 (vl_api_gpe_fwd_entry_path_details_t * mp)
3491 vat_main_t *vam = &vat_main;
3492 vat_json_node_t *node = NULL;
3493 vat_json_node_t *loc_node;
3495 if (VAT_JSON_ARRAY != vam->json_tree.type)
3497 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3498 vat_json_init_array (&vam->json_tree);
3500 node = vat_json_array_add (&vam->json_tree);
3501 vat_json_init_object (node);
3503 loc_node = vat_json_object_add (node, "local_locator");
3504 vat_json_init_object (loc_node);
3505 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3507 loc_node = vat_json_object_add (node, "remote_locator");
3508 vat_json_init_object (loc_node);
3509 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3513 vl_api_gpe_fwd_entries_get_reply_t_handler
3514 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3516 vat_main_t *vam = &vat_main;
3518 int retval = clib_net_to_host_u32 (mp->retval);
3519 vl_api_gpe_fwd_entry_t *e;
3524 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3526 for (i = 0; i < mp->count; i++)
3528 e = &mp->entries[i];
3529 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3530 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3531 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3535 vam->retval = retval;
3536 vam->result_ready = 1;
3540 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3541 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3544 vat_main_t *vam = &vat_main;
3545 vat_json_node_t *e = 0, root;
3547 int retval = clib_net_to_host_u32 (mp->retval);
3548 vl_api_gpe_fwd_entry_t *fwd;
3553 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3554 vat_json_init_array (&root);
3556 for (i = 0; i < mp->count; i++)
3558 e = vat_json_array_add (&root);
3559 fwd = &mp->entries[i];
3561 vat_json_init_object (e);
3562 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3563 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3564 vat_json_object_add_int (e, "vni", fwd->vni);
3565 vat_json_object_add_int (e, "action", fwd->action);
3567 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3568 fwd->leid_prefix_len);
3570 vat_json_object_add_string_copy (e, "leid", s);
3573 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3574 fwd->reid_prefix_len);
3576 vat_json_object_add_string_copy (e, "reid", s);
3580 vat_json_print (vam->ofp, &root);
3581 vat_json_free (&root);
3584 vam->retval = retval;
3585 vam->result_ready = 1;
3589 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3590 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3592 vat_main_t *vam = &vat_main;
3594 int retval = clib_net_to_host_u32 (mp->retval);
3595 vl_api_gpe_native_fwd_rpath_t *r;
3600 n = clib_net_to_host_u32 (mp->count);
3602 for (i = 0; i < n; i++)
3604 r = &mp->entries[i];
3605 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3606 clib_net_to_host_u32 (r->fib_index),
3607 clib_net_to_host_u32 (r->nh_sw_if_index),
3608 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3612 vam->retval = retval;
3613 vam->result_ready = 1;
3617 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3618 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3620 vat_main_t *vam = &vat_main;
3621 vat_json_node_t root, *e;
3623 int retval = clib_net_to_host_u32 (mp->retval);
3624 vl_api_gpe_native_fwd_rpath_t *r;
3630 n = clib_net_to_host_u32 (mp->count);
3631 vat_json_init_array (&root);
3633 for (i = 0; i < n; i++)
3635 e = vat_json_array_add (&root);
3636 vat_json_init_object (e);
3637 r = &mp->entries[i];
3639 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3642 vat_json_object_add_string_copy (e, "ip4", s);
3645 vat_json_object_add_uint (e, "fib_index",
3646 clib_net_to_host_u32 (r->fib_index));
3647 vat_json_object_add_uint (e, "nh_sw_if_index",
3648 clib_net_to_host_u32 (r->nh_sw_if_index));
3651 vat_json_print (vam->ofp, &root);
3652 vat_json_free (&root);
3655 vam->retval = retval;
3656 vam->result_ready = 1;
3660 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3661 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3663 vat_main_t *vam = &vat_main;
3665 int retval = clib_net_to_host_u32 (mp->retval);
3670 n = clib_net_to_host_u32 (mp->count);
3672 for (i = 0; i < n; i++)
3673 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3676 vam->retval = retval;
3677 vam->result_ready = 1;
3681 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3682 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3684 vat_main_t *vam = &vat_main;
3685 vat_json_node_t root;
3687 int retval = clib_net_to_host_u32 (mp->retval);
3692 n = clib_net_to_host_u32 (mp->count);
3693 vat_json_init_array (&root);
3695 for (i = 0; i < n; i++)
3696 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3698 vat_json_print (vam->ofp, &root);
3699 vat_json_free (&root);
3702 vam->retval = retval;
3703 vam->result_ready = 1;
3707 vl_api_one_ndp_entries_get_reply_t_handler
3708 (vl_api_one_ndp_entries_get_reply_t * mp)
3710 vat_main_t *vam = &vat_main;
3712 int retval = clib_net_to_host_u32 (mp->retval);
3717 n = clib_net_to_host_u32 (mp->count);
3719 for (i = 0; i < n; i++)
3720 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3721 format_ethernet_address, mp->entries[i].mac);
3724 vam->retval = retval;
3725 vam->result_ready = 1;
3729 vl_api_one_ndp_entries_get_reply_t_handler_json
3730 (vl_api_one_ndp_entries_get_reply_t * mp)
3733 vat_main_t *vam = &vat_main;
3734 vat_json_node_t *e = 0, root;
3736 int retval = clib_net_to_host_u32 (mp->retval);
3737 vl_api_one_ndp_entry_t *arp_entry;
3742 n = clib_net_to_host_u32 (mp->count);
3743 vat_json_init_array (&root);
3745 for (i = 0; i < n; i++)
3747 e = vat_json_array_add (&root);
3748 arp_entry = &mp->entries[i];
3750 vat_json_init_object (e);
3751 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3754 vat_json_object_add_string_copy (e, "mac", s);
3757 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3759 vat_json_object_add_string_copy (e, "ip6", s);
3763 vat_json_print (vam->ofp, &root);
3764 vat_json_free (&root);
3767 vam->retval = retval;
3768 vam->result_ready = 1;
3772 vl_api_one_l2_arp_entries_get_reply_t_handler
3773 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3775 vat_main_t *vam = &vat_main;
3777 int retval = clib_net_to_host_u32 (mp->retval);
3782 n = clib_net_to_host_u32 (mp->count);
3784 for (i = 0; i < n; i++)
3785 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3786 format_ethernet_address, mp->entries[i].mac);
3789 vam->retval = retval;
3790 vam->result_ready = 1;
3794 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3795 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3798 vat_main_t *vam = &vat_main;
3799 vat_json_node_t *e = 0, root;
3801 int retval = clib_net_to_host_u32 (mp->retval);
3802 vl_api_one_l2_arp_entry_t *arp_entry;
3807 n = clib_net_to_host_u32 (mp->count);
3808 vat_json_init_array (&root);
3810 for (i = 0; i < n; i++)
3812 e = vat_json_array_add (&root);
3813 arp_entry = &mp->entries[i];
3815 vat_json_init_object (e);
3816 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3819 vat_json_object_add_string_copy (e, "mac", s);
3822 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3824 vat_json_object_add_string_copy (e, "ip4", s);
3828 vat_json_print (vam->ofp, &root);
3829 vat_json_free (&root);
3832 vam->retval = retval;
3833 vam->result_ready = 1;
3837 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3839 vat_main_t *vam = &vat_main;
3841 int retval = clib_net_to_host_u32 (mp->retval);
3846 n = clib_net_to_host_u32 (mp->count);
3848 for (i = 0; i < n; i++)
3850 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3854 vam->retval = retval;
3855 vam->result_ready = 1;
3859 vl_api_one_ndp_bd_get_reply_t_handler_json
3860 (vl_api_one_ndp_bd_get_reply_t * mp)
3862 vat_main_t *vam = &vat_main;
3863 vat_json_node_t root;
3865 int retval = clib_net_to_host_u32 (mp->retval);
3870 n = clib_net_to_host_u32 (mp->count);
3871 vat_json_init_array (&root);
3873 for (i = 0; i < n; i++)
3875 vat_json_array_add_uint (&root,
3876 clib_net_to_host_u32 (mp->bridge_domains[i]));
3879 vat_json_print (vam->ofp, &root);
3880 vat_json_free (&root);
3883 vam->retval = retval;
3884 vam->result_ready = 1;
3888 vl_api_one_l2_arp_bd_get_reply_t_handler
3889 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3891 vat_main_t *vam = &vat_main;
3893 int retval = clib_net_to_host_u32 (mp->retval);
3898 n = clib_net_to_host_u32 (mp->count);
3900 for (i = 0; i < n; i++)
3902 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3906 vam->retval = retval;
3907 vam->result_ready = 1;
3911 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3912 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3914 vat_main_t *vam = &vat_main;
3915 vat_json_node_t root;
3917 int retval = clib_net_to_host_u32 (mp->retval);
3922 n = clib_net_to_host_u32 (mp->count);
3923 vat_json_init_array (&root);
3925 for (i = 0; i < n; i++)
3927 vat_json_array_add_uint (&root,
3928 clib_net_to_host_u32 (mp->bridge_domains[i]));
3931 vat_json_print (vam->ofp, &root);
3932 vat_json_free (&root);
3935 vam->retval = retval;
3936 vam->result_ready = 1;
3940 vl_api_one_adjacencies_get_reply_t_handler
3941 (vl_api_one_adjacencies_get_reply_t * mp)
3943 vat_main_t *vam = &vat_main;
3945 int retval = clib_net_to_host_u32 (mp->retval);
3946 vl_api_one_adjacency_t *a;
3951 n = clib_net_to_host_u32 (mp->count);
3953 for (i = 0; i < n; i++)
3955 a = &mp->adjacencies[i];
3956 print (vam->ofp, "%U %40U",
3957 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3958 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3962 vam->retval = retval;
3963 vam->result_ready = 1;
3967 vl_api_one_adjacencies_get_reply_t_handler_json
3968 (vl_api_one_adjacencies_get_reply_t * mp)
3971 vat_main_t *vam = &vat_main;
3972 vat_json_node_t *e = 0, root;
3974 int retval = clib_net_to_host_u32 (mp->retval);
3975 vl_api_one_adjacency_t *a;
3980 n = clib_net_to_host_u32 (mp->count);
3981 vat_json_init_array (&root);
3983 for (i = 0; i < n; i++)
3985 e = vat_json_array_add (&root);
3986 a = &mp->adjacencies[i];
3988 vat_json_init_object (e);
3989 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3990 a->leid_prefix_len);
3992 vat_json_object_add_string_copy (e, "leid", s);
3995 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3996 a->reid_prefix_len);
3998 vat_json_object_add_string_copy (e, "reid", s);
4002 vat_json_print (vam->ofp, &root);
4003 vat_json_free (&root);
4006 vam->retval = retval;
4007 vam->result_ready = 1;
4011 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4013 vat_main_t *vam = &vat_main;
4015 print (vam->ofp, "%=20U",
4016 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4021 vl_api_one_map_server_details_t_handler_json
4022 (vl_api_one_map_server_details_t * mp)
4024 vat_main_t *vam = &vat_main;
4025 vat_json_node_t *node = NULL;
4026 struct in6_addr ip6;
4029 if (VAT_JSON_ARRAY != vam->json_tree.type)
4031 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4032 vat_json_init_array (&vam->json_tree);
4034 node = vat_json_array_add (&vam->json_tree);
4036 vat_json_init_object (node);
4039 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4040 vat_json_object_add_ip6 (node, "map-server", ip6);
4044 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4045 vat_json_object_add_ip4 (node, "map-server", ip4);
4050 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4053 vat_main_t *vam = &vat_main;
4055 print (vam->ofp, "%=20U",
4056 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4061 vl_api_one_map_resolver_details_t_handler_json
4062 (vl_api_one_map_resolver_details_t * mp)
4064 vat_main_t *vam = &vat_main;
4065 vat_json_node_t *node = NULL;
4066 struct in6_addr ip6;
4069 if (VAT_JSON_ARRAY != vam->json_tree.type)
4071 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4072 vat_json_init_array (&vam->json_tree);
4074 node = vat_json_array_add (&vam->json_tree);
4076 vat_json_init_object (node);
4079 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4080 vat_json_object_add_ip6 (node, "map resolver", ip6);
4084 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4085 vat_json_object_add_ip4 (node, "map resolver", ip4);
4090 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4092 vat_main_t *vam = &vat_main;
4093 i32 retval = ntohl (mp->retval);
4097 print (vam->ofp, "feature: %s\ngpe: %s",
4098 mp->feature_status ? "enabled" : "disabled",
4099 mp->gpe_status ? "enabled" : "disabled");
4102 vam->retval = retval;
4103 vam->result_ready = 1;
4107 vl_api_show_one_status_reply_t_handler_json
4108 (vl_api_show_one_status_reply_t * mp)
4110 vat_main_t *vam = &vat_main;
4111 vat_json_node_t node;
4112 u8 *gpe_status = NULL;
4113 u8 *feature_status = NULL;
4115 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4116 feature_status = format (0, "%s",
4117 mp->feature_status ? "enabled" : "disabled");
4118 vec_add1 (gpe_status, 0);
4119 vec_add1 (feature_status, 0);
4121 vat_json_init_object (&node);
4122 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4123 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4125 vec_free (gpe_status);
4126 vec_free (feature_status);
4128 vat_json_print (vam->ofp, &node);
4129 vat_json_free (&node);
4131 vam->retval = ntohl (mp->retval);
4132 vam->result_ready = 1;
4136 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4137 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4139 vat_main_t *vam = &vat_main;
4140 i32 retval = ntohl (mp->retval);
4144 print (vam->ofp, "%=20s", mp->locator_set_name);
4147 vam->retval = retval;
4148 vam->result_ready = 1;
4152 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4153 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4155 vat_main_t *vam = &vat_main;
4156 vat_json_node_t *node = NULL;
4158 if (VAT_JSON_ARRAY != vam->json_tree.type)
4160 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4161 vat_json_init_array (&vam->json_tree);
4163 node = vat_json_array_add (&vam->json_tree);
4165 vat_json_init_object (node);
4166 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4168 vat_json_print (vam->ofp, node);
4169 vat_json_free (node);
4171 vam->retval = ntohl (mp->retval);
4172 vam->result_ready = 1;
4176 format_lisp_map_request_mode (u8 * s, va_list * args)
4178 u32 mode = va_arg (*args, u32);
4183 return format (0, "dst-only");
4185 return format (0, "src-dst");
4191 vl_api_show_one_map_request_mode_reply_t_handler
4192 (vl_api_show_one_map_request_mode_reply_t * mp)
4194 vat_main_t *vam = &vat_main;
4195 i32 retval = ntohl (mp->retval);
4199 u32 mode = mp->mode;
4200 print (vam->ofp, "map_request_mode: %U",
4201 format_lisp_map_request_mode, mode);
4204 vam->retval = retval;
4205 vam->result_ready = 1;
4209 vl_api_show_one_map_request_mode_reply_t_handler_json
4210 (vl_api_show_one_map_request_mode_reply_t * mp)
4212 vat_main_t *vam = &vat_main;
4213 vat_json_node_t node;
4218 s = format (0, "%U", format_lisp_map_request_mode, mode);
4221 vat_json_init_object (&node);
4222 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4223 vat_json_print (vam->ofp, &node);
4224 vat_json_free (&node);
4227 vam->retval = ntohl (mp->retval);
4228 vam->result_ready = 1;
4232 vl_api_one_show_xtr_mode_reply_t_handler
4233 (vl_api_one_show_xtr_mode_reply_t * mp)
4235 vat_main_t *vam = &vat_main;
4236 i32 retval = ntohl (mp->retval);
4240 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4243 vam->retval = retval;
4244 vam->result_ready = 1;
4248 vl_api_one_show_xtr_mode_reply_t_handler_json
4249 (vl_api_one_show_xtr_mode_reply_t * mp)
4251 vat_main_t *vam = &vat_main;
4252 vat_json_node_t node;
4255 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4256 vec_add1 (status, 0);
4258 vat_json_init_object (&node);
4259 vat_json_object_add_string_copy (&node, "status", status);
4263 vat_json_print (vam->ofp, &node);
4264 vat_json_free (&node);
4266 vam->retval = ntohl (mp->retval);
4267 vam->result_ready = 1;
4271 vl_api_one_show_pitr_mode_reply_t_handler
4272 (vl_api_one_show_pitr_mode_reply_t * mp)
4274 vat_main_t *vam = &vat_main;
4275 i32 retval = ntohl (mp->retval);
4279 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4282 vam->retval = retval;
4283 vam->result_ready = 1;
4287 vl_api_one_show_pitr_mode_reply_t_handler_json
4288 (vl_api_one_show_pitr_mode_reply_t * mp)
4290 vat_main_t *vam = &vat_main;
4291 vat_json_node_t node;
4294 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4295 vec_add1 (status, 0);
4297 vat_json_init_object (&node);
4298 vat_json_object_add_string_copy (&node, "status", status);
4302 vat_json_print (vam->ofp, &node);
4303 vat_json_free (&node);
4305 vam->retval = ntohl (mp->retval);
4306 vam->result_ready = 1;
4310 vl_api_one_show_petr_mode_reply_t_handler
4311 (vl_api_one_show_petr_mode_reply_t * mp)
4313 vat_main_t *vam = &vat_main;
4314 i32 retval = ntohl (mp->retval);
4318 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4321 vam->retval = retval;
4322 vam->result_ready = 1;
4326 vl_api_one_show_petr_mode_reply_t_handler_json
4327 (vl_api_one_show_petr_mode_reply_t * mp)
4329 vat_main_t *vam = &vat_main;
4330 vat_json_node_t node;
4333 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4334 vec_add1 (status, 0);
4336 vat_json_init_object (&node);
4337 vat_json_object_add_string_copy (&node, "status", status);
4341 vat_json_print (vam->ofp, &node);
4342 vat_json_free (&node);
4344 vam->retval = ntohl (mp->retval);
4345 vam->result_ready = 1;
4349 vl_api_show_one_use_petr_reply_t_handler
4350 (vl_api_show_one_use_petr_reply_t * mp)
4352 vat_main_t *vam = &vat_main;
4353 i32 retval = ntohl (mp->retval);
4357 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4360 print (vam->ofp, "Proxy-ETR address; %U",
4361 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4366 vam->retval = retval;
4367 vam->result_ready = 1;
4371 vl_api_show_one_use_petr_reply_t_handler_json
4372 (vl_api_show_one_use_petr_reply_t * mp)
4374 vat_main_t *vam = &vat_main;
4375 vat_json_node_t node;
4378 struct in6_addr ip6;
4380 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4381 vec_add1 (status, 0);
4383 vat_json_init_object (&node);
4384 vat_json_object_add_string_copy (&node, "status", status);
4389 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4390 vat_json_object_add_ip6 (&node, "address", ip6);
4394 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4395 vat_json_object_add_ip4 (&node, "address", ip4);
4401 vat_json_print (vam->ofp, &node);
4402 vat_json_free (&node);
4404 vam->retval = ntohl (mp->retval);
4405 vam->result_ready = 1;
4409 vl_api_show_one_nsh_mapping_reply_t_handler
4410 (vl_api_show_one_nsh_mapping_reply_t * mp)
4412 vat_main_t *vam = &vat_main;
4413 i32 retval = ntohl (mp->retval);
4417 print (vam->ofp, "%-20s%-16s",
4418 mp->is_set ? "set" : "not-set",
4419 mp->is_set ? (char *) mp->locator_set_name : "");
4422 vam->retval = retval;
4423 vam->result_ready = 1;
4427 vl_api_show_one_nsh_mapping_reply_t_handler_json
4428 (vl_api_show_one_nsh_mapping_reply_t * mp)
4430 vat_main_t *vam = &vat_main;
4431 vat_json_node_t node;
4434 status = format (0, "%s", mp->is_set ? "yes" : "no");
4435 vec_add1 (status, 0);
4437 vat_json_init_object (&node);
4438 vat_json_object_add_string_copy (&node, "is_set", status);
4441 vat_json_object_add_string_copy (&node, "locator_set",
4442 mp->locator_set_name);
4447 vat_json_print (vam->ofp, &node);
4448 vat_json_free (&node);
4450 vam->retval = ntohl (mp->retval);
4451 vam->result_ready = 1;
4455 vl_api_show_one_map_register_ttl_reply_t_handler
4456 (vl_api_show_one_map_register_ttl_reply_t * mp)
4458 vat_main_t *vam = &vat_main;
4459 i32 retval = ntohl (mp->retval);
4461 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4465 print (vam->ofp, "ttl: %u", mp->ttl);
4468 vam->retval = retval;
4469 vam->result_ready = 1;
4473 vl_api_show_one_map_register_ttl_reply_t_handler_json
4474 (vl_api_show_one_map_register_ttl_reply_t * mp)
4476 vat_main_t *vam = &vat_main;
4477 vat_json_node_t node;
4479 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4480 vat_json_init_object (&node);
4481 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4483 vat_json_print (vam->ofp, &node);
4484 vat_json_free (&node);
4486 vam->retval = ntohl (mp->retval);
4487 vam->result_ready = 1;
4491 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4493 vat_main_t *vam = &vat_main;
4494 i32 retval = ntohl (mp->retval);
4498 print (vam->ofp, "%-20s%-16s",
4499 mp->status ? "enabled" : "disabled",
4500 mp->status ? (char *) mp->locator_set_name : "");
4503 vam->retval = retval;
4504 vam->result_ready = 1;
4508 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4510 vat_main_t *vam = &vat_main;
4511 vat_json_node_t node;
4514 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4515 vec_add1 (status, 0);
4517 vat_json_init_object (&node);
4518 vat_json_object_add_string_copy (&node, "status", status);
4521 vat_json_object_add_string_copy (&node, "locator_set",
4522 mp->locator_set_name);
4527 vat_json_print (vam->ofp, &node);
4528 vat_json_free (&node);
4530 vam->retval = ntohl (mp->retval);
4531 vam->result_ready = 1;
4535 format_policer_type (u8 * s, va_list * va)
4537 u32 i = va_arg (*va, u32);
4539 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4540 s = format (s, "1r2c");
4541 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4542 s = format (s, "1r3c");
4543 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4544 s = format (s, "2r3c-2698");
4545 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4546 s = format (s, "2r3c-4115");
4547 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4548 s = format (s, "2r3c-mef5cf1");
4550 s = format (s, "ILLEGAL");
4555 format_policer_rate_type (u8 * s, va_list * va)
4557 u32 i = va_arg (*va, u32);
4559 if (i == SSE2_QOS_RATE_KBPS)
4560 s = format (s, "kbps");
4561 else if (i == SSE2_QOS_RATE_PPS)
4562 s = format (s, "pps");
4564 s = format (s, "ILLEGAL");
4569 format_policer_round_type (u8 * s, va_list * va)
4571 u32 i = va_arg (*va, u32);
4573 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4574 s = format (s, "closest");
4575 else if (i == SSE2_QOS_ROUND_TO_UP)
4576 s = format (s, "up");
4577 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4578 s = format (s, "down");
4580 s = format (s, "ILLEGAL");
4585 format_policer_action_type (u8 * s, va_list * va)
4587 u32 i = va_arg (*va, u32);
4589 if (i == SSE2_QOS_ACTION_DROP)
4590 s = format (s, "drop");
4591 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4592 s = format (s, "transmit");
4593 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4594 s = format (s, "mark-and-transmit");
4596 s = format (s, "ILLEGAL");
4601 format_dscp (u8 * s, va_list * va)
4603 u32 i = va_arg (*va, u32);
4608 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4612 return format (s, "ILLEGAL");
4614 s = format (s, "%s", t);
4619 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4621 vat_main_t *vam = &vat_main;
4622 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4624 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4625 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4627 conform_dscp_str = format (0, "");
4629 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4630 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4632 exceed_dscp_str = format (0, "");
4634 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4635 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4637 violate_dscp_str = format (0, "");
4639 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4640 "rate type %U, round type %U, %s rate, %s color-aware, "
4641 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4642 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4643 "conform action %U%s, exceed action %U%s, violate action %U%s",
4645 format_policer_type, mp->type,
4648 clib_net_to_host_u64 (mp->cb),
4649 clib_net_to_host_u64 (mp->eb),
4650 format_policer_rate_type, mp->rate_type,
4651 format_policer_round_type, mp->round_type,
4652 mp->single_rate ? "single" : "dual",
4653 mp->color_aware ? "is" : "not",
4654 ntohl (mp->cir_tokens_per_period),
4655 ntohl (mp->pir_tokens_per_period),
4657 ntohl (mp->current_limit),
4658 ntohl (mp->current_bucket),
4659 ntohl (mp->extended_limit),
4660 ntohl (mp->extended_bucket),
4661 clib_net_to_host_u64 (mp->last_update_time),
4662 format_policer_action_type, mp->conform_action_type,
4664 format_policer_action_type, mp->exceed_action_type,
4666 format_policer_action_type, mp->violate_action_type,
4669 vec_free (conform_dscp_str);
4670 vec_free (exceed_dscp_str);
4671 vec_free (violate_dscp_str);
4674 static void vl_api_policer_details_t_handler_json
4675 (vl_api_policer_details_t * mp)
4677 vat_main_t *vam = &vat_main;
4678 vat_json_node_t *node;
4679 u8 *rate_type_str, *round_type_str, *type_str;
4680 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4682 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4684 format (0, "%U", format_policer_round_type, mp->round_type);
4685 type_str = format (0, "%U", format_policer_type, mp->type);
4686 conform_action_str = format (0, "%U", format_policer_action_type,
4687 mp->conform_action_type);
4688 exceed_action_str = format (0, "%U", format_policer_action_type,
4689 mp->exceed_action_type);
4690 violate_action_str = format (0, "%U", format_policer_action_type,
4691 mp->violate_action_type);
4693 if (VAT_JSON_ARRAY != vam->json_tree.type)
4695 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4696 vat_json_init_array (&vam->json_tree);
4698 node = vat_json_array_add (&vam->json_tree);
4700 vat_json_init_object (node);
4701 vat_json_object_add_string_copy (node, "name", mp->name);
4702 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4703 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4704 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4705 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4706 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4707 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4708 vat_json_object_add_string_copy (node, "type", type_str);
4709 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4710 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4711 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4712 vat_json_object_add_uint (node, "cir_tokens_per_period",
4713 ntohl (mp->cir_tokens_per_period));
4714 vat_json_object_add_uint (node, "eir_tokens_per_period",
4715 ntohl (mp->pir_tokens_per_period));
4716 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4717 vat_json_object_add_uint (node, "current_bucket",
4718 ntohl (mp->current_bucket));
4719 vat_json_object_add_uint (node, "extended_limit",
4720 ntohl (mp->extended_limit));
4721 vat_json_object_add_uint (node, "extended_bucket",
4722 ntohl (mp->extended_bucket));
4723 vat_json_object_add_uint (node, "last_update_time",
4724 ntohl (mp->last_update_time));
4725 vat_json_object_add_string_copy (node, "conform_action",
4726 conform_action_str);
4727 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4729 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4730 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4731 vec_free (dscp_str);
4733 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4734 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4736 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4737 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4738 vec_free (dscp_str);
4740 vat_json_object_add_string_copy (node, "violate_action",
4741 violate_action_str);
4742 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4744 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4745 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4746 vec_free (dscp_str);
4749 vec_free (rate_type_str);
4750 vec_free (round_type_str);
4751 vec_free (type_str);
4752 vec_free (conform_action_str);
4753 vec_free (exceed_action_str);
4754 vec_free (violate_action_str);
4758 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4761 vat_main_t *vam = &vat_main;
4762 int i, count = ntohl (mp->count);
4765 print (vam->ofp, "classify table ids (%d) : ", count);
4766 for (i = 0; i < count; i++)
4768 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4769 print (vam->ofp, (i < count - 1) ? "," : "");
4771 vam->retval = ntohl (mp->retval);
4772 vam->result_ready = 1;
4776 vl_api_classify_table_ids_reply_t_handler_json
4777 (vl_api_classify_table_ids_reply_t * mp)
4779 vat_main_t *vam = &vat_main;
4780 int i, count = ntohl (mp->count);
4784 vat_json_node_t node;
4786 vat_json_init_object (&node);
4787 for (i = 0; i < count; i++)
4789 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4791 vat_json_print (vam->ofp, &node);
4792 vat_json_free (&node);
4794 vam->retval = ntohl (mp->retval);
4795 vam->result_ready = 1;
4799 vl_api_classify_table_by_interface_reply_t_handler
4800 (vl_api_classify_table_by_interface_reply_t * mp)
4802 vat_main_t *vam = &vat_main;
4805 table_id = ntohl (mp->l2_table_id);
4807 print (vam->ofp, "l2 table id : %d", table_id);
4809 print (vam->ofp, "l2 table id : No input ACL tables configured");
4810 table_id = ntohl (mp->ip4_table_id);
4812 print (vam->ofp, "ip4 table id : %d", table_id);
4814 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4815 table_id = ntohl (mp->ip6_table_id);
4817 print (vam->ofp, "ip6 table id : %d", table_id);
4819 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4820 vam->retval = ntohl (mp->retval);
4821 vam->result_ready = 1;
4825 vl_api_classify_table_by_interface_reply_t_handler_json
4826 (vl_api_classify_table_by_interface_reply_t * mp)
4828 vat_main_t *vam = &vat_main;
4829 vat_json_node_t node;
4831 vat_json_init_object (&node);
4833 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4834 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4835 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4837 vat_json_print (vam->ofp, &node);
4838 vat_json_free (&node);
4840 vam->retval = ntohl (mp->retval);
4841 vam->result_ready = 1;
4844 static void vl_api_policer_add_del_reply_t_handler
4845 (vl_api_policer_add_del_reply_t * mp)
4847 vat_main_t *vam = &vat_main;
4848 i32 retval = ntohl (mp->retval);
4849 if (vam->async_mode)
4851 vam->async_errors += (retval < 0);
4855 vam->retval = retval;
4856 vam->result_ready = 1;
4857 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4859 * Note: this is just barely thread-safe, depends on
4860 * the main thread spinning waiting for an answer...
4862 errmsg ("policer index %d", ntohl (mp->policer_index));
4866 static void vl_api_policer_add_del_reply_t_handler_json
4867 (vl_api_policer_add_del_reply_t * mp)
4869 vat_main_t *vam = &vat_main;
4870 vat_json_node_t node;
4872 vat_json_init_object (&node);
4873 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4874 vat_json_object_add_uint (&node, "policer_index",
4875 ntohl (mp->policer_index));
4877 vat_json_print (vam->ofp, &node);
4878 vat_json_free (&node);
4880 vam->retval = ntohl (mp->retval);
4881 vam->result_ready = 1;
4884 /* Format hex dump. */
4886 format_hex_bytes (u8 * s, va_list * va)
4888 u8 *bytes = va_arg (*va, u8 *);
4889 int n_bytes = va_arg (*va, int);
4892 /* Print short or long form depending on byte count. */
4893 uword short_form = n_bytes <= 32;
4894 u32 indent = format_get_indent (s);
4899 for (i = 0; i < n_bytes; i++)
4901 if (!short_form && (i % 32) == 0)
4902 s = format (s, "%08x: ", i);
4903 s = format (s, "%02x", bytes[i]);
4904 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4905 s = format (s, "\n%U", format_white_space, indent);
4912 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4915 vat_main_t *vam = &vat_main;
4916 i32 retval = ntohl (mp->retval);
4919 print (vam->ofp, "classify table info :");
4920 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4921 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4922 ntohl (mp->miss_next_index));
4923 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4924 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4925 ntohl (mp->match_n_vectors));
4926 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4927 ntohl (mp->mask_length));
4929 vam->retval = retval;
4930 vam->result_ready = 1;
4934 vl_api_classify_table_info_reply_t_handler_json
4935 (vl_api_classify_table_info_reply_t * mp)
4937 vat_main_t *vam = &vat_main;
4938 vat_json_node_t node;
4940 i32 retval = ntohl (mp->retval);
4943 vat_json_init_object (&node);
4945 vat_json_object_add_int (&node, "sessions",
4946 ntohl (mp->active_sessions));
4947 vat_json_object_add_int (&node, "nexttbl",
4948 ntohl (mp->next_table_index));
4949 vat_json_object_add_int (&node, "nextnode",
4950 ntohl (mp->miss_next_index));
4951 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4952 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4953 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4954 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4955 ntohl (mp->mask_length), 0);
4956 vat_json_object_add_string_copy (&node, "mask", s);
4958 vat_json_print (vam->ofp, &node);
4959 vat_json_free (&node);
4961 vam->retval = ntohl (mp->retval);
4962 vam->result_ready = 1;
4966 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4969 vat_main_t *vam = &vat_main;
4971 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4972 ntohl (mp->hit_next_index), ntohl (mp->advance),
4973 ntohl (mp->opaque_index));
4974 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4975 ntohl (mp->match_length));
4979 vl_api_classify_session_details_t_handler_json
4980 (vl_api_classify_session_details_t * mp)
4982 vat_main_t *vam = &vat_main;
4983 vat_json_node_t *node = NULL;
4985 if (VAT_JSON_ARRAY != vam->json_tree.type)
4987 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4988 vat_json_init_array (&vam->json_tree);
4990 node = vat_json_array_add (&vam->json_tree);
4992 vat_json_init_object (node);
4993 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4994 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4995 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4997 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4999 vat_json_object_add_string_copy (node, "match", s);
5002 static void vl_api_pg_create_interface_reply_t_handler
5003 (vl_api_pg_create_interface_reply_t * mp)
5005 vat_main_t *vam = &vat_main;
5007 vam->retval = ntohl (mp->retval);
5008 vam->result_ready = 1;
5011 static void vl_api_pg_create_interface_reply_t_handler_json
5012 (vl_api_pg_create_interface_reply_t * mp)
5014 vat_main_t *vam = &vat_main;
5015 vat_json_node_t node;
5017 i32 retval = ntohl (mp->retval);
5020 vat_json_init_object (&node);
5022 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5024 vat_json_print (vam->ofp, &node);
5025 vat_json_free (&node);
5027 vam->retval = ntohl (mp->retval);
5028 vam->result_ready = 1;
5031 static void vl_api_policer_classify_details_t_handler
5032 (vl_api_policer_classify_details_t * mp)
5034 vat_main_t *vam = &vat_main;
5036 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5037 ntohl (mp->table_index));
5040 static void vl_api_policer_classify_details_t_handler_json
5041 (vl_api_policer_classify_details_t * mp)
5043 vat_main_t *vam = &vat_main;
5044 vat_json_node_t *node;
5046 if (VAT_JSON_ARRAY != vam->json_tree.type)
5048 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5049 vat_json_init_array (&vam->json_tree);
5051 node = vat_json_array_add (&vam->json_tree);
5053 vat_json_init_object (node);
5054 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5055 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5058 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5059 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5061 vat_main_t *vam = &vat_main;
5062 i32 retval = ntohl (mp->retval);
5063 if (vam->async_mode)
5065 vam->async_errors += (retval < 0);
5069 vam->retval = retval;
5070 vam->sw_if_index = ntohl (mp->sw_if_index);
5071 vam->result_ready = 1;
5073 vam->regenerate_interface_table = 1;
5076 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5077 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5079 vat_main_t *vam = &vat_main;
5080 vat_json_node_t node;
5082 vat_json_init_object (&node);
5083 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5084 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5086 vat_json_print (vam->ofp, &node);
5087 vat_json_free (&node);
5089 vam->retval = ntohl (mp->retval);
5090 vam->result_ready = 1;
5093 static void vl_api_flow_classify_details_t_handler
5094 (vl_api_flow_classify_details_t * mp)
5096 vat_main_t *vam = &vat_main;
5098 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5099 ntohl (mp->table_index));
5102 static void vl_api_flow_classify_details_t_handler_json
5103 (vl_api_flow_classify_details_t * mp)
5105 vat_main_t *vam = &vat_main;
5106 vat_json_node_t *node;
5108 if (VAT_JSON_ARRAY != vam->json_tree.type)
5110 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5111 vat_json_init_array (&vam->json_tree);
5113 node = vat_json_array_add (&vam->json_tree);
5115 vat_json_init_object (node);
5116 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5117 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5120 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5121 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5122 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5123 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5124 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5125 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5126 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5127 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5128 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5129 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5132 * Generate boilerplate reply handlers, which
5133 * dig the return value out of the xxx_reply_t API message,
5134 * stick it into vam->retval, and set vam->result_ready
5136 * Could also do this by pointing N message decode slots at
5137 * a single function, but that could break in subtle ways.
5140 #define foreach_standard_reply_retval_handler \
5141 _(sw_interface_set_flags_reply) \
5142 _(sw_interface_add_del_address_reply) \
5143 _(sw_interface_set_rx_mode_reply) \
5144 _(sw_interface_set_rx_placement_reply) \
5145 _(sw_interface_set_table_reply) \
5146 _(sw_interface_set_mpls_enable_reply) \
5147 _(sw_interface_set_vpath_reply) \
5148 _(sw_interface_set_vxlan_bypass_reply) \
5149 _(sw_interface_set_geneve_bypass_reply) \
5150 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5151 _(sw_interface_set_l2_bridge_reply) \
5152 _(bridge_domain_add_del_reply) \
5153 _(sw_interface_set_l2_xconnect_reply) \
5154 _(l2fib_add_del_reply) \
5155 _(l2fib_flush_int_reply) \
5156 _(l2fib_flush_bd_reply) \
5157 _(ip_add_del_route_reply) \
5158 _(ip_table_add_del_reply) \
5159 _(ip_mroute_add_del_reply) \
5160 _(mpls_route_add_del_reply) \
5161 _(mpls_table_add_del_reply) \
5162 _(mpls_ip_bind_unbind_reply) \
5163 _(bier_route_add_del_reply) \
5164 _(bier_table_add_del_reply) \
5165 _(proxy_arp_add_del_reply) \
5166 _(proxy_arp_intfc_enable_disable_reply) \
5167 _(sw_interface_set_unnumbered_reply) \
5168 _(ip_neighbor_add_del_reply) \
5169 _(oam_add_del_reply) \
5170 _(reset_fib_reply) \
5171 _(dhcp_proxy_config_reply) \
5172 _(dhcp_proxy_set_vss_reply) \
5173 _(dhcp_client_config_reply) \
5174 _(set_ip_flow_hash_reply) \
5175 _(sw_interface_ip6_enable_disable_reply) \
5176 _(ip6nd_proxy_add_del_reply) \
5177 _(sw_interface_ip6nd_ra_prefix_reply) \
5178 _(sw_interface_ip6nd_ra_config_reply) \
5179 _(set_arp_neighbor_limit_reply) \
5180 _(l2_patch_add_del_reply) \
5181 _(sr_mpls_policy_add_reply) \
5182 _(sr_mpls_policy_mod_reply) \
5183 _(sr_mpls_policy_del_reply) \
5184 _(sr_policy_add_reply) \
5185 _(sr_policy_mod_reply) \
5186 _(sr_policy_del_reply) \
5187 _(sr_localsid_add_del_reply) \
5188 _(sr_steering_add_del_reply) \
5189 _(classify_add_del_session_reply) \
5190 _(classify_set_interface_ip_table_reply) \
5191 _(classify_set_interface_l2_tables_reply) \
5192 _(l2tpv3_set_tunnel_cookies_reply) \
5193 _(l2tpv3_interface_enable_disable_reply) \
5194 _(l2tpv3_set_lookup_key_reply) \
5195 _(l2_fib_clear_table_reply) \
5196 _(l2_interface_efp_filter_reply) \
5197 _(l2_interface_vlan_tag_rewrite_reply) \
5198 _(modify_vhost_user_if_reply) \
5199 _(delete_vhost_user_if_reply) \
5200 _(ip_probe_neighbor_reply) \
5201 _(ip_scan_neighbor_enable_disable_reply) \
5202 _(want_ip4_arp_events_reply) \
5203 _(want_ip6_nd_events_reply) \
5204 _(want_l2_macs_events_reply) \
5205 _(input_acl_set_interface_reply) \
5206 _(ipsec_spd_add_del_reply) \
5207 _(ipsec_interface_add_del_spd_reply) \
5208 _(ipsec_spd_add_del_entry_reply) \
5209 _(ipsec_sad_add_del_entry_reply) \
5210 _(ipsec_sa_set_key_reply) \
5211 _(ipsec_tunnel_if_add_del_reply) \
5212 _(ipsec_tunnel_if_set_key_reply) \
5213 _(ipsec_tunnel_if_set_sa_reply) \
5214 _(ikev2_profile_add_del_reply) \
5215 _(ikev2_profile_set_auth_reply) \
5216 _(ikev2_profile_set_id_reply) \
5217 _(ikev2_profile_set_ts_reply) \
5218 _(ikev2_set_local_key_reply) \
5219 _(ikev2_set_responder_reply) \
5220 _(ikev2_set_ike_transforms_reply) \
5221 _(ikev2_set_esp_transforms_reply) \
5222 _(ikev2_set_sa_lifetime_reply) \
5223 _(ikev2_initiate_sa_init_reply) \
5224 _(ikev2_initiate_del_ike_sa_reply) \
5225 _(ikev2_initiate_del_child_sa_reply) \
5226 _(ikev2_initiate_rekey_child_sa_reply) \
5227 _(delete_loopback_reply) \
5228 _(bd_ip_mac_add_del_reply) \
5229 _(bd_ip_mac_flush_reply) \
5230 _(want_interface_events_reply) \
5231 _(cop_interface_enable_disable_reply) \
5232 _(cop_whitelist_enable_disable_reply) \
5233 _(sw_interface_clear_stats_reply) \
5234 _(ioam_enable_reply) \
5235 _(ioam_disable_reply) \
5236 _(one_add_del_locator_reply) \
5237 _(one_add_del_local_eid_reply) \
5238 _(one_add_del_remote_mapping_reply) \
5239 _(one_add_del_adjacency_reply) \
5240 _(one_add_del_map_resolver_reply) \
5241 _(one_add_del_map_server_reply) \
5242 _(one_enable_disable_reply) \
5243 _(one_rloc_probe_enable_disable_reply) \
5244 _(one_map_register_enable_disable_reply) \
5245 _(one_map_register_set_ttl_reply) \
5246 _(one_set_transport_protocol_reply) \
5247 _(one_map_register_fallback_threshold_reply) \
5248 _(one_pitr_set_locator_set_reply) \
5249 _(one_map_request_mode_reply) \
5250 _(one_add_del_map_request_itr_rlocs_reply) \
5251 _(one_eid_table_add_del_map_reply) \
5252 _(one_use_petr_reply) \
5253 _(one_stats_enable_disable_reply) \
5254 _(one_add_del_l2_arp_entry_reply) \
5255 _(one_add_del_ndp_entry_reply) \
5256 _(one_stats_flush_reply) \
5257 _(one_enable_disable_xtr_mode_reply) \
5258 _(one_enable_disable_pitr_mode_reply) \
5259 _(one_enable_disable_petr_mode_reply) \
5260 _(gpe_enable_disable_reply) \
5261 _(gpe_set_encap_mode_reply) \
5262 _(gpe_add_del_iface_reply) \
5263 _(gpe_add_del_native_fwd_rpath_reply) \
5264 _(af_packet_delete_reply) \
5265 _(policer_classify_set_interface_reply) \
5266 _(netmap_create_reply) \
5267 _(netmap_delete_reply) \
5268 _(set_ipfix_exporter_reply) \
5269 _(set_ipfix_classify_stream_reply) \
5270 _(ipfix_classify_table_add_del_reply) \
5271 _(flow_classify_set_interface_reply) \
5272 _(sw_interface_span_enable_disable_reply) \
5273 _(pg_capture_reply) \
5274 _(pg_enable_disable_reply) \
5275 _(ip_source_and_port_range_check_add_del_reply) \
5276 _(ip_source_and_port_range_check_interface_add_del_reply)\
5277 _(delete_subif_reply) \
5278 _(l2_interface_pbb_tag_rewrite_reply) \
5280 _(feature_enable_disable_reply) \
5281 _(sw_interface_tag_add_del_reply) \
5282 _(hw_interface_set_mtu_reply) \
5283 _(p2p_ethernet_add_reply) \
5284 _(p2p_ethernet_del_reply) \
5285 _(lldp_config_reply) \
5286 _(sw_interface_set_lldp_reply) \
5287 _(tcp_configure_src_addresses_reply) \
5288 _(dns_enable_disable_reply) \
5289 _(dns_name_server_add_del_reply) \
5290 _(session_rule_add_del_reply) \
5291 _(ip_container_proxy_add_del_reply) \
5292 _(output_acl_set_interface_reply) \
5293 _(qos_record_enable_disable_reply)
5296 static void vl_api_##n##_t_handler \
5297 (vl_api_##n##_t * mp) \
5299 vat_main_t * vam = &vat_main; \
5300 i32 retval = ntohl(mp->retval); \
5301 if (vam->async_mode) { \
5302 vam->async_errors += (retval < 0); \
5304 vam->retval = retval; \
5305 vam->result_ready = 1; \
5308 foreach_standard_reply_retval_handler;
5312 static void vl_api_##n##_t_handler_json \
5313 (vl_api_##n##_t * mp) \
5315 vat_main_t * vam = &vat_main; \
5316 vat_json_node_t node; \
5317 vat_json_init_object(&node); \
5318 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5319 vat_json_print(vam->ofp, &node); \
5320 vam->retval = ntohl(mp->retval); \
5321 vam->result_ready = 1; \
5323 foreach_standard_reply_retval_handler;
5327 * Table of message reply handlers, must include boilerplate handlers
5331 #define foreach_vpe_api_reply_msg \
5332 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5333 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5334 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5335 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5336 _(CONTROL_PING_REPLY, control_ping_reply) \
5337 _(CLI_REPLY, cli_reply) \
5338 _(CLI_INBAND_REPLY, cli_inband_reply) \
5339 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5340 sw_interface_add_del_address_reply) \
5341 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5342 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5343 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5344 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5345 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5346 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5347 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5348 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5349 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5350 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5351 sw_interface_set_l2_xconnect_reply) \
5352 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5353 sw_interface_set_l2_bridge_reply) \
5354 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5355 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5356 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5357 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5358 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5359 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5360 _(L2_FLAGS_REPLY, l2_flags_reply) \
5361 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5362 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5363 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5364 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5365 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5366 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5367 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5368 _(BOND_CREATE_REPLY, bond_create_reply) \
5369 _(BOND_DELETE_REPLY, bond_delete_reply) \
5370 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5371 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5372 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5373 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5374 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5375 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5376 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5377 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5378 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5379 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5380 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5381 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5382 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5383 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5384 proxy_arp_intfc_enable_disable_reply) \
5385 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5386 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5387 sw_interface_set_unnumbered_reply) \
5388 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5389 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5390 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5391 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5392 _(RESET_FIB_REPLY, reset_fib_reply) \
5393 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5394 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5395 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5396 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5397 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5398 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5399 sw_interface_ip6_enable_disable_reply) \
5400 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5401 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5402 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5403 sw_interface_ip6nd_ra_prefix_reply) \
5404 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5405 sw_interface_ip6nd_ra_config_reply) \
5406 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5407 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5408 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5409 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5410 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5411 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5412 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5413 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5414 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5415 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5416 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5417 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5418 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5419 classify_set_interface_ip_table_reply) \
5420 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5421 classify_set_interface_l2_tables_reply) \
5422 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5423 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5424 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5425 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5426 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5427 l2tpv3_interface_enable_disable_reply) \
5428 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5429 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5430 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5431 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5432 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5433 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5434 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5435 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5436 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5437 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5438 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5439 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5440 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5441 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5442 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5443 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5444 _(SHOW_VERSION_REPLY, show_version_reply) \
5445 _(SHOW_THREADS_REPLY, show_threads_reply) \
5446 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5447 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5448 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5449 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5450 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5451 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5452 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5453 _(IP4_ARP_EVENT, ip4_arp_event) \
5454 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5455 _(IP6_ND_EVENT, ip6_nd_event) \
5456 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5457 _(L2_MACS_EVENT, l2_macs_event) \
5458 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5459 _(IP_ADDRESS_DETAILS, ip_address_details) \
5460 _(IP_DETAILS, ip_details) \
5461 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5462 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5463 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5464 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5465 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5466 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5467 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5468 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5469 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5470 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5471 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5472 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5473 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5474 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5475 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5476 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5477 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5478 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5479 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5480 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5481 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5482 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5483 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5484 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5485 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5486 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5487 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5488 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5489 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5490 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5491 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5492 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5493 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5494 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5495 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5496 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5497 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5498 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5499 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5500 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5501 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5502 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5503 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5504 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5505 one_map_register_enable_disable_reply) \
5506 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5507 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5508 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5509 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5510 one_map_register_fallback_threshold_reply) \
5511 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5512 one_rloc_probe_enable_disable_reply) \
5513 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5514 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5515 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5516 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5517 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5518 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5519 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5520 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5521 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5522 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5523 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5524 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5525 _(ONE_STATS_DETAILS, one_stats_details) \
5526 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5527 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5528 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5529 show_one_stats_enable_disable_reply) \
5530 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5531 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5532 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5533 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5534 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5535 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5536 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5537 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5538 one_enable_disable_pitr_mode_reply) \
5539 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5540 one_enable_disable_petr_mode_reply) \
5541 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5542 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5543 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5544 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5545 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5546 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5547 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5548 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5549 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5550 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5551 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5552 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5553 gpe_add_del_native_fwd_rpath_reply) \
5554 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5555 gpe_fwd_entry_path_details) \
5556 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5557 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5558 one_add_del_map_request_itr_rlocs_reply) \
5559 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5560 one_get_map_request_itr_rlocs_reply) \
5561 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5562 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5563 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5564 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5565 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5566 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5567 show_one_map_register_state_reply) \
5568 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5569 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5570 show_one_map_register_fallback_threshold_reply) \
5571 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5572 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5573 _(AF_PACKET_DETAILS, af_packet_details) \
5574 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5575 _(POLICER_DETAILS, policer_details) \
5576 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5577 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5578 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5579 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5580 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5581 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5582 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5583 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5584 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5585 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5586 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5587 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5588 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5589 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5590 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5591 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5592 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5593 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5594 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5595 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5596 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5597 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5598 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5599 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5600 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5601 ip_source_and_port_range_check_add_del_reply) \
5602 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5603 ip_source_and_port_range_check_interface_add_del_reply) \
5604 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5605 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5606 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5607 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5608 _(SET_PUNT_REPLY, set_punt_reply) \
5609 _(IP_FIB_DETAILS, ip_fib_details) \
5610 _(IP6_FIB_DETAILS, ip6_fib_details) \
5611 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5612 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5613 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5614 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5615 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5616 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5617 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5618 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5619 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5620 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5621 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5622 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5623 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5624 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5625 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5626 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5627 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5628 _(SESSION_RULES_DETAILS, session_rules_details) \
5629 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5630 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5631 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5633 #define foreach_standalone_reply_msg \
5634 _(SW_INTERFACE_EVENT, sw_interface_event)
5642 #define STR_VTR_OP_CASE(op) \
5643 case L2_VTR_ ## op: \
5647 str_vtr_op (u32 vtr_op)
5651 STR_VTR_OP_CASE (DISABLED);
5652 STR_VTR_OP_CASE (PUSH_1);
5653 STR_VTR_OP_CASE (PUSH_2);
5654 STR_VTR_OP_CASE (POP_1);
5655 STR_VTR_OP_CASE (POP_2);
5656 STR_VTR_OP_CASE (TRANSLATE_1_1);
5657 STR_VTR_OP_CASE (TRANSLATE_1_2);
5658 STR_VTR_OP_CASE (TRANSLATE_2_1);
5659 STR_VTR_OP_CASE (TRANSLATE_2_2);
5666 dump_sub_interface_table (vat_main_t * vam)
5668 const sw_interface_subif_t *sub = NULL;
5670 if (vam->json_output)
5673 ("JSON output supported only for VPE API calls and dump_stats_table");
5678 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5679 "Interface", "sw_if_index",
5680 "sub id", "dot1ad", "tags", "outer id",
5681 "inner id", "exact", "default", "outer any", "inner any");
5683 vec_foreach (sub, vam->sw_if_subif_table)
5686 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5687 sub->interface_name,
5689 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5690 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5691 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5692 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5693 if (sub->vtr_op != L2_VTR_DISABLED)
5696 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5697 "tag1: %d tag2: %d ]",
5698 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5699 sub->vtr_tag1, sub->vtr_tag2);
5707 name_sort_cmp (void *a1, void *a2)
5709 name_sort_t *n1 = a1;
5710 name_sort_t *n2 = a2;
5712 return strcmp ((char *) n1->name, (char *) n2->name);
5716 dump_interface_table (vat_main_t * vam)
5719 name_sort_t *nses = 0, *ns;
5721 if (vam->json_output)
5724 ("JSON output supported only for VPE API calls and dump_stats_table");
5729 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5731 vec_add2 (nses, ns, 1);
5732 ns->name = (u8 *)(p->key);
5733 ns->value = (u32) p->value[0];
5737 vec_sort_with_function (nses, name_sort_cmp);
5739 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5740 vec_foreach (ns, nses)
5742 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5749 dump_ip_table (vat_main_t * vam, int is_ipv6)
5751 const ip_details_t *det = NULL;
5752 const ip_address_details_t *address = NULL;
5755 print (vam->ofp, "%-12s", "sw_if_index");
5757 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5764 print (vam->ofp, "%-12d", i);
5765 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5770 vec_foreach (address, det->addr)
5774 is_ipv6 ? format_ip6_address : format_ip4_address,
5775 address->ip, address->prefix_length);
5783 dump_ipv4_table (vat_main_t * vam)
5785 if (vam->json_output)
5788 ("JSON output supported only for VPE API calls and dump_stats_table");
5792 return dump_ip_table (vam, 0);
5796 dump_ipv6_table (vat_main_t * vam)
5798 if (vam->json_output)
5801 ("JSON output supported only for VPE API calls and dump_stats_table");
5805 return dump_ip_table (vam, 1);
5809 * Pass CLI buffers directly in the CLI_INBAND API message,
5810 * instead of an additional shared memory area.
5813 exec_inband (vat_main_t * vam)
5815 vl_api_cli_inband_t *mp;
5816 unformat_input_t *i = vam->input;
5819 if (vec_len (i->buffer) == 0)
5822 if (vam->exec_mode == 0 && unformat (i, "mode"))
5827 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5834 * In order for the CLI command to work, it
5835 * must be a vector ending in \n, not a C-string ending
5838 u32 len = vec_len (vam->input->buffer);
5839 M2 (CLI_INBAND, mp, len);
5840 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5844 /* json responses may or may not include a useful reply... */
5845 if (vec_len (vam->cmd_reply))
5846 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5851 exec (vat_main_t * vam)
5853 return exec_inband (vam);
5857 api_create_loopback (vat_main_t * vam)
5859 unformat_input_t *i = vam->input;
5860 vl_api_create_loopback_t *mp;
5861 vl_api_create_loopback_instance_t *mp_lbi;
5864 u8 is_specified = 0;
5865 u32 user_instance = 0;
5868 clib_memset (mac_address, 0, sizeof (mac_address));
5870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5872 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5874 if (unformat (i, "instance %d", &user_instance))
5882 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5883 mp_lbi->is_specified = is_specified;
5885 mp_lbi->user_instance = htonl (user_instance);
5887 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5892 /* Construct the API message */
5893 M (CREATE_LOOPBACK, mp);
5895 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5904 api_delete_loopback (vat_main_t * vam)
5906 unformat_input_t *i = vam->input;
5907 vl_api_delete_loopback_t *mp;
5908 u32 sw_if_index = ~0;
5911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5913 if (unformat (i, "sw_if_index %d", &sw_if_index))
5919 if (sw_if_index == ~0)
5921 errmsg ("missing sw_if_index");
5925 /* Construct the API message */
5926 M (DELETE_LOOPBACK, mp);
5927 mp->sw_if_index = ntohl (sw_if_index);
5935 api_want_interface_events (vat_main_t * vam)
5937 unformat_input_t *i = vam->input;
5938 vl_api_want_interface_events_t *mp;
5942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5944 if (unformat (i, "enable"))
5946 else if (unformat (i, "disable"))
5954 errmsg ("missing enable|disable");
5958 M (WANT_INTERFACE_EVENTS, mp);
5959 mp->enable_disable = enable;
5961 vam->interface_event_display = enable;
5969 /* Note: non-static, called once to set up the initial intfc table */
5971 api_sw_interface_dump (vat_main_t * vam)
5973 vl_api_sw_interface_dump_t *mp;
5974 vl_api_control_ping_t *mp_ping;
5976 name_sort_t *nses = 0, *ns;
5977 sw_interface_subif_t *sub = NULL;
5980 /* Toss the old name table */
5982 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5984 vec_add2 (nses, ns, 1);
5985 ns->name = (u8 *)(p->key);
5986 ns->value = (u32) p->value[0];
5990 hash_free (vam->sw_if_index_by_interface_name);
5992 vec_foreach (ns, nses) vec_free (ns->name);
5996 vec_foreach (sub, vam->sw_if_subif_table)
5998 vec_free (sub->interface_name);
6000 vec_free (vam->sw_if_subif_table);
6002 /* recreate the interface name hash table */
6003 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6006 * Ask for all interface names. Otherwise, the epic catalog of
6007 * name filters becomes ridiculously long, and vat ends up needing
6008 * to be taught about new interface types.
6010 M (SW_INTERFACE_DUMP, mp);
6013 /* Use a control ping for synchronization */
6014 MPING (CONTROL_PING, mp_ping);
6022 api_sw_interface_set_flags (vat_main_t * vam)
6024 unformat_input_t *i = vam->input;
6025 vl_api_sw_interface_set_flags_t *mp;
6027 u8 sw_if_index_set = 0;
6031 /* Parse args required to build the message */
6032 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6034 if (unformat (i, "admin-up"))
6036 else if (unformat (i, "admin-down"))
6039 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6040 sw_if_index_set = 1;
6041 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6042 sw_if_index_set = 1;
6047 if (sw_if_index_set == 0)
6049 errmsg ("missing interface name or sw_if_index");
6053 /* Construct the API message */
6054 M (SW_INTERFACE_SET_FLAGS, mp);
6055 mp->sw_if_index = ntohl (sw_if_index);
6056 mp->admin_up_down = admin_up;
6061 /* Wait for a reply, return the good/bad news... */
6067 api_sw_interface_set_rx_mode (vat_main_t * vam)
6069 unformat_input_t *i = vam->input;
6070 vl_api_sw_interface_set_rx_mode_t *mp;
6072 u8 sw_if_index_set = 0;
6074 u8 queue_id_valid = 0;
6076 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6078 /* Parse args required to build the message */
6079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6081 if (unformat (i, "queue %d", &queue_id))
6083 else if (unformat (i, "polling"))
6084 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6085 else if (unformat (i, "interrupt"))
6086 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6087 else if (unformat (i, "adaptive"))
6088 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6090 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6091 sw_if_index_set = 1;
6092 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6093 sw_if_index_set = 1;
6098 if (sw_if_index_set == 0)
6100 errmsg ("missing interface name or sw_if_index");
6103 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6105 errmsg ("missing rx-mode");
6109 /* Construct the API message */
6110 M (SW_INTERFACE_SET_RX_MODE, mp);
6111 mp->sw_if_index = ntohl (sw_if_index);
6113 mp->queue_id_valid = queue_id_valid;
6114 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6119 /* Wait for a reply, return the good/bad news... */
6125 api_sw_interface_set_rx_placement (vat_main_t * vam)
6127 unformat_input_t *i = vam->input;
6128 vl_api_sw_interface_set_rx_placement_t *mp;
6130 u8 sw_if_index_set = 0;
6133 u32 queue_id, thread_index;
6135 /* Parse args required to build the message */
6136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6138 if (unformat (i, "queue %d", &queue_id))
6140 else if (unformat (i, "main"))
6142 else if (unformat (i, "worker %d", &thread_index))
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");
6161 /* Construct the API message */
6162 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6163 mp->sw_if_index = ntohl (sw_if_index);
6164 mp->worker_id = ntohl (thread_index);
6165 mp->queue_id = ntohl (queue_id);
6166 mp->is_main = is_main;
6170 /* Wait for a reply, return the good/bad news... */
6175 static void vl_api_sw_interface_rx_placement_details_t_handler
6176 (vl_api_sw_interface_rx_placement_details_t * mp)
6178 vat_main_t *vam = &vat_main;
6179 u32 worker_id = ntohl (mp->worker_id);
6182 "\n%-11d %-11s %-6d %-5d %-9s",
6183 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6184 worker_id, ntohl (mp->queue_id),
6186 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6189 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6190 (vl_api_sw_interface_rx_placement_details_t * mp)
6192 vat_main_t *vam = &vat_main;
6193 vat_json_node_t *node = NULL;
6195 if (VAT_JSON_ARRAY != vam->json_tree.type)
6197 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6198 vat_json_init_array (&vam->json_tree);
6200 node = vat_json_array_add (&vam->json_tree);
6202 vat_json_init_object (node);
6203 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6204 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6205 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6206 vat_json_object_add_uint (node, "mode", mp->mode);
6210 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6212 unformat_input_t *i = vam->input;
6213 vl_api_sw_interface_rx_placement_dump_t *mp;
6214 vl_api_control_ping_t *mp_ping;
6217 u8 sw_if_index_set = 0;
6219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6221 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6223 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6230 "\n%-11s %-11s %-6s %-5s %-4s",
6231 "sw_if_index", "main/worker", "thread", "queue", "mode");
6233 /* Dump Interface rx placement */
6234 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6236 if (sw_if_index_set)
6237 mp->sw_if_index = htonl (sw_if_index);
6239 mp->sw_if_index = ~0;
6243 /* Use a control ping for synchronization */
6244 MPING (CONTROL_PING, mp_ping);
6252 api_sw_interface_clear_stats (vat_main_t * vam)
6254 unformat_input_t *i = vam->input;
6255 vl_api_sw_interface_clear_stats_t *mp;
6257 u8 sw_if_index_set = 0;
6260 /* Parse args required to build the message */
6261 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6263 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6264 sw_if_index_set = 1;
6265 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6266 sw_if_index_set = 1;
6271 /* Construct the API message */
6272 M (SW_INTERFACE_CLEAR_STATS, mp);
6274 if (sw_if_index_set == 1)
6275 mp->sw_if_index = ntohl (sw_if_index);
6277 mp->sw_if_index = ~0;
6282 /* Wait for a reply, return the good/bad news... */
6288 api_sw_interface_add_del_address (vat_main_t * vam)
6290 unformat_input_t *i = vam->input;
6291 vl_api_sw_interface_add_del_address_t *mp;
6293 u8 sw_if_index_set = 0;
6294 u8 is_add = 1, del_all = 0;
6295 u32 address_length = 0;
6296 u8 v4_address_set = 0;
6297 u8 v6_address_set = 0;
6298 ip4_address_t v4address;
6299 ip6_address_t v6address;
6302 /* Parse args required to build the message */
6303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6305 if (unformat (i, "del-all"))
6307 else if (unformat (i, "del"))
6310 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6311 sw_if_index_set = 1;
6312 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6313 sw_if_index_set = 1;
6314 else if (unformat (i, "%U/%d",
6315 unformat_ip4_address, &v4address, &address_length))
6317 else if (unformat (i, "%U/%d",
6318 unformat_ip6_address, &v6address, &address_length))
6324 if (sw_if_index_set == 0)
6326 errmsg ("missing interface name or sw_if_index");
6329 if (v4_address_set && v6_address_set)
6331 errmsg ("both v4 and v6 addresses set");
6334 if (!v4_address_set && !v6_address_set && !del_all)
6336 errmsg ("no addresses set");
6340 /* Construct the API message */
6341 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6343 mp->sw_if_index = ntohl (sw_if_index);
6344 mp->is_add = is_add;
6345 mp->del_all = del_all;
6349 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6353 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6355 mp->address_length = address_length;
6360 /* Wait for a reply, return good/bad news */
6366 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6368 unformat_input_t *i = vam->input;
6369 vl_api_sw_interface_set_mpls_enable_t *mp;
6371 u8 sw_if_index_set = 0;
6375 /* Parse args required to build the message */
6376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6378 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6379 sw_if_index_set = 1;
6380 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6381 sw_if_index_set = 1;
6382 else if (unformat (i, "disable"))
6384 else if (unformat (i, "dis"))
6390 if (sw_if_index_set == 0)
6392 errmsg ("missing interface name or sw_if_index");
6396 /* Construct the API message */
6397 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6399 mp->sw_if_index = ntohl (sw_if_index);
6400 mp->enable = enable;
6405 /* Wait for a reply... */
6411 api_sw_interface_set_table (vat_main_t * vam)
6413 unformat_input_t *i = vam->input;
6414 vl_api_sw_interface_set_table_t *mp;
6415 u32 sw_if_index, vrf_id = 0;
6416 u8 sw_if_index_set = 0;
6420 /* Parse args required to build the message */
6421 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6423 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6424 sw_if_index_set = 1;
6425 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6426 sw_if_index_set = 1;
6427 else if (unformat (i, "vrf %d", &vrf_id))
6429 else if (unformat (i, "ipv6"))
6435 if (sw_if_index_set == 0)
6437 errmsg ("missing interface name or sw_if_index");
6441 /* Construct the API message */
6442 M (SW_INTERFACE_SET_TABLE, mp);
6444 mp->sw_if_index = ntohl (sw_if_index);
6445 mp->is_ipv6 = is_ipv6;
6446 mp->vrf_id = ntohl (vrf_id);
6451 /* Wait for a reply... */
6456 static void vl_api_sw_interface_get_table_reply_t_handler
6457 (vl_api_sw_interface_get_table_reply_t * mp)
6459 vat_main_t *vam = &vat_main;
6461 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6463 vam->retval = ntohl (mp->retval);
6464 vam->result_ready = 1;
6468 static void vl_api_sw_interface_get_table_reply_t_handler_json
6469 (vl_api_sw_interface_get_table_reply_t * mp)
6471 vat_main_t *vam = &vat_main;
6472 vat_json_node_t node;
6474 vat_json_init_object (&node);
6475 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6476 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6478 vat_json_print (vam->ofp, &node);
6479 vat_json_free (&node);
6481 vam->retval = ntohl (mp->retval);
6482 vam->result_ready = 1;
6486 api_sw_interface_get_table (vat_main_t * vam)
6488 unformat_input_t *i = vam->input;
6489 vl_api_sw_interface_get_table_t *mp;
6491 u8 sw_if_index_set = 0;
6495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6497 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6498 sw_if_index_set = 1;
6499 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6500 sw_if_index_set = 1;
6501 else if (unformat (i, "ipv6"))
6507 if (sw_if_index_set == 0)
6509 errmsg ("missing interface name or sw_if_index");
6513 M (SW_INTERFACE_GET_TABLE, mp);
6514 mp->sw_if_index = htonl (sw_if_index);
6515 mp->is_ipv6 = is_ipv6;
6523 api_sw_interface_set_vpath (vat_main_t * vam)
6525 unformat_input_t *i = vam->input;
6526 vl_api_sw_interface_set_vpath_t *mp;
6527 u32 sw_if_index = 0;
6528 u8 sw_if_index_set = 0;
6532 /* Parse args required to build the message */
6533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6535 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6536 sw_if_index_set = 1;
6537 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6538 sw_if_index_set = 1;
6539 else if (unformat (i, "enable"))
6541 else if (unformat (i, "disable"))
6547 if (sw_if_index_set == 0)
6549 errmsg ("missing interface name or sw_if_index");
6553 /* Construct the API message */
6554 M (SW_INTERFACE_SET_VPATH, mp);
6556 mp->sw_if_index = ntohl (sw_if_index);
6557 mp->enable = is_enable;
6562 /* Wait for a reply... */
6568 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6570 unformat_input_t *i = vam->input;
6571 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6572 u32 sw_if_index = 0;
6573 u8 sw_if_index_set = 0;
6578 /* Parse args required to build the message */
6579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6581 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6582 sw_if_index_set = 1;
6583 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6584 sw_if_index_set = 1;
6585 else if (unformat (i, "enable"))
6587 else if (unformat (i, "disable"))
6589 else if (unformat (i, "ip4"))
6591 else if (unformat (i, "ip6"))
6597 if (sw_if_index_set == 0)
6599 errmsg ("missing interface name or sw_if_index");
6603 /* Construct the API message */
6604 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6606 mp->sw_if_index = ntohl (sw_if_index);
6607 mp->enable = is_enable;
6608 mp->is_ipv6 = is_ipv6;
6613 /* Wait for a reply... */
6619 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6621 unformat_input_t *i = vam->input;
6622 vl_api_sw_interface_set_geneve_bypass_t *mp;
6623 u32 sw_if_index = 0;
6624 u8 sw_if_index_set = 0;
6629 /* Parse args required to build the message */
6630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6632 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6633 sw_if_index_set = 1;
6634 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6635 sw_if_index_set = 1;
6636 else if (unformat (i, "enable"))
6638 else if (unformat (i, "disable"))
6640 else if (unformat (i, "ip4"))
6642 else if (unformat (i, "ip6"))
6648 if (sw_if_index_set == 0)
6650 errmsg ("missing interface name or sw_if_index");
6654 /* Construct the API message */
6655 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6657 mp->sw_if_index = ntohl (sw_if_index);
6658 mp->enable = is_enable;
6659 mp->is_ipv6 = is_ipv6;
6664 /* Wait for a reply... */
6670 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6672 unformat_input_t *i = vam->input;
6673 vl_api_sw_interface_set_l2_xconnect_t *mp;
6675 u8 rx_sw_if_index_set = 0;
6677 u8 tx_sw_if_index_set = 0;
6681 /* Parse args required to build the message */
6682 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6684 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6685 rx_sw_if_index_set = 1;
6686 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6687 tx_sw_if_index_set = 1;
6688 else if (unformat (i, "rx"))
6690 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6692 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6694 rx_sw_if_index_set = 1;
6699 else if (unformat (i, "tx"))
6701 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6703 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6705 tx_sw_if_index_set = 1;
6710 else if (unformat (i, "enable"))
6712 else if (unformat (i, "disable"))
6718 if (rx_sw_if_index_set == 0)
6720 errmsg ("missing rx interface name or rx_sw_if_index");
6724 if (enable && (tx_sw_if_index_set == 0))
6726 errmsg ("missing tx interface name or tx_sw_if_index");
6730 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6732 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6733 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6734 mp->enable = enable;
6742 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6744 unformat_input_t *i = vam->input;
6745 vl_api_sw_interface_set_l2_bridge_t *mp;
6746 vl_api_l2_port_type_t port_type;
6748 u8 rx_sw_if_index_set = 0;
6755 port_type = L2_API_PORT_TYPE_NORMAL;
6757 /* Parse args required to build the message */
6758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6760 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6761 rx_sw_if_index_set = 1;
6762 else if (unformat (i, "bd_id %d", &bd_id))
6766 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6767 rx_sw_if_index_set = 1;
6768 else if (unformat (i, "shg %d", &shg))
6770 else if (unformat (i, "bvi"))
6771 port_type = L2_API_PORT_TYPE_BVI;
6772 else if (unformat (i, "uu-fwd"))
6773 port_type = L2_API_PORT_TYPE_UU_FWD;
6774 else if (unformat (i, "enable"))
6776 else if (unformat (i, "disable"))
6782 if (rx_sw_if_index_set == 0)
6784 errmsg ("missing rx interface name or sw_if_index");
6788 if (enable && (bd_id_set == 0))
6790 errmsg ("missing bridge domain");
6794 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6796 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6797 mp->bd_id = ntohl (bd_id);
6799 mp->port_type = ntohl (port_type);
6800 mp->enable = enable;
6808 api_bridge_domain_dump (vat_main_t * vam)
6810 unformat_input_t *i = vam->input;
6811 vl_api_bridge_domain_dump_t *mp;
6812 vl_api_control_ping_t *mp_ping;
6816 /* Parse args required to build the message */
6817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6819 if (unformat (i, "bd_id %d", &bd_id))
6825 M (BRIDGE_DOMAIN_DUMP, mp);
6826 mp->bd_id = ntohl (bd_id);
6829 /* Use a control ping for synchronization */
6830 MPING (CONTROL_PING, mp_ping);
6838 api_bridge_domain_add_del (vat_main_t * vam)
6840 unformat_input_t *i = vam->input;
6841 vl_api_bridge_domain_add_del_t *mp;
6844 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6849 /* Parse args required to build the message */
6850 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6852 if (unformat (i, "bd_id %d", &bd_id))
6854 else if (unformat (i, "flood %d", &flood))
6856 else if (unformat (i, "uu-flood %d", &uu_flood))
6858 else if (unformat (i, "forward %d", &forward))
6860 else if (unformat (i, "learn %d", &learn))
6862 else if (unformat (i, "arp-term %d", &arp_term))
6864 else if (unformat (i, "mac-age %d", &mac_age))
6866 else if (unformat (i, "bd-tag %s", &bd_tag))
6868 else if (unformat (i, "del"))
6871 flood = uu_flood = forward = learn = 0;
6879 errmsg ("missing bridge domain");
6886 errmsg ("mac age must be less than 256 ");
6891 if ((bd_tag) && (vec_len (bd_tag) > 63))
6893 errmsg ("bd-tag cannot be longer than 63");
6898 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6900 mp->bd_id = ntohl (bd_id);
6902 mp->uu_flood = uu_flood;
6903 mp->forward = forward;
6905 mp->arp_term = arp_term;
6906 mp->is_add = is_add;
6907 mp->mac_age = (u8) mac_age;
6910 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6911 mp->bd_tag[vec_len (bd_tag)] = 0;
6922 api_l2fib_flush_bd (vat_main_t * vam)
6924 unformat_input_t *i = vam->input;
6925 vl_api_l2fib_flush_bd_t *mp;
6929 /* Parse args required to build the message */
6930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6932 if (unformat (i, "bd_id %d", &bd_id));
6939 errmsg ("missing bridge domain");
6943 M (L2FIB_FLUSH_BD, mp);
6945 mp->bd_id = htonl (bd_id);
6953 api_l2fib_flush_int (vat_main_t * vam)
6955 unformat_input_t *i = vam->input;
6956 vl_api_l2fib_flush_int_t *mp;
6957 u32 sw_if_index = ~0;
6960 /* Parse args required to build the message */
6961 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6963 if (unformat (i, "sw_if_index %d", &sw_if_index));
6965 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6970 if (sw_if_index == ~0)
6972 errmsg ("missing interface name or sw_if_index");
6976 M (L2FIB_FLUSH_INT, mp);
6978 mp->sw_if_index = ntohl (sw_if_index);
6986 api_l2fib_add_del (vat_main_t * vam)
6988 unformat_input_t *i = vam->input;
6989 vl_api_l2fib_add_del_t *mp;
6995 u32 sw_if_index = 0;
6996 u8 sw_if_index_set = 0;
7005 /* Parse args required to build the message */
7006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7008 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7010 else if (unformat (i, "bd_id %d", &bd_id))
7012 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7013 sw_if_index_set = 1;
7014 else if (unformat (i, "sw_if"))
7016 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7019 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7020 sw_if_index_set = 1;
7025 else if (unformat (i, "static"))
7027 else if (unformat (i, "filter"))
7032 else if (unformat (i, "bvi"))
7037 else if (unformat (i, "del"))
7039 else if (unformat (i, "count %d", &count))
7047 errmsg ("missing mac address");
7053 errmsg ("missing bridge domain");
7057 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7059 errmsg ("missing interface name or sw_if_index");
7065 /* Turn on async mode */
7066 vam->async_mode = 1;
7067 vam->async_errors = 0;
7068 before = vat_time_now (vam);
7071 for (j = 0; j < count; j++)
7073 M (L2FIB_ADD_DEL, mp);
7075 clib_memcpy (mp->mac, mac, 6);
7076 mp->bd_id = ntohl (bd_id);
7077 mp->is_add = is_add;
7078 mp->sw_if_index = ntohl (sw_if_index);
7082 mp->static_mac = static_mac;
7083 mp->filter_mac = filter_mac;
7084 mp->bvi_mac = bvi_mac;
7086 increment_mac_address (mac);
7093 vl_api_control_ping_t *mp_ping;
7096 /* Shut off async mode */
7097 vam->async_mode = 0;
7099 MPING (CONTROL_PING, mp_ping);
7102 timeout = vat_time_now (vam) + 1.0;
7103 while (vat_time_now (vam) < timeout)
7104 if (vam->result_ready == 1)
7109 if (vam->retval == -99)
7112 if (vam->async_errors > 0)
7114 errmsg ("%d asynchronous errors", vam->async_errors);
7117 vam->async_errors = 0;
7118 after = vat_time_now (vam);
7120 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7121 count, after - before, count / (after - before));
7127 /* Wait for a reply... */
7131 /* Return the good/bad news */
7132 return (vam->retval);
7136 api_bridge_domain_set_mac_age (vat_main_t * vam)
7138 unformat_input_t *i = vam->input;
7139 vl_api_bridge_domain_set_mac_age_t *mp;
7144 /* Parse args required to build the message */
7145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7147 if (unformat (i, "bd_id %d", &bd_id));
7148 else if (unformat (i, "mac-age %d", &mac_age));
7155 errmsg ("missing bridge domain");
7161 errmsg ("mac age must be less than 256 ");
7165 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7167 mp->bd_id = htonl (bd_id);
7168 mp->mac_age = (u8) mac_age;
7176 api_l2_flags (vat_main_t * vam)
7178 unformat_input_t *i = vam->input;
7179 vl_api_l2_flags_t *mp;
7182 u8 sw_if_index_set = 0;
7186 /* Parse args required to build the message */
7187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7189 if (unformat (i, "sw_if_index %d", &sw_if_index))
7190 sw_if_index_set = 1;
7191 else if (unformat (i, "sw_if"))
7193 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7196 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7197 sw_if_index_set = 1;
7202 else if (unformat (i, "learn"))
7204 else if (unformat (i, "forward"))
7206 else if (unformat (i, "flood"))
7208 else if (unformat (i, "uu-flood"))
7209 flags |= L2_UU_FLOOD;
7210 else if (unformat (i, "arp-term"))
7211 flags |= L2_ARP_TERM;
7212 else if (unformat (i, "off"))
7214 else if (unformat (i, "disable"))
7220 if (sw_if_index_set == 0)
7222 errmsg ("missing interface name or sw_if_index");
7228 mp->sw_if_index = ntohl (sw_if_index);
7229 mp->feature_bitmap = ntohl (flags);
7230 mp->is_set = is_set;
7238 api_bridge_flags (vat_main_t * vam)
7240 unformat_input_t *i = vam->input;
7241 vl_api_bridge_flags_t *mp;
7245 bd_flags_t flags = 0;
7248 /* Parse args required to build the message */
7249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7251 if (unformat (i, "bd_id %d", &bd_id))
7253 else if (unformat (i, "learn"))
7254 flags |= BRIDGE_API_FLAG_LEARN;
7255 else if (unformat (i, "forward"))
7256 flags |= BRIDGE_API_FLAG_FWD;
7257 else if (unformat (i, "flood"))
7258 flags |= BRIDGE_API_FLAG_FLOOD;
7259 else if (unformat (i, "uu-flood"))
7260 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7261 else if (unformat (i, "arp-term"))
7262 flags |= BRIDGE_API_FLAG_ARP_TERM;
7263 else if (unformat (i, "off"))
7265 else if (unformat (i, "disable"))
7273 errmsg ("missing bridge domain");
7277 M (BRIDGE_FLAGS, mp);
7279 mp->bd_id = ntohl (bd_id);
7280 mp->flags = ntohl (flags);
7281 mp->is_set = is_set;
7289 api_bd_ip_mac_add_del (vat_main_t * vam)
7291 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7292 vl_api_mac_address_t mac = { 0 };
7293 unformat_input_t *i = vam->input;
7294 vl_api_bd_ip_mac_add_del_t *mp;
7306 /* Parse args required to build the message */
7307 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7309 if (unformat (i, "bd_id %d", &bd_id))
7313 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7317 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7321 else if (unformat (i, "del"))
7329 errmsg ("missing bridge domain");
7332 else if (ip_set == 0)
7334 errmsg ("missing IP address");
7337 else if (mac_set == 0)
7339 errmsg ("missing MAC address");
7343 M (BD_IP_MAC_ADD_DEL, mp);
7345 mp->bd_id = ntohl (bd_id);
7346 mp->is_add = is_add;
7348 clib_memcpy (&mp->ip, &ip, sizeof (ip));
7349 clib_memcpy (&mp->mac, &mac, sizeof (mac));
7357 api_bd_ip_mac_flush (vat_main_t * vam)
7359 unformat_input_t *i = vam->input;
7360 vl_api_bd_ip_mac_flush_t *mp;
7365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7367 if (unformat (i, "bd_id %d", &bd_id))
7377 errmsg ("missing bridge domain");
7381 M (BD_IP_MAC_FLUSH, mp);
7383 mp->bd_id = ntohl (bd_id);
7390 static void vl_api_bd_ip_mac_details_t_handler
7391 (vl_api_bd_ip_mac_details_t * mp)
7393 vat_main_t *vam = &vat_main;
7398 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7401 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7404 "\n%-5d %-7s %-20U %-30s",
7405 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7406 format_ethernet_address, mp->mac_address, ip);
7411 static void vl_api_bd_ip_mac_details_t_handler_json
7412 (vl_api_bd_ip_mac_details_t * mp)
7414 vat_main_t *vam = &vat_main;
7415 vat_json_node_t *node = NULL;
7417 if (VAT_JSON_ARRAY != vam->json_tree.type)
7419 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7420 vat_json_init_array (&vam->json_tree);
7422 node = vat_json_array_add (&vam->json_tree);
7424 vat_json_init_object (node);
7425 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7426 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7427 vat_json_object_add_string_copy (node, "mac_address",
7428 format (0, "%U", format_ethernet_address,
7434 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7437 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7438 vat_json_object_add_string_copy (node, "ip_address", ip);
7443 api_bd_ip_mac_dump (vat_main_t * vam)
7445 unformat_input_t *i = vam->input;
7446 vl_api_bd_ip_mac_dump_t *mp;
7447 vl_api_control_ping_t *mp_ping;
7452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7454 if (unformat (i, "bd_id %d", &bd_id))
7463 "\n%-5s %-7s %-20s %-30s",
7464 "bd_id", "is_ipv6", "mac_address", "ip_address");
7466 /* Dump Bridge Domain Ip to Mac entries */
7467 M (BD_IP_MAC_DUMP, mp);
7470 mp->bd_id = htonl (bd_id);
7476 /* Use a control ping for synchronization */
7477 MPING (CONTROL_PING, mp_ping);
7485 api_tap_create_v2 (vat_main_t * vam)
7487 unformat_input_t *i = vam->input;
7488 vl_api_tap_create_v2_t *mp;
7492 u8 *host_if_name = 0;
7494 u8 host_mac_addr[6];
7495 u8 host_mac_addr_set = 0;
7496 u8 *host_bridge = 0;
7497 ip4_address_t host_ip4_addr;
7498 ip4_address_t host_ip4_gw;
7499 u8 host_ip4_gw_set = 0;
7500 u32 host_ip4_prefix_len = 0;
7501 ip6_address_t host_ip6_addr;
7502 ip6_address_t host_ip6_gw;
7503 u8 host_ip6_gw_set = 0;
7504 u32 host_ip6_prefix_len = 0;
7506 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7508 clib_memset (mac_address, 0, sizeof (mac_address));
7510 /* Parse args required to build the message */
7511 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7513 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7517 else if (unformat (i, "id %u", &id))
7519 else if (unformat (i, "host-if-name %s", &host_if_name))
7521 else if (unformat (i, "host-ns %s", &host_ns))
7523 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7525 host_mac_addr_set = 1;
7526 else if (unformat (i, "host-bridge %s", &host_bridge))
7528 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7529 &host_ip4_addr, &host_ip4_prefix_len))
7531 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7532 &host_ip6_addr, &host_ip6_prefix_len))
7534 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7536 host_ip4_gw_set = 1;
7537 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7539 host_ip6_gw_set = 1;
7540 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7542 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7548 if (vec_len (host_if_name) > 63)
7550 errmsg ("tap name too long. ");
7553 if (vec_len (host_ns) > 63)
7555 errmsg ("host name space too long. ");
7558 if (vec_len (host_bridge) > 63)
7560 errmsg ("host bridge name too long. ");
7563 if (host_ip4_prefix_len > 32)
7565 errmsg ("host ip4 prefix length not valid. ");
7568 if (host_ip6_prefix_len > 128)
7570 errmsg ("host ip6 prefix length not valid. ");
7573 if (!is_pow2 (rx_ring_sz))
7575 errmsg ("rx ring size must be power of 2. ");
7578 if (rx_ring_sz > 32768)
7580 errmsg ("rx ring size must be 32768 or lower. ");
7583 if (!is_pow2 (tx_ring_sz))
7585 errmsg ("tx ring size must be power of 2. ");
7588 if (tx_ring_sz > 32768)
7590 errmsg ("tx ring size must be 32768 or lower. ");
7594 /* Construct the API message */
7595 M (TAP_CREATE_V2, mp);
7597 mp->use_random_mac = random_mac;
7599 mp->id = ntohl (id);
7600 mp->host_namespace_set = host_ns != 0;
7601 mp->host_bridge_set = host_bridge != 0;
7602 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7603 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7604 mp->rx_ring_sz = ntohs (rx_ring_sz);
7605 mp->tx_ring_sz = ntohs (tx_ring_sz);
7607 if (random_mac == 0)
7608 clib_memcpy (mp->mac_address, mac_address, 6);
7609 if (host_mac_addr_set)
7610 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7612 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7614 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7616 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7617 if (host_ip4_prefix_len)
7618 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7619 if (host_ip6_prefix_len)
7620 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7621 if (host_ip4_gw_set)
7622 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7623 if (host_ip6_gw_set)
7624 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7627 vec_free (host_if_name);
7628 vec_free (host_bridge);
7633 /* Wait for a reply... */
7639 api_tap_delete_v2 (vat_main_t * vam)
7641 unformat_input_t *i = vam->input;
7642 vl_api_tap_delete_v2_t *mp;
7643 u32 sw_if_index = ~0;
7644 u8 sw_if_index_set = 0;
7647 /* Parse args required to build the message */
7648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7650 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7651 sw_if_index_set = 1;
7652 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7653 sw_if_index_set = 1;
7658 if (sw_if_index_set == 0)
7660 errmsg ("missing vpp interface name. ");
7664 /* Construct the API message */
7665 M (TAP_DELETE_V2, mp);
7667 mp->sw_if_index = ntohl (sw_if_index);
7672 /* Wait for a reply... */
7678 unformat_pci_addr (unformat_input_t * input, va_list * args)
7687 addr = va_arg (*args, struct pci_addr_t *);
7690 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7693 addr->domain = x[0];
7696 addr->function = x[3];
7702 api_virtio_pci_create (vat_main_t * vam)
7704 unformat_input_t *i = vam->input;
7705 vl_api_virtio_pci_create_t *mp;
7709 u64 features = (u64) ~ (0ULL);
7710 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7713 clib_memset (mac_address, 0, sizeof (mac_address));
7715 /* Parse args required to build the message */
7716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7718 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7722 else if (unformat (i, "pci-addr %U", unformat_pci_addr, &pci_addr))
7724 else if (unformat (i, "features 0x%llx", &features))
7726 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
7728 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
7736 errmsg ("pci address must be non zero. ");
7739 if (!is_pow2 (rx_ring_sz))
7741 errmsg ("rx ring size must be power of 2. ");
7744 if (rx_ring_sz > 32768)
7746 errmsg ("rx ring size must be 32768 or lower. ");
7749 if (!is_pow2 (tx_ring_sz))
7751 errmsg ("tx ring size must be power of 2. ");
7754 if (tx_ring_sz > 32768)
7756 errmsg ("tx ring size must be 32768 or lower. ");
7760 /* Construct the API message */
7761 M (VIRTIO_PCI_CREATE, mp);
7763 mp->use_random_mac = random_mac;
7765 mp->pci_addr = htonl (pci_addr);
7766 mp->features = clib_host_to_net_u64 (features);
7767 mp->rx_ring_sz = htons (rx_ring_sz);
7768 mp->tx_ring_sz = htons (tx_ring_sz);
7770 if (random_mac == 0)
7771 clib_memcpy (mp->mac_address, mac_address, 6);
7776 /* Wait for a reply... */
7782 api_virtio_pci_delete (vat_main_t * vam)
7784 unformat_input_t *i = vam->input;
7785 vl_api_virtio_pci_delete_t *mp;
7786 u32 sw_if_index = ~0;
7787 u8 sw_if_index_set = 0;
7790 /* Parse args required to build the message */
7791 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7793 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7794 sw_if_index_set = 1;
7795 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7796 sw_if_index_set = 1;
7801 if (sw_if_index_set == 0)
7803 errmsg ("missing vpp interface name. ");
7807 /* Construct the API message */
7808 M (VIRTIO_PCI_DELETE, mp);
7810 mp->sw_if_index = htonl (sw_if_index);
7815 /* Wait for a reply... */
7821 api_bond_create (vat_main_t * vam)
7823 unformat_input_t *i = vam->input;
7824 vl_api_bond_create_t *mp;
7833 clib_memset (mac_address, 0, sizeof (mac_address));
7836 /* Parse args required to build the message */
7837 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7839 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7841 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7842 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7844 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7847 else if (unformat (i, "id %u", &id))
7853 if (mode_is_set == 0)
7855 errmsg ("Missing bond mode. ");
7859 /* Construct the API message */
7860 M (BOND_CREATE, mp);
7862 mp->use_custom_mac = custom_mac;
7866 mp->id = htonl (id);
7869 clib_memcpy (mp->mac_address, mac_address, 6);
7874 /* Wait for a reply... */
7880 api_bond_delete (vat_main_t * vam)
7882 unformat_input_t *i = vam->input;
7883 vl_api_bond_delete_t *mp;
7884 u32 sw_if_index = ~0;
7885 u8 sw_if_index_set = 0;
7888 /* Parse args required to build the message */
7889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7891 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7892 sw_if_index_set = 1;
7893 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7894 sw_if_index_set = 1;
7899 if (sw_if_index_set == 0)
7901 errmsg ("missing vpp interface name. ");
7905 /* Construct the API message */
7906 M (BOND_DELETE, mp);
7908 mp->sw_if_index = ntohl (sw_if_index);
7913 /* Wait for a reply... */
7919 api_bond_enslave (vat_main_t * vam)
7921 unformat_input_t *i = vam->input;
7922 vl_api_bond_enslave_t *mp;
7923 u32 bond_sw_if_index;
7927 u32 bond_sw_if_index_is_set = 0;
7929 u8 sw_if_index_is_set = 0;
7931 /* Parse args required to build the message */
7932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7934 if (unformat (i, "sw_if_index %d", &sw_if_index))
7935 sw_if_index_is_set = 1;
7936 else if (unformat (i, "bond %u", &bond_sw_if_index))
7937 bond_sw_if_index_is_set = 1;
7938 else if (unformat (i, "passive %d", &is_passive))
7940 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7946 if (bond_sw_if_index_is_set == 0)
7948 errmsg ("Missing bond sw_if_index. ");
7951 if (sw_if_index_is_set == 0)
7953 errmsg ("Missing slave sw_if_index. ");
7957 /* Construct the API message */
7958 M (BOND_ENSLAVE, mp);
7960 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7961 mp->sw_if_index = ntohl (sw_if_index);
7962 mp->is_long_timeout = is_long_timeout;
7963 mp->is_passive = is_passive;
7968 /* Wait for a reply... */
7974 api_bond_detach_slave (vat_main_t * vam)
7976 unformat_input_t *i = vam->input;
7977 vl_api_bond_detach_slave_t *mp;
7978 u32 sw_if_index = ~0;
7979 u8 sw_if_index_set = 0;
7982 /* Parse args required to build the message */
7983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7985 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7986 sw_if_index_set = 1;
7987 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7988 sw_if_index_set = 1;
7993 if (sw_if_index_set == 0)
7995 errmsg ("missing vpp interface name. ");
7999 /* Construct the API message */
8000 M (BOND_DETACH_SLAVE, mp);
8002 mp->sw_if_index = ntohl (sw_if_index);
8007 /* Wait for a reply... */
8013 api_ip_table_add_del (vat_main_t * vam)
8015 unformat_input_t *i = vam->input;
8016 vl_api_ip_table_add_del_t *mp;
8022 /* Parse args required to build the message */
8023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8025 if (unformat (i, "ipv6"))
8027 else if (unformat (i, "del"))
8029 else if (unformat (i, "add"))
8031 else if (unformat (i, "table %d", &table_id))
8035 clib_warning ("parse error '%U'", format_unformat_error, i);
8042 errmsg ("missing table-ID");
8046 /* Construct the API message */
8047 M (IP_TABLE_ADD_DEL, mp);
8049 mp->table_id = ntohl (table_id);
8050 mp->is_ipv6 = is_ipv6;
8051 mp->is_add = is_add;
8056 /* Wait for a reply... */
8063 api_ip_add_del_route (vat_main_t * vam)
8065 unformat_input_t *i = vam->input;
8066 vl_api_ip_add_del_route_t *mp;
8067 u32 sw_if_index = ~0, vrf_id = 0;
8069 u8 is_local = 0, is_drop = 0;
8070 u8 is_unreach = 0, is_prohibit = 0;
8072 u32 next_hop_weight = 1;
8073 u8 is_multipath = 0;
8075 u8 address_length_set = 0;
8076 u32 next_hop_table_id = 0;
8077 u32 resolve_attempts = 0;
8078 u32 dst_address_length = 0;
8079 u8 next_hop_set = 0;
8080 ip4_address_t v4_dst_address, v4_next_hop_address;
8081 ip6_address_t v6_dst_address, v6_next_hop_address;
8085 u32 random_add_del = 0;
8086 u32 *random_vector = 0;
8088 u32 random_seed = 0xdeaddabe;
8089 u32 classify_table_index = ~0;
8091 u8 resolve_host = 0, resolve_attached = 0;
8092 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8093 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8094 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8096 clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8097 clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8098 /* Parse args required to build the message */
8099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8101 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8103 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8105 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8110 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8115 else if (unformat (i, "/%d", &dst_address_length))
8117 address_length_set = 1;
8120 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8121 &v4_next_hop_address))
8125 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8126 &v6_next_hop_address))
8132 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8136 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8140 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8142 else if (unformat (i, "weight %d", &next_hop_weight))
8144 else if (unformat (i, "drop"))
8148 else if (unformat (i, "null-send-unreach"))
8152 else if (unformat (i, "null-send-prohibit"))
8156 else if (unformat (i, "local"))
8160 else if (unformat (i, "classify %d", &classify_table_index))
8164 else if (unformat (i, "del"))
8166 else if (unformat (i, "add"))
8168 else if (unformat (i, "resolve-via-host"))
8170 else if (unformat (i, "resolve-via-attached"))
8171 resolve_attached = 1;
8172 else if (unformat (i, "multipath"))
8174 else if (unformat (i, "vrf %d", &vrf_id))
8176 else if (unformat (i, "count %d", &count))
8178 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8180 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8182 else if (unformat (i, "out-label %d", &next_hop_out_label))
8184 vl_api_fib_mpls_label_t fib_label = {
8185 .label = ntohl (next_hop_out_label),
8189 vec_add1 (next_hop_out_label_stack, fib_label);
8191 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8193 else if (unformat (i, "random"))
8195 else if (unformat (i, "seed %d", &random_seed))
8199 clib_warning ("parse error '%U'", format_unformat_error, i);
8204 if (!next_hop_set && !is_drop && !is_local &&
8205 !is_classify && !is_unreach && !is_prohibit &&
8206 MPLS_LABEL_INVALID == next_hop_via_label)
8209 ("next hop / local / drop / unreach / prohibit / classify not set");
8213 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8215 errmsg ("next hop and next-hop via label set");
8218 if (address_set == 0)
8220 errmsg ("missing addresses");
8224 if (address_length_set == 0)
8226 errmsg ("missing address length");
8230 /* Generate a pile of unique, random routes */
8233 u32 this_random_address;
8234 random_hash = hash_create (count, sizeof (uword));
8236 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8237 for (j = 0; j <= count; j++)
8241 this_random_address = random_u32 (&random_seed);
8242 this_random_address =
8243 clib_host_to_net_u32 (this_random_address);
8245 while (hash_get (random_hash, this_random_address));
8246 vec_add1 (random_vector, this_random_address);
8247 hash_set (random_hash, this_random_address, 1);
8249 hash_free (random_hash);
8250 v4_dst_address.as_u32 = random_vector[0];
8255 /* Turn on async mode */
8256 vam->async_mode = 1;
8257 vam->async_errors = 0;
8258 before = vat_time_now (vam);
8261 for (j = 0; j < count; j++)
8263 /* Construct the API message */
8264 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8265 vec_len (next_hop_out_label_stack));
8267 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8268 mp->table_id = ntohl (vrf_id);
8270 mp->is_add = is_add;
8271 mp->is_drop = is_drop;
8272 mp->is_unreach = is_unreach;
8273 mp->is_prohibit = is_prohibit;
8274 mp->is_ipv6 = is_ipv6;
8275 mp->is_local = is_local;
8276 mp->is_classify = is_classify;
8277 mp->is_multipath = is_multipath;
8278 mp->is_resolve_host = resolve_host;
8279 mp->is_resolve_attached = resolve_attached;
8280 mp->next_hop_weight = next_hop_weight;
8281 mp->next_hop_preference = 0;
8282 mp->dst_address_length = dst_address_length;
8283 mp->next_hop_table_id = ntohl (next_hop_table_id);
8284 mp->classify_table_index = ntohl (classify_table_index);
8285 mp->next_hop_via_label = ntohl (next_hop_via_label);
8286 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8287 if (0 != mp->next_hop_n_out_labels)
8289 memcpy (mp->next_hop_out_label_stack,
8290 next_hop_out_label_stack,
8291 (vec_len (next_hop_out_label_stack) *
8292 sizeof (vl_api_fib_mpls_label_t)));
8293 vec_free (next_hop_out_label_stack);
8298 clib_memcpy (mp->dst_address, &v6_dst_address,
8299 sizeof (v6_dst_address));
8301 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8302 sizeof (v6_next_hop_address));
8303 increment_v6_address (&v6_dst_address);
8307 clib_memcpy (mp->dst_address, &v4_dst_address,
8308 sizeof (v4_dst_address));
8310 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8311 sizeof (v4_next_hop_address));
8313 v4_dst_address.as_u32 = random_vector[j + 1];
8315 increment_v4_address (&v4_dst_address);
8319 /* If we receive SIGTERM, stop now... */
8324 /* When testing multiple add/del ops, use a control-ping to sync */
8327 vl_api_control_ping_t *mp_ping;
8331 /* Shut off async mode */
8332 vam->async_mode = 0;
8334 MPING (CONTROL_PING, mp_ping);
8337 timeout = vat_time_now (vam) + 1.0;
8338 while (vat_time_now (vam) < timeout)
8339 if (vam->result_ready == 1)
8344 if (vam->retval == -99)
8347 if (vam->async_errors > 0)
8349 errmsg ("%d asynchronous errors", vam->async_errors);
8352 vam->async_errors = 0;
8353 after = vat_time_now (vam);
8355 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8359 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8360 count, after - before, count / (after - before));
8366 /* Wait for a reply... */
8371 /* Return the good/bad news */
8372 return (vam->retval);
8376 api_ip_mroute_add_del (vat_main_t * vam)
8378 unformat_input_t *i = vam->input;
8379 vl_api_ip_mroute_add_del_t *mp;
8380 u32 sw_if_index = ~0, vrf_id = 0;
8385 u32 grp_address_length = 0;
8386 ip4_address_t v4_grp_address, v4_src_address;
8387 ip6_address_t v6_grp_address, v6_src_address;
8388 mfib_itf_flags_t iflags = 0;
8389 mfib_entry_flags_t eflags = 0;
8392 /* Parse args required to build the message */
8393 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8395 if (unformat (i, "sw_if_index %d", &sw_if_index))
8397 else if (unformat (i, "%U %U",
8398 unformat_ip4_address, &v4_src_address,
8399 unformat_ip4_address, &v4_grp_address))
8401 grp_address_length = 64;
8405 else if (unformat (i, "%U %U",
8406 unformat_ip6_address, &v6_src_address,
8407 unformat_ip6_address, &v6_grp_address))
8409 grp_address_length = 256;
8413 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8415 clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
8416 grp_address_length = 32;
8420 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8422 clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
8423 grp_address_length = 128;
8427 else if (unformat (i, "/%d", &grp_address_length))
8429 else if (unformat (i, "local"))
8433 else if (unformat (i, "del"))
8435 else if (unformat (i, "add"))
8437 else if (unformat (i, "vrf %d", &vrf_id))
8439 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8441 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8445 clib_warning ("parse error '%U'", format_unformat_error, i);
8450 if (address_set == 0)
8452 errmsg ("missing addresses\n");
8456 /* Construct the API message */
8457 M (IP_MROUTE_ADD_DEL, mp);
8459 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8460 mp->table_id = ntohl (vrf_id);
8462 mp->is_add = is_add;
8463 mp->is_ipv6 = is_ipv6;
8464 mp->is_local = is_local;
8465 mp->itf_flags = ntohl (iflags);
8466 mp->entry_flags = ntohl (eflags);
8467 mp->grp_address_length = grp_address_length;
8468 mp->grp_address_length = ntohs (mp->grp_address_length);
8472 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8473 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8477 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8478 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8484 /* Wait for a reply... */
8490 api_mpls_table_add_del (vat_main_t * vam)
8492 unformat_input_t *i = vam->input;
8493 vl_api_mpls_table_add_del_t *mp;
8498 /* Parse args required to build the message */
8499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8501 if (unformat (i, "table %d", &table_id))
8503 else if (unformat (i, "del"))
8505 else if (unformat (i, "add"))
8509 clib_warning ("parse error '%U'", format_unformat_error, i);
8516 errmsg ("missing table-ID");
8520 /* Construct the API message */
8521 M (MPLS_TABLE_ADD_DEL, mp);
8523 mp->mt_table_id = ntohl (table_id);
8524 mp->mt_is_add = is_add;
8529 /* Wait for a reply... */
8536 api_mpls_route_add_del (vat_main_t * vam)
8538 unformat_input_t *i = vam->input;
8539 vl_api_mpls_route_add_del_t *mp;
8540 u32 sw_if_index = ~0, table_id = 0;
8542 u32 next_hop_weight = 1;
8543 u8 is_multipath = 0;
8544 u32 next_hop_table_id = 0;
8545 u8 next_hop_set = 0;
8546 ip4_address_t v4_next_hop_address = {
8549 ip6_address_t v6_next_hop_address = { {0} };
8553 u32 classify_table_index = ~0;
8555 u8 resolve_host = 0, resolve_attached = 0;
8556 u8 is_interface_rx = 0;
8557 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8558 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8559 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8560 mpls_label_t local_label = MPLS_LABEL_INVALID;
8562 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
8564 /* Parse args required to build the message */
8565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8567 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8569 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8571 else if (unformat (i, "%d", &local_label))
8573 else if (unformat (i, "eos"))
8575 else if (unformat (i, "non-eos"))
8577 else if (unformat (i, "via %U", unformat_ip4_address,
8578 &v4_next_hop_address))
8581 next_hop_proto = DPO_PROTO_IP4;
8583 else if (unformat (i, "via %U", unformat_ip6_address,
8584 &v6_next_hop_address))
8587 next_hop_proto = DPO_PROTO_IP6;
8589 else if (unformat (i, "weight %d", &next_hop_weight))
8591 else if (unformat (i, "classify %d", &classify_table_index))
8595 else if (unformat (i, "del"))
8597 else if (unformat (i, "add"))
8599 else if (unformat (i, "resolve-via-host"))
8601 else if (unformat (i, "resolve-via-attached"))
8602 resolve_attached = 1;
8603 else if (unformat (i, "multipath"))
8605 else if (unformat (i, "count %d", &count))
8607 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
8610 next_hop_proto = DPO_PROTO_IP4;
8612 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
8615 next_hop_proto = DPO_PROTO_IP6;
8619 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
8623 next_hop_proto = DPO_PROTO_ETHERNET;
8624 is_interface_rx = 1;
8626 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
8629 next_hop_proto = DPO_PROTO_ETHERNET;
8630 is_interface_rx = 1;
8632 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
8634 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8636 else if (unformat (i, "out-label %d", &next_hop_out_label))
8638 vl_api_fib_mpls_label_t fib_label = {
8639 .label = ntohl (next_hop_out_label),
8643 vec_add1 (next_hop_out_label_stack, fib_label);
8647 clib_warning ("parse error '%U'", format_unformat_error, i);
8652 if (!next_hop_set && !is_classify)
8654 errmsg ("next hop / classify not set");
8658 if (MPLS_LABEL_INVALID == local_label)
8660 errmsg ("missing label");
8666 /* Turn on async mode */
8667 vam->async_mode = 1;
8668 vam->async_errors = 0;
8669 before = vat_time_now (vam);
8672 for (j = 0; j < count; j++)
8674 /* Construct the API message */
8675 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
8676 vec_len (next_hop_out_label_stack));
8678 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8679 mp->mr_table_id = ntohl (table_id);
8681 mp->mr_is_add = is_add;
8682 mp->mr_next_hop_proto = next_hop_proto;
8683 mp->mr_is_classify = is_classify;
8684 mp->mr_is_multipath = is_multipath;
8685 mp->mr_is_resolve_host = resolve_host;
8686 mp->mr_is_resolve_attached = resolve_attached;
8687 mp->mr_is_interface_rx = is_interface_rx;
8688 mp->mr_next_hop_weight = next_hop_weight;
8689 mp->mr_next_hop_preference = 0;
8690 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8691 mp->mr_classify_table_index = ntohl (classify_table_index);
8692 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8693 mp->mr_label = ntohl (local_label);
8694 mp->mr_eos = is_eos;
8696 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8697 if (0 != mp->mr_next_hop_n_out_labels)
8699 memcpy (mp->mr_next_hop_out_label_stack,
8700 next_hop_out_label_stack,
8701 vec_len (next_hop_out_label_stack) *
8702 sizeof (vl_api_fib_mpls_label_t));
8703 vec_free (next_hop_out_label_stack);
8708 if (DPO_PROTO_IP4 == next_hop_proto)
8710 clib_memcpy (mp->mr_next_hop,
8711 &v4_next_hop_address,
8712 sizeof (v4_next_hop_address));
8714 else if (DPO_PROTO_IP6 == next_hop_proto)
8717 clib_memcpy (mp->mr_next_hop,
8718 &v6_next_hop_address,
8719 sizeof (v6_next_hop_address));
8726 /* If we receive SIGTERM, stop now... */
8731 /* When testing multiple add/del ops, use a control-ping to sync */
8734 vl_api_control_ping_t *mp_ping;
8738 /* Shut off async mode */
8739 vam->async_mode = 0;
8741 MPING (CONTROL_PING, mp_ping);
8744 timeout = vat_time_now (vam) + 1.0;
8745 while (vat_time_now (vam) < timeout)
8746 if (vam->result_ready == 1)
8751 if (vam->retval == -99)
8754 if (vam->async_errors > 0)
8756 errmsg ("%d asynchronous errors", vam->async_errors);
8759 vam->async_errors = 0;
8760 after = vat_time_now (vam);
8762 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8766 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8767 count, after - before, count / (after - before));
8773 /* Wait for a reply... */
8778 /* Return the good/bad news */
8779 return (vam->retval);
8783 api_mpls_ip_bind_unbind (vat_main_t * vam)
8785 unformat_input_t *i = vam->input;
8786 vl_api_mpls_ip_bind_unbind_t *mp;
8787 u32 ip_table_id = 0;
8790 ip4_address_t v4_address;
8791 ip6_address_t v6_address;
8794 mpls_label_t local_label = MPLS_LABEL_INVALID;
8797 /* Parse args required to build the message */
8798 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8800 if (unformat (i, "%U/%d", unformat_ip4_address,
8801 &v4_address, &address_length))
8806 else if (unformat (i, "%U/%d", unformat_ip6_address,
8807 &v6_address, &address_length))
8812 else if (unformat (i, "%d", &local_label))
8814 else if (unformat (i, "table-id %d", &ip_table_id))
8816 else if (unformat (i, "unbind"))
8818 else if (unformat (i, "bind"))
8822 clib_warning ("parse error '%U'", format_unformat_error, i);
8829 errmsg ("IP address not set");
8833 if (MPLS_LABEL_INVALID == local_label)
8835 errmsg ("missing label");
8839 /* Construct the API message */
8840 M (MPLS_IP_BIND_UNBIND, mp);
8842 mp->mb_is_bind = is_bind;
8843 mp->mb_is_ip4 = is_ip4;
8844 mp->mb_ip_table_id = ntohl (ip_table_id);
8845 mp->mb_mpls_table_id = 0;
8846 mp->mb_label = ntohl (local_label);
8847 mp->mb_address_length = address_length;
8850 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8852 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8857 /* Wait for a reply... */
8863 api_sr_mpls_policy_add (vat_main_t * vam)
8865 unformat_input_t *i = vam->input;
8866 vl_api_sr_mpls_policy_add_t *mp;
8872 u32 *segments = NULL;
8875 /* Parse args required to build the message */
8876 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8878 if (unformat (i, "bsid %d", &bsid))
8880 else if (unformat (i, "weight %d", &weight))
8882 else if (unformat (i, "spray"))
8884 else if (unformat (i, "next %d", &sid))
8887 vec_add1 (segments, htonl (sid));
8891 clib_warning ("parse error '%U'", format_unformat_error, i);
8898 errmsg ("bsid not set");
8902 if (n_segments == 0)
8904 errmsg ("no sid in segment stack");
8908 /* Construct the API message */
8909 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8911 mp->bsid = htonl (bsid);
8912 mp->weight = htonl (weight);
8914 mp->n_segments = n_segments;
8915 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8916 vec_free (segments);
8921 /* Wait for a reply... */
8927 api_sr_mpls_policy_del (vat_main_t * vam)
8929 unformat_input_t *i = vam->input;
8930 vl_api_sr_mpls_policy_del_t *mp;
8934 /* Parse args required to build the message */
8935 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8937 if (unformat (i, "bsid %d", &bsid))
8941 clib_warning ("parse error '%U'", format_unformat_error, i);
8948 errmsg ("bsid not set");
8952 /* Construct the API message */
8953 M (SR_MPLS_POLICY_DEL, mp);
8955 mp->bsid = htonl (bsid);
8960 /* Wait for a reply... */
8966 api_bier_table_add_del (vat_main_t * vam)
8968 unformat_input_t *i = vam->input;
8969 vl_api_bier_table_add_del_t *mp;
8971 u32 set = 0, sub_domain = 0, hdr_len = 3;
8972 mpls_label_t local_label = MPLS_LABEL_INVALID;
8975 /* Parse args required to build the message */
8976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8978 if (unformat (i, "sub-domain %d", &sub_domain))
8980 else if (unformat (i, "set %d", &set))
8982 else if (unformat (i, "label %d", &local_label))
8984 else if (unformat (i, "hdr-len %d", &hdr_len))
8986 else if (unformat (i, "add"))
8988 else if (unformat (i, "del"))
8992 clib_warning ("parse error '%U'", format_unformat_error, i);
8997 if (MPLS_LABEL_INVALID == local_label)
8999 errmsg ("missing label\n");
9003 /* Construct the API message */
9004 M (BIER_TABLE_ADD_DEL, mp);
9006 mp->bt_is_add = is_add;
9007 mp->bt_label = ntohl (local_label);
9008 mp->bt_tbl_id.bt_set = set;
9009 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9010 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9015 /* Wait for a reply... */
9022 api_bier_route_add_del (vat_main_t * vam)
9024 unformat_input_t *i = vam->input;
9025 vl_api_bier_route_add_del_t *mp;
9027 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9028 ip4_address_t v4_next_hop_address;
9029 ip6_address_t v6_next_hop_address;
9030 u8 next_hop_set = 0;
9031 u8 next_hop_proto_is_ip4 = 1;
9032 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9035 /* Parse args required to build the message */
9036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9038 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9040 next_hop_proto_is_ip4 = 1;
9043 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9045 next_hop_proto_is_ip4 = 0;
9048 if (unformat (i, "sub-domain %d", &sub_domain))
9050 else if (unformat (i, "set %d", &set))
9052 else if (unformat (i, "hdr-len %d", &hdr_len))
9054 else if (unformat (i, "bp %d", &bp))
9056 else if (unformat (i, "add"))
9058 else if (unformat (i, "del"))
9060 else if (unformat (i, "out-label %d", &next_hop_out_label))
9064 clib_warning ("parse error '%U'", format_unformat_error, i);
9069 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9071 errmsg ("next hop / label set\n");
9076 errmsg ("bit=position not set\n");
9080 /* Construct the API message */
9081 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9083 mp->br_is_add = is_add;
9084 mp->br_tbl_id.bt_set = set;
9085 mp->br_tbl_id.bt_sub_domain = sub_domain;
9086 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9087 mp->br_bp = ntohs (bp);
9089 mp->br_paths[0].n_labels = 1;
9090 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9091 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9093 if (next_hop_proto_is_ip4)
9095 clib_memcpy (mp->br_paths[0].next_hop,
9096 &v4_next_hop_address, sizeof (v4_next_hop_address));
9100 clib_memcpy (mp->br_paths[0].next_hop,
9101 &v6_next_hop_address, sizeof (v6_next_hop_address));
9107 /* Wait for a reply... */
9114 api_proxy_arp_add_del (vat_main_t * vam)
9116 unformat_input_t *i = vam->input;
9117 vl_api_proxy_arp_add_del_t *mp;
9120 ip4_address_t lo, hi;
9124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9126 if (unformat (i, "vrf %d", &vrf_id))
9128 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9129 unformat_ip4_address, &hi))
9131 else if (unformat (i, "del"))
9135 clib_warning ("parse error '%U'", format_unformat_error, i);
9142 errmsg ("address range not set");
9146 M (PROXY_ARP_ADD_DEL, mp);
9148 mp->proxy.vrf_id = ntohl (vrf_id);
9149 mp->is_add = is_add;
9150 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9151 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9159 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9161 unformat_input_t *i = vam->input;
9162 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9165 u8 sw_if_index_set = 0;
9168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9170 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9171 sw_if_index_set = 1;
9172 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9173 sw_if_index_set = 1;
9174 else if (unformat (i, "enable"))
9176 else if (unformat (i, "disable"))
9180 clib_warning ("parse error '%U'", format_unformat_error, i);
9185 if (sw_if_index_set == 0)
9187 errmsg ("missing interface name or sw_if_index");
9191 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9193 mp->sw_if_index = ntohl (sw_if_index);
9194 mp->enable_disable = enable;
9202 api_mpls_tunnel_add_del (vat_main_t * vam)
9204 unformat_input_t *i = vam->input;
9205 vl_api_mpls_tunnel_add_del_t *mp;
9209 u32 sw_if_index = ~0;
9210 u32 next_hop_sw_if_index = ~0;
9211 u32 next_hop_proto_is_ip4 = 1;
9213 u32 next_hop_table_id = 0;
9214 ip4_address_t v4_next_hop_address = {
9217 ip6_address_t v6_next_hop_address = { {0} };
9218 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9219 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9220 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9223 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9225 if (unformat (i, "add"))
9229 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9231 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9233 else if (unformat (i, "via %U",
9234 unformat_ip4_address, &v4_next_hop_address))
9236 next_hop_proto_is_ip4 = 1;
9238 else if (unformat (i, "via %U",
9239 unformat_ip6_address, &v6_next_hop_address))
9241 next_hop_proto_is_ip4 = 0;
9243 else if (unformat (i, "via-label %d", &next_hop_via_label))
9247 (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
9249 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9251 else if (unformat (i, "l2-only"))
9253 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9255 else if (unformat (i, "out-label %d", &next_hop_out_label))
9257 vl_api_fib_mpls_label_t fib_label = {
9258 .label = ntohl (next_hop_out_label),
9262 vec_add1 (next_hop_out_label_stack, fib_label);
9266 clib_warning ("parse error '%U'", format_unformat_error, i);
9271 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9272 vec_len (next_hop_out_label_stack));
9274 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9275 mp->mt_sw_if_index = ntohl (sw_if_index);
9276 mp->mt_is_add = is_add;
9277 mp->mt_l2_only = l2_only;
9278 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9279 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9280 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9281 mp->mt_next_hop_weight = 1;
9282 mp->mt_next_hop_preference = 0;
9284 mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9286 if (0 != mp->mt_next_hop_n_out_labels)
9288 clib_memcpy (mp->mt_next_hop_out_label_stack,
9289 next_hop_out_label_stack,
9290 (vec_len (next_hop_out_label_stack) *
9291 sizeof (vl_api_fib_mpls_label_t)));
9292 vec_free (next_hop_out_label_stack);
9295 if (next_hop_proto_is_ip4)
9297 clib_memcpy (mp->mt_next_hop,
9298 &v4_next_hop_address, sizeof (v4_next_hop_address));
9302 clib_memcpy (mp->mt_next_hop,
9303 &v6_next_hop_address, sizeof (v6_next_hop_address));
9312 api_sw_interface_set_unnumbered (vat_main_t * vam)
9314 unformat_input_t *i = vam->input;
9315 vl_api_sw_interface_set_unnumbered_t *mp;
9317 u32 unnum_sw_index = ~0;
9319 u8 sw_if_index_set = 0;
9322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9324 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9325 sw_if_index_set = 1;
9326 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9327 sw_if_index_set = 1;
9328 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9330 else if (unformat (i, "del"))
9334 clib_warning ("parse error '%U'", format_unformat_error, i);
9339 if (sw_if_index_set == 0)
9341 errmsg ("missing interface name or sw_if_index");
9345 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9347 mp->sw_if_index = ntohl (sw_if_index);
9348 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9349 mp->is_add = is_add;
9357 api_ip_neighbor_add_del (vat_main_t * vam)
9359 unformat_input_t *i = vam->input;
9360 vl_api_ip_neighbor_add_del_t *mp;
9362 u8 sw_if_index_set = 0;
9365 u8 is_no_fib_entry = 0;
9368 u8 v4_address_set = 0;
9369 u8 v6_address_set = 0;
9370 ip4_address_t v4address;
9371 ip6_address_t v6address;
9374 clib_memset (mac_address, 0, sizeof (mac_address));
9376 /* Parse args required to build the message */
9377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9379 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9383 else if (unformat (i, "del"))
9386 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9387 sw_if_index_set = 1;
9388 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9389 sw_if_index_set = 1;
9390 else if (unformat (i, "is_static"))
9392 else if (unformat (i, "no-fib-entry"))
9393 is_no_fib_entry = 1;
9394 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9396 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9400 clib_warning ("parse error '%U'", format_unformat_error, i);
9405 if (sw_if_index_set == 0)
9407 errmsg ("missing interface name or sw_if_index");
9410 if (v4_address_set && v6_address_set)
9412 errmsg ("both v4 and v6 addresses set");
9415 if (!v4_address_set && !v6_address_set)
9417 errmsg ("no address set");
9421 /* Construct the API message */
9422 M (IP_NEIGHBOR_ADD_DEL, mp);
9424 mp->sw_if_index = ntohl (sw_if_index);
9425 mp->is_add = is_add;
9426 mp->is_static = is_static;
9427 mp->is_no_adj_fib = is_no_fib_entry;
9429 clib_memcpy (mp->mac_address, mac_address, 6);
9433 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9437 /* mp->is_ipv6 = 0; via clib_memset in M macro above */
9438 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9444 /* Wait for a reply, return good/bad news */
9450 api_create_vlan_subif (vat_main_t * vam)
9452 unformat_input_t *i = vam->input;
9453 vl_api_create_vlan_subif_t *mp;
9455 u8 sw_if_index_set = 0;
9460 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9462 if (unformat (i, "sw_if_index %d", &sw_if_index))
9463 sw_if_index_set = 1;
9465 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9466 sw_if_index_set = 1;
9467 else if (unformat (i, "vlan %d", &vlan_id))
9471 clib_warning ("parse error '%U'", format_unformat_error, i);
9476 if (sw_if_index_set == 0)
9478 errmsg ("missing interface name or sw_if_index");
9482 if (vlan_id_set == 0)
9484 errmsg ("missing vlan_id");
9487 M (CREATE_VLAN_SUBIF, mp);
9489 mp->sw_if_index = ntohl (sw_if_index);
9490 mp->vlan_id = ntohl (vlan_id);
9497 #define foreach_create_subif_bit \
9504 _(outer_vlan_id_any) \
9505 _(inner_vlan_id_any)
9508 api_create_subif (vat_main_t * vam)
9510 unformat_input_t *i = vam->input;
9511 vl_api_create_subif_t *mp;
9513 u8 sw_if_index_set = 0;
9520 u32 exact_match = 0;
9521 u32 default_sub = 0;
9522 u32 outer_vlan_id_any = 0;
9523 u32 inner_vlan_id_any = 0;
9525 u16 outer_vlan_id = 0;
9526 u16 inner_vlan_id = 0;
9529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9531 if (unformat (i, "sw_if_index %d", &sw_if_index))
9532 sw_if_index_set = 1;
9534 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9535 sw_if_index_set = 1;
9536 else if (unformat (i, "sub_id %d", &sub_id))
9538 else if (unformat (i, "outer_vlan_id %d", &tmp))
9539 outer_vlan_id = tmp;
9540 else if (unformat (i, "inner_vlan_id %d", &tmp))
9541 inner_vlan_id = tmp;
9543 #define _(a) else if (unformat (i, #a)) a = 1 ;
9544 foreach_create_subif_bit
9548 clib_warning ("parse error '%U'", format_unformat_error, i);
9553 if (sw_if_index_set == 0)
9555 errmsg ("missing interface name or sw_if_index");
9559 if (sub_id_set == 0)
9561 errmsg ("missing sub_id");
9564 M (CREATE_SUBIF, mp);
9566 mp->sw_if_index = ntohl (sw_if_index);
9567 mp->sub_id = ntohl (sub_id);
9569 #define _(a) mp->a = a;
9570 foreach_create_subif_bit;
9573 mp->outer_vlan_id = ntohs (outer_vlan_id);
9574 mp->inner_vlan_id = ntohs (inner_vlan_id);
9582 api_oam_add_del (vat_main_t * vam)
9584 unformat_input_t *i = vam->input;
9585 vl_api_oam_add_del_t *mp;
9588 ip4_address_t src, dst;
9593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9595 if (unformat (i, "vrf %d", &vrf_id))
9597 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9599 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9601 else if (unformat (i, "del"))
9605 clib_warning ("parse error '%U'", format_unformat_error, i);
9612 errmsg ("missing src addr");
9618 errmsg ("missing dst addr");
9622 M (OAM_ADD_DEL, mp);
9624 mp->vrf_id = ntohl (vrf_id);
9625 mp->is_add = is_add;
9626 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9627 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9635 api_reset_fib (vat_main_t * vam)
9637 unformat_input_t *i = vam->input;
9638 vl_api_reset_fib_t *mp;
9644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9646 if (unformat (i, "vrf %d", &vrf_id))
9648 else if (unformat (i, "ipv6"))
9652 clib_warning ("parse error '%U'", format_unformat_error, i);
9657 if (vrf_id_set == 0)
9659 errmsg ("missing vrf id");
9665 mp->vrf_id = ntohl (vrf_id);
9666 mp->is_ipv6 = is_ipv6;
9674 api_dhcp_proxy_config (vat_main_t * vam)
9676 unformat_input_t *i = vam->input;
9677 vl_api_dhcp_proxy_config_t *mp;
9679 u32 server_vrf_id = 0;
9681 u8 v4_address_set = 0;
9682 u8 v6_address_set = 0;
9683 ip4_address_t v4address;
9684 ip6_address_t v6address;
9685 u8 v4_src_address_set = 0;
9686 u8 v6_src_address_set = 0;
9687 ip4_address_t v4srcaddress;
9688 ip6_address_t v6srcaddress;
9691 /* Parse args required to build the message */
9692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9694 if (unformat (i, "del"))
9696 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9698 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9700 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9702 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9704 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9705 v4_src_address_set = 1;
9706 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9707 v6_src_address_set = 1;
9712 if (v4_address_set && v6_address_set)
9714 errmsg ("both v4 and v6 server addresses set");
9717 if (!v4_address_set && !v6_address_set)
9719 errmsg ("no server addresses set");
9723 if (v4_src_address_set && v6_src_address_set)
9725 errmsg ("both v4 and v6 src addresses set");
9728 if (!v4_src_address_set && !v6_src_address_set)
9730 errmsg ("no src addresses set");
9734 if (!(v4_src_address_set && v4_address_set) &&
9735 !(v6_src_address_set && v6_address_set))
9737 errmsg ("no matching server and src addresses set");
9741 /* Construct the API message */
9742 M (DHCP_PROXY_CONFIG, mp);
9744 mp->is_add = is_add;
9745 mp->rx_vrf_id = ntohl (rx_vrf_id);
9746 mp->server_vrf_id = ntohl (server_vrf_id);
9750 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9751 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9755 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9756 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9762 /* Wait for a reply, return good/bad news */
9767 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9768 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9771 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9773 vat_main_t *vam = &vat_main;
9774 u32 i, count = mp->count;
9775 vl_api_dhcp_server_t *s;
9779 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9780 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9781 ntohl (mp->rx_vrf_id),
9782 format_ip6_address, mp->dhcp_src_address,
9783 mp->vss_type, mp->vss_vpn_ascii_id,
9784 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9787 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9788 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9789 ntohl (mp->rx_vrf_id),
9790 format_ip4_address, mp->dhcp_src_address,
9791 mp->vss_type, mp->vss_vpn_ascii_id,
9792 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9794 for (i = 0; i < count; i++)
9796 s = &mp->servers[i];
9800 " Server Table-ID %d, Server Address %U",
9801 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9804 " Server Table-ID %d, Server Address %U",
9805 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9809 static void vl_api_dhcp_proxy_details_t_handler_json
9810 (vl_api_dhcp_proxy_details_t * mp)
9812 vat_main_t *vam = &vat_main;
9813 vat_json_node_t *node = NULL;
9814 u32 i, count = mp->count;
9816 struct in6_addr ip6;
9817 vl_api_dhcp_server_t *s;
9819 if (VAT_JSON_ARRAY != vam->json_tree.type)
9821 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9822 vat_json_init_array (&vam->json_tree);
9824 node = vat_json_array_add (&vam->json_tree);
9826 vat_json_init_object (node);
9827 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9828 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9829 sizeof (mp->vss_type));
9830 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9831 mp->vss_vpn_ascii_id);
9832 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9833 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9837 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9838 vat_json_object_add_ip6 (node, "src_address", ip6);
9842 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9843 vat_json_object_add_ip4 (node, "src_address", ip4);
9846 for (i = 0; i < count; i++)
9848 s = &mp->servers[i];
9850 vat_json_object_add_uint (node, "server-table-id",
9851 ntohl (s->server_vrf_id));
9855 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9856 vat_json_object_add_ip4 (node, "src_address", ip4);
9860 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9861 vat_json_object_add_ip6 (node, "server_address", ip6);
9867 api_dhcp_proxy_dump (vat_main_t * vam)
9869 unformat_input_t *i = vam->input;
9870 vl_api_control_ping_t *mp_ping;
9871 vl_api_dhcp_proxy_dump_t *mp;
9875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9877 if (unformat (i, "ipv6"))
9881 clib_warning ("parse error '%U'", format_unformat_error, i);
9886 M (DHCP_PROXY_DUMP, mp);
9888 mp->is_ip6 = is_ipv6;
9891 /* Use a control ping for synchronization */
9892 MPING (CONTROL_PING, mp_ping);
9900 api_dhcp_proxy_set_vss (vat_main_t * vam)
9902 unformat_input_t *i = vam->input;
9903 vl_api_dhcp_proxy_set_vss_t *mp;
9907 u8 vss_type = VSS_TYPE_DEFAULT;
9908 u8 *vpn_ascii_id = 0;
9913 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9915 if (unformat (i, "tbl_id %d", &tbl_id))
9917 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9918 vss_type = VSS_TYPE_ASCII;
9919 else if (unformat (i, "fib_id %d", &fib_id))
9920 vss_type = VSS_TYPE_VPN_ID;
9921 else if (unformat (i, "oui %d", &oui))
9922 vss_type = VSS_TYPE_VPN_ID;
9923 else if (unformat (i, "ipv6"))
9925 else if (unformat (i, "del"))
9933 errmsg ("missing tbl_id ");
9934 vec_free (vpn_ascii_id);
9938 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9940 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9941 vec_free (vpn_ascii_id);
9945 M (DHCP_PROXY_SET_VSS, mp);
9946 mp->tbl_id = ntohl (tbl_id);
9947 mp->vss_type = vss_type;
9950 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9951 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9953 mp->vpn_index = ntohl (fib_id);
9954 mp->oui = ntohl (oui);
9955 mp->is_ipv6 = is_ipv6;
9956 mp->is_add = is_add;
9961 vec_free (vpn_ascii_id);
9966 api_dhcp_client_config (vat_main_t * vam)
9968 unformat_input_t *i = vam->input;
9969 vl_api_dhcp_client_config_t *mp;
9971 u8 sw_if_index_set = 0;
9974 u8 disable_event = 0;
9977 /* Parse args required to build the message */
9978 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9980 if (unformat (i, "del"))
9983 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9984 sw_if_index_set = 1;
9985 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9986 sw_if_index_set = 1;
9987 else if (unformat (i, "hostname %s", &hostname))
9989 else if (unformat (i, "disable_event"))
9995 if (sw_if_index_set == 0)
9997 errmsg ("missing interface name or sw_if_index");
10001 if (vec_len (hostname) > 63)
10003 errmsg ("hostname too long");
10005 vec_add1 (hostname, 0);
10007 /* Construct the API message */
10008 M (DHCP_CLIENT_CONFIG, mp);
10010 mp->is_add = is_add;
10011 mp->client.sw_if_index = htonl (sw_if_index);
10012 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10013 vec_free (hostname);
10014 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10015 mp->client.pid = htonl (getpid ());
10020 /* Wait for a reply, return good/bad news */
10026 api_set_ip_flow_hash (vat_main_t * vam)
10028 unformat_input_t *i = vam->input;
10029 vl_api_set_ip_flow_hash_t *mp;
10041 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10043 if (unformat (i, "vrf %d", &vrf_id))
10045 else if (unformat (i, "ipv6"))
10047 else if (unformat (i, "src"))
10049 else if (unformat (i, "dst"))
10051 else if (unformat (i, "sport"))
10053 else if (unformat (i, "dport"))
10055 else if (unformat (i, "proto"))
10057 else if (unformat (i, "reverse"))
10062 clib_warning ("parse error '%U'", format_unformat_error, i);
10067 if (vrf_id_set == 0)
10069 errmsg ("missing vrf id");
10073 M (SET_IP_FLOW_HASH, mp);
10079 mp->reverse = reverse;
10080 mp->vrf_id = ntohl (vrf_id);
10081 mp->is_ipv6 = is_ipv6;
10089 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10091 unformat_input_t *i = vam->input;
10092 vl_api_sw_interface_ip6_enable_disable_t *mp;
10094 u8 sw_if_index_set = 0;
10098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10100 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10101 sw_if_index_set = 1;
10102 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10103 sw_if_index_set = 1;
10104 else if (unformat (i, "enable"))
10106 else if (unformat (i, "disable"))
10110 clib_warning ("parse error '%U'", format_unformat_error, i);
10115 if (sw_if_index_set == 0)
10117 errmsg ("missing interface name or sw_if_index");
10121 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10123 mp->sw_if_index = ntohl (sw_if_index);
10124 mp->enable = enable;
10132 api_ip6nd_proxy_add_del (vat_main_t * vam)
10134 unformat_input_t *i = vam->input;
10135 vl_api_ip6nd_proxy_add_del_t *mp;
10136 u32 sw_if_index = ~0;
10137 u8 v6_address_set = 0;
10138 ip6_address_t v6address;
10142 /* Parse args required to build the message */
10143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10145 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10147 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10149 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10150 v6_address_set = 1;
10151 if (unformat (i, "del"))
10155 clib_warning ("parse error '%U'", format_unformat_error, i);
10160 if (sw_if_index == ~0)
10162 errmsg ("missing interface name or sw_if_index");
10165 if (!v6_address_set)
10167 errmsg ("no address set");
10171 /* Construct the API message */
10172 M (IP6ND_PROXY_ADD_DEL, mp);
10174 mp->is_del = is_del;
10175 mp->sw_if_index = ntohl (sw_if_index);
10176 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10181 /* Wait for a reply, return good/bad news */
10187 api_ip6nd_proxy_dump (vat_main_t * vam)
10189 vl_api_ip6nd_proxy_dump_t *mp;
10190 vl_api_control_ping_t *mp_ping;
10193 M (IP6ND_PROXY_DUMP, mp);
10197 /* Use a control ping for synchronization */
10198 MPING (CONTROL_PING, mp_ping);
10205 static void vl_api_ip6nd_proxy_details_t_handler
10206 (vl_api_ip6nd_proxy_details_t * mp)
10208 vat_main_t *vam = &vat_main;
10210 print (vam->ofp, "host %U sw_if_index %d",
10211 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10214 static void vl_api_ip6nd_proxy_details_t_handler_json
10215 (vl_api_ip6nd_proxy_details_t * mp)
10217 vat_main_t *vam = &vat_main;
10218 struct in6_addr ip6;
10219 vat_json_node_t *node = NULL;
10221 if (VAT_JSON_ARRAY != vam->json_tree.type)
10223 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10224 vat_json_init_array (&vam->json_tree);
10226 node = vat_json_array_add (&vam->json_tree);
10228 vat_json_init_object (node);
10229 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10231 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10232 vat_json_object_add_ip6 (node, "host", ip6);
10236 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10238 unformat_input_t *i = vam->input;
10239 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10241 u8 sw_if_index_set = 0;
10242 u32 address_length = 0;
10243 u8 v6_address_set = 0;
10244 ip6_address_t v6address;
10245 u8 use_default = 0;
10246 u8 no_advertise = 0;
10248 u8 no_autoconfig = 0;
10251 u32 val_lifetime = 0;
10252 u32 pref_lifetime = 0;
10255 /* Parse args required to build the message */
10256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10258 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10259 sw_if_index_set = 1;
10260 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10261 sw_if_index_set = 1;
10262 else if (unformat (i, "%U/%d",
10263 unformat_ip6_address, &v6address, &address_length))
10264 v6_address_set = 1;
10265 else if (unformat (i, "val_life %d", &val_lifetime))
10267 else if (unformat (i, "pref_life %d", &pref_lifetime))
10269 else if (unformat (i, "def"))
10271 else if (unformat (i, "noadv"))
10273 else if (unformat (i, "offl"))
10275 else if (unformat (i, "noauto"))
10277 else if (unformat (i, "nolink"))
10279 else if (unformat (i, "isno"))
10283 clib_warning ("parse error '%U'", format_unformat_error, i);
10288 if (sw_if_index_set == 0)
10290 errmsg ("missing interface name or sw_if_index");
10293 if (!v6_address_set)
10295 errmsg ("no address set");
10299 /* Construct the API message */
10300 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10302 mp->sw_if_index = ntohl (sw_if_index);
10303 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10304 mp->address_length = address_length;
10305 mp->use_default = use_default;
10306 mp->no_advertise = no_advertise;
10307 mp->off_link = off_link;
10308 mp->no_autoconfig = no_autoconfig;
10309 mp->no_onlink = no_onlink;
10311 mp->val_lifetime = ntohl (val_lifetime);
10312 mp->pref_lifetime = ntohl (pref_lifetime);
10317 /* Wait for a reply, return good/bad news */
10323 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10325 unformat_input_t *i = vam->input;
10326 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10328 u8 sw_if_index_set = 0;
10333 u8 send_unicast = 0;
10336 u8 default_router = 0;
10337 u32 max_interval = 0;
10338 u32 min_interval = 0;
10340 u32 initial_count = 0;
10341 u32 initial_interval = 0;
10345 /* Parse args required to build the message */
10346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10348 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10349 sw_if_index_set = 1;
10350 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10351 sw_if_index_set = 1;
10352 else if (unformat (i, "maxint %d", &max_interval))
10354 else if (unformat (i, "minint %d", &min_interval))
10356 else if (unformat (i, "life %d", &lifetime))
10358 else if (unformat (i, "count %d", &initial_count))
10360 else if (unformat (i, "interval %d", &initial_interval))
10362 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10364 else if (unformat (i, "managed"))
10366 else if (unformat (i, "other"))
10368 else if (unformat (i, "ll"))
10370 else if (unformat (i, "send"))
10372 else if (unformat (i, "cease"))
10374 else if (unformat (i, "isno"))
10376 else if (unformat (i, "def"))
10377 default_router = 1;
10380 clib_warning ("parse error '%U'", format_unformat_error, i);
10385 if (sw_if_index_set == 0)
10387 errmsg ("missing interface name or sw_if_index");
10391 /* Construct the API message */
10392 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10394 mp->sw_if_index = ntohl (sw_if_index);
10395 mp->max_interval = ntohl (max_interval);
10396 mp->min_interval = ntohl (min_interval);
10397 mp->lifetime = ntohl (lifetime);
10398 mp->initial_count = ntohl (initial_count);
10399 mp->initial_interval = ntohl (initial_interval);
10400 mp->suppress = suppress;
10401 mp->managed = managed;
10403 mp->ll_option = ll_option;
10404 mp->send_unicast = send_unicast;
10407 mp->default_router = default_router;
10412 /* Wait for a reply, return good/bad news */
10418 api_set_arp_neighbor_limit (vat_main_t * vam)
10420 unformat_input_t *i = vam->input;
10421 vl_api_set_arp_neighbor_limit_t *mp;
10427 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10429 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10431 else if (unformat (i, "ipv6"))
10435 clib_warning ("parse error '%U'", format_unformat_error, i);
10440 if (limit_set == 0)
10442 errmsg ("missing limit value");
10446 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10448 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10449 mp->is_ipv6 = is_ipv6;
10457 api_l2_patch_add_del (vat_main_t * vam)
10459 unformat_input_t *i = vam->input;
10460 vl_api_l2_patch_add_del_t *mp;
10461 u32 rx_sw_if_index;
10462 u8 rx_sw_if_index_set = 0;
10463 u32 tx_sw_if_index;
10464 u8 tx_sw_if_index_set = 0;
10468 /* Parse args required to build the message */
10469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10471 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10472 rx_sw_if_index_set = 1;
10473 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10474 tx_sw_if_index_set = 1;
10475 else if (unformat (i, "rx"))
10477 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10479 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10481 rx_sw_if_index_set = 1;
10486 else if (unformat (i, "tx"))
10488 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10490 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10492 tx_sw_if_index_set = 1;
10497 else if (unformat (i, "del"))
10503 if (rx_sw_if_index_set == 0)
10505 errmsg ("missing rx interface name or rx_sw_if_index");
10509 if (tx_sw_if_index_set == 0)
10511 errmsg ("missing tx interface name or tx_sw_if_index");
10515 M (L2_PATCH_ADD_DEL, mp);
10517 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10518 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10519 mp->is_add = is_add;
10527 u8 localsid_addr[16];
10536 api_sr_localsid_add_del (vat_main_t * vam)
10538 unformat_input_t *i = vam->input;
10539 vl_api_sr_localsid_add_del_t *mp;
10542 ip6_address_t localsid;
10546 u32 fib_table = ~(u32) 0;
10547 ip6_address_t nh_addr6;
10548 ip4_address_t nh_addr4;
10549 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10550 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10552 bool nexthop_set = 0;
10556 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10558 if (unformat (i, "del"))
10560 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10561 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10563 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10565 else if (unformat (i, "behavior %u", &behavior));
10566 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10567 else if (unformat (i, "fib-table %u", &fib_table));
10568 else if (unformat (i, "end.psp %u", &behavior));
10573 M (SR_LOCALSID_ADD_DEL, mp);
10575 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10578 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10579 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10581 mp->behavior = behavior;
10582 mp->sw_if_index = ntohl (sw_if_index);
10583 mp->fib_table = ntohl (fib_table);
10584 mp->end_psp = end_psp;
10585 mp->is_del = is_del;
10593 api_ioam_enable (vat_main_t * vam)
10595 unformat_input_t *input = vam->input;
10596 vl_api_ioam_enable_t *mp;
10598 int has_trace_option = 0;
10599 int has_pot_option = 0;
10600 int has_seqno_option = 0;
10601 int has_analyse_option = 0;
10604 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10606 if (unformat (input, "trace"))
10607 has_trace_option = 1;
10608 else if (unformat (input, "pot"))
10609 has_pot_option = 1;
10610 else if (unformat (input, "seqno"))
10611 has_seqno_option = 1;
10612 else if (unformat (input, "analyse"))
10613 has_analyse_option = 1;
10617 M (IOAM_ENABLE, mp);
10618 mp->id = htons (id);
10619 mp->seqno = has_seqno_option;
10620 mp->analyse = has_analyse_option;
10621 mp->pot_enable = has_pot_option;
10622 mp->trace_enable = has_trace_option;
10631 api_ioam_disable (vat_main_t * vam)
10633 vl_api_ioam_disable_t *mp;
10636 M (IOAM_DISABLE, mp);
10642 #define foreach_tcp_proto_field \
10646 #define foreach_udp_proto_field \
10650 #define foreach_ip4_proto_field \
10662 u16 src_port, dst_port;
10665 #if VPP_API_TEST_BUILTIN == 0
10667 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10669 u8 **maskp = va_arg (*args, u8 **);
10671 u8 found_something = 0;
10674 #define _(a) u8 a=0;
10675 foreach_tcp_proto_field;
10678 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10681 #define _(a) else if (unformat (input, #a)) a=1;
10682 foreach_tcp_proto_field
10688 #define _(a) found_something += a;
10689 foreach_tcp_proto_field;
10692 if (found_something == 0)
10695 vec_validate (mask, sizeof (*tcp) - 1);
10697 tcp = (tcp_header_t *) mask;
10699 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10700 foreach_tcp_proto_field;
10708 unformat_udp_mask (unformat_input_t * input, va_list * args)
10710 u8 **maskp = va_arg (*args, u8 **);
10712 u8 found_something = 0;
10715 #define _(a) u8 a=0;
10716 foreach_udp_proto_field;
10719 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10722 #define _(a) else if (unformat (input, #a)) a=1;
10723 foreach_udp_proto_field
10729 #define _(a) found_something += a;
10730 foreach_udp_proto_field;
10733 if (found_something == 0)
10736 vec_validate (mask, sizeof (*udp) - 1);
10738 udp = (udp_header_t *) mask;
10740 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10741 foreach_udp_proto_field;
10749 unformat_l4_mask (unformat_input_t * input, va_list * args)
10751 u8 **maskp = va_arg (*args, u8 **);
10752 u16 src_port = 0, dst_port = 0;
10753 tcpudp_header_t *tcpudp;
10755 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10757 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10759 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10761 else if (unformat (input, "src_port"))
10763 else if (unformat (input, "dst_port"))
10769 if (!src_port && !dst_port)
10773 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10775 tcpudp = (tcpudp_header_t *) mask;
10776 tcpudp->src_port = src_port;
10777 tcpudp->dst_port = dst_port;
10785 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10787 u8 **maskp = va_arg (*args, u8 **);
10789 u8 found_something = 0;
10792 #define _(a) u8 a=0;
10793 foreach_ip4_proto_field;
10799 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10801 if (unformat (input, "version"))
10803 else if (unformat (input, "hdr_length"))
10805 else if (unformat (input, "src"))
10807 else if (unformat (input, "dst"))
10809 else if (unformat (input, "proto"))
10812 #define _(a) else if (unformat (input, #a)) a=1;
10813 foreach_ip4_proto_field
10819 #define _(a) found_something += a;
10820 foreach_ip4_proto_field;
10823 if (found_something == 0)
10826 vec_validate (mask, sizeof (*ip) - 1);
10828 ip = (ip4_header_t *) mask;
10830 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10831 foreach_ip4_proto_field;
10834 ip->ip_version_and_header_length = 0;
10837 ip->ip_version_and_header_length |= 0xF0;
10840 ip->ip_version_and_header_length |= 0x0F;
10846 #define foreach_ip6_proto_field \
10849 _(payload_length) \
10854 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10856 u8 **maskp = va_arg (*args, u8 **);
10858 u8 found_something = 0;
10860 u32 ip_version_traffic_class_and_flow_label;
10862 #define _(a) u8 a=0;
10863 foreach_ip6_proto_field;
10866 u8 traffic_class = 0;
10869 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10871 if (unformat (input, "version"))
10873 else if (unformat (input, "traffic-class"))
10875 else if (unformat (input, "flow-label"))
10877 else if (unformat (input, "src"))
10879 else if (unformat (input, "dst"))
10881 else if (unformat (input, "proto"))
10884 #define _(a) else if (unformat (input, #a)) a=1;
10885 foreach_ip6_proto_field
10891 #define _(a) found_something += a;
10892 foreach_ip6_proto_field;
10895 if (found_something == 0)
10898 vec_validate (mask, sizeof (*ip) - 1);
10900 ip = (ip6_header_t *) mask;
10902 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10903 foreach_ip6_proto_field;
10906 ip_version_traffic_class_and_flow_label = 0;
10909 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10912 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10915 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10917 ip->ip_version_traffic_class_and_flow_label =
10918 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10925 unformat_l3_mask (unformat_input_t * input, va_list * args)
10927 u8 **maskp = va_arg (*args, u8 **);
10929 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10931 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10933 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10942 unformat_l2_mask (unformat_input_t * input, va_list * args)
10944 u8 **maskp = va_arg (*args, u8 **);
10951 u8 ignore_tag1 = 0;
10952 u8 ignore_tag2 = 0;
10959 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10961 if (unformat (input, "src"))
10963 else if (unformat (input, "dst"))
10965 else if (unformat (input, "proto"))
10967 else if (unformat (input, "tag1"))
10969 else if (unformat (input, "tag2"))
10971 else if (unformat (input, "ignore-tag1"))
10973 else if (unformat (input, "ignore-tag2"))
10975 else if (unformat (input, "cos1"))
10977 else if (unformat (input, "cos2"))
10979 else if (unformat (input, "dot1q"))
10981 else if (unformat (input, "dot1ad"))
10986 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10987 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10990 if (tag1 || ignore_tag1 || cos1 || dot1q)
10992 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10995 vec_validate (mask, len - 1);
10998 clib_memset (mask, 0xff, 6);
11001 clib_memset (mask + 6, 0xff, 6);
11003 if (tag2 || dot1ad)
11005 /* inner vlan tag */
11014 mask[21] = mask[20] = 0xff;
11035 mask[16] = mask[17] = 0xff;
11045 mask[12] = mask[13] = 0xff;
11052 unformat_classify_mask (unformat_input_t * input, va_list * args)
11054 u8 **maskp = va_arg (*args, u8 **);
11055 u32 *skipp = va_arg (*args, u32 *);
11056 u32 *matchp = va_arg (*args, u32 *);
11064 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11066 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11068 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11070 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11072 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11086 if (mask || l2 || l3 || l4)
11088 if (l2 || l3 || l4)
11090 /* "With a free Ethernet header in every package" */
11092 vec_validate (l2, 13);
11096 vec_append (mask, l3);
11101 vec_append (mask, l4);
11106 /* Scan forward looking for the first significant mask octet */
11107 for (i = 0; i < vec_len (mask); i++)
11111 /* compute (skip, match) params */
11112 *skipp = i / sizeof (u32x4);
11113 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11115 /* Pad mask to an even multiple of the vector size */
11116 while (vec_len (mask) % sizeof (u32x4))
11117 vec_add1 (mask, 0);
11119 match = vec_len (mask) / sizeof (u32x4);
11121 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11123 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11124 if (*tmp || *(tmp + 1))
11129 clib_warning ("BUG: match 0");
11131 _vec_len (mask) = match * sizeof (u32x4);
11141 #endif /* VPP_API_TEST_BUILTIN */
11143 #define foreach_l2_next \
11145 _(ethernet, ETHERNET_INPUT) \
11146 _(ip4, IP4_INPUT) \
11150 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11152 u32 *miss_next_indexp = va_arg (*args, u32 *);
11153 u32 next_index = 0;
11157 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11161 if (unformat (input, "%d", &tmp))
11170 *miss_next_indexp = next_index;
11174 #define foreach_ip_next \
11177 _(rewrite, REWRITE)
11180 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11182 u32 *miss_next_indexp = va_arg (*args, u32 *);
11183 u32 next_index = 0;
11187 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11191 if (unformat (input, "%d", &tmp))
11200 *miss_next_indexp = next_index;
11204 #define foreach_acl_next \
11208 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11210 u32 *miss_next_indexp = va_arg (*args, u32 *);
11211 u32 next_index = 0;
11215 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11219 if (unformat (input, "permit"))
11224 else if (unformat (input, "%d", &tmp))
11233 *miss_next_indexp = next_index;
11238 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11240 u32 *r = va_arg (*args, u32 *);
11242 if (unformat (input, "conform-color"))
11243 *r = POLICE_CONFORM;
11244 else if (unformat (input, "exceed-color"))
11245 *r = POLICE_EXCEED;
11253 api_classify_add_del_table (vat_main_t * vam)
11255 unformat_input_t *i = vam->input;
11256 vl_api_classify_add_del_table_t *mp;
11263 u32 table_index = ~0;
11264 u32 next_table_index = ~0;
11265 u32 miss_next_index = ~0;
11266 u32 memory_size = 32 << 20;
11268 u32 current_data_flag = 0;
11269 int current_data_offset = 0;
11272 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11274 if (unformat (i, "del"))
11276 else if (unformat (i, "del-chain"))
11281 else if (unformat (i, "buckets %d", &nbuckets))
11283 else if (unformat (i, "memory_size %d", &memory_size))
11285 else if (unformat (i, "skip %d", &skip))
11287 else if (unformat (i, "match %d", &match))
11289 else if (unformat (i, "table %d", &table_index))
11291 else if (unformat (i, "mask %U", unformat_classify_mask,
11292 &mask, &skip, &match))
11294 else if (unformat (i, "next-table %d", &next_table_index))
11296 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11299 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11302 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11305 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11307 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11313 if (is_add && mask == 0)
11315 errmsg ("Mask required");
11319 if (is_add && skip == ~0)
11321 errmsg ("skip count required");
11325 if (is_add && match == ~0)
11327 errmsg ("match count required");
11331 if (!is_add && table_index == ~0)
11333 errmsg ("table index required for delete");
11337 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11339 mp->is_add = is_add;
11340 mp->del_chain = del_chain;
11341 mp->table_index = ntohl (table_index);
11342 mp->nbuckets = ntohl (nbuckets);
11343 mp->memory_size = ntohl (memory_size);
11344 mp->skip_n_vectors = ntohl (skip);
11345 mp->match_n_vectors = ntohl (match);
11346 mp->next_table_index = ntohl (next_table_index);
11347 mp->miss_next_index = ntohl (miss_next_index);
11348 mp->current_data_flag = ntohl (current_data_flag);
11349 mp->current_data_offset = ntohl (current_data_offset);
11350 mp->mask_len = ntohl (vec_len (mask));
11351 clib_memcpy (mp->mask, mask, vec_len (mask));
11360 #if VPP_API_TEST_BUILTIN == 0
11362 unformat_l4_match (unformat_input_t * input, va_list * args)
11364 u8 **matchp = va_arg (*args, u8 **);
11366 u8 *proto_header = 0;
11372 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11374 if (unformat (input, "src_port %d", &src_port))
11376 else if (unformat (input, "dst_port %d", &dst_port))
11382 h.src_port = clib_host_to_net_u16 (src_port);
11383 h.dst_port = clib_host_to_net_u16 (dst_port);
11384 vec_validate (proto_header, sizeof (h) - 1);
11385 memcpy (proto_header, &h, sizeof (h));
11387 *matchp = proto_header;
11393 unformat_ip4_match (unformat_input_t * input, va_list * args)
11395 u8 **matchp = va_arg (*args, u8 **);
11400 int hdr_length = 0;
11401 u32 hdr_length_val;
11402 int src = 0, dst = 0;
11403 ip4_address_t src_val, dst_val;
11410 int fragment_id = 0;
11411 u32 fragment_id_val;
11417 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11419 if (unformat (input, "version %d", &version_val))
11421 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11423 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11425 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11427 else if (unformat (input, "proto %d", &proto_val))
11429 else if (unformat (input, "tos %d", &tos_val))
11431 else if (unformat (input, "length %d", &length_val))
11433 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11435 else if (unformat (input, "ttl %d", &ttl_val))
11437 else if (unformat (input, "checksum %d", &checksum_val))
11443 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11444 + ttl + checksum == 0)
11448 * Aligned because we use the real comparison functions
11450 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11452 ip = (ip4_header_t *) match;
11454 /* These are realistically matched in practice */
11456 ip->src_address.as_u32 = src_val.as_u32;
11459 ip->dst_address.as_u32 = dst_val.as_u32;
11462 ip->protocol = proto_val;
11465 /* These are not, but they're included for completeness */
11467 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11470 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11476 ip->length = clib_host_to_net_u16 (length_val);
11482 ip->checksum = clib_host_to_net_u16 (checksum_val);
11489 unformat_ip6_match (unformat_input_t * input, va_list * args)
11491 u8 **matchp = va_arg (*args, u8 **);
11496 u8 traffic_class = 0;
11497 u32 traffic_class_val = 0;
11500 int src = 0, dst = 0;
11501 ip6_address_t src_val, dst_val;
11504 int payload_length = 0;
11505 u32 payload_length_val;
11508 u32 ip_version_traffic_class_and_flow_label;
11510 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11512 if (unformat (input, "version %d", &version_val))
11514 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11516 else if (unformat (input, "flow_label %d", &flow_label_val))
11518 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11520 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11522 else if (unformat (input, "proto %d", &proto_val))
11524 else if (unformat (input, "payload_length %d", &payload_length_val))
11525 payload_length = 1;
11526 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11532 if (version + traffic_class + flow_label + src + dst + proto +
11533 payload_length + hop_limit == 0)
11537 * Aligned because we use the real comparison functions
11539 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11541 ip = (ip6_header_t *) match;
11544 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11547 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11550 ip->protocol = proto_val;
11552 ip_version_traffic_class_and_flow_label = 0;
11555 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11558 ip_version_traffic_class_and_flow_label |=
11559 (traffic_class_val & 0xFF) << 20;
11562 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11564 ip->ip_version_traffic_class_and_flow_label =
11565 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11567 if (payload_length)
11568 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11571 ip->hop_limit = hop_limit_val;
11578 unformat_l3_match (unformat_input_t * input, va_list * args)
11580 u8 **matchp = va_arg (*args, u8 **);
11582 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11584 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11586 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11595 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11597 u8 *tagp = va_arg (*args, u8 *);
11600 if (unformat (input, "%d", &tag))
11602 tagp[0] = (tag >> 8) & 0x0F;
11603 tagp[1] = tag & 0xFF;
11611 unformat_l2_match (unformat_input_t * input, va_list * args)
11613 u8 **matchp = va_arg (*args, u8 **);
11626 u8 ignore_tag1 = 0;
11627 u8 ignore_tag2 = 0;
11633 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11635 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11638 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11640 else if (unformat (input, "proto %U",
11641 unformat_ethernet_type_host_byte_order, &proto_val))
11643 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11645 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11647 else if (unformat (input, "ignore-tag1"))
11649 else if (unformat (input, "ignore-tag2"))
11651 else if (unformat (input, "cos1 %d", &cos1_val))
11653 else if (unformat (input, "cos2 %d", &cos2_val))
11658 if ((src + dst + proto + tag1 + tag2 +
11659 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11662 if (tag1 || ignore_tag1 || cos1)
11664 if (tag2 || ignore_tag2 || cos2)
11667 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11670 clib_memcpy (match, dst_val, 6);
11673 clib_memcpy (match + 6, src_val, 6);
11677 /* inner vlan tag */
11678 match[19] = tag2_val[1];
11679 match[18] = tag2_val[0];
11681 match[18] |= (cos2_val & 0x7) << 5;
11684 match[21] = proto_val & 0xff;
11685 match[20] = proto_val >> 8;
11689 match[15] = tag1_val[1];
11690 match[14] = tag1_val[0];
11693 match[14] |= (cos1_val & 0x7) << 5;
11699 match[15] = tag1_val[1];
11700 match[14] = tag1_val[0];
11703 match[17] = proto_val & 0xff;
11704 match[16] = proto_val >> 8;
11707 match[14] |= (cos1_val & 0x7) << 5;
11713 match[18] |= (cos2_val & 0x7) << 5;
11715 match[14] |= (cos1_val & 0x7) << 5;
11718 match[13] = proto_val & 0xff;
11719 match[12] = proto_val >> 8;
11727 unformat_qos_source (unformat_input_t * input, va_list * args)
11729 int *qs = va_arg (*args, int *);
11731 if (unformat (input, "ip"))
11732 *qs = QOS_SOURCE_IP;
11733 else if (unformat (input, "mpls"))
11734 *qs = QOS_SOURCE_MPLS;
11735 else if (unformat (input, "ext"))
11736 *qs = QOS_SOURCE_EXT;
11737 else if (unformat (input, "vlan"))
11738 *qs = QOS_SOURCE_VLAN;
11747 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11749 u8 **matchp = va_arg (*args, u8 **);
11750 u32 skip_n_vectors = va_arg (*args, u32);
11751 u32 match_n_vectors = va_arg (*args, u32);
11758 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11760 if (unformat (input, "hex %U", unformat_hex_string, &match))
11762 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11764 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11766 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11780 if (match || l2 || l3 || l4)
11782 if (l2 || l3 || l4)
11784 /* "Win a free Ethernet header in every packet" */
11786 vec_validate_aligned (l2, 13, sizeof (u32x4));
11790 vec_append_aligned (match, l3, sizeof (u32x4));
11795 vec_append_aligned (match, l4, sizeof (u32x4));
11800 /* Make sure the vector is big enough even if key is all 0's */
11801 vec_validate_aligned
11802 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11805 /* Set size, include skipped vectors */
11806 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11817 api_classify_add_del_session (vat_main_t * vam)
11819 unformat_input_t *i = vam->input;
11820 vl_api_classify_add_del_session_t *mp;
11822 u32 table_index = ~0;
11823 u32 hit_next_index = ~0;
11824 u32 opaque_index = ~0;
11827 u32 skip_n_vectors = 0;
11828 u32 match_n_vectors = 0;
11834 * Warning: you have to supply skip_n and match_n
11835 * because the API client cant simply look at the classify
11839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11841 if (unformat (i, "del"))
11843 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11846 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11849 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11852 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11854 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11856 else if (unformat (i, "opaque-index %d", &opaque_index))
11858 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11860 else if (unformat (i, "match_n %d", &match_n_vectors))
11862 else if (unformat (i, "match %U", api_unformat_classify_match,
11863 &match, skip_n_vectors, match_n_vectors))
11865 else if (unformat (i, "advance %d", &advance))
11867 else if (unformat (i, "table-index %d", &table_index))
11869 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11871 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11873 else if (unformat (i, "action %d", &action))
11875 else if (unformat (i, "metadata %d", &metadata))
11881 if (table_index == ~0)
11883 errmsg ("Table index required");
11887 if (is_add && match == 0)
11889 errmsg ("Match value required");
11893 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11895 mp->is_add = is_add;
11896 mp->table_index = ntohl (table_index);
11897 mp->hit_next_index = ntohl (hit_next_index);
11898 mp->opaque_index = ntohl (opaque_index);
11899 mp->advance = ntohl (advance);
11900 mp->action = action;
11901 mp->metadata = ntohl (metadata);
11902 mp->match_len = ntohl (vec_len (match));
11903 clib_memcpy (mp->match, match, vec_len (match));
11912 api_classify_set_interface_ip_table (vat_main_t * vam)
11914 unformat_input_t *i = vam->input;
11915 vl_api_classify_set_interface_ip_table_t *mp;
11917 int sw_if_index_set;
11918 u32 table_index = ~0;
11922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11924 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11925 sw_if_index_set = 1;
11926 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11927 sw_if_index_set = 1;
11928 else if (unformat (i, "table %d", &table_index))
11932 clib_warning ("parse error '%U'", format_unformat_error, i);
11937 if (sw_if_index_set == 0)
11939 errmsg ("missing interface name or sw_if_index");
11944 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11946 mp->sw_if_index = ntohl (sw_if_index);
11947 mp->table_index = ntohl (table_index);
11948 mp->is_ipv6 = is_ipv6;
11956 api_classify_set_interface_l2_tables (vat_main_t * vam)
11958 unformat_input_t *i = vam->input;
11959 vl_api_classify_set_interface_l2_tables_t *mp;
11961 int sw_if_index_set;
11962 u32 ip4_table_index = ~0;
11963 u32 ip6_table_index = ~0;
11964 u32 other_table_index = ~0;
11968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11970 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11971 sw_if_index_set = 1;
11972 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11973 sw_if_index_set = 1;
11974 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11976 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11978 else if (unformat (i, "other-table %d", &other_table_index))
11980 else if (unformat (i, "is-input %d", &is_input))
11984 clib_warning ("parse error '%U'", format_unformat_error, i);
11989 if (sw_if_index_set == 0)
11991 errmsg ("missing interface name or sw_if_index");
11996 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11998 mp->sw_if_index = ntohl (sw_if_index);
11999 mp->ip4_table_index = ntohl (ip4_table_index);
12000 mp->ip6_table_index = ntohl (ip6_table_index);
12001 mp->other_table_index = ntohl (other_table_index);
12002 mp->is_input = (u8) is_input;
12010 api_set_ipfix_exporter (vat_main_t * vam)
12012 unformat_input_t *i = vam->input;
12013 vl_api_set_ipfix_exporter_t *mp;
12014 ip4_address_t collector_address;
12015 u8 collector_address_set = 0;
12016 u32 collector_port = ~0;
12017 ip4_address_t src_address;
12018 u8 src_address_set = 0;
12021 u32 template_interval = ~0;
12022 u8 udp_checksum = 0;
12025 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12027 if (unformat (i, "collector_address %U", unformat_ip4_address,
12028 &collector_address))
12029 collector_address_set = 1;
12030 else if (unformat (i, "collector_port %d", &collector_port))
12032 else if (unformat (i, "src_address %U", unformat_ip4_address,
12034 src_address_set = 1;
12035 else if (unformat (i, "vrf_id %d", &vrf_id))
12037 else if (unformat (i, "path_mtu %d", &path_mtu))
12039 else if (unformat (i, "template_interval %d", &template_interval))
12041 else if (unformat (i, "udp_checksum"))
12047 if (collector_address_set == 0)
12049 errmsg ("collector_address required");
12053 if (src_address_set == 0)
12055 errmsg ("src_address required");
12059 M (SET_IPFIX_EXPORTER, mp);
12061 memcpy (mp->collector_address, collector_address.data,
12062 sizeof (collector_address.data));
12063 mp->collector_port = htons ((u16) collector_port);
12064 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12065 mp->vrf_id = htonl (vrf_id);
12066 mp->path_mtu = htonl (path_mtu);
12067 mp->template_interval = htonl (template_interval);
12068 mp->udp_checksum = udp_checksum;
12076 api_set_ipfix_classify_stream (vat_main_t * vam)
12078 unformat_input_t *i = vam->input;
12079 vl_api_set_ipfix_classify_stream_t *mp;
12081 u32 src_port = UDP_DST_PORT_ipfix;
12084 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12086 if (unformat (i, "domain %d", &domain_id))
12088 else if (unformat (i, "src_port %d", &src_port))
12092 errmsg ("unknown input `%U'", format_unformat_error, i);
12097 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12099 mp->domain_id = htonl (domain_id);
12100 mp->src_port = htons ((u16) src_port);
12108 api_ipfix_classify_table_add_del (vat_main_t * vam)
12110 unformat_input_t *i = vam->input;
12111 vl_api_ipfix_classify_table_add_del_t *mp;
12113 u32 classify_table_index = ~0;
12115 u8 transport_protocol = 255;
12118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12120 if (unformat (i, "add"))
12122 else if (unformat (i, "del"))
12124 else if (unformat (i, "table %d", &classify_table_index))
12126 else if (unformat (i, "ip4"))
12128 else if (unformat (i, "ip6"))
12130 else if (unformat (i, "tcp"))
12131 transport_protocol = 6;
12132 else if (unformat (i, "udp"))
12133 transport_protocol = 17;
12136 errmsg ("unknown input `%U'", format_unformat_error, i);
12143 errmsg ("expecting: add|del");
12146 if (classify_table_index == ~0)
12148 errmsg ("classifier table not specified");
12151 if (ip_version == 0)
12153 errmsg ("IP version not specified");
12157 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12159 mp->is_add = is_add;
12160 mp->table_id = htonl (classify_table_index);
12161 mp->ip_version = ip_version;
12162 mp->transport_protocol = transport_protocol;
12170 api_get_node_index (vat_main_t * vam)
12172 unformat_input_t *i = vam->input;
12173 vl_api_get_node_index_t *mp;
12177 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12179 if (unformat (i, "node %s", &name))
12186 errmsg ("node name required");
12189 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12191 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12195 M (GET_NODE_INDEX, mp);
12196 clib_memcpy (mp->node_name, name, vec_len (name));
12205 api_get_next_index (vat_main_t * vam)
12207 unformat_input_t *i = vam->input;
12208 vl_api_get_next_index_t *mp;
12209 u8 *node_name = 0, *next_node_name = 0;
12212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12214 if (unformat (i, "node-name %s", &node_name))
12216 else if (unformat (i, "next-node-name %s", &next_node_name))
12220 if (node_name == 0)
12222 errmsg ("node name required");
12225 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12227 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12231 if (next_node_name == 0)
12233 errmsg ("next node name required");
12236 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12238 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12242 M (GET_NEXT_INDEX, mp);
12243 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12244 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12245 vec_free (node_name);
12246 vec_free (next_node_name);
12254 api_add_node_next (vat_main_t * vam)
12256 unformat_input_t *i = vam->input;
12257 vl_api_add_node_next_t *mp;
12262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12264 if (unformat (i, "node %s", &name))
12266 else if (unformat (i, "next %s", &next))
12273 errmsg ("node name required");
12276 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12278 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12283 errmsg ("next node required");
12286 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12288 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12292 M (ADD_NODE_NEXT, mp);
12293 clib_memcpy (mp->node_name, name, vec_len (name));
12294 clib_memcpy (mp->next_name, next, vec_len (next));
12304 api_l2tpv3_create_tunnel (vat_main_t * vam)
12306 unformat_input_t *i = vam->input;
12307 ip6_address_t client_address, our_address;
12308 int client_address_set = 0;
12309 int our_address_set = 0;
12310 u32 local_session_id = 0;
12311 u32 remote_session_id = 0;
12312 u64 local_cookie = 0;
12313 u64 remote_cookie = 0;
12314 u8 l2_sublayer_present = 0;
12315 vl_api_l2tpv3_create_tunnel_t *mp;
12318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12320 if (unformat (i, "client_address %U", unformat_ip6_address,
12322 client_address_set = 1;
12323 else if (unformat (i, "our_address %U", unformat_ip6_address,
12325 our_address_set = 1;
12326 else if (unformat (i, "local_session_id %d", &local_session_id))
12328 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12330 else if (unformat (i, "local_cookie %lld", &local_cookie))
12332 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12334 else if (unformat (i, "l2-sublayer-present"))
12335 l2_sublayer_present = 1;
12340 if (client_address_set == 0)
12342 errmsg ("client_address required");
12346 if (our_address_set == 0)
12348 errmsg ("our_address required");
12352 M (L2TPV3_CREATE_TUNNEL, mp);
12354 clib_memcpy (mp->client_address, client_address.as_u8,
12355 sizeof (mp->client_address));
12357 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12359 mp->local_session_id = ntohl (local_session_id);
12360 mp->remote_session_id = ntohl (remote_session_id);
12361 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12362 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12363 mp->l2_sublayer_present = l2_sublayer_present;
12372 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12374 unformat_input_t *i = vam->input;
12376 u8 sw_if_index_set = 0;
12377 u64 new_local_cookie = 0;
12378 u64 new_remote_cookie = 0;
12379 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12384 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12385 sw_if_index_set = 1;
12386 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12387 sw_if_index_set = 1;
12388 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12390 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12396 if (sw_if_index_set == 0)
12398 errmsg ("missing interface name or sw_if_index");
12402 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12404 mp->sw_if_index = ntohl (sw_if_index);
12405 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12406 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12414 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12416 unformat_input_t *i = vam->input;
12417 vl_api_l2tpv3_interface_enable_disable_t *mp;
12419 u8 sw_if_index_set = 0;
12420 u8 enable_disable = 1;
12423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12425 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12426 sw_if_index_set = 1;
12427 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12428 sw_if_index_set = 1;
12429 else if (unformat (i, "enable"))
12430 enable_disable = 1;
12431 else if (unformat (i, "disable"))
12432 enable_disable = 0;
12437 if (sw_if_index_set == 0)
12439 errmsg ("missing interface name or sw_if_index");
12443 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12445 mp->sw_if_index = ntohl (sw_if_index);
12446 mp->enable_disable = enable_disable;
12454 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12456 unformat_input_t *i = vam->input;
12457 vl_api_l2tpv3_set_lookup_key_t *mp;
12461 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12463 if (unformat (i, "lookup_v6_src"))
12464 key = L2T_LOOKUP_SRC_ADDRESS;
12465 else if (unformat (i, "lookup_v6_dst"))
12466 key = L2T_LOOKUP_DST_ADDRESS;
12467 else if (unformat (i, "lookup_session_id"))
12468 key = L2T_LOOKUP_SESSION_ID;
12473 if (key == (u8) ~ 0)
12475 errmsg ("l2tp session lookup key unset");
12479 M (L2TPV3_SET_LOOKUP_KEY, mp);
12488 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12489 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12491 vat_main_t *vam = &vat_main;
12493 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12494 format_ip6_address, mp->our_address,
12495 format_ip6_address, mp->client_address,
12496 clib_net_to_host_u32 (mp->sw_if_index));
12499 " local cookies %016llx %016llx remote cookie %016llx",
12500 clib_net_to_host_u64 (mp->local_cookie[0]),
12501 clib_net_to_host_u64 (mp->local_cookie[1]),
12502 clib_net_to_host_u64 (mp->remote_cookie));
12504 print (vam->ofp, " local session-id %d remote session-id %d",
12505 clib_net_to_host_u32 (mp->local_session_id),
12506 clib_net_to_host_u32 (mp->remote_session_id));
12508 print (vam->ofp, " l2 specific sublayer %s\n",
12509 mp->l2_sublayer_present ? "preset" : "absent");
12513 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12514 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12516 vat_main_t *vam = &vat_main;
12517 vat_json_node_t *node = NULL;
12518 struct in6_addr addr;
12520 if (VAT_JSON_ARRAY != vam->json_tree.type)
12522 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12523 vat_json_init_array (&vam->json_tree);
12525 node = vat_json_array_add (&vam->json_tree);
12527 vat_json_init_object (node);
12529 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12530 vat_json_object_add_ip6 (node, "our_address", addr);
12531 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12532 vat_json_object_add_ip6 (node, "client_address", addr);
12534 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12535 vat_json_init_array (lc);
12536 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12537 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12538 vat_json_object_add_uint (node, "remote_cookie",
12539 clib_net_to_host_u64 (mp->remote_cookie));
12541 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12542 vat_json_object_add_uint (node, "local_session_id",
12543 clib_net_to_host_u32 (mp->local_session_id));
12544 vat_json_object_add_uint (node, "remote_session_id",
12545 clib_net_to_host_u32 (mp->remote_session_id));
12546 vat_json_object_add_string_copy (node, "l2_sublayer",
12547 mp->l2_sublayer_present ? (u8 *) "present"
12548 : (u8 *) "absent");
12552 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12554 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12555 vl_api_control_ping_t *mp_ping;
12558 /* Get list of l2tpv3-tunnel interfaces */
12559 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12562 /* Use a control ping for synchronization */
12563 MPING (CONTROL_PING, mp_ping);
12571 static void vl_api_sw_interface_tap_v2_details_t_handler
12572 (vl_api_sw_interface_tap_v2_details_t * mp)
12574 vat_main_t *vam = &vat_main;
12576 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12577 mp->host_ip4_prefix_len);
12578 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12579 mp->host_ip6_prefix_len);
12582 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12583 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12584 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12585 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12586 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12592 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12593 (vl_api_sw_interface_tap_v2_details_t * mp)
12595 vat_main_t *vam = &vat_main;
12596 vat_json_node_t *node = NULL;
12598 if (VAT_JSON_ARRAY != vam->json_tree.type)
12600 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12601 vat_json_init_array (&vam->json_tree);
12603 node = vat_json_array_add (&vam->json_tree);
12605 vat_json_init_object (node);
12606 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12607 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12608 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12609 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12610 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12611 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12612 vat_json_object_add_string_copy (node, "host_mac_addr",
12613 format (0, "%U", format_ethernet_address,
12614 &mp->host_mac_addr));
12615 vat_json_object_add_string_copy (node, "host_namespace",
12616 mp->host_namespace);
12617 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12618 vat_json_object_add_string_copy (node, "host_ip4_addr",
12619 format (0, "%U/%d", format_ip4_address,
12621 mp->host_ip4_prefix_len));
12622 vat_json_object_add_string_copy (node, "host_ip6_addr",
12623 format (0, "%U/%d", format_ip6_address,
12625 mp->host_ip6_prefix_len));
12630 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12632 vl_api_sw_interface_tap_v2_dump_t *mp;
12633 vl_api_control_ping_t *mp_ping;
12637 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12638 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12639 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12642 /* Get list of tap interfaces */
12643 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12646 /* Use a control ping for synchronization */
12647 MPING (CONTROL_PING, mp_ping);
12654 static void vl_api_sw_interface_virtio_pci_details_t_handler
12655 (vl_api_sw_interface_virtio_pci_details_t * mp)
12657 vat_main_t *vam = &vat_main;
12671 addr.as_u32 = ntohl (mp->pci_addr);
12672 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
12673 addr.slot, addr.function);
12676 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
12677 pci_addr, ntohl (mp->sw_if_index),
12678 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12679 format_ethernet_address, mp->mac_addr,
12680 clib_net_to_host_u64 (mp->features));
12681 vec_free (pci_addr);
12684 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
12685 (vl_api_sw_interface_virtio_pci_details_t * mp)
12687 vat_main_t *vam = &vat_main;
12688 vat_json_node_t *node = NULL;
12690 if (VAT_JSON_ARRAY != vam->json_tree.type)
12692 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12693 vat_json_init_array (&vam->json_tree);
12695 node = vat_json_array_add (&vam->json_tree);
12697 vat_json_init_object (node);
12698 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
12699 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12700 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12701 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12702 vat_json_object_add_uint (node, "features",
12703 clib_net_to_host_u64 (mp->features));
12704 vat_json_object_add_string_copy (node, "mac_addr",
12705 format (0, "%U", format_ethernet_address,
12710 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12712 vl_api_sw_interface_virtio_pci_dump_t *mp;
12713 vl_api_control_ping_t *mp_ping;
12717 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12718 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12719 "mac_addr", "features");
12721 /* Get list of tap interfaces */
12722 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12725 /* Use a control ping for synchronization */
12726 MPING (CONTROL_PING, mp_ping);
12734 api_vxlan_offload_rx (vat_main_t * vam)
12736 unformat_input_t *line_input = vam->input;
12737 vl_api_vxlan_offload_rx_t *mp;
12738 u32 hw_if_index = ~0, rx_if_index = ~0;
12742 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12744 if (unformat (line_input, "del"))
12746 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12749 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12751 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12754 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12758 errmsg ("parse error '%U'", format_unformat_error, line_input);
12763 if (hw_if_index == ~0)
12765 errmsg ("no hw interface");
12769 if (rx_if_index == ~0)
12771 errmsg ("no rx tunnel");
12775 M (VXLAN_OFFLOAD_RX, mp);
12777 mp->hw_if_index = ntohl (hw_if_index);
12778 mp->sw_if_index = ntohl (rx_if_index);
12779 mp->enable = is_add;
12786 static uword unformat_vxlan_decap_next
12787 (unformat_input_t * input, va_list * args)
12789 u32 *result = va_arg (*args, u32 *);
12792 if (unformat (input, "l2"))
12793 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12794 else if (unformat (input, "%d", &tmp))
12802 api_vxlan_add_del_tunnel (vat_main_t * vam)
12804 unformat_input_t *line_input = vam->input;
12805 vl_api_vxlan_add_del_tunnel_t *mp;
12806 ip46_address_t src, dst;
12808 u8 ipv4_set = 0, ipv6_set = 0;
12813 u32 mcast_sw_if_index = ~0;
12814 u32 encap_vrf_id = 0;
12815 u32 decap_next_index = ~0;
12819 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12820 clib_memset (&src, 0, sizeof src);
12821 clib_memset (&dst, 0, sizeof dst);
12823 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12825 if (unformat (line_input, "del"))
12827 else if (unformat (line_input, "instance %d", &instance))
12830 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12836 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12842 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12848 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12853 else if (unformat (line_input, "group %U %U",
12854 unformat_ip4_address, &dst.ip4,
12855 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12857 grp_set = dst_set = 1;
12860 else if (unformat (line_input, "group %U",
12861 unformat_ip4_address, &dst.ip4))
12863 grp_set = dst_set = 1;
12866 else if (unformat (line_input, "group %U %U",
12867 unformat_ip6_address, &dst.ip6,
12868 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12870 grp_set = dst_set = 1;
12873 else if (unformat (line_input, "group %U",
12874 unformat_ip6_address, &dst.ip6))
12876 grp_set = dst_set = 1;
12880 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12882 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12884 else if (unformat (line_input, "decap-next %U",
12885 unformat_vxlan_decap_next, &decap_next_index))
12887 else if (unformat (line_input, "vni %d", &vni))
12891 errmsg ("parse error '%U'", format_unformat_error, line_input);
12898 errmsg ("tunnel src address not specified");
12903 errmsg ("tunnel dst address not specified");
12907 if (grp_set && !ip46_address_is_multicast (&dst))
12909 errmsg ("tunnel group address not multicast");
12912 if (grp_set && mcast_sw_if_index == ~0)
12914 errmsg ("tunnel nonexistent multicast device");
12917 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12919 errmsg ("tunnel dst address must be unicast");
12924 if (ipv4_set && ipv6_set)
12926 errmsg ("both IPv4 and IPv6 addresses specified");
12930 if ((vni == 0) || (vni >> 24))
12932 errmsg ("vni not specified or out of range");
12936 M (VXLAN_ADD_DEL_TUNNEL, mp);
12940 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12941 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12945 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12946 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12949 mp->instance = htonl (instance);
12950 mp->encap_vrf_id = ntohl (encap_vrf_id);
12951 mp->decap_next_index = ntohl (decap_next_index);
12952 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12953 mp->vni = ntohl (vni);
12954 mp->is_add = is_add;
12955 mp->is_ipv6 = ipv6_set;
12962 static void vl_api_vxlan_tunnel_details_t_handler
12963 (vl_api_vxlan_tunnel_details_t * mp)
12965 vat_main_t *vam = &vat_main;
12966 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12967 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12969 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12970 ntohl (mp->sw_if_index),
12971 ntohl (mp->instance),
12972 format_ip46_address, &src, IP46_TYPE_ANY,
12973 format_ip46_address, &dst, IP46_TYPE_ANY,
12974 ntohl (mp->encap_vrf_id),
12975 ntohl (mp->decap_next_index), ntohl (mp->vni),
12976 ntohl (mp->mcast_sw_if_index));
12979 static void vl_api_vxlan_tunnel_details_t_handler_json
12980 (vl_api_vxlan_tunnel_details_t * mp)
12982 vat_main_t *vam = &vat_main;
12983 vat_json_node_t *node = NULL;
12985 if (VAT_JSON_ARRAY != vam->json_tree.type)
12987 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12988 vat_json_init_array (&vam->json_tree);
12990 node = vat_json_array_add (&vam->json_tree);
12992 vat_json_init_object (node);
12993 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12995 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12999 struct in6_addr ip6;
13001 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13002 vat_json_object_add_ip6 (node, "src_address", ip6);
13003 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13004 vat_json_object_add_ip6 (node, "dst_address", ip6);
13008 struct in_addr ip4;
13010 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13011 vat_json_object_add_ip4 (node, "src_address", ip4);
13012 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13013 vat_json_object_add_ip4 (node, "dst_address", ip4);
13015 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13016 vat_json_object_add_uint (node, "decap_next_index",
13017 ntohl (mp->decap_next_index));
13018 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13019 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13020 vat_json_object_add_uint (node, "mcast_sw_if_index",
13021 ntohl (mp->mcast_sw_if_index));
13025 api_vxlan_tunnel_dump (vat_main_t * vam)
13027 unformat_input_t *i = vam->input;
13028 vl_api_vxlan_tunnel_dump_t *mp;
13029 vl_api_control_ping_t *mp_ping;
13031 u8 sw_if_index_set = 0;
13034 /* Parse args required to build the message */
13035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13037 if (unformat (i, "sw_if_index %d", &sw_if_index))
13038 sw_if_index_set = 1;
13043 if (sw_if_index_set == 0)
13048 if (!vam->json_output)
13050 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13051 "sw_if_index", "instance", "src_address", "dst_address",
13052 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13055 /* Get list of vxlan-tunnel interfaces */
13056 M (VXLAN_TUNNEL_DUMP, mp);
13058 mp->sw_if_index = htonl (sw_if_index);
13062 /* Use a control ping for synchronization */
13063 MPING (CONTROL_PING, mp_ping);
13070 static uword unformat_geneve_decap_next
13071 (unformat_input_t * input, va_list * args)
13073 u32 *result = va_arg (*args, u32 *);
13076 if (unformat (input, "l2"))
13077 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13078 else if (unformat (input, "%d", &tmp))
13086 api_geneve_add_del_tunnel (vat_main_t * vam)
13088 unformat_input_t *line_input = vam->input;
13089 vl_api_geneve_add_del_tunnel_t *mp;
13090 ip46_address_t src, dst;
13092 u8 ipv4_set = 0, ipv6_set = 0;
13096 u32 mcast_sw_if_index = ~0;
13097 u32 encap_vrf_id = 0;
13098 u32 decap_next_index = ~0;
13102 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13103 clib_memset (&src, 0, sizeof src);
13104 clib_memset (&dst, 0, sizeof dst);
13106 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13108 if (unformat (line_input, "del"))
13111 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13117 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13123 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13129 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13134 else if (unformat (line_input, "group %U %U",
13135 unformat_ip4_address, &dst.ip4,
13136 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13138 grp_set = dst_set = 1;
13141 else if (unformat (line_input, "group %U",
13142 unformat_ip4_address, &dst.ip4))
13144 grp_set = dst_set = 1;
13147 else if (unformat (line_input, "group %U %U",
13148 unformat_ip6_address, &dst.ip6,
13149 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13151 grp_set = dst_set = 1;
13154 else if (unformat (line_input, "group %U",
13155 unformat_ip6_address, &dst.ip6))
13157 grp_set = dst_set = 1;
13161 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13163 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13165 else if (unformat (line_input, "decap-next %U",
13166 unformat_geneve_decap_next, &decap_next_index))
13168 else if (unformat (line_input, "vni %d", &vni))
13172 errmsg ("parse error '%U'", format_unformat_error, line_input);
13179 errmsg ("tunnel src address not specified");
13184 errmsg ("tunnel dst address not specified");
13188 if (grp_set && !ip46_address_is_multicast (&dst))
13190 errmsg ("tunnel group address not multicast");
13193 if (grp_set && mcast_sw_if_index == ~0)
13195 errmsg ("tunnel nonexistent multicast device");
13198 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13200 errmsg ("tunnel dst address must be unicast");
13205 if (ipv4_set && ipv6_set)
13207 errmsg ("both IPv4 and IPv6 addresses specified");
13211 if ((vni == 0) || (vni >> 24))
13213 errmsg ("vni not specified or out of range");
13217 M (GENEVE_ADD_DEL_TUNNEL, mp);
13221 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13222 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13226 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13227 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13229 mp->encap_vrf_id = ntohl (encap_vrf_id);
13230 mp->decap_next_index = ntohl (decap_next_index);
13231 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13232 mp->vni = ntohl (vni);
13233 mp->is_add = is_add;
13234 mp->is_ipv6 = ipv6_set;
13241 static void vl_api_geneve_tunnel_details_t_handler
13242 (vl_api_geneve_tunnel_details_t * mp)
13244 vat_main_t *vam = &vat_main;
13245 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13246 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13248 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13249 ntohl (mp->sw_if_index),
13250 format_ip46_address, &src, IP46_TYPE_ANY,
13251 format_ip46_address, &dst, IP46_TYPE_ANY,
13252 ntohl (mp->encap_vrf_id),
13253 ntohl (mp->decap_next_index), ntohl (mp->vni),
13254 ntohl (mp->mcast_sw_if_index));
13257 static void vl_api_geneve_tunnel_details_t_handler_json
13258 (vl_api_geneve_tunnel_details_t * mp)
13260 vat_main_t *vam = &vat_main;
13261 vat_json_node_t *node = NULL;
13263 if (VAT_JSON_ARRAY != vam->json_tree.type)
13265 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13266 vat_json_init_array (&vam->json_tree);
13268 node = vat_json_array_add (&vam->json_tree);
13270 vat_json_init_object (node);
13271 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13274 struct in6_addr ip6;
13276 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13277 vat_json_object_add_ip6 (node, "src_address", ip6);
13278 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13279 vat_json_object_add_ip6 (node, "dst_address", ip6);
13283 struct in_addr ip4;
13285 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13286 vat_json_object_add_ip4 (node, "src_address", ip4);
13287 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13288 vat_json_object_add_ip4 (node, "dst_address", ip4);
13290 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13291 vat_json_object_add_uint (node, "decap_next_index",
13292 ntohl (mp->decap_next_index));
13293 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13294 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13295 vat_json_object_add_uint (node, "mcast_sw_if_index",
13296 ntohl (mp->mcast_sw_if_index));
13300 api_geneve_tunnel_dump (vat_main_t * vam)
13302 unformat_input_t *i = vam->input;
13303 vl_api_geneve_tunnel_dump_t *mp;
13304 vl_api_control_ping_t *mp_ping;
13306 u8 sw_if_index_set = 0;
13309 /* Parse args required to build the message */
13310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13312 if (unformat (i, "sw_if_index %d", &sw_if_index))
13313 sw_if_index_set = 1;
13318 if (sw_if_index_set == 0)
13323 if (!vam->json_output)
13325 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13326 "sw_if_index", "local_address", "remote_address",
13327 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13330 /* Get list of geneve-tunnel interfaces */
13331 M (GENEVE_TUNNEL_DUMP, mp);
13333 mp->sw_if_index = htonl (sw_if_index);
13337 /* Use a control ping for synchronization */
13338 M (CONTROL_PING, mp_ping);
13346 api_gre_add_del_tunnel (vat_main_t * vam)
13348 unformat_input_t *line_input = vam->input;
13349 vl_api_gre_add_del_tunnel_t *mp;
13350 ip4_address_t src4, dst4;
13351 ip6_address_t src6, dst6;
13355 u8 t_type = GRE_TUNNEL_TYPE_L3;
13358 u32 outer_fib_id = 0;
13359 u32 session_id = 0;
13363 clib_memset (&src4, 0, sizeof src4);
13364 clib_memset (&dst4, 0, sizeof dst4);
13365 clib_memset (&src6, 0, sizeof src6);
13366 clib_memset (&dst6, 0, sizeof dst6);
13368 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13370 if (unformat (line_input, "del"))
13372 else if (unformat (line_input, "instance %d", &instance))
13374 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13379 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13384 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13389 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13394 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13396 else if (unformat (line_input, "teb"))
13397 t_type = GRE_TUNNEL_TYPE_TEB;
13398 else if (unformat (line_input, "erspan %d", &session_id))
13399 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13402 errmsg ("parse error '%U'", format_unformat_error, line_input);
13409 errmsg ("tunnel src address not specified");
13414 errmsg ("tunnel dst address not specified");
13417 if (ipv4_set && ipv6_set)
13419 errmsg ("both IPv4 and IPv6 addresses specified");
13424 M (GRE_ADD_DEL_TUNNEL, mp);
13428 clib_memcpy (&mp->src_address, &src4, 4);
13429 clib_memcpy (&mp->dst_address, &dst4, 4);
13433 clib_memcpy (&mp->src_address, &src6, 16);
13434 clib_memcpy (&mp->dst_address, &dst6, 16);
13436 mp->instance = htonl (instance);
13437 mp->outer_fib_id = htonl (outer_fib_id);
13438 mp->is_add = is_add;
13439 mp->session_id = htons ((u16) session_id);
13440 mp->tunnel_type = t_type;
13441 mp->is_ipv6 = ipv6_set;
13448 static void vl_api_gre_tunnel_details_t_handler
13449 (vl_api_gre_tunnel_details_t * mp)
13451 vat_main_t *vam = &vat_main;
13452 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13453 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13455 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13456 ntohl (mp->sw_if_index),
13457 ntohl (mp->instance),
13458 format_ip46_address, &src, IP46_TYPE_ANY,
13459 format_ip46_address, &dst, IP46_TYPE_ANY,
13460 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13463 static void vl_api_gre_tunnel_details_t_handler_json
13464 (vl_api_gre_tunnel_details_t * mp)
13466 vat_main_t *vam = &vat_main;
13467 vat_json_node_t *node = NULL;
13468 struct in_addr ip4;
13469 struct in6_addr ip6;
13471 if (VAT_JSON_ARRAY != vam->json_tree.type)
13473 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13474 vat_json_init_array (&vam->json_tree);
13476 node = vat_json_array_add (&vam->json_tree);
13478 vat_json_init_object (node);
13479 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13480 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13483 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13484 vat_json_object_add_ip4 (node, "src_address", ip4);
13485 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13486 vat_json_object_add_ip4 (node, "dst_address", ip4);
13490 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13491 vat_json_object_add_ip6 (node, "src_address", ip6);
13492 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13493 vat_json_object_add_ip6 (node, "dst_address", ip6);
13495 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13496 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13497 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13498 vat_json_object_add_uint (node, "session_id", mp->session_id);
13502 api_gre_tunnel_dump (vat_main_t * vam)
13504 unformat_input_t *i = vam->input;
13505 vl_api_gre_tunnel_dump_t *mp;
13506 vl_api_control_ping_t *mp_ping;
13508 u8 sw_if_index_set = 0;
13511 /* Parse args required to build the message */
13512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13514 if (unformat (i, "sw_if_index %d", &sw_if_index))
13515 sw_if_index_set = 1;
13520 if (sw_if_index_set == 0)
13525 if (!vam->json_output)
13527 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13528 "sw_if_index", "instance", "src_address", "dst_address",
13529 "tunnel_type", "outer_fib_id", "session_id");
13532 /* Get list of gre-tunnel interfaces */
13533 M (GRE_TUNNEL_DUMP, mp);
13535 mp->sw_if_index = htonl (sw_if_index);
13539 /* Use a control ping for synchronization */
13540 MPING (CONTROL_PING, mp_ping);
13548 api_l2_fib_clear_table (vat_main_t * vam)
13550 // unformat_input_t * i = vam->input;
13551 vl_api_l2_fib_clear_table_t *mp;
13554 M (L2_FIB_CLEAR_TABLE, mp);
13562 api_l2_interface_efp_filter (vat_main_t * vam)
13564 unformat_input_t *i = vam->input;
13565 vl_api_l2_interface_efp_filter_t *mp;
13568 u8 sw_if_index_set = 0;
13571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13573 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13574 sw_if_index_set = 1;
13575 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13576 sw_if_index_set = 1;
13577 else if (unformat (i, "enable"))
13579 else if (unformat (i, "disable"))
13583 clib_warning ("parse error '%U'", format_unformat_error, i);
13588 if (sw_if_index_set == 0)
13590 errmsg ("missing sw_if_index");
13594 M (L2_INTERFACE_EFP_FILTER, mp);
13596 mp->sw_if_index = ntohl (sw_if_index);
13597 mp->enable_disable = enable;
13604 #define foreach_vtr_op \
13605 _("disable", L2_VTR_DISABLED) \
13606 _("push-1", L2_VTR_PUSH_1) \
13607 _("push-2", L2_VTR_PUSH_2) \
13608 _("pop-1", L2_VTR_POP_1) \
13609 _("pop-2", L2_VTR_POP_2) \
13610 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13611 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13612 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13613 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13616 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13618 unformat_input_t *i = vam->input;
13619 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13621 u8 sw_if_index_set = 0;
13624 u32 push_dot1q = 1;
13629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13631 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13632 sw_if_index_set = 1;
13633 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13634 sw_if_index_set = 1;
13635 else if (unformat (i, "vtr_op %d", &vtr_op))
13637 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13640 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13642 else if (unformat (i, "tag1 %d", &tag1))
13644 else if (unformat (i, "tag2 %d", &tag2))
13648 clib_warning ("parse error '%U'", format_unformat_error, i);
13653 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13655 errmsg ("missing vtr operation or sw_if_index");
13659 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13660 mp->sw_if_index = ntohl (sw_if_index);
13661 mp->vtr_op = ntohl (vtr_op);
13662 mp->push_dot1q = ntohl (push_dot1q);
13663 mp->tag1 = ntohl (tag1);
13664 mp->tag2 = ntohl (tag2);
13672 api_create_vhost_user_if (vat_main_t * vam)
13674 unformat_input_t *i = vam->input;
13675 vl_api_create_vhost_user_if_t *mp;
13678 u8 file_name_set = 0;
13679 u32 custom_dev_instance = ~0;
13681 u8 use_custom_mac = 0;
13682 u8 disable_mrg_rxbuf = 0;
13683 u8 disable_indirect_desc = 0;
13687 /* Shut up coverity */
13688 clib_memset (hwaddr, 0, sizeof (hwaddr));
13690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13692 if (unformat (i, "socket %s", &file_name))
13696 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13698 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13699 use_custom_mac = 1;
13700 else if (unformat (i, "server"))
13702 else if (unformat (i, "disable_mrg_rxbuf"))
13703 disable_mrg_rxbuf = 1;
13704 else if (unformat (i, "disable_indirect_desc"))
13705 disable_indirect_desc = 1;
13706 else if (unformat (i, "tag %s", &tag))
13712 if (file_name_set == 0)
13714 errmsg ("missing socket file name");
13718 if (vec_len (file_name) > 255)
13720 errmsg ("socket file name too long");
13723 vec_add1 (file_name, 0);
13725 M (CREATE_VHOST_USER_IF, mp);
13727 mp->is_server = is_server;
13728 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13729 mp->disable_indirect_desc = disable_indirect_desc;
13730 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13731 vec_free (file_name);
13732 if (custom_dev_instance != ~0)
13735 mp->custom_dev_instance = ntohl (custom_dev_instance);
13738 mp->use_custom_mac = use_custom_mac;
13739 clib_memcpy (mp->mac_address, hwaddr, 6);
13741 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13750 api_modify_vhost_user_if (vat_main_t * vam)
13752 unformat_input_t *i = vam->input;
13753 vl_api_modify_vhost_user_if_t *mp;
13756 u8 file_name_set = 0;
13757 u32 custom_dev_instance = ~0;
13758 u8 sw_if_index_set = 0;
13759 u32 sw_if_index = (u32) ~ 0;
13762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13764 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13765 sw_if_index_set = 1;
13766 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13767 sw_if_index_set = 1;
13768 else if (unformat (i, "socket %s", &file_name))
13772 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13774 else if (unformat (i, "server"))
13780 if (sw_if_index_set == 0)
13782 errmsg ("missing sw_if_index or interface name");
13786 if (file_name_set == 0)
13788 errmsg ("missing socket file name");
13792 if (vec_len (file_name) > 255)
13794 errmsg ("socket file name too long");
13797 vec_add1 (file_name, 0);
13799 M (MODIFY_VHOST_USER_IF, mp);
13801 mp->sw_if_index = ntohl (sw_if_index);
13802 mp->is_server = is_server;
13803 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13804 vec_free (file_name);
13805 if (custom_dev_instance != ~0)
13808 mp->custom_dev_instance = ntohl (custom_dev_instance);
13817 api_delete_vhost_user_if (vat_main_t * vam)
13819 unformat_input_t *i = vam->input;
13820 vl_api_delete_vhost_user_if_t *mp;
13821 u32 sw_if_index = ~0;
13822 u8 sw_if_index_set = 0;
13825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13827 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13828 sw_if_index_set = 1;
13829 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13830 sw_if_index_set = 1;
13835 if (sw_if_index_set == 0)
13837 errmsg ("missing sw_if_index or interface name");
13842 M (DELETE_VHOST_USER_IF, mp);
13844 mp->sw_if_index = ntohl (sw_if_index);
13851 static void vl_api_sw_interface_vhost_user_details_t_handler
13852 (vl_api_sw_interface_vhost_user_details_t * mp)
13854 vat_main_t *vam = &vat_main;
13856 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13857 (char *) mp->interface_name,
13858 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13859 clib_net_to_host_u64 (mp->features), mp->is_server,
13860 ntohl (mp->num_regions), (char *) mp->sock_filename);
13861 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13864 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13865 (vl_api_sw_interface_vhost_user_details_t * mp)
13867 vat_main_t *vam = &vat_main;
13868 vat_json_node_t *node = NULL;
13870 if (VAT_JSON_ARRAY != vam->json_tree.type)
13872 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13873 vat_json_init_array (&vam->json_tree);
13875 node = vat_json_array_add (&vam->json_tree);
13877 vat_json_init_object (node);
13878 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13879 vat_json_object_add_string_copy (node, "interface_name",
13880 mp->interface_name);
13881 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13882 ntohl (mp->virtio_net_hdr_sz));
13883 vat_json_object_add_uint (node, "features",
13884 clib_net_to_host_u64 (mp->features));
13885 vat_json_object_add_uint (node, "is_server", mp->is_server);
13886 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13887 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13888 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13892 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13894 vl_api_sw_interface_vhost_user_dump_t *mp;
13895 vl_api_control_ping_t *mp_ping;
13898 "Interface name idx hdr_sz features server regions filename");
13900 /* Get list of vhost-user interfaces */
13901 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13904 /* Use a control ping for synchronization */
13905 MPING (CONTROL_PING, mp_ping);
13913 api_show_version (vat_main_t * vam)
13915 vl_api_show_version_t *mp;
13918 M (SHOW_VERSION, mp);
13927 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13929 unformat_input_t *line_input = vam->input;
13930 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13931 ip4_address_t local4, remote4;
13932 ip6_address_t local6, remote6;
13934 u8 ipv4_set = 0, ipv6_set = 0;
13938 u32 mcast_sw_if_index = ~0;
13939 u32 encap_vrf_id = 0;
13940 u32 decap_vrf_id = 0;
13946 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13947 clib_memset (&local4, 0, sizeof local4);
13948 clib_memset (&remote4, 0, sizeof remote4);
13949 clib_memset (&local6, 0, sizeof local6);
13950 clib_memset (&remote6, 0, sizeof remote6);
13952 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13954 if (unformat (line_input, "del"))
13956 else if (unformat (line_input, "local %U",
13957 unformat_ip4_address, &local4))
13962 else if (unformat (line_input, "remote %U",
13963 unformat_ip4_address, &remote4))
13968 else if (unformat (line_input, "local %U",
13969 unformat_ip6_address, &local6))
13974 else if (unformat (line_input, "remote %U",
13975 unformat_ip6_address, &remote6))
13980 else if (unformat (line_input, "group %U %U",
13981 unformat_ip4_address, &remote4,
13982 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13984 grp_set = remote_set = 1;
13987 else if (unformat (line_input, "group %U",
13988 unformat_ip4_address, &remote4))
13990 grp_set = remote_set = 1;
13993 else if (unformat (line_input, "group %U %U",
13994 unformat_ip6_address, &remote6,
13995 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13997 grp_set = remote_set = 1;
14000 else if (unformat (line_input, "group %U",
14001 unformat_ip6_address, &remote6))
14003 grp_set = remote_set = 1;
14007 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14009 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14011 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14013 else if (unformat (line_input, "vni %d", &vni))
14015 else if (unformat (line_input, "next-ip4"))
14017 else if (unformat (line_input, "next-ip6"))
14019 else if (unformat (line_input, "next-ethernet"))
14021 else if (unformat (line_input, "next-nsh"))
14025 errmsg ("parse error '%U'", format_unformat_error, line_input);
14030 if (local_set == 0)
14032 errmsg ("tunnel local address not specified");
14035 if (remote_set == 0)
14037 errmsg ("tunnel remote address not specified");
14040 if (grp_set && mcast_sw_if_index == ~0)
14042 errmsg ("tunnel nonexistent multicast device");
14045 if (ipv4_set && ipv6_set)
14047 errmsg ("both IPv4 and IPv6 addresses specified");
14053 errmsg ("vni not specified");
14057 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14062 clib_memcpy (&mp->local, &local6, sizeof (local6));
14063 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14067 clib_memcpy (&mp->local, &local4, sizeof (local4));
14068 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14071 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14072 mp->encap_vrf_id = ntohl (encap_vrf_id);
14073 mp->decap_vrf_id = ntohl (decap_vrf_id);
14074 mp->protocol = protocol;
14075 mp->vni = ntohl (vni);
14076 mp->is_add = is_add;
14077 mp->is_ipv6 = ipv6_set;
14084 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14085 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14087 vat_main_t *vam = &vat_main;
14088 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14089 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14091 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14092 ntohl (mp->sw_if_index),
14093 format_ip46_address, &local, IP46_TYPE_ANY,
14094 format_ip46_address, &remote, IP46_TYPE_ANY,
14095 ntohl (mp->vni), mp->protocol,
14096 ntohl (mp->mcast_sw_if_index),
14097 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14101 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14102 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14104 vat_main_t *vam = &vat_main;
14105 vat_json_node_t *node = NULL;
14106 struct in_addr ip4;
14107 struct in6_addr ip6;
14109 if (VAT_JSON_ARRAY != vam->json_tree.type)
14111 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14112 vat_json_init_array (&vam->json_tree);
14114 node = vat_json_array_add (&vam->json_tree);
14116 vat_json_init_object (node);
14117 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14120 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14121 vat_json_object_add_ip6 (node, "local", ip6);
14122 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14123 vat_json_object_add_ip6 (node, "remote", ip6);
14127 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14128 vat_json_object_add_ip4 (node, "local", ip4);
14129 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14130 vat_json_object_add_ip4 (node, "remote", ip4);
14132 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14133 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14134 vat_json_object_add_uint (node, "mcast_sw_if_index",
14135 ntohl (mp->mcast_sw_if_index));
14136 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14137 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14138 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14142 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14144 unformat_input_t *i = vam->input;
14145 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14146 vl_api_control_ping_t *mp_ping;
14148 u8 sw_if_index_set = 0;
14151 /* Parse args required to build the message */
14152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14154 if (unformat (i, "sw_if_index %d", &sw_if_index))
14155 sw_if_index_set = 1;
14160 if (sw_if_index_set == 0)
14165 if (!vam->json_output)
14167 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14168 "sw_if_index", "local", "remote", "vni",
14169 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14172 /* Get list of vxlan-tunnel interfaces */
14173 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14175 mp->sw_if_index = htonl (sw_if_index);
14179 /* Use a control ping for synchronization */
14180 MPING (CONTROL_PING, mp_ping);
14187 static void vl_api_l2_fib_table_details_t_handler
14188 (vl_api_l2_fib_table_details_t * mp)
14190 vat_main_t *vam = &vat_main;
14192 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14194 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14195 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14199 static void vl_api_l2_fib_table_details_t_handler_json
14200 (vl_api_l2_fib_table_details_t * mp)
14202 vat_main_t *vam = &vat_main;
14203 vat_json_node_t *node = NULL;
14205 if (VAT_JSON_ARRAY != vam->json_tree.type)
14207 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14208 vat_json_init_array (&vam->json_tree);
14210 node = vat_json_array_add (&vam->json_tree);
14212 vat_json_init_object (node);
14213 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14214 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14215 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14216 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14217 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14218 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14222 api_l2_fib_table_dump (vat_main_t * vam)
14224 unformat_input_t *i = vam->input;
14225 vl_api_l2_fib_table_dump_t *mp;
14226 vl_api_control_ping_t *mp_ping;
14231 /* Parse args required to build the message */
14232 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14234 if (unformat (i, "bd_id %d", &bd_id))
14240 if (bd_id_set == 0)
14242 errmsg ("missing bridge domain");
14246 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14248 /* Get list of l2 fib entries */
14249 M (L2_FIB_TABLE_DUMP, mp);
14251 mp->bd_id = ntohl (bd_id);
14254 /* Use a control ping for synchronization */
14255 MPING (CONTROL_PING, mp_ping);
14264 api_interface_name_renumber (vat_main_t * vam)
14266 unformat_input_t *line_input = vam->input;
14267 vl_api_interface_name_renumber_t *mp;
14268 u32 sw_if_index = ~0;
14269 u32 new_show_dev_instance = ~0;
14272 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14274 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14277 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14279 else if (unformat (line_input, "new_show_dev_instance %d",
14280 &new_show_dev_instance))
14286 if (sw_if_index == ~0)
14288 errmsg ("missing interface name or sw_if_index");
14292 if (new_show_dev_instance == ~0)
14294 errmsg ("missing new_show_dev_instance");
14298 M (INTERFACE_NAME_RENUMBER, mp);
14300 mp->sw_if_index = ntohl (sw_if_index);
14301 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14309 api_ip_probe_neighbor (vat_main_t * vam)
14311 unformat_input_t *i = vam->input;
14312 vl_api_ip_probe_neighbor_t *mp;
14320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14322 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14324 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14326 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14328 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14339 errmsg ("missing interface");
14345 errmsg ("missing addresses");
14349 M (IP_PROBE_NEIGHBOR, mp);
14351 mp->sw_if_index = ntohl (sw_if_index);
14352 mp->is_ipv6 = is_ipv6;
14353 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14361 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14363 unformat_input_t *i = vam->input;
14364 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14365 u8 mode = IP_SCAN_V46_NEIGHBORS;
14366 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14371 if (unformat (i, "ip4"))
14372 mode = IP_SCAN_V4_NEIGHBORS;
14373 else if (unformat (i, "ip6"))
14374 mode = IP_SCAN_V6_NEIGHBORS;
14375 if (unformat (i, "both"))
14376 mode = IP_SCAN_V46_NEIGHBORS;
14377 else if (unformat (i, "disable"))
14378 mode = IP_SCAN_DISABLED;
14379 else if (unformat (i, "interval %d", &interval))
14381 else if (unformat (i, "max-time %d", &time))
14383 else if (unformat (i, "max-update %d", &update))
14385 else if (unformat (i, "delay %d", &delay))
14387 else if (unformat (i, "stale %d", &stale))
14393 if (interval > 255)
14395 errmsg ("interval cannot exceed 255 minutes.");
14400 errmsg ("max-time cannot exceed 255 usec.");
14405 errmsg ("max-update cannot exceed 255.");
14410 errmsg ("delay cannot exceed 255 msec.");
14415 errmsg ("stale cannot exceed 255 minutes.");
14419 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14421 mp->scan_interval = interval;
14422 mp->max_proc_time = time;
14423 mp->max_update = update;
14424 mp->scan_int_delay = delay;
14425 mp->stale_threshold = stale;
14433 api_want_ip4_arp_events (vat_main_t * vam)
14435 unformat_input_t *line_input = vam->input;
14436 vl_api_want_ip4_arp_events_t *mp;
14437 ip4_address_t address;
14438 int address_set = 0;
14439 u32 enable_disable = 1;
14442 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14444 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14446 else if (unformat (line_input, "del"))
14447 enable_disable = 0;
14452 if (address_set == 0)
14454 errmsg ("missing addresses");
14458 M (WANT_IP4_ARP_EVENTS, mp);
14459 mp->enable_disable = enable_disable;
14460 mp->pid = htonl (getpid ());
14461 mp->address = address.as_u32;
14469 api_want_ip6_nd_events (vat_main_t * vam)
14471 unformat_input_t *line_input = vam->input;
14472 vl_api_want_ip6_nd_events_t *mp;
14473 ip6_address_t address;
14474 int address_set = 0;
14475 u32 enable_disable = 1;
14478 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14480 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14482 else if (unformat (line_input, "del"))
14483 enable_disable = 0;
14488 if (address_set == 0)
14490 errmsg ("missing addresses");
14494 M (WANT_IP6_ND_EVENTS, mp);
14495 mp->enable_disable = enable_disable;
14496 mp->pid = htonl (getpid ());
14497 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14505 api_want_l2_macs_events (vat_main_t * vam)
14507 unformat_input_t *line_input = vam->input;
14508 vl_api_want_l2_macs_events_t *mp;
14509 u8 enable_disable = 1;
14510 u32 scan_delay = 0;
14511 u32 max_macs_in_event = 0;
14512 u32 learn_limit = 0;
14515 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14517 if (unformat (line_input, "learn-limit %d", &learn_limit))
14519 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14521 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14523 else if (unformat (line_input, "disable"))
14524 enable_disable = 0;
14529 M (WANT_L2_MACS_EVENTS, mp);
14530 mp->enable_disable = enable_disable;
14531 mp->pid = htonl (getpid ());
14532 mp->learn_limit = htonl (learn_limit);
14533 mp->scan_delay = (u8) scan_delay;
14534 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14541 api_input_acl_set_interface (vat_main_t * vam)
14543 unformat_input_t *i = vam->input;
14544 vl_api_input_acl_set_interface_t *mp;
14546 int sw_if_index_set;
14547 u32 ip4_table_index = ~0;
14548 u32 ip6_table_index = ~0;
14549 u32 l2_table_index = ~0;
14553 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14555 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14556 sw_if_index_set = 1;
14557 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14558 sw_if_index_set = 1;
14559 else if (unformat (i, "del"))
14561 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14563 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14565 else if (unformat (i, "l2-table %d", &l2_table_index))
14569 clib_warning ("parse error '%U'", format_unformat_error, i);
14574 if (sw_if_index_set == 0)
14576 errmsg ("missing interface name or sw_if_index");
14580 M (INPUT_ACL_SET_INTERFACE, mp);
14582 mp->sw_if_index = ntohl (sw_if_index);
14583 mp->ip4_table_index = ntohl (ip4_table_index);
14584 mp->ip6_table_index = ntohl (ip6_table_index);
14585 mp->l2_table_index = ntohl (l2_table_index);
14586 mp->is_add = is_add;
14594 api_output_acl_set_interface (vat_main_t * vam)
14596 unformat_input_t *i = vam->input;
14597 vl_api_output_acl_set_interface_t *mp;
14599 int sw_if_index_set;
14600 u32 ip4_table_index = ~0;
14601 u32 ip6_table_index = ~0;
14602 u32 l2_table_index = ~0;
14606 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14608 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14609 sw_if_index_set = 1;
14610 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14611 sw_if_index_set = 1;
14612 else if (unformat (i, "del"))
14614 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14616 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14618 else if (unformat (i, "l2-table %d", &l2_table_index))
14622 clib_warning ("parse error '%U'", format_unformat_error, i);
14627 if (sw_if_index_set == 0)
14629 errmsg ("missing interface name or sw_if_index");
14633 M (OUTPUT_ACL_SET_INTERFACE, mp);
14635 mp->sw_if_index = ntohl (sw_if_index);
14636 mp->ip4_table_index = ntohl (ip4_table_index);
14637 mp->ip6_table_index = ntohl (ip6_table_index);
14638 mp->l2_table_index = ntohl (l2_table_index);
14639 mp->is_add = is_add;
14647 api_ip_address_dump (vat_main_t * vam)
14649 unformat_input_t *i = vam->input;
14650 vl_api_ip_address_dump_t *mp;
14651 vl_api_control_ping_t *mp_ping;
14652 u32 sw_if_index = ~0;
14653 u8 sw_if_index_set = 0;
14658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14660 if (unformat (i, "sw_if_index %d", &sw_if_index))
14661 sw_if_index_set = 1;
14663 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14664 sw_if_index_set = 1;
14665 else if (unformat (i, "ipv4"))
14667 else if (unformat (i, "ipv6"))
14673 if (ipv4_set && ipv6_set)
14675 errmsg ("ipv4 and ipv6 flags cannot be both set");
14679 if ((!ipv4_set) && (!ipv6_set))
14681 errmsg ("no ipv4 nor ipv6 flag set");
14685 if (sw_if_index_set == 0)
14687 errmsg ("missing interface name or sw_if_index");
14691 vam->current_sw_if_index = sw_if_index;
14692 vam->is_ipv6 = ipv6_set;
14694 M (IP_ADDRESS_DUMP, mp);
14695 mp->sw_if_index = ntohl (sw_if_index);
14696 mp->is_ipv6 = ipv6_set;
14699 /* Use a control ping for synchronization */
14700 MPING (CONTROL_PING, mp_ping);
14708 api_ip_dump (vat_main_t * vam)
14710 vl_api_ip_dump_t *mp;
14711 vl_api_control_ping_t *mp_ping;
14712 unformat_input_t *in = vam->input;
14719 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14721 if (unformat (in, "ipv4"))
14723 else if (unformat (in, "ipv6"))
14729 if (ipv4_set && ipv6_set)
14731 errmsg ("ipv4 and ipv6 flags cannot be both set");
14735 if ((!ipv4_set) && (!ipv6_set))
14737 errmsg ("no ipv4 nor ipv6 flag set");
14741 is_ipv6 = ipv6_set;
14742 vam->is_ipv6 = is_ipv6;
14744 /* free old data */
14745 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14747 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14749 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14752 mp->is_ipv6 = ipv6_set;
14755 /* Use a control ping for synchronization */
14756 MPING (CONTROL_PING, mp_ping);
14764 api_ipsec_spd_add_del (vat_main_t * vam)
14766 unformat_input_t *i = vam->input;
14767 vl_api_ipsec_spd_add_del_t *mp;
14772 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14774 if (unformat (i, "spd_id %d", &spd_id))
14776 else if (unformat (i, "del"))
14780 clib_warning ("parse error '%U'", format_unformat_error, i);
14786 errmsg ("spd_id must be set");
14790 M (IPSEC_SPD_ADD_DEL, mp);
14792 mp->spd_id = ntohl (spd_id);
14793 mp->is_add = is_add;
14801 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14803 unformat_input_t *i = vam->input;
14804 vl_api_ipsec_interface_add_del_spd_t *mp;
14806 u8 sw_if_index_set = 0;
14807 u32 spd_id = (u32) ~ 0;
14811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14813 if (unformat (i, "del"))
14815 else if (unformat (i, "spd_id %d", &spd_id))
14818 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14819 sw_if_index_set = 1;
14820 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14821 sw_if_index_set = 1;
14824 clib_warning ("parse error '%U'", format_unformat_error, i);
14830 if (spd_id == (u32) ~ 0)
14832 errmsg ("spd_id must be set");
14836 if (sw_if_index_set == 0)
14838 errmsg ("missing interface name or sw_if_index");
14842 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14844 mp->spd_id = ntohl (spd_id);
14845 mp->sw_if_index = ntohl (sw_if_index);
14846 mp->is_add = is_add;
14854 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14856 unformat_input_t *i = vam->input;
14857 vl_api_ipsec_spd_add_del_entry_t *mp;
14858 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14859 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14861 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14862 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14863 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14864 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14867 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14868 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14869 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14870 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14871 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14872 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14876 if (unformat (i, "del"))
14878 if (unformat (i, "outbound"))
14880 if (unformat (i, "inbound"))
14882 else if (unformat (i, "spd_id %d", &spd_id))
14884 else if (unformat (i, "sa_id %d", &sa_id))
14886 else if (unformat (i, "priority %d", &priority))
14888 else if (unformat (i, "protocol %d", &protocol))
14890 else if (unformat (i, "lport_start %d", &lport_start))
14892 else if (unformat (i, "lport_stop %d", &lport_stop))
14894 else if (unformat (i, "rport_start %d", &rport_start))
14896 else if (unformat (i, "rport_stop %d", &rport_stop))
14900 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
14906 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
14913 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14919 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14926 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
14932 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
14939 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
14945 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
14951 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14953 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14955 clib_warning ("unsupported action: 'resolve'");
14961 clib_warning ("parse error '%U'", format_unformat_error, i);
14967 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
14969 mp->spd_id = ntohl (spd_id);
14970 mp->priority = ntohl (priority);
14971 mp->is_outbound = is_outbound;
14973 mp->is_ipv6 = is_ipv6;
14974 if (is_ipv6 || is_ip_any)
14976 clib_memcpy (mp->remote_address_start, &raddr6_start,
14977 sizeof (ip6_address_t));
14978 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
14979 sizeof (ip6_address_t));
14980 clib_memcpy (mp->local_address_start, &laddr6_start,
14981 sizeof (ip6_address_t));
14982 clib_memcpy (mp->local_address_stop, &laddr6_stop,
14983 sizeof (ip6_address_t));
14987 clib_memcpy (mp->remote_address_start, &raddr4_start,
14988 sizeof (ip4_address_t));
14989 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
14990 sizeof (ip4_address_t));
14991 clib_memcpy (mp->local_address_start, &laddr4_start,
14992 sizeof (ip4_address_t));
14993 clib_memcpy (mp->local_address_stop, &laddr4_stop,
14994 sizeof (ip4_address_t));
14996 mp->protocol = (u8) protocol;
14997 mp->local_port_start = ntohs ((u16) lport_start);
14998 mp->local_port_stop = ntohs ((u16) lport_stop);
14999 mp->remote_port_start = ntohs ((u16) rport_start);
15000 mp->remote_port_stop = ntohs ((u16) rport_stop);
15001 mp->policy = (u8) policy;
15002 mp->sa_id = ntohl (sa_id);
15003 mp->is_add = is_add;
15004 mp->is_ip_any = is_ip_any;
15011 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15013 unformat_input_t *i = vam->input;
15014 vl_api_ipsec_sad_add_del_entry_t *mp;
15015 u32 sad_id = 0, spi = 0;
15016 u8 *ck = 0, *ik = 0;
15019 u8 protocol = IPSEC_PROTOCOL_AH;
15020 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15021 u32 crypto_alg = 0, integ_alg = 0;
15022 ip4_address_t tun_src4;
15023 ip4_address_t tun_dst4;
15024 ip6_address_t tun_src6;
15025 ip6_address_t tun_dst6;
15028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15030 if (unformat (i, "del"))
15032 else if (unformat (i, "sad_id %d", &sad_id))
15034 else if (unformat (i, "spi %d", &spi))
15036 else if (unformat (i, "esp"))
15037 protocol = IPSEC_PROTOCOL_ESP;
15038 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15041 is_tunnel_ipv6 = 0;
15043 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15046 is_tunnel_ipv6 = 0;
15048 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15051 is_tunnel_ipv6 = 1;
15053 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15056 is_tunnel_ipv6 = 1;
15060 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15062 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15064 clib_warning ("unsupported crypto-alg: '%U'",
15065 format_ipsec_crypto_alg, crypto_alg);
15069 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15073 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15075 if (integ_alg >= IPSEC_INTEG_N_ALG)
15077 clib_warning ("unsupported integ-alg: '%U'",
15078 format_ipsec_integ_alg, integ_alg);
15082 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15086 clib_warning ("parse error '%U'", format_unformat_error, i);
15092 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15094 mp->sad_id = ntohl (sad_id);
15095 mp->is_add = is_add;
15096 mp->protocol = protocol;
15097 mp->spi = ntohl (spi);
15098 mp->is_tunnel = is_tunnel;
15099 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15100 mp->crypto_algorithm = crypto_alg;
15101 mp->integrity_algorithm = integ_alg;
15102 mp->crypto_key_length = vec_len (ck);
15103 mp->integrity_key_length = vec_len (ik);
15105 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15106 mp->crypto_key_length = sizeof (mp->crypto_key);
15108 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15109 mp->integrity_key_length = sizeof (mp->integrity_key);
15112 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15114 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15118 if (is_tunnel_ipv6)
15120 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15121 sizeof (ip6_address_t));
15122 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15123 sizeof (ip6_address_t));
15127 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15128 sizeof (ip4_address_t));
15129 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15130 sizeof (ip4_address_t));
15140 api_ipsec_sa_set_key (vat_main_t * vam)
15142 unformat_input_t *i = vam->input;
15143 vl_api_ipsec_sa_set_key_t *mp;
15145 u8 *ck = 0, *ik = 0;
15148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15150 if (unformat (i, "sa_id %d", &sa_id))
15152 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15154 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15158 clib_warning ("parse error '%U'", format_unformat_error, i);
15163 M (IPSEC_SA_SET_KEY, mp);
15165 mp->sa_id = ntohl (sa_id);
15166 mp->crypto_key_length = vec_len (ck);
15167 mp->integrity_key_length = vec_len (ik);
15169 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15170 mp->crypto_key_length = sizeof (mp->crypto_key);
15172 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15173 mp->integrity_key_length = sizeof (mp->integrity_key);
15176 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15178 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15186 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15188 unformat_input_t *i = vam->input;
15189 vl_api_ipsec_tunnel_if_add_del_t *mp;
15190 u32 local_spi = 0, remote_spi = 0;
15191 u32 crypto_alg = 0, integ_alg = 0;
15192 u8 *lck = NULL, *rck = NULL;
15193 u8 *lik = NULL, *rik = NULL;
15194 ip4_address_t local_ip = { {0} };
15195 ip4_address_t remote_ip = { {0} };
15198 u8 anti_replay = 0;
15203 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15205 if (unformat (i, "del"))
15207 else if (unformat (i, "esn"))
15209 else if (unformat (i, "anti_replay"))
15211 else if (unformat (i, "local_spi %d", &local_spi))
15213 else if (unformat (i, "remote_spi %d", &remote_spi))
15215 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15217 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15219 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15222 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15224 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15226 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15230 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15232 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15234 errmsg ("unsupported crypto-alg: '%U'\n",
15235 format_ipsec_crypto_alg, crypto_alg);
15241 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15243 if (integ_alg >= IPSEC_INTEG_N_ALG)
15245 errmsg ("unsupported integ-alg: '%U'\n",
15246 format_ipsec_integ_alg, integ_alg);
15250 else if (unformat (i, "instance %u", &instance))
15254 errmsg ("parse error '%U'\n", format_unformat_error, i);
15259 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15261 mp->is_add = is_add;
15263 mp->anti_replay = anti_replay;
15265 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15266 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15268 mp->local_spi = htonl (local_spi);
15269 mp->remote_spi = htonl (remote_spi);
15270 mp->crypto_alg = (u8) crypto_alg;
15272 mp->local_crypto_key_len = 0;
15275 mp->local_crypto_key_len = vec_len (lck);
15276 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15277 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15278 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15281 mp->remote_crypto_key_len = 0;
15284 mp->remote_crypto_key_len = vec_len (rck);
15285 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15286 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15287 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15290 mp->integ_alg = (u8) integ_alg;
15292 mp->local_integ_key_len = 0;
15295 mp->local_integ_key_len = vec_len (lik);
15296 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15297 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15298 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15301 mp->remote_integ_key_len = 0;
15304 mp->remote_integ_key_len = vec_len (rik);
15305 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15306 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15307 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15312 mp->renumber = renumber;
15313 mp->show_instance = ntohl (instance);
15322 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15324 vat_main_t *vam = &vat_main;
15326 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15327 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15328 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15329 "tunnel_src_addr %U tunnel_dst_addr %U "
15330 "salt %u seq_outbound %lu last_seq_inbound %lu "
15331 "replay_window %lu total_data_size %lu\n",
15332 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15334 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15335 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15336 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15337 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15338 mp->tunnel_src_addr,
15339 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15340 mp->tunnel_dst_addr,
15342 clib_net_to_host_u64 (mp->seq_outbound),
15343 clib_net_to_host_u64 (mp->last_seq_inbound),
15344 clib_net_to_host_u64 (mp->replay_window),
15345 clib_net_to_host_u64 (mp->total_data_size));
15348 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15349 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15351 static void vl_api_ipsec_sa_details_t_handler_json
15352 (vl_api_ipsec_sa_details_t * mp)
15354 vat_main_t *vam = &vat_main;
15355 vat_json_node_t *node = NULL;
15356 struct in_addr src_ip4, dst_ip4;
15357 struct in6_addr src_ip6, dst_ip6;
15359 if (VAT_JSON_ARRAY != vam->json_tree.type)
15361 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15362 vat_json_init_array (&vam->json_tree);
15364 node = vat_json_array_add (&vam->json_tree);
15366 vat_json_init_object (node);
15367 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15368 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15369 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15370 vat_json_object_add_uint (node, "proto", mp->protocol);
15371 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15372 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15373 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15374 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15375 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15376 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15377 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15378 mp->crypto_key_len);
15379 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15380 mp->integ_key_len);
15381 if (mp->is_tunnel_ip6)
15383 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15384 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15385 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15386 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15390 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15391 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15392 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15393 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15395 vat_json_object_add_uint (node, "replay_window",
15396 clib_net_to_host_u64 (mp->replay_window));
15397 vat_json_object_add_uint (node, "total_data_size",
15398 clib_net_to_host_u64 (mp->total_data_size));
15403 api_ipsec_sa_dump (vat_main_t * vam)
15405 unformat_input_t *i = vam->input;
15406 vl_api_ipsec_sa_dump_t *mp;
15407 vl_api_control_ping_t *mp_ping;
15411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15413 if (unformat (i, "sa_id %d", &sa_id))
15417 clib_warning ("parse error '%U'", format_unformat_error, i);
15422 M (IPSEC_SA_DUMP, mp);
15424 mp->sa_id = ntohl (sa_id);
15428 /* Use a control ping for synchronization */
15429 M (CONTROL_PING, mp_ping);
15437 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15439 unformat_input_t *i = vam->input;
15440 vl_api_ipsec_tunnel_if_set_key_t *mp;
15441 u32 sw_if_index = ~0;
15442 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15449 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15452 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15453 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15455 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15456 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15457 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15458 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15460 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15461 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15462 else if (unformat (i, "%U", unformat_hex_string, &key))
15466 clib_warning ("parse error '%U'", format_unformat_error, i);
15471 if (sw_if_index == ~0)
15473 errmsg ("interface must be specified");
15477 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15479 errmsg ("key type must be specified");
15485 errmsg ("algorithm must be specified");
15489 if (vec_len (key) == 0)
15491 errmsg ("key must be specified");
15495 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15497 mp->sw_if_index = htonl (sw_if_index);
15499 mp->key_type = key_type;
15500 mp->key_len = vec_len (key);
15501 clib_memcpy (mp->key, key, vec_len (key));
15510 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15512 unformat_input_t *i = vam->input;
15513 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15514 u32 sw_if_index = ~0;
15516 u8 is_outbound = (u8) ~ 0;
15519 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15521 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15523 else if (unformat (i, "sa_id %d", &sa_id))
15525 else if (unformat (i, "outbound"))
15527 else if (unformat (i, "inbound"))
15531 clib_warning ("parse error '%U'", format_unformat_error, i);
15536 if (sw_if_index == ~0)
15538 errmsg ("interface must be specified");
15544 errmsg ("SA ID must be specified");
15548 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15550 mp->sw_if_index = htonl (sw_if_index);
15551 mp->sa_id = htonl (sa_id);
15552 mp->is_outbound = is_outbound;
15561 api_ikev2_profile_add_del (vat_main_t * vam)
15563 unformat_input_t *i = vam->input;
15564 vl_api_ikev2_profile_add_del_t *mp;
15569 const char *valid_chars = "a-zA-Z0-9_";
15571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15573 if (unformat (i, "del"))
15575 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15576 vec_add1 (name, 0);
15579 errmsg ("parse error '%U'", format_unformat_error, i);
15584 if (!vec_len (name))
15586 errmsg ("profile name must be specified");
15590 if (vec_len (name) > 64)
15592 errmsg ("profile name too long");
15596 M (IKEV2_PROFILE_ADD_DEL, mp);
15598 clib_memcpy (mp->name, name, vec_len (name));
15599 mp->is_add = is_add;
15608 api_ikev2_profile_set_auth (vat_main_t * vam)
15610 unformat_input_t *i = vam->input;
15611 vl_api_ikev2_profile_set_auth_t *mp;
15614 u32 auth_method = 0;
15618 const char *valid_chars = "a-zA-Z0-9_";
15620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15622 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15623 vec_add1 (name, 0);
15624 else if (unformat (i, "auth_method %U",
15625 unformat_ikev2_auth_method, &auth_method))
15627 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15629 else if (unformat (i, "auth_data %v", &data))
15633 errmsg ("parse error '%U'", format_unformat_error, i);
15638 if (!vec_len (name))
15640 errmsg ("profile name must be specified");
15644 if (vec_len (name) > 64)
15646 errmsg ("profile name too long");
15650 if (!vec_len (data))
15652 errmsg ("auth_data must be specified");
15658 errmsg ("auth_method must be specified");
15662 M (IKEV2_PROFILE_SET_AUTH, mp);
15664 mp->is_hex = is_hex;
15665 mp->auth_method = (u8) auth_method;
15666 mp->data_len = vec_len (data);
15667 clib_memcpy (mp->name, name, vec_len (name));
15668 clib_memcpy (mp->data, data, vec_len (data));
15678 api_ikev2_profile_set_id (vat_main_t * vam)
15680 unformat_input_t *i = vam->input;
15681 vl_api_ikev2_profile_set_id_t *mp;
15689 const char *valid_chars = "a-zA-Z0-9_";
15691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15693 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15694 vec_add1 (name, 0);
15695 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15697 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15699 data = vec_new (u8, 4);
15700 clib_memcpy (data, ip4.as_u8, 4);
15702 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15704 else if (unformat (i, "id_data %v", &data))
15706 else if (unformat (i, "local"))
15708 else if (unformat (i, "remote"))
15712 errmsg ("parse error '%U'", format_unformat_error, i);
15717 if (!vec_len (name))
15719 errmsg ("profile name must be specified");
15723 if (vec_len (name) > 64)
15725 errmsg ("profile name too long");
15729 if (!vec_len (data))
15731 errmsg ("id_data must be specified");
15737 errmsg ("id_type must be specified");
15741 M (IKEV2_PROFILE_SET_ID, mp);
15743 mp->is_local = is_local;
15744 mp->id_type = (u8) id_type;
15745 mp->data_len = vec_len (data);
15746 clib_memcpy (mp->name, name, vec_len (name));
15747 clib_memcpy (mp->data, data, vec_len (data));
15757 api_ikev2_profile_set_ts (vat_main_t * vam)
15759 unformat_input_t *i = vam->input;
15760 vl_api_ikev2_profile_set_ts_t *mp;
15763 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15764 ip4_address_t start_addr, end_addr;
15766 const char *valid_chars = "a-zA-Z0-9_";
15769 start_addr.as_u32 = 0;
15770 end_addr.as_u32 = (u32) ~ 0;
15772 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15774 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15775 vec_add1 (name, 0);
15776 else if (unformat (i, "protocol %d", &proto))
15778 else if (unformat (i, "start_port %d", &start_port))
15780 else if (unformat (i, "end_port %d", &end_port))
15783 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15785 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15787 else if (unformat (i, "local"))
15789 else if (unformat (i, "remote"))
15793 errmsg ("parse error '%U'", format_unformat_error, i);
15798 if (!vec_len (name))
15800 errmsg ("profile name must be specified");
15804 if (vec_len (name) > 64)
15806 errmsg ("profile name too long");
15810 M (IKEV2_PROFILE_SET_TS, mp);
15812 mp->is_local = is_local;
15813 mp->proto = (u8) proto;
15814 mp->start_port = (u16) start_port;
15815 mp->end_port = (u16) end_port;
15816 mp->start_addr = start_addr.as_u32;
15817 mp->end_addr = end_addr.as_u32;
15818 clib_memcpy (mp->name, name, vec_len (name));
15827 api_ikev2_set_local_key (vat_main_t * vam)
15829 unformat_input_t *i = vam->input;
15830 vl_api_ikev2_set_local_key_t *mp;
15834 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15836 if (unformat (i, "file %v", &file))
15837 vec_add1 (file, 0);
15840 errmsg ("parse error '%U'", format_unformat_error, i);
15845 if (!vec_len (file))
15847 errmsg ("RSA key file must be specified");
15851 if (vec_len (file) > 256)
15853 errmsg ("file name too long");
15857 M (IKEV2_SET_LOCAL_KEY, mp);
15859 clib_memcpy (mp->key_file, file, vec_len (file));
15868 api_ikev2_set_responder (vat_main_t * vam)
15870 unformat_input_t *i = vam->input;
15871 vl_api_ikev2_set_responder_t *mp;
15874 u32 sw_if_index = ~0;
15875 ip4_address_t address;
15877 const char *valid_chars = "a-zA-Z0-9_";
15879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15882 (i, "%U interface %d address %U", unformat_token, valid_chars,
15883 &name, &sw_if_index, unformat_ip4_address, &address))
15884 vec_add1 (name, 0);
15887 errmsg ("parse error '%U'", format_unformat_error, i);
15892 if (!vec_len (name))
15894 errmsg ("profile name must be specified");
15898 if (vec_len (name) > 64)
15900 errmsg ("profile name too long");
15904 M (IKEV2_SET_RESPONDER, mp);
15906 clib_memcpy (mp->name, name, vec_len (name));
15909 mp->sw_if_index = sw_if_index;
15910 clib_memcpy (mp->address, &address, sizeof (address));
15918 api_ikev2_set_ike_transforms (vat_main_t * vam)
15920 unformat_input_t *i = vam->input;
15921 vl_api_ikev2_set_ike_transforms_t *mp;
15924 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15926 const char *valid_chars = "a-zA-Z0-9_";
15928 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15930 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15931 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15932 vec_add1 (name, 0);
15935 errmsg ("parse error '%U'", format_unformat_error, i);
15940 if (!vec_len (name))
15942 errmsg ("profile name must be specified");
15946 if (vec_len (name) > 64)
15948 errmsg ("profile name too long");
15952 M (IKEV2_SET_IKE_TRANSFORMS, mp);
15954 clib_memcpy (mp->name, name, vec_len (name));
15956 mp->crypto_alg = crypto_alg;
15957 mp->crypto_key_size = crypto_key_size;
15958 mp->integ_alg = integ_alg;
15959 mp->dh_group = dh_group;
15968 api_ikev2_set_esp_transforms (vat_main_t * vam)
15970 unformat_input_t *i = vam->input;
15971 vl_api_ikev2_set_esp_transforms_t *mp;
15974 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15976 const char *valid_chars = "a-zA-Z0-9_";
15978 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15980 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15981 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15982 vec_add1 (name, 0);
15985 errmsg ("parse error '%U'", format_unformat_error, i);
15990 if (!vec_len (name))
15992 errmsg ("profile name must be specified");
15996 if (vec_len (name) > 64)
15998 errmsg ("profile name too long");
16002 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16004 clib_memcpy (mp->name, name, vec_len (name));
16006 mp->crypto_alg = crypto_alg;
16007 mp->crypto_key_size = crypto_key_size;
16008 mp->integ_alg = integ_alg;
16009 mp->dh_group = dh_group;
16017 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16019 unformat_input_t *i = vam->input;
16020 vl_api_ikev2_set_sa_lifetime_t *mp;
16023 u64 lifetime, lifetime_maxdata;
16024 u32 lifetime_jitter, handover;
16026 const char *valid_chars = "a-zA-Z0-9_";
16028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16030 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16031 &lifetime, &lifetime_jitter, &handover,
16032 &lifetime_maxdata))
16033 vec_add1 (name, 0);
16036 errmsg ("parse error '%U'", format_unformat_error, i);
16041 if (!vec_len (name))
16043 errmsg ("profile name must be specified");
16047 if (vec_len (name) > 64)
16049 errmsg ("profile name too long");
16053 M (IKEV2_SET_SA_LIFETIME, mp);
16055 clib_memcpy (mp->name, name, vec_len (name));
16057 mp->lifetime = lifetime;
16058 mp->lifetime_jitter = lifetime_jitter;
16059 mp->handover = handover;
16060 mp->lifetime_maxdata = lifetime_maxdata;
16068 api_ikev2_initiate_sa_init (vat_main_t * vam)
16070 unformat_input_t *i = vam->input;
16071 vl_api_ikev2_initiate_sa_init_t *mp;
16075 const char *valid_chars = "a-zA-Z0-9_";
16077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16079 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16080 vec_add1 (name, 0);
16083 errmsg ("parse error '%U'", format_unformat_error, i);
16088 if (!vec_len (name))
16090 errmsg ("profile name must be specified");
16094 if (vec_len (name) > 64)
16096 errmsg ("profile name too long");
16100 M (IKEV2_INITIATE_SA_INIT, mp);
16102 clib_memcpy (mp->name, name, vec_len (name));
16111 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16113 unformat_input_t *i = vam->input;
16114 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16121 if (unformat (i, "%lx", &ispi))
16125 errmsg ("parse error '%U'", format_unformat_error, i);
16130 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16140 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16142 unformat_input_t *i = vam->input;
16143 vl_api_ikev2_initiate_del_child_sa_t *mp;
16148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16150 if (unformat (i, "%x", &ispi))
16154 errmsg ("parse error '%U'", format_unformat_error, i);
16159 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16169 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16171 unformat_input_t *i = vam->input;
16172 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16177 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16179 if (unformat (i, "%x", &ispi))
16183 errmsg ("parse error '%U'", format_unformat_error, i);
16188 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16198 api_get_first_msg_id (vat_main_t * vam)
16200 vl_api_get_first_msg_id_t *mp;
16201 unformat_input_t *i = vam->input;
16206 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16208 if (unformat (i, "client %s", &name))
16216 errmsg ("missing client name");
16219 vec_add1 (name, 0);
16221 if (vec_len (name) > 63)
16223 errmsg ("client name too long");
16227 M (GET_FIRST_MSG_ID, mp);
16228 clib_memcpy (mp->name, name, vec_len (name));
16235 api_cop_interface_enable_disable (vat_main_t * vam)
16237 unformat_input_t *line_input = vam->input;
16238 vl_api_cop_interface_enable_disable_t *mp;
16239 u32 sw_if_index = ~0;
16240 u8 enable_disable = 1;
16243 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16245 if (unformat (line_input, "disable"))
16246 enable_disable = 0;
16247 if (unformat (line_input, "enable"))
16248 enable_disable = 1;
16249 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16250 vam, &sw_if_index))
16252 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16258 if (sw_if_index == ~0)
16260 errmsg ("missing interface name or sw_if_index");
16264 /* Construct the API message */
16265 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16266 mp->sw_if_index = ntohl (sw_if_index);
16267 mp->enable_disable = enable_disable;
16271 /* Wait for the reply */
16277 api_cop_whitelist_enable_disable (vat_main_t * vam)
16279 unformat_input_t *line_input = vam->input;
16280 vl_api_cop_whitelist_enable_disable_t *mp;
16281 u32 sw_if_index = ~0;
16282 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16286 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16288 if (unformat (line_input, "ip4"))
16290 else if (unformat (line_input, "ip6"))
16292 else if (unformat (line_input, "default"))
16294 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16295 vam, &sw_if_index))
16297 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16299 else if (unformat (line_input, "fib-id %d", &fib_id))
16305 if (sw_if_index == ~0)
16307 errmsg ("missing interface name or sw_if_index");
16311 /* Construct the API message */
16312 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16313 mp->sw_if_index = ntohl (sw_if_index);
16314 mp->fib_id = ntohl (fib_id);
16317 mp->default_cop = default_cop;
16321 /* Wait for the reply */
16327 api_get_node_graph (vat_main_t * vam)
16329 vl_api_get_node_graph_t *mp;
16332 M (GET_NODE_GRAPH, mp);
16336 /* Wait for the reply */
16342 /** Used for parsing LISP eids */
16343 typedef CLIB_PACKED(struct{
16344 u8 addr[16]; /**< eid address */
16345 u32 len; /**< prefix length if IP */
16346 u8 type; /**< type of eid */
16351 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16353 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16355 clib_memset (a, 0, sizeof (a[0]));
16357 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16359 a->type = 0; /* ipv4 type */
16361 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16363 a->type = 1; /* ipv6 type */
16365 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16367 a->type = 2; /* mac type */
16369 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16371 a->type = 3; /* NSH type */
16372 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16373 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16380 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16389 lisp_eid_size_vat (u8 type)
16406 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16408 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16412 api_one_add_del_locator_set (vat_main_t * vam)
16414 unformat_input_t *input = vam->input;
16415 vl_api_one_add_del_locator_set_t *mp;
16417 u8 *locator_set_name = NULL;
16418 u8 locator_set_name_set = 0;
16419 vl_api_local_locator_t locator, *locators = 0;
16420 u32 sw_if_index, priority, weight;
16424 /* Parse args required to build the message */
16425 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16427 if (unformat (input, "del"))
16431 else if (unformat (input, "locator-set %s", &locator_set_name))
16433 locator_set_name_set = 1;
16435 else if (unformat (input, "sw_if_index %u p %u w %u",
16436 &sw_if_index, &priority, &weight))
16438 locator.sw_if_index = htonl (sw_if_index);
16439 locator.priority = priority;
16440 locator.weight = weight;
16441 vec_add1 (locators, locator);
16445 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16446 &sw_if_index, &priority, &weight))
16448 locator.sw_if_index = htonl (sw_if_index);
16449 locator.priority = priority;
16450 locator.weight = weight;
16451 vec_add1 (locators, locator);
16457 if (locator_set_name_set == 0)
16459 errmsg ("missing locator-set name");
16460 vec_free (locators);
16464 if (vec_len (locator_set_name) > 64)
16466 errmsg ("locator-set name too long");
16467 vec_free (locator_set_name);
16468 vec_free (locators);
16471 vec_add1 (locator_set_name, 0);
16473 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16475 /* Construct the API message */
16476 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16478 mp->is_add = is_add;
16479 clib_memcpy (mp->locator_set_name, locator_set_name,
16480 vec_len (locator_set_name));
16481 vec_free (locator_set_name);
16483 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16485 clib_memcpy (mp->locators, locators, data_len);
16486 vec_free (locators);
16491 /* Wait for a reply... */
16496 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16499 api_one_add_del_locator (vat_main_t * vam)
16501 unformat_input_t *input = vam->input;
16502 vl_api_one_add_del_locator_t *mp;
16503 u32 tmp_if_index = ~0;
16504 u32 sw_if_index = ~0;
16505 u8 sw_if_index_set = 0;
16506 u8 sw_if_index_if_name_set = 0;
16508 u8 priority_set = 0;
16512 u8 *locator_set_name = NULL;
16513 u8 locator_set_name_set = 0;
16516 /* Parse args required to build the message */
16517 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16519 if (unformat (input, "del"))
16523 else if (unformat (input, "locator-set %s", &locator_set_name))
16525 locator_set_name_set = 1;
16527 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16530 sw_if_index_if_name_set = 1;
16531 sw_if_index = tmp_if_index;
16533 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16535 sw_if_index_set = 1;
16536 sw_if_index = tmp_if_index;
16538 else if (unformat (input, "p %d", &priority))
16542 else if (unformat (input, "w %d", &weight))
16550 if (locator_set_name_set == 0)
16552 errmsg ("missing locator-set name");
16556 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16558 errmsg ("missing sw_if_index");
16559 vec_free (locator_set_name);
16563 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16565 errmsg ("cannot use both params interface name and sw_if_index");
16566 vec_free (locator_set_name);
16570 if (priority_set == 0)
16572 errmsg ("missing locator-set priority");
16573 vec_free (locator_set_name);
16577 if (weight_set == 0)
16579 errmsg ("missing locator-set weight");
16580 vec_free (locator_set_name);
16584 if (vec_len (locator_set_name) > 64)
16586 errmsg ("locator-set name too long");
16587 vec_free (locator_set_name);
16590 vec_add1 (locator_set_name, 0);
16592 /* Construct the API message */
16593 M (ONE_ADD_DEL_LOCATOR, mp);
16595 mp->is_add = is_add;
16596 mp->sw_if_index = ntohl (sw_if_index);
16597 mp->priority = priority;
16598 mp->weight = weight;
16599 clib_memcpy (mp->locator_set_name, locator_set_name,
16600 vec_len (locator_set_name));
16601 vec_free (locator_set_name);
16606 /* Wait for a reply... */
16611 #define api_lisp_add_del_locator api_one_add_del_locator
16614 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16616 u32 *key_id = va_arg (*args, u32 *);
16619 if (unformat (input, "%s", &s))
16621 if (!strcmp ((char *) s, "sha1"))
16622 key_id[0] = HMAC_SHA_1_96;
16623 else if (!strcmp ((char *) s, "sha256"))
16624 key_id[0] = HMAC_SHA_256_128;
16627 clib_warning ("invalid key_id: '%s'", s);
16628 key_id[0] = HMAC_NO_KEY;
16639 api_one_add_del_local_eid (vat_main_t * vam)
16641 unformat_input_t *input = vam->input;
16642 vl_api_one_add_del_local_eid_t *mp;
16645 lisp_eid_vat_t _eid, *eid = &_eid;
16646 u8 *locator_set_name = 0;
16647 u8 locator_set_name_set = 0;
16653 /* Parse args required to build the message */
16654 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16656 if (unformat (input, "del"))
16660 else if (unformat (input, "vni %d", &vni))
16664 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16668 else if (unformat (input, "locator-set %s", &locator_set_name))
16670 locator_set_name_set = 1;
16672 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
16674 else if (unformat (input, "secret-key %_%v%_", &key))
16680 if (locator_set_name_set == 0)
16682 errmsg ("missing locator-set name");
16688 errmsg ("EID address not set!");
16689 vec_free (locator_set_name);
16693 if (key && (0 == key_id))
16695 errmsg ("invalid key_id!");
16699 if (vec_len (key) > 64)
16701 errmsg ("key too long");
16706 if (vec_len (locator_set_name) > 64)
16708 errmsg ("locator-set name too long");
16709 vec_free (locator_set_name);
16712 vec_add1 (locator_set_name, 0);
16714 /* Construct the API message */
16715 M (ONE_ADD_DEL_LOCAL_EID, mp);
16717 mp->is_add = is_add;
16718 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16719 mp->eid_type = eid->type;
16720 mp->prefix_len = eid->len;
16721 mp->vni = clib_host_to_net_u32 (vni);
16722 mp->key_id = clib_host_to_net_u16 (key_id);
16723 clib_memcpy (mp->locator_set_name, locator_set_name,
16724 vec_len (locator_set_name));
16725 clib_memcpy (mp->key, key, vec_len (key));
16727 vec_free (locator_set_name);
16733 /* Wait for a reply... */
16738 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16741 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16743 u32 dp_table = 0, vni = 0;;
16744 unformat_input_t *input = vam->input;
16745 vl_api_gpe_add_del_fwd_entry_t *mp;
16747 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16748 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16749 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16750 u32 action = ~0, w;
16751 ip4_address_t rmt_rloc4, lcl_rloc4;
16752 ip6_address_t rmt_rloc6, lcl_rloc6;
16753 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16756 clib_memset (&rloc, 0, sizeof (rloc));
16758 /* Parse args required to build the message */
16759 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16761 if (unformat (input, "del"))
16763 else if (unformat (input, "add"))
16765 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16769 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16773 else if (unformat (input, "vrf %d", &dp_table))
16775 else if (unformat (input, "bd %d", &dp_table))
16777 else if (unformat (input, "vni %d", &vni))
16779 else if (unformat (input, "w %d", &w))
16783 errmsg ("No RLOC configured for setting priority/weight!");
16786 curr_rloc->weight = w;
16788 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16789 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16793 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16795 vec_add1 (lcl_locs, rloc);
16797 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16798 vec_add1 (rmt_locs, rloc);
16799 /* weight saved in rmt loc */
16800 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16802 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16803 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16806 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16808 vec_add1 (lcl_locs, rloc);
16810 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16811 vec_add1 (rmt_locs, rloc);
16812 /* weight saved in rmt loc */
16813 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16815 else if (unformat (input, "action %d", &action))
16821 clib_warning ("parse error '%U'", format_unformat_error, input);
16828 errmsg ("remote eid addresses not set");
16832 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16834 errmsg ("eid types don't match");
16838 if (0 == rmt_locs && (u32) ~ 0 == action)
16840 errmsg ("action not set for negative mapping");
16844 /* Construct the API message */
16845 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16846 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16848 mp->is_add = is_add;
16849 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16850 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16851 mp->eid_type = rmt_eid->type;
16852 mp->dp_table = clib_host_to_net_u32 (dp_table);
16853 mp->vni = clib_host_to_net_u32 (vni);
16854 mp->rmt_len = rmt_eid->len;
16855 mp->lcl_len = lcl_eid->len;
16856 mp->action = action;
16858 if (0 != rmt_locs && 0 != lcl_locs)
16860 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16861 clib_memcpy (mp->locs, lcl_locs,
16862 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16864 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16865 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16866 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16868 vec_free (lcl_locs);
16869 vec_free (rmt_locs);
16874 /* Wait for a reply... */
16880 api_one_add_del_map_server (vat_main_t * vam)
16882 unformat_input_t *input = vam->input;
16883 vl_api_one_add_del_map_server_t *mp;
16887 ip4_address_t ipv4;
16888 ip6_address_t ipv6;
16891 /* Parse args required to build the message */
16892 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16894 if (unformat (input, "del"))
16898 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16902 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16910 if (ipv4_set && ipv6_set)
16912 errmsg ("both eid v4 and v6 addresses set");
16916 if (!ipv4_set && !ipv6_set)
16918 errmsg ("eid addresses not set");
16922 /* Construct the API message */
16923 M (ONE_ADD_DEL_MAP_SERVER, mp);
16925 mp->is_add = is_add;
16929 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16934 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16940 /* Wait for a reply... */
16945 #define api_lisp_add_del_map_server api_one_add_del_map_server
16948 api_one_add_del_map_resolver (vat_main_t * vam)
16950 unformat_input_t *input = vam->input;
16951 vl_api_one_add_del_map_resolver_t *mp;
16955 ip4_address_t ipv4;
16956 ip6_address_t ipv6;
16959 /* Parse args required to build the message */
16960 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16962 if (unformat (input, "del"))
16966 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16970 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16978 if (ipv4_set && ipv6_set)
16980 errmsg ("both eid v4 and v6 addresses set");
16984 if (!ipv4_set && !ipv6_set)
16986 errmsg ("eid addresses not set");
16990 /* Construct the API message */
16991 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16993 mp->is_add = is_add;
16997 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17002 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17008 /* Wait for a reply... */
17013 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17016 api_lisp_gpe_enable_disable (vat_main_t * vam)
17018 unformat_input_t *input = vam->input;
17019 vl_api_gpe_enable_disable_t *mp;
17024 /* Parse args required to build the message */
17025 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17027 if (unformat (input, "enable"))
17032 else if (unformat (input, "disable"))
17043 errmsg ("Value not set");
17047 /* Construct the API message */
17048 M (GPE_ENABLE_DISABLE, mp);
17055 /* Wait for a reply... */
17061 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17063 unformat_input_t *input = vam->input;
17064 vl_api_one_rloc_probe_enable_disable_t *mp;
17069 /* Parse args required to build the message */
17070 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17072 if (unformat (input, "enable"))
17077 else if (unformat (input, "disable"))
17085 errmsg ("Value not set");
17089 /* Construct the API message */
17090 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17092 mp->is_enabled = is_en;
17097 /* Wait for a reply... */
17102 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17105 api_one_map_register_enable_disable (vat_main_t * vam)
17107 unformat_input_t *input = vam->input;
17108 vl_api_one_map_register_enable_disable_t *mp;
17113 /* Parse args required to build the message */
17114 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17116 if (unformat (input, "enable"))
17121 else if (unformat (input, "disable"))
17129 errmsg ("Value not set");
17133 /* Construct the API message */
17134 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17136 mp->is_enabled = is_en;
17141 /* Wait for a reply... */
17146 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17149 api_one_enable_disable (vat_main_t * vam)
17151 unformat_input_t *input = vam->input;
17152 vl_api_one_enable_disable_t *mp;
17157 /* Parse args required to build the message */
17158 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17160 if (unformat (input, "enable"))
17165 else if (unformat (input, "disable"))
17175 errmsg ("Value not set");
17179 /* Construct the API message */
17180 M (ONE_ENABLE_DISABLE, mp);
17187 /* Wait for a reply... */
17192 #define api_lisp_enable_disable api_one_enable_disable
17195 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17197 unformat_input_t *input = vam->input;
17198 vl_api_one_enable_disable_xtr_mode_t *mp;
17203 /* Parse args required to build the message */
17204 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17206 if (unformat (input, "enable"))
17211 else if (unformat (input, "disable"))
17221 errmsg ("Value not set");
17225 /* Construct the API message */
17226 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17233 /* Wait for a reply... */
17239 api_one_show_xtr_mode (vat_main_t * vam)
17241 vl_api_one_show_xtr_mode_t *mp;
17244 /* Construct the API message */
17245 M (ONE_SHOW_XTR_MODE, mp);
17250 /* Wait for a reply... */
17256 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17258 unformat_input_t *input = vam->input;
17259 vl_api_one_enable_disable_pitr_mode_t *mp;
17264 /* Parse args required to build the message */
17265 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17267 if (unformat (input, "enable"))
17272 else if (unformat (input, "disable"))
17282 errmsg ("Value not set");
17286 /* Construct the API message */
17287 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17294 /* Wait for a reply... */
17300 api_one_show_pitr_mode (vat_main_t * vam)
17302 vl_api_one_show_pitr_mode_t *mp;
17305 /* Construct the API message */
17306 M (ONE_SHOW_PITR_MODE, mp);
17311 /* Wait for a reply... */
17317 api_one_enable_disable_petr_mode (vat_main_t * vam)
17319 unformat_input_t *input = vam->input;
17320 vl_api_one_enable_disable_petr_mode_t *mp;
17325 /* Parse args required to build the message */
17326 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17328 if (unformat (input, "enable"))
17333 else if (unformat (input, "disable"))
17343 errmsg ("Value not set");
17347 /* Construct the API message */
17348 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17355 /* Wait for a reply... */
17361 api_one_show_petr_mode (vat_main_t * vam)
17363 vl_api_one_show_petr_mode_t *mp;
17366 /* Construct the API message */
17367 M (ONE_SHOW_PETR_MODE, mp);
17372 /* Wait for a reply... */
17378 api_show_one_map_register_state (vat_main_t * vam)
17380 vl_api_show_one_map_register_state_t *mp;
17383 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17388 /* wait for reply */
17393 #define api_show_lisp_map_register_state api_show_one_map_register_state
17396 api_show_one_rloc_probe_state (vat_main_t * vam)
17398 vl_api_show_one_rloc_probe_state_t *mp;
17401 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17406 /* wait for reply */
17411 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17414 api_one_add_del_ndp_entry (vat_main_t * vam)
17416 vl_api_one_add_del_ndp_entry_t *mp;
17417 unformat_input_t *input = vam->input;
17422 u8 mac[6] = { 0, };
17423 u8 ip6[16] = { 0, };
17427 /* Parse args required to build the message */
17428 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17430 if (unformat (input, "del"))
17432 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17434 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17436 else if (unformat (input, "bd %d", &bd))
17440 errmsg ("parse error '%U'", format_unformat_error, input);
17445 if (!bd_set || !ip_set || (!mac_set && is_add))
17447 errmsg ("Missing BD, IP or MAC!");
17451 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17452 mp->is_add = is_add;
17453 clib_memcpy (mp->mac, mac, 6);
17454 mp->bd = clib_host_to_net_u32 (bd);
17455 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17460 /* wait for reply */
17466 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17468 vl_api_one_add_del_l2_arp_entry_t *mp;
17469 unformat_input_t *input = vam->input;
17474 u8 mac[6] = { 0, };
17475 u32 ip4 = 0, bd = ~0;
17478 /* Parse args required to build the message */
17479 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17481 if (unformat (input, "del"))
17483 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17485 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17487 else if (unformat (input, "bd %d", &bd))
17491 errmsg ("parse error '%U'", format_unformat_error, input);
17496 if (!bd_set || !ip_set || (!mac_set && is_add))
17498 errmsg ("Missing BD, IP or MAC!");
17502 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17503 mp->is_add = is_add;
17504 clib_memcpy (mp->mac, mac, 6);
17505 mp->bd = clib_host_to_net_u32 (bd);
17511 /* wait for reply */
17517 api_one_ndp_bd_get (vat_main_t * vam)
17519 vl_api_one_ndp_bd_get_t *mp;
17522 M (ONE_NDP_BD_GET, mp);
17527 /* wait for reply */
17533 api_one_ndp_entries_get (vat_main_t * vam)
17535 vl_api_one_ndp_entries_get_t *mp;
17536 unformat_input_t *input = vam->input;
17541 /* Parse args required to build the message */
17542 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17544 if (unformat (input, "bd %d", &bd))
17548 errmsg ("parse error '%U'", format_unformat_error, input);
17555 errmsg ("Expected bridge domain!");
17559 M (ONE_NDP_ENTRIES_GET, mp);
17560 mp->bd = clib_host_to_net_u32 (bd);
17565 /* wait for reply */
17571 api_one_l2_arp_bd_get (vat_main_t * vam)
17573 vl_api_one_l2_arp_bd_get_t *mp;
17576 M (ONE_L2_ARP_BD_GET, mp);
17581 /* wait for reply */
17587 api_one_l2_arp_entries_get (vat_main_t * vam)
17589 vl_api_one_l2_arp_entries_get_t *mp;
17590 unformat_input_t *input = vam->input;
17595 /* Parse args required to build the message */
17596 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17598 if (unformat (input, "bd %d", &bd))
17602 errmsg ("parse error '%U'", format_unformat_error, input);
17609 errmsg ("Expected bridge domain!");
17613 M (ONE_L2_ARP_ENTRIES_GET, mp);
17614 mp->bd = clib_host_to_net_u32 (bd);
17619 /* wait for reply */
17625 api_one_stats_enable_disable (vat_main_t * vam)
17627 vl_api_one_stats_enable_disable_t *mp;
17628 unformat_input_t *input = vam->input;
17633 /* Parse args required to build the message */
17634 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17636 if (unformat (input, "enable"))
17641 else if (unformat (input, "disable"))
17651 errmsg ("Value not set");
17655 M (ONE_STATS_ENABLE_DISABLE, mp);
17661 /* wait for reply */
17667 api_show_one_stats_enable_disable (vat_main_t * vam)
17669 vl_api_show_one_stats_enable_disable_t *mp;
17672 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
17677 /* wait for reply */
17683 api_show_one_map_request_mode (vat_main_t * vam)
17685 vl_api_show_one_map_request_mode_t *mp;
17688 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
17693 /* wait for reply */
17698 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
17701 api_one_map_request_mode (vat_main_t * vam)
17703 unformat_input_t *input = vam->input;
17704 vl_api_one_map_request_mode_t *mp;
17708 /* Parse args required to build the message */
17709 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17711 if (unformat (input, "dst-only"))
17713 else if (unformat (input, "src-dst"))
17717 errmsg ("parse error '%U'", format_unformat_error, input);
17722 M (ONE_MAP_REQUEST_MODE, mp);
17729 /* wait for reply */
17734 #define api_lisp_map_request_mode api_one_map_request_mode
17737 * Enable/disable ONE proxy ITR.
17739 * @param vam vpp API test context
17740 * @return return code
17743 api_one_pitr_set_locator_set (vat_main_t * vam)
17745 u8 ls_name_set = 0;
17746 unformat_input_t *input = vam->input;
17747 vl_api_one_pitr_set_locator_set_t *mp;
17752 /* Parse args required to build the message */
17753 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17755 if (unformat (input, "del"))
17757 else if (unformat (input, "locator-set %s", &ls_name))
17761 errmsg ("parse error '%U'", format_unformat_error, input);
17768 errmsg ("locator-set name not set!");
17772 M (ONE_PITR_SET_LOCATOR_SET, mp);
17774 mp->is_add = is_add;
17775 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17776 vec_free (ls_name);
17781 /* wait for reply */
17786 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17789 api_one_nsh_set_locator_set (vat_main_t * vam)
17791 u8 ls_name_set = 0;
17792 unformat_input_t *input = vam->input;
17793 vl_api_one_nsh_set_locator_set_t *mp;
17798 /* Parse args required to build the message */
17799 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17801 if (unformat (input, "del"))
17803 else if (unformat (input, "ls %s", &ls_name))
17807 errmsg ("parse error '%U'", format_unformat_error, input);
17812 if (!ls_name_set && is_add)
17814 errmsg ("locator-set name not set!");
17818 M (ONE_NSH_SET_LOCATOR_SET, mp);
17820 mp->is_add = is_add;
17821 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17822 vec_free (ls_name);
17827 /* wait for reply */
17833 api_show_one_pitr (vat_main_t * vam)
17835 vl_api_show_one_pitr_t *mp;
17838 if (!vam->json_output)
17840 print (vam->ofp, "%=20s", "lisp status:");
17843 M (SHOW_ONE_PITR, mp);
17847 /* Wait for a reply... */
17852 #define api_show_lisp_pitr api_show_one_pitr
17855 api_one_use_petr (vat_main_t * vam)
17857 unformat_input_t *input = vam->input;
17858 vl_api_one_use_petr_t *mp;
17863 clib_memset (&ip, 0, sizeof (ip));
17865 /* Parse args required to build the message */
17866 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17868 if (unformat (input, "disable"))
17871 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17874 ip_addr_version (&ip) = IP4;
17877 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17880 ip_addr_version (&ip) = IP6;
17884 errmsg ("parse error '%U'", format_unformat_error, input);
17889 M (ONE_USE_PETR, mp);
17891 mp->is_add = is_add;
17894 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17896 clib_memcpy (mp->address, &ip, 4);
17898 clib_memcpy (mp->address, &ip, 16);
17904 /* wait for reply */
17909 #define api_lisp_use_petr api_one_use_petr
17912 api_show_one_nsh_mapping (vat_main_t * vam)
17914 vl_api_show_one_use_petr_t *mp;
17917 if (!vam->json_output)
17919 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17922 M (SHOW_ONE_NSH_MAPPING, mp);
17926 /* Wait for a reply... */
17932 api_show_one_use_petr (vat_main_t * vam)
17934 vl_api_show_one_use_petr_t *mp;
17937 if (!vam->json_output)
17939 print (vam->ofp, "%=20s", "Proxy-ETR status:");
17942 M (SHOW_ONE_USE_PETR, mp);
17946 /* Wait for a reply... */
17951 #define api_show_lisp_use_petr api_show_one_use_petr
17954 * Add/delete mapping between vni and vrf
17957 api_one_eid_table_add_del_map (vat_main_t * vam)
17959 unformat_input_t *input = vam->input;
17960 vl_api_one_eid_table_add_del_map_t *mp;
17961 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
17962 u32 vni, vrf, bd_index;
17965 /* Parse args required to build the message */
17966 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17968 if (unformat (input, "del"))
17970 else if (unformat (input, "vrf %d", &vrf))
17972 else if (unformat (input, "bd_index %d", &bd_index))
17974 else if (unformat (input, "vni %d", &vni))
17980 if (!vni_set || (!vrf_set && !bd_index_set))
17982 errmsg ("missing arguments!");
17986 if (vrf_set && bd_index_set)
17988 errmsg ("error: both vrf and bd entered!");
17992 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17994 mp->is_add = is_add;
17995 mp->vni = htonl (vni);
17996 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17997 mp->is_l2 = bd_index_set;
18002 /* wait for reply */
18007 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18010 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18012 u32 *action = va_arg (*args, u32 *);
18015 if (unformat (input, "%s", &s))
18017 if (!strcmp ((char *) s, "no-action"))
18019 else if (!strcmp ((char *) s, "natively-forward"))
18021 else if (!strcmp ((char *) s, "send-map-request"))
18023 else if (!strcmp ((char *) s, "drop"))
18027 clib_warning ("invalid action: '%s'", s);
18039 * Add/del remote mapping to/from ONE control plane
18041 * @param vam vpp API test context
18042 * @return return code
18045 api_one_add_del_remote_mapping (vat_main_t * vam)
18047 unformat_input_t *input = vam->input;
18048 vl_api_one_add_del_remote_mapping_t *mp;
18050 lisp_eid_vat_t _eid, *eid = &_eid;
18051 lisp_eid_vat_t _seid, *seid = &_seid;
18052 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18053 u32 action = ~0, p, w, data_len;
18054 ip4_address_t rloc4;
18055 ip6_address_t rloc6;
18056 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18059 clib_memset (&rloc, 0, sizeof (rloc));
18061 /* Parse args required to build the message */
18062 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18064 if (unformat (input, "del-all"))
18068 else if (unformat (input, "del"))
18072 else if (unformat (input, "add"))
18076 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18080 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18084 else if (unformat (input, "vni %d", &vni))
18088 else if (unformat (input, "p %d w %d", &p, &w))
18092 errmsg ("No RLOC configured for setting priority/weight!");
18095 curr_rloc->priority = p;
18096 curr_rloc->weight = w;
18098 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18101 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18102 vec_add1 (rlocs, rloc);
18103 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18105 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18108 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18109 vec_add1 (rlocs, rloc);
18110 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18112 else if (unformat (input, "action %U",
18113 unformat_negative_mapping_action, &action))
18119 clib_warning ("parse error '%U'", format_unformat_error, input);
18126 errmsg ("missing params!");
18130 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18132 errmsg ("no action set for negative map-reply!");
18136 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18138 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18139 mp->is_add = is_add;
18140 mp->vni = htonl (vni);
18141 mp->action = (u8) action;
18142 mp->is_src_dst = seid_set;
18143 mp->eid_len = eid->len;
18144 mp->seid_len = seid->len;
18145 mp->del_all = del_all;
18146 mp->eid_type = eid->type;
18147 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18148 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18150 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18151 clib_memcpy (mp->rlocs, rlocs, data_len);
18157 /* Wait for a reply... */
18162 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18165 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18166 * forwarding entries in data-plane accordingly.
18168 * @param vam vpp API test context
18169 * @return return code
18172 api_one_add_del_adjacency (vat_main_t * vam)
18174 unformat_input_t *input = vam->input;
18175 vl_api_one_add_del_adjacency_t *mp;
18177 ip4_address_t leid4, reid4;
18178 ip6_address_t leid6, reid6;
18179 u8 reid_mac[6] = { 0 };
18180 u8 leid_mac[6] = { 0 };
18181 u8 reid_type, leid_type;
18182 u32 leid_len = 0, reid_len = 0, len;
18186 leid_type = reid_type = (u8) ~ 0;
18188 /* Parse args required to build the message */
18189 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18191 if (unformat (input, "del"))
18195 else if (unformat (input, "add"))
18199 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18202 reid_type = 0; /* ipv4 */
18205 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18208 reid_type = 1; /* ipv6 */
18211 else if (unformat (input, "reid %U", unformat_ethernet_address,
18214 reid_type = 2; /* mac */
18216 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18219 leid_type = 0; /* ipv4 */
18222 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18225 leid_type = 1; /* ipv6 */
18228 else if (unformat (input, "leid %U", unformat_ethernet_address,
18231 leid_type = 2; /* mac */
18233 else if (unformat (input, "vni %d", &vni))
18239 errmsg ("parse error '%U'", format_unformat_error, input);
18244 if ((u8) ~ 0 == reid_type)
18246 errmsg ("missing params!");
18250 if (leid_type != reid_type)
18252 errmsg ("remote and local EIDs are of different types!");
18256 M (ONE_ADD_DEL_ADJACENCY, mp);
18257 mp->is_add = is_add;
18258 mp->vni = htonl (vni);
18259 mp->leid_len = leid_len;
18260 mp->reid_len = reid_len;
18261 mp->eid_type = reid_type;
18263 switch (mp->eid_type)
18266 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18267 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18270 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18271 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18274 clib_memcpy (mp->leid, leid_mac, 6);
18275 clib_memcpy (mp->reid, reid_mac, 6);
18278 errmsg ("unknown EID type %d!", mp->eid_type);
18285 /* Wait for a reply... */
18290 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18293 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18295 u32 *mode = va_arg (*args, u32 *);
18297 if (unformat (input, "lisp"))
18299 else if (unformat (input, "vxlan"))
18308 api_gpe_get_encap_mode (vat_main_t * vam)
18310 vl_api_gpe_get_encap_mode_t *mp;
18313 /* Construct the API message */
18314 M (GPE_GET_ENCAP_MODE, mp);
18319 /* Wait for a reply... */
18325 api_gpe_set_encap_mode (vat_main_t * vam)
18327 unformat_input_t *input = vam->input;
18328 vl_api_gpe_set_encap_mode_t *mp;
18332 /* Parse args required to build the message */
18333 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18335 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18341 /* Construct the API message */
18342 M (GPE_SET_ENCAP_MODE, mp);
18349 /* Wait for a reply... */
18355 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18357 unformat_input_t *input = vam->input;
18358 vl_api_gpe_add_del_iface_t *mp;
18359 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18360 u32 dp_table = 0, vni = 0;
18363 /* Parse args required to build the message */
18364 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18366 if (unformat (input, "up"))
18371 else if (unformat (input, "down"))
18376 else if (unformat (input, "table_id %d", &dp_table))
18380 else if (unformat (input, "bd_id %d", &dp_table))
18385 else if (unformat (input, "vni %d", &vni))
18393 if (action_set == 0)
18395 errmsg ("Action not set");
18398 if (dp_table_set == 0 || vni_set == 0)
18400 errmsg ("vni and dp_table must be set");
18404 /* Construct the API message */
18405 M (GPE_ADD_DEL_IFACE, mp);
18407 mp->is_add = is_add;
18408 mp->dp_table = clib_host_to_net_u32 (dp_table);
18410 mp->vni = clib_host_to_net_u32 (vni);
18415 /* Wait for a reply... */
18421 api_one_map_register_fallback_threshold (vat_main_t * vam)
18423 unformat_input_t *input = vam->input;
18424 vl_api_one_map_register_fallback_threshold_t *mp;
18429 /* Parse args required to build the message */
18430 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18432 if (unformat (input, "%u", &value))
18436 clib_warning ("parse error '%U'", format_unformat_error, input);
18443 errmsg ("fallback threshold value is missing!");
18447 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18448 mp->value = clib_host_to_net_u32 (value);
18453 /* Wait for a reply... */
18459 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18461 vl_api_show_one_map_register_fallback_threshold_t *mp;
18464 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18469 /* Wait for a reply... */
18475 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18477 u32 *proto = va_arg (*args, u32 *);
18479 if (unformat (input, "udp"))
18481 else if (unformat (input, "api"))
18490 api_one_set_transport_protocol (vat_main_t * vam)
18492 unformat_input_t *input = vam->input;
18493 vl_api_one_set_transport_protocol_t *mp;
18498 /* Parse args required to build the message */
18499 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18501 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18505 clib_warning ("parse error '%U'", format_unformat_error, input);
18512 errmsg ("Transport protocol missing!");
18516 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18517 mp->protocol = (u8) protocol;
18522 /* Wait for a reply... */
18528 api_one_get_transport_protocol (vat_main_t * vam)
18530 vl_api_one_get_transport_protocol_t *mp;
18533 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18538 /* Wait for a reply... */
18544 api_one_map_register_set_ttl (vat_main_t * vam)
18546 unformat_input_t *input = vam->input;
18547 vl_api_one_map_register_set_ttl_t *mp;
18552 /* Parse args required to build the message */
18553 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18555 if (unformat (input, "%u", &ttl))
18559 clib_warning ("parse error '%U'", format_unformat_error, input);
18566 errmsg ("TTL value missing!");
18570 M (ONE_MAP_REGISTER_SET_TTL, mp);
18571 mp->ttl = clib_host_to_net_u32 (ttl);
18576 /* Wait for a reply... */
18582 api_show_one_map_register_ttl (vat_main_t * vam)
18584 vl_api_show_one_map_register_ttl_t *mp;
18587 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18592 /* Wait for a reply... */
18598 * Add/del map request itr rlocs from ONE control plane and updates
18600 * @param vam vpp API test context
18601 * @return return code
18604 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18606 unformat_input_t *input = vam->input;
18607 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18608 u8 *locator_set_name = 0;
18609 u8 locator_set_name_set = 0;
18613 /* Parse args required to build the message */
18614 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18616 if (unformat (input, "del"))
18620 else if (unformat (input, "%_%v%_", &locator_set_name))
18622 locator_set_name_set = 1;
18626 clib_warning ("parse error '%U'", format_unformat_error, input);
18631 if (is_add && !locator_set_name_set)
18633 errmsg ("itr-rloc is not set!");
18637 if (is_add && vec_len (locator_set_name) > 64)
18639 errmsg ("itr-rloc locator-set name too long");
18640 vec_free (locator_set_name);
18644 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18645 mp->is_add = is_add;
18648 clib_memcpy (mp->locator_set_name, locator_set_name,
18649 vec_len (locator_set_name));
18653 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18655 vec_free (locator_set_name);
18660 /* Wait for a reply... */
18665 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18668 api_one_locator_dump (vat_main_t * vam)
18670 unformat_input_t *input = vam->input;
18671 vl_api_one_locator_dump_t *mp;
18672 vl_api_control_ping_t *mp_ping;
18673 u8 is_index_set = 0, is_name_set = 0;
18678 /* Parse args required to build the message */
18679 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18681 if (unformat (input, "ls_name %_%v%_", &ls_name))
18685 else if (unformat (input, "ls_index %d", &ls_index))
18691 errmsg ("parse error '%U'", format_unformat_error, input);
18696 if (!is_index_set && !is_name_set)
18698 errmsg ("error: expected one of index or name!");
18702 if (is_index_set && is_name_set)
18704 errmsg ("error: only one param expected!");
18708 if (vec_len (ls_name) > 62)
18710 errmsg ("error: locator set name too long!");
18714 if (!vam->json_output)
18716 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
18719 M (ONE_LOCATOR_DUMP, mp);
18720 mp->is_index_set = is_index_set;
18723 mp->ls_index = clib_host_to_net_u32 (ls_index);
18726 vec_add1 (ls_name, 0);
18727 strncpy ((char *) mp->ls_name, (char *) ls_name,
18728 sizeof (mp->ls_name) - 1);
18734 /* Use a control ping for synchronization */
18735 MPING (CONTROL_PING, mp_ping);
18738 /* Wait for a reply... */
18743 #define api_lisp_locator_dump api_one_locator_dump
18746 api_one_locator_set_dump (vat_main_t * vam)
18748 vl_api_one_locator_set_dump_t *mp;
18749 vl_api_control_ping_t *mp_ping;
18750 unformat_input_t *input = vam->input;
18754 /* Parse args required to build the message */
18755 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18757 if (unformat (input, "local"))
18761 else if (unformat (input, "remote"))
18767 errmsg ("parse error '%U'", format_unformat_error, input);
18772 if (!vam->json_output)
18774 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18777 M (ONE_LOCATOR_SET_DUMP, mp);
18779 mp->filter = filter;
18784 /* Use a control ping for synchronization */
18785 MPING (CONTROL_PING, mp_ping);
18788 /* Wait for a reply... */
18793 #define api_lisp_locator_set_dump api_one_locator_set_dump
18796 api_one_eid_table_map_dump (vat_main_t * vam)
18800 unformat_input_t *input = vam->input;
18801 vl_api_one_eid_table_map_dump_t *mp;
18802 vl_api_control_ping_t *mp_ping;
18805 /* Parse args required to build the message */
18806 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18808 if (unformat (input, "l2"))
18813 else if (unformat (input, "l3"))
18820 errmsg ("parse error '%U'", format_unformat_error, input);
18827 errmsg ("expected one of 'l2' or 'l3' parameter!");
18831 if (!vam->json_output)
18833 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18836 M (ONE_EID_TABLE_MAP_DUMP, mp);
18842 /* Use a control ping for synchronization */
18843 MPING (CONTROL_PING, mp_ping);
18846 /* Wait for a reply... */
18851 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18854 api_one_eid_table_vni_dump (vat_main_t * vam)
18856 vl_api_one_eid_table_vni_dump_t *mp;
18857 vl_api_control_ping_t *mp_ping;
18860 if (!vam->json_output)
18862 print (vam->ofp, "VNI");
18865 M (ONE_EID_TABLE_VNI_DUMP, mp);
18870 /* Use a control ping for synchronization */
18871 MPING (CONTROL_PING, mp_ping);
18874 /* Wait for a reply... */
18879 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18882 api_one_eid_table_dump (vat_main_t * vam)
18884 unformat_input_t *i = vam->input;
18885 vl_api_one_eid_table_dump_t *mp;
18886 vl_api_control_ping_t *mp_ping;
18887 struct in_addr ip4;
18888 struct in6_addr ip6;
18890 u8 eid_type = ~0, eid_set = 0;
18891 u32 prefix_length = ~0, t, vni = 0;
18894 lisp_nsh_api_t nsh;
18896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18898 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18904 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18910 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18915 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18920 else if (unformat (i, "vni %d", &t))
18924 else if (unformat (i, "local"))
18928 else if (unformat (i, "remote"))
18934 errmsg ("parse error '%U'", format_unformat_error, i);
18939 if (!vam->json_output)
18941 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
18942 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
18945 M (ONE_EID_TABLE_DUMP, mp);
18947 mp->filter = filter;
18951 mp->vni = htonl (vni);
18952 mp->eid_type = eid_type;
18956 mp->prefix_length = prefix_length;
18957 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
18960 mp->prefix_length = prefix_length;
18961 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
18964 clib_memcpy (mp->eid, mac, sizeof (mac));
18967 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
18970 errmsg ("unknown EID type %d!", eid_type);
18978 /* Use a control ping for synchronization */
18979 MPING (CONTROL_PING, mp_ping);
18982 /* Wait for a reply... */
18987 #define api_lisp_eid_table_dump api_one_eid_table_dump
18990 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18992 unformat_input_t *i = vam->input;
18993 vl_api_gpe_fwd_entries_get_t *mp;
18998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19000 if (unformat (i, "vni %d", &vni))
19006 errmsg ("parse error '%U'", format_unformat_error, i);
19013 errmsg ("vni not set!");
19017 if (!vam->json_output)
19019 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19023 M (GPE_FWD_ENTRIES_GET, mp);
19024 mp->vni = clib_host_to_net_u32 (vni);
19029 /* Wait for a reply... */
19034 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19035 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19036 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19037 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19038 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19039 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19040 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19041 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19044 api_one_adjacencies_get (vat_main_t * vam)
19046 unformat_input_t *i = vam->input;
19047 vl_api_one_adjacencies_get_t *mp;
19052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19054 if (unformat (i, "vni %d", &vni))
19060 errmsg ("parse error '%U'", format_unformat_error, i);
19067 errmsg ("vni not set!");
19071 if (!vam->json_output)
19073 print (vam->ofp, "%s %40s", "leid", "reid");
19076 M (ONE_ADJACENCIES_GET, mp);
19077 mp->vni = clib_host_to_net_u32 (vni);
19082 /* Wait for a reply... */
19087 #define api_lisp_adjacencies_get api_one_adjacencies_get
19090 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19092 unformat_input_t *i = vam->input;
19093 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19095 u8 ip_family_set = 0, is_ip4 = 1;
19097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19099 if (unformat (i, "ip4"))
19104 else if (unformat (i, "ip6"))
19111 errmsg ("parse error '%U'", format_unformat_error, i);
19116 if (!ip_family_set)
19118 errmsg ("ip family not set!");
19122 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19123 mp->is_ip4 = is_ip4;
19128 /* Wait for a reply... */
19134 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19136 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19139 if (!vam->json_output)
19141 print (vam->ofp, "VNIs");
19144 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19149 /* Wait for a reply... */
19155 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19157 unformat_input_t *i = vam->input;
19158 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19160 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19161 struct in_addr ip4;
19162 struct in6_addr ip6;
19163 u32 table_id = 0, nh_sw_if_index = ~0;
19165 clib_memset (&ip4, 0, sizeof (ip4));
19166 clib_memset (&ip6, 0, sizeof (ip6));
19168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19170 if (unformat (i, "del"))
19172 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19173 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19178 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19179 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19184 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19188 nh_sw_if_index = ~0;
19190 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19194 nh_sw_if_index = ~0;
19196 else if (unformat (i, "table %d", &table_id))
19200 errmsg ("parse error '%U'", format_unformat_error, i);
19207 errmsg ("nh addr not set!");
19211 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19212 mp->is_add = is_add;
19213 mp->table_id = clib_host_to_net_u32 (table_id);
19214 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19215 mp->is_ip4 = is_ip4;
19217 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19219 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19224 /* Wait for a reply... */
19230 api_one_map_server_dump (vat_main_t * vam)
19232 vl_api_one_map_server_dump_t *mp;
19233 vl_api_control_ping_t *mp_ping;
19236 if (!vam->json_output)
19238 print (vam->ofp, "%=20s", "Map server");
19241 M (ONE_MAP_SERVER_DUMP, mp);
19245 /* Use a control ping for synchronization */
19246 MPING (CONTROL_PING, mp_ping);
19249 /* Wait for a reply... */
19254 #define api_lisp_map_server_dump api_one_map_server_dump
19257 api_one_map_resolver_dump (vat_main_t * vam)
19259 vl_api_one_map_resolver_dump_t *mp;
19260 vl_api_control_ping_t *mp_ping;
19263 if (!vam->json_output)
19265 print (vam->ofp, "%=20s", "Map resolver");
19268 M (ONE_MAP_RESOLVER_DUMP, mp);
19272 /* Use a control ping for synchronization */
19273 MPING (CONTROL_PING, mp_ping);
19276 /* Wait for a reply... */
19281 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19284 api_one_stats_flush (vat_main_t * vam)
19286 vl_api_one_stats_flush_t *mp;
19289 M (ONE_STATS_FLUSH, mp);
19296 api_one_stats_dump (vat_main_t * vam)
19298 vl_api_one_stats_dump_t *mp;
19299 vl_api_control_ping_t *mp_ping;
19302 M (ONE_STATS_DUMP, mp);
19306 /* Use a control ping for synchronization */
19307 MPING (CONTROL_PING, mp_ping);
19310 /* Wait for a reply... */
19316 api_show_one_status (vat_main_t * vam)
19318 vl_api_show_one_status_t *mp;
19321 if (!vam->json_output)
19323 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19326 M (SHOW_ONE_STATUS, mp);
19329 /* Wait for a reply... */
19334 #define api_show_lisp_status api_show_one_status
19337 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19339 vl_api_gpe_fwd_entry_path_dump_t *mp;
19340 vl_api_control_ping_t *mp_ping;
19341 unformat_input_t *i = vam->input;
19342 u32 fwd_entry_index = ~0;
19345 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19347 if (unformat (i, "index %d", &fwd_entry_index))
19353 if (~0 == fwd_entry_index)
19355 errmsg ("no index specified!");
19359 if (!vam->json_output)
19361 print (vam->ofp, "first line");
19364 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19368 /* Use a control ping for synchronization */
19369 MPING (CONTROL_PING, mp_ping);
19372 /* Wait for a reply... */
19378 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19380 vl_api_one_get_map_request_itr_rlocs_t *mp;
19383 if (!vam->json_output)
19385 print (vam->ofp, "%=20s", "itr-rlocs:");
19388 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19391 /* Wait for a reply... */
19396 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19399 api_af_packet_create (vat_main_t * vam)
19401 unformat_input_t *i = vam->input;
19402 vl_api_af_packet_create_t *mp;
19403 u8 *host_if_name = 0;
19405 u8 random_hw_addr = 1;
19408 clib_memset (hw_addr, 0, sizeof (hw_addr));
19410 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19412 if (unformat (i, "name %s", &host_if_name))
19413 vec_add1 (host_if_name, 0);
19414 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19415 random_hw_addr = 0;
19420 if (!vec_len (host_if_name))
19422 errmsg ("host-interface name must be specified");
19426 if (vec_len (host_if_name) > 64)
19428 errmsg ("host-interface name too long");
19432 M (AF_PACKET_CREATE, mp);
19434 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19435 clib_memcpy (mp->hw_addr, hw_addr, 6);
19436 mp->use_random_hw_addr = random_hw_addr;
19437 vec_free (host_if_name);
19445 fprintf (vam->ofp ? vam->ofp : stderr,
19446 " new sw_if_index = %d\n", vam->sw_if_index);
19453 api_af_packet_delete (vat_main_t * vam)
19455 unformat_input_t *i = vam->input;
19456 vl_api_af_packet_delete_t *mp;
19457 u8 *host_if_name = 0;
19460 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19462 if (unformat (i, "name %s", &host_if_name))
19463 vec_add1 (host_if_name, 0);
19468 if (!vec_len (host_if_name))
19470 errmsg ("host-interface name must be specified");
19474 if (vec_len (host_if_name) > 64)
19476 errmsg ("host-interface name too long");
19480 M (AF_PACKET_DELETE, mp);
19482 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19483 vec_free (host_if_name);
19490 static void vl_api_af_packet_details_t_handler
19491 (vl_api_af_packet_details_t * mp)
19493 vat_main_t *vam = &vat_main;
19495 print (vam->ofp, "%-16s %d",
19496 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19499 static void vl_api_af_packet_details_t_handler_json
19500 (vl_api_af_packet_details_t * mp)
19502 vat_main_t *vam = &vat_main;
19503 vat_json_node_t *node = NULL;
19505 if (VAT_JSON_ARRAY != vam->json_tree.type)
19507 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19508 vat_json_init_array (&vam->json_tree);
19510 node = vat_json_array_add (&vam->json_tree);
19512 vat_json_init_object (node);
19513 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19514 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19518 api_af_packet_dump (vat_main_t * vam)
19520 vl_api_af_packet_dump_t *mp;
19521 vl_api_control_ping_t *mp_ping;
19524 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19525 /* Get list of tap interfaces */
19526 M (AF_PACKET_DUMP, mp);
19529 /* Use a control ping for synchronization */
19530 MPING (CONTROL_PING, mp_ping);
19538 api_policer_add_del (vat_main_t * vam)
19540 unformat_input_t *i = vam->input;
19541 vl_api_policer_add_del_t *mp;
19551 u8 color_aware = 0;
19552 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19555 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19556 conform_action.dscp = 0;
19557 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19558 exceed_action.dscp = 0;
19559 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19560 violate_action.dscp = 0;
19562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19564 if (unformat (i, "del"))
19566 else if (unformat (i, "name %s", &name))
19567 vec_add1 (name, 0);
19568 else if (unformat (i, "cir %u", &cir))
19570 else if (unformat (i, "eir %u", &eir))
19572 else if (unformat (i, "cb %u", &cb))
19574 else if (unformat (i, "eb %u", &eb))
19576 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19579 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19582 else if (unformat (i, "type %U", unformat_policer_type, &type))
19584 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19587 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19590 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19593 else if (unformat (i, "color-aware"))
19599 if (!vec_len (name))
19601 errmsg ("policer name must be specified");
19605 if (vec_len (name) > 64)
19607 errmsg ("policer name too long");
19611 M (POLICER_ADD_DEL, mp);
19613 clib_memcpy (mp->name, name, vec_len (name));
19615 mp->is_add = is_add;
19616 mp->cir = ntohl (cir);
19617 mp->eir = ntohl (eir);
19618 mp->cb = clib_net_to_host_u64 (cb);
19619 mp->eb = clib_net_to_host_u64 (eb);
19620 mp->rate_type = rate_type;
19621 mp->round_type = round_type;
19623 mp->conform_action_type = conform_action.action_type;
19624 mp->conform_dscp = conform_action.dscp;
19625 mp->exceed_action_type = exceed_action.action_type;
19626 mp->exceed_dscp = exceed_action.dscp;
19627 mp->violate_action_type = violate_action.action_type;
19628 mp->violate_dscp = violate_action.dscp;
19629 mp->color_aware = color_aware;
19637 api_policer_dump (vat_main_t * vam)
19639 unformat_input_t *i = vam->input;
19640 vl_api_policer_dump_t *mp;
19641 vl_api_control_ping_t *mp_ping;
19642 u8 *match_name = 0;
19643 u8 match_name_valid = 0;
19646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19648 if (unformat (i, "name %s", &match_name))
19650 vec_add1 (match_name, 0);
19651 match_name_valid = 1;
19657 M (POLICER_DUMP, mp);
19658 mp->match_name_valid = match_name_valid;
19659 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19660 vec_free (match_name);
19664 /* Use a control ping for synchronization */
19665 MPING (CONTROL_PING, mp_ping);
19668 /* Wait for a reply... */
19674 api_policer_classify_set_interface (vat_main_t * vam)
19676 unformat_input_t *i = vam->input;
19677 vl_api_policer_classify_set_interface_t *mp;
19679 int sw_if_index_set;
19680 u32 ip4_table_index = ~0;
19681 u32 ip6_table_index = ~0;
19682 u32 l2_table_index = ~0;
19686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19688 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19689 sw_if_index_set = 1;
19690 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19691 sw_if_index_set = 1;
19692 else if (unformat (i, "del"))
19694 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19696 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19698 else if (unformat (i, "l2-table %d", &l2_table_index))
19702 clib_warning ("parse error '%U'", format_unformat_error, i);
19707 if (sw_if_index_set == 0)
19709 errmsg ("missing interface name or sw_if_index");
19713 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19715 mp->sw_if_index = ntohl (sw_if_index);
19716 mp->ip4_table_index = ntohl (ip4_table_index);
19717 mp->ip6_table_index = ntohl (ip6_table_index);
19718 mp->l2_table_index = ntohl (l2_table_index);
19719 mp->is_add = is_add;
19727 api_policer_classify_dump (vat_main_t * vam)
19729 unformat_input_t *i = vam->input;
19730 vl_api_policer_classify_dump_t *mp;
19731 vl_api_control_ping_t *mp_ping;
19732 u8 type = POLICER_CLASSIFY_N_TABLES;
19735 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19739 errmsg ("classify table type must be specified");
19743 if (!vam->json_output)
19745 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19748 M (POLICER_CLASSIFY_DUMP, mp);
19753 /* Use a control ping for synchronization */
19754 MPING (CONTROL_PING, mp_ping);
19757 /* Wait for a reply... */
19763 api_netmap_create (vat_main_t * vam)
19765 unformat_input_t *i = vam->input;
19766 vl_api_netmap_create_t *mp;
19769 u8 random_hw_addr = 1;
19774 clib_memset (hw_addr, 0, sizeof (hw_addr));
19776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19778 if (unformat (i, "name %s", &if_name))
19779 vec_add1 (if_name, 0);
19780 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19781 random_hw_addr = 0;
19782 else if (unformat (i, "pipe"))
19784 else if (unformat (i, "master"))
19786 else if (unformat (i, "slave"))
19792 if (!vec_len (if_name))
19794 errmsg ("interface name must be specified");
19798 if (vec_len (if_name) > 64)
19800 errmsg ("interface name too long");
19804 M (NETMAP_CREATE, mp);
19806 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19807 clib_memcpy (mp->hw_addr, hw_addr, 6);
19808 mp->use_random_hw_addr = random_hw_addr;
19809 mp->is_pipe = is_pipe;
19810 mp->is_master = is_master;
19811 vec_free (if_name);
19819 api_netmap_delete (vat_main_t * vam)
19821 unformat_input_t *i = vam->input;
19822 vl_api_netmap_delete_t *mp;
19826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19828 if (unformat (i, "name %s", &if_name))
19829 vec_add1 (if_name, 0);
19834 if (!vec_len (if_name))
19836 errmsg ("interface name must be specified");
19840 if (vec_len (if_name) > 64)
19842 errmsg ("interface name too long");
19846 M (NETMAP_DELETE, mp);
19848 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19849 vec_free (if_name);
19857 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
19859 if (fp->afi == IP46_TYPE_IP6)
19861 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19862 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19863 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
19864 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19865 format_ip6_address, fp->next_hop);
19866 else if (fp->afi == IP46_TYPE_IP4)
19868 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19869 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19870 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
19871 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19872 format_ip4_address, fp->next_hop);
19876 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19877 vl_api_fib_path_t * fp)
19879 struct in_addr ip4;
19880 struct in6_addr ip6;
19882 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19883 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19884 vat_json_object_add_uint (node, "is_local", fp->is_local);
19885 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19886 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19887 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19888 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19889 if (fp->afi == IP46_TYPE_IP4)
19891 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19892 vat_json_object_add_ip4 (node, "next_hop", ip4);
19894 else if (fp->afi == IP46_TYPE_IP6)
19896 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19897 vat_json_object_add_ip6 (node, "next_hop", ip6);
19902 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19904 vat_main_t *vam = &vat_main;
19905 int count = ntohl (mp->mt_count);
19906 vl_api_fib_path_t *fp;
19909 print (vam->ofp, "[%d]: sw_if_index %d via:",
19910 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19912 for (i = 0; i < count; i++)
19914 vl_api_mpls_fib_path_print (vam, fp);
19918 print (vam->ofp, "");
19921 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19922 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19925 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19927 vat_main_t *vam = &vat_main;
19928 vat_json_node_t *node = NULL;
19929 int count = ntohl (mp->mt_count);
19930 vl_api_fib_path_t *fp;
19933 if (VAT_JSON_ARRAY != vam->json_tree.type)
19935 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19936 vat_json_init_array (&vam->json_tree);
19938 node = vat_json_array_add (&vam->json_tree);
19940 vat_json_init_object (node);
19941 vat_json_object_add_uint (node, "tunnel_index",
19942 ntohl (mp->mt_tunnel_index));
19943 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
19945 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
19948 for (i = 0; i < count; i++)
19950 vl_api_mpls_fib_path_json_print (node, fp);
19956 api_mpls_tunnel_dump (vat_main_t * vam)
19958 vl_api_mpls_tunnel_dump_t *mp;
19959 vl_api_control_ping_t *mp_ping;
19960 u32 sw_if_index = ~0;
19963 /* Parse args required to build the message */
19964 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
19966 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
19970 print (vam->ofp, " sw_if_index %d", sw_if_index);
19972 M (MPLS_TUNNEL_DUMP, mp);
19973 mp->sw_if_index = htonl (sw_if_index);
19976 /* Use a control ping for synchronization */
19977 MPING (CONTROL_PING, mp_ping);
19984 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
19985 #define vl_api_mpls_fib_details_t_print vl_noop_handler
19989 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
19991 vat_main_t *vam = &vat_main;
19992 int count = ntohl (mp->count);
19993 vl_api_fib_path_t *fp;
19997 "table-id %d, label %u, ess_bit %u",
19998 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20000 for (i = 0; i < count; i++)
20002 vl_api_mpls_fib_path_print (vam, fp);
20007 static void vl_api_mpls_fib_details_t_handler_json
20008 (vl_api_mpls_fib_details_t * mp)
20010 vat_main_t *vam = &vat_main;
20011 int count = ntohl (mp->count);
20012 vat_json_node_t *node = NULL;
20013 vl_api_fib_path_t *fp;
20016 if (VAT_JSON_ARRAY != vam->json_tree.type)
20018 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20019 vat_json_init_array (&vam->json_tree);
20021 node = vat_json_array_add (&vam->json_tree);
20023 vat_json_init_object (node);
20024 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20025 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20026 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20027 vat_json_object_add_uint (node, "path_count", count);
20029 for (i = 0; i < count; i++)
20031 vl_api_mpls_fib_path_json_print (node, fp);
20037 api_mpls_fib_dump (vat_main_t * vam)
20039 vl_api_mpls_fib_dump_t *mp;
20040 vl_api_control_ping_t *mp_ping;
20043 M (MPLS_FIB_DUMP, mp);
20046 /* Use a control ping for synchronization */
20047 MPING (CONTROL_PING, mp_ping);
20054 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20055 #define vl_api_ip_fib_details_t_print vl_noop_handler
20058 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20060 vat_main_t *vam = &vat_main;
20061 int count = ntohl (mp->count);
20062 vl_api_fib_path_t *fp;
20066 "table-id %d, prefix %U/%d stats-index %d",
20067 ntohl (mp->table_id), format_ip4_address, mp->address,
20068 mp->address_length, ntohl (mp->stats_index));
20070 for (i = 0; i < count; i++)
20072 if (fp->afi == IP46_TYPE_IP6)
20074 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20075 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20076 "next_hop_table %d",
20077 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20078 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20079 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20080 else if (fp->afi == IP46_TYPE_IP4)
20082 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20083 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20084 "next_hop_table %d",
20085 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20086 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20087 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20092 static void vl_api_ip_fib_details_t_handler_json
20093 (vl_api_ip_fib_details_t * mp)
20095 vat_main_t *vam = &vat_main;
20096 int count = ntohl (mp->count);
20097 vat_json_node_t *node = NULL;
20098 struct in_addr ip4;
20099 struct in6_addr ip6;
20100 vl_api_fib_path_t *fp;
20103 if (VAT_JSON_ARRAY != vam->json_tree.type)
20105 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20106 vat_json_init_array (&vam->json_tree);
20108 node = vat_json_array_add (&vam->json_tree);
20110 vat_json_init_object (node);
20111 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20112 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20113 vat_json_object_add_ip4 (node, "prefix", ip4);
20114 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20115 vat_json_object_add_uint (node, "path_count", count);
20117 for (i = 0; i < count; i++)
20119 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20120 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20121 vat_json_object_add_uint (node, "is_local", fp->is_local);
20122 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20123 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20124 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20125 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20126 if (fp->afi == IP46_TYPE_IP4)
20128 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20129 vat_json_object_add_ip4 (node, "next_hop", ip4);
20131 else if (fp->afi == IP46_TYPE_IP6)
20133 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20134 vat_json_object_add_ip6 (node, "next_hop", ip6);
20140 api_ip_fib_dump (vat_main_t * vam)
20142 vl_api_ip_fib_dump_t *mp;
20143 vl_api_control_ping_t *mp_ping;
20146 M (IP_FIB_DUMP, mp);
20149 /* Use a control ping for synchronization */
20150 MPING (CONTROL_PING, mp_ping);
20158 api_ip_mfib_dump (vat_main_t * vam)
20160 vl_api_ip_mfib_dump_t *mp;
20161 vl_api_control_ping_t *mp_ping;
20164 M (IP_MFIB_DUMP, mp);
20167 /* Use a control ping for synchronization */
20168 MPING (CONTROL_PING, mp_ping);
20175 static void vl_api_ip_neighbor_details_t_handler
20176 (vl_api_ip_neighbor_details_t * mp)
20178 vat_main_t *vam = &vat_main;
20180 print (vam->ofp, "%c %U %U",
20181 (mp->is_static) ? 'S' : 'D',
20182 format_ethernet_address, &mp->mac_address,
20183 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20187 static void vl_api_ip_neighbor_details_t_handler_json
20188 (vl_api_ip_neighbor_details_t * mp)
20191 vat_main_t *vam = &vat_main;
20192 vat_json_node_t *node;
20193 struct in_addr ip4;
20194 struct in6_addr ip6;
20196 if (VAT_JSON_ARRAY != vam->json_tree.type)
20198 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20199 vat_json_init_array (&vam->json_tree);
20201 node = vat_json_array_add (&vam->json_tree);
20203 vat_json_init_object (node);
20204 vat_json_object_add_string_copy (node, "flag",
20205 (mp->is_static) ? (u8 *) "static" : (u8 *)
20208 vat_json_object_add_string_copy (node, "link_layer",
20209 format (0, "%U", format_ethernet_address,
20210 &mp->mac_address));
20214 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20215 vat_json_object_add_ip6 (node, "ip_address", ip6);
20219 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20220 vat_json_object_add_ip4 (node, "ip_address", ip4);
20225 api_ip_neighbor_dump (vat_main_t * vam)
20227 unformat_input_t *i = vam->input;
20228 vl_api_ip_neighbor_dump_t *mp;
20229 vl_api_control_ping_t *mp_ping;
20231 u32 sw_if_index = ~0;
20234 /* Parse args required to build the message */
20235 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20237 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20239 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20241 else if (unformat (i, "ip6"))
20247 if (sw_if_index == ~0)
20249 errmsg ("missing interface name or sw_if_index");
20253 M (IP_NEIGHBOR_DUMP, mp);
20254 mp->is_ipv6 = (u8) is_ipv6;
20255 mp->sw_if_index = ntohl (sw_if_index);
20258 /* Use a control ping for synchronization */
20259 MPING (CONTROL_PING, mp_ping);
20266 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20267 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20270 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20272 vat_main_t *vam = &vat_main;
20273 int count = ntohl (mp->count);
20274 vl_api_fib_path_t *fp;
20278 "table-id %d, prefix %U/%d stats-index %d",
20279 ntohl (mp->table_id), format_ip6_address, mp->address,
20280 mp->address_length, ntohl (mp->stats_index));
20282 for (i = 0; i < count; i++)
20284 if (fp->afi == IP46_TYPE_IP6)
20286 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20287 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20288 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20289 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20290 format_ip6_address, fp->next_hop);
20291 else if (fp->afi == IP46_TYPE_IP4)
20293 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20294 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20295 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20296 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20297 format_ip4_address, fp->next_hop);
20302 static void vl_api_ip6_fib_details_t_handler_json
20303 (vl_api_ip6_fib_details_t * mp)
20305 vat_main_t *vam = &vat_main;
20306 int count = ntohl (mp->count);
20307 vat_json_node_t *node = NULL;
20308 struct in_addr ip4;
20309 struct in6_addr ip6;
20310 vl_api_fib_path_t *fp;
20313 if (VAT_JSON_ARRAY != vam->json_tree.type)
20315 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20316 vat_json_init_array (&vam->json_tree);
20318 node = vat_json_array_add (&vam->json_tree);
20320 vat_json_init_object (node);
20321 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20322 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20323 vat_json_object_add_ip6 (node, "prefix", ip6);
20324 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20325 vat_json_object_add_uint (node, "path_count", count);
20327 for (i = 0; i < count; i++)
20329 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20330 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20331 vat_json_object_add_uint (node, "is_local", fp->is_local);
20332 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20333 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20334 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20335 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20336 if (fp->afi == IP46_TYPE_IP4)
20338 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20339 vat_json_object_add_ip4 (node, "next_hop", ip4);
20341 else if (fp->afi == IP46_TYPE_IP6)
20343 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20344 vat_json_object_add_ip6 (node, "next_hop", ip6);
20350 api_ip6_fib_dump (vat_main_t * vam)
20352 vl_api_ip6_fib_dump_t *mp;
20353 vl_api_control_ping_t *mp_ping;
20356 M (IP6_FIB_DUMP, mp);
20359 /* Use a control ping for synchronization */
20360 MPING (CONTROL_PING, mp_ping);
20368 api_ip6_mfib_dump (vat_main_t * vam)
20370 vl_api_ip6_mfib_dump_t *mp;
20371 vl_api_control_ping_t *mp_ping;
20374 M (IP6_MFIB_DUMP, mp);
20377 /* Use a control ping for synchronization */
20378 MPING (CONTROL_PING, mp_ping);
20386 api_classify_table_ids (vat_main_t * vam)
20388 vl_api_classify_table_ids_t *mp;
20391 /* Construct the API message */
20392 M (CLASSIFY_TABLE_IDS, mp);
20401 api_classify_table_by_interface (vat_main_t * vam)
20403 unformat_input_t *input = vam->input;
20404 vl_api_classify_table_by_interface_t *mp;
20406 u32 sw_if_index = ~0;
20408 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20410 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20412 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20417 if (sw_if_index == ~0)
20419 errmsg ("missing interface name or sw_if_index");
20423 /* Construct the API message */
20424 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20426 mp->sw_if_index = ntohl (sw_if_index);
20434 api_classify_table_info (vat_main_t * vam)
20436 unformat_input_t *input = vam->input;
20437 vl_api_classify_table_info_t *mp;
20441 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20443 if (unformat (input, "table_id %d", &table_id))
20448 if (table_id == ~0)
20450 errmsg ("missing table id");
20454 /* Construct the API message */
20455 M (CLASSIFY_TABLE_INFO, mp);
20457 mp->table_id = ntohl (table_id);
20465 api_classify_session_dump (vat_main_t * vam)
20467 unformat_input_t *input = vam->input;
20468 vl_api_classify_session_dump_t *mp;
20469 vl_api_control_ping_t *mp_ping;
20473 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20475 if (unformat (input, "table_id %d", &table_id))
20480 if (table_id == ~0)
20482 errmsg ("missing table id");
20486 /* Construct the API message */
20487 M (CLASSIFY_SESSION_DUMP, mp);
20489 mp->table_id = ntohl (table_id);
20492 /* Use a control ping for synchronization */
20493 MPING (CONTROL_PING, mp_ping);
20501 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20503 vat_main_t *vam = &vat_main;
20505 print (vam->ofp, "collector_address %U, collector_port %d, "
20506 "src_address %U, vrf_id %d, path_mtu %u, "
20507 "template_interval %u, udp_checksum %d",
20508 format_ip4_address, mp->collector_address,
20509 ntohs (mp->collector_port),
20510 format_ip4_address, mp->src_address,
20511 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20512 ntohl (mp->template_interval), mp->udp_checksum);
20515 vam->result_ready = 1;
20519 vl_api_ipfix_exporter_details_t_handler_json
20520 (vl_api_ipfix_exporter_details_t * mp)
20522 vat_main_t *vam = &vat_main;
20523 vat_json_node_t node;
20524 struct in_addr collector_address;
20525 struct in_addr src_address;
20527 vat_json_init_object (&node);
20528 clib_memcpy (&collector_address, &mp->collector_address,
20529 sizeof (collector_address));
20530 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20531 vat_json_object_add_uint (&node, "collector_port",
20532 ntohs (mp->collector_port));
20533 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20534 vat_json_object_add_ip4 (&node, "src_address", src_address);
20535 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20536 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20537 vat_json_object_add_uint (&node, "template_interval",
20538 ntohl (mp->template_interval));
20539 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20541 vat_json_print (vam->ofp, &node);
20542 vat_json_free (&node);
20544 vam->result_ready = 1;
20548 api_ipfix_exporter_dump (vat_main_t * vam)
20550 vl_api_ipfix_exporter_dump_t *mp;
20553 /* Construct the API message */
20554 M (IPFIX_EXPORTER_DUMP, mp);
20563 api_ipfix_classify_stream_dump (vat_main_t * vam)
20565 vl_api_ipfix_classify_stream_dump_t *mp;
20568 /* Construct the API message */
20569 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20580 vl_api_ipfix_classify_stream_details_t_handler
20581 (vl_api_ipfix_classify_stream_details_t * mp)
20583 vat_main_t *vam = &vat_main;
20584 print (vam->ofp, "domain_id %d, src_port %d",
20585 ntohl (mp->domain_id), ntohs (mp->src_port));
20587 vam->result_ready = 1;
20591 vl_api_ipfix_classify_stream_details_t_handler_json
20592 (vl_api_ipfix_classify_stream_details_t * mp)
20594 vat_main_t *vam = &vat_main;
20595 vat_json_node_t node;
20597 vat_json_init_object (&node);
20598 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20599 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20601 vat_json_print (vam->ofp, &node);
20602 vat_json_free (&node);
20604 vam->result_ready = 1;
20608 api_ipfix_classify_table_dump (vat_main_t * vam)
20610 vl_api_ipfix_classify_table_dump_t *mp;
20611 vl_api_control_ping_t *mp_ping;
20614 if (!vam->json_output)
20616 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20617 "transport_protocol");
20620 /* Construct the API message */
20621 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20626 /* Use a control ping for synchronization */
20627 MPING (CONTROL_PING, mp_ping);
20635 vl_api_ipfix_classify_table_details_t_handler
20636 (vl_api_ipfix_classify_table_details_t * mp)
20638 vat_main_t *vam = &vat_main;
20639 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20640 mp->transport_protocol);
20644 vl_api_ipfix_classify_table_details_t_handler_json
20645 (vl_api_ipfix_classify_table_details_t * mp)
20647 vat_json_node_t *node = NULL;
20648 vat_main_t *vam = &vat_main;
20650 if (VAT_JSON_ARRAY != vam->json_tree.type)
20652 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20653 vat_json_init_array (&vam->json_tree);
20656 node = vat_json_array_add (&vam->json_tree);
20657 vat_json_init_object (node);
20659 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20660 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20661 vat_json_object_add_uint (node, "transport_protocol",
20662 mp->transport_protocol);
20666 api_sw_interface_span_enable_disable (vat_main_t * vam)
20668 unformat_input_t *i = vam->input;
20669 vl_api_sw_interface_span_enable_disable_t *mp;
20670 u32 src_sw_if_index = ~0;
20671 u32 dst_sw_if_index = ~0;
20676 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20679 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
20681 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
20685 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
20687 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
20689 else if (unformat (i, "disable"))
20691 else if (unformat (i, "rx"))
20693 else if (unformat (i, "tx"))
20695 else if (unformat (i, "both"))
20697 else if (unformat (i, "l2"))
20703 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20705 mp->sw_if_index_from = htonl (src_sw_if_index);
20706 mp->sw_if_index_to = htonl (dst_sw_if_index);
20716 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
20719 vat_main_t *vam = &vat_main;
20720 u8 *sw_if_from_name = 0;
20721 u8 *sw_if_to_name = 0;
20722 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20723 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20724 char *states[] = { "none", "rx", "tx", "both" };
20728 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20730 if ((u32) p->value[0] == sw_if_index_from)
20732 sw_if_from_name = (u8 *)(p->key);
20736 if ((u32) p->value[0] == sw_if_index_to)
20738 sw_if_to_name = (u8 *)(p->key);
20739 if (sw_if_from_name)
20744 print (vam->ofp, "%20s => %20s (%s) %s",
20745 sw_if_from_name, sw_if_to_name, states[mp->state],
20746 mp->is_l2 ? "l2" : "device");
20750 vl_api_sw_interface_span_details_t_handler_json
20751 (vl_api_sw_interface_span_details_t * mp)
20753 vat_main_t *vam = &vat_main;
20754 vat_json_node_t *node = NULL;
20755 u8 *sw_if_from_name = 0;
20756 u8 *sw_if_to_name = 0;
20757 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20758 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20762 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20764 if ((u32) p->value[0] == sw_if_index_from)
20766 sw_if_from_name = (u8 *)(p->key);
20770 if ((u32) p->value[0] == sw_if_index_to)
20772 sw_if_to_name = (u8 *)(p->key);
20773 if (sw_if_from_name)
20779 if (VAT_JSON_ARRAY != vam->json_tree.type)
20781 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20782 vat_json_init_array (&vam->json_tree);
20784 node = vat_json_array_add (&vam->json_tree);
20786 vat_json_init_object (node);
20787 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20788 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20789 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20790 if (0 != sw_if_to_name)
20792 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20794 vat_json_object_add_uint (node, "state", mp->state);
20795 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
20799 api_sw_interface_span_dump (vat_main_t * vam)
20801 unformat_input_t *input = vam->input;
20802 vl_api_sw_interface_span_dump_t *mp;
20803 vl_api_control_ping_t *mp_ping;
20807 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20809 if (unformat (input, "l2"))
20815 M (SW_INTERFACE_SPAN_DUMP, mp);
20819 /* Use a control ping for synchronization */
20820 MPING (CONTROL_PING, mp_ping);
20828 api_pg_create_interface (vat_main_t * vam)
20830 unformat_input_t *input = vam->input;
20831 vl_api_pg_create_interface_t *mp;
20835 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20837 if (unformat (input, "if_id %d", &if_id))
20844 errmsg ("missing pg interface index");
20848 /* Construct the API message */
20849 M (PG_CREATE_INTERFACE, mp);
20851 mp->interface_id = ntohl (if_id);
20859 api_pg_capture (vat_main_t * vam)
20861 unformat_input_t *input = vam->input;
20862 vl_api_pg_capture_t *mp;
20867 u8 pcap_file_set = 0;
20870 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20872 if (unformat (input, "if_id %d", &if_id))
20874 else if (unformat (input, "pcap %s", &pcap_file))
20876 else if (unformat (input, "count %d", &count))
20878 else if (unformat (input, "disable"))
20885 errmsg ("missing pg interface index");
20888 if (pcap_file_set > 0)
20890 if (vec_len (pcap_file) > 255)
20892 errmsg ("pcap file name is too long");
20897 u32 name_len = vec_len (pcap_file);
20898 /* Construct the API message */
20899 M (PG_CAPTURE, mp);
20901 mp->interface_id = ntohl (if_id);
20902 mp->is_enabled = enable;
20903 mp->count = ntohl (count);
20904 mp->pcap_name_length = ntohl (name_len);
20905 if (pcap_file_set != 0)
20907 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20909 vec_free (pcap_file);
20917 api_pg_enable_disable (vat_main_t * vam)
20919 unformat_input_t *input = vam->input;
20920 vl_api_pg_enable_disable_t *mp;
20923 u8 stream_name_set = 0;
20924 u8 *stream_name = 0;
20926 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20928 if (unformat (input, "stream %s", &stream_name))
20929 stream_name_set = 1;
20930 else if (unformat (input, "disable"))
20936 if (stream_name_set > 0)
20938 if (vec_len (stream_name) > 255)
20940 errmsg ("stream name too long");
20945 u32 name_len = vec_len (stream_name);
20946 /* Construct the API message */
20947 M (PG_ENABLE_DISABLE, mp);
20949 mp->is_enabled = enable;
20950 if (stream_name_set != 0)
20952 mp->stream_name_length = ntohl (name_len);
20953 clib_memcpy (mp->stream_name, stream_name, name_len);
20955 vec_free (stream_name);
20963 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
20965 unformat_input_t *input = vam->input;
20966 vl_api_ip_source_and_port_range_check_add_del_t *mp;
20968 u16 *low_ports = 0;
20969 u16 *high_ports = 0;
20972 ip4_address_t ip4_addr;
20973 ip6_address_t ip6_addr;
20982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20984 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
20990 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
20995 else if (unformat (input, "vrf %d", &vrf_id))
20997 else if (unformat (input, "del"))
20999 else if (unformat (input, "port %d", &tmp))
21001 if (tmp == 0 || tmp > 65535)
21003 errmsg ("port %d out of range", tmp);
21007 this_hi = this_low + 1;
21008 vec_add1 (low_ports, this_low);
21009 vec_add1 (high_ports, this_hi);
21011 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21013 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21015 errmsg ("incorrect range parameters");
21019 /* Note: in debug CLI +1 is added to high before
21020 passing to real fn that does "the work"
21021 (ip_source_and_port_range_check_add_del).
21022 This fn is a wrapper around the binary API fn a
21023 control plane will call, which expects this increment
21024 to have occurred. Hence letting the binary API control
21025 plane fn do the increment for consistency between VAT
21026 and other control planes.
21029 vec_add1 (low_ports, this_low);
21030 vec_add1 (high_ports, this_hi);
21036 if (prefix_set == 0)
21038 errmsg ("<address>/<mask> not specified");
21044 errmsg ("VRF ID required, not specified");
21051 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21055 if (vec_len (low_ports) == 0)
21057 errmsg ("At least one port or port range required");
21061 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21063 mp->is_add = is_add;
21068 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21073 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21076 mp->mask_length = length;
21077 mp->number_of_ranges = vec_len (low_ports);
21079 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21080 vec_free (low_ports);
21082 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21083 vec_free (high_ports);
21085 mp->vrf_id = ntohl (vrf_id);
21093 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21095 unformat_input_t *input = vam->input;
21096 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21097 u32 sw_if_index = ~0;
21099 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21100 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21104 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21106 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21108 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21110 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21112 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21114 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21116 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21118 else if (unformat (input, "del"))
21124 if (sw_if_index == ~0)
21126 errmsg ("Interface required but not specified");
21132 errmsg ("VRF ID required but not specified");
21136 if (tcp_out_vrf_id == 0
21137 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21140 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21144 /* Construct the API message */
21145 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21147 mp->sw_if_index = ntohl (sw_if_index);
21148 mp->is_add = is_add;
21149 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21150 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21151 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21152 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21157 /* Wait for a reply... */
21163 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21165 unformat_input_t *i = vam->input;
21166 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21167 u32 local_sa_id = 0;
21168 u32 remote_sa_id = 0;
21169 ip4_address_t src_address;
21170 ip4_address_t dst_address;
21174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21176 if (unformat (i, "local_sa %d", &local_sa_id))
21178 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21180 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21182 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21184 else if (unformat (i, "del"))
21188 clib_warning ("parse error '%U'", format_unformat_error, i);
21193 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21195 mp->local_sa_id = ntohl (local_sa_id);
21196 mp->remote_sa_id = ntohl (remote_sa_id);
21197 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21198 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21199 mp->is_add = is_add;
21207 api_set_punt (vat_main_t * vam)
21209 unformat_input_t *i = vam->input;
21210 vl_api_set_punt_t *mp;
21217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21219 if (unformat (i, "ip %d", &ipv))
21221 else if (unformat (i, "protocol %d", &protocol))
21223 else if (unformat (i, "port %d", &port))
21225 else if (unformat (i, "del"))
21229 clib_warning ("parse error '%U'", format_unformat_error, i);
21236 mp->is_add = (u8) is_add;
21237 mp->punt.ipv = (u8) ipv;
21238 mp->punt.l4_protocol = (u8) protocol;
21239 mp->punt.l4_port = htons ((u16) port);
21246 static void vl_api_ipsec_gre_tunnel_details_t_handler
21247 (vl_api_ipsec_gre_tunnel_details_t * mp)
21249 vat_main_t *vam = &vat_main;
21251 print (vam->ofp, "%11d%15U%15U%14d%14d",
21252 ntohl (mp->sw_if_index),
21253 format_ip4_address, &mp->src_address,
21254 format_ip4_address, &mp->dst_address,
21255 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21258 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21259 (vl_api_ipsec_gre_tunnel_details_t * mp)
21261 vat_main_t *vam = &vat_main;
21262 vat_json_node_t *node = NULL;
21263 struct in_addr ip4;
21265 if (VAT_JSON_ARRAY != vam->json_tree.type)
21267 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21268 vat_json_init_array (&vam->json_tree);
21270 node = vat_json_array_add (&vam->json_tree);
21272 vat_json_init_object (node);
21273 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21274 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21275 vat_json_object_add_ip4 (node, "src_address", ip4);
21276 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21277 vat_json_object_add_ip4 (node, "dst_address", ip4);
21278 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21279 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21283 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21285 unformat_input_t *i = vam->input;
21286 vl_api_ipsec_gre_tunnel_dump_t *mp;
21287 vl_api_control_ping_t *mp_ping;
21289 u8 sw_if_index_set = 0;
21292 /* Parse args required to build the message */
21293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21295 if (unformat (i, "sw_if_index %d", &sw_if_index))
21296 sw_if_index_set = 1;
21301 if (sw_if_index_set == 0)
21306 if (!vam->json_output)
21308 print (vam->ofp, "%11s%15s%15s%14s%14s",
21309 "sw_if_index", "src_address", "dst_address",
21310 "local_sa_id", "remote_sa_id");
21313 /* Get list of gre-tunnel interfaces */
21314 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21316 mp->sw_if_index = htonl (sw_if_index);
21320 /* Use a control ping for synchronization */
21321 MPING (CONTROL_PING, mp_ping);
21329 api_delete_subif (vat_main_t * vam)
21331 unformat_input_t *i = vam->input;
21332 vl_api_delete_subif_t *mp;
21333 u32 sw_if_index = ~0;
21336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21338 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21340 if (unformat (i, "sw_if_index %d", &sw_if_index))
21346 if (sw_if_index == ~0)
21348 errmsg ("missing sw_if_index");
21352 /* Construct the API message */
21353 M (DELETE_SUBIF, mp);
21354 mp->sw_if_index = ntohl (sw_if_index);
21361 #define foreach_pbb_vtr_op \
21362 _("disable", L2_VTR_DISABLED) \
21363 _("pop", L2_VTR_POP_2) \
21364 _("push", L2_VTR_PUSH_2)
21367 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21369 unformat_input_t *i = vam->input;
21370 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21371 u32 sw_if_index = ~0, vtr_op = ~0;
21372 u16 outer_tag = ~0;
21373 u8 dmac[6], smac[6];
21374 u8 dmac_set = 0, smac_set = 0;
21380 /* Shut up coverity */
21381 clib_memset (dmac, 0, sizeof (dmac));
21382 clib_memset (smac, 0, sizeof (smac));
21384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21386 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21388 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21390 else if (unformat (i, "vtr_op %d", &vtr_op))
21392 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21395 else if (unformat (i, "translate_pbb_stag"))
21397 if (unformat (i, "%d", &tmp))
21399 vtr_op = L2_VTR_TRANSLATE_2_1;
21405 ("translate_pbb_stag operation requires outer tag definition");
21409 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21411 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21413 else if (unformat (i, "sid %d", &sid))
21415 else if (unformat (i, "vlanid %d", &tmp))
21419 clib_warning ("parse error '%U'", format_unformat_error, i);
21424 if ((sw_if_index == ~0) || (vtr_op == ~0))
21426 errmsg ("missing sw_if_index or vtr operation");
21429 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21430 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21433 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21437 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21438 mp->sw_if_index = ntohl (sw_if_index);
21439 mp->vtr_op = ntohl (vtr_op);
21440 mp->outer_tag = ntohs (outer_tag);
21441 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21442 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21443 mp->b_vlanid = ntohs (vlanid);
21444 mp->i_sid = ntohl (sid);
21452 api_flow_classify_set_interface (vat_main_t * vam)
21454 unformat_input_t *i = vam->input;
21455 vl_api_flow_classify_set_interface_t *mp;
21457 int sw_if_index_set;
21458 u32 ip4_table_index = ~0;
21459 u32 ip6_table_index = ~0;
21463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21465 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21466 sw_if_index_set = 1;
21467 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21468 sw_if_index_set = 1;
21469 else if (unformat (i, "del"))
21471 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21473 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21477 clib_warning ("parse error '%U'", format_unformat_error, i);
21482 if (sw_if_index_set == 0)
21484 errmsg ("missing interface name or sw_if_index");
21488 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21490 mp->sw_if_index = ntohl (sw_if_index);
21491 mp->ip4_table_index = ntohl (ip4_table_index);
21492 mp->ip6_table_index = ntohl (ip6_table_index);
21493 mp->is_add = is_add;
21501 api_flow_classify_dump (vat_main_t * vam)
21503 unformat_input_t *i = vam->input;
21504 vl_api_flow_classify_dump_t *mp;
21505 vl_api_control_ping_t *mp_ping;
21506 u8 type = FLOW_CLASSIFY_N_TABLES;
21509 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21513 errmsg ("classify table type must be specified");
21517 if (!vam->json_output)
21519 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21522 M (FLOW_CLASSIFY_DUMP, mp);
21527 /* Use a control ping for synchronization */
21528 MPING (CONTROL_PING, mp_ping);
21531 /* Wait for a reply... */
21537 api_feature_enable_disable (vat_main_t * vam)
21539 unformat_input_t *i = vam->input;
21540 vl_api_feature_enable_disable_t *mp;
21542 u8 *feature_name = 0;
21543 u32 sw_if_index = ~0;
21547 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21549 if (unformat (i, "arc_name %s", &arc_name))
21551 else if (unformat (i, "feature_name %s", &feature_name))
21554 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21556 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21558 else if (unformat (i, "disable"))
21566 errmsg ("missing arc name");
21569 if (vec_len (arc_name) > 63)
21571 errmsg ("arc name too long");
21574 if (feature_name == 0)
21576 errmsg ("missing feature name");
21579 if (vec_len (feature_name) > 63)
21581 errmsg ("feature name too long");
21584 if (sw_if_index == ~0)
21586 errmsg ("missing interface name or sw_if_index");
21590 /* Construct the API message */
21591 M (FEATURE_ENABLE_DISABLE, mp);
21592 mp->sw_if_index = ntohl (sw_if_index);
21593 mp->enable = enable;
21594 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21595 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21596 vec_free (arc_name);
21597 vec_free (feature_name);
21605 api_sw_interface_tag_add_del (vat_main_t * vam)
21607 unformat_input_t *i = vam->input;
21608 vl_api_sw_interface_tag_add_del_t *mp;
21609 u32 sw_if_index = ~0;
21614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21616 if (unformat (i, "tag %s", &tag))
21618 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21620 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21622 else if (unformat (i, "del"))
21628 if (sw_if_index == ~0)
21630 errmsg ("missing interface name or sw_if_index");
21634 if (enable && (tag == 0))
21636 errmsg ("no tag specified");
21640 /* Construct the API message */
21641 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21642 mp->sw_if_index = ntohl (sw_if_index);
21643 mp->is_add = enable;
21645 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21653 static void vl_api_l2_xconnect_details_t_handler
21654 (vl_api_l2_xconnect_details_t * mp)
21656 vat_main_t *vam = &vat_main;
21658 print (vam->ofp, "%15d%15d",
21659 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21662 static void vl_api_l2_xconnect_details_t_handler_json
21663 (vl_api_l2_xconnect_details_t * mp)
21665 vat_main_t *vam = &vat_main;
21666 vat_json_node_t *node = NULL;
21668 if (VAT_JSON_ARRAY != vam->json_tree.type)
21670 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21671 vat_json_init_array (&vam->json_tree);
21673 node = vat_json_array_add (&vam->json_tree);
21675 vat_json_init_object (node);
21676 vat_json_object_add_uint (node, "rx_sw_if_index",
21677 ntohl (mp->rx_sw_if_index));
21678 vat_json_object_add_uint (node, "tx_sw_if_index",
21679 ntohl (mp->tx_sw_if_index));
21683 api_l2_xconnect_dump (vat_main_t * vam)
21685 vl_api_l2_xconnect_dump_t *mp;
21686 vl_api_control_ping_t *mp_ping;
21689 if (!vam->json_output)
21691 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
21694 M (L2_XCONNECT_DUMP, mp);
21698 /* Use a control ping for synchronization */
21699 MPING (CONTROL_PING, mp_ping);
21707 api_hw_interface_set_mtu (vat_main_t * vam)
21709 unformat_input_t *i = vam->input;
21710 vl_api_hw_interface_set_mtu_t *mp;
21711 u32 sw_if_index = ~0;
21715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21717 if (unformat (i, "mtu %d", &mtu))
21719 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21721 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21727 if (sw_if_index == ~0)
21729 errmsg ("missing interface name or sw_if_index");
21735 errmsg ("no mtu specified");
21739 /* Construct the API message */
21740 M (HW_INTERFACE_SET_MTU, mp);
21741 mp->sw_if_index = ntohl (sw_if_index);
21742 mp->mtu = ntohs ((u16) mtu);
21750 api_p2p_ethernet_add (vat_main_t * vam)
21752 unformat_input_t *i = vam->input;
21753 vl_api_p2p_ethernet_add_t *mp;
21754 u32 parent_if_index = ~0;
21760 clib_memset (remote_mac, 0, sizeof (remote_mac));
21761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21763 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21765 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21769 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21771 else if (unformat (i, "sub_id %d", &sub_id))
21775 clib_warning ("parse error '%U'", format_unformat_error, i);
21780 if (parent_if_index == ~0)
21782 errmsg ("missing interface name or sw_if_index");
21787 errmsg ("missing remote mac address");
21792 errmsg ("missing sub-interface id");
21796 M (P2P_ETHERNET_ADD, mp);
21797 mp->parent_if_index = ntohl (parent_if_index);
21798 mp->subif_id = ntohl (sub_id);
21799 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21807 api_p2p_ethernet_del (vat_main_t * vam)
21809 unformat_input_t *i = vam->input;
21810 vl_api_p2p_ethernet_del_t *mp;
21811 u32 parent_if_index = ~0;
21816 clib_memset (remote_mac, 0, sizeof (remote_mac));
21817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21819 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21821 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21825 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21829 clib_warning ("parse error '%U'", format_unformat_error, i);
21834 if (parent_if_index == ~0)
21836 errmsg ("missing interface name or sw_if_index");
21841 errmsg ("missing remote mac address");
21845 M (P2P_ETHERNET_DEL, mp);
21846 mp->parent_if_index = ntohl (parent_if_index);
21847 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21855 api_lldp_config (vat_main_t * vam)
21857 unformat_input_t *i = vam->input;
21858 vl_api_lldp_config_t *mp;
21860 int tx_interval = 0;
21861 u8 *sys_name = NULL;
21864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21866 if (unformat (i, "system-name %s", &sys_name))
21868 else if (unformat (i, "tx-hold %d", &tx_hold))
21870 else if (unformat (i, "tx-interval %d", &tx_interval))
21874 clib_warning ("parse error '%U'", format_unformat_error, i);
21879 vec_add1 (sys_name, 0);
21881 M (LLDP_CONFIG, mp);
21882 mp->tx_hold = htonl (tx_hold);
21883 mp->tx_interval = htonl (tx_interval);
21884 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21885 vec_free (sys_name);
21893 api_sw_interface_set_lldp (vat_main_t * vam)
21895 unformat_input_t *i = vam->input;
21896 vl_api_sw_interface_set_lldp_t *mp;
21897 u32 sw_if_index = ~0;
21899 u8 *port_desc = NULL, *mgmt_oid = NULL;
21900 ip4_address_t ip4_addr;
21901 ip6_address_t ip6_addr;
21904 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
21905 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
21907 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21909 if (unformat (i, "disable"))
21912 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21914 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21916 else if (unformat (i, "port-desc %s", &port_desc))
21918 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21920 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21922 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
21928 if (sw_if_index == ~0)
21930 errmsg ("missing interface name or sw_if_index");
21934 /* Construct the API message */
21935 vec_add1 (port_desc, 0);
21936 vec_add1 (mgmt_oid, 0);
21937 M (SW_INTERFACE_SET_LLDP, mp);
21938 mp->sw_if_index = ntohl (sw_if_index);
21939 mp->enable = enable;
21940 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
21941 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
21942 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
21943 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
21944 vec_free (port_desc);
21945 vec_free (mgmt_oid);
21953 api_tcp_configure_src_addresses (vat_main_t * vam)
21955 vl_api_tcp_configure_src_addresses_t *mp;
21956 unformat_input_t *i = vam->input;
21957 ip4_address_t v4first, v4last;
21958 ip6_address_t v6first, v6last;
21963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21965 if (unformat (i, "%U - %U",
21966 unformat_ip4_address, &v4first,
21967 unformat_ip4_address, &v4last))
21971 errmsg ("one range per message (range already set)");
21976 else if (unformat (i, "%U - %U",
21977 unformat_ip6_address, &v6first,
21978 unformat_ip6_address, &v6last))
21982 errmsg ("one range per message (range already set)");
21987 else if (unformat (i, "vrf %d", &vrf_id))
21993 if (range_set == 0)
21995 errmsg ("address range not set");
21999 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22000 mp->vrf_id = ntohl (vrf_id);
22002 if (range_set == 2)
22005 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22006 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22011 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22012 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22019 static void vl_api_app_namespace_add_del_reply_t_handler
22020 (vl_api_app_namespace_add_del_reply_t * mp)
22022 vat_main_t *vam = &vat_main;
22023 i32 retval = ntohl (mp->retval);
22024 if (vam->async_mode)
22026 vam->async_errors += (retval < 0);
22030 vam->retval = retval;
22032 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22033 vam->result_ready = 1;
22037 static void vl_api_app_namespace_add_del_reply_t_handler_json
22038 (vl_api_app_namespace_add_del_reply_t * mp)
22040 vat_main_t *vam = &vat_main;
22041 vat_json_node_t node;
22043 vat_json_init_object (&node);
22044 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22045 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22047 vat_json_print (vam->ofp, &node);
22048 vat_json_free (&node);
22050 vam->retval = ntohl (mp->retval);
22051 vam->result_ready = 1;
22055 api_app_namespace_add_del (vat_main_t * vam)
22057 vl_api_app_namespace_add_del_t *mp;
22058 unformat_input_t *i = vam->input;
22059 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22060 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22064 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22066 if (unformat (i, "id %_%v%_", &ns_id))
22068 else if (unformat (i, "secret %lu", &secret))
22070 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22071 sw_if_index_set = 1;
22072 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22074 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22079 if (!ns_id || !secret_set || !sw_if_index_set)
22081 errmsg ("namespace id, secret and sw_if_index must be set");
22084 if (vec_len (ns_id) > 64)
22086 errmsg ("namespace id too long");
22089 M (APP_NAMESPACE_ADD_DEL, mp);
22091 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22092 mp->namespace_id_len = vec_len (ns_id);
22093 mp->secret = clib_host_to_net_u64 (secret);
22094 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22095 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22096 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22104 api_sock_init_shm (vat_main_t * vam)
22106 #if VPP_API_TEST_BUILTIN == 0
22107 unformat_input_t *i = vam->input;
22108 vl_api_shm_elem_config_t *config = 0;
22109 u64 size = 64 << 20;
22112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22114 if (unformat (i, "size %U", unformat_memory_size, &size))
22121 * Canned custom ring allocator config.
22122 * Should probably parse all of this
22124 vec_validate (config, 6);
22125 config[0].type = VL_API_VLIB_RING;
22126 config[0].size = 256;
22127 config[0].count = 32;
22129 config[1].type = VL_API_VLIB_RING;
22130 config[1].size = 1024;
22131 config[1].count = 16;
22133 config[2].type = VL_API_VLIB_RING;
22134 config[2].size = 4096;
22135 config[2].count = 2;
22137 config[3].type = VL_API_CLIENT_RING;
22138 config[3].size = 256;
22139 config[3].count = 32;
22141 config[4].type = VL_API_CLIENT_RING;
22142 config[4].size = 1024;
22143 config[4].count = 16;
22145 config[5].type = VL_API_CLIENT_RING;
22146 config[5].size = 4096;
22147 config[5].count = 2;
22149 config[6].type = VL_API_QUEUE;
22150 config[6].count = 128;
22151 config[6].size = sizeof (uword);
22153 rv = vl_socket_client_init_shm (config);
22155 vam->client_index_invalid = 1;
22163 api_dns_enable_disable (vat_main_t * vam)
22165 unformat_input_t *line_input = vam->input;
22166 vl_api_dns_enable_disable_t *mp;
22167 u8 enable_disable = 1;
22170 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22172 if (unformat (line_input, "disable"))
22173 enable_disable = 0;
22174 if (unformat (line_input, "enable"))
22175 enable_disable = 1;
22180 /* Construct the API message */
22181 M (DNS_ENABLE_DISABLE, mp);
22182 mp->enable = enable_disable;
22186 /* Wait for the reply */
22192 api_dns_resolve_name (vat_main_t * vam)
22194 unformat_input_t *line_input = vam->input;
22195 vl_api_dns_resolve_name_t *mp;
22199 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22201 if (unformat (line_input, "%s", &name))
22207 if (vec_len (name) > 127)
22209 errmsg ("name too long");
22213 /* Construct the API message */
22214 M (DNS_RESOLVE_NAME, mp);
22215 memcpy (mp->name, name, vec_len (name));
22220 /* Wait for the reply */
22226 api_dns_resolve_ip (vat_main_t * vam)
22228 unformat_input_t *line_input = vam->input;
22229 vl_api_dns_resolve_ip_t *mp;
22231 ip4_address_t addr4;
22232 ip6_address_t addr6;
22235 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22237 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22239 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22247 errmsg ("missing address");
22251 /* Construct the API message */
22252 M (DNS_RESOLVE_IP, mp);
22253 mp->is_ip6 = is_ip6;
22255 memcpy (mp->address, &addr6, sizeof (addr6));
22257 memcpy (mp->address, &addr4, sizeof (addr4));
22261 /* Wait for the reply */
22267 api_dns_name_server_add_del (vat_main_t * vam)
22269 unformat_input_t *i = vam->input;
22270 vl_api_dns_name_server_add_del_t *mp;
22272 ip6_address_t ip6_server;
22273 ip4_address_t ip4_server;
22278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22280 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22282 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22284 else if (unformat (i, "del"))
22288 clib_warning ("parse error '%U'", format_unformat_error, i);
22293 if (ip4_set && ip6_set)
22295 errmsg ("Only one server address allowed per message");
22298 if ((ip4_set + ip6_set) == 0)
22300 errmsg ("Server address required");
22304 /* Construct the API message */
22305 M (DNS_NAME_SERVER_ADD_DEL, mp);
22309 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22314 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22318 mp->is_add = is_add;
22323 /* Wait for a reply, return good/bad news */
22329 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22331 vat_main_t *vam = &vat_main;
22336 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22337 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22338 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22339 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22340 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22341 clib_net_to_host_u32 (mp->action_index), mp->tag);
22346 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22347 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22348 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22349 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22350 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22351 clib_net_to_host_u32 (mp->action_index), mp->tag);
22356 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22359 vat_main_t *vam = &vat_main;
22360 vat_json_node_t *node = NULL;
22361 struct in6_addr ip6;
22362 struct in_addr ip4;
22364 if (VAT_JSON_ARRAY != vam->json_tree.type)
22366 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22367 vat_json_init_array (&vam->json_tree);
22369 node = vat_json_array_add (&vam->json_tree);
22370 vat_json_init_object (node);
22372 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22373 vat_json_object_add_uint (node, "appns_index",
22374 clib_net_to_host_u32 (mp->appns_index));
22375 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22376 vat_json_object_add_uint (node, "scope", mp->scope);
22377 vat_json_object_add_uint (node, "action_index",
22378 clib_net_to_host_u32 (mp->action_index));
22379 vat_json_object_add_uint (node, "lcl_port",
22380 clib_net_to_host_u16 (mp->lcl_port));
22381 vat_json_object_add_uint (node, "rmt_port",
22382 clib_net_to_host_u16 (mp->rmt_port));
22383 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22384 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22385 vat_json_object_add_string_copy (node, "tag", mp->tag);
22388 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22389 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22390 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22391 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22395 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22396 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22397 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22398 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22403 api_session_rule_add_del (vat_main_t * vam)
22405 vl_api_session_rule_add_del_t *mp;
22406 unformat_input_t *i = vam->input;
22407 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22408 u32 appns_index = 0, scope = 0;
22409 ip4_address_t lcl_ip4, rmt_ip4;
22410 ip6_address_t lcl_ip6, rmt_ip6;
22411 u8 is_ip4 = 1, conn_set = 0;
22412 u8 is_add = 1, *tag = 0;
22415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22417 if (unformat (i, "del"))
22419 else if (unformat (i, "add"))
22421 else if (unformat (i, "proto tcp"))
22423 else if (unformat (i, "proto udp"))
22425 else if (unformat (i, "appns %d", &appns_index))
22427 else if (unformat (i, "scope %d", &scope))
22429 else if (unformat (i, "tag %_%v%_", &tag))
22433 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22434 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22442 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22443 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22449 else if (unformat (i, "action %d", &action))
22454 if (proto == ~0 || !conn_set || action == ~0)
22456 errmsg ("transport proto, connection and action must be set");
22462 errmsg ("scope should be 0-3");
22466 M (SESSION_RULE_ADD_DEL, mp);
22468 mp->is_ip4 = is_ip4;
22469 mp->transport_proto = proto;
22470 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22471 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22472 mp->lcl_plen = lcl_plen;
22473 mp->rmt_plen = rmt_plen;
22474 mp->action_index = clib_host_to_net_u32 (action);
22475 mp->appns_index = clib_host_to_net_u32 (appns_index);
22477 mp->is_add = is_add;
22480 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22481 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22485 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22486 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22490 clib_memcpy (mp->tag, tag, vec_len (tag));
22500 api_session_rules_dump (vat_main_t * vam)
22502 vl_api_session_rules_dump_t *mp;
22503 vl_api_control_ping_t *mp_ping;
22506 if (!vam->json_output)
22508 print (vam->ofp, "%=20s", "Session Rules");
22511 M (SESSION_RULES_DUMP, mp);
22515 /* Use a control ping for synchronization */
22516 MPING (CONTROL_PING, mp_ping);
22519 /* Wait for a reply... */
22525 api_ip_container_proxy_add_del (vat_main_t * vam)
22527 vl_api_ip_container_proxy_add_del_t *mp;
22528 unformat_input_t *i = vam->input;
22529 u32 plen = ~0, sw_if_index = ~0;
22536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22538 if (unformat (i, "del"))
22540 else if (unformat (i, "add"))
22542 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22547 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22552 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22557 if (sw_if_index == ~0 || plen == ~0)
22559 errmsg ("address and sw_if_index must be set");
22563 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22565 mp->is_ip4 = is_ip4;
22566 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22568 mp->is_add = is_add;
22570 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22572 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22580 api_qos_record_enable_disable (vat_main_t * vam)
22582 unformat_input_t *i = vam->input;
22583 vl_api_qos_record_enable_disable_t *mp;
22584 u32 sw_if_index, qs = 0xff;
22585 u8 sw_if_index_set = 0;
22589 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22591 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22592 sw_if_index_set = 1;
22593 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22594 sw_if_index_set = 1;
22595 else if (unformat (i, "%U", unformat_qos_source, &qs))
22597 else if (unformat (i, "disable"))
22601 clib_warning ("parse error '%U'", format_unformat_error, i);
22606 if (sw_if_index_set == 0)
22608 errmsg ("missing interface name or sw_if_index");
22613 errmsg ("input location must be specified");
22617 M (QOS_RECORD_ENABLE_DISABLE, mp);
22619 mp->sw_if_index = ntohl (sw_if_index);
22620 mp->input_source = qs;
22621 mp->enable = enable;
22630 q_or_quit (vat_main_t * vam)
22632 #if VPP_API_TEST_BUILTIN == 0
22633 longjmp (vam->jump_buf, 1);
22635 return 0; /* not so much */
22639 q (vat_main_t * vam)
22641 return q_or_quit (vam);
22645 quit (vat_main_t * vam)
22647 return q_or_quit (vam);
22651 comment (vat_main_t * vam)
22657 statseg (vat_main_t * vam)
22659 ssvm_private_t *ssvmp = &vam->stat_segment;
22660 ssvm_shared_header_t *shared_header = ssvmp->sh;
22661 vlib_counter_t **counters;
22662 u64 thread0_index1_packets;
22663 u64 thread0_index1_bytes;
22664 f64 vector_rate, input_rate;
22667 uword *counter_vector_by_name;
22668 if (vam->stat_segment_lockp == 0)
22670 errmsg ("Stat segment not mapped...");
22674 /* look up "/if/rx for sw_if_index 1 as a test */
22676 clib_spinlock_lock (vam->stat_segment_lockp);
22678 counter_vector_by_name = (uword *) shared_header->opaque[1];
22680 p = hash_get_mem (counter_vector_by_name, "/if/rx");
22683 clib_spinlock_unlock (vam->stat_segment_lockp);
22684 errmsg ("/if/tx not found?");
22688 /* Fish per-thread vector of combined counters from shared memory */
22689 counters = (vlib_counter_t **) p[0];
22691 if (vec_len (counters[0]) < 2)
22693 clib_spinlock_unlock (vam->stat_segment_lockp);
22694 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
22698 /* Read thread 0 sw_if_index 1 counter */
22699 thread0_index1_packets = counters[0][1].packets;
22700 thread0_index1_bytes = counters[0][1].bytes;
22702 p = hash_get_mem (counter_vector_by_name, "vector_rate");
22705 clib_spinlock_unlock (vam->stat_segment_lockp);
22706 errmsg ("vector_rate not found?");
22710 vector_rate = *(f64 *) (p[0]);
22711 p = hash_get_mem (counter_vector_by_name, "input_rate");
22714 clib_spinlock_unlock (vam->stat_segment_lockp);
22715 errmsg ("input_rate not found?");
22718 input_rate = *(f64 *) (p[0]);
22720 clib_spinlock_unlock (vam->stat_segment_lockp);
22722 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
22723 vector_rate, input_rate);
22724 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
22725 thread0_index1_packets, thread0_index1_bytes);
22731 cmd_cmp (void *a1, void *a2)
22736 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22740 help (vat_main_t * vam)
22745 unformat_input_t *i = vam->input;
22748 if (unformat (i, "%s", &name))
22752 vec_add1 (name, 0);
22754 hs = hash_get_mem (vam->help_by_name, name);
22756 print (vam->ofp, "usage: %s %s", name, hs[0]);
22758 print (vam->ofp, "No such msg / command '%s'", name);
22763 print (vam->ofp, "Help is available for the following:");
22766 hash_foreach_pair (p, vam->function_by_name,
22768 vec_add1 (cmds, (u8 *)(p->key));
22772 vec_sort_with_function (cmds, cmd_cmp);
22774 for (j = 0; j < vec_len (cmds); j++)
22775 print (vam->ofp, "%s", cmds[j]);
22782 set (vat_main_t * vam)
22784 u8 *name = 0, *value = 0;
22785 unformat_input_t *i = vam->input;
22787 if (unformat (i, "%s", &name))
22789 /* The input buffer is a vector, not a string. */
22790 value = vec_dup (i->buffer);
22791 vec_delete (value, i->index, 0);
22792 /* Almost certainly has a trailing newline */
22793 if (value[vec_len (value) - 1] == '\n')
22794 value[vec_len (value) - 1] = 0;
22795 /* Make sure it's a proper string, one way or the other */
22796 vec_add1 (value, 0);
22797 (void) clib_macro_set_value (&vam->macro_main,
22798 (char *) name, (char *) value);
22801 errmsg ("usage: set <name> <value>");
22809 unset (vat_main_t * vam)
22813 if (unformat (vam->input, "%s", &name))
22814 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
22815 errmsg ("unset: %s wasn't set", name);
22828 macro_sort_cmp (void *a1, void *a2)
22830 macro_sort_t *s1 = a1;
22831 macro_sort_t *s2 = a2;
22833 return strcmp ((char *) (s1->name), (char *) (s2->name));
22837 dump_macro_table (vat_main_t * vam)
22839 macro_sort_t *sort_me = 0, *sm;
22844 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
22846 vec_add2 (sort_me, sm, 1);
22847 sm->name = (u8 *)(p->key);
22848 sm->value = (u8 *) (p->value[0]);
22852 vec_sort_with_function (sort_me, macro_sort_cmp);
22854 if (vec_len (sort_me))
22855 print (vam->ofp, "%-15s%s", "Name", "Value");
22857 print (vam->ofp, "The macro table is empty...");
22859 for (i = 0; i < vec_len (sort_me); i++)
22860 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
22865 dump_node_table (vat_main_t * vam)
22868 vlib_node_t *node, *next_node;
22870 if (vec_len (vam->graph_nodes) == 0)
22872 print (vam->ofp, "Node table empty, issue get_node_graph...");
22876 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
22878 node = vam->graph_nodes[0][i];
22879 print (vam->ofp, "[%d] %s", i, node->name);
22880 for (j = 0; j < vec_len (node->next_nodes); j++)
22882 if (node->next_nodes[j] != ~0)
22884 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22885 print (vam->ofp, " [%d] %s", j, next_node->name);
22893 value_sort_cmp (void *a1, void *a2)
22895 name_sort_t *n1 = a1;
22896 name_sort_t *n2 = a2;
22898 if (n1->value < n2->value)
22900 if (n1->value > n2->value)
22907 dump_msg_api_table (vat_main_t * vam)
22909 api_main_t *am = &api_main;
22910 name_sort_t *nses = 0, *ns;
22915 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
22917 vec_add2 (nses, ns, 1);
22918 ns->name = (u8 *)(hp->key);
22919 ns->value = (u32) hp->value[0];
22923 vec_sort_with_function (nses, value_sort_cmp);
22925 for (i = 0; i < vec_len (nses); i++)
22926 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
22932 get_msg_id (vat_main_t * vam)
22937 if (unformat (vam->input, "%s", &name_and_crc))
22939 message_index = vl_msg_api_get_msg_index (name_and_crc);
22940 if (message_index == ~0)
22942 print (vam->ofp, " '%s' not found", name_and_crc);
22945 print (vam->ofp, " '%s' has message index %d",
22946 name_and_crc, message_index);
22949 errmsg ("name_and_crc required...");
22954 search_node_table (vat_main_t * vam)
22956 unformat_input_t *line_input = vam->input;
22959 vlib_node_t *node, *next_node;
22962 if (vam->graph_node_index_by_name == 0)
22964 print (vam->ofp, "Node table empty, issue get_node_graph...");
22968 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22970 if (unformat (line_input, "%s", &node_to_find))
22972 vec_add1 (node_to_find, 0);
22973 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
22976 print (vam->ofp, "%s not found...", node_to_find);
22979 node = vam->graph_nodes[0][p[0]];
22980 print (vam->ofp, "[%d] %s", p[0], node->name);
22981 for (j = 0; j < vec_len (node->next_nodes); j++)
22983 if (node->next_nodes[j] != ~0)
22985 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22986 print (vam->ofp, " [%d] %s", j, next_node->name);
22993 clib_warning ("parse error '%U'", format_unformat_error,
22999 vec_free (node_to_find);
23008 script (vat_main_t * vam)
23010 #if (VPP_API_TEST_BUILTIN==0)
23012 char *save_current_file;
23013 unformat_input_t save_input;
23014 jmp_buf save_jump_buf;
23015 u32 save_line_number;
23017 FILE *new_fp, *save_ifp;
23019 if (unformat (vam->input, "%s", &s))
23021 new_fp = fopen ((char *) s, "r");
23024 errmsg ("Couldn't open script file %s", s);
23031 errmsg ("Missing script name");
23035 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23036 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23037 save_ifp = vam->ifp;
23038 save_line_number = vam->input_line_number;
23039 save_current_file = (char *) vam->current_file;
23041 vam->input_line_number = 0;
23043 vam->current_file = s;
23046 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23047 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23048 vam->ifp = save_ifp;
23049 vam->input_line_number = save_line_number;
23050 vam->current_file = (u8 *) save_current_file;
23055 clib_warning ("use the exec command...");
23061 echo (vat_main_t * vam)
23063 print (vam->ofp, "%v", vam->input->buffer);
23067 /* List of API message constructors, CLI names map to api_xxx */
23068 #define foreach_vpe_api_msg \
23069 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23070 _(sw_interface_dump,"") \
23071 _(sw_interface_set_flags, \
23072 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23073 _(sw_interface_add_del_address, \
23074 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23075 _(sw_interface_set_rx_mode, \
23076 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23077 _(sw_interface_set_rx_placement, \
23078 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
23079 _(sw_interface_rx_placement_dump, \
23080 "[<intfc> | sw_if_index <id>]") \
23081 _(sw_interface_set_table, \
23082 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23083 _(sw_interface_set_mpls_enable, \
23084 "<intfc> | sw_if_index [disable | dis]") \
23085 _(sw_interface_set_vpath, \
23086 "<intfc> | sw_if_index <id> enable | disable") \
23087 _(sw_interface_set_vxlan_bypass, \
23088 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23089 _(sw_interface_set_geneve_bypass, \
23090 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23091 _(sw_interface_set_l2_xconnect, \
23092 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23093 "enable | disable") \
23094 _(sw_interface_set_l2_bridge, \
23095 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23096 "[shg <split-horizon-group>] [bvi]\n" \
23097 "enable | disable") \
23098 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23099 _(bridge_domain_add_del, \
23100 "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") \
23101 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23103 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23104 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23105 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23107 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23109 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23111 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23113 "<vpp-if-name> | sw_if_index <id>") \
23114 _(sw_interface_tap_v2_dump, "") \
23115 _(virtio_pci_create, \
23116 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [tx-ring-size <num> [rx-ring-size <num>] [features <hex-value>]") \
23117 _(virtio_pci_delete, \
23118 "<vpp-if-name> | sw_if_index <id>") \
23119 _(sw_interface_virtio_pci_dump, "") \
23121 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23122 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
23125 "<vpp-if-name> | sw_if_index <id>") \
23127 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23128 _(bond_detach_slave, \
23129 "sw_if_index <n>") \
23130 _(sw_interface_bond_dump, "") \
23131 _(sw_interface_slave_dump, \
23132 "<vpp-if-name> | sw_if_index <id>") \
23133 _(ip_table_add_del, \
23134 "table <n> [ipv6] [add | del]\n") \
23135 _(ip_add_del_route, \
23136 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
23137 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
23138 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
23139 "[multipath] [count <n>] [del]") \
23140 _(ip_mroute_add_del, \
23141 "<src> <grp>/<mask> [table-id <n>]\n" \
23142 "[<intfc> | sw_if_index <id>] [local] [del]") \
23143 _(mpls_table_add_del, \
23144 "table <n> [add | del]\n") \
23145 _(mpls_route_add_del, \
23146 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
23147 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
23148 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
23149 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
23150 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
23151 "[count <n>] [del]") \
23152 _(mpls_ip_bind_unbind, \
23153 "<label> <addr/len>") \
23154 _(mpls_tunnel_add_del, \
23155 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
23156 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
23157 "[l2-only] [out-label <n>]") \
23158 _(sr_mpls_policy_add, \
23159 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
23160 _(sr_mpls_policy_del, \
23162 _(bier_table_add_del, \
23163 "<label> <sub-domain> <set> <bsl> [del]") \
23164 _(bier_route_add_del, \
23165 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23166 "[<intfc> | sw_if_index <id>]" \
23167 "[weight <n>] [del] [multipath]") \
23168 _(proxy_arp_add_del, \
23169 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23170 _(proxy_arp_intfc_enable_disable, \
23171 "<intfc> | sw_if_index <id> enable | disable") \
23172 _(sw_interface_set_unnumbered, \
23173 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23174 _(ip_neighbor_add_del, \
23175 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23176 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23177 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23178 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23179 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23180 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23181 "[outer_vlan_id_any][inner_vlan_id_any]") \
23182 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23183 _(reset_fib, "vrf <n> [ipv6]") \
23184 _(dhcp_proxy_config, \
23185 "svr <v46-address> src <v46-address>\n" \
23186 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23187 _(dhcp_proxy_set_vss, \
23188 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23189 _(dhcp_proxy_dump, "ip6") \
23190 _(dhcp_client_config, \
23191 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23192 _(set_ip_flow_hash, \
23193 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23194 _(sw_interface_ip6_enable_disable, \
23195 "<intfc> | sw_if_index <id> enable | disable") \
23196 _(ip6nd_proxy_add_del, \
23197 "<intfc> | sw_if_index <id> <ip6-address>") \
23198 _(ip6nd_proxy_dump, "") \
23199 _(sw_interface_ip6nd_ra_prefix, \
23200 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23201 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23202 "[nolink] [isno]") \
23203 _(sw_interface_ip6nd_ra_config, \
23204 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23205 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23206 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23207 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23208 _(l2_patch_add_del, \
23209 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23210 "enable | disable") \
23211 _(sr_localsid_add_del, \
23212 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23213 "fib-table <num> (end.psp) sw_if_index <num>") \
23214 _(classify_add_del_table, \
23215 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23216 " [del] [del-chain] mask <mask-value>\n" \
23217 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23218 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23219 _(classify_add_del_session, \
23220 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23221 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23222 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23223 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23224 _(classify_set_interface_ip_table, \
23225 "<intfc> | sw_if_index <nn> table <nn>") \
23226 _(classify_set_interface_l2_tables, \
23227 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23228 " [other-table <nn>]") \
23229 _(get_node_index, "node <node-name") \
23230 _(add_node_next, "node <node-name> next <next-node-name>") \
23231 _(l2tpv3_create_tunnel, \
23232 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23233 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23234 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23235 _(l2tpv3_set_tunnel_cookies, \
23236 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23237 "[new_remote_cookie <nn>]\n") \
23238 _(l2tpv3_interface_enable_disable, \
23239 "<intfc> | sw_if_index <nn> enable | disable") \
23240 _(l2tpv3_set_lookup_key, \
23241 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23242 _(sw_if_l2tpv3_tunnel_dump, "") \
23243 _(vxlan_offload_rx, \
23244 "hw { <interface name> | hw_if_index <nn>} " \
23245 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23246 _(vxlan_add_del_tunnel, \
23247 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23248 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23249 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23250 _(geneve_add_del_tunnel, \
23251 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23252 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23253 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23254 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23255 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23256 _(gre_add_del_tunnel, \
23257 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23258 "[teb | erspan <session-id>] [del]") \
23259 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23260 _(l2_fib_clear_table, "") \
23261 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23262 _(l2_interface_vlan_tag_rewrite, \
23263 "<intfc> | sw_if_index <nn> \n" \
23264 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23265 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23266 _(create_vhost_user_if, \
23267 "socket <filename> [server] [renumber <dev_instance>] " \
23268 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
23269 "[mac <mac_address>]") \
23270 _(modify_vhost_user_if, \
23271 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23272 "[server] [renumber <dev_instance>]") \
23273 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23274 _(sw_interface_vhost_user_dump, "") \
23275 _(show_version, "") \
23276 _(show_threads, "") \
23277 _(vxlan_gpe_add_del_tunnel, \
23278 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23279 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23280 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23281 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23282 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23283 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23284 _(interface_name_renumber, \
23285 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23286 _(input_acl_set_interface, \
23287 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23288 " [l2-table <nn>] [del]") \
23289 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23290 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23291 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23292 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23293 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23294 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23295 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23296 _(ip_dump, "ipv4 | ipv6") \
23297 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23298 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23300 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23301 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23302 " integ_alg <alg> integ_key <hex>") \
23303 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23304 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23305 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23306 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23307 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23308 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23309 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23310 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23311 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23312 " [instance <n>]") \
23313 _(ipsec_sa_dump, "[sa_id <n>]") \
23314 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23315 " <alg> <hex>\n") \
23316 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23317 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23318 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23319 "(auth_data 0x<data> | auth_data <data>)") \
23320 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23321 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23322 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23323 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23324 "(local|remote)") \
23325 _(ikev2_set_local_key, "file <absolute_file_path>") \
23326 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23327 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23328 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23329 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23330 _(ikev2_initiate_sa_init, "<profile_name>") \
23331 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23332 _(ikev2_initiate_del_child_sa, "<ispi>") \
23333 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23334 _(delete_loopback,"sw_if_index <nn>") \
23335 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23336 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
23337 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
23338 _(want_interface_events, "enable|disable") \
23339 _(get_first_msg_id, "client <name>") \
23340 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23341 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23342 "fib-id <nn> [ip4][ip6][default]") \
23343 _(get_node_graph, " ") \
23344 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23345 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23346 _(ioam_disable, "") \
23347 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23348 " sw_if_index <sw_if_index> p <priority> " \
23349 "w <weight>] [del]") \
23350 _(one_add_del_locator, "locator-set <locator_name> " \
23351 "iface <intf> | sw_if_index <sw_if_index> " \
23352 "p <priority> w <weight> [del]") \
23353 _(one_add_del_local_eid,"vni <vni> eid " \
23354 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23355 "locator-set <locator_name> [del]" \
23356 "[key-id sha1|sha256 secret-key <secret-key>]")\
23357 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23358 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23359 _(one_enable_disable, "enable|disable") \
23360 _(one_map_register_enable_disable, "enable|disable") \
23361 _(one_map_register_fallback_threshold, "<value>") \
23362 _(one_rloc_probe_enable_disable, "enable|disable") \
23363 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23365 "rloc <locator> p <prio> " \
23366 "w <weight> [rloc <loc> ... ] " \
23367 "action <action> [del-all]") \
23368 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23370 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23371 _(one_use_petr, "ip-address> | disable") \
23372 _(one_map_request_mode, "src-dst|dst-only") \
23373 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23374 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23375 _(one_locator_set_dump, "[local | remote]") \
23376 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23377 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23378 "[local] | [remote]") \
23379 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23380 _(one_ndp_bd_get, "") \
23381 _(one_ndp_entries_get, "bd <bridge-domain>") \
23382 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23383 _(one_l2_arp_bd_get, "") \
23384 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23385 _(one_stats_enable_disable, "enable|disable") \
23386 _(show_one_stats_enable_disable, "") \
23387 _(one_eid_table_vni_dump, "") \
23388 _(one_eid_table_map_dump, "l2|l3") \
23389 _(one_map_resolver_dump, "") \
23390 _(one_map_server_dump, "") \
23391 _(one_adjacencies_get, "vni <vni>") \
23392 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23393 _(show_one_rloc_probe_state, "") \
23394 _(show_one_map_register_state, "") \
23395 _(show_one_status, "") \
23396 _(one_stats_dump, "") \
23397 _(one_stats_flush, "") \
23398 _(one_get_map_request_itr_rlocs, "") \
23399 _(one_map_register_set_ttl, "<ttl>") \
23400 _(one_set_transport_protocol, "udp|api") \
23401 _(one_get_transport_protocol, "") \
23402 _(one_enable_disable_xtr_mode, "enable|disable") \
23403 _(one_show_xtr_mode, "") \
23404 _(one_enable_disable_pitr_mode, "enable|disable") \
23405 _(one_show_pitr_mode, "") \
23406 _(one_enable_disable_petr_mode, "enable|disable") \
23407 _(one_show_petr_mode, "") \
23408 _(show_one_nsh_mapping, "") \
23409 _(show_one_pitr, "") \
23410 _(show_one_use_petr, "") \
23411 _(show_one_map_request_mode, "") \
23412 _(show_one_map_register_ttl, "") \
23413 _(show_one_map_register_fallback_threshold, "") \
23414 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23415 " sw_if_index <sw_if_index> p <priority> " \
23416 "w <weight>] [del]") \
23417 _(lisp_add_del_locator, "locator-set <locator_name> " \
23418 "iface <intf> | sw_if_index <sw_if_index> " \
23419 "p <priority> w <weight> [del]") \
23420 _(lisp_add_del_local_eid,"vni <vni> eid " \
23421 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23422 "locator-set <locator_name> [del]" \
23423 "[key-id sha1|sha256 secret-key <secret-key>]") \
23424 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23425 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23426 _(lisp_enable_disable, "enable|disable") \
23427 _(lisp_map_register_enable_disable, "enable|disable") \
23428 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23429 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23431 "rloc <locator> p <prio> " \
23432 "w <weight> [rloc <loc> ... ] " \
23433 "action <action> [del-all]") \
23434 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23436 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23437 _(lisp_use_petr, "<ip-address> | disable") \
23438 _(lisp_map_request_mode, "src-dst|dst-only") \
23439 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23440 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23441 _(lisp_locator_set_dump, "[local | remote]") \
23442 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23443 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23444 "[local] | [remote]") \
23445 _(lisp_eid_table_vni_dump, "") \
23446 _(lisp_eid_table_map_dump, "l2|l3") \
23447 _(lisp_map_resolver_dump, "") \
23448 _(lisp_map_server_dump, "") \
23449 _(lisp_adjacencies_get, "vni <vni>") \
23450 _(gpe_fwd_entry_vnis_get, "") \
23451 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23452 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23453 "[table <table-id>]") \
23454 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23455 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23456 _(gpe_set_encap_mode, "lisp|vxlan") \
23457 _(gpe_get_encap_mode, "") \
23458 _(lisp_gpe_add_del_iface, "up|down") \
23459 _(lisp_gpe_enable_disable, "enable|disable") \
23460 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23461 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23462 _(show_lisp_rloc_probe_state, "") \
23463 _(show_lisp_map_register_state, "") \
23464 _(show_lisp_status, "") \
23465 _(lisp_get_map_request_itr_rlocs, "") \
23466 _(show_lisp_pitr, "") \
23467 _(show_lisp_use_petr, "") \
23468 _(show_lisp_map_request_mode, "") \
23469 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23470 _(af_packet_delete, "name <host interface name>") \
23471 _(af_packet_dump, "") \
23472 _(policer_add_del, "name <policer name> <params> [del]") \
23473 _(policer_dump, "[name <policer name>]") \
23474 _(policer_classify_set_interface, \
23475 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23476 " [l2-table <nn>] [del]") \
23477 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23478 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23479 "[master|slave]") \
23480 _(netmap_delete, "name <interface name>") \
23481 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23482 _(mpls_fib_dump, "") \
23483 _(classify_table_ids, "") \
23484 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23485 _(classify_table_info, "table_id <nn>") \
23486 _(classify_session_dump, "table_id <nn>") \
23487 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23488 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23489 "[template_interval <nn>] [udp_checksum]") \
23490 _(ipfix_exporter_dump, "") \
23491 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23492 _(ipfix_classify_stream_dump, "") \
23493 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23494 _(ipfix_classify_table_dump, "") \
23495 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23496 _(sw_interface_span_dump, "[l2]") \
23497 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23498 _(pg_create_interface, "if_id <nn>") \
23499 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23500 _(pg_enable_disable, "[stream <id>] disable") \
23501 _(ip_source_and_port_range_check_add_del, \
23502 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23503 _(ip_source_and_port_range_check_interface_add_del, \
23504 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23505 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23506 _(ipsec_gre_add_del_tunnel, \
23507 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23508 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23509 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23510 _(l2_interface_pbb_tag_rewrite, \
23511 "<intfc> | sw_if_index <nn> \n" \
23512 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23513 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23514 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23515 _(flow_classify_set_interface, \
23516 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23517 _(flow_classify_dump, "type [ip4|ip6]") \
23518 _(ip_fib_dump, "") \
23519 _(ip_mfib_dump, "") \
23520 _(ip6_fib_dump, "") \
23521 _(ip6_mfib_dump, "") \
23522 _(feature_enable_disable, "arc_name <arc_name> " \
23523 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23524 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23526 _(l2_xconnect_dump, "") \
23527 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
23528 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23529 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23530 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23531 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23532 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23533 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23534 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23535 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23536 _(sock_init_shm, "size <nnn>") \
23537 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23538 _(dns_enable_disable, "[enable][disable]") \
23539 _(dns_name_server_add_del, "<ip-address> [del]") \
23540 _(dns_resolve_name, "<hostname>") \
23541 _(dns_resolve_ip, "<ip4|ip6>") \
23542 _(dns_name_server_add_del, "<ip-address> [del]") \
23543 _(dns_resolve_name, "<hostname>") \
23544 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23545 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23546 _(session_rules_dump, "") \
23547 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23548 _(output_acl_set_interface, \
23549 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23550 " [l2-table <nn>] [del]") \
23551 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
23553 /* List of command functions, CLI names map directly to functions */
23554 #define foreach_cli_function \
23555 _(comment, "usage: comment <ignore-rest-of-line>") \
23556 _(dump_interface_table, "usage: dump_interface_table") \
23557 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23558 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23559 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23560 _(dump_macro_table, "usage: dump_macro_table ") \
23561 _(dump_node_table, "usage: dump_node_table") \
23562 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23563 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23564 _(echo, "usage: echo <message>") \
23565 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23566 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23567 _(help, "usage: help") \
23568 _(q, "usage: quit") \
23569 _(quit, "usage: quit") \
23570 _(search_node_table, "usage: search_node_table <name>...") \
23571 _(set, "usage: set <variable-name> <value>") \
23572 _(script, "usage: script <file-name>") \
23573 _(statseg, "usage: statseg"); \
23574 _(unset, "usage: unset <variable-name>")
23577 static void vl_api_##n##_t_handler_uni \
23578 (vl_api_##n##_t * mp) \
23580 vat_main_t * vam = &vat_main; \
23581 if (vam->json_output) { \
23582 vl_api_##n##_t_handler_json(mp); \
23584 vl_api_##n##_t_handler(mp); \
23587 foreach_vpe_api_reply_msg;
23588 #if VPP_API_TEST_BUILTIN == 0
23589 foreach_standalone_reply_msg;
23594 vat_api_hookup (vat_main_t * vam)
23597 vl_msg_api_set_handlers(VL_API_##N, #n, \
23598 vl_api_##n##_t_handler_uni, \
23600 vl_api_##n##_t_endian, \
23601 vl_api_##n##_t_print, \
23602 sizeof(vl_api_##n##_t), 1);
23603 foreach_vpe_api_reply_msg;
23604 #if VPP_API_TEST_BUILTIN == 0
23605 foreach_standalone_reply_msg;
23609 #if (VPP_API_TEST_BUILTIN==0)
23610 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23612 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23614 vam->function_by_name = hash_create_string (0, sizeof (uword));
23616 vam->help_by_name = hash_create_string (0, sizeof (uword));
23619 /* API messages we can send */
23620 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23621 foreach_vpe_api_msg;
23625 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23626 foreach_vpe_api_msg;
23629 /* CLI functions */
23630 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23631 foreach_cli_function;
23635 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23636 foreach_cli_function;
23640 #if VPP_API_TEST_BUILTIN
23641 static clib_error_t *
23642 vat_api_hookup_shim (vlib_main_t * vm)
23644 vat_api_hookup (&vat_main);
23648 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
23652 * fd.io coding-style-patch-verification: ON
23655 * eval: (c-set-style "gnu")