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 <vlib/pci/pci.h>
22 #include <vpp/api/types.h>
23 #include <vppinfra/socket.h>
24 #include <vlibapi/api.h>
25 #include <vlibmemory/api.h>
26 #include <vnet/ip/ip.h>
27 #include <vnet/ip-neighbor/ip_neighbor.h>
28 #include <vnet/ip/ip_types_api.h>
29 #include <vnet/l2/l2_input.h>
30 #include <vnet/l2tp/l2tp.h>
31 #include <vnet/vxlan/vxlan.h>
32 #include <vnet/geneve/geneve.h>
33 #include <vnet/gre/gre.h>
34 #include <vnet/vxlan-gpe/vxlan_gpe.h>
35 #include <vnet/lisp-gpe/lisp_gpe.h>
37 #include <vpp/api/vpe_msg_enum.h>
38 #include <vnet/l2/l2_classify.h>
39 #include <vnet/l2/l2_vtr.h>
40 #include <vnet/classify/in_out_acl.h>
41 #include <vnet/classify/policer_classify.h>
42 #include <vnet/classify/flow_classify.h>
43 #include <vnet/mpls/mpls.h>
44 #include <vnet/ipsec/ipsec.h>
46 #include <vnet/cop/cop.h>
47 #include <vnet/ip/ip6_hop_by_hop.h>
48 #include <vnet/ip/ip_source_and_port_range_check.h>
49 #include <vnet/policer/xlate.h>
50 #include <vnet/span/span.h>
51 #include <vnet/policer/policer.h>
52 #include <vnet/policer/police.h>
53 #include <vnet/mfib/mfib_types.h>
54 #include <vnet/bonding/node.h>
55 #include <vnet/qos/qos_types.h>
56 #include <vnet/ethernet/ethernet_types_api.h>
57 #include <vnet/ip/ip_types_api.h>
58 #include "vat/json_format.h"
59 #include <vnet/ip/ip_types_api.h>
60 #include <vnet/ethernet/ethernet_types_api.h>
65 #define vl_typedefs /* define message structures */
66 #include <vpp/api/vpe_all_api_h.h>
69 /* declare message handlers for each api */
71 #define vl_endianfun /* define message structures */
72 #include <vpp/api/vpe_all_api_h.h>
75 /* instantiate all the print functions we know about */
76 #if VPP_API_TEST_BUILTIN == 0
77 #define vl_print(handle, ...)
79 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
82 #include <vpp/api/vpe_all_api_h.h>
85 #define __plugin_msg_base 0
86 #include <vlibapi/vat_helper_macros.h>
88 #include <vnet/format_fns.h>
90 void vl_api_set_elog_main (elog_main_t * m);
91 int vl_api_set_elog_trace_api_messages (int enable);
93 #if VPP_API_TEST_BUILTIN == 0
103 vat_socket_connect (vat_main_t * vam)
106 vam->socket_client_main = &socket_client_main;
107 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
109 0 /* default socket rx, tx buffer */ )))
111 /* vpp expects the client index in network order */
112 vam->my_client_index = htonl (socket_client_main.client_index);
115 #else /* vpp built-in case, we don't do sockets... */
117 vat_socket_connect (vat_main_t * vam)
123 vl_socket_client_read (int wait)
129 vl_socket_client_write ()
135 vl_socket_client_msg_alloc (int nbytes)
143 vat_time_now (vat_main_t * vam)
145 #if VPP_API_TEST_BUILTIN
146 return vlib_time_now (vam->vlib_main);
148 return clib_time_now (&vam->clib_time);
153 errmsg (char *fmt, ...)
155 vat_main_t *vam = &vat_main;
160 s = va_format (0, fmt, &va);
165 #if VPP_API_TEST_BUILTIN
166 vlib_cli_output (vam->vlib_main, (char *) s);
169 if (vam->ifp != stdin)
170 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
171 vam->input_line_number);
173 fformat (vam->ofp, "%s\n", (char *) s);
181 #if VPP_API_TEST_BUILTIN == 0
183 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
185 vat_main_t *vam = va_arg (*args, vat_main_t *);
186 u32 *result = va_arg (*args, u32 *);
190 if (!unformat (input, "%s", &if_name))
193 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
201 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
206 /* Parse an IP4 address %d.%d.%d.%d. */
208 unformat_ip4_address (unformat_input_t * input, va_list * args)
210 u8 *result = va_arg (*args, u8 *);
213 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
216 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
228 unformat_ethernet_address (unformat_input_t * input, va_list * args)
230 u8 *result = va_arg (*args, u8 *);
233 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
234 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
238 for (i = 0; i < 6; i++)
239 if (a[i] >= (1 << 8))
242 for (i = 0; i < 6; i++)
248 /* Returns ethernet type as an int in host byte order. */
250 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
253 u16 *result = va_arg (*args, u16 *);
257 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
259 if (type >= (1 << 16))
267 /* Parse an IP46 address. */
269 unformat_ip46_address (unformat_input_t * input, va_list * args)
271 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
272 ip46_type_t type = va_arg (*args, ip46_type_t);
273 if ((type != IP46_TYPE_IP6) &&
274 unformat (input, "%U", unformat_ip4_address, &ip46->ip4))
276 ip46_address_mask_ip4 (ip46);
279 else if ((type != IP46_TYPE_IP4) &&
280 unformat (input, "%U", unformat_ip6_address, &ip46->ip6))
287 /* Parse an IP6 address. */
289 unformat_ip6_address (unformat_input_t * input, va_list * args)
291 ip6_address_t *result = va_arg (*args, ip6_address_t *);
293 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
294 uword c, n_colon, double_colon_index;
296 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
297 double_colon_index = ARRAY_LEN (hex_quads);
298 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
301 if (c >= '0' && c <= '9')
303 else if (c >= 'a' && c <= 'f')
304 hex_digit = c + 10 - 'a';
305 else if (c >= 'A' && c <= 'F')
306 hex_digit = c + 10 - 'A';
307 else if (c == ':' && n_colon < 2)
311 unformat_put_input (input);
315 /* Too many hex quads. */
316 if (n_hex_quads >= ARRAY_LEN (hex_quads))
321 hex_quad = (hex_quad << 4) | hex_digit;
323 /* Hex quad must fit in 16 bits. */
324 if (n_hex_digits >= 4)
331 /* Save position of :: */
334 /* More than one :: ? */
335 if (double_colon_index < ARRAY_LEN (hex_quads))
337 double_colon_index = n_hex_quads;
340 if (n_colon > 0 && n_hex_digits > 0)
342 hex_quads[n_hex_quads++] = hex_quad;
348 if (n_hex_digits > 0)
349 hex_quads[n_hex_quads++] = hex_quad;
354 /* Expand :: to appropriate number of zero hex quads. */
355 if (double_colon_index < ARRAY_LEN (hex_quads))
357 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
359 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
360 hex_quads[n_zero + i] = hex_quads[i];
362 for (i = 0; i < n_zero; i++)
363 hex_quads[double_colon_index + i] = 0;
365 n_hex_quads = ARRAY_LEN (hex_quads);
368 /* Too few hex quads given. */
369 if (n_hex_quads < ARRAY_LEN (hex_quads))
372 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
373 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
380 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
382 u32 *r = va_arg (*args, u32 *);
385 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
386 foreach_ipsec_policy_action
394 format_ipsec_crypto_alg (u8 * s, va_list * args)
396 u32 i = va_arg (*args, u32);
401 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
402 foreach_ipsec_crypto_alg
405 return format (s, "unknown");
407 return format (s, "%s", t);
411 format_ipsec_integ_alg (u8 * s, va_list * args)
413 u32 i = va_arg (*args, u32);
418 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
419 foreach_ipsec_integ_alg
422 return format (s, "unknown");
424 return format (s, "%s", t);
427 #else /* VPP_API_TEST_BUILTIN == 1 */
429 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
431 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
432 vnet_main_t *vnm = vnet_get_main ();
433 u32 *result = va_arg (*args, u32 *);
435 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
439 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
441 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
442 vnet_main_t *vnm = vnet_get_main ();
443 u32 *result = va_arg (*args, u32 *);
445 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
448 #endif /* VPP_API_TEST_BUILTIN */
451 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
453 u32 *r = va_arg (*args, u32 *);
456 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
457 foreach_ipsec_crypto_alg
465 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
467 u32 *r = va_arg (*args, u32 *);
470 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
471 foreach_ipsec_integ_alg
479 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
481 u8 *r = va_arg (*args, u8 *);
483 if (unformat (input, "kbps"))
484 *r = SSE2_QOS_RATE_KBPS;
485 else if (unformat (input, "pps"))
486 *r = SSE2_QOS_RATE_PPS;
493 unformat_policer_round_type (unformat_input_t * input, va_list * args)
495 u8 *r = va_arg (*args, u8 *);
497 if (unformat (input, "closest"))
498 *r = SSE2_QOS_ROUND_TO_CLOSEST;
499 else if (unformat (input, "up"))
500 *r = SSE2_QOS_ROUND_TO_UP;
501 else if (unformat (input, "down"))
502 *r = SSE2_QOS_ROUND_TO_DOWN;
509 unformat_policer_type (unformat_input_t * input, va_list * args)
511 u8 *r = va_arg (*args, u8 *);
513 if (unformat (input, "1r2c"))
514 *r = SSE2_QOS_POLICER_TYPE_1R2C;
515 else if (unformat (input, "1r3c"))
516 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
517 else if (unformat (input, "2r3c-2698"))
518 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
519 else if (unformat (input, "2r3c-4115"))
520 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
521 else if (unformat (input, "2r3c-mef5cf1"))
522 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
529 unformat_dscp (unformat_input_t * input, va_list * va)
531 u8 *r = va_arg (*va, u8 *);
534 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
543 unformat_policer_action_type (unformat_input_t * input, va_list * va)
545 sse2_qos_pol_action_params_st *a
546 = va_arg (*va, sse2_qos_pol_action_params_st *);
548 if (unformat (input, "drop"))
549 a->action_type = SSE2_QOS_ACTION_DROP;
550 else if (unformat (input, "transmit"))
551 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
552 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
553 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
560 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
562 u32 *r = va_arg (*va, u32 *);
565 if (unformat (input, "ip4"))
566 tid = POLICER_CLASSIFY_TABLE_IP4;
567 else if (unformat (input, "ip6"))
568 tid = POLICER_CLASSIFY_TABLE_IP6;
569 else if (unformat (input, "l2"))
570 tid = POLICER_CLASSIFY_TABLE_L2;
579 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
581 u32 *r = va_arg (*va, u32 *);
584 if (unformat (input, "ip4"))
585 tid = FLOW_CLASSIFY_TABLE_IP4;
586 else if (unformat (input, "ip6"))
587 tid = FLOW_CLASSIFY_TABLE_IP6;
595 #if (VPP_API_TEST_BUILTIN==0)
597 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
598 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
599 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
600 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
603 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
605 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
606 mfib_itf_attribute_t attr;
609 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
611 if (unformat (input, mfib_itf_flag_long_names[attr]))
612 *iflags |= (1 << attr);
614 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
616 if (unformat (input, mfib_itf_flag_names[attr]))
617 *iflags |= (1 << attr);
620 return (old == *iflags ? 0 : 1);
624 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
626 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
627 mfib_entry_attribute_t attr;
630 FOR_EACH_MFIB_ATTRIBUTE (attr)
632 if (unformat (input, mfib_flag_long_names[attr]))
633 *eflags |= (1 << attr);
635 FOR_EACH_MFIB_ATTRIBUTE (attr)
637 if (unformat (input, mfib_flag_names[attr]))
638 *eflags |= (1 << attr);
641 return (old == *eflags ? 0 : 1);
645 format_ip4_address (u8 * s, va_list * args)
647 u8 *a = va_arg (*args, u8 *);
648 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
652 format_ip6_address (u8 * s, va_list * args)
654 ip6_address_t *a = va_arg (*args, ip6_address_t *);
655 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
657 i_max_n_zero = ARRAY_LEN (a->as_u16);
659 i_first_zero = i_max_n_zero;
661 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
663 u32 is_zero = a->as_u16[i] == 0;
664 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
670 if ((!is_zero && n_zeros > max_n_zeros)
671 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
673 i_max_n_zero = i_first_zero;
674 max_n_zeros = n_zeros;
675 i_first_zero = ARRAY_LEN (a->as_u16);
680 last_double_colon = 0;
681 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
683 if (i == i_max_n_zero && max_n_zeros > 1)
685 s = format (s, "::");
686 i += max_n_zeros - 1;
687 last_double_colon = 1;
691 s = format (s, "%s%x",
692 (last_double_colon || i == 0) ? "" : ":",
693 clib_net_to_host_u16 (a->as_u16[i]));
694 last_double_colon = 0;
701 /* Format an IP46 address. */
703 format_ip46_address (u8 * s, va_list * args)
705 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
706 ip46_type_t type = va_arg (*args, ip46_type_t);
712 is_ip4 = ip46_address_is_ip4 (ip46);
723 format (s, "%U", format_ip4_address, &ip46->ip4) :
724 format (s, "%U", format_ip6_address, &ip46->ip6);
728 format_ethernet_address (u8 * s, va_list * args)
730 u8 *a = va_arg (*args, u8 *);
732 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
733 a[0], a[1], a[2], a[3], a[4], a[5]);
738 increment_v4_address (vl_api_ip4_address_t * i)
740 ip4_address_t *a = (ip4_address_t *) i;
743 v = ntohl (a->as_u32) + 1;
744 a->as_u32 = ntohl (v);
748 increment_v6_address (vl_api_ip6_address_t * i)
750 ip6_address_t *a = (ip6_address_t *) i;
753 v0 = clib_net_to_host_u64 (a->as_u64[0]);
754 v1 = clib_net_to_host_u64 (a->as_u64[1]);
759 a->as_u64[0] = clib_net_to_host_u64 (v0);
760 a->as_u64[1] = clib_net_to_host_u64 (v1);
764 increment_address (vl_api_address_t * a)
766 if (clib_net_to_host_u32 (a->af) == ADDRESS_IP4)
767 increment_v4_address (&a->un.ip4);
768 else if (clib_net_to_host_u32 (a->af) == ADDRESS_IP6)
769 increment_v6_address (&a->un.ip6);
773 set_ip4_address (vl_api_address_t * a, u32 v)
775 if (a->af == ADDRESS_IP4)
777 ip4_address_t *i = (ip4_address_t *) & a->un.ip4;
783 ip_set (ip46_address_t * dst, void *src, u8 is_ip4)
786 dst->ip4.as_u32 = ((ip4_address_t *) src)->as_u32;
788 clib_memcpy_fast (&dst->ip6, (ip6_address_t *) src,
789 sizeof (ip6_address_t));
793 increment_mac_address (u8 * mac)
795 u64 tmp = *((u64 *) mac);
796 tmp = clib_net_to_host_u64 (tmp);
797 tmp += 1 << 16; /* skip unused (least significant) octets */
798 tmp = clib_host_to_net_u64 (tmp);
800 clib_memcpy (mac, &tmp, 6);
804 vat_json_object_add_address (vat_json_node_t * node,
805 const char *str, const vl_api_address_t * addr)
807 if (ADDRESS_IP6 == addr->af)
811 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
812 vat_json_object_add_ip6 (node, str, ip6);
818 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
819 vat_json_object_add_ip4 (node, str, ip4);
824 vat_json_object_add_prefix (vat_json_node_t * node,
825 const vl_api_prefix_t * prefix)
827 vat_json_object_add_uint (node, "len", prefix->len);
828 vat_json_object_add_address (node, "address", &prefix->address);
831 static void vl_api_create_loopback_reply_t_handler
832 (vl_api_create_loopback_reply_t * mp)
834 vat_main_t *vam = &vat_main;
835 i32 retval = ntohl (mp->retval);
837 vam->retval = retval;
838 vam->regenerate_interface_table = 1;
839 vam->sw_if_index = ntohl (mp->sw_if_index);
840 vam->result_ready = 1;
843 static void vl_api_create_loopback_reply_t_handler_json
844 (vl_api_create_loopback_reply_t * mp)
846 vat_main_t *vam = &vat_main;
847 vat_json_node_t node;
849 vat_json_init_object (&node);
850 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
851 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
853 vat_json_print (vam->ofp, &node);
854 vat_json_free (&node);
855 vam->retval = ntohl (mp->retval);
856 vam->result_ready = 1;
859 static void vl_api_create_loopback_instance_reply_t_handler
860 (vl_api_create_loopback_instance_reply_t * mp)
862 vat_main_t *vam = &vat_main;
863 i32 retval = ntohl (mp->retval);
865 vam->retval = retval;
866 vam->regenerate_interface_table = 1;
867 vam->sw_if_index = ntohl (mp->sw_if_index);
868 vam->result_ready = 1;
871 static void vl_api_create_loopback_instance_reply_t_handler_json
872 (vl_api_create_loopback_instance_reply_t * mp)
874 vat_main_t *vam = &vat_main;
875 vat_json_node_t node;
877 vat_json_init_object (&node);
878 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
879 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
881 vat_json_print (vam->ofp, &node);
882 vat_json_free (&node);
883 vam->retval = ntohl (mp->retval);
884 vam->result_ready = 1;
887 static void vl_api_af_packet_create_reply_t_handler
888 (vl_api_af_packet_create_reply_t * mp)
890 vat_main_t *vam = &vat_main;
891 i32 retval = ntohl (mp->retval);
893 vam->retval = retval;
894 vam->regenerate_interface_table = 1;
895 vam->sw_if_index = ntohl (mp->sw_if_index);
896 vam->result_ready = 1;
899 static void vl_api_af_packet_create_reply_t_handler_json
900 (vl_api_af_packet_create_reply_t * mp)
902 vat_main_t *vam = &vat_main;
903 vat_json_node_t node;
905 vat_json_init_object (&node);
906 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
907 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
909 vat_json_print (vam->ofp, &node);
910 vat_json_free (&node);
912 vam->retval = ntohl (mp->retval);
913 vam->result_ready = 1;
916 static void vl_api_create_vlan_subif_reply_t_handler
917 (vl_api_create_vlan_subif_reply_t * mp)
919 vat_main_t *vam = &vat_main;
920 i32 retval = ntohl (mp->retval);
922 vam->retval = retval;
923 vam->regenerate_interface_table = 1;
924 vam->sw_if_index = ntohl (mp->sw_if_index);
925 vam->result_ready = 1;
928 static void vl_api_create_vlan_subif_reply_t_handler_json
929 (vl_api_create_vlan_subif_reply_t * mp)
931 vat_main_t *vam = &vat_main;
932 vat_json_node_t node;
934 vat_json_init_object (&node);
935 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
936 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
938 vat_json_print (vam->ofp, &node);
939 vat_json_free (&node);
941 vam->retval = ntohl (mp->retval);
942 vam->result_ready = 1;
945 static void vl_api_create_subif_reply_t_handler
946 (vl_api_create_subif_reply_t * mp)
948 vat_main_t *vam = &vat_main;
949 i32 retval = ntohl (mp->retval);
951 vam->retval = retval;
952 vam->regenerate_interface_table = 1;
953 vam->sw_if_index = ntohl (mp->sw_if_index);
954 vam->result_ready = 1;
957 static void vl_api_create_subif_reply_t_handler_json
958 (vl_api_create_subif_reply_t * mp)
960 vat_main_t *vam = &vat_main;
961 vat_json_node_t node;
963 vat_json_init_object (&node);
964 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
965 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
967 vat_json_print (vam->ofp, &node);
968 vat_json_free (&node);
970 vam->retval = ntohl (mp->retval);
971 vam->result_ready = 1;
974 static void vl_api_interface_name_renumber_reply_t_handler
975 (vl_api_interface_name_renumber_reply_t * mp)
977 vat_main_t *vam = &vat_main;
978 i32 retval = ntohl (mp->retval);
980 vam->retval = retval;
981 vam->regenerate_interface_table = 1;
982 vam->result_ready = 1;
985 static void vl_api_interface_name_renumber_reply_t_handler_json
986 (vl_api_interface_name_renumber_reply_t * mp)
988 vat_main_t *vam = &vat_main;
989 vat_json_node_t node;
991 vat_json_init_object (&node);
992 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
994 vat_json_print (vam->ofp, &node);
995 vat_json_free (&node);
997 vam->retval = ntohl (mp->retval);
998 vam->result_ready = 1;
1002 * Special-case: build the interface table, maintain
1003 * the next loopback sw_if_index vbl.
1005 static void vl_api_sw_interface_details_t_handler
1006 (vl_api_sw_interface_details_t * mp)
1008 vat_main_t *vam = &vat_main;
1009 u8 *s = format (0, "%s%c", mp->interface_name, 0);
1011 hash_set_mem (vam->sw_if_index_by_interface_name, s,
1012 ntohl (mp->sw_if_index));
1014 /* In sub interface case, fill the sub interface table entry */
1015 if (mp->sw_if_index != mp->sup_sw_if_index)
1017 sw_interface_subif_t *sub = NULL;
1019 vec_add2 (vam->sw_if_subif_table, sub, 1);
1021 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
1022 strncpy ((char *) sub->interface_name, (char *) s,
1023 vec_len (sub->interface_name));
1024 sub->sw_if_index = ntohl (mp->sw_if_index);
1025 sub->sub_id = ntohl (mp->sub_id);
1027 sub->raw_flags = ntohl (mp->sub_if_flags & SUB_IF_API_FLAG_MASK_VNET);
1029 sub->sub_number_of_tags = mp->sub_number_of_tags;
1030 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
1031 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
1033 /* vlan tag rewrite */
1034 sub->vtr_op = ntohl (mp->vtr_op);
1035 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
1036 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
1037 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
1041 static void vl_api_sw_interface_details_t_handler_json
1042 (vl_api_sw_interface_details_t * mp)
1044 vat_main_t *vam = &vat_main;
1045 vat_json_node_t *node = NULL;
1047 if (VAT_JSON_ARRAY != vam->json_tree.type)
1049 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1050 vat_json_init_array (&vam->json_tree);
1052 node = vat_json_array_add (&vam->json_tree);
1054 vat_json_init_object (node);
1055 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1056 vat_json_object_add_uint (node, "sup_sw_if_index",
1057 ntohl (mp->sup_sw_if_index));
1058 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
1059 sizeof (mp->l2_address));
1060 vat_json_object_add_string_copy (node, "interface_name",
1061 mp->interface_name);
1062 vat_json_object_add_string_copy (node, "interface_dev_type",
1063 mp->interface_dev_type);
1064 vat_json_object_add_uint (node, "flags", mp->flags);
1065 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1066 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1067 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1068 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1069 vat_json_object_add_uint (node, "sub_number_of_tags",
1070 mp->sub_number_of_tags);
1071 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1072 ntohs (mp->sub_outer_vlan_id));
1073 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1074 ntohs (mp->sub_inner_vlan_id));
1075 vat_json_object_add_uint (node, "sub_if_flags", ntohl (mp->sub_if_flags));
1076 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1077 vat_json_object_add_uint (node, "vtr_push_dot1q",
1078 ntohl (mp->vtr_push_dot1q));
1079 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1080 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1081 if (ntohl (mp->sub_if_flags) & SUB_IF_API_FLAG_DOT1AH)
1083 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1085 format_ethernet_address,
1087 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1089 format_ethernet_address,
1091 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1092 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1096 #if VPP_API_TEST_BUILTIN == 0
1097 static void vl_api_sw_interface_event_t_handler
1098 (vl_api_sw_interface_event_t * mp)
1100 vat_main_t *vam = &vat_main;
1101 if (vam->interface_event_display)
1102 errmsg ("interface flags: sw_if_index %d %s %s",
1103 ntohl (mp->sw_if_index),
1104 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
1105 "admin-up" : "admin-down",
1106 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_LINK_UP) ?
1107 "link-up" : "link-down");
1111 __clib_unused static void
1112 vl_api_sw_interface_event_t_handler_json (vl_api_sw_interface_event_t * mp)
1114 /* JSON output not supported */
1118 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1120 vat_main_t *vam = &vat_main;
1121 i32 retval = ntohl (mp->retval);
1123 vam->retval = retval;
1124 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1125 vam->result_ready = 1;
1129 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1131 vat_main_t *vam = &vat_main;
1132 vat_json_node_t node;
1136 vat_json_init_object (&node);
1137 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1138 vat_json_object_add_uint (&node, "reply_in_shmem",
1139 ntohl (mp->reply_in_shmem));
1140 /* Toss the shared-memory original... */
1141 oldheap = vl_msg_push_heap ();
1143 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1146 vl_msg_pop_heap (oldheap);
1148 vat_json_print (vam->ofp, &node);
1149 vat_json_free (&node);
1151 vam->retval = ntohl (mp->retval);
1152 vam->result_ready = 1;
1156 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1158 vat_main_t *vam = &vat_main;
1159 i32 retval = ntohl (mp->retval);
1161 vec_reset_length (vam->cmd_reply);
1163 vam->retval = retval;
1165 vam->cmd_reply = vl_api_from_api_to_new_vec (&mp->reply);
1166 vam->result_ready = 1;
1170 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1172 vat_main_t *vam = &vat_main;
1173 vat_json_node_t node;
1174 u8 *reply = 0; /* reply vector */
1176 reply = vl_api_from_api_to_new_vec (&mp->reply);
1177 vec_reset_length (vam->cmd_reply);
1179 vat_json_init_object (&node);
1180 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1181 vat_json_object_add_string_copy (&node, "reply", reply);
1183 vat_json_print (vam->ofp, &node);
1184 vat_json_free (&node);
1187 vam->retval = ntohl (mp->retval);
1188 vam->result_ready = 1;
1191 static void vl_api_classify_add_del_table_reply_t_handler
1192 (vl_api_classify_add_del_table_reply_t * mp)
1194 vat_main_t *vam = &vat_main;
1195 i32 retval = ntohl (mp->retval);
1196 if (vam->async_mode)
1198 vam->async_errors += (retval < 0);
1202 vam->retval = retval;
1204 ((mp->new_table_index != 0xFFFFFFFF) ||
1205 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1206 (mp->match_n_vectors != 0xFFFFFFFF)))
1208 * Note: this is just barely thread-safe, depends on
1209 * the main thread spinning waiting for an answer...
1211 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1212 ntohl (mp->new_table_index),
1213 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1214 vam->result_ready = 1;
1218 static void vl_api_classify_add_del_table_reply_t_handler_json
1219 (vl_api_classify_add_del_table_reply_t * mp)
1221 vat_main_t *vam = &vat_main;
1222 vat_json_node_t node;
1224 vat_json_init_object (&node);
1225 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1226 vat_json_object_add_uint (&node, "new_table_index",
1227 ntohl (mp->new_table_index));
1228 vat_json_object_add_uint (&node, "skip_n_vectors",
1229 ntohl (mp->skip_n_vectors));
1230 vat_json_object_add_uint (&node, "match_n_vectors",
1231 ntohl (mp->match_n_vectors));
1233 vat_json_print (vam->ofp, &node);
1234 vat_json_free (&node);
1236 vam->retval = ntohl (mp->retval);
1237 vam->result_ready = 1;
1240 static void vl_api_get_node_index_reply_t_handler
1241 (vl_api_get_node_index_reply_t * mp)
1243 vat_main_t *vam = &vat_main;
1244 i32 retval = ntohl (mp->retval);
1245 if (vam->async_mode)
1247 vam->async_errors += (retval < 0);
1251 vam->retval = retval;
1253 errmsg ("node index %d", ntohl (mp->node_index));
1254 vam->result_ready = 1;
1258 static void vl_api_get_node_index_reply_t_handler_json
1259 (vl_api_get_node_index_reply_t * mp)
1261 vat_main_t *vam = &vat_main;
1262 vat_json_node_t node;
1264 vat_json_init_object (&node);
1265 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1266 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1268 vat_json_print (vam->ofp, &node);
1269 vat_json_free (&node);
1271 vam->retval = ntohl (mp->retval);
1272 vam->result_ready = 1;
1275 static void vl_api_get_next_index_reply_t_handler
1276 (vl_api_get_next_index_reply_t * mp)
1278 vat_main_t *vam = &vat_main;
1279 i32 retval = ntohl (mp->retval);
1280 if (vam->async_mode)
1282 vam->async_errors += (retval < 0);
1286 vam->retval = retval;
1288 errmsg ("next node index %d", ntohl (mp->next_index));
1289 vam->result_ready = 1;
1293 static void vl_api_get_next_index_reply_t_handler_json
1294 (vl_api_get_next_index_reply_t * mp)
1296 vat_main_t *vam = &vat_main;
1297 vat_json_node_t node;
1299 vat_json_init_object (&node);
1300 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1301 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1303 vat_json_print (vam->ofp, &node);
1304 vat_json_free (&node);
1306 vam->retval = ntohl (mp->retval);
1307 vam->result_ready = 1;
1310 static void vl_api_add_node_next_reply_t_handler
1311 (vl_api_add_node_next_reply_t * mp)
1313 vat_main_t *vam = &vat_main;
1314 i32 retval = ntohl (mp->retval);
1315 if (vam->async_mode)
1317 vam->async_errors += (retval < 0);
1321 vam->retval = retval;
1323 errmsg ("next index %d", ntohl (mp->next_index));
1324 vam->result_ready = 1;
1328 static void vl_api_add_node_next_reply_t_handler_json
1329 (vl_api_add_node_next_reply_t * mp)
1331 vat_main_t *vam = &vat_main;
1332 vat_json_node_t node;
1334 vat_json_init_object (&node);
1335 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1336 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1338 vat_json_print (vam->ofp, &node);
1339 vat_json_free (&node);
1341 vam->retval = ntohl (mp->retval);
1342 vam->result_ready = 1;
1345 static void vl_api_show_version_reply_t_handler
1346 (vl_api_show_version_reply_t * mp)
1348 vat_main_t *vam = &vat_main;
1349 i32 retval = ntohl (mp->retval);
1353 errmsg (" program: %s", mp->program);
1354 errmsg (" version: %s", mp->version);
1355 errmsg (" build date: %s", mp->build_date);
1356 errmsg ("build directory: %s", mp->build_directory);
1358 vam->retval = retval;
1359 vam->result_ready = 1;
1362 static void vl_api_show_version_reply_t_handler_json
1363 (vl_api_show_version_reply_t * mp)
1365 vat_main_t *vam = &vat_main;
1366 vat_json_node_t node;
1368 vat_json_init_object (&node);
1369 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1370 vat_json_object_add_string_copy (&node, "program", mp->program);
1371 vat_json_object_add_string_copy (&node, "version", mp->version);
1372 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1373 vat_json_object_add_string_copy (&node, "build_directory",
1374 mp->build_directory);
1376 vat_json_print (vam->ofp, &node);
1377 vat_json_free (&node);
1379 vam->retval = ntohl (mp->retval);
1380 vam->result_ready = 1;
1383 static void vl_api_show_threads_reply_t_handler
1384 (vl_api_show_threads_reply_t * mp)
1386 vat_main_t *vam = &vat_main;
1387 i32 retval = ntohl (mp->retval);
1391 count = ntohl (mp->count);
1393 for (i = 0; i < count; i++)
1395 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1396 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1397 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1398 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1399 ntohl (mp->thread_data[i].cpu_socket));
1401 vam->retval = retval;
1402 vam->result_ready = 1;
1405 static void vl_api_show_threads_reply_t_handler_json
1406 (vl_api_show_threads_reply_t * mp)
1408 vat_main_t *vam = &vat_main;
1409 vat_json_node_t node;
1410 vl_api_thread_data_t *td;
1411 i32 retval = ntohl (mp->retval);
1415 count = ntohl (mp->count);
1417 vat_json_init_object (&node);
1418 vat_json_object_add_int (&node, "retval", retval);
1419 vat_json_object_add_uint (&node, "count", count);
1421 for (i = 0; i < count; i++)
1423 td = &mp->thread_data[i];
1424 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1425 vat_json_object_add_string_copy (&node, "name", td->name);
1426 vat_json_object_add_string_copy (&node, "type", td->type);
1427 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1428 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1429 vat_json_object_add_int (&node, "core", ntohl (td->id));
1430 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1433 vat_json_print (vam->ofp, &node);
1434 vat_json_free (&node);
1436 vam->retval = retval;
1437 vam->result_ready = 1;
1441 api_show_threads (vat_main_t * vam)
1443 vl_api_show_threads_t *mp;
1447 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1448 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1450 M (SHOW_THREADS, mp);
1458 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1460 u32 n_macs = ntohl (mp->n_macs);
1461 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1462 ntohl (mp->pid), mp->client_index, n_macs);
1464 for (i = 0; i < n_macs; i++)
1466 vl_api_mac_entry_t *mac = &mp->mac[i];
1467 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1468 i + 1, ntohl (mac->sw_if_index),
1469 format_ethernet_address, mac->mac_addr, mac->action);
1476 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1478 /* JSON output not supported */
1481 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1482 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1485 * Special-case: build the bridge domain table, maintain
1486 * the next bd id vbl.
1488 static void vl_api_bridge_domain_details_t_handler
1489 (vl_api_bridge_domain_details_t * mp)
1491 vat_main_t *vam = &vat_main;
1492 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1495 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1496 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1498 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1499 ntohl (mp->bd_id), mp->learn, mp->forward,
1500 mp->flood, ntohl (mp->bvi_sw_if_index),
1501 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1505 vl_api_bridge_domain_sw_if_t *sw_ifs;
1506 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1509 sw_ifs = mp->sw_if_details;
1510 for (i = 0; i < n_sw_ifs; i++)
1516 sw_if_index = ntohl (sw_ifs->sw_if_index);
1519 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1521 if ((u32) p->value[0] == sw_if_index)
1523 sw_if_name = (u8 *)(p->key);
1528 print (vam->ofp, "%7d %3d %s", sw_if_index,
1529 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1530 "sw_if_index not found!");
1537 static void vl_api_bridge_domain_details_t_handler_json
1538 (vl_api_bridge_domain_details_t * mp)
1540 vat_main_t *vam = &vat_main;
1541 vat_json_node_t *node, *array = NULL;
1542 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1544 if (VAT_JSON_ARRAY != vam->json_tree.type)
1546 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1547 vat_json_init_array (&vam->json_tree);
1549 node = vat_json_array_add (&vam->json_tree);
1551 vat_json_init_object (node);
1552 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1553 vat_json_object_add_uint (node, "flood", mp->flood);
1554 vat_json_object_add_uint (node, "forward", mp->forward);
1555 vat_json_object_add_uint (node, "learn", mp->learn);
1556 vat_json_object_add_uint (node, "bvi_sw_if_index",
1557 ntohl (mp->bvi_sw_if_index));
1558 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1559 array = vat_json_object_add (node, "sw_if");
1560 vat_json_init_array (array);
1566 vl_api_bridge_domain_sw_if_t *sw_ifs;
1569 sw_ifs = mp->sw_if_details;
1570 for (i = 0; i < n_sw_ifs; i++)
1572 node = vat_json_array_add (array);
1573 vat_json_init_object (node);
1574 vat_json_object_add_uint (node, "sw_if_index",
1575 ntohl (sw_ifs->sw_if_index));
1576 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1582 static void vl_api_control_ping_reply_t_handler
1583 (vl_api_control_ping_reply_t * mp)
1585 vat_main_t *vam = &vat_main;
1586 i32 retval = ntohl (mp->retval);
1587 if (vam->async_mode)
1589 vam->async_errors += (retval < 0);
1593 vam->retval = retval;
1594 vam->result_ready = 1;
1596 if (vam->socket_client_main)
1597 vam->socket_client_main->control_pings_outstanding--;
1600 static void vl_api_control_ping_reply_t_handler_json
1601 (vl_api_control_ping_reply_t * mp)
1603 vat_main_t *vam = &vat_main;
1604 i32 retval = ntohl (mp->retval);
1606 if (VAT_JSON_NONE != vam->json_tree.type)
1608 vat_json_print (vam->ofp, &vam->json_tree);
1609 vat_json_free (&vam->json_tree);
1610 vam->json_tree.type = VAT_JSON_NONE;
1615 vat_json_init_array (&vam->json_tree);
1616 vat_json_print (vam->ofp, &vam->json_tree);
1617 vam->json_tree.type = VAT_JSON_NONE;
1620 vam->retval = retval;
1621 vam->result_ready = 1;
1625 vl_api_bridge_domain_set_mac_age_reply_t_handler
1626 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1628 vat_main_t *vam = &vat_main;
1629 i32 retval = ntohl (mp->retval);
1630 if (vam->async_mode)
1632 vam->async_errors += (retval < 0);
1636 vam->retval = retval;
1637 vam->result_ready = 1;
1641 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1642 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1644 vat_main_t *vam = &vat_main;
1645 vat_json_node_t node;
1647 vat_json_init_object (&node);
1648 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1650 vat_json_print (vam->ofp, &node);
1651 vat_json_free (&node);
1653 vam->retval = ntohl (mp->retval);
1654 vam->result_ready = 1;
1658 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1660 vat_main_t *vam = &vat_main;
1661 i32 retval = ntohl (mp->retval);
1662 if (vam->async_mode)
1664 vam->async_errors += (retval < 0);
1668 vam->retval = retval;
1669 vam->result_ready = 1;
1673 static void vl_api_l2_flags_reply_t_handler_json
1674 (vl_api_l2_flags_reply_t * mp)
1676 vat_main_t *vam = &vat_main;
1677 vat_json_node_t node;
1679 vat_json_init_object (&node);
1680 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1681 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1682 ntohl (mp->resulting_feature_bitmap));
1684 vat_json_print (vam->ofp, &node);
1685 vat_json_free (&node);
1687 vam->retval = ntohl (mp->retval);
1688 vam->result_ready = 1;
1691 static void vl_api_bridge_flags_reply_t_handler
1692 (vl_api_bridge_flags_reply_t * mp)
1694 vat_main_t *vam = &vat_main;
1695 i32 retval = ntohl (mp->retval);
1696 if (vam->async_mode)
1698 vam->async_errors += (retval < 0);
1702 vam->retval = retval;
1703 vam->result_ready = 1;
1707 static void vl_api_bridge_flags_reply_t_handler_json
1708 (vl_api_bridge_flags_reply_t * mp)
1710 vat_main_t *vam = &vat_main;
1711 vat_json_node_t node;
1713 vat_json_init_object (&node);
1714 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1715 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1716 ntohl (mp->resulting_feature_bitmap));
1718 vat_json_print (vam->ofp, &node);
1719 vat_json_free (&node);
1721 vam->retval = ntohl (mp->retval);
1722 vam->result_ready = 1;
1726 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1728 vat_main_t *vam = &vat_main;
1729 i32 retval = ntohl (mp->retval);
1730 if (vam->async_mode)
1732 vam->async_errors += (retval < 0);
1736 vam->retval = retval;
1737 vam->sw_if_index = ntohl (mp->sw_if_index);
1738 vam->result_ready = 1;
1743 static void vl_api_tap_create_v2_reply_t_handler_json
1744 (vl_api_tap_create_v2_reply_t * mp)
1746 vat_main_t *vam = &vat_main;
1747 vat_json_node_t node;
1749 vat_json_init_object (&node);
1750 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1751 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1753 vat_json_print (vam->ofp, &node);
1754 vat_json_free (&node);
1756 vam->retval = ntohl (mp->retval);
1757 vam->result_ready = 1;
1762 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1764 vat_main_t *vam = &vat_main;
1765 i32 retval = ntohl (mp->retval);
1766 if (vam->async_mode)
1768 vam->async_errors += (retval < 0);
1772 vam->retval = retval;
1773 vam->result_ready = 1;
1777 static void vl_api_tap_delete_v2_reply_t_handler_json
1778 (vl_api_tap_delete_v2_reply_t * mp)
1780 vat_main_t *vam = &vat_main;
1781 vat_json_node_t node;
1783 vat_json_init_object (&node);
1784 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1786 vat_json_print (vam->ofp, &node);
1787 vat_json_free (&node);
1789 vam->retval = ntohl (mp->retval);
1790 vam->result_ready = 1;
1794 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1797 vat_main_t *vam = &vat_main;
1798 i32 retval = ntohl (mp->retval);
1799 if (vam->async_mode)
1801 vam->async_errors += (retval < 0);
1805 vam->retval = retval;
1806 vam->sw_if_index = ntohl (mp->sw_if_index);
1807 vam->result_ready = 1;
1811 static void vl_api_virtio_pci_create_reply_t_handler_json
1812 (vl_api_virtio_pci_create_reply_t * mp)
1814 vat_main_t *vam = &vat_main;
1815 vat_json_node_t node;
1817 vat_json_init_object (&node);
1818 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1819 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1821 vat_json_print (vam->ofp, &node);
1822 vat_json_free (&node);
1824 vam->retval = ntohl (mp->retval);
1825 vam->result_ready = 1;
1830 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1833 vat_main_t *vam = &vat_main;
1834 i32 retval = ntohl (mp->retval);
1835 if (vam->async_mode)
1837 vam->async_errors += (retval < 0);
1841 vam->retval = retval;
1842 vam->result_ready = 1;
1846 static void vl_api_virtio_pci_delete_reply_t_handler_json
1847 (vl_api_virtio_pci_delete_reply_t * mp)
1849 vat_main_t *vam = &vat_main;
1850 vat_json_node_t node;
1852 vat_json_init_object (&node);
1853 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1855 vat_json_print (vam->ofp, &node);
1856 vat_json_free (&node);
1858 vam->retval = ntohl (mp->retval);
1859 vam->result_ready = 1;
1863 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1865 vat_main_t *vam = &vat_main;
1866 i32 retval = ntohl (mp->retval);
1868 if (vam->async_mode)
1870 vam->async_errors += (retval < 0);
1874 vam->retval = retval;
1875 vam->sw_if_index = ntohl (mp->sw_if_index);
1876 vam->result_ready = 1;
1880 static void vl_api_bond_create_reply_t_handler_json
1881 (vl_api_bond_create_reply_t * mp)
1883 vat_main_t *vam = &vat_main;
1884 vat_json_node_t node;
1886 vat_json_init_object (&node);
1887 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1888 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1890 vat_json_print (vam->ofp, &node);
1891 vat_json_free (&node);
1893 vam->retval = ntohl (mp->retval);
1894 vam->result_ready = 1;
1898 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1900 vat_main_t *vam = &vat_main;
1901 i32 retval = ntohl (mp->retval);
1903 if (vam->async_mode)
1905 vam->async_errors += (retval < 0);
1909 vam->retval = retval;
1910 vam->result_ready = 1;
1914 static void vl_api_bond_delete_reply_t_handler_json
1915 (vl_api_bond_delete_reply_t * mp)
1917 vat_main_t *vam = &vat_main;
1918 vat_json_node_t node;
1920 vat_json_init_object (&node);
1921 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1923 vat_json_print (vam->ofp, &node);
1924 vat_json_free (&node);
1926 vam->retval = ntohl (mp->retval);
1927 vam->result_ready = 1;
1931 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1933 vat_main_t *vam = &vat_main;
1934 i32 retval = ntohl (mp->retval);
1936 if (vam->async_mode)
1938 vam->async_errors += (retval < 0);
1942 vam->retval = retval;
1943 vam->result_ready = 1;
1947 static void vl_api_bond_enslave_reply_t_handler_json
1948 (vl_api_bond_enslave_reply_t * mp)
1950 vat_main_t *vam = &vat_main;
1951 vat_json_node_t node;
1953 vat_json_init_object (&node);
1954 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1956 vat_json_print (vam->ofp, &node);
1957 vat_json_free (&node);
1959 vam->retval = ntohl (mp->retval);
1960 vam->result_ready = 1;
1964 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1967 vat_main_t *vam = &vat_main;
1968 i32 retval = ntohl (mp->retval);
1970 if (vam->async_mode)
1972 vam->async_errors += (retval < 0);
1976 vam->retval = retval;
1977 vam->result_ready = 1;
1981 static void vl_api_bond_detach_slave_reply_t_handler_json
1982 (vl_api_bond_detach_slave_reply_t * mp)
1984 vat_main_t *vam = &vat_main;
1985 vat_json_node_t node;
1987 vat_json_init_object (&node);
1988 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1990 vat_json_print (vam->ofp, &node);
1991 vat_json_free (&node);
1993 vam->retval = ntohl (mp->retval);
1994 vam->result_ready = 1;
1998 api_sw_interface_set_bond_weight (vat_main_t * vam)
2000 unformat_input_t *i = vam->input;
2001 vl_api_sw_interface_set_bond_weight_t *mp;
2002 u32 sw_if_index = ~0;
2004 u8 weight_enter = 0;
2007 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2009 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2011 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2013 else if (unformat (i, "weight %u", &weight))
2019 if (sw_if_index == ~0)
2021 errmsg ("missing interface name or sw_if_index");
2024 if (weight_enter == 0)
2026 errmsg ("missing valid weight");
2030 /* Construct the API message */
2031 M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
2032 mp->sw_if_index = ntohl (sw_if_index);
2033 mp->weight = ntohl (weight);
2040 static void vl_api_sw_interface_bond_details_t_handler
2041 (vl_api_sw_interface_bond_details_t * mp)
2043 vat_main_t *vam = &vat_main;
2046 "%-16s %-12d %-12U %-13U %-14u %-14u",
2047 mp->interface_name, ntohl (mp->sw_if_index),
2048 format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
2049 ntohl (mp->lb), ntohl (mp->active_slaves), ntohl (mp->slaves));
2052 static void vl_api_sw_interface_bond_details_t_handler_json
2053 (vl_api_sw_interface_bond_details_t * mp)
2055 vat_main_t *vam = &vat_main;
2056 vat_json_node_t *node = NULL;
2058 if (VAT_JSON_ARRAY != vam->json_tree.type)
2060 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2061 vat_json_init_array (&vam->json_tree);
2063 node = vat_json_array_add (&vam->json_tree);
2065 vat_json_init_object (node);
2066 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2067 vat_json_object_add_string_copy (node, "interface_name",
2068 mp->interface_name);
2069 vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
2070 vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
2071 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2072 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2076 api_sw_interface_bond_dump (vat_main_t * vam)
2078 vl_api_sw_interface_bond_dump_t *mp;
2079 vl_api_control_ping_t *mp_ping;
2083 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2084 "interface name", "sw_if_index", "mode", "load balance",
2085 "active slaves", "slaves");
2087 /* Get list of bond interfaces */
2088 M (SW_INTERFACE_BOND_DUMP, mp);
2091 /* Use a control ping for synchronization */
2092 MPING (CONTROL_PING, mp_ping);
2099 static void vl_api_sw_interface_slave_details_t_handler
2100 (vl_api_sw_interface_slave_details_t * mp)
2102 vat_main_t *vam = &vat_main;
2105 "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
2106 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
2107 ntohl (mp->weight), mp->is_local_numa);
2110 static void vl_api_sw_interface_slave_details_t_handler_json
2111 (vl_api_sw_interface_slave_details_t * mp)
2113 vat_main_t *vam = &vat_main;
2114 vat_json_node_t *node = NULL;
2116 if (VAT_JSON_ARRAY != vam->json_tree.type)
2118 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2119 vat_json_init_array (&vam->json_tree);
2121 node = vat_json_array_add (&vam->json_tree);
2123 vat_json_init_object (node);
2124 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2125 vat_json_object_add_string_copy (node, "interface_name",
2126 mp->interface_name);
2127 vat_json_object_add_uint (node, "passive", mp->is_passive);
2128 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2129 vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
2130 vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
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 %-7s %-12s %-10s %-10s",
2162 "slave interface name", "sw_if_index", "passive", "long_timeout",
2163 "weight", "local numa");
2165 /* Get list of bond interfaces */
2166 M (SW_INTERFACE_SLAVE_DUMP, mp);
2167 mp->sw_if_index = ntohl (sw_if_index);
2170 /* Use a control ping for synchronization */
2171 MPING (CONTROL_PING, mp_ping);
2178 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2179 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2181 vat_main_t *vam = &vat_main;
2182 i32 retval = ntohl (mp->retval);
2183 if (vam->async_mode)
2185 vam->async_errors += (retval < 0);
2189 vam->retval = retval;
2190 vam->sw_if_index = ntohl (mp->sw_if_index);
2191 vam->result_ready = 1;
2193 vam->regenerate_interface_table = 1;
2196 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2197 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2199 vat_main_t *vam = &vat_main;
2200 vat_json_node_t node;
2202 vat_json_init_object (&node);
2203 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2204 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2205 ntohl (mp->sw_if_index));
2207 vat_json_print (vam->ofp, &node);
2208 vat_json_free (&node);
2210 vam->retval = ntohl (mp->retval);
2211 vam->result_ready = 1;
2214 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2215 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2217 vat_main_t *vam = &vat_main;
2218 i32 retval = ntohl (mp->retval);
2219 if (vam->async_mode)
2221 vam->async_errors += (retval < 0);
2225 vam->retval = retval;
2226 vam->sw_if_index = ntohl (mp->sw_if_index);
2227 vam->result_ready = 1;
2231 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2232 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2234 vat_main_t *vam = &vat_main;
2235 vat_json_node_t node;
2237 vat_json_init_object (&node);
2238 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2239 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2241 vat_json_print (vam->ofp, &node);
2242 vat_json_free (&node);
2244 vam->retval = ntohl (mp->retval);
2245 vam->result_ready = 1;
2248 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2249 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2251 vat_main_t *vam = &vat_main;
2252 i32 retval = ntohl (mp->retval);
2253 if (vam->async_mode)
2255 vam->async_errors += (retval < 0);
2259 vam->retval = retval;
2260 vam->result_ready = 1;
2264 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2265 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2267 vat_main_t *vam = &vat_main;
2268 vat_json_node_t node;
2270 vat_json_init_object (&node);
2271 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2272 vat_json_object_add_uint (&node, "fwd_entry_index",
2273 clib_net_to_host_u32 (mp->fwd_entry_index));
2275 vat_json_print (vam->ofp, &node);
2276 vat_json_free (&node);
2278 vam->retval = ntohl (mp->retval);
2279 vam->result_ready = 1;
2283 format_lisp_transport_protocol (u8 * s, va_list * args)
2285 u32 proto = va_arg (*args, u32);
2290 return format (s, "udp");
2292 return format (s, "api");
2299 static void vl_api_one_get_transport_protocol_reply_t_handler
2300 (vl_api_one_get_transport_protocol_reply_t * mp)
2302 vat_main_t *vam = &vat_main;
2303 i32 retval = ntohl (mp->retval);
2304 if (vam->async_mode)
2306 vam->async_errors += (retval < 0);
2310 u32 proto = mp->protocol;
2311 print (vam->ofp, "Transport protocol: %U",
2312 format_lisp_transport_protocol, proto);
2313 vam->retval = retval;
2314 vam->result_ready = 1;
2318 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2319 (vl_api_one_get_transport_protocol_reply_t * mp)
2321 vat_main_t *vam = &vat_main;
2322 vat_json_node_t node;
2325 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2328 vat_json_init_object (&node);
2329 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2330 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2333 vat_json_print (vam->ofp, &node);
2334 vat_json_free (&node);
2336 vam->retval = ntohl (mp->retval);
2337 vam->result_ready = 1;
2340 static void vl_api_one_add_del_locator_set_reply_t_handler
2341 (vl_api_one_add_del_locator_set_reply_t * mp)
2343 vat_main_t *vam = &vat_main;
2344 i32 retval = ntohl (mp->retval);
2345 if (vam->async_mode)
2347 vam->async_errors += (retval < 0);
2351 vam->retval = retval;
2352 vam->result_ready = 1;
2356 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2357 (vl_api_one_add_del_locator_set_reply_t * mp)
2359 vat_main_t *vam = &vat_main;
2360 vat_json_node_t node;
2362 vat_json_init_object (&node);
2363 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2364 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2366 vat_json_print (vam->ofp, &node);
2367 vat_json_free (&node);
2369 vam->retval = ntohl (mp->retval);
2370 vam->result_ready = 1;
2373 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2374 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2376 vat_main_t *vam = &vat_main;
2377 i32 retval = ntohl (mp->retval);
2378 if (vam->async_mode)
2380 vam->async_errors += (retval < 0);
2384 vam->retval = retval;
2385 vam->sw_if_index = ntohl (mp->sw_if_index);
2386 vam->result_ready = 1;
2388 vam->regenerate_interface_table = 1;
2391 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2392 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2394 vat_main_t *vam = &vat_main;
2395 vat_json_node_t node;
2397 vat_json_init_object (&node);
2398 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2399 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2401 vat_json_print (vam->ofp, &node);
2402 vat_json_free (&node);
2404 vam->retval = ntohl (mp->retval);
2405 vam->result_ready = 1;
2408 static void vl_api_vxlan_offload_rx_reply_t_handler
2409 (vl_api_vxlan_offload_rx_reply_t * mp)
2411 vat_main_t *vam = &vat_main;
2412 i32 retval = ntohl (mp->retval);
2413 if (vam->async_mode)
2415 vam->async_errors += (retval < 0);
2419 vam->retval = retval;
2420 vam->result_ready = 1;
2424 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2425 (vl_api_vxlan_offload_rx_reply_t * mp)
2427 vat_main_t *vam = &vat_main;
2428 vat_json_node_t node;
2430 vat_json_init_object (&node);
2431 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2433 vat_json_print (vam->ofp, &node);
2434 vat_json_free (&node);
2436 vam->retval = ntohl (mp->retval);
2437 vam->result_ready = 1;
2440 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2441 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2443 vat_main_t *vam = &vat_main;
2444 i32 retval = ntohl (mp->retval);
2445 if (vam->async_mode)
2447 vam->async_errors += (retval < 0);
2451 vam->retval = retval;
2452 vam->sw_if_index = ntohl (mp->sw_if_index);
2453 vam->result_ready = 1;
2457 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2458 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2460 vat_main_t *vam = &vat_main;
2461 vat_json_node_t node;
2463 vat_json_init_object (&node);
2464 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2465 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2467 vat_json_print (vam->ofp, &node);
2468 vat_json_free (&node);
2470 vam->retval = ntohl (mp->retval);
2471 vam->result_ready = 1;
2474 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2475 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2477 vat_main_t *vam = &vat_main;
2478 i32 retval = ntohl (mp->retval);
2479 if (vam->async_mode)
2481 vam->async_errors += (retval < 0);
2485 vam->retval = retval;
2486 vam->sw_if_index = ntohl (mp->sw_if_index);
2487 vam->result_ready = 1;
2489 vam->regenerate_interface_table = 1;
2492 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2493 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2495 vat_main_t *vam = &vat_main;
2496 vat_json_node_t node;
2498 vat_json_init_object (&node);
2499 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2500 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2502 vat_json_print (vam->ofp, &node);
2503 vat_json_free (&node);
2505 vam->retval = ntohl (mp->retval);
2506 vam->result_ready = 1;
2509 static void vl_api_gre_tunnel_add_del_reply_t_handler
2510 (vl_api_gre_tunnel_add_del_reply_t * mp)
2512 vat_main_t *vam = &vat_main;
2513 i32 retval = ntohl (mp->retval);
2514 if (vam->async_mode)
2516 vam->async_errors += (retval < 0);
2520 vam->retval = retval;
2521 vam->sw_if_index = ntohl (mp->sw_if_index);
2522 vam->result_ready = 1;
2526 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2527 (vl_api_gre_tunnel_add_del_reply_t * mp)
2529 vat_main_t *vam = &vat_main;
2530 vat_json_node_t node;
2532 vat_json_init_object (&node);
2533 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2534 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2536 vat_json_print (vam->ofp, &node);
2537 vat_json_free (&node);
2539 vam->retval = ntohl (mp->retval);
2540 vam->result_ready = 1;
2543 static void vl_api_create_vhost_user_if_reply_t_handler
2544 (vl_api_create_vhost_user_if_reply_t * mp)
2546 vat_main_t *vam = &vat_main;
2547 i32 retval = ntohl (mp->retval);
2548 if (vam->async_mode)
2550 vam->async_errors += (retval < 0);
2554 vam->retval = retval;
2555 vam->sw_if_index = ntohl (mp->sw_if_index);
2556 vam->result_ready = 1;
2558 vam->regenerate_interface_table = 1;
2561 static void vl_api_create_vhost_user_if_reply_t_handler_json
2562 (vl_api_create_vhost_user_if_reply_t * mp)
2564 vat_main_t *vam = &vat_main;
2565 vat_json_node_t node;
2567 vat_json_init_object (&node);
2568 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2569 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2571 vat_json_print (vam->ofp, &node);
2572 vat_json_free (&node);
2574 vam->retval = ntohl (mp->retval);
2575 vam->result_ready = 1;
2578 static void vl_api_ip_address_details_t_handler
2579 (vl_api_ip_address_details_t * mp)
2581 vat_main_t *vam = &vat_main;
2582 static ip_address_details_t empty_ip_address_details = { {0} };
2583 ip_address_details_t *address = NULL;
2584 ip_details_t *current_ip_details = NULL;
2585 ip_details_t *details = NULL;
2587 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2589 if (!details || vam->current_sw_if_index >= vec_len (details)
2590 || !details[vam->current_sw_if_index].present)
2592 errmsg ("ip address details arrived but not stored");
2593 errmsg ("ip_dump should be called first");
2597 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2599 #define addresses (current_ip_details->addr)
2601 vec_validate_init_empty (addresses, vec_len (addresses),
2602 empty_ip_address_details);
2604 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2606 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2607 address->prefix_length = mp->prefix.len;
2611 static void vl_api_ip_address_details_t_handler_json
2612 (vl_api_ip_address_details_t * mp)
2614 vat_main_t *vam = &vat_main;
2615 vat_json_node_t *node = NULL;
2617 if (VAT_JSON_ARRAY != vam->json_tree.type)
2619 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2620 vat_json_init_array (&vam->json_tree);
2622 node = vat_json_array_add (&vam->json_tree);
2624 vat_json_init_object (node);
2625 vat_json_object_add_prefix (node, &mp->prefix);
2629 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2631 vat_main_t *vam = &vat_main;
2632 static ip_details_t empty_ip_details = { 0 };
2633 ip_details_t *ip = NULL;
2634 u32 sw_if_index = ~0;
2636 sw_if_index = ntohl (mp->sw_if_index);
2638 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2639 sw_if_index, empty_ip_details);
2641 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2648 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2650 vat_main_t *vam = &vat_main;
2652 if (VAT_JSON_ARRAY != vam->json_tree.type)
2654 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2655 vat_json_init_array (&vam->json_tree);
2657 vat_json_array_add_uint (&vam->json_tree,
2658 clib_net_to_host_u32 (mp->sw_if_index));
2661 static void vl_api_get_first_msg_id_reply_t_handler
2662 (vl_api_get_first_msg_id_reply_t * mp)
2664 vat_main_t *vam = &vat_main;
2665 i32 retval = ntohl (mp->retval);
2667 if (vam->async_mode)
2669 vam->async_errors += (retval < 0);
2673 vam->retval = retval;
2674 vam->result_ready = 1;
2678 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2682 static void vl_api_get_first_msg_id_reply_t_handler_json
2683 (vl_api_get_first_msg_id_reply_t * mp)
2685 vat_main_t *vam = &vat_main;
2686 vat_json_node_t node;
2688 vat_json_init_object (&node);
2689 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2690 vat_json_object_add_uint (&node, "first_msg_id",
2691 (uint) ntohs (mp->first_msg_id));
2693 vat_json_print (vam->ofp, &node);
2694 vat_json_free (&node);
2696 vam->retval = ntohl (mp->retval);
2697 vam->result_ready = 1;
2700 static void vl_api_get_node_graph_reply_t_handler
2701 (vl_api_get_node_graph_reply_t * mp)
2703 vat_main_t *vam = &vat_main;
2704 i32 retval = ntohl (mp->retval);
2705 u8 *pvt_copy, *reply;
2710 if (vam->async_mode)
2712 vam->async_errors += (retval < 0);
2716 vam->retval = retval;
2717 vam->result_ready = 1;
2720 /* "Should never happen..." */
2724 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2725 pvt_copy = vec_dup (reply);
2727 /* Toss the shared-memory original... */
2728 oldheap = vl_msg_push_heap ();
2732 vl_msg_pop_heap (oldheap);
2734 if (vam->graph_nodes)
2736 hash_free (vam->graph_node_index_by_name);
2738 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2740 node = vam->graph_nodes[0][i];
2741 vec_free (node->name);
2742 vec_free (node->next_nodes);
2745 vec_free (vam->graph_nodes[0]);
2746 vec_free (vam->graph_nodes);
2749 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2750 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2751 vec_free (pvt_copy);
2753 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2755 node = vam->graph_nodes[0][i];
2756 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2760 static void vl_api_get_node_graph_reply_t_handler_json
2761 (vl_api_get_node_graph_reply_t * mp)
2763 vat_main_t *vam = &vat_main;
2765 vat_json_node_t node;
2768 /* $$$$ make this real? */
2769 vat_json_init_object (&node);
2770 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2771 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2773 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2775 /* Toss the shared-memory original... */
2776 oldheap = vl_msg_push_heap ();
2780 vl_msg_pop_heap (oldheap);
2782 vat_json_print (vam->ofp, &node);
2783 vat_json_free (&node);
2785 vam->retval = ntohl (mp->retval);
2786 vam->result_ready = 1;
2790 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2792 vat_main_t *vam = &vat_main;
2797 s = format (s, "%=16d%=16d%=16d",
2798 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2802 s = format (s, "%=16U%=16d%=16d",
2803 mp->is_ipv6 ? format_ip6_address :
2805 mp->ip_address, mp->priority, mp->weight);
2808 print (vam->ofp, "%v", s);
2813 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2815 vat_main_t *vam = &vat_main;
2816 vat_json_node_t *node = NULL;
2817 struct in6_addr ip6;
2820 if (VAT_JSON_ARRAY != vam->json_tree.type)
2822 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2823 vat_json_init_array (&vam->json_tree);
2825 node = vat_json_array_add (&vam->json_tree);
2826 vat_json_init_object (node);
2828 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2829 vat_json_object_add_uint (node, "priority", mp->priority);
2830 vat_json_object_add_uint (node, "weight", mp->weight);
2833 vat_json_object_add_uint (node, "sw_if_index",
2834 clib_net_to_host_u32 (mp->sw_if_index));
2839 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2840 vat_json_object_add_ip6 (node, "address", ip6);
2844 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2845 vat_json_object_add_ip4 (node, "address", ip4);
2851 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2854 vat_main_t *vam = &vat_main;
2857 ls_name = format (0, "%s", mp->ls_name);
2859 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2865 vl_api_one_locator_set_details_t_handler_json
2866 (vl_api_one_locator_set_details_t * mp)
2868 vat_main_t *vam = &vat_main;
2869 vat_json_node_t *node = 0;
2872 ls_name = format (0, "%s", mp->ls_name);
2873 vec_add1 (ls_name, 0);
2875 if (VAT_JSON_ARRAY != vam->json_tree.type)
2877 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2878 vat_json_init_array (&vam->json_tree);
2880 node = vat_json_array_add (&vam->json_tree);
2882 vat_json_init_object (node);
2883 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2884 vat_json_object_add_uint (node, "ls_index",
2885 clib_net_to_host_u32 (mp->ls_index));
2893 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2896 unformat_nsh_address (unformat_input_t * input, va_list * args)
2898 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2899 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2903 format_nsh_address_vat (u8 * s, va_list * args)
2905 nsh_t *a = va_arg (*args, nsh_t *);
2906 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2910 format_lisp_flat_eid (u8 * s, va_list * args)
2912 u32 type = va_arg (*args, u32);
2913 u8 *eid = va_arg (*args, u8 *);
2914 u32 eid_len = va_arg (*args, u32);
2919 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2921 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2923 return format (s, "%U", format_ethernet_address, eid);
2925 return format (s, "%U", format_nsh_address_vat, eid);
2931 format_lisp_eid_vat (u8 * s, va_list * args)
2933 u32 type = va_arg (*args, u32);
2934 u8 *eid = va_arg (*args, u8 *);
2935 u32 eid_len = va_arg (*args, u32);
2936 u8 *seid = va_arg (*args, u8 *);
2937 u32 seid_len = va_arg (*args, u32);
2938 u32 is_src_dst = va_arg (*args, u32);
2941 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2943 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2949 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2951 vat_main_t *vam = &vat_main;
2952 u8 *s = 0, *eid = 0;
2954 if (~0 == mp->locator_set_index)
2955 s = format (0, "action: %d", mp->action);
2957 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2959 eid = format (0, "%U", format_lisp_eid_vat,
2963 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2966 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2967 clib_net_to_host_u32 (mp->vni),
2969 mp->is_local ? "local" : "remote",
2970 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2971 clib_net_to_host_u16 (mp->key_id), mp->key);
2978 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2981 vat_main_t *vam = &vat_main;
2982 vat_json_node_t *node = 0;
2985 if (VAT_JSON_ARRAY != vam->json_tree.type)
2987 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2988 vat_json_init_array (&vam->json_tree);
2990 node = vat_json_array_add (&vam->json_tree);
2992 vat_json_init_object (node);
2993 if (~0 == mp->locator_set_index)
2994 vat_json_object_add_uint (node, "action", mp->action);
2996 vat_json_object_add_uint (node, "locator_set_index",
2997 clib_net_to_host_u32 (mp->locator_set_index));
2999 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3000 if (mp->eid_type == 3)
3002 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3003 vat_json_init_object (nsh_json);
3004 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3005 vat_json_object_add_uint (nsh_json, "spi",
3006 clib_net_to_host_u32 (nsh->spi));
3007 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3011 eid = format (0, "%U", format_lisp_eid_vat,
3015 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3017 vat_json_object_add_string_copy (node, "eid", eid);
3020 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3021 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3022 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3026 vat_json_object_add_uint (node, "key_id",
3027 clib_net_to_host_u16 (mp->key_id));
3028 vat_json_object_add_string_copy (node, "key", mp->key);
3033 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3035 vat_main_t *vam = &vat_main;
3036 u8 *seid = 0, *deid = 0;
3037 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3039 deid = format (0, "%U", format_lisp_eid_vat,
3040 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3042 seid = format (0, "%U", format_lisp_eid_vat,
3043 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3049 format_ip_address_fcn = format_ip4_address;
3051 format_ip_address_fcn = format_ip6_address;
3054 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3055 clib_net_to_host_u32 (mp->vni),
3057 format_ip_address_fcn, mp->lloc,
3058 format_ip_address_fcn, mp->rloc,
3059 clib_net_to_host_u32 (mp->pkt_count),
3060 clib_net_to_host_u32 (mp->bytes));
3067 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3069 struct in6_addr ip6;
3071 vat_main_t *vam = &vat_main;
3072 vat_json_node_t *node = 0;
3073 u8 *deid = 0, *seid = 0;
3075 if (VAT_JSON_ARRAY != vam->json_tree.type)
3077 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3078 vat_json_init_array (&vam->json_tree);
3080 node = vat_json_array_add (&vam->json_tree);
3082 vat_json_init_object (node);
3083 deid = format (0, "%U", format_lisp_eid_vat,
3084 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3086 seid = format (0, "%U", format_lisp_eid_vat,
3087 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3092 vat_json_object_add_string_copy (node, "seid", seid);
3093 vat_json_object_add_string_copy (node, "deid", deid);
3094 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3098 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3099 vat_json_object_add_ip4 (node, "lloc", ip4);
3100 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3101 vat_json_object_add_ip4 (node, "rloc", ip4);
3105 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3106 vat_json_object_add_ip6 (node, "lloc", ip6);
3107 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3108 vat_json_object_add_ip6 (node, "rloc", ip6);
3110 vat_json_object_add_uint (node, "pkt_count",
3111 clib_net_to_host_u32 (mp->pkt_count));
3112 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3119 vl_api_one_eid_table_map_details_t_handler
3120 (vl_api_one_eid_table_map_details_t * mp)
3122 vat_main_t *vam = &vat_main;
3124 u8 *line = format (0, "%=10d%=10d",
3125 clib_net_to_host_u32 (mp->vni),
3126 clib_net_to_host_u32 (mp->dp_table));
3127 print (vam->ofp, "%v", line);
3132 vl_api_one_eid_table_map_details_t_handler_json
3133 (vl_api_one_eid_table_map_details_t * mp)
3135 vat_main_t *vam = &vat_main;
3136 vat_json_node_t *node = NULL;
3138 if (VAT_JSON_ARRAY != vam->json_tree.type)
3140 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3141 vat_json_init_array (&vam->json_tree);
3143 node = vat_json_array_add (&vam->json_tree);
3144 vat_json_init_object (node);
3145 vat_json_object_add_uint (node, "dp_table",
3146 clib_net_to_host_u32 (mp->dp_table));
3147 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3151 vl_api_one_eid_table_vni_details_t_handler
3152 (vl_api_one_eid_table_vni_details_t * mp)
3154 vat_main_t *vam = &vat_main;
3156 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3157 print (vam->ofp, "%v", line);
3162 vl_api_one_eid_table_vni_details_t_handler_json
3163 (vl_api_one_eid_table_vni_details_t * mp)
3165 vat_main_t *vam = &vat_main;
3166 vat_json_node_t *node = NULL;
3168 if (VAT_JSON_ARRAY != vam->json_tree.type)
3170 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3171 vat_json_init_array (&vam->json_tree);
3173 node = vat_json_array_add (&vam->json_tree);
3174 vat_json_init_object (node);
3175 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3179 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3180 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3182 vat_main_t *vam = &vat_main;
3183 int retval = clib_net_to_host_u32 (mp->retval);
3185 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3186 print (vam->ofp, "fallback threshold value: %d", mp->value);
3188 vam->retval = retval;
3189 vam->result_ready = 1;
3193 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3194 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3196 vat_main_t *vam = &vat_main;
3197 vat_json_node_t _node, *node = &_node;
3198 int retval = clib_net_to_host_u32 (mp->retval);
3200 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3201 vat_json_init_object (node);
3202 vat_json_object_add_uint (node, "value", mp->value);
3204 vat_json_print (vam->ofp, node);
3205 vat_json_free (node);
3207 vam->retval = retval;
3208 vam->result_ready = 1;
3212 vl_api_show_one_map_register_state_reply_t_handler
3213 (vl_api_show_one_map_register_state_reply_t * mp)
3215 vat_main_t *vam = &vat_main;
3216 int retval = clib_net_to_host_u32 (mp->retval);
3218 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3220 vam->retval = retval;
3221 vam->result_ready = 1;
3225 vl_api_show_one_map_register_state_reply_t_handler_json
3226 (vl_api_show_one_map_register_state_reply_t * mp)
3228 vat_main_t *vam = &vat_main;
3229 vat_json_node_t _node, *node = &_node;
3230 int retval = clib_net_to_host_u32 (mp->retval);
3232 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3234 vat_json_init_object (node);
3235 vat_json_object_add_string_copy (node, "state", s);
3237 vat_json_print (vam->ofp, node);
3238 vat_json_free (node);
3240 vam->retval = retval;
3241 vam->result_ready = 1;
3246 vl_api_show_one_rloc_probe_state_reply_t_handler
3247 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3249 vat_main_t *vam = &vat_main;
3250 int retval = clib_net_to_host_u32 (mp->retval);
3255 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3257 vam->retval = retval;
3258 vam->result_ready = 1;
3262 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3263 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3265 vat_main_t *vam = &vat_main;
3266 vat_json_node_t _node, *node = &_node;
3267 int retval = clib_net_to_host_u32 (mp->retval);
3269 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3270 vat_json_init_object (node);
3271 vat_json_object_add_string_copy (node, "state", s);
3273 vat_json_print (vam->ofp, node);
3274 vat_json_free (node);
3276 vam->retval = retval;
3277 vam->result_ready = 1;
3282 vl_api_show_one_stats_enable_disable_reply_t_handler
3283 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3285 vat_main_t *vam = &vat_main;
3286 int retval = clib_net_to_host_u32 (mp->retval);
3291 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3293 vam->retval = retval;
3294 vam->result_ready = 1;
3298 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3299 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3301 vat_main_t *vam = &vat_main;
3302 vat_json_node_t _node, *node = &_node;
3303 int retval = clib_net_to_host_u32 (mp->retval);
3305 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3306 vat_json_init_object (node);
3307 vat_json_object_add_string_copy (node, "state", s);
3309 vat_json_print (vam->ofp, node);
3310 vat_json_free (node);
3312 vam->retval = retval;
3313 vam->result_ready = 1;
3318 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3320 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3321 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3322 e->vni = clib_net_to_host_u32 (e->vni);
3326 gpe_fwd_entries_get_reply_t_net_to_host
3327 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3331 mp->count = clib_net_to_host_u32 (mp->count);
3332 for (i = 0; i < mp->count; i++)
3334 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3339 format_gpe_encap_mode (u8 * s, va_list * args)
3341 u32 mode = va_arg (*args, u32);
3346 return format (s, "lisp");
3348 return format (s, "vxlan");
3354 vl_api_gpe_get_encap_mode_reply_t_handler
3355 (vl_api_gpe_get_encap_mode_reply_t * mp)
3357 vat_main_t *vam = &vat_main;
3359 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3360 vam->retval = ntohl (mp->retval);
3361 vam->result_ready = 1;
3365 vl_api_gpe_get_encap_mode_reply_t_handler_json
3366 (vl_api_gpe_get_encap_mode_reply_t * mp)
3368 vat_main_t *vam = &vat_main;
3369 vat_json_node_t node;
3371 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3372 vec_add1 (encap_mode, 0);
3374 vat_json_init_object (&node);
3375 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3377 vec_free (encap_mode);
3378 vat_json_print (vam->ofp, &node);
3379 vat_json_free (&node);
3381 vam->retval = ntohl (mp->retval);
3382 vam->result_ready = 1;
3386 vl_api_gpe_fwd_entry_path_details_t_handler
3387 (vl_api_gpe_fwd_entry_path_details_t * mp)
3389 vat_main_t *vam = &vat_main;
3390 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3392 if (mp->lcl_loc.is_ip4)
3393 format_ip_address_fcn = format_ip4_address;
3395 format_ip_address_fcn = format_ip6_address;
3397 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3398 format_ip_address_fcn, &mp->lcl_loc,
3399 format_ip_address_fcn, &mp->rmt_loc);
3403 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3405 struct in6_addr ip6;
3410 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3411 vat_json_object_add_ip4 (n, "address", ip4);
3415 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3416 vat_json_object_add_ip6 (n, "address", ip6);
3418 vat_json_object_add_uint (n, "weight", loc->weight);
3422 vl_api_gpe_fwd_entry_path_details_t_handler_json
3423 (vl_api_gpe_fwd_entry_path_details_t * mp)
3425 vat_main_t *vam = &vat_main;
3426 vat_json_node_t *node = NULL;
3427 vat_json_node_t *loc_node;
3429 if (VAT_JSON_ARRAY != vam->json_tree.type)
3431 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3432 vat_json_init_array (&vam->json_tree);
3434 node = vat_json_array_add (&vam->json_tree);
3435 vat_json_init_object (node);
3437 loc_node = vat_json_object_add (node, "local_locator");
3438 vat_json_init_object (loc_node);
3439 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3441 loc_node = vat_json_object_add (node, "remote_locator");
3442 vat_json_init_object (loc_node);
3443 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3447 vl_api_gpe_fwd_entries_get_reply_t_handler
3448 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3450 vat_main_t *vam = &vat_main;
3452 int retval = clib_net_to_host_u32 (mp->retval);
3453 vl_api_gpe_fwd_entry_t *e;
3458 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3460 for (i = 0; i < mp->count; i++)
3462 e = &mp->entries[i];
3463 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3464 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3465 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3469 vam->retval = retval;
3470 vam->result_ready = 1;
3474 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3475 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3478 vat_main_t *vam = &vat_main;
3479 vat_json_node_t *e = 0, root;
3481 int retval = clib_net_to_host_u32 (mp->retval);
3482 vl_api_gpe_fwd_entry_t *fwd;
3487 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3488 vat_json_init_array (&root);
3490 for (i = 0; i < mp->count; i++)
3492 e = vat_json_array_add (&root);
3493 fwd = &mp->entries[i];
3495 vat_json_init_object (e);
3496 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3497 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3498 vat_json_object_add_int (e, "vni", fwd->vni);
3499 vat_json_object_add_int (e, "action", fwd->action);
3501 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3502 fwd->leid_prefix_len);
3504 vat_json_object_add_string_copy (e, "leid", s);
3507 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3508 fwd->reid_prefix_len);
3510 vat_json_object_add_string_copy (e, "reid", s);
3514 vat_json_print (vam->ofp, &root);
3515 vat_json_free (&root);
3518 vam->retval = retval;
3519 vam->result_ready = 1;
3523 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3524 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3526 vat_main_t *vam = &vat_main;
3528 int retval = clib_net_to_host_u32 (mp->retval);
3529 vl_api_gpe_native_fwd_rpath_t *r;
3534 n = clib_net_to_host_u32 (mp->count);
3536 for (i = 0; i < n; i++)
3538 r = &mp->entries[i];
3539 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3540 clib_net_to_host_u32 (r->fib_index),
3541 clib_net_to_host_u32 (r->nh_sw_if_index),
3542 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3546 vam->retval = retval;
3547 vam->result_ready = 1;
3551 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3552 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3554 vat_main_t *vam = &vat_main;
3555 vat_json_node_t root, *e;
3557 int retval = clib_net_to_host_u32 (mp->retval);
3558 vl_api_gpe_native_fwd_rpath_t *r;
3564 n = clib_net_to_host_u32 (mp->count);
3565 vat_json_init_array (&root);
3567 for (i = 0; i < n; i++)
3569 e = vat_json_array_add (&root);
3570 vat_json_init_object (e);
3571 r = &mp->entries[i];
3573 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3576 vat_json_object_add_string_copy (e, "ip4", s);
3579 vat_json_object_add_uint (e, "fib_index",
3580 clib_net_to_host_u32 (r->fib_index));
3581 vat_json_object_add_uint (e, "nh_sw_if_index",
3582 clib_net_to_host_u32 (r->nh_sw_if_index));
3585 vat_json_print (vam->ofp, &root);
3586 vat_json_free (&root);
3589 vam->retval = retval;
3590 vam->result_ready = 1;
3594 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3595 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3597 vat_main_t *vam = &vat_main;
3599 int retval = clib_net_to_host_u32 (mp->retval);
3604 n = clib_net_to_host_u32 (mp->count);
3606 for (i = 0; i < n; i++)
3607 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3610 vam->retval = retval;
3611 vam->result_ready = 1;
3615 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3616 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3618 vat_main_t *vam = &vat_main;
3619 vat_json_node_t root;
3621 int retval = clib_net_to_host_u32 (mp->retval);
3626 n = clib_net_to_host_u32 (mp->count);
3627 vat_json_init_array (&root);
3629 for (i = 0; i < n; i++)
3630 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3632 vat_json_print (vam->ofp, &root);
3633 vat_json_free (&root);
3636 vam->retval = retval;
3637 vam->result_ready = 1;
3641 vl_api_one_ndp_entries_get_reply_t_handler
3642 (vl_api_one_ndp_entries_get_reply_t * mp)
3644 vat_main_t *vam = &vat_main;
3646 int retval = clib_net_to_host_u32 (mp->retval);
3651 n = clib_net_to_host_u32 (mp->count);
3653 for (i = 0; i < n; i++)
3654 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3655 format_ethernet_address, mp->entries[i].mac);
3658 vam->retval = retval;
3659 vam->result_ready = 1;
3663 vl_api_one_ndp_entries_get_reply_t_handler_json
3664 (vl_api_one_ndp_entries_get_reply_t * mp)
3667 vat_main_t *vam = &vat_main;
3668 vat_json_node_t *e = 0, root;
3670 int retval = clib_net_to_host_u32 (mp->retval);
3671 vl_api_one_ndp_entry_t *arp_entry;
3676 n = clib_net_to_host_u32 (mp->count);
3677 vat_json_init_array (&root);
3679 for (i = 0; i < n; i++)
3681 e = vat_json_array_add (&root);
3682 arp_entry = &mp->entries[i];
3684 vat_json_init_object (e);
3685 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3688 vat_json_object_add_string_copy (e, "mac", s);
3691 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3693 vat_json_object_add_string_copy (e, "ip6", s);
3697 vat_json_print (vam->ofp, &root);
3698 vat_json_free (&root);
3701 vam->retval = retval;
3702 vam->result_ready = 1;
3706 vl_api_one_l2_arp_entries_get_reply_t_handler
3707 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3709 vat_main_t *vam = &vat_main;
3711 int retval = clib_net_to_host_u32 (mp->retval);
3716 n = clib_net_to_host_u32 (mp->count);
3718 for (i = 0; i < n; i++)
3719 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3720 format_ethernet_address, mp->entries[i].mac);
3723 vam->retval = retval;
3724 vam->result_ready = 1;
3728 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3729 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3732 vat_main_t *vam = &vat_main;
3733 vat_json_node_t *e = 0, root;
3735 int retval = clib_net_to_host_u32 (mp->retval);
3736 vl_api_one_l2_arp_entry_t *arp_entry;
3741 n = clib_net_to_host_u32 (mp->count);
3742 vat_json_init_array (&root);
3744 for (i = 0; i < n; i++)
3746 e = vat_json_array_add (&root);
3747 arp_entry = &mp->entries[i];
3749 vat_json_init_object (e);
3750 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3753 vat_json_object_add_string_copy (e, "mac", s);
3756 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3758 vat_json_object_add_string_copy (e, "ip4", s);
3762 vat_json_print (vam->ofp, &root);
3763 vat_json_free (&root);
3766 vam->retval = retval;
3767 vam->result_ready = 1;
3771 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3773 vat_main_t *vam = &vat_main;
3775 int retval = clib_net_to_host_u32 (mp->retval);
3780 n = clib_net_to_host_u32 (mp->count);
3782 for (i = 0; i < n; i++)
3784 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3788 vam->retval = retval;
3789 vam->result_ready = 1;
3793 vl_api_one_ndp_bd_get_reply_t_handler_json
3794 (vl_api_one_ndp_bd_get_reply_t * mp)
3796 vat_main_t *vam = &vat_main;
3797 vat_json_node_t root;
3799 int retval = clib_net_to_host_u32 (mp->retval);
3804 n = clib_net_to_host_u32 (mp->count);
3805 vat_json_init_array (&root);
3807 for (i = 0; i < n; i++)
3809 vat_json_array_add_uint (&root,
3810 clib_net_to_host_u32 (mp->bridge_domains[i]));
3813 vat_json_print (vam->ofp, &root);
3814 vat_json_free (&root);
3817 vam->retval = retval;
3818 vam->result_ready = 1;
3822 vl_api_one_l2_arp_bd_get_reply_t_handler
3823 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3825 vat_main_t *vam = &vat_main;
3827 int retval = clib_net_to_host_u32 (mp->retval);
3832 n = clib_net_to_host_u32 (mp->count);
3834 for (i = 0; i < n; i++)
3836 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3840 vam->retval = retval;
3841 vam->result_ready = 1;
3845 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3846 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3848 vat_main_t *vam = &vat_main;
3849 vat_json_node_t root;
3851 int retval = clib_net_to_host_u32 (mp->retval);
3856 n = clib_net_to_host_u32 (mp->count);
3857 vat_json_init_array (&root);
3859 for (i = 0; i < n; i++)
3861 vat_json_array_add_uint (&root,
3862 clib_net_to_host_u32 (mp->bridge_domains[i]));
3865 vat_json_print (vam->ofp, &root);
3866 vat_json_free (&root);
3869 vam->retval = retval;
3870 vam->result_ready = 1;
3874 vl_api_one_adjacencies_get_reply_t_handler
3875 (vl_api_one_adjacencies_get_reply_t * mp)
3877 vat_main_t *vam = &vat_main;
3879 int retval = clib_net_to_host_u32 (mp->retval);
3880 vl_api_one_adjacency_t *a;
3885 n = clib_net_to_host_u32 (mp->count);
3887 for (i = 0; i < n; i++)
3889 a = &mp->adjacencies[i];
3890 print (vam->ofp, "%U %40U",
3891 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3892 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3896 vam->retval = retval;
3897 vam->result_ready = 1;
3901 vl_api_one_adjacencies_get_reply_t_handler_json
3902 (vl_api_one_adjacencies_get_reply_t * mp)
3905 vat_main_t *vam = &vat_main;
3906 vat_json_node_t *e = 0, root;
3908 int retval = clib_net_to_host_u32 (mp->retval);
3909 vl_api_one_adjacency_t *a;
3914 n = clib_net_to_host_u32 (mp->count);
3915 vat_json_init_array (&root);
3917 for (i = 0; i < n; i++)
3919 e = vat_json_array_add (&root);
3920 a = &mp->adjacencies[i];
3922 vat_json_init_object (e);
3923 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3924 a->leid_prefix_len);
3926 vat_json_object_add_string_copy (e, "leid", s);
3929 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3930 a->reid_prefix_len);
3932 vat_json_object_add_string_copy (e, "reid", s);
3936 vat_json_print (vam->ofp, &root);
3937 vat_json_free (&root);
3940 vam->retval = retval;
3941 vam->result_ready = 1;
3945 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3947 vat_main_t *vam = &vat_main;
3949 print (vam->ofp, "%=20U",
3950 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3955 vl_api_one_map_server_details_t_handler_json
3956 (vl_api_one_map_server_details_t * mp)
3958 vat_main_t *vam = &vat_main;
3959 vat_json_node_t *node = NULL;
3960 struct in6_addr ip6;
3963 if (VAT_JSON_ARRAY != vam->json_tree.type)
3965 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3966 vat_json_init_array (&vam->json_tree);
3968 node = vat_json_array_add (&vam->json_tree);
3970 vat_json_init_object (node);
3973 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3974 vat_json_object_add_ip6 (node, "map-server", ip6);
3978 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3979 vat_json_object_add_ip4 (node, "map-server", ip4);
3984 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3987 vat_main_t *vam = &vat_main;
3989 print (vam->ofp, "%=20U",
3990 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3995 vl_api_one_map_resolver_details_t_handler_json
3996 (vl_api_one_map_resolver_details_t * mp)
3998 vat_main_t *vam = &vat_main;
3999 vat_json_node_t *node = NULL;
4000 struct in6_addr ip6;
4003 if (VAT_JSON_ARRAY != vam->json_tree.type)
4005 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4006 vat_json_init_array (&vam->json_tree);
4008 node = vat_json_array_add (&vam->json_tree);
4010 vat_json_init_object (node);
4013 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4014 vat_json_object_add_ip6 (node, "map resolver", ip6);
4018 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4019 vat_json_object_add_ip4 (node, "map resolver", ip4);
4024 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4026 vat_main_t *vam = &vat_main;
4027 i32 retval = ntohl (mp->retval);
4031 print (vam->ofp, "feature: %s\ngpe: %s",
4032 mp->feature_status ? "enabled" : "disabled",
4033 mp->gpe_status ? "enabled" : "disabled");
4036 vam->retval = retval;
4037 vam->result_ready = 1;
4041 vl_api_show_one_status_reply_t_handler_json
4042 (vl_api_show_one_status_reply_t * mp)
4044 vat_main_t *vam = &vat_main;
4045 vat_json_node_t node;
4046 u8 *gpe_status = NULL;
4047 u8 *feature_status = NULL;
4049 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4050 feature_status = format (0, "%s",
4051 mp->feature_status ? "enabled" : "disabled");
4052 vec_add1 (gpe_status, 0);
4053 vec_add1 (feature_status, 0);
4055 vat_json_init_object (&node);
4056 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4057 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4059 vec_free (gpe_status);
4060 vec_free (feature_status);
4062 vat_json_print (vam->ofp, &node);
4063 vat_json_free (&node);
4065 vam->retval = ntohl (mp->retval);
4066 vam->result_ready = 1;
4070 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4071 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4073 vat_main_t *vam = &vat_main;
4074 i32 retval = ntohl (mp->retval);
4078 print (vam->ofp, "%=20s", mp->locator_set_name);
4081 vam->retval = retval;
4082 vam->result_ready = 1;
4086 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4087 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4089 vat_main_t *vam = &vat_main;
4090 vat_json_node_t *node = NULL;
4092 if (VAT_JSON_ARRAY != vam->json_tree.type)
4094 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4095 vat_json_init_array (&vam->json_tree);
4097 node = vat_json_array_add (&vam->json_tree);
4099 vat_json_init_object (node);
4100 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4102 vat_json_print (vam->ofp, node);
4103 vat_json_free (node);
4105 vam->retval = ntohl (mp->retval);
4106 vam->result_ready = 1;
4110 format_lisp_map_request_mode (u8 * s, va_list * args)
4112 u32 mode = va_arg (*args, u32);
4117 return format (0, "dst-only");
4119 return format (0, "src-dst");
4125 vl_api_show_one_map_request_mode_reply_t_handler
4126 (vl_api_show_one_map_request_mode_reply_t * mp)
4128 vat_main_t *vam = &vat_main;
4129 i32 retval = ntohl (mp->retval);
4133 u32 mode = mp->mode;
4134 print (vam->ofp, "map_request_mode: %U",
4135 format_lisp_map_request_mode, mode);
4138 vam->retval = retval;
4139 vam->result_ready = 1;
4143 vl_api_show_one_map_request_mode_reply_t_handler_json
4144 (vl_api_show_one_map_request_mode_reply_t * mp)
4146 vat_main_t *vam = &vat_main;
4147 vat_json_node_t node;
4152 s = format (0, "%U", format_lisp_map_request_mode, mode);
4155 vat_json_init_object (&node);
4156 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4157 vat_json_print (vam->ofp, &node);
4158 vat_json_free (&node);
4161 vam->retval = ntohl (mp->retval);
4162 vam->result_ready = 1;
4166 vl_api_one_show_xtr_mode_reply_t_handler
4167 (vl_api_one_show_xtr_mode_reply_t * mp)
4169 vat_main_t *vam = &vat_main;
4170 i32 retval = ntohl (mp->retval);
4174 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4177 vam->retval = retval;
4178 vam->result_ready = 1;
4182 vl_api_one_show_xtr_mode_reply_t_handler_json
4183 (vl_api_one_show_xtr_mode_reply_t * mp)
4185 vat_main_t *vam = &vat_main;
4186 vat_json_node_t node;
4189 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4190 vec_add1 (status, 0);
4192 vat_json_init_object (&node);
4193 vat_json_object_add_string_copy (&node, "status", status);
4197 vat_json_print (vam->ofp, &node);
4198 vat_json_free (&node);
4200 vam->retval = ntohl (mp->retval);
4201 vam->result_ready = 1;
4205 vl_api_one_show_pitr_mode_reply_t_handler
4206 (vl_api_one_show_pitr_mode_reply_t * mp)
4208 vat_main_t *vam = &vat_main;
4209 i32 retval = ntohl (mp->retval);
4213 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4216 vam->retval = retval;
4217 vam->result_ready = 1;
4221 vl_api_one_show_pitr_mode_reply_t_handler_json
4222 (vl_api_one_show_pitr_mode_reply_t * mp)
4224 vat_main_t *vam = &vat_main;
4225 vat_json_node_t node;
4228 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4229 vec_add1 (status, 0);
4231 vat_json_init_object (&node);
4232 vat_json_object_add_string_copy (&node, "status", status);
4236 vat_json_print (vam->ofp, &node);
4237 vat_json_free (&node);
4239 vam->retval = ntohl (mp->retval);
4240 vam->result_ready = 1;
4244 vl_api_one_show_petr_mode_reply_t_handler
4245 (vl_api_one_show_petr_mode_reply_t * mp)
4247 vat_main_t *vam = &vat_main;
4248 i32 retval = ntohl (mp->retval);
4252 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4255 vam->retval = retval;
4256 vam->result_ready = 1;
4260 vl_api_one_show_petr_mode_reply_t_handler_json
4261 (vl_api_one_show_petr_mode_reply_t * mp)
4263 vat_main_t *vam = &vat_main;
4264 vat_json_node_t node;
4267 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4268 vec_add1 (status, 0);
4270 vat_json_init_object (&node);
4271 vat_json_object_add_string_copy (&node, "status", status);
4275 vat_json_print (vam->ofp, &node);
4276 vat_json_free (&node);
4278 vam->retval = ntohl (mp->retval);
4279 vam->result_ready = 1;
4283 vl_api_show_one_use_petr_reply_t_handler
4284 (vl_api_show_one_use_petr_reply_t * mp)
4286 vat_main_t *vam = &vat_main;
4287 i32 retval = ntohl (mp->retval);
4291 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4294 print (vam->ofp, "Proxy-ETR address; %U",
4295 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4300 vam->retval = retval;
4301 vam->result_ready = 1;
4305 vl_api_show_one_use_petr_reply_t_handler_json
4306 (vl_api_show_one_use_petr_reply_t * mp)
4308 vat_main_t *vam = &vat_main;
4309 vat_json_node_t node;
4312 struct in6_addr ip6;
4314 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4315 vec_add1 (status, 0);
4317 vat_json_init_object (&node);
4318 vat_json_object_add_string_copy (&node, "status", status);
4323 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4324 vat_json_object_add_ip6 (&node, "address", ip6);
4328 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4329 vat_json_object_add_ip4 (&node, "address", ip4);
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_show_one_nsh_mapping_reply_t_handler
4344 (vl_api_show_one_nsh_mapping_reply_t * mp)
4346 vat_main_t *vam = &vat_main;
4347 i32 retval = ntohl (mp->retval);
4351 print (vam->ofp, "%-20s%-16s",
4352 mp->is_set ? "set" : "not-set",
4353 mp->is_set ? (char *) mp->locator_set_name : "");
4356 vam->retval = retval;
4357 vam->result_ready = 1;
4361 vl_api_show_one_nsh_mapping_reply_t_handler_json
4362 (vl_api_show_one_nsh_mapping_reply_t * mp)
4364 vat_main_t *vam = &vat_main;
4365 vat_json_node_t node;
4368 status = format (0, "%s", mp->is_set ? "yes" : "no");
4369 vec_add1 (status, 0);
4371 vat_json_init_object (&node);
4372 vat_json_object_add_string_copy (&node, "is_set", status);
4375 vat_json_object_add_string_copy (&node, "locator_set",
4376 mp->locator_set_name);
4381 vat_json_print (vam->ofp, &node);
4382 vat_json_free (&node);
4384 vam->retval = ntohl (mp->retval);
4385 vam->result_ready = 1;
4389 vl_api_show_one_map_register_ttl_reply_t_handler
4390 (vl_api_show_one_map_register_ttl_reply_t * mp)
4392 vat_main_t *vam = &vat_main;
4393 i32 retval = ntohl (mp->retval);
4395 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4399 print (vam->ofp, "ttl: %u", mp->ttl);
4402 vam->retval = retval;
4403 vam->result_ready = 1;
4407 vl_api_show_one_map_register_ttl_reply_t_handler_json
4408 (vl_api_show_one_map_register_ttl_reply_t * mp)
4410 vat_main_t *vam = &vat_main;
4411 vat_json_node_t node;
4413 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4414 vat_json_init_object (&node);
4415 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4417 vat_json_print (vam->ofp, &node);
4418 vat_json_free (&node);
4420 vam->retval = ntohl (mp->retval);
4421 vam->result_ready = 1;
4425 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4427 vat_main_t *vam = &vat_main;
4428 i32 retval = ntohl (mp->retval);
4432 print (vam->ofp, "%-20s%-16s",
4433 mp->status ? "enabled" : "disabled",
4434 mp->status ? (char *) mp->locator_set_name : "");
4437 vam->retval = retval;
4438 vam->result_ready = 1;
4442 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4444 vat_main_t *vam = &vat_main;
4445 vat_json_node_t node;
4448 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4449 vec_add1 (status, 0);
4451 vat_json_init_object (&node);
4452 vat_json_object_add_string_copy (&node, "status", status);
4455 vat_json_object_add_string_copy (&node, "locator_set",
4456 mp->locator_set_name);
4461 vat_json_print (vam->ofp, &node);
4462 vat_json_free (&node);
4464 vam->retval = ntohl (mp->retval);
4465 vam->result_ready = 1;
4469 format_policer_type (u8 * s, va_list * va)
4471 u32 i = va_arg (*va, u32);
4473 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4474 s = format (s, "1r2c");
4475 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4476 s = format (s, "1r3c");
4477 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4478 s = format (s, "2r3c-2698");
4479 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4480 s = format (s, "2r3c-4115");
4481 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4482 s = format (s, "2r3c-mef5cf1");
4484 s = format (s, "ILLEGAL");
4489 format_policer_rate_type (u8 * s, va_list * va)
4491 u32 i = va_arg (*va, u32);
4493 if (i == SSE2_QOS_RATE_KBPS)
4494 s = format (s, "kbps");
4495 else if (i == SSE2_QOS_RATE_PPS)
4496 s = format (s, "pps");
4498 s = format (s, "ILLEGAL");
4503 format_policer_round_type (u8 * s, va_list * va)
4505 u32 i = va_arg (*va, u32);
4507 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4508 s = format (s, "closest");
4509 else if (i == SSE2_QOS_ROUND_TO_UP)
4510 s = format (s, "up");
4511 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4512 s = format (s, "down");
4514 s = format (s, "ILLEGAL");
4519 format_policer_action_type (u8 * s, va_list * va)
4521 u32 i = va_arg (*va, u32);
4523 if (i == SSE2_QOS_ACTION_DROP)
4524 s = format (s, "drop");
4525 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4526 s = format (s, "transmit");
4527 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4528 s = format (s, "mark-and-transmit");
4530 s = format (s, "ILLEGAL");
4535 format_dscp (u8 * s, va_list * va)
4537 u32 i = va_arg (*va, u32);
4542 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4546 return format (s, "ILLEGAL");
4548 s = format (s, "%s", t);
4553 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4555 vat_main_t *vam = &vat_main;
4556 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4558 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4559 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
4561 conform_dscp_str = format (0, "");
4563 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4564 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
4566 exceed_dscp_str = format (0, "");
4568 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4569 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
4571 violate_dscp_str = format (0, "");
4573 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4574 "rate type %U, round type %U, %s rate, %s color-aware, "
4575 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4576 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4577 "conform action %U%s, exceed action %U%s, violate action %U%s",
4579 format_policer_type, mp->type,
4582 clib_net_to_host_u64 (mp->cb),
4583 clib_net_to_host_u64 (mp->eb),
4584 format_policer_rate_type, mp->rate_type,
4585 format_policer_round_type, mp->round_type,
4586 mp->single_rate ? "single" : "dual",
4587 mp->color_aware ? "is" : "not",
4588 ntohl (mp->cir_tokens_per_period),
4589 ntohl (mp->pir_tokens_per_period),
4591 ntohl (mp->current_limit),
4592 ntohl (mp->current_bucket),
4593 ntohl (mp->extended_limit),
4594 ntohl (mp->extended_bucket),
4595 clib_net_to_host_u64 (mp->last_update_time),
4596 format_policer_action_type, mp->conform_action.type,
4598 format_policer_action_type, mp->exceed_action.type,
4600 format_policer_action_type, mp->violate_action.type,
4603 vec_free (conform_dscp_str);
4604 vec_free (exceed_dscp_str);
4605 vec_free (violate_dscp_str);
4608 static void vl_api_policer_details_t_handler_json
4609 (vl_api_policer_details_t * mp)
4611 vat_main_t *vam = &vat_main;
4612 vat_json_node_t *node;
4613 u8 *rate_type_str, *round_type_str, *type_str;
4614 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4616 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4618 format (0, "%U", format_policer_round_type, mp->round_type);
4619 type_str = format (0, "%U", format_policer_type, mp->type);
4620 conform_action_str = format (0, "%U", format_policer_action_type,
4621 mp->conform_action.type);
4622 exceed_action_str = format (0, "%U", format_policer_action_type,
4623 mp->exceed_action.type);
4624 violate_action_str = format (0, "%U", format_policer_action_type,
4625 mp->violate_action.type);
4627 if (VAT_JSON_ARRAY != vam->json_tree.type)
4629 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4630 vat_json_init_array (&vam->json_tree);
4632 node = vat_json_array_add (&vam->json_tree);
4634 vat_json_init_object (node);
4635 vat_json_object_add_string_copy (node, "name", mp->name);
4636 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4637 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4638 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4639 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4640 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4641 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4642 vat_json_object_add_string_copy (node, "type", type_str);
4643 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4644 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4645 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4646 vat_json_object_add_uint (node, "cir_tokens_per_period",
4647 ntohl (mp->cir_tokens_per_period));
4648 vat_json_object_add_uint (node, "eir_tokens_per_period",
4649 ntohl (mp->pir_tokens_per_period));
4650 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4651 vat_json_object_add_uint (node, "current_bucket",
4652 ntohl (mp->current_bucket));
4653 vat_json_object_add_uint (node, "extended_limit",
4654 ntohl (mp->extended_limit));
4655 vat_json_object_add_uint (node, "extended_bucket",
4656 ntohl (mp->extended_bucket));
4657 vat_json_object_add_uint (node, "last_update_time",
4658 ntohl (mp->last_update_time));
4659 vat_json_object_add_string_copy (node, "conform_action",
4660 conform_action_str);
4661 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4663 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
4664 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4665 vec_free (dscp_str);
4667 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4668 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4670 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
4671 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4672 vec_free (dscp_str);
4674 vat_json_object_add_string_copy (node, "violate_action",
4675 violate_action_str);
4676 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4678 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
4679 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4680 vec_free (dscp_str);
4683 vec_free (rate_type_str);
4684 vec_free (round_type_str);
4685 vec_free (type_str);
4686 vec_free (conform_action_str);
4687 vec_free (exceed_action_str);
4688 vec_free (violate_action_str);
4692 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4695 vat_main_t *vam = &vat_main;
4696 int i, count = ntohl (mp->count);
4699 print (vam->ofp, "classify table ids (%d) : ", count);
4700 for (i = 0; i < count; i++)
4702 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4703 print (vam->ofp, (i < count - 1) ? "," : "");
4705 vam->retval = ntohl (mp->retval);
4706 vam->result_ready = 1;
4710 vl_api_classify_table_ids_reply_t_handler_json
4711 (vl_api_classify_table_ids_reply_t * mp)
4713 vat_main_t *vam = &vat_main;
4714 int i, count = ntohl (mp->count);
4718 vat_json_node_t node;
4720 vat_json_init_object (&node);
4721 for (i = 0; i < count; i++)
4723 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4725 vat_json_print (vam->ofp, &node);
4726 vat_json_free (&node);
4728 vam->retval = ntohl (mp->retval);
4729 vam->result_ready = 1;
4733 vl_api_classify_table_by_interface_reply_t_handler
4734 (vl_api_classify_table_by_interface_reply_t * mp)
4736 vat_main_t *vam = &vat_main;
4739 table_id = ntohl (mp->l2_table_id);
4741 print (vam->ofp, "l2 table id : %d", table_id);
4743 print (vam->ofp, "l2 table id : No input ACL tables configured");
4744 table_id = ntohl (mp->ip4_table_id);
4746 print (vam->ofp, "ip4 table id : %d", table_id);
4748 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4749 table_id = ntohl (mp->ip6_table_id);
4751 print (vam->ofp, "ip6 table id : %d", table_id);
4753 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4754 vam->retval = ntohl (mp->retval);
4755 vam->result_ready = 1;
4759 vl_api_classify_table_by_interface_reply_t_handler_json
4760 (vl_api_classify_table_by_interface_reply_t * mp)
4762 vat_main_t *vam = &vat_main;
4763 vat_json_node_t node;
4765 vat_json_init_object (&node);
4767 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4768 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4769 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4771 vat_json_print (vam->ofp, &node);
4772 vat_json_free (&node);
4774 vam->retval = ntohl (mp->retval);
4775 vam->result_ready = 1;
4778 static void vl_api_policer_add_del_reply_t_handler
4779 (vl_api_policer_add_del_reply_t * mp)
4781 vat_main_t *vam = &vat_main;
4782 i32 retval = ntohl (mp->retval);
4783 if (vam->async_mode)
4785 vam->async_errors += (retval < 0);
4789 vam->retval = retval;
4790 vam->result_ready = 1;
4791 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4793 * Note: this is just barely thread-safe, depends on
4794 * the main thread spinning waiting for an answer...
4796 errmsg ("policer index %d", ntohl (mp->policer_index));
4800 static void vl_api_policer_add_del_reply_t_handler_json
4801 (vl_api_policer_add_del_reply_t * mp)
4803 vat_main_t *vam = &vat_main;
4804 vat_json_node_t node;
4806 vat_json_init_object (&node);
4807 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4808 vat_json_object_add_uint (&node, "policer_index",
4809 ntohl (mp->policer_index));
4811 vat_json_print (vam->ofp, &node);
4812 vat_json_free (&node);
4814 vam->retval = ntohl (mp->retval);
4815 vam->result_ready = 1;
4818 /* Format hex dump. */
4820 format_hex_bytes (u8 * s, va_list * va)
4822 u8 *bytes = va_arg (*va, u8 *);
4823 int n_bytes = va_arg (*va, int);
4826 /* Print short or long form depending on byte count. */
4827 uword short_form = n_bytes <= 32;
4828 u32 indent = format_get_indent (s);
4833 for (i = 0; i < n_bytes; i++)
4835 if (!short_form && (i % 32) == 0)
4836 s = format (s, "%08x: ", i);
4837 s = format (s, "%02x", bytes[i]);
4838 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4839 s = format (s, "\n%U", format_white_space, indent);
4846 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4849 vat_main_t *vam = &vat_main;
4850 i32 retval = ntohl (mp->retval);
4853 print (vam->ofp, "classify table info :");
4854 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4855 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4856 ntohl (mp->miss_next_index));
4857 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4858 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4859 ntohl (mp->match_n_vectors));
4860 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4861 ntohl (mp->mask_length));
4863 vam->retval = retval;
4864 vam->result_ready = 1;
4868 vl_api_classify_table_info_reply_t_handler_json
4869 (vl_api_classify_table_info_reply_t * mp)
4871 vat_main_t *vam = &vat_main;
4872 vat_json_node_t node;
4874 i32 retval = ntohl (mp->retval);
4877 vat_json_init_object (&node);
4879 vat_json_object_add_int (&node, "sessions",
4880 ntohl (mp->active_sessions));
4881 vat_json_object_add_int (&node, "nexttbl",
4882 ntohl (mp->next_table_index));
4883 vat_json_object_add_int (&node, "nextnode",
4884 ntohl (mp->miss_next_index));
4885 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4886 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4887 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4888 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4889 ntohl (mp->mask_length), 0);
4890 vat_json_object_add_string_copy (&node, "mask", s);
4892 vat_json_print (vam->ofp, &node);
4893 vat_json_free (&node);
4895 vam->retval = ntohl (mp->retval);
4896 vam->result_ready = 1;
4900 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4903 vat_main_t *vam = &vat_main;
4905 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4906 ntohl (mp->hit_next_index), ntohl (mp->advance),
4907 ntohl (mp->opaque_index));
4908 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4909 ntohl (mp->match_length));
4913 vl_api_classify_session_details_t_handler_json
4914 (vl_api_classify_session_details_t * mp)
4916 vat_main_t *vam = &vat_main;
4917 vat_json_node_t *node = NULL;
4919 if (VAT_JSON_ARRAY != vam->json_tree.type)
4921 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4922 vat_json_init_array (&vam->json_tree);
4924 node = vat_json_array_add (&vam->json_tree);
4926 vat_json_init_object (node);
4927 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4928 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4929 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4931 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4933 vat_json_object_add_string_copy (node, "match", s);
4936 static void vl_api_pg_create_interface_reply_t_handler
4937 (vl_api_pg_create_interface_reply_t * mp)
4939 vat_main_t *vam = &vat_main;
4941 vam->retval = ntohl (mp->retval);
4942 vam->result_ready = 1;
4945 static void vl_api_pg_create_interface_reply_t_handler_json
4946 (vl_api_pg_create_interface_reply_t * mp)
4948 vat_main_t *vam = &vat_main;
4949 vat_json_node_t node;
4951 i32 retval = ntohl (mp->retval);
4954 vat_json_init_object (&node);
4956 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4958 vat_json_print (vam->ofp, &node);
4959 vat_json_free (&node);
4961 vam->retval = ntohl (mp->retval);
4962 vam->result_ready = 1;
4965 static void vl_api_policer_classify_details_t_handler
4966 (vl_api_policer_classify_details_t * mp)
4968 vat_main_t *vam = &vat_main;
4970 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4971 ntohl (mp->table_index));
4974 static void vl_api_policer_classify_details_t_handler_json
4975 (vl_api_policer_classify_details_t * mp)
4977 vat_main_t *vam = &vat_main;
4978 vat_json_node_t *node;
4980 if (VAT_JSON_ARRAY != vam->json_tree.type)
4982 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4983 vat_json_init_array (&vam->json_tree);
4985 node = vat_json_array_add (&vam->json_tree);
4987 vat_json_init_object (node);
4988 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4989 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4992 static void vl_api_flow_classify_details_t_handler
4993 (vl_api_flow_classify_details_t * mp)
4995 vat_main_t *vam = &vat_main;
4997 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4998 ntohl (mp->table_index));
5001 static void vl_api_flow_classify_details_t_handler_json
5002 (vl_api_flow_classify_details_t * mp)
5004 vat_main_t *vam = &vat_main;
5005 vat_json_node_t *node;
5007 if (VAT_JSON_ARRAY != vam->json_tree.type)
5009 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5010 vat_json_init_array (&vam->json_tree);
5012 node = vat_json_array_add (&vam->json_tree);
5014 vat_json_init_object (node);
5015 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5016 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5019 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5020 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5021 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5022 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5023 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5024 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5025 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5026 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5027 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5028 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5031 * Generate boilerplate reply handlers, which
5032 * dig the return value out of the xxx_reply_t API message,
5033 * stick it into vam->retval, and set vam->result_ready
5035 * Could also do this by pointing N message decode slots at
5036 * a single function, but that could break in subtle ways.
5039 #define foreach_standard_reply_retval_handler \
5040 _(sw_interface_set_flags_reply) \
5041 _(sw_interface_add_del_address_reply) \
5042 _(sw_interface_set_rx_mode_reply) \
5043 _(sw_interface_set_rx_placement_reply) \
5044 _(sw_interface_set_table_reply) \
5045 _(sw_interface_set_mpls_enable_reply) \
5046 _(sw_interface_set_vpath_reply) \
5047 _(sw_interface_set_vxlan_bypass_reply) \
5048 _(sw_interface_set_geneve_bypass_reply) \
5049 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5050 _(sw_interface_set_l2_bridge_reply) \
5051 _(sw_interface_set_bond_weight_reply) \
5052 _(bridge_domain_add_del_reply) \
5053 _(sw_interface_set_l2_xconnect_reply) \
5054 _(l2fib_add_del_reply) \
5055 _(l2fib_flush_int_reply) \
5056 _(l2fib_flush_bd_reply) \
5057 _(ip_route_add_del_reply) \
5058 _(ip_table_add_del_reply) \
5059 _(ip_table_replace_begin_reply) \
5060 _(ip_table_flush_reply) \
5061 _(ip_table_replace_end_reply) \
5062 _(ip_mroute_add_del_reply) \
5063 _(mpls_route_add_del_reply) \
5064 _(mpls_table_add_del_reply) \
5065 _(mpls_ip_bind_unbind_reply) \
5066 _(bier_route_add_del_reply) \
5067 _(bier_table_add_del_reply) \
5068 _(sw_interface_set_unnumbered_reply) \
5069 _(set_ip_flow_hash_reply) \
5070 _(sw_interface_ip6_enable_disable_reply) \
5071 _(l2_patch_add_del_reply) \
5072 _(sr_mpls_policy_add_reply) \
5073 _(sr_mpls_policy_mod_reply) \
5074 _(sr_mpls_policy_del_reply) \
5075 _(sr_policy_add_reply) \
5076 _(sr_policy_mod_reply) \
5077 _(sr_policy_del_reply) \
5078 _(sr_localsid_add_del_reply) \
5079 _(sr_steering_add_del_reply) \
5080 _(classify_add_del_session_reply) \
5081 _(classify_set_interface_ip_table_reply) \
5082 _(classify_set_interface_l2_tables_reply) \
5083 _(l2tpv3_set_tunnel_cookies_reply) \
5084 _(l2tpv3_interface_enable_disable_reply) \
5085 _(l2tpv3_set_lookup_key_reply) \
5086 _(l2_fib_clear_table_reply) \
5087 _(l2_interface_efp_filter_reply) \
5088 _(l2_interface_vlan_tag_rewrite_reply) \
5089 _(modify_vhost_user_if_reply) \
5090 _(delete_vhost_user_if_reply) \
5091 _(want_l2_macs_events_reply) \
5092 _(input_acl_set_interface_reply) \
5093 _(ipsec_spd_add_del_reply) \
5094 _(ipsec_interface_add_del_spd_reply) \
5095 _(ipsec_spd_entry_add_del_reply) \
5096 _(ipsec_sad_entry_add_del_reply) \
5097 _(ipsec_tunnel_if_add_del_reply) \
5098 _(ipsec_tunnel_if_set_sa_reply) \
5099 _(delete_loopback_reply) \
5100 _(bd_ip_mac_add_del_reply) \
5101 _(bd_ip_mac_flush_reply) \
5102 _(want_interface_events_reply) \
5103 _(cop_interface_enable_disable_reply) \
5104 _(cop_whitelist_enable_disable_reply) \
5105 _(sw_interface_clear_stats_reply) \
5106 _(ioam_enable_reply) \
5107 _(ioam_disable_reply) \
5108 _(one_add_del_locator_reply) \
5109 _(one_add_del_local_eid_reply) \
5110 _(one_add_del_remote_mapping_reply) \
5111 _(one_add_del_adjacency_reply) \
5112 _(one_add_del_map_resolver_reply) \
5113 _(one_add_del_map_server_reply) \
5114 _(one_enable_disable_reply) \
5115 _(one_rloc_probe_enable_disable_reply) \
5116 _(one_map_register_enable_disable_reply) \
5117 _(one_map_register_set_ttl_reply) \
5118 _(one_set_transport_protocol_reply) \
5119 _(one_map_register_fallback_threshold_reply) \
5120 _(one_pitr_set_locator_set_reply) \
5121 _(one_map_request_mode_reply) \
5122 _(one_add_del_map_request_itr_rlocs_reply) \
5123 _(one_eid_table_add_del_map_reply) \
5124 _(one_use_petr_reply) \
5125 _(one_stats_enable_disable_reply) \
5126 _(one_add_del_l2_arp_entry_reply) \
5127 _(one_add_del_ndp_entry_reply) \
5128 _(one_stats_flush_reply) \
5129 _(one_enable_disable_xtr_mode_reply) \
5130 _(one_enable_disable_pitr_mode_reply) \
5131 _(one_enable_disable_petr_mode_reply) \
5132 _(gpe_enable_disable_reply) \
5133 _(gpe_set_encap_mode_reply) \
5134 _(gpe_add_del_iface_reply) \
5135 _(gpe_add_del_native_fwd_rpath_reply) \
5136 _(af_packet_delete_reply) \
5137 _(policer_classify_set_interface_reply) \
5138 _(set_ipfix_exporter_reply) \
5139 _(set_ipfix_classify_stream_reply) \
5140 _(ipfix_classify_table_add_del_reply) \
5141 _(flow_classify_set_interface_reply) \
5142 _(sw_interface_span_enable_disable_reply) \
5143 _(pg_capture_reply) \
5144 _(pg_enable_disable_reply) \
5145 _(ip_source_and_port_range_check_add_del_reply) \
5146 _(ip_source_and_port_range_check_interface_add_del_reply)\
5147 _(delete_subif_reply) \
5148 _(l2_interface_pbb_tag_rewrite_reply) \
5150 _(feature_enable_disable_reply) \
5151 _(feature_gso_enable_disable_reply) \
5152 _(sw_interface_tag_add_del_reply) \
5153 _(sw_interface_add_del_mac_address_reply) \
5154 _(hw_interface_set_mtu_reply) \
5155 _(p2p_ethernet_add_reply) \
5156 _(p2p_ethernet_del_reply) \
5157 _(lldp_config_reply) \
5158 _(sw_interface_set_lldp_reply) \
5159 _(tcp_configure_src_addresses_reply) \
5160 _(session_rule_add_del_reply) \
5161 _(ip_container_proxy_add_del_reply) \
5162 _(output_acl_set_interface_reply) \
5163 _(qos_record_enable_disable_reply)
5166 static void vl_api_##n##_t_handler \
5167 (vl_api_##n##_t * mp) \
5169 vat_main_t * vam = &vat_main; \
5170 i32 retval = ntohl(mp->retval); \
5171 if (vam->async_mode) { \
5172 vam->async_errors += (retval < 0); \
5174 vam->retval = retval; \
5175 vam->result_ready = 1; \
5178 foreach_standard_reply_retval_handler;
5182 static void vl_api_##n##_t_handler_json \
5183 (vl_api_##n##_t * mp) \
5185 vat_main_t * vam = &vat_main; \
5186 vat_json_node_t node; \
5187 vat_json_init_object(&node); \
5188 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5189 vat_json_print(vam->ofp, &node); \
5190 vam->retval = ntohl(mp->retval); \
5191 vam->result_ready = 1; \
5193 foreach_standard_reply_retval_handler;
5197 * Table of message reply handlers, must include boilerplate handlers
5201 #define foreach_vpe_api_reply_msg \
5202 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5203 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5204 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5205 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5206 _(CONTROL_PING_REPLY, control_ping_reply) \
5207 _(CLI_REPLY, cli_reply) \
5208 _(CLI_INBAND_REPLY, cli_inband_reply) \
5209 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5210 sw_interface_add_del_address_reply) \
5211 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5212 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5213 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5214 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5215 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5216 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5217 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5218 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5219 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5220 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5221 sw_interface_set_l2_xconnect_reply) \
5222 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5223 sw_interface_set_l2_bridge_reply) \
5224 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5225 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5226 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5227 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5228 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5229 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5230 _(L2_FLAGS_REPLY, l2_flags_reply) \
5231 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5232 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5233 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5234 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5235 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5236 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5237 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5238 _(BOND_CREATE_REPLY, bond_create_reply) \
5239 _(BOND_DELETE_REPLY, bond_delete_reply) \
5240 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5241 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5242 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5243 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5244 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5245 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5246 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5247 _(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
5248 _(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
5249 _(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_reply) \
5250 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5251 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5252 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5253 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5254 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5255 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5256 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5257 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5258 sw_interface_set_unnumbered_reply) \
5259 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5260 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5261 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5262 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5263 sw_interface_ip6_enable_disable_reply) \
5264 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5265 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5266 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5267 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5268 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5269 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5270 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5271 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5272 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5273 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5274 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5275 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5276 classify_set_interface_ip_table_reply) \
5277 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5278 classify_set_interface_l2_tables_reply) \
5279 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5280 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5281 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5282 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5283 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5284 l2tpv3_interface_enable_disable_reply) \
5285 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5286 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5287 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5288 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5289 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5290 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5291 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5292 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5293 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5294 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5295 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5296 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5297 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5298 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5299 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5300 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5301 _(SHOW_VERSION_REPLY, show_version_reply) \
5302 _(SHOW_THREADS_REPLY, show_threads_reply) \
5303 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5304 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5305 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5306 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5307 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5308 _(L2_MACS_EVENT, l2_macs_event) \
5309 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5310 _(IP_ADDRESS_DETAILS, ip_address_details) \
5311 _(IP_DETAILS, ip_details) \
5312 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5313 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5314 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5315 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5316 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5317 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5318 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5319 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5320 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5321 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5322 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5323 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5324 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5325 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5326 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5327 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5328 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5329 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5330 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5331 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5332 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5333 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5334 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5335 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5336 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5337 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5338 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5339 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5340 one_map_register_enable_disable_reply) \
5341 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5342 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5343 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5344 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5345 one_map_register_fallback_threshold_reply) \
5346 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5347 one_rloc_probe_enable_disable_reply) \
5348 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5349 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5350 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5351 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5352 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5353 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5354 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5355 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5356 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5357 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5358 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5359 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5360 _(ONE_STATS_DETAILS, one_stats_details) \
5361 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5362 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5363 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5364 show_one_stats_enable_disable_reply) \
5365 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5366 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5367 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5368 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5369 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5370 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5371 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5372 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5373 one_enable_disable_pitr_mode_reply) \
5374 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5375 one_enable_disable_petr_mode_reply) \
5376 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5377 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5378 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5379 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5380 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5381 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5382 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5383 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5384 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5385 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5386 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5387 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5388 gpe_add_del_native_fwd_rpath_reply) \
5389 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5390 gpe_fwd_entry_path_details) \
5391 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5392 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5393 one_add_del_map_request_itr_rlocs_reply) \
5394 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5395 one_get_map_request_itr_rlocs_reply) \
5396 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5397 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5398 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5399 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5400 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5401 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5402 show_one_map_register_state_reply) \
5403 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5404 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5405 show_one_map_register_fallback_threshold_reply) \
5406 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5407 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5408 _(AF_PACKET_DETAILS, af_packet_details) \
5409 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5410 _(POLICER_DETAILS, policer_details) \
5411 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5412 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5413 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5414 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5415 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5416 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5417 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5418 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5419 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5420 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5421 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5422 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5423 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5424 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5425 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5426 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5427 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5428 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5429 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5430 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5431 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5432 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5433 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5434 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5435 ip_source_and_port_range_check_add_del_reply) \
5436 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5437 ip_source_and_port_range_check_interface_add_del_reply) \
5438 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5439 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5440 _(SET_PUNT_REPLY, set_punt_reply) \
5441 _(IP_TABLE_DETAILS, ip_table_details) \
5442 _(IP_ROUTE_DETAILS, ip_route_details) \
5443 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5444 _(FEATURE_GSO_ENABLE_DISABLE_REPLY, feature_gso_enable_disable_reply) \
5445 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5446 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
5447 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5448 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5449 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5450 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5451 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5452 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5453 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5454 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5455 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5456 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5457 _(SESSION_RULES_DETAILS, session_rules_details) \
5458 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5459 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5460 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5462 #define foreach_standalone_reply_msg \
5463 _(SW_INTERFACE_EVENT, sw_interface_event)
5471 #define STR_VTR_OP_CASE(op) \
5472 case L2_VTR_ ## op: \
5476 str_vtr_op (u32 vtr_op)
5480 STR_VTR_OP_CASE (DISABLED);
5481 STR_VTR_OP_CASE (PUSH_1);
5482 STR_VTR_OP_CASE (PUSH_2);
5483 STR_VTR_OP_CASE (POP_1);
5484 STR_VTR_OP_CASE (POP_2);
5485 STR_VTR_OP_CASE (TRANSLATE_1_1);
5486 STR_VTR_OP_CASE (TRANSLATE_1_2);
5487 STR_VTR_OP_CASE (TRANSLATE_2_1);
5488 STR_VTR_OP_CASE (TRANSLATE_2_2);
5495 dump_sub_interface_table (vat_main_t * vam)
5497 const sw_interface_subif_t *sub = NULL;
5499 if (vam->json_output)
5502 ("JSON output supported only for VPE API calls and dump_stats_table");
5507 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5508 "Interface", "sw_if_index",
5509 "sub id", "dot1ad", "tags", "outer id",
5510 "inner id", "exact", "default", "outer any", "inner any");
5512 vec_foreach (sub, vam->sw_if_subif_table)
5515 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5516 sub->interface_name,
5518 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5519 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5520 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5521 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5522 if (sub->vtr_op != L2_VTR_DISABLED)
5525 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5526 "tag1: %d tag2: %d ]",
5527 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5528 sub->vtr_tag1, sub->vtr_tag2);
5536 name_sort_cmp (void *a1, void *a2)
5538 name_sort_t *n1 = a1;
5539 name_sort_t *n2 = a2;
5541 return strcmp ((char *) n1->name, (char *) n2->name);
5545 dump_interface_table (vat_main_t * vam)
5548 name_sort_t *nses = 0, *ns;
5550 if (vam->json_output)
5553 ("JSON output supported only for VPE API calls and dump_stats_table");
5558 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5560 vec_add2 (nses, ns, 1);
5561 ns->name = (u8 *)(p->key);
5562 ns->value = (u32) p->value[0];
5566 vec_sort_with_function (nses, name_sort_cmp);
5568 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5569 vec_foreach (ns, nses)
5571 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5578 dump_ip_table (vat_main_t * vam, int is_ipv6)
5580 const ip_details_t *det = NULL;
5581 const ip_address_details_t *address = NULL;
5584 print (vam->ofp, "%-12s", "sw_if_index");
5586 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5593 print (vam->ofp, "%-12d", i);
5594 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5599 vec_foreach (address, det->addr)
5603 is_ipv6 ? format_ip6_address : format_ip4_address,
5604 address->ip, address->prefix_length);
5612 dump_ipv4_table (vat_main_t * vam)
5614 if (vam->json_output)
5617 ("JSON output supported only for VPE API calls and dump_stats_table");
5621 return dump_ip_table (vam, 0);
5625 dump_ipv6_table (vat_main_t * vam)
5627 if (vam->json_output)
5630 ("JSON output supported only for VPE API calls and dump_stats_table");
5634 return dump_ip_table (vam, 1);
5638 * Pass CLI buffers directly in the CLI_INBAND API message,
5639 * instead of an additional shared memory area.
5642 exec_inband (vat_main_t * vam)
5644 vl_api_cli_inband_t *mp;
5645 unformat_input_t *i = vam->input;
5648 if (vec_len (i->buffer) == 0)
5651 if (vam->exec_mode == 0 && unformat (i, "mode"))
5656 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5663 * In order for the CLI command to work, it
5664 * must be a vector ending in \n, not a C-string ending
5667 M2 (CLI_INBAND, mp, vec_len (vam->input->buffer));
5668 vl_api_vec_to_api_string (vam->input->buffer, &mp->cmd);
5672 /* json responses may or may not include a useful reply... */
5673 if (vec_len (vam->cmd_reply))
5674 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5679 exec (vat_main_t * vam)
5681 return exec_inband (vam);
5685 api_create_loopback (vat_main_t * vam)
5687 unformat_input_t *i = vam->input;
5688 vl_api_create_loopback_t *mp;
5689 vl_api_create_loopback_instance_t *mp_lbi;
5692 u8 is_specified = 0;
5693 u32 user_instance = 0;
5696 clib_memset (mac_address, 0, sizeof (mac_address));
5698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5700 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5702 if (unformat (i, "instance %d", &user_instance))
5710 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5711 mp_lbi->is_specified = is_specified;
5713 mp_lbi->user_instance = htonl (user_instance);
5715 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5720 /* Construct the API message */
5721 M (CREATE_LOOPBACK, mp);
5723 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5732 api_delete_loopback (vat_main_t * vam)
5734 unformat_input_t *i = vam->input;
5735 vl_api_delete_loopback_t *mp;
5736 u32 sw_if_index = ~0;
5739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5741 if (unformat (i, "sw_if_index %d", &sw_if_index))
5747 if (sw_if_index == ~0)
5749 errmsg ("missing sw_if_index");
5753 /* Construct the API message */
5754 M (DELETE_LOOPBACK, mp);
5755 mp->sw_if_index = ntohl (sw_if_index);
5763 api_want_interface_events (vat_main_t * vam)
5765 unformat_input_t *i = vam->input;
5766 vl_api_want_interface_events_t *mp;
5770 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5772 if (unformat (i, "enable"))
5774 else if (unformat (i, "disable"))
5782 errmsg ("missing enable|disable");
5786 M (WANT_INTERFACE_EVENTS, mp);
5787 mp->enable_disable = enable;
5789 vam->interface_event_display = enable;
5797 /* Note: non-static, called once to set up the initial intfc table */
5799 api_sw_interface_dump (vat_main_t * vam)
5801 vl_api_sw_interface_dump_t *mp;
5802 vl_api_control_ping_t *mp_ping;
5804 name_sort_t *nses = 0, *ns;
5805 sw_interface_subif_t *sub = NULL;
5808 /* Toss the old name table */
5810 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5812 vec_add2 (nses, ns, 1);
5813 ns->name = (u8 *)(p->key);
5814 ns->value = (u32) p->value[0];
5818 hash_free (vam->sw_if_index_by_interface_name);
5820 vec_foreach (ns, nses) vec_free (ns->name);
5824 vec_foreach (sub, vam->sw_if_subif_table)
5826 vec_free (sub->interface_name);
5828 vec_free (vam->sw_if_subif_table);
5830 /* recreate the interface name hash table */
5831 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5834 * Ask for all interface names. Otherwise, the epic catalog of
5835 * name filters becomes ridiculously long, and vat ends up needing
5836 * to be taught about new interface types.
5838 M (SW_INTERFACE_DUMP, mp);
5841 /* Use a control ping for synchronization */
5842 MPING (CONTROL_PING, mp_ping);
5850 api_sw_interface_set_flags (vat_main_t * vam)
5852 unformat_input_t *i = vam->input;
5853 vl_api_sw_interface_set_flags_t *mp;
5855 u8 sw_if_index_set = 0;
5859 /* Parse args required to build the message */
5860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5862 if (unformat (i, "admin-up"))
5864 else if (unformat (i, "admin-down"))
5867 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5868 sw_if_index_set = 1;
5869 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5870 sw_if_index_set = 1;
5875 if (sw_if_index_set == 0)
5877 errmsg ("missing interface name or sw_if_index");
5881 /* Construct the API message */
5882 M (SW_INTERFACE_SET_FLAGS, mp);
5883 mp->sw_if_index = ntohl (sw_if_index);
5884 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5889 /* Wait for a reply, return the good/bad news... */
5895 api_sw_interface_set_rx_mode (vat_main_t * vam)
5897 unformat_input_t *i = vam->input;
5898 vl_api_sw_interface_set_rx_mode_t *mp;
5900 u8 sw_if_index_set = 0;
5902 u8 queue_id_valid = 0;
5904 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5906 /* Parse args required to build the message */
5907 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5909 if (unformat (i, "queue %d", &queue_id))
5911 else if (unformat (i, "polling"))
5912 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5913 else if (unformat (i, "interrupt"))
5914 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5915 else if (unformat (i, "adaptive"))
5916 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5918 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5919 sw_if_index_set = 1;
5920 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5921 sw_if_index_set = 1;
5926 if (sw_if_index_set == 0)
5928 errmsg ("missing interface name or sw_if_index");
5931 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
5933 errmsg ("missing rx-mode");
5937 /* Construct the API message */
5938 M (SW_INTERFACE_SET_RX_MODE, mp);
5939 mp->sw_if_index = ntohl (sw_if_index);
5940 mp->mode = (vl_api_rx_mode_t) mode;
5941 mp->queue_id_valid = queue_id_valid;
5942 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
5947 /* Wait for a reply, return the good/bad news... */
5953 api_sw_interface_set_rx_placement (vat_main_t * vam)
5955 unformat_input_t *i = vam->input;
5956 vl_api_sw_interface_set_rx_placement_t *mp;
5958 u8 sw_if_index_set = 0;
5961 u32 queue_id, thread_index;
5963 /* Parse args required to build the message */
5964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5966 if (unformat (i, "queue %d", &queue_id))
5968 else if (unformat (i, "main"))
5970 else if (unformat (i, "worker %d", &thread_index))
5973 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5974 sw_if_index_set = 1;
5975 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5976 sw_if_index_set = 1;
5981 if (sw_if_index_set == 0)
5983 errmsg ("missing interface name or sw_if_index");
5989 /* Construct the API message */
5990 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
5991 mp->sw_if_index = ntohl (sw_if_index);
5992 mp->worker_id = ntohl (thread_index);
5993 mp->queue_id = ntohl (queue_id);
5994 mp->is_main = is_main;
5998 /* Wait for a reply, return the good/bad news... */
6003 static void vl_api_sw_interface_rx_placement_details_t_handler
6004 (vl_api_sw_interface_rx_placement_details_t * mp)
6006 vat_main_t *vam = &vat_main;
6007 u32 worker_id = ntohl (mp->worker_id);
6010 "\n%-11d %-11s %-6d %-5d %-9s",
6011 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6012 worker_id, ntohl (mp->queue_id),
6014 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6017 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6018 (vl_api_sw_interface_rx_placement_details_t * mp)
6020 vat_main_t *vam = &vat_main;
6021 vat_json_node_t *node = NULL;
6023 if (VAT_JSON_ARRAY != vam->json_tree.type)
6025 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6026 vat_json_init_array (&vam->json_tree);
6028 node = vat_json_array_add (&vam->json_tree);
6030 vat_json_init_object (node);
6031 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6032 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6033 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6034 vat_json_object_add_uint (node, "mode", mp->mode);
6038 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6040 unformat_input_t *i = vam->input;
6041 vl_api_sw_interface_rx_placement_dump_t *mp;
6042 vl_api_control_ping_t *mp_ping;
6045 u8 sw_if_index_set = 0;
6047 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6049 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6051 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6058 "\n%-11s %-11s %-6s %-5s %-4s",
6059 "sw_if_index", "main/worker", "thread", "queue", "mode");
6061 /* Dump Interface rx placement */
6062 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6064 if (sw_if_index_set)
6065 mp->sw_if_index = htonl (sw_if_index);
6067 mp->sw_if_index = ~0;
6071 /* Use a control ping for synchronization */
6072 MPING (CONTROL_PING, mp_ping);
6080 api_sw_interface_clear_stats (vat_main_t * vam)
6082 unformat_input_t *i = vam->input;
6083 vl_api_sw_interface_clear_stats_t *mp;
6085 u8 sw_if_index_set = 0;
6088 /* Parse args required to build the message */
6089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6091 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6092 sw_if_index_set = 1;
6093 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6094 sw_if_index_set = 1;
6099 /* Construct the API message */
6100 M (SW_INTERFACE_CLEAR_STATS, mp);
6102 if (sw_if_index_set == 1)
6103 mp->sw_if_index = ntohl (sw_if_index);
6105 mp->sw_if_index = ~0;
6110 /* Wait for a reply, return the good/bad news... */
6116 api_sw_interface_add_del_address (vat_main_t * vam)
6118 unformat_input_t *i = vam->input;
6119 vl_api_sw_interface_add_del_address_t *mp;
6121 u8 sw_if_index_set = 0;
6122 u8 is_add = 1, del_all = 0;
6123 u32 address_length = 0;
6124 u8 v4_address_set = 0;
6125 u8 v6_address_set = 0;
6126 ip4_address_t v4address;
6127 ip6_address_t v6address;
6130 /* Parse args required to build the message */
6131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6133 if (unformat (i, "del-all"))
6135 else if (unformat (i, "del"))
6138 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6139 sw_if_index_set = 1;
6140 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6141 sw_if_index_set = 1;
6142 else if (unformat (i, "%U/%d",
6143 unformat_ip4_address, &v4address, &address_length))
6145 else if (unformat (i, "%U/%d",
6146 unformat_ip6_address, &v6address, &address_length))
6152 if (sw_if_index_set == 0)
6154 errmsg ("missing interface name or sw_if_index");
6157 if (v4_address_set && v6_address_set)
6159 errmsg ("both v4 and v6 addresses set");
6162 if (!v4_address_set && !v6_address_set && !del_all)
6164 errmsg ("no addresses set");
6168 /* Construct the API message */
6169 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6171 mp->sw_if_index = ntohl (sw_if_index);
6172 mp->is_add = is_add;
6173 mp->del_all = del_all;
6176 mp->prefix.address.af = ADDRESS_IP6;
6177 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6181 mp->prefix.address.af = ADDRESS_IP4;
6182 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6184 mp->prefix.len = address_length;
6189 /* Wait for a reply, return good/bad news */
6195 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6197 unformat_input_t *i = vam->input;
6198 vl_api_sw_interface_set_mpls_enable_t *mp;
6200 u8 sw_if_index_set = 0;
6204 /* Parse args required to build the message */
6205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6207 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6208 sw_if_index_set = 1;
6209 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6210 sw_if_index_set = 1;
6211 else if (unformat (i, "disable"))
6213 else if (unformat (i, "dis"))
6219 if (sw_if_index_set == 0)
6221 errmsg ("missing interface name or sw_if_index");
6225 /* Construct the API message */
6226 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6228 mp->sw_if_index = ntohl (sw_if_index);
6229 mp->enable = enable;
6234 /* Wait for a reply... */
6240 api_sw_interface_set_table (vat_main_t * vam)
6242 unformat_input_t *i = vam->input;
6243 vl_api_sw_interface_set_table_t *mp;
6244 u32 sw_if_index, vrf_id = 0;
6245 u8 sw_if_index_set = 0;
6249 /* Parse args required to build the message */
6250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6252 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6253 sw_if_index_set = 1;
6254 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6255 sw_if_index_set = 1;
6256 else if (unformat (i, "vrf %d", &vrf_id))
6258 else if (unformat (i, "ipv6"))
6264 if (sw_if_index_set == 0)
6266 errmsg ("missing interface name or sw_if_index");
6270 /* Construct the API message */
6271 M (SW_INTERFACE_SET_TABLE, mp);
6273 mp->sw_if_index = ntohl (sw_if_index);
6274 mp->is_ipv6 = is_ipv6;
6275 mp->vrf_id = ntohl (vrf_id);
6280 /* Wait for a reply... */
6285 static void vl_api_sw_interface_get_table_reply_t_handler
6286 (vl_api_sw_interface_get_table_reply_t * mp)
6288 vat_main_t *vam = &vat_main;
6290 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6292 vam->retval = ntohl (mp->retval);
6293 vam->result_ready = 1;
6297 static void vl_api_sw_interface_get_table_reply_t_handler_json
6298 (vl_api_sw_interface_get_table_reply_t * mp)
6300 vat_main_t *vam = &vat_main;
6301 vat_json_node_t node;
6303 vat_json_init_object (&node);
6304 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6305 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6307 vat_json_print (vam->ofp, &node);
6308 vat_json_free (&node);
6310 vam->retval = ntohl (mp->retval);
6311 vam->result_ready = 1;
6315 api_sw_interface_get_table (vat_main_t * vam)
6317 unformat_input_t *i = vam->input;
6318 vl_api_sw_interface_get_table_t *mp;
6320 u8 sw_if_index_set = 0;
6324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6326 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6327 sw_if_index_set = 1;
6328 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6329 sw_if_index_set = 1;
6330 else if (unformat (i, "ipv6"))
6336 if (sw_if_index_set == 0)
6338 errmsg ("missing interface name or sw_if_index");
6342 M (SW_INTERFACE_GET_TABLE, mp);
6343 mp->sw_if_index = htonl (sw_if_index);
6344 mp->is_ipv6 = is_ipv6;
6352 api_sw_interface_set_vpath (vat_main_t * vam)
6354 unformat_input_t *i = vam->input;
6355 vl_api_sw_interface_set_vpath_t *mp;
6356 u32 sw_if_index = 0;
6357 u8 sw_if_index_set = 0;
6361 /* Parse args required to build the message */
6362 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6364 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6365 sw_if_index_set = 1;
6366 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6367 sw_if_index_set = 1;
6368 else if (unformat (i, "enable"))
6370 else if (unformat (i, "disable"))
6376 if (sw_if_index_set == 0)
6378 errmsg ("missing interface name or sw_if_index");
6382 /* Construct the API message */
6383 M (SW_INTERFACE_SET_VPATH, mp);
6385 mp->sw_if_index = ntohl (sw_if_index);
6386 mp->enable = is_enable;
6391 /* Wait for a reply... */
6397 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6399 unformat_input_t *i = vam->input;
6400 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6401 u32 sw_if_index = 0;
6402 u8 sw_if_index_set = 0;
6407 /* Parse args required to build the message */
6408 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6410 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6411 sw_if_index_set = 1;
6412 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6413 sw_if_index_set = 1;
6414 else if (unformat (i, "enable"))
6416 else if (unformat (i, "disable"))
6418 else if (unformat (i, "ip4"))
6420 else if (unformat (i, "ip6"))
6426 if (sw_if_index_set == 0)
6428 errmsg ("missing interface name or sw_if_index");
6432 /* Construct the API message */
6433 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6435 mp->sw_if_index = ntohl (sw_if_index);
6436 mp->enable = is_enable;
6437 mp->is_ipv6 = is_ipv6;
6442 /* Wait for a reply... */
6448 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6450 unformat_input_t *i = vam->input;
6451 vl_api_sw_interface_set_geneve_bypass_t *mp;
6452 u32 sw_if_index = 0;
6453 u8 sw_if_index_set = 0;
6458 /* Parse args required to build the message */
6459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6461 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6462 sw_if_index_set = 1;
6463 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6464 sw_if_index_set = 1;
6465 else if (unformat (i, "enable"))
6467 else if (unformat (i, "disable"))
6469 else if (unformat (i, "ip4"))
6471 else if (unformat (i, "ip6"))
6477 if (sw_if_index_set == 0)
6479 errmsg ("missing interface name or sw_if_index");
6483 /* Construct the API message */
6484 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6486 mp->sw_if_index = ntohl (sw_if_index);
6487 mp->enable = is_enable;
6488 mp->is_ipv6 = is_ipv6;
6493 /* Wait for a reply... */
6499 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6501 unformat_input_t *i = vam->input;
6502 vl_api_sw_interface_set_l2_xconnect_t *mp;
6504 u8 rx_sw_if_index_set = 0;
6506 u8 tx_sw_if_index_set = 0;
6510 /* Parse args required to build the message */
6511 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6513 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6514 rx_sw_if_index_set = 1;
6515 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6516 tx_sw_if_index_set = 1;
6517 else if (unformat (i, "rx"))
6519 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6521 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6523 rx_sw_if_index_set = 1;
6528 else if (unformat (i, "tx"))
6530 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6532 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6534 tx_sw_if_index_set = 1;
6539 else if (unformat (i, "enable"))
6541 else if (unformat (i, "disable"))
6547 if (rx_sw_if_index_set == 0)
6549 errmsg ("missing rx interface name or rx_sw_if_index");
6553 if (enable && (tx_sw_if_index_set == 0))
6555 errmsg ("missing tx interface name or tx_sw_if_index");
6559 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6561 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6562 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6563 mp->enable = enable;
6571 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6573 unformat_input_t *i = vam->input;
6574 vl_api_sw_interface_set_l2_bridge_t *mp;
6575 vl_api_l2_port_type_t port_type;
6577 u8 rx_sw_if_index_set = 0;
6584 port_type = L2_API_PORT_TYPE_NORMAL;
6586 /* Parse args required to build the message */
6587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6589 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6590 rx_sw_if_index_set = 1;
6591 else if (unformat (i, "bd_id %d", &bd_id))
6595 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6596 rx_sw_if_index_set = 1;
6597 else if (unformat (i, "shg %d", &shg))
6599 else if (unformat (i, "bvi"))
6600 port_type = L2_API_PORT_TYPE_BVI;
6601 else if (unformat (i, "uu-fwd"))
6602 port_type = L2_API_PORT_TYPE_UU_FWD;
6603 else if (unformat (i, "enable"))
6605 else if (unformat (i, "disable"))
6611 if (rx_sw_if_index_set == 0)
6613 errmsg ("missing rx interface name or sw_if_index");
6617 if (enable && (bd_id_set == 0))
6619 errmsg ("missing bridge domain");
6623 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6625 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6626 mp->bd_id = ntohl (bd_id);
6628 mp->port_type = ntohl (port_type);
6629 mp->enable = enable;
6637 api_bridge_domain_dump (vat_main_t * vam)
6639 unformat_input_t *i = vam->input;
6640 vl_api_bridge_domain_dump_t *mp;
6641 vl_api_control_ping_t *mp_ping;
6645 /* Parse args required to build the message */
6646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6648 if (unformat (i, "bd_id %d", &bd_id))
6654 M (BRIDGE_DOMAIN_DUMP, mp);
6655 mp->bd_id = ntohl (bd_id);
6658 /* Use a control ping for synchronization */
6659 MPING (CONTROL_PING, mp_ping);
6667 api_bridge_domain_add_del (vat_main_t * vam)
6669 unformat_input_t *i = vam->input;
6670 vl_api_bridge_domain_add_del_t *mp;
6673 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6678 /* Parse args required to build the message */
6679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6681 if (unformat (i, "bd_id %d", &bd_id))
6683 else if (unformat (i, "flood %d", &flood))
6685 else if (unformat (i, "uu-flood %d", &uu_flood))
6687 else if (unformat (i, "forward %d", &forward))
6689 else if (unformat (i, "learn %d", &learn))
6691 else if (unformat (i, "arp-term %d", &arp_term))
6693 else if (unformat (i, "mac-age %d", &mac_age))
6695 else if (unformat (i, "bd-tag %s", &bd_tag))
6697 else if (unformat (i, "del"))
6700 flood = uu_flood = forward = learn = 0;
6708 errmsg ("missing bridge domain");
6715 errmsg ("mac age must be less than 256 ");
6720 if ((bd_tag) && (vec_len (bd_tag) > 63))
6722 errmsg ("bd-tag cannot be longer than 63");
6727 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6729 mp->bd_id = ntohl (bd_id);
6731 mp->uu_flood = uu_flood;
6732 mp->forward = forward;
6734 mp->arp_term = arp_term;
6735 mp->is_add = is_add;
6736 mp->mac_age = (u8) mac_age;
6739 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6740 mp->bd_tag[vec_len (bd_tag)] = 0;
6751 api_l2fib_flush_bd (vat_main_t * vam)
6753 unformat_input_t *i = vam->input;
6754 vl_api_l2fib_flush_bd_t *mp;
6758 /* Parse args required to build the message */
6759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6761 if (unformat (i, "bd_id %d", &bd_id));
6768 errmsg ("missing bridge domain");
6772 M (L2FIB_FLUSH_BD, mp);
6774 mp->bd_id = htonl (bd_id);
6782 api_l2fib_flush_int (vat_main_t * vam)
6784 unformat_input_t *i = vam->input;
6785 vl_api_l2fib_flush_int_t *mp;
6786 u32 sw_if_index = ~0;
6789 /* Parse args required to build the message */
6790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6792 if (unformat (i, "sw_if_index %d", &sw_if_index));
6794 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6799 if (sw_if_index == ~0)
6801 errmsg ("missing interface name or sw_if_index");
6805 M (L2FIB_FLUSH_INT, mp);
6807 mp->sw_if_index = ntohl (sw_if_index);
6815 api_l2fib_add_del (vat_main_t * vam)
6817 unformat_input_t *i = vam->input;
6818 vl_api_l2fib_add_del_t *mp;
6824 u32 sw_if_index = 0;
6825 u8 sw_if_index_set = 0;
6834 /* Parse args required to build the message */
6835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6837 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6839 else if (unformat (i, "bd_id %d", &bd_id))
6841 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6842 sw_if_index_set = 1;
6843 else if (unformat (i, "sw_if"))
6845 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6848 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6849 sw_if_index_set = 1;
6854 else if (unformat (i, "static"))
6856 else if (unformat (i, "filter"))
6861 else if (unformat (i, "bvi"))
6866 else if (unformat (i, "del"))
6868 else if (unformat (i, "count %d", &count))
6876 errmsg ("missing mac address");
6882 errmsg ("missing bridge domain");
6886 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6888 errmsg ("missing interface name or sw_if_index");
6894 /* Turn on async mode */
6895 vam->async_mode = 1;
6896 vam->async_errors = 0;
6897 before = vat_time_now (vam);
6900 for (j = 0; j < count; j++)
6902 M (L2FIB_ADD_DEL, mp);
6904 clib_memcpy (mp->mac, mac, 6);
6905 mp->bd_id = ntohl (bd_id);
6906 mp->is_add = is_add;
6907 mp->sw_if_index = ntohl (sw_if_index);
6911 mp->static_mac = static_mac;
6912 mp->filter_mac = filter_mac;
6913 mp->bvi_mac = bvi_mac;
6915 increment_mac_address (mac);
6922 vl_api_control_ping_t *mp_ping;
6925 /* Shut off async mode */
6926 vam->async_mode = 0;
6928 MPING (CONTROL_PING, mp_ping);
6931 timeout = vat_time_now (vam) + 1.0;
6932 while (vat_time_now (vam) < timeout)
6933 if (vam->result_ready == 1)
6938 if (vam->retval == -99)
6941 if (vam->async_errors > 0)
6943 errmsg ("%d asynchronous errors", vam->async_errors);
6946 vam->async_errors = 0;
6947 after = vat_time_now (vam);
6949 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6950 count, after - before, count / (after - before));
6956 /* Wait for a reply... */
6960 /* Return the good/bad news */
6961 return (vam->retval);
6965 api_bridge_domain_set_mac_age (vat_main_t * vam)
6967 unformat_input_t *i = vam->input;
6968 vl_api_bridge_domain_set_mac_age_t *mp;
6973 /* Parse args required to build the message */
6974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6976 if (unformat (i, "bd_id %d", &bd_id));
6977 else if (unformat (i, "mac-age %d", &mac_age));
6984 errmsg ("missing bridge domain");
6990 errmsg ("mac age must be less than 256 ");
6994 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6996 mp->bd_id = htonl (bd_id);
6997 mp->mac_age = (u8) mac_age;
7005 api_l2_flags (vat_main_t * vam)
7007 unformat_input_t *i = vam->input;
7008 vl_api_l2_flags_t *mp;
7011 u8 sw_if_index_set = 0;
7015 /* Parse args required to build the message */
7016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7018 if (unformat (i, "sw_if_index %d", &sw_if_index))
7019 sw_if_index_set = 1;
7020 else if (unformat (i, "sw_if"))
7022 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7025 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7026 sw_if_index_set = 1;
7031 else if (unformat (i, "learn"))
7033 else if (unformat (i, "forward"))
7035 else if (unformat (i, "flood"))
7037 else if (unformat (i, "uu-flood"))
7038 flags |= L2_UU_FLOOD;
7039 else if (unformat (i, "arp-term"))
7040 flags |= L2_ARP_TERM;
7041 else if (unformat (i, "off"))
7043 else if (unformat (i, "disable"))
7049 if (sw_if_index_set == 0)
7051 errmsg ("missing interface name or sw_if_index");
7057 mp->sw_if_index = ntohl (sw_if_index);
7058 mp->feature_bitmap = ntohl (flags);
7059 mp->is_set = is_set;
7067 api_bridge_flags (vat_main_t * vam)
7069 unformat_input_t *i = vam->input;
7070 vl_api_bridge_flags_t *mp;
7074 bd_flags_t flags = 0;
7077 /* Parse args required to build the message */
7078 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7080 if (unformat (i, "bd_id %d", &bd_id))
7082 else if (unformat (i, "learn"))
7083 flags |= BRIDGE_API_FLAG_LEARN;
7084 else if (unformat (i, "forward"))
7085 flags |= BRIDGE_API_FLAG_FWD;
7086 else if (unformat (i, "flood"))
7087 flags |= BRIDGE_API_FLAG_FLOOD;
7088 else if (unformat (i, "uu-flood"))
7089 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7090 else if (unformat (i, "arp-term"))
7091 flags |= BRIDGE_API_FLAG_ARP_TERM;
7092 else if (unformat (i, "off"))
7094 else if (unformat (i, "disable"))
7102 errmsg ("missing bridge domain");
7106 M (BRIDGE_FLAGS, mp);
7108 mp->bd_id = ntohl (bd_id);
7109 mp->flags = ntohl (flags);
7110 mp->is_set = is_set;
7118 api_bd_ip_mac_add_del (vat_main_t * vam)
7120 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7121 vl_api_mac_address_t mac = { 0 };
7122 unformat_input_t *i = vam->input;
7123 vl_api_bd_ip_mac_add_del_t *mp;
7132 /* Parse args required to build the message */
7133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7135 if (unformat (i, "bd_id %d", &bd_id))
7139 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7143 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7147 else if (unformat (i, "del"))
7155 errmsg ("missing bridge domain");
7158 else if (ip_set == 0)
7160 errmsg ("missing IP address");
7163 else if (mac_set == 0)
7165 errmsg ("missing MAC address");
7169 M (BD_IP_MAC_ADD_DEL, mp);
7171 mp->entry.bd_id = ntohl (bd_id);
7172 mp->is_add = is_add;
7174 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7175 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7183 api_bd_ip_mac_flush (vat_main_t * vam)
7185 unformat_input_t *i = vam->input;
7186 vl_api_bd_ip_mac_flush_t *mp;
7191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7193 if (unformat (i, "bd_id %d", &bd_id))
7203 errmsg ("missing bridge domain");
7207 M (BD_IP_MAC_FLUSH, mp);
7209 mp->bd_id = ntohl (bd_id);
7216 static void vl_api_bd_ip_mac_details_t_handler
7217 (vl_api_bd_ip_mac_details_t * mp)
7219 vat_main_t *vam = &vat_main;
7223 ntohl (mp->entry.bd_id),
7224 format_vl_api_mac_address, mp->entry.mac,
7225 format_vl_api_address, &mp->entry.ip);
7228 static void vl_api_bd_ip_mac_details_t_handler_json
7229 (vl_api_bd_ip_mac_details_t * mp)
7231 vat_main_t *vam = &vat_main;
7232 vat_json_node_t *node = NULL;
7234 if (VAT_JSON_ARRAY != vam->json_tree.type)
7236 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7237 vat_json_init_array (&vam->json_tree);
7239 node = vat_json_array_add (&vam->json_tree);
7241 vat_json_init_object (node);
7242 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7243 vat_json_object_add_string_copy (node, "mac_address",
7244 format (0, "%U", format_vl_api_mac_address,
7248 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7249 vat_json_object_add_string_copy (node, "ip_address", ip);
7254 api_bd_ip_mac_dump (vat_main_t * vam)
7256 unformat_input_t *i = vam->input;
7257 vl_api_bd_ip_mac_dump_t *mp;
7258 vl_api_control_ping_t *mp_ping;
7263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7265 if (unformat (i, "bd_id %d", &bd_id))
7274 "\n%-5s %-7s %-20s %-30s",
7275 "bd_id", "is_ipv6", "mac_address", "ip_address");
7277 /* Dump Bridge Domain Ip to Mac entries */
7278 M (BD_IP_MAC_DUMP, mp);
7281 mp->bd_id = htonl (bd_id);
7287 /* Use a control ping for synchronization */
7288 MPING (CONTROL_PING, mp_ping);
7296 api_tap_create_v2 (vat_main_t * vam)
7298 unformat_input_t *i = vam->input;
7299 vl_api_tap_create_v2_t *mp;
7303 u32 num_rx_queues = 0;
7304 u8 *host_if_name = 0;
7305 u8 host_if_name_set = 0;
7308 u8 host_mac_addr[6];
7309 u8 host_mac_addr_set = 0;
7310 u8 *host_bridge = 0;
7311 u8 host_bridge_set = 0;
7312 u8 host_ip4_prefix_set = 0;
7313 u8 host_ip6_prefix_set = 0;
7314 ip4_address_t host_ip4_addr;
7315 ip4_address_t host_ip4_gw;
7316 u8 host_ip4_gw_set = 0;
7317 u32 host_ip4_prefix_len = 0;
7318 ip6_address_t host_ip6_addr;
7319 ip6_address_t host_ip6_gw;
7320 u8 host_ip6_gw_set = 0;
7321 u32 host_ip6_prefix_len = 0;
7322 u32 host_mtu_size = 0;
7323 u8 host_mtu_set = 0;
7326 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7328 clib_memset (mac_address, 0, sizeof (mac_address));
7330 /* Parse args required to build the message */
7331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7333 if (unformat (i, "id %u", &id))
7337 (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7339 else if (unformat (i, "host-if-name %s", &host_if_name))
7340 host_if_name_set = 1;
7341 else if (unformat (i, "num-rx-queues %u", &num_rx_queues))
7343 else if (unformat (i, "host-ns %s", &host_ns))
7345 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7347 host_mac_addr_set = 1;
7348 else if (unformat (i, "host-bridge %s", &host_bridge))
7349 host_bridge_set = 1;
7350 else if (unformat (i, "host-ip4-addr %U/%u", unformat_ip4_address,
7351 &host_ip4_addr, &host_ip4_prefix_len))
7352 host_ip4_prefix_set = 1;
7353 else if (unformat (i, "host-ip6-addr %U/%u", unformat_ip6_address,
7354 &host_ip6_addr, &host_ip6_prefix_len))
7355 host_ip6_prefix_set = 1;
7356 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7358 host_ip4_gw_set = 1;
7359 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7361 host_ip6_gw_set = 1;
7362 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
7364 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
7366 else if (unformat (i, "host-mtu-size %u", &host_mtu_size))
7368 else if (unformat (i, "no-gso"))
7369 tap_flags &= ~TAP_FLAG_GSO;
7370 else if (unformat (i, "gso"))
7371 tap_flags |= TAP_FLAG_GSO;
7372 else if (unformat (i, "csum-offload"))
7373 tap_flags |= TAP_FLAG_CSUM_OFFLOAD;
7374 else if (unformat (i, "persist"))
7375 tap_flags |= TAP_FLAG_PERSIST;
7376 else if (unformat (i, "attach"))
7377 tap_flags |= TAP_FLAG_ATTACH;
7382 if (vec_len (host_if_name) > 63)
7384 errmsg ("tap name too long. ");
7387 if (vec_len (host_ns) > 63)
7389 errmsg ("host name space too long. ");
7392 if (vec_len (host_bridge) > 63)
7394 errmsg ("host bridge name too long. ");
7397 if (host_ip4_prefix_len > 32)
7399 errmsg ("host ip4 prefix length not valid. ");
7402 if (host_ip6_prefix_len > 128)
7404 errmsg ("host ip6 prefix length not valid. ");
7407 if (!is_pow2 (rx_ring_sz))
7409 errmsg ("rx ring size must be power of 2. ");
7412 if (rx_ring_sz > 32768)
7414 errmsg ("rx ring size must be 32768 or lower. ");
7417 if (!is_pow2 (tx_ring_sz))
7419 errmsg ("tx ring size must be power of 2. ");
7422 if (tx_ring_sz > 32768)
7424 errmsg ("tx ring size must be 32768 or lower. ");
7427 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7429 errmsg ("host MTU size must be in between 64 and 65355. ");
7433 /* Construct the API message */
7434 M (TAP_CREATE_V2, mp);
7436 mp->id = ntohl (id);
7437 mp->use_random_mac = random_mac;
7438 mp->num_rx_queues = (u8) num_rx_queues;
7439 mp->tx_ring_sz = ntohs (tx_ring_sz);
7440 mp->rx_ring_sz = ntohs (rx_ring_sz);
7441 mp->host_mtu_set = host_mtu_set;
7442 mp->host_mtu_size = ntohl (host_mtu_size);
7443 mp->host_mac_addr_set = host_mac_addr_set;
7444 mp->host_ip4_prefix_set = host_ip4_prefix_set;
7445 mp->host_ip6_prefix_set = host_ip6_prefix_set;
7446 mp->host_ip4_gw_set = host_ip4_gw_set;
7447 mp->host_ip6_gw_set = host_ip6_gw_set;
7448 mp->tap_flags = ntohl (tap_flags);
7449 mp->host_namespace_set = host_ns_set;
7450 mp->host_if_name_set = host_if_name_set;
7451 mp->host_bridge_set = host_bridge_set;
7453 if (random_mac == 0)
7454 clib_memcpy (mp->mac_address, mac_address, 6);
7455 if (host_mac_addr_set)
7456 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7457 if (host_if_name_set)
7458 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7460 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7461 if (host_bridge_set)
7462 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7463 if (host_ip4_prefix_set)
7465 clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
7466 mp->host_ip4_prefix.len = (u8) host_ip4_prefix_len;
7468 if (host_ip6_prefix_set)
7470 clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
7471 mp->host_ip6_prefix.len = (u8) host_ip6_prefix_len;
7473 if (host_ip4_gw_set)
7474 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7475 if (host_ip6_gw_set)
7476 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7479 vec_free (host_if_name);
7480 vec_free (host_bridge);
7485 /* Wait for a reply... */
7491 api_tap_delete_v2 (vat_main_t * vam)
7493 unformat_input_t *i = vam->input;
7494 vl_api_tap_delete_v2_t *mp;
7495 u32 sw_if_index = ~0;
7496 u8 sw_if_index_set = 0;
7499 /* Parse args required to build the message */
7500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7502 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7503 sw_if_index_set = 1;
7504 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7505 sw_if_index_set = 1;
7510 if (sw_if_index_set == 0)
7512 errmsg ("missing vpp interface name. ");
7516 /* Construct the API message */
7517 M (TAP_DELETE_V2, mp);
7519 mp->sw_if_index = ntohl (sw_if_index);
7524 /* Wait for a reply... */
7530 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7532 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7535 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7538 addr->domain = x[0];
7541 addr->function = x[3];
7547 api_virtio_pci_create (vat_main_t * vam)
7549 unformat_input_t *i = vam->input;
7550 vl_api_virtio_pci_create_t *mp;
7554 u8 checksum_offload_enabled = 0;
7556 u64 features = (u64) ~ (0ULL);
7559 clib_memset (mac_address, 0, sizeof (mac_address));
7561 /* Parse args required to build the message */
7562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7564 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7568 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7570 else if (unformat (i, "features 0x%llx", &features))
7572 else if (unformat (i, "gso-enabled"))
7574 else if (unformat (i, "csum-offload-enabled"))
7575 checksum_offload_enabled = 1;
7582 errmsg ("pci address must be non zero. ");
7586 /* Construct the API message */
7587 M (VIRTIO_PCI_CREATE, mp);
7589 mp->use_random_mac = random_mac;
7591 mp->pci_addr.domain = htons (((vlib_pci_addr_t) pci_addr).domain);
7592 mp->pci_addr.bus = ((vlib_pci_addr_t) pci_addr).bus;
7593 mp->pci_addr.slot = ((vlib_pci_addr_t) pci_addr).slot;
7594 mp->pci_addr.function = ((vlib_pci_addr_t) pci_addr).function;
7596 mp->features = clib_host_to_net_u64 (features);
7597 mp->gso_enabled = gso_enabled;
7598 mp->checksum_offload_enabled = checksum_offload_enabled;
7600 if (random_mac == 0)
7601 clib_memcpy (mp->mac_address, mac_address, 6);
7606 /* Wait for a reply... */
7612 api_virtio_pci_delete (vat_main_t * vam)
7614 unformat_input_t *i = vam->input;
7615 vl_api_virtio_pci_delete_t *mp;
7616 u32 sw_if_index = ~0;
7617 u8 sw_if_index_set = 0;
7620 /* Parse args required to build the message */
7621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7623 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7624 sw_if_index_set = 1;
7625 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7626 sw_if_index_set = 1;
7631 if (sw_if_index_set == 0)
7633 errmsg ("missing vpp interface name. ");
7637 /* Construct the API message */
7638 M (VIRTIO_PCI_DELETE, mp);
7640 mp->sw_if_index = htonl (sw_if_index);
7645 /* Wait for a reply... */
7651 api_bond_create (vat_main_t * vam)
7653 unformat_input_t *i = vam->input;
7654 vl_api_bond_create_t *mp;
7664 clib_memset (mac_address, 0, sizeof (mac_address));
7667 /* Parse args required to build the message */
7668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7670 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7672 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7673 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7675 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7678 else if (unformat (i, "numa-only"))
7680 else if (unformat (i, "id %u", &id))
7686 if (mode_is_set == 0)
7688 errmsg ("Missing bond mode. ");
7692 /* Construct the API message */
7693 M (BOND_CREATE, mp);
7695 mp->use_custom_mac = custom_mac;
7697 mp->mode = htonl (mode);
7698 mp->lb = htonl (lb);
7699 mp->id = htonl (id);
7700 mp->numa_only = numa_only;
7703 clib_memcpy (mp->mac_address, mac_address, 6);
7708 /* Wait for a reply... */
7714 api_bond_delete (vat_main_t * vam)
7716 unformat_input_t *i = vam->input;
7717 vl_api_bond_delete_t *mp;
7718 u32 sw_if_index = ~0;
7719 u8 sw_if_index_set = 0;
7722 /* Parse args required to build the message */
7723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7725 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7726 sw_if_index_set = 1;
7727 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7728 sw_if_index_set = 1;
7733 if (sw_if_index_set == 0)
7735 errmsg ("missing vpp interface name. ");
7739 /* Construct the API message */
7740 M (BOND_DELETE, mp);
7742 mp->sw_if_index = ntohl (sw_if_index);
7747 /* Wait for a reply... */
7753 api_bond_enslave (vat_main_t * vam)
7755 unformat_input_t *i = vam->input;
7756 vl_api_bond_enslave_t *mp;
7757 u32 bond_sw_if_index;
7761 u32 bond_sw_if_index_is_set = 0;
7763 u8 sw_if_index_is_set = 0;
7765 /* Parse args required to build the message */
7766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7768 if (unformat (i, "sw_if_index %d", &sw_if_index))
7769 sw_if_index_is_set = 1;
7770 else if (unformat (i, "bond %u", &bond_sw_if_index))
7771 bond_sw_if_index_is_set = 1;
7772 else if (unformat (i, "passive %d", &is_passive))
7774 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7780 if (bond_sw_if_index_is_set == 0)
7782 errmsg ("Missing bond sw_if_index. ");
7785 if (sw_if_index_is_set == 0)
7787 errmsg ("Missing slave sw_if_index. ");
7791 /* Construct the API message */
7792 M (BOND_ENSLAVE, mp);
7794 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7795 mp->sw_if_index = ntohl (sw_if_index);
7796 mp->is_long_timeout = is_long_timeout;
7797 mp->is_passive = is_passive;
7802 /* Wait for a reply... */
7808 api_bond_detach_slave (vat_main_t * vam)
7810 unformat_input_t *i = vam->input;
7811 vl_api_bond_detach_slave_t *mp;
7812 u32 sw_if_index = ~0;
7813 u8 sw_if_index_set = 0;
7816 /* Parse args required to build the message */
7817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7819 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7820 sw_if_index_set = 1;
7821 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7822 sw_if_index_set = 1;
7827 if (sw_if_index_set == 0)
7829 errmsg ("missing vpp interface name. ");
7833 /* Construct the API message */
7834 M (BOND_DETACH_SLAVE, mp);
7836 mp->sw_if_index = ntohl (sw_if_index);
7841 /* Wait for a reply... */
7847 api_ip_table_add_del (vat_main_t * vam)
7849 unformat_input_t *i = vam->input;
7850 vl_api_ip_table_add_del_t *mp;
7856 /* Parse args required to build the message */
7857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7859 if (unformat (i, "ipv6"))
7861 else if (unformat (i, "del"))
7863 else if (unformat (i, "add"))
7865 else if (unformat (i, "table %d", &table_id))
7869 clib_warning ("parse error '%U'", format_unformat_error, i);
7876 errmsg ("missing table-ID");
7880 /* Construct the API message */
7881 M (IP_TABLE_ADD_DEL, mp);
7883 mp->table.table_id = ntohl (table_id);
7884 mp->table.is_ip6 = is_ipv6;
7885 mp->is_add = is_add;
7890 /* Wait for a reply... */
7897 unformat_fib_path (unformat_input_t * input, va_list * args)
7899 vat_main_t *vam = va_arg (*args, vat_main_t *);
7900 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7901 u32 weight, preference;
7902 mpls_label_t out_label;
7904 clib_memset (path, 0, sizeof (*path));
7906 path->sw_if_index = ~0;
7910 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7912 if (unformat (input, "%U %U",
7913 unformat_vl_api_ip4_address,
7914 &path->nh.address.ip4,
7915 api_unformat_sw_if_index, vam, &path->sw_if_index))
7917 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7919 else if (unformat (input, "%U %U",
7920 unformat_vl_api_ip6_address,
7921 &path->nh.address.ip6,
7922 api_unformat_sw_if_index, vam, &path->sw_if_index))
7924 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7926 else if (unformat (input, "weight %u", &weight))
7928 path->weight = weight;
7930 else if (unformat (input, "preference %u", &preference))
7932 path->preference = preference;
7934 else if (unformat (input, "%U next-hop-table %d",
7935 unformat_vl_api_ip4_address,
7936 &path->nh.address.ip4, &path->table_id))
7938 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7940 else if (unformat (input, "%U next-hop-table %d",
7941 unformat_vl_api_ip6_address,
7942 &path->nh.address.ip6, &path->table_id))
7944 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7946 else if (unformat (input, "%U",
7947 unformat_vl_api_ip4_address, &path->nh.address.ip4))
7950 * the recursive next-hops are by default in the default table
7953 path->sw_if_index = ~0;
7954 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7956 else if (unformat (input, "%U",
7957 unformat_vl_api_ip6_address, &path->nh.address.ip6))
7960 * the recursive next-hops are by default in the default table
7963 path->sw_if_index = ~0;
7964 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7966 else if (unformat (input, "resolve-via-host"))
7968 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
7970 else if (unformat (input, "resolve-via-attached"))
7972 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
7974 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
7976 path->type = FIB_API_PATH_TYPE_LOCAL;
7977 path->sw_if_index = ~0;
7978 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7980 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
7982 path->type = FIB_API_PATH_TYPE_LOCAL;
7983 path->sw_if_index = ~0;
7984 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7986 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
7988 else if (unformat (input, "via-label %d", &path->nh.via_label))
7990 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
7991 path->sw_if_index = ~0;
7993 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
7995 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
7996 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
7998 else if (unformat (input, "local"))
8000 path->type = FIB_API_PATH_TYPE_LOCAL;
8002 else if (unformat (input, "out-labels"))
8004 while (unformat (input, "%d", &out_label))
8006 path->label_stack[path->n_labels].label = out_label;
8007 path->label_stack[path->n_labels].is_uniform = 0;
8008 path->label_stack[path->n_labels].ttl = 64;
8012 else if (unformat (input, "via"))
8014 /* new path, back up and return */
8015 unformat_put_input (input);
8016 unformat_put_input (input);
8017 unformat_put_input (input);
8018 unformat_put_input (input);
8027 path->proto = ntohl (path->proto);
8028 path->type = ntohl (path->type);
8029 path->flags = ntohl (path->flags);
8030 path->table_id = ntohl (path->table_id);
8031 path->sw_if_index = ntohl (path->sw_if_index);
8037 api_ip_route_add_del (vat_main_t * vam)
8039 unformat_input_t *i = vam->input;
8040 vl_api_ip_route_add_del_t *mp;
8043 u8 is_multipath = 0;
8046 vl_api_prefix_t pfx = { };
8047 vl_api_fib_path_t paths[8];
8051 u32 random_add_del = 0;
8052 u32 *random_vector = 0;
8053 u32 random_seed = 0xdeaddabe;
8055 /* Parse args required to build the message */
8056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8058 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8060 else if (unformat (i, "del"))
8062 else if (unformat (i, "add"))
8064 else if (unformat (i, "vrf %d", &vrf_id))
8066 else if (unformat (i, "count %d", &count))
8068 else if (unformat (i, "random"))
8070 else if (unformat (i, "multipath"))
8072 else if (unformat (i, "seed %d", &random_seed))
8076 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8079 if (8 == path_count)
8081 errmsg ("max 8 paths");
8087 clib_warning ("parse error '%U'", format_unformat_error, i);
8094 errmsg ("specify a path; via ...");
8097 if (prefix_set == 0)
8099 errmsg ("missing prefix");
8103 /* Generate a pile of unique, random routes */
8106 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8107 u32 this_random_address;
8110 random_hash = hash_create (count, sizeof (uword));
8112 hash_set (random_hash, i->as_u32, 1);
8113 for (j = 0; j <= count; j++)
8117 this_random_address = random_u32 (&random_seed);
8118 this_random_address =
8119 clib_host_to_net_u32 (this_random_address);
8121 while (hash_get (random_hash, this_random_address));
8122 vec_add1 (random_vector, this_random_address);
8123 hash_set (random_hash, this_random_address, 1);
8125 hash_free (random_hash);
8126 set_ip4_address (&pfx.address, random_vector[0]);
8131 /* Turn on async mode */
8132 vam->async_mode = 1;
8133 vam->async_errors = 0;
8134 before = vat_time_now (vam);
8137 for (j = 0; j < count; j++)
8139 /* Construct the API message */
8140 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8142 mp->is_add = is_add;
8143 mp->is_multipath = is_multipath;
8145 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8146 mp->route.table_id = ntohl (vrf_id);
8147 mp->route.n_paths = path_count;
8149 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8152 set_ip4_address (&pfx.address, random_vector[j + 1]);
8154 increment_address (&pfx.address);
8157 /* If we receive SIGTERM, stop now... */
8162 /* When testing multiple add/del ops, use a control-ping to sync */
8165 vl_api_control_ping_t *mp_ping;
8169 /* Shut off async mode */
8170 vam->async_mode = 0;
8172 MPING (CONTROL_PING, mp_ping);
8175 timeout = vat_time_now (vam) + 1.0;
8176 while (vat_time_now (vam) < timeout)
8177 if (vam->result_ready == 1)
8182 if (vam->retval == -99)
8185 if (vam->async_errors > 0)
8187 errmsg ("%d asynchronous errors", vam->async_errors);
8190 vam->async_errors = 0;
8191 after = vat_time_now (vam);
8193 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8197 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8198 count, after - before, count / (after - before));
8204 /* Wait for a reply... */
8209 /* Return the good/bad news */
8210 return (vam->retval);
8214 api_ip_mroute_add_del (vat_main_t * vam)
8216 unformat_input_t *i = vam->input;
8217 u8 path_set = 0, prefix_set = 0, is_add = 1;
8218 vl_api_ip_mroute_add_del_t *mp;
8219 mfib_entry_flags_t eflags = 0;
8220 vl_api_mfib_path_t path;
8221 vl_api_mprefix_t pfx = { };
8225 /* Parse args required to build the message */
8226 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8228 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8231 pfx.grp_address_length = htons (pfx.grp_address_length);
8233 else if (unformat (i, "del"))
8235 else if (unformat (i, "add"))
8237 else if (unformat (i, "vrf %d", &vrf_id))
8239 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8240 path.itf_flags = htonl (path.itf_flags);
8241 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8243 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8247 clib_warning ("parse error '%U'", format_unformat_error, i);
8252 if (prefix_set == 0)
8254 errmsg ("missing addresses\n");
8259 errmsg ("missing path\n");
8263 /* Construct the API message */
8264 M (IP_MROUTE_ADD_DEL, mp);
8266 mp->is_add = is_add;
8267 mp->is_multipath = 1;
8269 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8270 mp->route.table_id = htonl (vrf_id);
8271 mp->route.n_paths = 1;
8272 mp->route.entry_flags = htonl (eflags);
8274 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8278 /* Wait for a reply... */
8284 api_mpls_table_add_del (vat_main_t * vam)
8286 unformat_input_t *i = vam->input;
8287 vl_api_mpls_table_add_del_t *mp;
8292 /* Parse args required to build the message */
8293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8295 if (unformat (i, "table %d", &table_id))
8297 else if (unformat (i, "del"))
8299 else if (unformat (i, "add"))
8303 clib_warning ("parse error '%U'", format_unformat_error, i);
8310 errmsg ("missing table-ID");
8314 /* Construct the API message */
8315 M (MPLS_TABLE_ADD_DEL, mp);
8317 mp->mt_table.mt_table_id = ntohl (table_id);
8318 mp->mt_is_add = is_add;
8323 /* Wait for a reply... */
8330 api_mpls_route_add_del (vat_main_t * vam)
8332 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8333 mpls_label_t local_label = MPLS_LABEL_INVALID;
8334 unformat_input_t *i = vam->input;
8335 vl_api_mpls_route_add_del_t *mp;
8336 vl_api_fib_path_t paths[8];
8340 /* Parse args required to build the message */
8341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8343 if (unformat (i, "%d", &local_label))
8345 else if (unformat (i, "eos"))
8347 else if (unformat (i, "non-eos"))
8349 else if (unformat (i, "del"))
8351 else if (unformat (i, "add"))
8353 else if (unformat (i, "multipath"))
8355 else if (unformat (i, "count %d", &count))
8359 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8362 if (8 == path_count)
8364 errmsg ("max 8 paths");
8370 clib_warning ("parse error '%U'", format_unformat_error, i);
8377 errmsg ("specify a path; via ...");
8381 if (MPLS_LABEL_INVALID == local_label)
8383 errmsg ("missing label");
8389 /* Turn on async mode */
8390 vam->async_mode = 1;
8391 vam->async_errors = 0;
8392 before = vat_time_now (vam);
8395 for (j = 0; j < count; j++)
8397 /* Construct the API message */
8398 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8400 mp->mr_is_add = is_add;
8401 mp->mr_is_multipath = is_multipath;
8403 mp->mr_route.mr_label = local_label;
8404 mp->mr_route.mr_eos = is_eos;
8405 mp->mr_route.mr_table_id = 0;
8406 mp->mr_route.mr_n_paths = path_count;
8408 clib_memcpy (&mp->mr_route.mr_paths, paths,
8409 sizeof (paths[0]) * path_count);
8415 /* If we receive SIGTERM, stop now... */
8420 /* When testing multiple add/del ops, use a control-ping to sync */
8423 vl_api_control_ping_t *mp_ping;
8427 /* Shut off async mode */
8428 vam->async_mode = 0;
8430 MPING (CONTROL_PING, mp_ping);
8433 timeout = vat_time_now (vam) + 1.0;
8434 while (vat_time_now (vam) < timeout)
8435 if (vam->result_ready == 1)
8440 if (vam->retval == -99)
8443 if (vam->async_errors > 0)
8445 errmsg ("%d asynchronous errors", vam->async_errors);
8448 vam->async_errors = 0;
8449 after = vat_time_now (vam);
8451 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8455 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8456 count, after - before, count / (after - before));
8462 /* Wait for a reply... */
8467 /* Return the good/bad news */
8468 return (vam->retval);
8473 api_mpls_ip_bind_unbind (vat_main_t * vam)
8475 unformat_input_t *i = vam->input;
8476 vl_api_mpls_ip_bind_unbind_t *mp;
8477 u32 ip_table_id = 0;
8479 vl_api_prefix_t pfx;
8481 mpls_label_t local_label = MPLS_LABEL_INVALID;
8484 /* Parse args required to build the message */
8485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8487 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8489 else if (unformat (i, "%d", &local_label))
8491 else if (unformat (i, "table-id %d", &ip_table_id))
8493 else if (unformat (i, "unbind"))
8495 else if (unformat (i, "bind"))
8499 clib_warning ("parse error '%U'", format_unformat_error, i);
8506 errmsg ("IP prefix not set");
8510 if (MPLS_LABEL_INVALID == local_label)
8512 errmsg ("missing label");
8516 /* Construct the API message */
8517 M (MPLS_IP_BIND_UNBIND, mp);
8519 mp->mb_is_bind = is_bind;
8520 mp->mb_ip_table_id = ntohl (ip_table_id);
8521 mp->mb_mpls_table_id = 0;
8522 mp->mb_label = ntohl (local_label);
8523 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8528 /* Wait for a reply... */
8535 api_sr_mpls_policy_add (vat_main_t * vam)
8537 unformat_input_t *i = vam->input;
8538 vl_api_sr_mpls_policy_add_t *mp;
8544 u32 *segments = NULL;
8547 /* Parse args required to build the message */
8548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8550 if (unformat (i, "bsid %d", &bsid))
8552 else if (unformat (i, "weight %d", &weight))
8554 else if (unformat (i, "spray"))
8556 else if (unformat (i, "next %d", &sid))
8559 vec_add1 (segments, htonl (sid));
8563 clib_warning ("parse error '%U'", format_unformat_error, i);
8570 errmsg ("bsid not set");
8574 if (n_segments == 0)
8576 errmsg ("no sid in segment stack");
8580 /* Construct the API message */
8581 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8583 mp->bsid = htonl (bsid);
8584 mp->weight = htonl (weight);
8585 mp->is_spray = type;
8586 mp->n_segments = n_segments;
8587 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8588 vec_free (segments);
8593 /* Wait for a reply... */
8599 api_sr_mpls_policy_del (vat_main_t * vam)
8601 unformat_input_t *i = vam->input;
8602 vl_api_sr_mpls_policy_del_t *mp;
8606 /* Parse args required to build the message */
8607 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8609 if (unformat (i, "bsid %d", &bsid))
8613 clib_warning ("parse error '%U'", format_unformat_error, i);
8620 errmsg ("bsid not set");
8624 /* Construct the API message */
8625 M (SR_MPLS_POLICY_DEL, mp);
8627 mp->bsid = htonl (bsid);
8632 /* Wait for a reply... */
8638 api_bier_table_add_del (vat_main_t * vam)
8640 unformat_input_t *i = vam->input;
8641 vl_api_bier_table_add_del_t *mp;
8643 u32 set = 0, sub_domain = 0, hdr_len = 3;
8644 mpls_label_t local_label = MPLS_LABEL_INVALID;
8647 /* Parse args required to build the message */
8648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8650 if (unformat (i, "sub-domain %d", &sub_domain))
8652 else if (unformat (i, "set %d", &set))
8654 else if (unformat (i, "label %d", &local_label))
8656 else if (unformat (i, "hdr-len %d", &hdr_len))
8658 else if (unformat (i, "add"))
8660 else if (unformat (i, "del"))
8664 clib_warning ("parse error '%U'", format_unformat_error, i);
8669 if (MPLS_LABEL_INVALID == local_label)
8671 errmsg ("missing label\n");
8675 /* Construct the API message */
8676 M (BIER_TABLE_ADD_DEL, mp);
8678 mp->bt_is_add = is_add;
8679 mp->bt_label = ntohl (local_label);
8680 mp->bt_tbl_id.bt_set = set;
8681 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8682 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8687 /* Wait for a reply... */
8694 api_bier_route_add_del (vat_main_t * vam)
8696 unformat_input_t *i = vam->input;
8697 vl_api_bier_route_add_del_t *mp;
8699 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8700 ip4_address_t v4_next_hop_address;
8701 ip6_address_t v6_next_hop_address;
8702 u8 next_hop_set = 0;
8703 u8 next_hop_proto_is_ip4 = 1;
8704 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8707 /* Parse args required to build the message */
8708 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8710 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8712 next_hop_proto_is_ip4 = 1;
8715 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8717 next_hop_proto_is_ip4 = 0;
8720 if (unformat (i, "sub-domain %d", &sub_domain))
8722 else if (unformat (i, "set %d", &set))
8724 else if (unformat (i, "hdr-len %d", &hdr_len))
8726 else if (unformat (i, "bp %d", &bp))
8728 else if (unformat (i, "add"))
8730 else if (unformat (i, "del"))
8732 else if (unformat (i, "out-label %d", &next_hop_out_label))
8736 clib_warning ("parse error '%U'", format_unformat_error, i);
8741 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8743 errmsg ("next hop / label set\n");
8748 errmsg ("bit=position not set\n");
8752 /* Construct the API message */
8753 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8755 mp->br_is_add = is_add;
8756 mp->br_route.br_tbl_id.bt_set = set;
8757 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8758 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8759 mp->br_route.br_bp = ntohs (bp);
8760 mp->br_route.br_n_paths = 1;
8761 mp->br_route.br_paths[0].n_labels = 1;
8762 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8763 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8764 FIB_API_PATH_NH_PROTO_IP4 :
8765 FIB_API_PATH_NH_PROTO_IP6);
8767 if (next_hop_proto_is_ip4)
8769 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8770 &v4_next_hop_address, sizeof (v4_next_hop_address));
8774 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8775 &v6_next_hop_address, sizeof (v6_next_hop_address));
8781 /* Wait for a reply... */
8788 api_mpls_tunnel_add_del (vat_main_t * vam)
8790 unformat_input_t *i = vam->input;
8791 vl_api_mpls_tunnel_add_del_t *mp;
8793 vl_api_fib_path_t paths[8];
8794 u32 sw_if_index = ~0;
8800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8802 if (unformat (i, "add"))
8806 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8808 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8810 else if (unformat (i, "l2-only"))
8814 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8817 if (8 == path_count)
8819 errmsg ("max 8 paths");
8825 clib_warning ("parse error '%U'", format_unformat_error, i);
8830 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8832 mp->mt_is_add = is_add;
8833 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8834 mp->mt_tunnel.mt_l2_only = l2_only;
8835 mp->mt_tunnel.mt_is_multicast = 0;
8836 mp->mt_tunnel.mt_n_paths = path_count;
8838 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8839 sizeof (paths[0]) * path_count);
8847 api_sw_interface_set_unnumbered (vat_main_t * vam)
8849 unformat_input_t *i = vam->input;
8850 vl_api_sw_interface_set_unnumbered_t *mp;
8852 u32 unnum_sw_index = ~0;
8854 u8 sw_if_index_set = 0;
8857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8859 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8860 sw_if_index_set = 1;
8861 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8862 sw_if_index_set = 1;
8863 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8865 else if (unformat (i, "del"))
8869 clib_warning ("parse error '%U'", format_unformat_error, i);
8874 if (sw_if_index_set == 0)
8876 errmsg ("missing interface name or sw_if_index");
8880 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8882 mp->sw_if_index = ntohl (sw_if_index);
8883 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8884 mp->is_add = is_add;
8893 api_create_vlan_subif (vat_main_t * vam)
8895 unformat_input_t *i = vam->input;
8896 vl_api_create_vlan_subif_t *mp;
8898 u8 sw_if_index_set = 0;
8903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8905 if (unformat (i, "sw_if_index %d", &sw_if_index))
8906 sw_if_index_set = 1;
8908 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8909 sw_if_index_set = 1;
8910 else if (unformat (i, "vlan %d", &vlan_id))
8914 clib_warning ("parse error '%U'", format_unformat_error, i);
8919 if (sw_if_index_set == 0)
8921 errmsg ("missing interface name or sw_if_index");
8925 if (vlan_id_set == 0)
8927 errmsg ("missing vlan_id");
8930 M (CREATE_VLAN_SUBIF, mp);
8932 mp->sw_if_index = ntohl (sw_if_index);
8933 mp->vlan_id = ntohl (vlan_id);
8940 #define foreach_create_subif_bit \
8947 _(outer_vlan_id_any) \
8948 _(inner_vlan_id_any)
8950 #define foreach_create_subif_flag \
8955 _(4, "exact_match") \
8956 _(5, "default_sub") \
8957 _(6, "outer_vlan_id_any") \
8958 _(7, "inner_vlan_id_any")
8961 api_create_subif (vat_main_t * vam)
8963 unformat_input_t *i = vam->input;
8964 vl_api_create_subif_t *mp;
8966 u8 sw_if_index_set = 0;
8969 u32 __attribute__ ((unused)) no_tags = 0;
8970 u32 __attribute__ ((unused)) one_tag = 0;
8971 u32 __attribute__ ((unused)) two_tags = 0;
8972 u32 __attribute__ ((unused)) dot1ad = 0;
8973 u32 __attribute__ ((unused)) exact_match = 0;
8974 u32 __attribute__ ((unused)) default_sub = 0;
8975 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
8976 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
8978 u16 outer_vlan_id = 0;
8979 u16 inner_vlan_id = 0;
8982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8984 if (unformat (i, "sw_if_index %d", &sw_if_index))
8985 sw_if_index_set = 1;
8987 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8988 sw_if_index_set = 1;
8989 else if (unformat (i, "sub_id %d", &sub_id))
8991 else if (unformat (i, "outer_vlan_id %d", &tmp))
8992 outer_vlan_id = tmp;
8993 else if (unformat (i, "inner_vlan_id %d", &tmp))
8994 inner_vlan_id = tmp;
8996 #define _(a) else if (unformat (i, #a)) a = 1 ;
8997 foreach_create_subif_bit
9001 clib_warning ("parse error '%U'", format_unformat_error, i);
9006 if (sw_if_index_set == 0)
9008 errmsg ("missing interface name or sw_if_index");
9012 if (sub_id_set == 0)
9014 errmsg ("missing sub_id");
9017 M (CREATE_SUBIF, mp);
9019 mp->sw_if_index = ntohl (sw_if_index);
9020 mp->sub_id = ntohl (sub_id);
9022 #define _(a,b) mp->sub_if_flags |= (1 << a);
9023 foreach_create_subif_flag;
9026 mp->outer_vlan_id = ntohs (outer_vlan_id);
9027 mp->inner_vlan_id = ntohs (inner_vlan_id);
9035 api_ip_table_replace_begin (vat_main_t * vam)
9037 unformat_input_t *i = vam->input;
9038 vl_api_ip_table_replace_begin_t *mp;
9043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9045 if (unformat (i, "table %d", &table_id))
9047 else if (unformat (i, "ipv6"))
9051 clib_warning ("parse error '%U'", format_unformat_error, i);
9056 M (IP_TABLE_REPLACE_BEGIN, mp);
9058 mp->table.table_id = ntohl (table_id);
9059 mp->table.is_ip6 = is_ipv6;
9067 api_ip_table_flush (vat_main_t * vam)
9069 unformat_input_t *i = vam->input;
9070 vl_api_ip_table_flush_t *mp;
9075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9077 if (unformat (i, "table %d", &table_id))
9079 else if (unformat (i, "ipv6"))
9083 clib_warning ("parse error '%U'", format_unformat_error, i);
9088 M (IP_TABLE_FLUSH, mp);
9090 mp->table.table_id = ntohl (table_id);
9091 mp->table.is_ip6 = is_ipv6;
9099 api_ip_table_replace_end (vat_main_t * vam)
9101 unformat_input_t *i = vam->input;
9102 vl_api_ip_table_replace_end_t *mp;
9107 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9109 if (unformat (i, "table %d", &table_id))
9111 else if (unformat (i, "ipv6"))
9115 clib_warning ("parse error '%U'", format_unformat_error, i);
9120 M (IP_TABLE_REPLACE_END, mp);
9122 mp->table.table_id = ntohl (table_id);
9123 mp->table.is_ip6 = is_ipv6;
9131 api_set_ip_flow_hash (vat_main_t * vam)
9133 unformat_input_t *i = vam->input;
9134 vl_api_set_ip_flow_hash_t *mp;
9146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9148 if (unformat (i, "vrf %d", &vrf_id))
9150 else if (unformat (i, "ipv6"))
9152 else if (unformat (i, "src"))
9154 else if (unformat (i, "dst"))
9156 else if (unformat (i, "sport"))
9158 else if (unformat (i, "dport"))
9160 else if (unformat (i, "proto"))
9162 else if (unformat (i, "reverse"))
9167 clib_warning ("parse error '%U'", format_unformat_error, i);
9172 if (vrf_id_set == 0)
9174 errmsg ("missing vrf id");
9178 M (SET_IP_FLOW_HASH, mp);
9184 mp->reverse = reverse;
9185 mp->vrf_id = ntohl (vrf_id);
9186 mp->is_ipv6 = is_ipv6;
9194 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9196 unformat_input_t *i = vam->input;
9197 vl_api_sw_interface_ip6_enable_disable_t *mp;
9199 u8 sw_if_index_set = 0;
9203 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9205 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9206 sw_if_index_set = 1;
9207 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9208 sw_if_index_set = 1;
9209 else if (unformat (i, "enable"))
9211 else if (unformat (i, "disable"))
9215 clib_warning ("parse error '%U'", format_unformat_error, i);
9220 if (sw_if_index_set == 0)
9222 errmsg ("missing interface name or sw_if_index");
9226 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9228 mp->sw_if_index = ntohl (sw_if_index);
9229 mp->enable = enable;
9238 api_l2_patch_add_del (vat_main_t * vam)
9240 unformat_input_t *i = vam->input;
9241 vl_api_l2_patch_add_del_t *mp;
9243 u8 rx_sw_if_index_set = 0;
9245 u8 tx_sw_if_index_set = 0;
9249 /* Parse args required to build the message */
9250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9252 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9253 rx_sw_if_index_set = 1;
9254 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9255 tx_sw_if_index_set = 1;
9256 else if (unformat (i, "rx"))
9258 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9260 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9262 rx_sw_if_index_set = 1;
9267 else if (unformat (i, "tx"))
9269 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9271 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9273 tx_sw_if_index_set = 1;
9278 else if (unformat (i, "del"))
9284 if (rx_sw_if_index_set == 0)
9286 errmsg ("missing rx interface name or rx_sw_if_index");
9290 if (tx_sw_if_index_set == 0)
9292 errmsg ("missing tx interface name or tx_sw_if_index");
9296 M (L2_PATCH_ADD_DEL, mp);
9298 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9299 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9300 mp->is_add = is_add;
9308 u8 localsid_addr[16];
9317 api_sr_localsid_add_del (vat_main_t * vam)
9319 unformat_input_t *i = vam->input;
9320 vl_api_sr_localsid_add_del_t *mp;
9323 ip6_address_t localsid;
9327 u32 fib_table = ~(u32) 0;
9328 ip46_address_t nh_addr;
9329 clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
9331 bool nexthop_set = 0;
9335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9337 if (unformat (i, "del"))
9339 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9340 else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
9342 else if (unformat (i, "behavior %u", &behavior));
9343 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9344 else if (unformat (i, "fib-table %u", &fib_table));
9345 else if (unformat (i, "end.psp %u", &behavior));
9350 M (SR_LOCALSID_ADD_DEL, mp);
9352 clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
9356 clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
9358 mp->behavior = behavior;
9359 mp->sw_if_index = ntohl (sw_if_index);
9360 mp->fib_table = ntohl (fib_table);
9361 mp->end_psp = end_psp;
9362 mp->is_del = is_del;
9370 api_ioam_enable (vat_main_t * vam)
9372 unformat_input_t *input = vam->input;
9373 vl_api_ioam_enable_t *mp;
9375 int has_trace_option = 0;
9376 int has_pot_option = 0;
9377 int has_seqno_option = 0;
9378 int has_analyse_option = 0;
9381 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9383 if (unformat (input, "trace"))
9384 has_trace_option = 1;
9385 else if (unformat (input, "pot"))
9387 else if (unformat (input, "seqno"))
9388 has_seqno_option = 1;
9389 else if (unformat (input, "analyse"))
9390 has_analyse_option = 1;
9394 M (IOAM_ENABLE, mp);
9395 mp->id = htons (id);
9396 mp->seqno = has_seqno_option;
9397 mp->analyse = has_analyse_option;
9398 mp->pot_enable = has_pot_option;
9399 mp->trace_enable = has_trace_option;
9408 api_ioam_disable (vat_main_t * vam)
9410 vl_api_ioam_disable_t *mp;
9413 M (IOAM_DISABLE, mp);
9419 #define foreach_tcp_proto_field \
9423 #define foreach_udp_proto_field \
9427 #define foreach_ip4_proto_field \
9439 u16 src_port, dst_port;
9442 #if VPP_API_TEST_BUILTIN == 0
9444 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9446 u8 **maskp = va_arg (*args, u8 **);
9448 u8 found_something = 0;
9451 #define _(a) u8 a=0;
9452 foreach_tcp_proto_field;
9455 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9458 #define _(a) else if (unformat (input, #a)) a=1;
9459 foreach_tcp_proto_field
9465 #define _(a) found_something += a;
9466 foreach_tcp_proto_field;
9469 if (found_something == 0)
9472 vec_validate (mask, sizeof (*tcp) - 1);
9474 tcp = (tcp_header_t *) mask;
9476 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
9477 foreach_tcp_proto_field;
9485 unformat_udp_mask (unformat_input_t * input, va_list * args)
9487 u8 **maskp = va_arg (*args, u8 **);
9489 u8 found_something = 0;
9492 #define _(a) u8 a=0;
9493 foreach_udp_proto_field;
9496 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9499 #define _(a) else if (unformat (input, #a)) a=1;
9500 foreach_udp_proto_field
9506 #define _(a) found_something += a;
9507 foreach_udp_proto_field;
9510 if (found_something == 0)
9513 vec_validate (mask, sizeof (*udp) - 1);
9515 udp = (udp_header_t *) mask;
9517 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
9518 foreach_udp_proto_field;
9526 unformat_l4_mask (unformat_input_t * input, va_list * args)
9528 u8 **maskp = va_arg (*args, u8 **);
9529 u16 src_port = 0, dst_port = 0;
9530 tcpudp_header_t *tcpudp;
9532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9534 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9536 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9538 else if (unformat (input, "src_port"))
9540 else if (unformat (input, "dst_port"))
9546 if (!src_port && !dst_port)
9550 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9552 tcpudp = (tcpudp_header_t *) mask;
9553 tcpudp->src_port = src_port;
9554 tcpudp->dst_port = dst_port;
9562 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9564 u8 **maskp = va_arg (*args, u8 **);
9566 u8 found_something = 0;
9569 #define _(a) u8 a=0;
9570 foreach_ip4_proto_field;
9576 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9578 if (unformat (input, "version"))
9580 else if (unformat (input, "hdr_length"))
9582 else if (unformat (input, "src"))
9584 else if (unformat (input, "dst"))
9586 else if (unformat (input, "proto"))
9589 #define _(a) else if (unformat (input, #a)) a=1;
9590 foreach_ip4_proto_field
9596 #define _(a) found_something += a;
9597 foreach_ip4_proto_field;
9600 if (found_something == 0)
9603 vec_validate (mask, sizeof (*ip) - 1);
9605 ip = (ip4_header_t *) mask;
9607 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9608 foreach_ip4_proto_field;
9611 ip->ip_version_and_header_length = 0;
9614 ip->ip_version_and_header_length |= 0xF0;
9617 ip->ip_version_and_header_length |= 0x0F;
9623 #define foreach_ip6_proto_field \
9631 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9633 u8 **maskp = va_arg (*args, u8 **);
9635 u8 found_something = 0;
9637 u32 ip_version_traffic_class_and_flow_label;
9639 #define _(a) u8 a=0;
9640 foreach_ip6_proto_field;
9643 u8 traffic_class = 0;
9646 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9648 if (unformat (input, "version"))
9650 else if (unformat (input, "traffic-class"))
9652 else if (unformat (input, "flow-label"))
9654 else if (unformat (input, "src"))
9656 else if (unformat (input, "dst"))
9658 else if (unformat (input, "proto"))
9661 #define _(a) else if (unformat (input, #a)) a=1;
9662 foreach_ip6_proto_field
9668 #define _(a) found_something += a;
9669 foreach_ip6_proto_field;
9672 if (found_something == 0)
9675 vec_validate (mask, sizeof (*ip) - 1);
9677 ip = (ip6_header_t *) mask;
9679 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9680 foreach_ip6_proto_field;
9683 ip_version_traffic_class_and_flow_label = 0;
9686 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9689 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9692 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9694 ip->ip_version_traffic_class_and_flow_label =
9695 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9702 unformat_l3_mask (unformat_input_t * input, va_list * args)
9704 u8 **maskp = va_arg (*args, u8 **);
9706 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9708 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9710 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9719 unformat_l2_mask (unformat_input_t * input, va_list * args)
9721 u8 **maskp = va_arg (*args, u8 **);
9736 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9738 if (unformat (input, "src"))
9740 else if (unformat (input, "dst"))
9742 else if (unformat (input, "proto"))
9744 else if (unformat (input, "tag1"))
9746 else if (unformat (input, "tag2"))
9748 else if (unformat (input, "ignore-tag1"))
9750 else if (unformat (input, "ignore-tag2"))
9752 else if (unformat (input, "cos1"))
9754 else if (unformat (input, "cos2"))
9756 else if (unformat (input, "dot1q"))
9758 else if (unformat (input, "dot1ad"))
9763 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9764 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9767 if (tag1 || ignore_tag1 || cos1 || dot1q)
9769 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9772 vec_validate (mask, len - 1);
9775 clib_memset (mask, 0xff, 6);
9778 clib_memset (mask + 6, 0xff, 6);
9782 /* inner vlan tag */
9791 mask[21] = mask[20] = 0xff;
9812 mask[16] = mask[17] = 0xff;
9822 mask[12] = mask[13] = 0xff;
9829 unformat_classify_mask (unformat_input_t * input, va_list * args)
9831 u8 **maskp = va_arg (*args, u8 **);
9832 u32 *skipp = va_arg (*args, u32 *);
9833 u32 *matchp = va_arg (*args, u32 *);
9841 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9843 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9845 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9847 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9849 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9863 if (mask || l2 || l3 || l4)
9867 /* "With a free Ethernet header in every package" */
9869 vec_validate (l2, 13);
9873 vec_append (mask, l3);
9878 vec_append (mask, l4);
9883 /* Scan forward looking for the first significant mask octet */
9884 for (i = 0; i < vec_len (mask); i++)
9888 /* compute (skip, match) params */
9889 *skipp = i / sizeof (u32x4);
9890 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9892 /* Pad mask to an even multiple of the vector size */
9893 while (vec_len (mask) % sizeof (u32x4))
9896 match = vec_len (mask) / sizeof (u32x4);
9898 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9900 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9901 if (*tmp || *(tmp + 1))
9906 clib_warning ("BUG: match 0");
9908 _vec_len (mask) = match * sizeof (u32x4);
9918 #endif /* VPP_API_TEST_BUILTIN */
9920 #define foreach_l2_next \
9922 _(ethernet, ETHERNET_INPUT) \
9927 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9929 u32 *miss_next_indexp = va_arg (*args, u32 *);
9934 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9938 if (unformat (input, "%d", &tmp))
9947 *miss_next_indexp = next_index;
9951 #define foreach_ip_next \
9957 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9959 u32 *miss_next_indexp = va_arg (*args, u32 *);
9964 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9968 if (unformat (input, "%d", &tmp))
9977 *miss_next_indexp = next_index;
9981 #define foreach_acl_next \
9985 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9987 u32 *miss_next_indexp = va_arg (*args, u32 *);
9992 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9996 if (unformat (input, "permit"))
10001 else if (unformat (input, "%d", &tmp))
10010 *miss_next_indexp = next_index;
10015 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10017 u32 *r = va_arg (*args, u32 *);
10019 if (unformat (input, "conform-color"))
10020 *r = POLICE_CONFORM;
10021 else if (unformat (input, "exceed-color"))
10022 *r = POLICE_EXCEED;
10030 api_classify_add_del_table (vat_main_t * vam)
10032 unformat_input_t *i = vam->input;
10033 vl_api_classify_add_del_table_t *mp;
10040 u32 table_index = ~0;
10041 u32 next_table_index = ~0;
10042 u32 miss_next_index = ~0;
10043 u32 memory_size = 32 << 20;
10045 u32 current_data_flag = 0;
10046 int current_data_offset = 0;
10049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10051 if (unformat (i, "del"))
10053 else if (unformat (i, "del-chain"))
10058 else if (unformat (i, "buckets %d", &nbuckets))
10060 else if (unformat (i, "memory_size %d", &memory_size))
10062 else if (unformat (i, "skip %d", &skip))
10064 else if (unformat (i, "match %d", &match))
10066 else if (unformat (i, "table %d", &table_index))
10068 else if (unformat (i, "mask %U", unformat_classify_mask,
10069 &mask, &skip, &match))
10071 else if (unformat (i, "next-table %d", &next_table_index))
10073 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10076 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10079 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10082 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10084 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10090 if (is_add && mask == 0)
10092 errmsg ("Mask required");
10096 if (is_add && skip == ~0)
10098 errmsg ("skip count required");
10102 if (is_add && match == ~0)
10104 errmsg ("match count required");
10108 if (!is_add && table_index == ~0)
10110 errmsg ("table index required for delete");
10114 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10116 mp->is_add = is_add;
10117 mp->del_chain = del_chain;
10118 mp->table_index = ntohl (table_index);
10119 mp->nbuckets = ntohl (nbuckets);
10120 mp->memory_size = ntohl (memory_size);
10121 mp->skip_n_vectors = ntohl (skip);
10122 mp->match_n_vectors = ntohl (match);
10123 mp->next_table_index = ntohl (next_table_index);
10124 mp->miss_next_index = ntohl (miss_next_index);
10125 mp->current_data_flag = ntohl (current_data_flag);
10126 mp->current_data_offset = ntohl (current_data_offset);
10127 mp->mask_len = ntohl (vec_len (mask));
10128 clib_memcpy (mp->mask, mask, vec_len (mask));
10137 #if VPP_API_TEST_BUILTIN == 0
10139 unformat_l4_match (unformat_input_t * input, va_list * args)
10141 u8 **matchp = va_arg (*args, u8 **);
10143 u8 *proto_header = 0;
10149 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10151 if (unformat (input, "src_port %d", &src_port))
10153 else if (unformat (input, "dst_port %d", &dst_port))
10159 h.src_port = clib_host_to_net_u16 (src_port);
10160 h.dst_port = clib_host_to_net_u16 (dst_port);
10161 vec_validate (proto_header, sizeof (h) - 1);
10162 memcpy (proto_header, &h, sizeof (h));
10164 *matchp = proto_header;
10170 unformat_ip4_match (unformat_input_t * input, va_list * args)
10172 u8 **matchp = va_arg (*args, u8 **);
10177 int hdr_length = 0;
10178 u32 hdr_length_val;
10179 int src = 0, dst = 0;
10180 ip4_address_t src_val, dst_val;
10187 int fragment_id = 0;
10188 u32 fragment_id_val;
10194 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10196 if (unformat (input, "version %d", &version_val))
10198 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10200 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10202 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10204 else if (unformat (input, "proto %d", &proto_val))
10206 else if (unformat (input, "tos %d", &tos_val))
10208 else if (unformat (input, "length %d", &length_val))
10210 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10212 else if (unformat (input, "ttl %d", &ttl_val))
10214 else if (unformat (input, "checksum %d", &checksum_val))
10220 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10221 + ttl + checksum == 0)
10225 * Aligned because we use the real comparison functions
10227 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10229 ip = (ip4_header_t *) match;
10231 /* These are realistically matched in practice */
10233 ip->src_address.as_u32 = src_val.as_u32;
10236 ip->dst_address.as_u32 = dst_val.as_u32;
10239 ip->protocol = proto_val;
10242 /* These are not, but they're included for completeness */
10244 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10247 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10253 ip->length = clib_host_to_net_u16 (length_val);
10259 ip->checksum = clib_host_to_net_u16 (checksum_val);
10266 unformat_ip6_match (unformat_input_t * input, va_list * args)
10268 u8 **matchp = va_arg (*args, u8 **);
10273 u8 traffic_class = 0;
10274 u32 traffic_class_val = 0;
10277 int src = 0, dst = 0;
10278 ip6_address_t src_val, dst_val;
10281 int payload_length = 0;
10282 u32 payload_length_val;
10285 u32 ip_version_traffic_class_and_flow_label;
10287 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10289 if (unformat (input, "version %d", &version_val))
10291 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10293 else if (unformat (input, "flow_label %d", &flow_label_val))
10295 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10297 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10299 else if (unformat (input, "proto %d", &proto_val))
10301 else if (unformat (input, "payload_length %d", &payload_length_val))
10302 payload_length = 1;
10303 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10309 if (version + traffic_class + flow_label + src + dst + proto +
10310 payload_length + hop_limit == 0)
10314 * Aligned because we use the real comparison functions
10316 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10318 ip = (ip6_header_t *) match;
10321 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10324 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10327 ip->protocol = proto_val;
10329 ip_version_traffic_class_and_flow_label = 0;
10332 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10335 ip_version_traffic_class_and_flow_label |=
10336 (traffic_class_val & 0xFF) << 20;
10339 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10341 ip->ip_version_traffic_class_and_flow_label =
10342 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10344 if (payload_length)
10345 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10348 ip->hop_limit = hop_limit_val;
10355 unformat_l3_match (unformat_input_t * input, va_list * args)
10357 u8 **matchp = va_arg (*args, u8 **);
10359 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10361 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10363 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10372 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10374 u8 *tagp = va_arg (*args, u8 *);
10377 if (unformat (input, "%d", &tag))
10379 tagp[0] = (tag >> 8) & 0x0F;
10380 tagp[1] = tag & 0xFF;
10388 unformat_l2_match (unformat_input_t * input, va_list * args)
10390 u8 **matchp = va_arg (*args, u8 **);
10403 u8 ignore_tag1 = 0;
10404 u8 ignore_tag2 = 0;
10410 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10412 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10415 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10417 else if (unformat (input, "proto %U",
10418 unformat_ethernet_type_host_byte_order, &proto_val))
10420 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10422 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10424 else if (unformat (input, "ignore-tag1"))
10426 else if (unformat (input, "ignore-tag2"))
10428 else if (unformat (input, "cos1 %d", &cos1_val))
10430 else if (unformat (input, "cos2 %d", &cos2_val))
10435 if ((src + dst + proto + tag1 + tag2 +
10436 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10439 if (tag1 || ignore_tag1 || cos1)
10441 if (tag2 || ignore_tag2 || cos2)
10444 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10447 clib_memcpy (match, dst_val, 6);
10450 clib_memcpy (match + 6, src_val, 6);
10454 /* inner vlan tag */
10455 match[19] = tag2_val[1];
10456 match[18] = tag2_val[0];
10458 match[18] |= (cos2_val & 0x7) << 5;
10461 match[21] = proto_val & 0xff;
10462 match[20] = proto_val >> 8;
10466 match[15] = tag1_val[1];
10467 match[14] = tag1_val[0];
10470 match[14] |= (cos1_val & 0x7) << 5;
10476 match[15] = tag1_val[1];
10477 match[14] = tag1_val[0];
10480 match[17] = proto_val & 0xff;
10481 match[16] = proto_val >> 8;
10484 match[14] |= (cos1_val & 0x7) << 5;
10490 match[18] |= (cos2_val & 0x7) << 5;
10492 match[14] |= (cos1_val & 0x7) << 5;
10495 match[13] = proto_val & 0xff;
10496 match[12] = proto_val >> 8;
10504 unformat_qos_source (unformat_input_t * input, va_list * args)
10506 int *qs = va_arg (*args, int *);
10508 if (unformat (input, "ip"))
10509 *qs = QOS_SOURCE_IP;
10510 else if (unformat (input, "mpls"))
10511 *qs = QOS_SOURCE_MPLS;
10512 else if (unformat (input, "ext"))
10513 *qs = QOS_SOURCE_EXT;
10514 else if (unformat (input, "vlan"))
10515 *qs = QOS_SOURCE_VLAN;
10524 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10526 u8 **matchp = va_arg (*args, u8 **);
10527 u32 skip_n_vectors = va_arg (*args, u32);
10528 u32 match_n_vectors = va_arg (*args, u32);
10535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10537 if (unformat (input, "hex %U", unformat_hex_string, &match))
10539 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10541 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10543 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10557 if (match || l2 || l3 || l4)
10559 if (l2 || l3 || l4)
10561 /* "Win a free Ethernet header in every packet" */
10563 vec_validate_aligned (l2, 13, sizeof (u32x4));
10567 vec_append_aligned (match, l3, sizeof (u32x4));
10572 vec_append_aligned (match, l4, sizeof (u32x4));
10577 /* Make sure the vector is big enough even if key is all 0's */
10578 vec_validate_aligned
10579 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10582 /* Set size, include skipped vectors */
10583 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10594 api_classify_add_del_session (vat_main_t * vam)
10596 unformat_input_t *i = vam->input;
10597 vl_api_classify_add_del_session_t *mp;
10599 u32 table_index = ~0;
10600 u32 hit_next_index = ~0;
10601 u32 opaque_index = ~0;
10604 u32 skip_n_vectors = 0;
10605 u32 match_n_vectors = 0;
10611 * Warning: you have to supply skip_n and match_n
10612 * because the API client cant simply look at the classify
10616 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10618 if (unformat (i, "del"))
10620 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10623 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10626 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10629 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10631 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10633 else if (unformat (i, "opaque-index %d", &opaque_index))
10635 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10637 else if (unformat (i, "match_n %d", &match_n_vectors))
10639 else if (unformat (i, "match %U", api_unformat_classify_match,
10640 &match, skip_n_vectors, match_n_vectors))
10642 else if (unformat (i, "advance %d", &advance))
10644 else if (unformat (i, "table-index %d", &table_index))
10646 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10648 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10650 else if (unformat (i, "action %d", &action))
10652 else if (unformat (i, "metadata %d", &metadata))
10658 if (table_index == ~0)
10660 errmsg ("Table index required");
10664 if (is_add && match == 0)
10666 errmsg ("Match value required");
10670 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10672 mp->is_add = is_add;
10673 mp->table_index = ntohl (table_index);
10674 mp->hit_next_index = ntohl (hit_next_index);
10675 mp->opaque_index = ntohl (opaque_index);
10676 mp->advance = ntohl (advance);
10677 mp->action = action;
10678 mp->metadata = ntohl (metadata);
10679 mp->match_len = ntohl (vec_len (match));
10680 clib_memcpy (mp->match, match, vec_len (match));
10689 api_classify_set_interface_ip_table (vat_main_t * vam)
10691 unformat_input_t *i = vam->input;
10692 vl_api_classify_set_interface_ip_table_t *mp;
10694 int sw_if_index_set;
10695 u32 table_index = ~0;
10699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10701 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10702 sw_if_index_set = 1;
10703 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10704 sw_if_index_set = 1;
10705 else if (unformat (i, "table %d", &table_index))
10709 clib_warning ("parse error '%U'", format_unformat_error, i);
10714 if (sw_if_index_set == 0)
10716 errmsg ("missing interface name or sw_if_index");
10721 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10723 mp->sw_if_index = ntohl (sw_if_index);
10724 mp->table_index = ntohl (table_index);
10725 mp->is_ipv6 = is_ipv6;
10733 api_classify_set_interface_l2_tables (vat_main_t * vam)
10735 unformat_input_t *i = vam->input;
10736 vl_api_classify_set_interface_l2_tables_t *mp;
10738 int sw_if_index_set;
10739 u32 ip4_table_index = ~0;
10740 u32 ip6_table_index = ~0;
10741 u32 other_table_index = ~0;
10745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10747 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10748 sw_if_index_set = 1;
10749 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10750 sw_if_index_set = 1;
10751 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10753 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10755 else if (unformat (i, "other-table %d", &other_table_index))
10757 else if (unformat (i, "is-input %d", &is_input))
10761 clib_warning ("parse error '%U'", format_unformat_error, i);
10766 if (sw_if_index_set == 0)
10768 errmsg ("missing interface name or sw_if_index");
10773 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10775 mp->sw_if_index = ntohl (sw_if_index);
10776 mp->ip4_table_index = ntohl (ip4_table_index);
10777 mp->ip6_table_index = ntohl (ip6_table_index);
10778 mp->other_table_index = ntohl (other_table_index);
10779 mp->is_input = (u8) is_input;
10787 api_set_ipfix_exporter (vat_main_t * vam)
10789 unformat_input_t *i = vam->input;
10790 vl_api_set_ipfix_exporter_t *mp;
10791 ip4_address_t collector_address;
10792 u8 collector_address_set = 0;
10793 u32 collector_port = ~0;
10794 ip4_address_t src_address;
10795 u8 src_address_set = 0;
10798 u32 template_interval = ~0;
10799 u8 udp_checksum = 0;
10802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10804 if (unformat (i, "collector_address %U", unformat_ip4_address,
10805 &collector_address))
10806 collector_address_set = 1;
10807 else if (unformat (i, "collector_port %d", &collector_port))
10809 else if (unformat (i, "src_address %U", unformat_ip4_address,
10811 src_address_set = 1;
10812 else if (unformat (i, "vrf_id %d", &vrf_id))
10814 else if (unformat (i, "path_mtu %d", &path_mtu))
10816 else if (unformat (i, "template_interval %d", &template_interval))
10818 else if (unformat (i, "udp_checksum"))
10824 if (collector_address_set == 0)
10826 errmsg ("collector_address required");
10830 if (src_address_set == 0)
10832 errmsg ("src_address required");
10836 M (SET_IPFIX_EXPORTER, mp);
10838 memcpy (mp->collector_address.un.ip4, collector_address.data,
10839 sizeof (collector_address.data));
10840 mp->collector_port = htons ((u16) collector_port);
10841 memcpy (mp->src_address.un.ip4, src_address.data,
10842 sizeof (src_address.data));
10843 mp->vrf_id = htonl (vrf_id);
10844 mp->path_mtu = htonl (path_mtu);
10845 mp->template_interval = htonl (template_interval);
10846 mp->udp_checksum = udp_checksum;
10854 api_set_ipfix_classify_stream (vat_main_t * vam)
10856 unformat_input_t *i = vam->input;
10857 vl_api_set_ipfix_classify_stream_t *mp;
10859 u32 src_port = UDP_DST_PORT_ipfix;
10862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10864 if (unformat (i, "domain %d", &domain_id))
10866 else if (unformat (i, "src_port %d", &src_port))
10870 errmsg ("unknown input `%U'", format_unformat_error, i);
10875 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10877 mp->domain_id = htonl (domain_id);
10878 mp->src_port = htons ((u16) src_port);
10886 api_ipfix_classify_table_add_del (vat_main_t * vam)
10888 unformat_input_t *i = vam->input;
10889 vl_api_ipfix_classify_table_add_del_t *mp;
10891 u32 classify_table_index = ~0;
10893 u8 transport_protocol = 255;
10896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10898 if (unformat (i, "add"))
10900 else if (unformat (i, "del"))
10902 else if (unformat (i, "table %d", &classify_table_index))
10904 else if (unformat (i, "ip4"))
10906 else if (unformat (i, "ip6"))
10908 else if (unformat (i, "tcp"))
10909 transport_protocol = 6;
10910 else if (unformat (i, "udp"))
10911 transport_protocol = 17;
10914 errmsg ("unknown input `%U'", format_unformat_error, i);
10921 errmsg ("expecting: add|del");
10924 if (classify_table_index == ~0)
10926 errmsg ("classifier table not specified");
10929 if (ip_version == 0)
10931 errmsg ("IP version not specified");
10935 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10937 mp->is_add = is_add;
10938 mp->table_id = htonl (classify_table_index);
10939 mp->ip_version = ip_version;
10940 mp->transport_protocol = transport_protocol;
10948 api_get_node_index (vat_main_t * vam)
10950 unformat_input_t *i = vam->input;
10951 vl_api_get_node_index_t *mp;
10955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10957 if (unformat (i, "node %s", &name))
10964 errmsg ("node name required");
10967 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10969 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10973 M (GET_NODE_INDEX, mp);
10974 clib_memcpy (mp->node_name, name, vec_len (name));
10983 api_get_next_index (vat_main_t * vam)
10985 unformat_input_t *i = vam->input;
10986 vl_api_get_next_index_t *mp;
10987 u8 *node_name = 0, *next_node_name = 0;
10990 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10992 if (unformat (i, "node-name %s", &node_name))
10994 else if (unformat (i, "next-node-name %s", &next_node_name))
10998 if (node_name == 0)
11000 errmsg ("node name required");
11003 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11005 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11009 if (next_node_name == 0)
11011 errmsg ("next node name required");
11014 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11016 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11020 M (GET_NEXT_INDEX, mp);
11021 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11022 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11023 vec_free (node_name);
11024 vec_free (next_node_name);
11032 api_add_node_next (vat_main_t * vam)
11034 unformat_input_t *i = vam->input;
11035 vl_api_add_node_next_t *mp;
11040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11042 if (unformat (i, "node %s", &name))
11044 else if (unformat (i, "next %s", &next))
11051 errmsg ("node name required");
11054 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11056 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11061 errmsg ("next node required");
11064 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11066 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11070 M (ADD_NODE_NEXT, mp);
11071 clib_memcpy (mp->node_name, name, vec_len (name));
11072 clib_memcpy (mp->next_name, next, vec_len (next));
11082 api_l2tpv3_create_tunnel (vat_main_t * vam)
11084 unformat_input_t *i = vam->input;
11085 ip6_address_t client_address, our_address;
11086 int client_address_set = 0;
11087 int our_address_set = 0;
11088 u32 local_session_id = 0;
11089 u32 remote_session_id = 0;
11090 u64 local_cookie = 0;
11091 u64 remote_cookie = 0;
11092 u8 l2_sublayer_present = 0;
11093 vl_api_l2tpv3_create_tunnel_t *mp;
11096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11098 if (unformat (i, "client_address %U", unformat_ip6_address,
11100 client_address_set = 1;
11101 else if (unformat (i, "our_address %U", unformat_ip6_address,
11103 our_address_set = 1;
11104 else if (unformat (i, "local_session_id %d", &local_session_id))
11106 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11108 else if (unformat (i, "local_cookie %lld", &local_cookie))
11110 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11112 else if (unformat (i, "l2-sublayer-present"))
11113 l2_sublayer_present = 1;
11118 if (client_address_set == 0)
11120 errmsg ("client_address required");
11124 if (our_address_set == 0)
11126 errmsg ("our_address required");
11130 M (L2TPV3_CREATE_TUNNEL, mp);
11132 clib_memcpy (mp->client_address.un.ip6, client_address.as_u8,
11133 sizeof (ip6_address_t));
11135 clib_memcpy (mp->our_address.un.ip6, our_address.as_u8,
11136 sizeof (ip6_address_t));
11138 mp->local_session_id = ntohl (local_session_id);
11139 mp->remote_session_id = ntohl (remote_session_id);
11140 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11141 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11142 mp->l2_sublayer_present = l2_sublayer_present;
11150 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11152 unformat_input_t *i = vam->input;
11154 u8 sw_if_index_set = 0;
11155 u64 new_local_cookie = 0;
11156 u64 new_remote_cookie = 0;
11157 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11162 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11163 sw_if_index_set = 1;
11164 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11165 sw_if_index_set = 1;
11166 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11168 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11174 if (sw_if_index_set == 0)
11176 errmsg ("missing interface name or sw_if_index");
11180 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11182 mp->sw_if_index = ntohl (sw_if_index);
11183 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11184 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11192 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11194 unformat_input_t *i = vam->input;
11195 vl_api_l2tpv3_interface_enable_disable_t *mp;
11197 u8 sw_if_index_set = 0;
11198 u8 enable_disable = 1;
11201 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11203 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11204 sw_if_index_set = 1;
11205 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11206 sw_if_index_set = 1;
11207 else if (unformat (i, "enable"))
11208 enable_disable = 1;
11209 else if (unformat (i, "disable"))
11210 enable_disable = 0;
11215 if (sw_if_index_set == 0)
11217 errmsg ("missing interface name or sw_if_index");
11221 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11223 mp->sw_if_index = ntohl (sw_if_index);
11224 mp->enable_disable = enable_disable;
11232 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11234 unformat_input_t *i = vam->input;
11235 vl_api_l2tpv3_set_lookup_key_t *mp;
11239 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11241 if (unformat (i, "lookup_v6_src"))
11242 key = L2T_LOOKUP_SRC_ADDRESS;
11243 else if (unformat (i, "lookup_v6_dst"))
11244 key = L2T_LOOKUP_DST_ADDRESS;
11245 else if (unformat (i, "lookup_session_id"))
11246 key = L2T_LOOKUP_SESSION_ID;
11251 if (key == (u8) ~ 0)
11253 errmsg ("l2tp session lookup key unset");
11257 M (L2TPV3_SET_LOOKUP_KEY, mp);
11266 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11267 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11269 vat_main_t *vam = &vat_main;
11271 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11272 format_ip6_address, mp->our_address,
11273 format_ip6_address, mp->client_address,
11274 clib_net_to_host_u32 (mp->sw_if_index));
11277 " local cookies %016llx %016llx remote cookie %016llx",
11278 clib_net_to_host_u64 (mp->local_cookie[0]),
11279 clib_net_to_host_u64 (mp->local_cookie[1]),
11280 clib_net_to_host_u64 (mp->remote_cookie));
11282 print (vam->ofp, " local session-id %d remote session-id %d",
11283 clib_net_to_host_u32 (mp->local_session_id),
11284 clib_net_to_host_u32 (mp->remote_session_id));
11286 print (vam->ofp, " l2 specific sublayer %s\n",
11287 mp->l2_sublayer_present ? "preset" : "absent");
11291 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11292 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11294 vat_main_t *vam = &vat_main;
11295 vat_json_node_t *node = NULL;
11296 struct in6_addr addr;
11298 if (VAT_JSON_ARRAY != vam->json_tree.type)
11300 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11301 vat_json_init_array (&vam->json_tree);
11303 node = vat_json_array_add (&vam->json_tree);
11305 vat_json_init_object (node);
11307 clib_memcpy (&addr, mp->our_address.un.ip6, sizeof (addr));
11308 vat_json_object_add_ip6 (node, "our_address", addr);
11309 clib_memcpy (&addr, mp->client_address.un.ip6, sizeof (addr));
11310 vat_json_object_add_ip6 (node, "client_address", addr);
11312 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11313 vat_json_init_array (lc);
11314 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11315 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11316 vat_json_object_add_uint (node, "remote_cookie",
11317 clib_net_to_host_u64 (mp->remote_cookie));
11319 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11320 vat_json_object_add_uint (node, "local_session_id",
11321 clib_net_to_host_u32 (mp->local_session_id));
11322 vat_json_object_add_uint (node, "remote_session_id",
11323 clib_net_to_host_u32 (mp->remote_session_id));
11324 vat_json_object_add_string_copy (node, "l2_sublayer",
11325 mp->l2_sublayer_present ? (u8 *) "present"
11326 : (u8 *) "absent");
11330 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11332 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11333 vl_api_control_ping_t *mp_ping;
11336 /* Get list of l2tpv3-tunnel interfaces */
11337 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11340 /* Use a control ping for synchronization */
11341 MPING (CONTROL_PING, mp_ping);
11349 static void vl_api_sw_interface_tap_v2_details_t_handler
11350 (vl_api_sw_interface_tap_v2_details_t * mp)
11352 vat_main_t *vam = &vat_main;
11355 format (0, "%U/%d", format_ip4_address, mp->host_ip4_prefix.address,
11356 mp->host_ip4_prefix.len);
11358 format (0, "%U/%d", format_ip6_address, mp->host_ip6_prefix.address,
11359 mp->host_ip6_prefix.len);
11362 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
11363 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
11364 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11365 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
11366 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
11372 static void vl_api_sw_interface_tap_v2_details_t_handler_json
11373 (vl_api_sw_interface_tap_v2_details_t * mp)
11375 vat_main_t *vam = &vat_main;
11376 vat_json_node_t *node = NULL;
11378 if (VAT_JSON_ARRAY != vam->json_tree.type)
11380 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11381 vat_json_init_array (&vam->json_tree);
11383 node = vat_json_array_add (&vam->json_tree);
11385 vat_json_init_object (node);
11386 vat_json_object_add_uint (node, "id", ntohl (mp->id));
11387 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11388 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
11389 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11390 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11391 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11392 vat_json_object_add_string_copy (node, "host_mac_addr",
11393 format (0, "%U", format_ethernet_address,
11394 &mp->host_mac_addr));
11395 vat_json_object_add_string_copy (node, "host_namespace",
11396 mp->host_namespace);
11397 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
11398 vat_json_object_add_string_copy (node, "host_ip4_addr",
11399 format (0, "%U/%d", format_ip4_address,
11400 mp->host_ip4_prefix.address,
11401 mp->host_ip4_prefix.len));
11402 vat_json_object_add_string_copy (node, "host_ip6_prefix",
11403 format (0, "%U/%d", format_ip6_address,
11404 mp->host_ip6_prefix.address,
11405 mp->host_ip6_prefix.len));
11410 api_sw_interface_tap_v2_dump (vat_main_t * vam)
11412 vl_api_sw_interface_tap_v2_dump_t *mp;
11413 vl_api_control_ping_t *mp_ping;
11417 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
11418 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
11419 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
11422 /* Get list of tap interfaces */
11423 M (SW_INTERFACE_TAP_V2_DUMP, mp);
11426 /* Use a control ping for synchronization */
11427 MPING (CONTROL_PING, mp_ping);
11434 static void vl_api_sw_interface_virtio_pci_details_t_handler
11435 (vl_api_sw_interface_virtio_pci_details_t * mp)
11437 vat_main_t *vam = &vat_main;
11452 addr.domain = ntohs (mp->pci_addr.domain);
11453 addr.bus = mp->pci_addr.bus;
11454 addr.slot = mp->pci_addr.slot;
11455 addr.function = mp->pci_addr.function;
11457 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
11458 addr.slot, addr.function);
11461 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
11462 pci_addr, ntohl (mp->sw_if_index),
11463 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11464 format_ethernet_address, mp->mac_addr,
11465 clib_net_to_host_u64 (mp->features));
11466 vec_free (pci_addr);
11469 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
11470 (vl_api_sw_interface_virtio_pci_details_t * mp)
11472 vat_main_t *vam = &vat_main;
11473 vat_json_node_t *node = NULL;
11474 vlib_pci_addr_t pci_addr;
11476 if (VAT_JSON_ARRAY != vam->json_tree.type)
11478 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11479 vat_json_init_array (&vam->json_tree);
11481 node = vat_json_array_add (&vam->json_tree);
11483 pci_addr.domain = ntohs (mp->pci_addr.domain);
11484 pci_addr.bus = mp->pci_addr.bus;
11485 pci_addr.slot = mp->pci_addr.slot;
11486 pci_addr.function = mp->pci_addr.function;
11488 vat_json_init_object (node);
11489 vat_json_object_add_uint (node, "pci-addr", pci_addr.as_u32);
11490 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11491 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11492 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11493 vat_json_object_add_uint (node, "features",
11494 clib_net_to_host_u64 (mp->features));
11495 vat_json_object_add_string_copy (node, "mac_addr",
11496 format (0, "%U", format_ethernet_address,
11501 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
11503 vl_api_sw_interface_virtio_pci_dump_t *mp;
11504 vl_api_control_ping_t *mp_ping;
11508 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
11509 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
11510 "mac_addr", "features");
11512 /* Get list of tap interfaces */
11513 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
11516 /* Use a control ping for synchronization */
11517 MPING (CONTROL_PING, mp_ping);
11525 api_vxlan_offload_rx (vat_main_t * vam)
11527 unformat_input_t *line_input = vam->input;
11528 vl_api_vxlan_offload_rx_t *mp;
11529 u32 hw_if_index = ~0, rx_if_index = ~0;
11533 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11535 if (unformat (line_input, "del"))
11537 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
11540 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
11542 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
11545 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
11549 errmsg ("parse error '%U'", format_unformat_error, line_input);
11554 if (hw_if_index == ~0)
11556 errmsg ("no hw interface");
11560 if (rx_if_index == ~0)
11562 errmsg ("no rx tunnel");
11566 M (VXLAN_OFFLOAD_RX, mp);
11568 mp->hw_if_index = ntohl (hw_if_index);
11569 mp->sw_if_index = ntohl (rx_if_index);
11570 mp->enable = is_add;
11577 static uword unformat_vxlan_decap_next
11578 (unformat_input_t * input, va_list * args)
11580 u32 *result = va_arg (*args, u32 *);
11583 if (unformat (input, "l2"))
11584 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11585 else if (unformat (input, "%d", &tmp))
11593 api_vxlan_add_del_tunnel (vat_main_t * vam)
11595 unformat_input_t *line_input = vam->input;
11596 vl_api_vxlan_add_del_tunnel_t *mp;
11597 ip46_address_t src, dst;
11599 u8 ipv4_set = 0, ipv6_set = 0;
11604 u32 mcast_sw_if_index = ~0;
11605 u32 encap_vrf_id = 0;
11606 u32 decap_next_index = ~0;
11610 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11611 clib_memset (&src, 0, sizeof src);
11612 clib_memset (&dst, 0, sizeof dst);
11614 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11616 if (unformat (line_input, "del"))
11618 else if (unformat (line_input, "instance %d", &instance))
11621 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11627 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11633 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11639 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11644 else if (unformat (line_input, "group %U %U",
11645 unformat_ip4_address, &dst.ip4,
11646 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11648 grp_set = dst_set = 1;
11651 else if (unformat (line_input, "group %U",
11652 unformat_ip4_address, &dst.ip4))
11654 grp_set = dst_set = 1;
11657 else if (unformat (line_input, "group %U %U",
11658 unformat_ip6_address, &dst.ip6,
11659 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11661 grp_set = dst_set = 1;
11664 else if (unformat (line_input, "group %U",
11665 unformat_ip6_address, &dst.ip6))
11667 grp_set = dst_set = 1;
11671 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11673 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11675 else if (unformat (line_input, "decap-next %U",
11676 unformat_vxlan_decap_next, &decap_next_index))
11678 else if (unformat (line_input, "vni %d", &vni))
11682 errmsg ("parse error '%U'", format_unformat_error, line_input);
11689 errmsg ("tunnel src address not specified");
11694 errmsg ("tunnel dst address not specified");
11698 if (grp_set && !ip46_address_is_multicast (&dst))
11700 errmsg ("tunnel group address not multicast");
11703 if (grp_set && mcast_sw_if_index == ~0)
11705 errmsg ("tunnel nonexistent multicast device");
11708 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11710 errmsg ("tunnel dst address must be unicast");
11715 if (ipv4_set && ipv6_set)
11717 errmsg ("both IPv4 and IPv6 addresses specified");
11721 if ((vni == 0) || (vni >> 24))
11723 errmsg ("vni not specified or out of range");
11727 M (VXLAN_ADD_DEL_TUNNEL, mp);
11731 clib_memcpy (mp->src_address.un.ip6, &src.ip6, sizeof (src.ip6));
11732 clib_memcpy (mp->dst_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
11736 clib_memcpy (mp->src_address.un.ip4, &src.ip4, sizeof (src.ip4));
11737 clib_memcpy (mp->dst_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
11739 mp->src_address.af = ipv6_set;
11740 mp->dst_address.af = ipv6_set;
11742 mp->instance = htonl (instance);
11743 mp->encap_vrf_id = ntohl (encap_vrf_id);
11744 mp->decap_next_index = ntohl (decap_next_index);
11745 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11746 mp->vni = ntohl (vni);
11747 mp->is_add = is_add;
11754 static void vl_api_vxlan_tunnel_details_t_handler
11755 (vl_api_vxlan_tunnel_details_t * mp)
11757 vat_main_t *vam = &vat_main;
11758 ip46_address_t src =
11759 to_ip46 (mp->dst_address.af, (u8 *) & mp->dst_address.un);
11760 ip46_address_t dst =
11761 to_ip46 (mp->dst_address.af, (u8 *) & mp->src_address.un);
11763 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
11764 ntohl (mp->sw_if_index),
11765 ntohl (mp->instance),
11766 format_ip46_address, &src, IP46_TYPE_ANY,
11767 format_ip46_address, &dst, IP46_TYPE_ANY,
11768 ntohl (mp->encap_vrf_id),
11769 ntohl (mp->decap_next_index), ntohl (mp->vni),
11770 ntohl (mp->mcast_sw_if_index));
11773 static void vl_api_vxlan_tunnel_details_t_handler_json
11774 (vl_api_vxlan_tunnel_details_t * mp)
11776 vat_main_t *vam = &vat_main;
11777 vat_json_node_t *node = NULL;
11779 if (VAT_JSON_ARRAY != vam->json_tree.type)
11781 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11782 vat_json_init_array (&vam->json_tree);
11784 node = vat_json_array_add (&vam->json_tree);
11786 vat_json_init_object (node);
11787 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11789 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
11791 if (mp->src_address.af)
11793 struct in6_addr ip6;
11795 clib_memcpy (&ip6, mp->src_address.un.ip6, sizeof (ip6));
11796 vat_json_object_add_ip6 (node, "src_address", ip6);
11797 clib_memcpy (&ip6, mp->dst_address.un.ip6, sizeof (ip6));
11798 vat_json_object_add_ip6 (node, "dst_address", ip6);
11802 struct in_addr ip4;
11804 clib_memcpy (&ip4, mp->src_address.un.ip4, sizeof (ip4));
11805 vat_json_object_add_ip4 (node, "src_address", ip4);
11806 clib_memcpy (&ip4, mp->dst_address.un.ip4, sizeof (ip4));
11807 vat_json_object_add_ip4 (node, "dst_address", ip4);
11809 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11810 vat_json_object_add_uint (node, "decap_next_index",
11811 ntohl (mp->decap_next_index));
11812 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11813 vat_json_object_add_uint (node, "mcast_sw_if_index",
11814 ntohl (mp->mcast_sw_if_index));
11818 api_vxlan_tunnel_dump (vat_main_t * vam)
11820 unformat_input_t *i = vam->input;
11821 vl_api_vxlan_tunnel_dump_t *mp;
11822 vl_api_control_ping_t *mp_ping;
11824 u8 sw_if_index_set = 0;
11827 /* Parse args required to build the message */
11828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11830 if (unformat (i, "sw_if_index %d", &sw_if_index))
11831 sw_if_index_set = 1;
11836 if (sw_if_index_set == 0)
11841 if (!vam->json_output)
11843 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
11844 "sw_if_index", "instance", "src_address", "dst_address",
11845 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11848 /* Get list of vxlan-tunnel interfaces */
11849 M (VXLAN_TUNNEL_DUMP, mp);
11851 mp->sw_if_index = htonl (sw_if_index);
11855 /* Use a control ping for synchronization */
11856 MPING (CONTROL_PING, mp_ping);
11863 static uword unformat_geneve_decap_next
11864 (unformat_input_t * input, va_list * args)
11866 u32 *result = va_arg (*args, u32 *);
11869 if (unformat (input, "l2"))
11870 *result = GENEVE_INPUT_NEXT_L2_INPUT;
11871 else if (unformat (input, "%d", &tmp))
11879 api_geneve_add_del_tunnel (vat_main_t * vam)
11881 unformat_input_t *line_input = vam->input;
11882 vl_api_geneve_add_del_tunnel_t *mp;
11883 ip46_address_t src, dst;
11885 u8 ipv4_set = 0, ipv6_set = 0;
11889 u32 mcast_sw_if_index = ~0;
11890 u32 encap_vrf_id = 0;
11891 u32 decap_next_index = ~0;
11895 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11896 clib_memset (&src, 0, sizeof src);
11897 clib_memset (&dst, 0, sizeof dst);
11899 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11901 if (unformat (line_input, "del"))
11904 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11910 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11916 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11922 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11927 else if (unformat (line_input, "group %U %U",
11928 unformat_ip4_address, &dst.ip4,
11929 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11931 grp_set = dst_set = 1;
11934 else if (unformat (line_input, "group %U",
11935 unformat_ip4_address, &dst.ip4))
11937 grp_set = dst_set = 1;
11940 else if (unformat (line_input, "group %U %U",
11941 unformat_ip6_address, &dst.ip6,
11942 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11944 grp_set = dst_set = 1;
11947 else if (unformat (line_input, "group %U",
11948 unformat_ip6_address, &dst.ip6))
11950 grp_set = dst_set = 1;
11954 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11956 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11958 else if (unformat (line_input, "decap-next %U",
11959 unformat_geneve_decap_next, &decap_next_index))
11961 else if (unformat (line_input, "vni %d", &vni))
11965 errmsg ("parse error '%U'", format_unformat_error, line_input);
11972 errmsg ("tunnel src address not specified");
11977 errmsg ("tunnel dst address not specified");
11981 if (grp_set && !ip46_address_is_multicast (&dst))
11983 errmsg ("tunnel group address not multicast");
11986 if (grp_set && mcast_sw_if_index == ~0)
11988 errmsg ("tunnel nonexistent multicast device");
11991 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11993 errmsg ("tunnel dst address must be unicast");
11998 if (ipv4_set && ipv6_set)
12000 errmsg ("both IPv4 and IPv6 addresses specified");
12004 if ((vni == 0) || (vni >> 24))
12006 errmsg ("vni not specified or out of range");
12010 M (GENEVE_ADD_DEL_TUNNEL, mp);
12014 clib_memcpy (&mp->local_address.un.ip6, &src.ip6, sizeof (src.ip6));
12015 clib_memcpy (&mp->remote_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
12019 clib_memcpy (&mp->local_address.un.ip4, &src.ip4, sizeof (src.ip4));
12020 clib_memcpy (&mp->remote_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
12022 mp->encap_vrf_id = ntohl (encap_vrf_id);
12023 mp->decap_next_index = ntohl (decap_next_index);
12024 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12025 mp->vni = ntohl (vni);
12026 mp->is_add = is_add;
12033 static void vl_api_geneve_tunnel_details_t_handler
12034 (vl_api_geneve_tunnel_details_t * mp)
12036 vat_main_t *vam = &vat_main;
12037 ip46_address_t src = {.as_u64[0] = 0,.as_u64[1] = 0 };
12038 ip46_address_t dst = {.as_u64[0] = 0,.as_u64[1] = 0 };
12040 if (mp->src_address.af == ADDRESS_IP6)
12042 clib_memcpy (&src.ip6, &mp->src_address.un.ip6, sizeof (ip6_address_t));
12043 clib_memcpy (&dst.ip6, &mp->dst_address.un.ip6, sizeof (ip6_address_t));
12047 clib_memcpy (&src.ip4, &mp->src_address.un.ip4, sizeof (ip4_address_t));
12048 clib_memcpy (&dst.ip4, &mp->dst_address.un.ip4, sizeof (ip4_address_t));
12051 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12052 ntohl (mp->sw_if_index),
12053 format_ip46_address, &src, IP46_TYPE_ANY,
12054 format_ip46_address, &dst, IP46_TYPE_ANY,
12055 ntohl (mp->encap_vrf_id),
12056 ntohl (mp->decap_next_index), ntohl (mp->vni),
12057 ntohl (mp->mcast_sw_if_index));
12060 static void vl_api_geneve_tunnel_details_t_handler_json
12061 (vl_api_geneve_tunnel_details_t * mp)
12063 vat_main_t *vam = &vat_main;
12064 vat_json_node_t *node = NULL;
12067 if (VAT_JSON_ARRAY != vam->json_tree.type)
12069 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12070 vat_json_init_array (&vam->json_tree);
12072 node = vat_json_array_add (&vam->json_tree);
12074 vat_json_init_object (node);
12075 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12076 is_ipv6 = mp->src_address.af == ADDRESS_IP6;
12079 struct in6_addr ip6;
12081 clib_memcpy (&ip6, &mp->src_address.un.ip6, sizeof (ip6));
12082 vat_json_object_add_ip6 (node, "src_address", ip6);
12083 clib_memcpy (&ip6, &mp->dst_address.un.ip6, sizeof (ip6));
12084 vat_json_object_add_ip6 (node, "dst_address", ip6);
12088 struct in_addr ip4;
12090 clib_memcpy (&ip4, &mp->src_address.un.ip4, sizeof (ip4));
12091 vat_json_object_add_ip4 (node, "src_address", ip4);
12092 clib_memcpy (&ip4, &mp->dst_address.un.ip4, sizeof (ip4));
12093 vat_json_object_add_ip4 (node, "dst_address", ip4);
12095 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12096 vat_json_object_add_uint (node, "decap_next_index",
12097 ntohl (mp->decap_next_index));
12098 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12099 vat_json_object_add_uint (node, "mcast_sw_if_index",
12100 ntohl (mp->mcast_sw_if_index));
12104 api_geneve_tunnel_dump (vat_main_t * vam)
12106 unformat_input_t *i = vam->input;
12107 vl_api_geneve_tunnel_dump_t *mp;
12108 vl_api_control_ping_t *mp_ping;
12110 u8 sw_if_index_set = 0;
12113 /* Parse args required to build the message */
12114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12116 if (unformat (i, "sw_if_index %d", &sw_if_index))
12117 sw_if_index_set = 1;
12122 if (sw_if_index_set == 0)
12127 if (!vam->json_output)
12129 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12130 "sw_if_index", "local_address", "remote_address",
12131 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12134 /* Get list of geneve-tunnel interfaces */
12135 M (GENEVE_TUNNEL_DUMP, mp);
12137 mp->sw_if_index = htonl (sw_if_index);
12141 /* Use a control ping for synchronization */
12142 M (CONTROL_PING, mp_ping);
12150 api_gre_tunnel_add_del (vat_main_t * vam)
12152 unformat_input_t *line_input = vam->input;
12153 vl_api_address_t src = { }, dst =
12156 vl_api_gre_tunnel_add_del_t *mp;
12157 vl_api_gre_tunnel_type_t t_type;
12161 u32 outer_table_id = 0;
12162 u32 session_id = 0;
12166 t_type = GRE_API_TUNNEL_TYPE_L3;
12168 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12170 if (unformat (line_input, "del"))
12172 else if (unformat (line_input, "instance %d", &instance))
12174 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
12178 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
12182 else if (unformat (line_input, "outer-table-id %d", &outer_table_id))
12184 else if (unformat (line_input, "teb"))
12185 t_type = GRE_API_TUNNEL_TYPE_TEB;
12186 else if (unformat (line_input, "erspan %d", &session_id))
12187 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
12190 errmsg ("parse error '%U'", format_unformat_error, line_input);
12197 errmsg ("tunnel src address not specified");
12202 errmsg ("tunnel dst address not specified");
12206 M (GRE_TUNNEL_ADD_DEL, mp);
12208 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
12209 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
12211 mp->tunnel.instance = htonl (instance);
12212 mp->tunnel.outer_table_id = htonl (outer_table_id);
12213 mp->is_add = is_add;
12214 mp->tunnel.session_id = htons ((u16) session_id);
12215 mp->tunnel.type = htonl (t_type);
12222 static void vl_api_gre_tunnel_details_t_handler
12223 (vl_api_gre_tunnel_details_t * mp)
12225 vat_main_t *vam = &vat_main;
12227 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
12228 ntohl (mp->tunnel.sw_if_index),
12229 ntohl (mp->tunnel.instance),
12230 format_vl_api_address, &mp->tunnel.src,
12231 format_vl_api_address, &mp->tunnel.dst,
12232 mp->tunnel.type, ntohl (mp->tunnel.outer_table_id),
12233 ntohl (mp->tunnel.session_id));
12236 static void vl_api_gre_tunnel_details_t_handler_json
12237 (vl_api_gre_tunnel_details_t * mp)
12239 vat_main_t *vam = &vat_main;
12240 vat_json_node_t *node = NULL;
12242 if (VAT_JSON_ARRAY != vam->json_tree.type)
12244 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12245 vat_json_init_array (&vam->json_tree);
12247 node = vat_json_array_add (&vam->json_tree);
12249 vat_json_init_object (node);
12250 vat_json_object_add_uint (node, "sw_if_index",
12251 ntohl (mp->tunnel.sw_if_index));
12252 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
12254 vat_json_object_add_address (node, "src", &mp->tunnel.src);
12255 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
12256 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
12257 vat_json_object_add_uint (node, "outer_table_id",
12258 ntohl (mp->tunnel.outer_table_id));
12259 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
12263 api_gre_tunnel_dump (vat_main_t * vam)
12265 unformat_input_t *i = vam->input;
12266 vl_api_gre_tunnel_dump_t *mp;
12267 vl_api_control_ping_t *mp_ping;
12269 u8 sw_if_index_set = 0;
12272 /* Parse args required to build the message */
12273 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12275 if (unformat (i, "sw_if_index %d", &sw_if_index))
12276 sw_if_index_set = 1;
12281 if (sw_if_index_set == 0)
12286 if (!vam->json_output)
12288 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
12289 "sw_if_index", "instance", "src_address", "dst_address",
12290 "tunnel_type", "outer_fib_id", "session_id");
12293 /* Get list of gre-tunnel interfaces */
12294 M (GRE_TUNNEL_DUMP, mp);
12296 mp->sw_if_index = htonl (sw_if_index);
12300 /* Use a control ping for synchronization */
12301 MPING (CONTROL_PING, mp_ping);
12309 api_l2_fib_clear_table (vat_main_t * vam)
12311 // unformat_input_t * i = vam->input;
12312 vl_api_l2_fib_clear_table_t *mp;
12315 M (L2_FIB_CLEAR_TABLE, mp);
12323 api_l2_interface_efp_filter (vat_main_t * vam)
12325 unformat_input_t *i = vam->input;
12326 vl_api_l2_interface_efp_filter_t *mp;
12329 u8 sw_if_index_set = 0;
12332 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12334 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12335 sw_if_index_set = 1;
12336 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12337 sw_if_index_set = 1;
12338 else if (unformat (i, "enable"))
12340 else if (unformat (i, "disable"))
12344 clib_warning ("parse error '%U'", format_unformat_error, i);
12349 if (sw_if_index_set == 0)
12351 errmsg ("missing sw_if_index");
12355 M (L2_INTERFACE_EFP_FILTER, mp);
12357 mp->sw_if_index = ntohl (sw_if_index);
12358 mp->enable_disable = enable;
12365 #define foreach_vtr_op \
12366 _("disable", L2_VTR_DISABLED) \
12367 _("push-1", L2_VTR_PUSH_1) \
12368 _("push-2", L2_VTR_PUSH_2) \
12369 _("pop-1", L2_VTR_POP_1) \
12370 _("pop-2", L2_VTR_POP_2) \
12371 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12372 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12373 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12374 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12377 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12379 unformat_input_t *i = vam->input;
12380 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12382 u8 sw_if_index_set = 0;
12385 u32 push_dot1q = 1;
12390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12392 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12393 sw_if_index_set = 1;
12394 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12395 sw_if_index_set = 1;
12396 else if (unformat (i, "vtr_op %d", &vtr_op))
12398 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12401 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12403 else if (unformat (i, "tag1 %d", &tag1))
12405 else if (unformat (i, "tag2 %d", &tag2))
12409 clib_warning ("parse error '%U'", format_unformat_error, i);
12414 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12416 errmsg ("missing vtr operation or sw_if_index");
12420 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12421 mp->sw_if_index = ntohl (sw_if_index);
12422 mp->vtr_op = ntohl (vtr_op);
12423 mp->push_dot1q = ntohl (push_dot1q);
12424 mp->tag1 = ntohl (tag1);
12425 mp->tag2 = ntohl (tag2);
12433 api_create_vhost_user_if (vat_main_t * vam)
12435 unformat_input_t *i = vam->input;
12436 vl_api_create_vhost_user_if_t *mp;
12439 u8 file_name_set = 0;
12440 u32 custom_dev_instance = ~0;
12442 u8 use_custom_mac = 0;
12443 u8 disable_mrg_rxbuf = 0;
12444 u8 disable_indirect_desc = 0;
12449 /* Shut up coverity */
12450 clib_memset (hwaddr, 0, sizeof (hwaddr));
12452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12454 if (unformat (i, "socket %s", &file_name))
12458 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12460 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12461 use_custom_mac = 1;
12462 else if (unformat (i, "server"))
12464 else if (unformat (i, "disable_mrg_rxbuf"))
12465 disable_mrg_rxbuf = 1;
12466 else if (unformat (i, "disable_indirect_desc"))
12467 disable_indirect_desc = 1;
12468 else if (unformat (i, "gso"))
12470 else if (unformat (i, "tag %s", &tag))
12476 if (file_name_set == 0)
12478 errmsg ("missing socket file name");
12482 if (vec_len (file_name) > 255)
12484 errmsg ("socket file name too long");
12487 vec_add1 (file_name, 0);
12489 M (CREATE_VHOST_USER_IF, mp);
12491 mp->is_server = is_server;
12492 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
12493 mp->disable_indirect_desc = disable_indirect_desc;
12494 mp->enable_gso = enable_gso;
12495 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12496 vec_free (file_name);
12497 if (custom_dev_instance != ~0)
12500 mp->custom_dev_instance = ntohl (custom_dev_instance);
12503 mp->use_custom_mac = use_custom_mac;
12504 clib_memcpy (mp->mac_address, hwaddr, 6);
12506 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12515 api_modify_vhost_user_if (vat_main_t * vam)
12517 unformat_input_t *i = vam->input;
12518 vl_api_modify_vhost_user_if_t *mp;
12521 u8 file_name_set = 0;
12522 u32 custom_dev_instance = ~0;
12523 u8 sw_if_index_set = 0;
12524 u32 sw_if_index = (u32) ~ 0;
12528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12530 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12531 sw_if_index_set = 1;
12532 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12533 sw_if_index_set = 1;
12534 else if (unformat (i, "socket %s", &file_name))
12538 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12540 else if (unformat (i, "server"))
12542 else if (unformat (i, "gso"))
12548 if (sw_if_index_set == 0)
12550 errmsg ("missing sw_if_index or interface name");
12554 if (file_name_set == 0)
12556 errmsg ("missing socket file name");
12560 if (vec_len (file_name) > 255)
12562 errmsg ("socket file name too long");
12565 vec_add1 (file_name, 0);
12567 M (MODIFY_VHOST_USER_IF, mp);
12569 mp->sw_if_index = ntohl (sw_if_index);
12570 mp->is_server = is_server;
12571 mp->enable_gso = enable_gso;
12572 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12573 vec_free (file_name);
12574 if (custom_dev_instance != ~0)
12577 mp->custom_dev_instance = ntohl (custom_dev_instance);
12586 api_delete_vhost_user_if (vat_main_t * vam)
12588 unformat_input_t *i = vam->input;
12589 vl_api_delete_vhost_user_if_t *mp;
12590 u32 sw_if_index = ~0;
12591 u8 sw_if_index_set = 0;
12594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12596 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12597 sw_if_index_set = 1;
12598 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12599 sw_if_index_set = 1;
12604 if (sw_if_index_set == 0)
12606 errmsg ("missing sw_if_index or interface name");
12611 M (DELETE_VHOST_USER_IF, mp);
12613 mp->sw_if_index = ntohl (sw_if_index);
12620 static void vl_api_sw_interface_vhost_user_details_t_handler
12621 (vl_api_sw_interface_vhost_user_details_t * mp)
12623 vat_main_t *vam = &vat_main;
12627 clib_net_to_host_u32 (mp->features_first_32) | ((u64)
12628 clib_net_to_host_u32
12629 (mp->features_last_32) <<
12632 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12633 (char *) mp->interface_name,
12634 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12635 features, mp->is_server,
12636 ntohl (mp->num_regions), (char *) mp->sock_filename);
12637 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12640 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12641 (vl_api_sw_interface_vhost_user_details_t * mp)
12643 vat_main_t *vam = &vat_main;
12644 vat_json_node_t *node = NULL;
12646 if (VAT_JSON_ARRAY != vam->json_tree.type)
12648 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12649 vat_json_init_array (&vam->json_tree);
12651 node = vat_json_array_add (&vam->json_tree);
12653 vat_json_init_object (node);
12654 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12655 vat_json_object_add_string_copy (node, "interface_name",
12656 mp->interface_name);
12657 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12658 ntohl (mp->virtio_net_hdr_sz));
12659 vat_json_object_add_uint (node, "features_first_32",
12660 clib_net_to_host_u32 (mp->features_first_32));
12661 vat_json_object_add_uint (node, "features_last_32",
12662 clib_net_to_host_u32 (mp->features_last_32));
12663 vat_json_object_add_uint (node, "is_server", mp->is_server);
12664 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12665 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12666 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12670 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12672 vl_api_sw_interface_vhost_user_dump_t *mp;
12673 vl_api_control_ping_t *mp_ping;
12676 "Interface name idx hdr_sz features server regions filename");
12678 /* Get list of vhost-user interfaces */
12679 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12680 mp->sw_if_index = ntohl (~0);
12683 /* Use a control ping for synchronization */
12684 MPING (CONTROL_PING, mp_ping);
12692 api_show_version (vat_main_t * vam)
12694 vl_api_show_version_t *mp;
12697 M (SHOW_VERSION, mp);
12706 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12708 unformat_input_t *line_input = vam->input;
12709 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12710 ip46_address_t local, remote;
12715 u32 mcast_sw_if_index = ~0;
12716 u32 encap_vrf_id = 0;
12717 u32 decap_vrf_id = 0;
12723 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12725 if (unformat (line_input, "del"))
12727 else if (unformat (line_input, "local %U",
12728 unformat_ip46_address, &local))
12732 else if (unformat (line_input, "remote %U",
12733 unformat_ip46_address, &remote))
12737 else if (unformat (line_input, "group %U %U",
12738 unformat_ip46_address, &remote,
12739 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12741 grp_set = remote_set = 1;
12743 else if (unformat (line_input, "group %U",
12744 unformat_ip46_address, &remote))
12746 grp_set = remote_set = 1;
12749 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12751 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12753 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12755 else if (unformat (line_input, "vni %d", &vni))
12757 else if (unformat (line_input, "next-ip4"))
12759 else if (unformat (line_input, "next-ip6"))
12761 else if (unformat (line_input, "next-ethernet"))
12763 else if (unformat (line_input, "next-nsh"))
12767 errmsg ("parse error '%U'", format_unformat_error, line_input);
12772 if (local_set == 0)
12774 errmsg ("tunnel local address not specified");
12777 if (remote_set == 0)
12779 errmsg ("tunnel remote address not specified");
12782 if (grp_set && mcast_sw_if_index == ~0)
12784 errmsg ("tunnel nonexistent multicast device");
12787 if (ip46_address_is_ip4 (&local) != ip46_address_is_ip4 (&remote))
12789 errmsg ("both IPv4 and IPv6 addresses specified");
12795 errmsg ("vni not specified");
12799 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12801 ip_address_encode (&local,
12802 ip46_address_is_ip4 (&local) ? IP46_TYPE_IP4 :
12803 IP46_TYPE_IP6, &mp->local);
12804 ip_address_encode (&remote,
12805 ip46_address_is_ip4 (&remote) ? IP46_TYPE_IP4 :
12806 IP46_TYPE_IP6, &mp->remote);
12808 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12809 mp->encap_vrf_id = ntohl (encap_vrf_id);
12810 mp->decap_vrf_id = ntohl (decap_vrf_id);
12811 mp->protocol = protocol;
12812 mp->vni = ntohl (vni);
12813 mp->is_add = is_add;
12820 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12821 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12823 vat_main_t *vam = &vat_main;
12824 ip46_address_t local, remote;
12826 ip_address_decode (&mp->local, &local);
12827 ip_address_decode (&mp->remote, &remote);
12829 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12830 ntohl (mp->sw_if_index),
12831 format_ip46_address, &local, IP46_TYPE_ANY,
12832 format_ip46_address, &remote, IP46_TYPE_ANY,
12833 ntohl (mp->vni), mp->protocol,
12834 ntohl (mp->mcast_sw_if_index),
12835 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12839 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12840 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12842 vat_main_t *vam = &vat_main;
12843 vat_json_node_t *node = NULL;
12844 struct in_addr ip4;
12845 struct in6_addr ip6;
12846 ip46_address_t local, remote;
12848 ip_address_decode (&mp->local, &local);
12849 ip_address_decode (&mp->remote, &remote);
12851 if (VAT_JSON_ARRAY != vam->json_tree.type)
12853 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12854 vat_json_init_array (&vam->json_tree);
12856 node = vat_json_array_add (&vam->json_tree);
12858 vat_json_init_object (node);
12859 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12860 if (ip46_address_is_ip4 (&local))
12862 clib_memcpy (&ip4, &local.ip4, sizeof (ip4));
12863 vat_json_object_add_ip4 (node, "local", ip4);
12864 clib_memcpy (&ip4, &remote.ip4, sizeof (ip4));
12865 vat_json_object_add_ip4 (node, "remote", ip4);
12869 clib_memcpy (&ip6, &local.ip6, sizeof (ip6));
12870 vat_json_object_add_ip6 (node, "local", ip6);
12871 clib_memcpy (&ip6, &remote.ip6, sizeof (ip6));
12872 vat_json_object_add_ip6 (node, "remote", ip6);
12874 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12875 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12876 vat_json_object_add_uint (node, "mcast_sw_if_index",
12877 ntohl (mp->mcast_sw_if_index));
12878 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12879 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12880 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12884 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12886 unformat_input_t *i = vam->input;
12887 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12888 vl_api_control_ping_t *mp_ping;
12890 u8 sw_if_index_set = 0;
12893 /* Parse args required to build the message */
12894 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12896 if (unformat (i, "sw_if_index %d", &sw_if_index))
12897 sw_if_index_set = 1;
12902 if (sw_if_index_set == 0)
12907 if (!vam->json_output)
12909 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12910 "sw_if_index", "local", "remote", "vni",
12911 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12914 /* Get list of vxlan-tunnel interfaces */
12915 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12917 mp->sw_if_index = htonl (sw_if_index);
12921 /* Use a control ping for synchronization */
12922 MPING (CONTROL_PING, mp_ping);
12929 static void vl_api_l2_fib_table_details_t_handler
12930 (vl_api_l2_fib_table_details_t * mp)
12932 vat_main_t *vam = &vat_main;
12934 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12936 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
12937 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12941 static void vl_api_l2_fib_table_details_t_handler_json
12942 (vl_api_l2_fib_table_details_t * mp)
12944 vat_main_t *vam = &vat_main;
12945 vat_json_node_t *node = NULL;
12947 if (VAT_JSON_ARRAY != vam->json_tree.type)
12949 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12950 vat_json_init_array (&vam->json_tree);
12952 node = vat_json_array_add (&vam->json_tree);
12954 vat_json_init_object (node);
12955 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12956 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
12957 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12958 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12959 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12960 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12964 api_l2_fib_table_dump (vat_main_t * vam)
12966 unformat_input_t *i = vam->input;
12967 vl_api_l2_fib_table_dump_t *mp;
12968 vl_api_control_ping_t *mp_ping;
12973 /* Parse args required to build the message */
12974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12976 if (unformat (i, "bd_id %d", &bd_id))
12982 if (bd_id_set == 0)
12984 errmsg ("missing bridge domain");
12988 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12990 /* Get list of l2 fib entries */
12991 M (L2_FIB_TABLE_DUMP, mp);
12993 mp->bd_id = ntohl (bd_id);
12996 /* Use a control ping for synchronization */
12997 MPING (CONTROL_PING, mp_ping);
13006 api_interface_name_renumber (vat_main_t * vam)
13008 unformat_input_t *line_input = vam->input;
13009 vl_api_interface_name_renumber_t *mp;
13010 u32 sw_if_index = ~0;
13011 u32 new_show_dev_instance = ~0;
13014 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13016 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13019 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13021 else if (unformat (line_input, "new_show_dev_instance %d",
13022 &new_show_dev_instance))
13028 if (sw_if_index == ~0)
13030 errmsg ("missing interface name or sw_if_index");
13034 if (new_show_dev_instance == ~0)
13036 errmsg ("missing new_show_dev_instance");
13040 M (INTERFACE_NAME_RENUMBER, mp);
13042 mp->sw_if_index = ntohl (sw_if_index);
13043 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13051 api_want_l2_macs_events (vat_main_t * vam)
13053 unformat_input_t *line_input = vam->input;
13054 vl_api_want_l2_macs_events_t *mp;
13055 u8 enable_disable = 1;
13056 u32 scan_delay = 0;
13057 u32 max_macs_in_event = 0;
13058 u32 learn_limit = 0;
13061 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13063 if (unformat (line_input, "learn-limit %d", &learn_limit))
13065 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13067 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13069 else if (unformat (line_input, "disable"))
13070 enable_disable = 0;
13075 M (WANT_L2_MACS_EVENTS, mp);
13076 mp->enable_disable = enable_disable;
13077 mp->pid = htonl (getpid ());
13078 mp->learn_limit = htonl (learn_limit);
13079 mp->scan_delay = (u8) scan_delay;
13080 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13087 api_input_acl_set_interface (vat_main_t * vam)
13089 unformat_input_t *i = vam->input;
13090 vl_api_input_acl_set_interface_t *mp;
13092 int sw_if_index_set;
13093 u32 ip4_table_index = ~0;
13094 u32 ip6_table_index = ~0;
13095 u32 l2_table_index = ~0;
13099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13101 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13102 sw_if_index_set = 1;
13103 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13104 sw_if_index_set = 1;
13105 else if (unformat (i, "del"))
13107 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13109 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13111 else if (unformat (i, "l2-table %d", &l2_table_index))
13115 clib_warning ("parse error '%U'", format_unformat_error, i);
13120 if (sw_if_index_set == 0)
13122 errmsg ("missing interface name or sw_if_index");
13126 M (INPUT_ACL_SET_INTERFACE, mp);
13128 mp->sw_if_index = ntohl (sw_if_index);
13129 mp->ip4_table_index = ntohl (ip4_table_index);
13130 mp->ip6_table_index = ntohl (ip6_table_index);
13131 mp->l2_table_index = ntohl (l2_table_index);
13132 mp->is_add = is_add;
13140 api_output_acl_set_interface (vat_main_t * vam)
13142 unformat_input_t *i = vam->input;
13143 vl_api_output_acl_set_interface_t *mp;
13145 int sw_if_index_set;
13146 u32 ip4_table_index = ~0;
13147 u32 ip6_table_index = ~0;
13148 u32 l2_table_index = ~0;
13152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13154 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13155 sw_if_index_set = 1;
13156 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13157 sw_if_index_set = 1;
13158 else if (unformat (i, "del"))
13160 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13162 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13164 else if (unformat (i, "l2-table %d", &l2_table_index))
13168 clib_warning ("parse error '%U'", format_unformat_error, i);
13173 if (sw_if_index_set == 0)
13175 errmsg ("missing interface name or sw_if_index");
13179 M (OUTPUT_ACL_SET_INTERFACE, mp);
13181 mp->sw_if_index = ntohl (sw_if_index);
13182 mp->ip4_table_index = ntohl (ip4_table_index);
13183 mp->ip6_table_index = ntohl (ip6_table_index);
13184 mp->l2_table_index = ntohl (l2_table_index);
13185 mp->is_add = is_add;
13193 api_ip_address_dump (vat_main_t * vam)
13195 unformat_input_t *i = vam->input;
13196 vl_api_ip_address_dump_t *mp;
13197 vl_api_control_ping_t *mp_ping;
13198 u32 sw_if_index = ~0;
13199 u8 sw_if_index_set = 0;
13204 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13206 if (unformat (i, "sw_if_index %d", &sw_if_index))
13207 sw_if_index_set = 1;
13209 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13210 sw_if_index_set = 1;
13211 else if (unformat (i, "ipv4"))
13213 else if (unformat (i, "ipv6"))
13219 if (ipv4_set && ipv6_set)
13221 errmsg ("ipv4 and ipv6 flags cannot be both set");
13225 if ((!ipv4_set) && (!ipv6_set))
13227 errmsg ("no ipv4 nor ipv6 flag set");
13231 if (sw_if_index_set == 0)
13233 errmsg ("missing interface name or sw_if_index");
13237 vam->current_sw_if_index = sw_if_index;
13238 vam->is_ipv6 = ipv6_set;
13240 M (IP_ADDRESS_DUMP, mp);
13241 mp->sw_if_index = ntohl (sw_if_index);
13242 mp->is_ipv6 = ipv6_set;
13245 /* Use a control ping for synchronization */
13246 MPING (CONTROL_PING, mp_ping);
13254 api_ip_dump (vat_main_t * vam)
13256 vl_api_ip_dump_t *mp;
13257 vl_api_control_ping_t *mp_ping;
13258 unformat_input_t *in = vam->input;
13265 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13267 if (unformat (in, "ipv4"))
13269 else if (unformat (in, "ipv6"))
13275 if (ipv4_set && ipv6_set)
13277 errmsg ("ipv4 and ipv6 flags cannot be both set");
13281 if ((!ipv4_set) && (!ipv6_set))
13283 errmsg ("no ipv4 nor ipv6 flag set");
13287 is_ipv6 = ipv6_set;
13288 vam->is_ipv6 = is_ipv6;
13290 /* free old data */
13291 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13293 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13295 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13298 mp->is_ipv6 = ipv6_set;
13301 /* Use a control ping for synchronization */
13302 MPING (CONTROL_PING, mp_ping);
13310 api_ipsec_spd_add_del (vat_main_t * vam)
13312 unformat_input_t *i = vam->input;
13313 vl_api_ipsec_spd_add_del_t *mp;
13318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13320 if (unformat (i, "spd_id %d", &spd_id))
13322 else if (unformat (i, "del"))
13326 clib_warning ("parse error '%U'", format_unformat_error, i);
13332 errmsg ("spd_id must be set");
13336 M (IPSEC_SPD_ADD_DEL, mp);
13338 mp->spd_id = ntohl (spd_id);
13339 mp->is_add = is_add;
13347 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13349 unformat_input_t *i = vam->input;
13350 vl_api_ipsec_interface_add_del_spd_t *mp;
13352 u8 sw_if_index_set = 0;
13353 u32 spd_id = (u32) ~ 0;
13357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13359 if (unformat (i, "del"))
13361 else if (unformat (i, "spd_id %d", &spd_id))
13364 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13365 sw_if_index_set = 1;
13366 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13367 sw_if_index_set = 1;
13370 clib_warning ("parse error '%U'", format_unformat_error, i);
13376 if (spd_id == (u32) ~ 0)
13378 errmsg ("spd_id must be set");
13382 if (sw_if_index_set == 0)
13384 errmsg ("missing interface name or sw_if_index");
13388 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13390 mp->spd_id = ntohl (spd_id);
13391 mp->sw_if_index = ntohl (sw_if_index);
13392 mp->is_add = is_add;
13400 api_ipsec_spd_entry_add_del (vat_main_t * vam)
13402 unformat_input_t *i = vam->input;
13403 vl_api_ipsec_spd_entry_add_del_t *mp;
13404 u8 is_add = 1, is_outbound = 0;
13405 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13407 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13408 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13409 vl_api_address_t laddr_start = { }, laddr_stop =
13418 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13420 if (unformat (i, "del"))
13422 if (unformat (i, "outbound"))
13424 if (unformat (i, "inbound"))
13426 else if (unformat (i, "spd_id %d", &spd_id))
13428 else if (unformat (i, "sa_id %d", &sa_id))
13430 else if (unformat (i, "priority %d", &priority))
13432 else if (unformat (i, "protocol %d", &protocol))
13434 else if (unformat (i, "lport_start %d", &lport_start))
13436 else if (unformat (i, "lport_stop %d", &lport_stop))
13438 else if (unformat (i, "rport_start %d", &rport_start))
13440 else if (unformat (i, "rport_stop %d", &rport_stop))
13442 else if (unformat (i, "laddr_start %U",
13443 unformat_vl_api_address, &laddr_start))
13445 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
13448 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
13451 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
13455 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13457 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13459 clib_warning ("unsupported action: 'resolve'");
13465 clib_warning ("parse error '%U'", format_unformat_error, i);
13471 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
13473 mp->is_add = is_add;
13475 mp->entry.spd_id = ntohl (spd_id);
13476 mp->entry.priority = ntohl (priority);
13477 mp->entry.is_outbound = is_outbound;
13479 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
13480 sizeof (vl_api_address_t));
13481 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
13482 sizeof (vl_api_address_t));
13483 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
13484 sizeof (vl_api_address_t));
13485 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
13486 sizeof (vl_api_address_t));
13488 mp->entry.protocol = (u8) protocol;
13489 mp->entry.local_port_start = ntohs ((u16) lport_start);
13490 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
13491 mp->entry.remote_port_start = ntohs ((u16) rport_start);
13492 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
13493 mp->entry.policy = (u8) policy;
13494 mp->entry.sa_id = ntohl (sa_id);
13502 api_ipsec_sad_entry_add_del (vat_main_t * vam)
13504 unformat_input_t *i = vam->input;
13505 vl_api_ipsec_sad_entry_add_del_t *mp;
13506 u32 sad_id = 0, spi = 0;
13507 u8 *ck = 0, *ik = 0;
13510 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
13511 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
13512 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
13513 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
13514 vl_api_address_t tun_src, tun_dst;
13517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13519 if (unformat (i, "del"))
13521 else if (unformat (i, "sad_id %d", &sad_id))
13523 else if (unformat (i, "spi %d", &spi))
13525 else if (unformat (i, "esp"))
13526 protocol = IPSEC_API_PROTO_ESP;
13528 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
13530 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13531 if (ADDRESS_IP6 == tun_src.af)
13532 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13535 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
13537 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13538 if (ADDRESS_IP6 == tun_src.af)
13539 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13542 if (unformat (i, "crypto_alg %U",
13543 unformat_ipsec_api_crypto_alg, &crypto_alg))
13545 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13547 else if (unformat (i, "integ_alg %U",
13548 unformat_ipsec_api_integ_alg, &integ_alg))
13550 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13554 clib_warning ("parse error '%U'", format_unformat_error, i);
13560 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
13562 mp->is_add = is_add;
13563 mp->entry.sad_id = ntohl (sad_id);
13564 mp->entry.protocol = protocol;
13565 mp->entry.spi = ntohl (spi);
13566 mp->entry.flags = flags;
13568 mp->entry.crypto_algorithm = crypto_alg;
13569 mp->entry.integrity_algorithm = integ_alg;
13570 mp->entry.crypto_key.length = vec_len (ck);
13571 mp->entry.integrity_key.length = vec_len (ik);
13573 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
13574 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
13576 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
13577 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
13580 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
13582 clib_memcpy (mp->entry.integrity_key.data, ik,
13583 mp->entry.integrity_key.length);
13585 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
13587 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
13588 sizeof (mp->entry.tunnel_src));
13589 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
13590 sizeof (mp->entry.tunnel_dst));
13599 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13601 unformat_input_t *i = vam->input;
13602 vl_api_ipsec_tunnel_if_add_del_t *mp;
13603 u32 local_spi = 0, remote_spi = 0;
13604 u32 crypto_alg = 0, integ_alg = 0;
13605 u8 *lck = NULL, *rck = NULL;
13606 u8 *lik = NULL, *rik = NULL;
13607 vl_api_address_t local_ip = { 0 };
13608 vl_api_address_t remote_ip = { 0 };
13612 u8 anti_replay = 0;
13618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13620 if (unformat (i, "del"))
13622 else if (unformat (i, "esn"))
13624 else if (unformat (i, "anti-replay"))
13626 else if (unformat (i, "count %d", &count))
13628 else if (unformat (i, "local_spi %d", &local_spi))
13630 else if (unformat (i, "remote_spi %d", &remote_spi))
13633 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
13636 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
13638 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13641 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13643 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13645 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13649 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
13651 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
13653 errmsg ("unsupported crypto-alg: '%U'\n",
13654 format_ipsec_crypto_alg, crypto_alg);
13660 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
13662 if (integ_alg >= IPSEC_INTEG_N_ALG)
13664 errmsg ("unsupported integ-alg: '%U'\n",
13665 format_ipsec_integ_alg, integ_alg);
13669 else if (unformat (i, "instance %u", &instance))
13673 errmsg ("parse error '%U'\n", format_unformat_error, i);
13680 /* Turn on async mode */
13681 vam->async_mode = 1;
13682 vam->async_errors = 0;
13683 before = vat_time_now (vam);
13686 for (jj = 0; jj < count; jj++)
13688 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13690 mp->is_add = is_add;
13692 mp->anti_replay = anti_replay;
13695 increment_address (&remote_ip);
13697 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
13698 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
13700 mp->local_spi = htonl (local_spi + jj);
13701 mp->remote_spi = htonl (remote_spi + jj);
13702 mp->crypto_alg = (u8) crypto_alg;
13704 mp->local_crypto_key_len = 0;
13707 mp->local_crypto_key_len = vec_len (lck);
13708 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13709 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13710 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13713 mp->remote_crypto_key_len = 0;
13716 mp->remote_crypto_key_len = vec_len (rck);
13717 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13718 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13719 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13722 mp->integ_alg = (u8) integ_alg;
13724 mp->local_integ_key_len = 0;
13727 mp->local_integ_key_len = vec_len (lik);
13728 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13729 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13730 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13733 mp->remote_integ_key_len = 0;
13736 mp->remote_integ_key_len = vec_len (rik);
13737 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13738 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13739 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13744 mp->renumber = renumber;
13745 mp->show_instance = ntohl (instance);
13750 /* When testing multiple add/del ops, use a control-ping to sync */
13753 vl_api_control_ping_t *mp_ping;
13757 /* Shut off async mode */
13758 vam->async_mode = 0;
13760 MPING (CONTROL_PING, mp_ping);
13763 timeout = vat_time_now (vam) + 1.0;
13764 while (vat_time_now (vam) < timeout)
13765 if (vam->result_ready == 1)
13770 if (vam->retval == -99)
13771 errmsg ("timeout");
13773 if (vam->async_errors > 0)
13775 errmsg ("%d asynchronous errors", vam->async_errors);
13778 vam->async_errors = 0;
13779 after = vat_time_now (vam);
13781 /* slim chance, but we might have eaten SIGTERM on the first iteration */
13785 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
13786 count, after - before, count / (after - before));
13790 /* Wait for a reply... */
13799 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
13801 vat_main_t *vam = &vat_main;
13803 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
13804 "crypto_key %U integ_alg %u integ_key %U flags %x "
13805 "tunnel_src_addr %U tunnel_dst_addr %U "
13806 "salt %u seq_outbound %lu last_seq_inbound %lu "
13807 "replay_window %lu stat_index %u\n",
13808 ntohl (mp->entry.sad_id),
13809 ntohl (mp->sw_if_index),
13810 ntohl (mp->entry.spi),
13811 ntohl (mp->entry.protocol),
13812 ntohl (mp->entry.crypto_algorithm),
13813 format_hex_bytes, mp->entry.crypto_key.data,
13814 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
13815 format_hex_bytes, mp->entry.integrity_key.data,
13816 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
13817 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
13818 &mp->entry.tunnel_dst, ntohl (mp->salt),
13819 clib_net_to_host_u64 (mp->seq_outbound),
13820 clib_net_to_host_u64 (mp->last_seq_inbound),
13821 clib_net_to_host_u64 (mp->replay_window), ntohl (mp->stat_index));
13824 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
13825 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
13827 static void vl_api_ipsec_sa_details_t_handler_json
13828 (vl_api_ipsec_sa_details_t * mp)
13830 vat_main_t *vam = &vat_main;
13831 vat_json_node_t *node = NULL;
13832 vl_api_ipsec_sad_flags_t flags;
13834 if (VAT_JSON_ARRAY != vam->json_tree.type)
13836 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13837 vat_json_init_array (&vam->json_tree);
13839 node = vat_json_array_add (&vam->json_tree);
13841 vat_json_init_object (node);
13842 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
13843 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13844 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
13845 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
13846 vat_json_object_add_uint (node, "crypto_alg",
13847 ntohl (mp->entry.crypto_algorithm));
13848 vat_json_object_add_uint (node, "integ_alg",
13849 ntohl (mp->entry.integrity_algorithm));
13850 flags = ntohl (mp->entry.flags);
13851 vat_json_object_add_uint (node, "use_esn",
13852 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
13853 vat_json_object_add_uint (node, "use_anti_replay",
13854 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
13855 vat_json_object_add_uint (node, "is_tunnel",
13856 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
13857 vat_json_object_add_uint (node, "is_tunnel_ip6",
13858 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
13859 vat_json_object_add_uint (node, "udp_encap",
13860 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
13861 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
13862 mp->entry.crypto_key.length);
13863 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
13864 mp->entry.integrity_key.length);
13865 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
13866 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
13867 vat_json_object_add_uint (node, "replay_window",
13868 clib_net_to_host_u64 (mp->replay_window));
13869 vat_json_object_add_uint (node, "stat_index", ntohl (mp->stat_index));
13873 api_ipsec_sa_dump (vat_main_t * vam)
13875 unformat_input_t *i = vam->input;
13876 vl_api_ipsec_sa_dump_t *mp;
13877 vl_api_control_ping_t *mp_ping;
13881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13883 if (unformat (i, "sa_id %d", &sa_id))
13887 clib_warning ("parse error '%U'", format_unformat_error, i);
13892 M (IPSEC_SA_DUMP, mp);
13894 mp->sa_id = ntohl (sa_id);
13898 /* Use a control ping for synchronization */
13899 M (CONTROL_PING, mp_ping);
13907 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
13909 unformat_input_t *i = vam->input;
13910 vl_api_ipsec_tunnel_if_set_sa_t *mp;
13911 u32 sw_if_index = ~0;
13913 u8 is_outbound = (u8) ~ 0;
13916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13918 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13920 else if (unformat (i, "sa_id %d", &sa_id))
13922 else if (unformat (i, "outbound"))
13924 else if (unformat (i, "inbound"))
13928 clib_warning ("parse error '%U'", format_unformat_error, i);
13933 if (sw_if_index == ~0)
13935 errmsg ("interface must be specified");
13941 errmsg ("SA ID must be specified");
13945 M (IPSEC_TUNNEL_IF_SET_SA, mp);
13947 mp->sw_if_index = htonl (sw_if_index);
13948 mp->sa_id = htonl (sa_id);
13949 mp->is_outbound = is_outbound;
13958 api_get_first_msg_id (vat_main_t * vam)
13960 vl_api_get_first_msg_id_t *mp;
13961 unformat_input_t *i = vam->input;
13966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13968 if (unformat (i, "client %s", &name))
13976 errmsg ("missing client name");
13979 vec_add1 (name, 0);
13981 if (vec_len (name) > 63)
13983 errmsg ("client name too long");
13987 M (GET_FIRST_MSG_ID, mp);
13988 clib_memcpy (mp->name, name, vec_len (name));
13995 api_cop_interface_enable_disable (vat_main_t * vam)
13997 unformat_input_t *line_input = vam->input;
13998 vl_api_cop_interface_enable_disable_t *mp;
13999 u32 sw_if_index = ~0;
14000 u8 enable_disable = 1;
14003 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14005 if (unformat (line_input, "disable"))
14006 enable_disable = 0;
14007 if (unformat (line_input, "enable"))
14008 enable_disable = 1;
14009 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14010 vam, &sw_if_index))
14012 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14018 if (sw_if_index == ~0)
14020 errmsg ("missing interface name or sw_if_index");
14024 /* Construct the API message */
14025 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14026 mp->sw_if_index = ntohl (sw_if_index);
14027 mp->enable_disable = enable_disable;
14031 /* Wait for the reply */
14037 api_cop_whitelist_enable_disable (vat_main_t * vam)
14039 unformat_input_t *line_input = vam->input;
14040 vl_api_cop_whitelist_enable_disable_t *mp;
14041 u32 sw_if_index = ~0;
14042 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14046 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14048 if (unformat (line_input, "ip4"))
14050 else if (unformat (line_input, "ip6"))
14052 else if (unformat (line_input, "default"))
14054 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14055 vam, &sw_if_index))
14057 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14059 else if (unformat (line_input, "fib-id %d", &fib_id))
14065 if (sw_if_index == ~0)
14067 errmsg ("missing interface name or sw_if_index");
14071 /* Construct the API message */
14072 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14073 mp->sw_if_index = ntohl (sw_if_index);
14074 mp->fib_id = ntohl (fib_id);
14077 mp->default_cop = default_cop;
14081 /* Wait for the reply */
14087 api_get_node_graph (vat_main_t * vam)
14089 vl_api_get_node_graph_t *mp;
14092 M (GET_NODE_GRAPH, mp);
14096 /* Wait for the reply */
14102 /** Used for parsing LISP eids */
14103 typedef CLIB_PACKED(struct{
14104 u8 addr[16]; /**< eid address */
14105 u32 len; /**< prefix length if IP */
14106 u8 type; /**< type of eid */
14111 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14113 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14115 clib_memset (a, 0, sizeof (a[0]));
14117 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14119 a->type = 0; /* ipv4 type */
14121 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14123 a->type = 1; /* ipv6 type */
14125 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14127 a->type = 2; /* mac type */
14129 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14131 a->type = 3; /* NSH type */
14132 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14133 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14140 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14149 lisp_eid_size_vat (u8 type)
14166 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14168 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14172 api_one_add_del_locator_set (vat_main_t * vam)
14174 unformat_input_t *input = vam->input;
14175 vl_api_one_add_del_locator_set_t *mp;
14177 u8 *locator_set_name = NULL;
14178 u8 locator_set_name_set = 0;
14179 vl_api_local_locator_t locator, *locators = 0;
14180 u32 sw_if_index, priority, weight;
14184 /* Parse args required to build the message */
14185 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14187 if (unformat (input, "del"))
14191 else if (unformat (input, "locator-set %s", &locator_set_name))
14193 locator_set_name_set = 1;
14195 else if (unformat (input, "sw_if_index %u p %u w %u",
14196 &sw_if_index, &priority, &weight))
14198 locator.sw_if_index = htonl (sw_if_index);
14199 locator.priority = priority;
14200 locator.weight = weight;
14201 vec_add1 (locators, locator);
14205 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14206 &sw_if_index, &priority, &weight))
14208 locator.sw_if_index = htonl (sw_if_index);
14209 locator.priority = priority;
14210 locator.weight = weight;
14211 vec_add1 (locators, locator);
14217 if (locator_set_name_set == 0)
14219 errmsg ("missing locator-set name");
14220 vec_free (locators);
14224 if (vec_len (locator_set_name) > 64)
14226 errmsg ("locator-set name too long");
14227 vec_free (locator_set_name);
14228 vec_free (locators);
14231 vec_add1 (locator_set_name, 0);
14233 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14235 /* Construct the API message */
14236 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14238 mp->is_add = is_add;
14239 clib_memcpy (mp->locator_set_name, locator_set_name,
14240 vec_len (locator_set_name));
14241 vec_free (locator_set_name);
14243 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14245 clib_memcpy (mp->locators, locators, data_len);
14246 vec_free (locators);
14251 /* Wait for a reply... */
14256 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14259 api_one_add_del_locator (vat_main_t * vam)
14261 unformat_input_t *input = vam->input;
14262 vl_api_one_add_del_locator_t *mp;
14263 u32 tmp_if_index = ~0;
14264 u32 sw_if_index = ~0;
14265 u8 sw_if_index_set = 0;
14266 u8 sw_if_index_if_name_set = 0;
14268 u8 priority_set = 0;
14272 u8 *locator_set_name = NULL;
14273 u8 locator_set_name_set = 0;
14276 /* Parse args required to build the message */
14277 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14279 if (unformat (input, "del"))
14283 else if (unformat (input, "locator-set %s", &locator_set_name))
14285 locator_set_name_set = 1;
14287 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14290 sw_if_index_if_name_set = 1;
14291 sw_if_index = tmp_if_index;
14293 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14295 sw_if_index_set = 1;
14296 sw_if_index = tmp_if_index;
14298 else if (unformat (input, "p %d", &priority))
14302 else if (unformat (input, "w %d", &weight))
14310 if (locator_set_name_set == 0)
14312 errmsg ("missing locator-set name");
14316 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14318 errmsg ("missing sw_if_index");
14319 vec_free (locator_set_name);
14323 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14325 errmsg ("cannot use both params interface name and sw_if_index");
14326 vec_free (locator_set_name);
14330 if (priority_set == 0)
14332 errmsg ("missing locator-set priority");
14333 vec_free (locator_set_name);
14337 if (weight_set == 0)
14339 errmsg ("missing locator-set weight");
14340 vec_free (locator_set_name);
14344 if (vec_len (locator_set_name) > 64)
14346 errmsg ("locator-set name too long");
14347 vec_free (locator_set_name);
14350 vec_add1 (locator_set_name, 0);
14352 /* Construct the API message */
14353 M (ONE_ADD_DEL_LOCATOR, mp);
14355 mp->is_add = is_add;
14356 mp->sw_if_index = ntohl (sw_if_index);
14357 mp->priority = priority;
14358 mp->weight = weight;
14359 clib_memcpy (mp->locator_set_name, locator_set_name,
14360 vec_len (locator_set_name));
14361 vec_free (locator_set_name);
14366 /* Wait for a reply... */
14371 #define api_lisp_add_del_locator api_one_add_del_locator
14374 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14376 u32 *key_id = va_arg (*args, u32 *);
14379 if (unformat (input, "%s", &s))
14381 if (!strcmp ((char *) s, "sha1"))
14382 key_id[0] = HMAC_SHA_1_96;
14383 else if (!strcmp ((char *) s, "sha256"))
14384 key_id[0] = HMAC_SHA_256_128;
14387 clib_warning ("invalid key_id: '%s'", s);
14388 key_id[0] = HMAC_NO_KEY;
14399 api_one_add_del_local_eid (vat_main_t * vam)
14401 unformat_input_t *input = vam->input;
14402 vl_api_one_add_del_local_eid_t *mp;
14405 lisp_eid_vat_t _eid, *eid = &_eid;
14406 u8 *locator_set_name = 0;
14407 u8 locator_set_name_set = 0;
14413 /* Parse args required to build the message */
14414 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14416 if (unformat (input, "del"))
14420 else if (unformat (input, "vni %d", &vni))
14424 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14428 else if (unformat (input, "locator-set %s", &locator_set_name))
14430 locator_set_name_set = 1;
14432 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14434 else if (unformat (input, "secret-key %_%v%_", &key))
14440 if (locator_set_name_set == 0)
14442 errmsg ("missing locator-set name");
14448 errmsg ("EID address not set!");
14449 vec_free (locator_set_name);
14453 if (key && (0 == key_id))
14455 errmsg ("invalid key_id!");
14459 if (vec_len (key) > 64)
14461 errmsg ("key too long");
14466 if (vec_len (locator_set_name) > 64)
14468 errmsg ("locator-set name too long");
14469 vec_free (locator_set_name);
14472 vec_add1 (locator_set_name, 0);
14474 /* Construct the API message */
14475 M (ONE_ADD_DEL_LOCAL_EID, mp);
14477 mp->is_add = is_add;
14478 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14479 mp->eid_type = eid->type;
14480 mp->prefix_len = eid->len;
14481 mp->vni = clib_host_to_net_u32 (vni);
14482 mp->key_id = clib_host_to_net_u16 (key_id);
14483 clib_memcpy (mp->locator_set_name, locator_set_name,
14484 vec_len (locator_set_name));
14485 clib_memcpy (mp->key, key, vec_len (key));
14487 vec_free (locator_set_name);
14493 /* Wait for a reply... */
14498 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14501 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14503 u32 dp_table = 0, vni = 0;;
14504 unformat_input_t *input = vam->input;
14505 vl_api_gpe_add_del_fwd_entry_t *mp;
14507 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14508 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14509 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14510 u32 action = ~0, w;
14511 ip4_address_t rmt_rloc4, lcl_rloc4;
14512 ip6_address_t rmt_rloc6, lcl_rloc6;
14513 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14516 clib_memset (&rloc, 0, sizeof (rloc));
14518 /* Parse args required to build the message */
14519 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14521 if (unformat (input, "del"))
14523 else if (unformat (input, "add"))
14525 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14529 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14533 else if (unformat (input, "vrf %d", &dp_table))
14535 else if (unformat (input, "bd %d", &dp_table))
14537 else if (unformat (input, "vni %d", &vni))
14539 else if (unformat (input, "w %d", &w))
14543 errmsg ("No RLOC configured for setting priority/weight!");
14546 curr_rloc->weight = w;
14548 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14549 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14553 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14555 vec_add1 (lcl_locs, rloc);
14557 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14558 vec_add1 (rmt_locs, rloc);
14559 /* weight saved in rmt loc */
14560 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14562 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14563 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14566 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14568 vec_add1 (lcl_locs, rloc);
14570 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14571 vec_add1 (rmt_locs, rloc);
14572 /* weight saved in rmt loc */
14573 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14575 else if (unformat (input, "action %d", &action))
14581 clib_warning ("parse error '%U'", format_unformat_error, input);
14588 errmsg ("remote eid addresses not set");
14592 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14594 errmsg ("eid types don't match");
14598 if (0 == rmt_locs && (u32) ~ 0 == action)
14600 errmsg ("action not set for negative mapping");
14604 /* Construct the API message */
14605 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14606 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14608 mp->is_add = is_add;
14609 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14610 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14611 mp->eid_type = rmt_eid->type;
14612 mp->dp_table = clib_host_to_net_u32 (dp_table);
14613 mp->vni = clib_host_to_net_u32 (vni);
14614 mp->rmt_len = rmt_eid->len;
14615 mp->lcl_len = lcl_eid->len;
14616 mp->action = action;
14618 if (0 != rmt_locs && 0 != lcl_locs)
14620 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14621 clib_memcpy (mp->locs, lcl_locs,
14622 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14624 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14625 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14626 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14628 vec_free (lcl_locs);
14629 vec_free (rmt_locs);
14634 /* Wait for a reply... */
14640 api_one_add_del_map_server (vat_main_t * vam)
14642 unformat_input_t *input = vam->input;
14643 vl_api_one_add_del_map_server_t *mp;
14647 ip4_address_t ipv4;
14648 ip6_address_t ipv6;
14651 /* Parse args required to build the message */
14652 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14654 if (unformat (input, "del"))
14658 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14662 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14670 if (ipv4_set && ipv6_set)
14672 errmsg ("both eid v4 and v6 addresses set");
14676 if (!ipv4_set && !ipv6_set)
14678 errmsg ("eid addresses not set");
14682 /* Construct the API message */
14683 M (ONE_ADD_DEL_MAP_SERVER, mp);
14685 mp->is_add = is_add;
14689 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14694 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14700 /* Wait for a reply... */
14705 #define api_lisp_add_del_map_server api_one_add_del_map_server
14708 api_one_add_del_map_resolver (vat_main_t * vam)
14710 unformat_input_t *input = vam->input;
14711 vl_api_one_add_del_map_resolver_t *mp;
14715 ip4_address_t ipv4;
14716 ip6_address_t ipv6;
14719 /* Parse args required to build the message */
14720 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14722 if (unformat (input, "del"))
14726 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14730 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14738 if (ipv4_set && ipv6_set)
14740 errmsg ("both eid v4 and v6 addresses set");
14744 if (!ipv4_set && !ipv6_set)
14746 errmsg ("eid addresses not set");
14750 /* Construct the API message */
14751 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14753 mp->is_add = is_add;
14757 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14762 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14768 /* Wait for a reply... */
14773 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14776 api_lisp_gpe_enable_disable (vat_main_t * vam)
14778 unformat_input_t *input = vam->input;
14779 vl_api_gpe_enable_disable_t *mp;
14784 /* Parse args required to build the message */
14785 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14787 if (unformat (input, "enable"))
14792 else if (unformat (input, "disable"))
14803 errmsg ("Value not set");
14807 /* Construct the API message */
14808 M (GPE_ENABLE_DISABLE, mp);
14815 /* Wait for a reply... */
14821 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14823 unformat_input_t *input = vam->input;
14824 vl_api_one_rloc_probe_enable_disable_t *mp;
14829 /* Parse args required to build the message */
14830 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14832 if (unformat (input, "enable"))
14837 else if (unformat (input, "disable"))
14845 errmsg ("Value not set");
14849 /* Construct the API message */
14850 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14852 mp->is_enabled = is_en;
14857 /* Wait for a reply... */
14862 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14865 api_one_map_register_enable_disable (vat_main_t * vam)
14867 unformat_input_t *input = vam->input;
14868 vl_api_one_map_register_enable_disable_t *mp;
14873 /* Parse args required to build the message */
14874 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14876 if (unformat (input, "enable"))
14881 else if (unformat (input, "disable"))
14889 errmsg ("Value not set");
14893 /* Construct the API message */
14894 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14896 mp->is_enabled = is_en;
14901 /* Wait for a reply... */
14906 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14909 api_one_enable_disable (vat_main_t * vam)
14911 unformat_input_t *input = vam->input;
14912 vl_api_one_enable_disable_t *mp;
14917 /* Parse args required to build the message */
14918 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14920 if (unformat (input, "enable"))
14925 else if (unformat (input, "disable"))
14935 errmsg ("Value not set");
14939 /* Construct the API message */
14940 M (ONE_ENABLE_DISABLE, mp);
14947 /* Wait for a reply... */
14952 #define api_lisp_enable_disable api_one_enable_disable
14955 api_one_enable_disable_xtr_mode (vat_main_t * vam)
14957 unformat_input_t *input = vam->input;
14958 vl_api_one_enable_disable_xtr_mode_t *mp;
14963 /* Parse args required to build the message */
14964 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14966 if (unformat (input, "enable"))
14971 else if (unformat (input, "disable"))
14981 errmsg ("Value not set");
14985 /* Construct the API message */
14986 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
14993 /* Wait for a reply... */
14999 api_one_show_xtr_mode (vat_main_t * vam)
15001 vl_api_one_show_xtr_mode_t *mp;
15004 /* Construct the API message */
15005 M (ONE_SHOW_XTR_MODE, mp);
15010 /* Wait for a reply... */
15016 api_one_enable_disable_pitr_mode (vat_main_t * vam)
15018 unformat_input_t *input = vam->input;
15019 vl_api_one_enable_disable_pitr_mode_t *mp;
15024 /* Parse args required to build the message */
15025 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15027 if (unformat (input, "enable"))
15032 else if (unformat (input, "disable"))
15042 errmsg ("Value not set");
15046 /* Construct the API message */
15047 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
15054 /* Wait for a reply... */
15060 api_one_show_pitr_mode (vat_main_t * vam)
15062 vl_api_one_show_pitr_mode_t *mp;
15065 /* Construct the API message */
15066 M (ONE_SHOW_PITR_MODE, mp);
15071 /* Wait for a reply... */
15077 api_one_enable_disable_petr_mode (vat_main_t * vam)
15079 unformat_input_t *input = vam->input;
15080 vl_api_one_enable_disable_petr_mode_t *mp;
15085 /* Parse args required to build the message */
15086 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15088 if (unformat (input, "enable"))
15093 else if (unformat (input, "disable"))
15103 errmsg ("Value not set");
15107 /* Construct the API message */
15108 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
15115 /* Wait for a reply... */
15121 api_one_show_petr_mode (vat_main_t * vam)
15123 vl_api_one_show_petr_mode_t *mp;
15126 /* Construct the API message */
15127 M (ONE_SHOW_PETR_MODE, mp);
15132 /* Wait for a reply... */
15138 api_show_one_map_register_state (vat_main_t * vam)
15140 vl_api_show_one_map_register_state_t *mp;
15143 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15148 /* wait for reply */
15153 #define api_show_lisp_map_register_state api_show_one_map_register_state
15156 api_show_one_rloc_probe_state (vat_main_t * vam)
15158 vl_api_show_one_rloc_probe_state_t *mp;
15161 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15166 /* wait for reply */
15171 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15174 api_one_add_del_ndp_entry (vat_main_t * vam)
15176 vl_api_one_add_del_ndp_entry_t *mp;
15177 unformat_input_t *input = vam->input;
15182 u8 mac[6] = { 0, };
15183 u8 ip6[16] = { 0, };
15187 /* Parse args required to build the message */
15188 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15190 if (unformat (input, "del"))
15192 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15194 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15196 else if (unformat (input, "bd %d", &bd))
15200 errmsg ("parse error '%U'", format_unformat_error, input);
15205 if (!bd_set || !ip_set || (!mac_set && is_add))
15207 errmsg ("Missing BD, IP or MAC!");
15211 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15212 mp->is_add = is_add;
15213 clib_memcpy (mp->mac, mac, 6);
15214 mp->bd = clib_host_to_net_u32 (bd);
15215 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
15220 /* wait for reply */
15226 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15228 vl_api_one_add_del_l2_arp_entry_t *mp;
15229 unformat_input_t *input = vam->input;
15234 u8 mac[6] = { 0, };
15235 u32 ip4 = 0, bd = ~0;
15238 /* Parse args required to build the message */
15239 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15241 if (unformat (input, "del"))
15243 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15245 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15247 else if (unformat (input, "bd %d", &bd))
15251 errmsg ("parse error '%U'", format_unformat_error, input);
15256 if (!bd_set || !ip_set || (!mac_set && is_add))
15258 errmsg ("Missing BD, IP or MAC!");
15262 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15263 mp->is_add = is_add;
15264 clib_memcpy (mp->mac, mac, 6);
15265 mp->bd = clib_host_to_net_u32 (bd);
15271 /* wait for reply */
15277 api_one_ndp_bd_get (vat_main_t * vam)
15279 vl_api_one_ndp_bd_get_t *mp;
15282 M (ONE_NDP_BD_GET, mp);
15287 /* wait for reply */
15293 api_one_ndp_entries_get (vat_main_t * vam)
15295 vl_api_one_ndp_entries_get_t *mp;
15296 unformat_input_t *input = vam->input;
15301 /* Parse args required to build the message */
15302 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15304 if (unformat (input, "bd %d", &bd))
15308 errmsg ("parse error '%U'", format_unformat_error, input);
15315 errmsg ("Expected bridge domain!");
15319 M (ONE_NDP_ENTRIES_GET, mp);
15320 mp->bd = clib_host_to_net_u32 (bd);
15325 /* wait for reply */
15331 api_one_l2_arp_bd_get (vat_main_t * vam)
15333 vl_api_one_l2_arp_bd_get_t *mp;
15336 M (ONE_L2_ARP_BD_GET, mp);
15341 /* wait for reply */
15347 api_one_l2_arp_entries_get (vat_main_t * vam)
15349 vl_api_one_l2_arp_entries_get_t *mp;
15350 unformat_input_t *input = vam->input;
15355 /* Parse args required to build the message */
15356 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15358 if (unformat (input, "bd %d", &bd))
15362 errmsg ("parse error '%U'", format_unformat_error, input);
15369 errmsg ("Expected bridge domain!");
15373 M (ONE_L2_ARP_ENTRIES_GET, mp);
15374 mp->bd = clib_host_to_net_u32 (bd);
15379 /* wait for reply */
15385 api_one_stats_enable_disable (vat_main_t * vam)
15387 vl_api_one_stats_enable_disable_t *mp;
15388 unformat_input_t *input = vam->input;
15393 /* Parse args required to build the message */
15394 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15396 if (unformat (input, "enable"))
15401 else if (unformat (input, "disable"))
15411 errmsg ("Value not set");
15415 M (ONE_STATS_ENABLE_DISABLE, mp);
15421 /* wait for reply */
15427 api_show_one_stats_enable_disable (vat_main_t * vam)
15429 vl_api_show_one_stats_enable_disable_t *mp;
15432 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15437 /* wait for reply */
15443 api_show_one_map_request_mode (vat_main_t * vam)
15445 vl_api_show_one_map_request_mode_t *mp;
15448 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15453 /* wait for reply */
15458 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15461 api_one_map_request_mode (vat_main_t * vam)
15463 unformat_input_t *input = vam->input;
15464 vl_api_one_map_request_mode_t *mp;
15468 /* Parse args required to build the message */
15469 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15471 if (unformat (input, "dst-only"))
15473 else if (unformat (input, "src-dst"))
15477 errmsg ("parse error '%U'", format_unformat_error, input);
15482 M (ONE_MAP_REQUEST_MODE, mp);
15489 /* wait for reply */
15494 #define api_lisp_map_request_mode api_one_map_request_mode
15497 * Enable/disable ONE proxy ITR.
15499 * @param vam vpp API test context
15500 * @return return code
15503 api_one_pitr_set_locator_set (vat_main_t * vam)
15505 u8 ls_name_set = 0;
15506 unformat_input_t *input = vam->input;
15507 vl_api_one_pitr_set_locator_set_t *mp;
15512 /* Parse args required to build the message */
15513 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15515 if (unformat (input, "del"))
15517 else if (unformat (input, "locator-set %s", &ls_name))
15521 errmsg ("parse error '%U'", format_unformat_error, input);
15528 errmsg ("locator-set name not set!");
15532 M (ONE_PITR_SET_LOCATOR_SET, mp);
15534 mp->is_add = is_add;
15535 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15536 vec_free (ls_name);
15541 /* wait for reply */
15546 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15549 api_one_nsh_set_locator_set (vat_main_t * vam)
15551 u8 ls_name_set = 0;
15552 unformat_input_t *input = vam->input;
15553 vl_api_one_nsh_set_locator_set_t *mp;
15558 /* Parse args required to build the message */
15559 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15561 if (unformat (input, "del"))
15563 else if (unformat (input, "ls %s", &ls_name))
15567 errmsg ("parse error '%U'", format_unformat_error, input);
15572 if (!ls_name_set && is_add)
15574 errmsg ("locator-set name not set!");
15578 M (ONE_NSH_SET_LOCATOR_SET, mp);
15580 mp->is_add = is_add;
15581 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15582 vec_free (ls_name);
15587 /* wait for reply */
15593 api_show_one_pitr (vat_main_t * vam)
15595 vl_api_show_one_pitr_t *mp;
15598 if (!vam->json_output)
15600 print (vam->ofp, "%=20s", "lisp status:");
15603 M (SHOW_ONE_PITR, mp);
15607 /* Wait for a reply... */
15612 #define api_show_lisp_pitr api_show_one_pitr
15615 api_one_use_petr (vat_main_t * vam)
15617 unformat_input_t *input = vam->input;
15618 vl_api_one_use_petr_t *mp;
15623 clib_memset (&ip, 0, sizeof (ip));
15625 /* Parse args required to build the message */
15626 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15628 if (unformat (input, "disable"))
15631 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15634 ip_addr_version (&ip) = AF_IP4;
15637 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15640 ip_addr_version (&ip) = AF_IP6;
15644 errmsg ("parse error '%U'", format_unformat_error, input);
15649 M (ONE_USE_PETR, mp);
15651 mp->is_add = is_add;
15654 mp->is_ip4 = ip_addr_version (&ip) == AF_IP4 ? 1 : 0;
15656 clib_memcpy (mp->address, &ip, 4);
15658 clib_memcpy (mp->address, &ip, 16);
15664 /* wait for reply */
15669 #define api_lisp_use_petr api_one_use_petr
15672 api_show_one_nsh_mapping (vat_main_t * vam)
15674 vl_api_show_one_use_petr_t *mp;
15677 if (!vam->json_output)
15679 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15682 M (SHOW_ONE_NSH_MAPPING, mp);
15686 /* Wait for a reply... */
15692 api_show_one_use_petr (vat_main_t * vam)
15694 vl_api_show_one_use_petr_t *mp;
15697 if (!vam->json_output)
15699 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15702 M (SHOW_ONE_USE_PETR, mp);
15706 /* Wait for a reply... */
15711 #define api_show_lisp_use_petr api_show_one_use_petr
15714 * Add/delete mapping between vni and vrf
15717 api_one_eid_table_add_del_map (vat_main_t * vam)
15719 unformat_input_t *input = vam->input;
15720 vl_api_one_eid_table_add_del_map_t *mp;
15721 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15722 u32 vni, vrf, bd_index;
15725 /* Parse args required to build the message */
15726 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15728 if (unformat (input, "del"))
15730 else if (unformat (input, "vrf %d", &vrf))
15732 else if (unformat (input, "bd_index %d", &bd_index))
15734 else if (unformat (input, "vni %d", &vni))
15740 if (!vni_set || (!vrf_set && !bd_index_set))
15742 errmsg ("missing arguments!");
15746 if (vrf_set && bd_index_set)
15748 errmsg ("error: both vrf and bd entered!");
15752 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15754 mp->is_add = is_add;
15755 mp->vni = htonl (vni);
15756 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15757 mp->is_l2 = bd_index_set;
15762 /* wait for reply */
15767 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15770 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15772 u32 *action = va_arg (*args, u32 *);
15775 if (unformat (input, "%s", &s))
15777 if (!strcmp ((char *) s, "no-action"))
15779 else if (!strcmp ((char *) s, "natively-forward"))
15781 else if (!strcmp ((char *) s, "send-map-request"))
15783 else if (!strcmp ((char *) s, "drop"))
15787 clib_warning ("invalid action: '%s'", s);
15799 * Add/del remote mapping to/from ONE control plane
15801 * @param vam vpp API test context
15802 * @return return code
15805 api_one_add_del_remote_mapping (vat_main_t * vam)
15807 unformat_input_t *input = vam->input;
15808 vl_api_one_add_del_remote_mapping_t *mp;
15810 lisp_eid_vat_t _eid, *eid = &_eid;
15811 lisp_eid_vat_t _seid, *seid = &_seid;
15812 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15813 u32 action = ~0, p, w, data_len;
15814 ip4_address_t rloc4;
15815 ip6_address_t rloc6;
15816 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15819 clib_memset (&rloc, 0, sizeof (rloc));
15821 /* Parse args required to build the message */
15822 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15824 if (unformat (input, "del-all"))
15828 else if (unformat (input, "del"))
15832 else if (unformat (input, "add"))
15836 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15840 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15844 else if (unformat (input, "vni %d", &vni))
15848 else if (unformat (input, "p %d w %d", &p, &w))
15852 errmsg ("No RLOC configured for setting priority/weight!");
15855 curr_rloc->priority = p;
15856 curr_rloc->weight = w;
15858 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15861 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15862 vec_add1 (rlocs, rloc);
15863 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15865 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15868 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15869 vec_add1 (rlocs, rloc);
15870 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15872 else if (unformat (input, "action %U",
15873 unformat_negative_mapping_action, &action))
15879 clib_warning ("parse error '%U'", format_unformat_error, input);
15886 errmsg ("missing params!");
15890 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15892 errmsg ("no action set for negative map-reply!");
15896 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15898 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15899 mp->is_add = is_add;
15900 mp->vni = htonl (vni);
15901 mp->action = (u8) action;
15902 mp->is_src_dst = seid_set;
15903 mp->eid_len = eid->len;
15904 mp->seid_len = seid->len;
15905 mp->del_all = del_all;
15906 mp->eid_type = eid->type;
15907 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15908 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15910 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15911 clib_memcpy (mp->rlocs, rlocs, data_len);
15917 /* Wait for a reply... */
15922 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15925 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15926 * forwarding entries in data-plane accordingly.
15928 * @param vam vpp API test context
15929 * @return return code
15932 api_one_add_del_adjacency (vat_main_t * vam)
15934 unformat_input_t *input = vam->input;
15935 vl_api_one_add_del_adjacency_t *mp;
15937 ip4_address_t leid4, reid4;
15938 ip6_address_t leid6, reid6;
15939 u8 reid_mac[6] = { 0 };
15940 u8 leid_mac[6] = { 0 };
15941 u8 reid_type, leid_type;
15942 u32 leid_len = 0, reid_len = 0, len;
15946 leid_type = reid_type = (u8) ~ 0;
15948 /* Parse args required to build the message */
15949 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15951 if (unformat (input, "del"))
15955 else if (unformat (input, "add"))
15959 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15962 reid_type = 0; /* ipv4 */
15965 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15968 reid_type = 1; /* ipv6 */
15971 else if (unformat (input, "reid %U", unformat_ethernet_address,
15974 reid_type = 2; /* mac */
15976 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15979 leid_type = 0; /* ipv4 */
15982 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15985 leid_type = 1; /* ipv6 */
15988 else if (unformat (input, "leid %U", unformat_ethernet_address,
15991 leid_type = 2; /* mac */
15993 else if (unformat (input, "vni %d", &vni))
15999 errmsg ("parse error '%U'", format_unformat_error, input);
16004 if ((u8) ~ 0 == reid_type)
16006 errmsg ("missing params!");
16010 if (leid_type != reid_type)
16012 errmsg ("remote and local EIDs are of different types!");
16016 M (ONE_ADD_DEL_ADJACENCY, mp);
16017 mp->is_add = is_add;
16018 mp->vni = htonl (vni);
16019 mp->leid_len = leid_len;
16020 mp->reid_len = reid_len;
16021 mp->eid_type = reid_type;
16023 switch (mp->eid_type)
16026 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
16027 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
16030 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
16031 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
16034 clib_memcpy (mp->leid, leid_mac, 6);
16035 clib_memcpy (mp->reid, reid_mac, 6);
16038 errmsg ("unknown EID type %d!", mp->eid_type);
16045 /* Wait for a reply... */
16050 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16053 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16055 u32 *mode = va_arg (*args, u32 *);
16057 if (unformat (input, "lisp"))
16059 else if (unformat (input, "vxlan"))
16068 api_gpe_get_encap_mode (vat_main_t * vam)
16070 vl_api_gpe_get_encap_mode_t *mp;
16073 /* Construct the API message */
16074 M (GPE_GET_ENCAP_MODE, mp);
16079 /* Wait for a reply... */
16085 api_gpe_set_encap_mode (vat_main_t * vam)
16087 unformat_input_t *input = vam->input;
16088 vl_api_gpe_set_encap_mode_t *mp;
16092 /* Parse args required to build the message */
16093 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16095 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16101 /* Construct the API message */
16102 M (GPE_SET_ENCAP_MODE, mp);
16109 /* Wait for a reply... */
16115 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16117 unformat_input_t *input = vam->input;
16118 vl_api_gpe_add_del_iface_t *mp;
16119 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16120 u32 dp_table = 0, vni = 0;
16123 /* Parse args required to build the message */
16124 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16126 if (unformat (input, "up"))
16131 else if (unformat (input, "down"))
16136 else if (unformat (input, "table_id %d", &dp_table))
16140 else if (unformat (input, "bd_id %d", &dp_table))
16145 else if (unformat (input, "vni %d", &vni))
16153 if (action_set == 0)
16155 errmsg ("Action not set");
16158 if (dp_table_set == 0 || vni_set == 0)
16160 errmsg ("vni and dp_table must be set");
16164 /* Construct the API message */
16165 M (GPE_ADD_DEL_IFACE, mp);
16167 mp->is_add = is_add;
16168 mp->dp_table = clib_host_to_net_u32 (dp_table);
16170 mp->vni = clib_host_to_net_u32 (vni);
16175 /* Wait for a reply... */
16181 api_one_map_register_fallback_threshold (vat_main_t * vam)
16183 unformat_input_t *input = vam->input;
16184 vl_api_one_map_register_fallback_threshold_t *mp;
16189 /* Parse args required to build the message */
16190 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16192 if (unformat (input, "%u", &value))
16196 clib_warning ("parse error '%U'", format_unformat_error, input);
16203 errmsg ("fallback threshold value is missing!");
16207 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16208 mp->value = clib_host_to_net_u32 (value);
16213 /* Wait for a reply... */
16219 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16221 vl_api_show_one_map_register_fallback_threshold_t *mp;
16224 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16229 /* Wait for a reply... */
16235 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
16237 u32 *proto = va_arg (*args, u32 *);
16239 if (unformat (input, "udp"))
16241 else if (unformat (input, "api"))
16250 api_one_set_transport_protocol (vat_main_t * vam)
16252 unformat_input_t *input = vam->input;
16253 vl_api_one_set_transport_protocol_t *mp;
16258 /* Parse args required to build the message */
16259 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16261 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
16265 clib_warning ("parse error '%U'", format_unformat_error, input);
16272 errmsg ("Transport protocol missing!");
16276 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
16277 mp->protocol = (u8) protocol;
16282 /* Wait for a reply... */
16288 api_one_get_transport_protocol (vat_main_t * vam)
16290 vl_api_one_get_transport_protocol_t *mp;
16293 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
16298 /* Wait for a reply... */
16304 api_one_map_register_set_ttl (vat_main_t * vam)
16306 unformat_input_t *input = vam->input;
16307 vl_api_one_map_register_set_ttl_t *mp;
16312 /* Parse args required to build the message */
16313 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16315 if (unformat (input, "%u", &ttl))
16319 clib_warning ("parse error '%U'", format_unformat_error, input);
16326 errmsg ("TTL value missing!");
16330 M (ONE_MAP_REGISTER_SET_TTL, mp);
16331 mp->ttl = clib_host_to_net_u32 (ttl);
16336 /* Wait for a reply... */
16342 api_show_one_map_register_ttl (vat_main_t * vam)
16344 vl_api_show_one_map_register_ttl_t *mp;
16347 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16352 /* Wait for a reply... */
16358 * Add/del map request itr rlocs from ONE control plane and updates
16360 * @param vam vpp API test context
16361 * @return return code
16364 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16366 unformat_input_t *input = vam->input;
16367 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16368 u8 *locator_set_name = 0;
16369 u8 locator_set_name_set = 0;
16373 /* Parse args required to build the message */
16374 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16376 if (unformat (input, "del"))
16380 else if (unformat (input, "%_%v%_", &locator_set_name))
16382 locator_set_name_set = 1;
16386 clib_warning ("parse error '%U'", format_unformat_error, input);
16391 if (is_add && !locator_set_name_set)
16393 errmsg ("itr-rloc is not set!");
16397 if (is_add && vec_len (locator_set_name) > 64)
16399 errmsg ("itr-rloc locator-set name too long");
16400 vec_free (locator_set_name);
16404 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16405 mp->is_add = is_add;
16408 clib_memcpy (mp->locator_set_name, locator_set_name,
16409 vec_len (locator_set_name));
16413 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16415 vec_free (locator_set_name);
16420 /* Wait for a reply... */
16425 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16428 api_one_locator_dump (vat_main_t * vam)
16430 unformat_input_t *input = vam->input;
16431 vl_api_one_locator_dump_t *mp;
16432 vl_api_control_ping_t *mp_ping;
16433 u8 is_index_set = 0, is_name_set = 0;
16438 /* Parse args required to build the message */
16439 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16441 if (unformat (input, "ls_name %_%v%_", &ls_name))
16445 else if (unformat (input, "ls_index %d", &ls_index))
16451 errmsg ("parse error '%U'", format_unformat_error, input);
16456 if (!is_index_set && !is_name_set)
16458 errmsg ("error: expected one of index or name!");
16462 if (is_index_set && is_name_set)
16464 errmsg ("error: only one param expected!");
16468 if (vec_len (ls_name) > 62)
16470 errmsg ("error: locator set name too long!");
16474 if (!vam->json_output)
16476 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16479 M (ONE_LOCATOR_DUMP, mp);
16480 mp->is_index_set = is_index_set;
16483 mp->ls_index = clib_host_to_net_u32 (ls_index);
16486 vec_add1 (ls_name, 0);
16487 strncpy ((char *) mp->ls_name, (char *) ls_name,
16488 sizeof (mp->ls_name) - 1);
16494 /* Use a control ping for synchronization */
16495 MPING (CONTROL_PING, mp_ping);
16498 /* Wait for a reply... */
16503 #define api_lisp_locator_dump api_one_locator_dump
16506 api_one_locator_set_dump (vat_main_t * vam)
16508 vl_api_one_locator_set_dump_t *mp;
16509 vl_api_control_ping_t *mp_ping;
16510 unformat_input_t *input = vam->input;
16514 /* Parse args required to build the message */
16515 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16517 if (unformat (input, "local"))
16521 else if (unformat (input, "remote"))
16527 errmsg ("parse error '%U'", format_unformat_error, input);
16532 if (!vam->json_output)
16534 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16537 M (ONE_LOCATOR_SET_DUMP, mp);
16539 mp->filter = filter;
16544 /* Use a control ping for synchronization */
16545 MPING (CONTROL_PING, mp_ping);
16548 /* Wait for a reply... */
16553 #define api_lisp_locator_set_dump api_one_locator_set_dump
16556 api_one_eid_table_map_dump (vat_main_t * vam)
16560 unformat_input_t *input = vam->input;
16561 vl_api_one_eid_table_map_dump_t *mp;
16562 vl_api_control_ping_t *mp_ping;
16565 /* Parse args required to build the message */
16566 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16568 if (unformat (input, "l2"))
16573 else if (unformat (input, "l3"))
16580 errmsg ("parse error '%U'", format_unformat_error, input);
16587 errmsg ("expected one of 'l2' or 'l3' parameter!");
16591 if (!vam->json_output)
16593 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16596 M (ONE_EID_TABLE_MAP_DUMP, mp);
16602 /* Use a control ping for synchronization */
16603 MPING (CONTROL_PING, mp_ping);
16606 /* Wait for a reply... */
16611 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16614 api_one_eid_table_vni_dump (vat_main_t * vam)
16616 vl_api_one_eid_table_vni_dump_t *mp;
16617 vl_api_control_ping_t *mp_ping;
16620 if (!vam->json_output)
16622 print (vam->ofp, "VNI");
16625 M (ONE_EID_TABLE_VNI_DUMP, mp);
16630 /* Use a control ping for synchronization */
16631 MPING (CONTROL_PING, mp_ping);
16634 /* Wait for a reply... */
16639 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16642 api_one_eid_table_dump (vat_main_t * vam)
16644 unformat_input_t *i = vam->input;
16645 vl_api_one_eid_table_dump_t *mp;
16646 vl_api_control_ping_t *mp_ping;
16647 struct in_addr ip4;
16648 struct in6_addr ip6;
16650 u8 eid_type = ~0, eid_set = 0;
16651 u32 prefix_length = ~0, t, vni = 0;
16654 lisp_nsh_api_t nsh;
16656 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16658 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
16664 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
16670 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
16675 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
16680 else if (unformat (i, "vni %d", &t))
16684 else if (unformat (i, "local"))
16688 else if (unformat (i, "remote"))
16694 errmsg ("parse error '%U'", format_unformat_error, i);
16699 if (!vam->json_output)
16701 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16702 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16705 M (ONE_EID_TABLE_DUMP, mp);
16707 mp->filter = filter;
16711 mp->vni = htonl (vni);
16712 mp->eid_type = eid_type;
16716 mp->prefix_length = prefix_length;
16717 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
16720 mp->prefix_length = prefix_length;
16721 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
16724 clib_memcpy (mp->eid, mac, sizeof (mac));
16727 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
16730 errmsg ("unknown EID type %d!", eid_type);
16738 /* Use a control ping for synchronization */
16739 MPING (CONTROL_PING, mp_ping);
16742 /* Wait for a reply... */
16747 #define api_lisp_eid_table_dump api_one_eid_table_dump
16750 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16752 unformat_input_t *i = vam->input;
16753 vl_api_gpe_fwd_entries_get_t *mp;
16758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16760 if (unformat (i, "vni %d", &vni))
16766 errmsg ("parse error '%U'", format_unformat_error, i);
16773 errmsg ("vni not set!");
16777 if (!vam->json_output)
16779 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16783 M (GPE_FWD_ENTRIES_GET, mp);
16784 mp->vni = clib_host_to_net_u32 (vni);
16789 /* Wait for a reply... */
16794 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16795 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16796 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16797 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16798 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16799 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16800 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16801 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16804 api_one_adjacencies_get (vat_main_t * vam)
16806 unformat_input_t *i = vam->input;
16807 vl_api_one_adjacencies_get_t *mp;
16812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16814 if (unformat (i, "vni %d", &vni))
16820 errmsg ("parse error '%U'", format_unformat_error, i);
16827 errmsg ("vni not set!");
16831 if (!vam->json_output)
16833 print (vam->ofp, "%s %40s", "leid", "reid");
16836 M (ONE_ADJACENCIES_GET, mp);
16837 mp->vni = clib_host_to_net_u32 (vni);
16842 /* Wait for a reply... */
16847 #define api_lisp_adjacencies_get api_one_adjacencies_get
16850 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16852 unformat_input_t *i = vam->input;
16853 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16855 u8 ip_family_set = 0, is_ip4 = 1;
16857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16859 if (unformat (i, "ip4"))
16864 else if (unformat (i, "ip6"))
16871 errmsg ("parse error '%U'", format_unformat_error, i);
16876 if (!ip_family_set)
16878 errmsg ("ip family not set!");
16882 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16883 mp->is_ip4 = is_ip4;
16888 /* Wait for a reply... */
16894 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16896 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16899 if (!vam->json_output)
16901 print (vam->ofp, "VNIs");
16904 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16909 /* Wait for a reply... */
16915 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16917 unformat_input_t *i = vam->input;
16918 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16920 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16921 struct in_addr ip4;
16922 struct in6_addr ip6;
16923 u32 table_id = 0, nh_sw_if_index = ~0;
16925 clib_memset (&ip4, 0, sizeof (ip4));
16926 clib_memset (&ip6, 0, sizeof (ip6));
16928 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16930 if (unformat (i, "del"))
16932 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
16933 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16938 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
16939 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16944 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
16948 nh_sw_if_index = ~0;
16950 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
16954 nh_sw_if_index = ~0;
16956 else if (unformat (i, "table %d", &table_id))
16960 errmsg ("parse error '%U'", format_unformat_error, i);
16967 errmsg ("nh addr not set!");
16971 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
16972 mp->is_add = is_add;
16973 mp->table_id = clib_host_to_net_u32 (table_id);
16974 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
16975 mp->is_ip4 = is_ip4;
16977 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
16979 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
16984 /* Wait for a reply... */
16990 api_one_map_server_dump (vat_main_t * vam)
16992 vl_api_one_map_server_dump_t *mp;
16993 vl_api_control_ping_t *mp_ping;
16996 if (!vam->json_output)
16998 print (vam->ofp, "%=20s", "Map server");
17001 M (ONE_MAP_SERVER_DUMP, mp);
17005 /* Use a control ping for synchronization */
17006 MPING (CONTROL_PING, mp_ping);
17009 /* Wait for a reply... */
17014 #define api_lisp_map_server_dump api_one_map_server_dump
17017 api_one_map_resolver_dump (vat_main_t * vam)
17019 vl_api_one_map_resolver_dump_t *mp;
17020 vl_api_control_ping_t *mp_ping;
17023 if (!vam->json_output)
17025 print (vam->ofp, "%=20s", "Map resolver");
17028 M (ONE_MAP_RESOLVER_DUMP, mp);
17032 /* Use a control ping for synchronization */
17033 MPING (CONTROL_PING, mp_ping);
17036 /* Wait for a reply... */
17041 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
17044 api_one_stats_flush (vat_main_t * vam)
17046 vl_api_one_stats_flush_t *mp;
17049 M (ONE_STATS_FLUSH, mp);
17056 api_one_stats_dump (vat_main_t * vam)
17058 vl_api_one_stats_dump_t *mp;
17059 vl_api_control_ping_t *mp_ping;
17062 M (ONE_STATS_DUMP, mp);
17066 /* Use a control ping for synchronization */
17067 MPING (CONTROL_PING, mp_ping);
17070 /* Wait for a reply... */
17076 api_show_one_status (vat_main_t * vam)
17078 vl_api_show_one_status_t *mp;
17081 if (!vam->json_output)
17083 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17086 M (SHOW_ONE_STATUS, mp);
17089 /* Wait for a reply... */
17094 #define api_show_lisp_status api_show_one_status
17097 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17099 vl_api_gpe_fwd_entry_path_dump_t *mp;
17100 vl_api_control_ping_t *mp_ping;
17101 unformat_input_t *i = vam->input;
17102 u32 fwd_entry_index = ~0;
17105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17107 if (unformat (i, "index %d", &fwd_entry_index))
17113 if (~0 == fwd_entry_index)
17115 errmsg ("no index specified!");
17119 if (!vam->json_output)
17121 print (vam->ofp, "first line");
17124 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17128 /* Use a control ping for synchronization */
17129 MPING (CONTROL_PING, mp_ping);
17132 /* Wait for a reply... */
17138 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17140 vl_api_one_get_map_request_itr_rlocs_t *mp;
17143 if (!vam->json_output)
17145 print (vam->ofp, "%=20s", "itr-rlocs:");
17148 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17151 /* Wait for a reply... */
17156 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17159 api_af_packet_create (vat_main_t * vam)
17161 unformat_input_t *i = vam->input;
17162 vl_api_af_packet_create_t *mp;
17163 u8 *host_if_name = 0;
17165 u8 random_hw_addr = 1;
17168 clib_memset (hw_addr, 0, sizeof (hw_addr));
17170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17172 if (unformat (i, "name %s", &host_if_name))
17173 vec_add1 (host_if_name, 0);
17174 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17175 random_hw_addr = 0;
17180 if (!vec_len (host_if_name))
17182 errmsg ("host-interface name must be specified");
17186 if (vec_len (host_if_name) > 64)
17188 errmsg ("host-interface name too long");
17192 M (AF_PACKET_CREATE, mp);
17194 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17195 clib_memcpy (mp->hw_addr, hw_addr, 6);
17196 mp->use_random_hw_addr = random_hw_addr;
17197 vec_free (host_if_name);
17205 fprintf (vam->ofp ? vam->ofp : stderr,
17206 " new sw_if_index = %d\n", vam->sw_if_index);
17213 api_af_packet_delete (vat_main_t * vam)
17215 unformat_input_t *i = vam->input;
17216 vl_api_af_packet_delete_t *mp;
17217 u8 *host_if_name = 0;
17220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17222 if (unformat (i, "name %s", &host_if_name))
17223 vec_add1 (host_if_name, 0);
17228 if (!vec_len (host_if_name))
17230 errmsg ("host-interface name must be specified");
17234 if (vec_len (host_if_name) > 64)
17236 errmsg ("host-interface name too long");
17240 M (AF_PACKET_DELETE, mp);
17242 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17243 vec_free (host_if_name);
17250 static void vl_api_af_packet_details_t_handler
17251 (vl_api_af_packet_details_t * mp)
17253 vat_main_t *vam = &vat_main;
17255 print (vam->ofp, "%-16s %d",
17256 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
17259 static void vl_api_af_packet_details_t_handler_json
17260 (vl_api_af_packet_details_t * mp)
17262 vat_main_t *vam = &vat_main;
17263 vat_json_node_t *node = NULL;
17265 if (VAT_JSON_ARRAY != vam->json_tree.type)
17267 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17268 vat_json_init_array (&vam->json_tree);
17270 node = vat_json_array_add (&vam->json_tree);
17272 vat_json_init_object (node);
17273 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17274 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
17278 api_af_packet_dump (vat_main_t * vam)
17280 vl_api_af_packet_dump_t *mp;
17281 vl_api_control_ping_t *mp_ping;
17284 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
17285 /* Get list of tap interfaces */
17286 M (AF_PACKET_DUMP, mp);
17289 /* Use a control ping for synchronization */
17290 MPING (CONTROL_PING, mp_ping);
17298 api_policer_add_del (vat_main_t * vam)
17300 unformat_input_t *i = vam->input;
17301 vl_api_policer_add_del_t *mp;
17311 u8 color_aware = 0;
17312 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17315 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17316 conform_action.dscp = 0;
17317 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17318 exceed_action.dscp = 0;
17319 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17320 violate_action.dscp = 0;
17322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17324 if (unformat (i, "del"))
17326 else if (unformat (i, "name %s", &name))
17327 vec_add1 (name, 0);
17328 else if (unformat (i, "cir %u", &cir))
17330 else if (unformat (i, "eir %u", &eir))
17332 else if (unformat (i, "cb %u", &cb))
17334 else if (unformat (i, "eb %u", &eb))
17336 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17339 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17342 else if (unformat (i, "type %U", unformat_policer_type, &type))
17344 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17347 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17350 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17353 else if (unformat (i, "color-aware"))
17359 if (!vec_len (name))
17361 errmsg ("policer name must be specified");
17365 if (vec_len (name) > 64)
17367 errmsg ("policer name too long");
17371 M (POLICER_ADD_DEL, mp);
17373 clib_memcpy (mp->name, name, vec_len (name));
17375 mp->is_add = is_add;
17376 mp->cir = ntohl (cir);
17377 mp->eir = ntohl (eir);
17378 mp->cb = clib_net_to_host_u64 (cb);
17379 mp->eb = clib_net_to_host_u64 (eb);
17380 mp->rate_type = rate_type;
17381 mp->round_type = round_type;
17383 mp->conform_action.type = conform_action.action_type;
17384 mp->conform_action.dscp = conform_action.dscp;
17385 mp->exceed_action.type = exceed_action.action_type;
17386 mp->exceed_action.dscp = exceed_action.dscp;
17387 mp->violate_action.type = violate_action.action_type;
17388 mp->violate_action.dscp = violate_action.dscp;
17389 mp->color_aware = color_aware;
17397 api_policer_dump (vat_main_t * vam)
17399 unformat_input_t *i = vam->input;
17400 vl_api_policer_dump_t *mp;
17401 vl_api_control_ping_t *mp_ping;
17402 u8 *match_name = 0;
17403 u8 match_name_valid = 0;
17406 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17408 if (unformat (i, "name %s", &match_name))
17410 vec_add1 (match_name, 0);
17411 match_name_valid = 1;
17417 M (POLICER_DUMP, mp);
17418 mp->match_name_valid = match_name_valid;
17419 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17420 vec_free (match_name);
17424 /* Use a control ping for synchronization */
17425 MPING (CONTROL_PING, mp_ping);
17428 /* Wait for a reply... */
17434 api_policer_classify_set_interface (vat_main_t * vam)
17436 unformat_input_t *i = vam->input;
17437 vl_api_policer_classify_set_interface_t *mp;
17439 int sw_if_index_set;
17440 u32 ip4_table_index = ~0;
17441 u32 ip6_table_index = ~0;
17442 u32 l2_table_index = ~0;
17446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17448 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17449 sw_if_index_set = 1;
17450 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17451 sw_if_index_set = 1;
17452 else if (unformat (i, "del"))
17454 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17456 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17458 else if (unformat (i, "l2-table %d", &l2_table_index))
17462 clib_warning ("parse error '%U'", format_unformat_error, i);
17467 if (sw_if_index_set == 0)
17469 errmsg ("missing interface name or sw_if_index");
17473 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17475 mp->sw_if_index = ntohl (sw_if_index);
17476 mp->ip4_table_index = ntohl (ip4_table_index);
17477 mp->ip6_table_index = ntohl (ip6_table_index);
17478 mp->l2_table_index = ntohl (l2_table_index);
17479 mp->is_add = is_add;
17487 api_policer_classify_dump (vat_main_t * vam)
17489 unformat_input_t *i = vam->input;
17490 vl_api_policer_classify_dump_t *mp;
17491 vl_api_control_ping_t *mp_ping;
17492 u8 type = POLICER_CLASSIFY_N_TABLES;
17495 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17499 errmsg ("classify table type must be specified");
17503 if (!vam->json_output)
17505 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17508 M (POLICER_CLASSIFY_DUMP, mp);
17513 /* Use a control ping for synchronization */
17514 MPING (CONTROL_PING, mp_ping);
17517 /* Wait for a reply... */
17523 format_fib_api_path_nh_proto (u8 * s, va_list * args)
17525 vl_api_fib_path_nh_proto_t proto =
17526 va_arg (*args, vl_api_fib_path_nh_proto_t);
17530 case FIB_API_PATH_NH_PROTO_IP4:
17531 s = format (s, "ip4");
17533 case FIB_API_PATH_NH_PROTO_IP6:
17534 s = format (s, "ip6");
17536 case FIB_API_PATH_NH_PROTO_MPLS:
17537 s = format (s, "mpls");
17539 case FIB_API_PATH_NH_PROTO_BIER:
17540 s = format (s, "bier");
17542 case FIB_API_PATH_NH_PROTO_ETHERNET:
17543 s = format (s, "ethernet");
17551 format_vl_api_ip_address_union (u8 * s, va_list * args)
17553 vl_api_address_family_t af = va_arg (*args, int);
17554 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
17559 s = format (s, "%U", format_ip4_address, u->ip4);
17562 s = format (s, "%U", format_ip6_address, u->ip6);
17569 format_vl_api_fib_path_type (u8 * s, va_list * args)
17571 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
17575 case FIB_API_PATH_TYPE_NORMAL:
17576 s = format (s, "normal");
17578 case FIB_API_PATH_TYPE_LOCAL:
17579 s = format (s, "local");
17581 case FIB_API_PATH_TYPE_DROP:
17582 s = format (s, "drop");
17584 case FIB_API_PATH_TYPE_UDP_ENCAP:
17585 s = format (s, "udp-encap");
17587 case FIB_API_PATH_TYPE_BIER_IMP:
17588 s = format (s, "bier-imp");
17590 case FIB_API_PATH_TYPE_ICMP_UNREACH:
17591 s = format (s, "unreach");
17593 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
17594 s = format (s, "prohibit");
17596 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
17597 s = format (s, "src-lookup");
17599 case FIB_API_PATH_TYPE_DVR:
17600 s = format (s, "dvr");
17602 case FIB_API_PATH_TYPE_INTERFACE_RX:
17603 s = format (s, "interface-rx");
17605 case FIB_API_PATH_TYPE_CLASSIFY:
17606 s = format (s, "classify");
17614 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
17617 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
17618 ntohl (fp->weight), ntohl (fp->sw_if_index),
17619 format_vl_api_fib_path_type, fp->type,
17620 format_fib_api_path_nh_proto, fp->proto,
17621 format_vl_api_ip_address_union, &fp->nh.address);
17625 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17626 vl_api_fib_path_t * fp)
17628 struct in_addr ip4;
17629 struct in6_addr ip6;
17631 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17632 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17633 vat_json_object_add_uint (node, "type", fp->type);
17634 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
17635 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
17637 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
17638 vat_json_object_add_ip4 (node, "next_hop", ip4);
17640 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP6)
17642 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
17643 vat_json_object_add_ip6 (node, "next_hop", ip6);
17648 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17650 vat_main_t *vam = &vat_main;
17651 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17652 vl_api_fib_path_t *fp;
17655 print (vam->ofp, "sw_if_index %d via:",
17656 ntohl (mp->mt_tunnel.mt_sw_if_index));
17657 fp = mp->mt_tunnel.mt_paths;
17658 for (i = 0; i < count; i++)
17660 vl_api_fib_path_print (vam, fp);
17664 print (vam->ofp, "");
17667 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17668 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17671 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17673 vat_main_t *vam = &vat_main;
17674 vat_json_node_t *node = NULL;
17675 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17676 vl_api_fib_path_t *fp;
17679 if (VAT_JSON_ARRAY != vam->json_tree.type)
17681 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17682 vat_json_init_array (&vam->json_tree);
17684 node = vat_json_array_add (&vam->json_tree);
17686 vat_json_init_object (node);
17687 vat_json_object_add_uint (node, "sw_if_index",
17688 ntohl (mp->mt_tunnel.mt_sw_if_index));
17690 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
17692 fp = mp->mt_tunnel.mt_paths;
17693 for (i = 0; i < count; i++)
17695 vl_api_mpls_fib_path_json_print (node, fp);
17701 api_mpls_tunnel_dump (vat_main_t * vam)
17703 vl_api_mpls_tunnel_dump_t *mp;
17704 vl_api_control_ping_t *mp_ping;
17707 M (MPLS_TUNNEL_DUMP, mp);
17711 /* Use a control ping for synchronization */
17712 MPING (CONTROL_PING, mp_ping);
17719 #define vl_api_mpls_table_details_t_endian vl_noop_handler
17720 #define vl_api_mpls_table_details_t_print vl_noop_handler
17724 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
17726 vat_main_t *vam = &vat_main;
17728 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
17731 static void vl_api_mpls_table_details_t_handler_json
17732 (vl_api_mpls_table_details_t * mp)
17734 vat_main_t *vam = &vat_main;
17735 vat_json_node_t *node = NULL;
17737 if (VAT_JSON_ARRAY != vam->json_tree.type)
17739 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17740 vat_json_init_array (&vam->json_tree);
17742 node = vat_json_array_add (&vam->json_tree);
17744 vat_json_init_object (node);
17745 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
17749 api_mpls_table_dump (vat_main_t * vam)
17751 vl_api_mpls_table_dump_t *mp;
17752 vl_api_control_ping_t *mp_ping;
17755 M (MPLS_TABLE_DUMP, mp);
17758 /* Use a control ping for synchronization */
17759 MPING (CONTROL_PING, mp_ping);
17766 #define vl_api_mpls_route_details_t_endian vl_noop_handler
17767 #define vl_api_mpls_route_details_t_print vl_noop_handler
17770 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
17772 vat_main_t *vam = &vat_main;
17773 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
17774 vl_api_fib_path_t *fp;
17778 "table-id %d, label %u, ess_bit %u",
17779 ntohl (mp->mr_route.mr_table_id),
17780 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
17781 fp = mp->mr_route.mr_paths;
17782 for (i = 0; i < count; i++)
17784 vl_api_fib_path_print (vam, fp);
17789 static void vl_api_mpls_route_details_t_handler_json
17790 (vl_api_mpls_route_details_t * mp)
17792 vat_main_t *vam = &vat_main;
17793 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
17794 vat_json_node_t *node = NULL;
17795 vl_api_fib_path_t *fp;
17798 if (VAT_JSON_ARRAY != vam->json_tree.type)
17800 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17801 vat_json_init_array (&vam->json_tree);
17803 node = vat_json_array_add (&vam->json_tree);
17805 vat_json_init_object (node);
17806 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
17807 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
17808 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
17809 vat_json_object_add_uint (node, "path_count", count);
17810 fp = mp->mr_route.mr_paths;
17811 for (i = 0; i < count; i++)
17813 vl_api_mpls_fib_path_json_print (node, fp);
17819 api_mpls_route_dump (vat_main_t * vam)
17821 unformat_input_t *input = vam->input;
17822 vl_api_mpls_route_dump_t *mp;
17823 vl_api_control_ping_t *mp_ping;
17827 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17829 if (unformat (input, "table_id %d", &table_id))
17834 if (table_id == ~0)
17836 errmsg ("missing table id");
17840 M (MPLS_ROUTE_DUMP, mp);
17842 mp->table.mt_table_id = ntohl (table_id);
17845 /* Use a control ping for synchronization */
17846 MPING (CONTROL_PING, mp_ping);
17853 #define vl_api_ip_table_details_t_endian vl_noop_handler
17854 #define vl_api_ip_table_details_t_print vl_noop_handler
17857 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
17859 vat_main_t *vam = &vat_main;
17862 "%s; table-id %d, prefix %U/%d",
17863 mp->table.name, ntohl (mp->table.table_id));
17867 static void vl_api_ip_table_details_t_handler_json
17868 (vl_api_ip_table_details_t * mp)
17870 vat_main_t *vam = &vat_main;
17871 vat_json_node_t *node = NULL;
17873 if (VAT_JSON_ARRAY != vam->json_tree.type)
17875 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17876 vat_json_init_array (&vam->json_tree);
17878 node = vat_json_array_add (&vam->json_tree);
17880 vat_json_init_object (node);
17881 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
17885 api_ip_table_dump (vat_main_t * vam)
17887 vl_api_ip_table_dump_t *mp;
17888 vl_api_control_ping_t *mp_ping;
17891 M (IP_TABLE_DUMP, mp);
17894 /* Use a control ping for synchronization */
17895 MPING (CONTROL_PING, mp_ping);
17903 api_ip_mtable_dump (vat_main_t * vam)
17905 vl_api_ip_mtable_dump_t *mp;
17906 vl_api_control_ping_t *mp_ping;
17909 M (IP_MTABLE_DUMP, mp);
17912 /* Use a control ping for synchronization */
17913 MPING (CONTROL_PING, mp_ping);
17921 api_ip_mroute_dump (vat_main_t * vam)
17923 unformat_input_t *input = vam->input;
17924 vl_api_control_ping_t *mp_ping;
17925 vl_api_ip_mroute_dump_t *mp;
17930 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17932 if (unformat (input, "table_id %d", &table_id))
17934 else if (unformat (input, "ip6"))
17936 else if (unformat (input, "ip4"))
17941 if (table_id == ~0)
17943 errmsg ("missing table id");
17947 M (IP_MROUTE_DUMP, mp);
17948 mp->table.table_id = table_id;
17949 mp->table.is_ip6 = is_ip6;
17952 /* Use a control ping for synchronization */
17953 MPING (CONTROL_PING, mp_ping);
17960 #define vl_api_ip_route_details_t_endian vl_noop_handler
17961 #define vl_api_ip_route_details_t_print vl_noop_handler
17964 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
17966 vat_main_t *vam = &vat_main;
17967 u8 count = mp->route.n_paths;
17968 vl_api_fib_path_t *fp;
17972 "table-id %d, prefix %U/%d",
17973 ntohl (mp->route.table_id),
17974 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
17975 for (i = 0; i < count; i++)
17977 fp = &mp->route.paths[i];
17979 vl_api_fib_path_print (vam, fp);
17984 static void vl_api_ip_route_details_t_handler_json
17985 (vl_api_ip_route_details_t * mp)
17987 vat_main_t *vam = &vat_main;
17988 u8 count = mp->route.n_paths;
17989 vat_json_node_t *node = NULL;
17990 struct in_addr ip4;
17991 struct in6_addr ip6;
17992 vl_api_fib_path_t *fp;
17995 if (VAT_JSON_ARRAY != vam->json_tree.type)
17997 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17998 vat_json_init_array (&vam->json_tree);
18000 node = vat_json_array_add (&vam->json_tree);
18002 vat_json_init_object (node);
18003 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
18004 if (ADDRESS_IP6 == mp->route.prefix.address.af)
18006 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
18007 vat_json_object_add_ip6 (node, "prefix", ip6);
18011 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
18012 vat_json_object_add_ip4 (node, "prefix", ip4);
18014 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
18015 vat_json_object_add_uint (node, "path_count", count);
18016 for (i = 0; i < count; i++)
18018 fp = &mp->route.paths[i];
18019 vl_api_mpls_fib_path_json_print (node, fp);
18024 api_ip_route_dump (vat_main_t * vam)
18026 unformat_input_t *input = vam->input;
18027 vl_api_ip_route_dump_t *mp;
18028 vl_api_control_ping_t *mp_ping;
18034 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18036 if (unformat (input, "table_id %d", &table_id))
18038 else if (unformat (input, "ip6"))
18040 else if (unformat (input, "ip4"))
18045 if (table_id == ~0)
18047 errmsg ("missing table id");
18051 M (IP_ROUTE_DUMP, mp);
18053 mp->table.table_id = table_id;
18054 mp->table.is_ip6 = is_ip6;
18058 /* Use a control ping for synchronization */
18059 MPING (CONTROL_PING, mp_ping);
18067 api_classify_table_ids (vat_main_t * vam)
18069 vl_api_classify_table_ids_t *mp;
18072 /* Construct the API message */
18073 M (CLASSIFY_TABLE_IDS, mp);
18082 api_classify_table_by_interface (vat_main_t * vam)
18084 unformat_input_t *input = vam->input;
18085 vl_api_classify_table_by_interface_t *mp;
18087 u32 sw_if_index = ~0;
18089 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18091 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18093 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18098 if (sw_if_index == ~0)
18100 errmsg ("missing interface name or sw_if_index");
18104 /* Construct the API message */
18105 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18107 mp->sw_if_index = ntohl (sw_if_index);
18115 api_classify_table_info (vat_main_t * vam)
18117 unformat_input_t *input = vam->input;
18118 vl_api_classify_table_info_t *mp;
18122 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18124 if (unformat (input, "table_id %d", &table_id))
18129 if (table_id == ~0)
18131 errmsg ("missing table id");
18135 /* Construct the API message */
18136 M (CLASSIFY_TABLE_INFO, mp);
18138 mp->table_id = ntohl (table_id);
18146 api_classify_session_dump (vat_main_t * vam)
18148 unformat_input_t *input = vam->input;
18149 vl_api_classify_session_dump_t *mp;
18150 vl_api_control_ping_t *mp_ping;
18154 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18156 if (unformat (input, "table_id %d", &table_id))
18161 if (table_id == ~0)
18163 errmsg ("missing table id");
18167 /* Construct the API message */
18168 M (CLASSIFY_SESSION_DUMP, mp);
18170 mp->table_id = ntohl (table_id);
18173 /* Use a control ping for synchronization */
18174 MPING (CONTROL_PING, mp_ping);
18182 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
18184 vat_main_t *vam = &vat_main;
18186 print (vam->ofp, "collector_address %U, collector_port %d, "
18187 "src_address %U, vrf_id %d, path_mtu %u, "
18188 "template_interval %u, udp_checksum %d",
18189 format_ip4_address, mp->collector_address,
18190 ntohs (mp->collector_port),
18191 format_ip4_address, mp->src_address,
18192 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
18193 ntohl (mp->template_interval), mp->udp_checksum);
18196 vam->result_ready = 1;
18200 vl_api_ipfix_exporter_details_t_handler_json
18201 (vl_api_ipfix_exporter_details_t * mp)
18203 vat_main_t *vam = &vat_main;
18204 vat_json_node_t node;
18205 struct in_addr collector_address;
18206 struct in_addr src_address;
18208 vat_json_init_object (&node);
18209 clib_memcpy (&collector_address, &mp->collector_address,
18210 sizeof (collector_address));
18211 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
18212 vat_json_object_add_uint (&node, "collector_port",
18213 ntohs (mp->collector_port));
18214 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
18215 vat_json_object_add_ip4 (&node, "src_address", src_address);
18216 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
18217 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
18218 vat_json_object_add_uint (&node, "template_interval",
18219 ntohl (mp->template_interval));
18220 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
18222 vat_json_print (vam->ofp, &node);
18223 vat_json_free (&node);
18225 vam->result_ready = 1;
18229 api_ipfix_exporter_dump (vat_main_t * vam)
18231 vl_api_ipfix_exporter_dump_t *mp;
18234 /* Construct the API message */
18235 M (IPFIX_EXPORTER_DUMP, mp);
18244 api_ipfix_classify_stream_dump (vat_main_t * vam)
18246 vl_api_ipfix_classify_stream_dump_t *mp;
18249 /* Construct the API message */
18250 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
18261 vl_api_ipfix_classify_stream_details_t_handler
18262 (vl_api_ipfix_classify_stream_details_t * mp)
18264 vat_main_t *vam = &vat_main;
18265 print (vam->ofp, "domain_id %d, src_port %d",
18266 ntohl (mp->domain_id), ntohs (mp->src_port));
18268 vam->result_ready = 1;
18272 vl_api_ipfix_classify_stream_details_t_handler_json
18273 (vl_api_ipfix_classify_stream_details_t * mp)
18275 vat_main_t *vam = &vat_main;
18276 vat_json_node_t node;
18278 vat_json_init_object (&node);
18279 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18280 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18282 vat_json_print (vam->ofp, &node);
18283 vat_json_free (&node);
18285 vam->result_ready = 1;
18289 api_ipfix_classify_table_dump (vat_main_t * vam)
18291 vl_api_ipfix_classify_table_dump_t *mp;
18292 vl_api_control_ping_t *mp_ping;
18295 if (!vam->json_output)
18297 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18298 "transport_protocol");
18301 /* Construct the API message */
18302 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18307 /* Use a control ping for synchronization */
18308 MPING (CONTROL_PING, mp_ping);
18316 vl_api_ipfix_classify_table_details_t_handler
18317 (vl_api_ipfix_classify_table_details_t * mp)
18319 vat_main_t *vam = &vat_main;
18320 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18321 mp->transport_protocol);
18325 vl_api_ipfix_classify_table_details_t_handler_json
18326 (vl_api_ipfix_classify_table_details_t * mp)
18328 vat_json_node_t *node = NULL;
18329 vat_main_t *vam = &vat_main;
18331 if (VAT_JSON_ARRAY != vam->json_tree.type)
18333 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18334 vat_json_init_array (&vam->json_tree);
18337 node = vat_json_array_add (&vam->json_tree);
18338 vat_json_init_object (node);
18340 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18341 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18342 vat_json_object_add_uint (node, "transport_protocol",
18343 mp->transport_protocol);
18347 api_sw_interface_span_enable_disable (vat_main_t * vam)
18349 unformat_input_t *i = vam->input;
18350 vl_api_sw_interface_span_enable_disable_t *mp;
18351 u32 src_sw_if_index = ~0;
18352 u32 dst_sw_if_index = ~0;
18357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18360 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18362 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18366 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18368 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18370 else if (unformat (i, "disable"))
18372 else if (unformat (i, "rx"))
18374 else if (unformat (i, "tx"))
18376 else if (unformat (i, "both"))
18378 else if (unformat (i, "l2"))
18384 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18386 mp->sw_if_index_from = htonl (src_sw_if_index);
18387 mp->sw_if_index_to = htonl (dst_sw_if_index);
18397 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18400 vat_main_t *vam = &vat_main;
18401 u8 *sw_if_from_name = 0;
18402 u8 *sw_if_to_name = 0;
18403 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18404 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18405 char *states[] = { "none", "rx", "tx", "both" };
18409 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18411 if ((u32) p->value[0] == sw_if_index_from)
18413 sw_if_from_name = (u8 *)(p->key);
18417 if ((u32) p->value[0] == sw_if_index_to)
18419 sw_if_to_name = (u8 *)(p->key);
18420 if (sw_if_from_name)
18425 print (vam->ofp, "%20s => %20s (%s) %s",
18426 sw_if_from_name, sw_if_to_name, states[mp->state],
18427 mp->is_l2 ? "l2" : "device");
18431 vl_api_sw_interface_span_details_t_handler_json
18432 (vl_api_sw_interface_span_details_t * mp)
18434 vat_main_t *vam = &vat_main;
18435 vat_json_node_t *node = NULL;
18436 u8 *sw_if_from_name = 0;
18437 u8 *sw_if_to_name = 0;
18438 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18439 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18443 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18445 if ((u32) p->value[0] == sw_if_index_from)
18447 sw_if_from_name = (u8 *)(p->key);
18451 if ((u32) p->value[0] == sw_if_index_to)
18453 sw_if_to_name = (u8 *)(p->key);
18454 if (sw_if_from_name)
18460 if (VAT_JSON_ARRAY != vam->json_tree.type)
18462 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18463 vat_json_init_array (&vam->json_tree);
18465 node = vat_json_array_add (&vam->json_tree);
18467 vat_json_init_object (node);
18468 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18469 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18470 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18471 if (0 != sw_if_to_name)
18473 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18475 vat_json_object_add_uint (node, "state", mp->state);
18476 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
18480 api_sw_interface_span_dump (vat_main_t * vam)
18482 unformat_input_t *input = vam->input;
18483 vl_api_sw_interface_span_dump_t *mp;
18484 vl_api_control_ping_t *mp_ping;
18488 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18490 if (unformat (input, "l2"))
18496 M (SW_INTERFACE_SPAN_DUMP, mp);
18500 /* Use a control ping for synchronization */
18501 MPING (CONTROL_PING, mp_ping);
18509 api_pg_create_interface (vat_main_t * vam)
18511 unformat_input_t *input = vam->input;
18512 vl_api_pg_create_interface_t *mp;
18514 u32 if_id = ~0, gso_size = 0;
18515 u8 gso_enabled = 0;
18517 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18519 if (unformat (input, "if_id %d", &if_id))
18521 else if (unformat (input, "gso-enabled"))
18524 if (unformat (input, "gso-size %u", &gso_size))
18528 errmsg ("missing gso-size");
18537 errmsg ("missing pg interface index");
18541 /* Construct the API message */
18542 M (PG_CREATE_INTERFACE, mp);
18544 mp->interface_id = ntohl (if_id);
18545 mp->gso_enabled = gso_enabled;
18553 api_pg_capture (vat_main_t * vam)
18555 unformat_input_t *input = vam->input;
18556 vl_api_pg_capture_t *mp;
18561 u8 pcap_file_set = 0;
18564 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18566 if (unformat (input, "if_id %d", &if_id))
18568 else if (unformat (input, "pcap %s", &pcap_file))
18570 else if (unformat (input, "count %d", &count))
18572 else if (unformat (input, "disable"))
18579 errmsg ("missing pg interface index");
18582 if (pcap_file_set > 0)
18584 if (vec_len (pcap_file) > 255)
18586 errmsg ("pcap file name is too long");
18591 /* Construct the API message */
18592 M (PG_CAPTURE, mp);
18594 mp->interface_id = ntohl (if_id);
18595 mp->is_enabled = enable;
18596 mp->count = ntohl (count);
18597 if (pcap_file_set != 0)
18599 vl_api_vec_to_api_string (pcap_file, &mp->pcap_file_name);
18601 vec_free (pcap_file);
18609 api_pg_enable_disable (vat_main_t * vam)
18611 unformat_input_t *input = vam->input;
18612 vl_api_pg_enable_disable_t *mp;
18615 u8 stream_name_set = 0;
18616 u8 *stream_name = 0;
18618 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18620 if (unformat (input, "stream %s", &stream_name))
18621 stream_name_set = 1;
18622 else if (unformat (input, "disable"))
18628 if (stream_name_set > 0)
18630 if (vec_len (stream_name) > 255)
18632 errmsg ("stream name too long");
18637 /* Construct the API message */
18638 M (PG_ENABLE_DISABLE, mp);
18640 mp->is_enabled = enable;
18641 if (stream_name_set != 0)
18643 vl_api_vec_to_api_string (stream_name, &mp->stream_name);
18645 vec_free (stream_name);
18653 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18655 unformat_input_t *input = vam->input;
18656 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18658 u16 *low_ports = 0;
18659 u16 *high_ports = 0;
18662 vl_api_prefix_t prefix;
18669 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18671 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
18673 else if (unformat (input, "vrf %d", &vrf_id))
18675 else if (unformat (input, "del"))
18677 else if (unformat (input, "port %d", &tmp))
18679 if (tmp == 0 || tmp > 65535)
18681 errmsg ("port %d out of range", tmp);
18685 this_hi = this_low + 1;
18686 vec_add1 (low_ports, this_low);
18687 vec_add1 (high_ports, this_hi);
18689 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18691 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18693 errmsg ("incorrect range parameters");
18697 /* Note: in debug CLI +1 is added to high before
18698 passing to real fn that does "the work"
18699 (ip_source_and_port_range_check_add_del).
18700 This fn is a wrapper around the binary API fn a
18701 control plane will call, which expects this increment
18702 to have occurred. Hence letting the binary API control
18703 plane fn do the increment for consistency between VAT
18704 and other control planes.
18707 vec_add1 (low_ports, this_low);
18708 vec_add1 (high_ports, this_hi);
18714 if (prefix_set == 0)
18716 errmsg ("<address>/<mask> not specified");
18722 errmsg ("VRF ID required, not specified");
18729 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18733 if (vec_len (low_ports) == 0)
18735 errmsg ("At least one port or port range required");
18739 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18741 mp->is_add = is_add;
18743 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
18745 mp->number_of_ranges = vec_len (low_ports);
18747 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18748 vec_free (low_ports);
18750 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18751 vec_free (high_ports);
18753 mp->vrf_id = ntohl (vrf_id);
18761 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18763 unformat_input_t *input = vam->input;
18764 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18765 u32 sw_if_index = ~0;
18767 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18768 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18772 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18774 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18776 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18778 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18780 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18782 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18784 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18786 else if (unformat (input, "del"))
18792 if (sw_if_index == ~0)
18794 errmsg ("Interface required but not specified");
18800 errmsg ("VRF ID required but not specified");
18804 if (tcp_out_vrf_id == 0
18805 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18808 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18812 /* Construct the API message */
18813 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18815 mp->sw_if_index = ntohl (sw_if_index);
18816 mp->is_add = is_add;
18817 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18818 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18819 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18820 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18825 /* Wait for a reply... */
18831 api_set_punt (vat_main_t * vam)
18833 unformat_input_t *i = vam->input;
18834 vl_api_address_family_t af;
18835 vl_api_set_punt_t *mp;
18841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18843 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
18845 else if (unformat (i, "protocol %d", &protocol))
18847 else if (unformat (i, "port %d", &port))
18849 else if (unformat (i, "del"))
18853 clib_warning ("parse error '%U'", format_unformat_error, i);
18860 mp->is_add = (u8) is_add;
18861 mp->punt.type = PUNT_API_TYPE_L4;
18862 mp->punt.punt.l4.af = af;
18863 mp->punt.punt.l4.protocol = (u8) protocol;
18864 mp->punt.punt.l4.port = htons ((u16) port);
18872 api_delete_subif (vat_main_t * vam)
18874 unformat_input_t *i = vam->input;
18875 vl_api_delete_subif_t *mp;
18876 u32 sw_if_index = ~0;
18879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18881 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18883 if (unformat (i, "sw_if_index %d", &sw_if_index))
18889 if (sw_if_index == ~0)
18891 errmsg ("missing sw_if_index");
18895 /* Construct the API message */
18896 M (DELETE_SUBIF, mp);
18897 mp->sw_if_index = ntohl (sw_if_index);
18904 #define foreach_pbb_vtr_op \
18905 _("disable", L2_VTR_DISABLED) \
18906 _("pop", L2_VTR_POP_2) \
18907 _("push", L2_VTR_PUSH_2)
18910 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18912 unformat_input_t *i = vam->input;
18913 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18914 u32 sw_if_index = ~0, vtr_op = ~0;
18915 u16 outer_tag = ~0;
18916 u8 dmac[6], smac[6];
18917 u8 dmac_set = 0, smac_set = 0;
18923 /* Shut up coverity */
18924 clib_memset (dmac, 0, sizeof (dmac));
18925 clib_memset (smac, 0, sizeof (smac));
18927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18929 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18931 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18933 else if (unformat (i, "vtr_op %d", &vtr_op))
18935 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18938 else if (unformat (i, "translate_pbb_stag"))
18940 if (unformat (i, "%d", &tmp))
18942 vtr_op = L2_VTR_TRANSLATE_2_1;
18948 ("translate_pbb_stag operation requires outer tag definition");
18952 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18954 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18956 else if (unformat (i, "sid %d", &sid))
18958 else if (unformat (i, "vlanid %d", &tmp))
18962 clib_warning ("parse error '%U'", format_unformat_error, i);
18967 if ((sw_if_index == ~0) || (vtr_op == ~0))
18969 errmsg ("missing sw_if_index or vtr operation");
18972 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18973 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18976 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18980 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18981 mp->sw_if_index = ntohl (sw_if_index);
18982 mp->vtr_op = ntohl (vtr_op);
18983 mp->outer_tag = ntohs (outer_tag);
18984 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18985 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18986 mp->b_vlanid = ntohs (vlanid);
18987 mp->i_sid = ntohl (sid);
18995 api_flow_classify_set_interface (vat_main_t * vam)
18997 unformat_input_t *i = vam->input;
18998 vl_api_flow_classify_set_interface_t *mp;
19000 int sw_if_index_set;
19001 u32 ip4_table_index = ~0;
19002 u32 ip6_table_index = ~0;
19006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19008 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19009 sw_if_index_set = 1;
19010 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19011 sw_if_index_set = 1;
19012 else if (unformat (i, "del"))
19014 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19016 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19020 clib_warning ("parse error '%U'", format_unformat_error, i);
19025 if (sw_if_index_set == 0)
19027 errmsg ("missing interface name or sw_if_index");
19031 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19033 mp->sw_if_index = ntohl (sw_if_index);
19034 mp->ip4_table_index = ntohl (ip4_table_index);
19035 mp->ip6_table_index = ntohl (ip6_table_index);
19036 mp->is_add = is_add;
19044 api_flow_classify_dump (vat_main_t * vam)
19046 unformat_input_t *i = vam->input;
19047 vl_api_flow_classify_dump_t *mp;
19048 vl_api_control_ping_t *mp_ping;
19049 u8 type = FLOW_CLASSIFY_N_TABLES;
19052 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19056 errmsg ("classify table type must be specified");
19060 if (!vam->json_output)
19062 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19065 M (FLOW_CLASSIFY_DUMP, mp);
19070 /* Use a control ping for synchronization */
19071 MPING (CONTROL_PING, mp_ping);
19074 /* Wait for a reply... */
19080 api_feature_enable_disable (vat_main_t * vam)
19082 unformat_input_t *i = vam->input;
19083 vl_api_feature_enable_disable_t *mp;
19085 u8 *feature_name = 0;
19086 u32 sw_if_index = ~0;
19090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19092 if (unformat (i, "arc_name %s", &arc_name))
19094 else if (unformat (i, "feature_name %s", &feature_name))
19097 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19099 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19101 else if (unformat (i, "disable"))
19109 errmsg ("missing arc name");
19112 if (vec_len (arc_name) > 63)
19114 errmsg ("arc name too long");
19117 if (feature_name == 0)
19119 errmsg ("missing feature name");
19122 if (vec_len (feature_name) > 63)
19124 errmsg ("feature name too long");
19127 if (sw_if_index == ~0)
19129 errmsg ("missing interface name or sw_if_index");
19133 /* Construct the API message */
19134 M (FEATURE_ENABLE_DISABLE, mp);
19135 mp->sw_if_index = ntohl (sw_if_index);
19136 mp->enable = enable;
19137 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19138 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19139 vec_free (arc_name);
19140 vec_free (feature_name);
19148 api_feature_gso_enable_disable (vat_main_t * vam)
19150 unformat_input_t *i = vam->input;
19151 vl_api_feature_gso_enable_disable_t *mp;
19152 u32 sw_if_index = ~0;
19156 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19158 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19160 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19162 else if (unformat (i, "enable"))
19164 else if (unformat (i, "disable"))
19170 if (sw_if_index == ~0)
19172 errmsg ("missing interface name or sw_if_index");
19176 /* Construct the API message */
19177 M (FEATURE_GSO_ENABLE_DISABLE, mp);
19178 mp->sw_if_index = ntohl (sw_if_index);
19179 mp->enable_disable = enable;
19187 api_sw_interface_tag_add_del (vat_main_t * vam)
19189 unformat_input_t *i = vam->input;
19190 vl_api_sw_interface_tag_add_del_t *mp;
19191 u32 sw_if_index = ~0;
19196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19198 if (unformat (i, "tag %s", &tag))
19200 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19202 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19204 else if (unformat (i, "del"))
19210 if (sw_if_index == ~0)
19212 errmsg ("missing interface name or sw_if_index");
19216 if (enable && (tag == 0))
19218 errmsg ("no tag specified");
19222 /* Construct the API message */
19223 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19224 mp->sw_if_index = ntohl (sw_if_index);
19225 mp->is_add = enable;
19227 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19236 api_sw_interface_add_del_mac_address (vat_main_t * vam)
19238 unformat_input_t *i = vam->input;
19239 vl_api_mac_address_t mac = { 0 };
19240 vl_api_sw_interface_add_del_mac_address_t *mp;
19241 u32 sw_if_index = ~0;
19246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19248 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19250 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19252 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
19254 else if (unformat (i, "del"))
19260 if (sw_if_index == ~0)
19262 errmsg ("missing interface name or sw_if_index");
19268 errmsg ("missing MAC address");
19272 /* Construct the API message */
19273 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
19274 mp->sw_if_index = ntohl (sw_if_index);
19275 mp->is_add = is_add;
19276 clib_memcpy (&mp->addr, &mac, sizeof (mac));
19283 static void vl_api_l2_xconnect_details_t_handler
19284 (vl_api_l2_xconnect_details_t * mp)
19286 vat_main_t *vam = &vat_main;
19288 print (vam->ofp, "%15d%15d",
19289 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19292 static void vl_api_l2_xconnect_details_t_handler_json
19293 (vl_api_l2_xconnect_details_t * mp)
19295 vat_main_t *vam = &vat_main;
19296 vat_json_node_t *node = NULL;
19298 if (VAT_JSON_ARRAY != vam->json_tree.type)
19300 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19301 vat_json_init_array (&vam->json_tree);
19303 node = vat_json_array_add (&vam->json_tree);
19305 vat_json_init_object (node);
19306 vat_json_object_add_uint (node, "rx_sw_if_index",
19307 ntohl (mp->rx_sw_if_index));
19308 vat_json_object_add_uint (node, "tx_sw_if_index",
19309 ntohl (mp->tx_sw_if_index));
19313 api_l2_xconnect_dump (vat_main_t * vam)
19315 vl_api_l2_xconnect_dump_t *mp;
19316 vl_api_control_ping_t *mp_ping;
19319 if (!vam->json_output)
19321 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19324 M (L2_XCONNECT_DUMP, mp);
19328 /* Use a control ping for synchronization */
19329 MPING (CONTROL_PING, mp_ping);
19337 api_hw_interface_set_mtu (vat_main_t * vam)
19339 unformat_input_t *i = vam->input;
19340 vl_api_hw_interface_set_mtu_t *mp;
19341 u32 sw_if_index = ~0;
19345 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19347 if (unformat (i, "mtu %d", &mtu))
19349 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19351 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19357 if (sw_if_index == ~0)
19359 errmsg ("missing interface name or sw_if_index");
19365 errmsg ("no mtu specified");
19369 /* Construct the API message */
19370 M (HW_INTERFACE_SET_MTU, mp);
19371 mp->sw_if_index = ntohl (sw_if_index);
19372 mp->mtu = ntohs ((u16) mtu);
19380 api_p2p_ethernet_add (vat_main_t * vam)
19382 unformat_input_t *i = vam->input;
19383 vl_api_p2p_ethernet_add_t *mp;
19384 u32 parent_if_index = ~0;
19390 clib_memset (remote_mac, 0, sizeof (remote_mac));
19391 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19393 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19395 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19399 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19401 else if (unformat (i, "sub_id %d", &sub_id))
19405 clib_warning ("parse error '%U'", format_unformat_error, i);
19410 if (parent_if_index == ~0)
19412 errmsg ("missing interface name or sw_if_index");
19417 errmsg ("missing remote mac address");
19422 errmsg ("missing sub-interface id");
19426 M (P2P_ETHERNET_ADD, mp);
19427 mp->parent_if_index = ntohl (parent_if_index);
19428 mp->subif_id = ntohl (sub_id);
19429 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19437 api_p2p_ethernet_del (vat_main_t * vam)
19439 unformat_input_t *i = vam->input;
19440 vl_api_p2p_ethernet_del_t *mp;
19441 u32 parent_if_index = ~0;
19446 clib_memset (remote_mac, 0, sizeof (remote_mac));
19447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19449 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19451 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19455 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19459 clib_warning ("parse error '%U'", format_unformat_error, i);
19464 if (parent_if_index == ~0)
19466 errmsg ("missing interface name or sw_if_index");
19471 errmsg ("missing remote mac address");
19475 M (P2P_ETHERNET_DEL, mp);
19476 mp->parent_if_index = ntohl (parent_if_index);
19477 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19485 api_lldp_config (vat_main_t * vam)
19487 unformat_input_t *i = vam->input;
19488 vl_api_lldp_config_t *mp;
19490 int tx_interval = 0;
19491 u8 *sys_name = NULL;
19494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19496 if (unformat (i, "system-name %s", &sys_name))
19498 else if (unformat (i, "tx-hold %d", &tx_hold))
19500 else if (unformat (i, "tx-interval %d", &tx_interval))
19504 clib_warning ("parse error '%U'", format_unformat_error, i);
19509 vec_add1 (sys_name, 0);
19511 M (LLDP_CONFIG, mp);
19512 mp->tx_hold = htonl (tx_hold);
19513 mp->tx_interval = htonl (tx_interval);
19514 vl_api_vec_to_api_string (sys_name, &mp->system_name);
19515 vec_free (sys_name);
19523 api_sw_interface_set_lldp (vat_main_t * vam)
19525 unformat_input_t *i = vam->input;
19526 vl_api_sw_interface_set_lldp_t *mp;
19527 u32 sw_if_index = ~0;
19529 u8 *port_desc = NULL, *mgmt_oid = NULL;
19530 ip4_address_t ip4_addr;
19531 ip6_address_t ip6_addr;
19534 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
19535 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
19537 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19539 if (unformat (i, "disable"))
19542 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19544 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19546 else if (unformat (i, "port-desc %s", &port_desc))
19548 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
19550 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
19552 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
19558 if (sw_if_index == ~0)
19560 errmsg ("missing interface name or sw_if_index");
19564 /* Construct the API message */
19565 vec_add1 (port_desc, 0);
19566 vec_add1 (mgmt_oid, 0);
19567 M (SW_INTERFACE_SET_LLDP, mp);
19568 mp->sw_if_index = ntohl (sw_if_index);
19569 mp->enable = enable;
19570 vl_api_vec_to_api_string (port_desc, &mp->port_desc);
19571 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
19572 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
19573 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
19574 vec_free (port_desc);
19575 vec_free (mgmt_oid);
19583 api_tcp_configure_src_addresses (vat_main_t * vam)
19585 vl_api_tcp_configure_src_addresses_t *mp;
19586 unformat_input_t *i = vam->input;
19587 vl_api_address_t first, last;
19592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19594 if (unformat (i, "%U - %U",
19595 unformat_vl_api_address, &first,
19596 unformat_vl_api_address, &last))
19600 errmsg ("one range per message (range already set)");
19605 else if (unformat (i, "vrf %d", &vrf_id))
19611 if (range_set == 0)
19613 errmsg ("address range not set");
19617 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
19619 mp->vrf_id = ntohl (vrf_id);
19620 clib_memcpy (&mp->first_address, &first, sizeof (first));
19621 clib_memcpy (&mp->last_address, &last, sizeof (last));
19628 static void vl_api_app_namespace_add_del_reply_t_handler
19629 (vl_api_app_namespace_add_del_reply_t * mp)
19631 vat_main_t *vam = &vat_main;
19632 i32 retval = ntohl (mp->retval);
19633 if (vam->async_mode)
19635 vam->async_errors += (retval < 0);
19639 vam->retval = retval;
19641 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
19642 vam->result_ready = 1;
19646 static void vl_api_app_namespace_add_del_reply_t_handler_json
19647 (vl_api_app_namespace_add_del_reply_t * mp)
19649 vat_main_t *vam = &vat_main;
19650 vat_json_node_t node;
19652 vat_json_init_object (&node);
19653 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
19654 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
19656 vat_json_print (vam->ofp, &node);
19657 vat_json_free (&node);
19659 vam->retval = ntohl (mp->retval);
19660 vam->result_ready = 1;
19664 api_app_namespace_add_del (vat_main_t * vam)
19666 vl_api_app_namespace_add_del_t *mp;
19667 unformat_input_t *i = vam->input;
19668 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
19669 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
19673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19675 if (unformat (i, "id %_%v%_", &ns_id))
19677 else if (unformat (i, "secret %lu", &secret))
19679 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19680 sw_if_index_set = 1;
19681 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
19683 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
19688 if (!ns_id || !secret_set || !sw_if_index_set)
19690 errmsg ("namespace id, secret and sw_if_index must be set");
19693 if (vec_len (ns_id) > 64)
19695 errmsg ("namespace id too long");
19698 M (APP_NAMESPACE_ADD_DEL, mp);
19700 vl_api_vec_to_api_string (ns_id, &mp->namespace_id);
19701 mp->secret = clib_host_to_net_u64 (secret);
19702 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
19703 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
19704 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
19712 api_sock_init_shm (vat_main_t * vam)
19714 #if VPP_API_TEST_BUILTIN == 0
19715 unformat_input_t *i = vam->input;
19716 vl_api_shm_elem_config_t *config = 0;
19717 u64 size = 64 << 20;
19720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19722 if (unformat (i, "size %U", unformat_memory_size, &size))
19729 * Canned custom ring allocator config.
19730 * Should probably parse all of this
19732 vec_validate (config, 6);
19733 config[0].type = VL_API_VLIB_RING;
19734 config[0].size = 256;
19735 config[0].count = 32;
19737 config[1].type = VL_API_VLIB_RING;
19738 config[1].size = 1024;
19739 config[1].count = 16;
19741 config[2].type = VL_API_VLIB_RING;
19742 config[2].size = 4096;
19743 config[2].count = 2;
19745 config[3].type = VL_API_CLIENT_RING;
19746 config[3].size = 256;
19747 config[3].count = 32;
19749 config[4].type = VL_API_CLIENT_RING;
19750 config[4].size = 1024;
19751 config[4].count = 16;
19753 config[5].type = VL_API_CLIENT_RING;
19754 config[5].size = 4096;
19755 config[5].count = 2;
19757 config[6].type = VL_API_QUEUE;
19758 config[6].count = 128;
19759 config[6].size = sizeof (uword);
19761 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
19763 vam->client_index_invalid = 1;
19771 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
19773 vat_main_t *vam = &vat_main;
19774 fib_prefix_t lcl, rmt;
19776 ip_prefix_decode (&mp->lcl, &lcl);
19777 ip_prefix_decode (&mp->rmt, &rmt);
19779 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19782 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19783 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19784 mp->scope, format_ip4_address, &lcl.fp_addr.ip4, lcl.fp_len,
19785 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
19786 &rmt.fp_addr.ip4, rmt.fp_len,
19787 clib_net_to_host_u16 (mp->rmt_port),
19788 clib_net_to_host_u32 (mp->action_index), mp->tag);
19793 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19794 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19795 mp->scope, format_ip6_address, &lcl.fp_addr.ip6, lcl.fp_len,
19796 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
19797 &rmt.fp_addr.ip6, rmt.fp_len,
19798 clib_net_to_host_u16 (mp->rmt_port),
19799 clib_net_to_host_u32 (mp->action_index), mp->tag);
19804 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
19807 vat_main_t *vam = &vat_main;
19808 vat_json_node_t *node = NULL;
19809 struct in6_addr ip6;
19810 struct in_addr ip4;
19812 fib_prefix_t lcl, rmt;
19814 ip_prefix_decode (&mp->lcl, &lcl);
19815 ip_prefix_decode (&mp->rmt, &rmt);
19817 if (VAT_JSON_ARRAY != vam->json_tree.type)
19819 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19820 vat_json_init_array (&vam->json_tree);
19822 node = vat_json_array_add (&vam->json_tree);
19823 vat_json_init_object (node);
19825 vat_json_object_add_uint (node, "appns_index",
19826 clib_net_to_host_u32 (mp->appns_index));
19827 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
19828 vat_json_object_add_uint (node, "scope", mp->scope);
19829 vat_json_object_add_uint (node, "action_index",
19830 clib_net_to_host_u32 (mp->action_index));
19831 vat_json_object_add_uint (node, "lcl_port",
19832 clib_net_to_host_u16 (mp->lcl_port));
19833 vat_json_object_add_uint (node, "rmt_port",
19834 clib_net_to_host_u16 (mp->rmt_port));
19835 vat_json_object_add_uint (node, "lcl_plen", lcl.fp_len);
19836 vat_json_object_add_uint (node, "rmt_plen", rmt.fp_len);
19837 vat_json_object_add_string_copy (node, "tag", mp->tag);
19838 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19840 clib_memcpy (&ip4, &lcl.fp_addr.ip4, sizeof (ip4));
19841 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
19842 clib_memcpy (&ip4, &rmt.fp_addr.ip4, sizeof (ip4));
19843 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
19847 clib_memcpy (&ip6, &lcl.fp_addr.ip6, sizeof (ip6));
19848 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
19849 clib_memcpy (&ip6, &rmt.fp_addr.ip6, sizeof (ip6));
19850 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
19855 api_session_rule_add_del (vat_main_t * vam)
19857 vl_api_session_rule_add_del_t *mp;
19858 unformat_input_t *i = vam->input;
19859 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
19860 u32 appns_index = 0, scope = 0;
19861 ip4_address_t lcl_ip4, rmt_ip4;
19862 ip6_address_t lcl_ip6, rmt_ip6;
19863 u8 is_ip4 = 1, conn_set = 0;
19864 u8 is_add = 1, *tag = 0;
19866 fib_prefix_t lcl, rmt;
19868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19870 if (unformat (i, "del"))
19872 else if (unformat (i, "add"))
19874 else if (unformat (i, "proto tcp"))
19876 else if (unformat (i, "proto udp"))
19878 else if (unformat (i, "appns %d", &appns_index))
19880 else if (unformat (i, "scope %d", &scope))
19882 else if (unformat (i, "tag %_%v%_", &tag))
19886 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
19887 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
19895 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
19896 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
19902 else if (unformat (i, "action %d", &action))
19907 if (proto == ~0 || !conn_set || action == ~0)
19909 errmsg ("transport proto, connection and action must be set");
19915 errmsg ("scope should be 0-3");
19919 M (SESSION_RULE_ADD_DEL, mp);
19921 clib_memset (&lcl, 0, sizeof (lcl));
19922 clib_memset (&rmt, 0, sizeof (rmt));
19925 ip_set (&lcl.fp_addr, &lcl_ip4, 1);
19926 ip_set (&rmt.fp_addr, &rmt_ip4, 1);
19927 lcl.fp_len = lcl_plen;
19928 rmt.fp_len = rmt_plen;
19932 ip_set (&lcl.fp_addr, &lcl_ip6, 0);
19933 ip_set (&rmt.fp_addr, &rmt_ip6, 0);
19934 lcl.fp_len = lcl_plen;
19935 rmt.fp_len = rmt_plen;
19939 ip_prefix_encode (&lcl, &mp->lcl);
19940 ip_prefix_encode (&rmt, &mp->rmt);
19941 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
19942 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
19943 mp->transport_proto =
19944 proto ? TRANSPORT_PROTO_API_UDP : TRANSPORT_PROTO_API_TCP;
19945 mp->action_index = clib_host_to_net_u32 (action);
19946 mp->appns_index = clib_host_to_net_u32 (appns_index);
19948 mp->is_add = is_add;
19951 clib_memcpy (mp->tag, tag, vec_len (tag));
19961 api_session_rules_dump (vat_main_t * vam)
19963 vl_api_session_rules_dump_t *mp;
19964 vl_api_control_ping_t *mp_ping;
19967 if (!vam->json_output)
19969 print (vam->ofp, "%=20s", "Session Rules");
19972 M (SESSION_RULES_DUMP, mp);
19976 /* Use a control ping for synchronization */
19977 MPING (CONTROL_PING, mp_ping);
19980 /* Wait for a reply... */
19986 api_ip_container_proxy_add_del (vat_main_t * vam)
19988 vl_api_ip_container_proxy_add_del_t *mp;
19989 unformat_input_t *i = vam->input;
19990 u32 sw_if_index = ~0;
19991 vl_api_prefix_t pfx = { };
19995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19997 if (unformat (i, "del"))
19999 else if (unformat (i, "add"))
20001 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
20003 else if (unformat (i, "sw_if_index %u", &sw_if_index))
20008 if (sw_if_index == ~0 || pfx.len == 0)
20010 errmsg ("address and sw_if_index must be set");
20014 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
20016 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20017 mp->is_add = is_add;
20018 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
20026 api_qos_record_enable_disable (vat_main_t * vam)
20028 unformat_input_t *i = vam->input;
20029 vl_api_qos_record_enable_disable_t *mp;
20030 u32 sw_if_index, qs = 0xff;
20031 u8 sw_if_index_set = 0;
20035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20037 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20038 sw_if_index_set = 1;
20039 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20040 sw_if_index_set = 1;
20041 else if (unformat (i, "%U", unformat_qos_source, &qs))
20043 else if (unformat (i, "disable"))
20047 clib_warning ("parse error '%U'", format_unformat_error, i);
20052 if (sw_if_index_set == 0)
20054 errmsg ("missing interface name or sw_if_index");
20059 errmsg ("input location must be specified");
20063 M (QOS_RECORD_ENABLE_DISABLE, mp);
20065 mp->record.sw_if_index = ntohl (sw_if_index);
20066 mp->record.input_source = qs;
20067 mp->enable = enable;
20076 q_or_quit (vat_main_t * vam)
20078 #if VPP_API_TEST_BUILTIN == 0
20079 longjmp (vam->jump_buf, 1);
20081 return 0; /* not so much */
20085 q (vat_main_t * vam)
20087 return q_or_quit (vam);
20091 quit (vat_main_t * vam)
20093 return q_or_quit (vam);
20097 comment (vat_main_t * vam)
20103 elog_save (vat_main_t * vam)
20105 #if VPP_API_TEST_BUILTIN == 0
20106 elog_main_t *em = &vam->elog_main;
20107 unformat_input_t *i = vam->input;
20108 char *file, *chroot_file;
20109 clib_error_t *error;
20111 if (!unformat (i, "%s", &file))
20113 errmsg ("expected file name, got `%U'", format_unformat_error, i);
20117 /* It's fairly hard to get "../oopsie" through unformat; just in case */
20118 if (strstr (file, "..") || index (file, '/'))
20120 errmsg ("illegal characters in filename '%s'", file);
20124 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
20128 errmsg ("Saving %wd of %wd events to %s",
20129 elog_n_events_in_buffer (em),
20130 elog_buffer_capacity (em), chroot_file);
20132 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
20133 vec_free (chroot_file);
20136 clib_error_report (error);
20138 errmsg ("Use the vpp event loger...");
20145 elog_setup (vat_main_t * vam)
20147 #if VPP_API_TEST_BUILTIN == 0
20148 elog_main_t *em = &vam->elog_main;
20149 unformat_input_t *i = vam->input;
20150 u32 nevents = 128 << 10;
20152 (void) unformat (i, "nevents %d", &nevents);
20154 elog_init (em, nevents);
20155 vl_api_set_elog_main (em);
20156 vl_api_set_elog_trace_api_messages (1);
20157 errmsg ("Event logger initialized with %u events", nevents);
20159 errmsg ("Use the vpp event loger...");
20165 elog_enable (vat_main_t * vam)
20167 #if VPP_API_TEST_BUILTIN == 0
20168 elog_main_t *em = &vam->elog_main;
20170 elog_enable_disable (em, 1 /* enable */ );
20171 vl_api_set_elog_trace_api_messages (1);
20172 errmsg ("Event logger enabled...");
20174 errmsg ("Use the vpp event loger...");
20180 elog_disable (vat_main_t * vam)
20182 #if VPP_API_TEST_BUILTIN == 0
20183 elog_main_t *em = &vam->elog_main;
20185 elog_enable_disable (em, 0 /* enable */ );
20186 vl_api_set_elog_trace_api_messages (1);
20187 errmsg ("Event logger disabled...");
20189 errmsg ("Use the vpp event loger...");
20195 statseg (vat_main_t * vam)
20197 ssvm_private_t *ssvmp = &vam->stat_segment;
20198 ssvm_shared_header_t *shared_header = ssvmp->sh;
20199 vlib_counter_t **counters;
20200 u64 thread0_index1_packets;
20201 u64 thread0_index1_bytes;
20202 f64 vector_rate, input_rate;
20205 uword *counter_vector_by_name;
20206 if (vam->stat_segment_lockp == 0)
20208 errmsg ("Stat segment not mapped...");
20212 /* look up "/if/rx for sw_if_index 1 as a test */
20214 clib_spinlock_lock (vam->stat_segment_lockp);
20216 counter_vector_by_name = (uword *) shared_header->opaque[1];
20218 p = hash_get_mem (counter_vector_by_name, "/if/rx");
20221 clib_spinlock_unlock (vam->stat_segment_lockp);
20222 errmsg ("/if/tx not found?");
20226 /* Fish per-thread vector of combined counters from shared memory */
20227 counters = (vlib_counter_t **) p[0];
20229 if (vec_len (counters[0]) < 2)
20231 clib_spinlock_unlock (vam->stat_segment_lockp);
20232 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
20236 /* Read thread 0 sw_if_index 1 counter */
20237 thread0_index1_packets = counters[0][1].packets;
20238 thread0_index1_bytes = counters[0][1].bytes;
20240 p = hash_get_mem (counter_vector_by_name, "vector_rate");
20243 clib_spinlock_unlock (vam->stat_segment_lockp);
20244 errmsg ("vector_rate not found?");
20248 vector_rate = *(f64 *) (p[0]);
20249 p = hash_get_mem (counter_vector_by_name, "input_rate");
20252 clib_spinlock_unlock (vam->stat_segment_lockp);
20253 errmsg ("input_rate not found?");
20256 input_rate = *(f64 *) (p[0]);
20258 clib_spinlock_unlock (vam->stat_segment_lockp);
20260 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
20261 vector_rate, input_rate);
20262 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
20263 thread0_index1_packets, thread0_index1_bytes);
20269 cmd_cmp (void *a1, void *a2)
20274 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
20278 help (vat_main_t * vam)
20283 unformat_input_t *i = vam->input;
20286 if (unformat (i, "%s", &name))
20290 vec_add1 (name, 0);
20292 hs = hash_get_mem (vam->help_by_name, name);
20294 print (vam->ofp, "usage: %s %s", name, hs[0]);
20296 print (vam->ofp, "No such msg / command '%s'", name);
20301 print (vam->ofp, "Help is available for the following:");
20304 hash_foreach_pair (p, vam->function_by_name,
20306 vec_add1 (cmds, (u8 *)(p->key));
20310 vec_sort_with_function (cmds, cmd_cmp);
20312 for (j = 0; j < vec_len (cmds); j++)
20313 print (vam->ofp, "%s", cmds[j]);
20320 set (vat_main_t * vam)
20322 u8 *name = 0, *value = 0;
20323 unformat_input_t *i = vam->input;
20325 if (unformat (i, "%s", &name))
20327 /* The input buffer is a vector, not a string. */
20328 value = vec_dup (i->buffer);
20329 vec_delete (value, i->index, 0);
20330 /* Almost certainly has a trailing newline */
20331 if (value[vec_len (value) - 1] == '\n')
20332 value[vec_len (value) - 1] = 0;
20333 /* Make sure it's a proper string, one way or the other */
20334 vec_add1 (value, 0);
20335 (void) clib_macro_set_value (&vam->macro_main,
20336 (char *) name, (char *) value);
20339 errmsg ("usage: set <name> <value>");
20347 unset (vat_main_t * vam)
20351 if (unformat (vam->input, "%s", &name))
20352 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
20353 errmsg ("unset: %s wasn't set", name);
20366 macro_sort_cmp (void *a1, void *a2)
20368 macro_sort_t *s1 = a1;
20369 macro_sort_t *s2 = a2;
20371 return strcmp ((char *) (s1->name), (char *) (s2->name));
20375 dump_macro_table (vat_main_t * vam)
20377 macro_sort_t *sort_me = 0, *sm;
20382 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
20384 vec_add2 (sort_me, sm, 1);
20385 sm->name = (u8 *)(p->key);
20386 sm->value = (u8 *) (p->value[0]);
20390 vec_sort_with_function (sort_me, macro_sort_cmp);
20392 if (vec_len (sort_me))
20393 print (vam->ofp, "%-15s%s", "Name", "Value");
20395 print (vam->ofp, "The macro table is empty...");
20397 for (i = 0; i < vec_len (sort_me); i++)
20398 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
20403 dump_node_table (vat_main_t * vam)
20406 vlib_node_t *node, *next_node;
20408 if (vec_len (vam->graph_nodes) == 0)
20410 print (vam->ofp, "Node table empty, issue get_node_graph...");
20414 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
20416 node = vam->graph_nodes[0][i];
20417 print (vam->ofp, "[%d] %s", i, node->name);
20418 for (j = 0; j < vec_len (node->next_nodes); j++)
20420 if (node->next_nodes[j] != ~0)
20422 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20423 print (vam->ofp, " [%d] %s", j, next_node->name);
20431 value_sort_cmp (void *a1, void *a2)
20433 name_sort_t *n1 = a1;
20434 name_sort_t *n2 = a2;
20436 if (n1->value < n2->value)
20438 if (n1->value > n2->value)
20445 dump_msg_api_table (vat_main_t * vam)
20447 api_main_t *am = vlibapi_get_main ();
20448 name_sort_t *nses = 0, *ns;
20453 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
20455 vec_add2 (nses, ns, 1);
20456 ns->name = (u8 *)(hp->key);
20457 ns->value = (u32) hp->value[0];
20461 vec_sort_with_function (nses, value_sort_cmp);
20463 for (i = 0; i < vec_len (nses); i++)
20464 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
20470 get_msg_id (vat_main_t * vam)
20475 if (unformat (vam->input, "%s", &name_and_crc))
20477 message_index = vl_msg_api_get_msg_index (name_and_crc);
20478 if (message_index == ~0)
20480 print (vam->ofp, " '%s' not found", name_and_crc);
20483 print (vam->ofp, " '%s' has message index %d",
20484 name_and_crc, message_index);
20487 errmsg ("name_and_crc required...");
20492 search_node_table (vat_main_t * vam)
20494 unformat_input_t *line_input = vam->input;
20497 vlib_node_t *node, *next_node;
20500 if (vam->graph_node_index_by_name == 0)
20502 print (vam->ofp, "Node table empty, issue get_node_graph...");
20506 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20508 if (unformat (line_input, "%s", &node_to_find))
20510 vec_add1 (node_to_find, 0);
20511 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
20514 print (vam->ofp, "%s not found...", node_to_find);
20517 node = vam->graph_nodes[0][p[0]];
20518 print (vam->ofp, "[%d] %s", p[0], node->name);
20519 for (j = 0; j < vec_len (node->next_nodes); j++)
20521 if (node->next_nodes[j] != ~0)
20523 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20524 print (vam->ofp, " [%d] %s", j, next_node->name);
20531 clib_warning ("parse error '%U'", format_unformat_error,
20537 vec_free (node_to_find);
20546 script (vat_main_t * vam)
20548 #if (VPP_API_TEST_BUILTIN==0)
20550 char *save_current_file;
20551 unformat_input_t save_input;
20552 jmp_buf save_jump_buf;
20553 u32 save_line_number;
20555 FILE *new_fp, *save_ifp;
20557 if (unformat (vam->input, "%s", &s))
20559 new_fp = fopen ((char *) s, "r");
20562 errmsg ("Couldn't open script file %s", s);
20569 errmsg ("Missing script name");
20573 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
20574 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
20575 save_ifp = vam->ifp;
20576 save_line_number = vam->input_line_number;
20577 save_current_file = (char *) vam->current_file;
20579 vam->input_line_number = 0;
20581 vam->current_file = s;
20584 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
20585 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
20586 vam->ifp = save_ifp;
20587 vam->input_line_number = save_line_number;
20588 vam->current_file = (u8 *) save_current_file;
20593 clib_warning ("use the exec command...");
20599 echo (vat_main_t * vam)
20601 print (vam->ofp, "%v", vam->input->buffer);
20605 /* List of API message constructors, CLI names map to api_xxx */
20606 #define foreach_vpe_api_msg \
20607 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
20608 _(sw_interface_dump,"") \
20609 _(sw_interface_set_flags, \
20610 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
20611 _(sw_interface_add_del_address, \
20612 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
20613 _(sw_interface_set_rx_mode, \
20614 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
20615 _(sw_interface_set_rx_placement, \
20616 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
20617 _(sw_interface_rx_placement_dump, \
20618 "[<intfc> | sw_if_index <id>]") \
20619 _(sw_interface_set_table, \
20620 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
20621 _(sw_interface_set_mpls_enable, \
20622 "<intfc> | sw_if_index [disable | dis]") \
20623 _(sw_interface_set_vpath, \
20624 "<intfc> | sw_if_index <id> enable | disable") \
20625 _(sw_interface_set_vxlan_bypass, \
20626 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20627 _(sw_interface_set_geneve_bypass, \
20628 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20629 _(sw_interface_set_l2_xconnect, \
20630 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20631 "enable | disable") \
20632 _(sw_interface_set_l2_bridge, \
20633 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
20634 "[shg <split-horizon-group>] [bvi]\n" \
20635 "enable | disable") \
20636 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
20637 _(bridge_domain_add_del, \
20638 "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") \
20639 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
20641 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
20642 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
20643 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
20645 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20647 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20649 "id <num> [hw-addr <mac-addr>] [host-if-name <name>] [host-ns <name>] [num-rx-queues <num>] [rx-ring-size <num>] [tx-ring-size <num>] [host-bridge <name>] [host-mac-addr <mac-addr>] [host-ip4-addr <ip4addr/mask>] [host-ip6-addr <ip6addr/mask>] [host-mtu-size <mtu>] [gso | no-gso | csum-offload] [persist] [attach]") \
20651 "<vpp-if-name> | sw_if_index <id>") \
20652 _(sw_interface_tap_v2_dump, "") \
20653 _(virtio_pci_create, \
20654 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled | csum-offload-enabled]") \
20655 _(virtio_pci_delete, \
20656 "<vpp-if-name> | sw_if_index <id>") \
20657 _(sw_interface_virtio_pci_dump, "") \
20659 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
20660 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
20663 "<vpp-if-name> | sw_if_index <id>") \
20665 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
20666 _(bond_detach_slave, \
20667 "sw_if_index <n>") \
20668 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
20669 _(sw_interface_bond_dump, "") \
20670 _(sw_interface_slave_dump, \
20671 "<vpp-if-name> | sw_if_index <id>") \
20672 _(ip_table_add_del, \
20673 "table <n> [ipv6] [add | del]\n") \
20674 _(ip_route_add_del, \
20675 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
20676 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
20677 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
20678 "[multipath] [count <n>] [del]") \
20679 _(ip_mroute_add_del, \
20680 "<src> <grp>/<mask> [table-id <n>]\n" \
20681 "[<intfc> | sw_if_index <id>] [local] [del]") \
20682 _(mpls_table_add_del, \
20683 "table <n> [add | del]\n") \
20684 _(mpls_route_add_del, \
20685 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
20686 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
20687 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
20688 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
20689 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
20690 "[count <n>] [del]") \
20691 _(mpls_ip_bind_unbind, \
20692 "<label> <addr/len>") \
20693 _(mpls_tunnel_add_del, \
20694 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
20695 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
20696 "[l2-only] [out-label <n>]") \
20697 _(sr_mpls_policy_add, \
20698 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
20699 _(sr_mpls_policy_del, \
20701 _(bier_table_add_del, \
20702 "<label> <sub-domain> <set> <bsl> [del]") \
20703 _(bier_route_add_del, \
20704 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
20705 "[<intfc> | sw_if_index <id>]" \
20706 "[weight <n>] [del] [multipath]") \
20707 _(sw_interface_set_unnumbered, \
20708 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
20709 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
20710 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
20711 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
20712 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
20713 "[outer_vlan_id_any][inner_vlan_id_any]") \
20714 _(ip_table_replace_begin, "table <n> [ipv6]") \
20715 _(ip_table_flush, "table <n> [ipv6]") \
20716 _(ip_table_replace_end, "table <n> [ipv6]") \
20717 _(set_ip_flow_hash, \
20718 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
20719 _(sw_interface_ip6_enable_disable, \
20720 "<intfc> | sw_if_index <id> enable | disable") \
20721 _(l2_patch_add_del, \
20722 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20723 "enable | disable") \
20724 _(sr_localsid_add_del, \
20725 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
20726 "fib-table <num> (end.psp) sw_if_index <num>") \
20727 _(classify_add_del_table, \
20728 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
20729 " [del] [del-chain] mask <mask-value>\n" \
20730 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
20731 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
20732 _(classify_add_del_session, \
20733 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
20734 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
20735 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
20736 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
20737 _(classify_set_interface_ip_table, \
20738 "<intfc> | sw_if_index <nn> table <nn>") \
20739 _(classify_set_interface_l2_tables, \
20740 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20741 " [other-table <nn>]") \
20742 _(get_node_index, "node <node-name") \
20743 _(add_node_next, "node <node-name> next <next-node-name>") \
20744 _(l2tpv3_create_tunnel, \
20745 "client_address <ip6-addr> our_address <ip6-addr>\n" \
20746 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
20747 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
20748 _(l2tpv3_set_tunnel_cookies, \
20749 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
20750 "[new_remote_cookie <nn>]\n") \
20751 _(l2tpv3_interface_enable_disable, \
20752 "<intfc> | sw_if_index <nn> enable | disable") \
20753 _(l2tpv3_set_lookup_key, \
20754 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
20755 _(sw_if_l2tpv3_tunnel_dump, "") \
20756 _(vxlan_offload_rx, \
20757 "hw { <interface name> | hw_if_index <nn>} " \
20758 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
20759 _(vxlan_add_del_tunnel, \
20760 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20761 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
20762 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20763 _(geneve_add_del_tunnel, \
20764 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20765 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20766 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20767 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20768 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20769 _(gre_tunnel_add_del, \
20770 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
20771 "[teb | erspan <session-id>] [del]") \
20772 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20773 _(l2_fib_clear_table, "") \
20774 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
20775 _(l2_interface_vlan_tag_rewrite, \
20776 "<intfc> | sw_if_index <nn> \n" \
20777 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
20778 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
20779 _(create_vhost_user_if, \
20780 "socket <filename> [server] [renumber <dev_instance>] " \
20781 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
20782 "[mac <mac_address>]") \
20783 _(modify_vhost_user_if, \
20784 "<intfc> | sw_if_index <nn> socket <filename>\n" \
20785 "[server] [renumber <dev_instance>] [gso]") \
20786 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
20787 _(sw_interface_vhost_user_dump, "") \
20788 _(show_version, "") \
20789 _(show_threads, "") \
20790 _(vxlan_gpe_add_del_tunnel, \
20791 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
20792 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20793 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
20794 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
20795 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20796 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
20797 _(interface_name_renumber, \
20798 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
20799 _(input_acl_set_interface, \
20800 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20801 " [l2-table <nn>] [del]") \
20802 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
20803 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
20804 _(ip_dump, "ipv4 | ipv6") \
20805 _(ipsec_spd_add_del, "spd_id <n> [del]") \
20806 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
20808 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
20809 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
20810 " integ_alg <alg> integ_key <hex>") \
20811 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
20812 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
20813 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
20814 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
20815 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
20816 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
20817 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
20818 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
20819 " [instance <n>]") \
20820 _(ipsec_sa_dump, "[sa_id <n>]") \
20821 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
20822 _(delete_loopback,"sw_if_index <nn>") \
20823 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20824 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
20825 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
20826 _(want_interface_events, "enable|disable") \
20827 _(get_first_msg_id, "client <name>") \
20828 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20829 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20830 "fib-id <nn> [ip4][ip6][default]") \
20831 _(get_node_graph, " ") \
20832 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20833 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20834 _(ioam_disable, "") \
20835 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
20836 " sw_if_index <sw_if_index> p <priority> " \
20837 "w <weight>] [del]") \
20838 _(one_add_del_locator, "locator-set <locator_name> " \
20839 "iface <intf> | sw_if_index <sw_if_index> " \
20840 "p <priority> w <weight> [del]") \
20841 _(one_add_del_local_eid,"vni <vni> eid " \
20842 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20843 "locator-set <locator_name> [del]" \
20844 "[key-id sha1|sha256 secret-key <secret-key>]")\
20845 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
20846 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
20847 _(one_enable_disable, "enable|disable") \
20848 _(one_map_register_enable_disable, "enable|disable") \
20849 _(one_map_register_fallback_threshold, "<value>") \
20850 _(one_rloc_probe_enable_disable, "enable|disable") \
20851 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20853 "rloc <locator> p <prio> " \
20854 "w <weight> [rloc <loc> ... ] " \
20855 "action <action> [del-all]") \
20856 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20858 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20859 _(one_use_petr, "ip-address> | disable") \
20860 _(one_map_request_mode, "src-dst|dst-only") \
20861 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20862 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20863 _(one_locator_set_dump, "[local | remote]") \
20864 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
20865 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20866 "[local] | [remote]") \
20867 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
20868 _(one_ndp_bd_get, "") \
20869 _(one_ndp_entries_get, "bd <bridge-domain>") \
20870 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
20871 _(one_l2_arp_bd_get, "") \
20872 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
20873 _(one_stats_enable_disable, "enable|disable") \
20874 _(show_one_stats_enable_disable, "") \
20875 _(one_eid_table_vni_dump, "") \
20876 _(one_eid_table_map_dump, "l2|l3") \
20877 _(one_map_resolver_dump, "") \
20878 _(one_map_server_dump, "") \
20879 _(one_adjacencies_get, "vni <vni>") \
20880 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
20881 _(show_one_rloc_probe_state, "") \
20882 _(show_one_map_register_state, "") \
20883 _(show_one_status, "") \
20884 _(one_stats_dump, "") \
20885 _(one_stats_flush, "") \
20886 _(one_get_map_request_itr_rlocs, "") \
20887 _(one_map_register_set_ttl, "<ttl>") \
20888 _(one_set_transport_protocol, "udp|api") \
20889 _(one_get_transport_protocol, "") \
20890 _(one_enable_disable_xtr_mode, "enable|disable") \
20891 _(one_show_xtr_mode, "") \
20892 _(one_enable_disable_pitr_mode, "enable|disable") \
20893 _(one_show_pitr_mode, "") \
20894 _(one_enable_disable_petr_mode, "enable|disable") \
20895 _(one_show_petr_mode, "") \
20896 _(show_one_nsh_mapping, "") \
20897 _(show_one_pitr, "") \
20898 _(show_one_use_petr, "") \
20899 _(show_one_map_request_mode, "") \
20900 _(show_one_map_register_ttl, "") \
20901 _(show_one_map_register_fallback_threshold, "") \
20902 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
20903 " sw_if_index <sw_if_index> p <priority> " \
20904 "w <weight>] [del]") \
20905 _(lisp_add_del_locator, "locator-set <locator_name> " \
20906 "iface <intf> | sw_if_index <sw_if_index> " \
20907 "p <priority> w <weight> [del]") \
20908 _(lisp_add_del_local_eid,"vni <vni> eid " \
20909 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20910 "locator-set <locator_name> [del]" \
20911 "[key-id sha1|sha256 secret-key <secret-key>]") \
20912 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
20913 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
20914 _(lisp_enable_disable, "enable|disable") \
20915 _(lisp_map_register_enable_disable, "enable|disable") \
20916 _(lisp_rloc_probe_enable_disable, "enable|disable") \
20917 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20919 "rloc <locator> p <prio> " \
20920 "w <weight> [rloc <loc> ... ] " \
20921 "action <action> [del-all]") \
20922 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20924 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20925 _(lisp_use_petr, "<ip-address> | disable") \
20926 _(lisp_map_request_mode, "src-dst|dst-only") \
20927 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20928 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20929 _(lisp_locator_set_dump, "[local | remote]") \
20930 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
20931 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20932 "[local] | [remote]") \
20933 _(lisp_eid_table_vni_dump, "") \
20934 _(lisp_eid_table_map_dump, "l2|l3") \
20935 _(lisp_map_resolver_dump, "") \
20936 _(lisp_map_server_dump, "") \
20937 _(lisp_adjacencies_get, "vni <vni>") \
20938 _(gpe_fwd_entry_vnis_get, "") \
20939 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
20940 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
20941 "[table <table-id>]") \
20942 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
20943 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
20944 _(gpe_set_encap_mode, "lisp|vxlan") \
20945 _(gpe_get_encap_mode, "") \
20946 _(lisp_gpe_add_del_iface, "up|down") \
20947 _(lisp_gpe_enable_disable, "enable|disable") \
20948 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
20949 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
20950 _(show_lisp_rloc_probe_state, "") \
20951 _(show_lisp_map_register_state, "") \
20952 _(show_lisp_status, "") \
20953 _(lisp_get_map_request_itr_rlocs, "") \
20954 _(show_lisp_pitr, "") \
20955 _(show_lisp_use_petr, "") \
20956 _(show_lisp_map_request_mode, "") \
20957 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
20958 _(af_packet_delete, "name <host interface name>") \
20959 _(af_packet_dump, "") \
20960 _(policer_add_del, "name <policer name> <params> [del]") \
20961 _(policer_dump, "[name <policer name>]") \
20962 _(policer_classify_set_interface, \
20963 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20964 " [l2-table <nn>] [del]") \
20965 _(policer_classify_dump, "type [ip4|ip6|l2]") \
20966 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
20967 _(mpls_table_dump, "") \
20968 _(mpls_route_dump, "table-id <ID>") \
20969 _(classify_table_ids, "") \
20970 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
20971 _(classify_table_info, "table_id <nn>") \
20972 _(classify_session_dump, "table_id <nn>") \
20973 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
20974 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
20975 "[template_interval <nn>] [udp_checksum]") \
20976 _(ipfix_exporter_dump, "") \
20977 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
20978 _(ipfix_classify_stream_dump, "") \
20979 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
20980 _(ipfix_classify_table_dump, "") \
20981 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
20982 _(sw_interface_span_dump, "[l2]") \
20983 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
20984 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
20985 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
20986 _(pg_enable_disable, "[stream <id>] disable") \
20987 _(ip_source_and_port_range_check_add_del, \
20988 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
20989 _(ip_source_and_port_range_check_interface_add_del, \
20990 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
20991 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
20992 _(delete_subif,"<intfc> | sw_if_index <nn>") \
20993 _(l2_interface_pbb_tag_rewrite, \
20994 "<intfc> | sw_if_index <nn> \n" \
20995 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
20996 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
20997 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
20998 _(flow_classify_set_interface, \
20999 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21000 _(flow_classify_dump, "type [ip4|ip6]") \
21001 _(ip_table_dump, "") \
21002 _(ip_route_dump, "table-id [ip4|ip6]") \
21003 _(ip_mtable_dump, "") \
21004 _(ip_mroute_dump, "table-id [ip4|ip6]") \
21005 _(feature_enable_disable, "arc_name <arc_name> " \
21006 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21007 _(feature_gso_enable_disable, "<intfc> | sw_if_index <nn> " \
21008 "[enable | disable] ") \
21009 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21011 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
21012 "mac <mac-address> [del]") \
21013 _(l2_xconnect_dump, "") \
21014 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
21015 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21016 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21017 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21018 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21019 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21020 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21021 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21022 _(sock_init_shm, "size <nnn>") \
21023 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21024 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
21025 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
21026 _(session_rules_dump, "") \
21027 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
21028 _(output_acl_set_interface, \
21029 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21030 " [l2-table <nn>] [del]") \
21031 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
21033 /* List of command functions, CLI names map directly to functions */
21034 #define foreach_cli_function \
21035 _(comment, "usage: comment <ignore-rest-of-line>") \
21036 _(dump_interface_table, "usage: dump_interface_table") \
21037 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21038 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21039 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21040 _(dump_macro_table, "usage: dump_macro_table ") \
21041 _(dump_node_table, "usage: dump_node_table") \
21042 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21043 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
21044 _(elog_disable, "usage: elog_disable") \
21045 _(elog_enable, "usage: elog_enable") \
21046 _(elog_save, "usage: elog_save <filename>") \
21047 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21048 _(echo, "usage: echo <message>") \
21049 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21050 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21051 _(help, "usage: help") \
21052 _(q, "usage: quit") \
21053 _(quit, "usage: quit") \
21054 _(search_node_table, "usage: search_node_table <name>...") \
21055 _(set, "usage: set <variable-name> <value>") \
21056 _(script, "usage: script <file-name>") \
21057 _(statseg, "usage: statseg") \
21058 _(unset, "usage: unset <variable-name>")
21061 static void vl_api_##n##_t_handler_uni \
21062 (vl_api_##n##_t * mp) \
21064 vat_main_t * vam = &vat_main; \
21065 if (vam->json_output) { \
21066 vl_api_##n##_t_handler_json(mp); \
21068 vl_api_##n##_t_handler(mp); \
21071 foreach_vpe_api_reply_msg;
21072 #if VPP_API_TEST_BUILTIN == 0
21073 foreach_standalone_reply_msg;
21078 vat_api_hookup (vat_main_t * vam)
21081 vl_msg_api_set_handlers(VL_API_##N, #n, \
21082 vl_api_##n##_t_handler_uni, \
21084 vl_api_##n##_t_endian, \
21085 vl_api_##n##_t_print, \
21086 sizeof(vl_api_##n##_t), 1);
21087 foreach_vpe_api_reply_msg;
21088 #if VPP_API_TEST_BUILTIN == 0
21089 foreach_standalone_reply_msg;
21093 #if (VPP_API_TEST_BUILTIN==0)
21094 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21096 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21098 vam->function_by_name = hash_create_string (0, sizeof (uword));
21100 vam->help_by_name = hash_create_string (0, sizeof (uword));
21103 /* API messages we can send */
21104 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21105 foreach_vpe_api_msg;
21109 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21110 foreach_vpe_api_msg;
21113 /* CLI functions */
21114 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21115 foreach_cli_function;
21119 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21120 foreach_cli_function;
21124 #if VPP_API_TEST_BUILTIN
21125 static clib_error_t *
21126 vat_api_hookup_shim (vlib_main_t * vm)
21128 vat_api_hookup (&vat_main);
21132 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21136 * fd.io coding-style-patch-verification: ON
21139 * eval: (c-set-style "gnu")