2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vpp/api/types.h>
22 #include <vppinfra/socket.h>
23 #include <vlibapi/api.h>
24 #include <vlibmemory/api.h>
25 #include <vnet/ip/ip.h>
26 #include <vnet/ip/ip_neighbor.h>
27 #include <vnet/l2/l2_input.h>
28 #include <vnet/l2tp/l2tp.h>
29 #include <vnet/vxlan/vxlan.h>
30 #include <vnet/geneve/geneve.h>
31 #include <vnet/gre/gre.h>
32 #include <vnet/vxlan-gpe/vxlan_gpe.h>
33 #include <vnet/lisp-gpe/lisp_gpe.h>
35 #include <vpp/api/vpe_msg_enum.h>
36 #include <vnet/l2/l2_classify.h>
37 #include <vnet/l2/l2_vtr.h>
38 #include <vnet/classify/in_out_acl.h>
39 #include <vnet/classify/policer_classify.h>
40 #include <vnet/classify/flow_classify.h>
41 #include <vnet/mpls/mpls.h>
42 #include <vnet/ipsec/ipsec.h>
43 #include <vnet/ipsec/ikev2.h>
45 #include <vnet/cop/cop.h>
46 #include <vnet/ip/ip6_hop_by_hop.h>
47 #include <vnet/ip/ip_source_and_port_range_check.h>
48 #include <vnet/policer/xlate.h>
49 #include <vnet/span/span.h>
50 #include <vnet/policer/policer.h>
51 #include <vnet/policer/police.h>
52 #include <vnet/mfib/mfib_types.h>
53 #include <vnet/dhcp/dhcp_proxy.h>
54 #include <vnet/bonding/node.h>
55 #include <vnet/qos/qos_types.h>
56 #include "vat/json_format.h"
57 #include <vnet/ip/ip_types_api.h>
58 #include <vnet/ethernet/ethernet_types_api.h>
63 #define vl_typedefs /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
67 /* declare message handlers for each api */
69 #define vl_endianfun /* define message structures */
70 #include <vpp/api/vpe_all_api_h.h>
73 /* instantiate all the print functions we know about */
74 #define vl_print(handle, ...)
76 #include <vpp/api/vpe_all_api_h.h>
79 #define __plugin_msg_base 0
80 #include <vlibapi/vat_helper_macros.h>
82 #if VPP_API_TEST_BUILTIN == 0
92 vat_socket_connect (vat_main_t * vam)
95 vam->socket_client_main = &socket_client_main;
96 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
98 0 /* default socket rx, tx buffer */ )))
100 /* vpp expects the client index in network order */
101 vam->my_client_index = htonl (socket_client_main.client_index);
104 #else /* vpp built-in case, we don't do sockets... */
106 vat_socket_connect (vat_main_t * vam)
112 vl_socket_client_read (int wait)
118 vl_socket_client_write ()
124 vl_socket_client_msg_alloc (int nbytes)
132 vat_time_now (vat_main_t * vam)
134 #if VPP_API_TEST_BUILTIN
135 return vlib_time_now (vam->vlib_main);
137 return clib_time_now (&vam->clib_time);
142 errmsg (char *fmt, ...)
144 vat_main_t *vam = &vat_main;
149 s = va_format (0, fmt, &va);
154 #if VPP_API_TEST_BUILTIN
155 vlib_cli_output (vam->vlib_main, (char *) s);
158 if (vam->ifp != stdin)
159 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
160 vam->input_line_number);
161 fformat (vam->ofp, (char *) s);
169 #if VPP_API_TEST_BUILTIN == 0
171 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
173 vat_main_t *vam = va_arg (*args, vat_main_t *);
174 u32 *result = va_arg (*args, u32 *);
178 if (!unformat (input, "%s", &if_name))
181 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
189 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
194 /* Parse an IP4 address %d.%d.%d.%d. */
196 unformat_ip4_address (unformat_input_t * input, va_list * args)
198 u8 *result = va_arg (*args, u8 *);
201 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
204 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
216 unformat_ethernet_address (unformat_input_t * input, va_list * args)
218 u8 *result = va_arg (*args, u8 *);
221 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
222 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
226 for (i = 0; i < 6; i++)
227 if (a[i] >= (1 << 8))
230 for (i = 0; i < 6; i++)
236 /* Returns ethernet type as an int in host byte order. */
238 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
241 u16 *result = va_arg (*args, u16 *);
245 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
247 if (type >= (1 << 16))
255 /* Parse an IP6 address. */
257 unformat_ip6_address (unformat_input_t * input, va_list * args)
259 ip6_address_t *result = va_arg (*args, ip6_address_t *);
261 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
262 uword c, n_colon, double_colon_index;
264 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
265 double_colon_index = ARRAY_LEN (hex_quads);
266 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
269 if (c >= '0' && c <= '9')
271 else if (c >= 'a' && c <= 'f')
272 hex_digit = c + 10 - 'a';
273 else if (c >= 'A' && c <= 'F')
274 hex_digit = c + 10 - 'A';
275 else if (c == ':' && n_colon < 2)
279 unformat_put_input (input);
283 /* Too many hex quads. */
284 if (n_hex_quads >= ARRAY_LEN (hex_quads))
289 hex_quad = (hex_quad << 4) | hex_digit;
291 /* Hex quad must fit in 16 bits. */
292 if (n_hex_digits >= 4)
299 /* Save position of :: */
302 /* More than one :: ? */
303 if (double_colon_index < ARRAY_LEN (hex_quads))
305 double_colon_index = n_hex_quads;
308 if (n_colon > 0 && n_hex_digits > 0)
310 hex_quads[n_hex_quads++] = hex_quad;
316 if (n_hex_digits > 0)
317 hex_quads[n_hex_quads++] = hex_quad;
322 /* Expand :: to appropriate number of zero hex quads. */
323 if (double_colon_index < ARRAY_LEN (hex_quads))
325 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
327 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
328 hex_quads[n_zero + i] = hex_quads[i];
330 for (i = 0; i < n_zero; i++)
331 hex_quads[double_colon_index + i] = 0;
333 n_hex_quads = ARRAY_LEN (hex_quads);
336 /* Too few hex quads given. */
337 if (n_hex_quads < ARRAY_LEN (hex_quads))
340 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
341 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
348 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
350 u32 *r = va_arg (*args, u32 *);
353 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
354 foreach_ipsec_policy_action
362 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
364 u32 *r = va_arg (*args, u32 *);
367 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
368 foreach_ipsec_crypto_alg
376 format_ipsec_crypto_alg (u8 * s, va_list * args)
378 u32 i = va_arg (*args, u32);
383 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
384 foreach_ipsec_crypto_alg
387 return format (s, "unknown");
389 return format (s, "%s", t);
393 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
395 u32 *r = va_arg (*args, u32 *);
398 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
399 foreach_ipsec_integ_alg
407 format_ipsec_integ_alg (u8 * s, va_list * args)
409 u32 i = va_arg (*args, u32);
414 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
415 foreach_ipsec_integ_alg
418 return format (s, "unknown");
420 return format (s, "%s", t);
424 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
426 u32 *r = va_arg (*args, u32 *);
429 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
430 foreach_ikev2_auth_method
438 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
440 u32 *r = va_arg (*args, u32 *);
443 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
444 foreach_ikev2_id_type
450 #else /* VPP_API_TEST_BUILTIN == 1 */
452 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
454 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
455 vnet_main_t *vnm = vnet_get_main ();
456 u32 *result = va_arg (*args, u32 *);
458 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
462 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
464 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
465 vnet_main_t *vnm = vnet_get_main ();
466 u32 *result = va_arg (*args, u32 *);
468 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
471 #endif /* VPP_API_TEST_BUILTIN */
474 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
476 u8 *r = va_arg (*args, u8 *);
478 if (unformat (input, "kbps"))
479 *r = SSE2_QOS_RATE_KBPS;
480 else if (unformat (input, "pps"))
481 *r = SSE2_QOS_RATE_PPS;
488 unformat_policer_round_type (unformat_input_t * input, va_list * args)
490 u8 *r = va_arg (*args, u8 *);
492 if (unformat (input, "closest"))
493 *r = SSE2_QOS_ROUND_TO_CLOSEST;
494 else if (unformat (input, "up"))
495 *r = SSE2_QOS_ROUND_TO_UP;
496 else if (unformat (input, "down"))
497 *r = SSE2_QOS_ROUND_TO_DOWN;
504 unformat_policer_type (unformat_input_t * input, va_list * args)
506 u8 *r = va_arg (*args, u8 *);
508 if (unformat (input, "1r2c"))
509 *r = SSE2_QOS_POLICER_TYPE_1R2C;
510 else if (unformat (input, "1r3c"))
511 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
512 else if (unformat (input, "2r3c-2698"))
513 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
514 else if (unformat (input, "2r3c-4115"))
515 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
516 else if (unformat (input, "2r3c-mef5cf1"))
517 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
524 unformat_dscp (unformat_input_t * input, va_list * va)
526 u8 *r = va_arg (*va, u8 *);
529 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
538 unformat_policer_action_type (unformat_input_t * input, va_list * va)
540 sse2_qos_pol_action_params_st *a
541 = va_arg (*va, sse2_qos_pol_action_params_st *);
543 if (unformat (input, "drop"))
544 a->action_type = SSE2_QOS_ACTION_DROP;
545 else if (unformat (input, "transmit"))
546 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
547 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
548 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
555 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
557 u32 *r = va_arg (*va, u32 *);
560 if (unformat (input, "ip4"))
561 tid = POLICER_CLASSIFY_TABLE_IP4;
562 else if (unformat (input, "ip6"))
563 tid = POLICER_CLASSIFY_TABLE_IP6;
564 else if (unformat (input, "l2"))
565 tid = POLICER_CLASSIFY_TABLE_L2;
574 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
576 u32 *r = va_arg (*va, u32 *);
579 if (unformat (input, "ip4"))
580 tid = FLOW_CLASSIFY_TABLE_IP4;
581 else if (unformat (input, "ip6"))
582 tid = FLOW_CLASSIFY_TABLE_IP6;
590 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
591 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
592 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
593 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
595 #if (VPP_API_TEST_BUILTIN==0)
597 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
599 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
600 mfib_itf_attribute_t attr;
603 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
605 if (unformat (input, mfib_itf_flag_long_names[attr]))
606 *iflags |= (1 << attr);
608 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
610 if (unformat (input, mfib_itf_flag_names[attr]))
611 *iflags |= (1 << attr);
614 return (old == *iflags ? 0 : 1);
618 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
620 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
621 mfib_entry_attribute_t attr;
624 FOR_EACH_MFIB_ATTRIBUTE (attr)
626 if (unformat (input, mfib_flag_long_names[attr]))
627 *eflags |= (1 << attr);
629 FOR_EACH_MFIB_ATTRIBUTE (attr)
631 if (unformat (input, mfib_flag_names[attr]))
632 *eflags |= (1 << attr);
635 return (old == *eflags ? 0 : 1);
639 format_ip4_address (u8 * s, va_list * args)
641 u8 *a = va_arg (*args, u8 *);
642 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
646 format_ip6_address (u8 * s, va_list * args)
648 ip6_address_t *a = va_arg (*args, ip6_address_t *);
649 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
651 i_max_n_zero = ARRAY_LEN (a->as_u16);
653 i_first_zero = i_max_n_zero;
655 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
657 u32 is_zero = a->as_u16[i] == 0;
658 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
664 if ((!is_zero && n_zeros > max_n_zeros)
665 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
667 i_max_n_zero = i_first_zero;
668 max_n_zeros = n_zeros;
669 i_first_zero = ARRAY_LEN (a->as_u16);
674 last_double_colon = 0;
675 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
677 if (i == i_max_n_zero && max_n_zeros > 1)
679 s = format (s, "::");
680 i += max_n_zeros - 1;
681 last_double_colon = 1;
685 s = format (s, "%s%x",
686 (last_double_colon || i == 0) ? "" : ":",
687 clib_net_to_host_u16 (a->as_u16[i]));
688 last_double_colon = 0;
695 /* Format an IP46 address. */
697 format_ip46_address (u8 * s, va_list * args)
699 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
700 ip46_type_t type = va_arg (*args, ip46_type_t);
706 is_ip4 = ip46_address_is_ip4 (ip46);
717 format (s, "%U", format_ip4_address, &ip46->ip4) :
718 format (s, "%U", format_ip6_address, &ip46->ip6);
722 format_ethernet_address (u8 * s, va_list * args)
724 u8 *a = va_arg (*args, u8 *);
726 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
727 a[0], a[1], a[2], a[3], a[4], a[5]);
732 increment_v4_address (ip4_address_t * a)
736 v = ntohl (a->as_u32) + 1;
737 a->as_u32 = ntohl (v);
741 increment_v6_address (ip6_address_t * a)
745 v0 = clib_net_to_host_u64 (a->as_u64[0]);
746 v1 = clib_net_to_host_u64 (a->as_u64[1]);
751 a->as_u64[0] = clib_net_to_host_u64 (v0);
752 a->as_u64[1] = clib_net_to_host_u64 (v1);
756 increment_mac_address (u8 * mac)
758 u64 tmp = *((u64 *) mac);
759 tmp = clib_net_to_host_u64 (tmp);
760 tmp += 1 << 16; /* skip unused (least significant) octets */
761 tmp = clib_host_to_net_u64 (tmp);
763 clib_memcpy (mac, &tmp, 6);
766 static void vl_api_create_loopback_reply_t_handler
767 (vl_api_create_loopback_reply_t * mp)
769 vat_main_t *vam = &vat_main;
770 i32 retval = ntohl (mp->retval);
772 vam->retval = retval;
773 vam->regenerate_interface_table = 1;
774 vam->sw_if_index = ntohl (mp->sw_if_index);
775 vam->result_ready = 1;
778 static void vl_api_create_loopback_reply_t_handler_json
779 (vl_api_create_loopback_reply_t * mp)
781 vat_main_t *vam = &vat_main;
782 vat_json_node_t node;
784 vat_json_init_object (&node);
785 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
786 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
788 vat_json_print (vam->ofp, &node);
789 vat_json_free (&node);
790 vam->retval = ntohl (mp->retval);
791 vam->result_ready = 1;
794 static void vl_api_create_loopback_instance_reply_t_handler
795 (vl_api_create_loopback_instance_reply_t * mp)
797 vat_main_t *vam = &vat_main;
798 i32 retval = ntohl (mp->retval);
800 vam->retval = retval;
801 vam->regenerate_interface_table = 1;
802 vam->sw_if_index = ntohl (mp->sw_if_index);
803 vam->result_ready = 1;
806 static void vl_api_create_loopback_instance_reply_t_handler_json
807 (vl_api_create_loopback_instance_reply_t * mp)
809 vat_main_t *vam = &vat_main;
810 vat_json_node_t node;
812 vat_json_init_object (&node);
813 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
814 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
816 vat_json_print (vam->ofp, &node);
817 vat_json_free (&node);
818 vam->retval = ntohl (mp->retval);
819 vam->result_ready = 1;
822 static void vl_api_af_packet_create_reply_t_handler
823 (vl_api_af_packet_create_reply_t * mp)
825 vat_main_t *vam = &vat_main;
826 i32 retval = ntohl (mp->retval);
828 vam->retval = retval;
829 vam->regenerate_interface_table = 1;
830 vam->sw_if_index = ntohl (mp->sw_if_index);
831 vam->result_ready = 1;
834 static void vl_api_af_packet_create_reply_t_handler_json
835 (vl_api_af_packet_create_reply_t * mp)
837 vat_main_t *vam = &vat_main;
838 vat_json_node_t node;
840 vat_json_init_object (&node);
841 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
842 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
844 vat_json_print (vam->ofp, &node);
845 vat_json_free (&node);
847 vam->retval = ntohl (mp->retval);
848 vam->result_ready = 1;
851 static void vl_api_create_vlan_subif_reply_t_handler
852 (vl_api_create_vlan_subif_reply_t * mp)
854 vat_main_t *vam = &vat_main;
855 i32 retval = ntohl (mp->retval);
857 vam->retval = retval;
858 vam->regenerate_interface_table = 1;
859 vam->sw_if_index = ntohl (mp->sw_if_index);
860 vam->result_ready = 1;
863 static void vl_api_create_vlan_subif_reply_t_handler_json
864 (vl_api_create_vlan_subif_reply_t * mp)
866 vat_main_t *vam = &vat_main;
867 vat_json_node_t node;
869 vat_json_init_object (&node);
870 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
871 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
873 vat_json_print (vam->ofp, &node);
874 vat_json_free (&node);
876 vam->retval = ntohl (mp->retval);
877 vam->result_ready = 1;
880 static void vl_api_create_subif_reply_t_handler
881 (vl_api_create_subif_reply_t * mp)
883 vat_main_t *vam = &vat_main;
884 i32 retval = ntohl (mp->retval);
886 vam->retval = retval;
887 vam->regenerate_interface_table = 1;
888 vam->sw_if_index = ntohl (mp->sw_if_index);
889 vam->result_ready = 1;
892 static void vl_api_create_subif_reply_t_handler_json
893 (vl_api_create_subif_reply_t * mp)
895 vat_main_t *vam = &vat_main;
896 vat_json_node_t node;
898 vat_json_init_object (&node);
899 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
900 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
902 vat_json_print (vam->ofp, &node);
903 vat_json_free (&node);
905 vam->retval = ntohl (mp->retval);
906 vam->result_ready = 1;
909 static void vl_api_interface_name_renumber_reply_t_handler
910 (vl_api_interface_name_renumber_reply_t * mp)
912 vat_main_t *vam = &vat_main;
913 i32 retval = ntohl (mp->retval);
915 vam->retval = retval;
916 vam->regenerate_interface_table = 1;
917 vam->result_ready = 1;
920 static void vl_api_interface_name_renumber_reply_t_handler_json
921 (vl_api_interface_name_renumber_reply_t * mp)
923 vat_main_t *vam = &vat_main;
924 vat_json_node_t node;
926 vat_json_init_object (&node);
927 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
929 vat_json_print (vam->ofp, &node);
930 vat_json_free (&node);
932 vam->retval = ntohl (mp->retval);
933 vam->result_ready = 1;
937 * Special-case: build the interface table, maintain
938 * the next loopback sw_if_index vbl.
940 static void vl_api_sw_interface_details_t_handler
941 (vl_api_sw_interface_details_t * mp)
943 vat_main_t *vam = &vat_main;
944 u8 *s = format (0, "%s%c", mp->interface_name, 0);
946 hash_set_mem (vam->sw_if_index_by_interface_name, s,
947 ntohl (mp->sw_if_index));
949 /* In sub interface case, fill the sub interface table entry */
950 if (mp->sw_if_index != mp->sup_sw_if_index)
952 sw_interface_subif_t *sub = NULL;
954 vec_add2 (vam->sw_if_subif_table, sub, 1);
956 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
957 strncpy ((char *) sub->interface_name, (char *) s,
958 vec_len (sub->interface_name));
959 sub->sw_if_index = ntohl (mp->sw_if_index);
960 sub->sub_id = ntohl (mp->sub_id);
962 sub->sub_dot1ad = mp->sub_dot1ad;
963 sub->sub_number_of_tags = mp->sub_number_of_tags;
964 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
965 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
966 sub->sub_exact_match = mp->sub_exact_match;
967 sub->sub_default = mp->sub_default;
968 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
969 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
971 /* vlan tag rewrite */
972 sub->vtr_op = ntohl (mp->vtr_op);
973 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
974 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
975 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
979 static void vl_api_sw_interface_details_t_handler_json
980 (vl_api_sw_interface_details_t * mp)
982 vat_main_t *vam = &vat_main;
983 vat_json_node_t *node = NULL;
985 if (VAT_JSON_ARRAY != vam->json_tree.type)
987 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
988 vat_json_init_array (&vam->json_tree);
990 node = vat_json_array_add (&vam->json_tree);
992 vat_json_init_object (node);
993 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
994 vat_json_object_add_uint (node, "sup_sw_if_index",
995 ntohl (mp->sup_sw_if_index));
996 vat_json_object_add_uint (node, "l2_address_length",
997 ntohl (mp->l2_address_length));
998 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
999 sizeof (mp->l2_address));
1000 vat_json_object_add_string_copy (node, "interface_name",
1001 mp->interface_name);
1002 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
1003 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
1004 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1005 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1006 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1007 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1008 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
1009 vat_json_object_add_uint (node, "sub_number_of_tags",
1010 mp->sub_number_of_tags);
1011 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1012 ntohs (mp->sub_outer_vlan_id));
1013 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1014 ntohs (mp->sub_inner_vlan_id));
1015 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
1016 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
1017 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
1018 mp->sub_outer_vlan_id_any);
1019 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1020 mp->sub_inner_vlan_id_any);
1021 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1022 vat_json_object_add_uint (node, "vtr_push_dot1q",
1023 ntohl (mp->vtr_push_dot1q));
1024 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1025 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1028 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1030 format_ethernet_address,
1032 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1034 format_ethernet_address,
1036 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1037 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1041 #if VPP_API_TEST_BUILTIN == 0
1042 static void vl_api_sw_interface_event_t_handler
1043 (vl_api_sw_interface_event_t * mp)
1045 vat_main_t *vam = &vat_main;
1046 if (vam->interface_event_display)
1047 errmsg ("interface flags: sw_if_index %d %s %s",
1048 ntohl (mp->sw_if_index),
1049 mp->admin_up_down ? "admin-up" : "admin-down",
1050 mp->link_up_down ? "link-up" : "link-down");
1054 static void vl_api_sw_interface_event_t_handler_json
1055 (vl_api_sw_interface_event_t * mp)
1057 /* JSON output not supported */
1061 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1063 vat_main_t *vam = &vat_main;
1064 i32 retval = ntohl (mp->retval);
1066 vam->retval = retval;
1067 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1068 vam->result_ready = 1;
1072 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1074 vat_main_t *vam = &vat_main;
1075 vat_json_node_t node;
1076 api_main_t *am = &api_main;
1080 vat_json_init_object (&node);
1081 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1082 vat_json_object_add_uint (&node, "reply_in_shmem",
1083 ntohl (mp->reply_in_shmem));
1084 /* Toss the shared-memory original... */
1085 pthread_mutex_lock (&am->vlib_rp->mutex);
1086 oldheap = svm_push_data_heap (am->vlib_rp);
1088 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1091 svm_pop_heap (oldheap);
1092 pthread_mutex_unlock (&am->vlib_rp->mutex);
1094 vat_json_print (vam->ofp, &node);
1095 vat_json_free (&node);
1097 vam->retval = ntohl (mp->retval);
1098 vam->result_ready = 1;
1102 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1104 vat_main_t *vam = &vat_main;
1105 i32 retval = ntohl (mp->retval);
1106 u32 length = vl_api_string_len (&mp->reply);
1108 vec_reset_length (vam->cmd_reply);
1110 vam->retval = retval;
1113 vec_validate (vam->cmd_reply, length);
1114 clib_memcpy ((char *) (vam->cmd_reply),
1115 vl_api_from_api_string (&mp->reply), length);
1116 vam->cmd_reply[length] = 0;
1118 vam->result_ready = 1;
1122 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1124 vat_main_t *vam = &vat_main;
1125 vat_json_node_t node;
1127 vec_reset_length (vam->cmd_reply);
1129 vat_json_init_object (&node);
1130 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1131 vat_json_object_add_string_copy (&node, "reply",
1132 vl_api_from_api_string (&mp->reply));
1134 vat_json_print (vam->ofp, &node);
1135 vat_json_free (&node);
1137 vam->retval = ntohl (mp->retval);
1138 vam->result_ready = 1;
1141 static void vl_api_classify_add_del_table_reply_t_handler
1142 (vl_api_classify_add_del_table_reply_t * mp)
1144 vat_main_t *vam = &vat_main;
1145 i32 retval = ntohl (mp->retval);
1146 if (vam->async_mode)
1148 vam->async_errors += (retval < 0);
1152 vam->retval = retval;
1154 ((mp->new_table_index != 0xFFFFFFFF) ||
1155 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1156 (mp->match_n_vectors != 0xFFFFFFFF)))
1158 * Note: this is just barely thread-safe, depends on
1159 * the main thread spinning waiting for an answer...
1161 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1162 ntohl (mp->new_table_index),
1163 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1164 vam->result_ready = 1;
1168 static void vl_api_classify_add_del_table_reply_t_handler_json
1169 (vl_api_classify_add_del_table_reply_t * mp)
1171 vat_main_t *vam = &vat_main;
1172 vat_json_node_t node;
1174 vat_json_init_object (&node);
1175 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1176 vat_json_object_add_uint (&node, "new_table_index",
1177 ntohl (mp->new_table_index));
1178 vat_json_object_add_uint (&node, "skip_n_vectors",
1179 ntohl (mp->skip_n_vectors));
1180 vat_json_object_add_uint (&node, "match_n_vectors",
1181 ntohl (mp->match_n_vectors));
1183 vat_json_print (vam->ofp, &node);
1184 vat_json_free (&node);
1186 vam->retval = ntohl (mp->retval);
1187 vam->result_ready = 1;
1190 static void vl_api_get_node_index_reply_t_handler
1191 (vl_api_get_node_index_reply_t * mp)
1193 vat_main_t *vam = &vat_main;
1194 i32 retval = ntohl (mp->retval);
1195 if (vam->async_mode)
1197 vam->async_errors += (retval < 0);
1201 vam->retval = retval;
1203 errmsg ("node index %d", ntohl (mp->node_index));
1204 vam->result_ready = 1;
1208 static void vl_api_get_node_index_reply_t_handler_json
1209 (vl_api_get_node_index_reply_t * mp)
1211 vat_main_t *vam = &vat_main;
1212 vat_json_node_t node;
1214 vat_json_init_object (&node);
1215 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1216 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1218 vat_json_print (vam->ofp, &node);
1219 vat_json_free (&node);
1221 vam->retval = ntohl (mp->retval);
1222 vam->result_ready = 1;
1225 static void vl_api_get_next_index_reply_t_handler
1226 (vl_api_get_next_index_reply_t * mp)
1228 vat_main_t *vam = &vat_main;
1229 i32 retval = ntohl (mp->retval);
1230 if (vam->async_mode)
1232 vam->async_errors += (retval < 0);
1236 vam->retval = retval;
1238 errmsg ("next node index %d", ntohl (mp->next_index));
1239 vam->result_ready = 1;
1243 static void vl_api_get_next_index_reply_t_handler_json
1244 (vl_api_get_next_index_reply_t * mp)
1246 vat_main_t *vam = &vat_main;
1247 vat_json_node_t node;
1249 vat_json_init_object (&node);
1250 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1251 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1253 vat_json_print (vam->ofp, &node);
1254 vat_json_free (&node);
1256 vam->retval = ntohl (mp->retval);
1257 vam->result_ready = 1;
1260 static void vl_api_add_node_next_reply_t_handler
1261 (vl_api_add_node_next_reply_t * mp)
1263 vat_main_t *vam = &vat_main;
1264 i32 retval = ntohl (mp->retval);
1265 if (vam->async_mode)
1267 vam->async_errors += (retval < 0);
1271 vam->retval = retval;
1273 errmsg ("next index %d", ntohl (mp->next_index));
1274 vam->result_ready = 1;
1278 static void vl_api_add_node_next_reply_t_handler_json
1279 (vl_api_add_node_next_reply_t * mp)
1281 vat_main_t *vam = &vat_main;
1282 vat_json_node_t node;
1284 vat_json_init_object (&node);
1285 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1286 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1288 vat_json_print (vam->ofp, &node);
1289 vat_json_free (&node);
1291 vam->retval = ntohl (mp->retval);
1292 vam->result_ready = 1;
1295 static void vl_api_show_version_reply_t_handler
1296 (vl_api_show_version_reply_t * mp)
1298 vat_main_t *vam = &vat_main;
1299 i32 retval = ntohl (mp->retval);
1304 char *p = (char *) &mp->program;
1306 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1307 errmsg (" program: %s\n", s);
1311 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1312 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1313 errmsg (" version: %s\n", s);
1317 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1318 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1319 errmsg (" build date: %s\n", s);
1323 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1324 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1325 errmsg ("build directory: %s\n", s);
1328 vam->retval = retval;
1329 vam->result_ready = 1;
1332 static void vl_api_show_version_reply_t_handler_json
1333 (vl_api_show_version_reply_t * mp)
1335 vat_main_t *vam = &vat_main;
1336 vat_json_node_t node;
1338 vat_json_init_object (&node);
1339 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1340 char *p = (char *) &mp->program;
1341 vat_json_object_add_string_copy (&node, "program",
1342 vl_api_from_api_string ((vl_api_string_t *)
1344 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1345 vat_json_object_add_string_copy (&node, "version",
1346 vl_api_from_api_string ((vl_api_string_t *)
1348 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1349 vat_json_object_add_string_copy (&node, "build_date",
1350 vl_api_from_api_string ((vl_api_string_t *)
1352 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1353 vat_json_object_add_string_copy (&node, "build_directory",
1354 vl_api_from_api_string ((vl_api_string_t *)
1357 vat_json_print (vam->ofp, &node);
1358 vat_json_free (&node);
1360 vam->retval = ntohl (mp->retval);
1361 vam->result_ready = 1;
1364 static void vl_api_show_threads_reply_t_handler
1365 (vl_api_show_threads_reply_t * mp)
1367 vat_main_t *vam = &vat_main;
1368 i32 retval = ntohl (mp->retval);
1372 count = ntohl (mp->count);
1374 for (i = 0; i < count; i++)
1376 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1377 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1378 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1379 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1380 ntohl (mp->thread_data[i].cpu_socket));
1382 vam->retval = retval;
1383 vam->result_ready = 1;
1386 static void vl_api_show_threads_reply_t_handler_json
1387 (vl_api_show_threads_reply_t * mp)
1389 vat_main_t *vam = &vat_main;
1390 vat_json_node_t node;
1391 vl_api_thread_data_t *td;
1392 i32 retval = ntohl (mp->retval);
1396 count = ntohl (mp->count);
1398 vat_json_init_object (&node);
1399 vat_json_object_add_int (&node, "retval", retval);
1400 vat_json_object_add_uint (&node, "count", count);
1402 for (i = 0; i < count; i++)
1404 td = &mp->thread_data[i];
1405 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1406 vat_json_object_add_string_copy (&node, "name", td->name);
1407 vat_json_object_add_string_copy (&node, "type", td->type);
1408 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1409 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1410 vat_json_object_add_int (&node, "core", ntohl (td->id));
1411 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1414 vat_json_print (vam->ofp, &node);
1415 vat_json_free (&node);
1417 vam->retval = retval;
1418 vam->result_ready = 1;
1422 api_show_threads (vat_main_t * vam)
1424 vl_api_show_threads_t *mp;
1428 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1429 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1431 M (SHOW_THREADS, mp);
1439 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1441 u32 sw_if_index = ntohl (mp->sw_if_index);
1442 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1443 mp->mac_ip ? "mac/ip binding" : "address resolution",
1444 ntohl (mp->pid), format_ip4_address, &mp->address,
1445 format_ethernet_address, mp->new_mac, sw_if_index);
1449 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1451 /* JSON output not supported */
1455 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1457 u32 sw_if_index = ntohl (mp->sw_if_index);
1458 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1459 mp->mac_ip ? "mac/ip binding" : "address resolution",
1460 ntohl (mp->pid), format_ip6_address, mp->address,
1461 format_ethernet_address, mp->new_mac, sw_if_index);
1465 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1467 /* JSON output not supported */
1471 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1473 u32 n_macs = ntohl (mp->n_macs);
1474 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1475 ntohl (mp->pid), mp->client_index, n_macs);
1477 for (i = 0; i < n_macs; i++)
1479 vl_api_mac_entry_t *mac = &mp->mac[i];
1480 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1481 i + 1, ntohl (mac->sw_if_index),
1482 format_ethernet_address, mac->mac_addr, mac->action);
1489 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1491 /* JSON output not supported */
1494 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1495 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1498 * Special-case: build the bridge domain table, maintain
1499 * the next bd id vbl.
1501 static void vl_api_bridge_domain_details_t_handler
1502 (vl_api_bridge_domain_details_t * mp)
1504 vat_main_t *vam = &vat_main;
1505 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1508 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1509 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1511 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1512 ntohl (mp->bd_id), mp->learn, mp->forward,
1513 mp->flood, ntohl (mp->bvi_sw_if_index),
1514 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1518 vl_api_bridge_domain_sw_if_t *sw_ifs;
1519 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1522 sw_ifs = mp->sw_if_details;
1523 for (i = 0; i < n_sw_ifs; i++)
1529 sw_if_index = ntohl (sw_ifs->sw_if_index);
1532 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1534 if ((u32) p->value[0] == sw_if_index)
1536 sw_if_name = (u8 *)(p->key);
1541 print (vam->ofp, "%7d %3d %s", sw_if_index,
1542 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1543 "sw_if_index not found!");
1550 static void vl_api_bridge_domain_details_t_handler_json
1551 (vl_api_bridge_domain_details_t * mp)
1553 vat_main_t *vam = &vat_main;
1554 vat_json_node_t *node, *array = NULL;
1555 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1557 if (VAT_JSON_ARRAY != vam->json_tree.type)
1559 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1560 vat_json_init_array (&vam->json_tree);
1562 node = vat_json_array_add (&vam->json_tree);
1564 vat_json_init_object (node);
1565 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1566 vat_json_object_add_uint (node, "flood", mp->flood);
1567 vat_json_object_add_uint (node, "forward", mp->forward);
1568 vat_json_object_add_uint (node, "learn", mp->learn);
1569 vat_json_object_add_uint (node, "bvi_sw_if_index",
1570 ntohl (mp->bvi_sw_if_index));
1571 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1572 array = vat_json_object_add (node, "sw_if");
1573 vat_json_init_array (array);
1579 vl_api_bridge_domain_sw_if_t *sw_ifs;
1582 sw_ifs = mp->sw_if_details;
1583 for (i = 0; i < n_sw_ifs; i++)
1585 node = vat_json_array_add (array);
1586 vat_json_init_object (node);
1587 vat_json_object_add_uint (node, "sw_if_index",
1588 ntohl (sw_ifs->sw_if_index));
1589 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1595 static void vl_api_control_ping_reply_t_handler
1596 (vl_api_control_ping_reply_t * mp)
1598 vat_main_t *vam = &vat_main;
1599 i32 retval = ntohl (mp->retval);
1600 if (vam->async_mode)
1602 vam->async_errors += (retval < 0);
1606 vam->retval = retval;
1607 vam->result_ready = 1;
1609 if (vam->socket_client_main)
1610 vam->socket_client_main->control_pings_outstanding--;
1613 static void vl_api_control_ping_reply_t_handler_json
1614 (vl_api_control_ping_reply_t * mp)
1616 vat_main_t *vam = &vat_main;
1617 i32 retval = ntohl (mp->retval);
1619 if (VAT_JSON_NONE != vam->json_tree.type)
1621 vat_json_print (vam->ofp, &vam->json_tree);
1622 vat_json_free (&vam->json_tree);
1623 vam->json_tree.type = VAT_JSON_NONE;
1628 vat_json_init_array (&vam->json_tree);
1629 vat_json_print (vam->ofp, &vam->json_tree);
1630 vam->json_tree.type = VAT_JSON_NONE;
1633 vam->retval = retval;
1634 vam->result_ready = 1;
1638 vl_api_bridge_domain_set_mac_age_reply_t_handler
1639 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1641 vat_main_t *vam = &vat_main;
1642 i32 retval = ntohl (mp->retval);
1643 if (vam->async_mode)
1645 vam->async_errors += (retval < 0);
1649 vam->retval = retval;
1650 vam->result_ready = 1;
1654 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1655 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1657 vat_main_t *vam = &vat_main;
1658 vat_json_node_t node;
1660 vat_json_init_object (&node);
1661 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1663 vat_json_print (vam->ofp, &node);
1664 vat_json_free (&node);
1666 vam->retval = ntohl (mp->retval);
1667 vam->result_ready = 1;
1671 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1673 vat_main_t *vam = &vat_main;
1674 i32 retval = ntohl (mp->retval);
1675 if (vam->async_mode)
1677 vam->async_errors += (retval < 0);
1681 vam->retval = retval;
1682 vam->result_ready = 1;
1686 static void vl_api_l2_flags_reply_t_handler_json
1687 (vl_api_l2_flags_reply_t * mp)
1689 vat_main_t *vam = &vat_main;
1690 vat_json_node_t node;
1692 vat_json_init_object (&node);
1693 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1694 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1695 ntohl (mp->resulting_feature_bitmap));
1697 vat_json_print (vam->ofp, &node);
1698 vat_json_free (&node);
1700 vam->retval = ntohl (mp->retval);
1701 vam->result_ready = 1;
1704 static void vl_api_bridge_flags_reply_t_handler
1705 (vl_api_bridge_flags_reply_t * mp)
1707 vat_main_t *vam = &vat_main;
1708 i32 retval = ntohl (mp->retval);
1709 if (vam->async_mode)
1711 vam->async_errors += (retval < 0);
1715 vam->retval = retval;
1716 vam->result_ready = 1;
1720 static void vl_api_bridge_flags_reply_t_handler_json
1721 (vl_api_bridge_flags_reply_t * mp)
1723 vat_main_t *vam = &vat_main;
1724 vat_json_node_t node;
1726 vat_json_init_object (&node);
1727 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1728 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1729 ntohl (mp->resulting_feature_bitmap));
1731 vat_json_print (vam->ofp, &node);
1732 vat_json_free (&node);
1734 vam->retval = ntohl (mp->retval);
1735 vam->result_ready = 1;
1738 static void vl_api_tap_connect_reply_t_handler
1739 (vl_api_tap_connect_reply_t * mp)
1741 vat_main_t *vam = &vat_main;
1742 i32 retval = ntohl (mp->retval);
1743 if (vam->async_mode)
1745 vam->async_errors += (retval < 0);
1749 vam->retval = retval;
1750 vam->sw_if_index = ntohl (mp->sw_if_index);
1751 vam->result_ready = 1;
1756 static void vl_api_tap_connect_reply_t_handler_json
1757 (vl_api_tap_connect_reply_t * mp)
1759 vat_main_t *vam = &vat_main;
1760 vat_json_node_t node;
1762 vat_json_init_object (&node);
1763 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1764 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1766 vat_json_print (vam->ofp, &node);
1767 vat_json_free (&node);
1769 vam->retval = ntohl (mp->retval);
1770 vam->result_ready = 1;
1775 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1777 vat_main_t *vam = &vat_main;
1778 i32 retval = ntohl (mp->retval);
1779 if (vam->async_mode)
1781 vam->async_errors += (retval < 0);
1785 vam->retval = retval;
1786 vam->sw_if_index = ntohl (mp->sw_if_index);
1787 vam->result_ready = 1;
1791 static void vl_api_tap_modify_reply_t_handler_json
1792 (vl_api_tap_modify_reply_t * mp)
1794 vat_main_t *vam = &vat_main;
1795 vat_json_node_t node;
1797 vat_json_init_object (&node);
1798 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1799 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1801 vat_json_print (vam->ofp, &node);
1802 vat_json_free (&node);
1804 vam->retval = ntohl (mp->retval);
1805 vam->result_ready = 1;
1809 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1811 vat_main_t *vam = &vat_main;
1812 i32 retval = ntohl (mp->retval);
1813 if (vam->async_mode)
1815 vam->async_errors += (retval < 0);
1819 vam->retval = retval;
1820 vam->result_ready = 1;
1824 static void vl_api_tap_delete_reply_t_handler_json
1825 (vl_api_tap_delete_reply_t * mp)
1827 vat_main_t *vam = &vat_main;
1828 vat_json_node_t node;
1830 vat_json_init_object (&node);
1831 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1833 vat_json_print (vam->ofp, &node);
1834 vat_json_free (&node);
1836 vam->retval = ntohl (mp->retval);
1837 vam->result_ready = 1;
1841 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1843 vat_main_t *vam = &vat_main;
1844 i32 retval = ntohl (mp->retval);
1845 if (vam->async_mode)
1847 vam->async_errors += (retval < 0);
1851 vam->retval = retval;
1852 vam->sw_if_index = ntohl (mp->sw_if_index);
1853 vam->result_ready = 1;
1858 static void vl_api_tap_create_v2_reply_t_handler_json
1859 (vl_api_tap_create_v2_reply_t * mp)
1861 vat_main_t *vam = &vat_main;
1862 vat_json_node_t node;
1864 vat_json_init_object (&node);
1865 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1866 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1868 vat_json_print (vam->ofp, &node);
1869 vat_json_free (&node);
1871 vam->retval = ntohl (mp->retval);
1872 vam->result_ready = 1;
1877 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1879 vat_main_t *vam = &vat_main;
1880 i32 retval = ntohl (mp->retval);
1881 if (vam->async_mode)
1883 vam->async_errors += (retval < 0);
1887 vam->retval = retval;
1888 vam->result_ready = 1;
1892 static void vl_api_tap_delete_v2_reply_t_handler_json
1893 (vl_api_tap_delete_v2_reply_t * mp)
1895 vat_main_t *vam = &vat_main;
1896 vat_json_node_t node;
1898 vat_json_init_object (&node);
1899 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1901 vat_json_print (vam->ofp, &node);
1902 vat_json_free (&node);
1904 vam->retval = ntohl (mp->retval);
1905 vam->result_ready = 1;
1909 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1911 vat_main_t *vam = &vat_main;
1912 i32 retval = ntohl (mp->retval);
1914 if (vam->async_mode)
1916 vam->async_errors += (retval < 0);
1920 vam->retval = retval;
1921 vam->sw_if_index = ntohl (mp->sw_if_index);
1922 vam->result_ready = 1;
1926 static void vl_api_bond_create_reply_t_handler_json
1927 (vl_api_bond_create_reply_t * mp)
1929 vat_main_t *vam = &vat_main;
1930 vat_json_node_t node;
1932 vat_json_init_object (&node);
1933 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1934 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1936 vat_json_print (vam->ofp, &node);
1937 vat_json_free (&node);
1939 vam->retval = ntohl (mp->retval);
1940 vam->result_ready = 1;
1944 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_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_delete_reply_t_handler_json
1961 (vl_api_bond_delete_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_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1979 vat_main_t *vam = &vat_main;
1980 i32 retval = ntohl (mp->retval);
1982 if (vam->async_mode)
1984 vam->async_errors += (retval < 0);
1988 vam->retval = retval;
1989 vam->result_ready = 1;
1993 static void vl_api_bond_enslave_reply_t_handler_json
1994 (vl_api_bond_enslave_reply_t * mp)
1996 vat_main_t *vam = &vat_main;
1997 vat_json_node_t node;
1999 vat_json_init_object (&node);
2000 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2002 vat_json_print (vam->ofp, &node);
2003 vat_json_free (&node);
2005 vam->retval = ntohl (mp->retval);
2006 vam->result_ready = 1;
2010 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
2013 vat_main_t *vam = &vat_main;
2014 i32 retval = ntohl (mp->retval);
2016 if (vam->async_mode)
2018 vam->async_errors += (retval < 0);
2022 vam->retval = retval;
2023 vam->result_ready = 1;
2027 static void vl_api_bond_detach_slave_reply_t_handler_json
2028 (vl_api_bond_detach_slave_reply_t * mp)
2030 vat_main_t *vam = &vat_main;
2031 vat_json_node_t node;
2033 vat_json_init_object (&node);
2034 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2036 vat_json_print (vam->ofp, &node);
2037 vat_json_free (&node);
2039 vam->retval = ntohl (mp->retval);
2040 vam->result_ready = 1;
2043 static void vl_api_sw_interface_bond_details_t_handler
2044 (vl_api_sw_interface_bond_details_t * mp)
2046 vat_main_t *vam = &vat_main;
2049 "%-16s %-12d %-12U %-13U %-14u %-14u",
2050 mp->interface_name, ntohl (mp->sw_if_index),
2051 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2052 ntohl (mp->active_slaves), ntohl (mp->slaves));
2055 static void vl_api_sw_interface_bond_details_t_handler_json
2056 (vl_api_sw_interface_bond_details_t * mp)
2058 vat_main_t *vam = &vat_main;
2059 vat_json_node_t *node = NULL;
2061 if (VAT_JSON_ARRAY != vam->json_tree.type)
2063 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2064 vat_json_init_array (&vam->json_tree);
2066 node = vat_json_array_add (&vam->json_tree);
2068 vat_json_init_object (node);
2069 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2070 vat_json_object_add_string_copy (node, "interface_name",
2071 mp->interface_name);
2072 vat_json_object_add_uint (node, "mode", mp->mode);
2073 vat_json_object_add_uint (node, "load_balance", mp->lb);
2074 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2075 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2079 api_sw_interface_bond_dump (vat_main_t * vam)
2081 vl_api_sw_interface_bond_dump_t *mp;
2082 vl_api_control_ping_t *mp_ping;
2086 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2087 "interface name", "sw_if_index", "mode", "load balance",
2088 "active slaves", "slaves");
2090 /* Get list of bond interfaces */
2091 M (SW_INTERFACE_BOND_DUMP, mp);
2094 /* Use a control ping for synchronization */
2095 MPING (CONTROL_PING, mp_ping);
2102 static void vl_api_sw_interface_slave_details_t_handler
2103 (vl_api_sw_interface_slave_details_t * mp)
2105 vat_main_t *vam = &vat_main;
2108 "%-25s %-12d %-12d %d", mp->interface_name,
2109 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2112 static void vl_api_sw_interface_slave_details_t_handler_json
2113 (vl_api_sw_interface_slave_details_t * mp)
2115 vat_main_t *vam = &vat_main;
2116 vat_json_node_t *node = NULL;
2118 if (VAT_JSON_ARRAY != vam->json_tree.type)
2120 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2121 vat_json_init_array (&vam->json_tree);
2123 node = vat_json_array_add (&vam->json_tree);
2125 vat_json_init_object (node);
2126 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2127 vat_json_object_add_string_copy (node, "interface_name",
2128 mp->interface_name);
2129 vat_json_object_add_uint (node, "passive", mp->is_passive);
2130 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2134 api_sw_interface_slave_dump (vat_main_t * vam)
2136 unformat_input_t *i = vam->input;
2137 vl_api_sw_interface_slave_dump_t *mp;
2138 vl_api_control_ping_t *mp_ping;
2139 u32 sw_if_index = ~0;
2140 u8 sw_if_index_set = 0;
2143 /* Parse args required to build the message */
2144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2146 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2147 sw_if_index_set = 1;
2148 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2149 sw_if_index_set = 1;
2154 if (sw_if_index_set == 0)
2156 errmsg ("missing vpp interface name. ");
2161 "\n%-25s %-12s %-12s %s",
2162 "slave interface name", "sw_if_index", "passive", "long_timeout");
2164 /* Get list of bond interfaces */
2165 M (SW_INTERFACE_SLAVE_DUMP, mp);
2166 mp->sw_if_index = ntohl (sw_if_index);
2169 /* Use a control ping for synchronization */
2170 MPING (CONTROL_PING, mp_ping);
2177 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2178 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2180 vat_main_t *vam = &vat_main;
2181 i32 retval = ntohl (mp->retval);
2182 if (vam->async_mode)
2184 vam->async_errors += (retval < 0);
2188 vam->retval = retval;
2189 vam->sw_if_index = ntohl (mp->sw_if_index);
2190 vam->result_ready = 1;
2192 vam->regenerate_interface_table = 1;
2195 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2196 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2198 vat_main_t *vam = &vat_main;
2199 vat_json_node_t node;
2201 vat_json_init_object (&node);
2202 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2203 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2204 ntohl (mp->sw_if_index));
2206 vat_json_print (vam->ofp, &node);
2207 vat_json_free (&node);
2209 vam->retval = ntohl (mp->retval);
2210 vam->result_ready = 1;
2213 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2214 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2216 vat_main_t *vam = &vat_main;
2217 i32 retval = ntohl (mp->retval);
2218 if (vam->async_mode)
2220 vam->async_errors += (retval < 0);
2224 vam->retval = retval;
2225 vam->sw_if_index = ntohl (mp->sw_if_index);
2226 vam->result_ready = 1;
2230 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2231 (vl_api_l2tpv3_create_tunnel_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, "sw_if_index", ntohl (mp->sw_if_index));
2240 vat_json_print (vam->ofp, &node);
2241 vat_json_free (&node);
2243 vam->retval = ntohl (mp->retval);
2244 vam->result_ready = 1;
2247 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2248 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2250 vat_main_t *vam = &vat_main;
2251 i32 retval = ntohl (mp->retval);
2252 if (vam->async_mode)
2254 vam->async_errors += (retval < 0);
2258 vam->retval = retval;
2259 vam->result_ready = 1;
2263 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2264 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2266 vat_main_t *vam = &vat_main;
2267 vat_json_node_t node;
2269 vat_json_init_object (&node);
2270 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2271 vat_json_object_add_uint (&node, "fwd_entry_index",
2272 clib_net_to_host_u32 (mp->fwd_entry_index));
2274 vat_json_print (vam->ofp, &node);
2275 vat_json_free (&node);
2277 vam->retval = ntohl (mp->retval);
2278 vam->result_ready = 1;
2282 format_lisp_transport_protocol (u8 * s, va_list * args)
2284 u32 proto = va_arg (*args, u32);
2289 return format (s, "udp");
2291 return format (s, "api");
2298 static void vl_api_one_get_transport_protocol_reply_t_handler
2299 (vl_api_one_get_transport_protocol_reply_t * mp)
2301 vat_main_t *vam = &vat_main;
2302 i32 retval = ntohl (mp->retval);
2303 if (vam->async_mode)
2305 vam->async_errors += (retval < 0);
2309 u32 proto = mp->protocol;
2310 print (vam->ofp, "Transport protocol: %U",
2311 format_lisp_transport_protocol, proto);
2312 vam->retval = retval;
2313 vam->result_ready = 1;
2317 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2318 (vl_api_one_get_transport_protocol_reply_t * mp)
2320 vat_main_t *vam = &vat_main;
2321 vat_json_node_t node;
2324 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2327 vat_json_init_object (&node);
2328 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2329 vat_json_object_add_string_copy (&node, "transport-protocol", s);
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_one_add_del_locator_set_reply_t_handler
2340 (vl_api_one_add_del_locator_set_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->result_ready = 1;
2355 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2356 (vl_api_one_add_del_locator_set_reply_t * mp)
2358 vat_main_t *vam = &vat_main;
2359 vat_json_node_t node;
2361 vat_json_init_object (&node);
2362 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2363 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2365 vat_json_print (vam->ofp, &node);
2366 vat_json_free (&node);
2368 vam->retval = ntohl (mp->retval);
2369 vam->result_ready = 1;
2372 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2373 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2375 vat_main_t *vam = &vat_main;
2376 i32 retval = ntohl (mp->retval);
2377 if (vam->async_mode)
2379 vam->async_errors += (retval < 0);
2383 vam->retval = retval;
2384 vam->sw_if_index = ntohl (mp->sw_if_index);
2385 vam->result_ready = 1;
2387 vam->regenerate_interface_table = 1;
2390 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2391 (vl_api_vxlan_add_del_tunnel_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));
2398 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2400 vat_json_print (vam->ofp, &node);
2401 vat_json_free (&node);
2403 vam->retval = ntohl (mp->retval);
2404 vam->result_ready = 1;
2407 static void vl_api_vxlan_offload_rx_reply_t_handler
2408 (vl_api_vxlan_offload_rx_reply_t * mp)
2410 vat_main_t *vam = &vat_main;
2411 i32 retval = ntohl (mp->retval);
2412 if (vam->async_mode)
2414 vam->async_errors += (retval < 0);
2418 vam->retval = retval;
2419 vam->result_ready = 1;
2423 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2424 (vl_api_vxlan_offload_rx_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));
2432 vat_json_print (vam->ofp, &node);
2433 vat_json_free (&node);
2435 vam->retval = ntohl (mp->retval);
2436 vam->result_ready = 1;
2439 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2440 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2442 vat_main_t *vam = &vat_main;
2443 i32 retval = ntohl (mp->retval);
2444 if (vam->async_mode)
2446 vam->async_errors += (retval < 0);
2450 vam->retval = retval;
2451 vam->sw_if_index = ntohl (mp->sw_if_index);
2452 vam->result_ready = 1;
2456 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2457 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2459 vat_main_t *vam = &vat_main;
2460 vat_json_node_t node;
2462 vat_json_init_object (&node);
2463 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2464 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2466 vat_json_print (vam->ofp, &node);
2467 vat_json_free (&node);
2469 vam->retval = ntohl (mp->retval);
2470 vam->result_ready = 1;
2473 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2474 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2476 vat_main_t *vam = &vat_main;
2477 i32 retval = ntohl (mp->retval);
2478 if (vam->async_mode)
2480 vam->async_errors += (retval < 0);
2484 vam->retval = retval;
2485 vam->sw_if_index = ntohl (mp->sw_if_index);
2486 vam->result_ready = 1;
2488 vam->regenerate_interface_table = 1;
2491 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2492 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2494 vat_main_t *vam = &vat_main;
2495 vat_json_node_t node;
2497 vat_json_init_object (&node);
2498 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2499 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2501 vat_json_print (vam->ofp, &node);
2502 vat_json_free (&node);
2504 vam->retval = ntohl (mp->retval);
2505 vam->result_ready = 1;
2508 static void vl_api_gre_add_del_tunnel_reply_t_handler
2509 (vl_api_gre_add_del_tunnel_reply_t * mp)
2511 vat_main_t *vam = &vat_main;
2512 i32 retval = ntohl (mp->retval);
2513 if (vam->async_mode)
2515 vam->async_errors += (retval < 0);
2519 vam->retval = retval;
2520 vam->sw_if_index = ntohl (mp->sw_if_index);
2521 vam->result_ready = 1;
2525 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2526 (vl_api_gre_add_del_tunnel_reply_t * mp)
2528 vat_main_t *vam = &vat_main;
2529 vat_json_node_t node;
2531 vat_json_init_object (&node);
2532 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2533 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2535 vat_json_print (vam->ofp, &node);
2536 vat_json_free (&node);
2538 vam->retval = ntohl (mp->retval);
2539 vam->result_ready = 1;
2542 static void vl_api_create_vhost_user_if_reply_t_handler
2543 (vl_api_create_vhost_user_if_reply_t * mp)
2545 vat_main_t *vam = &vat_main;
2546 i32 retval = ntohl (mp->retval);
2547 if (vam->async_mode)
2549 vam->async_errors += (retval < 0);
2553 vam->retval = retval;
2554 vam->sw_if_index = ntohl (mp->sw_if_index);
2555 vam->result_ready = 1;
2557 vam->regenerate_interface_table = 1;
2560 static void vl_api_create_vhost_user_if_reply_t_handler_json
2561 (vl_api_create_vhost_user_if_reply_t * mp)
2563 vat_main_t *vam = &vat_main;
2564 vat_json_node_t node;
2566 vat_json_init_object (&node);
2567 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2568 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2570 vat_json_print (vam->ofp, &node);
2571 vat_json_free (&node);
2573 vam->retval = ntohl (mp->retval);
2574 vam->result_ready = 1;
2577 static void vl_api_dns_resolve_name_reply_t_handler
2578 (vl_api_dns_resolve_name_reply_t * mp)
2580 vat_main_t *vam = &vat_main;
2581 i32 retval = ntohl (mp->retval);
2582 if (vam->async_mode)
2584 vam->async_errors += (retval < 0);
2588 vam->retval = retval;
2589 vam->result_ready = 1;
2594 clib_warning ("ip4 address %U", format_ip4_address,
2595 (ip4_address_t *) mp->ip4_address);
2597 clib_warning ("ip6 address %U", format_ip6_address,
2598 (ip6_address_t *) mp->ip6_address);
2601 clib_warning ("retval %d", retval);
2605 static void vl_api_dns_resolve_name_reply_t_handler_json
2606 (vl_api_dns_resolve_name_reply_t * mp)
2608 clib_warning ("not implemented");
2611 static void vl_api_dns_resolve_ip_reply_t_handler
2612 (vl_api_dns_resolve_ip_reply_t * mp)
2614 vat_main_t *vam = &vat_main;
2615 i32 retval = ntohl (mp->retval);
2616 if (vam->async_mode)
2618 vam->async_errors += (retval < 0);
2622 vam->retval = retval;
2623 vam->result_ready = 1;
2627 clib_warning ("canonical name %s", mp->name);
2630 clib_warning ("retval %d", retval);
2634 static void vl_api_dns_resolve_ip_reply_t_handler_json
2635 (vl_api_dns_resolve_ip_reply_t * mp)
2637 clib_warning ("not implemented");
2641 static void vl_api_ip_address_details_t_handler
2642 (vl_api_ip_address_details_t * mp)
2644 vat_main_t *vam = &vat_main;
2645 static ip_address_details_t empty_ip_address_details = { {0} };
2646 ip_address_details_t *address = NULL;
2647 ip_details_t *current_ip_details = NULL;
2648 ip_details_t *details = NULL;
2650 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2652 if (!details || vam->current_sw_if_index >= vec_len (details)
2653 || !details[vam->current_sw_if_index].present)
2655 errmsg ("ip address details arrived but not stored");
2656 errmsg ("ip_dump should be called first");
2660 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2662 #define addresses (current_ip_details->addr)
2664 vec_validate_init_empty (addresses, vec_len (addresses),
2665 empty_ip_address_details);
2667 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2669 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2670 address->prefix_length = mp->prefix_length;
2674 static void vl_api_ip_address_details_t_handler_json
2675 (vl_api_ip_address_details_t * mp)
2677 vat_main_t *vam = &vat_main;
2678 vat_json_node_t *node = NULL;
2679 struct in6_addr ip6;
2682 if (VAT_JSON_ARRAY != vam->json_tree.type)
2684 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2685 vat_json_init_array (&vam->json_tree);
2687 node = vat_json_array_add (&vam->json_tree);
2689 vat_json_init_object (node);
2692 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2693 vat_json_object_add_ip6 (node, "ip", ip6);
2697 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2698 vat_json_object_add_ip4 (node, "ip", ip4);
2700 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2704 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2706 vat_main_t *vam = &vat_main;
2707 static ip_details_t empty_ip_details = { 0 };
2708 ip_details_t *ip = NULL;
2709 u32 sw_if_index = ~0;
2711 sw_if_index = ntohl (mp->sw_if_index);
2713 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2714 sw_if_index, empty_ip_details);
2716 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2723 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2725 vat_main_t *vam = &vat_main;
2727 if (VAT_JSON_ARRAY != vam->json_tree.type)
2729 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2730 vat_json_init_array (&vam->json_tree);
2732 vat_json_array_add_uint (&vam->json_tree,
2733 clib_net_to_host_u32 (mp->sw_if_index));
2737 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2739 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2740 "router_addr %U host_mac %U",
2741 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2743 format_ip4_address, &mp->lease.host_address,
2744 format_ip4_address, &mp->lease.router_address,
2745 format_ethernet_address, mp->lease.host_mac);
2748 static void vl_api_dhcp_compl_event_t_handler_json
2749 (vl_api_dhcp_compl_event_t * mp)
2751 /* JSON output not supported */
2754 static void vl_api_get_first_msg_id_reply_t_handler
2755 (vl_api_get_first_msg_id_reply_t * mp)
2757 vat_main_t *vam = &vat_main;
2758 i32 retval = ntohl (mp->retval);
2760 if (vam->async_mode)
2762 vam->async_errors += (retval < 0);
2766 vam->retval = retval;
2767 vam->result_ready = 1;
2771 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2775 static void vl_api_get_first_msg_id_reply_t_handler_json
2776 (vl_api_get_first_msg_id_reply_t * mp)
2778 vat_main_t *vam = &vat_main;
2779 vat_json_node_t node;
2781 vat_json_init_object (&node);
2782 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2783 vat_json_object_add_uint (&node, "first_msg_id",
2784 (uint) ntohs (mp->first_msg_id));
2786 vat_json_print (vam->ofp, &node);
2787 vat_json_free (&node);
2789 vam->retval = ntohl (mp->retval);
2790 vam->result_ready = 1;
2793 static void vl_api_get_node_graph_reply_t_handler
2794 (vl_api_get_node_graph_reply_t * mp)
2796 vat_main_t *vam = &vat_main;
2797 api_main_t *am = &api_main;
2798 i32 retval = ntohl (mp->retval);
2799 u8 *pvt_copy, *reply;
2804 if (vam->async_mode)
2806 vam->async_errors += (retval < 0);
2810 vam->retval = retval;
2811 vam->result_ready = 1;
2814 /* "Should never happen..." */
2818 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2819 pvt_copy = vec_dup (reply);
2821 /* Toss the shared-memory original... */
2822 pthread_mutex_lock (&am->vlib_rp->mutex);
2823 oldheap = svm_push_data_heap (am->vlib_rp);
2827 svm_pop_heap (oldheap);
2828 pthread_mutex_unlock (&am->vlib_rp->mutex);
2830 if (vam->graph_nodes)
2832 hash_free (vam->graph_node_index_by_name);
2834 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2836 node = vam->graph_nodes[0][i];
2837 vec_free (node->name);
2838 vec_free (node->next_nodes);
2841 vec_free (vam->graph_nodes[0]);
2842 vec_free (vam->graph_nodes);
2845 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2846 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2847 vec_free (pvt_copy);
2849 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2851 node = vam->graph_nodes[0][i];
2852 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2856 static void vl_api_get_node_graph_reply_t_handler_json
2857 (vl_api_get_node_graph_reply_t * mp)
2859 vat_main_t *vam = &vat_main;
2860 api_main_t *am = &api_main;
2862 vat_json_node_t node;
2865 /* $$$$ make this real? */
2866 vat_json_init_object (&node);
2867 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2868 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2870 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2872 /* Toss the shared-memory original... */
2873 pthread_mutex_lock (&am->vlib_rp->mutex);
2874 oldheap = svm_push_data_heap (am->vlib_rp);
2878 svm_pop_heap (oldheap);
2879 pthread_mutex_unlock (&am->vlib_rp->mutex);
2881 vat_json_print (vam->ofp, &node);
2882 vat_json_free (&node);
2884 vam->retval = ntohl (mp->retval);
2885 vam->result_ready = 1;
2889 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2891 vat_main_t *vam = &vat_main;
2896 s = format (s, "%=16d%=16d%=16d",
2897 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2901 s = format (s, "%=16U%=16d%=16d",
2902 mp->is_ipv6 ? format_ip6_address :
2904 mp->ip_address, mp->priority, mp->weight);
2907 print (vam->ofp, "%v", s);
2912 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2914 vat_main_t *vam = &vat_main;
2915 vat_json_node_t *node = NULL;
2916 struct in6_addr ip6;
2919 if (VAT_JSON_ARRAY != vam->json_tree.type)
2921 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2922 vat_json_init_array (&vam->json_tree);
2924 node = vat_json_array_add (&vam->json_tree);
2925 vat_json_init_object (node);
2927 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2928 vat_json_object_add_uint (node, "priority", mp->priority);
2929 vat_json_object_add_uint (node, "weight", mp->weight);
2932 vat_json_object_add_uint (node, "sw_if_index",
2933 clib_net_to_host_u32 (mp->sw_if_index));
2938 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2939 vat_json_object_add_ip6 (node, "address", ip6);
2943 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2944 vat_json_object_add_ip4 (node, "address", ip4);
2950 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2953 vat_main_t *vam = &vat_main;
2956 ls_name = format (0, "%s", mp->ls_name);
2958 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2964 vl_api_one_locator_set_details_t_handler_json
2965 (vl_api_one_locator_set_details_t * mp)
2967 vat_main_t *vam = &vat_main;
2968 vat_json_node_t *node = 0;
2971 ls_name = format (0, "%s", mp->ls_name);
2972 vec_add1 (ls_name, 0);
2974 if (VAT_JSON_ARRAY != vam->json_tree.type)
2976 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2977 vat_json_init_array (&vam->json_tree);
2979 node = vat_json_array_add (&vam->json_tree);
2981 vat_json_init_object (node);
2982 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2983 vat_json_object_add_uint (node, "ls_index",
2984 clib_net_to_host_u32 (mp->ls_index));
2992 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2995 unformat_nsh_address (unformat_input_t * input, va_list * args)
2997 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2998 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3002 format_nsh_address_vat (u8 * s, va_list * args)
3004 nsh_t *a = va_arg (*args, nsh_t *);
3005 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3009 format_lisp_flat_eid (u8 * s, va_list * args)
3011 u32 type = va_arg (*args, u32);
3012 u8 *eid = va_arg (*args, u8 *);
3013 u32 eid_len = va_arg (*args, u32);
3018 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3020 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3022 return format (s, "%U", format_ethernet_address, eid);
3024 return format (s, "%U", format_nsh_address_vat, eid);
3030 format_lisp_eid_vat (u8 * s, va_list * args)
3032 u32 type = va_arg (*args, u32);
3033 u8 *eid = va_arg (*args, u8 *);
3034 u32 eid_len = va_arg (*args, u32);
3035 u8 *seid = va_arg (*args, u8 *);
3036 u32 seid_len = va_arg (*args, u32);
3037 u32 is_src_dst = va_arg (*args, u32);
3040 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3042 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3048 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3050 vat_main_t *vam = &vat_main;
3051 u8 *s = 0, *eid = 0;
3053 if (~0 == mp->locator_set_index)
3054 s = format (0, "action: %d", mp->action);
3056 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3058 eid = format (0, "%U", format_lisp_eid_vat,
3062 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3065 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3066 clib_net_to_host_u32 (mp->vni),
3068 mp->is_local ? "local" : "remote",
3069 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3070 clib_net_to_host_u16 (mp->key_id), mp->key);
3077 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3080 vat_main_t *vam = &vat_main;
3081 vat_json_node_t *node = 0;
3084 if (VAT_JSON_ARRAY != vam->json_tree.type)
3086 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3087 vat_json_init_array (&vam->json_tree);
3089 node = vat_json_array_add (&vam->json_tree);
3091 vat_json_init_object (node);
3092 if (~0 == mp->locator_set_index)
3093 vat_json_object_add_uint (node, "action", mp->action);
3095 vat_json_object_add_uint (node, "locator_set_index",
3096 clib_net_to_host_u32 (mp->locator_set_index));
3098 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3099 if (mp->eid_type == 3)
3101 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3102 vat_json_init_object (nsh_json);
3103 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3104 vat_json_object_add_uint (nsh_json, "spi",
3105 clib_net_to_host_u32 (nsh->spi));
3106 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3110 eid = format (0, "%U", format_lisp_eid_vat,
3114 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3116 vat_json_object_add_string_copy (node, "eid", eid);
3119 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3120 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3121 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3125 vat_json_object_add_uint (node, "key_id",
3126 clib_net_to_host_u16 (mp->key_id));
3127 vat_json_object_add_string_copy (node, "key", mp->key);
3132 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3134 vat_main_t *vam = &vat_main;
3135 u8 *seid = 0, *deid = 0;
3136 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3138 deid = format (0, "%U", format_lisp_eid_vat,
3139 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3141 seid = format (0, "%U", format_lisp_eid_vat,
3142 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3148 format_ip_address_fcn = format_ip4_address;
3150 format_ip_address_fcn = format_ip6_address;
3153 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3154 clib_net_to_host_u32 (mp->vni),
3156 format_ip_address_fcn, mp->lloc,
3157 format_ip_address_fcn, mp->rloc,
3158 clib_net_to_host_u32 (mp->pkt_count),
3159 clib_net_to_host_u32 (mp->bytes));
3166 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3168 struct in6_addr ip6;
3170 vat_main_t *vam = &vat_main;
3171 vat_json_node_t *node = 0;
3172 u8 *deid = 0, *seid = 0;
3174 if (VAT_JSON_ARRAY != vam->json_tree.type)
3176 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3177 vat_json_init_array (&vam->json_tree);
3179 node = vat_json_array_add (&vam->json_tree);
3181 vat_json_init_object (node);
3182 deid = format (0, "%U", format_lisp_eid_vat,
3183 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3185 seid = format (0, "%U", format_lisp_eid_vat,
3186 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3191 vat_json_object_add_string_copy (node, "seid", seid);
3192 vat_json_object_add_string_copy (node, "deid", deid);
3193 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3197 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3198 vat_json_object_add_ip4 (node, "lloc", ip4);
3199 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3200 vat_json_object_add_ip4 (node, "rloc", ip4);
3204 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3205 vat_json_object_add_ip6 (node, "lloc", ip6);
3206 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3207 vat_json_object_add_ip6 (node, "rloc", ip6);
3209 vat_json_object_add_uint (node, "pkt_count",
3210 clib_net_to_host_u32 (mp->pkt_count));
3211 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3218 vl_api_one_eid_table_map_details_t_handler
3219 (vl_api_one_eid_table_map_details_t * mp)
3221 vat_main_t *vam = &vat_main;
3223 u8 *line = format (0, "%=10d%=10d",
3224 clib_net_to_host_u32 (mp->vni),
3225 clib_net_to_host_u32 (mp->dp_table));
3226 print (vam->ofp, "%v", line);
3231 vl_api_one_eid_table_map_details_t_handler_json
3232 (vl_api_one_eid_table_map_details_t * mp)
3234 vat_main_t *vam = &vat_main;
3235 vat_json_node_t *node = NULL;
3237 if (VAT_JSON_ARRAY != vam->json_tree.type)
3239 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3240 vat_json_init_array (&vam->json_tree);
3242 node = vat_json_array_add (&vam->json_tree);
3243 vat_json_init_object (node);
3244 vat_json_object_add_uint (node, "dp_table",
3245 clib_net_to_host_u32 (mp->dp_table));
3246 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3250 vl_api_one_eid_table_vni_details_t_handler
3251 (vl_api_one_eid_table_vni_details_t * mp)
3253 vat_main_t *vam = &vat_main;
3255 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3256 print (vam->ofp, "%v", line);
3261 vl_api_one_eid_table_vni_details_t_handler_json
3262 (vl_api_one_eid_table_vni_details_t * mp)
3264 vat_main_t *vam = &vat_main;
3265 vat_json_node_t *node = NULL;
3267 if (VAT_JSON_ARRAY != vam->json_tree.type)
3269 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3270 vat_json_init_array (&vam->json_tree);
3272 node = vat_json_array_add (&vam->json_tree);
3273 vat_json_init_object (node);
3274 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3278 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3279 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3281 vat_main_t *vam = &vat_main;
3282 int retval = clib_net_to_host_u32 (mp->retval);
3284 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3285 print (vam->ofp, "fallback threshold value: %d", mp->value);
3287 vam->retval = retval;
3288 vam->result_ready = 1;
3292 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3293 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3295 vat_main_t *vam = &vat_main;
3296 vat_json_node_t _node, *node = &_node;
3297 int retval = clib_net_to_host_u32 (mp->retval);
3299 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3300 vat_json_init_object (node);
3301 vat_json_object_add_uint (node, "value", mp->value);
3303 vat_json_print (vam->ofp, node);
3304 vat_json_free (node);
3306 vam->retval = retval;
3307 vam->result_ready = 1;
3311 vl_api_show_one_map_register_state_reply_t_handler
3312 (vl_api_show_one_map_register_state_reply_t * mp)
3314 vat_main_t *vam = &vat_main;
3315 int retval = clib_net_to_host_u32 (mp->retval);
3317 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3319 vam->retval = retval;
3320 vam->result_ready = 1;
3324 vl_api_show_one_map_register_state_reply_t_handler_json
3325 (vl_api_show_one_map_register_state_reply_t * mp)
3327 vat_main_t *vam = &vat_main;
3328 vat_json_node_t _node, *node = &_node;
3329 int retval = clib_net_to_host_u32 (mp->retval);
3331 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3333 vat_json_init_object (node);
3334 vat_json_object_add_string_copy (node, "state", s);
3336 vat_json_print (vam->ofp, node);
3337 vat_json_free (node);
3339 vam->retval = retval;
3340 vam->result_ready = 1;
3345 vl_api_show_one_rloc_probe_state_reply_t_handler
3346 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3348 vat_main_t *vam = &vat_main;
3349 int retval = clib_net_to_host_u32 (mp->retval);
3354 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3356 vam->retval = retval;
3357 vam->result_ready = 1;
3361 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3362 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3364 vat_main_t *vam = &vat_main;
3365 vat_json_node_t _node, *node = &_node;
3366 int retval = clib_net_to_host_u32 (mp->retval);
3368 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3369 vat_json_init_object (node);
3370 vat_json_object_add_string_copy (node, "state", s);
3372 vat_json_print (vam->ofp, node);
3373 vat_json_free (node);
3375 vam->retval = retval;
3376 vam->result_ready = 1;
3381 vl_api_show_one_stats_enable_disable_reply_t_handler
3382 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3384 vat_main_t *vam = &vat_main;
3385 int retval = clib_net_to_host_u32 (mp->retval);
3390 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3392 vam->retval = retval;
3393 vam->result_ready = 1;
3397 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3398 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3400 vat_main_t *vam = &vat_main;
3401 vat_json_node_t _node, *node = &_node;
3402 int retval = clib_net_to_host_u32 (mp->retval);
3404 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3405 vat_json_init_object (node);
3406 vat_json_object_add_string_copy (node, "state", s);
3408 vat_json_print (vam->ofp, node);
3409 vat_json_free (node);
3411 vam->retval = retval;
3412 vam->result_ready = 1;
3417 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3419 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3420 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3421 e->vni = clib_net_to_host_u32 (e->vni);
3425 gpe_fwd_entries_get_reply_t_net_to_host
3426 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3430 mp->count = clib_net_to_host_u32 (mp->count);
3431 for (i = 0; i < mp->count; i++)
3433 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3438 format_gpe_encap_mode (u8 * s, va_list * args)
3440 u32 mode = va_arg (*args, u32);
3445 return format (s, "lisp");
3447 return format (s, "vxlan");
3453 vl_api_gpe_get_encap_mode_reply_t_handler
3454 (vl_api_gpe_get_encap_mode_reply_t * mp)
3456 vat_main_t *vam = &vat_main;
3458 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3459 vam->retval = ntohl (mp->retval);
3460 vam->result_ready = 1;
3464 vl_api_gpe_get_encap_mode_reply_t_handler_json
3465 (vl_api_gpe_get_encap_mode_reply_t * mp)
3467 vat_main_t *vam = &vat_main;
3468 vat_json_node_t node;
3470 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3471 vec_add1 (encap_mode, 0);
3473 vat_json_init_object (&node);
3474 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3476 vec_free (encap_mode);
3477 vat_json_print (vam->ofp, &node);
3478 vat_json_free (&node);
3480 vam->retval = ntohl (mp->retval);
3481 vam->result_ready = 1;
3485 vl_api_gpe_fwd_entry_path_details_t_handler
3486 (vl_api_gpe_fwd_entry_path_details_t * mp)
3488 vat_main_t *vam = &vat_main;
3489 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3491 if (mp->lcl_loc.is_ip4)
3492 format_ip_address_fcn = format_ip4_address;
3494 format_ip_address_fcn = format_ip6_address;
3496 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3497 format_ip_address_fcn, &mp->lcl_loc,
3498 format_ip_address_fcn, &mp->rmt_loc);
3502 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3504 struct in6_addr ip6;
3509 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3510 vat_json_object_add_ip4 (n, "address", ip4);
3514 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3515 vat_json_object_add_ip6 (n, "address", ip6);
3517 vat_json_object_add_uint (n, "weight", loc->weight);
3521 vl_api_gpe_fwd_entry_path_details_t_handler_json
3522 (vl_api_gpe_fwd_entry_path_details_t * mp)
3524 vat_main_t *vam = &vat_main;
3525 vat_json_node_t *node = NULL;
3526 vat_json_node_t *loc_node;
3528 if (VAT_JSON_ARRAY != vam->json_tree.type)
3530 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3531 vat_json_init_array (&vam->json_tree);
3533 node = vat_json_array_add (&vam->json_tree);
3534 vat_json_init_object (node);
3536 loc_node = vat_json_object_add (node, "local_locator");
3537 vat_json_init_object (loc_node);
3538 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3540 loc_node = vat_json_object_add (node, "remote_locator");
3541 vat_json_init_object (loc_node);
3542 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3546 vl_api_gpe_fwd_entries_get_reply_t_handler
3547 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3549 vat_main_t *vam = &vat_main;
3551 int retval = clib_net_to_host_u32 (mp->retval);
3552 vl_api_gpe_fwd_entry_t *e;
3557 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3559 for (i = 0; i < mp->count; i++)
3561 e = &mp->entries[i];
3562 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3563 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3564 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3568 vam->retval = retval;
3569 vam->result_ready = 1;
3573 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3574 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3577 vat_main_t *vam = &vat_main;
3578 vat_json_node_t *e = 0, root;
3580 int retval = clib_net_to_host_u32 (mp->retval);
3581 vl_api_gpe_fwd_entry_t *fwd;
3586 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3587 vat_json_init_array (&root);
3589 for (i = 0; i < mp->count; i++)
3591 e = vat_json_array_add (&root);
3592 fwd = &mp->entries[i];
3594 vat_json_init_object (e);
3595 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3596 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3597 vat_json_object_add_int (e, "vni", fwd->vni);
3598 vat_json_object_add_int (e, "action", fwd->action);
3600 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3601 fwd->leid_prefix_len);
3603 vat_json_object_add_string_copy (e, "leid", s);
3606 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3607 fwd->reid_prefix_len);
3609 vat_json_object_add_string_copy (e, "reid", s);
3613 vat_json_print (vam->ofp, &root);
3614 vat_json_free (&root);
3617 vam->retval = retval;
3618 vam->result_ready = 1;
3622 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3623 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3625 vat_main_t *vam = &vat_main;
3627 int retval = clib_net_to_host_u32 (mp->retval);
3628 vl_api_gpe_native_fwd_rpath_t *r;
3633 n = clib_net_to_host_u32 (mp->count);
3635 for (i = 0; i < n; i++)
3637 r = &mp->entries[i];
3638 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3639 clib_net_to_host_u32 (r->fib_index),
3640 clib_net_to_host_u32 (r->nh_sw_if_index),
3641 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3645 vam->retval = retval;
3646 vam->result_ready = 1;
3650 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3651 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3653 vat_main_t *vam = &vat_main;
3654 vat_json_node_t root, *e;
3656 int retval = clib_net_to_host_u32 (mp->retval);
3657 vl_api_gpe_native_fwd_rpath_t *r;
3663 n = clib_net_to_host_u32 (mp->count);
3664 vat_json_init_array (&root);
3666 for (i = 0; i < n; i++)
3668 e = vat_json_array_add (&root);
3669 vat_json_init_object (e);
3670 r = &mp->entries[i];
3672 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3675 vat_json_object_add_string_copy (e, "ip4", s);
3678 vat_json_object_add_uint (e, "fib_index",
3679 clib_net_to_host_u32 (r->fib_index));
3680 vat_json_object_add_uint (e, "nh_sw_if_index",
3681 clib_net_to_host_u32 (r->nh_sw_if_index));
3684 vat_json_print (vam->ofp, &root);
3685 vat_json_free (&root);
3688 vam->retval = retval;
3689 vam->result_ready = 1;
3693 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3694 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3696 vat_main_t *vam = &vat_main;
3698 int retval = clib_net_to_host_u32 (mp->retval);
3703 n = clib_net_to_host_u32 (mp->count);
3705 for (i = 0; i < n; i++)
3706 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3709 vam->retval = retval;
3710 vam->result_ready = 1;
3714 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3715 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3717 vat_main_t *vam = &vat_main;
3718 vat_json_node_t root;
3720 int retval = clib_net_to_host_u32 (mp->retval);
3725 n = clib_net_to_host_u32 (mp->count);
3726 vat_json_init_array (&root);
3728 for (i = 0; i < n; i++)
3729 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3731 vat_json_print (vam->ofp, &root);
3732 vat_json_free (&root);
3735 vam->retval = retval;
3736 vam->result_ready = 1;
3740 vl_api_one_ndp_entries_get_reply_t_handler
3741 (vl_api_one_ndp_entries_get_reply_t * mp)
3743 vat_main_t *vam = &vat_main;
3745 int retval = clib_net_to_host_u32 (mp->retval);
3750 n = clib_net_to_host_u32 (mp->count);
3752 for (i = 0; i < n; i++)
3753 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3754 format_ethernet_address, mp->entries[i].mac);
3757 vam->retval = retval;
3758 vam->result_ready = 1;
3762 vl_api_one_ndp_entries_get_reply_t_handler_json
3763 (vl_api_one_ndp_entries_get_reply_t * mp)
3766 vat_main_t *vam = &vat_main;
3767 vat_json_node_t *e = 0, root;
3769 int retval = clib_net_to_host_u32 (mp->retval);
3770 vl_api_one_ndp_entry_t *arp_entry;
3775 n = clib_net_to_host_u32 (mp->count);
3776 vat_json_init_array (&root);
3778 for (i = 0; i < n; i++)
3780 e = vat_json_array_add (&root);
3781 arp_entry = &mp->entries[i];
3783 vat_json_init_object (e);
3784 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3787 vat_json_object_add_string_copy (e, "mac", s);
3790 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3792 vat_json_object_add_string_copy (e, "ip6", s);
3796 vat_json_print (vam->ofp, &root);
3797 vat_json_free (&root);
3800 vam->retval = retval;
3801 vam->result_ready = 1;
3805 vl_api_one_l2_arp_entries_get_reply_t_handler
3806 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3808 vat_main_t *vam = &vat_main;
3810 int retval = clib_net_to_host_u32 (mp->retval);
3815 n = clib_net_to_host_u32 (mp->count);
3817 for (i = 0; i < n; i++)
3818 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3819 format_ethernet_address, mp->entries[i].mac);
3822 vam->retval = retval;
3823 vam->result_ready = 1;
3827 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3828 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3831 vat_main_t *vam = &vat_main;
3832 vat_json_node_t *e = 0, root;
3834 int retval = clib_net_to_host_u32 (mp->retval);
3835 vl_api_one_l2_arp_entry_t *arp_entry;
3840 n = clib_net_to_host_u32 (mp->count);
3841 vat_json_init_array (&root);
3843 for (i = 0; i < n; i++)
3845 e = vat_json_array_add (&root);
3846 arp_entry = &mp->entries[i];
3848 vat_json_init_object (e);
3849 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3852 vat_json_object_add_string_copy (e, "mac", s);
3855 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3857 vat_json_object_add_string_copy (e, "ip4", s);
3861 vat_json_print (vam->ofp, &root);
3862 vat_json_free (&root);
3865 vam->retval = retval;
3866 vam->result_ready = 1;
3870 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3872 vat_main_t *vam = &vat_main;
3874 int retval = clib_net_to_host_u32 (mp->retval);
3879 n = clib_net_to_host_u32 (mp->count);
3881 for (i = 0; i < n; i++)
3883 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3887 vam->retval = retval;
3888 vam->result_ready = 1;
3892 vl_api_one_ndp_bd_get_reply_t_handler_json
3893 (vl_api_one_ndp_bd_get_reply_t * mp)
3895 vat_main_t *vam = &vat_main;
3896 vat_json_node_t root;
3898 int retval = clib_net_to_host_u32 (mp->retval);
3903 n = clib_net_to_host_u32 (mp->count);
3904 vat_json_init_array (&root);
3906 for (i = 0; i < n; i++)
3908 vat_json_array_add_uint (&root,
3909 clib_net_to_host_u32 (mp->bridge_domains[i]));
3912 vat_json_print (vam->ofp, &root);
3913 vat_json_free (&root);
3916 vam->retval = retval;
3917 vam->result_ready = 1;
3921 vl_api_one_l2_arp_bd_get_reply_t_handler
3922 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3924 vat_main_t *vam = &vat_main;
3926 int retval = clib_net_to_host_u32 (mp->retval);
3931 n = clib_net_to_host_u32 (mp->count);
3933 for (i = 0; i < n; i++)
3935 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3939 vam->retval = retval;
3940 vam->result_ready = 1;
3944 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3945 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3947 vat_main_t *vam = &vat_main;
3948 vat_json_node_t root;
3950 int retval = clib_net_to_host_u32 (mp->retval);
3955 n = clib_net_to_host_u32 (mp->count);
3956 vat_json_init_array (&root);
3958 for (i = 0; i < n; i++)
3960 vat_json_array_add_uint (&root,
3961 clib_net_to_host_u32 (mp->bridge_domains[i]));
3964 vat_json_print (vam->ofp, &root);
3965 vat_json_free (&root);
3968 vam->retval = retval;
3969 vam->result_ready = 1;
3973 vl_api_one_adjacencies_get_reply_t_handler
3974 (vl_api_one_adjacencies_get_reply_t * mp)
3976 vat_main_t *vam = &vat_main;
3978 int retval = clib_net_to_host_u32 (mp->retval);
3979 vl_api_one_adjacency_t *a;
3984 n = clib_net_to_host_u32 (mp->count);
3986 for (i = 0; i < n; i++)
3988 a = &mp->adjacencies[i];
3989 print (vam->ofp, "%U %40U",
3990 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3991 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3995 vam->retval = retval;
3996 vam->result_ready = 1;
4000 vl_api_one_adjacencies_get_reply_t_handler_json
4001 (vl_api_one_adjacencies_get_reply_t * mp)
4004 vat_main_t *vam = &vat_main;
4005 vat_json_node_t *e = 0, root;
4007 int retval = clib_net_to_host_u32 (mp->retval);
4008 vl_api_one_adjacency_t *a;
4013 n = clib_net_to_host_u32 (mp->count);
4014 vat_json_init_array (&root);
4016 for (i = 0; i < n; i++)
4018 e = vat_json_array_add (&root);
4019 a = &mp->adjacencies[i];
4021 vat_json_init_object (e);
4022 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4023 a->leid_prefix_len);
4025 vat_json_object_add_string_copy (e, "leid", s);
4028 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4029 a->reid_prefix_len);
4031 vat_json_object_add_string_copy (e, "reid", s);
4035 vat_json_print (vam->ofp, &root);
4036 vat_json_free (&root);
4039 vam->retval = retval;
4040 vam->result_ready = 1;
4044 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4046 vat_main_t *vam = &vat_main;
4048 print (vam->ofp, "%=20U",
4049 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4054 vl_api_one_map_server_details_t_handler_json
4055 (vl_api_one_map_server_details_t * mp)
4057 vat_main_t *vam = &vat_main;
4058 vat_json_node_t *node = NULL;
4059 struct in6_addr ip6;
4062 if (VAT_JSON_ARRAY != vam->json_tree.type)
4064 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4065 vat_json_init_array (&vam->json_tree);
4067 node = vat_json_array_add (&vam->json_tree);
4069 vat_json_init_object (node);
4072 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4073 vat_json_object_add_ip6 (node, "map-server", ip6);
4077 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4078 vat_json_object_add_ip4 (node, "map-server", ip4);
4083 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4086 vat_main_t *vam = &vat_main;
4088 print (vam->ofp, "%=20U",
4089 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4094 vl_api_one_map_resolver_details_t_handler_json
4095 (vl_api_one_map_resolver_details_t * mp)
4097 vat_main_t *vam = &vat_main;
4098 vat_json_node_t *node = NULL;
4099 struct in6_addr ip6;
4102 if (VAT_JSON_ARRAY != vam->json_tree.type)
4104 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4105 vat_json_init_array (&vam->json_tree);
4107 node = vat_json_array_add (&vam->json_tree);
4109 vat_json_init_object (node);
4112 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4113 vat_json_object_add_ip6 (node, "map resolver", ip6);
4117 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4118 vat_json_object_add_ip4 (node, "map resolver", ip4);
4123 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4125 vat_main_t *vam = &vat_main;
4126 i32 retval = ntohl (mp->retval);
4130 print (vam->ofp, "feature: %s\ngpe: %s",
4131 mp->feature_status ? "enabled" : "disabled",
4132 mp->gpe_status ? "enabled" : "disabled");
4135 vam->retval = retval;
4136 vam->result_ready = 1;
4140 vl_api_show_one_status_reply_t_handler_json
4141 (vl_api_show_one_status_reply_t * mp)
4143 vat_main_t *vam = &vat_main;
4144 vat_json_node_t node;
4145 u8 *gpe_status = NULL;
4146 u8 *feature_status = NULL;
4148 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4149 feature_status = format (0, "%s",
4150 mp->feature_status ? "enabled" : "disabled");
4151 vec_add1 (gpe_status, 0);
4152 vec_add1 (feature_status, 0);
4154 vat_json_init_object (&node);
4155 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4156 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4158 vec_free (gpe_status);
4159 vec_free (feature_status);
4161 vat_json_print (vam->ofp, &node);
4162 vat_json_free (&node);
4164 vam->retval = ntohl (mp->retval);
4165 vam->result_ready = 1;
4169 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4170 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4172 vat_main_t *vam = &vat_main;
4173 i32 retval = ntohl (mp->retval);
4177 print (vam->ofp, "%=20s", mp->locator_set_name);
4180 vam->retval = retval;
4181 vam->result_ready = 1;
4185 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4186 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4188 vat_main_t *vam = &vat_main;
4189 vat_json_node_t *node = NULL;
4191 if (VAT_JSON_ARRAY != vam->json_tree.type)
4193 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4194 vat_json_init_array (&vam->json_tree);
4196 node = vat_json_array_add (&vam->json_tree);
4198 vat_json_init_object (node);
4199 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4201 vat_json_print (vam->ofp, node);
4202 vat_json_free (node);
4204 vam->retval = ntohl (mp->retval);
4205 vam->result_ready = 1;
4209 format_lisp_map_request_mode (u8 * s, va_list * args)
4211 u32 mode = va_arg (*args, u32);
4216 return format (0, "dst-only");
4218 return format (0, "src-dst");
4224 vl_api_show_one_map_request_mode_reply_t_handler
4225 (vl_api_show_one_map_request_mode_reply_t * mp)
4227 vat_main_t *vam = &vat_main;
4228 i32 retval = ntohl (mp->retval);
4232 u32 mode = mp->mode;
4233 print (vam->ofp, "map_request_mode: %U",
4234 format_lisp_map_request_mode, mode);
4237 vam->retval = retval;
4238 vam->result_ready = 1;
4242 vl_api_show_one_map_request_mode_reply_t_handler_json
4243 (vl_api_show_one_map_request_mode_reply_t * mp)
4245 vat_main_t *vam = &vat_main;
4246 vat_json_node_t node;
4251 s = format (0, "%U", format_lisp_map_request_mode, mode);
4254 vat_json_init_object (&node);
4255 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4256 vat_json_print (vam->ofp, &node);
4257 vat_json_free (&node);
4260 vam->retval = ntohl (mp->retval);
4261 vam->result_ready = 1;
4265 vl_api_one_show_xtr_mode_reply_t_handler
4266 (vl_api_one_show_xtr_mode_reply_t * mp)
4268 vat_main_t *vam = &vat_main;
4269 i32 retval = ntohl (mp->retval);
4273 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4276 vam->retval = retval;
4277 vam->result_ready = 1;
4281 vl_api_one_show_xtr_mode_reply_t_handler_json
4282 (vl_api_one_show_xtr_mode_reply_t * mp)
4284 vat_main_t *vam = &vat_main;
4285 vat_json_node_t node;
4288 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4289 vec_add1 (status, 0);
4291 vat_json_init_object (&node);
4292 vat_json_object_add_string_copy (&node, "status", status);
4296 vat_json_print (vam->ofp, &node);
4297 vat_json_free (&node);
4299 vam->retval = ntohl (mp->retval);
4300 vam->result_ready = 1;
4304 vl_api_one_show_pitr_mode_reply_t_handler
4305 (vl_api_one_show_pitr_mode_reply_t * mp)
4307 vat_main_t *vam = &vat_main;
4308 i32 retval = ntohl (mp->retval);
4312 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4315 vam->retval = retval;
4316 vam->result_ready = 1;
4320 vl_api_one_show_pitr_mode_reply_t_handler_json
4321 (vl_api_one_show_pitr_mode_reply_t * mp)
4323 vat_main_t *vam = &vat_main;
4324 vat_json_node_t node;
4327 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4328 vec_add1 (status, 0);
4330 vat_json_init_object (&node);
4331 vat_json_object_add_string_copy (&node, "status", status);
4335 vat_json_print (vam->ofp, &node);
4336 vat_json_free (&node);
4338 vam->retval = ntohl (mp->retval);
4339 vam->result_ready = 1;
4343 vl_api_one_show_petr_mode_reply_t_handler
4344 (vl_api_one_show_petr_mode_reply_t * mp)
4346 vat_main_t *vam = &vat_main;
4347 i32 retval = ntohl (mp->retval);
4351 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4354 vam->retval = retval;
4355 vam->result_ready = 1;
4359 vl_api_one_show_petr_mode_reply_t_handler_json
4360 (vl_api_one_show_petr_mode_reply_t * mp)
4362 vat_main_t *vam = &vat_main;
4363 vat_json_node_t node;
4366 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4367 vec_add1 (status, 0);
4369 vat_json_init_object (&node);
4370 vat_json_object_add_string_copy (&node, "status", status);
4374 vat_json_print (vam->ofp, &node);
4375 vat_json_free (&node);
4377 vam->retval = ntohl (mp->retval);
4378 vam->result_ready = 1;
4382 vl_api_show_one_use_petr_reply_t_handler
4383 (vl_api_show_one_use_petr_reply_t * mp)
4385 vat_main_t *vam = &vat_main;
4386 i32 retval = ntohl (mp->retval);
4390 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4393 print (vam->ofp, "Proxy-ETR address; %U",
4394 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4399 vam->retval = retval;
4400 vam->result_ready = 1;
4404 vl_api_show_one_use_petr_reply_t_handler_json
4405 (vl_api_show_one_use_petr_reply_t * mp)
4407 vat_main_t *vam = &vat_main;
4408 vat_json_node_t node;
4411 struct in6_addr ip6;
4413 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4414 vec_add1 (status, 0);
4416 vat_json_init_object (&node);
4417 vat_json_object_add_string_copy (&node, "status", status);
4422 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4423 vat_json_object_add_ip6 (&node, "address", ip6);
4427 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4428 vat_json_object_add_ip4 (&node, "address", ip4);
4434 vat_json_print (vam->ofp, &node);
4435 vat_json_free (&node);
4437 vam->retval = ntohl (mp->retval);
4438 vam->result_ready = 1;
4442 vl_api_show_one_nsh_mapping_reply_t_handler
4443 (vl_api_show_one_nsh_mapping_reply_t * mp)
4445 vat_main_t *vam = &vat_main;
4446 i32 retval = ntohl (mp->retval);
4450 print (vam->ofp, "%-20s%-16s",
4451 mp->is_set ? "set" : "not-set",
4452 mp->is_set ? (char *) mp->locator_set_name : "");
4455 vam->retval = retval;
4456 vam->result_ready = 1;
4460 vl_api_show_one_nsh_mapping_reply_t_handler_json
4461 (vl_api_show_one_nsh_mapping_reply_t * mp)
4463 vat_main_t *vam = &vat_main;
4464 vat_json_node_t node;
4467 status = format (0, "%s", mp->is_set ? "yes" : "no");
4468 vec_add1 (status, 0);
4470 vat_json_init_object (&node);
4471 vat_json_object_add_string_copy (&node, "is_set", status);
4474 vat_json_object_add_string_copy (&node, "locator_set",
4475 mp->locator_set_name);
4480 vat_json_print (vam->ofp, &node);
4481 vat_json_free (&node);
4483 vam->retval = ntohl (mp->retval);
4484 vam->result_ready = 1;
4488 vl_api_show_one_map_register_ttl_reply_t_handler
4489 (vl_api_show_one_map_register_ttl_reply_t * mp)
4491 vat_main_t *vam = &vat_main;
4492 i32 retval = ntohl (mp->retval);
4494 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4498 print (vam->ofp, "ttl: %u", mp->ttl);
4501 vam->retval = retval;
4502 vam->result_ready = 1;
4506 vl_api_show_one_map_register_ttl_reply_t_handler_json
4507 (vl_api_show_one_map_register_ttl_reply_t * mp)
4509 vat_main_t *vam = &vat_main;
4510 vat_json_node_t node;
4512 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4513 vat_json_init_object (&node);
4514 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4516 vat_json_print (vam->ofp, &node);
4517 vat_json_free (&node);
4519 vam->retval = ntohl (mp->retval);
4520 vam->result_ready = 1;
4524 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4526 vat_main_t *vam = &vat_main;
4527 i32 retval = ntohl (mp->retval);
4531 print (vam->ofp, "%-20s%-16s",
4532 mp->status ? "enabled" : "disabled",
4533 mp->status ? (char *) mp->locator_set_name : "");
4536 vam->retval = retval;
4537 vam->result_ready = 1;
4541 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4543 vat_main_t *vam = &vat_main;
4544 vat_json_node_t node;
4547 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4548 vec_add1 (status, 0);
4550 vat_json_init_object (&node);
4551 vat_json_object_add_string_copy (&node, "status", status);
4554 vat_json_object_add_string_copy (&node, "locator_set",
4555 mp->locator_set_name);
4560 vat_json_print (vam->ofp, &node);
4561 vat_json_free (&node);
4563 vam->retval = ntohl (mp->retval);
4564 vam->result_ready = 1;
4568 format_policer_type (u8 * s, va_list * va)
4570 u32 i = va_arg (*va, u32);
4572 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4573 s = format (s, "1r2c");
4574 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4575 s = format (s, "1r3c");
4576 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4577 s = format (s, "2r3c-2698");
4578 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4579 s = format (s, "2r3c-4115");
4580 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4581 s = format (s, "2r3c-mef5cf1");
4583 s = format (s, "ILLEGAL");
4588 format_policer_rate_type (u8 * s, va_list * va)
4590 u32 i = va_arg (*va, u32);
4592 if (i == SSE2_QOS_RATE_KBPS)
4593 s = format (s, "kbps");
4594 else if (i == SSE2_QOS_RATE_PPS)
4595 s = format (s, "pps");
4597 s = format (s, "ILLEGAL");
4602 format_policer_round_type (u8 * s, va_list * va)
4604 u32 i = va_arg (*va, u32);
4606 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4607 s = format (s, "closest");
4608 else if (i == SSE2_QOS_ROUND_TO_UP)
4609 s = format (s, "up");
4610 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4611 s = format (s, "down");
4613 s = format (s, "ILLEGAL");
4618 format_policer_action_type (u8 * s, va_list * va)
4620 u32 i = va_arg (*va, u32);
4622 if (i == SSE2_QOS_ACTION_DROP)
4623 s = format (s, "drop");
4624 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4625 s = format (s, "transmit");
4626 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4627 s = format (s, "mark-and-transmit");
4629 s = format (s, "ILLEGAL");
4634 format_dscp (u8 * s, va_list * va)
4636 u32 i = va_arg (*va, u32);
4641 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4645 return format (s, "ILLEGAL");
4647 s = format (s, "%s", t);
4652 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4654 vat_main_t *vam = &vat_main;
4655 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4657 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4658 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4660 conform_dscp_str = format (0, "");
4662 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4663 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4665 exceed_dscp_str = format (0, "");
4667 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4668 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4670 violate_dscp_str = format (0, "");
4672 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4673 "rate type %U, round type %U, %s rate, %s color-aware, "
4674 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4675 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4676 "conform action %U%s, exceed action %U%s, violate action %U%s",
4678 format_policer_type, mp->type,
4681 clib_net_to_host_u64 (mp->cb),
4682 clib_net_to_host_u64 (mp->eb),
4683 format_policer_rate_type, mp->rate_type,
4684 format_policer_round_type, mp->round_type,
4685 mp->single_rate ? "single" : "dual",
4686 mp->color_aware ? "is" : "not",
4687 ntohl (mp->cir_tokens_per_period),
4688 ntohl (mp->pir_tokens_per_period),
4690 ntohl (mp->current_limit),
4691 ntohl (mp->current_bucket),
4692 ntohl (mp->extended_limit),
4693 ntohl (mp->extended_bucket),
4694 clib_net_to_host_u64 (mp->last_update_time),
4695 format_policer_action_type, mp->conform_action_type,
4697 format_policer_action_type, mp->exceed_action_type,
4699 format_policer_action_type, mp->violate_action_type,
4702 vec_free (conform_dscp_str);
4703 vec_free (exceed_dscp_str);
4704 vec_free (violate_dscp_str);
4707 static void vl_api_policer_details_t_handler_json
4708 (vl_api_policer_details_t * mp)
4710 vat_main_t *vam = &vat_main;
4711 vat_json_node_t *node;
4712 u8 *rate_type_str, *round_type_str, *type_str;
4713 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4715 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4717 format (0, "%U", format_policer_round_type, mp->round_type);
4718 type_str = format (0, "%U", format_policer_type, mp->type);
4719 conform_action_str = format (0, "%U", format_policer_action_type,
4720 mp->conform_action_type);
4721 exceed_action_str = format (0, "%U", format_policer_action_type,
4722 mp->exceed_action_type);
4723 violate_action_str = format (0, "%U", format_policer_action_type,
4724 mp->violate_action_type);
4726 if (VAT_JSON_ARRAY != vam->json_tree.type)
4728 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4729 vat_json_init_array (&vam->json_tree);
4731 node = vat_json_array_add (&vam->json_tree);
4733 vat_json_init_object (node);
4734 vat_json_object_add_string_copy (node, "name", mp->name);
4735 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4736 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4737 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4738 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4739 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4740 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4741 vat_json_object_add_string_copy (node, "type", type_str);
4742 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4743 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4744 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4745 vat_json_object_add_uint (node, "cir_tokens_per_period",
4746 ntohl (mp->cir_tokens_per_period));
4747 vat_json_object_add_uint (node, "eir_tokens_per_period",
4748 ntohl (mp->pir_tokens_per_period));
4749 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4750 vat_json_object_add_uint (node, "current_bucket",
4751 ntohl (mp->current_bucket));
4752 vat_json_object_add_uint (node, "extended_limit",
4753 ntohl (mp->extended_limit));
4754 vat_json_object_add_uint (node, "extended_bucket",
4755 ntohl (mp->extended_bucket));
4756 vat_json_object_add_uint (node, "last_update_time",
4757 ntohl (mp->last_update_time));
4758 vat_json_object_add_string_copy (node, "conform_action",
4759 conform_action_str);
4760 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4762 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4763 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4764 vec_free (dscp_str);
4766 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4767 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4769 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4770 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4771 vec_free (dscp_str);
4773 vat_json_object_add_string_copy (node, "violate_action",
4774 violate_action_str);
4775 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4777 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4778 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4779 vec_free (dscp_str);
4782 vec_free (rate_type_str);
4783 vec_free (round_type_str);
4784 vec_free (type_str);
4785 vec_free (conform_action_str);
4786 vec_free (exceed_action_str);
4787 vec_free (violate_action_str);
4791 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4794 vat_main_t *vam = &vat_main;
4795 int i, count = ntohl (mp->count);
4798 print (vam->ofp, "classify table ids (%d) : ", count);
4799 for (i = 0; i < count; i++)
4801 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4802 print (vam->ofp, (i < count - 1) ? "," : "");
4804 vam->retval = ntohl (mp->retval);
4805 vam->result_ready = 1;
4809 vl_api_classify_table_ids_reply_t_handler_json
4810 (vl_api_classify_table_ids_reply_t * mp)
4812 vat_main_t *vam = &vat_main;
4813 int i, count = ntohl (mp->count);
4817 vat_json_node_t node;
4819 vat_json_init_object (&node);
4820 for (i = 0; i < count; i++)
4822 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4824 vat_json_print (vam->ofp, &node);
4825 vat_json_free (&node);
4827 vam->retval = ntohl (mp->retval);
4828 vam->result_ready = 1;
4832 vl_api_classify_table_by_interface_reply_t_handler
4833 (vl_api_classify_table_by_interface_reply_t * mp)
4835 vat_main_t *vam = &vat_main;
4838 table_id = ntohl (mp->l2_table_id);
4840 print (vam->ofp, "l2 table id : %d", table_id);
4842 print (vam->ofp, "l2 table id : No input ACL tables configured");
4843 table_id = ntohl (mp->ip4_table_id);
4845 print (vam->ofp, "ip4 table id : %d", table_id);
4847 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4848 table_id = ntohl (mp->ip6_table_id);
4850 print (vam->ofp, "ip6 table id : %d", table_id);
4852 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4853 vam->retval = ntohl (mp->retval);
4854 vam->result_ready = 1;
4858 vl_api_classify_table_by_interface_reply_t_handler_json
4859 (vl_api_classify_table_by_interface_reply_t * mp)
4861 vat_main_t *vam = &vat_main;
4862 vat_json_node_t node;
4864 vat_json_init_object (&node);
4866 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4867 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4868 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4870 vat_json_print (vam->ofp, &node);
4871 vat_json_free (&node);
4873 vam->retval = ntohl (mp->retval);
4874 vam->result_ready = 1;
4877 static void vl_api_policer_add_del_reply_t_handler
4878 (vl_api_policer_add_del_reply_t * mp)
4880 vat_main_t *vam = &vat_main;
4881 i32 retval = ntohl (mp->retval);
4882 if (vam->async_mode)
4884 vam->async_errors += (retval < 0);
4888 vam->retval = retval;
4889 vam->result_ready = 1;
4890 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4892 * Note: this is just barely thread-safe, depends on
4893 * the main thread spinning waiting for an answer...
4895 errmsg ("policer index %d", ntohl (mp->policer_index));
4899 static void vl_api_policer_add_del_reply_t_handler_json
4900 (vl_api_policer_add_del_reply_t * mp)
4902 vat_main_t *vam = &vat_main;
4903 vat_json_node_t node;
4905 vat_json_init_object (&node);
4906 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4907 vat_json_object_add_uint (&node, "policer_index",
4908 ntohl (mp->policer_index));
4910 vat_json_print (vam->ofp, &node);
4911 vat_json_free (&node);
4913 vam->retval = ntohl (mp->retval);
4914 vam->result_ready = 1;
4917 /* Format hex dump. */
4919 format_hex_bytes (u8 * s, va_list * va)
4921 u8 *bytes = va_arg (*va, u8 *);
4922 int n_bytes = va_arg (*va, int);
4925 /* Print short or long form depending on byte count. */
4926 uword short_form = n_bytes <= 32;
4927 u32 indent = format_get_indent (s);
4932 for (i = 0; i < n_bytes; i++)
4934 if (!short_form && (i % 32) == 0)
4935 s = format (s, "%08x: ", i);
4936 s = format (s, "%02x", bytes[i]);
4937 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4938 s = format (s, "\n%U", format_white_space, indent);
4945 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4948 vat_main_t *vam = &vat_main;
4949 i32 retval = ntohl (mp->retval);
4952 print (vam->ofp, "classify table info :");
4953 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4954 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4955 ntohl (mp->miss_next_index));
4956 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4957 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4958 ntohl (mp->match_n_vectors));
4959 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4960 ntohl (mp->mask_length));
4962 vam->retval = retval;
4963 vam->result_ready = 1;
4967 vl_api_classify_table_info_reply_t_handler_json
4968 (vl_api_classify_table_info_reply_t * mp)
4970 vat_main_t *vam = &vat_main;
4971 vat_json_node_t node;
4973 i32 retval = ntohl (mp->retval);
4976 vat_json_init_object (&node);
4978 vat_json_object_add_int (&node, "sessions",
4979 ntohl (mp->active_sessions));
4980 vat_json_object_add_int (&node, "nexttbl",
4981 ntohl (mp->next_table_index));
4982 vat_json_object_add_int (&node, "nextnode",
4983 ntohl (mp->miss_next_index));
4984 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4985 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4986 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4987 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4988 ntohl (mp->mask_length), 0);
4989 vat_json_object_add_string_copy (&node, "mask", s);
4991 vat_json_print (vam->ofp, &node);
4992 vat_json_free (&node);
4994 vam->retval = ntohl (mp->retval);
4995 vam->result_ready = 1;
4999 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5002 vat_main_t *vam = &vat_main;
5004 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5005 ntohl (mp->hit_next_index), ntohl (mp->advance),
5006 ntohl (mp->opaque_index));
5007 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5008 ntohl (mp->match_length));
5012 vl_api_classify_session_details_t_handler_json
5013 (vl_api_classify_session_details_t * mp)
5015 vat_main_t *vam = &vat_main;
5016 vat_json_node_t *node = NULL;
5018 if (VAT_JSON_ARRAY != vam->json_tree.type)
5020 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5021 vat_json_init_array (&vam->json_tree);
5023 node = vat_json_array_add (&vam->json_tree);
5025 vat_json_init_object (node);
5026 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5027 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5028 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5030 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5032 vat_json_object_add_string_copy (node, "match", s);
5035 static void vl_api_pg_create_interface_reply_t_handler
5036 (vl_api_pg_create_interface_reply_t * mp)
5038 vat_main_t *vam = &vat_main;
5040 vam->retval = ntohl (mp->retval);
5041 vam->result_ready = 1;
5044 static void vl_api_pg_create_interface_reply_t_handler_json
5045 (vl_api_pg_create_interface_reply_t * mp)
5047 vat_main_t *vam = &vat_main;
5048 vat_json_node_t node;
5050 i32 retval = ntohl (mp->retval);
5053 vat_json_init_object (&node);
5055 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5057 vat_json_print (vam->ofp, &node);
5058 vat_json_free (&node);
5060 vam->retval = ntohl (mp->retval);
5061 vam->result_ready = 1;
5064 static void vl_api_policer_classify_details_t_handler
5065 (vl_api_policer_classify_details_t * mp)
5067 vat_main_t *vam = &vat_main;
5069 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5070 ntohl (mp->table_index));
5073 static void vl_api_policer_classify_details_t_handler_json
5074 (vl_api_policer_classify_details_t * mp)
5076 vat_main_t *vam = &vat_main;
5077 vat_json_node_t *node;
5079 if (VAT_JSON_ARRAY != vam->json_tree.type)
5081 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5082 vat_json_init_array (&vam->json_tree);
5084 node = vat_json_array_add (&vam->json_tree);
5086 vat_json_init_object (node);
5087 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5088 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5091 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5092 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5094 vat_main_t *vam = &vat_main;
5095 i32 retval = ntohl (mp->retval);
5096 if (vam->async_mode)
5098 vam->async_errors += (retval < 0);
5102 vam->retval = retval;
5103 vam->sw_if_index = ntohl (mp->sw_if_index);
5104 vam->result_ready = 1;
5106 vam->regenerate_interface_table = 1;
5109 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5110 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5112 vat_main_t *vam = &vat_main;
5113 vat_json_node_t node;
5115 vat_json_init_object (&node);
5116 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5117 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5119 vat_json_print (vam->ofp, &node);
5120 vat_json_free (&node);
5122 vam->retval = ntohl (mp->retval);
5123 vam->result_ready = 1;
5126 static void vl_api_flow_classify_details_t_handler
5127 (vl_api_flow_classify_details_t * mp)
5129 vat_main_t *vam = &vat_main;
5131 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5132 ntohl (mp->table_index));
5135 static void vl_api_flow_classify_details_t_handler_json
5136 (vl_api_flow_classify_details_t * mp)
5138 vat_main_t *vam = &vat_main;
5139 vat_json_node_t *node;
5141 if (VAT_JSON_ARRAY != vam->json_tree.type)
5143 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5144 vat_json_init_array (&vam->json_tree);
5146 node = vat_json_array_add (&vam->json_tree);
5148 vat_json_init_object (node);
5149 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5150 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5153 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5154 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5155 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5156 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5157 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5158 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5159 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5160 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5161 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5162 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5165 * Generate boilerplate reply handlers, which
5166 * dig the return value out of the xxx_reply_t API message,
5167 * stick it into vam->retval, and set vam->result_ready
5169 * Could also do this by pointing N message decode slots at
5170 * a single function, but that could break in subtle ways.
5173 #define foreach_standard_reply_retval_handler \
5174 _(sw_interface_set_flags_reply) \
5175 _(sw_interface_add_del_address_reply) \
5176 _(sw_interface_set_rx_mode_reply) \
5177 _(sw_interface_set_rx_placement_reply) \
5178 _(sw_interface_set_table_reply) \
5179 _(sw_interface_set_mpls_enable_reply) \
5180 _(sw_interface_set_vpath_reply) \
5181 _(sw_interface_set_vxlan_bypass_reply) \
5182 _(sw_interface_set_geneve_bypass_reply) \
5183 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5184 _(sw_interface_set_l2_bridge_reply) \
5185 _(bridge_domain_add_del_reply) \
5186 _(sw_interface_set_l2_xconnect_reply) \
5187 _(l2fib_add_del_reply) \
5188 _(l2fib_flush_int_reply) \
5189 _(l2fib_flush_bd_reply) \
5190 _(ip_add_del_route_reply) \
5191 _(ip_table_add_del_reply) \
5192 _(ip_mroute_add_del_reply) \
5193 _(mpls_route_add_del_reply) \
5194 _(mpls_table_add_del_reply) \
5195 _(mpls_ip_bind_unbind_reply) \
5196 _(bier_route_add_del_reply) \
5197 _(bier_table_add_del_reply) \
5198 _(proxy_arp_add_del_reply) \
5199 _(proxy_arp_intfc_enable_disable_reply) \
5200 _(sw_interface_set_unnumbered_reply) \
5201 _(ip_neighbor_add_del_reply) \
5202 _(oam_add_del_reply) \
5203 _(reset_fib_reply) \
5204 _(dhcp_proxy_config_reply) \
5205 _(dhcp_proxy_set_vss_reply) \
5206 _(dhcp_client_config_reply) \
5207 _(set_ip_flow_hash_reply) \
5208 _(sw_interface_ip6_enable_disable_reply) \
5209 _(ip6nd_proxy_add_del_reply) \
5210 _(sw_interface_ip6nd_ra_prefix_reply) \
5211 _(sw_interface_ip6nd_ra_config_reply) \
5212 _(set_arp_neighbor_limit_reply) \
5213 _(l2_patch_add_del_reply) \
5214 _(sr_mpls_policy_add_reply) \
5215 _(sr_mpls_policy_mod_reply) \
5216 _(sr_mpls_policy_del_reply) \
5217 _(sr_policy_add_reply) \
5218 _(sr_policy_mod_reply) \
5219 _(sr_policy_del_reply) \
5220 _(sr_localsid_add_del_reply) \
5221 _(sr_steering_add_del_reply) \
5222 _(classify_add_del_session_reply) \
5223 _(classify_set_interface_ip_table_reply) \
5224 _(classify_set_interface_l2_tables_reply) \
5225 _(l2tpv3_set_tunnel_cookies_reply) \
5226 _(l2tpv3_interface_enable_disable_reply) \
5227 _(l2tpv3_set_lookup_key_reply) \
5228 _(l2_fib_clear_table_reply) \
5229 _(l2_interface_efp_filter_reply) \
5230 _(l2_interface_vlan_tag_rewrite_reply) \
5231 _(modify_vhost_user_if_reply) \
5232 _(delete_vhost_user_if_reply) \
5233 _(ip_probe_neighbor_reply) \
5234 _(ip_scan_neighbor_enable_disable_reply) \
5235 _(want_ip4_arp_events_reply) \
5236 _(want_ip6_nd_events_reply) \
5237 _(want_l2_macs_events_reply) \
5238 _(input_acl_set_interface_reply) \
5239 _(ipsec_spd_add_del_reply) \
5240 _(ipsec_interface_add_del_spd_reply) \
5241 _(ipsec_spd_add_del_entry_reply) \
5242 _(ipsec_sad_add_del_entry_reply) \
5243 _(ipsec_sa_set_key_reply) \
5244 _(ipsec_tunnel_if_add_del_reply) \
5245 _(ipsec_tunnel_if_set_key_reply) \
5246 _(ipsec_tunnel_if_set_sa_reply) \
5247 _(ikev2_profile_add_del_reply) \
5248 _(ikev2_profile_set_auth_reply) \
5249 _(ikev2_profile_set_id_reply) \
5250 _(ikev2_profile_set_ts_reply) \
5251 _(ikev2_set_local_key_reply) \
5252 _(ikev2_set_responder_reply) \
5253 _(ikev2_set_ike_transforms_reply) \
5254 _(ikev2_set_esp_transforms_reply) \
5255 _(ikev2_set_sa_lifetime_reply) \
5256 _(ikev2_initiate_sa_init_reply) \
5257 _(ikev2_initiate_del_ike_sa_reply) \
5258 _(ikev2_initiate_del_child_sa_reply) \
5259 _(ikev2_initiate_rekey_child_sa_reply) \
5260 _(delete_loopback_reply) \
5261 _(bd_ip_mac_add_del_reply) \
5262 _(bd_ip_mac_flush_reply) \
5263 _(want_interface_events_reply) \
5264 _(cop_interface_enable_disable_reply) \
5265 _(cop_whitelist_enable_disable_reply) \
5266 _(sw_interface_clear_stats_reply) \
5267 _(ioam_enable_reply) \
5268 _(ioam_disable_reply) \
5269 _(one_add_del_locator_reply) \
5270 _(one_add_del_local_eid_reply) \
5271 _(one_add_del_remote_mapping_reply) \
5272 _(one_add_del_adjacency_reply) \
5273 _(one_add_del_map_resolver_reply) \
5274 _(one_add_del_map_server_reply) \
5275 _(one_enable_disable_reply) \
5276 _(one_rloc_probe_enable_disable_reply) \
5277 _(one_map_register_enable_disable_reply) \
5278 _(one_map_register_set_ttl_reply) \
5279 _(one_set_transport_protocol_reply) \
5280 _(one_map_register_fallback_threshold_reply) \
5281 _(one_pitr_set_locator_set_reply) \
5282 _(one_map_request_mode_reply) \
5283 _(one_add_del_map_request_itr_rlocs_reply) \
5284 _(one_eid_table_add_del_map_reply) \
5285 _(one_use_petr_reply) \
5286 _(one_stats_enable_disable_reply) \
5287 _(one_add_del_l2_arp_entry_reply) \
5288 _(one_add_del_ndp_entry_reply) \
5289 _(one_stats_flush_reply) \
5290 _(one_enable_disable_xtr_mode_reply) \
5291 _(one_enable_disable_pitr_mode_reply) \
5292 _(one_enable_disable_petr_mode_reply) \
5293 _(gpe_enable_disable_reply) \
5294 _(gpe_set_encap_mode_reply) \
5295 _(gpe_add_del_iface_reply) \
5296 _(gpe_add_del_native_fwd_rpath_reply) \
5297 _(af_packet_delete_reply) \
5298 _(policer_classify_set_interface_reply) \
5299 _(netmap_create_reply) \
5300 _(netmap_delete_reply) \
5301 _(set_ipfix_exporter_reply) \
5302 _(set_ipfix_classify_stream_reply) \
5303 _(ipfix_classify_table_add_del_reply) \
5304 _(flow_classify_set_interface_reply) \
5305 _(sw_interface_span_enable_disable_reply) \
5306 _(pg_capture_reply) \
5307 _(pg_enable_disable_reply) \
5308 _(ip_source_and_port_range_check_add_del_reply) \
5309 _(ip_source_and_port_range_check_interface_add_del_reply)\
5310 _(delete_subif_reply) \
5311 _(l2_interface_pbb_tag_rewrite_reply) \
5313 _(feature_enable_disable_reply) \
5314 _(sw_interface_tag_add_del_reply) \
5315 _(hw_interface_set_mtu_reply) \
5316 _(p2p_ethernet_add_reply) \
5317 _(p2p_ethernet_del_reply) \
5318 _(lldp_config_reply) \
5319 _(sw_interface_set_lldp_reply) \
5320 _(tcp_configure_src_addresses_reply) \
5321 _(dns_enable_disable_reply) \
5322 _(dns_name_server_add_del_reply) \
5323 _(session_rule_add_del_reply) \
5324 _(ip_container_proxy_add_del_reply) \
5325 _(output_acl_set_interface_reply) \
5326 _(qos_record_enable_disable_reply)
5329 static void vl_api_##n##_t_handler \
5330 (vl_api_##n##_t * mp) \
5332 vat_main_t * vam = &vat_main; \
5333 i32 retval = ntohl(mp->retval); \
5334 if (vam->async_mode) { \
5335 vam->async_errors += (retval < 0); \
5337 vam->retval = retval; \
5338 vam->result_ready = 1; \
5341 foreach_standard_reply_retval_handler;
5345 static void vl_api_##n##_t_handler_json \
5346 (vl_api_##n##_t * mp) \
5348 vat_main_t * vam = &vat_main; \
5349 vat_json_node_t node; \
5350 vat_json_init_object(&node); \
5351 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5352 vat_json_print(vam->ofp, &node); \
5353 vam->retval = ntohl(mp->retval); \
5354 vam->result_ready = 1; \
5356 foreach_standard_reply_retval_handler;
5360 * Table of message reply handlers, must include boilerplate handlers
5364 #define foreach_vpe_api_reply_msg \
5365 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5366 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5367 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5368 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5369 _(CONTROL_PING_REPLY, control_ping_reply) \
5370 _(CLI_REPLY, cli_reply) \
5371 _(CLI_INBAND_REPLY, cli_inband_reply) \
5372 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5373 sw_interface_add_del_address_reply) \
5374 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5375 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5376 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5377 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5378 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5379 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5380 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5381 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5382 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5383 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5384 sw_interface_set_l2_xconnect_reply) \
5385 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5386 sw_interface_set_l2_bridge_reply) \
5387 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5388 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5389 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5390 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5391 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5392 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5393 _(L2_FLAGS_REPLY, l2_flags_reply) \
5394 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5395 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5396 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5397 _(TAP_DELETE_REPLY, tap_delete_reply) \
5398 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5399 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5400 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5401 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5402 _(BOND_CREATE_REPLY, bond_create_reply) \
5403 _(BOND_DELETE_REPLY, bond_delete_reply) \
5404 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5405 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5406 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5407 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5408 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5409 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5410 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5411 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5412 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5413 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5414 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5415 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5416 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5417 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5418 proxy_arp_intfc_enable_disable_reply) \
5419 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5420 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5421 sw_interface_set_unnumbered_reply) \
5422 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5423 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5424 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5425 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5426 _(RESET_FIB_REPLY, reset_fib_reply) \
5427 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5428 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5429 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5430 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5431 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5432 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5433 sw_interface_ip6_enable_disable_reply) \
5434 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5435 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5436 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5437 sw_interface_ip6nd_ra_prefix_reply) \
5438 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5439 sw_interface_ip6nd_ra_config_reply) \
5440 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5441 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5442 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5443 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5444 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5445 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5446 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5447 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5448 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5449 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5450 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5451 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5452 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5453 classify_set_interface_ip_table_reply) \
5454 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5455 classify_set_interface_l2_tables_reply) \
5456 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5457 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5458 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5459 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5460 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5461 l2tpv3_interface_enable_disable_reply) \
5462 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5463 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5464 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5465 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5466 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5467 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5468 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5469 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5470 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5471 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5472 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5473 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5474 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5475 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5476 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5477 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5478 _(SHOW_VERSION_REPLY, show_version_reply) \
5479 _(SHOW_THREADS_REPLY, show_threads_reply) \
5480 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5481 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5482 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5483 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5484 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5485 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5486 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5487 _(IP4_ARP_EVENT, ip4_arp_event) \
5488 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5489 _(IP6_ND_EVENT, ip6_nd_event) \
5490 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5491 _(L2_MACS_EVENT, l2_macs_event) \
5492 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5493 _(IP_ADDRESS_DETAILS, ip_address_details) \
5494 _(IP_DETAILS, ip_details) \
5495 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5496 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5497 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5498 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5499 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5500 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5501 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5502 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5503 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5504 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5505 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5506 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5507 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5508 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5509 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5510 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5511 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5512 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5513 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5514 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5515 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5516 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5517 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5518 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5519 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5520 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5521 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5522 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5523 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5524 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5525 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5526 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5527 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5528 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5529 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5530 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5531 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5532 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5533 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5534 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5535 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5536 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5537 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5538 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5539 one_map_register_enable_disable_reply) \
5540 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5541 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5542 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5543 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5544 one_map_register_fallback_threshold_reply) \
5545 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5546 one_rloc_probe_enable_disable_reply) \
5547 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5548 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5549 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5550 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5551 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5552 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5553 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5554 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5555 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5556 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5557 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5558 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5559 _(ONE_STATS_DETAILS, one_stats_details) \
5560 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5561 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5562 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5563 show_one_stats_enable_disable_reply) \
5564 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5565 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5566 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5567 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5568 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5569 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5570 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5571 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5572 one_enable_disable_pitr_mode_reply) \
5573 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5574 one_enable_disable_petr_mode_reply) \
5575 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5576 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5577 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5578 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5579 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5580 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5581 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5582 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5583 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5584 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5585 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5586 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5587 gpe_add_del_native_fwd_rpath_reply) \
5588 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5589 gpe_fwd_entry_path_details) \
5590 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5591 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5592 one_add_del_map_request_itr_rlocs_reply) \
5593 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5594 one_get_map_request_itr_rlocs_reply) \
5595 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5596 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5597 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5598 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5599 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5600 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5601 show_one_map_register_state_reply) \
5602 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5603 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5604 show_one_map_register_fallback_threshold_reply) \
5605 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5606 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5607 _(AF_PACKET_DETAILS, af_packet_details) \
5608 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5609 _(POLICER_DETAILS, policer_details) \
5610 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5611 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5612 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5613 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5614 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5615 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5616 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5617 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5618 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5619 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5620 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5621 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5622 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5623 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5624 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5625 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5626 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5627 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5628 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5629 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5630 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5631 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5632 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5633 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5634 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5635 ip_source_and_port_range_check_add_del_reply) \
5636 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5637 ip_source_and_port_range_check_interface_add_del_reply) \
5638 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5639 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5640 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5641 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5642 _(SET_PUNT_REPLY, set_punt_reply) \
5643 _(IP_FIB_DETAILS, ip_fib_details) \
5644 _(IP6_FIB_DETAILS, ip6_fib_details) \
5645 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5646 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5647 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5648 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5649 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5650 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5651 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5652 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5653 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5654 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5655 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5656 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5657 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5658 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5659 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5660 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5661 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5662 _(SESSION_RULES_DETAILS, session_rules_details) \
5663 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5664 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5665 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5667 #define foreach_standalone_reply_msg \
5668 _(SW_INTERFACE_EVENT, sw_interface_event)
5676 #define STR_VTR_OP_CASE(op) \
5677 case L2_VTR_ ## op: \
5681 str_vtr_op (u32 vtr_op)
5685 STR_VTR_OP_CASE (DISABLED);
5686 STR_VTR_OP_CASE (PUSH_1);
5687 STR_VTR_OP_CASE (PUSH_2);
5688 STR_VTR_OP_CASE (POP_1);
5689 STR_VTR_OP_CASE (POP_2);
5690 STR_VTR_OP_CASE (TRANSLATE_1_1);
5691 STR_VTR_OP_CASE (TRANSLATE_1_2);
5692 STR_VTR_OP_CASE (TRANSLATE_2_1);
5693 STR_VTR_OP_CASE (TRANSLATE_2_2);
5700 dump_sub_interface_table (vat_main_t * vam)
5702 const sw_interface_subif_t *sub = NULL;
5704 if (vam->json_output)
5707 ("JSON output supported only for VPE API calls and dump_stats_table");
5712 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5713 "Interface", "sw_if_index",
5714 "sub id", "dot1ad", "tags", "outer id",
5715 "inner id", "exact", "default", "outer any", "inner any");
5717 vec_foreach (sub, vam->sw_if_subif_table)
5720 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5721 sub->interface_name,
5723 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5724 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5725 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5726 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5727 if (sub->vtr_op != L2_VTR_DISABLED)
5730 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5731 "tag1: %d tag2: %d ]",
5732 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5733 sub->vtr_tag1, sub->vtr_tag2);
5741 name_sort_cmp (void *a1, void *a2)
5743 name_sort_t *n1 = a1;
5744 name_sort_t *n2 = a2;
5746 return strcmp ((char *) n1->name, (char *) n2->name);
5750 dump_interface_table (vat_main_t * vam)
5753 name_sort_t *nses = 0, *ns;
5755 if (vam->json_output)
5758 ("JSON output supported only for VPE API calls and dump_stats_table");
5763 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5765 vec_add2 (nses, ns, 1);
5766 ns->name = (u8 *)(p->key);
5767 ns->value = (u32) p->value[0];
5771 vec_sort_with_function (nses, name_sort_cmp);
5773 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5774 vec_foreach (ns, nses)
5776 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5783 dump_ip_table (vat_main_t * vam, int is_ipv6)
5785 const ip_details_t *det = NULL;
5786 const ip_address_details_t *address = NULL;
5789 print (vam->ofp, "%-12s", "sw_if_index");
5791 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5798 print (vam->ofp, "%-12d", i);
5799 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5804 vec_foreach (address, det->addr)
5808 is_ipv6 ? format_ip6_address : format_ip4_address,
5809 address->ip, address->prefix_length);
5817 dump_ipv4_table (vat_main_t * vam)
5819 if (vam->json_output)
5822 ("JSON output supported only for VPE API calls and dump_stats_table");
5826 return dump_ip_table (vam, 0);
5830 dump_ipv6_table (vat_main_t * vam)
5832 if (vam->json_output)
5835 ("JSON output supported only for VPE API calls and dump_stats_table");
5839 return dump_ip_table (vam, 1);
5843 * Pass CLI buffers directly in the CLI_INBAND API message,
5844 * instead of an additional shared memory area.
5847 exec_inband (vat_main_t * vam)
5849 vl_api_cli_inband_t *mp;
5850 unformat_input_t *i = vam->input;
5853 if (vec_len (i->buffer) == 0)
5856 if (vam->exec_mode == 0 && unformat (i, "mode"))
5861 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5868 * In order for the CLI command to work, it
5869 * must be a vector ending in \n, not a C-string ending
5872 u32 len = vec_len (vam->input->buffer);
5873 M2 (CLI_INBAND, mp, len);
5874 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5878 /* json responses may or may not include a useful reply... */
5879 if (vec_len (vam->cmd_reply))
5880 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5885 exec (vat_main_t * vam)
5887 return exec_inband (vam);
5891 api_create_loopback (vat_main_t * vam)
5893 unformat_input_t *i = vam->input;
5894 vl_api_create_loopback_t *mp;
5895 vl_api_create_loopback_instance_t *mp_lbi;
5898 u8 is_specified = 0;
5899 u32 user_instance = 0;
5902 clib_memset (mac_address, 0, sizeof (mac_address));
5904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5906 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5908 if (unformat (i, "instance %d", &user_instance))
5916 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5917 mp_lbi->is_specified = is_specified;
5919 mp_lbi->user_instance = htonl (user_instance);
5921 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5926 /* Construct the API message */
5927 M (CREATE_LOOPBACK, mp);
5929 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5938 api_delete_loopback (vat_main_t * vam)
5940 unformat_input_t *i = vam->input;
5941 vl_api_delete_loopback_t *mp;
5942 u32 sw_if_index = ~0;
5945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5947 if (unformat (i, "sw_if_index %d", &sw_if_index))
5953 if (sw_if_index == ~0)
5955 errmsg ("missing sw_if_index");
5959 /* Construct the API message */
5960 M (DELETE_LOOPBACK, mp);
5961 mp->sw_if_index = ntohl (sw_if_index);
5969 api_want_interface_events (vat_main_t * vam)
5971 unformat_input_t *i = vam->input;
5972 vl_api_want_interface_events_t *mp;
5976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5978 if (unformat (i, "enable"))
5980 else if (unformat (i, "disable"))
5988 errmsg ("missing enable|disable");
5992 M (WANT_INTERFACE_EVENTS, mp);
5993 mp->enable_disable = enable;
5995 vam->interface_event_display = enable;
6003 /* Note: non-static, called once to set up the initial intfc table */
6005 api_sw_interface_dump (vat_main_t * vam)
6007 vl_api_sw_interface_dump_t *mp;
6008 vl_api_control_ping_t *mp_ping;
6010 name_sort_t *nses = 0, *ns;
6011 sw_interface_subif_t *sub = NULL;
6014 /* Toss the old name table */
6016 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6018 vec_add2 (nses, ns, 1);
6019 ns->name = (u8 *)(p->key);
6020 ns->value = (u32) p->value[0];
6024 hash_free (vam->sw_if_index_by_interface_name);
6026 vec_foreach (ns, nses) vec_free (ns->name);
6030 vec_foreach (sub, vam->sw_if_subif_table)
6032 vec_free (sub->interface_name);
6034 vec_free (vam->sw_if_subif_table);
6036 /* recreate the interface name hash table */
6037 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6040 * Ask for all interface names. Otherwise, the epic catalog of
6041 * name filters becomes ridiculously long, and vat ends up needing
6042 * to be taught about new interface types.
6044 M (SW_INTERFACE_DUMP, mp);
6047 /* Use a control ping for synchronization */
6048 MPING (CONTROL_PING, mp_ping);
6056 api_sw_interface_set_flags (vat_main_t * vam)
6058 unformat_input_t *i = vam->input;
6059 vl_api_sw_interface_set_flags_t *mp;
6061 u8 sw_if_index_set = 0;
6065 /* Parse args required to build the message */
6066 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6068 if (unformat (i, "admin-up"))
6070 else if (unformat (i, "admin-down"))
6073 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6074 sw_if_index_set = 1;
6075 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6076 sw_if_index_set = 1;
6081 if (sw_if_index_set == 0)
6083 errmsg ("missing interface name or sw_if_index");
6087 /* Construct the API message */
6088 M (SW_INTERFACE_SET_FLAGS, mp);
6089 mp->sw_if_index = ntohl (sw_if_index);
6090 mp->admin_up_down = admin_up;
6095 /* Wait for a reply, return the good/bad news... */
6101 api_sw_interface_set_rx_mode (vat_main_t * vam)
6103 unformat_input_t *i = vam->input;
6104 vl_api_sw_interface_set_rx_mode_t *mp;
6106 u8 sw_if_index_set = 0;
6108 u8 queue_id_valid = 0;
6110 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6112 /* Parse args required to build the message */
6113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6115 if (unformat (i, "queue %d", &queue_id))
6117 else if (unformat (i, "polling"))
6118 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6119 else if (unformat (i, "interrupt"))
6120 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6121 else if (unformat (i, "adaptive"))
6122 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6124 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6125 sw_if_index_set = 1;
6126 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6127 sw_if_index_set = 1;
6132 if (sw_if_index_set == 0)
6134 errmsg ("missing interface name or sw_if_index");
6137 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6139 errmsg ("missing rx-mode");
6143 /* Construct the API message */
6144 M (SW_INTERFACE_SET_RX_MODE, mp);
6145 mp->sw_if_index = ntohl (sw_if_index);
6147 mp->queue_id_valid = queue_id_valid;
6148 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6153 /* Wait for a reply, return the good/bad news... */
6159 api_sw_interface_set_rx_placement (vat_main_t * vam)
6161 unformat_input_t *i = vam->input;
6162 vl_api_sw_interface_set_rx_placement_t *mp;
6164 u8 sw_if_index_set = 0;
6167 u32 queue_id, thread_index;
6169 /* Parse args required to build the message */
6170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6172 if (unformat (i, "queue %d", &queue_id))
6174 else if (unformat (i, "main"))
6176 else if (unformat (i, "worker %d", &thread_index))
6179 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6180 sw_if_index_set = 1;
6181 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6182 sw_if_index_set = 1;
6187 if (sw_if_index_set == 0)
6189 errmsg ("missing interface name or sw_if_index");
6195 /* Construct the API message */
6196 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6197 mp->sw_if_index = ntohl (sw_if_index);
6198 mp->worker_id = ntohl (thread_index);
6199 mp->queue_id = ntohl (queue_id);
6200 mp->is_main = is_main;
6204 /* Wait for a reply, return the good/bad news... */
6209 static void vl_api_sw_interface_rx_placement_details_t_handler
6210 (vl_api_sw_interface_rx_placement_details_t * mp)
6212 vat_main_t *vam = &vat_main;
6213 u32 worker_id = ntohl (mp->worker_id);
6216 "\n%-11d %-11s %-6d %-5d %-9s",
6217 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6218 worker_id, ntohl (mp->queue_id),
6220 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6223 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6224 (vl_api_sw_interface_rx_placement_details_t * mp)
6226 vat_main_t *vam = &vat_main;
6227 vat_json_node_t *node = NULL;
6229 if (VAT_JSON_ARRAY != vam->json_tree.type)
6231 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6232 vat_json_init_array (&vam->json_tree);
6234 node = vat_json_array_add (&vam->json_tree);
6236 vat_json_init_object (node);
6237 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6238 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6239 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6240 vat_json_object_add_uint (node, "mode", mp->mode);
6244 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6246 unformat_input_t *i = vam->input;
6247 vl_api_sw_interface_rx_placement_dump_t *mp;
6248 vl_api_control_ping_t *mp_ping;
6251 u8 sw_if_index_set = 0;
6253 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6255 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6257 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6264 "\n%-11s %-11s %-6s %-5s %-4s",
6265 "sw_if_index", "main/worker", "thread", "queue", "mode");
6267 /* Dump Interface rx placement */
6268 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6270 if (sw_if_index_set)
6271 mp->sw_if_index = htonl (sw_if_index);
6273 mp->sw_if_index = ~0;
6277 /* Use a control ping for synchronization */
6278 MPING (CONTROL_PING, mp_ping);
6286 api_sw_interface_clear_stats (vat_main_t * vam)
6288 unformat_input_t *i = vam->input;
6289 vl_api_sw_interface_clear_stats_t *mp;
6291 u8 sw_if_index_set = 0;
6294 /* Parse args required to build the message */
6295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6297 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6298 sw_if_index_set = 1;
6299 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6300 sw_if_index_set = 1;
6305 /* Construct the API message */
6306 M (SW_INTERFACE_CLEAR_STATS, mp);
6308 if (sw_if_index_set == 1)
6309 mp->sw_if_index = ntohl (sw_if_index);
6311 mp->sw_if_index = ~0;
6316 /* Wait for a reply, return the good/bad news... */
6322 api_sw_interface_add_del_address (vat_main_t * vam)
6324 unformat_input_t *i = vam->input;
6325 vl_api_sw_interface_add_del_address_t *mp;
6327 u8 sw_if_index_set = 0;
6328 u8 is_add = 1, del_all = 0;
6329 u32 address_length = 0;
6330 u8 v4_address_set = 0;
6331 u8 v6_address_set = 0;
6332 ip4_address_t v4address;
6333 ip6_address_t v6address;
6336 /* Parse args required to build the message */
6337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6339 if (unformat (i, "del-all"))
6341 else if (unformat (i, "del"))
6344 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6345 sw_if_index_set = 1;
6346 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6347 sw_if_index_set = 1;
6348 else if (unformat (i, "%U/%d",
6349 unformat_ip4_address, &v4address, &address_length))
6351 else if (unformat (i, "%U/%d",
6352 unformat_ip6_address, &v6address, &address_length))
6358 if (sw_if_index_set == 0)
6360 errmsg ("missing interface name or sw_if_index");
6363 if (v4_address_set && v6_address_set)
6365 errmsg ("both v4 and v6 addresses set");
6368 if (!v4_address_set && !v6_address_set && !del_all)
6370 errmsg ("no addresses set");
6374 /* Construct the API message */
6375 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6377 mp->sw_if_index = ntohl (sw_if_index);
6378 mp->is_add = is_add;
6379 mp->del_all = del_all;
6383 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6387 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6389 mp->address_length = address_length;
6394 /* Wait for a reply, return good/bad news */
6400 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6402 unformat_input_t *i = vam->input;
6403 vl_api_sw_interface_set_mpls_enable_t *mp;
6405 u8 sw_if_index_set = 0;
6409 /* Parse args required to build the message */
6410 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6412 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6413 sw_if_index_set = 1;
6414 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6415 sw_if_index_set = 1;
6416 else if (unformat (i, "disable"))
6418 else if (unformat (i, "dis"))
6424 if (sw_if_index_set == 0)
6426 errmsg ("missing interface name or sw_if_index");
6430 /* Construct the API message */
6431 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6433 mp->sw_if_index = ntohl (sw_if_index);
6434 mp->enable = enable;
6439 /* Wait for a reply... */
6445 api_sw_interface_set_table (vat_main_t * vam)
6447 unformat_input_t *i = vam->input;
6448 vl_api_sw_interface_set_table_t *mp;
6449 u32 sw_if_index, vrf_id = 0;
6450 u8 sw_if_index_set = 0;
6454 /* Parse args required to build the message */
6455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6457 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6458 sw_if_index_set = 1;
6459 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6460 sw_if_index_set = 1;
6461 else if (unformat (i, "vrf %d", &vrf_id))
6463 else if (unformat (i, "ipv6"))
6469 if (sw_if_index_set == 0)
6471 errmsg ("missing interface name or sw_if_index");
6475 /* Construct the API message */
6476 M (SW_INTERFACE_SET_TABLE, mp);
6478 mp->sw_if_index = ntohl (sw_if_index);
6479 mp->is_ipv6 = is_ipv6;
6480 mp->vrf_id = ntohl (vrf_id);
6485 /* Wait for a reply... */
6490 static void vl_api_sw_interface_get_table_reply_t_handler
6491 (vl_api_sw_interface_get_table_reply_t * mp)
6493 vat_main_t *vam = &vat_main;
6495 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6497 vam->retval = ntohl (mp->retval);
6498 vam->result_ready = 1;
6502 static void vl_api_sw_interface_get_table_reply_t_handler_json
6503 (vl_api_sw_interface_get_table_reply_t * mp)
6505 vat_main_t *vam = &vat_main;
6506 vat_json_node_t node;
6508 vat_json_init_object (&node);
6509 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6510 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6512 vat_json_print (vam->ofp, &node);
6513 vat_json_free (&node);
6515 vam->retval = ntohl (mp->retval);
6516 vam->result_ready = 1;
6520 api_sw_interface_get_table (vat_main_t * vam)
6522 unformat_input_t *i = vam->input;
6523 vl_api_sw_interface_get_table_t *mp;
6525 u8 sw_if_index_set = 0;
6529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6531 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6532 sw_if_index_set = 1;
6533 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6534 sw_if_index_set = 1;
6535 else if (unformat (i, "ipv6"))
6541 if (sw_if_index_set == 0)
6543 errmsg ("missing interface name or sw_if_index");
6547 M (SW_INTERFACE_GET_TABLE, mp);
6548 mp->sw_if_index = htonl (sw_if_index);
6549 mp->is_ipv6 = is_ipv6;
6557 api_sw_interface_set_vpath (vat_main_t * vam)
6559 unformat_input_t *i = vam->input;
6560 vl_api_sw_interface_set_vpath_t *mp;
6561 u32 sw_if_index = 0;
6562 u8 sw_if_index_set = 0;
6566 /* Parse args required to build the message */
6567 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6569 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6570 sw_if_index_set = 1;
6571 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6572 sw_if_index_set = 1;
6573 else if (unformat (i, "enable"))
6575 else if (unformat (i, "disable"))
6581 if (sw_if_index_set == 0)
6583 errmsg ("missing interface name or sw_if_index");
6587 /* Construct the API message */
6588 M (SW_INTERFACE_SET_VPATH, mp);
6590 mp->sw_if_index = ntohl (sw_if_index);
6591 mp->enable = is_enable;
6596 /* Wait for a reply... */
6602 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6604 unformat_input_t *i = vam->input;
6605 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6606 u32 sw_if_index = 0;
6607 u8 sw_if_index_set = 0;
6612 /* Parse args required to build the message */
6613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6615 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6616 sw_if_index_set = 1;
6617 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6618 sw_if_index_set = 1;
6619 else if (unformat (i, "enable"))
6621 else if (unformat (i, "disable"))
6623 else if (unformat (i, "ip4"))
6625 else if (unformat (i, "ip6"))
6631 if (sw_if_index_set == 0)
6633 errmsg ("missing interface name or sw_if_index");
6637 /* Construct the API message */
6638 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6640 mp->sw_if_index = ntohl (sw_if_index);
6641 mp->enable = is_enable;
6642 mp->is_ipv6 = is_ipv6;
6647 /* Wait for a reply... */
6653 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6655 unformat_input_t *i = vam->input;
6656 vl_api_sw_interface_set_geneve_bypass_t *mp;
6657 u32 sw_if_index = 0;
6658 u8 sw_if_index_set = 0;
6663 /* Parse args required to build the message */
6664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6666 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6667 sw_if_index_set = 1;
6668 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6669 sw_if_index_set = 1;
6670 else if (unformat (i, "enable"))
6672 else if (unformat (i, "disable"))
6674 else if (unformat (i, "ip4"))
6676 else if (unformat (i, "ip6"))
6682 if (sw_if_index_set == 0)
6684 errmsg ("missing interface name or sw_if_index");
6688 /* Construct the API message */
6689 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6691 mp->sw_if_index = ntohl (sw_if_index);
6692 mp->enable = is_enable;
6693 mp->is_ipv6 = is_ipv6;
6698 /* Wait for a reply... */
6704 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6706 unformat_input_t *i = vam->input;
6707 vl_api_sw_interface_set_l2_xconnect_t *mp;
6709 u8 rx_sw_if_index_set = 0;
6711 u8 tx_sw_if_index_set = 0;
6715 /* Parse args required to build the message */
6716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6718 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6719 rx_sw_if_index_set = 1;
6720 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6721 tx_sw_if_index_set = 1;
6722 else if (unformat (i, "rx"))
6724 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6726 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6728 rx_sw_if_index_set = 1;
6733 else if (unformat (i, "tx"))
6735 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6737 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6739 tx_sw_if_index_set = 1;
6744 else if (unformat (i, "enable"))
6746 else if (unformat (i, "disable"))
6752 if (rx_sw_if_index_set == 0)
6754 errmsg ("missing rx interface name or rx_sw_if_index");
6758 if (enable && (tx_sw_if_index_set == 0))
6760 errmsg ("missing tx interface name or tx_sw_if_index");
6764 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6766 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6767 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6768 mp->enable = enable;
6776 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6778 unformat_input_t *i = vam->input;
6779 vl_api_sw_interface_set_l2_bridge_t *mp;
6780 vl_api_l2_port_type_t port_type;
6782 u8 rx_sw_if_index_set = 0;
6789 port_type = L2_API_PORT_TYPE_NORMAL;
6791 /* Parse args required to build the message */
6792 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6794 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6795 rx_sw_if_index_set = 1;
6796 else if (unformat (i, "bd_id %d", &bd_id))
6800 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6801 rx_sw_if_index_set = 1;
6802 else if (unformat (i, "shg %d", &shg))
6804 else if (unformat (i, "bvi"))
6805 port_type = L2_API_PORT_TYPE_BVI;
6806 else if (unformat (i, "uu-fwd"))
6807 port_type = L2_API_PORT_TYPE_UU_FWD;
6808 else if (unformat (i, "enable"))
6810 else if (unformat (i, "disable"))
6816 if (rx_sw_if_index_set == 0)
6818 errmsg ("missing rx interface name or sw_if_index");
6822 if (enable && (bd_id_set == 0))
6824 errmsg ("missing bridge domain");
6828 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6830 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6831 mp->bd_id = ntohl (bd_id);
6833 mp->port_type = ntohl (port_type);
6834 mp->enable = enable;
6842 api_bridge_domain_dump (vat_main_t * vam)
6844 unformat_input_t *i = vam->input;
6845 vl_api_bridge_domain_dump_t *mp;
6846 vl_api_control_ping_t *mp_ping;
6850 /* Parse args required to build the message */
6851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6853 if (unformat (i, "bd_id %d", &bd_id))
6859 M (BRIDGE_DOMAIN_DUMP, mp);
6860 mp->bd_id = ntohl (bd_id);
6863 /* Use a control ping for synchronization */
6864 MPING (CONTROL_PING, mp_ping);
6872 api_bridge_domain_add_del (vat_main_t * vam)
6874 unformat_input_t *i = vam->input;
6875 vl_api_bridge_domain_add_del_t *mp;
6878 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6883 /* Parse args required to build the message */
6884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6886 if (unformat (i, "bd_id %d", &bd_id))
6888 else if (unformat (i, "flood %d", &flood))
6890 else if (unformat (i, "uu-flood %d", &uu_flood))
6892 else if (unformat (i, "forward %d", &forward))
6894 else if (unformat (i, "learn %d", &learn))
6896 else if (unformat (i, "arp-term %d", &arp_term))
6898 else if (unformat (i, "mac-age %d", &mac_age))
6900 else if (unformat (i, "bd-tag %s", &bd_tag))
6902 else if (unformat (i, "del"))
6905 flood = uu_flood = forward = learn = 0;
6913 errmsg ("missing bridge domain");
6920 errmsg ("mac age must be less than 256 ");
6925 if ((bd_tag) && (vec_len (bd_tag) > 63))
6927 errmsg ("bd-tag cannot be longer than 63");
6932 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6934 mp->bd_id = ntohl (bd_id);
6936 mp->uu_flood = uu_flood;
6937 mp->forward = forward;
6939 mp->arp_term = arp_term;
6940 mp->is_add = is_add;
6941 mp->mac_age = (u8) mac_age;
6944 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6945 mp->bd_tag[vec_len (bd_tag)] = 0;
6956 api_l2fib_flush_bd (vat_main_t * vam)
6958 unformat_input_t *i = vam->input;
6959 vl_api_l2fib_flush_bd_t *mp;
6963 /* Parse args required to build the message */
6964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6966 if (unformat (i, "bd_id %d", &bd_id));
6973 errmsg ("missing bridge domain");
6977 M (L2FIB_FLUSH_BD, mp);
6979 mp->bd_id = htonl (bd_id);
6987 api_l2fib_flush_int (vat_main_t * vam)
6989 unformat_input_t *i = vam->input;
6990 vl_api_l2fib_flush_int_t *mp;
6991 u32 sw_if_index = ~0;
6994 /* Parse args required to build the message */
6995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6997 if (unformat (i, "sw_if_index %d", &sw_if_index));
6999 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7004 if (sw_if_index == ~0)
7006 errmsg ("missing interface name or sw_if_index");
7010 M (L2FIB_FLUSH_INT, mp);
7012 mp->sw_if_index = ntohl (sw_if_index);
7020 api_l2fib_add_del (vat_main_t * vam)
7022 unformat_input_t *i = vam->input;
7023 vl_api_l2fib_add_del_t *mp;
7029 u32 sw_if_index = 0;
7030 u8 sw_if_index_set = 0;
7039 /* Parse args required to build the message */
7040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7042 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7044 else if (unformat (i, "bd_id %d", &bd_id))
7046 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7047 sw_if_index_set = 1;
7048 else if (unformat (i, "sw_if"))
7050 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7053 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7054 sw_if_index_set = 1;
7059 else if (unformat (i, "static"))
7061 else if (unformat (i, "filter"))
7066 else if (unformat (i, "bvi"))
7071 else if (unformat (i, "del"))
7073 else if (unformat (i, "count %d", &count))
7081 errmsg ("missing mac address");
7087 errmsg ("missing bridge domain");
7091 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7093 errmsg ("missing interface name or sw_if_index");
7099 /* Turn on async mode */
7100 vam->async_mode = 1;
7101 vam->async_errors = 0;
7102 before = vat_time_now (vam);
7105 for (j = 0; j < count; j++)
7107 M (L2FIB_ADD_DEL, mp);
7109 clib_memcpy (mp->mac, mac, 6);
7110 mp->bd_id = ntohl (bd_id);
7111 mp->is_add = is_add;
7112 mp->sw_if_index = ntohl (sw_if_index);
7116 mp->static_mac = static_mac;
7117 mp->filter_mac = filter_mac;
7118 mp->bvi_mac = bvi_mac;
7120 increment_mac_address (mac);
7127 vl_api_control_ping_t *mp_ping;
7130 /* Shut off async mode */
7131 vam->async_mode = 0;
7133 MPING (CONTROL_PING, mp_ping);
7136 timeout = vat_time_now (vam) + 1.0;
7137 while (vat_time_now (vam) < timeout)
7138 if (vam->result_ready == 1)
7143 if (vam->retval == -99)
7146 if (vam->async_errors > 0)
7148 errmsg ("%d asynchronous errors", vam->async_errors);
7151 vam->async_errors = 0;
7152 after = vat_time_now (vam);
7154 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7155 count, after - before, count / (after - before));
7161 /* Wait for a reply... */
7165 /* Return the good/bad news */
7166 return (vam->retval);
7170 api_bridge_domain_set_mac_age (vat_main_t * vam)
7172 unformat_input_t *i = vam->input;
7173 vl_api_bridge_domain_set_mac_age_t *mp;
7178 /* Parse args required to build the message */
7179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7181 if (unformat (i, "bd_id %d", &bd_id));
7182 else if (unformat (i, "mac-age %d", &mac_age));
7189 errmsg ("missing bridge domain");
7195 errmsg ("mac age must be less than 256 ");
7199 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7201 mp->bd_id = htonl (bd_id);
7202 mp->mac_age = (u8) mac_age;
7210 api_l2_flags (vat_main_t * vam)
7212 unformat_input_t *i = vam->input;
7213 vl_api_l2_flags_t *mp;
7216 u8 sw_if_index_set = 0;
7220 /* Parse args required to build the message */
7221 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7223 if (unformat (i, "sw_if_index %d", &sw_if_index))
7224 sw_if_index_set = 1;
7225 else if (unformat (i, "sw_if"))
7227 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7230 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7231 sw_if_index_set = 1;
7236 else if (unformat (i, "learn"))
7238 else if (unformat (i, "forward"))
7240 else if (unformat (i, "flood"))
7242 else if (unformat (i, "uu-flood"))
7243 flags |= L2_UU_FLOOD;
7244 else if (unformat (i, "arp-term"))
7245 flags |= L2_ARP_TERM;
7246 else if (unformat (i, "off"))
7248 else if (unformat (i, "disable"))
7254 if (sw_if_index_set == 0)
7256 errmsg ("missing interface name or sw_if_index");
7262 mp->sw_if_index = ntohl (sw_if_index);
7263 mp->feature_bitmap = ntohl (flags);
7264 mp->is_set = is_set;
7272 api_bridge_flags (vat_main_t * vam)
7274 unformat_input_t *i = vam->input;
7275 vl_api_bridge_flags_t *mp;
7279 bd_flags_t flags = 0;
7282 /* Parse args required to build the message */
7283 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7285 if (unformat (i, "bd_id %d", &bd_id))
7287 else if (unformat (i, "learn"))
7288 flags |= BRIDGE_API_FLAG_LEARN;
7289 else if (unformat (i, "forward"))
7290 flags |= BRIDGE_API_FLAG_FWD;
7291 else if (unformat (i, "flood"))
7292 flags |= BRIDGE_API_FLAG_FLOOD;
7293 else if (unformat (i, "uu-flood"))
7294 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7295 else if (unformat (i, "arp-term"))
7296 flags |= BRIDGE_API_FLAG_ARP_TERM;
7297 else if (unformat (i, "off"))
7299 else if (unformat (i, "disable"))
7307 errmsg ("missing bridge domain");
7311 M (BRIDGE_FLAGS, mp);
7313 mp->bd_id = ntohl (bd_id);
7314 mp->flags = ntohl (flags);
7315 mp->is_set = is_set;
7323 api_bd_ip_mac_add_del (vat_main_t * vam)
7325 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7326 vl_api_mac_address_t mac = { 0 };
7327 unformat_input_t *i = vam->input;
7328 vl_api_bd_ip_mac_add_del_t *mp;
7340 /* Parse args required to build the message */
7341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7343 if (unformat (i, "bd_id %d", &bd_id))
7347 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7351 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7355 else if (unformat (i, "del"))
7363 errmsg ("missing bridge domain");
7366 else if (ip_set == 0)
7368 errmsg ("missing IP address");
7371 else if (mac_set == 0)
7373 errmsg ("missing MAC address");
7377 M (BD_IP_MAC_ADD_DEL, mp);
7379 mp->bd_id = ntohl (bd_id);
7380 mp->is_add = is_add;
7382 clib_memcpy (&mp->ip, &ip, sizeof (ip));
7383 clib_memcpy (&mp->mac, &mac, sizeof (mac));
7391 api_bd_ip_mac_flush (vat_main_t * vam)
7393 unformat_input_t *i = vam->input;
7394 vl_api_bd_ip_mac_flush_t *mp;
7399 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7401 if (unformat (i, "bd_id %d", &bd_id))
7411 errmsg ("missing bridge domain");
7415 M (BD_IP_MAC_FLUSH, mp);
7417 mp->bd_id = ntohl (bd_id);
7424 static void vl_api_bd_ip_mac_details_t_handler
7425 (vl_api_bd_ip_mac_details_t * mp)
7427 vat_main_t *vam = &vat_main;
7432 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7435 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7438 "\n%-5d %-7s %-20U %-30s",
7439 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7440 format_ethernet_address, mp->mac_address, ip);
7445 static void vl_api_bd_ip_mac_details_t_handler_json
7446 (vl_api_bd_ip_mac_details_t * mp)
7448 vat_main_t *vam = &vat_main;
7449 vat_json_node_t *node = NULL;
7451 if (VAT_JSON_ARRAY != vam->json_tree.type)
7453 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7454 vat_json_init_array (&vam->json_tree);
7456 node = vat_json_array_add (&vam->json_tree);
7458 vat_json_init_object (node);
7459 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7460 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7461 vat_json_object_add_string_copy (node, "mac_address",
7462 format (0, "%U", format_ethernet_address,
7468 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7471 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7472 vat_json_object_add_string_copy (node, "ip_address", ip);
7477 api_bd_ip_mac_dump (vat_main_t * vam)
7479 unformat_input_t *i = vam->input;
7480 vl_api_bd_ip_mac_dump_t *mp;
7481 vl_api_control_ping_t *mp_ping;
7486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7488 if (unformat (i, "bd_id %d", &bd_id))
7497 "\n%-5s %-7s %-20s %-30s",
7498 "bd_id", "is_ipv6", "mac_address", "ip_address");
7500 /* Dump Bridge Domain Ip to Mac entries */
7501 M (BD_IP_MAC_DUMP, mp);
7504 mp->bd_id = htonl (bd_id);
7510 /* Use a control ping for synchronization */
7511 MPING (CONTROL_PING, mp_ping);
7519 api_tap_connect (vat_main_t * vam)
7521 unformat_input_t *i = vam->input;
7522 vl_api_tap_connect_t *mp;
7528 ip4_address_t ip4_address;
7530 int ip4_address_set = 0;
7531 ip6_address_t ip6_address;
7533 int ip6_address_set = 0;
7536 clib_memset (mac_address, 0, sizeof (mac_address));
7538 /* Parse args required to build the message */
7539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7541 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7545 else if (unformat (i, "random-mac"))
7547 else if (unformat (i, "tapname %s", &tap_name))
7549 else if (unformat (i, "tag %s", &tag))
7551 else if (unformat (i, "address %U/%d",
7552 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7553 ip4_address_set = 1;
7554 else if (unformat (i, "address %U/%d",
7555 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7556 ip6_address_set = 1;
7563 errmsg ("missing tap name");
7566 if (vec_len (tap_name) > 63)
7568 errmsg ("tap name too long");
7571 vec_add1 (tap_name, 0);
7573 if (vec_len (tag) > 63)
7575 errmsg ("tag too long");
7579 /* Construct the API message */
7580 M (TAP_CONNECT, mp);
7582 mp->use_random_mac = random_mac;
7583 clib_memcpy (mp->mac_address, mac_address, 6);
7584 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7586 clib_memcpy (mp->tag, tag, vec_len (tag));
7588 if (ip4_address_set)
7590 mp->ip4_address_set = 1;
7591 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7592 mp->ip4_mask_width = ip4_mask_width;
7594 if (ip6_address_set)
7596 mp->ip6_address_set = 1;
7597 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7598 mp->ip6_mask_width = ip6_mask_width;
7601 vec_free (tap_name);
7607 /* Wait for a reply... */
7613 api_tap_modify (vat_main_t * vam)
7615 unformat_input_t *i = vam->input;
7616 vl_api_tap_modify_t *mp;
7621 u32 sw_if_index = ~0;
7622 u8 sw_if_index_set = 0;
7625 clib_memset (mac_address, 0, sizeof (mac_address));
7627 /* Parse args required to build the message */
7628 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7630 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7631 sw_if_index_set = 1;
7632 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7633 sw_if_index_set = 1;
7634 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7638 else if (unformat (i, "random-mac"))
7640 else if (unformat (i, "tapname %s", &tap_name))
7646 if (sw_if_index_set == 0)
7648 errmsg ("missing vpp interface name");
7653 errmsg ("missing tap name");
7656 if (vec_len (tap_name) > 63)
7658 errmsg ("tap name too long");
7660 vec_add1 (tap_name, 0);
7662 /* Construct the API message */
7665 mp->use_random_mac = random_mac;
7666 mp->sw_if_index = ntohl (sw_if_index);
7667 clib_memcpy (mp->mac_address, mac_address, 6);
7668 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7669 vec_free (tap_name);
7674 /* Wait for a reply... */
7680 api_tap_delete (vat_main_t * vam)
7682 unformat_input_t *i = vam->input;
7683 vl_api_tap_delete_t *mp;
7684 u32 sw_if_index = ~0;
7685 u8 sw_if_index_set = 0;
7688 /* Parse args required to build the message */
7689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7691 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7692 sw_if_index_set = 1;
7693 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7694 sw_if_index_set = 1;
7699 if (sw_if_index_set == 0)
7701 errmsg ("missing vpp interface name");
7705 /* Construct the API message */
7708 mp->sw_if_index = ntohl (sw_if_index);
7713 /* Wait for a reply... */
7719 api_tap_create_v2 (vat_main_t * vam)
7721 unformat_input_t *i = vam->input;
7722 vl_api_tap_create_v2_t *mp;
7726 u8 *host_if_name = 0;
7728 u8 host_mac_addr[6];
7729 u8 host_mac_addr_set = 0;
7730 u8 *host_bridge = 0;
7731 ip4_address_t host_ip4_addr;
7732 ip4_address_t host_ip4_gw;
7733 u8 host_ip4_gw_set = 0;
7734 u32 host_ip4_prefix_len = 0;
7735 ip6_address_t host_ip6_addr;
7736 ip6_address_t host_ip6_gw;
7737 u8 host_ip6_gw_set = 0;
7738 u32 host_ip6_prefix_len = 0;
7740 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7742 clib_memset (mac_address, 0, sizeof (mac_address));
7744 /* Parse args required to build the message */
7745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7747 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7751 else if (unformat (i, "id %u", &id))
7753 else if (unformat (i, "host-if-name %s", &host_if_name))
7755 else if (unformat (i, "host-ns %s", &host_ns))
7757 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7759 host_mac_addr_set = 1;
7760 else if (unformat (i, "host-bridge %s", &host_bridge))
7762 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7763 &host_ip4_addr, &host_ip4_prefix_len))
7765 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7766 &host_ip6_addr, &host_ip6_prefix_len))
7768 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7770 host_ip4_gw_set = 1;
7771 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7773 host_ip6_gw_set = 1;
7774 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7776 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7782 if (vec_len (host_if_name) > 63)
7784 errmsg ("tap name too long. ");
7787 if (vec_len (host_ns) > 63)
7789 errmsg ("host name space too long. ");
7792 if (vec_len (host_bridge) > 63)
7794 errmsg ("host bridge name too long. ");
7797 if (host_ip4_prefix_len > 32)
7799 errmsg ("host ip4 prefix length not valid. ");
7802 if (host_ip6_prefix_len > 128)
7804 errmsg ("host ip6 prefix length not valid. ");
7807 if (!is_pow2 (rx_ring_sz))
7809 errmsg ("rx ring size must be power of 2. ");
7812 if (rx_ring_sz > 32768)
7814 errmsg ("rx ring size must be 32768 or lower. ");
7817 if (!is_pow2 (tx_ring_sz))
7819 errmsg ("tx ring size must be power of 2. ");
7822 if (tx_ring_sz > 32768)
7824 errmsg ("tx ring size must be 32768 or lower. ");
7828 /* Construct the API message */
7829 M (TAP_CREATE_V2, mp);
7831 mp->use_random_mac = random_mac;
7833 mp->id = ntohl (id);
7834 mp->host_namespace_set = host_ns != 0;
7835 mp->host_bridge_set = host_bridge != 0;
7836 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7837 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7838 mp->rx_ring_sz = ntohs (rx_ring_sz);
7839 mp->tx_ring_sz = ntohs (tx_ring_sz);
7841 if (random_mac == 0)
7842 clib_memcpy (mp->mac_address, mac_address, 6);
7843 if (host_mac_addr_set)
7844 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7846 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7848 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7850 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7851 if (host_ip4_prefix_len)
7852 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7853 if (host_ip6_prefix_len)
7854 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7855 if (host_ip4_gw_set)
7856 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7857 if (host_ip6_gw_set)
7858 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7861 vec_free (host_if_name);
7862 vec_free (host_bridge);
7867 /* Wait for a reply... */
7873 api_tap_delete_v2 (vat_main_t * vam)
7875 unformat_input_t *i = vam->input;
7876 vl_api_tap_delete_v2_t *mp;
7877 u32 sw_if_index = ~0;
7878 u8 sw_if_index_set = 0;
7881 /* Parse args required to build the message */
7882 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7884 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7885 sw_if_index_set = 1;
7886 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7887 sw_if_index_set = 1;
7892 if (sw_if_index_set == 0)
7894 errmsg ("missing vpp interface name. ");
7898 /* Construct the API message */
7899 M (TAP_DELETE_V2, mp);
7901 mp->sw_if_index = ntohl (sw_if_index);
7906 /* Wait for a reply... */
7912 api_bond_create (vat_main_t * vam)
7914 unformat_input_t *i = vam->input;
7915 vl_api_bond_create_t *mp;
7924 clib_memset (mac_address, 0, sizeof (mac_address));
7927 /* Parse args required to build the message */
7928 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7930 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7932 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7933 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7935 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7938 else if (unformat (i, "id %u", &id))
7944 if (mode_is_set == 0)
7946 errmsg ("Missing bond mode. ");
7950 /* Construct the API message */
7951 M (BOND_CREATE, mp);
7953 mp->use_custom_mac = custom_mac;
7957 mp->id = htonl (id);
7960 clib_memcpy (mp->mac_address, mac_address, 6);
7965 /* Wait for a reply... */
7971 api_bond_delete (vat_main_t * vam)
7973 unformat_input_t *i = vam->input;
7974 vl_api_bond_delete_t *mp;
7975 u32 sw_if_index = ~0;
7976 u8 sw_if_index_set = 0;
7979 /* Parse args required to build the message */
7980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7982 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7983 sw_if_index_set = 1;
7984 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7985 sw_if_index_set = 1;
7990 if (sw_if_index_set == 0)
7992 errmsg ("missing vpp interface name. ");
7996 /* Construct the API message */
7997 M (BOND_DELETE, mp);
7999 mp->sw_if_index = ntohl (sw_if_index);
8004 /* Wait for a reply... */
8010 api_bond_enslave (vat_main_t * vam)
8012 unformat_input_t *i = vam->input;
8013 vl_api_bond_enslave_t *mp;
8014 u32 bond_sw_if_index;
8018 u32 bond_sw_if_index_is_set = 0;
8020 u8 sw_if_index_is_set = 0;
8022 /* Parse args required to build the message */
8023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8025 if (unformat (i, "sw_if_index %d", &sw_if_index))
8026 sw_if_index_is_set = 1;
8027 else if (unformat (i, "bond %u", &bond_sw_if_index))
8028 bond_sw_if_index_is_set = 1;
8029 else if (unformat (i, "passive %d", &is_passive))
8031 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8037 if (bond_sw_if_index_is_set == 0)
8039 errmsg ("Missing bond sw_if_index. ");
8042 if (sw_if_index_is_set == 0)
8044 errmsg ("Missing slave sw_if_index. ");
8048 /* Construct the API message */
8049 M (BOND_ENSLAVE, mp);
8051 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8052 mp->sw_if_index = ntohl (sw_if_index);
8053 mp->is_long_timeout = is_long_timeout;
8054 mp->is_passive = is_passive;
8059 /* Wait for a reply... */
8065 api_bond_detach_slave (vat_main_t * vam)
8067 unformat_input_t *i = vam->input;
8068 vl_api_bond_detach_slave_t *mp;
8069 u32 sw_if_index = ~0;
8070 u8 sw_if_index_set = 0;
8073 /* Parse args required to build the message */
8074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8076 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8077 sw_if_index_set = 1;
8078 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8079 sw_if_index_set = 1;
8084 if (sw_if_index_set == 0)
8086 errmsg ("missing vpp interface name. ");
8090 /* Construct the API message */
8091 M (BOND_DETACH_SLAVE, mp);
8093 mp->sw_if_index = ntohl (sw_if_index);
8098 /* Wait for a reply... */
8104 api_ip_table_add_del (vat_main_t * vam)
8106 unformat_input_t *i = vam->input;
8107 vl_api_ip_table_add_del_t *mp;
8113 /* Parse args required to build the message */
8114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8116 if (unformat (i, "ipv6"))
8118 else if (unformat (i, "del"))
8120 else if (unformat (i, "add"))
8122 else if (unformat (i, "table %d", &table_id))
8126 clib_warning ("parse error '%U'", format_unformat_error, i);
8133 errmsg ("missing table-ID");
8137 /* Construct the API message */
8138 M (IP_TABLE_ADD_DEL, mp);
8140 mp->table_id = ntohl (table_id);
8141 mp->is_ipv6 = is_ipv6;
8142 mp->is_add = is_add;
8147 /* Wait for a reply... */
8154 api_ip_add_del_route (vat_main_t * vam)
8156 unformat_input_t *i = vam->input;
8157 vl_api_ip_add_del_route_t *mp;
8158 u32 sw_if_index = ~0, vrf_id = 0;
8160 u8 is_local = 0, is_drop = 0;
8161 u8 is_unreach = 0, is_prohibit = 0;
8163 u32 next_hop_weight = 1;
8164 u8 is_multipath = 0;
8166 u8 address_length_set = 0;
8167 u32 next_hop_table_id = 0;
8168 u32 resolve_attempts = 0;
8169 u32 dst_address_length = 0;
8170 u8 next_hop_set = 0;
8171 ip4_address_t v4_dst_address, v4_next_hop_address;
8172 ip6_address_t v6_dst_address, v6_next_hop_address;
8176 u32 random_add_del = 0;
8177 u32 *random_vector = 0;
8179 u32 random_seed = 0xdeaddabe;
8180 u32 classify_table_index = ~0;
8182 u8 resolve_host = 0, resolve_attached = 0;
8183 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8184 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8185 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8187 clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8188 clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8189 /* Parse args required to build the message */
8190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8192 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8194 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8196 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8201 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8206 else if (unformat (i, "/%d", &dst_address_length))
8208 address_length_set = 1;
8211 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8212 &v4_next_hop_address))
8216 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8217 &v6_next_hop_address))
8223 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8227 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8231 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8233 else if (unformat (i, "weight %d", &next_hop_weight))
8235 else if (unformat (i, "drop"))
8239 else if (unformat (i, "null-send-unreach"))
8243 else if (unformat (i, "null-send-prohibit"))
8247 else if (unformat (i, "local"))
8251 else if (unformat (i, "classify %d", &classify_table_index))
8255 else if (unformat (i, "del"))
8257 else if (unformat (i, "add"))
8259 else if (unformat (i, "resolve-via-host"))
8261 else if (unformat (i, "resolve-via-attached"))
8262 resolve_attached = 1;
8263 else if (unformat (i, "multipath"))
8265 else if (unformat (i, "vrf %d", &vrf_id))
8267 else if (unformat (i, "count %d", &count))
8269 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8271 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8273 else if (unformat (i, "out-label %d", &next_hop_out_label))
8275 vl_api_fib_mpls_label_t fib_label = {
8276 .label = ntohl (next_hop_out_label),
8280 vec_add1 (next_hop_out_label_stack, fib_label);
8282 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8284 else if (unformat (i, "random"))
8286 else if (unformat (i, "seed %d", &random_seed))
8290 clib_warning ("parse error '%U'", format_unformat_error, i);
8295 if (!next_hop_set && !is_drop && !is_local &&
8296 !is_classify && !is_unreach && !is_prohibit &&
8297 MPLS_LABEL_INVALID == next_hop_via_label)
8300 ("next hop / local / drop / unreach / prohibit / classify not set");
8304 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8306 errmsg ("next hop and next-hop via label set");
8309 if (address_set == 0)
8311 errmsg ("missing addresses");
8315 if (address_length_set == 0)
8317 errmsg ("missing address length");
8321 /* Generate a pile of unique, random routes */
8324 u32 this_random_address;
8325 random_hash = hash_create (count, sizeof (uword));
8327 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8328 for (j = 0; j <= count; j++)
8332 this_random_address = random_u32 (&random_seed);
8333 this_random_address =
8334 clib_host_to_net_u32 (this_random_address);
8336 while (hash_get (random_hash, this_random_address));
8337 vec_add1 (random_vector, this_random_address);
8338 hash_set (random_hash, this_random_address, 1);
8340 hash_free (random_hash);
8341 v4_dst_address.as_u32 = random_vector[0];
8346 /* Turn on async mode */
8347 vam->async_mode = 1;
8348 vam->async_errors = 0;
8349 before = vat_time_now (vam);
8352 for (j = 0; j < count; j++)
8354 /* Construct the API message */
8355 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8356 vec_len (next_hop_out_label_stack));
8358 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8359 mp->table_id = ntohl (vrf_id);
8361 mp->is_add = is_add;
8362 mp->is_drop = is_drop;
8363 mp->is_unreach = is_unreach;
8364 mp->is_prohibit = is_prohibit;
8365 mp->is_ipv6 = is_ipv6;
8366 mp->is_local = is_local;
8367 mp->is_classify = is_classify;
8368 mp->is_multipath = is_multipath;
8369 mp->is_resolve_host = resolve_host;
8370 mp->is_resolve_attached = resolve_attached;
8371 mp->next_hop_weight = next_hop_weight;
8372 mp->next_hop_preference = 0;
8373 mp->dst_address_length = dst_address_length;
8374 mp->next_hop_table_id = ntohl (next_hop_table_id);
8375 mp->classify_table_index = ntohl (classify_table_index);
8376 mp->next_hop_via_label = ntohl (next_hop_via_label);
8377 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8378 if (0 != mp->next_hop_n_out_labels)
8380 memcpy (mp->next_hop_out_label_stack,
8381 next_hop_out_label_stack,
8382 (vec_len (next_hop_out_label_stack) *
8383 sizeof (vl_api_fib_mpls_label_t)));
8384 vec_free (next_hop_out_label_stack);
8389 clib_memcpy (mp->dst_address, &v6_dst_address,
8390 sizeof (v6_dst_address));
8392 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8393 sizeof (v6_next_hop_address));
8394 increment_v6_address (&v6_dst_address);
8398 clib_memcpy (mp->dst_address, &v4_dst_address,
8399 sizeof (v4_dst_address));
8401 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8402 sizeof (v4_next_hop_address));
8404 v4_dst_address.as_u32 = random_vector[j + 1];
8406 increment_v4_address (&v4_dst_address);
8410 /* If we receive SIGTERM, stop now... */
8415 /* When testing multiple add/del ops, use a control-ping to sync */
8418 vl_api_control_ping_t *mp_ping;
8422 /* Shut off async mode */
8423 vam->async_mode = 0;
8425 MPING (CONTROL_PING, mp_ping);
8428 timeout = vat_time_now (vam) + 1.0;
8429 while (vat_time_now (vam) < timeout)
8430 if (vam->result_ready == 1)
8435 if (vam->retval == -99)
8438 if (vam->async_errors > 0)
8440 errmsg ("%d asynchronous errors", vam->async_errors);
8443 vam->async_errors = 0;
8444 after = vat_time_now (vam);
8446 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8450 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8451 count, after - before, count / (after - before));
8457 /* Wait for a reply... */
8462 /* Return the good/bad news */
8463 return (vam->retval);
8467 api_ip_mroute_add_del (vat_main_t * vam)
8469 unformat_input_t *i = vam->input;
8470 vl_api_ip_mroute_add_del_t *mp;
8471 u32 sw_if_index = ~0, vrf_id = 0;
8476 u32 grp_address_length = 0;
8477 ip4_address_t v4_grp_address, v4_src_address;
8478 ip6_address_t v6_grp_address, v6_src_address;
8479 mfib_itf_flags_t iflags = 0;
8480 mfib_entry_flags_t eflags = 0;
8483 /* Parse args required to build the message */
8484 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8486 if (unformat (i, "sw_if_index %d", &sw_if_index))
8488 else if (unformat (i, "%U %U",
8489 unformat_ip4_address, &v4_src_address,
8490 unformat_ip4_address, &v4_grp_address))
8492 grp_address_length = 64;
8496 else if (unformat (i, "%U %U",
8497 unformat_ip6_address, &v6_src_address,
8498 unformat_ip6_address, &v6_grp_address))
8500 grp_address_length = 256;
8504 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8506 clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
8507 grp_address_length = 32;
8511 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8513 clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
8514 grp_address_length = 128;
8518 else if (unformat (i, "/%d", &grp_address_length))
8520 else if (unformat (i, "local"))
8524 else if (unformat (i, "del"))
8526 else if (unformat (i, "add"))
8528 else if (unformat (i, "vrf %d", &vrf_id))
8530 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8532 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8536 clib_warning ("parse error '%U'", format_unformat_error, i);
8541 if (address_set == 0)
8543 errmsg ("missing addresses\n");
8547 /* Construct the API message */
8548 M (IP_MROUTE_ADD_DEL, mp);
8550 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8551 mp->table_id = ntohl (vrf_id);
8553 mp->is_add = is_add;
8554 mp->is_ipv6 = is_ipv6;
8555 mp->is_local = is_local;
8556 mp->itf_flags = ntohl (iflags);
8557 mp->entry_flags = ntohl (eflags);
8558 mp->grp_address_length = grp_address_length;
8559 mp->grp_address_length = ntohs (mp->grp_address_length);
8563 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8564 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8568 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8569 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8575 /* Wait for a reply... */
8581 api_mpls_table_add_del (vat_main_t * vam)
8583 unformat_input_t *i = vam->input;
8584 vl_api_mpls_table_add_del_t *mp;
8589 /* Parse args required to build the message */
8590 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8592 if (unformat (i, "table %d", &table_id))
8594 else if (unformat (i, "del"))
8596 else if (unformat (i, "add"))
8600 clib_warning ("parse error '%U'", format_unformat_error, i);
8607 errmsg ("missing table-ID");
8611 /* Construct the API message */
8612 M (MPLS_TABLE_ADD_DEL, mp);
8614 mp->mt_table_id = ntohl (table_id);
8615 mp->mt_is_add = is_add;
8620 /* Wait for a reply... */
8627 api_mpls_route_add_del (vat_main_t * vam)
8629 unformat_input_t *i = vam->input;
8630 vl_api_mpls_route_add_del_t *mp;
8631 u32 sw_if_index = ~0, table_id = 0;
8633 u32 next_hop_weight = 1;
8634 u8 is_multipath = 0;
8635 u32 next_hop_table_id = 0;
8636 u8 next_hop_set = 0;
8637 ip4_address_t v4_next_hop_address = {
8640 ip6_address_t v6_next_hop_address = { {0} };
8644 u32 classify_table_index = ~0;
8646 u8 resolve_host = 0, resolve_attached = 0;
8647 u8 is_interface_rx = 0;
8648 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8649 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8650 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8651 mpls_label_t local_label = MPLS_LABEL_INVALID;
8653 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
8655 /* Parse args required to build the message */
8656 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8658 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8660 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8662 else if (unformat (i, "%d", &local_label))
8664 else if (unformat (i, "eos"))
8666 else if (unformat (i, "non-eos"))
8668 else if (unformat (i, "via %U", unformat_ip4_address,
8669 &v4_next_hop_address))
8672 next_hop_proto = DPO_PROTO_IP4;
8674 else if (unformat (i, "via %U", unformat_ip6_address,
8675 &v6_next_hop_address))
8678 next_hop_proto = DPO_PROTO_IP6;
8680 else if (unformat (i, "weight %d", &next_hop_weight))
8682 else if (unformat (i, "classify %d", &classify_table_index))
8686 else if (unformat (i, "del"))
8688 else if (unformat (i, "add"))
8690 else if (unformat (i, "resolve-via-host"))
8692 else if (unformat (i, "resolve-via-attached"))
8693 resolve_attached = 1;
8694 else if (unformat (i, "multipath"))
8696 else if (unformat (i, "count %d", &count))
8698 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
8701 next_hop_proto = DPO_PROTO_IP4;
8703 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
8706 next_hop_proto = DPO_PROTO_IP6;
8710 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
8714 next_hop_proto = DPO_PROTO_ETHERNET;
8715 is_interface_rx = 1;
8717 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
8720 next_hop_proto = DPO_PROTO_ETHERNET;
8721 is_interface_rx = 1;
8723 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
8725 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8727 else if (unformat (i, "out-label %d", &next_hop_out_label))
8729 vl_api_fib_mpls_label_t fib_label = {
8730 .label = ntohl (next_hop_out_label),
8734 vec_add1 (next_hop_out_label_stack, fib_label);
8738 clib_warning ("parse error '%U'", format_unformat_error, i);
8743 if (!next_hop_set && !is_classify)
8745 errmsg ("next hop / classify not set");
8749 if (MPLS_LABEL_INVALID == local_label)
8751 errmsg ("missing label");
8757 /* Turn on async mode */
8758 vam->async_mode = 1;
8759 vam->async_errors = 0;
8760 before = vat_time_now (vam);
8763 for (j = 0; j < count; j++)
8765 /* Construct the API message */
8766 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
8767 vec_len (next_hop_out_label_stack));
8769 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8770 mp->mr_table_id = ntohl (table_id);
8772 mp->mr_is_add = is_add;
8773 mp->mr_next_hop_proto = next_hop_proto;
8774 mp->mr_is_classify = is_classify;
8775 mp->mr_is_multipath = is_multipath;
8776 mp->mr_is_resolve_host = resolve_host;
8777 mp->mr_is_resolve_attached = resolve_attached;
8778 mp->mr_is_interface_rx = is_interface_rx;
8779 mp->mr_next_hop_weight = next_hop_weight;
8780 mp->mr_next_hop_preference = 0;
8781 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8782 mp->mr_classify_table_index = ntohl (classify_table_index);
8783 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8784 mp->mr_label = ntohl (local_label);
8785 mp->mr_eos = is_eos;
8787 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8788 if (0 != mp->mr_next_hop_n_out_labels)
8790 memcpy (mp->mr_next_hop_out_label_stack,
8791 next_hop_out_label_stack,
8792 vec_len (next_hop_out_label_stack) *
8793 sizeof (vl_api_fib_mpls_label_t));
8794 vec_free (next_hop_out_label_stack);
8799 if (DPO_PROTO_IP4 == next_hop_proto)
8801 clib_memcpy (mp->mr_next_hop,
8802 &v4_next_hop_address,
8803 sizeof (v4_next_hop_address));
8805 else if (DPO_PROTO_IP6 == next_hop_proto)
8808 clib_memcpy (mp->mr_next_hop,
8809 &v6_next_hop_address,
8810 sizeof (v6_next_hop_address));
8817 /* If we receive SIGTERM, stop now... */
8822 /* When testing multiple add/del ops, use a control-ping to sync */
8825 vl_api_control_ping_t *mp_ping;
8829 /* Shut off async mode */
8830 vam->async_mode = 0;
8832 MPING (CONTROL_PING, mp_ping);
8835 timeout = vat_time_now (vam) + 1.0;
8836 while (vat_time_now (vam) < timeout)
8837 if (vam->result_ready == 1)
8842 if (vam->retval == -99)
8845 if (vam->async_errors > 0)
8847 errmsg ("%d asynchronous errors", vam->async_errors);
8850 vam->async_errors = 0;
8851 after = vat_time_now (vam);
8853 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8857 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8858 count, after - before, count / (after - before));
8864 /* Wait for a reply... */
8869 /* Return the good/bad news */
8870 return (vam->retval);
8874 api_mpls_ip_bind_unbind (vat_main_t * vam)
8876 unformat_input_t *i = vam->input;
8877 vl_api_mpls_ip_bind_unbind_t *mp;
8878 u32 ip_table_id = 0;
8881 ip4_address_t v4_address;
8882 ip6_address_t v6_address;
8885 mpls_label_t local_label = MPLS_LABEL_INVALID;
8888 /* Parse args required to build the message */
8889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8891 if (unformat (i, "%U/%d", unformat_ip4_address,
8892 &v4_address, &address_length))
8897 else if (unformat (i, "%U/%d", unformat_ip6_address,
8898 &v6_address, &address_length))
8903 else if (unformat (i, "%d", &local_label))
8905 else if (unformat (i, "table-id %d", &ip_table_id))
8907 else if (unformat (i, "unbind"))
8909 else if (unformat (i, "bind"))
8913 clib_warning ("parse error '%U'", format_unformat_error, i);
8920 errmsg ("IP address not set");
8924 if (MPLS_LABEL_INVALID == local_label)
8926 errmsg ("missing label");
8930 /* Construct the API message */
8931 M (MPLS_IP_BIND_UNBIND, mp);
8933 mp->mb_is_bind = is_bind;
8934 mp->mb_is_ip4 = is_ip4;
8935 mp->mb_ip_table_id = ntohl (ip_table_id);
8936 mp->mb_mpls_table_id = 0;
8937 mp->mb_label = ntohl (local_label);
8938 mp->mb_address_length = address_length;
8941 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8943 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8948 /* Wait for a reply... */
8954 api_sr_mpls_policy_add (vat_main_t * vam)
8956 unformat_input_t *i = vam->input;
8957 vl_api_sr_mpls_policy_add_t *mp;
8963 u32 *segments = NULL;
8966 /* Parse args required to build the message */
8967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8969 if (unformat (i, "bsid %d", &bsid))
8971 else if (unformat (i, "weight %d", &weight))
8973 else if (unformat (i, "spray"))
8975 else if (unformat (i, "next %d", &sid))
8978 vec_add1 (segments, htonl (sid));
8982 clib_warning ("parse error '%U'", format_unformat_error, i);
8989 errmsg ("bsid not set");
8993 if (n_segments == 0)
8995 errmsg ("no sid in segment stack");
8999 /* Construct the API message */
9000 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
9002 mp->bsid = htonl (bsid);
9003 mp->weight = htonl (weight);
9005 mp->n_segments = n_segments;
9006 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
9007 vec_free (segments);
9012 /* Wait for a reply... */
9018 api_sr_mpls_policy_del (vat_main_t * vam)
9020 unformat_input_t *i = vam->input;
9021 vl_api_sr_mpls_policy_del_t *mp;
9025 /* Parse args required to build the message */
9026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9028 if (unformat (i, "bsid %d", &bsid))
9032 clib_warning ("parse error '%U'", format_unformat_error, i);
9039 errmsg ("bsid not set");
9043 /* Construct the API message */
9044 M (SR_MPLS_POLICY_DEL, mp);
9046 mp->bsid = htonl (bsid);
9051 /* Wait for a reply... */
9057 api_bier_table_add_del (vat_main_t * vam)
9059 unformat_input_t *i = vam->input;
9060 vl_api_bier_table_add_del_t *mp;
9062 u32 set = 0, sub_domain = 0, hdr_len = 3;
9063 mpls_label_t local_label = MPLS_LABEL_INVALID;
9066 /* Parse args required to build the message */
9067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9069 if (unformat (i, "sub-domain %d", &sub_domain))
9071 else if (unformat (i, "set %d", &set))
9073 else if (unformat (i, "label %d", &local_label))
9075 else if (unformat (i, "hdr-len %d", &hdr_len))
9077 else if (unformat (i, "add"))
9079 else if (unformat (i, "del"))
9083 clib_warning ("parse error '%U'", format_unformat_error, i);
9088 if (MPLS_LABEL_INVALID == local_label)
9090 errmsg ("missing label\n");
9094 /* Construct the API message */
9095 M (BIER_TABLE_ADD_DEL, mp);
9097 mp->bt_is_add = is_add;
9098 mp->bt_label = ntohl (local_label);
9099 mp->bt_tbl_id.bt_set = set;
9100 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9101 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9106 /* Wait for a reply... */
9113 api_bier_route_add_del (vat_main_t * vam)
9115 unformat_input_t *i = vam->input;
9116 vl_api_bier_route_add_del_t *mp;
9118 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9119 ip4_address_t v4_next_hop_address;
9120 ip6_address_t v6_next_hop_address;
9121 u8 next_hop_set = 0;
9122 u8 next_hop_proto_is_ip4 = 1;
9123 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9126 /* Parse args required to build the message */
9127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9129 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9131 next_hop_proto_is_ip4 = 1;
9134 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9136 next_hop_proto_is_ip4 = 0;
9139 if (unformat (i, "sub-domain %d", &sub_domain))
9141 else if (unformat (i, "set %d", &set))
9143 else if (unformat (i, "hdr-len %d", &hdr_len))
9145 else if (unformat (i, "bp %d", &bp))
9147 else if (unformat (i, "add"))
9149 else if (unformat (i, "del"))
9151 else if (unformat (i, "out-label %d", &next_hop_out_label))
9155 clib_warning ("parse error '%U'", format_unformat_error, i);
9160 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9162 errmsg ("next hop / label set\n");
9167 errmsg ("bit=position not set\n");
9171 /* Construct the API message */
9172 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9174 mp->br_is_add = is_add;
9175 mp->br_tbl_id.bt_set = set;
9176 mp->br_tbl_id.bt_sub_domain = sub_domain;
9177 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9178 mp->br_bp = ntohs (bp);
9180 mp->br_paths[0].n_labels = 1;
9181 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9182 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9184 if (next_hop_proto_is_ip4)
9186 clib_memcpy (mp->br_paths[0].next_hop,
9187 &v4_next_hop_address, sizeof (v4_next_hop_address));
9191 clib_memcpy (mp->br_paths[0].next_hop,
9192 &v6_next_hop_address, sizeof (v6_next_hop_address));
9198 /* Wait for a reply... */
9205 api_proxy_arp_add_del (vat_main_t * vam)
9207 unformat_input_t *i = vam->input;
9208 vl_api_proxy_arp_add_del_t *mp;
9211 ip4_address_t lo, hi;
9215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9217 if (unformat (i, "vrf %d", &vrf_id))
9219 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9220 unformat_ip4_address, &hi))
9222 else if (unformat (i, "del"))
9226 clib_warning ("parse error '%U'", format_unformat_error, i);
9233 errmsg ("address range not set");
9237 M (PROXY_ARP_ADD_DEL, mp);
9239 mp->proxy.vrf_id = ntohl (vrf_id);
9240 mp->is_add = is_add;
9241 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9242 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9250 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9252 unformat_input_t *i = vam->input;
9253 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9256 u8 sw_if_index_set = 0;
9259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9261 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9262 sw_if_index_set = 1;
9263 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9264 sw_if_index_set = 1;
9265 else if (unformat (i, "enable"))
9267 else if (unformat (i, "disable"))
9271 clib_warning ("parse error '%U'", format_unformat_error, i);
9276 if (sw_if_index_set == 0)
9278 errmsg ("missing interface name or sw_if_index");
9282 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9284 mp->sw_if_index = ntohl (sw_if_index);
9285 mp->enable_disable = enable;
9293 api_mpls_tunnel_add_del (vat_main_t * vam)
9295 unformat_input_t *i = vam->input;
9296 vl_api_mpls_tunnel_add_del_t *mp;
9300 u32 sw_if_index = ~0;
9301 u32 next_hop_sw_if_index = ~0;
9302 u32 next_hop_proto_is_ip4 = 1;
9304 u32 next_hop_table_id = 0;
9305 ip4_address_t v4_next_hop_address = {
9308 ip6_address_t v6_next_hop_address = { {0} };
9309 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9310 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9311 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9316 if (unformat (i, "add"))
9320 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9322 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9324 else if (unformat (i, "via %U",
9325 unformat_ip4_address, &v4_next_hop_address))
9327 next_hop_proto_is_ip4 = 1;
9329 else if (unformat (i, "via %U",
9330 unformat_ip6_address, &v6_next_hop_address))
9332 next_hop_proto_is_ip4 = 0;
9334 else if (unformat (i, "via-label %d", &next_hop_via_label))
9338 (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
9340 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9342 else if (unformat (i, "l2-only"))
9344 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9346 else if (unformat (i, "out-label %d", &next_hop_out_label))
9348 vl_api_fib_mpls_label_t fib_label = {
9349 .label = ntohl (next_hop_out_label),
9353 vec_add1 (next_hop_out_label_stack, fib_label);
9357 clib_warning ("parse error '%U'", format_unformat_error, i);
9362 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9363 vec_len (next_hop_out_label_stack));
9365 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9366 mp->mt_sw_if_index = ntohl (sw_if_index);
9367 mp->mt_is_add = is_add;
9368 mp->mt_l2_only = l2_only;
9369 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9370 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9371 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9372 mp->mt_next_hop_weight = 1;
9373 mp->mt_next_hop_preference = 0;
9375 mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9377 if (0 != mp->mt_next_hop_n_out_labels)
9379 clib_memcpy (mp->mt_next_hop_out_label_stack,
9380 next_hop_out_label_stack,
9381 (vec_len (next_hop_out_label_stack) *
9382 sizeof (vl_api_fib_mpls_label_t)));
9383 vec_free (next_hop_out_label_stack);
9386 if (next_hop_proto_is_ip4)
9388 clib_memcpy (mp->mt_next_hop,
9389 &v4_next_hop_address, sizeof (v4_next_hop_address));
9393 clib_memcpy (mp->mt_next_hop,
9394 &v6_next_hop_address, sizeof (v6_next_hop_address));
9403 api_sw_interface_set_unnumbered (vat_main_t * vam)
9405 unformat_input_t *i = vam->input;
9406 vl_api_sw_interface_set_unnumbered_t *mp;
9408 u32 unnum_sw_index = ~0;
9410 u8 sw_if_index_set = 0;
9413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9415 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9416 sw_if_index_set = 1;
9417 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9418 sw_if_index_set = 1;
9419 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9421 else if (unformat (i, "del"))
9425 clib_warning ("parse error '%U'", format_unformat_error, i);
9430 if (sw_if_index_set == 0)
9432 errmsg ("missing interface name or sw_if_index");
9436 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9438 mp->sw_if_index = ntohl (sw_if_index);
9439 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9440 mp->is_add = is_add;
9448 api_ip_neighbor_add_del (vat_main_t * vam)
9450 unformat_input_t *i = vam->input;
9451 vl_api_ip_neighbor_add_del_t *mp;
9453 u8 sw_if_index_set = 0;
9456 u8 is_no_fib_entry = 0;
9459 u8 v4_address_set = 0;
9460 u8 v6_address_set = 0;
9461 ip4_address_t v4address;
9462 ip6_address_t v6address;
9465 clib_memset (mac_address, 0, sizeof (mac_address));
9467 /* Parse args required to build the message */
9468 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9470 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9474 else if (unformat (i, "del"))
9477 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9478 sw_if_index_set = 1;
9479 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9480 sw_if_index_set = 1;
9481 else if (unformat (i, "is_static"))
9483 else if (unformat (i, "no-fib-entry"))
9484 is_no_fib_entry = 1;
9485 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9487 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9491 clib_warning ("parse error '%U'", format_unformat_error, i);
9496 if (sw_if_index_set == 0)
9498 errmsg ("missing interface name or sw_if_index");
9501 if (v4_address_set && v6_address_set)
9503 errmsg ("both v4 and v6 addresses set");
9506 if (!v4_address_set && !v6_address_set)
9508 errmsg ("no address set");
9512 /* Construct the API message */
9513 M (IP_NEIGHBOR_ADD_DEL, mp);
9515 mp->sw_if_index = ntohl (sw_if_index);
9516 mp->is_add = is_add;
9517 mp->is_static = is_static;
9518 mp->is_no_adj_fib = is_no_fib_entry;
9520 clib_memcpy (mp->mac_address, mac_address, 6);
9524 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9528 /* mp->is_ipv6 = 0; via clib_memset in M macro above */
9529 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9535 /* Wait for a reply, return good/bad news */
9541 api_create_vlan_subif (vat_main_t * vam)
9543 unformat_input_t *i = vam->input;
9544 vl_api_create_vlan_subif_t *mp;
9546 u8 sw_if_index_set = 0;
9551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9553 if (unformat (i, "sw_if_index %d", &sw_if_index))
9554 sw_if_index_set = 1;
9556 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9557 sw_if_index_set = 1;
9558 else if (unformat (i, "vlan %d", &vlan_id))
9562 clib_warning ("parse error '%U'", format_unformat_error, i);
9567 if (sw_if_index_set == 0)
9569 errmsg ("missing interface name or sw_if_index");
9573 if (vlan_id_set == 0)
9575 errmsg ("missing vlan_id");
9578 M (CREATE_VLAN_SUBIF, mp);
9580 mp->sw_if_index = ntohl (sw_if_index);
9581 mp->vlan_id = ntohl (vlan_id);
9588 #define foreach_create_subif_bit \
9595 _(outer_vlan_id_any) \
9596 _(inner_vlan_id_any)
9599 api_create_subif (vat_main_t * vam)
9601 unformat_input_t *i = vam->input;
9602 vl_api_create_subif_t *mp;
9604 u8 sw_if_index_set = 0;
9611 u32 exact_match = 0;
9612 u32 default_sub = 0;
9613 u32 outer_vlan_id_any = 0;
9614 u32 inner_vlan_id_any = 0;
9616 u16 outer_vlan_id = 0;
9617 u16 inner_vlan_id = 0;
9620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9622 if (unformat (i, "sw_if_index %d", &sw_if_index))
9623 sw_if_index_set = 1;
9625 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9626 sw_if_index_set = 1;
9627 else if (unformat (i, "sub_id %d", &sub_id))
9629 else if (unformat (i, "outer_vlan_id %d", &tmp))
9630 outer_vlan_id = tmp;
9631 else if (unformat (i, "inner_vlan_id %d", &tmp))
9632 inner_vlan_id = tmp;
9634 #define _(a) else if (unformat (i, #a)) a = 1 ;
9635 foreach_create_subif_bit
9639 clib_warning ("parse error '%U'", format_unformat_error, i);
9644 if (sw_if_index_set == 0)
9646 errmsg ("missing interface name or sw_if_index");
9650 if (sub_id_set == 0)
9652 errmsg ("missing sub_id");
9655 M (CREATE_SUBIF, mp);
9657 mp->sw_if_index = ntohl (sw_if_index);
9658 mp->sub_id = ntohl (sub_id);
9660 #define _(a) mp->a = a;
9661 foreach_create_subif_bit;
9664 mp->outer_vlan_id = ntohs (outer_vlan_id);
9665 mp->inner_vlan_id = ntohs (inner_vlan_id);
9673 api_oam_add_del (vat_main_t * vam)
9675 unformat_input_t *i = vam->input;
9676 vl_api_oam_add_del_t *mp;
9679 ip4_address_t src, dst;
9684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9686 if (unformat (i, "vrf %d", &vrf_id))
9688 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9690 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9692 else if (unformat (i, "del"))
9696 clib_warning ("parse error '%U'", format_unformat_error, i);
9703 errmsg ("missing src addr");
9709 errmsg ("missing dst addr");
9713 M (OAM_ADD_DEL, mp);
9715 mp->vrf_id = ntohl (vrf_id);
9716 mp->is_add = is_add;
9717 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9718 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9726 api_reset_fib (vat_main_t * vam)
9728 unformat_input_t *i = vam->input;
9729 vl_api_reset_fib_t *mp;
9735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9737 if (unformat (i, "vrf %d", &vrf_id))
9739 else if (unformat (i, "ipv6"))
9743 clib_warning ("parse error '%U'", format_unformat_error, i);
9748 if (vrf_id_set == 0)
9750 errmsg ("missing vrf id");
9756 mp->vrf_id = ntohl (vrf_id);
9757 mp->is_ipv6 = is_ipv6;
9765 api_dhcp_proxy_config (vat_main_t * vam)
9767 unformat_input_t *i = vam->input;
9768 vl_api_dhcp_proxy_config_t *mp;
9770 u32 server_vrf_id = 0;
9772 u8 v4_address_set = 0;
9773 u8 v6_address_set = 0;
9774 ip4_address_t v4address;
9775 ip6_address_t v6address;
9776 u8 v4_src_address_set = 0;
9777 u8 v6_src_address_set = 0;
9778 ip4_address_t v4srcaddress;
9779 ip6_address_t v6srcaddress;
9782 /* Parse args required to build the message */
9783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9785 if (unformat (i, "del"))
9787 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9789 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9791 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9793 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9795 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9796 v4_src_address_set = 1;
9797 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9798 v6_src_address_set = 1;
9803 if (v4_address_set && v6_address_set)
9805 errmsg ("both v4 and v6 server addresses set");
9808 if (!v4_address_set && !v6_address_set)
9810 errmsg ("no server addresses set");
9814 if (v4_src_address_set && v6_src_address_set)
9816 errmsg ("both v4 and v6 src addresses set");
9819 if (!v4_src_address_set && !v6_src_address_set)
9821 errmsg ("no src addresses set");
9825 if (!(v4_src_address_set && v4_address_set) &&
9826 !(v6_src_address_set && v6_address_set))
9828 errmsg ("no matching server and src addresses set");
9832 /* Construct the API message */
9833 M (DHCP_PROXY_CONFIG, mp);
9835 mp->is_add = is_add;
9836 mp->rx_vrf_id = ntohl (rx_vrf_id);
9837 mp->server_vrf_id = ntohl (server_vrf_id);
9841 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9842 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9846 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9847 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9853 /* Wait for a reply, return good/bad news */
9858 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9859 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9862 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9864 vat_main_t *vam = &vat_main;
9865 u32 i, count = mp->count;
9866 vl_api_dhcp_server_t *s;
9870 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9871 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9872 ntohl (mp->rx_vrf_id),
9873 format_ip6_address, mp->dhcp_src_address,
9874 mp->vss_type, mp->vss_vpn_ascii_id,
9875 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9878 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9879 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9880 ntohl (mp->rx_vrf_id),
9881 format_ip4_address, mp->dhcp_src_address,
9882 mp->vss_type, mp->vss_vpn_ascii_id,
9883 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9885 for (i = 0; i < count; i++)
9887 s = &mp->servers[i];
9891 " Server Table-ID %d, Server Address %U",
9892 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9895 " Server Table-ID %d, Server Address %U",
9896 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9900 static void vl_api_dhcp_proxy_details_t_handler_json
9901 (vl_api_dhcp_proxy_details_t * mp)
9903 vat_main_t *vam = &vat_main;
9904 vat_json_node_t *node = NULL;
9905 u32 i, count = mp->count;
9907 struct in6_addr ip6;
9908 vl_api_dhcp_server_t *s;
9910 if (VAT_JSON_ARRAY != vam->json_tree.type)
9912 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9913 vat_json_init_array (&vam->json_tree);
9915 node = vat_json_array_add (&vam->json_tree);
9917 vat_json_init_object (node);
9918 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9919 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9920 sizeof (mp->vss_type));
9921 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9922 mp->vss_vpn_ascii_id);
9923 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9924 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9928 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9929 vat_json_object_add_ip6 (node, "src_address", ip6);
9933 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9934 vat_json_object_add_ip4 (node, "src_address", ip4);
9937 for (i = 0; i < count; i++)
9939 s = &mp->servers[i];
9941 vat_json_object_add_uint (node, "server-table-id",
9942 ntohl (s->server_vrf_id));
9946 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9947 vat_json_object_add_ip4 (node, "src_address", ip4);
9951 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9952 vat_json_object_add_ip6 (node, "server_address", ip6);
9958 api_dhcp_proxy_dump (vat_main_t * vam)
9960 unformat_input_t *i = vam->input;
9961 vl_api_control_ping_t *mp_ping;
9962 vl_api_dhcp_proxy_dump_t *mp;
9966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9968 if (unformat (i, "ipv6"))
9972 clib_warning ("parse error '%U'", format_unformat_error, i);
9977 M (DHCP_PROXY_DUMP, mp);
9979 mp->is_ip6 = is_ipv6;
9982 /* Use a control ping for synchronization */
9983 MPING (CONTROL_PING, mp_ping);
9991 api_dhcp_proxy_set_vss (vat_main_t * vam)
9993 unformat_input_t *i = vam->input;
9994 vl_api_dhcp_proxy_set_vss_t *mp;
9998 u8 vss_type = VSS_TYPE_DEFAULT;
9999 u8 *vpn_ascii_id = 0;
10004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10006 if (unformat (i, "tbl_id %d", &tbl_id))
10008 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10009 vss_type = VSS_TYPE_ASCII;
10010 else if (unformat (i, "fib_id %d", &fib_id))
10011 vss_type = VSS_TYPE_VPN_ID;
10012 else if (unformat (i, "oui %d", &oui))
10013 vss_type = VSS_TYPE_VPN_ID;
10014 else if (unformat (i, "ipv6"))
10016 else if (unformat (i, "del"))
10024 errmsg ("missing tbl_id ");
10025 vec_free (vpn_ascii_id);
10029 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10031 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10032 vec_free (vpn_ascii_id);
10036 M (DHCP_PROXY_SET_VSS, mp);
10037 mp->tbl_id = ntohl (tbl_id);
10038 mp->vss_type = vss_type;
10041 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10042 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10044 mp->vpn_index = ntohl (fib_id);
10045 mp->oui = ntohl (oui);
10046 mp->is_ipv6 = is_ipv6;
10047 mp->is_add = is_add;
10052 vec_free (vpn_ascii_id);
10057 api_dhcp_client_config (vat_main_t * vam)
10059 unformat_input_t *i = vam->input;
10060 vl_api_dhcp_client_config_t *mp;
10062 u8 sw_if_index_set = 0;
10065 u8 disable_event = 0;
10068 /* Parse args required to build the message */
10069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10071 if (unformat (i, "del"))
10074 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10075 sw_if_index_set = 1;
10076 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10077 sw_if_index_set = 1;
10078 else if (unformat (i, "hostname %s", &hostname))
10080 else if (unformat (i, "disable_event"))
10086 if (sw_if_index_set == 0)
10088 errmsg ("missing interface name or sw_if_index");
10092 if (vec_len (hostname) > 63)
10094 errmsg ("hostname too long");
10096 vec_add1 (hostname, 0);
10098 /* Construct the API message */
10099 M (DHCP_CLIENT_CONFIG, mp);
10101 mp->is_add = is_add;
10102 mp->client.sw_if_index = htonl (sw_if_index);
10103 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10104 vec_free (hostname);
10105 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10106 mp->client.pid = htonl (getpid ());
10111 /* Wait for a reply, return good/bad news */
10117 api_set_ip_flow_hash (vat_main_t * vam)
10119 unformat_input_t *i = vam->input;
10120 vl_api_set_ip_flow_hash_t *mp;
10132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10134 if (unformat (i, "vrf %d", &vrf_id))
10136 else if (unformat (i, "ipv6"))
10138 else if (unformat (i, "src"))
10140 else if (unformat (i, "dst"))
10142 else if (unformat (i, "sport"))
10144 else if (unformat (i, "dport"))
10146 else if (unformat (i, "proto"))
10148 else if (unformat (i, "reverse"))
10153 clib_warning ("parse error '%U'", format_unformat_error, i);
10158 if (vrf_id_set == 0)
10160 errmsg ("missing vrf id");
10164 M (SET_IP_FLOW_HASH, mp);
10170 mp->reverse = reverse;
10171 mp->vrf_id = ntohl (vrf_id);
10172 mp->is_ipv6 = is_ipv6;
10180 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10182 unformat_input_t *i = vam->input;
10183 vl_api_sw_interface_ip6_enable_disable_t *mp;
10185 u8 sw_if_index_set = 0;
10189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10191 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10192 sw_if_index_set = 1;
10193 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10194 sw_if_index_set = 1;
10195 else if (unformat (i, "enable"))
10197 else if (unformat (i, "disable"))
10201 clib_warning ("parse error '%U'", format_unformat_error, i);
10206 if (sw_if_index_set == 0)
10208 errmsg ("missing interface name or sw_if_index");
10212 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10214 mp->sw_if_index = ntohl (sw_if_index);
10215 mp->enable = enable;
10223 api_ip6nd_proxy_add_del (vat_main_t * vam)
10225 unformat_input_t *i = vam->input;
10226 vl_api_ip6nd_proxy_add_del_t *mp;
10227 u32 sw_if_index = ~0;
10228 u8 v6_address_set = 0;
10229 ip6_address_t v6address;
10233 /* Parse args required to build the message */
10234 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10236 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10238 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10240 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10241 v6_address_set = 1;
10242 if (unformat (i, "del"))
10246 clib_warning ("parse error '%U'", format_unformat_error, i);
10251 if (sw_if_index == ~0)
10253 errmsg ("missing interface name or sw_if_index");
10256 if (!v6_address_set)
10258 errmsg ("no address set");
10262 /* Construct the API message */
10263 M (IP6ND_PROXY_ADD_DEL, mp);
10265 mp->is_del = is_del;
10266 mp->sw_if_index = ntohl (sw_if_index);
10267 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10272 /* Wait for a reply, return good/bad news */
10278 api_ip6nd_proxy_dump (vat_main_t * vam)
10280 vl_api_ip6nd_proxy_dump_t *mp;
10281 vl_api_control_ping_t *mp_ping;
10284 M (IP6ND_PROXY_DUMP, mp);
10288 /* Use a control ping for synchronization */
10289 MPING (CONTROL_PING, mp_ping);
10296 static void vl_api_ip6nd_proxy_details_t_handler
10297 (vl_api_ip6nd_proxy_details_t * mp)
10299 vat_main_t *vam = &vat_main;
10301 print (vam->ofp, "host %U sw_if_index %d",
10302 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10305 static void vl_api_ip6nd_proxy_details_t_handler_json
10306 (vl_api_ip6nd_proxy_details_t * mp)
10308 vat_main_t *vam = &vat_main;
10309 struct in6_addr ip6;
10310 vat_json_node_t *node = NULL;
10312 if (VAT_JSON_ARRAY != vam->json_tree.type)
10314 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10315 vat_json_init_array (&vam->json_tree);
10317 node = vat_json_array_add (&vam->json_tree);
10319 vat_json_init_object (node);
10320 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10322 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10323 vat_json_object_add_ip6 (node, "host", ip6);
10327 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10329 unformat_input_t *i = vam->input;
10330 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10332 u8 sw_if_index_set = 0;
10333 u32 address_length = 0;
10334 u8 v6_address_set = 0;
10335 ip6_address_t v6address;
10336 u8 use_default = 0;
10337 u8 no_advertise = 0;
10339 u8 no_autoconfig = 0;
10342 u32 val_lifetime = 0;
10343 u32 pref_lifetime = 0;
10346 /* Parse args required to build the message */
10347 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10349 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10350 sw_if_index_set = 1;
10351 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10352 sw_if_index_set = 1;
10353 else if (unformat (i, "%U/%d",
10354 unformat_ip6_address, &v6address, &address_length))
10355 v6_address_set = 1;
10356 else if (unformat (i, "val_life %d", &val_lifetime))
10358 else if (unformat (i, "pref_life %d", &pref_lifetime))
10360 else if (unformat (i, "def"))
10362 else if (unformat (i, "noadv"))
10364 else if (unformat (i, "offl"))
10366 else if (unformat (i, "noauto"))
10368 else if (unformat (i, "nolink"))
10370 else if (unformat (i, "isno"))
10374 clib_warning ("parse error '%U'", format_unformat_error, i);
10379 if (sw_if_index_set == 0)
10381 errmsg ("missing interface name or sw_if_index");
10384 if (!v6_address_set)
10386 errmsg ("no address set");
10390 /* Construct the API message */
10391 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10393 mp->sw_if_index = ntohl (sw_if_index);
10394 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10395 mp->address_length = address_length;
10396 mp->use_default = use_default;
10397 mp->no_advertise = no_advertise;
10398 mp->off_link = off_link;
10399 mp->no_autoconfig = no_autoconfig;
10400 mp->no_onlink = no_onlink;
10402 mp->val_lifetime = ntohl (val_lifetime);
10403 mp->pref_lifetime = ntohl (pref_lifetime);
10408 /* Wait for a reply, return good/bad news */
10414 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10416 unformat_input_t *i = vam->input;
10417 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10419 u8 sw_if_index_set = 0;
10424 u8 send_unicast = 0;
10427 u8 default_router = 0;
10428 u32 max_interval = 0;
10429 u32 min_interval = 0;
10431 u32 initial_count = 0;
10432 u32 initial_interval = 0;
10436 /* Parse args required to build the message */
10437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10439 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10440 sw_if_index_set = 1;
10441 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10442 sw_if_index_set = 1;
10443 else if (unformat (i, "maxint %d", &max_interval))
10445 else if (unformat (i, "minint %d", &min_interval))
10447 else if (unformat (i, "life %d", &lifetime))
10449 else if (unformat (i, "count %d", &initial_count))
10451 else if (unformat (i, "interval %d", &initial_interval))
10453 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10455 else if (unformat (i, "managed"))
10457 else if (unformat (i, "other"))
10459 else if (unformat (i, "ll"))
10461 else if (unformat (i, "send"))
10463 else if (unformat (i, "cease"))
10465 else if (unformat (i, "isno"))
10467 else if (unformat (i, "def"))
10468 default_router = 1;
10471 clib_warning ("parse error '%U'", format_unformat_error, i);
10476 if (sw_if_index_set == 0)
10478 errmsg ("missing interface name or sw_if_index");
10482 /* Construct the API message */
10483 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10485 mp->sw_if_index = ntohl (sw_if_index);
10486 mp->max_interval = ntohl (max_interval);
10487 mp->min_interval = ntohl (min_interval);
10488 mp->lifetime = ntohl (lifetime);
10489 mp->initial_count = ntohl (initial_count);
10490 mp->initial_interval = ntohl (initial_interval);
10491 mp->suppress = suppress;
10492 mp->managed = managed;
10494 mp->ll_option = ll_option;
10495 mp->send_unicast = send_unicast;
10498 mp->default_router = default_router;
10503 /* Wait for a reply, return good/bad news */
10509 api_set_arp_neighbor_limit (vat_main_t * vam)
10511 unformat_input_t *i = vam->input;
10512 vl_api_set_arp_neighbor_limit_t *mp;
10518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10520 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10522 else if (unformat (i, "ipv6"))
10526 clib_warning ("parse error '%U'", format_unformat_error, i);
10531 if (limit_set == 0)
10533 errmsg ("missing limit value");
10537 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10539 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10540 mp->is_ipv6 = is_ipv6;
10548 api_l2_patch_add_del (vat_main_t * vam)
10550 unformat_input_t *i = vam->input;
10551 vl_api_l2_patch_add_del_t *mp;
10552 u32 rx_sw_if_index;
10553 u8 rx_sw_if_index_set = 0;
10554 u32 tx_sw_if_index;
10555 u8 tx_sw_if_index_set = 0;
10559 /* Parse args required to build the message */
10560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10562 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10563 rx_sw_if_index_set = 1;
10564 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10565 tx_sw_if_index_set = 1;
10566 else if (unformat (i, "rx"))
10568 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10570 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10572 rx_sw_if_index_set = 1;
10577 else if (unformat (i, "tx"))
10579 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10581 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10583 tx_sw_if_index_set = 1;
10588 else if (unformat (i, "del"))
10594 if (rx_sw_if_index_set == 0)
10596 errmsg ("missing rx interface name or rx_sw_if_index");
10600 if (tx_sw_if_index_set == 0)
10602 errmsg ("missing tx interface name or tx_sw_if_index");
10606 M (L2_PATCH_ADD_DEL, mp);
10608 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10609 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10610 mp->is_add = is_add;
10618 u8 localsid_addr[16];
10627 api_sr_localsid_add_del (vat_main_t * vam)
10629 unformat_input_t *i = vam->input;
10630 vl_api_sr_localsid_add_del_t *mp;
10633 ip6_address_t localsid;
10637 u32 fib_table = ~(u32) 0;
10638 ip6_address_t nh_addr6;
10639 ip4_address_t nh_addr4;
10640 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10641 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10643 bool nexthop_set = 0;
10647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10649 if (unformat (i, "del"))
10651 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10652 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10654 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10656 else if (unformat (i, "behavior %u", &behavior));
10657 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10658 else if (unformat (i, "fib-table %u", &fib_table));
10659 else if (unformat (i, "end.psp %u", &behavior));
10664 M (SR_LOCALSID_ADD_DEL, mp);
10666 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10669 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10670 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10672 mp->behavior = behavior;
10673 mp->sw_if_index = ntohl (sw_if_index);
10674 mp->fib_table = ntohl (fib_table);
10675 mp->end_psp = end_psp;
10676 mp->is_del = is_del;
10684 api_ioam_enable (vat_main_t * vam)
10686 unformat_input_t *input = vam->input;
10687 vl_api_ioam_enable_t *mp;
10689 int has_trace_option = 0;
10690 int has_pot_option = 0;
10691 int has_seqno_option = 0;
10692 int has_analyse_option = 0;
10695 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10697 if (unformat (input, "trace"))
10698 has_trace_option = 1;
10699 else if (unformat (input, "pot"))
10700 has_pot_option = 1;
10701 else if (unformat (input, "seqno"))
10702 has_seqno_option = 1;
10703 else if (unformat (input, "analyse"))
10704 has_analyse_option = 1;
10708 M (IOAM_ENABLE, mp);
10709 mp->id = htons (id);
10710 mp->seqno = has_seqno_option;
10711 mp->analyse = has_analyse_option;
10712 mp->pot_enable = has_pot_option;
10713 mp->trace_enable = has_trace_option;
10722 api_ioam_disable (vat_main_t * vam)
10724 vl_api_ioam_disable_t *mp;
10727 M (IOAM_DISABLE, mp);
10733 #define foreach_tcp_proto_field \
10737 #define foreach_udp_proto_field \
10741 #define foreach_ip4_proto_field \
10753 u16 src_port, dst_port;
10756 #if VPP_API_TEST_BUILTIN == 0
10758 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10760 u8 **maskp = va_arg (*args, u8 **);
10762 u8 found_something = 0;
10765 #define _(a) u8 a=0;
10766 foreach_tcp_proto_field;
10769 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10772 #define _(a) else if (unformat (input, #a)) a=1;
10773 foreach_tcp_proto_field
10779 #define _(a) found_something += a;
10780 foreach_tcp_proto_field;
10783 if (found_something == 0)
10786 vec_validate (mask, sizeof (*tcp) - 1);
10788 tcp = (tcp_header_t *) mask;
10790 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10791 foreach_tcp_proto_field;
10799 unformat_udp_mask (unformat_input_t * input, va_list * args)
10801 u8 **maskp = va_arg (*args, u8 **);
10803 u8 found_something = 0;
10806 #define _(a) u8 a=0;
10807 foreach_udp_proto_field;
10810 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10813 #define _(a) else if (unformat (input, #a)) a=1;
10814 foreach_udp_proto_field
10820 #define _(a) found_something += a;
10821 foreach_udp_proto_field;
10824 if (found_something == 0)
10827 vec_validate (mask, sizeof (*udp) - 1);
10829 udp = (udp_header_t *) mask;
10831 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10832 foreach_udp_proto_field;
10840 unformat_l4_mask (unformat_input_t * input, va_list * args)
10842 u8 **maskp = va_arg (*args, u8 **);
10843 u16 src_port = 0, dst_port = 0;
10844 tcpudp_header_t *tcpudp;
10846 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10848 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10850 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10852 else if (unformat (input, "src_port"))
10854 else if (unformat (input, "dst_port"))
10860 if (!src_port && !dst_port)
10864 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10866 tcpudp = (tcpudp_header_t *) mask;
10867 tcpudp->src_port = src_port;
10868 tcpudp->dst_port = dst_port;
10876 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10878 u8 **maskp = va_arg (*args, u8 **);
10880 u8 found_something = 0;
10883 #define _(a) u8 a=0;
10884 foreach_ip4_proto_field;
10890 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10892 if (unformat (input, "version"))
10894 else if (unformat (input, "hdr_length"))
10896 else if (unformat (input, "src"))
10898 else if (unformat (input, "dst"))
10900 else if (unformat (input, "proto"))
10903 #define _(a) else if (unformat (input, #a)) a=1;
10904 foreach_ip4_proto_field
10910 #define _(a) found_something += a;
10911 foreach_ip4_proto_field;
10914 if (found_something == 0)
10917 vec_validate (mask, sizeof (*ip) - 1);
10919 ip = (ip4_header_t *) mask;
10921 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10922 foreach_ip4_proto_field;
10925 ip->ip_version_and_header_length = 0;
10928 ip->ip_version_and_header_length |= 0xF0;
10931 ip->ip_version_and_header_length |= 0x0F;
10937 #define foreach_ip6_proto_field \
10940 _(payload_length) \
10945 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10947 u8 **maskp = va_arg (*args, u8 **);
10949 u8 found_something = 0;
10951 u32 ip_version_traffic_class_and_flow_label;
10953 #define _(a) u8 a=0;
10954 foreach_ip6_proto_field;
10957 u8 traffic_class = 0;
10960 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10962 if (unformat (input, "version"))
10964 else if (unformat (input, "traffic-class"))
10966 else if (unformat (input, "flow-label"))
10968 else if (unformat (input, "src"))
10970 else if (unformat (input, "dst"))
10972 else if (unformat (input, "proto"))
10975 #define _(a) else if (unformat (input, #a)) a=1;
10976 foreach_ip6_proto_field
10982 #define _(a) found_something += a;
10983 foreach_ip6_proto_field;
10986 if (found_something == 0)
10989 vec_validate (mask, sizeof (*ip) - 1);
10991 ip = (ip6_header_t *) mask;
10993 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10994 foreach_ip6_proto_field;
10997 ip_version_traffic_class_and_flow_label = 0;
11000 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11003 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11006 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11008 ip->ip_version_traffic_class_and_flow_label =
11009 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11016 unformat_l3_mask (unformat_input_t * input, va_list * args)
11018 u8 **maskp = va_arg (*args, u8 **);
11020 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11022 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11024 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11033 unformat_l2_mask (unformat_input_t * input, va_list * args)
11035 u8 **maskp = va_arg (*args, u8 **);
11042 u8 ignore_tag1 = 0;
11043 u8 ignore_tag2 = 0;
11050 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11052 if (unformat (input, "src"))
11054 else if (unformat (input, "dst"))
11056 else if (unformat (input, "proto"))
11058 else if (unformat (input, "tag1"))
11060 else if (unformat (input, "tag2"))
11062 else if (unformat (input, "ignore-tag1"))
11064 else if (unformat (input, "ignore-tag2"))
11066 else if (unformat (input, "cos1"))
11068 else if (unformat (input, "cos2"))
11070 else if (unformat (input, "dot1q"))
11072 else if (unformat (input, "dot1ad"))
11077 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11078 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11081 if (tag1 || ignore_tag1 || cos1 || dot1q)
11083 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11086 vec_validate (mask, len - 1);
11089 clib_memset (mask, 0xff, 6);
11092 clib_memset (mask + 6, 0xff, 6);
11094 if (tag2 || dot1ad)
11096 /* inner vlan tag */
11105 mask[21] = mask[20] = 0xff;
11126 mask[16] = mask[17] = 0xff;
11136 mask[12] = mask[13] = 0xff;
11143 unformat_classify_mask (unformat_input_t * input, va_list * args)
11145 u8 **maskp = va_arg (*args, u8 **);
11146 u32 *skipp = va_arg (*args, u32 *);
11147 u32 *matchp = va_arg (*args, u32 *);
11155 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11157 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11159 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11161 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11163 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11177 if (mask || l2 || l3 || l4)
11179 if (l2 || l3 || l4)
11181 /* "With a free Ethernet header in every package" */
11183 vec_validate (l2, 13);
11187 vec_append (mask, l3);
11192 vec_append (mask, l4);
11197 /* Scan forward looking for the first significant mask octet */
11198 for (i = 0; i < vec_len (mask); i++)
11202 /* compute (skip, match) params */
11203 *skipp = i / sizeof (u32x4);
11204 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11206 /* Pad mask to an even multiple of the vector size */
11207 while (vec_len (mask) % sizeof (u32x4))
11208 vec_add1 (mask, 0);
11210 match = vec_len (mask) / sizeof (u32x4);
11212 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11214 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11215 if (*tmp || *(tmp + 1))
11220 clib_warning ("BUG: match 0");
11222 _vec_len (mask) = match * sizeof (u32x4);
11232 #endif /* VPP_API_TEST_BUILTIN */
11234 #define foreach_l2_next \
11236 _(ethernet, ETHERNET_INPUT) \
11237 _(ip4, IP4_INPUT) \
11241 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11243 u32 *miss_next_indexp = va_arg (*args, u32 *);
11244 u32 next_index = 0;
11248 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11252 if (unformat (input, "%d", &tmp))
11261 *miss_next_indexp = next_index;
11265 #define foreach_ip_next \
11268 _(rewrite, REWRITE)
11271 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11273 u32 *miss_next_indexp = va_arg (*args, u32 *);
11274 u32 next_index = 0;
11278 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11282 if (unformat (input, "%d", &tmp))
11291 *miss_next_indexp = next_index;
11295 #define foreach_acl_next \
11299 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11301 u32 *miss_next_indexp = va_arg (*args, u32 *);
11302 u32 next_index = 0;
11306 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11310 if (unformat (input, "permit"))
11315 else if (unformat (input, "%d", &tmp))
11324 *miss_next_indexp = next_index;
11329 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11331 u32 *r = va_arg (*args, u32 *);
11333 if (unformat (input, "conform-color"))
11334 *r = POLICE_CONFORM;
11335 else if (unformat (input, "exceed-color"))
11336 *r = POLICE_EXCEED;
11344 api_classify_add_del_table (vat_main_t * vam)
11346 unformat_input_t *i = vam->input;
11347 vl_api_classify_add_del_table_t *mp;
11354 u32 table_index = ~0;
11355 u32 next_table_index = ~0;
11356 u32 miss_next_index = ~0;
11357 u32 memory_size = 32 << 20;
11359 u32 current_data_flag = 0;
11360 int current_data_offset = 0;
11363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11365 if (unformat (i, "del"))
11367 else if (unformat (i, "del-chain"))
11372 else if (unformat (i, "buckets %d", &nbuckets))
11374 else if (unformat (i, "memory_size %d", &memory_size))
11376 else if (unformat (i, "skip %d", &skip))
11378 else if (unformat (i, "match %d", &match))
11380 else if (unformat (i, "table %d", &table_index))
11382 else if (unformat (i, "mask %U", unformat_classify_mask,
11383 &mask, &skip, &match))
11385 else if (unformat (i, "next-table %d", &next_table_index))
11387 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11390 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11393 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11396 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11398 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11404 if (is_add && mask == 0)
11406 errmsg ("Mask required");
11410 if (is_add && skip == ~0)
11412 errmsg ("skip count required");
11416 if (is_add && match == ~0)
11418 errmsg ("match count required");
11422 if (!is_add && table_index == ~0)
11424 errmsg ("table index required for delete");
11428 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11430 mp->is_add = is_add;
11431 mp->del_chain = del_chain;
11432 mp->table_index = ntohl (table_index);
11433 mp->nbuckets = ntohl (nbuckets);
11434 mp->memory_size = ntohl (memory_size);
11435 mp->skip_n_vectors = ntohl (skip);
11436 mp->match_n_vectors = ntohl (match);
11437 mp->next_table_index = ntohl (next_table_index);
11438 mp->miss_next_index = ntohl (miss_next_index);
11439 mp->current_data_flag = ntohl (current_data_flag);
11440 mp->current_data_offset = ntohl (current_data_offset);
11441 mp->mask_len = ntohl (vec_len (mask));
11442 clib_memcpy (mp->mask, mask, vec_len (mask));
11451 #if VPP_API_TEST_BUILTIN == 0
11453 unformat_l4_match (unformat_input_t * input, va_list * args)
11455 u8 **matchp = va_arg (*args, u8 **);
11457 u8 *proto_header = 0;
11463 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11465 if (unformat (input, "src_port %d", &src_port))
11467 else if (unformat (input, "dst_port %d", &dst_port))
11473 h.src_port = clib_host_to_net_u16 (src_port);
11474 h.dst_port = clib_host_to_net_u16 (dst_port);
11475 vec_validate (proto_header, sizeof (h) - 1);
11476 memcpy (proto_header, &h, sizeof (h));
11478 *matchp = proto_header;
11484 unformat_ip4_match (unformat_input_t * input, va_list * args)
11486 u8 **matchp = va_arg (*args, u8 **);
11491 int hdr_length = 0;
11492 u32 hdr_length_val;
11493 int src = 0, dst = 0;
11494 ip4_address_t src_val, dst_val;
11501 int fragment_id = 0;
11502 u32 fragment_id_val;
11508 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11510 if (unformat (input, "version %d", &version_val))
11512 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11514 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11516 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11518 else if (unformat (input, "proto %d", &proto_val))
11520 else if (unformat (input, "tos %d", &tos_val))
11522 else if (unformat (input, "length %d", &length_val))
11524 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11526 else if (unformat (input, "ttl %d", &ttl_val))
11528 else if (unformat (input, "checksum %d", &checksum_val))
11534 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11535 + ttl + checksum == 0)
11539 * Aligned because we use the real comparison functions
11541 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11543 ip = (ip4_header_t *) match;
11545 /* These are realistically matched in practice */
11547 ip->src_address.as_u32 = src_val.as_u32;
11550 ip->dst_address.as_u32 = dst_val.as_u32;
11553 ip->protocol = proto_val;
11556 /* These are not, but they're included for completeness */
11558 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11561 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11567 ip->length = clib_host_to_net_u16 (length_val);
11573 ip->checksum = clib_host_to_net_u16 (checksum_val);
11580 unformat_ip6_match (unformat_input_t * input, va_list * args)
11582 u8 **matchp = va_arg (*args, u8 **);
11587 u8 traffic_class = 0;
11588 u32 traffic_class_val = 0;
11591 int src = 0, dst = 0;
11592 ip6_address_t src_val, dst_val;
11595 int payload_length = 0;
11596 u32 payload_length_val;
11599 u32 ip_version_traffic_class_and_flow_label;
11601 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11603 if (unformat (input, "version %d", &version_val))
11605 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11607 else if (unformat (input, "flow_label %d", &flow_label_val))
11609 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11611 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11613 else if (unformat (input, "proto %d", &proto_val))
11615 else if (unformat (input, "payload_length %d", &payload_length_val))
11616 payload_length = 1;
11617 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11623 if (version + traffic_class + flow_label + src + dst + proto +
11624 payload_length + hop_limit == 0)
11628 * Aligned because we use the real comparison functions
11630 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11632 ip = (ip6_header_t *) match;
11635 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11638 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11641 ip->protocol = proto_val;
11643 ip_version_traffic_class_and_flow_label = 0;
11646 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11649 ip_version_traffic_class_and_flow_label |=
11650 (traffic_class_val & 0xFF) << 20;
11653 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11655 ip->ip_version_traffic_class_and_flow_label =
11656 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11658 if (payload_length)
11659 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11662 ip->hop_limit = hop_limit_val;
11669 unformat_l3_match (unformat_input_t * input, va_list * args)
11671 u8 **matchp = va_arg (*args, u8 **);
11673 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11675 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11677 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11686 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11688 u8 *tagp = va_arg (*args, u8 *);
11691 if (unformat (input, "%d", &tag))
11693 tagp[0] = (tag >> 8) & 0x0F;
11694 tagp[1] = tag & 0xFF;
11702 unformat_l2_match (unformat_input_t * input, va_list * args)
11704 u8 **matchp = va_arg (*args, u8 **);
11717 u8 ignore_tag1 = 0;
11718 u8 ignore_tag2 = 0;
11724 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11726 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11729 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11731 else if (unformat (input, "proto %U",
11732 unformat_ethernet_type_host_byte_order, &proto_val))
11734 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11736 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11738 else if (unformat (input, "ignore-tag1"))
11740 else if (unformat (input, "ignore-tag2"))
11742 else if (unformat (input, "cos1 %d", &cos1_val))
11744 else if (unformat (input, "cos2 %d", &cos2_val))
11749 if ((src + dst + proto + tag1 + tag2 +
11750 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11753 if (tag1 || ignore_tag1 || cos1)
11755 if (tag2 || ignore_tag2 || cos2)
11758 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11761 clib_memcpy (match, dst_val, 6);
11764 clib_memcpy (match + 6, src_val, 6);
11768 /* inner vlan tag */
11769 match[19] = tag2_val[1];
11770 match[18] = tag2_val[0];
11772 match[18] |= (cos2_val & 0x7) << 5;
11775 match[21] = proto_val & 0xff;
11776 match[20] = proto_val >> 8;
11780 match[15] = tag1_val[1];
11781 match[14] = tag1_val[0];
11784 match[14] |= (cos1_val & 0x7) << 5;
11790 match[15] = tag1_val[1];
11791 match[14] = tag1_val[0];
11794 match[17] = proto_val & 0xff;
11795 match[16] = proto_val >> 8;
11798 match[14] |= (cos1_val & 0x7) << 5;
11804 match[18] |= (cos2_val & 0x7) << 5;
11806 match[14] |= (cos1_val & 0x7) << 5;
11809 match[13] = proto_val & 0xff;
11810 match[12] = proto_val >> 8;
11818 unformat_qos_source (unformat_input_t * input, va_list * args)
11820 int *qs = va_arg (*args, int *);
11822 if (unformat (input, "ip"))
11823 *qs = QOS_SOURCE_IP;
11824 else if (unformat (input, "mpls"))
11825 *qs = QOS_SOURCE_MPLS;
11826 else if (unformat (input, "ext"))
11827 *qs = QOS_SOURCE_EXT;
11828 else if (unformat (input, "vlan"))
11829 *qs = QOS_SOURCE_VLAN;
11838 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11840 u8 **matchp = va_arg (*args, u8 **);
11841 u32 skip_n_vectors = va_arg (*args, u32);
11842 u32 match_n_vectors = va_arg (*args, u32);
11849 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11851 if (unformat (input, "hex %U", unformat_hex_string, &match))
11853 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11855 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11857 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11871 if (match || l2 || l3 || l4)
11873 if (l2 || l3 || l4)
11875 /* "Win a free Ethernet header in every packet" */
11877 vec_validate_aligned (l2, 13, sizeof (u32x4));
11881 vec_append_aligned (match, l3, sizeof (u32x4));
11886 vec_append_aligned (match, l4, sizeof (u32x4));
11891 /* Make sure the vector is big enough even if key is all 0's */
11892 vec_validate_aligned
11893 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11896 /* Set size, include skipped vectors */
11897 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11908 api_classify_add_del_session (vat_main_t * vam)
11910 unformat_input_t *i = vam->input;
11911 vl_api_classify_add_del_session_t *mp;
11913 u32 table_index = ~0;
11914 u32 hit_next_index = ~0;
11915 u32 opaque_index = ~0;
11918 u32 skip_n_vectors = 0;
11919 u32 match_n_vectors = 0;
11925 * Warning: you have to supply skip_n and match_n
11926 * because the API client cant simply look at the classify
11930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11932 if (unformat (i, "del"))
11934 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11937 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11940 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11943 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11945 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11947 else if (unformat (i, "opaque-index %d", &opaque_index))
11949 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11951 else if (unformat (i, "match_n %d", &match_n_vectors))
11953 else if (unformat (i, "match %U", api_unformat_classify_match,
11954 &match, skip_n_vectors, match_n_vectors))
11956 else if (unformat (i, "advance %d", &advance))
11958 else if (unformat (i, "table-index %d", &table_index))
11960 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11962 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11964 else if (unformat (i, "action %d", &action))
11966 else if (unformat (i, "metadata %d", &metadata))
11972 if (table_index == ~0)
11974 errmsg ("Table index required");
11978 if (is_add && match == 0)
11980 errmsg ("Match value required");
11984 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11986 mp->is_add = is_add;
11987 mp->table_index = ntohl (table_index);
11988 mp->hit_next_index = ntohl (hit_next_index);
11989 mp->opaque_index = ntohl (opaque_index);
11990 mp->advance = ntohl (advance);
11991 mp->action = action;
11992 mp->metadata = ntohl (metadata);
11993 mp->match_len = ntohl (vec_len (match));
11994 clib_memcpy (mp->match, match, vec_len (match));
12003 api_classify_set_interface_ip_table (vat_main_t * vam)
12005 unformat_input_t *i = vam->input;
12006 vl_api_classify_set_interface_ip_table_t *mp;
12008 int sw_if_index_set;
12009 u32 table_index = ~0;
12013 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12015 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12016 sw_if_index_set = 1;
12017 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12018 sw_if_index_set = 1;
12019 else if (unformat (i, "table %d", &table_index))
12023 clib_warning ("parse error '%U'", format_unformat_error, i);
12028 if (sw_if_index_set == 0)
12030 errmsg ("missing interface name or sw_if_index");
12035 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12037 mp->sw_if_index = ntohl (sw_if_index);
12038 mp->table_index = ntohl (table_index);
12039 mp->is_ipv6 = is_ipv6;
12047 api_classify_set_interface_l2_tables (vat_main_t * vam)
12049 unformat_input_t *i = vam->input;
12050 vl_api_classify_set_interface_l2_tables_t *mp;
12052 int sw_if_index_set;
12053 u32 ip4_table_index = ~0;
12054 u32 ip6_table_index = ~0;
12055 u32 other_table_index = ~0;
12059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12061 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12062 sw_if_index_set = 1;
12063 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12064 sw_if_index_set = 1;
12065 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12067 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12069 else if (unformat (i, "other-table %d", &other_table_index))
12071 else if (unformat (i, "is-input %d", &is_input))
12075 clib_warning ("parse error '%U'", format_unformat_error, i);
12080 if (sw_if_index_set == 0)
12082 errmsg ("missing interface name or sw_if_index");
12087 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12089 mp->sw_if_index = ntohl (sw_if_index);
12090 mp->ip4_table_index = ntohl (ip4_table_index);
12091 mp->ip6_table_index = ntohl (ip6_table_index);
12092 mp->other_table_index = ntohl (other_table_index);
12093 mp->is_input = (u8) is_input;
12101 api_set_ipfix_exporter (vat_main_t * vam)
12103 unformat_input_t *i = vam->input;
12104 vl_api_set_ipfix_exporter_t *mp;
12105 ip4_address_t collector_address;
12106 u8 collector_address_set = 0;
12107 u32 collector_port = ~0;
12108 ip4_address_t src_address;
12109 u8 src_address_set = 0;
12112 u32 template_interval = ~0;
12113 u8 udp_checksum = 0;
12116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12118 if (unformat (i, "collector_address %U", unformat_ip4_address,
12119 &collector_address))
12120 collector_address_set = 1;
12121 else if (unformat (i, "collector_port %d", &collector_port))
12123 else if (unformat (i, "src_address %U", unformat_ip4_address,
12125 src_address_set = 1;
12126 else if (unformat (i, "vrf_id %d", &vrf_id))
12128 else if (unformat (i, "path_mtu %d", &path_mtu))
12130 else if (unformat (i, "template_interval %d", &template_interval))
12132 else if (unformat (i, "udp_checksum"))
12138 if (collector_address_set == 0)
12140 errmsg ("collector_address required");
12144 if (src_address_set == 0)
12146 errmsg ("src_address required");
12150 M (SET_IPFIX_EXPORTER, mp);
12152 memcpy (mp->collector_address, collector_address.data,
12153 sizeof (collector_address.data));
12154 mp->collector_port = htons ((u16) collector_port);
12155 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12156 mp->vrf_id = htonl (vrf_id);
12157 mp->path_mtu = htonl (path_mtu);
12158 mp->template_interval = htonl (template_interval);
12159 mp->udp_checksum = udp_checksum;
12167 api_set_ipfix_classify_stream (vat_main_t * vam)
12169 unformat_input_t *i = vam->input;
12170 vl_api_set_ipfix_classify_stream_t *mp;
12172 u32 src_port = UDP_DST_PORT_ipfix;
12175 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12177 if (unformat (i, "domain %d", &domain_id))
12179 else if (unformat (i, "src_port %d", &src_port))
12183 errmsg ("unknown input `%U'", format_unformat_error, i);
12188 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12190 mp->domain_id = htonl (domain_id);
12191 mp->src_port = htons ((u16) src_port);
12199 api_ipfix_classify_table_add_del (vat_main_t * vam)
12201 unformat_input_t *i = vam->input;
12202 vl_api_ipfix_classify_table_add_del_t *mp;
12204 u32 classify_table_index = ~0;
12206 u8 transport_protocol = 255;
12209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12211 if (unformat (i, "add"))
12213 else if (unformat (i, "del"))
12215 else if (unformat (i, "table %d", &classify_table_index))
12217 else if (unformat (i, "ip4"))
12219 else if (unformat (i, "ip6"))
12221 else if (unformat (i, "tcp"))
12222 transport_protocol = 6;
12223 else if (unformat (i, "udp"))
12224 transport_protocol = 17;
12227 errmsg ("unknown input `%U'", format_unformat_error, i);
12234 errmsg ("expecting: add|del");
12237 if (classify_table_index == ~0)
12239 errmsg ("classifier table not specified");
12242 if (ip_version == 0)
12244 errmsg ("IP version not specified");
12248 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12250 mp->is_add = is_add;
12251 mp->table_id = htonl (classify_table_index);
12252 mp->ip_version = ip_version;
12253 mp->transport_protocol = transport_protocol;
12261 api_get_node_index (vat_main_t * vam)
12263 unformat_input_t *i = vam->input;
12264 vl_api_get_node_index_t *mp;
12268 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12270 if (unformat (i, "node %s", &name))
12277 errmsg ("node name required");
12280 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12282 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12286 M (GET_NODE_INDEX, mp);
12287 clib_memcpy (mp->node_name, name, vec_len (name));
12296 api_get_next_index (vat_main_t * vam)
12298 unformat_input_t *i = vam->input;
12299 vl_api_get_next_index_t *mp;
12300 u8 *node_name = 0, *next_node_name = 0;
12303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12305 if (unformat (i, "node-name %s", &node_name))
12307 else if (unformat (i, "next-node-name %s", &next_node_name))
12311 if (node_name == 0)
12313 errmsg ("node name required");
12316 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12318 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12322 if (next_node_name == 0)
12324 errmsg ("next node name required");
12327 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12329 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12333 M (GET_NEXT_INDEX, mp);
12334 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12335 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12336 vec_free (node_name);
12337 vec_free (next_node_name);
12345 api_add_node_next (vat_main_t * vam)
12347 unformat_input_t *i = vam->input;
12348 vl_api_add_node_next_t *mp;
12353 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12355 if (unformat (i, "node %s", &name))
12357 else if (unformat (i, "next %s", &next))
12364 errmsg ("node name required");
12367 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12369 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12374 errmsg ("next node required");
12377 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12379 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12383 M (ADD_NODE_NEXT, mp);
12384 clib_memcpy (mp->node_name, name, vec_len (name));
12385 clib_memcpy (mp->next_name, next, vec_len (next));
12395 api_l2tpv3_create_tunnel (vat_main_t * vam)
12397 unformat_input_t *i = vam->input;
12398 ip6_address_t client_address, our_address;
12399 int client_address_set = 0;
12400 int our_address_set = 0;
12401 u32 local_session_id = 0;
12402 u32 remote_session_id = 0;
12403 u64 local_cookie = 0;
12404 u64 remote_cookie = 0;
12405 u8 l2_sublayer_present = 0;
12406 vl_api_l2tpv3_create_tunnel_t *mp;
12409 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12411 if (unformat (i, "client_address %U", unformat_ip6_address,
12413 client_address_set = 1;
12414 else if (unformat (i, "our_address %U", unformat_ip6_address,
12416 our_address_set = 1;
12417 else if (unformat (i, "local_session_id %d", &local_session_id))
12419 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12421 else if (unformat (i, "local_cookie %lld", &local_cookie))
12423 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12425 else if (unformat (i, "l2-sublayer-present"))
12426 l2_sublayer_present = 1;
12431 if (client_address_set == 0)
12433 errmsg ("client_address required");
12437 if (our_address_set == 0)
12439 errmsg ("our_address required");
12443 M (L2TPV3_CREATE_TUNNEL, mp);
12445 clib_memcpy (mp->client_address, client_address.as_u8,
12446 sizeof (mp->client_address));
12448 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12450 mp->local_session_id = ntohl (local_session_id);
12451 mp->remote_session_id = ntohl (remote_session_id);
12452 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12453 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12454 mp->l2_sublayer_present = l2_sublayer_present;
12463 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12465 unformat_input_t *i = vam->input;
12467 u8 sw_if_index_set = 0;
12468 u64 new_local_cookie = 0;
12469 u64 new_remote_cookie = 0;
12470 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12475 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12476 sw_if_index_set = 1;
12477 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12478 sw_if_index_set = 1;
12479 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12481 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12487 if (sw_if_index_set == 0)
12489 errmsg ("missing interface name or sw_if_index");
12493 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12495 mp->sw_if_index = ntohl (sw_if_index);
12496 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12497 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12505 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12507 unformat_input_t *i = vam->input;
12508 vl_api_l2tpv3_interface_enable_disable_t *mp;
12510 u8 sw_if_index_set = 0;
12511 u8 enable_disable = 1;
12514 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12516 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12517 sw_if_index_set = 1;
12518 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12519 sw_if_index_set = 1;
12520 else if (unformat (i, "enable"))
12521 enable_disable = 1;
12522 else if (unformat (i, "disable"))
12523 enable_disable = 0;
12528 if (sw_if_index_set == 0)
12530 errmsg ("missing interface name or sw_if_index");
12534 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12536 mp->sw_if_index = ntohl (sw_if_index);
12537 mp->enable_disable = enable_disable;
12545 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12547 unformat_input_t *i = vam->input;
12548 vl_api_l2tpv3_set_lookup_key_t *mp;
12552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12554 if (unformat (i, "lookup_v6_src"))
12555 key = L2T_LOOKUP_SRC_ADDRESS;
12556 else if (unformat (i, "lookup_v6_dst"))
12557 key = L2T_LOOKUP_DST_ADDRESS;
12558 else if (unformat (i, "lookup_session_id"))
12559 key = L2T_LOOKUP_SESSION_ID;
12564 if (key == (u8) ~ 0)
12566 errmsg ("l2tp session lookup key unset");
12570 M (L2TPV3_SET_LOOKUP_KEY, mp);
12579 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12580 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12582 vat_main_t *vam = &vat_main;
12584 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12585 format_ip6_address, mp->our_address,
12586 format_ip6_address, mp->client_address,
12587 clib_net_to_host_u32 (mp->sw_if_index));
12590 " local cookies %016llx %016llx remote cookie %016llx",
12591 clib_net_to_host_u64 (mp->local_cookie[0]),
12592 clib_net_to_host_u64 (mp->local_cookie[1]),
12593 clib_net_to_host_u64 (mp->remote_cookie));
12595 print (vam->ofp, " local session-id %d remote session-id %d",
12596 clib_net_to_host_u32 (mp->local_session_id),
12597 clib_net_to_host_u32 (mp->remote_session_id));
12599 print (vam->ofp, " l2 specific sublayer %s\n",
12600 mp->l2_sublayer_present ? "preset" : "absent");
12604 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12605 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12607 vat_main_t *vam = &vat_main;
12608 vat_json_node_t *node = NULL;
12609 struct in6_addr addr;
12611 if (VAT_JSON_ARRAY != vam->json_tree.type)
12613 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12614 vat_json_init_array (&vam->json_tree);
12616 node = vat_json_array_add (&vam->json_tree);
12618 vat_json_init_object (node);
12620 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12621 vat_json_object_add_ip6 (node, "our_address", addr);
12622 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12623 vat_json_object_add_ip6 (node, "client_address", addr);
12625 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12626 vat_json_init_array (lc);
12627 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12628 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12629 vat_json_object_add_uint (node, "remote_cookie",
12630 clib_net_to_host_u64 (mp->remote_cookie));
12632 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12633 vat_json_object_add_uint (node, "local_session_id",
12634 clib_net_to_host_u32 (mp->local_session_id));
12635 vat_json_object_add_uint (node, "remote_session_id",
12636 clib_net_to_host_u32 (mp->remote_session_id));
12637 vat_json_object_add_string_copy (node, "l2_sublayer",
12638 mp->l2_sublayer_present ? (u8 *) "present"
12639 : (u8 *) "absent");
12643 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12645 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12646 vl_api_control_ping_t *mp_ping;
12649 /* Get list of l2tpv3-tunnel interfaces */
12650 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12653 /* Use a control ping for synchronization */
12654 MPING (CONTROL_PING, mp_ping);
12662 static void vl_api_sw_interface_tap_details_t_handler
12663 (vl_api_sw_interface_tap_details_t * mp)
12665 vat_main_t *vam = &vat_main;
12667 print (vam->ofp, "%-16s %d",
12668 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12671 static void vl_api_sw_interface_tap_details_t_handler_json
12672 (vl_api_sw_interface_tap_details_t * mp)
12674 vat_main_t *vam = &vat_main;
12675 vat_json_node_t *node = NULL;
12677 if (VAT_JSON_ARRAY != vam->json_tree.type)
12679 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12680 vat_json_init_array (&vam->json_tree);
12682 node = vat_json_array_add (&vam->json_tree);
12684 vat_json_init_object (node);
12685 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12686 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12690 api_sw_interface_tap_dump (vat_main_t * vam)
12692 vl_api_sw_interface_tap_dump_t *mp;
12693 vl_api_control_ping_t *mp_ping;
12696 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12697 /* Get list of tap interfaces */
12698 M (SW_INTERFACE_TAP_DUMP, mp);
12701 /* Use a control ping for synchronization */
12702 MPING (CONTROL_PING, mp_ping);
12709 static void vl_api_sw_interface_tap_v2_details_t_handler
12710 (vl_api_sw_interface_tap_v2_details_t * mp)
12712 vat_main_t *vam = &vat_main;
12714 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12715 mp->host_ip4_prefix_len);
12716 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12717 mp->host_ip6_prefix_len);
12720 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12721 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12722 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12723 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12724 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12730 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12731 (vl_api_sw_interface_tap_v2_details_t * mp)
12733 vat_main_t *vam = &vat_main;
12734 vat_json_node_t *node = NULL;
12736 if (VAT_JSON_ARRAY != vam->json_tree.type)
12738 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12739 vat_json_init_array (&vam->json_tree);
12741 node = vat_json_array_add (&vam->json_tree);
12743 vat_json_init_object (node);
12744 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12745 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12746 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12747 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12748 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12749 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12750 vat_json_object_add_string_copy (node, "host_mac_addr",
12751 format (0, "%U", format_ethernet_address,
12752 &mp->host_mac_addr));
12753 vat_json_object_add_string_copy (node, "host_namespace",
12754 mp->host_namespace);
12755 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12756 vat_json_object_add_string_copy (node, "host_ip4_addr",
12757 format (0, "%U/%d", format_ip4_address,
12759 mp->host_ip4_prefix_len));
12760 vat_json_object_add_string_copy (node, "host_ip6_addr",
12761 format (0, "%U/%d", format_ip6_address,
12763 mp->host_ip6_prefix_len));
12768 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12770 vl_api_sw_interface_tap_v2_dump_t *mp;
12771 vl_api_control_ping_t *mp_ping;
12775 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12776 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12777 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12780 /* Get list of tap interfaces */
12781 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12784 /* Use a control ping for synchronization */
12785 MPING (CONTROL_PING, mp_ping);
12793 api_vxlan_offload_rx (vat_main_t * vam)
12795 unformat_input_t *line_input = vam->input;
12796 vl_api_vxlan_offload_rx_t *mp;
12797 u32 hw_if_index = ~0, rx_if_index = ~0;
12801 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12803 if (unformat (line_input, "del"))
12805 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12808 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12810 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12813 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12817 errmsg ("parse error '%U'", format_unformat_error, line_input);
12822 if (hw_if_index == ~0)
12824 errmsg ("no hw interface");
12828 if (rx_if_index == ~0)
12830 errmsg ("no rx tunnel");
12834 M (VXLAN_OFFLOAD_RX, mp);
12836 mp->hw_if_index = ntohl (hw_if_index);
12837 mp->sw_if_index = ntohl (rx_if_index);
12838 mp->enable = is_add;
12845 static uword unformat_vxlan_decap_next
12846 (unformat_input_t * input, va_list * args)
12848 u32 *result = va_arg (*args, u32 *);
12851 if (unformat (input, "l2"))
12852 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12853 else if (unformat (input, "%d", &tmp))
12861 api_vxlan_add_del_tunnel (vat_main_t * vam)
12863 unformat_input_t *line_input = vam->input;
12864 vl_api_vxlan_add_del_tunnel_t *mp;
12865 ip46_address_t src, dst;
12867 u8 ipv4_set = 0, ipv6_set = 0;
12872 u32 mcast_sw_if_index = ~0;
12873 u32 encap_vrf_id = 0;
12874 u32 decap_next_index = ~0;
12878 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12879 clib_memset (&src, 0, sizeof src);
12880 clib_memset (&dst, 0, sizeof dst);
12882 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12884 if (unformat (line_input, "del"))
12886 else if (unformat (line_input, "instance %d", &instance))
12889 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12895 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12901 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12907 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12912 else if (unformat (line_input, "group %U %U",
12913 unformat_ip4_address, &dst.ip4,
12914 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12916 grp_set = dst_set = 1;
12919 else if (unformat (line_input, "group %U",
12920 unformat_ip4_address, &dst.ip4))
12922 grp_set = dst_set = 1;
12925 else if (unformat (line_input, "group %U %U",
12926 unformat_ip6_address, &dst.ip6,
12927 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12929 grp_set = dst_set = 1;
12932 else if (unformat (line_input, "group %U",
12933 unformat_ip6_address, &dst.ip6))
12935 grp_set = dst_set = 1;
12939 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12941 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12943 else if (unformat (line_input, "decap-next %U",
12944 unformat_vxlan_decap_next, &decap_next_index))
12946 else if (unformat (line_input, "vni %d", &vni))
12950 errmsg ("parse error '%U'", format_unformat_error, line_input);
12957 errmsg ("tunnel src address not specified");
12962 errmsg ("tunnel dst address not specified");
12966 if (grp_set && !ip46_address_is_multicast (&dst))
12968 errmsg ("tunnel group address not multicast");
12971 if (grp_set && mcast_sw_if_index == ~0)
12973 errmsg ("tunnel nonexistent multicast device");
12976 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12978 errmsg ("tunnel dst address must be unicast");
12983 if (ipv4_set && ipv6_set)
12985 errmsg ("both IPv4 and IPv6 addresses specified");
12989 if ((vni == 0) || (vni >> 24))
12991 errmsg ("vni not specified or out of range");
12995 M (VXLAN_ADD_DEL_TUNNEL, mp);
12999 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13000 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13004 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13005 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13008 mp->instance = htonl (instance);
13009 mp->encap_vrf_id = ntohl (encap_vrf_id);
13010 mp->decap_next_index = ntohl (decap_next_index);
13011 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13012 mp->vni = ntohl (vni);
13013 mp->is_add = is_add;
13014 mp->is_ipv6 = ipv6_set;
13021 static void vl_api_vxlan_tunnel_details_t_handler
13022 (vl_api_vxlan_tunnel_details_t * mp)
13024 vat_main_t *vam = &vat_main;
13025 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13026 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13028 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13029 ntohl (mp->sw_if_index),
13030 ntohl (mp->instance),
13031 format_ip46_address, &src, IP46_TYPE_ANY,
13032 format_ip46_address, &dst, IP46_TYPE_ANY,
13033 ntohl (mp->encap_vrf_id),
13034 ntohl (mp->decap_next_index), ntohl (mp->vni),
13035 ntohl (mp->mcast_sw_if_index));
13038 static void vl_api_vxlan_tunnel_details_t_handler_json
13039 (vl_api_vxlan_tunnel_details_t * mp)
13041 vat_main_t *vam = &vat_main;
13042 vat_json_node_t *node = NULL;
13044 if (VAT_JSON_ARRAY != vam->json_tree.type)
13046 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13047 vat_json_init_array (&vam->json_tree);
13049 node = vat_json_array_add (&vam->json_tree);
13051 vat_json_init_object (node);
13052 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13054 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13058 struct in6_addr ip6;
13060 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13061 vat_json_object_add_ip6 (node, "src_address", ip6);
13062 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13063 vat_json_object_add_ip6 (node, "dst_address", ip6);
13067 struct in_addr ip4;
13069 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13070 vat_json_object_add_ip4 (node, "src_address", ip4);
13071 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13072 vat_json_object_add_ip4 (node, "dst_address", ip4);
13074 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13075 vat_json_object_add_uint (node, "decap_next_index",
13076 ntohl (mp->decap_next_index));
13077 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13078 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13079 vat_json_object_add_uint (node, "mcast_sw_if_index",
13080 ntohl (mp->mcast_sw_if_index));
13084 api_vxlan_tunnel_dump (vat_main_t * vam)
13086 unformat_input_t *i = vam->input;
13087 vl_api_vxlan_tunnel_dump_t *mp;
13088 vl_api_control_ping_t *mp_ping;
13090 u8 sw_if_index_set = 0;
13093 /* Parse args required to build the message */
13094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13096 if (unformat (i, "sw_if_index %d", &sw_if_index))
13097 sw_if_index_set = 1;
13102 if (sw_if_index_set == 0)
13107 if (!vam->json_output)
13109 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13110 "sw_if_index", "instance", "src_address", "dst_address",
13111 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13114 /* Get list of vxlan-tunnel interfaces */
13115 M (VXLAN_TUNNEL_DUMP, mp);
13117 mp->sw_if_index = htonl (sw_if_index);
13121 /* Use a control ping for synchronization */
13122 MPING (CONTROL_PING, mp_ping);
13129 static uword unformat_geneve_decap_next
13130 (unformat_input_t * input, va_list * args)
13132 u32 *result = va_arg (*args, u32 *);
13135 if (unformat (input, "l2"))
13136 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13137 else if (unformat (input, "%d", &tmp))
13145 api_geneve_add_del_tunnel (vat_main_t * vam)
13147 unformat_input_t *line_input = vam->input;
13148 vl_api_geneve_add_del_tunnel_t *mp;
13149 ip46_address_t src, dst;
13151 u8 ipv4_set = 0, ipv6_set = 0;
13155 u32 mcast_sw_if_index = ~0;
13156 u32 encap_vrf_id = 0;
13157 u32 decap_next_index = ~0;
13161 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13162 clib_memset (&src, 0, sizeof src);
13163 clib_memset (&dst, 0, sizeof dst);
13165 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13167 if (unformat (line_input, "del"))
13170 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13176 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13182 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13188 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13193 else if (unformat (line_input, "group %U %U",
13194 unformat_ip4_address, &dst.ip4,
13195 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13197 grp_set = dst_set = 1;
13200 else if (unformat (line_input, "group %U",
13201 unformat_ip4_address, &dst.ip4))
13203 grp_set = dst_set = 1;
13206 else if (unformat (line_input, "group %U %U",
13207 unformat_ip6_address, &dst.ip6,
13208 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13210 grp_set = dst_set = 1;
13213 else if (unformat (line_input, "group %U",
13214 unformat_ip6_address, &dst.ip6))
13216 grp_set = dst_set = 1;
13220 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13222 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13224 else if (unformat (line_input, "decap-next %U",
13225 unformat_geneve_decap_next, &decap_next_index))
13227 else if (unformat (line_input, "vni %d", &vni))
13231 errmsg ("parse error '%U'", format_unformat_error, line_input);
13238 errmsg ("tunnel src address not specified");
13243 errmsg ("tunnel dst address not specified");
13247 if (grp_set && !ip46_address_is_multicast (&dst))
13249 errmsg ("tunnel group address not multicast");
13252 if (grp_set && mcast_sw_if_index == ~0)
13254 errmsg ("tunnel nonexistent multicast device");
13257 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13259 errmsg ("tunnel dst address must be unicast");
13264 if (ipv4_set && ipv6_set)
13266 errmsg ("both IPv4 and IPv6 addresses specified");
13270 if ((vni == 0) || (vni >> 24))
13272 errmsg ("vni not specified or out of range");
13276 M (GENEVE_ADD_DEL_TUNNEL, mp);
13280 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13281 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13285 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13286 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13288 mp->encap_vrf_id = ntohl (encap_vrf_id);
13289 mp->decap_next_index = ntohl (decap_next_index);
13290 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13291 mp->vni = ntohl (vni);
13292 mp->is_add = is_add;
13293 mp->is_ipv6 = ipv6_set;
13300 static void vl_api_geneve_tunnel_details_t_handler
13301 (vl_api_geneve_tunnel_details_t * mp)
13303 vat_main_t *vam = &vat_main;
13304 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13305 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13307 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13308 ntohl (mp->sw_if_index),
13309 format_ip46_address, &src, IP46_TYPE_ANY,
13310 format_ip46_address, &dst, IP46_TYPE_ANY,
13311 ntohl (mp->encap_vrf_id),
13312 ntohl (mp->decap_next_index), ntohl (mp->vni),
13313 ntohl (mp->mcast_sw_if_index));
13316 static void vl_api_geneve_tunnel_details_t_handler_json
13317 (vl_api_geneve_tunnel_details_t * mp)
13319 vat_main_t *vam = &vat_main;
13320 vat_json_node_t *node = NULL;
13322 if (VAT_JSON_ARRAY != vam->json_tree.type)
13324 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13325 vat_json_init_array (&vam->json_tree);
13327 node = vat_json_array_add (&vam->json_tree);
13329 vat_json_init_object (node);
13330 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13333 struct in6_addr ip6;
13335 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13336 vat_json_object_add_ip6 (node, "src_address", ip6);
13337 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13338 vat_json_object_add_ip6 (node, "dst_address", ip6);
13342 struct in_addr ip4;
13344 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13345 vat_json_object_add_ip4 (node, "src_address", ip4);
13346 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13347 vat_json_object_add_ip4 (node, "dst_address", ip4);
13349 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13350 vat_json_object_add_uint (node, "decap_next_index",
13351 ntohl (mp->decap_next_index));
13352 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13353 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13354 vat_json_object_add_uint (node, "mcast_sw_if_index",
13355 ntohl (mp->mcast_sw_if_index));
13359 api_geneve_tunnel_dump (vat_main_t * vam)
13361 unformat_input_t *i = vam->input;
13362 vl_api_geneve_tunnel_dump_t *mp;
13363 vl_api_control_ping_t *mp_ping;
13365 u8 sw_if_index_set = 0;
13368 /* Parse args required to build the message */
13369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13371 if (unformat (i, "sw_if_index %d", &sw_if_index))
13372 sw_if_index_set = 1;
13377 if (sw_if_index_set == 0)
13382 if (!vam->json_output)
13384 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13385 "sw_if_index", "local_address", "remote_address",
13386 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13389 /* Get list of geneve-tunnel interfaces */
13390 M (GENEVE_TUNNEL_DUMP, mp);
13392 mp->sw_if_index = htonl (sw_if_index);
13396 /* Use a control ping for synchronization */
13397 M (CONTROL_PING, mp_ping);
13405 api_gre_add_del_tunnel (vat_main_t * vam)
13407 unformat_input_t *line_input = vam->input;
13408 vl_api_gre_add_del_tunnel_t *mp;
13409 ip4_address_t src4, dst4;
13410 ip6_address_t src6, dst6;
13414 u8 t_type = GRE_TUNNEL_TYPE_L3;
13417 u32 outer_fib_id = 0;
13418 u32 session_id = 0;
13422 clib_memset (&src4, 0, sizeof src4);
13423 clib_memset (&dst4, 0, sizeof dst4);
13424 clib_memset (&src6, 0, sizeof src6);
13425 clib_memset (&dst6, 0, sizeof dst6);
13427 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13429 if (unformat (line_input, "del"))
13431 else if (unformat (line_input, "instance %d", &instance))
13433 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13438 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13443 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13448 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13453 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13455 else if (unformat (line_input, "teb"))
13456 t_type = GRE_TUNNEL_TYPE_TEB;
13457 else if (unformat (line_input, "erspan %d", &session_id))
13458 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13461 errmsg ("parse error '%U'", format_unformat_error, line_input);
13468 errmsg ("tunnel src address not specified");
13473 errmsg ("tunnel dst address not specified");
13476 if (ipv4_set && ipv6_set)
13478 errmsg ("both IPv4 and IPv6 addresses specified");
13483 M (GRE_ADD_DEL_TUNNEL, mp);
13487 clib_memcpy (&mp->src_address, &src4, 4);
13488 clib_memcpy (&mp->dst_address, &dst4, 4);
13492 clib_memcpy (&mp->src_address, &src6, 16);
13493 clib_memcpy (&mp->dst_address, &dst6, 16);
13495 mp->instance = htonl (instance);
13496 mp->outer_fib_id = htonl (outer_fib_id);
13497 mp->is_add = is_add;
13498 mp->session_id = htons ((u16) session_id);
13499 mp->tunnel_type = t_type;
13500 mp->is_ipv6 = ipv6_set;
13507 static void vl_api_gre_tunnel_details_t_handler
13508 (vl_api_gre_tunnel_details_t * mp)
13510 vat_main_t *vam = &vat_main;
13511 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13512 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13514 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13515 ntohl (mp->sw_if_index),
13516 ntohl (mp->instance),
13517 format_ip46_address, &src, IP46_TYPE_ANY,
13518 format_ip46_address, &dst, IP46_TYPE_ANY,
13519 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13522 static void vl_api_gre_tunnel_details_t_handler_json
13523 (vl_api_gre_tunnel_details_t * mp)
13525 vat_main_t *vam = &vat_main;
13526 vat_json_node_t *node = NULL;
13527 struct in_addr ip4;
13528 struct in6_addr ip6;
13530 if (VAT_JSON_ARRAY != vam->json_tree.type)
13532 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13533 vat_json_init_array (&vam->json_tree);
13535 node = vat_json_array_add (&vam->json_tree);
13537 vat_json_init_object (node);
13538 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13539 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13542 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13543 vat_json_object_add_ip4 (node, "src_address", ip4);
13544 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13545 vat_json_object_add_ip4 (node, "dst_address", ip4);
13549 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13550 vat_json_object_add_ip6 (node, "src_address", ip6);
13551 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13552 vat_json_object_add_ip6 (node, "dst_address", ip6);
13554 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13555 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13556 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13557 vat_json_object_add_uint (node, "session_id", mp->session_id);
13561 api_gre_tunnel_dump (vat_main_t * vam)
13563 unformat_input_t *i = vam->input;
13564 vl_api_gre_tunnel_dump_t *mp;
13565 vl_api_control_ping_t *mp_ping;
13567 u8 sw_if_index_set = 0;
13570 /* Parse args required to build the message */
13571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13573 if (unformat (i, "sw_if_index %d", &sw_if_index))
13574 sw_if_index_set = 1;
13579 if (sw_if_index_set == 0)
13584 if (!vam->json_output)
13586 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13587 "sw_if_index", "instance", "src_address", "dst_address",
13588 "tunnel_type", "outer_fib_id", "session_id");
13591 /* Get list of gre-tunnel interfaces */
13592 M (GRE_TUNNEL_DUMP, mp);
13594 mp->sw_if_index = htonl (sw_if_index);
13598 /* Use a control ping for synchronization */
13599 MPING (CONTROL_PING, mp_ping);
13607 api_l2_fib_clear_table (vat_main_t * vam)
13609 // unformat_input_t * i = vam->input;
13610 vl_api_l2_fib_clear_table_t *mp;
13613 M (L2_FIB_CLEAR_TABLE, mp);
13621 api_l2_interface_efp_filter (vat_main_t * vam)
13623 unformat_input_t *i = vam->input;
13624 vl_api_l2_interface_efp_filter_t *mp;
13627 u8 sw_if_index_set = 0;
13630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13632 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13633 sw_if_index_set = 1;
13634 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13635 sw_if_index_set = 1;
13636 else if (unformat (i, "enable"))
13638 else if (unformat (i, "disable"))
13642 clib_warning ("parse error '%U'", format_unformat_error, i);
13647 if (sw_if_index_set == 0)
13649 errmsg ("missing sw_if_index");
13653 M (L2_INTERFACE_EFP_FILTER, mp);
13655 mp->sw_if_index = ntohl (sw_if_index);
13656 mp->enable_disable = enable;
13663 #define foreach_vtr_op \
13664 _("disable", L2_VTR_DISABLED) \
13665 _("push-1", L2_VTR_PUSH_1) \
13666 _("push-2", L2_VTR_PUSH_2) \
13667 _("pop-1", L2_VTR_POP_1) \
13668 _("pop-2", L2_VTR_POP_2) \
13669 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13670 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13671 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13672 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13675 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13677 unformat_input_t *i = vam->input;
13678 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13680 u8 sw_if_index_set = 0;
13683 u32 push_dot1q = 1;
13688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13690 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13691 sw_if_index_set = 1;
13692 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13693 sw_if_index_set = 1;
13694 else if (unformat (i, "vtr_op %d", &vtr_op))
13696 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13699 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13701 else if (unformat (i, "tag1 %d", &tag1))
13703 else if (unformat (i, "tag2 %d", &tag2))
13707 clib_warning ("parse error '%U'", format_unformat_error, i);
13712 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13714 errmsg ("missing vtr operation or sw_if_index");
13718 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13719 mp->sw_if_index = ntohl (sw_if_index);
13720 mp->vtr_op = ntohl (vtr_op);
13721 mp->push_dot1q = ntohl (push_dot1q);
13722 mp->tag1 = ntohl (tag1);
13723 mp->tag2 = ntohl (tag2);
13731 api_create_vhost_user_if (vat_main_t * vam)
13733 unformat_input_t *i = vam->input;
13734 vl_api_create_vhost_user_if_t *mp;
13737 u8 file_name_set = 0;
13738 u32 custom_dev_instance = ~0;
13740 u8 use_custom_mac = 0;
13741 u8 disable_mrg_rxbuf = 0;
13742 u8 disable_indirect_desc = 0;
13746 /* Shut up coverity */
13747 clib_memset (hwaddr, 0, sizeof (hwaddr));
13749 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13751 if (unformat (i, "socket %s", &file_name))
13755 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13757 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13758 use_custom_mac = 1;
13759 else if (unformat (i, "server"))
13761 else if (unformat (i, "disable_mrg_rxbuf"))
13762 disable_mrg_rxbuf = 1;
13763 else if (unformat (i, "disable_indirect_desc"))
13764 disable_indirect_desc = 1;
13765 else if (unformat (i, "tag %s", &tag))
13771 if (file_name_set == 0)
13773 errmsg ("missing socket file name");
13777 if (vec_len (file_name) > 255)
13779 errmsg ("socket file name too long");
13782 vec_add1 (file_name, 0);
13784 M (CREATE_VHOST_USER_IF, mp);
13786 mp->is_server = is_server;
13787 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13788 mp->disable_indirect_desc = disable_indirect_desc;
13789 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13790 vec_free (file_name);
13791 if (custom_dev_instance != ~0)
13794 mp->custom_dev_instance = ntohl (custom_dev_instance);
13797 mp->use_custom_mac = use_custom_mac;
13798 clib_memcpy (mp->mac_address, hwaddr, 6);
13800 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13809 api_modify_vhost_user_if (vat_main_t * vam)
13811 unformat_input_t *i = vam->input;
13812 vl_api_modify_vhost_user_if_t *mp;
13815 u8 file_name_set = 0;
13816 u32 custom_dev_instance = ~0;
13817 u8 sw_if_index_set = 0;
13818 u32 sw_if_index = (u32) ~ 0;
13821 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13823 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13824 sw_if_index_set = 1;
13825 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13826 sw_if_index_set = 1;
13827 else if (unformat (i, "socket %s", &file_name))
13831 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13833 else if (unformat (i, "server"))
13839 if (sw_if_index_set == 0)
13841 errmsg ("missing sw_if_index or interface name");
13845 if (file_name_set == 0)
13847 errmsg ("missing socket file name");
13851 if (vec_len (file_name) > 255)
13853 errmsg ("socket file name too long");
13856 vec_add1 (file_name, 0);
13858 M (MODIFY_VHOST_USER_IF, mp);
13860 mp->sw_if_index = ntohl (sw_if_index);
13861 mp->is_server = is_server;
13862 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13863 vec_free (file_name);
13864 if (custom_dev_instance != ~0)
13867 mp->custom_dev_instance = ntohl (custom_dev_instance);
13876 api_delete_vhost_user_if (vat_main_t * vam)
13878 unformat_input_t *i = vam->input;
13879 vl_api_delete_vhost_user_if_t *mp;
13880 u32 sw_if_index = ~0;
13881 u8 sw_if_index_set = 0;
13884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13886 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13887 sw_if_index_set = 1;
13888 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13889 sw_if_index_set = 1;
13894 if (sw_if_index_set == 0)
13896 errmsg ("missing sw_if_index or interface name");
13901 M (DELETE_VHOST_USER_IF, mp);
13903 mp->sw_if_index = ntohl (sw_if_index);
13910 static void vl_api_sw_interface_vhost_user_details_t_handler
13911 (vl_api_sw_interface_vhost_user_details_t * mp)
13913 vat_main_t *vam = &vat_main;
13915 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13916 (char *) mp->interface_name,
13917 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13918 clib_net_to_host_u64 (mp->features), mp->is_server,
13919 ntohl (mp->num_regions), (char *) mp->sock_filename);
13920 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13923 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13924 (vl_api_sw_interface_vhost_user_details_t * mp)
13926 vat_main_t *vam = &vat_main;
13927 vat_json_node_t *node = NULL;
13929 if (VAT_JSON_ARRAY != vam->json_tree.type)
13931 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13932 vat_json_init_array (&vam->json_tree);
13934 node = vat_json_array_add (&vam->json_tree);
13936 vat_json_init_object (node);
13937 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13938 vat_json_object_add_string_copy (node, "interface_name",
13939 mp->interface_name);
13940 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13941 ntohl (mp->virtio_net_hdr_sz));
13942 vat_json_object_add_uint (node, "features",
13943 clib_net_to_host_u64 (mp->features));
13944 vat_json_object_add_uint (node, "is_server", mp->is_server);
13945 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13946 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13947 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13951 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13953 vl_api_sw_interface_vhost_user_dump_t *mp;
13954 vl_api_control_ping_t *mp_ping;
13957 "Interface name idx hdr_sz features server regions filename");
13959 /* Get list of vhost-user interfaces */
13960 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13963 /* Use a control ping for synchronization */
13964 MPING (CONTROL_PING, mp_ping);
13972 api_show_version (vat_main_t * vam)
13974 vl_api_show_version_t *mp;
13977 M (SHOW_VERSION, mp);
13986 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13988 unformat_input_t *line_input = vam->input;
13989 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13990 ip4_address_t local4, remote4;
13991 ip6_address_t local6, remote6;
13993 u8 ipv4_set = 0, ipv6_set = 0;
13997 u32 mcast_sw_if_index = ~0;
13998 u32 encap_vrf_id = 0;
13999 u32 decap_vrf_id = 0;
14005 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14006 clib_memset (&local4, 0, sizeof local4);
14007 clib_memset (&remote4, 0, sizeof remote4);
14008 clib_memset (&local6, 0, sizeof local6);
14009 clib_memset (&remote6, 0, sizeof remote6);
14011 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14013 if (unformat (line_input, "del"))
14015 else if (unformat (line_input, "local %U",
14016 unformat_ip4_address, &local4))
14021 else if (unformat (line_input, "remote %U",
14022 unformat_ip4_address, &remote4))
14027 else if (unformat (line_input, "local %U",
14028 unformat_ip6_address, &local6))
14033 else if (unformat (line_input, "remote %U",
14034 unformat_ip6_address, &remote6))
14039 else if (unformat (line_input, "group %U %U",
14040 unformat_ip4_address, &remote4,
14041 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14043 grp_set = remote_set = 1;
14046 else if (unformat (line_input, "group %U",
14047 unformat_ip4_address, &remote4))
14049 grp_set = remote_set = 1;
14052 else if (unformat (line_input, "group %U %U",
14053 unformat_ip6_address, &remote6,
14054 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14056 grp_set = remote_set = 1;
14059 else if (unformat (line_input, "group %U",
14060 unformat_ip6_address, &remote6))
14062 grp_set = remote_set = 1;
14066 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14068 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14070 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14072 else if (unformat (line_input, "vni %d", &vni))
14074 else if (unformat (line_input, "next-ip4"))
14076 else if (unformat (line_input, "next-ip6"))
14078 else if (unformat (line_input, "next-ethernet"))
14080 else if (unformat (line_input, "next-nsh"))
14084 errmsg ("parse error '%U'", format_unformat_error, line_input);
14089 if (local_set == 0)
14091 errmsg ("tunnel local address not specified");
14094 if (remote_set == 0)
14096 errmsg ("tunnel remote address not specified");
14099 if (grp_set && mcast_sw_if_index == ~0)
14101 errmsg ("tunnel nonexistent multicast device");
14104 if (ipv4_set && ipv6_set)
14106 errmsg ("both IPv4 and IPv6 addresses specified");
14112 errmsg ("vni not specified");
14116 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14121 clib_memcpy (&mp->local, &local6, sizeof (local6));
14122 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14126 clib_memcpy (&mp->local, &local4, sizeof (local4));
14127 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14130 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14131 mp->encap_vrf_id = ntohl (encap_vrf_id);
14132 mp->decap_vrf_id = ntohl (decap_vrf_id);
14133 mp->protocol = protocol;
14134 mp->vni = ntohl (vni);
14135 mp->is_add = is_add;
14136 mp->is_ipv6 = ipv6_set;
14143 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14144 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14146 vat_main_t *vam = &vat_main;
14147 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14148 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14150 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14151 ntohl (mp->sw_if_index),
14152 format_ip46_address, &local, IP46_TYPE_ANY,
14153 format_ip46_address, &remote, IP46_TYPE_ANY,
14154 ntohl (mp->vni), mp->protocol,
14155 ntohl (mp->mcast_sw_if_index),
14156 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14160 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14161 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14163 vat_main_t *vam = &vat_main;
14164 vat_json_node_t *node = NULL;
14165 struct in_addr ip4;
14166 struct in6_addr ip6;
14168 if (VAT_JSON_ARRAY != vam->json_tree.type)
14170 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14171 vat_json_init_array (&vam->json_tree);
14173 node = vat_json_array_add (&vam->json_tree);
14175 vat_json_init_object (node);
14176 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14179 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14180 vat_json_object_add_ip6 (node, "local", ip6);
14181 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14182 vat_json_object_add_ip6 (node, "remote", ip6);
14186 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14187 vat_json_object_add_ip4 (node, "local", ip4);
14188 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14189 vat_json_object_add_ip4 (node, "remote", ip4);
14191 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14192 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14193 vat_json_object_add_uint (node, "mcast_sw_if_index",
14194 ntohl (mp->mcast_sw_if_index));
14195 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14196 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14197 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14201 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14203 unformat_input_t *i = vam->input;
14204 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14205 vl_api_control_ping_t *mp_ping;
14207 u8 sw_if_index_set = 0;
14210 /* Parse args required to build the message */
14211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14213 if (unformat (i, "sw_if_index %d", &sw_if_index))
14214 sw_if_index_set = 1;
14219 if (sw_if_index_set == 0)
14224 if (!vam->json_output)
14226 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14227 "sw_if_index", "local", "remote", "vni",
14228 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14231 /* Get list of vxlan-tunnel interfaces */
14232 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14234 mp->sw_if_index = htonl (sw_if_index);
14238 /* Use a control ping for synchronization */
14239 MPING (CONTROL_PING, mp_ping);
14246 static void vl_api_l2_fib_table_details_t_handler
14247 (vl_api_l2_fib_table_details_t * mp)
14249 vat_main_t *vam = &vat_main;
14251 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14253 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14254 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14258 static void vl_api_l2_fib_table_details_t_handler_json
14259 (vl_api_l2_fib_table_details_t * mp)
14261 vat_main_t *vam = &vat_main;
14262 vat_json_node_t *node = NULL;
14264 if (VAT_JSON_ARRAY != vam->json_tree.type)
14266 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14267 vat_json_init_array (&vam->json_tree);
14269 node = vat_json_array_add (&vam->json_tree);
14271 vat_json_init_object (node);
14272 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14273 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14274 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14275 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14276 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14277 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14281 api_l2_fib_table_dump (vat_main_t * vam)
14283 unformat_input_t *i = vam->input;
14284 vl_api_l2_fib_table_dump_t *mp;
14285 vl_api_control_ping_t *mp_ping;
14290 /* Parse args required to build the message */
14291 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14293 if (unformat (i, "bd_id %d", &bd_id))
14299 if (bd_id_set == 0)
14301 errmsg ("missing bridge domain");
14305 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14307 /* Get list of l2 fib entries */
14308 M (L2_FIB_TABLE_DUMP, mp);
14310 mp->bd_id = ntohl (bd_id);
14313 /* Use a control ping for synchronization */
14314 MPING (CONTROL_PING, mp_ping);
14323 api_interface_name_renumber (vat_main_t * vam)
14325 unformat_input_t *line_input = vam->input;
14326 vl_api_interface_name_renumber_t *mp;
14327 u32 sw_if_index = ~0;
14328 u32 new_show_dev_instance = ~0;
14331 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14333 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14336 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14338 else if (unformat (line_input, "new_show_dev_instance %d",
14339 &new_show_dev_instance))
14345 if (sw_if_index == ~0)
14347 errmsg ("missing interface name or sw_if_index");
14351 if (new_show_dev_instance == ~0)
14353 errmsg ("missing new_show_dev_instance");
14357 M (INTERFACE_NAME_RENUMBER, mp);
14359 mp->sw_if_index = ntohl (sw_if_index);
14360 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14368 api_ip_probe_neighbor (vat_main_t * vam)
14370 unformat_input_t *i = vam->input;
14371 vl_api_ip_probe_neighbor_t *mp;
14379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14381 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14383 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14385 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14387 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14398 errmsg ("missing interface");
14404 errmsg ("missing addresses");
14408 M (IP_PROBE_NEIGHBOR, mp);
14410 mp->sw_if_index = ntohl (sw_if_index);
14411 mp->is_ipv6 = is_ipv6;
14412 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14420 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14422 unformat_input_t *i = vam->input;
14423 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14424 u8 mode = IP_SCAN_V46_NEIGHBORS;
14425 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14430 if (unformat (i, "ip4"))
14431 mode = IP_SCAN_V4_NEIGHBORS;
14432 else if (unformat (i, "ip6"))
14433 mode = IP_SCAN_V6_NEIGHBORS;
14434 if (unformat (i, "both"))
14435 mode = IP_SCAN_V46_NEIGHBORS;
14436 else if (unformat (i, "disable"))
14437 mode = IP_SCAN_DISABLED;
14438 else if (unformat (i, "interval %d", &interval))
14440 else if (unformat (i, "max-time %d", &time))
14442 else if (unformat (i, "max-update %d", &update))
14444 else if (unformat (i, "delay %d", &delay))
14446 else if (unformat (i, "stale %d", &stale))
14452 if (interval > 255)
14454 errmsg ("interval cannot exceed 255 minutes.");
14459 errmsg ("max-time cannot exceed 255 usec.");
14464 errmsg ("max-update cannot exceed 255.");
14469 errmsg ("delay cannot exceed 255 msec.");
14474 errmsg ("stale cannot exceed 255 minutes.");
14478 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14480 mp->scan_interval = interval;
14481 mp->max_proc_time = time;
14482 mp->max_update = update;
14483 mp->scan_int_delay = delay;
14484 mp->stale_threshold = stale;
14492 api_want_ip4_arp_events (vat_main_t * vam)
14494 unformat_input_t *line_input = vam->input;
14495 vl_api_want_ip4_arp_events_t *mp;
14496 ip4_address_t address;
14497 int address_set = 0;
14498 u32 enable_disable = 1;
14501 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14503 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14505 else if (unformat (line_input, "del"))
14506 enable_disable = 0;
14511 if (address_set == 0)
14513 errmsg ("missing addresses");
14517 M (WANT_IP4_ARP_EVENTS, mp);
14518 mp->enable_disable = enable_disable;
14519 mp->pid = htonl (getpid ());
14520 mp->address = address.as_u32;
14528 api_want_ip6_nd_events (vat_main_t * vam)
14530 unformat_input_t *line_input = vam->input;
14531 vl_api_want_ip6_nd_events_t *mp;
14532 ip6_address_t address;
14533 int address_set = 0;
14534 u32 enable_disable = 1;
14537 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14539 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14541 else if (unformat (line_input, "del"))
14542 enable_disable = 0;
14547 if (address_set == 0)
14549 errmsg ("missing addresses");
14553 M (WANT_IP6_ND_EVENTS, mp);
14554 mp->enable_disable = enable_disable;
14555 mp->pid = htonl (getpid ());
14556 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14564 api_want_l2_macs_events (vat_main_t * vam)
14566 unformat_input_t *line_input = vam->input;
14567 vl_api_want_l2_macs_events_t *mp;
14568 u8 enable_disable = 1;
14569 u32 scan_delay = 0;
14570 u32 max_macs_in_event = 0;
14571 u32 learn_limit = 0;
14574 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14576 if (unformat (line_input, "learn-limit %d", &learn_limit))
14578 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14580 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14582 else if (unformat (line_input, "disable"))
14583 enable_disable = 0;
14588 M (WANT_L2_MACS_EVENTS, mp);
14589 mp->enable_disable = enable_disable;
14590 mp->pid = htonl (getpid ());
14591 mp->learn_limit = htonl (learn_limit);
14592 mp->scan_delay = (u8) scan_delay;
14593 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14600 api_input_acl_set_interface (vat_main_t * vam)
14602 unformat_input_t *i = vam->input;
14603 vl_api_input_acl_set_interface_t *mp;
14605 int sw_if_index_set;
14606 u32 ip4_table_index = ~0;
14607 u32 ip6_table_index = ~0;
14608 u32 l2_table_index = ~0;
14612 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14614 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14615 sw_if_index_set = 1;
14616 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14617 sw_if_index_set = 1;
14618 else if (unformat (i, "del"))
14620 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14622 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14624 else if (unformat (i, "l2-table %d", &l2_table_index))
14628 clib_warning ("parse error '%U'", format_unformat_error, i);
14633 if (sw_if_index_set == 0)
14635 errmsg ("missing interface name or sw_if_index");
14639 M (INPUT_ACL_SET_INTERFACE, mp);
14641 mp->sw_if_index = ntohl (sw_if_index);
14642 mp->ip4_table_index = ntohl (ip4_table_index);
14643 mp->ip6_table_index = ntohl (ip6_table_index);
14644 mp->l2_table_index = ntohl (l2_table_index);
14645 mp->is_add = is_add;
14653 api_output_acl_set_interface (vat_main_t * vam)
14655 unformat_input_t *i = vam->input;
14656 vl_api_output_acl_set_interface_t *mp;
14658 int sw_if_index_set;
14659 u32 ip4_table_index = ~0;
14660 u32 ip6_table_index = ~0;
14661 u32 l2_table_index = ~0;
14665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14667 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14668 sw_if_index_set = 1;
14669 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14670 sw_if_index_set = 1;
14671 else if (unformat (i, "del"))
14673 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14675 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14677 else if (unformat (i, "l2-table %d", &l2_table_index))
14681 clib_warning ("parse error '%U'", format_unformat_error, i);
14686 if (sw_if_index_set == 0)
14688 errmsg ("missing interface name or sw_if_index");
14692 M (OUTPUT_ACL_SET_INTERFACE, mp);
14694 mp->sw_if_index = ntohl (sw_if_index);
14695 mp->ip4_table_index = ntohl (ip4_table_index);
14696 mp->ip6_table_index = ntohl (ip6_table_index);
14697 mp->l2_table_index = ntohl (l2_table_index);
14698 mp->is_add = is_add;
14706 api_ip_address_dump (vat_main_t * vam)
14708 unformat_input_t *i = vam->input;
14709 vl_api_ip_address_dump_t *mp;
14710 vl_api_control_ping_t *mp_ping;
14711 u32 sw_if_index = ~0;
14712 u8 sw_if_index_set = 0;
14717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14719 if (unformat (i, "sw_if_index %d", &sw_if_index))
14720 sw_if_index_set = 1;
14722 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14723 sw_if_index_set = 1;
14724 else if (unformat (i, "ipv4"))
14726 else if (unformat (i, "ipv6"))
14732 if (ipv4_set && ipv6_set)
14734 errmsg ("ipv4 and ipv6 flags cannot be both set");
14738 if ((!ipv4_set) && (!ipv6_set))
14740 errmsg ("no ipv4 nor ipv6 flag set");
14744 if (sw_if_index_set == 0)
14746 errmsg ("missing interface name or sw_if_index");
14750 vam->current_sw_if_index = sw_if_index;
14751 vam->is_ipv6 = ipv6_set;
14753 M (IP_ADDRESS_DUMP, mp);
14754 mp->sw_if_index = ntohl (sw_if_index);
14755 mp->is_ipv6 = ipv6_set;
14758 /* Use a control ping for synchronization */
14759 MPING (CONTROL_PING, mp_ping);
14767 api_ip_dump (vat_main_t * vam)
14769 vl_api_ip_dump_t *mp;
14770 vl_api_control_ping_t *mp_ping;
14771 unformat_input_t *in = vam->input;
14778 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14780 if (unformat (in, "ipv4"))
14782 else if (unformat (in, "ipv6"))
14788 if (ipv4_set && ipv6_set)
14790 errmsg ("ipv4 and ipv6 flags cannot be both set");
14794 if ((!ipv4_set) && (!ipv6_set))
14796 errmsg ("no ipv4 nor ipv6 flag set");
14800 is_ipv6 = ipv6_set;
14801 vam->is_ipv6 = is_ipv6;
14803 /* free old data */
14804 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14806 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14808 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14811 mp->is_ipv6 = ipv6_set;
14814 /* Use a control ping for synchronization */
14815 MPING (CONTROL_PING, mp_ping);
14823 api_ipsec_spd_add_del (vat_main_t * vam)
14825 unformat_input_t *i = vam->input;
14826 vl_api_ipsec_spd_add_del_t *mp;
14831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14833 if (unformat (i, "spd_id %d", &spd_id))
14835 else if (unformat (i, "del"))
14839 clib_warning ("parse error '%U'", format_unformat_error, i);
14845 errmsg ("spd_id must be set");
14849 M (IPSEC_SPD_ADD_DEL, mp);
14851 mp->spd_id = ntohl (spd_id);
14852 mp->is_add = is_add;
14860 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14862 unformat_input_t *i = vam->input;
14863 vl_api_ipsec_interface_add_del_spd_t *mp;
14865 u8 sw_if_index_set = 0;
14866 u32 spd_id = (u32) ~ 0;
14870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14872 if (unformat (i, "del"))
14874 else if (unformat (i, "spd_id %d", &spd_id))
14877 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14878 sw_if_index_set = 1;
14879 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14880 sw_if_index_set = 1;
14883 clib_warning ("parse error '%U'", format_unformat_error, i);
14889 if (spd_id == (u32) ~ 0)
14891 errmsg ("spd_id must be set");
14895 if (sw_if_index_set == 0)
14897 errmsg ("missing interface name or sw_if_index");
14901 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14903 mp->spd_id = ntohl (spd_id);
14904 mp->sw_if_index = ntohl (sw_if_index);
14905 mp->is_add = is_add;
14913 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14915 unformat_input_t *i = vam->input;
14916 vl_api_ipsec_spd_add_del_entry_t *mp;
14917 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14918 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14920 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14921 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14922 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14923 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14926 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14927 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14928 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14929 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14930 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14931 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14935 if (unformat (i, "del"))
14937 if (unformat (i, "outbound"))
14939 if (unformat (i, "inbound"))
14941 else if (unformat (i, "spd_id %d", &spd_id))
14943 else if (unformat (i, "sa_id %d", &sa_id))
14945 else if (unformat (i, "priority %d", &priority))
14947 else if (unformat (i, "protocol %d", &protocol))
14949 else if (unformat (i, "lport_start %d", &lport_start))
14951 else if (unformat (i, "lport_stop %d", &lport_stop))
14953 else if (unformat (i, "rport_start %d", &rport_start))
14955 else if (unformat (i, "rport_stop %d", &rport_stop))
14959 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
14965 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
14972 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14978 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14985 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
14991 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
14998 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15004 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15010 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15012 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15014 clib_warning ("unsupported action: 'resolve'");
15020 clib_warning ("parse error '%U'", format_unformat_error, i);
15026 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15028 mp->spd_id = ntohl (spd_id);
15029 mp->priority = ntohl (priority);
15030 mp->is_outbound = is_outbound;
15032 mp->is_ipv6 = is_ipv6;
15033 if (is_ipv6 || is_ip_any)
15035 clib_memcpy (mp->remote_address_start, &raddr6_start,
15036 sizeof (ip6_address_t));
15037 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15038 sizeof (ip6_address_t));
15039 clib_memcpy (mp->local_address_start, &laddr6_start,
15040 sizeof (ip6_address_t));
15041 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15042 sizeof (ip6_address_t));
15046 clib_memcpy (mp->remote_address_start, &raddr4_start,
15047 sizeof (ip4_address_t));
15048 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15049 sizeof (ip4_address_t));
15050 clib_memcpy (mp->local_address_start, &laddr4_start,
15051 sizeof (ip4_address_t));
15052 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15053 sizeof (ip4_address_t));
15055 mp->protocol = (u8) protocol;
15056 mp->local_port_start = ntohs ((u16) lport_start);
15057 mp->local_port_stop = ntohs ((u16) lport_stop);
15058 mp->remote_port_start = ntohs ((u16) rport_start);
15059 mp->remote_port_stop = ntohs ((u16) rport_stop);
15060 mp->policy = (u8) policy;
15061 mp->sa_id = ntohl (sa_id);
15062 mp->is_add = is_add;
15063 mp->is_ip_any = is_ip_any;
15070 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15072 unformat_input_t *i = vam->input;
15073 vl_api_ipsec_sad_add_del_entry_t *mp;
15074 u32 sad_id = 0, spi = 0;
15075 u8 *ck = 0, *ik = 0;
15078 u8 protocol = IPSEC_PROTOCOL_AH;
15079 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15080 u32 crypto_alg = 0, integ_alg = 0;
15081 ip4_address_t tun_src4;
15082 ip4_address_t tun_dst4;
15083 ip6_address_t tun_src6;
15084 ip6_address_t tun_dst6;
15087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15089 if (unformat (i, "del"))
15091 else if (unformat (i, "sad_id %d", &sad_id))
15093 else if (unformat (i, "spi %d", &spi))
15095 else if (unformat (i, "esp"))
15096 protocol = IPSEC_PROTOCOL_ESP;
15097 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15100 is_tunnel_ipv6 = 0;
15102 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15105 is_tunnel_ipv6 = 0;
15107 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15110 is_tunnel_ipv6 = 1;
15112 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15115 is_tunnel_ipv6 = 1;
15119 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15121 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15123 clib_warning ("unsupported crypto-alg: '%U'",
15124 format_ipsec_crypto_alg, crypto_alg);
15128 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15132 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15134 if (integ_alg >= IPSEC_INTEG_N_ALG)
15136 clib_warning ("unsupported integ-alg: '%U'",
15137 format_ipsec_integ_alg, integ_alg);
15141 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15145 clib_warning ("parse error '%U'", format_unformat_error, i);
15151 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15153 mp->sad_id = ntohl (sad_id);
15154 mp->is_add = is_add;
15155 mp->protocol = protocol;
15156 mp->spi = ntohl (spi);
15157 mp->is_tunnel = is_tunnel;
15158 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15159 mp->crypto_algorithm = crypto_alg;
15160 mp->integrity_algorithm = integ_alg;
15161 mp->crypto_key_length = vec_len (ck);
15162 mp->integrity_key_length = vec_len (ik);
15164 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15165 mp->crypto_key_length = sizeof (mp->crypto_key);
15167 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15168 mp->integrity_key_length = sizeof (mp->integrity_key);
15171 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15173 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15177 if (is_tunnel_ipv6)
15179 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15180 sizeof (ip6_address_t));
15181 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15182 sizeof (ip6_address_t));
15186 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15187 sizeof (ip4_address_t));
15188 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15189 sizeof (ip4_address_t));
15199 api_ipsec_sa_set_key (vat_main_t * vam)
15201 unformat_input_t *i = vam->input;
15202 vl_api_ipsec_sa_set_key_t *mp;
15204 u8 *ck = 0, *ik = 0;
15207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15209 if (unformat (i, "sa_id %d", &sa_id))
15211 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15213 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15217 clib_warning ("parse error '%U'", format_unformat_error, i);
15222 M (IPSEC_SA_SET_KEY, mp);
15224 mp->sa_id = ntohl (sa_id);
15225 mp->crypto_key_length = vec_len (ck);
15226 mp->integrity_key_length = vec_len (ik);
15228 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15229 mp->crypto_key_length = sizeof (mp->crypto_key);
15231 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15232 mp->integrity_key_length = sizeof (mp->integrity_key);
15235 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15237 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15245 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15247 unformat_input_t *i = vam->input;
15248 vl_api_ipsec_tunnel_if_add_del_t *mp;
15249 u32 local_spi = 0, remote_spi = 0;
15250 u32 crypto_alg = 0, integ_alg = 0;
15251 u8 *lck = NULL, *rck = NULL;
15252 u8 *lik = NULL, *rik = NULL;
15253 ip4_address_t local_ip = { {0} };
15254 ip4_address_t remote_ip = { {0} };
15257 u8 anti_replay = 0;
15262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15264 if (unformat (i, "del"))
15266 else if (unformat (i, "esn"))
15268 else if (unformat (i, "anti_replay"))
15270 else if (unformat (i, "local_spi %d", &local_spi))
15272 else if (unformat (i, "remote_spi %d", &remote_spi))
15274 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15276 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15278 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15281 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15283 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15285 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15289 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15291 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15293 errmsg ("unsupported crypto-alg: '%U'\n",
15294 format_ipsec_crypto_alg, crypto_alg);
15300 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15302 if (integ_alg >= IPSEC_INTEG_N_ALG)
15304 errmsg ("unsupported integ-alg: '%U'\n",
15305 format_ipsec_integ_alg, integ_alg);
15309 else if (unformat (i, "instance %u", &instance))
15313 errmsg ("parse error '%U'\n", format_unformat_error, i);
15318 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15320 mp->is_add = is_add;
15322 mp->anti_replay = anti_replay;
15324 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15325 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15327 mp->local_spi = htonl (local_spi);
15328 mp->remote_spi = htonl (remote_spi);
15329 mp->crypto_alg = (u8) crypto_alg;
15331 mp->local_crypto_key_len = 0;
15334 mp->local_crypto_key_len = vec_len (lck);
15335 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15336 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15337 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15340 mp->remote_crypto_key_len = 0;
15343 mp->remote_crypto_key_len = vec_len (rck);
15344 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15345 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15346 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15349 mp->integ_alg = (u8) integ_alg;
15351 mp->local_integ_key_len = 0;
15354 mp->local_integ_key_len = vec_len (lik);
15355 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15356 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15357 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15360 mp->remote_integ_key_len = 0;
15363 mp->remote_integ_key_len = vec_len (rik);
15364 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15365 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15366 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15371 mp->renumber = renumber;
15372 mp->show_instance = ntohl (instance);
15381 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15383 vat_main_t *vam = &vat_main;
15385 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15386 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15387 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15388 "tunnel_src_addr %U tunnel_dst_addr %U "
15389 "salt %u seq_outbound %lu last_seq_inbound %lu "
15390 "replay_window %lu total_data_size %lu\n",
15391 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15393 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15394 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15395 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15396 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15397 mp->tunnel_src_addr,
15398 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15399 mp->tunnel_dst_addr,
15401 clib_net_to_host_u64 (mp->seq_outbound),
15402 clib_net_to_host_u64 (mp->last_seq_inbound),
15403 clib_net_to_host_u64 (mp->replay_window),
15404 clib_net_to_host_u64 (mp->total_data_size));
15407 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15408 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15410 static void vl_api_ipsec_sa_details_t_handler_json
15411 (vl_api_ipsec_sa_details_t * mp)
15413 vat_main_t *vam = &vat_main;
15414 vat_json_node_t *node = NULL;
15415 struct in_addr src_ip4, dst_ip4;
15416 struct in6_addr src_ip6, dst_ip6;
15418 if (VAT_JSON_ARRAY != vam->json_tree.type)
15420 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15421 vat_json_init_array (&vam->json_tree);
15423 node = vat_json_array_add (&vam->json_tree);
15425 vat_json_init_object (node);
15426 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15427 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15428 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15429 vat_json_object_add_uint (node, "proto", mp->protocol);
15430 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15431 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15432 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15433 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15434 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15435 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15436 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15437 mp->crypto_key_len);
15438 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15439 mp->integ_key_len);
15440 if (mp->is_tunnel_ip6)
15442 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15443 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15444 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15445 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15449 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15450 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15451 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15452 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15454 vat_json_object_add_uint (node, "replay_window",
15455 clib_net_to_host_u64 (mp->replay_window));
15456 vat_json_object_add_uint (node, "total_data_size",
15457 clib_net_to_host_u64 (mp->total_data_size));
15462 api_ipsec_sa_dump (vat_main_t * vam)
15464 unformat_input_t *i = vam->input;
15465 vl_api_ipsec_sa_dump_t *mp;
15466 vl_api_control_ping_t *mp_ping;
15470 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15472 if (unformat (i, "sa_id %d", &sa_id))
15476 clib_warning ("parse error '%U'", format_unformat_error, i);
15481 M (IPSEC_SA_DUMP, mp);
15483 mp->sa_id = ntohl (sa_id);
15487 /* Use a control ping for synchronization */
15488 M (CONTROL_PING, mp_ping);
15496 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15498 unformat_input_t *i = vam->input;
15499 vl_api_ipsec_tunnel_if_set_key_t *mp;
15500 u32 sw_if_index = ~0;
15501 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15508 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15511 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15512 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15514 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15515 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15516 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15517 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15519 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15520 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15521 else if (unformat (i, "%U", unformat_hex_string, &key))
15525 clib_warning ("parse error '%U'", format_unformat_error, i);
15530 if (sw_if_index == ~0)
15532 errmsg ("interface must be specified");
15536 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15538 errmsg ("key type must be specified");
15544 errmsg ("algorithm must be specified");
15548 if (vec_len (key) == 0)
15550 errmsg ("key must be specified");
15554 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15556 mp->sw_if_index = htonl (sw_if_index);
15558 mp->key_type = key_type;
15559 mp->key_len = vec_len (key);
15560 clib_memcpy (mp->key, key, vec_len (key));
15569 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15571 unformat_input_t *i = vam->input;
15572 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15573 u32 sw_if_index = ~0;
15575 u8 is_outbound = (u8) ~ 0;
15578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15580 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15582 else if (unformat (i, "sa_id %d", &sa_id))
15584 else if (unformat (i, "outbound"))
15586 else if (unformat (i, "inbound"))
15590 clib_warning ("parse error '%U'", format_unformat_error, i);
15595 if (sw_if_index == ~0)
15597 errmsg ("interface must be specified");
15603 errmsg ("SA ID must be specified");
15607 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15609 mp->sw_if_index = htonl (sw_if_index);
15610 mp->sa_id = htonl (sa_id);
15611 mp->is_outbound = is_outbound;
15620 api_ikev2_profile_add_del (vat_main_t * vam)
15622 unformat_input_t *i = vam->input;
15623 vl_api_ikev2_profile_add_del_t *mp;
15628 const char *valid_chars = "a-zA-Z0-9_";
15630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15632 if (unformat (i, "del"))
15634 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15635 vec_add1 (name, 0);
15638 errmsg ("parse error '%U'", format_unformat_error, i);
15643 if (!vec_len (name))
15645 errmsg ("profile name must be specified");
15649 if (vec_len (name) > 64)
15651 errmsg ("profile name too long");
15655 M (IKEV2_PROFILE_ADD_DEL, mp);
15657 clib_memcpy (mp->name, name, vec_len (name));
15658 mp->is_add = is_add;
15667 api_ikev2_profile_set_auth (vat_main_t * vam)
15669 unformat_input_t *i = vam->input;
15670 vl_api_ikev2_profile_set_auth_t *mp;
15673 u32 auth_method = 0;
15677 const char *valid_chars = "a-zA-Z0-9_";
15679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15681 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15682 vec_add1 (name, 0);
15683 else if (unformat (i, "auth_method %U",
15684 unformat_ikev2_auth_method, &auth_method))
15686 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15688 else if (unformat (i, "auth_data %v", &data))
15692 errmsg ("parse error '%U'", format_unformat_error, i);
15697 if (!vec_len (name))
15699 errmsg ("profile name must be specified");
15703 if (vec_len (name) > 64)
15705 errmsg ("profile name too long");
15709 if (!vec_len (data))
15711 errmsg ("auth_data must be specified");
15717 errmsg ("auth_method must be specified");
15721 M (IKEV2_PROFILE_SET_AUTH, mp);
15723 mp->is_hex = is_hex;
15724 mp->auth_method = (u8) auth_method;
15725 mp->data_len = vec_len (data);
15726 clib_memcpy (mp->name, name, vec_len (name));
15727 clib_memcpy (mp->data, data, vec_len (data));
15737 api_ikev2_profile_set_id (vat_main_t * vam)
15739 unformat_input_t *i = vam->input;
15740 vl_api_ikev2_profile_set_id_t *mp;
15748 const char *valid_chars = "a-zA-Z0-9_";
15750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15752 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15753 vec_add1 (name, 0);
15754 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15756 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15758 data = vec_new (u8, 4);
15759 clib_memcpy (data, ip4.as_u8, 4);
15761 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15763 else if (unformat (i, "id_data %v", &data))
15765 else if (unformat (i, "local"))
15767 else if (unformat (i, "remote"))
15771 errmsg ("parse error '%U'", format_unformat_error, i);
15776 if (!vec_len (name))
15778 errmsg ("profile name must be specified");
15782 if (vec_len (name) > 64)
15784 errmsg ("profile name too long");
15788 if (!vec_len (data))
15790 errmsg ("id_data must be specified");
15796 errmsg ("id_type must be specified");
15800 M (IKEV2_PROFILE_SET_ID, mp);
15802 mp->is_local = is_local;
15803 mp->id_type = (u8) id_type;
15804 mp->data_len = vec_len (data);
15805 clib_memcpy (mp->name, name, vec_len (name));
15806 clib_memcpy (mp->data, data, vec_len (data));
15816 api_ikev2_profile_set_ts (vat_main_t * vam)
15818 unformat_input_t *i = vam->input;
15819 vl_api_ikev2_profile_set_ts_t *mp;
15822 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15823 ip4_address_t start_addr, end_addr;
15825 const char *valid_chars = "a-zA-Z0-9_";
15828 start_addr.as_u32 = 0;
15829 end_addr.as_u32 = (u32) ~ 0;
15831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15833 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15834 vec_add1 (name, 0);
15835 else if (unformat (i, "protocol %d", &proto))
15837 else if (unformat (i, "start_port %d", &start_port))
15839 else if (unformat (i, "end_port %d", &end_port))
15842 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15844 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15846 else if (unformat (i, "local"))
15848 else if (unformat (i, "remote"))
15852 errmsg ("parse error '%U'", format_unformat_error, i);
15857 if (!vec_len (name))
15859 errmsg ("profile name must be specified");
15863 if (vec_len (name) > 64)
15865 errmsg ("profile name too long");
15869 M (IKEV2_PROFILE_SET_TS, mp);
15871 mp->is_local = is_local;
15872 mp->proto = (u8) proto;
15873 mp->start_port = (u16) start_port;
15874 mp->end_port = (u16) end_port;
15875 mp->start_addr = start_addr.as_u32;
15876 mp->end_addr = end_addr.as_u32;
15877 clib_memcpy (mp->name, name, vec_len (name));
15886 api_ikev2_set_local_key (vat_main_t * vam)
15888 unformat_input_t *i = vam->input;
15889 vl_api_ikev2_set_local_key_t *mp;
15893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15895 if (unformat (i, "file %v", &file))
15896 vec_add1 (file, 0);
15899 errmsg ("parse error '%U'", format_unformat_error, i);
15904 if (!vec_len (file))
15906 errmsg ("RSA key file must be specified");
15910 if (vec_len (file) > 256)
15912 errmsg ("file name too long");
15916 M (IKEV2_SET_LOCAL_KEY, mp);
15918 clib_memcpy (mp->key_file, file, vec_len (file));
15927 api_ikev2_set_responder (vat_main_t * vam)
15929 unformat_input_t *i = vam->input;
15930 vl_api_ikev2_set_responder_t *mp;
15933 u32 sw_if_index = ~0;
15934 ip4_address_t address;
15936 const char *valid_chars = "a-zA-Z0-9_";
15938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15941 (i, "%U interface %d address %U", unformat_token, valid_chars,
15942 &name, &sw_if_index, unformat_ip4_address, &address))
15943 vec_add1 (name, 0);
15946 errmsg ("parse error '%U'", format_unformat_error, i);
15951 if (!vec_len (name))
15953 errmsg ("profile name must be specified");
15957 if (vec_len (name) > 64)
15959 errmsg ("profile name too long");
15963 M (IKEV2_SET_RESPONDER, mp);
15965 clib_memcpy (mp->name, name, vec_len (name));
15968 mp->sw_if_index = sw_if_index;
15969 clib_memcpy (mp->address, &address, sizeof (address));
15977 api_ikev2_set_ike_transforms (vat_main_t * vam)
15979 unformat_input_t *i = vam->input;
15980 vl_api_ikev2_set_ike_transforms_t *mp;
15983 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15985 const char *valid_chars = "a-zA-Z0-9_";
15987 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15989 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15990 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15991 vec_add1 (name, 0);
15994 errmsg ("parse error '%U'", format_unformat_error, i);
15999 if (!vec_len (name))
16001 errmsg ("profile name must be specified");
16005 if (vec_len (name) > 64)
16007 errmsg ("profile name too long");
16011 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16013 clib_memcpy (mp->name, name, vec_len (name));
16015 mp->crypto_alg = crypto_alg;
16016 mp->crypto_key_size = crypto_key_size;
16017 mp->integ_alg = integ_alg;
16018 mp->dh_group = dh_group;
16027 api_ikev2_set_esp_transforms (vat_main_t * vam)
16029 unformat_input_t *i = vam->input;
16030 vl_api_ikev2_set_esp_transforms_t *mp;
16033 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16035 const char *valid_chars = "a-zA-Z0-9_";
16037 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16039 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16040 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16041 vec_add1 (name, 0);
16044 errmsg ("parse error '%U'", format_unformat_error, i);
16049 if (!vec_len (name))
16051 errmsg ("profile name must be specified");
16055 if (vec_len (name) > 64)
16057 errmsg ("profile name too long");
16061 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16063 clib_memcpy (mp->name, name, vec_len (name));
16065 mp->crypto_alg = crypto_alg;
16066 mp->crypto_key_size = crypto_key_size;
16067 mp->integ_alg = integ_alg;
16068 mp->dh_group = dh_group;
16076 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16078 unformat_input_t *i = vam->input;
16079 vl_api_ikev2_set_sa_lifetime_t *mp;
16082 u64 lifetime, lifetime_maxdata;
16083 u32 lifetime_jitter, handover;
16085 const char *valid_chars = "a-zA-Z0-9_";
16087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16089 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16090 &lifetime, &lifetime_jitter, &handover,
16091 &lifetime_maxdata))
16092 vec_add1 (name, 0);
16095 errmsg ("parse error '%U'", format_unformat_error, i);
16100 if (!vec_len (name))
16102 errmsg ("profile name must be specified");
16106 if (vec_len (name) > 64)
16108 errmsg ("profile name too long");
16112 M (IKEV2_SET_SA_LIFETIME, mp);
16114 clib_memcpy (mp->name, name, vec_len (name));
16116 mp->lifetime = lifetime;
16117 mp->lifetime_jitter = lifetime_jitter;
16118 mp->handover = handover;
16119 mp->lifetime_maxdata = lifetime_maxdata;
16127 api_ikev2_initiate_sa_init (vat_main_t * vam)
16129 unformat_input_t *i = vam->input;
16130 vl_api_ikev2_initiate_sa_init_t *mp;
16134 const char *valid_chars = "a-zA-Z0-9_";
16136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16138 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16139 vec_add1 (name, 0);
16142 errmsg ("parse error '%U'", format_unformat_error, i);
16147 if (!vec_len (name))
16149 errmsg ("profile name must be specified");
16153 if (vec_len (name) > 64)
16155 errmsg ("profile name too long");
16159 M (IKEV2_INITIATE_SA_INIT, mp);
16161 clib_memcpy (mp->name, name, vec_len (name));
16170 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16172 unformat_input_t *i = vam->input;
16173 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16180 if (unformat (i, "%lx", &ispi))
16184 errmsg ("parse error '%U'", format_unformat_error, i);
16189 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16199 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16201 unformat_input_t *i = vam->input;
16202 vl_api_ikev2_initiate_del_child_sa_t *mp;
16207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16209 if (unformat (i, "%x", &ispi))
16213 errmsg ("parse error '%U'", format_unformat_error, i);
16218 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16228 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16230 unformat_input_t *i = vam->input;
16231 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16238 if (unformat (i, "%x", &ispi))
16242 errmsg ("parse error '%U'", format_unformat_error, i);
16247 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16257 api_get_first_msg_id (vat_main_t * vam)
16259 vl_api_get_first_msg_id_t *mp;
16260 unformat_input_t *i = vam->input;
16265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16267 if (unformat (i, "client %s", &name))
16275 errmsg ("missing client name");
16278 vec_add1 (name, 0);
16280 if (vec_len (name) > 63)
16282 errmsg ("client name too long");
16286 M (GET_FIRST_MSG_ID, mp);
16287 clib_memcpy (mp->name, name, vec_len (name));
16294 api_cop_interface_enable_disable (vat_main_t * vam)
16296 unformat_input_t *line_input = vam->input;
16297 vl_api_cop_interface_enable_disable_t *mp;
16298 u32 sw_if_index = ~0;
16299 u8 enable_disable = 1;
16302 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16304 if (unformat (line_input, "disable"))
16305 enable_disable = 0;
16306 if (unformat (line_input, "enable"))
16307 enable_disable = 1;
16308 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16309 vam, &sw_if_index))
16311 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16317 if (sw_if_index == ~0)
16319 errmsg ("missing interface name or sw_if_index");
16323 /* Construct the API message */
16324 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16325 mp->sw_if_index = ntohl (sw_if_index);
16326 mp->enable_disable = enable_disable;
16330 /* Wait for the reply */
16336 api_cop_whitelist_enable_disable (vat_main_t * vam)
16338 unformat_input_t *line_input = vam->input;
16339 vl_api_cop_whitelist_enable_disable_t *mp;
16340 u32 sw_if_index = ~0;
16341 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16345 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16347 if (unformat (line_input, "ip4"))
16349 else if (unformat (line_input, "ip6"))
16351 else if (unformat (line_input, "default"))
16353 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16354 vam, &sw_if_index))
16356 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16358 else if (unformat (line_input, "fib-id %d", &fib_id))
16364 if (sw_if_index == ~0)
16366 errmsg ("missing interface name or sw_if_index");
16370 /* Construct the API message */
16371 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16372 mp->sw_if_index = ntohl (sw_if_index);
16373 mp->fib_id = ntohl (fib_id);
16376 mp->default_cop = default_cop;
16380 /* Wait for the reply */
16386 api_get_node_graph (vat_main_t * vam)
16388 vl_api_get_node_graph_t *mp;
16391 M (GET_NODE_GRAPH, mp);
16395 /* Wait for the reply */
16401 /** Used for parsing LISP eids */
16402 typedef CLIB_PACKED(struct{
16403 u8 addr[16]; /**< eid address */
16404 u32 len; /**< prefix length if IP */
16405 u8 type; /**< type of eid */
16410 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16412 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16414 clib_memset (a, 0, sizeof (a[0]));
16416 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16418 a->type = 0; /* ipv4 type */
16420 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16422 a->type = 1; /* ipv6 type */
16424 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16426 a->type = 2; /* mac type */
16428 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16430 a->type = 3; /* NSH type */
16431 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16432 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16439 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16448 lisp_eid_size_vat (u8 type)
16465 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16467 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16471 api_one_add_del_locator_set (vat_main_t * vam)
16473 unformat_input_t *input = vam->input;
16474 vl_api_one_add_del_locator_set_t *mp;
16476 u8 *locator_set_name = NULL;
16477 u8 locator_set_name_set = 0;
16478 vl_api_local_locator_t locator, *locators = 0;
16479 u32 sw_if_index, priority, weight;
16483 /* Parse args required to build the message */
16484 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16486 if (unformat (input, "del"))
16490 else if (unformat (input, "locator-set %s", &locator_set_name))
16492 locator_set_name_set = 1;
16494 else if (unformat (input, "sw_if_index %u p %u w %u",
16495 &sw_if_index, &priority, &weight))
16497 locator.sw_if_index = htonl (sw_if_index);
16498 locator.priority = priority;
16499 locator.weight = weight;
16500 vec_add1 (locators, locator);
16504 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16505 &sw_if_index, &priority, &weight))
16507 locator.sw_if_index = htonl (sw_if_index);
16508 locator.priority = priority;
16509 locator.weight = weight;
16510 vec_add1 (locators, locator);
16516 if (locator_set_name_set == 0)
16518 errmsg ("missing locator-set name");
16519 vec_free (locators);
16523 if (vec_len (locator_set_name) > 64)
16525 errmsg ("locator-set name too long");
16526 vec_free (locator_set_name);
16527 vec_free (locators);
16530 vec_add1 (locator_set_name, 0);
16532 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16534 /* Construct the API message */
16535 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16537 mp->is_add = is_add;
16538 clib_memcpy (mp->locator_set_name, locator_set_name,
16539 vec_len (locator_set_name));
16540 vec_free (locator_set_name);
16542 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16544 clib_memcpy (mp->locators, locators, data_len);
16545 vec_free (locators);
16550 /* Wait for a reply... */
16555 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16558 api_one_add_del_locator (vat_main_t * vam)
16560 unformat_input_t *input = vam->input;
16561 vl_api_one_add_del_locator_t *mp;
16562 u32 tmp_if_index = ~0;
16563 u32 sw_if_index = ~0;
16564 u8 sw_if_index_set = 0;
16565 u8 sw_if_index_if_name_set = 0;
16567 u8 priority_set = 0;
16571 u8 *locator_set_name = NULL;
16572 u8 locator_set_name_set = 0;
16575 /* Parse args required to build the message */
16576 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16578 if (unformat (input, "del"))
16582 else if (unformat (input, "locator-set %s", &locator_set_name))
16584 locator_set_name_set = 1;
16586 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16589 sw_if_index_if_name_set = 1;
16590 sw_if_index = tmp_if_index;
16592 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16594 sw_if_index_set = 1;
16595 sw_if_index = tmp_if_index;
16597 else if (unformat (input, "p %d", &priority))
16601 else if (unformat (input, "w %d", &weight))
16609 if (locator_set_name_set == 0)
16611 errmsg ("missing locator-set name");
16615 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16617 errmsg ("missing sw_if_index");
16618 vec_free (locator_set_name);
16622 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16624 errmsg ("cannot use both params interface name and sw_if_index");
16625 vec_free (locator_set_name);
16629 if (priority_set == 0)
16631 errmsg ("missing locator-set priority");
16632 vec_free (locator_set_name);
16636 if (weight_set == 0)
16638 errmsg ("missing locator-set weight");
16639 vec_free (locator_set_name);
16643 if (vec_len (locator_set_name) > 64)
16645 errmsg ("locator-set name too long");
16646 vec_free (locator_set_name);
16649 vec_add1 (locator_set_name, 0);
16651 /* Construct the API message */
16652 M (ONE_ADD_DEL_LOCATOR, mp);
16654 mp->is_add = is_add;
16655 mp->sw_if_index = ntohl (sw_if_index);
16656 mp->priority = priority;
16657 mp->weight = weight;
16658 clib_memcpy (mp->locator_set_name, locator_set_name,
16659 vec_len (locator_set_name));
16660 vec_free (locator_set_name);
16665 /* Wait for a reply... */
16670 #define api_lisp_add_del_locator api_one_add_del_locator
16673 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16675 u32 *key_id = va_arg (*args, u32 *);
16678 if (unformat (input, "%s", &s))
16680 if (!strcmp ((char *) s, "sha1"))
16681 key_id[0] = HMAC_SHA_1_96;
16682 else if (!strcmp ((char *) s, "sha256"))
16683 key_id[0] = HMAC_SHA_256_128;
16686 clib_warning ("invalid key_id: '%s'", s);
16687 key_id[0] = HMAC_NO_KEY;
16698 api_one_add_del_local_eid (vat_main_t * vam)
16700 unformat_input_t *input = vam->input;
16701 vl_api_one_add_del_local_eid_t *mp;
16704 lisp_eid_vat_t _eid, *eid = &_eid;
16705 u8 *locator_set_name = 0;
16706 u8 locator_set_name_set = 0;
16712 /* Parse args required to build the message */
16713 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16715 if (unformat (input, "del"))
16719 else if (unformat (input, "vni %d", &vni))
16723 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16727 else if (unformat (input, "locator-set %s", &locator_set_name))
16729 locator_set_name_set = 1;
16731 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
16733 else if (unformat (input, "secret-key %_%v%_", &key))
16739 if (locator_set_name_set == 0)
16741 errmsg ("missing locator-set name");
16747 errmsg ("EID address not set!");
16748 vec_free (locator_set_name);
16752 if (key && (0 == key_id))
16754 errmsg ("invalid key_id!");
16758 if (vec_len (key) > 64)
16760 errmsg ("key too long");
16765 if (vec_len (locator_set_name) > 64)
16767 errmsg ("locator-set name too long");
16768 vec_free (locator_set_name);
16771 vec_add1 (locator_set_name, 0);
16773 /* Construct the API message */
16774 M (ONE_ADD_DEL_LOCAL_EID, mp);
16776 mp->is_add = is_add;
16777 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16778 mp->eid_type = eid->type;
16779 mp->prefix_len = eid->len;
16780 mp->vni = clib_host_to_net_u32 (vni);
16781 mp->key_id = clib_host_to_net_u16 (key_id);
16782 clib_memcpy (mp->locator_set_name, locator_set_name,
16783 vec_len (locator_set_name));
16784 clib_memcpy (mp->key, key, vec_len (key));
16786 vec_free (locator_set_name);
16792 /* Wait for a reply... */
16797 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16800 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16802 u32 dp_table = 0, vni = 0;;
16803 unformat_input_t *input = vam->input;
16804 vl_api_gpe_add_del_fwd_entry_t *mp;
16806 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16807 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16808 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16809 u32 action = ~0, w;
16810 ip4_address_t rmt_rloc4, lcl_rloc4;
16811 ip6_address_t rmt_rloc6, lcl_rloc6;
16812 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16815 clib_memset (&rloc, 0, sizeof (rloc));
16817 /* Parse args required to build the message */
16818 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16820 if (unformat (input, "del"))
16822 else if (unformat (input, "add"))
16824 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16828 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16832 else if (unformat (input, "vrf %d", &dp_table))
16834 else if (unformat (input, "bd %d", &dp_table))
16836 else if (unformat (input, "vni %d", &vni))
16838 else if (unformat (input, "w %d", &w))
16842 errmsg ("No RLOC configured for setting priority/weight!");
16845 curr_rloc->weight = w;
16847 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16848 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16852 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16854 vec_add1 (lcl_locs, rloc);
16856 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16857 vec_add1 (rmt_locs, rloc);
16858 /* weight saved in rmt loc */
16859 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16861 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16862 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16865 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16867 vec_add1 (lcl_locs, rloc);
16869 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16870 vec_add1 (rmt_locs, rloc);
16871 /* weight saved in rmt loc */
16872 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16874 else if (unformat (input, "action %d", &action))
16880 clib_warning ("parse error '%U'", format_unformat_error, input);
16887 errmsg ("remote eid addresses not set");
16891 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16893 errmsg ("eid types don't match");
16897 if (0 == rmt_locs && (u32) ~ 0 == action)
16899 errmsg ("action not set for negative mapping");
16903 /* Construct the API message */
16904 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16905 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16907 mp->is_add = is_add;
16908 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16909 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16910 mp->eid_type = rmt_eid->type;
16911 mp->dp_table = clib_host_to_net_u32 (dp_table);
16912 mp->vni = clib_host_to_net_u32 (vni);
16913 mp->rmt_len = rmt_eid->len;
16914 mp->lcl_len = lcl_eid->len;
16915 mp->action = action;
16917 if (0 != rmt_locs && 0 != lcl_locs)
16919 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16920 clib_memcpy (mp->locs, lcl_locs,
16921 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16923 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16924 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16925 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16927 vec_free (lcl_locs);
16928 vec_free (rmt_locs);
16933 /* Wait for a reply... */
16939 api_one_add_del_map_server (vat_main_t * vam)
16941 unformat_input_t *input = vam->input;
16942 vl_api_one_add_del_map_server_t *mp;
16946 ip4_address_t ipv4;
16947 ip6_address_t ipv6;
16950 /* Parse args required to build the message */
16951 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16953 if (unformat (input, "del"))
16957 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16961 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16969 if (ipv4_set && ipv6_set)
16971 errmsg ("both eid v4 and v6 addresses set");
16975 if (!ipv4_set && !ipv6_set)
16977 errmsg ("eid addresses not set");
16981 /* Construct the API message */
16982 M (ONE_ADD_DEL_MAP_SERVER, mp);
16984 mp->is_add = is_add;
16988 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16993 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16999 /* Wait for a reply... */
17004 #define api_lisp_add_del_map_server api_one_add_del_map_server
17007 api_one_add_del_map_resolver (vat_main_t * vam)
17009 unformat_input_t *input = vam->input;
17010 vl_api_one_add_del_map_resolver_t *mp;
17014 ip4_address_t ipv4;
17015 ip6_address_t ipv6;
17018 /* Parse args required to build the message */
17019 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17021 if (unformat (input, "del"))
17025 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17029 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17037 if (ipv4_set && ipv6_set)
17039 errmsg ("both eid v4 and v6 addresses set");
17043 if (!ipv4_set && !ipv6_set)
17045 errmsg ("eid addresses not set");
17049 /* Construct the API message */
17050 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17052 mp->is_add = is_add;
17056 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17061 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17067 /* Wait for a reply... */
17072 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17075 api_lisp_gpe_enable_disable (vat_main_t * vam)
17077 unformat_input_t *input = vam->input;
17078 vl_api_gpe_enable_disable_t *mp;
17083 /* Parse args required to build the message */
17084 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17086 if (unformat (input, "enable"))
17091 else if (unformat (input, "disable"))
17102 errmsg ("Value not set");
17106 /* Construct the API message */
17107 M (GPE_ENABLE_DISABLE, mp);
17114 /* Wait for a reply... */
17120 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17122 unformat_input_t *input = vam->input;
17123 vl_api_one_rloc_probe_enable_disable_t *mp;
17128 /* Parse args required to build the message */
17129 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17131 if (unformat (input, "enable"))
17136 else if (unformat (input, "disable"))
17144 errmsg ("Value not set");
17148 /* Construct the API message */
17149 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17151 mp->is_enabled = is_en;
17156 /* Wait for a reply... */
17161 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17164 api_one_map_register_enable_disable (vat_main_t * vam)
17166 unformat_input_t *input = vam->input;
17167 vl_api_one_map_register_enable_disable_t *mp;
17172 /* Parse args required to build the message */
17173 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17175 if (unformat (input, "enable"))
17180 else if (unformat (input, "disable"))
17188 errmsg ("Value not set");
17192 /* Construct the API message */
17193 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17195 mp->is_enabled = is_en;
17200 /* Wait for a reply... */
17205 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17208 api_one_enable_disable (vat_main_t * vam)
17210 unformat_input_t *input = vam->input;
17211 vl_api_one_enable_disable_t *mp;
17216 /* Parse args required to build the message */
17217 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17219 if (unformat (input, "enable"))
17224 else if (unformat (input, "disable"))
17234 errmsg ("Value not set");
17238 /* Construct the API message */
17239 M (ONE_ENABLE_DISABLE, mp);
17246 /* Wait for a reply... */
17251 #define api_lisp_enable_disable api_one_enable_disable
17254 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17256 unformat_input_t *input = vam->input;
17257 vl_api_one_enable_disable_xtr_mode_t *mp;
17262 /* Parse args required to build the message */
17263 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17265 if (unformat (input, "enable"))
17270 else if (unformat (input, "disable"))
17280 errmsg ("Value not set");
17284 /* Construct the API message */
17285 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17292 /* Wait for a reply... */
17298 api_one_show_xtr_mode (vat_main_t * vam)
17300 vl_api_one_show_xtr_mode_t *mp;
17303 /* Construct the API message */
17304 M (ONE_SHOW_XTR_MODE, mp);
17309 /* Wait for a reply... */
17315 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17317 unformat_input_t *input = vam->input;
17318 vl_api_one_enable_disable_pitr_mode_t *mp;
17323 /* Parse args required to build the message */
17324 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17326 if (unformat (input, "enable"))
17331 else if (unformat (input, "disable"))
17341 errmsg ("Value not set");
17345 /* Construct the API message */
17346 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17353 /* Wait for a reply... */
17359 api_one_show_pitr_mode (vat_main_t * vam)
17361 vl_api_one_show_pitr_mode_t *mp;
17364 /* Construct the API message */
17365 M (ONE_SHOW_PITR_MODE, mp);
17370 /* Wait for a reply... */
17376 api_one_enable_disable_petr_mode (vat_main_t * vam)
17378 unformat_input_t *input = vam->input;
17379 vl_api_one_enable_disable_petr_mode_t *mp;
17384 /* Parse args required to build the message */
17385 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17387 if (unformat (input, "enable"))
17392 else if (unformat (input, "disable"))
17402 errmsg ("Value not set");
17406 /* Construct the API message */
17407 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17414 /* Wait for a reply... */
17420 api_one_show_petr_mode (vat_main_t * vam)
17422 vl_api_one_show_petr_mode_t *mp;
17425 /* Construct the API message */
17426 M (ONE_SHOW_PETR_MODE, mp);
17431 /* Wait for a reply... */
17437 api_show_one_map_register_state (vat_main_t * vam)
17439 vl_api_show_one_map_register_state_t *mp;
17442 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17447 /* wait for reply */
17452 #define api_show_lisp_map_register_state api_show_one_map_register_state
17455 api_show_one_rloc_probe_state (vat_main_t * vam)
17457 vl_api_show_one_rloc_probe_state_t *mp;
17460 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17465 /* wait for reply */
17470 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17473 api_one_add_del_ndp_entry (vat_main_t * vam)
17475 vl_api_one_add_del_ndp_entry_t *mp;
17476 unformat_input_t *input = vam->input;
17481 u8 mac[6] = { 0, };
17482 u8 ip6[16] = { 0, };
17486 /* Parse args required to build the message */
17487 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17489 if (unformat (input, "del"))
17491 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17493 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17495 else if (unformat (input, "bd %d", &bd))
17499 errmsg ("parse error '%U'", format_unformat_error, input);
17504 if (!bd_set || !ip_set || (!mac_set && is_add))
17506 errmsg ("Missing BD, IP or MAC!");
17510 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17511 mp->is_add = is_add;
17512 clib_memcpy (mp->mac, mac, 6);
17513 mp->bd = clib_host_to_net_u32 (bd);
17514 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17519 /* wait for reply */
17525 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17527 vl_api_one_add_del_l2_arp_entry_t *mp;
17528 unformat_input_t *input = vam->input;
17533 u8 mac[6] = { 0, };
17534 u32 ip4 = 0, bd = ~0;
17537 /* Parse args required to build the message */
17538 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17540 if (unformat (input, "del"))
17542 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17544 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17546 else if (unformat (input, "bd %d", &bd))
17550 errmsg ("parse error '%U'", format_unformat_error, input);
17555 if (!bd_set || !ip_set || (!mac_set && is_add))
17557 errmsg ("Missing BD, IP or MAC!");
17561 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17562 mp->is_add = is_add;
17563 clib_memcpy (mp->mac, mac, 6);
17564 mp->bd = clib_host_to_net_u32 (bd);
17570 /* wait for reply */
17576 api_one_ndp_bd_get (vat_main_t * vam)
17578 vl_api_one_ndp_bd_get_t *mp;
17581 M (ONE_NDP_BD_GET, mp);
17586 /* wait for reply */
17592 api_one_ndp_entries_get (vat_main_t * vam)
17594 vl_api_one_ndp_entries_get_t *mp;
17595 unformat_input_t *input = vam->input;
17600 /* Parse args required to build the message */
17601 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17603 if (unformat (input, "bd %d", &bd))
17607 errmsg ("parse error '%U'", format_unformat_error, input);
17614 errmsg ("Expected bridge domain!");
17618 M (ONE_NDP_ENTRIES_GET, mp);
17619 mp->bd = clib_host_to_net_u32 (bd);
17624 /* wait for reply */
17630 api_one_l2_arp_bd_get (vat_main_t * vam)
17632 vl_api_one_l2_arp_bd_get_t *mp;
17635 M (ONE_L2_ARP_BD_GET, mp);
17640 /* wait for reply */
17646 api_one_l2_arp_entries_get (vat_main_t * vam)
17648 vl_api_one_l2_arp_entries_get_t *mp;
17649 unformat_input_t *input = vam->input;
17654 /* Parse args required to build the message */
17655 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17657 if (unformat (input, "bd %d", &bd))
17661 errmsg ("parse error '%U'", format_unformat_error, input);
17668 errmsg ("Expected bridge domain!");
17672 M (ONE_L2_ARP_ENTRIES_GET, mp);
17673 mp->bd = clib_host_to_net_u32 (bd);
17678 /* wait for reply */
17684 api_one_stats_enable_disable (vat_main_t * vam)
17686 vl_api_one_stats_enable_disable_t *mp;
17687 unformat_input_t *input = vam->input;
17692 /* Parse args required to build the message */
17693 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17695 if (unformat (input, "enable"))
17700 else if (unformat (input, "disable"))
17710 errmsg ("Value not set");
17714 M (ONE_STATS_ENABLE_DISABLE, mp);
17720 /* wait for reply */
17726 api_show_one_stats_enable_disable (vat_main_t * vam)
17728 vl_api_show_one_stats_enable_disable_t *mp;
17731 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
17736 /* wait for reply */
17742 api_show_one_map_request_mode (vat_main_t * vam)
17744 vl_api_show_one_map_request_mode_t *mp;
17747 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
17752 /* wait for reply */
17757 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
17760 api_one_map_request_mode (vat_main_t * vam)
17762 unformat_input_t *input = vam->input;
17763 vl_api_one_map_request_mode_t *mp;
17767 /* Parse args required to build the message */
17768 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17770 if (unformat (input, "dst-only"))
17772 else if (unformat (input, "src-dst"))
17776 errmsg ("parse error '%U'", format_unformat_error, input);
17781 M (ONE_MAP_REQUEST_MODE, mp);
17788 /* wait for reply */
17793 #define api_lisp_map_request_mode api_one_map_request_mode
17796 * Enable/disable ONE proxy ITR.
17798 * @param vam vpp API test context
17799 * @return return code
17802 api_one_pitr_set_locator_set (vat_main_t * vam)
17804 u8 ls_name_set = 0;
17805 unformat_input_t *input = vam->input;
17806 vl_api_one_pitr_set_locator_set_t *mp;
17811 /* Parse args required to build the message */
17812 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17814 if (unformat (input, "del"))
17816 else if (unformat (input, "locator-set %s", &ls_name))
17820 errmsg ("parse error '%U'", format_unformat_error, input);
17827 errmsg ("locator-set name not set!");
17831 M (ONE_PITR_SET_LOCATOR_SET, mp);
17833 mp->is_add = is_add;
17834 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17835 vec_free (ls_name);
17840 /* wait for reply */
17845 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17848 api_one_nsh_set_locator_set (vat_main_t * vam)
17850 u8 ls_name_set = 0;
17851 unformat_input_t *input = vam->input;
17852 vl_api_one_nsh_set_locator_set_t *mp;
17857 /* Parse args required to build the message */
17858 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17860 if (unformat (input, "del"))
17862 else if (unformat (input, "ls %s", &ls_name))
17866 errmsg ("parse error '%U'", format_unformat_error, input);
17871 if (!ls_name_set && is_add)
17873 errmsg ("locator-set name not set!");
17877 M (ONE_NSH_SET_LOCATOR_SET, mp);
17879 mp->is_add = is_add;
17880 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17881 vec_free (ls_name);
17886 /* wait for reply */
17892 api_show_one_pitr (vat_main_t * vam)
17894 vl_api_show_one_pitr_t *mp;
17897 if (!vam->json_output)
17899 print (vam->ofp, "%=20s", "lisp status:");
17902 M (SHOW_ONE_PITR, mp);
17906 /* Wait for a reply... */
17911 #define api_show_lisp_pitr api_show_one_pitr
17914 api_one_use_petr (vat_main_t * vam)
17916 unformat_input_t *input = vam->input;
17917 vl_api_one_use_petr_t *mp;
17922 clib_memset (&ip, 0, sizeof (ip));
17924 /* Parse args required to build the message */
17925 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17927 if (unformat (input, "disable"))
17930 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17933 ip_addr_version (&ip) = IP4;
17936 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17939 ip_addr_version (&ip) = IP6;
17943 errmsg ("parse error '%U'", format_unformat_error, input);
17948 M (ONE_USE_PETR, mp);
17950 mp->is_add = is_add;
17953 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17955 clib_memcpy (mp->address, &ip, 4);
17957 clib_memcpy (mp->address, &ip, 16);
17963 /* wait for reply */
17968 #define api_lisp_use_petr api_one_use_petr
17971 api_show_one_nsh_mapping (vat_main_t * vam)
17973 vl_api_show_one_use_petr_t *mp;
17976 if (!vam->json_output)
17978 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17981 M (SHOW_ONE_NSH_MAPPING, mp);
17985 /* Wait for a reply... */
17991 api_show_one_use_petr (vat_main_t * vam)
17993 vl_api_show_one_use_petr_t *mp;
17996 if (!vam->json_output)
17998 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18001 M (SHOW_ONE_USE_PETR, mp);
18005 /* Wait for a reply... */
18010 #define api_show_lisp_use_petr api_show_one_use_petr
18013 * Add/delete mapping between vni and vrf
18016 api_one_eid_table_add_del_map (vat_main_t * vam)
18018 unformat_input_t *input = vam->input;
18019 vl_api_one_eid_table_add_del_map_t *mp;
18020 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18021 u32 vni, vrf, bd_index;
18024 /* Parse args required to build the message */
18025 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18027 if (unformat (input, "del"))
18029 else if (unformat (input, "vrf %d", &vrf))
18031 else if (unformat (input, "bd_index %d", &bd_index))
18033 else if (unformat (input, "vni %d", &vni))
18039 if (!vni_set || (!vrf_set && !bd_index_set))
18041 errmsg ("missing arguments!");
18045 if (vrf_set && bd_index_set)
18047 errmsg ("error: both vrf and bd entered!");
18051 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18053 mp->is_add = is_add;
18054 mp->vni = htonl (vni);
18055 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18056 mp->is_l2 = bd_index_set;
18061 /* wait for reply */
18066 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18069 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18071 u32 *action = va_arg (*args, u32 *);
18074 if (unformat (input, "%s", &s))
18076 if (!strcmp ((char *) s, "no-action"))
18078 else if (!strcmp ((char *) s, "natively-forward"))
18080 else if (!strcmp ((char *) s, "send-map-request"))
18082 else if (!strcmp ((char *) s, "drop"))
18086 clib_warning ("invalid action: '%s'", s);
18098 * Add/del remote mapping to/from ONE control plane
18100 * @param vam vpp API test context
18101 * @return return code
18104 api_one_add_del_remote_mapping (vat_main_t * vam)
18106 unformat_input_t *input = vam->input;
18107 vl_api_one_add_del_remote_mapping_t *mp;
18109 lisp_eid_vat_t _eid, *eid = &_eid;
18110 lisp_eid_vat_t _seid, *seid = &_seid;
18111 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18112 u32 action = ~0, p, w, data_len;
18113 ip4_address_t rloc4;
18114 ip6_address_t rloc6;
18115 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18118 clib_memset (&rloc, 0, sizeof (rloc));
18120 /* Parse args required to build the message */
18121 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18123 if (unformat (input, "del-all"))
18127 else if (unformat (input, "del"))
18131 else if (unformat (input, "add"))
18135 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18139 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18143 else if (unformat (input, "vni %d", &vni))
18147 else if (unformat (input, "p %d w %d", &p, &w))
18151 errmsg ("No RLOC configured for setting priority/weight!");
18154 curr_rloc->priority = p;
18155 curr_rloc->weight = w;
18157 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18160 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18161 vec_add1 (rlocs, rloc);
18162 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18164 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18167 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18168 vec_add1 (rlocs, rloc);
18169 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18171 else if (unformat (input, "action %U",
18172 unformat_negative_mapping_action, &action))
18178 clib_warning ("parse error '%U'", format_unformat_error, input);
18185 errmsg ("missing params!");
18189 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18191 errmsg ("no action set for negative map-reply!");
18195 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18197 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18198 mp->is_add = is_add;
18199 mp->vni = htonl (vni);
18200 mp->action = (u8) action;
18201 mp->is_src_dst = seid_set;
18202 mp->eid_len = eid->len;
18203 mp->seid_len = seid->len;
18204 mp->del_all = del_all;
18205 mp->eid_type = eid->type;
18206 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18207 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18209 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18210 clib_memcpy (mp->rlocs, rlocs, data_len);
18216 /* Wait for a reply... */
18221 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18224 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18225 * forwarding entries in data-plane accordingly.
18227 * @param vam vpp API test context
18228 * @return return code
18231 api_one_add_del_adjacency (vat_main_t * vam)
18233 unformat_input_t *input = vam->input;
18234 vl_api_one_add_del_adjacency_t *mp;
18236 ip4_address_t leid4, reid4;
18237 ip6_address_t leid6, reid6;
18238 u8 reid_mac[6] = { 0 };
18239 u8 leid_mac[6] = { 0 };
18240 u8 reid_type, leid_type;
18241 u32 leid_len = 0, reid_len = 0, len;
18245 leid_type = reid_type = (u8) ~ 0;
18247 /* Parse args required to build the message */
18248 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18250 if (unformat (input, "del"))
18254 else if (unformat (input, "add"))
18258 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18261 reid_type = 0; /* ipv4 */
18264 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18267 reid_type = 1; /* ipv6 */
18270 else if (unformat (input, "reid %U", unformat_ethernet_address,
18273 reid_type = 2; /* mac */
18275 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18278 leid_type = 0; /* ipv4 */
18281 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18284 leid_type = 1; /* ipv6 */
18287 else if (unformat (input, "leid %U", unformat_ethernet_address,
18290 leid_type = 2; /* mac */
18292 else if (unformat (input, "vni %d", &vni))
18298 errmsg ("parse error '%U'", format_unformat_error, input);
18303 if ((u8) ~ 0 == reid_type)
18305 errmsg ("missing params!");
18309 if (leid_type != reid_type)
18311 errmsg ("remote and local EIDs are of different types!");
18315 M (ONE_ADD_DEL_ADJACENCY, mp);
18316 mp->is_add = is_add;
18317 mp->vni = htonl (vni);
18318 mp->leid_len = leid_len;
18319 mp->reid_len = reid_len;
18320 mp->eid_type = reid_type;
18322 switch (mp->eid_type)
18325 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18326 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18329 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18330 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18333 clib_memcpy (mp->leid, leid_mac, 6);
18334 clib_memcpy (mp->reid, reid_mac, 6);
18337 errmsg ("unknown EID type %d!", mp->eid_type);
18344 /* Wait for a reply... */
18349 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18352 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18354 u32 *mode = va_arg (*args, u32 *);
18356 if (unformat (input, "lisp"))
18358 else if (unformat (input, "vxlan"))
18367 api_gpe_get_encap_mode (vat_main_t * vam)
18369 vl_api_gpe_get_encap_mode_t *mp;
18372 /* Construct the API message */
18373 M (GPE_GET_ENCAP_MODE, mp);
18378 /* Wait for a reply... */
18384 api_gpe_set_encap_mode (vat_main_t * vam)
18386 unformat_input_t *input = vam->input;
18387 vl_api_gpe_set_encap_mode_t *mp;
18391 /* Parse args required to build the message */
18392 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18394 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18400 /* Construct the API message */
18401 M (GPE_SET_ENCAP_MODE, mp);
18408 /* Wait for a reply... */
18414 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18416 unformat_input_t *input = vam->input;
18417 vl_api_gpe_add_del_iface_t *mp;
18418 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18419 u32 dp_table = 0, vni = 0;
18422 /* Parse args required to build the message */
18423 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18425 if (unformat (input, "up"))
18430 else if (unformat (input, "down"))
18435 else if (unformat (input, "table_id %d", &dp_table))
18439 else if (unformat (input, "bd_id %d", &dp_table))
18444 else if (unformat (input, "vni %d", &vni))
18452 if (action_set == 0)
18454 errmsg ("Action not set");
18457 if (dp_table_set == 0 || vni_set == 0)
18459 errmsg ("vni and dp_table must be set");
18463 /* Construct the API message */
18464 M (GPE_ADD_DEL_IFACE, mp);
18466 mp->is_add = is_add;
18467 mp->dp_table = clib_host_to_net_u32 (dp_table);
18469 mp->vni = clib_host_to_net_u32 (vni);
18474 /* Wait for a reply... */
18480 api_one_map_register_fallback_threshold (vat_main_t * vam)
18482 unformat_input_t *input = vam->input;
18483 vl_api_one_map_register_fallback_threshold_t *mp;
18488 /* Parse args required to build the message */
18489 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18491 if (unformat (input, "%u", &value))
18495 clib_warning ("parse error '%U'", format_unformat_error, input);
18502 errmsg ("fallback threshold value is missing!");
18506 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18507 mp->value = clib_host_to_net_u32 (value);
18512 /* Wait for a reply... */
18518 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18520 vl_api_show_one_map_register_fallback_threshold_t *mp;
18523 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18528 /* Wait for a reply... */
18534 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18536 u32 *proto = va_arg (*args, u32 *);
18538 if (unformat (input, "udp"))
18540 else if (unformat (input, "api"))
18549 api_one_set_transport_protocol (vat_main_t * vam)
18551 unformat_input_t *input = vam->input;
18552 vl_api_one_set_transport_protocol_t *mp;
18557 /* Parse args required to build the message */
18558 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18560 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18564 clib_warning ("parse error '%U'", format_unformat_error, input);
18571 errmsg ("Transport protocol missing!");
18575 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18576 mp->protocol = (u8) protocol;
18581 /* Wait for a reply... */
18587 api_one_get_transport_protocol (vat_main_t * vam)
18589 vl_api_one_get_transport_protocol_t *mp;
18592 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18597 /* Wait for a reply... */
18603 api_one_map_register_set_ttl (vat_main_t * vam)
18605 unformat_input_t *input = vam->input;
18606 vl_api_one_map_register_set_ttl_t *mp;
18611 /* Parse args required to build the message */
18612 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18614 if (unformat (input, "%u", &ttl))
18618 clib_warning ("parse error '%U'", format_unformat_error, input);
18625 errmsg ("TTL value missing!");
18629 M (ONE_MAP_REGISTER_SET_TTL, mp);
18630 mp->ttl = clib_host_to_net_u32 (ttl);
18635 /* Wait for a reply... */
18641 api_show_one_map_register_ttl (vat_main_t * vam)
18643 vl_api_show_one_map_register_ttl_t *mp;
18646 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18651 /* Wait for a reply... */
18657 * Add/del map request itr rlocs from ONE control plane and updates
18659 * @param vam vpp API test context
18660 * @return return code
18663 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18665 unformat_input_t *input = vam->input;
18666 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18667 u8 *locator_set_name = 0;
18668 u8 locator_set_name_set = 0;
18672 /* Parse args required to build the message */
18673 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18675 if (unformat (input, "del"))
18679 else if (unformat (input, "%_%v%_", &locator_set_name))
18681 locator_set_name_set = 1;
18685 clib_warning ("parse error '%U'", format_unformat_error, input);
18690 if (is_add && !locator_set_name_set)
18692 errmsg ("itr-rloc is not set!");
18696 if (is_add && vec_len (locator_set_name) > 64)
18698 errmsg ("itr-rloc locator-set name too long");
18699 vec_free (locator_set_name);
18703 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18704 mp->is_add = is_add;
18707 clib_memcpy (mp->locator_set_name, locator_set_name,
18708 vec_len (locator_set_name));
18712 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18714 vec_free (locator_set_name);
18719 /* Wait for a reply... */
18724 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18727 api_one_locator_dump (vat_main_t * vam)
18729 unformat_input_t *input = vam->input;
18730 vl_api_one_locator_dump_t *mp;
18731 vl_api_control_ping_t *mp_ping;
18732 u8 is_index_set = 0, is_name_set = 0;
18737 /* Parse args required to build the message */
18738 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18740 if (unformat (input, "ls_name %_%v%_", &ls_name))
18744 else if (unformat (input, "ls_index %d", &ls_index))
18750 errmsg ("parse error '%U'", format_unformat_error, input);
18755 if (!is_index_set && !is_name_set)
18757 errmsg ("error: expected one of index or name!");
18761 if (is_index_set && is_name_set)
18763 errmsg ("error: only one param expected!");
18767 if (vec_len (ls_name) > 62)
18769 errmsg ("error: locator set name too long!");
18773 if (!vam->json_output)
18775 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
18778 M (ONE_LOCATOR_DUMP, mp);
18779 mp->is_index_set = is_index_set;
18782 mp->ls_index = clib_host_to_net_u32 (ls_index);
18785 vec_add1 (ls_name, 0);
18786 strncpy ((char *) mp->ls_name, (char *) ls_name,
18787 sizeof (mp->ls_name) - 1);
18793 /* Use a control ping for synchronization */
18794 MPING (CONTROL_PING, mp_ping);
18797 /* Wait for a reply... */
18802 #define api_lisp_locator_dump api_one_locator_dump
18805 api_one_locator_set_dump (vat_main_t * vam)
18807 vl_api_one_locator_set_dump_t *mp;
18808 vl_api_control_ping_t *mp_ping;
18809 unformat_input_t *input = vam->input;
18813 /* Parse args required to build the message */
18814 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18816 if (unformat (input, "local"))
18820 else if (unformat (input, "remote"))
18826 errmsg ("parse error '%U'", format_unformat_error, input);
18831 if (!vam->json_output)
18833 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18836 M (ONE_LOCATOR_SET_DUMP, mp);
18838 mp->filter = filter;
18843 /* Use a control ping for synchronization */
18844 MPING (CONTROL_PING, mp_ping);
18847 /* Wait for a reply... */
18852 #define api_lisp_locator_set_dump api_one_locator_set_dump
18855 api_one_eid_table_map_dump (vat_main_t * vam)
18859 unformat_input_t *input = vam->input;
18860 vl_api_one_eid_table_map_dump_t *mp;
18861 vl_api_control_ping_t *mp_ping;
18864 /* Parse args required to build the message */
18865 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18867 if (unformat (input, "l2"))
18872 else if (unformat (input, "l3"))
18879 errmsg ("parse error '%U'", format_unformat_error, input);
18886 errmsg ("expected one of 'l2' or 'l3' parameter!");
18890 if (!vam->json_output)
18892 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18895 M (ONE_EID_TABLE_MAP_DUMP, mp);
18901 /* Use a control ping for synchronization */
18902 MPING (CONTROL_PING, mp_ping);
18905 /* Wait for a reply... */
18910 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18913 api_one_eid_table_vni_dump (vat_main_t * vam)
18915 vl_api_one_eid_table_vni_dump_t *mp;
18916 vl_api_control_ping_t *mp_ping;
18919 if (!vam->json_output)
18921 print (vam->ofp, "VNI");
18924 M (ONE_EID_TABLE_VNI_DUMP, mp);
18929 /* Use a control ping for synchronization */
18930 MPING (CONTROL_PING, mp_ping);
18933 /* Wait for a reply... */
18938 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18941 api_one_eid_table_dump (vat_main_t * vam)
18943 unformat_input_t *i = vam->input;
18944 vl_api_one_eid_table_dump_t *mp;
18945 vl_api_control_ping_t *mp_ping;
18946 struct in_addr ip4;
18947 struct in6_addr ip6;
18949 u8 eid_type = ~0, eid_set = 0;
18950 u32 prefix_length = ~0, t, vni = 0;
18953 lisp_nsh_api_t nsh;
18955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18957 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18963 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18969 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18974 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18979 else if (unformat (i, "vni %d", &t))
18983 else if (unformat (i, "local"))
18987 else if (unformat (i, "remote"))
18993 errmsg ("parse error '%U'", format_unformat_error, i);
18998 if (!vam->json_output)
19000 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19001 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19004 M (ONE_EID_TABLE_DUMP, mp);
19006 mp->filter = filter;
19010 mp->vni = htonl (vni);
19011 mp->eid_type = eid_type;
19015 mp->prefix_length = prefix_length;
19016 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19019 mp->prefix_length = prefix_length;
19020 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19023 clib_memcpy (mp->eid, mac, sizeof (mac));
19026 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19029 errmsg ("unknown EID type %d!", eid_type);
19037 /* Use a control ping for synchronization */
19038 MPING (CONTROL_PING, mp_ping);
19041 /* Wait for a reply... */
19046 #define api_lisp_eid_table_dump api_one_eid_table_dump
19049 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19051 unformat_input_t *i = vam->input;
19052 vl_api_gpe_fwd_entries_get_t *mp;
19057 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19059 if (unformat (i, "vni %d", &vni))
19065 errmsg ("parse error '%U'", format_unformat_error, i);
19072 errmsg ("vni not set!");
19076 if (!vam->json_output)
19078 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19082 M (GPE_FWD_ENTRIES_GET, mp);
19083 mp->vni = clib_host_to_net_u32 (vni);
19088 /* Wait for a reply... */
19093 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19094 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19095 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19096 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19097 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19098 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19099 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19100 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19103 api_one_adjacencies_get (vat_main_t * vam)
19105 unformat_input_t *i = vam->input;
19106 vl_api_one_adjacencies_get_t *mp;
19111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19113 if (unformat (i, "vni %d", &vni))
19119 errmsg ("parse error '%U'", format_unformat_error, i);
19126 errmsg ("vni not set!");
19130 if (!vam->json_output)
19132 print (vam->ofp, "%s %40s", "leid", "reid");
19135 M (ONE_ADJACENCIES_GET, mp);
19136 mp->vni = clib_host_to_net_u32 (vni);
19141 /* Wait for a reply... */
19146 #define api_lisp_adjacencies_get api_one_adjacencies_get
19149 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19151 unformat_input_t *i = vam->input;
19152 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19154 u8 ip_family_set = 0, is_ip4 = 1;
19156 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19158 if (unformat (i, "ip4"))
19163 else if (unformat (i, "ip6"))
19170 errmsg ("parse error '%U'", format_unformat_error, i);
19175 if (!ip_family_set)
19177 errmsg ("ip family not set!");
19181 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19182 mp->is_ip4 = is_ip4;
19187 /* Wait for a reply... */
19193 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19195 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19198 if (!vam->json_output)
19200 print (vam->ofp, "VNIs");
19203 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19208 /* Wait for a reply... */
19214 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19216 unformat_input_t *i = vam->input;
19217 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19219 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19220 struct in_addr ip4;
19221 struct in6_addr ip6;
19222 u32 table_id = 0, nh_sw_if_index = ~0;
19224 clib_memset (&ip4, 0, sizeof (ip4));
19225 clib_memset (&ip6, 0, sizeof (ip6));
19227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19229 if (unformat (i, "del"))
19231 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19232 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19237 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19238 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19243 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19247 nh_sw_if_index = ~0;
19249 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19253 nh_sw_if_index = ~0;
19255 else if (unformat (i, "table %d", &table_id))
19259 errmsg ("parse error '%U'", format_unformat_error, i);
19266 errmsg ("nh addr not set!");
19270 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19271 mp->is_add = is_add;
19272 mp->table_id = clib_host_to_net_u32 (table_id);
19273 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19274 mp->is_ip4 = is_ip4;
19276 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19278 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19283 /* Wait for a reply... */
19289 api_one_map_server_dump (vat_main_t * vam)
19291 vl_api_one_map_server_dump_t *mp;
19292 vl_api_control_ping_t *mp_ping;
19295 if (!vam->json_output)
19297 print (vam->ofp, "%=20s", "Map server");
19300 M (ONE_MAP_SERVER_DUMP, mp);
19304 /* Use a control ping for synchronization */
19305 MPING (CONTROL_PING, mp_ping);
19308 /* Wait for a reply... */
19313 #define api_lisp_map_server_dump api_one_map_server_dump
19316 api_one_map_resolver_dump (vat_main_t * vam)
19318 vl_api_one_map_resolver_dump_t *mp;
19319 vl_api_control_ping_t *mp_ping;
19322 if (!vam->json_output)
19324 print (vam->ofp, "%=20s", "Map resolver");
19327 M (ONE_MAP_RESOLVER_DUMP, mp);
19331 /* Use a control ping for synchronization */
19332 MPING (CONTROL_PING, mp_ping);
19335 /* Wait for a reply... */
19340 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19343 api_one_stats_flush (vat_main_t * vam)
19345 vl_api_one_stats_flush_t *mp;
19348 M (ONE_STATS_FLUSH, mp);
19355 api_one_stats_dump (vat_main_t * vam)
19357 vl_api_one_stats_dump_t *mp;
19358 vl_api_control_ping_t *mp_ping;
19361 M (ONE_STATS_DUMP, mp);
19365 /* Use a control ping for synchronization */
19366 MPING (CONTROL_PING, mp_ping);
19369 /* Wait for a reply... */
19375 api_show_one_status (vat_main_t * vam)
19377 vl_api_show_one_status_t *mp;
19380 if (!vam->json_output)
19382 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19385 M (SHOW_ONE_STATUS, mp);
19388 /* Wait for a reply... */
19393 #define api_show_lisp_status api_show_one_status
19396 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19398 vl_api_gpe_fwd_entry_path_dump_t *mp;
19399 vl_api_control_ping_t *mp_ping;
19400 unformat_input_t *i = vam->input;
19401 u32 fwd_entry_index = ~0;
19404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19406 if (unformat (i, "index %d", &fwd_entry_index))
19412 if (~0 == fwd_entry_index)
19414 errmsg ("no index specified!");
19418 if (!vam->json_output)
19420 print (vam->ofp, "first line");
19423 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19427 /* Use a control ping for synchronization */
19428 MPING (CONTROL_PING, mp_ping);
19431 /* Wait for a reply... */
19437 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19439 vl_api_one_get_map_request_itr_rlocs_t *mp;
19442 if (!vam->json_output)
19444 print (vam->ofp, "%=20s", "itr-rlocs:");
19447 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19450 /* Wait for a reply... */
19455 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19458 api_af_packet_create (vat_main_t * vam)
19460 unformat_input_t *i = vam->input;
19461 vl_api_af_packet_create_t *mp;
19462 u8 *host_if_name = 0;
19464 u8 random_hw_addr = 1;
19467 clib_memset (hw_addr, 0, sizeof (hw_addr));
19469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19471 if (unformat (i, "name %s", &host_if_name))
19472 vec_add1 (host_if_name, 0);
19473 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19474 random_hw_addr = 0;
19479 if (!vec_len (host_if_name))
19481 errmsg ("host-interface name must be specified");
19485 if (vec_len (host_if_name) > 64)
19487 errmsg ("host-interface name too long");
19491 M (AF_PACKET_CREATE, mp);
19493 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19494 clib_memcpy (mp->hw_addr, hw_addr, 6);
19495 mp->use_random_hw_addr = random_hw_addr;
19496 vec_free (host_if_name);
19504 fprintf (vam->ofp ? vam->ofp : stderr,
19505 " new sw_if_index = %d\n", vam->sw_if_index);
19512 api_af_packet_delete (vat_main_t * vam)
19514 unformat_input_t *i = vam->input;
19515 vl_api_af_packet_delete_t *mp;
19516 u8 *host_if_name = 0;
19519 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19521 if (unformat (i, "name %s", &host_if_name))
19522 vec_add1 (host_if_name, 0);
19527 if (!vec_len (host_if_name))
19529 errmsg ("host-interface name must be specified");
19533 if (vec_len (host_if_name) > 64)
19535 errmsg ("host-interface name too long");
19539 M (AF_PACKET_DELETE, mp);
19541 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19542 vec_free (host_if_name);
19549 static void vl_api_af_packet_details_t_handler
19550 (vl_api_af_packet_details_t * mp)
19552 vat_main_t *vam = &vat_main;
19554 print (vam->ofp, "%-16s %d",
19555 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19558 static void vl_api_af_packet_details_t_handler_json
19559 (vl_api_af_packet_details_t * mp)
19561 vat_main_t *vam = &vat_main;
19562 vat_json_node_t *node = NULL;
19564 if (VAT_JSON_ARRAY != vam->json_tree.type)
19566 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19567 vat_json_init_array (&vam->json_tree);
19569 node = vat_json_array_add (&vam->json_tree);
19571 vat_json_init_object (node);
19572 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19573 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19577 api_af_packet_dump (vat_main_t * vam)
19579 vl_api_af_packet_dump_t *mp;
19580 vl_api_control_ping_t *mp_ping;
19583 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19584 /* Get list of tap interfaces */
19585 M (AF_PACKET_DUMP, mp);
19588 /* Use a control ping for synchronization */
19589 MPING (CONTROL_PING, mp_ping);
19597 api_policer_add_del (vat_main_t * vam)
19599 unformat_input_t *i = vam->input;
19600 vl_api_policer_add_del_t *mp;
19610 u8 color_aware = 0;
19611 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19614 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19615 conform_action.dscp = 0;
19616 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19617 exceed_action.dscp = 0;
19618 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19619 violate_action.dscp = 0;
19621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19623 if (unformat (i, "del"))
19625 else if (unformat (i, "name %s", &name))
19626 vec_add1 (name, 0);
19627 else if (unformat (i, "cir %u", &cir))
19629 else if (unformat (i, "eir %u", &eir))
19631 else if (unformat (i, "cb %u", &cb))
19633 else if (unformat (i, "eb %u", &eb))
19635 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19638 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19641 else if (unformat (i, "type %U", unformat_policer_type, &type))
19643 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19646 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19649 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19652 else if (unformat (i, "color-aware"))
19658 if (!vec_len (name))
19660 errmsg ("policer name must be specified");
19664 if (vec_len (name) > 64)
19666 errmsg ("policer name too long");
19670 M (POLICER_ADD_DEL, mp);
19672 clib_memcpy (mp->name, name, vec_len (name));
19674 mp->is_add = is_add;
19675 mp->cir = ntohl (cir);
19676 mp->eir = ntohl (eir);
19677 mp->cb = clib_net_to_host_u64 (cb);
19678 mp->eb = clib_net_to_host_u64 (eb);
19679 mp->rate_type = rate_type;
19680 mp->round_type = round_type;
19682 mp->conform_action_type = conform_action.action_type;
19683 mp->conform_dscp = conform_action.dscp;
19684 mp->exceed_action_type = exceed_action.action_type;
19685 mp->exceed_dscp = exceed_action.dscp;
19686 mp->violate_action_type = violate_action.action_type;
19687 mp->violate_dscp = violate_action.dscp;
19688 mp->color_aware = color_aware;
19696 api_policer_dump (vat_main_t * vam)
19698 unformat_input_t *i = vam->input;
19699 vl_api_policer_dump_t *mp;
19700 vl_api_control_ping_t *mp_ping;
19701 u8 *match_name = 0;
19702 u8 match_name_valid = 0;
19705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19707 if (unformat (i, "name %s", &match_name))
19709 vec_add1 (match_name, 0);
19710 match_name_valid = 1;
19716 M (POLICER_DUMP, mp);
19717 mp->match_name_valid = match_name_valid;
19718 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19719 vec_free (match_name);
19723 /* Use a control ping for synchronization */
19724 MPING (CONTROL_PING, mp_ping);
19727 /* Wait for a reply... */
19733 api_policer_classify_set_interface (vat_main_t * vam)
19735 unformat_input_t *i = vam->input;
19736 vl_api_policer_classify_set_interface_t *mp;
19738 int sw_if_index_set;
19739 u32 ip4_table_index = ~0;
19740 u32 ip6_table_index = ~0;
19741 u32 l2_table_index = ~0;
19745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19747 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19748 sw_if_index_set = 1;
19749 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19750 sw_if_index_set = 1;
19751 else if (unformat (i, "del"))
19753 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19755 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19757 else if (unformat (i, "l2-table %d", &l2_table_index))
19761 clib_warning ("parse error '%U'", format_unformat_error, i);
19766 if (sw_if_index_set == 0)
19768 errmsg ("missing interface name or sw_if_index");
19772 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19774 mp->sw_if_index = ntohl (sw_if_index);
19775 mp->ip4_table_index = ntohl (ip4_table_index);
19776 mp->ip6_table_index = ntohl (ip6_table_index);
19777 mp->l2_table_index = ntohl (l2_table_index);
19778 mp->is_add = is_add;
19786 api_policer_classify_dump (vat_main_t * vam)
19788 unformat_input_t *i = vam->input;
19789 vl_api_policer_classify_dump_t *mp;
19790 vl_api_control_ping_t *mp_ping;
19791 u8 type = POLICER_CLASSIFY_N_TABLES;
19794 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19798 errmsg ("classify table type must be specified");
19802 if (!vam->json_output)
19804 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19807 M (POLICER_CLASSIFY_DUMP, mp);
19812 /* Use a control ping for synchronization */
19813 MPING (CONTROL_PING, mp_ping);
19816 /* Wait for a reply... */
19822 api_netmap_create (vat_main_t * vam)
19824 unformat_input_t *i = vam->input;
19825 vl_api_netmap_create_t *mp;
19828 u8 random_hw_addr = 1;
19833 clib_memset (hw_addr, 0, sizeof (hw_addr));
19835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19837 if (unformat (i, "name %s", &if_name))
19838 vec_add1 (if_name, 0);
19839 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19840 random_hw_addr = 0;
19841 else if (unformat (i, "pipe"))
19843 else if (unformat (i, "master"))
19845 else if (unformat (i, "slave"))
19851 if (!vec_len (if_name))
19853 errmsg ("interface name must be specified");
19857 if (vec_len (if_name) > 64)
19859 errmsg ("interface name too long");
19863 M (NETMAP_CREATE, mp);
19865 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19866 clib_memcpy (mp->hw_addr, hw_addr, 6);
19867 mp->use_random_hw_addr = random_hw_addr;
19868 mp->is_pipe = is_pipe;
19869 mp->is_master = is_master;
19870 vec_free (if_name);
19878 api_netmap_delete (vat_main_t * vam)
19880 unformat_input_t *i = vam->input;
19881 vl_api_netmap_delete_t *mp;
19885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19887 if (unformat (i, "name %s", &if_name))
19888 vec_add1 (if_name, 0);
19893 if (!vec_len (if_name))
19895 errmsg ("interface name must be specified");
19899 if (vec_len (if_name) > 64)
19901 errmsg ("interface name too long");
19905 M (NETMAP_DELETE, mp);
19907 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19908 vec_free (if_name);
19916 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
19918 if (fp->afi == IP46_TYPE_IP6)
19920 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19921 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19922 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
19923 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19924 format_ip6_address, fp->next_hop);
19925 else if (fp->afi == IP46_TYPE_IP4)
19927 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19928 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19929 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
19930 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19931 format_ip4_address, fp->next_hop);
19935 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19936 vl_api_fib_path_t * fp)
19938 struct in_addr ip4;
19939 struct in6_addr ip6;
19941 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19942 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19943 vat_json_object_add_uint (node, "is_local", fp->is_local);
19944 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19945 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19946 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19947 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19948 if (fp->afi == IP46_TYPE_IP4)
19950 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19951 vat_json_object_add_ip4 (node, "next_hop", ip4);
19953 else if (fp->afi == IP46_TYPE_IP6)
19955 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19956 vat_json_object_add_ip6 (node, "next_hop", ip6);
19961 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19963 vat_main_t *vam = &vat_main;
19964 int count = ntohl (mp->mt_count);
19965 vl_api_fib_path_t *fp;
19968 print (vam->ofp, "[%d]: sw_if_index %d via:",
19969 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19971 for (i = 0; i < count; i++)
19973 vl_api_mpls_fib_path_print (vam, fp);
19977 print (vam->ofp, "");
19980 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19981 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19984 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19986 vat_main_t *vam = &vat_main;
19987 vat_json_node_t *node = NULL;
19988 int count = ntohl (mp->mt_count);
19989 vl_api_fib_path_t *fp;
19992 if (VAT_JSON_ARRAY != vam->json_tree.type)
19994 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19995 vat_json_init_array (&vam->json_tree);
19997 node = vat_json_array_add (&vam->json_tree);
19999 vat_json_init_object (node);
20000 vat_json_object_add_uint (node, "tunnel_index",
20001 ntohl (mp->mt_tunnel_index));
20002 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20004 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20007 for (i = 0; i < count; i++)
20009 vl_api_mpls_fib_path_json_print (node, fp);
20015 api_mpls_tunnel_dump (vat_main_t * vam)
20017 vl_api_mpls_tunnel_dump_t *mp;
20018 vl_api_control_ping_t *mp_ping;
20019 u32 sw_if_index = ~0;
20022 /* Parse args required to build the message */
20023 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20025 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
20029 print (vam->ofp, " sw_if_index %d", sw_if_index);
20031 M (MPLS_TUNNEL_DUMP, mp);
20032 mp->sw_if_index = htonl (sw_if_index);
20035 /* Use a control ping for synchronization */
20036 MPING (CONTROL_PING, mp_ping);
20043 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20044 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20048 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20050 vat_main_t *vam = &vat_main;
20051 int count = ntohl (mp->count);
20052 vl_api_fib_path_t *fp;
20056 "table-id %d, label %u, ess_bit %u",
20057 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20059 for (i = 0; i < count; i++)
20061 vl_api_mpls_fib_path_print (vam, fp);
20066 static void vl_api_mpls_fib_details_t_handler_json
20067 (vl_api_mpls_fib_details_t * mp)
20069 vat_main_t *vam = &vat_main;
20070 int count = ntohl (mp->count);
20071 vat_json_node_t *node = NULL;
20072 vl_api_fib_path_t *fp;
20075 if (VAT_JSON_ARRAY != vam->json_tree.type)
20077 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20078 vat_json_init_array (&vam->json_tree);
20080 node = vat_json_array_add (&vam->json_tree);
20082 vat_json_init_object (node);
20083 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20084 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20085 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20086 vat_json_object_add_uint (node, "path_count", count);
20088 for (i = 0; i < count; i++)
20090 vl_api_mpls_fib_path_json_print (node, fp);
20096 api_mpls_fib_dump (vat_main_t * vam)
20098 vl_api_mpls_fib_dump_t *mp;
20099 vl_api_control_ping_t *mp_ping;
20102 M (MPLS_FIB_DUMP, mp);
20105 /* Use a control ping for synchronization */
20106 MPING (CONTROL_PING, mp_ping);
20113 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20114 #define vl_api_ip_fib_details_t_print vl_noop_handler
20117 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20119 vat_main_t *vam = &vat_main;
20120 int count = ntohl (mp->count);
20121 vl_api_fib_path_t *fp;
20125 "table-id %d, prefix %U/%d stats-index %d",
20126 ntohl (mp->table_id), format_ip4_address, mp->address,
20127 mp->address_length, ntohl (mp->stats_index));
20129 for (i = 0; i < count; i++)
20131 if (fp->afi == IP46_TYPE_IP6)
20133 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20134 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20135 "next_hop_table %d",
20136 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20137 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20138 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
20139 else if (fp->afi == IP46_TYPE_IP4)
20141 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20142 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
20143 "next_hop_table %d",
20144 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20145 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20146 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
20151 static void vl_api_ip_fib_details_t_handler_json
20152 (vl_api_ip_fib_details_t * mp)
20154 vat_main_t *vam = &vat_main;
20155 int count = ntohl (mp->count);
20156 vat_json_node_t *node = NULL;
20157 struct in_addr ip4;
20158 struct in6_addr ip6;
20159 vl_api_fib_path_t *fp;
20162 if (VAT_JSON_ARRAY != vam->json_tree.type)
20164 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20165 vat_json_init_array (&vam->json_tree);
20167 node = vat_json_array_add (&vam->json_tree);
20169 vat_json_init_object (node);
20170 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20171 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20172 vat_json_object_add_ip4 (node, "prefix", ip4);
20173 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20174 vat_json_object_add_uint (node, "path_count", count);
20176 for (i = 0; i < count; i++)
20178 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20179 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20180 vat_json_object_add_uint (node, "is_local", fp->is_local);
20181 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20182 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20183 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20184 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20185 if (fp->afi == IP46_TYPE_IP4)
20187 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20188 vat_json_object_add_ip4 (node, "next_hop", ip4);
20190 else if (fp->afi == IP46_TYPE_IP6)
20192 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20193 vat_json_object_add_ip6 (node, "next_hop", ip6);
20199 api_ip_fib_dump (vat_main_t * vam)
20201 vl_api_ip_fib_dump_t *mp;
20202 vl_api_control_ping_t *mp_ping;
20205 M (IP_FIB_DUMP, mp);
20208 /* Use a control ping for synchronization */
20209 MPING (CONTROL_PING, mp_ping);
20217 api_ip_mfib_dump (vat_main_t * vam)
20219 vl_api_ip_mfib_dump_t *mp;
20220 vl_api_control_ping_t *mp_ping;
20223 M (IP_MFIB_DUMP, mp);
20226 /* Use a control ping for synchronization */
20227 MPING (CONTROL_PING, mp_ping);
20234 static void vl_api_ip_neighbor_details_t_handler
20235 (vl_api_ip_neighbor_details_t * mp)
20237 vat_main_t *vam = &vat_main;
20239 print (vam->ofp, "%c %U %U",
20240 (mp->is_static) ? 'S' : 'D',
20241 format_ethernet_address, &mp->mac_address,
20242 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20246 static void vl_api_ip_neighbor_details_t_handler_json
20247 (vl_api_ip_neighbor_details_t * mp)
20250 vat_main_t *vam = &vat_main;
20251 vat_json_node_t *node;
20252 struct in_addr ip4;
20253 struct in6_addr ip6;
20255 if (VAT_JSON_ARRAY != vam->json_tree.type)
20257 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20258 vat_json_init_array (&vam->json_tree);
20260 node = vat_json_array_add (&vam->json_tree);
20262 vat_json_init_object (node);
20263 vat_json_object_add_string_copy (node, "flag",
20264 (mp->is_static) ? (u8 *) "static" : (u8 *)
20267 vat_json_object_add_string_copy (node, "link_layer",
20268 format (0, "%U", format_ethernet_address,
20269 &mp->mac_address));
20273 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20274 vat_json_object_add_ip6 (node, "ip_address", ip6);
20278 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20279 vat_json_object_add_ip4 (node, "ip_address", ip4);
20284 api_ip_neighbor_dump (vat_main_t * vam)
20286 unformat_input_t *i = vam->input;
20287 vl_api_ip_neighbor_dump_t *mp;
20288 vl_api_control_ping_t *mp_ping;
20290 u32 sw_if_index = ~0;
20293 /* Parse args required to build the message */
20294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20296 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20298 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20300 else if (unformat (i, "ip6"))
20306 if (sw_if_index == ~0)
20308 errmsg ("missing interface name or sw_if_index");
20312 M (IP_NEIGHBOR_DUMP, mp);
20313 mp->is_ipv6 = (u8) is_ipv6;
20314 mp->sw_if_index = ntohl (sw_if_index);
20317 /* Use a control ping for synchronization */
20318 MPING (CONTROL_PING, mp_ping);
20325 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20326 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20329 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20331 vat_main_t *vam = &vat_main;
20332 int count = ntohl (mp->count);
20333 vl_api_fib_path_t *fp;
20337 "table-id %d, prefix %U/%d stats-index %d",
20338 ntohl (mp->table_id), format_ip6_address, mp->address,
20339 mp->address_length, ntohl (mp->stats_index));
20341 for (i = 0; i < count; i++)
20343 if (fp->afi == IP46_TYPE_IP6)
20345 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20346 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20347 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20348 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20349 format_ip6_address, fp->next_hop);
20350 else if (fp->afi == IP46_TYPE_IP4)
20352 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20353 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20354 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20355 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20356 format_ip4_address, fp->next_hop);
20361 static void vl_api_ip6_fib_details_t_handler_json
20362 (vl_api_ip6_fib_details_t * mp)
20364 vat_main_t *vam = &vat_main;
20365 int count = ntohl (mp->count);
20366 vat_json_node_t *node = NULL;
20367 struct in_addr ip4;
20368 struct in6_addr ip6;
20369 vl_api_fib_path_t *fp;
20372 if (VAT_JSON_ARRAY != vam->json_tree.type)
20374 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20375 vat_json_init_array (&vam->json_tree);
20377 node = vat_json_array_add (&vam->json_tree);
20379 vat_json_init_object (node);
20380 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20381 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20382 vat_json_object_add_ip6 (node, "prefix", ip6);
20383 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20384 vat_json_object_add_uint (node, "path_count", count);
20386 for (i = 0; i < count; i++)
20388 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20389 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20390 vat_json_object_add_uint (node, "is_local", fp->is_local);
20391 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20392 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20393 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20394 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20395 if (fp->afi == IP46_TYPE_IP4)
20397 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20398 vat_json_object_add_ip4 (node, "next_hop", ip4);
20400 else if (fp->afi == IP46_TYPE_IP6)
20402 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20403 vat_json_object_add_ip6 (node, "next_hop", ip6);
20409 api_ip6_fib_dump (vat_main_t * vam)
20411 vl_api_ip6_fib_dump_t *mp;
20412 vl_api_control_ping_t *mp_ping;
20415 M (IP6_FIB_DUMP, mp);
20418 /* Use a control ping for synchronization */
20419 MPING (CONTROL_PING, mp_ping);
20427 api_ip6_mfib_dump (vat_main_t * vam)
20429 vl_api_ip6_mfib_dump_t *mp;
20430 vl_api_control_ping_t *mp_ping;
20433 M (IP6_MFIB_DUMP, mp);
20436 /* Use a control ping for synchronization */
20437 MPING (CONTROL_PING, mp_ping);
20445 api_classify_table_ids (vat_main_t * vam)
20447 vl_api_classify_table_ids_t *mp;
20450 /* Construct the API message */
20451 M (CLASSIFY_TABLE_IDS, mp);
20460 api_classify_table_by_interface (vat_main_t * vam)
20462 unformat_input_t *input = vam->input;
20463 vl_api_classify_table_by_interface_t *mp;
20465 u32 sw_if_index = ~0;
20467 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20469 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20471 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20476 if (sw_if_index == ~0)
20478 errmsg ("missing interface name or sw_if_index");
20482 /* Construct the API message */
20483 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20485 mp->sw_if_index = ntohl (sw_if_index);
20493 api_classify_table_info (vat_main_t * vam)
20495 unformat_input_t *input = vam->input;
20496 vl_api_classify_table_info_t *mp;
20500 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20502 if (unformat (input, "table_id %d", &table_id))
20507 if (table_id == ~0)
20509 errmsg ("missing table id");
20513 /* Construct the API message */
20514 M (CLASSIFY_TABLE_INFO, mp);
20516 mp->table_id = ntohl (table_id);
20524 api_classify_session_dump (vat_main_t * vam)
20526 unformat_input_t *input = vam->input;
20527 vl_api_classify_session_dump_t *mp;
20528 vl_api_control_ping_t *mp_ping;
20532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20534 if (unformat (input, "table_id %d", &table_id))
20539 if (table_id == ~0)
20541 errmsg ("missing table id");
20545 /* Construct the API message */
20546 M (CLASSIFY_SESSION_DUMP, mp);
20548 mp->table_id = ntohl (table_id);
20551 /* Use a control ping for synchronization */
20552 MPING (CONTROL_PING, mp_ping);
20560 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20562 vat_main_t *vam = &vat_main;
20564 print (vam->ofp, "collector_address %U, collector_port %d, "
20565 "src_address %U, vrf_id %d, path_mtu %u, "
20566 "template_interval %u, udp_checksum %d",
20567 format_ip4_address, mp->collector_address,
20568 ntohs (mp->collector_port),
20569 format_ip4_address, mp->src_address,
20570 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20571 ntohl (mp->template_interval), mp->udp_checksum);
20574 vam->result_ready = 1;
20578 vl_api_ipfix_exporter_details_t_handler_json
20579 (vl_api_ipfix_exporter_details_t * mp)
20581 vat_main_t *vam = &vat_main;
20582 vat_json_node_t node;
20583 struct in_addr collector_address;
20584 struct in_addr src_address;
20586 vat_json_init_object (&node);
20587 clib_memcpy (&collector_address, &mp->collector_address,
20588 sizeof (collector_address));
20589 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20590 vat_json_object_add_uint (&node, "collector_port",
20591 ntohs (mp->collector_port));
20592 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20593 vat_json_object_add_ip4 (&node, "src_address", src_address);
20594 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20595 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20596 vat_json_object_add_uint (&node, "template_interval",
20597 ntohl (mp->template_interval));
20598 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20600 vat_json_print (vam->ofp, &node);
20601 vat_json_free (&node);
20603 vam->result_ready = 1;
20607 api_ipfix_exporter_dump (vat_main_t * vam)
20609 vl_api_ipfix_exporter_dump_t *mp;
20612 /* Construct the API message */
20613 M (IPFIX_EXPORTER_DUMP, mp);
20622 api_ipfix_classify_stream_dump (vat_main_t * vam)
20624 vl_api_ipfix_classify_stream_dump_t *mp;
20627 /* Construct the API message */
20628 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20639 vl_api_ipfix_classify_stream_details_t_handler
20640 (vl_api_ipfix_classify_stream_details_t * mp)
20642 vat_main_t *vam = &vat_main;
20643 print (vam->ofp, "domain_id %d, src_port %d",
20644 ntohl (mp->domain_id), ntohs (mp->src_port));
20646 vam->result_ready = 1;
20650 vl_api_ipfix_classify_stream_details_t_handler_json
20651 (vl_api_ipfix_classify_stream_details_t * mp)
20653 vat_main_t *vam = &vat_main;
20654 vat_json_node_t node;
20656 vat_json_init_object (&node);
20657 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20658 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20660 vat_json_print (vam->ofp, &node);
20661 vat_json_free (&node);
20663 vam->result_ready = 1;
20667 api_ipfix_classify_table_dump (vat_main_t * vam)
20669 vl_api_ipfix_classify_table_dump_t *mp;
20670 vl_api_control_ping_t *mp_ping;
20673 if (!vam->json_output)
20675 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20676 "transport_protocol");
20679 /* Construct the API message */
20680 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20685 /* Use a control ping for synchronization */
20686 MPING (CONTROL_PING, mp_ping);
20694 vl_api_ipfix_classify_table_details_t_handler
20695 (vl_api_ipfix_classify_table_details_t * mp)
20697 vat_main_t *vam = &vat_main;
20698 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20699 mp->transport_protocol);
20703 vl_api_ipfix_classify_table_details_t_handler_json
20704 (vl_api_ipfix_classify_table_details_t * mp)
20706 vat_json_node_t *node = NULL;
20707 vat_main_t *vam = &vat_main;
20709 if (VAT_JSON_ARRAY != vam->json_tree.type)
20711 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20712 vat_json_init_array (&vam->json_tree);
20715 node = vat_json_array_add (&vam->json_tree);
20716 vat_json_init_object (node);
20718 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20719 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20720 vat_json_object_add_uint (node, "transport_protocol",
20721 mp->transport_protocol);
20725 api_sw_interface_span_enable_disable (vat_main_t * vam)
20727 unformat_input_t *i = vam->input;
20728 vl_api_sw_interface_span_enable_disable_t *mp;
20729 u32 src_sw_if_index = ~0;
20730 u32 dst_sw_if_index = ~0;
20735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20738 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
20740 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
20744 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
20746 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
20748 else if (unformat (i, "disable"))
20750 else if (unformat (i, "rx"))
20752 else if (unformat (i, "tx"))
20754 else if (unformat (i, "both"))
20756 else if (unformat (i, "l2"))
20762 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20764 mp->sw_if_index_from = htonl (src_sw_if_index);
20765 mp->sw_if_index_to = htonl (dst_sw_if_index);
20775 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
20778 vat_main_t *vam = &vat_main;
20779 u8 *sw_if_from_name = 0;
20780 u8 *sw_if_to_name = 0;
20781 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20782 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20783 char *states[] = { "none", "rx", "tx", "both" };
20787 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20789 if ((u32) p->value[0] == sw_if_index_from)
20791 sw_if_from_name = (u8 *)(p->key);
20795 if ((u32) p->value[0] == sw_if_index_to)
20797 sw_if_to_name = (u8 *)(p->key);
20798 if (sw_if_from_name)
20803 print (vam->ofp, "%20s => %20s (%s) %s",
20804 sw_if_from_name, sw_if_to_name, states[mp->state],
20805 mp->is_l2 ? "l2" : "device");
20809 vl_api_sw_interface_span_details_t_handler_json
20810 (vl_api_sw_interface_span_details_t * mp)
20812 vat_main_t *vam = &vat_main;
20813 vat_json_node_t *node = NULL;
20814 u8 *sw_if_from_name = 0;
20815 u8 *sw_if_to_name = 0;
20816 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20817 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20821 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20823 if ((u32) p->value[0] == sw_if_index_from)
20825 sw_if_from_name = (u8 *)(p->key);
20829 if ((u32) p->value[0] == sw_if_index_to)
20831 sw_if_to_name = (u8 *)(p->key);
20832 if (sw_if_from_name)
20838 if (VAT_JSON_ARRAY != vam->json_tree.type)
20840 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20841 vat_json_init_array (&vam->json_tree);
20843 node = vat_json_array_add (&vam->json_tree);
20845 vat_json_init_object (node);
20846 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20847 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20848 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20849 if (0 != sw_if_to_name)
20851 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20853 vat_json_object_add_uint (node, "state", mp->state);
20854 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
20858 api_sw_interface_span_dump (vat_main_t * vam)
20860 unformat_input_t *input = vam->input;
20861 vl_api_sw_interface_span_dump_t *mp;
20862 vl_api_control_ping_t *mp_ping;
20866 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20868 if (unformat (input, "l2"))
20874 M (SW_INTERFACE_SPAN_DUMP, mp);
20878 /* Use a control ping for synchronization */
20879 MPING (CONTROL_PING, mp_ping);
20887 api_pg_create_interface (vat_main_t * vam)
20889 unformat_input_t *input = vam->input;
20890 vl_api_pg_create_interface_t *mp;
20894 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20896 if (unformat (input, "if_id %d", &if_id))
20903 errmsg ("missing pg interface index");
20907 /* Construct the API message */
20908 M (PG_CREATE_INTERFACE, mp);
20910 mp->interface_id = ntohl (if_id);
20918 api_pg_capture (vat_main_t * vam)
20920 unformat_input_t *input = vam->input;
20921 vl_api_pg_capture_t *mp;
20926 u8 pcap_file_set = 0;
20929 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20931 if (unformat (input, "if_id %d", &if_id))
20933 else if (unformat (input, "pcap %s", &pcap_file))
20935 else if (unformat (input, "count %d", &count))
20937 else if (unformat (input, "disable"))
20944 errmsg ("missing pg interface index");
20947 if (pcap_file_set > 0)
20949 if (vec_len (pcap_file) > 255)
20951 errmsg ("pcap file name is too long");
20956 u32 name_len = vec_len (pcap_file);
20957 /* Construct the API message */
20958 M (PG_CAPTURE, mp);
20960 mp->interface_id = ntohl (if_id);
20961 mp->is_enabled = enable;
20962 mp->count = ntohl (count);
20963 mp->pcap_name_length = ntohl (name_len);
20964 if (pcap_file_set != 0)
20966 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20968 vec_free (pcap_file);
20976 api_pg_enable_disable (vat_main_t * vam)
20978 unformat_input_t *input = vam->input;
20979 vl_api_pg_enable_disable_t *mp;
20982 u8 stream_name_set = 0;
20983 u8 *stream_name = 0;
20985 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20987 if (unformat (input, "stream %s", &stream_name))
20988 stream_name_set = 1;
20989 else if (unformat (input, "disable"))
20995 if (stream_name_set > 0)
20997 if (vec_len (stream_name) > 255)
20999 errmsg ("stream name too long");
21004 u32 name_len = vec_len (stream_name);
21005 /* Construct the API message */
21006 M (PG_ENABLE_DISABLE, mp);
21008 mp->is_enabled = enable;
21009 if (stream_name_set != 0)
21011 mp->stream_name_length = ntohl (name_len);
21012 clib_memcpy (mp->stream_name, stream_name, name_len);
21014 vec_free (stream_name);
21022 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21024 unformat_input_t *input = vam->input;
21025 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21027 u16 *low_ports = 0;
21028 u16 *high_ports = 0;
21031 ip4_address_t ip4_addr;
21032 ip6_address_t ip6_addr;
21041 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21043 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21049 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21054 else if (unformat (input, "vrf %d", &vrf_id))
21056 else if (unformat (input, "del"))
21058 else if (unformat (input, "port %d", &tmp))
21060 if (tmp == 0 || tmp > 65535)
21062 errmsg ("port %d out of range", tmp);
21066 this_hi = this_low + 1;
21067 vec_add1 (low_ports, this_low);
21068 vec_add1 (high_ports, this_hi);
21070 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21072 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21074 errmsg ("incorrect range parameters");
21078 /* Note: in debug CLI +1 is added to high before
21079 passing to real fn that does "the work"
21080 (ip_source_and_port_range_check_add_del).
21081 This fn is a wrapper around the binary API fn a
21082 control plane will call, which expects this increment
21083 to have occurred. Hence letting the binary API control
21084 plane fn do the increment for consistency between VAT
21085 and other control planes.
21088 vec_add1 (low_ports, this_low);
21089 vec_add1 (high_ports, this_hi);
21095 if (prefix_set == 0)
21097 errmsg ("<address>/<mask> not specified");
21103 errmsg ("VRF ID required, not specified");
21110 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21114 if (vec_len (low_ports) == 0)
21116 errmsg ("At least one port or port range required");
21120 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21122 mp->is_add = is_add;
21127 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21132 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21135 mp->mask_length = length;
21136 mp->number_of_ranges = vec_len (low_ports);
21138 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21139 vec_free (low_ports);
21141 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21142 vec_free (high_ports);
21144 mp->vrf_id = ntohl (vrf_id);
21152 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21154 unformat_input_t *input = vam->input;
21155 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21156 u32 sw_if_index = ~0;
21158 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21159 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21163 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21165 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21167 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21169 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21171 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21173 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21175 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21177 else if (unformat (input, "del"))
21183 if (sw_if_index == ~0)
21185 errmsg ("Interface required but not specified");
21191 errmsg ("VRF ID required but not specified");
21195 if (tcp_out_vrf_id == 0
21196 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21199 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21203 /* Construct the API message */
21204 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21206 mp->sw_if_index = ntohl (sw_if_index);
21207 mp->is_add = is_add;
21208 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21209 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21210 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21211 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21216 /* Wait for a reply... */
21222 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21224 unformat_input_t *i = vam->input;
21225 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21226 u32 local_sa_id = 0;
21227 u32 remote_sa_id = 0;
21228 ip4_address_t src_address;
21229 ip4_address_t dst_address;
21233 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21235 if (unformat (i, "local_sa %d", &local_sa_id))
21237 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21239 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21241 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21243 else if (unformat (i, "del"))
21247 clib_warning ("parse error '%U'", format_unformat_error, i);
21252 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21254 mp->local_sa_id = ntohl (local_sa_id);
21255 mp->remote_sa_id = ntohl (remote_sa_id);
21256 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21257 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21258 mp->is_add = is_add;
21266 api_set_punt (vat_main_t * vam)
21268 unformat_input_t *i = vam->input;
21269 vl_api_set_punt_t *mp;
21276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21278 if (unformat (i, "ip %d", &ipv))
21280 else if (unformat (i, "protocol %d", &protocol))
21282 else if (unformat (i, "port %d", &port))
21284 else if (unformat (i, "del"))
21288 clib_warning ("parse error '%U'", format_unformat_error, i);
21295 mp->is_add = (u8) is_add;
21296 mp->punt.ipv = (u8) ipv;
21297 mp->punt.l4_protocol = (u8) protocol;
21298 mp->punt.l4_port = htons ((u16) port);
21305 static void vl_api_ipsec_gre_tunnel_details_t_handler
21306 (vl_api_ipsec_gre_tunnel_details_t * mp)
21308 vat_main_t *vam = &vat_main;
21310 print (vam->ofp, "%11d%15U%15U%14d%14d",
21311 ntohl (mp->sw_if_index),
21312 format_ip4_address, &mp->src_address,
21313 format_ip4_address, &mp->dst_address,
21314 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21317 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21318 (vl_api_ipsec_gre_tunnel_details_t * mp)
21320 vat_main_t *vam = &vat_main;
21321 vat_json_node_t *node = NULL;
21322 struct in_addr ip4;
21324 if (VAT_JSON_ARRAY != vam->json_tree.type)
21326 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21327 vat_json_init_array (&vam->json_tree);
21329 node = vat_json_array_add (&vam->json_tree);
21331 vat_json_init_object (node);
21332 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21333 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21334 vat_json_object_add_ip4 (node, "src_address", ip4);
21335 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21336 vat_json_object_add_ip4 (node, "dst_address", ip4);
21337 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21338 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21342 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21344 unformat_input_t *i = vam->input;
21345 vl_api_ipsec_gre_tunnel_dump_t *mp;
21346 vl_api_control_ping_t *mp_ping;
21348 u8 sw_if_index_set = 0;
21351 /* Parse args required to build the message */
21352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21354 if (unformat (i, "sw_if_index %d", &sw_if_index))
21355 sw_if_index_set = 1;
21360 if (sw_if_index_set == 0)
21365 if (!vam->json_output)
21367 print (vam->ofp, "%11s%15s%15s%14s%14s",
21368 "sw_if_index", "src_address", "dst_address",
21369 "local_sa_id", "remote_sa_id");
21372 /* Get list of gre-tunnel interfaces */
21373 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21375 mp->sw_if_index = htonl (sw_if_index);
21379 /* Use a control ping for synchronization */
21380 MPING (CONTROL_PING, mp_ping);
21388 api_delete_subif (vat_main_t * vam)
21390 unformat_input_t *i = vam->input;
21391 vl_api_delete_subif_t *mp;
21392 u32 sw_if_index = ~0;
21395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21397 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21399 if (unformat (i, "sw_if_index %d", &sw_if_index))
21405 if (sw_if_index == ~0)
21407 errmsg ("missing sw_if_index");
21411 /* Construct the API message */
21412 M (DELETE_SUBIF, mp);
21413 mp->sw_if_index = ntohl (sw_if_index);
21420 #define foreach_pbb_vtr_op \
21421 _("disable", L2_VTR_DISABLED) \
21422 _("pop", L2_VTR_POP_2) \
21423 _("push", L2_VTR_PUSH_2)
21426 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21428 unformat_input_t *i = vam->input;
21429 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21430 u32 sw_if_index = ~0, vtr_op = ~0;
21431 u16 outer_tag = ~0;
21432 u8 dmac[6], smac[6];
21433 u8 dmac_set = 0, smac_set = 0;
21439 /* Shut up coverity */
21440 clib_memset (dmac, 0, sizeof (dmac));
21441 clib_memset (smac, 0, sizeof (smac));
21443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21445 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21447 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21449 else if (unformat (i, "vtr_op %d", &vtr_op))
21451 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21454 else if (unformat (i, "translate_pbb_stag"))
21456 if (unformat (i, "%d", &tmp))
21458 vtr_op = L2_VTR_TRANSLATE_2_1;
21464 ("translate_pbb_stag operation requires outer tag definition");
21468 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21470 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21472 else if (unformat (i, "sid %d", &sid))
21474 else if (unformat (i, "vlanid %d", &tmp))
21478 clib_warning ("parse error '%U'", format_unformat_error, i);
21483 if ((sw_if_index == ~0) || (vtr_op == ~0))
21485 errmsg ("missing sw_if_index or vtr operation");
21488 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21489 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21492 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21496 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21497 mp->sw_if_index = ntohl (sw_if_index);
21498 mp->vtr_op = ntohl (vtr_op);
21499 mp->outer_tag = ntohs (outer_tag);
21500 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21501 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21502 mp->b_vlanid = ntohs (vlanid);
21503 mp->i_sid = ntohl (sid);
21511 api_flow_classify_set_interface (vat_main_t * vam)
21513 unformat_input_t *i = vam->input;
21514 vl_api_flow_classify_set_interface_t *mp;
21516 int sw_if_index_set;
21517 u32 ip4_table_index = ~0;
21518 u32 ip6_table_index = ~0;
21522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21524 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21525 sw_if_index_set = 1;
21526 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21527 sw_if_index_set = 1;
21528 else if (unformat (i, "del"))
21530 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21532 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21536 clib_warning ("parse error '%U'", format_unformat_error, i);
21541 if (sw_if_index_set == 0)
21543 errmsg ("missing interface name or sw_if_index");
21547 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21549 mp->sw_if_index = ntohl (sw_if_index);
21550 mp->ip4_table_index = ntohl (ip4_table_index);
21551 mp->ip6_table_index = ntohl (ip6_table_index);
21552 mp->is_add = is_add;
21560 api_flow_classify_dump (vat_main_t * vam)
21562 unformat_input_t *i = vam->input;
21563 vl_api_flow_classify_dump_t *mp;
21564 vl_api_control_ping_t *mp_ping;
21565 u8 type = FLOW_CLASSIFY_N_TABLES;
21568 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21572 errmsg ("classify table type must be specified");
21576 if (!vam->json_output)
21578 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21581 M (FLOW_CLASSIFY_DUMP, mp);
21586 /* Use a control ping for synchronization */
21587 MPING (CONTROL_PING, mp_ping);
21590 /* Wait for a reply... */
21596 api_feature_enable_disable (vat_main_t * vam)
21598 unformat_input_t *i = vam->input;
21599 vl_api_feature_enable_disable_t *mp;
21601 u8 *feature_name = 0;
21602 u32 sw_if_index = ~0;
21606 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21608 if (unformat (i, "arc_name %s", &arc_name))
21610 else if (unformat (i, "feature_name %s", &feature_name))
21613 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21615 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21617 else if (unformat (i, "disable"))
21625 errmsg ("missing arc name");
21628 if (vec_len (arc_name) > 63)
21630 errmsg ("arc name too long");
21633 if (feature_name == 0)
21635 errmsg ("missing feature name");
21638 if (vec_len (feature_name) > 63)
21640 errmsg ("feature name too long");
21643 if (sw_if_index == ~0)
21645 errmsg ("missing interface name or sw_if_index");
21649 /* Construct the API message */
21650 M (FEATURE_ENABLE_DISABLE, mp);
21651 mp->sw_if_index = ntohl (sw_if_index);
21652 mp->enable = enable;
21653 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21654 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21655 vec_free (arc_name);
21656 vec_free (feature_name);
21664 api_sw_interface_tag_add_del (vat_main_t * vam)
21666 unformat_input_t *i = vam->input;
21667 vl_api_sw_interface_tag_add_del_t *mp;
21668 u32 sw_if_index = ~0;
21673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21675 if (unformat (i, "tag %s", &tag))
21677 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21679 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21681 else if (unformat (i, "del"))
21687 if (sw_if_index == ~0)
21689 errmsg ("missing interface name or sw_if_index");
21693 if (enable && (tag == 0))
21695 errmsg ("no tag specified");
21699 /* Construct the API message */
21700 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21701 mp->sw_if_index = ntohl (sw_if_index);
21702 mp->is_add = enable;
21704 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21712 static void vl_api_l2_xconnect_details_t_handler
21713 (vl_api_l2_xconnect_details_t * mp)
21715 vat_main_t *vam = &vat_main;
21717 print (vam->ofp, "%15d%15d",
21718 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21721 static void vl_api_l2_xconnect_details_t_handler_json
21722 (vl_api_l2_xconnect_details_t * mp)
21724 vat_main_t *vam = &vat_main;
21725 vat_json_node_t *node = NULL;
21727 if (VAT_JSON_ARRAY != vam->json_tree.type)
21729 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21730 vat_json_init_array (&vam->json_tree);
21732 node = vat_json_array_add (&vam->json_tree);
21734 vat_json_init_object (node);
21735 vat_json_object_add_uint (node, "rx_sw_if_index",
21736 ntohl (mp->rx_sw_if_index));
21737 vat_json_object_add_uint (node, "tx_sw_if_index",
21738 ntohl (mp->tx_sw_if_index));
21742 api_l2_xconnect_dump (vat_main_t * vam)
21744 vl_api_l2_xconnect_dump_t *mp;
21745 vl_api_control_ping_t *mp_ping;
21748 if (!vam->json_output)
21750 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
21753 M (L2_XCONNECT_DUMP, mp);
21757 /* Use a control ping for synchronization */
21758 MPING (CONTROL_PING, mp_ping);
21766 api_hw_interface_set_mtu (vat_main_t * vam)
21768 unformat_input_t *i = vam->input;
21769 vl_api_hw_interface_set_mtu_t *mp;
21770 u32 sw_if_index = ~0;
21774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21776 if (unformat (i, "mtu %d", &mtu))
21778 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21780 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21786 if (sw_if_index == ~0)
21788 errmsg ("missing interface name or sw_if_index");
21794 errmsg ("no mtu specified");
21798 /* Construct the API message */
21799 M (HW_INTERFACE_SET_MTU, mp);
21800 mp->sw_if_index = ntohl (sw_if_index);
21801 mp->mtu = ntohs ((u16) mtu);
21809 api_p2p_ethernet_add (vat_main_t * vam)
21811 unformat_input_t *i = vam->input;
21812 vl_api_p2p_ethernet_add_t *mp;
21813 u32 parent_if_index = ~0;
21819 clib_memset (remote_mac, 0, sizeof (remote_mac));
21820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21822 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21824 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21828 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21830 else if (unformat (i, "sub_id %d", &sub_id))
21834 clib_warning ("parse error '%U'", format_unformat_error, i);
21839 if (parent_if_index == ~0)
21841 errmsg ("missing interface name or sw_if_index");
21846 errmsg ("missing remote mac address");
21851 errmsg ("missing sub-interface id");
21855 M (P2P_ETHERNET_ADD, mp);
21856 mp->parent_if_index = ntohl (parent_if_index);
21857 mp->subif_id = ntohl (sub_id);
21858 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21866 api_p2p_ethernet_del (vat_main_t * vam)
21868 unformat_input_t *i = vam->input;
21869 vl_api_p2p_ethernet_del_t *mp;
21870 u32 parent_if_index = ~0;
21875 clib_memset (remote_mac, 0, sizeof (remote_mac));
21876 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21878 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21880 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21884 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21888 clib_warning ("parse error '%U'", format_unformat_error, i);
21893 if (parent_if_index == ~0)
21895 errmsg ("missing interface name or sw_if_index");
21900 errmsg ("missing remote mac address");
21904 M (P2P_ETHERNET_DEL, mp);
21905 mp->parent_if_index = ntohl (parent_if_index);
21906 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21914 api_lldp_config (vat_main_t * vam)
21916 unformat_input_t *i = vam->input;
21917 vl_api_lldp_config_t *mp;
21919 int tx_interval = 0;
21920 u8 *sys_name = NULL;
21923 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21925 if (unformat (i, "system-name %s", &sys_name))
21927 else if (unformat (i, "tx-hold %d", &tx_hold))
21929 else if (unformat (i, "tx-interval %d", &tx_interval))
21933 clib_warning ("parse error '%U'", format_unformat_error, i);
21938 vec_add1 (sys_name, 0);
21940 M (LLDP_CONFIG, mp);
21941 mp->tx_hold = htonl (tx_hold);
21942 mp->tx_interval = htonl (tx_interval);
21943 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21944 vec_free (sys_name);
21952 api_sw_interface_set_lldp (vat_main_t * vam)
21954 unformat_input_t *i = vam->input;
21955 vl_api_sw_interface_set_lldp_t *mp;
21956 u32 sw_if_index = ~0;
21958 u8 *port_desc = NULL, *mgmt_oid = NULL;
21959 ip4_address_t ip4_addr;
21960 ip6_address_t ip6_addr;
21963 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
21964 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
21966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21968 if (unformat (i, "disable"))
21971 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21973 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21975 else if (unformat (i, "port-desc %s", &port_desc))
21977 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21979 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21981 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
21987 if (sw_if_index == ~0)
21989 errmsg ("missing interface name or sw_if_index");
21993 /* Construct the API message */
21994 vec_add1 (port_desc, 0);
21995 vec_add1 (mgmt_oid, 0);
21996 M (SW_INTERFACE_SET_LLDP, mp);
21997 mp->sw_if_index = ntohl (sw_if_index);
21998 mp->enable = enable;
21999 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22000 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22001 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22002 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22003 vec_free (port_desc);
22004 vec_free (mgmt_oid);
22012 api_tcp_configure_src_addresses (vat_main_t * vam)
22014 vl_api_tcp_configure_src_addresses_t *mp;
22015 unformat_input_t *i = vam->input;
22016 ip4_address_t v4first, v4last;
22017 ip6_address_t v6first, v6last;
22022 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22024 if (unformat (i, "%U - %U",
22025 unformat_ip4_address, &v4first,
22026 unformat_ip4_address, &v4last))
22030 errmsg ("one range per message (range already set)");
22035 else if (unformat (i, "%U - %U",
22036 unformat_ip6_address, &v6first,
22037 unformat_ip6_address, &v6last))
22041 errmsg ("one range per message (range already set)");
22046 else if (unformat (i, "vrf %d", &vrf_id))
22052 if (range_set == 0)
22054 errmsg ("address range not set");
22058 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22059 mp->vrf_id = ntohl (vrf_id);
22061 if (range_set == 2)
22064 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22065 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22070 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22071 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22078 static void vl_api_app_namespace_add_del_reply_t_handler
22079 (vl_api_app_namespace_add_del_reply_t * mp)
22081 vat_main_t *vam = &vat_main;
22082 i32 retval = ntohl (mp->retval);
22083 if (vam->async_mode)
22085 vam->async_errors += (retval < 0);
22089 vam->retval = retval;
22091 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22092 vam->result_ready = 1;
22096 static void vl_api_app_namespace_add_del_reply_t_handler_json
22097 (vl_api_app_namespace_add_del_reply_t * mp)
22099 vat_main_t *vam = &vat_main;
22100 vat_json_node_t node;
22102 vat_json_init_object (&node);
22103 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22104 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22106 vat_json_print (vam->ofp, &node);
22107 vat_json_free (&node);
22109 vam->retval = ntohl (mp->retval);
22110 vam->result_ready = 1;
22114 api_app_namespace_add_del (vat_main_t * vam)
22116 vl_api_app_namespace_add_del_t *mp;
22117 unformat_input_t *i = vam->input;
22118 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22119 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22125 if (unformat (i, "id %_%v%_", &ns_id))
22127 else if (unformat (i, "secret %lu", &secret))
22129 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22130 sw_if_index_set = 1;
22131 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22133 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22138 if (!ns_id || !secret_set || !sw_if_index_set)
22140 errmsg ("namespace id, secret and sw_if_index must be set");
22143 if (vec_len (ns_id) > 64)
22145 errmsg ("namespace id too long");
22148 M (APP_NAMESPACE_ADD_DEL, mp);
22150 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22151 mp->namespace_id_len = vec_len (ns_id);
22152 mp->secret = clib_host_to_net_u64 (secret);
22153 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22154 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22155 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22163 api_sock_init_shm (vat_main_t * vam)
22165 #if VPP_API_TEST_BUILTIN == 0
22166 unformat_input_t *i = vam->input;
22167 vl_api_shm_elem_config_t *config = 0;
22168 u64 size = 64 << 20;
22171 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22173 if (unformat (i, "size %U", unformat_memory_size, &size))
22180 * Canned custom ring allocator config.
22181 * Should probably parse all of this
22183 vec_validate (config, 6);
22184 config[0].type = VL_API_VLIB_RING;
22185 config[0].size = 256;
22186 config[0].count = 32;
22188 config[1].type = VL_API_VLIB_RING;
22189 config[1].size = 1024;
22190 config[1].count = 16;
22192 config[2].type = VL_API_VLIB_RING;
22193 config[2].size = 4096;
22194 config[2].count = 2;
22196 config[3].type = VL_API_CLIENT_RING;
22197 config[3].size = 256;
22198 config[3].count = 32;
22200 config[4].type = VL_API_CLIENT_RING;
22201 config[4].size = 1024;
22202 config[4].count = 16;
22204 config[5].type = VL_API_CLIENT_RING;
22205 config[5].size = 4096;
22206 config[5].count = 2;
22208 config[6].type = VL_API_QUEUE;
22209 config[6].count = 128;
22210 config[6].size = sizeof (uword);
22212 rv = vl_socket_client_init_shm (config);
22214 vam->client_index_invalid = 1;
22222 api_dns_enable_disable (vat_main_t * vam)
22224 unformat_input_t *line_input = vam->input;
22225 vl_api_dns_enable_disable_t *mp;
22226 u8 enable_disable = 1;
22229 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22231 if (unformat (line_input, "disable"))
22232 enable_disable = 0;
22233 if (unformat (line_input, "enable"))
22234 enable_disable = 1;
22239 /* Construct the API message */
22240 M (DNS_ENABLE_DISABLE, mp);
22241 mp->enable = enable_disable;
22245 /* Wait for the reply */
22251 api_dns_resolve_name (vat_main_t * vam)
22253 unformat_input_t *line_input = vam->input;
22254 vl_api_dns_resolve_name_t *mp;
22258 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22260 if (unformat (line_input, "%s", &name))
22266 if (vec_len (name) > 127)
22268 errmsg ("name too long");
22272 /* Construct the API message */
22273 M (DNS_RESOLVE_NAME, mp);
22274 memcpy (mp->name, name, vec_len (name));
22279 /* Wait for the reply */
22285 api_dns_resolve_ip (vat_main_t * vam)
22287 unformat_input_t *line_input = vam->input;
22288 vl_api_dns_resolve_ip_t *mp;
22290 ip4_address_t addr4;
22291 ip6_address_t addr6;
22294 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22296 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22298 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22306 errmsg ("missing address");
22310 /* Construct the API message */
22311 M (DNS_RESOLVE_IP, mp);
22312 mp->is_ip6 = is_ip6;
22314 memcpy (mp->address, &addr6, sizeof (addr6));
22316 memcpy (mp->address, &addr4, sizeof (addr4));
22320 /* Wait for the reply */
22326 api_dns_name_server_add_del (vat_main_t * vam)
22328 unformat_input_t *i = vam->input;
22329 vl_api_dns_name_server_add_del_t *mp;
22331 ip6_address_t ip6_server;
22332 ip4_address_t ip4_server;
22337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22339 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22341 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22343 else if (unformat (i, "del"))
22347 clib_warning ("parse error '%U'", format_unformat_error, i);
22352 if (ip4_set && ip6_set)
22354 errmsg ("Only one server address allowed per message");
22357 if ((ip4_set + ip6_set) == 0)
22359 errmsg ("Server address required");
22363 /* Construct the API message */
22364 M (DNS_NAME_SERVER_ADD_DEL, mp);
22368 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22373 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22377 mp->is_add = is_add;
22382 /* Wait for a reply, return good/bad news */
22388 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22390 vat_main_t *vam = &vat_main;
22395 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22396 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22397 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22398 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22399 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22400 clib_net_to_host_u32 (mp->action_index), mp->tag);
22405 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22406 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22407 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22408 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22409 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22410 clib_net_to_host_u32 (mp->action_index), mp->tag);
22415 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22418 vat_main_t *vam = &vat_main;
22419 vat_json_node_t *node = NULL;
22420 struct in6_addr ip6;
22421 struct in_addr ip4;
22423 if (VAT_JSON_ARRAY != vam->json_tree.type)
22425 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22426 vat_json_init_array (&vam->json_tree);
22428 node = vat_json_array_add (&vam->json_tree);
22429 vat_json_init_object (node);
22431 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22432 vat_json_object_add_uint (node, "appns_index",
22433 clib_net_to_host_u32 (mp->appns_index));
22434 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22435 vat_json_object_add_uint (node, "scope", mp->scope);
22436 vat_json_object_add_uint (node, "action_index",
22437 clib_net_to_host_u32 (mp->action_index));
22438 vat_json_object_add_uint (node, "lcl_port",
22439 clib_net_to_host_u16 (mp->lcl_port));
22440 vat_json_object_add_uint (node, "rmt_port",
22441 clib_net_to_host_u16 (mp->rmt_port));
22442 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22443 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22444 vat_json_object_add_string_copy (node, "tag", mp->tag);
22447 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22448 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22449 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22450 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22454 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22455 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22456 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22457 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22462 api_session_rule_add_del (vat_main_t * vam)
22464 vl_api_session_rule_add_del_t *mp;
22465 unformat_input_t *i = vam->input;
22466 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22467 u32 appns_index = 0, scope = 0;
22468 ip4_address_t lcl_ip4, rmt_ip4;
22469 ip6_address_t lcl_ip6, rmt_ip6;
22470 u8 is_ip4 = 1, conn_set = 0;
22471 u8 is_add = 1, *tag = 0;
22474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22476 if (unformat (i, "del"))
22478 else if (unformat (i, "add"))
22480 else if (unformat (i, "proto tcp"))
22482 else if (unformat (i, "proto udp"))
22484 else if (unformat (i, "appns %d", &appns_index))
22486 else if (unformat (i, "scope %d", &scope))
22488 else if (unformat (i, "tag %_%v%_", &tag))
22492 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22493 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22501 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22502 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22508 else if (unformat (i, "action %d", &action))
22513 if (proto == ~0 || !conn_set || action == ~0)
22515 errmsg ("transport proto, connection and action must be set");
22521 errmsg ("scope should be 0-3");
22525 M (SESSION_RULE_ADD_DEL, mp);
22527 mp->is_ip4 = is_ip4;
22528 mp->transport_proto = proto;
22529 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22530 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22531 mp->lcl_plen = lcl_plen;
22532 mp->rmt_plen = rmt_plen;
22533 mp->action_index = clib_host_to_net_u32 (action);
22534 mp->appns_index = clib_host_to_net_u32 (appns_index);
22536 mp->is_add = is_add;
22539 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22540 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22544 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22545 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22549 clib_memcpy (mp->tag, tag, vec_len (tag));
22559 api_session_rules_dump (vat_main_t * vam)
22561 vl_api_session_rules_dump_t *mp;
22562 vl_api_control_ping_t *mp_ping;
22565 if (!vam->json_output)
22567 print (vam->ofp, "%=20s", "Session Rules");
22570 M (SESSION_RULES_DUMP, mp);
22574 /* Use a control ping for synchronization */
22575 MPING (CONTROL_PING, mp_ping);
22578 /* Wait for a reply... */
22584 api_ip_container_proxy_add_del (vat_main_t * vam)
22586 vl_api_ip_container_proxy_add_del_t *mp;
22587 unformat_input_t *i = vam->input;
22588 u32 plen = ~0, sw_if_index = ~0;
22595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22597 if (unformat (i, "del"))
22599 else if (unformat (i, "add"))
22601 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22606 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22611 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22616 if (sw_if_index == ~0 || plen == ~0)
22618 errmsg ("address and sw_if_index must be set");
22622 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22624 mp->is_ip4 = is_ip4;
22625 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22627 mp->is_add = is_add;
22629 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22631 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22639 api_qos_record_enable_disable (vat_main_t * vam)
22641 unformat_input_t *i = vam->input;
22642 vl_api_qos_record_enable_disable_t *mp;
22643 u32 sw_if_index, qs = 0xff;
22644 u8 sw_if_index_set = 0;
22648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22650 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22651 sw_if_index_set = 1;
22652 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22653 sw_if_index_set = 1;
22654 else if (unformat (i, "%U", unformat_qos_source, &qs))
22656 else if (unformat (i, "disable"))
22660 clib_warning ("parse error '%U'", format_unformat_error, i);
22665 if (sw_if_index_set == 0)
22667 errmsg ("missing interface name or sw_if_index");
22672 errmsg ("input location must be specified");
22676 M (QOS_RECORD_ENABLE_DISABLE, mp);
22678 mp->sw_if_index = ntohl (sw_if_index);
22679 mp->input_source = qs;
22680 mp->enable = enable;
22689 q_or_quit (vat_main_t * vam)
22691 #if VPP_API_TEST_BUILTIN == 0
22692 longjmp (vam->jump_buf, 1);
22694 return 0; /* not so much */
22698 q (vat_main_t * vam)
22700 return q_or_quit (vam);
22704 quit (vat_main_t * vam)
22706 return q_or_quit (vam);
22710 comment (vat_main_t * vam)
22716 statseg (vat_main_t * vam)
22718 ssvm_private_t *ssvmp = &vam->stat_segment;
22719 ssvm_shared_header_t *shared_header = ssvmp->sh;
22720 vlib_counter_t **counters;
22721 u64 thread0_index1_packets;
22722 u64 thread0_index1_bytes;
22723 f64 vector_rate, input_rate;
22726 uword *counter_vector_by_name;
22727 if (vam->stat_segment_lockp == 0)
22729 errmsg ("Stat segment not mapped...");
22733 /* look up "/if/rx for sw_if_index 1 as a test */
22735 clib_spinlock_lock (vam->stat_segment_lockp);
22737 counter_vector_by_name = (uword *) shared_header->opaque[1];
22739 p = hash_get_mem (counter_vector_by_name, "/if/rx");
22742 clib_spinlock_unlock (vam->stat_segment_lockp);
22743 errmsg ("/if/tx not found?");
22747 /* Fish per-thread vector of combined counters from shared memory */
22748 counters = (vlib_counter_t **) p[0];
22750 if (vec_len (counters[0]) < 2)
22752 clib_spinlock_unlock (vam->stat_segment_lockp);
22753 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
22757 /* Read thread 0 sw_if_index 1 counter */
22758 thread0_index1_packets = counters[0][1].packets;
22759 thread0_index1_bytes = counters[0][1].bytes;
22761 p = hash_get_mem (counter_vector_by_name, "vector_rate");
22764 clib_spinlock_unlock (vam->stat_segment_lockp);
22765 errmsg ("vector_rate not found?");
22769 vector_rate = *(f64 *) (p[0]);
22770 p = hash_get_mem (counter_vector_by_name, "input_rate");
22773 clib_spinlock_unlock (vam->stat_segment_lockp);
22774 errmsg ("input_rate not found?");
22777 input_rate = *(f64 *) (p[0]);
22779 clib_spinlock_unlock (vam->stat_segment_lockp);
22781 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
22782 vector_rate, input_rate);
22783 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
22784 thread0_index1_packets, thread0_index1_bytes);
22790 cmd_cmp (void *a1, void *a2)
22795 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22799 help (vat_main_t * vam)
22804 unformat_input_t *i = vam->input;
22807 if (unformat (i, "%s", &name))
22811 vec_add1 (name, 0);
22813 hs = hash_get_mem (vam->help_by_name, name);
22815 print (vam->ofp, "usage: %s %s", name, hs[0]);
22817 print (vam->ofp, "No such msg / command '%s'", name);
22822 print (vam->ofp, "Help is available for the following:");
22825 hash_foreach_pair (p, vam->function_by_name,
22827 vec_add1 (cmds, (u8 *)(p->key));
22831 vec_sort_with_function (cmds, cmd_cmp);
22833 for (j = 0; j < vec_len (cmds); j++)
22834 print (vam->ofp, "%s", cmds[j]);
22841 set (vat_main_t * vam)
22843 u8 *name = 0, *value = 0;
22844 unformat_input_t *i = vam->input;
22846 if (unformat (i, "%s", &name))
22848 /* The input buffer is a vector, not a string. */
22849 value = vec_dup (i->buffer);
22850 vec_delete (value, i->index, 0);
22851 /* Almost certainly has a trailing newline */
22852 if (value[vec_len (value) - 1] == '\n')
22853 value[vec_len (value) - 1] = 0;
22854 /* Make sure it's a proper string, one way or the other */
22855 vec_add1 (value, 0);
22856 (void) clib_macro_set_value (&vam->macro_main,
22857 (char *) name, (char *) value);
22860 errmsg ("usage: set <name> <value>");
22868 unset (vat_main_t * vam)
22872 if (unformat (vam->input, "%s", &name))
22873 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
22874 errmsg ("unset: %s wasn't set", name);
22887 macro_sort_cmp (void *a1, void *a2)
22889 macro_sort_t *s1 = a1;
22890 macro_sort_t *s2 = a2;
22892 return strcmp ((char *) (s1->name), (char *) (s2->name));
22896 dump_macro_table (vat_main_t * vam)
22898 macro_sort_t *sort_me = 0, *sm;
22903 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
22905 vec_add2 (sort_me, sm, 1);
22906 sm->name = (u8 *)(p->key);
22907 sm->value = (u8 *) (p->value[0]);
22911 vec_sort_with_function (sort_me, macro_sort_cmp);
22913 if (vec_len (sort_me))
22914 print (vam->ofp, "%-15s%s", "Name", "Value");
22916 print (vam->ofp, "The macro table is empty...");
22918 for (i = 0; i < vec_len (sort_me); i++)
22919 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
22924 dump_node_table (vat_main_t * vam)
22927 vlib_node_t *node, *next_node;
22929 if (vec_len (vam->graph_nodes) == 0)
22931 print (vam->ofp, "Node table empty, issue get_node_graph...");
22935 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
22937 node = vam->graph_nodes[0][i];
22938 print (vam->ofp, "[%d] %s", i, node->name);
22939 for (j = 0; j < vec_len (node->next_nodes); j++)
22941 if (node->next_nodes[j] != ~0)
22943 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22944 print (vam->ofp, " [%d] %s", j, next_node->name);
22952 value_sort_cmp (void *a1, void *a2)
22954 name_sort_t *n1 = a1;
22955 name_sort_t *n2 = a2;
22957 if (n1->value < n2->value)
22959 if (n1->value > n2->value)
22966 dump_msg_api_table (vat_main_t * vam)
22968 api_main_t *am = &api_main;
22969 name_sort_t *nses = 0, *ns;
22974 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
22976 vec_add2 (nses, ns, 1);
22977 ns->name = (u8 *)(hp->key);
22978 ns->value = (u32) hp->value[0];
22982 vec_sort_with_function (nses, value_sort_cmp);
22984 for (i = 0; i < vec_len (nses); i++)
22985 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
22991 get_msg_id (vat_main_t * vam)
22996 if (unformat (vam->input, "%s", &name_and_crc))
22998 message_index = vl_msg_api_get_msg_index (name_and_crc);
22999 if (message_index == ~0)
23001 print (vam->ofp, " '%s' not found", name_and_crc);
23004 print (vam->ofp, " '%s' has message index %d",
23005 name_and_crc, message_index);
23008 errmsg ("name_and_crc required...");
23013 search_node_table (vat_main_t * vam)
23015 unformat_input_t *line_input = vam->input;
23018 vlib_node_t *node, *next_node;
23021 if (vam->graph_node_index_by_name == 0)
23023 print (vam->ofp, "Node table empty, issue get_node_graph...");
23027 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23029 if (unformat (line_input, "%s", &node_to_find))
23031 vec_add1 (node_to_find, 0);
23032 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23035 print (vam->ofp, "%s not found...", node_to_find);
23038 node = vam->graph_nodes[0][p[0]];
23039 print (vam->ofp, "[%d] %s", p[0], node->name);
23040 for (j = 0; j < vec_len (node->next_nodes); j++)
23042 if (node->next_nodes[j] != ~0)
23044 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23045 print (vam->ofp, " [%d] %s", j, next_node->name);
23052 clib_warning ("parse error '%U'", format_unformat_error,
23058 vec_free (node_to_find);
23067 script (vat_main_t * vam)
23069 #if (VPP_API_TEST_BUILTIN==0)
23071 char *save_current_file;
23072 unformat_input_t save_input;
23073 jmp_buf save_jump_buf;
23074 u32 save_line_number;
23076 FILE *new_fp, *save_ifp;
23078 if (unformat (vam->input, "%s", &s))
23080 new_fp = fopen ((char *) s, "r");
23083 errmsg ("Couldn't open script file %s", s);
23090 errmsg ("Missing script name");
23094 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23095 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23096 save_ifp = vam->ifp;
23097 save_line_number = vam->input_line_number;
23098 save_current_file = (char *) vam->current_file;
23100 vam->input_line_number = 0;
23102 vam->current_file = s;
23105 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23106 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23107 vam->ifp = save_ifp;
23108 vam->input_line_number = save_line_number;
23109 vam->current_file = (u8 *) save_current_file;
23114 clib_warning ("use the exec command...");
23120 echo (vat_main_t * vam)
23122 print (vam->ofp, "%v", vam->input->buffer);
23126 /* List of API message constructors, CLI names map to api_xxx */
23127 #define foreach_vpe_api_msg \
23128 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23129 _(sw_interface_dump,"") \
23130 _(sw_interface_set_flags, \
23131 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23132 _(sw_interface_add_del_address, \
23133 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23134 _(sw_interface_set_rx_mode, \
23135 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23136 _(sw_interface_set_rx_placement, \
23137 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
23138 _(sw_interface_rx_placement_dump, \
23139 "[<intfc> | sw_if_index <id>]") \
23140 _(sw_interface_set_table, \
23141 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23142 _(sw_interface_set_mpls_enable, \
23143 "<intfc> | sw_if_index [disable | dis]") \
23144 _(sw_interface_set_vpath, \
23145 "<intfc> | sw_if_index <id> enable | disable") \
23146 _(sw_interface_set_vxlan_bypass, \
23147 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23148 _(sw_interface_set_geneve_bypass, \
23149 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23150 _(sw_interface_set_l2_xconnect, \
23151 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23152 "enable | disable") \
23153 _(sw_interface_set_l2_bridge, \
23154 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23155 "[shg <split-horizon-group>] [bvi]\n" \
23156 "enable | disable") \
23157 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23158 _(bridge_domain_add_del, \
23159 "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") \
23160 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23162 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23163 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23164 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23166 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23168 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23170 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23172 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23174 "<vpp-if-name> | sw_if_index <id>") \
23175 _(sw_interface_tap_dump, "") \
23177 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23179 "<vpp-if-name> | sw_if_index <id>") \
23180 _(sw_interface_tap_v2_dump, "") \
23182 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23183 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
23186 "<vpp-if-name> | sw_if_index <id>") \
23188 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23189 _(bond_detach_slave, \
23190 "sw_if_index <n>") \
23191 _(sw_interface_bond_dump, "") \
23192 _(sw_interface_slave_dump, \
23193 "<vpp-if-name> | sw_if_index <id>") \
23194 _(ip_table_add_del, \
23195 "table <n> [ipv6] [add | del]\n") \
23196 _(ip_add_del_route, \
23197 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
23198 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
23199 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
23200 "[multipath] [count <n>] [del]") \
23201 _(ip_mroute_add_del, \
23202 "<src> <grp>/<mask> [table-id <n>]\n" \
23203 "[<intfc> | sw_if_index <id>] [local] [del]") \
23204 _(mpls_table_add_del, \
23205 "table <n> [add | del]\n") \
23206 _(mpls_route_add_del, \
23207 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
23208 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
23209 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
23210 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
23211 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
23212 "[count <n>] [del]") \
23213 _(mpls_ip_bind_unbind, \
23214 "<label> <addr/len>") \
23215 _(mpls_tunnel_add_del, \
23216 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
23217 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
23218 "[l2-only] [out-label <n>]") \
23219 _(sr_mpls_policy_add, \
23220 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
23221 _(sr_mpls_policy_del, \
23223 _(bier_table_add_del, \
23224 "<label> <sub-domain> <set> <bsl> [del]") \
23225 _(bier_route_add_del, \
23226 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23227 "[<intfc> | sw_if_index <id>]" \
23228 "[weight <n>] [del] [multipath]") \
23229 _(proxy_arp_add_del, \
23230 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23231 _(proxy_arp_intfc_enable_disable, \
23232 "<intfc> | sw_if_index <id> enable | disable") \
23233 _(sw_interface_set_unnumbered, \
23234 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23235 _(ip_neighbor_add_del, \
23236 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23237 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23238 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23239 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23240 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23241 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23242 "[outer_vlan_id_any][inner_vlan_id_any]") \
23243 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23244 _(reset_fib, "vrf <n> [ipv6]") \
23245 _(dhcp_proxy_config, \
23246 "svr <v46-address> src <v46-address>\n" \
23247 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23248 _(dhcp_proxy_set_vss, \
23249 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23250 _(dhcp_proxy_dump, "ip6") \
23251 _(dhcp_client_config, \
23252 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23253 _(set_ip_flow_hash, \
23254 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23255 _(sw_interface_ip6_enable_disable, \
23256 "<intfc> | sw_if_index <id> enable | disable") \
23257 _(ip6nd_proxy_add_del, \
23258 "<intfc> | sw_if_index <id> <ip6-address>") \
23259 _(ip6nd_proxy_dump, "") \
23260 _(sw_interface_ip6nd_ra_prefix, \
23261 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23262 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23263 "[nolink] [isno]") \
23264 _(sw_interface_ip6nd_ra_config, \
23265 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23266 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23267 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23268 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23269 _(l2_patch_add_del, \
23270 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23271 "enable | disable") \
23272 _(sr_localsid_add_del, \
23273 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23274 "fib-table <num> (end.psp) sw_if_index <num>") \
23275 _(classify_add_del_table, \
23276 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23277 " [del] [del-chain] mask <mask-value>\n" \
23278 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23279 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23280 _(classify_add_del_session, \
23281 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23282 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23283 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23284 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23285 _(classify_set_interface_ip_table, \
23286 "<intfc> | sw_if_index <nn> table <nn>") \
23287 _(classify_set_interface_l2_tables, \
23288 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23289 " [other-table <nn>]") \
23290 _(get_node_index, "node <node-name") \
23291 _(add_node_next, "node <node-name> next <next-node-name>") \
23292 _(l2tpv3_create_tunnel, \
23293 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23294 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23295 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23296 _(l2tpv3_set_tunnel_cookies, \
23297 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23298 "[new_remote_cookie <nn>]\n") \
23299 _(l2tpv3_interface_enable_disable, \
23300 "<intfc> | sw_if_index <nn> enable | disable") \
23301 _(l2tpv3_set_lookup_key, \
23302 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23303 _(sw_if_l2tpv3_tunnel_dump, "") \
23304 _(vxlan_offload_rx, \
23305 "hw { <interface name> | hw_if_index <nn>} " \
23306 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23307 _(vxlan_add_del_tunnel, \
23308 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23309 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23310 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23311 _(geneve_add_del_tunnel, \
23312 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23313 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23314 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23315 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23316 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23317 _(gre_add_del_tunnel, \
23318 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23319 "[teb | erspan <session-id>] [del]") \
23320 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23321 _(l2_fib_clear_table, "") \
23322 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23323 _(l2_interface_vlan_tag_rewrite, \
23324 "<intfc> | sw_if_index <nn> \n" \
23325 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23326 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23327 _(create_vhost_user_if, \
23328 "socket <filename> [server] [renumber <dev_instance>] " \
23329 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
23330 "[mac <mac_address>]") \
23331 _(modify_vhost_user_if, \
23332 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23333 "[server] [renumber <dev_instance>]") \
23334 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23335 _(sw_interface_vhost_user_dump, "") \
23336 _(show_version, "") \
23337 _(show_threads, "") \
23338 _(vxlan_gpe_add_del_tunnel, \
23339 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23340 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23341 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23342 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23343 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23344 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23345 _(interface_name_renumber, \
23346 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23347 _(input_acl_set_interface, \
23348 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23349 " [l2-table <nn>] [del]") \
23350 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23351 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23352 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23353 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23354 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23355 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23356 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23357 _(ip_dump, "ipv4 | ipv6") \
23358 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23359 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23361 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23362 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23363 " integ_alg <alg> integ_key <hex>") \
23364 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23365 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23366 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23367 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23368 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23369 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23370 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23371 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23372 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23373 " [instance <n>]") \
23374 _(ipsec_sa_dump, "[sa_id <n>]") \
23375 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23376 " <alg> <hex>\n") \
23377 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23378 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23379 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23380 "(auth_data 0x<data> | auth_data <data>)") \
23381 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23382 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23383 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23384 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23385 "(local|remote)") \
23386 _(ikev2_set_local_key, "file <absolute_file_path>") \
23387 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23388 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23389 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23390 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23391 _(ikev2_initiate_sa_init, "<profile_name>") \
23392 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23393 _(ikev2_initiate_del_child_sa, "<ispi>") \
23394 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23395 _(delete_loopback,"sw_if_index <nn>") \
23396 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23397 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
23398 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
23399 _(want_interface_events, "enable|disable") \
23400 _(get_first_msg_id, "client <name>") \
23401 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23402 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23403 "fib-id <nn> [ip4][ip6][default]") \
23404 _(get_node_graph, " ") \
23405 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23406 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23407 _(ioam_disable, "") \
23408 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23409 " sw_if_index <sw_if_index> p <priority> " \
23410 "w <weight>] [del]") \
23411 _(one_add_del_locator, "locator-set <locator_name> " \
23412 "iface <intf> | sw_if_index <sw_if_index> " \
23413 "p <priority> w <weight> [del]") \
23414 _(one_add_del_local_eid,"vni <vni> eid " \
23415 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23416 "locator-set <locator_name> [del]" \
23417 "[key-id sha1|sha256 secret-key <secret-key>]")\
23418 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23419 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23420 _(one_enable_disable, "enable|disable") \
23421 _(one_map_register_enable_disable, "enable|disable") \
23422 _(one_map_register_fallback_threshold, "<value>") \
23423 _(one_rloc_probe_enable_disable, "enable|disable") \
23424 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23426 "rloc <locator> p <prio> " \
23427 "w <weight> [rloc <loc> ... ] " \
23428 "action <action> [del-all]") \
23429 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23431 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23432 _(one_use_petr, "ip-address> | disable") \
23433 _(one_map_request_mode, "src-dst|dst-only") \
23434 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23435 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23436 _(one_locator_set_dump, "[local | remote]") \
23437 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23438 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23439 "[local] | [remote]") \
23440 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23441 _(one_ndp_bd_get, "") \
23442 _(one_ndp_entries_get, "bd <bridge-domain>") \
23443 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23444 _(one_l2_arp_bd_get, "") \
23445 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23446 _(one_stats_enable_disable, "enable|disable") \
23447 _(show_one_stats_enable_disable, "") \
23448 _(one_eid_table_vni_dump, "") \
23449 _(one_eid_table_map_dump, "l2|l3") \
23450 _(one_map_resolver_dump, "") \
23451 _(one_map_server_dump, "") \
23452 _(one_adjacencies_get, "vni <vni>") \
23453 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23454 _(show_one_rloc_probe_state, "") \
23455 _(show_one_map_register_state, "") \
23456 _(show_one_status, "") \
23457 _(one_stats_dump, "") \
23458 _(one_stats_flush, "") \
23459 _(one_get_map_request_itr_rlocs, "") \
23460 _(one_map_register_set_ttl, "<ttl>") \
23461 _(one_set_transport_protocol, "udp|api") \
23462 _(one_get_transport_protocol, "") \
23463 _(one_enable_disable_xtr_mode, "enable|disable") \
23464 _(one_show_xtr_mode, "") \
23465 _(one_enable_disable_pitr_mode, "enable|disable") \
23466 _(one_show_pitr_mode, "") \
23467 _(one_enable_disable_petr_mode, "enable|disable") \
23468 _(one_show_petr_mode, "") \
23469 _(show_one_nsh_mapping, "") \
23470 _(show_one_pitr, "") \
23471 _(show_one_use_petr, "") \
23472 _(show_one_map_request_mode, "") \
23473 _(show_one_map_register_ttl, "") \
23474 _(show_one_map_register_fallback_threshold, "") \
23475 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23476 " sw_if_index <sw_if_index> p <priority> " \
23477 "w <weight>] [del]") \
23478 _(lisp_add_del_locator, "locator-set <locator_name> " \
23479 "iface <intf> | sw_if_index <sw_if_index> " \
23480 "p <priority> w <weight> [del]") \
23481 _(lisp_add_del_local_eid,"vni <vni> eid " \
23482 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23483 "locator-set <locator_name> [del]" \
23484 "[key-id sha1|sha256 secret-key <secret-key>]") \
23485 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23486 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23487 _(lisp_enable_disable, "enable|disable") \
23488 _(lisp_map_register_enable_disable, "enable|disable") \
23489 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23490 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23492 "rloc <locator> p <prio> " \
23493 "w <weight> [rloc <loc> ... ] " \
23494 "action <action> [del-all]") \
23495 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23497 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23498 _(lisp_use_petr, "<ip-address> | disable") \
23499 _(lisp_map_request_mode, "src-dst|dst-only") \
23500 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23501 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23502 _(lisp_locator_set_dump, "[local | remote]") \
23503 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23504 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23505 "[local] | [remote]") \
23506 _(lisp_eid_table_vni_dump, "") \
23507 _(lisp_eid_table_map_dump, "l2|l3") \
23508 _(lisp_map_resolver_dump, "") \
23509 _(lisp_map_server_dump, "") \
23510 _(lisp_adjacencies_get, "vni <vni>") \
23511 _(gpe_fwd_entry_vnis_get, "") \
23512 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23513 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23514 "[table <table-id>]") \
23515 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23516 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23517 _(gpe_set_encap_mode, "lisp|vxlan") \
23518 _(gpe_get_encap_mode, "") \
23519 _(lisp_gpe_add_del_iface, "up|down") \
23520 _(lisp_gpe_enable_disable, "enable|disable") \
23521 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23522 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23523 _(show_lisp_rloc_probe_state, "") \
23524 _(show_lisp_map_register_state, "") \
23525 _(show_lisp_status, "") \
23526 _(lisp_get_map_request_itr_rlocs, "") \
23527 _(show_lisp_pitr, "") \
23528 _(show_lisp_use_petr, "") \
23529 _(show_lisp_map_request_mode, "") \
23530 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23531 _(af_packet_delete, "name <host interface name>") \
23532 _(af_packet_dump, "") \
23533 _(policer_add_del, "name <policer name> <params> [del]") \
23534 _(policer_dump, "[name <policer name>]") \
23535 _(policer_classify_set_interface, \
23536 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23537 " [l2-table <nn>] [del]") \
23538 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23539 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23540 "[master|slave]") \
23541 _(netmap_delete, "name <interface name>") \
23542 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23543 _(mpls_fib_dump, "") \
23544 _(classify_table_ids, "") \
23545 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23546 _(classify_table_info, "table_id <nn>") \
23547 _(classify_session_dump, "table_id <nn>") \
23548 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23549 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23550 "[template_interval <nn>] [udp_checksum]") \
23551 _(ipfix_exporter_dump, "") \
23552 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23553 _(ipfix_classify_stream_dump, "") \
23554 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23555 _(ipfix_classify_table_dump, "") \
23556 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23557 _(sw_interface_span_dump, "[l2]") \
23558 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23559 _(pg_create_interface, "if_id <nn>") \
23560 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23561 _(pg_enable_disable, "[stream <id>] disable") \
23562 _(ip_source_and_port_range_check_add_del, \
23563 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23564 _(ip_source_and_port_range_check_interface_add_del, \
23565 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23566 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23567 _(ipsec_gre_add_del_tunnel, \
23568 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23569 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23570 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23571 _(l2_interface_pbb_tag_rewrite, \
23572 "<intfc> | sw_if_index <nn> \n" \
23573 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23574 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23575 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23576 _(flow_classify_set_interface, \
23577 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23578 _(flow_classify_dump, "type [ip4|ip6]") \
23579 _(ip_fib_dump, "") \
23580 _(ip_mfib_dump, "") \
23581 _(ip6_fib_dump, "") \
23582 _(ip6_mfib_dump, "") \
23583 _(feature_enable_disable, "arc_name <arc_name> " \
23584 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23585 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23587 _(l2_xconnect_dump, "") \
23588 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
23589 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23590 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23591 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23592 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23593 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23594 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23595 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23596 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23597 _(sock_init_shm, "size <nnn>") \
23598 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23599 _(dns_enable_disable, "[enable][disable]") \
23600 _(dns_name_server_add_del, "<ip-address> [del]") \
23601 _(dns_resolve_name, "<hostname>") \
23602 _(dns_resolve_ip, "<ip4|ip6>") \
23603 _(dns_name_server_add_del, "<ip-address> [del]") \
23604 _(dns_resolve_name, "<hostname>") \
23605 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23606 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23607 _(session_rules_dump, "") \
23608 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23609 _(output_acl_set_interface, \
23610 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23611 " [l2-table <nn>] [del]") \
23612 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
23614 /* List of command functions, CLI names map directly to functions */
23615 #define foreach_cli_function \
23616 _(comment, "usage: comment <ignore-rest-of-line>") \
23617 _(dump_interface_table, "usage: dump_interface_table") \
23618 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23619 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23620 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23621 _(dump_macro_table, "usage: dump_macro_table ") \
23622 _(dump_node_table, "usage: dump_node_table") \
23623 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23624 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23625 _(echo, "usage: echo <message>") \
23626 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23627 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23628 _(help, "usage: help") \
23629 _(q, "usage: quit") \
23630 _(quit, "usage: quit") \
23631 _(search_node_table, "usage: search_node_table <name>...") \
23632 _(set, "usage: set <variable-name> <value>") \
23633 _(script, "usage: script <file-name>") \
23634 _(statseg, "usage: statseg"); \
23635 _(unset, "usage: unset <variable-name>")
23638 static void vl_api_##n##_t_handler_uni \
23639 (vl_api_##n##_t * mp) \
23641 vat_main_t * vam = &vat_main; \
23642 if (vam->json_output) { \
23643 vl_api_##n##_t_handler_json(mp); \
23645 vl_api_##n##_t_handler(mp); \
23648 foreach_vpe_api_reply_msg;
23649 #if VPP_API_TEST_BUILTIN == 0
23650 foreach_standalone_reply_msg;
23655 vat_api_hookup (vat_main_t * vam)
23658 vl_msg_api_set_handlers(VL_API_##N, #n, \
23659 vl_api_##n##_t_handler_uni, \
23661 vl_api_##n##_t_endian, \
23662 vl_api_##n##_t_print, \
23663 sizeof(vl_api_##n##_t), 1);
23664 foreach_vpe_api_reply_msg;
23665 #if VPP_API_TEST_BUILTIN == 0
23666 foreach_standalone_reply_msg;
23670 #if (VPP_API_TEST_BUILTIN==0)
23671 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23673 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23675 vam->function_by_name = hash_create_string (0, sizeof (uword));
23677 vam->help_by_name = hash_create_string (0, sizeof (uword));
23680 /* API messages we can send */
23681 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23682 foreach_vpe_api_msg;
23686 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23687 foreach_vpe_api_msg;
23690 /* CLI functions */
23691 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23692 foreach_cli_function;
23696 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23697 foreach_cli_function;
23701 #if VPP_API_TEST_BUILTIN
23702 static clib_error_t *
23703 vat_api_hookup_shim (vlib_main_t * vm)
23705 vat_api_hookup (&vat_main);
23709 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
23713 * fd.io coding-style-patch-verification: ON
23716 * eval: (c-set-style "gnu")