2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2020 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/vxlan/vxlan.h>
31 #include <vnet/gre/gre.h>
32 #include <vnet/vxlan-gpe/vxlan_gpe.h>
33 #include <vnet/lisp-gpe/lisp_gpe.h>
35 #include <vpp/api/vpe_msg_enum.h>
36 #include <vnet/l2/l2_classify.h>
37 #include <vnet/l2/l2_vtr.h>
38 #include <vnet/classify/in_out_acl.h>
39 #include <vnet/classify/policer_classify.h>
40 #include <vnet/classify/flow_classify.h>
41 #include <vnet/mpls/mpls.h>
42 #include <vnet/ipsec/ipsec.h>
44 #include <vnet/ip/ip6_hop_by_hop.h>
45 #include <vnet/ip/ip_source_and_port_range_check.h>
46 #include <vnet/policer/xlate.h>
47 #include <vnet/span/span.h>
48 #include <vnet/policer/policer.h>
49 #include <vnet/policer/police.h>
50 #include <vnet/mfib/mfib_types.h>
51 #include <vnet/bonding/node.h>
52 #include <vnet/qos/qos_types.h>
53 #include <vnet/ethernet/ethernet_types_api.h>
54 #include <vnet/ip/ip_types_api.h>
55 #include "vat/json_format.h"
56 #include <vnet/ip/ip_types_api.h>
57 #include <vnet/ethernet/ethernet_types_api.h>
62 #define vl_typedefs /* define message structures */
63 #include <vpp/api/vpe_all_api_h.h>
66 /* declare message handlers for each api */
68 #define vl_endianfun /* define message structures */
69 #include <vpp/api/vpe_all_api_h.h>
72 /* instantiate all the print functions we know about */
73 #if VPP_API_TEST_BUILTIN == 0
74 #define vl_print(handle, ...)
76 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
79 #include <vpp/api/vpe_all_api_h.h>
82 #define __plugin_msg_base 0
83 #include <vlibapi/vat_helper_macros.h>
85 #include <vnet/format_fns.h>
87 void vl_api_set_elog_main (elog_main_t * m);
88 int vl_api_set_elog_trace_api_messages (int enable);
90 #if VPP_API_TEST_BUILTIN == 0
100 vat_socket_connect (vat_main_t * vam)
103 api_main_t *am = vlibapi_get_main ();
104 vam->socket_client_main = &socket_client_main;
105 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
107 0 /* default socket rx, tx buffer */ )))
110 /* vpp expects the client index in network order */
111 vam->my_client_index = htonl (socket_client_main.client_index);
112 am->my_client_index = vam->my_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 (a->af == ADDRESS_IP4)
767 increment_v4_address (&a->un.ip4);
768 else if (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, &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, &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_create_v2_reply_t_handler
1831 (vl_api_virtio_pci_create_v2_reply_t * mp)
1833 vat_main_t *vam = &vat_main;
1834 i32 retval = ntohl (mp->retval);
1835 if (vam->async_mode)
1837 vam->async_errors += (retval < 0);
1841 vam->retval = retval;
1842 vam->sw_if_index = ntohl (mp->sw_if_index);
1843 vam->result_ready = 1;
1847 static void vl_api_virtio_pci_create_v2_reply_t_handler_json
1848 (vl_api_virtio_pci_create_v2_reply_t * mp)
1850 vat_main_t *vam = &vat_main;
1851 vat_json_node_t node;
1853 vat_json_init_object (&node);
1854 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1855 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1857 vat_json_print (vam->ofp, &node);
1858 vat_json_free (&node);
1860 vam->retval = ntohl (mp->retval);
1861 vam->result_ready = 1;
1865 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1868 vat_main_t *vam = &vat_main;
1869 i32 retval = ntohl (mp->retval);
1870 if (vam->async_mode)
1872 vam->async_errors += (retval < 0);
1876 vam->retval = retval;
1877 vam->result_ready = 1;
1881 static void vl_api_virtio_pci_delete_reply_t_handler_json
1882 (vl_api_virtio_pci_delete_reply_t * mp)
1884 vat_main_t *vam = &vat_main;
1885 vat_json_node_t node;
1887 vat_json_init_object (&node);
1888 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
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_create_reply_t_handler (vl_api_bond_create_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->sw_if_index = ntohl (mp->sw_if_index);
1911 vam->result_ready = 1;
1915 static void vl_api_bond_create_reply_t_handler_json
1916 (vl_api_bond_create_reply_t * mp)
1918 vat_main_t *vam = &vat_main;
1919 vat_json_node_t node;
1921 vat_json_init_object (&node);
1922 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1923 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1925 vat_json_print (vam->ofp, &node);
1926 vat_json_free (&node);
1928 vam->retval = ntohl (mp->retval);
1929 vam->result_ready = 1;
1933 vl_api_bond_create2_reply_t_handler (vl_api_bond_create2_reply_t * mp)
1935 vat_main_t *vam = &vat_main;
1936 i32 retval = ntohl (mp->retval);
1938 if (vam->async_mode)
1940 vam->async_errors += (retval < 0);
1944 vam->retval = retval;
1945 vam->sw_if_index = ntohl (mp->sw_if_index);
1946 vam->result_ready = 1;
1950 static void vl_api_bond_create2_reply_t_handler_json
1951 (vl_api_bond_create2_reply_t * mp)
1953 vat_main_t *vam = &vat_main;
1954 vat_json_node_t node;
1956 vat_json_init_object (&node);
1957 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1958 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1960 vat_json_print (vam->ofp, &node);
1961 vat_json_free (&node);
1963 vam->retval = ntohl (mp->retval);
1964 vam->result_ready = 1;
1968 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1970 vat_main_t *vam = &vat_main;
1971 i32 retval = ntohl (mp->retval);
1973 if (vam->async_mode)
1975 vam->async_errors += (retval < 0);
1979 vam->retval = retval;
1980 vam->result_ready = 1;
1984 static void vl_api_bond_delete_reply_t_handler_json
1985 (vl_api_bond_delete_reply_t * mp)
1987 vat_main_t *vam = &vat_main;
1988 vat_json_node_t node;
1990 vat_json_init_object (&node);
1991 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1993 vat_json_print (vam->ofp, &node);
1994 vat_json_free (&node);
1996 vam->retval = ntohl (mp->retval);
1997 vam->result_ready = 1;
2001 vl_api_bond_add_member_reply_t_handler (vl_api_bond_add_member_reply_t * mp)
2003 vat_main_t *vam = &vat_main;
2004 i32 retval = ntohl (mp->retval);
2006 if (vam->async_mode)
2008 vam->async_errors += (retval < 0);
2012 vam->retval = retval;
2013 vam->result_ready = 1;
2017 static void vl_api_bond_add_member_reply_t_handler_json
2018 (vl_api_bond_add_member_reply_t * mp)
2020 vat_main_t *vam = &vat_main;
2021 vat_json_node_t node;
2023 vat_json_init_object (&node);
2024 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2026 vat_json_print (vam->ofp, &node);
2027 vat_json_free (&node);
2029 vam->retval = ntohl (mp->retval);
2030 vam->result_ready = 1;
2034 vl_api_bond_detach_member_reply_t_handler (vl_api_bond_detach_member_reply_t *
2037 vat_main_t *vam = &vat_main;
2038 i32 retval = ntohl (mp->retval);
2040 if (vam->async_mode)
2042 vam->async_errors += (retval < 0);
2046 vam->retval = retval;
2047 vam->result_ready = 1;
2051 static void vl_api_bond_detach_member_reply_t_handler_json
2052 (vl_api_bond_detach_member_reply_t * mp)
2054 vat_main_t *vam = &vat_main;
2055 vat_json_node_t node;
2057 vat_json_init_object (&node);
2058 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2060 vat_json_print (vam->ofp, &node);
2061 vat_json_free (&node);
2063 vam->retval = ntohl (mp->retval);
2064 vam->result_ready = 1;
2068 api_sw_interface_set_bond_weight (vat_main_t * vam)
2070 unformat_input_t *i = vam->input;
2071 vl_api_sw_interface_set_bond_weight_t *mp;
2072 u32 sw_if_index = ~0;
2074 u8 weight_enter = 0;
2077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2079 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2081 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2083 else if (unformat (i, "weight %u", &weight))
2089 if (sw_if_index == ~0)
2091 errmsg ("missing interface name or sw_if_index");
2094 if (weight_enter == 0)
2096 errmsg ("missing valid weight");
2100 /* Construct the API message */
2101 M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
2102 mp->sw_if_index = ntohl (sw_if_index);
2103 mp->weight = ntohl (weight);
2110 static void vl_api_sw_bond_interface_details_t_handler
2111 (vl_api_sw_bond_interface_details_t * mp)
2113 vat_main_t *vam = &vat_main;
2116 "%-16s %-12d %-12U %-13U %-14u %-14u",
2117 mp->interface_name, ntohl (mp->sw_if_index),
2118 format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
2119 ntohl (mp->lb), ntohl (mp->active_members), ntohl (mp->members));
2122 static void vl_api_sw_bond_interface_details_t_handler_json
2123 (vl_api_sw_bond_interface_details_t * mp)
2125 vat_main_t *vam = &vat_main;
2126 vat_json_node_t *node = NULL;
2128 if (VAT_JSON_ARRAY != vam->json_tree.type)
2130 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2131 vat_json_init_array (&vam->json_tree);
2133 node = vat_json_array_add (&vam->json_tree);
2135 vat_json_init_object (node);
2136 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2137 vat_json_object_add_string_copy (node, "interface_name",
2138 mp->interface_name);
2139 vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
2140 vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
2141 vat_json_object_add_uint (node, "active_members",
2142 ntohl (mp->active_members));
2143 vat_json_object_add_uint (node, "members", ntohl (mp->members));
2147 api_sw_bond_interface_dump (vat_main_t * vam)
2149 unformat_input_t *i = vam->input;
2150 vl_api_sw_bond_interface_dump_t *mp;
2151 vl_api_control_ping_t *mp_ping;
2153 u32 sw_if_index = ~0;
2155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2157 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2159 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2166 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2167 "interface name", "sw_if_index", "mode", "load balance",
2168 "active members", "members");
2170 /* Get list of bond interfaces */
2171 M (SW_BOND_INTERFACE_DUMP, mp);
2172 mp->sw_if_index = ntohl (sw_if_index);
2175 /* Use a control ping for synchronization */
2176 MPING (CONTROL_PING, mp_ping);
2183 static void vl_api_sw_member_interface_details_t_handler
2184 (vl_api_sw_member_interface_details_t * mp)
2186 vat_main_t *vam = &vat_main;
2189 "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
2190 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
2191 ntohl (mp->weight), mp->is_local_numa);
2194 static void vl_api_sw_member_interface_details_t_handler_json
2195 (vl_api_sw_member_interface_details_t * mp)
2197 vat_main_t *vam = &vat_main;
2198 vat_json_node_t *node = NULL;
2200 if (VAT_JSON_ARRAY != vam->json_tree.type)
2202 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2203 vat_json_init_array (&vam->json_tree);
2205 node = vat_json_array_add (&vam->json_tree);
2207 vat_json_init_object (node);
2208 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2209 vat_json_object_add_string_copy (node, "interface_name",
2210 mp->interface_name);
2211 vat_json_object_add_uint (node, "passive", mp->is_passive);
2212 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2213 vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
2214 vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
2218 api_sw_member_interface_dump (vat_main_t * vam)
2220 unformat_input_t *i = vam->input;
2221 vl_api_sw_member_interface_dump_t *mp;
2222 vl_api_control_ping_t *mp_ping;
2223 u32 sw_if_index = ~0;
2224 u8 sw_if_index_set = 0;
2227 /* Parse args required to build the message */
2228 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2230 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2231 sw_if_index_set = 1;
2232 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2233 sw_if_index_set = 1;
2238 if (sw_if_index_set == 0)
2240 errmsg ("missing vpp interface name. ");
2245 "\n%-25s %-12s %-7s %-12s %-10s %-10s",
2246 "member interface name", "sw_if_index", "passive", "long_timeout",
2247 "weight", "local numa");
2249 /* Get list of bond interfaces */
2250 M (SW_MEMBER_INTERFACE_DUMP, mp);
2251 mp->sw_if_index = ntohl (sw_if_index);
2254 /* Use a control ping for synchronization */
2255 MPING (CONTROL_PING, mp_ping);
2262 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2263 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2265 vat_main_t *vam = &vat_main;
2266 i32 retval = ntohl (mp->retval);
2267 if (vam->async_mode)
2269 vam->async_errors += (retval < 0);
2273 vam->retval = retval;
2274 vam->sw_if_index = ntohl (mp->sw_if_index);
2275 vam->result_ready = 1;
2277 vam->regenerate_interface_table = 1;
2280 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2281 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2283 vat_main_t *vam = &vat_main;
2284 vat_json_node_t node;
2286 vat_json_init_object (&node);
2287 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2288 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2289 ntohl (mp->sw_if_index));
2291 vat_json_print (vam->ofp, &node);
2292 vat_json_free (&node);
2294 vam->retval = ntohl (mp->retval);
2295 vam->result_ready = 1;
2298 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2299 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2301 vat_main_t *vam = &vat_main;
2302 i32 retval = ntohl (mp->retval);
2303 if (vam->async_mode)
2305 vam->async_errors += (retval < 0);
2309 vam->retval = retval;
2310 vam->result_ready = 1;
2314 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2315 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2317 vat_main_t *vam = &vat_main;
2318 vat_json_node_t node;
2320 vat_json_init_object (&node);
2321 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2322 vat_json_object_add_uint (&node, "fwd_entry_index",
2323 clib_net_to_host_u32 (mp->fwd_entry_index));
2325 vat_json_print (vam->ofp, &node);
2326 vat_json_free (&node);
2328 vam->retval = ntohl (mp->retval);
2329 vam->result_ready = 1;
2333 format_lisp_transport_protocol (u8 * s, va_list * args)
2335 u32 proto = va_arg (*args, u32);
2340 return format (s, "udp");
2342 return format (s, "api");
2349 static void vl_api_one_get_transport_protocol_reply_t_handler
2350 (vl_api_one_get_transport_protocol_reply_t * mp)
2352 vat_main_t *vam = &vat_main;
2353 i32 retval = ntohl (mp->retval);
2354 if (vam->async_mode)
2356 vam->async_errors += (retval < 0);
2360 u32 proto = mp->protocol;
2361 print (vam->ofp, "Transport protocol: %U",
2362 format_lisp_transport_protocol, proto);
2363 vam->retval = retval;
2364 vam->result_ready = 1;
2368 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2369 (vl_api_one_get_transport_protocol_reply_t * mp)
2371 vat_main_t *vam = &vat_main;
2372 vat_json_node_t node;
2375 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2378 vat_json_init_object (&node);
2379 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2380 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2383 vat_json_print (vam->ofp, &node);
2384 vat_json_free (&node);
2386 vam->retval = ntohl (mp->retval);
2387 vam->result_ready = 1;
2390 static void vl_api_one_add_del_locator_set_reply_t_handler
2391 (vl_api_one_add_del_locator_set_reply_t * mp)
2393 vat_main_t *vam = &vat_main;
2394 i32 retval = ntohl (mp->retval);
2395 if (vam->async_mode)
2397 vam->async_errors += (retval < 0);
2401 vam->retval = retval;
2402 vam->result_ready = 1;
2406 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2407 (vl_api_one_add_del_locator_set_reply_t * mp)
2409 vat_main_t *vam = &vat_main;
2410 vat_json_node_t node;
2412 vat_json_init_object (&node);
2413 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2414 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2416 vat_json_print (vam->ofp, &node);
2417 vat_json_free (&node);
2419 vam->retval = ntohl (mp->retval);
2420 vam->result_ready = 1;
2423 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2424 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2426 vat_main_t *vam = &vat_main;
2427 i32 retval = ntohl (mp->retval);
2428 if (vam->async_mode)
2430 vam->async_errors += (retval < 0);
2434 vam->retval = retval;
2435 vam->sw_if_index = ntohl (mp->sw_if_index);
2436 vam->result_ready = 1;
2438 vam->regenerate_interface_table = 1;
2441 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2442 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2444 vat_main_t *vam = &vat_main;
2445 vat_json_node_t node;
2447 vat_json_init_object (&node);
2448 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2449 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2451 vat_json_print (vam->ofp, &node);
2452 vat_json_free (&node);
2454 vam->retval = ntohl (mp->retval);
2455 vam->result_ready = 1;
2458 static void vl_api_vxlan_offload_rx_reply_t_handler
2459 (vl_api_vxlan_offload_rx_reply_t * mp)
2461 vat_main_t *vam = &vat_main;
2462 i32 retval = ntohl (mp->retval);
2463 if (vam->async_mode)
2465 vam->async_errors += (retval < 0);
2469 vam->retval = retval;
2470 vam->result_ready = 1;
2474 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2475 (vl_api_vxlan_offload_rx_reply_t * mp)
2477 vat_main_t *vam = &vat_main;
2478 vat_json_node_t node;
2480 vat_json_init_object (&node);
2481 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2483 vat_json_print (vam->ofp, &node);
2484 vat_json_free (&node);
2486 vam->retval = ntohl (mp->retval);
2487 vam->result_ready = 1;
2490 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2491 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2493 vat_main_t *vam = &vat_main;
2494 i32 retval = ntohl (mp->retval);
2495 if (vam->async_mode)
2497 vam->async_errors += (retval < 0);
2501 vam->retval = retval;
2502 vam->sw_if_index = ntohl (mp->sw_if_index);
2503 vam->result_ready = 1;
2505 vam->regenerate_interface_table = 1;
2508 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2509 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2511 vat_main_t *vam = &vat_main;
2512 vat_json_node_t node;
2514 vat_json_init_object (&node);
2515 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2516 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2518 vat_json_print (vam->ofp, &node);
2519 vat_json_free (&node);
2521 vam->retval = ntohl (mp->retval);
2522 vam->result_ready = 1;
2525 static void vl_api_gre_tunnel_add_del_reply_t_handler
2526 (vl_api_gre_tunnel_add_del_reply_t * mp)
2528 vat_main_t *vam = &vat_main;
2529 i32 retval = ntohl (mp->retval);
2530 if (vam->async_mode)
2532 vam->async_errors += (retval < 0);
2536 vam->retval = retval;
2537 vam->sw_if_index = ntohl (mp->sw_if_index);
2538 vam->result_ready = 1;
2542 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2543 (vl_api_gre_tunnel_add_del_reply_t * mp)
2545 vat_main_t *vam = &vat_main;
2546 vat_json_node_t node;
2548 vat_json_init_object (&node);
2549 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2550 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2552 vat_json_print (vam->ofp, &node);
2553 vat_json_free (&node);
2555 vam->retval = ntohl (mp->retval);
2556 vam->result_ready = 1;
2559 static void vl_api_create_vhost_user_if_reply_t_handler
2560 (vl_api_create_vhost_user_if_reply_t * mp)
2562 vat_main_t *vam = &vat_main;
2563 i32 retval = ntohl (mp->retval);
2564 if (vam->async_mode)
2566 vam->async_errors += (retval < 0);
2570 vam->retval = retval;
2571 vam->sw_if_index = ntohl (mp->sw_if_index);
2572 vam->result_ready = 1;
2574 vam->regenerate_interface_table = 1;
2577 static void vl_api_create_vhost_user_if_reply_t_handler_json
2578 (vl_api_create_vhost_user_if_reply_t * mp)
2580 vat_main_t *vam = &vat_main;
2581 vat_json_node_t node;
2583 vat_json_init_object (&node);
2584 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2585 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2587 vat_json_print (vam->ofp, &node);
2588 vat_json_free (&node);
2590 vam->retval = ntohl (mp->retval);
2591 vam->result_ready = 1;
2594 static void vl_api_ip_address_details_t_handler
2595 (vl_api_ip_address_details_t * mp)
2597 vat_main_t *vam = &vat_main;
2598 static ip_address_details_t empty_ip_address_details = { {0} };
2599 ip_address_details_t *address = NULL;
2600 ip_details_t *current_ip_details = NULL;
2601 ip_details_t *details = NULL;
2603 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2605 if (!details || vam->current_sw_if_index >= vec_len (details)
2606 || !details[vam->current_sw_if_index].present)
2608 errmsg ("ip address details arrived but not stored");
2609 errmsg ("ip_dump should be called first");
2613 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2615 #define addresses (current_ip_details->addr)
2617 vec_validate_init_empty (addresses, vec_len (addresses),
2618 empty_ip_address_details);
2620 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2622 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2623 address->prefix_length = mp->prefix.len;
2627 static void vl_api_ip_address_details_t_handler_json
2628 (vl_api_ip_address_details_t * mp)
2630 vat_main_t *vam = &vat_main;
2631 vat_json_node_t *node = NULL;
2633 if (VAT_JSON_ARRAY != vam->json_tree.type)
2635 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2636 vat_json_init_array (&vam->json_tree);
2638 node = vat_json_array_add (&vam->json_tree);
2640 vat_json_init_object (node);
2641 vat_json_object_add_prefix (node, &mp->prefix);
2645 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2647 vat_main_t *vam = &vat_main;
2648 static ip_details_t empty_ip_details = { 0 };
2649 ip_details_t *ip = NULL;
2650 u32 sw_if_index = ~0;
2652 sw_if_index = ntohl (mp->sw_if_index);
2654 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2655 sw_if_index, empty_ip_details);
2657 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2664 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2666 vat_main_t *vam = &vat_main;
2668 if (VAT_JSON_ARRAY != vam->json_tree.type)
2670 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2671 vat_json_init_array (&vam->json_tree);
2673 vat_json_array_add_uint (&vam->json_tree,
2674 clib_net_to_host_u32 (mp->sw_if_index));
2677 static void vl_api_get_first_msg_id_reply_t_handler
2678 (vl_api_get_first_msg_id_reply_t * mp)
2680 vat_main_t *vam = &vat_main;
2681 i32 retval = ntohl (mp->retval);
2683 if (vam->async_mode)
2685 vam->async_errors += (retval < 0);
2689 vam->retval = retval;
2690 vam->result_ready = 1;
2694 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2698 static void vl_api_get_first_msg_id_reply_t_handler_json
2699 (vl_api_get_first_msg_id_reply_t * mp)
2701 vat_main_t *vam = &vat_main;
2702 vat_json_node_t node;
2704 vat_json_init_object (&node);
2705 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2706 vat_json_object_add_uint (&node, "first_msg_id",
2707 (uint) ntohs (mp->first_msg_id));
2709 vat_json_print (vam->ofp, &node);
2710 vat_json_free (&node);
2712 vam->retval = ntohl (mp->retval);
2713 vam->result_ready = 1;
2716 static void vl_api_get_node_graph_reply_t_handler
2717 (vl_api_get_node_graph_reply_t * mp)
2719 vat_main_t *vam = &vat_main;
2720 i32 retval = ntohl (mp->retval);
2721 u8 *pvt_copy, *reply;
2726 if (vam->async_mode)
2728 vam->async_errors += (retval < 0);
2732 vam->retval = retval;
2733 vam->result_ready = 1;
2736 /* "Should never happen..." */
2740 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2741 pvt_copy = vec_dup (reply);
2743 /* Toss the shared-memory original... */
2744 oldheap = vl_msg_push_heap ();
2748 vl_msg_pop_heap (oldheap);
2750 if (vam->graph_nodes)
2752 hash_free (vam->graph_node_index_by_name);
2754 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2756 node = vam->graph_nodes[0][i];
2757 vec_free (node->name);
2758 vec_free (node->next_nodes);
2761 vec_free (vam->graph_nodes[0]);
2762 vec_free (vam->graph_nodes);
2765 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2766 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2767 vec_free (pvt_copy);
2769 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2771 node = vam->graph_nodes[0][i];
2772 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2776 static void vl_api_get_node_graph_reply_t_handler_json
2777 (vl_api_get_node_graph_reply_t * mp)
2779 vat_main_t *vam = &vat_main;
2781 vat_json_node_t node;
2784 /* $$$$ make this real? */
2785 vat_json_init_object (&node);
2786 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2787 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2789 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2791 /* Toss the shared-memory original... */
2792 oldheap = vl_msg_push_heap ();
2796 vl_msg_pop_heap (oldheap);
2798 vat_json_print (vam->ofp, &node);
2799 vat_json_free (&node);
2801 vam->retval = ntohl (mp->retval);
2802 vam->result_ready = 1;
2806 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2808 vat_main_t *vam = &vat_main;
2813 s = format (s, "%=16d%=16d%=16d",
2814 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2818 s = format (s, "%=16U%=16d%=16d",
2819 format_ip46_address,
2820 mp->ip_address, mp->priority, mp->weight);
2823 print (vam->ofp, "%v", s);
2828 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2830 vat_main_t *vam = &vat_main;
2831 vat_json_node_t *node = NULL;
2832 struct in6_addr ip6;
2835 if (VAT_JSON_ARRAY != vam->json_tree.type)
2837 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2838 vat_json_init_array (&vam->json_tree);
2840 node = vat_json_array_add (&vam->json_tree);
2841 vat_json_init_object (node);
2843 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2844 vat_json_object_add_uint (node, "priority", mp->priority);
2845 vat_json_object_add_uint (node, "weight", mp->weight);
2848 vat_json_object_add_uint (node, "sw_if_index",
2849 clib_net_to_host_u32 (mp->sw_if_index));
2852 if (mp->ip_address.af)
2854 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
2855 vat_json_object_add_ip6 (node, "address", ip6);
2859 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
2860 vat_json_object_add_ip4 (node, "address", ip4);
2866 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2869 vat_main_t *vam = &vat_main;
2872 ls_name = format (0, "%s", mp->ls_name);
2874 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2880 vl_api_one_locator_set_details_t_handler_json
2881 (vl_api_one_locator_set_details_t * mp)
2883 vat_main_t *vam = &vat_main;
2884 vat_json_node_t *node = 0;
2887 ls_name = format (0, "%s", mp->ls_name);
2888 vec_add1 (ls_name, 0);
2890 if (VAT_JSON_ARRAY != vam->json_tree.type)
2892 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2893 vat_json_init_array (&vam->json_tree);
2895 node = vat_json_array_add (&vam->json_tree);
2897 vat_json_init_object (node);
2898 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2899 vat_json_object_add_uint (node, "ls_index",
2900 clib_net_to_host_u32 (mp->ls_index));
2908 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2911 unformat_nsh_address (unformat_input_t * input, va_list * args)
2913 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2914 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2918 format_nsh_address_vat (u8 * s, va_list * args)
2920 nsh_t *a = va_arg (*args, nsh_t *);
2921 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2925 format_lisp_flat_eid (u8 * s, va_list * args)
2927 vl_api_eid_t *eid = va_arg (*args, vl_api_eid_t *);
2931 case EID_TYPE_API_PREFIX:
2932 if (eid->address.prefix.address.af)
2933 return format (s, "%U/%d", format_ip6_address,
2934 eid->address.prefix.address.un.ip6,
2935 eid->address.prefix.len);
2936 return format (s, "%U/%d", format_ip4_address,
2937 eid->address.prefix.address.un.ip4,
2938 eid->address.prefix.len);
2939 case EID_TYPE_API_MAC:
2940 return format (s, "%U", format_ethernet_address, eid->address.mac);
2941 case EID_TYPE_API_NSH:
2942 return format (s, "%U", format_nsh_address_vat, eid->address.nsh);
2948 format_lisp_eid_vat (u8 * s, va_list * args)
2950 vl_api_eid_t *deid = va_arg (*args, vl_api_eid_t *);
2951 vl_api_eid_t *seid = va_arg (*args, vl_api_eid_t *);
2952 u8 is_src_dst = (u8) va_arg (*args, int);
2955 s = format (s, "%U|", format_lisp_flat_eid, seid);
2957 s = format (s, "%U", format_lisp_flat_eid, deid);
2963 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2965 vat_main_t *vam = &vat_main;
2966 u8 *s = 0, *eid = 0;
2968 if (~0 == mp->locator_set_index)
2969 s = format (0, "action: %d", mp->action);
2971 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2973 eid = format (0, "%U", format_lisp_eid_vat,
2974 &mp->deid, &mp->seid, mp->is_src_dst);
2977 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2978 clib_net_to_host_u32 (mp->vni),
2980 mp->is_local ? "local" : "remote",
2981 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2982 clib_net_to_host_u16 (mp->key.id), mp->key.key);
2989 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2992 vat_main_t *vam = &vat_main;
2993 vat_json_node_t *node = 0;
2996 if (VAT_JSON_ARRAY != vam->json_tree.type)
2998 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2999 vat_json_init_array (&vam->json_tree);
3001 node = vat_json_array_add (&vam->json_tree);
3003 vat_json_init_object (node);
3004 if (~0 == mp->locator_set_index)
3005 vat_json_object_add_uint (node, "action", mp->action);
3007 vat_json_object_add_uint (node, "locator_set_index",
3008 clib_net_to_host_u32 (mp->locator_set_index));
3010 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3011 if (mp->deid.type == 3)
3013 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3014 vat_json_init_object (nsh_json);
3015 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) & mp->deid.address.nsh;
3016 vat_json_object_add_uint (nsh_json, "spi",
3017 clib_net_to_host_u32 (nsh->spi));
3018 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3022 eid = format (0, "%U", format_lisp_eid_vat,
3023 &mp->deid, &mp->seid, mp->is_src_dst);
3025 vat_json_object_add_string_copy (node, "eid", eid);
3028 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3029 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3030 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3034 vat_json_object_add_uint (node, "key_id",
3035 clib_net_to_host_u16 (mp->key.id));
3036 vat_json_object_add_string_copy (node, "key", mp->key.key);
3041 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3043 vat_main_t *vam = &vat_main;
3044 u8 *seid = 0, *deid = 0;
3045 ip46_address_t lloc, rloc;
3047 deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0);
3049 seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0);
3056 clib_memcpy (&lloc.ip6, mp->lloc.un.ip6, 16);
3057 clib_memcpy (&rloc.ip6, mp->rloc.un.ip6, 16);
3061 clib_memcpy (&lloc.ip4, mp->lloc.un.ip4, 4);
3062 clib_memcpy (&rloc.ip4, mp->rloc.un.ip4, 4);
3066 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3067 clib_net_to_host_u32 (mp->vni),
3069 format_ip46_address, lloc,
3070 format_ip46_address, rloc,
3071 clib_net_to_host_u32 (mp->pkt_count),
3072 clib_net_to_host_u32 (mp->bytes));
3079 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3081 struct in6_addr ip6;
3083 vat_main_t *vam = &vat_main;
3084 vat_json_node_t *node = 0;
3085 u8 *deid = 0, *seid = 0;
3087 if (VAT_JSON_ARRAY != vam->json_tree.type)
3089 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3090 vat_json_init_array (&vam->json_tree);
3092 node = vat_json_array_add (&vam->json_tree);
3094 vat_json_init_object (node);
3095 deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0);
3097 seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0);
3102 vat_json_object_add_string_copy (node, "seid", seid);
3103 vat_json_object_add_string_copy (node, "deid", deid);
3104 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3108 clib_memcpy (&ip6, mp->lloc.un.ip6, sizeof (ip6));
3109 vat_json_object_add_ip6 (node, "lloc", ip6);
3110 clib_memcpy (&ip6, mp->rloc.un.ip6, sizeof (ip6));
3111 vat_json_object_add_ip6 (node, "rloc", ip6);
3116 clib_memcpy (&ip4, mp->lloc.un.ip4, sizeof (ip4));
3117 vat_json_object_add_ip4 (node, "lloc", ip4);
3118 clib_memcpy (&ip4, mp->rloc.un.ip4, sizeof (ip4));
3119 vat_json_object_add_ip4 (node, "rloc", ip4);
3121 vat_json_object_add_uint (node, "pkt_count",
3122 clib_net_to_host_u32 (mp->pkt_count));
3123 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3130 vl_api_one_eid_table_map_details_t_handler
3131 (vl_api_one_eid_table_map_details_t * mp)
3133 vat_main_t *vam = &vat_main;
3135 u8 *line = format (0, "%=10d%=10d",
3136 clib_net_to_host_u32 (mp->vni),
3137 clib_net_to_host_u32 (mp->dp_table));
3138 print (vam->ofp, "%v", line);
3143 vl_api_one_eid_table_map_details_t_handler_json
3144 (vl_api_one_eid_table_map_details_t * mp)
3146 vat_main_t *vam = &vat_main;
3147 vat_json_node_t *node = NULL;
3149 if (VAT_JSON_ARRAY != vam->json_tree.type)
3151 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3152 vat_json_init_array (&vam->json_tree);
3154 node = vat_json_array_add (&vam->json_tree);
3155 vat_json_init_object (node);
3156 vat_json_object_add_uint (node, "dp_table",
3157 clib_net_to_host_u32 (mp->dp_table));
3158 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3162 vl_api_one_eid_table_vni_details_t_handler
3163 (vl_api_one_eid_table_vni_details_t * mp)
3165 vat_main_t *vam = &vat_main;
3167 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3168 print (vam->ofp, "%v", line);
3173 vl_api_one_eid_table_vni_details_t_handler_json
3174 (vl_api_one_eid_table_vni_details_t * mp)
3176 vat_main_t *vam = &vat_main;
3177 vat_json_node_t *node = NULL;
3179 if (VAT_JSON_ARRAY != vam->json_tree.type)
3181 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3182 vat_json_init_array (&vam->json_tree);
3184 node = vat_json_array_add (&vam->json_tree);
3185 vat_json_init_object (node);
3186 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3190 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3191 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3193 vat_main_t *vam = &vat_main;
3194 int retval = clib_net_to_host_u32 (mp->retval);
3196 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3197 print (vam->ofp, "fallback threshold value: %d", mp->value);
3199 vam->retval = retval;
3200 vam->result_ready = 1;
3204 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3205 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3207 vat_main_t *vam = &vat_main;
3208 vat_json_node_t _node, *node = &_node;
3209 int retval = clib_net_to_host_u32 (mp->retval);
3211 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3212 vat_json_init_object (node);
3213 vat_json_object_add_uint (node, "value", mp->value);
3215 vat_json_print (vam->ofp, node);
3216 vat_json_free (node);
3218 vam->retval = retval;
3219 vam->result_ready = 1;
3223 vl_api_show_one_map_register_state_reply_t_handler
3224 (vl_api_show_one_map_register_state_reply_t * mp)
3226 vat_main_t *vam = &vat_main;
3227 int retval = clib_net_to_host_u32 (mp->retval);
3229 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3231 vam->retval = retval;
3232 vam->result_ready = 1;
3236 vl_api_show_one_map_register_state_reply_t_handler_json
3237 (vl_api_show_one_map_register_state_reply_t * mp)
3239 vat_main_t *vam = &vat_main;
3240 vat_json_node_t _node, *node = &_node;
3241 int retval = clib_net_to_host_u32 (mp->retval);
3243 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3245 vat_json_init_object (node);
3246 vat_json_object_add_string_copy (node, "state", s);
3248 vat_json_print (vam->ofp, node);
3249 vat_json_free (node);
3251 vam->retval = retval;
3252 vam->result_ready = 1;
3257 vl_api_show_one_rloc_probe_state_reply_t_handler
3258 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3260 vat_main_t *vam = &vat_main;
3261 int retval = clib_net_to_host_u32 (mp->retval);
3266 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3268 vam->retval = retval;
3269 vam->result_ready = 1;
3273 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3274 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3276 vat_main_t *vam = &vat_main;
3277 vat_json_node_t _node, *node = &_node;
3278 int retval = clib_net_to_host_u32 (mp->retval);
3280 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3281 vat_json_init_object (node);
3282 vat_json_object_add_string_copy (node, "state", s);
3284 vat_json_print (vam->ofp, node);
3285 vat_json_free (node);
3287 vam->retval = retval;
3288 vam->result_ready = 1;
3293 vl_api_show_one_stats_enable_disable_reply_t_handler
3294 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3296 vat_main_t *vam = &vat_main;
3297 int retval = clib_net_to_host_u32 (mp->retval);
3302 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3304 vam->retval = retval;
3305 vam->result_ready = 1;
3309 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3310 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3312 vat_main_t *vam = &vat_main;
3313 vat_json_node_t _node, *node = &_node;
3314 int retval = clib_net_to_host_u32 (mp->retval);
3316 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3317 vat_json_init_object (node);
3318 vat_json_object_add_string_copy (node, "state", s);
3320 vat_json_print (vam->ofp, node);
3321 vat_json_free (node);
3323 vam->retval = retval;
3324 vam->result_ready = 1;
3329 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3331 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3332 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3333 e->vni = clib_net_to_host_u32 (e->vni);
3337 gpe_fwd_entries_get_reply_t_net_to_host
3338 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3342 mp->count = clib_net_to_host_u32 (mp->count);
3343 for (i = 0; i < mp->count; i++)
3345 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3350 format_gpe_encap_mode (u8 * s, va_list * args)
3352 u32 mode = va_arg (*args, u32);
3357 return format (s, "lisp");
3359 return format (s, "vxlan");
3365 vl_api_gpe_get_encap_mode_reply_t_handler
3366 (vl_api_gpe_get_encap_mode_reply_t * mp)
3368 vat_main_t *vam = &vat_main;
3370 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3371 vam->retval = ntohl (mp->retval);
3372 vam->result_ready = 1;
3376 vl_api_gpe_get_encap_mode_reply_t_handler_json
3377 (vl_api_gpe_get_encap_mode_reply_t * mp)
3379 vat_main_t *vam = &vat_main;
3380 vat_json_node_t node;
3382 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3383 vec_add1 (encap_mode, 0);
3385 vat_json_init_object (&node);
3386 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3388 vec_free (encap_mode);
3389 vat_json_print (vam->ofp, &node);
3390 vat_json_free (&node);
3392 vam->retval = ntohl (mp->retval);
3393 vam->result_ready = 1;
3397 vl_api_gpe_fwd_entry_path_details_t_handler
3398 (vl_api_gpe_fwd_entry_path_details_t * mp)
3400 vat_main_t *vam = &vat_main;
3401 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3403 if (mp->lcl_loc.addr.af)
3404 format_ip_address_fcn = format_ip6_address;
3406 format_ip_address_fcn = format_ip4_address;
3408 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3409 format_ip_address_fcn, &mp->lcl_loc.addr.un,
3410 format_ip_address_fcn, &mp->rmt_loc.addr.un);
3414 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3416 struct in6_addr ip6;
3421 clib_memcpy (&ip6, loc->addr.un.ip6, sizeof (ip6));
3422 vat_json_object_add_ip6 (n, "address", ip6);
3426 clib_memcpy (&ip4, loc->addr.un.ip4, sizeof (ip4));
3427 vat_json_object_add_ip4 (n, "address", ip4);
3429 vat_json_object_add_uint (n, "weight", loc->weight);
3433 vl_api_gpe_fwd_entry_path_details_t_handler_json
3434 (vl_api_gpe_fwd_entry_path_details_t * mp)
3436 vat_main_t *vam = &vat_main;
3437 vat_json_node_t *node = NULL;
3438 vat_json_node_t *loc_node;
3440 if (VAT_JSON_ARRAY != vam->json_tree.type)
3442 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3443 vat_json_init_array (&vam->json_tree);
3445 node = vat_json_array_add (&vam->json_tree);
3446 vat_json_init_object (node);
3448 loc_node = vat_json_object_add (node, "local_locator");
3449 vat_json_init_object (loc_node);
3450 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3452 loc_node = vat_json_object_add (node, "remote_locator");
3453 vat_json_init_object (loc_node);
3454 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3458 vl_api_gpe_fwd_entries_get_reply_t_handler
3459 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3461 vat_main_t *vam = &vat_main;
3463 int retval = clib_net_to_host_u32 (mp->retval);
3464 vl_api_gpe_fwd_entry_t *e;
3469 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3471 for (i = 0; i < mp->count; i++)
3473 e = &mp->entries[i];
3474 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3475 format_lisp_flat_eid, e->leid, format_lisp_flat_eid, e->reid);
3479 vam->retval = retval;
3480 vam->result_ready = 1;
3484 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3485 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3488 vat_main_t *vam = &vat_main;
3489 vat_json_node_t *e = 0, root;
3491 int retval = clib_net_to_host_u32 (mp->retval);
3492 vl_api_gpe_fwd_entry_t *fwd;
3497 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3498 vat_json_init_array (&root);
3500 for (i = 0; i < mp->count; i++)
3502 e = vat_json_array_add (&root);
3503 fwd = &mp->entries[i];
3505 vat_json_init_object (e);
3506 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3507 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3508 vat_json_object_add_int (e, "vni", fwd->vni);
3509 vat_json_object_add_int (e, "action", fwd->action);
3511 s = format (0, "%U", format_lisp_flat_eid, fwd->leid);
3513 vat_json_object_add_string_copy (e, "leid", s);
3516 s = format (0, "%U", format_lisp_flat_eid, fwd->reid);
3518 vat_json_object_add_string_copy (e, "reid", s);
3522 vat_json_print (vam->ofp, &root);
3523 vat_json_free (&root);
3526 vam->retval = retval;
3527 vam->result_ready = 1;
3531 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3532 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3534 vat_main_t *vam = &vat_main;
3536 int retval = clib_net_to_host_u32 (mp->retval);
3537 vl_api_gpe_native_fwd_rpath_t *r;
3542 n = clib_net_to_host_u32 (mp->count);
3544 for (i = 0; i < n; i++)
3546 r = &mp->entries[i];
3547 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3548 clib_net_to_host_u32 (r->fib_index),
3549 clib_net_to_host_u32 (r->nh_sw_if_index),
3550 r->nh_addr.af ? format_ip6_address : format_ip4_address,
3555 vam->retval = retval;
3556 vam->result_ready = 1;
3560 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3561 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3563 vat_main_t *vam = &vat_main;
3564 vat_json_node_t root, *e;
3566 int retval = clib_net_to_host_u32 (mp->retval);
3567 vl_api_gpe_native_fwd_rpath_t *r;
3573 n = clib_net_to_host_u32 (mp->count);
3574 vat_json_init_array (&root);
3576 for (i = 0; i < n; i++)
3578 e = vat_json_array_add (&root);
3579 vat_json_init_object (e);
3580 r = &mp->entries[i];
3583 r->nh_addr.af ? format_ip6_address : format_ip4_address,
3586 vat_json_object_add_string_copy (e, "ip4", s);
3589 vat_json_object_add_uint (e, "fib_index",
3590 clib_net_to_host_u32 (r->fib_index));
3591 vat_json_object_add_uint (e, "nh_sw_if_index",
3592 clib_net_to_host_u32 (r->nh_sw_if_index));
3595 vat_json_print (vam->ofp, &root);
3596 vat_json_free (&root);
3599 vam->retval = retval;
3600 vam->result_ready = 1;
3604 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3605 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3607 vat_main_t *vam = &vat_main;
3609 int retval = clib_net_to_host_u32 (mp->retval);
3614 n = clib_net_to_host_u32 (mp->count);
3616 for (i = 0; i < n; i++)
3617 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3620 vam->retval = retval;
3621 vam->result_ready = 1;
3625 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3626 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3628 vat_main_t *vam = &vat_main;
3629 vat_json_node_t root;
3631 int retval = clib_net_to_host_u32 (mp->retval);
3636 n = clib_net_to_host_u32 (mp->count);
3637 vat_json_init_array (&root);
3639 for (i = 0; i < n; i++)
3640 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3642 vat_json_print (vam->ofp, &root);
3643 vat_json_free (&root);
3646 vam->retval = retval;
3647 vam->result_ready = 1;
3651 vl_api_one_ndp_entries_get_reply_t_handler
3652 (vl_api_one_ndp_entries_get_reply_t * mp)
3654 vat_main_t *vam = &vat_main;
3656 int retval = clib_net_to_host_u32 (mp->retval);
3661 n = clib_net_to_host_u32 (mp->count);
3663 for (i = 0; i < n; i++)
3664 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3665 format_ethernet_address, mp->entries[i].mac);
3668 vam->retval = retval;
3669 vam->result_ready = 1;
3673 vl_api_one_ndp_entries_get_reply_t_handler_json
3674 (vl_api_one_ndp_entries_get_reply_t * mp)
3677 vat_main_t *vam = &vat_main;
3678 vat_json_node_t *e = 0, root;
3680 int retval = clib_net_to_host_u32 (mp->retval);
3681 vl_api_one_ndp_entry_t *arp_entry;
3686 n = clib_net_to_host_u32 (mp->count);
3687 vat_json_init_array (&root);
3689 for (i = 0; i < n; i++)
3691 e = vat_json_array_add (&root);
3692 arp_entry = &mp->entries[i];
3694 vat_json_init_object (e);
3695 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3698 vat_json_object_add_string_copy (e, "mac", s);
3701 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3703 vat_json_object_add_string_copy (e, "ip6", s);
3707 vat_json_print (vam->ofp, &root);
3708 vat_json_free (&root);
3711 vam->retval = retval;
3712 vam->result_ready = 1;
3716 vl_api_one_l2_arp_entries_get_reply_t_handler
3717 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3719 vat_main_t *vam = &vat_main;
3721 int retval = clib_net_to_host_u32 (mp->retval);
3726 n = clib_net_to_host_u32 (mp->count);
3728 for (i = 0; i < n; i++)
3729 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3730 format_ethernet_address, mp->entries[i].mac);
3733 vam->retval = retval;
3734 vam->result_ready = 1;
3738 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3739 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3742 vat_main_t *vam = &vat_main;
3743 vat_json_node_t *e = 0, root;
3745 int retval = clib_net_to_host_u32 (mp->retval);
3746 vl_api_one_l2_arp_entry_t *arp_entry;
3751 n = clib_net_to_host_u32 (mp->count);
3752 vat_json_init_array (&root);
3754 for (i = 0; i < n; i++)
3756 e = vat_json_array_add (&root);
3757 arp_entry = &mp->entries[i];
3759 vat_json_init_object (e);
3760 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3763 vat_json_object_add_string_copy (e, "mac", s);
3766 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3768 vat_json_object_add_string_copy (e, "ip4", s);
3772 vat_json_print (vam->ofp, &root);
3773 vat_json_free (&root);
3776 vam->retval = retval;
3777 vam->result_ready = 1;
3781 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3783 vat_main_t *vam = &vat_main;
3785 int retval = clib_net_to_host_u32 (mp->retval);
3790 n = clib_net_to_host_u32 (mp->count);
3792 for (i = 0; i < n; i++)
3794 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3798 vam->retval = retval;
3799 vam->result_ready = 1;
3803 vl_api_one_ndp_bd_get_reply_t_handler_json
3804 (vl_api_one_ndp_bd_get_reply_t * mp)
3806 vat_main_t *vam = &vat_main;
3807 vat_json_node_t root;
3809 int retval = clib_net_to_host_u32 (mp->retval);
3814 n = clib_net_to_host_u32 (mp->count);
3815 vat_json_init_array (&root);
3817 for (i = 0; i < n; i++)
3819 vat_json_array_add_uint (&root,
3820 clib_net_to_host_u32 (mp->bridge_domains[i]));
3823 vat_json_print (vam->ofp, &root);
3824 vat_json_free (&root);
3827 vam->retval = retval;
3828 vam->result_ready = 1;
3832 vl_api_one_l2_arp_bd_get_reply_t_handler
3833 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3835 vat_main_t *vam = &vat_main;
3837 int retval = clib_net_to_host_u32 (mp->retval);
3842 n = clib_net_to_host_u32 (mp->count);
3844 for (i = 0; i < n; i++)
3846 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3850 vam->retval = retval;
3851 vam->result_ready = 1;
3855 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3856 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3858 vat_main_t *vam = &vat_main;
3859 vat_json_node_t root;
3861 int retval = clib_net_to_host_u32 (mp->retval);
3866 n = clib_net_to_host_u32 (mp->count);
3867 vat_json_init_array (&root);
3869 for (i = 0; i < n; i++)
3871 vat_json_array_add_uint (&root,
3872 clib_net_to_host_u32 (mp->bridge_domains[i]));
3875 vat_json_print (vam->ofp, &root);
3876 vat_json_free (&root);
3879 vam->retval = retval;
3880 vam->result_ready = 1;
3884 vl_api_one_adjacencies_get_reply_t_handler
3885 (vl_api_one_adjacencies_get_reply_t * mp)
3887 vat_main_t *vam = &vat_main;
3889 int retval = clib_net_to_host_u32 (mp->retval);
3890 vl_api_one_adjacency_t *a;
3895 n = clib_net_to_host_u32 (mp->count);
3897 for (i = 0; i < n; i++)
3899 a = &mp->adjacencies[i];
3900 print (vam->ofp, "%U %40U",
3901 format_lisp_flat_eid, a->leid, format_lisp_flat_eid, a->reid);
3905 vam->retval = retval;
3906 vam->result_ready = 1;
3910 vl_api_one_adjacencies_get_reply_t_handler_json
3911 (vl_api_one_adjacencies_get_reply_t * mp)
3914 vat_main_t *vam = &vat_main;
3915 vat_json_node_t *e = 0, root;
3917 int retval = clib_net_to_host_u32 (mp->retval);
3918 vl_api_one_adjacency_t *a;
3923 n = clib_net_to_host_u32 (mp->count);
3924 vat_json_init_array (&root);
3926 for (i = 0; i < n; i++)
3928 e = vat_json_array_add (&root);
3929 a = &mp->adjacencies[i];
3931 vat_json_init_object (e);
3932 s = format (0, "%U", format_lisp_flat_eid, a->leid);
3934 vat_json_object_add_string_copy (e, "leid", s);
3937 s = format (0, "%U", format_lisp_flat_eid, a->reid);
3939 vat_json_object_add_string_copy (e, "reid", s);
3943 vat_json_print (vam->ofp, &root);
3944 vat_json_free (&root);
3947 vam->retval = retval;
3948 vam->result_ready = 1;
3952 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3954 vat_main_t *vam = &vat_main;
3956 print (vam->ofp, "%=20U",
3957 mp->ip_address.af ? format_ip6_address : format_ip4_address,
3962 vl_api_one_map_server_details_t_handler_json
3963 (vl_api_one_map_server_details_t * mp)
3965 vat_main_t *vam = &vat_main;
3966 vat_json_node_t *node = NULL;
3967 struct in6_addr ip6;
3970 if (VAT_JSON_ARRAY != vam->json_tree.type)
3972 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3973 vat_json_init_array (&vam->json_tree);
3975 node = vat_json_array_add (&vam->json_tree);
3977 vat_json_init_object (node);
3978 if (mp->ip_address.af)
3980 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
3981 vat_json_object_add_ip6 (node, "map-server", ip6);
3985 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
3986 vat_json_object_add_ip4 (node, "map-server", ip4);
3991 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3994 vat_main_t *vam = &vat_main;
3996 print (vam->ofp, "%=20U",
3997 mp->ip_address.af ? format_ip6_address : format_ip4_address,
4002 vl_api_one_map_resolver_details_t_handler_json
4003 (vl_api_one_map_resolver_details_t * mp)
4005 vat_main_t *vam = &vat_main;
4006 vat_json_node_t *node = NULL;
4007 struct in6_addr ip6;
4010 if (VAT_JSON_ARRAY != vam->json_tree.type)
4012 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4013 vat_json_init_array (&vam->json_tree);
4015 node = vat_json_array_add (&vam->json_tree);
4017 vat_json_init_object (node);
4018 if (mp->ip_address.af)
4020 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
4021 vat_json_object_add_ip6 (node, "map resolver", ip6);
4025 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
4026 vat_json_object_add_ip4 (node, "map resolver", ip4);
4031 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4033 vat_main_t *vam = &vat_main;
4034 i32 retval = ntohl (mp->retval);
4038 print (vam->ofp, "feature: %s\ngpe: %s",
4039 mp->feature_status ? "enabled" : "disabled",
4040 mp->gpe_status ? "enabled" : "disabled");
4043 vam->retval = retval;
4044 vam->result_ready = 1;
4048 vl_api_show_one_status_reply_t_handler_json
4049 (vl_api_show_one_status_reply_t * mp)
4051 vat_main_t *vam = &vat_main;
4052 vat_json_node_t node;
4053 u8 *gpe_status = NULL;
4054 u8 *feature_status = NULL;
4056 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4057 feature_status = format (0, "%s",
4058 mp->feature_status ? "enabled" : "disabled");
4059 vec_add1 (gpe_status, 0);
4060 vec_add1 (feature_status, 0);
4062 vat_json_init_object (&node);
4063 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4064 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4066 vec_free (gpe_status);
4067 vec_free (feature_status);
4069 vat_json_print (vam->ofp, &node);
4070 vat_json_free (&node);
4072 vam->retval = ntohl (mp->retval);
4073 vam->result_ready = 1;
4077 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4078 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4080 vat_main_t *vam = &vat_main;
4081 i32 retval = ntohl (mp->retval);
4085 print (vam->ofp, "%=20s", mp->locator_set_name);
4088 vam->retval = retval;
4089 vam->result_ready = 1;
4093 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4094 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4096 vat_main_t *vam = &vat_main;
4097 vat_json_node_t *node = NULL;
4099 if (VAT_JSON_ARRAY != vam->json_tree.type)
4101 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4102 vat_json_init_array (&vam->json_tree);
4104 node = vat_json_array_add (&vam->json_tree);
4106 vat_json_init_object (node);
4107 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4109 vat_json_print (vam->ofp, node);
4110 vat_json_free (node);
4112 vam->retval = ntohl (mp->retval);
4113 vam->result_ready = 1;
4117 format_lisp_map_request_mode (u8 * s, va_list * args)
4119 u32 mode = va_arg (*args, u32);
4124 return format (0, "dst-only");
4126 return format (0, "src-dst");
4132 vl_api_show_one_map_request_mode_reply_t_handler
4133 (vl_api_show_one_map_request_mode_reply_t * mp)
4135 vat_main_t *vam = &vat_main;
4136 i32 retval = ntohl (mp->retval);
4140 u32 mode = mp->mode;
4141 print (vam->ofp, "map_request_mode: %U",
4142 format_lisp_map_request_mode, mode);
4145 vam->retval = retval;
4146 vam->result_ready = 1;
4150 vl_api_show_one_map_request_mode_reply_t_handler_json
4151 (vl_api_show_one_map_request_mode_reply_t * mp)
4153 vat_main_t *vam = &vat_main;
4154 vat_json_node_t node;
4159 s = format (0, "%U", format_lisp_map_request_mode, mode);
4162 vat_json_init_object (&node);
4163 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4164 vat_json_print (vam->ofp, &node);
4165 vat_json_free (&node);
4168 vam->retval = ntohl (mp->retval);
4169 vam->result_ready = 1;
4173 vl_api_one_show_xtr_mode_reply_t_handler
4174 (vl_api_one_show_xtr_mode_reply_t * mp)
4176 vat_main_t *vam = &vat_main;
4177 i32 retval = ntohl (mp->retval);
4181 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4184 vam->retval = retval;
4185 vam->result_ready = 1;
4189 vl_api_one_show_xtr_mode_reply_t_handler_json
4190 (vl_api_one_show_xtr_mode_reply_t * mp)
4192 vat_main_t *vam = &vat_main;
4193 vat_json_node_t node;
4196 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4197 vec_add1 (status, 0);
4199 vat_json_init_object (&node);
4200 vat_json_object_add_string_copy (&node, "status", status);
4204 vat_json_print (vam->ofp, &node);
4205 vat_json_free (&node);
4207 vam->retval = ntohl (mp->retval);
4208 vam->result_ready = 1;
4212 vl_api_one_show_pitr_mode_reply_t_handler
4213 (vl_api_one_show_pitr_mode_reply_t * mp)
4215 vat_main_t *vam = &vat_main;
4216 i32 retval = ntohl (mp->retval);
4220 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4223 vam->retval = retval;
4224 vam->result_ready = 1;
4228 vl_api_one_show_pitr_mode_reply_t_handler_json
4229 (vl_api_one_show_pitr_mode_reply_t * mp)
4231 vat_main_t *vam = &vat_main;
4232 vat_json_node_t node;
4235 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4236 vec_add1 (status, 0);
4238 vat_json_init_object (&node);
4239 vat_json_object_add_string_copy (&node, "status", status);
4243 vat_json_print (vam->ofp, &node);
4244 vat_json_free (&node);
4246 vam->retval = ntohl (mp->retval);
4247 vam->result_ready = 1;
4251 vl_api_one_show_petr_mode_reply_t_handler
4252 (vl_api_one_show_petr_mode_reply_t * mp)
4254 vat_main_t *vam = &vat_main;
4255 i32 retval = ntohl (mp->retval);
4259 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4262 vam->retval = retval;
4263 vam->result_ready = 1;
4267 vl_api_one_show_petr_mode_reply_t_handler_json
4268 (vl_api_one_show_petr_mode_reply_t * mp)
4270 vat_main_t *vam = &vat_main;
4271 vat_json_node_t node;
4274 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4275 vec_add1 (status, 0);
4277 vat_json_init_object (&node);
4278 vat_json_object_add_string_copy (&node, "status", status);
4282 vat_json_print (vam->ofp, &node);
4283 vat_json_free (&node);
4285 vam->retval = ntohl (mp->retval);
4286 vam->result_ready = 1;
4290 vl_api_show_one_use_petr_reply_t_handler
4291 (vl_api_show_one_use_petr_reply_t * mp)
4293 vat_main_t *vam = &vat_main;
4294 i32 retval = ntohl (mp->retval);
4298 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4301 print (vam->ofp, "Proxy-ETR address; %U",
4302 mp->ip_address.af ? format_ip6_address : format_ip4_address,
4307 vam->retval = retval;
4308 vam->result_ready = 1;
4312 vl_api_show_one_use_petr_reply_t_handler_json
4313 (vl_api_show_one_use_petr_reply_t * mp)
4315 vat_main_t *vam = &vat_main;
4316 vat_json_node_t node;
4319 struct in6_addr ip6;
4321 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4322 vec_add1 (status, 0);
4324 vat_json_init_object (&node);
4325 vat_json_object_add_string_copy (&node, "status", status);
4328 if (mp->ip_address.af)
4330 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
4331 vat_json_object_add_ip6 (&node, "address", ip6);
4335 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
4336 vat_json_object_add_ip4 (&node, "address", ip4);
4342 vat_json_print (vam->ofp, &node);
4343 vat_json_free (&node);
4345 vam->retval = ntohl (mp->retval);
4346 vam->result_ready = 1;
4350 vl_api_show_one_nsh_mapping_reply_t_handler
4351 (vl_api_show_one_nsh_mapping_reply_t * mp)
4353 vat_main_t *vam = &vat_main;
4354 i32 retval = ntohl (mp->retval);
4358 print (vam->ofp, "%-20s%-16s",
4359 mp->is_set ? "set" : "not-set",
4360 mp->is_set ? (char *) mp->locator_set_name : "");
4363 vam->retval = retval;
4364 vam->result_ready = 1;
4368 vl_api_show_one_nsh_mapping_reply_t_handler_json
4369 (vl_api_show_one_nsh_mapping_reply_t * mp)
4371 vat_main_t *vam = &vat_main;
4372 vat_json_node_t node;
4375 status = format (0, "%s", mp->is_set ? "yes" : "no");
4376 vec_add1 (status, 0);
4378 vat_json_init_object (&node);
4379 vat_json_object_add_string_copy (&node, "is_set", status);
4382 vat_json_object_add_string_copy (&node, "locator_set",
4383 mp->locator_set_name);
4388 vat_json_print (vam->ofp, &node);
4389 vat_json_free (&node);
4391 vam->retval = ntohl (mp->retval);
4392 vam->result_ready = 1;
4396 vl_api_show_one_map_register_ttl_reply_t_handler
4397 (vl_api_show_one_map_register_ttl_reply_t * mp)
4399 vat_main_t *vam = &vat_main;
4400 i32 retval = ntohl (mp->retval);
4402 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4406 print (vam->ofp, "ttl: %u", mp->ttl);
4409 vam->retval = retval;
4410 vam->result_ready = 1;
4414 vl_api_show_one_map_register_ttl_reply_t_handler_json
4415 (vl_api_show_one_map_register_ttl_reply_t * mp)
4417 vat_main_t *vam = &vat_main;
4418 vat_json_node_t node;
4420 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4421 vat_json_init_object (&node);
4422 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4424 vat_json_print (vam->ofp, &node);
4425 vat_json_free (&node);
4427 vam->retval = ntohl (mp->retval);
4428 vam->result_ready = 1;
4432 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4434 vat_main_t *vam = &vat_main;
4435 i32 retval = ntohl (mp->retval);
4439 print (vam->ofp, "%-20s%-16s",
4440 mp->status ? "enabled" : "disabled",
4441 mp->status ? (char *) mp->locator_set_name : "");
4444 vam->retval = retval;
4445 vam->result_ready = 1;
4449 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4451 vat_main_t *vam = &vat_main;
4452 vat_json_node_t node;
4455 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4456 vec_add1 (status, 0);
4458 vat_json_init_object (&node);
4459 vat_json_object_add_string_copy (&node, "status", status);
4462 vat_json_object_add_string_copy (&node, "locator_set",
4463 mp->locator_set_name);
4468 vat_json_print (vam->ofp, &node);
4469 vat_json_free (&node);
4471 vam->retval = ntohl (mp->retval);
4472 vam->result_ready = 1;
4476 format_policer_type (u8 * s, va_list * va)
4478 u32 i = va_arg (*va, u32);
4480 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4481 s = format (s, "1r2c");
4482 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4483 s = format (s, "1r3c");
4484 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4485 s = format (s, "2r3c-2698");
4486 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4487 s = format (s, "2r3c-4115");
4488 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4489 s = format (s, "2r3c-mef5cf1");
4491 s = format (s, "ILLEGAL");
4496 format_policer_rate_type (u8 * s, va_list * va)
4498 u32 i = va_arg (*va, u32);
4500 if (i == SSE2_QOS_RATE_KBPS)
4501 s = format (s, "kbps");
4502 else if (i == SSE2_QOS_RATE_PPS)
4503 s = format (s, "pps");
4505 s = format (s, "ILLEGAL");
4510 format_policer_round_type (u8 * s, va_list * va)
4512 u32 i = va_arg (*va, u32);
4514 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4515 s = format (s, "closest");
4516 else if (i == SSE2_QOS_ROUND_TO_UP)
4517 s = format (s, "up");
4518 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4519 s = format (s, "down");
4521 s = format (s, "ILLEGAL");
4526 format_policer_action_type (u8 * s, va_list * va)
4528 u32 i = va_arg (*va, u32);
4530 if (i == SSE2_QOS_ACTION_DROP)
4531 s = format (s, "drop");
4532 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4533 s = format (s, "transmit");
4534 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4535 s = format (s, "mark-and-transmit");
4537 s = format (s, "ILLEGAL");
4542 format_dscp (u8 * s, va_list * va)
4544 u32 i = va_arg (*va, u32);
4549 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4553 return format (s, "ILLEGAL");
4555 s = format (s, "%s", t);
4560 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4562 vat_main_t *vam = &vat_main;
4563 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4565 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4566 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
4568 conform_dscp_str = format (0, "");
4570 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4571 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
4573 exceed_dscp_str = format (0, "");
4575 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4576 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
4578 violate_dscp_str = format (0, "");
4580 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4581 "rate type %U, round type %U, %s rate, %s color-aware, "
4582 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4583 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4584 "conform action %U%s, exceed action %U%s, violate action %U%s",
4586 format_policer_type, mp->type,
4589 clib_net_to_host_u64 (mp->cb),
4590 clib_net_to_host_u64 (mp->eb),
4591 format_policer_rate_type, mp->rate_type,
4592 format_policer_round_type, mp->round_type,
4593 mp->single_rate ? "single" : "dual",
4594 mp->color_aware ? "is" : "not",
4595 ntohl (mp->cir_tokens_per_period),
4596 ntohl (mp->pir_tokens_per_period),
4598 ntohl (mp->current_limit),
4599 ntohl (mp->current_bucket),
4600 ntohl (mp->extended_limit),
4601 ntohl (mp->extended_bucket),
4602 clib_net_to_host_u64 (mp->last_update_time),
4603 format_policer_action_type, mp->conform_action.type,
4605 format_policer_action_type, mp->exceed_action.type,
4607 format_policer_action_type, mp->violate_action.type,
4610 vec_free (conform_dscp_str);
4611 vec_free (exceed_dscp_str);
4612 vec_free (violate_dscp_str);
4615 static void vl_api_policer_details_t_handler_json
4616 (vl_api_policer_details_t * mp)
4618 vat_main_t *vam = &vat_main;
4619 vat_json_node_t *node;
4620 u8 *rate_type_str, *round_type_str, *type_str;
4621 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4623 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4625 format (0, "%U", format_policer_round_type, mp->round_type);
4626 type_str = format (0, "%U", format_policer_type, mp->type);
4627 conform_action_str = format (0, "%U", format_policer_action_type,
4628 mp->conform_action.type);
4629 exceed_action_str = format (0, "%U", format_policer_action_type,
4630 mp->exceed_action.type);
4631 violate_action_str = format (0, "%U", format_policer_action_type,
4632 mp->violate_action.type);
4634 if (VAT_JSON_ARRAY != vam->json_tree.type)
4636 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4637 vat_json_init_array (&vam->json_tree);
4639 node = vat_json_array_add (&vam->json_tree);
4641 vat_json_init_object (node);
4642 vat_json_object_add_string_copy (node, "name", mp->name);
4643 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4644 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4645 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4646 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4647 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4648 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4649 vat_json_object_add_string_copy (node, "type", type_str);
4650 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4651 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4652 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4653 vat_json_object_add_uint (node, "cir_tokens_per_period",
4654 ntohl (mp->cir_tokens_per_period));
4655 vat_json_object_add_uint (node, "eir_tokens_per_period",
4656 ntohl (mp->pir_tokens_per_period));
4657 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4658 vat_json_object_add_uint (node, "current_bucket",
4659 ntohl (mp->current_bucket));
4660 vat_json_object_add_uint (node, "extended_limit",
4661 ntohl (mp->extended_limit));
4662 vat_json_object_add_uint (node, "extended_bucket",
4663 ntohl (mp->extended_bucket));
4664 vat_json_object_add_uint (node, "last_update_time",
4665 ntohl (mp->last_update_time));
4666 vat_json_object_add_string_copy (node, "conform_action",
4667 conform_action_str);
4668 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4670 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
4671 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4672 vec_free (dscp_str);
4674 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4675 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4677 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
4678 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4679 vec_free (dscp_str);
4681 vat_json_object_add_string_copy (node, "violate_action",
4682 violate_action_str);
4683 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4685 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
4686 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4687 vec_free (dscp_str);
4690 vec_free (rate_type_str);
4691 vec_free (round_type_str);
4692 vec_free (type_str);
4693 vec_free (conform_action_str);
4694 vec_free (exceed_action_str);
4695 vec_free (violate_action_str);
4699 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4702 vat_main_t *vam = &vat_main;
4703 int i, count = ntohl (mp->count);
4706 print (vam->ofp, "classify table ids (%d) : ", count);
4707 for (i = 0; i < count; i++)
4709 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4710 print (vam->ofp, (i < count - 1) ? "," : "");
4712 vam->retval = ntohl (mp->retval);
4713 vam->result_ready = 1;
4717 vl_api_classify_table_ids_reply_t_handler_json
4718 (vl_api_classify_table_ids_reply_t * mp)
4720 vat_main_t *vam = &vat_main;
4721 int i, count = ntohl (mp->count);
4725 vat_json_node_t node;
4727 vat_json_init_object (&node);
4728 for (i = 0; i < count; i++)
4730 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4732 vat_json_print (vam->ofp, &node);
4733 vat_json_free (&node);
4735 vam->retval = ntohl (mp->retval);
4736 vam->result_ready = 1;
4740 vl_api_classify_table_by_interface_reply_t_handler
4741 (vl_api_classify_table_by_interface_reply_t * mp)
4743 vat_main_t *vam = &vat_main;
4746 table_id = ntohl (mp->l2_table_id);
4748 print (vam->ofp, "l2 table id : %d", table_id);
4750 print (vam->ofp, "l2 table id : No input ACL tables configured");
4751 table_id = ntohl (mp->ip4_table_id);
4753 print (vam->ofp, "ip4 table id : %d", table_id);
4755 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4756 table_id = ntohl (mp->ip6_table_id);
4758 print (vam->ofp, "ip6 table id : %d", table_id);
4760 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4761 vam->retval = ntohl (mp->retval);
4762 vam->result_ready = 1;
4766 vl_api_classify_table_by_interface_reply_t_handler_json
4767 (vl_api_classify_table_by_interface_reply_t * mp)
4769 vat_main_t *vam = &vat_main;
4770 vat_json_node_t node;
4772 vat_json_init_object (&node);
4774 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4775 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4776 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4778 vat_json_print (vam->ofp, &node);
4779 vat_json_free (&node);
4781 vam->retval = ntohl (mp->retval);
4782 vam->result_ready = 1;
4785 static void vl_api_policer_add_del_reply_t_handler
4786 (vl_api_policer_add_del_reply_t * mp)
4788 vat_main_t *vam = &vat_main;
4789 i32 retval = ntohl (mp->retval);
4790 if (vam->async_mode)
4792 vam->async_errors += (retval < 0);
4796 vam->retval = retval;
4797 vam->result_ready = 1;
4798 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4800 * Note: this is just barely thread-safe, depends on
4801 * the main thread spinning waiting for an answer...
4803 errmsg ("policer index %d", ntohl (mp->policer_index));
4807 static void vl_api_policer_add_del_reply_t_handler_json
4808 (vl_api_policer_add_del_reply_t * mp)
4810 vat_main_t *vam = &vat_main;
4811 vat_json_node_t node;
4813 vat_json_init_object (&node);
4814 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4815 vat_json_object_add_uint (&node, "policer_index",
4816 ntohl (mp->policer_index));
4818 vat_json_print (vam->ofp, &node);
4819 vat_json_free (&node);
4821 vam->retval = ntohl (mp->retval);
4822 vam->result_ready = 1;
4825 /* Format hex dump. */
4827 format_hex_bytes (u8 * s, va_list * va)
4829 u8 *bytes = va_arg (*va, u8 *);
4830 int n_bytes = va_arg (*va, int);
4833 /* Print short or long form depending on byte count. */
4834 uword short_form = n_bytes <= 32;
4835 u32 indent = format_get_indent (s);
4840 for (i = 0; i < n_bytes; i++)
4842 if (!short_form && (i % 32) == 0)
4843 s = format (s, "%08x: ", i);
4844 s = format (s, "%02x", bytes[i]);
4845 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4846 s = format (s, "\n%U", format_white_space, indent);
4853 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4856 vat_main_t *vam = &vat_main;
4857 i32 retval = ntohl (mp->retval);
4860 print (vam->ofp, "classify table info :");
4861 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4862 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4863 ntohl (mp->miss_next_index));
4864 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4865 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4866 ntohl (mp->match_n_vectors));
4867 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4868 ntohl (mp->mask_length));
4870 vam->retval = retval;
4871 vam->result_ready = 1;
4875 vl_api_classify_table_info_reply_t_handler_json
4876 (vl_api_classify_table_info_reply_t * mp)
4878 vat_main_t *vam = &vat_main;
4879 vat_json_node_t node;
4881 i32 retval = ntohl (mp->retval);
4884 vat_json_init_object (&node);
4886 vat_json_object_add_int (&node, "sessions",
4887 ntohl (mp->active_sessions));
4888 vat_json_object_add_int (&node, "nexttbl",
4889 ntohl (mp->next_table_index));
4890 vat_json_object_add_int (&node, "nextnode",
4891 ntohl (mp->miss_next_index));
4892 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4893 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4894 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4895 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4896 ntohl (mp->mask_length), 0);
4897 vat_json_object_add_string_copy (&node, "mask", s);
4899 vat_json_print (vam->ofp, &node);
4900 vat_json_free (&node);
4902 vam->retval = ntohl (mp->retval);
4903 vam->result_ready = 1;
4907 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4910 vat_main_t *vam = &vat_main;
4912 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4913 ntohl (mp->hit_next_index), ntohl (mp->advance),
4914 ntohl (mp->opaque_index));
4915 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4916 ntohl (mp->match_length));
4920 vl_api_classify_session_details_t_handler_json
4921 (vl_api_classify_session_details_t * mp)
4923 vat_main_t *vam = &vat_main;
4924 vat_json_node_t *node = NULL;
4926 if (VAT_JSON_ARRAY != vam->json_tree.type)
4928 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4929 vat_json_init_array (&vam->json_tree);
4931 node = vat_json_array_add (&vam->json_tree);
4933 vat_json_init_object (node);
4934 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4935 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4936 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4938 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4940 vat_json_object_add_string_copy (node, "match", s);
4943 static void vl_api_pg_create_interface_reply_t_handler
4944 (vl_api_pg_create_interface_reply_t * mp)
4946 vat_main_t *vam = &vat_main;
4948 vam->retval = ntohl (mp->retval);
4949 vam->result_ready = 1;
4952 static void vl_api_pg_create_interface_reply_t_handler_json
4953 (vl_api_pg_create_interface_reply_t * mp)
4955 vat_main_t *vam = &vat_main;
4956 vat_json_node_t node;
4958 i32 retval = ntohl (mp->retval);
4961 vat_json_init_object (&node);
4963 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4965 vat_json_print (vam->ofp, &node);
4966 vat_json_free (&node);
4968 vam->retval = ntohl (mp->retval);
4969 vam->result_ready = 1;
4972 static void vl_api_policer_classify_details_t_handler
4973 (vl_api_policer_classify_details_t * mp)
4975 vat_main_t *vam = &vat_main;
4977 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4978 ntohl (mp->table_index));
4981 static void vl_api_policer_classify_details_t_handler_json
4982 (vl_api_policer_classify_details_t * mp)
4984 vat_main_t *vam = &vat_main;
4985 vat_json_node_t *node;
4987 if (VAT_JSON_ARRAY != vam->json_tree.type)
4989 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4990 vat_json_init_array (&vam->json_tree);
4992 node = vat_json_array_add (&vam->json_tree);
4994 vat_json_init_object (node);
4995 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4996 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4999 static void vl_api_flow_classify_details_t_handler
5000 (vl_api_flow_classify_details_t * mp)
5002 vat_main_t *vam = &vat_main;
5004 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5005 ntohl (mp->table_index));
5008 static void vl_api_flow_classify_details_t_handler_json
5009 (vl_api_flow_classify_details_t * mp)
5011 vat_main_t *vam = &vat_main;
5012 vat_json_node_t *node;
5014 if (VAT_JSON_ARRAY != vam->json_tree.type)
5016 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5017 vat_json_init_array (&vam->json_tree);
5019 node = vat_json_array_add (&vam->json_tree);
5021 vat_json_init_object (node);
5022 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5023 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5026 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5027 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5028 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5029 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5030 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5031 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5032 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5033 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5034 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5035 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5038 * Generate boilerplate reply handlers, which
5039 * dig the return value out of the xxx_reply_t API message,
5040 * stick it into vam->retval, and set vam->result_ready
5042 * Could also do this by pointing N message decode slots at
5043 * a single function, but that could break in subtle ways.
5046 #define foreach_standard_reply_retval_handler \
5047 _(sw_interface_set_flags_reply) \
5048 _(sw_interface_add_del_address_reply) \
5049 _(sw_interface_set_rx_mode_reply) \
5050 _(sw_interface_set_rx_placement_reply) \
5051 _(sw_interface_set_table_reply) \
5052 _(sw_interface_set_mpls_enable_reply) \
5053 _(sw_interface_set_vpath_reply) \
5054 _(sw_interface_set_vxlan_bypass_reply) \
5055 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5056 _(sw_interface_set_l2_bridge_reply) \
5057 _(sw_interface_set_bond_weight_reply) \
5058 _(bridge_domain_add_del_reply) \
5059 _(sw_interface_set_l2_xconnect_reply) \
5060 _(l2fib_add_del_reply) \
5061 _(l2fib_flush_int_reply) \
5062 _(l2fib_flush_bd_reply) \
5063 _(ip_route_add_del_reply) \
5064 _(ip_table_add_del_reply) \
5065 _(ip_table_replace_begin_reply) \
5066 _(ip_table_flush_reply) \
5067 _(ip_table_replace_end_reply) \
5068 _(ip_mroute_add_del_reply) \
5069 _(mpls_route_add_del_reply) \
5070 _(mpls_table_add_del_reply) \
5071 _(mpls_ip_bind_unbind_reply) \
5072 _(bier_route_add_del_reply) \
5073 _(bier_table_add_del_reply) \
5074 _(sw_interface_set_unnumbered_reply) \
5075 _(set_ip_flow_hash_reply) \
5076 _(sw_interface_ip6_enable_disable_reply) \
5077 _(l2_patch_add_del_reply) \
5078 _(sr_mpls_policy_add_reply) \
5079 _(sr_mpls_policy_mod_reply) \
5080 _(sr_mpls_policy_del_reply) \
5081 _(sr_policy_add_reply) \
5082 _(sr_policy_mod_reply) \
5083 _(sr_policy_del_reply) \
5084 _(sr_localsid_add_del_reply) \
5085 _(sr_steering_add_del_reply) \
5086 _(classify_add_del_session_reply) \
5087 _(classify_set_interface_ip_table_reply) \
5088 _(classify_set_interface_l2_tables_reply) \
5089 _(l2_fib_clear_table_reply) \
5090 _(l2_interface_efp_filter_reply) \
5091 _(l2_interface_vlan_tag_rewrite_reply) \
5092 _(modify_vhost_user_if_reply) \
5093 _(delete_vhost_user_if_reply) \
5094 _(want_l2_macs_events_reply) \
5095 _(input_acl_set_interface_reply) \
5096 _(ipsec_spd_add_del_reply) \
5097 _(ipsec_interface_add_del_spd_reply) \
5098 _(ipsec_spd_entry_add_del_reply) \
5099 _(ipsec_sad_entry_add_del_reply) \
5100 _(ipsec_tunnel_if_add_del_reply) \
5101 _(ipsec_tunnel_if_set_sa_reply) \
5102 _(delete_loopback_reply) \
5103 _(bd_ip_mac_add_del_reply) \
5104 _(bd_ip_mac_flush_reply) \
5105 _(want_interface_events_reply) \
5106 _(cop_interface_enable_disable_reply) \
5107 _(cop_whitelist_enable_disable_reply) \
5108 _(sw_interface_clear_stats_reply) \
5109 _(ioam_enable_reply) \
5110 _(ioam_disable_reply) \
5111 _(one_add_del_locator_reply) \
5112 _(one_add_del_local_eid_reply) \
5113 _(one_add_del_remote_mapping_reply) \
5114 _(one_add_del_adjacency_reply) \
5115 _(one_add_del_map_resolver_reply) \
5116 _(one_add_del_map_server_reply) \
5117 _(one_enable_disable_reply) \
5118 _(one_rloc_probe_enable_disable_reply) \
5119 _(one_map_register_enable_disable_reply) \
5120 _(one_map_register_set_ttl_reply) \
5121 _(one_set_transport_protocol_reply) \
5122 _(one_map_register_fallback_threshold_reply) \
5123 _(one_pitr_set_locator_set_reply) \
5124 _(one_map_request_mode_reply) \
5125 _(one_add_del_map_request_itr_rlocs_reply) \
5126 _(one_eid_table_add_del_map_reply) \
5127 _(one_use_petr_reply) \
5128 _(one_stats_enable_disable_reply) \
5129 _(one_add_del_l2_arp_entry_reply) \
5130 _(one_add_del_ndp_entry_reply) \
5131 _(one_stats_flush_reply) \
5132 _(one_enable_disable_xtr_mode_reply) \
5133 _(one_enable_disable_pitr_mode_reply) \
5134 _(one_enable_disable_petr_mode_reply) \
5135 _(gpe_enable_disable_reply) \
5136 _(gpe_set_encap_mode_reply) \
5137 _(gpe_add_del_iface_reply) \
5138 _(gpe_add_del_native_fwd_rpath_reply) \
5139 _(af_packet_delete_reply) \
5140 _(policer_classify_set_interface_reply) \
5141 _(set_ipfix_exporter_reply) \
5142 _(set_ipfix_classify_stream_reply) \
5143 _(ipfix_classify_table_add_del_reply) \
5144 _(flow_classify_set_interface_reply) \
5145 _(sw_interface_span_enable_disable_reply) \
5146 _(pg_capture_reply) \
5147 _(pg_enable_disable_reply) \
5148 _(pg_interface_enable_disable_coalesce_reply) \
5149 _(ip_source_and_port_range_check_add_del_reply) \
5150 _(ip_source_and_port_range_check_interface_add_del_reply)\
5151 _(delete_subif_reply) \
5152 _(l2_interface_pbb_tag_rewrite_reply) \
5154 _(feature_enable_disable_reply) \
5155 _(feature_gso_enable_disable_reply) \
5156 _(sw_interface_tag_add_del_reply) \
5157 _(sw_interface_add_del_mac_address_reply) \
5158 _(hw_interface_set_mtu_reply) \
5159 _(p2p_ethernet_add_reply) \
5160 _(p2p_ethernet_del_reply) \
5161 _(tcp_configure_src_addresses_reply) \
5162 _(session_rule_add_del_reply) \
5163 _(ip_container_proxy_add_del_reply) \
5164 _(output_acl_set_interface_reply) \
5165 _(qos_record_enable_disable_reply) \
5169 static void vl_api_##n##_t_handler \
5170 (vl_api_##n##_t * mp) \
5172 vat_main_t * vam = &vat_main; \
5173 i32 retval = ntohl(mp->retval); \
5174 if (vam->async_mode) { \
5175 vam->async_errors += (retval < 0); \
5177 vam->retval = retval; \
5178 vam->result_ready = 1; \
5181 foreach_standard_reply_retval_handler;
5185 static void vl_api_##n##_t_handler_json \
5186 (vl_api_##n##_t * mp) \
5188 vat_main_t * vam = &vat_main; \
5189 vat_json_node_t node; \
5190 vat_json_init_object(&node); \
5191 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5192 vat_json_print(vam->ofp, &node); \
5193 vam->retval = ntohl(mp->retval); \
5194 vam->result_ready = 1; \
5196 foreach_standard_reply_retval_handler;
5200 * Table of message reply handlers, must include boilerplate handlers
5204 #define foreach_vpe_api_reply_msg \
5205 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5206 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5207 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5208 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5209 _(CONTROL_PING_REPLY, control_ping_reply) \
5210 _(CLI_REPLY, cli_reply) \
5211 _(CLI_INBAND_REPLY, cli_inband_reply) \
5212 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5213 sw_interface_add_del_address_reply) \
5214 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5215 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5216 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5217 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5218 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5219 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5220 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5221 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5222 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5223 sw_interface_set_l2_xconnect_reply) \
5224 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5225 sw_interface_set_l2_bridge_reply) \
5226 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5227 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5228 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5229 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5230 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5231 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5232 _(L2_FLAGS_REPLY, l2_flags_reply) \
5233 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5234 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5235 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5236 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5237 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5238 _(VIRTIO_PCI_CREATE_V2_REPLY, virtio_pci_create_v2_reply) \
5239 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5240 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5241 _(BOND_CREATE_REPLY, bond_create_reply) \
5242 _(BOND_CREATE2_REPLY, bond_create2_reply) \
5243 _(BOND_DELETE_REPLY, bond_delete_reply) \
5244 _(BOND_ADD_MEMBER_REPLY, bond_add_member_reply) \
5245 _(BOND_DETACH_MEMBER_REPLY, bond_detach_member_reply) \
5246 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5247 _(SW_BOND_INTERFACE_DETAILS, sw_bond_interface_details) \
5248 _(SW_MEMBER_INTERFACE_DETAILS, sw_member_interface_details) \
5249 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5250 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5251 _(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
5252 _(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
5253 _(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_reply) \
5254 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5255 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5256 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5257 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5258 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5259 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5260 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5261 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5262 sw_interface_set_unnumbered_reply) \
5263 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5264 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5265 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5266 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5267 sw_interface_ip6_enable_disable_reply) \
5268 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5269 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5270 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5271 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5272 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5273 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5274 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5275 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5276 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5277 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5278 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5279 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5280 classify_set_interface_ip_table_reply) \
5281 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5282 classify_set_interface_l2_tables_reply) \
5283 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5284 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5285 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5286 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5287 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5288 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5289 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5290 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5291 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5292 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5293 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5294 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5295 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5296 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5297 _(SHOW_VERSION_REPLY, show_version_reply) \
5298 _(SHOW_THREADS_REPLY, show_threads_reply) \
5299 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5300 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5301 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5302 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5303 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5304 _(L2_MACS_EVENT, l2_macs_event) \
5305 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5306 _(IP_ADDRESS_DETAILS, ip_address_details) \
5307 _(IP_DETAILS, ip_details) \
5308 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5309 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5310 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5311 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5312 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5313 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5314 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5315 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5316 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5317 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5318 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5319 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5320 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5321 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5322 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5323 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5324 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5325 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5326 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5327 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5328 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5329 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5330 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5331 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5332 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5333 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5334 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5335 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5336 one_map_register_enable_disable_reply) \
5337 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5338 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5339 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5340 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5341 one_map_register_fallback_threshold_reply) \
5342 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5343 one_rloc_probe_enable_disable_reply) \
5344 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5345 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5346 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5347 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5348 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5349 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5350 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5351 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5352 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5353 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5354 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5355 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5356 _(ONE_STATS_DETAILS, one_stats_details) \
5357 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5358 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5359 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5360 show_one_stats_enable_disable_reply) \
5361 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5362 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5363 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5364 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5365 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5366 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5367 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5368 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5369 one_enable_disable_pitr_mode_reply) \
5370 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5371 one_enable_disable_petr_mode_reply) \
5372 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5373 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5374 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5375 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5376 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5377 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5378 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5379 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5380 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5381 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5382 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5383 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5384 gpe_add_del_native_fwd_rpath_reply) \
5385 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5386 gpe_fwd_entry_path_details) \
5387 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5388 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5389 one_add_del_map_request_itr_rlocs_reply) \
5390 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5391 one_get_map_request_itr_rlocs_reply) \
5392 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5393 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5394 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5395 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5396 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5397 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5398 show_one_map_register_state_reply) \
5399 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5400 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5401 show_one_map_register_fallback_threshold_reply) \
5402 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5403 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5404 _(AF_PACKET_DETAILS, af_packet_details) \
5405 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5406 _(POLICER_DETAILS, policer_details) \
5407 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5408 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5409 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5410 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5411 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5412 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5413 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5414 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5415 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5416 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5417 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5418 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5419 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5420 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5421 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5422 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5423 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5424 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5425 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5426 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5427 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5428 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5429 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5430 _(PG_INTERFACE_ENABLE_DISABLE_COALESCE_REPLY, pg_interface_enable_disable_coalesce_reply) \
5431 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5432 ip_source_and_port_range_check_add_del_reply) \
5433 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5434 ip_source_and_port_range_check_interface_add_del_reply) \
5435 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5436 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5437 _(SET_PUNT_REPLY, set_punt_reply) \
5438 _(IP_TABLE_DETAILS, ip_table_details) \
5439 _(IP_ROUTE_DETAILS, ip_route_details) \
5440 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5441 _(FEATURE_GSO_ENABLE_DISABLE_REPLY, feature_gso_enable_disable_reply) \
5442 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5443 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
5444 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5445 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5446 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5447 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5448 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5449 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5450 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5451 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5452 _(SESSION_RULES_DETAILS, session_rules_details) \
5453 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5454 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5455 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply) \
5456 _(FLOW_ADD_REPLY, flow_add_reply) \
5458 #define foreach_standalone_reply_msg \
5459 _(SW_INTERFACE_EVENT, sw_interface_event)
5467 #define STR_VTR_OP_CASE(op) \
5468 case L2_VTR_ ## op: \
5472 str_vtr_op (u32 vtr_op)
5476 STR_VTR_OP_CASE (DISABLED);
5477 STR_VTR_OP_CASE (PUSH_1);
5478 STR_VTR_OP_CASE (PUSH_2);
5479 STR_VTR_OP_CASE (POP_1);
5480 STR_VTR_OP_CASE (POP_2);
5481 STR_VTR_OP_CASE (TRANSLATE_1_1);
5482 STR_VTR_OP_CASE (TRANSLATE_1_2);
5483 STR_VTR_OP_CASE (TRANSLATE_2_1);
5484 STR_VTR_OP_CASE (TRANSLATE_2_2);
5491 dump_sub_interface_table (vat_main_t * vam)
5493 const sw_interface_subif_t *sub = NULL;
5495 if (vam->json_output)
5498 ("JSON output supported only for VPE API calls and dump_stats_table");
5503 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5504 "Interface", "sw_if_index",
5505 "sub id", "dot1ad", "tags", "outer id",
5506 "inner id", "exact", "default", "outer any", "inner any");
5508 vec_foreach (sub, vam->sw_if_subif_table)
5511 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5512 sub->interface_name,
5514 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5515 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5516 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5517 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5518 if (sub->vtr_op != L2_VTR_DISABLED)
5521 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5522 "tag1: %d tag2: %d ]",
5523 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5524 sub->vtr_tag1, sub->vtr_tag2);
5532 name_sort_cmp (void *a1, void *a2)
5534 name_sort_t *n1 = a1;
5535 name_sort_t *n2 = a2;
5537 return strcmp ((char *) n1->name, (char *) n2->name);
5541 dump_interface_table (vat_main_t * vam)
5544 name_sort_t *nses = 0, *ns;
5546 if (vam->json_output)
5549 ("JSON output supported only for VPE API calls and dump_stats_table");
5554 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5556 vec_add2 (nses, ns, 1);
5557 ns->name = (u8 *)(p->key);
5558 ns->value = (u32) p->value[0];
5562 vec_sort_with_function (nses, name_sort_cmp);
5564 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5565 vec_foreach (ns, nses)
5567 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5574 dump_ip_table (vat_main_t * vam, int is_ipv6)
5576 const ip_details_t *det = NULL;
5577 const ip_address_details_t *address = NULL;
5580 print (vam->ofp, "%-12s", "sw_if_index");
5582 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5589 print (vam->ofp, "%-12d", i);
5590 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5595 vec_foreach (address, det->addr)
5599 is_ipv6 ? format_ip6_address : format_ip4_address,
5600 address->ip, address->prefix_length);
5608 dump_ipv4_table (vat_main_t * vam)
5610 if (vam->json_output)
5613 ("JSON output supported only for VPE API calls and dump_stats_table");
5617 return dump_ip_table (vam, 0);
5621 dump_ipv6_table (vat_main_t * vam)
5623 if (vam->json_output)
5626 ("JSON output supported only for VPE API calls and dump_stats_table");
5630 return dump_ip_table (vam, 1);
5634 * Pass CLI buffers directly in the CLI_INBAND API message,
5635 * instead of an additional shared memory area.
5638 exec_inband (vat_main_t * vam)
5640 vl_api_cli_inband_t *mp;
5641 unformat_input_t *i = vam->input;
5644 if (vec_len (i->buffer) == 0)
5647 if (vam->exec_mode == 0 && unformat (i, "mode"))
5652 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5659 * In order for the CLI command to work, it
5660 * must be a vector ending in \n, not a C-string ending
5663 M2 (CLI_INBAND, mp, vec_len (vam->input->buffer));
5664 vl_api_vec_to_api_string (vam->input->buffer, &mp->cmd);
5668 /* json responses may or may not include a useful reply... */
5669 if (vec_len (vam->cmd_reply))
5670 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5675 exec (vat_main_t * vam)
5677 return exec_inband (vam);
5681 api_create_loopback (vat_main_t * vam)
5683 unformat_input_t *i = vam->input;
5684 vl_api_create_loopback_t *mp;
5685 vl_api_create_loopback_instance_t *mp_lbi;
5688 u8 is_specified = 0;
5689 u32 user_instance = 0;
5692 clib_memset (mac_address, 0, sizeof (mac_address));
5694 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5696 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5698 if (unformat (i, "instance %d", &user_instance))
5706 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5707 mp_lbi->is_specified = is_specified;
5709 mp_lbi->user_instance = htonl (user_instance);
5711 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5716 /* Construct the API message */
5717 M (CREATE_LOOPBACK, mp);
5719 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5728 api_delete_loopback (vat_main_t * vam)
5730 unformat_input_t *i = vam->input;
5731 vl_api_delete_loopback_t *mp;
5732 u32 sw_if_index = ~0;
5735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5737 if (unformat (i, "sw_if_index %d", &sw_if_index))
5743 if (sw_if_index == ~0)
5745 errmsg ("missing sw_if_index");
5749 /* Construct the API message */
5750 M (DELETE_LOOPBACK, mp);
5751 mp->sw_if_index = ntohl (sw_if_index);
5759 api_want_interface_events (vat_main_t * vam)
5761 unformat_input_t *i = vam->input;
5762 vl_api_want_interface_events_t *mp;
5766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5768 if (unformat (i, "enable"))
5770 else if (unformat (i, "disable"))
5778 errmsg ("missing enable|disable");
5782 M (WANT_INTERFACE_EVENTS, mp);
5783 mp->enable_disable = enable;
5785 vam->interface_event_display = enable;
5793 /* Note: non-static, called once to set up the initial intfc table */
5795 api_sw_interface_dump (vat_main_t * vam)
5797 vl_api_sw_interface_dump_t *mp;
5798 vl_api_control_ping_t *mp_ping;
5800 name_sort_t *nses = 0, *ns;
5801 sw_interface_subif_t *sub = NULL;
5804 /* Toss the old name table */
5806 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5808 vec_add2 (nses, ns, 1);
5809 ns->name = (u8 *)(p->key);
5810 ns->value = (u32) p->value[0];
5814 hash_free (vam->sw_if_index_by_interface_name);
5816 vec_foreach (ns, nses) vec_free (ns->name);
5820 vec_foreach (sub, vam->sw_if_subif_table)
5822 vec_free (sub->interface_name);
5824 vec_free (vam->sw_if_subif_table);
5826 /* recreate the interface name hash table */
5827 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5830 * Ask for all interface names. Otherwise, the epic catalog of
5831 * name filters becomes ridiculously long, and vat ends up needing
5832 * to be taught about new interface types.
5834 M (SW_INTERFACE_DUMP, mp);
5837 /* Use a control ping for synchronization */
5838 MPING (CONTROL_PING, mp_ping);
5846 api_sw_interface_set_flags (vat_main_t * vam)
5848 unformat_input_t *i = vam->input;
5849 vl_api_sw_interface_set_flags_t *mp;
5851 u8 sw_if_index_set = 0;
5855 /* Parse args required to build the message */
5856 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5858 if (unformat (i, "admin-up"))
5860 else if (unformat (i, "admin-down"))
5863 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5864 sw_if_index_set = 1;
5865 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5866 sw_if_index_set = 1;
5871 if (sw_if_index_set == 0)
5873 errmsg ("missing interface name or sw_if_index");
5877 /* Construct the API message */
5878 M (SW_INTERFACE_SET_FLAGS, mp);
5879 mp->sw_if_index = ntohl (sw_if_index);
5880 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5885 /* Wait for a reply, return the good/bad news... */
5891 api_sw_interface_set_rx_mode (vat_main_t * vam)
5893 unformat_input_t *i = vam->input;
5894 vl_api_sw_interface_set_rx_mode_t *mp;
5896 u8 sw_if_index_set = 0;
5898 u8 queue_id_valid = 0;
5900 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5902 /* Parse args required to build the message */
5903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5905 if (unformat (i, "queue %d", &queue_id))
5907 else if (unformat (i, "polling"))
5908 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5909 else if (unformat (i, "interrupt"))
5910 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5911 else if (unformat (i, "adaptive"))
5912 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5914 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5915 sw_if_index_set = 1;
5916 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5917 sw_if_index_set = 1;
5922 if (sw_if_index_set == 0)
5924 errmsg ("missing interface name or sw_if_index");
5927 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
5929 errmsg ("missing rx-mode");
5933 /* Construct the API message */
5934 M (SW_INTERFACE_SET_RX_MODE, mp);
5935 mp->sw_if_index = ntohl (sw_if_index);
5936 mp->mode = (vl_api_rx_mode_t) mode;
5937 mp->queue_id_valid = queue_id_valid;
5938 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
5943 /* Wait for a reply, return the good/bad news... */
5949 api_sw_interface_set_rx_placement (vat_main_t * vam)
5951 unformat_input_t *i = vam->input;
5952 vl_api_sw_interface_set_rx_placement_t *mp;
5954 u8 sw_if_index_set = 0;
5957 u32 queue_id, thread_index;
5959 /* Parse args required to build the message */
5960 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5962 if (unformat (i, "queue %d", &queue_id))
5964 else if (unformat (i, "main"))
5966 else if (unformat (i, "worker %d", &thread_index))
5969 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5970 sw_if_index_set = 1;
5971 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5972 sw_if_index_set = 1;
5977 if (sw_if_index_set == 0)
5979 errmsg ("missing interface name or sw_if_index");
5985 /* Construct the API message */
5986 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
5987 mp->sw_if_index = ntohl (sw_if_index);
5988 mp->worker_id = ntohl (thread_index);
5989 mp->queue_id = ntohl (queue_id);
5990 mp->is_main = is_main;
5994 /* Wait for a reply, return the good/bad news... */
5999 static void vl_api_sw_interface_rx_placement_details_t_handler
6000 (vl_api_sw_interface_rx_placement_details_t * mp)
6002 vat_main_t *vam = &vat_main;
6003 u32 worker_id = ntohl (mp->worker_id);
6006 "\n%-11d %-11s %-6d %-5d %-9s",
6007 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6008 worker_id, ntohl (mp->queue_id),
6010 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6013 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6014 (vl_api_sw_interface_rx_placement_details_t * mp)
6016 vat_main_t *vam = &vat_main;
6017 vat_json_node_t *node = NULL;
6019 if (VAT_JSON_ARRAY != vam->json_tree.type)
6021 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6022 vat_json_init_array (&vam->json_tree);
6024 node = vat_json_array_add (&vam->json_tree);
6026 vat_json_init_object (node);
6027 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6028 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6029 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6030 vat_json_object_add_uint (node, "mode", mp->mode);
6034 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6036 unformat_input_t *i = vam->input;
6037 vl_api_sw_interface_rx_placement_dump_t *mp;
6038 vl_api_control_ping_t *mp_ping;
6041 u8 sw_if_index_set = 0;
6043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6045 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6047 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6054 "\n%-11s %-11s %-6s %-5s %-4s",
6055 "sw_if_index", "main/worker", "thread", "queue", "mode");
6057 /* Dump Interface rx placement */
6058 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6060 if (sw_if_index_set)
6061 mp->sw_if_index = htonl (sw_if_index);
6063 mp->sw_if_index = ~0;
6067 /* Use a control ping for synchronization */
6068 MPING (CONTROL_PING, mp_ping);
6076 api_sw_interface_clear_stats (vat_main_t * vam)
6078 unformat_input_t *i = vam->input;
6079 vl_api_sw_interface_clear_stats_t *mp;
6081 u8 sw_if_index_set = 0;
6084 /* Parse args required to build the message */
6085 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6087 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6088 sw_if_index_set = 1;
6089 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6090 sw_if_index_set = 1;
6095 /* Construct the API message */
6096 M (SW_INTERFACE_CLEAR_STATS, mp);
6098 if (sw_if_index_set == 1)
6099 mp->sw_if_index = ntohl (sw_if_index);
6101 mp->sw_if_index = ~0;
6106 /* Wait for a reply, return the good/bad news... */
6112 api_sw_interface_add_del_address (vat_main_t * vam)
6114 unformat_input_t *i = vam->input;
6115 vl_api_sw_interface_add_del_address_t *mp;
6117 u8 sw_if_index_set = 0;
6118 u8 is_add = 1, del_all = 0;
6119 u32 address_length = 0;
6120 u8 v4_address_set = 0;
6121 u8 v6_address_set = 0;
6122 ip4_address_t v4address;
6123 ip6_address_t v6address;
6126 /* Parse args required to build the message */
6127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6129 if (unformat (i, "del-all"))
6131 else if (unformat (i, "del"))
6134 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6135 sw_if_index_set = 1;
6136 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6137 sw_if_index_set = 1;
6138 else if (unformat (i, "%U/%d",
6139 unformat_ip4_address, &v4address, &address_length))
6141 else if (unformat (i, "%U/%d",
6142 unformat_ip6_address, &v6address, &address_length))
6148 if (sw_if_index_set == 0)
6150 errmsg ("missing interface name or sw_if_index");
6153 if (v4_address_set && v6_address_set)
6155 errmsg ("both v4 and v6 addresses set");
6158 if (!v4_address_set && !v6_address_set && !del_all)
6160 errmsg ("no addresses set");
6164 /* Construct the API message */
6165 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6167 mp->sw_if_index = ntohl (sw_if_index);
6168 mp->is_add = is_add;
6169 mp->del_all = del_all;
6172 mp->prefix.address.af = ADDRESS_IP6;
6173 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6177 mp->prefix.address.af = ADDRESS_IP4;
6178 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6180 mp->prefix.len = address_length;
6185 /* Wait for a reply, return good/bad news */
6191 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6193 unformat_input_t *i = vam->input;
6194 vl_api_sw_interface_set_mpls_enable_t *mp;
6196 u8 sw_if_index_set = 0;
6200 /* Parse args required to build the message */
6201 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6203 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6204 sw_if_index_set = 1;
6205 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6206 sw_if_index_set = 1;
6207 else if (unformat (i, "disable"))
6209 else if (unformat (i, "dis"))
6215 if (sw_if_index_set == 0)
6217 errmsg ("missing interface name or sw_if_index");
6221 /* Construct the API message */
6222 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6224 mp->sw_if_index = ntohl (sw_if_index);
6225 mp->enable = enable;
6230 /* Wait for a reply... */
6236 api_sw_interface_set_table (vat_main_t * vam)
6238 unformat_input_t *i = vam->input;
6239 vl_api_sw_interface_set_table_t *mp;
6240 u32 sw_if_index, vrf_id = 0;
6241 u8 sw_if_index_set = 0;
6245 /* Parse args required to build the message */
6246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6248 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6249 sw_if_index_set = 1;
6250 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6251 sw_if_index_set = 1;
6252 else if (unformat (i, "vrf %d", &vrf_id))
6254 else if (unformat (i, "ipv6"))
6260 if (sw_if_index_set == 0)
6262 errmsg ("missing interface name or sw_if_index");
6266 /* Construct the API message */
6267 M (SW_INTERFACE_SET_TABLE, mp);
6269 mp->sw_if_index = ntohl (sw_if_index);
6270 mp->is_ipv6 = is_ipv6;
6271 mp->vrf_id = ntohl (vrf_id);
6276 /* Wait for a reply... */
6281 static void vl_api_sw_interface_get_table_reply_t_handler
6282 (vl_api_sw_interface_get_table_reply_t * mp)
6284 vat_main_t *vam = &vat_main;
6286 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6288 vam->retval = ntohl (mp->retval);
6289 vam->result_ready = 1;
6293 static void vl_api_sw_interface_get_table_reply_t_handler_json
6294 (vl_api_sw_interface_get_table_reply_t * mp)
6296 vat_main_t *vam = &vat_main;
6297 vat_json_node_t node;
6299 vat_json_init_object (&node);
6300 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6301 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6303 vat_json_print (vam->ofp, &node);
6304 vat_json_free (&node);
6306 vam->retval = ntohl (mp->retval);
6307 vam->result_ready = 1;
6311 api_sw_interface_get_table (vat_main_t * vam)
6313 unformat_input_t *i = vam->input;
6314 vl_api_sw_interface_get_table_t *mp;
6316 u8 sw_if_index_set = 0;
6320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6322 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6323 sw_if_index_set = 1;
6324 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6325 sw_if_index_set = 1;
6326 else if (unformat (i, "ipv6"))
6332 if (sw_if_index_set == 0)
6334 errmsg ("missing interface name or sw_if_index");
6338 M (SW_INTERFACE_GET_TABLE, mp);
6339 mp->sw_if_index = htonl (sw_if_index);
6340 mp->is_ipv6 = is_ipv6;
6348 api_sw_interface_set_vpath (vat_main_t * vam)
6350 unformat_input_t *i = vam->input;
6351 vl_api_sw_interface_set_vpath_t *mp;
6352 u32 sw_if_index = 0;
6353 u8 sw_if_index_set = 0;
6357 /* Parse args required to build the message */
6358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6360 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6361 sw_if_index_set = 1;
6362 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6363 sw_if_index_set = 1;
6364 else if (unformat (i, "enable"))
6366 else if (unformat (i, "disable"))
6372 if (sw_if_index_set == 0)
6374 errmsg ("missing interface name or sw_if_index");
6378 /* Construct the API message */
6379 M (SW_INTERFACE_SET_VPATH, mp);
6381 mp->sw_if_index = ntohl (sw_if_index);
6382 mp->enable = is_enable;
6387 /* Wait for a reply... */
6393 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6395 unformat_input_t *i = vam->input;
6396 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6397 u32 sw_if_index = 0;
6398 u8 sw_if_index_set = 0;
6403 /* Parse args required to build the message */
6404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6406 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6407 sw_if_index_set = 1;
6408 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6409 sw_if_index_set = 1;
6410 else if (unformat (i, "enable"))
6412 else if (unformat (i, "disable"))
6414 else if (unformat (i, "ip4"))
6416 else if (unformat (i, "ip6"))
6422 if (sw_if_index_set == 0)
6424 errmsg ("missing interface name or sw_if_index");
6428 /* Construct the API message */
6429 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6431 mp->sw_if_index = ntohl (sw_if_index);
6432 mp->enable = is_enable;
6433 mp->is_ipv6 = is_ipv6;
6438 /* Wait for a reply... */
6444 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6446 unformat_input_t *i = vam->input;
6447 vl_api_sw_interface_set_l2_xconnect_t *mp;
6449 u8 rx_sw_if_index_set = 0;
6451 u8 tx_sw_if_index_set = 0;
6455 /* Parse args required to build the message */
6456 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6458 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6459 rx_sw_if_index_set = 1;
6460 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6461 tx_sw_if_index_set = 1;
6462 else if (unformat (i, "rx"))
6464 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6466 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6468 rx_sw_if_index_set = 1;
6473 else if (unformat (i, "tx"))
6475 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6477 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6479 tx_sw_if_index_set = 1;
6484 else if (unformat (i, "enable"))
6486 else if (unformat (i, "disable"))
6492 if (rx_sw_if_index_set == 0)
6494 errmsg ("missing rx interface name or rx_sw_if_index");
6498 if (enable && (tx_sw_if_index_set == 0))
6500 errmsg ("missing tx interface name or tx_sw_if_index");
6504 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6506 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6507 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6508 mp->enable = enable;
6516 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6518 unformat_input_t *i = vam->input;
6519 vl_api_sw_interface_set_l2_bridge_t *mp;
6520 vl_api_l2_port_type_t port_type;
6522 u8 rx_sw_if_index_set = 0;
6529 port_type = L2_API_PORT_TYPE_NORMAL;
6531 /* Parse args required to build the message */
6532 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6534 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6535 rx_sw_if_index_set = 1;
6536 else if (unformat (i, "bd_id %d", &bd_id))
6540 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6541 rx_sw_if_index_set = 1;
6542 else if (unformat (i, "shg %d", &shg))
6544 else if (unformat (i, "bvi"))
6545 port_type = L2_API_PORT_TYPE_BVI;
6546 else if (unformat (i, "uu-fwd"))
6547 port_type = L2_API_PORT_TYPE_UU_FWD;
6548 else if (unformat (i, "enable"))
6550 else if (unformat (i, "disable"))
6556 if (rx_sw_if_index_set == 0)
6558 errmsg ("missing rx interface name or sw_if_index");
6562 if (enable && (bd_id_set == 0))
6564 errmsg ("missing bridge domain");
6568 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6570 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6571 mp->bd_id = ntohl (bd_id);
6573 mp->port_type = ntohl (port_type);
6574 mp->enable = enable;
6582 api_bridge_domain_dump (vat_main_t * vam)
6584 unformat_input_t *i = vam->input;
6585 vl_api_bridge_domain_dump_t *mp;
6586 vl_api_control_ping_t *mp_ping;
6590 /* Parse args required to build the message */
6591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6593 if (unformat (i, "bd_id %d", &bd_id))
6599 M (BRIDGE_DOMAIN_DUMP, mp);
6600 mp->bd_id = ntohl (bd_id);
6603 /* Use a control ping for synchronization */
6604 MPING (CONTROL_PING, mp_ping);
6612 api_bridge_domain_add_del (vat_main_t * vam)
6614 unformat_input_t *i = vam->input;
6615 vl_api_bridge_domain_add_del_t *mp;
6618 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6623 /* Parse args required to build the message */
6624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6626 if (unformat (i, "bd_id %d", &bd_id))
6628 else if (unformat (i, "flood %d", &flood))
6630 else if (unformat (i, "uu-flood %d", &uu_flood))
6632 else if (unformat (i, "forward %d", &forward))
6634 else if (unformat (i, "learn %d", &learn))
6636 else if (unformat (i, "arp-term %d", &arp_term))
6638 else if (unformat (i, "mac-age %d", &mac_age))
6640 else if (unformat (i, "bd-tag %s", &bd_tag))
6642 else if (unformat (i, "del"))
6645 flood = uu_flood = forward = learn = 0;
6653 errmsg ("missing bridge domain");
6660 errmsg ("mac age must be less than 256 ");
6665 if ((bd_tag) && (vec_len (bd_tag) > 63))
6667 errmsg ("bd-tag cannot be longer than 63");
6672 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6674 mp->bd_id = ntohl (bd_id);
6676 mp->uu_flood = uu_flood;
6677 mp->forward = forward;
6679 mp->arp_term = arp_term;
6680 mp->is_add = is_add;
6681 mp->mac_age = (u8) mac_age;
6684 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6685 mp->bd_tag[vec_len (bd_tag)] = 0;
6696 api_l2fib_flush_bd (vat_main_t * vam)
6698 unformat_input_t *i = vam->input;
6699 vl_api_l2fib_flush_bd_t *mp;
6703 /* Parse args required to build the message */
6704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6706 if (unformat (i, "bd_id %d", &bd_id));
6713 errmsg ("missing bridge domain");
6717 M (L2FIB_FLUSH_BD, mp);
6719 mp->bd_id = htonl (bd_id);
6727 api_l2fib_flush_int (vat_main_t * vam)
6729 unformat_input_t *i = vam->input;
6730 vl_api_l2fib_flush_int_t *mp;
6731 u32 sw_if_index = ~0;
6734 /* Parse args required to build the message */
6735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6737 if (unformat (i, "sw_if_index %d", &sw_if_index));
6739 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6744 if (sw_if_index == ~0)
6746 errmsg ("missing interface name or sw_if_index");
6750 M (L2FIB_FLUSH_INT, mp);
6752 mp->sw_if_index = ntohl (sw_if_index);
6760 api_l2fib_add_del (vat_main_t * vam)
6762 unformat_input_t *i = vam->input;
6763 vl_api_l2fib_add_del_t *mp;
6769 u32 sw_if_index = 0;
6770 u8 sw_if_index_set = 0;
6779 /* Parse args required to build the message */
6780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6782 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6784 else if (unformat (i, "bd_id %d", &bd_id))
6786 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6787 sw_if_index_set = 1;
6788 else if (unformat (i, "sw_if"))
6790 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6793 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6794 sw_if_index_set = 1;
6799 else if (unformat (i, "static"))
6801 else if (unformat (i, "filter"))
6806 else if (unformat (i, "bvi"))
6811 else if (unformat (i, "del"))
6813 else if (unformat (i, "count %d", &count))
6821 errmsg ("missing mac address");
6827 errmsg ("missing bridge domain");
6831 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6833 errmsg ("missing interface name or sw_if_index");
6839 /* Turn on async mode */
6840 vam->async_mode = 1;
6841 vam->async_errors = 0;
6842 before = vat_time_now (vam);
6845 for (j = 0; j < count; j++)
6847 M (L2FIB_ADD_DEL, mp);
6849 clib_memcpy (mp->mac, mac, 6);
6850 mp->bd_id = ntohl (bd_id);
6851 mp->is_add = is_add;
6852 mp->sw_if_index = ntohl (sw_if_index);
6856 mp->static_mac = static_mac;
6857 mp->filter_mac = filter_mac;
6858 mp->bvi_mac = bvi_mac;
6860 increment_mac_address (mac);
6867 vl_api_control_ping_t *mp_ping;
6870 /* Shut off async mode */
6871 vam->async_mode = 0;
6873 MPING (CONTROL_PING, mp_ping);
6876 timeout = vat_time_now (vam) + 1.0;
6877 while (vat_time_now (vam) < timeout)
6878 if (vam->result_ready == 1)
6883 if (vam->retval == -99)
6886 if (vam->async_errors > 0)
6888 errmsg ("%d asynchronous errors", vam->async_errors);
6891 vam->async_errors = 0;
6892 after = vat_time_now (vam);
6894 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6895 count, after - before, count / (after - before));
6901 /* Wait for a reply... */
6905 /* Return the good/bad news */
6906 return (vam->retval);
6910 api_bridge_domain_set_mac_age (vat_main_t * vam)
6912 unformat_input_t *i = vam->input;
6913 vl_api_bridge_domain_set_mac_age_t *mp;
6918 /* Parse args required to build the message */
6919 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6921 if (unformat (i, "bd_id %d", &bd_id));
6922 else if (unformat (i, "mac-age %d", &mac_age));
6929 errmsg ("missing bridge domain");
6935 errmsg ("mac age must be less than 256 ");
6939 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6941 mp->bd_id = htonl (bd_id);
6942 mp->mac_age = (u8) mac_age;
6950 api_l2_flags (vat_main_t * vam)
6952 unformat_input_t *i = vam->input;
6953 vl_api_l2_flags_t *mp;
6956 u8 sw_if_index_set = 0;
6960 /* Parse args required to build the message */
6961 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6963 if (unformat (i, "sw_if_index %d", &sw_if_index))
6964 sw_if_index_set = 1;
6965 else if (unformat (i, "sw_if"))
6967 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6970 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6971 sw_if_index_set = 1;
6976 else if (unformat (i, "learn"))
6978 else if (unformat (i, "forward"))
6980 else if (unformat (i, "flood"))
6982 else if (unformat (i, "uu-flood"))
6983 flags |= L2_UU_FLOOD;
6984 else if (unformat (i, "arp-term"))
6985 flags |= L2_ARP_TERM;
6986 else if (unformat (i, "off"))
6988 else if (unformat (i, "disable"))
6994 if (sw_if_index_set == 0)
6996 errmsg ("missing interface name or sw_if_index");
7002 mp->sw_if_index = ntohl (sw_if_index);
7003 mp->feature_bitmap = ntohl (flags);
7004 mp->is_set = is_set;
7012 api_bridge_flags (vat_main_t * vam)
7014 unformat_input_t *i = vam->input;
7015 vl_api_bridge_flags_t *mp;
7019 bd_flags_t flags = 0;
7022 /* Parse args required to build the message */
7023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7025 if (unformat (i, "bd_id %d", &bd_id))
7027 else if (unformat (i, "learn"))
7028 flags |= BRIDGE_API_FLAG_LEARN;
7029 else if (unformat (i, "forward"))
7030 flags |= BRIDGE_API_FLAG_FWD;
7031 else if (unformat (i, "flood"))
7032 flags |= BRIDGE_API_FLAG_FLOOD;
7033 else if (unformat (i, "uu-flood"))
7034 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7035 else if (unformat (i, "arp-term"))
7036 flags |= BRIDGE_API_FLAG_ARP_TERM;
7037 else if (unformat (i, "off"))
7039 else if (unformat (i, "disable"))
7047 errmsg ("missing bridge domain");
7051 M (BRIDGE_FLAGS, mp);
7053 mp->bd_id = ntohl (bd_id);
7054 mp->flags = ntohl (flags);
7055 mp->is_set = is_set;
7063 api_bd_ip_mac_add_del (vat_main_t * vam)
7065 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7066 vl_api_mac_address_t mac = { 0 };
7067 unformat_input_t *i = vam->input;
7068 vl_api_bd_ip_mac_add_del_t *mp;
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))
7084 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7088 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7092 else if (unformat (i, "del"))
7100 errmsg ("missing bridge domain");
7103 else if (ip_set == 0)
7105 errmsg ("missing IP address");
7108 else if (mac_set == 0)
7110 errmsg ("missing MAC address");
7114 M (BD_IP_MAC_ADD_DEL, mp);
7116 mp->entry.bd_id = ntohl (bd_id);
7117 mp->is_add = is_add;
7119 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7120 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7128 api_bd_ip_mac_flush (vat_main_t * vam)
7130 unformat_input_t *i = vam->input;
7131 vl_api_bd_ip_mac_flush_t *mp;
7136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7138 if (unformat (i, "bd_id %d", &bd_id))
7148 errmsg ("missing bridge domain");
7152 M (BD_IP_MAC_FLUSH, mp);
7154 mp->bd_id = ntohl (bd_id);
7161 static void vl_api_bd_ip_mac_details_t_handler
7162 (vl_api_bd_ip_mac_details_t * mp)
7164 vat_main_t *vam = &vat_main;
7168 ntohl (mp->entry.bd_id),
7169 format_vl_api_mac_address, mp->entry.mac,
7170 format_vl_api_address, &mp->entry.ip);
7173 static void vl_api_bd_ip_mac_details_t_handler_json
7174 (vl_api_bd_ip_mac_details_t * mp)
7176 vat_main_t *vam = &vat_main;
7177 vat_json_node_t *node = NULL;
7179 if (VAT_JSON_ARRAY != vam->json_tree.type)
7181 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7182 vat_json_init_array (&vam->json_tree);
7184 node = vat_json_array_add (&vam->json_tree);
7186 vat_json_init_object (node);
7187 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7188 vat_json_object_add_string_copy (node, "mac_address",
7189 format (0, "%U", format_vl_api_mac_address,
7193 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7194 vat_json_object_add_string_copy (node, "ip_address", ip);
7199 api_bd_ip_mac_dump (vat_main_t * vam)
7201 unformat_input_t *i = vam->input;
7202 vl_api_bd_ip_mac_dump_t *mp;
7203 vl_api_control_ping_t *mp_ping;
7208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7210 if (unformat (i, "bd_id %d", &bd_id))
7219 "\n%-5s %-7s %-20s %-30s",
7220 "bd_id", "is_ipv6", "mac_address", "ip_address");
7222 /* Dump Bridge Domain Ip to Mac entries */
7223 M (BD_IP_MAC_DUMP, mp);
7226 mp->bd_id = htonl (bd_id);
7232 /* Use a control ping for synchronization */
7233 MPING (CONTROL_PING, mp_ping);
7241 api_tap_create_v2 (vat_main_t * vam)
7243 unformat_input_t *i = vam->input;
7244 vl_api_tap_create_v2_t *mp;
7248 u32 num_rx_queues = 0;
7249 u8 *host_if_name = 0;
7250 u8 host_if_name_set = 0;
7253 u8 host_mac_addr[6];
7254 u8 host_mac_addr_set = 0;
7255 u8 *host_bridge = 0;
7256 u8 host_bridge_set = 0;
7257 u8 host_ip4_prefix_set = 0;
7258 u8 host_ip6_prefix_set = 0;
7259 ip4_address_t host_ip4_addr;
7260 ip4_address_t host_ip4_gw;
7261 u8 host_ip4_gw_set = 0;
7262 u32 host_ip4_prefix_len = 0;
7263 ip6_address_t host_ip6_addr;
7264 ip6_address_t host_ip6_gw;
7265 u8 host_ip6_gw_set = 0;
7266 u32 host_ip6_prefix_len = 0;
7267 u32 host_mtu_size = 0;
7268 u8 host_mtu_set = 0;
7271 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7273 clib_memset (mac_address, 0, sizeof (mac_address));
7275 /* Parse args required to build the message */
7276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7278 if (unformat (i, "id %u", &id))
7282 (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7284 else if (unformat (i, "host-if-name %s", &host_if_name))
7285 host_if_name_set = 1;
7286 else if (unformat (i, "num-rx-queues %u", &num_rx_queues))
7288 else if (unformat (i, "host-ns %s", &host_ns))
7290 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7292 host_mac_addr_set = 1;
7293 else if (unformat (i, "host-bridge %s", &host_bridge))
7294 host_bridge_set = 1;
7295 else if (unformat (i, "host-ip4-addr %U/%u", unformat_ip4_address,
7296 &host_ip4_addr, &host_ip4_prefix_len))
7297 host_ip4_prefix_set = 1;
7298 else if (unformat (i, "host-ip6-addr %U/%u", unformat_ip6_address,
7299 &host_ip6_addr, &host_ip6_prefix_len))
7300 host_ip6_prefix_set = 1;
7301 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7303 host_ip4_gw_set = 1;
7304 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7306 host_ip6_gw_set = 1;
7307 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
7309 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
7311 else if (unformat (i, "host-mtu-size %u", &host_mtu_size))
7313 else if (unformat (i, "no-gso"))
7314 tap_flags &= ~TAP_API_FLAG_GSO;
7315 else if (unformat (i, "gso"))
7316 tap_flags |= TAP_API_FLAG_GSO;
7317 else if (unformat (i, "csum-offload"))
7318 tap_flags |= TAP_API_FLAG_CSUM_OFFLOAD;
7319 else if (unformat (i, "persist"))
7320 tap_flags |= TAP_API_FLAG_PERSIST;
7321 else if (unformat (i, "attach"))
7322 tap_flags |= TAP_API_FLAG_ATTACH;
7323 else if (unformat (i, "tun"))
7324 tap_flags |= TAP_API_FLAG_TUN;
7325 else if (unformat (i, "gro-coalesce"))
7326 tap_flags |= TAP_API_FLAG_GRO_COALESCE;
7327 else if (unformat (i, "packed"))
7328 tap_flags |= TAP_API_FLAG_PACKED;
7329 else if (unformat (i, "in-order"))
7330 tap_flags |= TAP_API_FLAG_IN_ORDER;
7335 if (vec_len (host_if_name) > 63)
7337 errmsg ("tap name too long. ");
7340 if (vec_len (host_ns) > 63)
7342 errmsg ("host name space too long. ");
7345 if (vec_len (host_bridge) > 63)
7347 errmsg ("host bridge name too long. ");
7350 if (host_ip4_prefix_len > 32)
7352 errmsg ("host ip4 prefix length not valid. ");
7355 if (host_ip6_prefix_len > 128)
7357 errmsg ("host ip6 prefix length not valid. ");
7360 if (!is_pow2 (rx_ring_sz))
7362 errmsg ("rx ring size must be power of 2. ");
7365 if (rx_ring_sz > 32768)
7367 errmsg ("rx ring size must be 32768 or lower. ");
7370 if (!is_pow2 (tx_ring_sz))
7372 errmsg ("tx ring size must be power of 2. ");
7375 if (tx_ring_sz > 32768)
7377 errmsg ("tx ring size must be 32768 or lower. ");
7380 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7382 errmsg ("host MTU size must be in between 64 and 65355. ");
7386 /* Construct the API message */
7387 M (TAP_CREATE_V2, mp);
7389 mp->id = ntohl (id);
7390 mp->use_random_mac = random_mac;
7391 mp->num_rx_queues = (u8) num_rx_queues;
7392 mp->tx_ring_sz = ntohs (tx_ring_sz);
7393 mp->rx_ring_sz = ntohs (rx_ring_sz);
7394 mp->host_mtu_set = host_mtu_set;
7395 mp->host_mtu_size = ntohl (host_mtu_size);
7396 mp->host_mac_addr_set = host_mac_addr_set;
7397 mp->host_ip4_prefix_set = host_ip4_prefix_set;
7398 mp->host_ip6_prefix_set = host_ip6_prefix_set;
7399 mp->host_ip4_gw_set = host_ip4_gw_set;
7400 mp->host_ip6_gw_set = host_ip6_gw_set;
7401 mp->tap_flags = ntohl (tap_flags);
7402 mp->host_namespace_set = host_ns_set;
7403 mp->host_if_name_set = host_if_name_set;
7404 mp->host_bridge_set = host_bridge_set;
7406 if (random_mac == 0)
7407 clib_memcpy (mp->mac_address, mac_address, 6);
7408 if (host_mac_addr_set)
7409 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7410 if (host_if_name_set)
7411 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7413 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7414 if (host_bridge_set)
7415 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7416 if (host_ip4_prefix_set)
7418 clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
7419 mp->host_ip4_prefix.len = (u8) host_ip4_prefix_len;
7421 if (host_ip6_prefix_set)
7423 clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
7424 mp->host_ip6_prefix.len = (u8) host_ip6_prefix_len;
7426 if (host_ip4_gw_set)
7427 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7428 if (host_ip6_gw_set)
7429 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7432 vec_free (host_if_name);
7433 vec_free (host_bridge);
7438 /* Wait for a reply... */
7444 api_tap_delete_v2 (vat_main_t * vam)
7446 unformat_input_t *i = vam->input;
7447 vl_api_tap_delete_v2_t *mp;
7448 u32 sw_if_index = ~0;
7449 u8 sw_if_index_set = 0;
7452 /* Parse args required to build the message */
7453 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7455 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7456 sw_if_index_set = 1;
7457 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7458 sw_if_index_set = 1;
7463 if (sw_if_index_set == 0)
7465 errmsg ("missing vpp interface name. ");
7469 /* Construct the API message */
7470 M (TAP_DELETE_V2, mp);
7472 mp->sw_if_index = ntohl (sw_if_index);
7477 /* Wait for a reply... */
7483 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7485 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7488 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7491 addr->domain = x[0];
7494 addr->function = x[3];
7500 api_virtio_pci_create_v2 (vat_main_t * vam)
7502 unformat_input_t *i = vam->input;
7503 vl_api_virtio_pci_create_v2_t *mp;
7507 u64 features = (u64) ~ (0ULL);
7508 u32 virtio_flags = 0;
7511 clib_memset (mac_address, 0, sizeof (mac_address));
7513 /* Parse args required to build the message */
7514 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7516 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7520 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7522 else if (unformat (i, "features 0x%llx", &features))
7524 else if (unformat (i, "gso-enabled"))
7525 virtio_flags |= VIRTIO_API_FLAG_GSO;
7526 else if (unformat (i, "csum-offload-enabled"))
7527 virtio_flags |= VIRTIO_API_FLAG_CSUM_OFFLOAD;
7528 else if (unformat (i, "gro-coalesce"))
7529 virtio_flags |= VIRTIO_API_FLAG_GRO_COALESCE;
7530 else if (unformat (i, "packed"))
7531 virtio_flags |= VIRTIO_API_FLAG_PACKED;
7532 else if (unformat (i, "in-order"))
7533 virtio_flags |= VIRTIO_API_FLAG_IN_ORDER;
7540 errmsg ("pci address must be non zero. ");
7544 /* Construct the API message */
7545 M (VIRTIO_PCI_CREATE_V2, mp);
7547 mp->use_random_mac = random_mac;
7549 mp->pci_addr.domain = htons (((vlib_pci_addr_t) pci_addr).domain);
7550 mp->pci_addr.bus = ((vlib_pci_addr_t) pci_addr).bus;
7551 mp->pci_addr.slot = ((vlib_pci_addr_t) pci_addr).slot;
7552 mp->pci_addr.function = ((vlib_pci_addr_t) pci_addr).function;
7554 mp->features = clib_host_to_net_u64 (features);
7555 mp->virtio_flags = clib_host_to_net_u32 (virtio_flags);
7557 if (random_mac == 0)
7558 clib_memcpy (mp->mac_address, mac_address, 6);
7563 /* Wait for a reply... */
7569 api_virtio_pci_delete (vat_main_t * vam)
7571 unformat_input_t *i = vam->input;
7572 vl_api_virtio_pci_delete_t *mp;
7573 u32 sw_if_index = ~0;
7574 u8 sw_if_index_set = 0;
7577 /* Parse args required to build the message */
7578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7580 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7581 sw_if_index_set = 1;
7582 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7583 sw_if_index_set = 1;
7588 if (sw_if_index_set == 0)
7590 errmsg ("missing vpp interface name. ");
7594 /* Construct the API message */
7595 M (VIRTIO_PCI_DELETE, mp);
7597 mp->sw_if_index = htonl (sw_if_index);
7602 /* Wait for a reply... */
7608 api_bond_create (vat_main_t * vam)
7610 unformat_input_t *i = vam->input;
7611 vl_api_bond_create_t *mp;
7621 clib_memset (mac_address, 0, sizeof (mac_address));
7624 /* Parse args required to build the message */
7625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7627 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7629 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7630 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7632 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7635 else if (unformat (i, "numa-only"))
7637 else if (unformat (i, "id %u", &id))
7643 if (mode_is_set == 0)
7645 errmsg ("Missing bond mode. ");
7649 /* Construct the API message */
7650 M (BOND_CREATE, mp);
7652 mp->use_custom_mac = custom_mac;
7654 mp->mode = htonl (mode);
7655 mp->lb = htonl (lb);
7656 mp->id = htonl (id);
7657 mp->numa_only = numa_only;
7660 clib_memcpy (mp->mac_address, mac_address, 6);
7665 /* Wait for a reply... */
7671 api_bond_create2 (vat_main_t * vam)
7673 unformat_input_t *i = vam->input;
7674 vl_api_bond_create2_t *mp;
7685 clib_memset (mac_address, 0, sizeof (mac_address));
7688 /* Parse args required to build the message */
7689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7691 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7693 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7694 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7696 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7699 else if (unformat (i, "numa-only"))
7701 else if (unformat (i, "gso"))
7703 else if (unformat (i, "id %u", &id))
7709 if (mode_is_set == 0)
7711 errmsg ("Missing bond mode. ");
7715 /* Construct the API message */
7716 M (BOND_CREATE2, mp);
7718 mp->use_custom_mac = custom_mac;
7720 mp->mode = htonl (mode);
7721 mp->lb = htonl (lb);
7722 mp->id = htonl (id);
7723 mp->numa_only = numa_only;
7724 mp->enable_gso = gso;
7727 clib_memcpy (mp->mac_address, mac_address, 6);
7732 /* Wait for a reply... */
7738 api_bond_delete (vat_main_t * vam)
7740 unformat_input_t *i = vam->input;
7741 vl_api_bond_delete_t *mp;
7742 u32 sw_if_index = ~0;
7743 u8 sw_if_index_set = 0;
7746 /* Parse args required to build the message */
7747 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7749 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7750 sw_if_index_set = 1;
7751 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7752 sw_if_index_set = 1;
7757 if (sw_if_index_set == 0)
7759 errmsg ("missing vpp interface name. ");
7763 /* Construct the API message */
7764 M (BOND_DELETE, mp);
7766 mp->sw_if_index = ntohl (sw_if_index);
7771 /* Wait for a reply... */
7777 api_bond_add_member (vat_main_t * vam)
7779 unformat_input_t *i = vam->input;
7780 vl_api_bond_add_member_t *mp;
7781 u32 bond_sw_if_index;
7785 u32 bond_sw_if_index_is_set = 0;
7787 u8 sw_if_index_is_set = 0;
7789 /* Parse args required to build the message */
7790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7792 if (unformat (i, "sw_if_index %d", &sw_if_index))
7793 sw_if_index_is_set = 1;
7794 else if (unformat (i, "bond %u", &bond_sw_if_index))
7795 bond_sw_if_index_is_set = 1;
7796 else if (unformat (i, "passive %d", &is_passive))
7798 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7804 if (bond_sw_if_index_is_set == 0)
7806 errmsg ("Missing bond sw_if_index. ");
7809 if (sw_if_index_is_set == 0)
7811 errmsg ("Missing member sw_if_index. ");
7815 /* Construct the API message */
7816 M (BOND_ADD_MEMBER, mp);
7818 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7819 mp->sw_if_index = ntohl (sw_if_index);
7820 mp->is_long_timeout = is_long_timeout;
7821 mp->is_passive = is_passive;
7826 /* Wait for a reply... */
7832 api_bond_detach_member (vat_main_t * vam)
7834 unformat_input_t *i = vam->input;
7835 vl_api_bond_detach_member_t *mp;
7836 u32 sw_if_index = ~0;
7837 u8 sw_if_index_set = 0;
7840 /* Parse args required to build the message */
7841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7843 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7844 sw_if_index_set = 1;
7845 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7846 sw_if_index_set = 1;
7851 if (sw_if_index_set == 0)
7853 errmsg ("missing vpp interface name. ");
7857 /* Construct the API message */
7858 M (BOND_DETACH_MEMBER, mp);
7860 mp->sw_if_index = ntohl (sw_if_index);
7865 /* Wait for a reply... */
7871 api_ip_table_add_del (vat_main_t * vam)
7873 unformat_input_t *i = vam->input;
7874 vl_api_ip_table_add_del_t *mp;
7880 /* Parse args required to build the message */
7881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7883 if (unformat (i, "ipv6"))
7885 else if (unformat (i, "del"))
7887 else if (unformat (i, "add"))
7889 else if (unformat (i, "table %d", &table_id))
7893 clib_warning ("parse error '%U'", format_unformat_error, i);
7900 errmsg ("missing table-ID");
7904 /* Construct the API message */
7905 M (IP_TABLE_ADD_DEL, mp);
7907 mp->table.table_id = ntohl (table_id);
7908 mp->table.is_ip6 = is_ipv6;
7909 mp->is_add = is_add;
7914 /* Wait for a reply... */
7921 unformat_fib_path (unformat_input_t * input, va_list * args)
7923 vat_main_t *vam = va_arg (*args, vat_main_t *);
7924 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7925 u32 weight, preference;
7926 mpls_label_t out_label;
7928 clib_memset (path, 0, sizeof (*path));
7930 path->sw_if_index = ~0;
7934 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7936 if (unformat (input, "%U %U",
7937 unformat_vl_api_ip4_address,
7938 &path->nh.address.ip4,
7939 api_unformat_sw_if_index, vam, &path->sw_if_index))
7941 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7943 else if (unformat (input, "%U %U",
7944 unformat_vl_api_ip6_address,
7945 &path->nh.address.ip6,
7946 api_unformat_sw_if_index, vam, &path->sw_if_index))
7948 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7950 else if (unformat (input, "weight %u", &weight))
7952 path->weight = weight;
7954 else if (unformat (input, "preference %u", &preference))
7956 path->preference = preference;
7958 else if (unformat (input, "%U next-hop-table %d",
7959 unformat_vl_api_ip4_address,
7960 &path->nh.address.ip4, &path->table_id))
7962 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7964 else if (unformat (input, "%U next-hop-table %d",
7965 unformat_vl_api_ip6_address,
7966 &path->nh.address.ip6, &path->table_id))
7968 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7970 else if (unformat (input, "%U",
7971 unformat_vl_api_ip4_address, &path->nh.address.ip4))
7974 * the recursive next-hops are by default in the default table
7977 path->sw_if_index = ~0;
7978 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7980 else if (unformat (input, "%U",
7981 unformat_vl_api_ip6_address, &path->nh.address.ip6))
7984 * the recursive next-hops are by default in the default table
7987 path->sw_if_index = ~0;
7988 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7990 else if (unformat (input, "resolve-via-host"))
7992 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
7994 else if (unformat (input, "resolve-via-attached"))
7996 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
7998 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
8000 path->type = FIB_API_PATH_TYPE_LOCAL;
8001 path->sw_if_index = ~0;
8002 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8004 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
8006 path->type = FIB_API_PATH_TYPE_LOCAL;
8007 path->sw_if_index = ~0;
8008 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8010 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8012 else if (unformat (input, "via-label %d", &path->nh.via_label))
8014 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8015 path->sw_if_index = ~0;
8017 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8019 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8020 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8022 else if (unformat (input, "local"))
8024 path->type = FIB_API_PATH_TYPE_LOCAL;
8026 else if (unformat (input, "out-labels"))
8028 while (unformat (input, "%d", &out_label))
8030 path->label_stack[path->n_labels].label = out_label;
8031 path->label_stack[path->n_labels].is_uniform = 0;
8032 path->label_stack[path->n_labels].ttl = 64;
8036 else if (unformat (input, "via"))
8038 /* new path, back up and return */
8039 unformat_put_input (input);
8040 unformat_put_input (input);
8041 unformat_put_input (input);
8042 unformat_put_input (input);
8051 path->proto = ntohl (path->proto);
8052 path->type = ntohl (path->type);
8053 path->flags = ntohl (path->flags);
8054 path->table_id = ntohl (path->table_id);
8055 path->sw_if_index = ntohl (path->sw_if_index);
8061 api_ip_route_add_del (vat_main_t * vam)
8063 unformat_input_t *i = vam->input;
8064 vl_api_ip_route_add_del_t *mp;
8067 u8 is_multipath = 0;
8070 vl_api_prefix_t pfx = { };
8071 vl_api_fib_path_t paths[8];
8075 u32 random_add_del = 0;
8076 u32 *random_vector = 0;
8077 u32 random_seed = 0xdeaddabe;
8079 /* Parse args required to build the message */
8080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8082 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8084 else if (unformat (i, "del"))
8086 else if (unformat (i, "add"))
8088 else if (unformat (i, "vrf %d", &vrf_id))
8090 else if (unformat (i, "count %d", &count))
8092 else if (unformat (i, "random"))
8094 else if (unformat (i, "multipath"))
8096 else if (unformat (i, "seed %d", &random_seed))
8100 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8103 if (8 == path_count)
8105 errmsg ("max 8 paths");
8111 clib_warning ("parse error '%U'", format_unformat_error, i);
8118 errmsg ("specify a path; via ...");
8121 if (prefix_set == 0)
8123 errmsg ("missing prefix");
8127 /* Generate a pile of unique, random routes */
8130 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8131 u32 this_random_address;
8134 random_hash = hash_create (count, sizeof (uword));
8136 hash_set (random_hash, i->as_u32, 1);
8137 for (j = 0; j <= count; j++)
8141 this_random_address = random_u32 (&random_seed);
8142 this_random_address =
8143 clib_host_to_net_u32 (this_random_address);
8145 while (hash_get (random_hash, this_random_address));
8146 vec_add1 (random_vector, this_random_address);
8147 hash_set (random_hash, this_random_address, 1);
8149 hash_free (random_hash);
8150 set_ip4_address (&pfx.address, random_vector[0]);
8155 /* Turn on async mode */
8156 vam->async_mode = 1;
8157 vam->async_errors = 0;
8158 before = vat_time_now (vam);
8161 for (j = 0; j < count; j++)
8163 /* Construct the API message */
8164 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8166 mp->is_add = is_add;
8167 mp->is_multipath = is_multipath;
8169 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8170 mp->route.table_id = ntohl (vrf_id);
8171 mp->route.n_paths = path_count;
8173 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8176 set_ip4_address (&pfx.address, random_vector[j + 1]);
8178 increment_address (&pfx.address);
8181 /* If we receive SIGTERM, stop now... */
8186 /* When testing multiple add/del ops, use a control-ping to sync */
8189 vl_api_control_ping_t *mp_ping;
8193 /* Shut off async mode */
8194 vam->async_mode = 0;
8196 MPING (CONTROL_PING, mp_ping);
8199 timeout = vat_time_now (vam) + 1.0;
8200 while (vat_time_now (vam) < timeout)
8201 if (vam->result_ready == 1)
8206 if (vam->retval == -99)
8209 if (vam->async_errors > 0)
8211 errmsg ("%d asynchronous errors", vam->async_errors);
8214 vam->async_errors = 0;
8215 after = vat_time_now (vam);
8217 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8221 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8222 count, after - before, count / (after - before));
8228 /* Wait for a reply... */
8233 /* Return the good/bad news */
8234 return (vam->retval);
8238 api_ip_mroute_add_del (vat_main_t * vam)
8240 unformat_input_t *i = vam->input;
8241 u8 path_set = 0, prefix_set = 0, is_add = 1;
8242 vl_api_ip_mroute_add_del_t *mp;
8243 mfib_entry_flags_t eflags = 0;
8244 vl_api_mfib_path_t path;
8245 vl_api_mprefix_t pfx = { };
8249 /* Parse args required to build the message */
8250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8252 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8255 pfx.grp_address_length = htons (pfx.grp_address_length);
8257 else if (unformat (i, "del"))
8259 else if (unformat (i, "add"))
8261 else if (unformat (i, "vrf %d", &vrf_id))
8263 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8264 path.itf_flags = htonl (path.itf_flags);
8265 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8267 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8271 clib_warning ("parse error '%U'", format_unformat_error, i);
8276 if (prefix_set == 0)
8278 errmsg ("missing addresses\n");
8283 errmsg ("missing path\n");
8287 /* Construct the API message */
8288 M (IP_MROUTE_ADD_DEL, mp);
8290 mp->is_add = is_add;
8291 mp->is_multipath = 1;
8293 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8294 mp->route.table_id = htonl (vrf_id);
8295 mp->route.n_paths = 1;
8296 mp->route.entry_flags = htonl (eflags);
8298 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8302 /* Wait for a reply... */
8308 api_mpls_table_add_del (vat_main_t * vam)
8310 unformat_input_t *i = vam->input;
8311 vl_api_mpls_table_add_del_t *mp;
8316 /* Parse args required to build the message */
8317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8319 if (unformat (i, "table %d", &table_id))
8321 else if (unformat (i, "del"))
8323 else if (unformat (i, "add"))
8327 clib_warning ("parse error '%U'", format_unformat_error, i);
8334 errmsg ("missing table-ID");
8338 /* Construct the API message */
8339 M (MPLS_TABLE_ADD_DEL, mp);
8341 mp->mt_table.mt_table_id = ntohl (table_id);
8342 mp->mt_is_add = is_add;
8347 /* Wait for a reply... */
8354 api_mpls_route_add_del (vat_main_t * vam)
8356 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8357 mpls_label_t local_label = MPLS_LABEL_INVALID;
8358 unformat_input_t *i = vam->input;
8359 vl_api_mpls_route_add_del_t *mp;
8360 vl_api_fib_path_t paths[8];
8364 /* Parse args required to build the message */
8365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8367 if (unformat (i, "%d", &local_label))
8369 else if (unformat (i, "eos"))
8371 else if (unformat (i, "non-eos"))
8373 else if (unformat (i, "del"))
8375 else if (unformat (i, "add"))
8377 else if (unformat (i, "multipath"))
8379 else if (unformat (i, "count %d", &count))
8383 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8386 if (8 == path_count)
8388 errmsg ("max 8 paths");
8394 clib_warning ("parse error '%U'", format_unformat_error, i);
8401 errmsg ("specify a path; via ...");
8405 if (MPLS_LABEL_INVALID == local_label)
8407 errmsg ("missing label");
8413 /* Turn on async mode */
8414 vam->async_mode = 1;
8415 vam->async_errors = 0;
8416 before = vat_time_now (vam);
8419 for (j = 0; j < count; j++)
8421 /* Construct the API message */
8422 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8424 mp->mr_is_add = is_add;
8425 mp->mr_is_multipath = is_multipath;
8427 mp->mr_route.mr_label = local_label;
8428 mp->mr_route.mr_eos = is_eos;
8429 mp->mr_route.mr_table_id = 0;
8430 mp->mr_route.mr_n_paths = path_count;
8432 clib_memcpy (&mp->mr_route.mr_paths, paths,
8433 sizeof (paths[0]) * path_count);
8439 /* If we receive SIGTERM, stop now... */
8444 /* When testing multiple add/del ops, use a control-ping to sync */
8447 vl_api_control_ping_t *mp_ping;
8451 /* Shut off async mode */
8452 vam->async_mode = 0;
8454 MPING (CONTROL_PING, mp_ping);
8457 timeout = vat_time_now (vam) + 1.0;
8458 while (vat_time_now (vam) < timeout)
8459 if (vam->result_ready == 1)
8464 if (vam->retval == -99)
8467 if (vam->async_errors > 0)
8469 errmsg ("%d asynchronous errors", vam->async_errors);
8472 vam->async_errors = 0;
8473 after = vat_time_now (vam);
8475 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8479 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8480 count, after - before, count / (after - before));
8486 /* Wait for a reply... */
8491 /* Return the good/bad news */
8492 return (vam->retval);
8497 api_mpls_ip_bind_unbind (vat_main_t * vam)
8499 unformat_input_t *i = vam->input;
8500 vl_api_mpls_ip_bind_unbind_t *mp;
8501 u32 ip_table_id = 0;
8503 vl_api_prefix_t pfx;
8505 mpls_label_t local_label = MPLS_LABEL_INVALID;
8508 /* Parse args required to build the message */
8509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8511 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8513 else if (unformat (i, "%d", &local_label))
8515 else if (unformat (i, "table-id %d", &ip_table_id))
8517 else if (unformat (i, "unbind"))
8519 else if (unformat (i, "bind"))
8523 clib_warning ("parse error '%U'", format_unformat_error, i);
8530 errmsg ("IP prefix not set");
8534 if (MPLS_LABEL_INVALID == local_label)
8536 errmsg ("missing label");
8540 /* Construct the API message */
8541 M (MPLS_IP_BIND_UNBIND, mp);
8543 mp->mb_is_bind = is_bind;
8544 mp->mb_ip_table_id = ntohl (ip_table_id);
8545 mp->mb_mpls_table_id = 0;
8546 mp->mb_label = ntohl (local_label);
8547 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8552 /* Wait for a reply... */
8559 api_sr_mpls_policy_add (vat_main_t * vam)
8561 unformat_input_t *i = vam->input;
8562 vl_api_sr_mpls_policy_add_t *mp;
8568 u32 *segments = NULL;
8571 /* Parse args required to build the message */
8572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8574 if (unformat (i, "bsid %d", &bsid))
8576 else if (unformat (i, "weight %d", &weight))
8578 else if (unformat (i, "spray"))
8580 else if (unformat (i, "next %d", &sid))
8583 vec_add1 (segments, htonl (sid));
8587 clib_warning ("parse error '%U'", format_unformat_error, i);
8594 errmsg ("bsid not set");
8598 if (n_segments == 0)
8600 errmsg ("no sid in segment stack");
8604 /* Construct the API message */
8605 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8607 mp->bsid = htonl (bsid);
8608 mp->weight = htonl (weight);
8609 mp->is_spray = type;
8610 mp->n_segments = n_segments;
8611 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8612 vec_free (segments);
8617 /* Wait for a reply... */
8623 api_sr_mpls_policy_del (vat_main_t * vam)
8625 unformat_input_t *i = vam->input;
8626 vl_api_sr_mpls_policy_del_t *mp;
8630 /* Parse args required to build the message */
8631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8633 if (unformat (i, "bsid %d", &bsid))
8637 clib_warning ("parse error '%U'", format_unformat_error, i);
8644 errmsg ("bsid not set");
8648 /* Construct the API message */
8649 M (SR_MPLS_POLICY_DEL, mp);
8651 mp->bsid = htonl (bsid);
8656 /* Wait for a reply... */
8662 api_bier_table_add_del (vat_main_t * vam)
8664 unformat_input_t *i = vam->input;
8665 vl_api_bier_table_add_del_t *mp;
8667 u32 set = 0, sub_domain = 0, hdr_len = 3;
8668 mpls_label_t local_label = MPLS_LABEL_INVALID;
8671 /* Parse args required to build the message */
8672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8674 if (unformat (i, "sub-domain %d", &sub_domain))
8676 else if (unformat (i, "set %d", &set))
8678 else if (unformat (i, "label %d", &local_label))
8680 else if (unformat (i, "hdr-len %d", &hdr_len))
8682 else if (unformat (i, "add"))
8684 else if (unformat (i, "del"))
8688 clib_warning ("parse error '%U'", format_unformat_error, i);
8693 if (MPLS_LABEL_INVALID == local_label)
8695 errmsg ("missing label\n");
8699 /* Construct the API message */
8700 M (BIER_TABLE_ADD_DEL, mp);
8702 mp->bt_is_add = is_add;
8703 mp->bt_label = ntohl (local_label);
8704 mp->bt_tbl_id.bt_set = set;
8705 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8706 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8711 /* Wait for a reply... */
8718 api_bier_route_add_del (vat_main_t * vam)
8720 unformat_input_t *i = vam->input;
8721 vl_api_bier_route_add_del_t *mp;
8723 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8724 ip4_address_t v4_next_hop_address;
8725 ip6_address_t v6_next_hop_address;
8726 u8 next_hop_set = 0;
8727 u8 next_hop_proto_is_ip4 = 1;
8728 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8731 /* Parse args required to build the message */
8732 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8734 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8736 next_hop_proto_is_ip4 = 1;
8739 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8741 next_hop_proto_is_ip4 = 0;
8744 if (unformat (i, "sub-domain %d", &sub_domain))
8746 else if (unformat (i, "set %d", &set))
8748 else if (unformat (i, "hdr-len %d", &hdr_len))
8750 else if (unformat (i, "bp %d", &bp))
8752 else if (unformat (i, "add"))
8754 else if (unformat (i, "del"))
8756 else if (unformat (i, "out-label %d", &next_hop_out_label))
8760 clib_warning ("parse error '%U'", format_unformat_error, i);
8765 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8767 errmsg ("next hop / label set\n");
8772 errmsg ("bit=position not set\n");
8776 /* Construct the API message */
8777 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8779 mp->br_is_add = is_add;
8780 mp->br_route.br_tbl_id.bt_set = set;
8781 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8782 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8783 mp->br_route.br_bp = ntohs (bp);
8784 mp->br_route.br_n_paths = 1;
8785 mp->br_route.br_paths[0].n_labels = 1;
8786 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8787 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8788 FIB_API_PATH_NH_PROTO_IP4 :
8789 FIB_API_PATH_NH_PROTO_IP6);
8791 if (next_hop_proto_is_ip4)
8793 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8794 &v4_next_hop_address, sizeof (v4_next_hop_address));
8798 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8799 &v6_next_hop_address, sizeof (v6_next_hop_address));
8805 /* Wait for a reply... */
8812 api_mpls_tunnel_add_del (vat_main_t * vam)
8814 unformat_input_t *i = vam->input;
8815 vl_api_mpls_tunnel_add_del_t *mp;
8817 vl_api_fib_path_t paths[8];
8818 u32 sw_if_index = ~0;
8824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8826 if (unformat (i, "add"))
8830 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8832 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8834 else if (unformat (i, "l2-only"))
8838 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8841 if (8 == path_count)
8843 errmsg ("max 8 paths");
8849 clib_warning ("parse error '%U'", format_unformat_error, i);
8854 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8856 mp->mt_is_add = is_add;
8857 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8858 mp->mt_tunnel.mt_l2_only = l2_only;
8859 mp->mt_tunnel.mt_is_multicast = 0;
8860 mp->mt_tunnel.mt_n_paths = path_count;
8862 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8863 sizeof (paths[0]) * path_count);
8871 api_sw_interface_set_unnumbered (vat_main_t * vam)
8873 unformat_input_t *i = vam->input;
8874 vl_api_sw_interface_set_unnumbered_t *mp;
8876 u32 unnum_sw_index = ~0;
8878 u8 sw_if_index_set = 0;
8881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8883 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8884 sw_if_index_set = 1;
8885 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8886 sw_if_index_set = 1;
8887 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8889 else if (unformat (i, "del"))
8893 clib_warning ("parse error '%U'", format_unformat_error, i);
8898 if (sw_if_index_set == 0)
8900 errmsg ("missing interface name or sw_if_index");
8904 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8906 mp->sw_if_index = ntohl (sw_if_index);
8907 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8908 mp->is_add = is_add;
8917 api_create_vlan_subif (vat_main_t * vam)
8919 unformat_input_t *i = vam->input;
8920 vl_api_create_vlan_subif_t *mp;
8922 u8 sw_if_index_set = 0;
8927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8929 if (unformat (i, "sw_if_index %d", &sw_if_index))
8930 sw_if_index_set = 1;
8932 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8933 sw_if_index_set = 1;
8934 else if (unformat (i, "vlan %d", &vlan_id))
8938 clib_warning ("parse error '%U'", format_unformat_error, i);
8943 if (sw_if_index_set == 0)
8945 errmsg ("missing interface name or sw_if_index");
8949 if (vlan_id_set == 0)
8951 errmsg ("missing vlan_id");
8954 M (CREATE_VLAN_SUBIF, mp);
8956 mp->sw_if_index = ntohl (sw_if_index);
8957 mp->vlan_id = ntohl (vlan_id);
8964 #define foreach_create_subif_bit \
8971 _(outer_vlan_id_any) \
8972 _(inner_vlan_id_any)
8974 #define foreach_create_subif_flag \
8979 _(4, "exact_match") \
8980 _(5, "default_sub") \
8981 _(6, "outer_vlan_id_any") \
8982 _(7, "inner_vlan_id_any")
8985 api_create_subif (vat_main_t * vam)
8987 unformat_input_t *i = vam->input;
8988 vl_api_create_subif_t *mp;
8990 u8 sw_if_index_set = 0;
8993 u32 __attribute__ ((unused)) no_tags = 0;
8994 u32 __attribute__ ((unused)) one_tag = 0;
8995 u32 __attribute__ ((unused)) two_tags = 0;
8996 u32 __attribute__ ((unused)) dot1ad = 0;
8997 u32 __attribute__ ((unused)) exact_match = 0;
8998 u32 __attribute__ ((unused)) default_sub = 0;
8999 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
9000 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
9002 u16 outer_vlan_id = 0;
9003 u16 inner_vlan_id = 0;
9006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9008 if (unformat (i, "sw_if_index %d", &sw_if_index))
9009 sw_if_index_set = 1;
9011 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9012 sw_if_index_set = 1;
9013 else if (unformat (i, "sub_id %d", &sub_id))
9015 else if (unformat (i, "outer_vlan_id %d", &tmp))
9016 outer_vlan_id = tmp;
9017 else if (unformat (i, "inner_vlan_id %d", &tmp))
9018 inner_vlan_id = tmp;
9020 #define _(a) else if (unformat (i, #a)) a = 1 ;
9021 foreach_create_subif_bit
9025 clib_warning ("parse error '%U'", format_unformat_error, i);
9030 if (sw_if_index_set == 0)
9032 errmsg ("missing interface name or sw_if_index");
9036 if (sub_id_set == 0)
9038 errmsg ("missing sub_id");
9041 M (CREATE_SUBIF, mp);
9043 mp->sw_if_index = ntohl (sw_if_index);
9044 mp->sub_id = ntohl (sub_id);
9046 #define _(a,b) mp->sub_if_flags |= (1 << a);
9047 foreach_create_subif_flag;
9050 mp->outer_vlan_id = ntohs (outer_vlan_id);
9051 mp->inner_vlan_id = ntohs (inner_vlan_id);
9059 api_ip_table_replace_begin (vat_main_t * vam)
9061 unformat_input_t *i = vam->input;
9062 vl_api_ip_table_replace_begin_t *mp;
9067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9069 if (unformat (i, "table %d", &table_id))
9071 else if (unformat (i, "ipv6"))
9075 clib_warning ("parse error '%U'", format_unformat_error, i);
9080 M (IP_TABLE_REPLACE_BEGIN, mp);
9082 mp->table.table_id = ntohl (table_id);
9083 mp->table.is_ip6 = is_ipv6;
9091 api_ip_table_flush (vat_main_t * vam)
9093 unformat_input_t *i = vam->input;
9094 vl_api_ip_table_flush_t *mp;
9099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9101 if (unformat (i, "table %d", &table_id))
9103 else if (unformat (i, "ipv6"))
9107 clib_warning ("parse error '%U'", format_unformat_error, i);
9112 M (IP_TABLE_FLUSH, mp);
9114 mp->table.table_id = ntohl (table_id);
9115 mp->table.is_ip6 = is_ipv6;
9123 api_ip_table_replace_end (vat_main_t * vam)
9125 unformat_input_t *i = vam->input;
9126 vl_api_ip_table_replace_end_t *mp;
9131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9133 if (unformat (i, "table %d", &table_id))
9135 else if (unformat (i, "ipv6"))
9139 clib_warning ("parse error '%U'", format_unformat_error, i);
9144 M (IP_TABLE_REPLACE_END, mp);
9146 mp->table.table_id = ntohl (table_id);
9147 mp->table.is_ip6 = is_ipv6;
9155 api_set_ip_flow_hash (vat_main_t * vam)
9157 unformat_input_t *i = vam->input;
9158 vl_api_set_ip_flow_hash_t *mp;
9170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9172 if (unformat (i, "vrf %d", &vrf_id))
9174 else if (unformat (i, "ipv6"))
9176 else if (unformat (i, "src"))
9178 else if (unformat (i, "dst"))
9180 else if (unformat (i, "sport"))
9182 else if (unformat (i, "dport"))
9184 else if (unformat (i, "proto"))
9186 else if (unformat (i, "reverse"))
9191 clib_warning ("parse error '%U'", format_unformat_error, i);
9196 if (vrf_id_set == 0)
9198 errmsg ("missing vrf id");
9202 M (SET_IP_FLOW_HASH, mp);
9208 mp->reverse = reverse;
9209 mp->vrf_id = ntohl (vrf_id);
9210 mp->is_ipv6 = is_ipv6;
9218 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9220 unformat_input_t *i = vam->input;
9221 vl_api_sw_interface_ip6_enable_disable_t *mp;
9223 u8 sw_if_index_set = 0;
9227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9229 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9230 sw_if_index_set = 1;
9231 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9232 sw_if_index_set = 1;
9233 else if (unformat (i, "enable"))
9235 else if (unformat (i, "disable"))
9239 clib_warning ("parse error '%U'", format_unformat_error, i);
9244 if (sw_if_index_set == 0)
9246 errmsg ("missing interface name or sw_if_index");
9250 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9252 mp->sw_if_index = ntohl (sw_if_index);
9253 mp->enable = enable;
9262 api_l2_patch_add_del (vat_main_t * vam)
9264 unformat_input_t *i = vam->input;
9265 vl_api_l2_patch_add_del_t *mp;
9267 u8 rx_sw_if_index_set = 0;
9269 u8 tx_sw_if_index_set = 0;
9273 /* Parse args required to build the message */
9274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9276 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9277 rx_sw_if_index_set = 1;
9278 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9279 tx_sw_if_index_set = 1;
9280 else if (unformat (i, "rx"))
9282 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9284 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9286 rx_sw_if_index_set = 1;
9291 else if (unformat (i, "tx"))
9293 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9295 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9297 tx_sw_if_index_set = 1;
9302 else if (unformat (i, "del"))
9308 if (rx_sw_if_index_set == 0)
9310 errmsg ("missing rx interface name or rx_sw_if_index");
9314 if (tx_sw_if_index_set == 0)
9316 errmsg ("missing tx interface name or tx_sw_if_index");
9320 M (L2_PATCH_ADD_DEL, mp);
9322 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9323 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9324 mp->is_add = is_add;
9332 u8 localsid_addr[16];
9341 api_sr_localsid_add_del (vat_main_t * vam)
9343 unformat_input_t *i = vam->input;
9344 vl_api_sr_localsid_add_del_t *mp;
9347 ip6_address_t localsid;
9351 u32 fib_table = ~(u32) 0;
9352 ip46_address_t nh_addr;
9353 clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
9355 bool nexthop_set = 0;
9359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9361 if (unformat (i, "del"))
9363 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9364 else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
9366 else if (unformat (i, "behavior %u", &behavior));
9367 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9368 else if (unformat (i, "fib-table %u", &fib_table));
9369 else if (unformat (i, "end.psp %u", &behavior));
9374 M (SR_LOCALSID_ADD_DEL, mp);
9376 clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
9380 clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
9382 mp->behavior = behavior;
9383 mp->sw_if_index = ntohl (sw_if_index);
9384 mp->fib_table = ntohl (fib_table);
9385 mp->end_psp = end_psp;
9386 mp->is_del = is_del;
9394 api_ioam_enable (vat_main_t * vam)
9396 unformat_input_t *input = vam->input;
9397 vl_api_ioam_enable_t *mp;
9399 int has_trace_option = 0;
9400 int has_pot_option = 0;
9401 int has_seqno_option = 0;
9402 int has_analyse_option = 0;
9405 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9407 if (unformat (input, "trace"))
9408 has_trace_option = 1;
9409 else if (unformat (input, "pot"))
9411 else if (unformat (input, "seqno"))
9412 has_seqno_option = 1;
9413 else if (unformat (input, "analyse"))
9414 has_analyse_option = 1;
9418 M (IOAM_ENABLE, mp);
9419 mp->id = htons (id);
9420 mp->seqno = has_seqno_option;
9421 mp->analyse = has_analyse_option;
9422 mp->pot_enable = has_pot_option;
9423 mp->trace_enable = has_trace_option;
9432 api_ioam_disable (vat_main_t * vam)
9434 vl_api_ioam_disable_t *mp;
9437 M (IOAM_DISABLE, mp);
9443 #define foreach_tcp_proto_field \
9447 #define foreach_udp_proto_field \
9451 #define foreach_ip4_proto_field \
9463 u16 src_port, dst_port;
9466 #if VPP_API_TEST_BUILTIN == 0
9468 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9470 u8 **maskp = va_arg (*args, u8 **);
9472 u8 found_something = 0;
9475 #define _(a) u8 a=0;
9476 foreach_tcp_proto_field;
9479 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9482 #define _(a) else if (unformat (input, #a)) a=1;
9483 foreach_tcp_proto_field
9489 #define _(a) found_something += a;
9490 foreach_tcp_proto_field;
9493 if (found_something == 0)
9496 vec_validate (mask, sizeof (*tcp) - 1);
9498 tcp = (tcp_header_t *) mask;
9500 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
9501 foreach_tcp_proto_field;
9509 unformat_udp_mask (unformat_input_t * input, va_list * args)
9511 u8 **maskp = va_arg (*args, u8 **);
9513 u8 found_something = 0;
9516 #define _(a) u8 a=0;
9517 foreach_udp_proto_field;
9520 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9523 #define _(a) else if (unformat (input, #a)) a=1;
9524 foreach_udp_proto_field
9530 #define _(a) found_something += a;
9531 foreach_udp_proto_field;
9534 if (found_something == 0)
9537 vec_validate (mask, sizeof (*udp) - 1);
9539 udp = (udp_header_t *) mask;
9541 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
9542 foreach_udp_proto_field;
9550 unformat_l4_mask (unformat_input_t * input, va_list * args)
9552 u8 **maskp = va_arg (*args, u8 **);
9553 u16 src_port = 0, dst_port = 0;
9554 tcpudp_header_t *tcpudp;
9556 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9558 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9560 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9562 else if (unformat (input, "src_port"))
9564 else if (unformat (input, "dst_port"))
9570 if (!src_port && !dst_port)
9574 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9576 tcpudp = (tcpudp_header_t *) mask;
9577 tcpudp->src_port = src_port;
9578 tcpudp->dst_port = dst_port;
9586 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9588 u8 **maskp = va_arg (*args, u8 **);
9590 u8 found_something = 0;
9593 #define _(a) u8 a=0;
9594 foreach_ip4_proto_field;
9600 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9602 if (unformat (input, "version"))
9604 else if (unformat (input, "hdr_length"))
9606 else if (unformat (input, "src"))
9608 else if (unformat (input, "dst"))
9610 else if (unformat (input, "proto"))
9613 #define _(a) else if (unformat (input, #a)) a=1;
9614 foreach_ip4_proto_field
9620 #define _(a) found_something += a;
9621 foreach_ip4_proto_field;
9624 if (found_something == 0)
9627 vec_validate (mask, sizeof (*ip) - 1);
9629 ip = (ip4_header_t *) mask;
9631 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9632 foreach_ip4_proto_field;
9635 ip->ip_version_and_header_length = 0;
9638 ip->ip_version_and_header_length |= 0xF0;
9641 ip->ip_version_and_header_length |= 0x0F;
9647 #define foreach_ip6_proto_field \
9655 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9657 u8 **maskp = va_arg (*args, u8 **);
9659 u8 found_something = 0;
9661 u32 ip_version_traffic_class_and_flow_label;
9663 #define _(a) u8 a=0;
9664 foreach_ip6_proto_field;
9667 u8 traffic_class = 0;
9670 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9672 if (unformat (input, "version"))
9674 else if (unformat (input, "traffic-class"))
9676 else if (unformat (input, "flow-label"))
9678 else if (unformat (input, "src"))
9680 else if (unformat (input, "dst"))
9682 else if (unformat (input, "proto"))
9685 #define _(a) else if (unformat (input, #a)) a=1;
9686 foreach_ip6_proto_field
9692 #define _(a) found_something += a;
9693 foreach_ip6_proto_field;
9696 if (found_something == 0)
9699 vec_validate (mask, sizeof (*ip) - 1);
9701 ip = (ip6_header_t *) mask;
9703 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9704 foreach_ip6_proto_field;
9707 ip_version_traffic_class_and_flow_label = 0;
9710 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9713 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9716 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9718 ip->ip_version_traffic_class_and_flow_label =
9719 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9726 unformat_l3_mask (unformat_input_t * input, va_list * args)
9728 u8 **maskp = va_arg (*args, u8 **);
9730 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9732 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9734 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9743 unformat_l2_mask (unformat_input_t * input, va_list * args)
9745 u8 **maskp = va_arg (*args, u8 **);
9760 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9762 if (unformat (input, "src"))
9764 else if (unformat (input, "dst"))
9766 else if (unformat (input, "proto"))
9768 else if (unformat (input, "tag1"))
9770 else if (unformat (input, "tag2"))
9772 else if (unformat (input, "ignore-tag1"))
9774 else if (unformat (input, "ignore-tag2"))
9776 else if (unformat (input, "cos1"))
9778 else if (unformat (input, "cos2"))
9780 else if (unformat (input, "dot1q"))
9782 else if (unformat (input, "dot1ad"))
9787 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9788 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9791 if (tag1 || ignore_tag1 || cos1 || dot1q)
9793 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9796 vec_validate (mask, len - 1);
9799 clib_memset (mask, 0xff, 6);
9802 clib_memset (mask + 6, 0xff, 6);
9806 /* inner vlan tag */
9815 mask[21] = mask[20] = 0xff;
9836 mask[16] = mask[17] = 0xff;
9846 mask[12] = mask[13] = 0xff;
9853 unformat_classify_mask (unformat_input_t * input, va_list * args)
9855 u8 **maskp = va_arg (*args, u8 **);
9856 u32 *skipp = va_arg (*args, u32 *);
9857 u32 *matchp = va_arg (*args, u32 *);
9865 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9867 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9869 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9871 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9873 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9887 if (mask || l2 || l3 || l4)
9891 /* "With a free Ethernet header in every package" */
9893 vec_validate (l2, 13);
9897 vec_append (mask, l3);
9902 vec_append (mask, l4);
9907 /* Scan forward looking for the first significant mask octet */
9908 for (i = 0; i < vec_len (mask); i++)
9912 /* compute (skip, match) params */
9913 *skipp = i / sizeof (u32x4);
9914 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9916 /* Pad mask to an even multiple of the vector size */
9917 while (vec_len (mask) % sizeof (u32x4))
9920 match = vec_len (mask) / sizeof (u32x4);
9922 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9924 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9925 if (*tmp || *(tmp + 1))
9930 clib_warning ("BUG: match 0");
9932 _vec_len (mask) = match * sizeof (u32x4);
9942 #endif /* VPP_API_TEST_BUILTIN */
9944 #define foreach_l2_next \
9946 _(ethernet, ETHERNET_INPUT) \
9951 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9953 u32 *miss_next_indexp = va_arg (*args, u32 *);
9958 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9962 if (unformat (input, "%d", &tmp))
9971 *miss_next_indexp = next_index;
9975 #define foreach_ip_next \
9981 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9983 u32 *miss_next_indexp = va_arg (*args, u32 *);
9988 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9992 if (unformat (input, "%d", &tmp))
10001 *miss_next_indexp = next_index;
10005 #define foreach_acl_next \
10009 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10011 u32 *miss_next_indexp = va_arg (*args, u32 *);
10012 u32 next_index = 0;
10016 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10020 if (unformat (input, "permit"))
10025 else if (unformat (input, "%d", &tmp))
10034 *miss_next_indexp = next_index;
10039 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10041 u32 *r = va_arg (*args, u32 *);
10043 if (unformat (input, "conform-color"))
10044 *r = POLICE_CONFORM;
10045 else if (unformat (input, "exceed-color"))
10046 *r = POLICE_EXCEED;
10054 api_classify_add_del_table (vat_main_t * vam)
10056 unformat_input_t *i = vam->input;
10057 vl_api_classify_add_del_table_t *mp;
10064 u32 table_index = ~0;
10065 u32 next_table_index = ~0;
10066 u32 miss_next_index = ~0;
10067 u32 memory_size = 32 << 20;
10069 u32 current_data_flag = 0;
10070 int current_data_offset = 0;
10073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10075 if (unformat (i, "del"))
10077 else if (unformat (i, "del-chain"))
10082 else if (unformat (i, "buckets %d", &nbuckets))
10084 else if (unformat (i, "memory_size %d", &memory_size))
10086 else if (unformat (i, "skip %d", &skip))
10088 else if (unformat (i, "match %d", &match))
10090 else if (unformat (i, "table %d", &table_index))
10092 else if (unformat (i, "mask %U", unformat_classify_mask,
10093 &mask, &skip, &match))
10095 else if (unformat (i, "next-table %d", &next_table_index))
10097 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10100 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10103 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10106 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10108 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10114 if (is_add && mask == 0)
10116 errmsg ("Mask required");
10120 if (is_add && skip == ~0)
10122 errmsg ("skip count required");
10126 if (is_add && match == ~0)
10128 errmsg ("match count required");
10132 if (!is_add && table_index == ~0)
10134 errmsg ("table index required for delete");
10138 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10140 mp->is_add = is_add;
10141 mp->del_chain = del_chain;
10142 mp->table_index = ntohl (table_index);
10143 mp->nbuckets = ntohl (nbuckets);
10144 mp->memory_size = ntohl (memory_size);
10145 mp->skip_n_vectors = ntohl (skip);
10146 mp->match_n_vectors = ntohl (match);
10147 mp->next_table_index = ntohl (next_table_index);
10148 mp->miss_next_index = ntohl (miss_next_index);
10149 mp->current_data_flag = ntohl (current_data_flag);
10150 mp->current_data_offset = ntohl (current_data_offset);
10151 mp->mask_len = ntohl (vec_len (mask));
10152 clib_memcpy (mp->mask, mask, vec_len (mask));
10161 #if VPP_API_TEST_BUILTIN == 0
10163 unformat_l4_match (unformat_input_t * input, va_list * args)
10165 u8 **matchp = va_arg (*args, u8 **);
10167 u8 *proto_header = 0;
10173 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10175 if (unformat (input, "src_port %d", &src_port))
10177 else if (unformat (input, "dst_port %d", &dst_port))
10183 h.src_port = clib_host_to_net_u16 (src_port);
10184 h.dst_port = clib_host_to_net_u16 (dst_port);
10185 vec_validate (proto_header, sizeof (h) - 1);
10186 memcpy (proto_header, &h, sizeof (h));
10188 *matchp = proto_header;
10194 unformat_ip4_match (unformat_input_t * input, va_list * args)
10196 u8 **matchp = va_arg (*args, u8 **);
10201 int hdr_length = 0;
10202 u32 hdr_length_val;
10203 int src = 0, dst = 0;
10204 ip4_address_t src_val, dst_val;
10211 int fragment_id = 0;
10212 u32 fragment_id_val;
10218 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10220 if (unformat (input, "version %d", &version_val))
10222 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10224 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10226 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10228 else if (unformat (input, "proto %d", &proto_val))
10230 else if (unformat (input, "tos %d", &tos_val))
10232 else if (unformat (input, "length %d", &length_val))
10234 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10236 else if (unformat (input, "ttl %d", &ttl_val))
10238 else if (unformat (input, "checksum %d", &checksum_val))
10244 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10245 + ttl + checksum == 0)
10249 * Aligned because we use the real comparison functions
10251 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10253 ip = (ip4_header_t *) match;
10255 /* These are realistically matched in practice */
10257 ip->src_address.as_u32 = src_val.as_u32;
10260 ip->dst_address.as_u32 = dst_val.as_u32;
10263 ip->protocol = proto_val;
10266 /* These are not, but they're included for completeness */
10268 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10271 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10277 ip->length = clib_host_to_net_u16 (length_val);
10283 ip->checksum = clib_host_to_net_u16 (checksum_val);
10290 unformat_ip6_match (unformat_input_t * input, va_list * args)
10292 u8 **matchp = va_arg (*args, u8 **);
10297 u8 traffic_class = 0;
10298 u32 traffic_class_val = 0;
10301 int src = 0, dst = 0;
10302 ip6_address_t src_val, dst_val;
10305 int payload_length = 0;
10306 u32 payload_length_val;
10309 u32 ip_version_traffic_class_and_flow_label;
10311 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10313 if (unformat (input, "version %d", &version_val))
10315 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10317 else if (unformat (input, "flow_label %d", &flow_label_val))
10319 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10321 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10323 else if (unformat (input, "proto %d", &proto_val))
10325 else if (unformat (input, "payload_length %d", &payload_length_val))
10326 payload_length = 1;
10327 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10333 if (version + traffic_class + flow_label + src + dst + proto +
10334 payload_length + hop_limit == 0)
10338 * Aligned because we use the real comparison functions
10340 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10342 ip = (ip6_header_t *) match;
10345 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10348 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10351 ip->protocol = proto_val;
10353 ip_version_traffic_class_and_flow_label = 0;
10356 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10359 ip_version_traffic_class_and_flow_label |=
10360 (traffic_class_val & 0xFF) << 20;
10363 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10365 ip->ip_version_traffic_class_and_flow_label =
10366 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10368 if (payload_length)
10369 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10372 ip->hop_limit = hop_limit_val;
10379 unformat_l3_match (unformat_input_t * input, va_list * args)
10381 u8 **matchp = va_arg (*args, u8 **);
10383 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10385 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10387 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10396 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10398 u8 *tagp = va_arg (*args, u8 *);
10401 if (unformat (input, "%d", &tag))
10403 tagp[0] = (tag >> 8) & 0x0F;
10404 tagp[1] = tag & 0xFF;
10412 unformat_l2_match (unformat_input_t * input, va_list * args)
10414 u8 **matchp = va_arg (*args, u8 **);
10427 u8 ignore_tag1 = 0;
10428 u8 ignore_tag2 = 0;
10434 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10436 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10439 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10441 else if (unformat (input, "proto %U",
10442 unformat_ethernet_type_host_byte_order, &proto_val))
10444 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10446 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10448 else if (unformat (input, "ignore-tag1"))
10450 else if (unformat (input, "ignore-tag2"))
10452 else if (unformat (input, "cos1 %d", &cos1_val))
10454 else if (unformat (input, "cos2 %d", &cos2_val))
10459 if ((src + dst + proto + tag1 + tag2 +
10460 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10463 if (tag1 || ignore_tag1 || cos1)
10465 if (tag2 || ignore_tag2 || cos2)
10468 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10471 clib_memcpy (match, dst_val, 6);
10474 clib_memcpy (match + 6, src_val, 6);
10478 /* inner vlan tag */
10479 match[19] = tag2_val[1];
10480 match[18] = tag2_val[0];
10482 match[18] |= (cos2_val & 0x7) << 5;
10485 match[21] = proto_val & 0xff;
10486 match[20] = proto_val >> 8;
10490 match[15] = tag1_val[1];
10491 match[14] = tag1_val[0];
10494 match[14] |= (cos1_val & 0x7) << 5;
10500 match[15] = tag1_val[1];
10501 match[14] = tag1_val[0];
10504 match[17] = proto_val & 0xff;
10505 match[16] = proto_val >> 8;
10508 match[14] |= (cos1_val & 0x7) << 5;
10514 match[18] |= (cos2_val & 0x7) << 5;
10516 match[14] |= (cos1_val & 0x7) << 5;
10519 match[13] = proto_val & 0xff;
10520 match[12] = proto_val >> 8;
10528 unformat_qos_source (unformat_input_t * input, va_list * args)
10530 int *qs = va_arg (*args, int *);
10532 if (unformat (input, "ip"))
10533 *qs = QOS_SOURCE_IP;
10534 else if (unformat (input, "mpls"))
10535 *qs = QOS_SOURCE_MPLS;
10536 else if (unformat (input, "ext"))
10537 *qs = QOS_SOURCE_EXT;
10538 else if (unformat (input, "vlan"))
10539 *qs = QOS_SOURCE_VLAN;
10548 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10550 u8 **matchp = va_arg (*args, u8 **);
10551 u32 skip_n_vectors = va_arg (*args, u32);
10552 u32 match_n_vectors = va_arg (*args, u32);
10559 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10561 if (unformat (input, "hex %U", unformat_hex_string, &match))
10563 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10565 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10567 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10581 if (match || l2 || l3 || l4)
10583 if (l2 || l3 || l4)
10585 /* "Win a free Ethernet header in every packet" */
10587 vec_validate_aligned (l2, 13, sizeof (u32x4));
10591 vec_append_aligned (match, l3, sizeof (u32x4));
10596 vec_append_aligned (match, l4, sizeof (u32x4));
10601 /* Make sure the vector is big enough even if key is all 0's */
10602 vec_validate_aligned
10603 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10606 /* Set size, include skipped vectors */
10607 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10618 api_classify_add_del_session (vat_main_t * vam)
10620 unformat_input_t *i = vam->input;
10621 vl_api_classify_add_del_session_t *mp;
10623 u32 table_index = ~0;
10624 u32 hit_next_index = ~0;
10625 u32 opaque_index = ~0;
10628 u32 skip_n_vectors = 0;
10629 u32 match_n_vectors = 0;
10635 * Warning: you have to supply skip_n and match_n
10636 * because the API client cant simply look at the classify
10640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10642 if (unformat (i, "del"))
10644 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10647 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10650 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10653 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10655 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10657 else if (unformat (i, "opaque-index %d", &opaque_index))
10659 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10661 else if (unformat (i, "match_n %d", &match_n_vectors))
10663 else if (unformat (i, "match %U", api_unformat_classify_match,
10664 &match, skip_n_vectors, match_n_vectors))
10666 else if (unformat (i, "advance %d", &advance))
10668 else if (unformat (i, "table-index %d", &table_index))
10670 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10672 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10674 else if (unformat (i, "action %d", &action))
10676 else if (unformat (i, "metadata %d", &metadata))
10682 if (table_index == ~0)
10684 errmsg ("Table index required");
10688 if (is_add && match == 0)
10690 errmsg ("Match value required");
10694 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10696 mp->is_add = is_add;
10697 mp->table_index = ntohl (table_index);
10698 mp->hit_next_index = ntohl (hit_next_index);
10699 mp->opaque_index = ntohl (opaque_index);
10700 mp->advance = ntohl (advance);
10701 mp->action = action;
10702 mp->metadata = ntohl (metadata);
10703 mp->match_len = ntohl (vec_len (match));
10704 clib_memcpy (mp->match, match, vec_len (match));
10713 api_classify_set_interface_ip_table (vat_main_t * vam)
10715 unformat_input_t *i = vam->input;
10716 vl_api_classify_set_interface_ip_table_t *mp;
10718 int sw_if_index_set;
10719 u32 table_index = ~0;
10723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10725 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10726 sw_if_index_set = 1;
10727 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10728 sw_if_index_set = 1;
10729 else if (unformat (i, "table %d", &table_index))
10733 clib_warning ("parse error '%U'", format_unformat_error, i);
10738 if (sw_if_index_set == 0)
10740 errmsg ("missing interface name or sw_if_index");
10745 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10747 mp->sw_if_index = ntohl (sw_if_index);
10748 mp->table_index = ntohl (table_index);
10749 mp->is_ipv6 = is_ipv6;
10757 api_classify_set_interface_l2_tables (vat_main_t * vam)
10759 unformat_input_t *i = vam->input;
10760 vl_api_classify_set_interface_l2_tables_t *mp;
10762 int sw_if_index_set;
10763 u32 ip4_table_index = ~0;
10764 u32 ip6_table_index = ~0;
10765 u32 other_table_index = ~0;
10769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10771 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10772 sw_if_index_set = 1;
10773 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10774 sw_if_index_set = 1;
10775 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10777 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10779 else if (unformat (i, "other-table %d", &other_table_index))
10781 else if (unformat (i, "is-input %d", &is_input))
10785 clib_warning ("parse error '%U'", format_unformat_error, i);
10790 if (sw_if_index_set == 0)
10792 errmsg ("missing interface name or sw_if_index");
10797 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10799 mp->sw_if_index = ntohl (sw_if_index);
10800 mp->ip4_table_index = ntohl (ip4_table_index);
10801 mp->ip6_table_index = ntohl (ip6_table_index);
10802 mp->other_table_index = ntohl (other_table_index);
10803 mp->is_input = (u8) is_input;
10811 api_set_ipfix_exporter (vat_main_t * vam)
10813 unformat_input_t *i = vam->input;
10814 vl_api_set_ipfix_exporter_t *mp;
10815 ip4_address_t collector_address;
10816 u8 collector_address_set = 0;
10817 u32 collector_port = ~0;
10818 ip4_address_t src_address;
10819 u8 src_address_set = 0;
10822 u32 template_interval = ~0;
10823 u8 udp_checksum = 0;
10826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10828 if (unformat (i, "collector_address %U", unformat_ip4_address,
10829 &collector_address))
10830 collector_address_set = 1;
10831 else if (unformat (i, "collector_port %d", &collector_port))
10833 else if (unformat (i, "src_address %U", unformat_ip4_address,
10835 src_address_set = 1;
10836 else if (unformat (i, "vrf_id %d", &vrf_id))
10838 else if (unformat (i, "path_mtu %d", &path_mtu))
10840 else if (unformat (i, "template_interval %d", &template_interval))
10842 else if (unformat (i, "udp_checksum"))
10848 if (collector_address_set == 0)
10850 errmsg ("collector_address required");
10854 if (src_address_set == 0)
10856 errmsg ("src_address required");
10860 M (SET_IPFIX_EXPORTER, mp);
10862 memcpy (mp->collector_address.un.ip4, collector_address.data,
10863 sizeof (collector_address.data));
10864 mp->collector_port = htons ((u16) collector_port);
10865 memcpy (mp->src_address.un.ip4, src_address.data,
10866 sizeof (src_address.data));
10867 mp->vrf_id = htonl (vrf_id);
10868 mp->path_mtu = htonl (path_mtu);
10869 mp->template_interval = htonl (template_interval);
10870 mp->udp_checksum = udp_checksum;
10878 api_set_ipfix_classify_stream (vat_main_t * vam)
10880 unformat_input_t *i = vam->input;
10881 vl_api_set_ipfix_classify_stream_t *mp;
10883 u32 src_port = UDP_DST_PORT_ipfix;
10886 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10888 if (unformat (i, "domain %d", &domain_id))
10890 else if (unformat (i, "src_port %d", &src_port))
10894 errmsg ("unknown input `%U'", format_unformat_error, i);
10899 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10901 mp->domain_id = htonl (domain_id);
10902 mp->src_port = htons ((u16) src_port);
10910 api_ipfix_classify_table_add_del (vat_main_t * vam)
10912 unformat_input_t *i = vam->input;
10913 vl_api_ipfix_classify_table_add_del_t *mp;
10915 u32 classify_table_index = ~0;
10917 u8 transport_protocol = 255;
10920 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10922 if (unformat (i, "add"))
10924 else if (unformat (i, "del"))
10926 else if (unformat (i, "table %d", &classify_table_index))
10928 else if (unformat (i, "ip4"))
10930 else if (unformat (i, "ip6"))
10932 else if (unformat (i, "tcp"))
10933 transport_protocol = 6;
10934 else if (unformat (i, "udp"))
10935 transport_protocol = 17;
10938 errmsg ("unknown input `%U'", format_unformat_error, i);
10945 errmsg ("expecting: add|del");
10948 if (classify_table_index == ~0)
10950 errmsg ("classifier table not specified");
10953 if (ip_version == 0)
10955 errmsg ("IP version not specified");
10959 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10961 mp->is_add = is_add;
10962 mp->table_id = htonl (classify_table_index);
10963 mp->ip_version = ip_version;
10964 mp->transport_protocol = transport_protocol;
10972 api_get_node_index (vat_main_t * vam)
10974 unformat_input_t *i = vam->input;
10975 vl_api_get_node_index_t *mp;
10979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10981 if (unformat (i, "node %s", &name))
10988 errmsg ("node name required");
10991 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10993 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10997 M (GET_NODE_INDEX, mp);
10998 clib_memcpy (mp->node_name, name, vec_len (name));
11007 api_get_next_index (vat_main_t * vam)
11009 unformat_input_t *i = vam->input;
11010 vl_api_get_next_index_t *mp;
11011 u8 *node_name = 0, *next_node_name = 0;
11014 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11016 if (unformat (i, "node-name %s", &node_name))
11018 else if (unformat (i, "next-node-name %s", &next_node_name))
11022 if (node_name == 0)
11024 errmsg ("node name required");
11027 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11029 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11033 if (next_node_name == 0)
11035 errmsg ("next node name required");
11038 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11040 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11044 M (GET_NEXT_INDEX, mp);
11045 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11046 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11047 vec_free (node_name);
11048 vec_free (next_node_name);
11056 api_add_node_next (vat_main_t * vam)
11058 unformat_input_t *i = vam->input;
11059 vl_api_add_node_next_t *mp;
11064 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11066 if (unformat (i, "node %s", &name))
11068 else if (unformat (i, "next %s", &next))
11075 errmsg ("node name required");
11078 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11080 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11085 errmsg ("next node required");
11088 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11090 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11094 M (ADD_NODE_NEXT, mp);
11095 clib_memcpy (mp->node_name, name, vec_len (name));
11096 clib_memcpy (mp->next_name, next, vec_len (next));
11105 static void vl_api_sw_interface_tap_v2_details_t_handler
11106 (vl_api_sw_interface_tap_v2_details_t * mp)
11108 vat_main_t *vam = &vat_main;
11111 format (0, "%U/%d", format_ip4_address, mp->host_ip4_prefix.address,
11112 mp->host_ip4_prefix.len);
11114 format (0, "%U/%d", format_ip6_address, mp->host_ip6_prefix.address,
11115 mp->host_ip6_prefix.len);
11118 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
11119 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
11120 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11121 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
11122 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
11128 static void vl_api_sw_interface_tap_v2_details_t_handler_json
11129 (vl_api_sw_interface_tap_v2_details_t * mp)
11131 vat_main_t *vam = &vat_main;
11132 vat_json_node_t *node = NULL;
11134 if (VAT_JSON_ARRAY != vam->json_tree.type)
11136 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11137 vat_json_init_array (&vam->json_tree);
11139 node = vat_json_array_add (&vam->json_tree);
11141 vat_json_init_object (node);
11142 vat_json_object_add_uint (node, "id", ntohl (mp->id));
11143 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11144 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
11145 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11146 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11147 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11148 vat_json_object_add_string_copy (node, "host_mac_addr",
11149 format (0, "%U", format_ethernet_address,
11150 &mp->host_mac_addr));
11151 vat_json_object_add_string_copy (node, "host_namespace",
11152 mp->host_namespace);
11153 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
11154 vat_json_object_add_string_copy (node, "host_ip4_addr",
11155 format (0, "%U/%d", format_ip4_address,
11156 mp->host_ip4_prefix.address,
11157 mp->host_ip4_prefix.len));
11158 vat_json_object_add_string_copy (node, "host_ip6_prefix",
11159 format (0, "%U/%d", format_ip6_address,
11160 mp->host_ip6_prefix.address,
11161 mp->host_ip6_prefix.len));
11166 api_sw_interface_tap_v2_dump (vat_main_t * vam)
11168 vl_api_sw_interface_tap_v2_dump_t *mp;
11169 vl_api_control_ping_t *mp_ping;
11173 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
11174 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
11175 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
11178 /* Get list of tap interfaces */
11179 M (SW_INTERFACE_TAP_V2_DUMP, mp);
11182 /* Use a control ping for synchronization */
11183 MPING (CONTROL_PING, mp_ping);
11190 static void vl_api_sw_interface_virtio_pci_details_t_handler
11191 (vl_api_sw_interface_virtio_pci_details_t * mp)
11193 vat_main_t *vam = &vat_main;
11208 addr.domain = ntohs (mp->pci_addr.domain);
11209 addr.bus = mp->pci_addr.bus;
11210 addr.slot = mp->pci_addr.slot;
11211 addr.function = mp->pci_addr.function;
11213 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
11214 addr.slot, addr.function);
11217 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
11218 pci_addr, ntohl (mp->sw_if_index),
11219 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11220 format_ethernet_address, mp->mac_addr,
11221 clib_net_to_host_u64 (mp->features));
11222 vec_free (pci_addr);
11225 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
11226 (vl_api_sw_interface_virtio_pci_details_t * mp)
11228 vat_main_t *vam = &vat_main;
11229 vat_json_node_t *node = NULL;
11230 vlib_pci_addr_t pci_addr;
11232 if (VAT_JSON_ARRAY != vam->json_tree.type)
11234 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11235 vat_json_init_array (&vam->json_tree);
11237 node = vat_json_array_add (&vam->json_tree);
11239 pci_addr.domain = ntohs (mp->pci_addr.domain);
11240 pci_addr.bus = mp->pci_addr.bus;
11241 pci_addr.slot = mp->pci_addr.slot;
11242 pci_addr.function = mp->pci_addr.function;
11244 vat_json_init_object (node);
11245 vat_json_object_add_uint (node, "pci-addr", pci_addr.as_u32);
11246 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11247 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11248 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11249 vat_json_object_add_uint (node, "features",
11250 clib_net_to_host_u64 (mp->features));
11251 vat_json_object_add_string_copy (node, "mac_addr",
11252 format (0, "%U", format_ethernet_address,
11257 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
11259 vl_api_sw_interface_virtio_pci_dump_t *mp;
11260 vl_api_control_ping_t *mp_ping;
11264 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
11265 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
11266 "mac_addr", "features");
11268 /* Get list of tap interfaces */
11269 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
11272 /* Use a control ping for synchronization */
11273 MPING (CONTROL_PING, mp_ping);
11281 api_vxlan_offload_rx (vat_main_t * vam)
11283 unformat_input_t *line_input = vam->input;
11284 vl_api_vxlan_offload_rx_t *mp;
11285 u32 hw_if_index = ~0, rx_if_index = ~0;
11289 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11291 if (unformat (line_input, "del"))
11293 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
11296 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
11298 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
11301 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
11305 errmsg ("parse error '%U'", format_unformat_error, line_input);
11310 if (hw_if_index == ~0)
11312 errmsg ("no hw interface");
11316 if (rx_if_index == ~0)
11318 errmsg ("no rx tunnel");
11322 M (VXLAN_OFFLOAD_RX, mp);
11324 mp->hw_if_index = ntohl (hw_if_index);
11325 mp->sw_if_index = ntohl (rx_if_index);
11326 mp->enable = is_add;
11333 static uword unformat_vxlan_decap_next
11334 (unformat_input_t * input, va_list * args)
11336 u32 *result = va_arg (*args, u32 *);
11339 if (unformat (input, "l2"))
11340 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11341 else if (unformat (input, "%d", &tmp))
11349 api_vxlan_add_del_tunnel (vat_main_t * vam)
11351 unformat_input_t *line_input = vam->input;
11352 vl_api_vxlan_add_del_tunnel_t *mp;
11353 ip46_address_t src, dst;
11355 u8 ipv4_set = 0, ipv6_set = 0;
11360 u32 mcast_sw_if_index = ~0;
11361 u32 encap_vrf_id = 0;
11362 u32 decap_next_index = ~0;
11366 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11367 clib_memset (&src, 0, sizeof src);
11368 clib_memset (&dst, 0, sizeof dst);
11370 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11372 if (unformat (line_input, "del"))
11374 else if (unformat (line_input, "instance %d", &instance))
11377 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11383 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11389 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11395 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11400 else if (unformat (line_input, "group %U %U",
11401 unformat_ip4_address, &dst.ip4,
11402 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11404 grp_set = dst_set = 1;
11407 else if (unformat (line_input, "group %U",
11408 unformat_ip4_address, &dst.ip4))
11410 grp_set = dst_set = 1;
11413 else if (unformat (line_input, "group %U %U",
11414 unformat_ip6_address, &dst.ip6,
11415 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11417 grp_set = dst_set = 1;
11420 else if (unformat (line_input, "group %U",
11421 unformat_ip6_address, &dst.ip6))
11423 grp_set = dst_set = 1;
11427 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11429 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11431 else if (unformat (line_input, "decap-next %U",
11432 unformat_vxlan_decap_next, &decap_next_index))
11434 else if (unformat (line_input, "vni %d", &vni))
11438 errmsg ("parse error '%U'", format_unformat_error, line_input);
11445 errmsg ("tunnel src address not specified");
11450 errmsg ("tunnel dst address not specified");
11454 if (grp_set && !ip46_address_is_multicast (&dst))
11456 errmsg ("tunnel group address not multicast");
11459 if (grp_set && mcast_sw_if_index == ~0)
11461 errmsg ("tunnel nonexistent multicast device");
11464 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11466 errmsg ("tunnel dst address must be unicast");
11471 if (ipv4_set && ipv6_set)
11473 errmsg ("both IPv4 and IPv6 addresses specified");
11477 if ((vni == 0) || (vni >> 24))
11479 errmsg ("vni not specified or out of range");
11483 M (VXLAN_ADD_DEL_TUNNEL, mp);
11487 clib_memcpy (mp->src_address.un.ip6, &src.ip6, sizeof (src.ip6));
11488 clib_memcpy (mp->dst_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
11492 clib_memcpy (mp->src_address.un.ip4, &src.ip4, sizeof (src.ip4));
11493 clib_memcpy (mp->dst_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
11495 mp->src_address.af = ipv6_set;
11496 mp->dst_address.af = ipv6_set;
11498 mp->instance = htonl (instance);
11499 mp->encap_vrf_id = ntohl (encap_vrf_id);
11500 mp->decap_next_index = ntohl (decap_next_index);
11501 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11502 mp->vni = ntohl (vni);
11503 mp->is_add = is_add;
11510 static void vl_api_vxlan_tunnel_details_t_handler
11511 (vl_api_vxlan_tunnel_details_t * mp)
11513 vat_main_t *vam = &vat_main;
11514 ip46_address_t src =
11515 to_ip46 (mp->dst_address.af, (u8 *) & mp->dst_address.un);
11516 ip46_address_t dst =
11517 to_ip46 (mp->dst_address.af, (u8 *) & mp->src_address.un);
11519 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
11520 ntohl (mp->sw_if_index),
11521 ntohl (mp->instance),
11522 format_ip46_address, &src, IP46_TYPE_ANY,
11523 format_ip46_address, &dst, IP46_TYPE_ANY,
11524 ntohl (mp->encap_vrf_id),
11525 ntohl (mp->decap_next_index), ntohl (mp->vni),
11526 ntohl (mp->mcast_sw_if_index));
11529 static void vl_api_vxlan_tunnel_details_t_handler_json
11530 (vl_api_vxlan_tunnel_details_t * mp)
11532 vat_main_t *vam = &vat_main;
11533 vat_json_node_t *node = NULL;
11535 if (VAT_JSON_ARRAY != vam->json_tree.type)
11537 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11538 vat_json_init_array (&vam->json_tree);
11540 node = vat_json_array_add (&vam->json_tree);
11542 vat_json_init_object (node);
11543 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11545 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
11547 if (mp->src_address.af)
11549 struct in6_addr ip6;
11551 clib_memcpy (&ip6, mp->src_address.un.ip6, sizeof (ip6));
11552 vat_json_object_add_ip6 (node, "src_address", ip6);
11553 clib_memcpy (&ip6, mp->dst_address.un.ip6, sizeof (ip6));
11554 vat_json_object_add_ip6 (node, "dst_address", ip6);
11558 struct in_addr ip4;
11560 clib_memcpy (&ip4, mp->src_address.un.ip4, sizeof (ip4));
11561 vat_json_object_add_ip4 (node, "src_address", ip4);
11562 clib_memcpy (&ip4, mp->dst_address.un.ip4, sizeof (ip4));
11563 vat_json_object_add_ip4 (node, "dst_address", ip4);
11565 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11566 vat_json_object_add_uint (node, "decap_next_index",
11567 ntohl (mp->decap_next_index));
11568 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11569 vat_json_object_add_uint (node, "mcast_sw_if_index",
11570 ntohl (mp->mcast_sw_if_index));
11574 api_vxlan_tunnel_dump (vat_main_t * vam)
11576 unformat_input_t *i = vam->input;
11577 vl_api_vxlan_tunnel_dump_t *mp;
11578 vl_api_control_ping_t *mp_ping;
11580 u8 sw_if_index_set = 0;
11583 /* Parse args required to build the message */
11584 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11586 if (unformat (i, "sw_if_index %d", &sw_if_index))
11587 sw_if_index_set = 1;
11592 if (sw_if_index_set == 0)
11597 if (!vam->json_output)
11599 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
11600 "sw_if_index", "instance", "src_address", "dst_address",
11601 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11604 /* Get list of vxlan-tunnel interfaces */
11605 M (VXLAN_TUNNEL_DUMP, mp);
11607 mp->sw_if_index = htonl (sw_if_index);
11611 /* Use a control ping for synchronization */
11612 MPING (CONTROL_PING, mp_ping);
11620 api_gre_tunnel_add_del (vat_main_t * vam)
11622 unformat_input_t *line_input = vam->input;
11623 vl_api_address_t src = { }, dst =
11626 vl_api_gre_tunnel_add_del_t *mp;
11627 vl_api_gre_tunnel_type_t t_type;
11631 u32 outer_table_id = 0;
11632 u32 session_id = 0;
11636 t_type = GRE_API_TUNNEL_TYPE_L3;
11638 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11640 if (unformat (line_input, "del"))
11642 else if (unformat (line_input, "instance %d", &instance))
11644 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
11648 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
11652 else if (unformat (line_input, "outer-table-id %d", &outer_table_id))
11654 else if (unformat (line_input, "teb"))
11655 t_type = GRE_API_TUNNEL_TYPE_TEB;
11656 else if (unformat (line_input, "erspan %d", &session_id))
11657 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
11660 errmsg ("parse error '%U'", format_unformat_error, line_input);
11667 errmsg ("tunnel src address not specified");
11672 errmsg ("tunnel dst address not specified");
11676 M (GRE_TUNNEL_ADD_DEL, mp);
11678 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
11679 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
11681 mp->tunnel.instance = htonl (instance);
11682 mp->tunnel.outer_table_id = htonl (outer_table_id);
11683 mp->is_add = is_add;
11684 mp->tunnel.session_id = htons ((u16) session_id);
11685 mp->tunnel.type = htonl (t_type);
11692 static void vl_api_gre_tunnel_details_t_handler
11693 (vl_api_gre_tunnel_details_t * mp)
11695 vat_main_t *vam = &vat_main;
11697 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
11698 ntohl (mp->tunnel.sw_if_index),
11699 ntohl (mp->tunnel.instance),
11700 format_vl_api_address, &mp->tunnel.src,
11701 format_vl_api_address, &mp->tunnel.dst,
11702 mp->tunnel.type, ntohl (mp->tunnel.outer_table_id),
11703 ntohl (mp->tunnel.session_id));
11706 static void vl_api_gre_tunnel_details_t_handler_json
11707 (vl_api_gre_tunnel_details_t * mp)
11709 vat_main_t *vam = &vat_main;
11710 vat_json_node_t *node = NULL;
11712 if (VAT_JSON_ARRAY != vam->json_tree.type)
11714 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11715 vat_json_init_array (&vam->json_tree);
11717 node = vat_json_array_add (&vam->json_tree);
11719 vat_json_init_object (node);
11720 vat_json_object_add_uint (node, "sw_if_index",
11721 ntohl (mp->tunnel.sw_if_index));
11722 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
11724 vat_json_object_add_address (node, "src", &mp->tunnel.src);
11725 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
11726 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
11727 vat_json_object_add_uint (node, "outer_table_id",
11728 ntohl (mp->tunnel.outer_table_id));
11729 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
11733 api_gre_tunnel_dump (vat_main_t * vam)
11735 unformat_input_t *i = vam->input;
11736 vl_api_gre_tunnel_dump_t *mp;
11737 vl_api_control_ping_t *mp_ping;
11739 u8 sw_if_index_set = 0;
11742 /* Parse args required to build the message */
11743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11745 if (unformat (i, "sw_if_index %d", &sw_if_index))
11746 sw_if_index_set = 1;
11751 if (sw_if_index_set == 0)
11756 if (!vam->json_output)
11758 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
11759 "sw_if_index", "instance", "src_address", "dst_address",
11760 "tunnel_type", "outer_fib_id", "session_id");
11763 /* Get list of gre-tunnel interfaces */
11764 M (GRE_TUNNEL_DUMP, mp);
11766 mp->sw_if_index = htonl (sw_if_index);
11770 /* Use a control ping for synchronization */
11771 MPING (CONTROL_PING, mp_ping);
11779 api_l2_fib_clear_table (vat_main_t * vam)
11781 // unformat_input_t * i = vam->input;
11782 vl_api_l2_fib_clear_table_t *mp;
11785 M (L2_FIB_CLEAR_TABLE, mp);
11793 api_l2_interface_efp_filter (vat_main_t * vam)
11795 unformat_input_t *i = vam->input;
11796 vl_api_l2_interface_efp_filter_t *mp;
11799 u8 sw_if_index_set = 0;
11802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11804 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11805 sw_if_index_set = 1;
11806 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11807 sw_if_index_set = 1;
11808 else if (unformat (i, "enable"))
11810 else if (unformat (i, "disable"))
11814 clib_warning ("parse error '%U'", format_unformat_error, i);
11819 if (sw_if_index_set == 0)
11821 errmsg ("missing sw_if_index");
11825 M (L2_INTERFACE_EFP_FILTER, mp);
11827 mp->sw_if_index = ntohl (sw_if_index);
11828 mp->enable_disable = enable;
11835 #define foreach_vtr_op \
11836 _("disable", L2_VTR_DISABLED) \
11837 _("push-1", L2_VTR_PUSH_1) \
11838 _("push-2", L2_VTR_PUSH_2) \
11839 _("pop-1", L2_VTR_POP_1) \
11840 _("pop-2", L2_VTR_POP_2) \
11841 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11842 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11843 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11844 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11847 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11849 unformat_input_t *i = vam->input;
11850 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11852 u8 sw_if_index_set = 0;
11855 u32 push_dot1q = 1;
11860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11862 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11863 sw_if_index_set = 1;
11864 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11865 sw_if_index_set = 1;
11866 else if (unformat (i, "vtr_op %d", &vtr_op))
11868 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11871 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11873 else if (unformat (i, "tag1 %d", &tag1))
11875 else if (unformat (i, "tag2 %d", &tag2))
11879 clib_warning ("parse error '%U'", format_unformat_error, i);
11884 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11886 errmsg ("missing vtr operation or sw_if_index");
11890 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11891 mp->sw_if_index = ntohl (sw_if_index);
11892 mp->vtr_op = ntohl (vtr_op);
11893 mp->push_dot1q = ntohl (push_dot1q);
11894 mp->tag1 = ntohl (tag1);
11895 mp->tag2 = ntohl (tag2);
11903 api_create_vhost_user_if (vat_main_t * vam)
11905 unformat_input_t *i = vam->input;
11906 vl_api_create_vhost_user_if_t *mp;
11909 u8 file_name_set = 0;
11910 u32 custom_dev_instance = ~0;
11912 u8 use_custom_mac = 0;
11913 u8 disable_mrg_rxbuf = 0;
11914 u8 disable_indirect_desc = 0;
11917 u8 enable_packed = 0;
11920 /* Shut up coverity */
11921 clib_memset (hwaddr, 0, sizeof (hwaddr));
11923 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11925 if (unformat (i, "socket %s", &file_name))
11929 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11931 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11932 use_custom_mac = 1;
11933 else if (unformat (i, "server"))
11935 else if (unformat (i, "disable_mrg_rxbuf"))
11936 disable_mrg_rxbuf = 1;
11937 else if (unformat (i, "disable_indirect_desc"))
11938 disable_indirect_desc = 1;
11939 else if (unformat (i, "gso"))
11941 else if (unformat (i, "packed"))
11943 else if (unformat (i, "tag %s", &tag))
11949 if (file_name_set == 0)
11951 errmsg ("missing socket file name");
11955 if (vec_len (file_name) > 255)
11957 errmsg ("socket file name too long");
11960 vec_add1 (file_name, 0);
11962 M (CREATE_VHOST_USER_IF, mp);
11964 mp->is_server = is_server;
11965 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
11966 mp->disable_indirect_desc = disable_indirect_desc;
11967 mp->enable_gso = enable_gso;
11968 mp->enable_packed = enable_packed;
11969 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11970 vec_free (file_name);
11971 if (custom_dev_instance != ~0)
11974 mp->custom_dev_instance = ntohl (custom_dev_instance);
11977 mp->use_custom_mac = use_custom_mac;
11978 clib_memcpy (mp->mac_address, hwaddr, 6);
11980 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11989 api_modify_vhost_user_if (vat_main_t * vam)
11991 unformat_input_t *i = vam->input;
11992 vl_api_modify_vhost_user_if_t *mp;
11995 u8 file_name_set = 0;
11996 u32 custom_dev_instance = ~0;
11997 u8 sw_if_index_set = 0;
11998 u32 sw_if_index = (u32) ~ 0;
12000 u8 enable_packed = 0;
12003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12005 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12006 sw_if_index_set = 1;
12007 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12008 sw_if_index_set = 1;
12009 else if (unformat (i, "socket %s", &file_name))
12013 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12015 else if (unformat (i, "server"))
12017 else if (unformat (i, "gso"))
12019 else if (unformat (i, "packed"))
12025 if (sw_if_index_set == 0)
12027 errmsg ("missing sw_if_index or interface name");
12031 if (file_name_set == 0)
12033 errmsg ("missing socket file name");
12037 if (vec_len (file_name) > 255)
12039 errmsg ("socket file name too long");
12042 vec_add1 (file_name, 0);
12044 M (MODIFY_VHOST_USER_IF, mp);
12046 mp->sw_if_index = ntohl (sw_if_index);
12047 mp->is_server = is_server;
12048 mp->enable_gso = enable_gso;
12049 mp->enable_packed = enable_packed;
12050 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12051 vec_free (file_name);
12052 if (custom_dev_instance != ~0)
12055 mp->custom_dev_instance = ntohl (custom_dev_instance);
12064 api_delete_vhost_user_if (vat_main_t * vam)
12066 unformat_input_t *i = vam->input;
12067 vl_api_delete_vhost_user_if_t *mp;
12068 u32 sw_if_index = ~0;
12069 u8 sw_if_index_set = 0;
12072 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12074 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12075 sw_if_index_set = 1;
12076 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12077 sw_if_index_set = 1;
12082 if (sw_if_index_set == 0)
12084 errmsg ("missing sw_if_index or interface name");
12089 M (DELETE_VHOST_USER_IF, mp);
12091 mp->sw_if_index = ntohl (sw_if_index);
12098 static void vl_api_sw_interface_vhost_user_details_t_handler
12099 (vl_api_sw_interface_vhost_user_details_t * mp)
12101 vat_main_t *vam = &vat_main;
12105 clib_net_to_host_u32 (mp->features_first_32) | ((u64)
12106 clib_net_to_host_u32
12107 (mp->features_last_32) <<
12110 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12111 (char *) mp->interface_name,
12112 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12113 features, mp->is_server,
12114 ntohl (mp->num_regions), (char *) mp->sock_filename);
12115 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12118 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12119 (vl_api_sw_interface_vhost_user_details_t * mp)
12121 vat_main_t *vam = &vat_main;
12122 vat_json_node_t *node = NULL;
12124 if (VAT_JSON_ARRAY != vam->json_tree.type)
12126 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12127 vat_json_init_array (&vam->json_tree);
12129 node = vat_json_array_add (&vam->json_tree);
12131 vat_json_init_object (node);
12132 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12133 vat_json_object_add_string_copy (node, "interface_name",
12134 mp->interface_name);
12135 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12136 ntohl (mp->virtio_net_hdr_sz));
12137 vat_json_object_add_uint (node, "features_first_32",
12138 clib_net_to_host_u32 (mp->features_first_32));
12139 vat_json_object_add_uint (node, "features_last_32",
12140 clib_net_to_host_u32 (mp->features_last_32));
12141 vat_json_object_add_uint (node, "is_server", mp->is_server);
12142 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12143 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12144 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12148 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12150 unformat_input_t *i = vam->input;
12151 vl_api_sw_interface_vhost_user_dump_t *mp;
12152 vl_api_control_ping_t *mp_ping;
12154 u32 sw_if_index = ~0;
12156 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12158 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12160 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12167 "Interface name idx hdr_sz features server regions filename");
12169 /* Get list of vhost-user interfaces */
12170 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12171 mp->sw_if_index = ntohl (sw_if_index);
12174 /* Use a control ping for synchronization */
12175 MPING (CONTROL_PING, mp_ping);
12183 api_show_version (vat_main_t * vam)
12185 vl_api_show_version_t *mp;
12188 M (SHOW_VERSION, mp);
12197 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12199 unformat_input_t *line_input = vam->input;
12200 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12201 ip46_address_t local, remote;
12206 u32 mcast_sw_if_index = ~0;
12207 u32 encap_vrf_id = 0;
12208 u32 decap_vrf_id = 0;
12214 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12216 if (unformat (line_input, "del"))
12218 else if (unformat (line_input, "local %U",
12219 unformat_ip46_address, &local))
12223 else if (unformat (line_input, "remote %U",
12224 unformat_ip46_address, &remote))
12228 else if (unformat (line_input, "group %U %U",
12229 unformat_ip46_address, &remote,
12230 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12232 grp_set = remote_set = 1;
12234 else if (unformat (line_input, "group %U",
12235 unformat_ip46_address, &remote))
12237 grp_set = remote_set = 1;
12240 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12242 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12244 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12246 else if (unformat (line_input, "vni %d", &vni))
12248 else if (unformat (line_input, "next-ip4"))
12250 else if (unformat (line_input, "next-ip6"))
12252 else if (unformat (line_input, "next-ethernet"))
12254 else if (unformat (line_input, "next-nsh"))
12258 errmsg ("parse error '%U'", format_unformat_error, line_input);
12263 if (local_set == 0)
12265 errmsg ("tunnel local address not specified");
12268 if (remote_set == 0)
12270 errmsg ("tunnel remote address not specified");
12273 if (grp_set && mcast_sw_if_index == ~0)
12275 errmsg ("tunnel nonexistent multicast device");
12278 if (ip46_address_is_ip4 (&local) != ip46_address_is_ip4 (&remote))
12280 errmsg ("both IPv4 and IPv6 addresses specified");
12286 errmsg ("vni not specified");
12290 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12292 ip_address_encode (&local,
12293 ip46_address_is_ip4 (&local) ? IP46_TYPE_IP4 :
12294 IP46_TYPE_IP6, &mp->local);
12295 ip_address_encode (&remote,
12296 ip46_address_is_ip4 (&remote) ? IP46_TYPE_IP4 :
12297 IP46_TYPE_IP6, &mp->remote);
12299 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12300 mp->encap_vrf_id = ntohl (encap_vrf_id);
12301 mp->decap_vrf_id = ntohl (decap_vrf_id);
12302 mp->protocol = protocol;
12303 mp->vni = ntohl (vni);
12304 mp->is_add = is_add;
12311 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12312 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12314 vat_main_t *vam = &vat_main;
12315 ip46_address_t local, remote;
12317 ip_address_decode (&mp->local, &local);
12318 ip_address_decode (&mp->remote, &remote);
12320 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12321 ntohl (mp->sw_if_index),
12322 format_ip46_address, &local, IP46_TYPE_ANY,
12323 format_ip46_address, &remote, IP46_TYPE_ANY,
12324 ntohl (mp->vni), mp->protocol,
12325 ntohl (mp->mcast_sw_if_index),
12326 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12330 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12331 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12333 vat_main_t *vam = &vat_main;
12334 vat_json_node_t *node = NULL;
12335 struct in_addr ip4;
12336 struct in6_addr ip6;
12337 ip46_address_t local, remote;
12339 ip_address_decode (&mp->local, &local);
12340 ip_address_decode (&mp->remote, &remote);
12342 if (VAT_JSON_ARRAY != vam->json_tree.type)
12344 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12345 vat_json_init_array (&vam->json_tree);
12347 node = vat_json_array_add (&vam->json_tree);
12349 vat_json_init_object (node);
12350 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12351 if (ip46_address_is_ip4 (&local))
12353 clib_memcpy (&ip4, &local.ip4, sizeof (ip4));
12354 vat_json_object_add_ip4 (node, "local", ip4);
12355 clib_memcpy (&ip4, &remote.ip4, sizeof (ip4));
12356 vat_json_object_add_ip4 (node, "remote", ip4);
12360 clib_memcpy (&ip6, &local.ip6, sizeof (ip6));
12361 vat_json_object_add_ip6 (node, "local", ip6);
12362 clib_memcpy (&ip6, &remote.ip6, sizeof (ip6));
12363 vat_json_object_add_ip6 (node, "remote", ip6);
12365 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12366 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12367 vat_json_object_add_uint (node, "mcast_sw_if_index",
12368 ntohl (mp->mcast_sw_if_index));
12369 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12370 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12371 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12375 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12377 unformat_input_t *i = vam->input;
12378 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12379 vl_api_control_ping_t *mp_ping;
12381 u8 sw_if_index_set = 0;
12384 /* Parse args required to build the message */
12385 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12387 if (unformat (i, "sw_if_index %d", &sw_if_index))
12388 sw_if_index_set = 1;
12393 if (sw_if_index_set == 0)
12398 if (!vam->json_output)
12400 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12401 "sw_if_index", "local", "remote", "vni",
12402 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12405 /* Get list of vxlan-tunnel interfaces */
12406 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12408 mp->sw_if_index = htonl (sw_if_index);
12412 /* Use a control ping for synchronization */
12413 MPING (CONTROL_PING, mp_ping);
12420 static void vl_api_l2_fib_table_details_t_handler
12421 (vl_api_l2_fib_table_details_t * mp)
12423 vat_main_t *vam = &vat_main;
12425 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12427 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
12428 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12432 static void vl_api_l2_fib_table_details_t_handler_json
12433 (vl_api_l2_fib_table_details_t * mp)
12435 vat_main_t *vam = &vat_main;
12436 vat_json_node_t *node = NULL;
12438 if (VAT_JSON_ARRAY != vam->json_tree.type)
12440 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12441 vat_json_init_array (&vam->json_tree);
12443 node = vat_json_array_add (&vam->json_tree);
12445 vat_json_init_object (node);
12446 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12447 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
12448 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12449 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12450 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12451 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12455 api_l2_fib_table_dump (vat_main_t * vam)
12457 unformat_input_t *i = vam->input;
12458 vl_api_l2_fib_table_dump_t *mp;
12459 vl_api_control_ping_t *mp_ping;
12464 /* Parse args required to build the message */
12465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12467 if (unformat (i, "bd_id %d", &bd_id))
12473 if (bd_id_set == 0)
12475 errmsg ("missing bridge domain");
12479 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12481 /* Get list of l2 fib entries */
12482 M (L2_FIB_TABLE_DUMP, mp);
12484 mp->bd_id = ntohl (bd_id);
12487 /* Use a control ping for synchronization */
12488 MPING (CONTROL_PING, mp_ping);
12497 api_interface_name_renumber (vat_main_t * vam)
12499 unformat_input_t *line_input = vam->input;
12500 vl_api_interface_name_renumber_t *mp;
12501 u32 sw_if_index = ~0;
12502 u32 new_show_dev_instance = ~0;
12505 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12507 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12510 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12512 else if (unformat (line_input, "new_show_dev_instance %d",
12513 &new_show_dev_instance))
12519 if (sw_if_index == ~0)
12521 errmsg ("missing interface name or sw_if_index");
12525 if (new_show_dev_instance == ~0)
12527 errmsg ("missing new_show_dev_instance");
12531 M (INTERFACE_NAME_RENUMBER, mp);
12533 mp->sw_if_index = ntohl (sw_if_index);
12534 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12542 api_want_l2_macs_events (vat_main_t * vam)
12544 unformat_input_t *line_input = vam->input;
12545 vl_api_want_l2_macs_events_t *mp;
12546 u8 enable_disable = 1;
12547 u32 scan_delay = 0;
12548 u32 max_macs_in_event = 0;
12549 u32 learn_limit = 0;
12552 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12554 if (unformat (line_input, "learn-limit %d", &learn_limit))
12556 else if (unformat (line_input, "scan-delay %d", &scan_delay))
12558 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
12560 else if (unformat (line_input, "disable"))
12561 enable_disable = 0;
12566 M (WANT_L2_MACS_EVENTS, mp);
12567 mp->enable_disable = enable_disable;
12568 mp->pid = htonl (getpid ());
12569 mp->learn_limit = htonl (learn_limit);
12570 mp->scan_delay = (u8) scan_delay;
12571 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
12578 api_input_acl_set_interface (vat_main_t * vam)
12580 unformat_input_t *i = vam->input;
12581 vl_api_input_acl_set_interface_t *mp;
12583 int sw_if_index_set;
12584 u32 ip4_table_index = ~0;
12585 u32 ip6_table_index = ~0;
12586 u32 l2_table_index = ~0;
12590 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12592 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12593 sw_if_index_set = 1;
12594 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12595 sw_if_index_set = 1;
12596 else if (unformat (i, "del"))
12598 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12600 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12602 else if (unformat (i, "l2-table %d", &l2_table_index))
12606 clib_warning ("parse error '%U'", format_unformat_error, i);
12611 if (sw_if_index_set == 0)
12613 errmsg ("missing interface name or sw_if_index");
12617 M (INPUT_ACL_SET_INTERFACE, mp);
12619 mp->sw_if_index = ntohl (sw_if_index);
12620 mp->ip4_table_index = ntohl (ip4_table_index);
12621 mp->ip6_table_index = ntohl (ip6_table_index);
12622 mp->l2_table_index = ntohl (l2_table_index);
12623 mp->is_add = is_add;
12631 api_output_acl_set_interface (vat_main_t * vam)
12633 unformat_input_t *i = vam->input;
12634 vl_api_output_acl_set_interface_t *mp;
12636 int sw_if_index_set;
12637 u32 ip4_table_index = ~0;
12638 u32 ip6_table_index = ~0;
12639 u32 l2_table_index = ~0;
12643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12645 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12646 sw_if_index_set = 1;
12647 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12648 sw_if_index_set = 1;
12649 else if (unformat (i, "del"))
12651 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12653 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12655 else if (unformat (i, "l2-table %d", &l2_table_index))
12659 clib_warning ("parse error '%U'", format_unformat_error, i);
12664 if (sw_if_index_set == 0)
12666 errmsg ("missing interface name or sw_if_index");
12670 M (OUTPUT_ACL_SET_INTERFACE, mp);
12672 mp->sw_if_index = ntohl (sw_if_index);
12673 mp->ip4_table_index = ntohl (ip4_table_index);
12674 mp->ip6_table_index = ntohl (ip6_table_index);
12675 mp->l2_table_index = ntohl (l2_table_index);
12676 mp->is_add = is_add;
12684 api_ip_address_dump (vat_main_t * vam)
12686 unformat_input_t *i = vam->input;
12687 vl_api_ip_address_dump_t *mp;
12688 vl_api_control_ping_t *mp_ping;
12689 u32 sw_if_index = ~0;
12690 u8 sw_if_index_set = 0;
12695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12697 if (unformat (i, "sw_if_index %d", &sw_if_index))
12698 sw_if_index_set = 1;
12700 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12701 sw_if_index_set = 1;
12702 else if (unformat (i, "ipv4"))
12704 else if (unformat (i, "ipv6"))
12710 if (ipv4_set && ipv6_set)
12712 errmsg ("ipv4 and ipv6 flags cannot be both set");
12716 if ((!ipv4_set) && (!ipv6_set))
12718 errmsg ("no ipv4 nor ipv6 flag set");
12722 if (sw_if_index_set == 0)
12724 errmsg ("missing interface name or sw_if_index");
12728 vam->current_sw_if_index = sw_if_index;
12729 vam->is_ipv6 = ipv6_set;
12731 M (IP_ADDRESS_DUMP, mp);
12732 mp->sw_if_index = ntohl (sw_if_index);
12733 mp->is_ipv6 = ipv6_set;
12736 /* Use a control ping for synchronization */
12737 MPING (CONTROL_PING, mp_ping);
12745 api_ip_dump (vat_main_t * vam)
12747 vl_api_ip_dump_t *mp;
12748 vl_api_control_ping_t *mp_ping;
12749 unformat_input_t *in = vam->input;
12756 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12758 if (unformat (in, "ipv4"))
12760 else if (unformat (in, "ipv6"))
12766 if (ipv4_set && ipv6_set)
12768 errmsg ("ipv4 and ipv6 flags cannot be both set");
12772 if ((!ipv4_set) && (!ipv6_set))
12774 errmsg ("no ipv4 nor ipv6 flag set");
12778 is_ipv6 = ipv6_set;
12779 vam->is_ipv6 = is_ipv6;
12781 /* free old data */
12782 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12784 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12786 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12789 mp->is_ipv6 = ipv6_set;
12792 /* Use a control ping for synchronization */
12793 MPING (CONTROL_PING, mp_ping);
12801 api_ipsec_spd_add_del (vat_main_t * vam)
12803 unformat_input_t *i = vam->input;
12804 vl_api_ipsec_spd_add_del_t *mp;
12809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12811 if (unformat (i, "spd_id %d", &spd_id))
12813 else if (unformat (i, "del"))
12817 clib_warning ("parse error '%U'", format_unformat_error, i);
12823 errmsg ("spd_id must be set");
12827 M (IPSEC_SPD_ADD_DEL, mp);
12829 mp->spd_id = ntohl (spd_id);
12830 mp->is_add = is_add;
12838 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12840 unformat_input_t *i = vam->input;
12841 vl_api_ipsec_interface_add_del_spd_t *mp;
12843 u8 sw_if_index_set = 0;
12844 u32 spd_id = (u32) ~ 0;
12848 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12850 if (unformat (i, "del"))
12852 else if (unformat (i, "spd_id %d", &spd_id))
12855 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12856 sw_if_index_set = 1;
12857 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12858 sw_if_index_set = 1;
12861 clib_warning ("parse error '%U'", format_unformat_error, i);
12867 if (spd_id == (u32) ~ 0)
12869 errmsg ("spd_id must be set");
12873 if (sw_if_index_set == 0)
12875 errmsg ("missing interface name or sw_if_index");
12879 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12881 mp->spd_id = ntohl (spd_id);
12882 mp->sw_if_index = ntohl (sw_if_index);
12883 mp->is_add = is_add;
12891 api_ipsec_spd_entry_add_del (vat_main_t * vam)
12893 unformat_input_t *i = vam->input;
12894 vl_api_ipsec_spd_entry_add_del_t *mp;
12895 u8 is_add = 1, is_outbound = 0;
12896 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12898 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12899 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12900 vl_api_address_t laddr_start = { }, laddr_stop =
12909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12911 if (unformat (i, "del"))
12913 if (unformat (i, "outbound"))
12915 if (unformat (i, "inbound"))
12917 else if (unformat (i, "spd_id %d", &spd_id))
12919 else if (unformat (i, "sa_id %d", &sa_id))
12921 else if (unformat (i, "priority %d", &priority))
12923 else if (unformat (i, "protocol %d", &protocol))
12925 else if (unformat (i, "lport_start %d", &lport_start))
12927 else if (unformat (i, "lport_stop %d", &lport_stop))
12929 else if (unformat (i, "rport_start %d", &rport_start))
12931 else if (unformat (i, "rport_stop %d", &rport_stop))
12933 else if (unformat (i, "laddr_start %U",
12934 unformat_vl_api_address, &laddr_start))
12936 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
12939 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
12942 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
12946 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12948 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12950 clib_warning ("unsupported action: 'resolve'");
12956 clib_warning ("parse error '%U'", format_unformat_error, i);
12962 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
12964 mp->is_add = is_add;
12966 mp->entry.spd_id = ntohl (spd_id);
12967 mp->entry.priority = ntohl (priority);
12968 mp->entry.is_outbound = is_outbound;
12970 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
12971 sizeof (vl_api_address_t));
12972 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
12973 sizeof (vl_api_address_t));
12974 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
12975 sizeof (vl_api_address_t));
12976 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
12977 sizeof (vl_api_address_t));
12979 mp->entry.protocol = (u8) protocol;
12980 mp->entry.local_port_start = ntohs ((u16) lport_start);
12981 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
12982 mp->entry.remote_port_start = ntohs ((u16) rport_start);
12983 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
12984 mp->entry.policy = (u8) policy;
12985 mp->entry.sa_id = ntohl (sa_id);
12993 api_ipsec_sad_entry_add_del (vat_main_t * vam)
12995 unformat_input_t *i = vam->input;
12996 vl_api_ipsec_sad_entry_add_del_t *mp;
12997 u32 sad_id = 0, spi = 0;
12998 u8 *ck = 0, *ik = 0;
13001 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
13002 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
13003 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
13004 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
13005 vl_api_address_t tun_src, tun_dst;
13008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13010 if (unformat (i, "del"))
13012 else if (unformat (i, "sad_id %d", &sad_id))
13014 else if (unformat (i, "spi %d", &spi))
13016 else if (unformat (i, "esp"))
13017 protocol = IPSEC_API_PROTO_ESP;
13019 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
13021 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13022 if (ADDRESS_IP6 == tun_src.af)
13023 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13026 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
13028 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13029 if (ADDRESS_IP6 == tun_src.af)
13030 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13033 if (unformat (i, "crypto_alg %U",
13034 unformat_ipsec_api_crypto_alg, &crypto_alg))
13036 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13038 else if (unformat (i, "integ_alg %U",
13039 unformat_ipsec_api_integ_alg, &integ_alg))
13041 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13045 clib_warning ("parse error '%U'", format_unformat_error, i);
13051 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
13053 mp->is_add = is_add;
13054 mp->entry.sad_id = ntohl (sad_id);
13055 mp->entry.protocol = protocol;
13056 mp->entry.spi = ntohl (spi);
13057 mp->entry.flags = flags;
13059 mp->entry.crypto_algorithm = crypto_alg;
13060 mp->entry.integrity_algorithm = integ_alg;
13061 mp->entry.crypto_key.length = vec_len (ck);
13062 mp->entry.integrity_key.length = vec_len (ik);
13064 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
13065 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
13067 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
13068 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
13071 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
13073 clib_memcpy (mp->entry.integrity_key.data, ik,
13074 mp->entry.integrity_key.length);
13076 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
13078 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
13079 sizeof (mp->entry.tunnel_src));
13080 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
13081 sizeof (mp->entry.tunnel_dst));
13090 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13092 unformat_input_t *i = vam->input;
13093 vl_api_ipsec_tunnel_if_add_del_t *mp;
13094 u32 local_spi = 0, remote_spi = 0;
13095 u32 crypto_alg = 0, integ_alg = 0;
13096 u8 *lck = NULL, *rck = NULL;
13097 u8 *lik = NULL, *rik = NULL;
13098 vl_api_address_t local_ip = { 0 };
13099 vl_api_address_t remote_ip = { 0 };
13103 u8 anti_replay = 0;
13109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13111 if (unformat (i, "del"))
13113 else if (unformat (i, "esn"))
13115 else if (unformat (i, "anti-replay"))
13117 else if (unformat (i, "count %d", &count))
13119 else if (unformat (i, "local_spi %d", &local_spi))
13121 else if (unformat (i, "remote_spi %d", &remote_spi))
13124 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
13127 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
13129 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13132 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13134 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13136 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13140 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
13142 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
13144 errmsg ("unsupported crypto-alg: '%U'\n",
13145 format_ipsec_crypto_alg, crypto_alg);
13151 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
13153 if (integ_alg >= IPSEC_INTEG_N_ALG)
13155 errmsg ("unsupported integ-alg: '%U'\n",
13156 format_ipsec_integ_alg, integ_alg);
13160 else if (unformat (i, "instance %u", &instance))
13164 errmsg ("parse error '%U'\n", format_unformat_error, i);
13171 /* Turn on async mode */
13172 vam->async_mode = 1;
13173 vam->async_errors = 0;
13174 before = vat_time_now (vam);
13177 for (jj = 0; jj < count; jj++)
13179 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13181 mp->is_add = is_add;
13183 mp->anti_replay = anti_replay;
13186 increment_address (&remote_ip);
13188 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
13189 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
13191 mp->local_spi = htonl (local_spi + jj);
13192 mp->remote_spi = htonl (remote_spi + jj);
13193 mp->crypto_alg = (u8) crypto_alg;
13195 mp->local_crypto_key_len = 0;
13198 mp->local_crypto_key_len = vec_len (lck);
13199 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13200 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13201 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13204 mp->remote_crypto_key_len = 0;
13207 mp->remote_crypto_key_len = vec_len (rck);
13208 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13209 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13210 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13213 mp->integ_alg = (u8) integ_alg;
13215 mp->local_integ_key_len = 0;
13218 mp->local_integ_key_len = vec_len (lik);
13219 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13220 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13221 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13224 mp->remote_integ_key_len = 0;
13227 mp->remote_integ_key_len = vec_len (rik);
13228 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13229 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13230 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13235 mp->renumber = renumber;
13236 mp->show_instance = ntohl (instance);
13241 /* When testing multiple add/del ops, use a control-ping to sync */
13244 vl_api_control_ping_t *mp_ping;
13248 /* Shut off async mode */
13249 vam->async_mode = 0;
13251 MPING (CONTROL_PING, mp_ping);
13254 timeout = vat_time_now (vam) + 1.0;
13255 while (vat_time_now (vam) < timeout)
13256 if (vam->result_ready == 1)
13261 if (vam->retval == -99)
13262 errmsg ("timeout");
13264 if (vam->async_errors > 0)
13266 errmsg ("%d asynchronous errors", vam->async_errors);
13269 vam->async_errors = 0;
13270 after = vat_time_now (vam);
13272 /* slim chance, but we might have eaten SIGTERM on the first iteration */
13276 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
13277 count, after - before, count / (after - before));
13281 /* Wait for a reply... */
13290 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
13292 vat_main_t *vam = &vat_main;
13294 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
13295 "crypto_key %U integ_alg %u integ_key %U flags %x "
13296 "tunnel_src_addr %U tunnel_dst_addr %U "
13297 "salt %u seq_outbound %lu last_seq_inbound %lu "
13298 "replay_window %lu stat_index %u\n",
13299 ntohl (mp->entry.sad_id),
13300 ntohl (mp->sw_if_index),
13301 ntohl (mp->entry.spi),
13302 ntohl (mp->entry.protocol),
13303 ntohl (mp->entry.crypto_algorithm),
13304 format_hex_bytes, mp->entry.crypto_key.data,
13305 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
13306 format_hex_bytes, mp->entry.integrity_key.data,
13307 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
13308 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
13309 &mp->entry.tunnel_dst, ntohl (mp->salt),
13310 clib_net_to_host_u64 (mp->seq_outbound),
13311 clib_net_to_host_u64 (mp->last_seq_inbound),
13312 clib_net_to_host_u64 (mp->replay_window), ntohl (mp->stat_index));
13315 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
13316 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
13318 static void vl_api_ipsec_sa_details_t_handler_json
13319 (vl_api_ipsec_sa_details_t * mp)
13321 vat_main_t *vam = &vat_main;
13322 vat_json_node_t *node = NULL;
13323 vl_api_ipsec_sad_flags_t flags;
13325 if (VAT_JSON_ARRAY != vam->json_tree.type)
13327 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13328 vat_json_init_array (&vam->json_tree);
13330 node = vat_json_array_add (&vam->json_tree);
13332 vat_json_init_object (node);
13333 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
13334 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13335 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
13336 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
13337 vat_json_object_add_uint (node, "crypto_alg",
13338 ntohl (mp->entry.crypto_algorithm));
13339 vat_json_object_add_uint (node, "integ_alg",
13340 ntohl (mp->entry.integrity_algorithm));
13341 flags = ntohl (mp->entry.flags);
13342 vat_json_object_add_uint (node, "use_esn",
13343 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
13344 vat_json_object_add_uint (node, "use_anti_replay",
13345 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
13346 vat_json_object_add_uint (node, "is_tunnel",
13347 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
13348 vat_json_object_add_uint (node, "is_tunnel_ip6",
13349 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
13350 vat_json_object_add_uint (node, "udp_encap",
13351 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
13352 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
13353 mp->entry.crypto_key.length);
13354 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
13355 mp->entry.integrity_key.length);
13356 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
13357 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
13358 vat_json_object_add_uint (node, "replay_window",
13359 clib_net_to_host_u64 (mp->replay_window));
13360 vat_json_object_add_uint (node, "stat_index", ntohl (mp->stat_index));
13364 api_ipsec_sa_dump (vat_main_t * vam)
13366 unformat_input_t *i = vam->input;
13367 vl_api_ipsec_sa_dump_t *mp;
13368 vl_api_control_ping_t *mp_ping;
13372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13374 if (unformat (i, "sa_id %d", &sa_id))
13378 clib_warning ("parse error '%U'", format_unformat_error, i);
13383 M (IPSEC_SA_DUMP, mp);
13385 mp->sa_id = ntohl (sa_id);
13389 /* Use a control ping for synchronization */
13390 M (CONTROL_PING, mp_ping);
13398 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
13400 unformat_input_t *i = vam->input;
13401 vl_api_ipsec_tunnel_if_set_sa_t *mp;
13402 u32 sw_if_index = ~0;
13404 u8 is_outbound = (u8) ~ 0;
13407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13409 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13411 else if (unformat (i, "sa_id %d", &sa_id))
13413 else if (unformat (i, "outbound"))
13415 else if (unformat (i, "inbound"))
13419 clib_warning ("parse error '%U'", format_unformat_error, i);
13424 if (sw_if_index == ~0)
13426 errmsg ("interface must be specified");
13432 errmsg ("SA ID must be specified");
13436 M (IPSEC_TUNNEL_IF_SET_SA, mp);
13438 mp->sw_if_index = htonl (sw_if_index);
13439 mp->sa_id = htonl (sa_id);
13440 mp->is_outbound = is_outbound;
13449 api_get_first_msg_id (vat_main_t * vam)
13451 vl_api_get_first_msg_id_t *mp;
13452 unformat_input_t *i = vam->input;
13457 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13459 if (unformat (i, "client %s", &name))
13467 errmsg ("missing client name");
13470 vec_add1 (name, 0);
13472 if (vec_len (name) > 63)
13474 errmsg ("client name too long");
13478 M (GET_FIRST_MSG_ID, mp);
13479 clib_memcpy (mp->name, name, vec_len (name));
13486 api_cop_interface_enable_disable (vat_main_t * vam)
13488 unformat_input_t *line_input = vam->input;
13489 vl_api_cop_interface_enable_disable_t *mp;
13490 u32 sw_if_index = ~0;
13491 u8 enable_disable = 1;
13494 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13496 if (unformat (line_input, "disable"))
13497 enable_disable = 0;
13498 if (unformat (line_input, "enable"))
13499 enable_disable = 1;
13500 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13501 vam, &sw_if_index))
13503 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13509 if (sw_if_index == ~0)
13511 errmsg ("missing interface name or sw_if_index");
13515 /* Construct the API message */
13516 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13517 mp->sw_if_index = ntohl (sw_if_index);
13518 mp->enable_disable = enable_disable;
13522 /* Wait for the reply */
13528 api_cop_whitelist_enable_disable (vat_main_t * vam)
13530 unformat_input_t *line_input = vam->input;
13531 vl_api_cop_whitelist_enable_disable_t *mp;
13532 u32 sw_if_index = ~0;
13533 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13537 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13539 if (unformat (line_input, "ip4"))
13541 else if (unformat (line_input, "ip6"))
13543 else if (unformat (line_input, "default"))
13545 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13546 vam, &sw_if_index))
13548 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13550 else if (unformat (line_input, "fib-id %d", &fib_id))
13556 if (sw_if_index == ~0)
13558 errmsg ("missing interface name or sw_if_index");
13562 /* Construct the API message */
13563 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13564 mp->sw_if_index = ntohl (sw_if_index);
13565 mp->fib_id = ntohl (fib_id);
13568 mp->default_cop = default_cop;
13572 /* Wait for the reply */
13578 api_get_node_graph (vat_main_t * vam)
13580 vl_api_get_node_graph_t *mp;
13583 M (GET_NODE_GRAPH, mp);
13587 /* Wait for the reply */
13593 /** Used for parsing LISP eids */
13594 typedef CLIB_PACKED(struct{
13598 lisp_nsh_api_t nsh;
13600 u32 len; /**< prefix length if IP */
13601 u8 type; /**< type of eid */
13606 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13608 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13610 clib_memset (a, 0, sizeof (a[0]));
13612 if (unformat (input, "%U/%d", unformat_ip46_address, a->addr.ip, &a->len))
13614 a->type = 0; /* ip prefix type */
13616 else if (unformat (input, "%U", unformat_ethernet_address, &a->addr.mac))
13618 a->type = 1; /* mac type */
13620 else if (unformat (input, "%U", unformat_nsh_address, a->addr.nsh))
13622 a->type = 2; /* NSH type */
13623 a->addr.nsh.spi = clib_host_to_net_u32 (a->addr.nsh.spi);
13632 if (ip46_address_is_ip4 (&a->addr.ip))
13633 return a->len > 32 ? 1 : 0;
13635 return a->len > 128 ? 1 : 0;
13642 lisp_eid_put_vat (vl_api_eid_t * eid, const lisp_eid_vat_t * vat_eid)
13644 eid->type = vat_eid->type;
13647 case EID_TYPE_API_PREFIX:
13648 if (ip46_address_is_ip4 (&vat_eid->addr.ip))
13650 clib_memcpy (&eid->address.prefix.address.un.ip4,
13651 &vat_eid->addr.ip.ip4, 4);
13652 eid->address.prefix.address.af = ADDRESS_IP4;
13653 eid->address.prefix.len = vat_eid->len;
13657 clib_memcpy (&eid->address.prefix.address.un.ip6,
13658 &vat_eid->addr.ip.ip6, 16);
13659 eid->address.prefix.address.af = ADDRESS_IP6;
13660 eid->address.prefix.len = vat_eid->len;
13663 case EID_TYPE_API_MAC:
13664 clib_memcpy (&eid->address.mac, &vat_eid->addr.mac,
13665 sizeof (eid->address.mac));
13667 case EID_TYPE_API_NSH:
13668 clib_memcpy (&eid->address.nsh, &vat_eid->addr.nsh,
13669 sizeof (eid->address.nsh));
13678 api_one_add_del_locator_set (vat_main_t * vam)
13680 unformat_input_t *input = vam->input;
13681 vl_api_one_add_del_locator_set_t *mp;
13683 u8 *locator_set_name = NULL;
13684 u8 locator_set_name_set = 0;
13685 vl_api_local_locator_t locator, *locators = 0;
13686 u32 sw_if_index, priority, weight;
13690 /* Parse args required to build the message */
13691 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13693 if (unformat (input, "del"))
13697 else if (unformat (input, "locator-set %s", &locator_set_name))
13699 locator_set_name_set = 1;
13701 else if (unformat (input, "sw_if_index %u p %u w %u",
13702 &sw_if_index, &priority, &weight))
13704 locator.sw_if_index = htonl (sw_if_index);
13705 locator.priority = priority;
13706 locator.weight = weight;
13707 vec_add1 (locators, locator);
13711 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13712 &sw_if_index, &priority, &weight))
13714 locator.sw_if_index = htonl (sw_if_index);
13715 locator.priority = priority;
13716 locator.weight = weight;
13717 vec_add1 (locators, locator);
13723 if (locator_set_name_set == 0)
13725 errmsg ("missing locator-set name");
13726 vec_free (locators);
13730 if (vec_len (locator_set_name) > 64)
13732 errmsg ("locator-set name too long");
13733 vec_free (locator_set_name);
13734 vec_free (locators);
13737 vec_add1 (locator_set_name, 0);
13739 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13741 /* Construct the API message */
13742 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13744 mp->is_add = is_add;
13745 clib_memcpy (mp->locator_set_name, locator_set_name,
13746 vec_len (locator_set_name));
13747 vec_free (locator_set_name);
13749 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13751 clib_memcpy (mp->locators, locators, data_len);
13752 vec_free (locators);
13757 /* Wait for a reply... */
13762 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13765 api_one_add_del_locator (vat_main_t * vam)
13767 unformat_input_t *input = vam->input;
13768 vl_api_one_add_del_locator_t *mp;
13769 u32 tmp_if_index = ~0;
13770 u32 sw_if_index = ~0;
13771 u8 sw_if_index_set = 0;
13772 u8 sw_if_index_if_name_set = 0;
13774 u8 priority_set = 0;
13778 u8 *locator_set_name = NULL;
13779 u8 locator_set_name_set = 0;
13782 /* Parse args required to build the message */
13783 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13785 if (unformat (input, "del"))
13789 else if (unformat (input, "locator-set %s", &locator_set_name))
13791 locator_set_name_set = 1;
13793 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13796 sw_if_index_if_name_set = 1;
13797 sw_if_index = tmp_if_index;
13799 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13801 sw_if_index_set = 1;
13802 sw_if_index = tmp_if_index;
13804 else if (unformat (input, "p %d", &priority))
13808 else if (unformat (input, "w %d", &weight))
13816 if (locator_set_name_set == 0)
13818 errmsg ("missing locator-set name");
13822 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13824 errmsg ("missing sw_if_index");
13825 vec_free (locator_set_name);
13829 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13831 errmsg ("cannot use both params interface name and sw_if_index");
13832 vec_free (locator_set_name);
13836 if (priority_set == 0)
13838 errmsg ("missing locator-set priority");
13839 vec_free (locator_set_name);
13843 if (weight_set == 0)
13845 errmsg ("missing locator-set weight");
13846 vec_free (locator_set_name);
13850 if (vec_len (locator_set_name) > 64)
13852 errmsg ("locator-set name too long");
13853 vec_free (locator_set_name);
13856 vec_add1 (locator_set_name, 0);
13858 /* Construct the API message */
13859 M (ONE_ADD_DEL_LOCATOR, mp);
13861 mp->is_add = is_add;
13862 mp->sw_if_index = ntohl (sw_if_index);
13863 mp->priority = priority;
13864 mp->weight = weight;
13865 clib_memcpy (mp->locator_set_name, locator_set_name,
13866 vec_len (locator_set_name));
13867 vec_free (locator_set_name);
13872 /* Wait for a reply... */
13877 #define api_lisp_add_del_locator api_one_add_del_locator
13880 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13882 u32 *key_id = va_arg (*args, u32 *);
13885 if (unformat (input, "%s", &s))
13887 if (!strcmp ((char *) s, "sha1"))
13888 key_id[0] = HMAC_SHA_1_96;
13889 else if (!strcmp ((char *) s, "sha256"))
13890 key_id[0] = HMAC_SHA_256_128;
13893 clib_warning ("invalid key_id: '%s'", s);
13894 key_id[0] = HMAC_NO_KEY;
13905 api_one_add_del_local_eid (vat_main_t * vam)
13907 unformat_input_t *input = vam->input;
13908 vl_api_one_add_del_local_eid_t *mp;
13911 lisp_eid_vat_t _eid, *eid = &_eid;
13912 u8 *locator_set_name = 0;
13913 u8 locator_set_name_set = 0;
13919 /* Parse args required to build the message */
13920 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13922 if (unformat (input, "del"))
13926 else if (unformat (input, "vni %d", &vni))
13930 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13934 else if (unformat (input, "locator-set %s", &locator_set_name))
13936 locator_set_name_set = 1;
13938 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13940 else if (unformat (input, "secret-key %_%v%_", &key))
13946 if (locator_set_name_set == 0)
13948 errmsg ("missing locator-set name");
13954 errmsg ("EID address not set!");
13955 vec_free (locator_set_name);
13959 if (key && (0 == key_id))
13961 errmsg ("invalid key_id!");
13965 if (vec_len (key) > 64)
13967 errmsg ("key too long");
13972 if (vec_len (locator_set_name) > 64)
13974 errmsg ("locator-set name too long");
13975 vec_free (locator_set_name);
13978 vec_add1 (locator_set_name, 0);
13980 /* Construct the API message */
13981 M (ONE_ADD_DEL_LOCAL_EID, mp);
13983 mp->is_add = is_add;
13984 lisp_eid_put_vat (&mp->eid, eid);
13985 mp->vni = clib_host_to_net_u32 (vni);
13986 mp->key.id = key_id;
13987 clib_memcpy (mp->locator_set_name, locator_set_name,
13988 vec_len (locator_set_name));
13989 clib_memcpy (mp->key.key, key, vec_len (key));
13991 vec_free (locator_set_name);
13997 /* Wait for a reply... */
14002 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14005 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14007 u32 dp_table = 0, vni = 0;;
14008 unformat_input_t *input = vam->input;
14009 vl_api_gpe_add_del_fwd_entry_t *mp;
14011 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14012 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14013 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14014 u32 action = ~0, w;
14015 ip4_address_t rmt_rloc4, lcl_rloc4;
14016 ip6_address_t rmt_rloc6, lcl_rloc6;
14017 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14020 clib_memset (&rloc, 0, sizeof (rloc));
14022 /* Parse args required to build the message */
14023 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14025 if (unformat (input, "del"))
14027 else if (unformat (input, "add"))
14029 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14033 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14037 else if (unformat (input, "vrf %d", &dp_table))
14039 else if (unformat (input, "bd %d", &dp_table))
14041 else if (unformat (input, "vni %d", &vni))
14043 else if (unformat (input, "w %d", &w))
14047 errmsg ("No RLOC configured for setting priority/weight!");
14050 curr_rloc->weight = w;
14052 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14053 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14056 clib_memcpy (&rloc.addr.un.ip4, &lcl_rloc4, sizeof (lcl_rloc4));
14058 vec_add1 (lcl_locs, rloc);
14060 clib_memcpy (&rloc.addr.un.ip4, &rmt_rloc4, sizeof (rmt_rloc4));
14061 vec_add1 (rmt_locs, rloc);
14062 /* weight saved in rmt loc */
14063 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14065 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14066 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14069 clib_memcpy (&rloc.addr.un.ip6, &lcl_rloc6, sizeof (lcl_rloc6));
14071 vec_add1 (lcl_locs, rloc);
14073 clib_memcpy (&rloc.addr.un.ip6, &rmt_rloc6, sizeof (rmt_rloc6));
14074 vec_add1 (rmt_locs, rloc);
14075 /* weight saved in rmt loc */
14076 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14078 else if (unformat (input, "action %d", &action))
14084 clib_warning ("parse error '%U'", format_unformat_error, input);
14091 errmsg ("remote eid addresses not set");
14095 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14097 errmsg ("eid types don't match");
14101 if (0 == rmt_locs && (u32) ~ 0 == action)
14103 errmsg ("action not set for negative mapping");
14107 /* Construct the API message */
14108 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14109 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14111 mp->is_add = is_add;
14112 lisp_eid_put_vat (&mp->rmt_eid, rmt_eid);
14113 lisp_eid_put_vat (&mp->lcl_eid, lcl_eid);
14114 mp->dp_table = clib_host_to_net_u32 (dp_table);
14115 mp->vni = clib_host_to_net_u32 (vni);
14116 mp->action = action;
14118 if (0 != rmt_locs && 0 != lcl_locs)
14120 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14121 clib_memcpy (mp->locs, lcl_locs,
14122 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14124 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14125 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14126 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14128 vec_free (lcl_locs);
14129 vec_free (rmt_locs);
14134 /* Wait for a reply... */
14140 api_one_add_del_map_server (vat_main_t * vam)
14142 unformat_input_t *input = vam->input;
14143 vl_api_one_add_del_map_server_t *mp;
14147 ip4_address_t ipv4;
14148 ip6_address_t ipv6;
14151 /* Parse args required to build the message */
14152 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14154 if (unformat (input, "del"))
14158 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14162 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14170 if (ipv4_set && ipv6_set)
14172 errmsg ("both eid v4 and v6 addresses set");
14176 if (!ipv4_set && !ipv6_set)
14178 errmsg ("eid addresses not set");
14182 /* Construct the API message */
14183 M (ONE_ADD_DEL_MAP_SERVER, mp);
14185 mp->is_add = is_add;
14188 mp->ip_address.af = 1;
14189 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
14193 mp->ip_address.af = 0;
14194 clib_memcpy (mp->ip_address.un.ip4, &ipv4, sizeof (ipv4));
14200 /* Wait for a reply... */
14205 #define api_lisp_add_del_map_server api_one_add_del_map_server
14208 api_one_add_del_map_resolver (vat_main_t * vam)
14210 unformat_input_t *input = vam->input;
14211 vl_api_one_add_del_map_resolver_t *mp;
14215 ip4_address_t ipv4;
14216 ip6_address_t ipv6;
14219 /* Parse args required to build the message */
14220 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14222 if (unformat (input, "del"))
14226 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14230 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14238 if (ipv4_set && ipv6_set)
14240 errmsg ("both eid v4 and v6 addresses set");
14244 if (!ipv4_set && !ipv6_set)
14246 errmsg ("eid addresses not set");
14250 /* Construct the API message */
14251 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14253 mp->is_add = is_add;
14256 mp->ip_address.af = 1;
14257 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
14261 mp->ip_address.af = 0;
14262 clib_memcpy (mp->ip_address.un.ip6, &ipv4, sizeof (ipv4));
14268 /* Wait for a reply... */
14273 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14276 api_lisp_gpe_enable_disable (vat_main_t * vam)
14278 unformat_input_t *input = vam->input;
14279 vl_api_gpe_enable_disable_t *mp;
14284 /* Parse args required to build the message */
14285 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14287 if (unformat (input, "enable"))
14292 else if (unformat (input, "disable"))
14303 errmsg ("Value not set");
14307 /* Construct the API message */
14308 M (GPE_ENABLE_DISABLE, mp);
14310 mp->is_enable = is_enable;
14315 /* Wait for a reply... */
14321 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14323 unformat_input_t *input = vam->input;
14324 vl_api_one_rloc_probe_enable_disable_t *mp;
14329 /* Parse args required to build the message */
14330 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14332 if (unformat (input, "enable"))
14337 else if (unformat (input, "disable"))
14345 errmsg ("Value not set");
14349 /* Construct the API message */
14350 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14352 mp->is_enable = is_enable;
14357 /* Wait for a reply... */
14362 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14365 api_one_map_register_enable_disable (vat_main_t * vam)
14367 unformat_input_t *input = vam->input;
14368 vl_api_one_map_register_enable_disable_t *mp;
14373 /* Parse args required to build the message */
14374 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14376 if (unformat (input, "enable"))
14381 else if (unformat (input, "disable"))
14389 errmsg ("Value not set");
14393 /* Construct the API message */
14394 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14396 mp->is_enable = is_enable;
14401 /* Wait for a reply... */
14406 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14409 api_one_enable_disable (vat_main_t * vam)
14411 unformat_input_t *input = vam->input;
14412 vl_api_one_enable_disable_t *mp;
14417 /* Parse args required to build the message */
14418 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14420 if (unformat (input, "enable"))
14425 else if (unformat (input, "disable"))
14435 errmsg ("Value not set");
14439 /* Construct the API message */
14440 M (ONE_ENABLE_DISABLE, mp);
14442 mp->is_enable = is_enable;
14447 /* Wait for a reply... */
14452 #define api_lisp_enable_disable api_one_enable_disable
14455 api_one_enable_disable_xtr_mode (vat_main_t * vam)
14457 unformat_input_t *input = vam->input;
14458 vl_api_one_enable_disable_xtr_mode_t *mp;
14463 /* Parse args required to build the message */
14464 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14466 if (unformat (input, "enable"))
14471 else if (unformat (input, "disable"))
14481 errmsg ("Value not set");
14485 /* Construct the API message */
14486 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
14488 mp->is_enable = is_enable;
14493 /* Wait for a reply... */
14499 api_one_show_xtr_mode (vat_main_t * vam)
14501 vl_api_one_show_xtr_mode_t *mp;
14504 /* Construct the API message */
14505 M (ONE_SHOW_XTR_MODE, mp);
14510 /* Wait for a reply... */
14516 api_one_enable_disable_pitr_mode (vat_main_t * vam)
14518 unformat_input_t *input = vam->input;
14519 vl_api_one_enable_disable_pitr_mode_t *mp;
14524 /* Parse args required to build the message */
14525 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14527 if (unformat (input, "enable"))
14532 else if (unformat (input, "disable"))
14542 errmsg ("Value not set");
14546 /* Construct the API message */
14547 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
14549 mp->is_enable = is_enable;
14554 /* Wait for a reply... */
14560 api_one_show_pitr_mode (vat_main_t * vam)
14562 vl_api_one_show_pitr_mode_t *mp;
14565 /* Construct the API message */
14566 M (ONE_SHOW_PITR_MODE, mp);
14571 /* Wait for a reply... */
14577 api_one_enable_disable_petr_mode (vat_main_t * vam)
14579 unformat_input_t *input = vam->input;
14580 vl_api_one_enable_disable_petr_mode_t *mp;
14585 /* Parse args required to build the message */
14586 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14588 if (unformat (input, "enable"))
14593 else if (unformat (input, "disable"))
14603 errmsg ("Value not set");
14607 /* Construct the API message */
14608 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
14610 mp->is_enable = is_enable;
14615 /* Wait for a reply... */
14621 api_one_show_petr_mode (vat_main_t * vam)
14623 vl_api_one_show_petr_mode_t *mp;
14626 /* Construct the API message */
14627 M (ONE_SHOW_PETR_MODE, mp);
14632 /* Wait for a reply... */
14638 api_show_one_map_register_state (vat_main_t * vam)
14640 vl_api_show_one_map_register_state_t *mp;
14643 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14648 /* wait for reply */
14653 #define api_show_lisp_map_register_state api_show_one_map_register_state
14656 api_show_one_rloc_probe_state (vat_main_t * vam)
14658 vl_api_show_one_rloc_probe_state_t *mp;
14661 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14666 /* wait for reply */
14671 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14674 api_one_add_del_ndp_entry (vat_main_t * vam)
14676 vl_api_one_add_del_ndp_entry_t *mp;
14677 unformat_input_t *input = vam->input;
14682 u8 mac[6] = { 0, };
14683 u8 ip6[16] = { 0, };
14687 /* Parse args required to build the message */
14688 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14690 if (unformat (input, "del"))
14692 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
14694 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
14696 else if (unformat (input, "bd %d", &bd))
14700 errmsg ("parse error '%U'", format_unformat_error, input);
14705 if (!bd_set || !ip_set || (!mac_set && is_add))
14707 errmsg ("Missing BD, IP or MAC!");
14711 M (ONE_ADD_DEL_NDP_ENTRY, mp);
14712 mp->is_add = is_add;
14713 clib_memcpy (&mp->entry.mac, mac, 6);
14714 mp->bd = clib_host_to_net_u32 (bd);
14715 clib_memcpy (&mp->entry.ip6, ip6, sizeof (mp->entry.ip6));
14720 /* wait for reply */
14726 api_one_add_del_l2_arp_entry (vat_main_t * vam)
14728 vl_api_one_add_del_l2_arp_entry_t *mp;
14729 unformat_input_t *input = vam->input;
14734 u8 mac[6] = { 0, };
14735 u32 ip4 = 0, bd = ~0;
14738 /* Parse args required to build the message */
14739 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14741 if (unformat (input, "del"))
14743 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
14745 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
14747 else if (unformat (input, "bd %d", &bd))
14751 errmsg ("parse error '%U'", format_unformat_error, input);
14756 if (!bd_set || !ip_set || (!mac_set && is_add))
14758 errmsg ("Missing BD, IP or MAC!");
14762 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
14763 mp->is_add = is_add;
14764 clib_memcpy (&mp->entry.mac, mac, 6);
14765 mp->bd = clib_host_to_net_u32 (bd);
14766 clib_memcpy (mp->entry.ip4, &ip4, sizeof (mp->entry.ip4));
14771 /* wait for reply */
14777 api_one_ndp_bd_get (vat_main_t * vam)
14779 vl_api_one_ndp_bd_get_t *mp;
14782 M (ONE_NDP_BD_GET, mp);
14787 /* wait for reply */
14793 api_one_ndp_entries_get (vat_main_t * vam)
14795 vl_api_one_ndp_entries_get_t *mp;
14796 unformat_input_t *input = vam->input;
14801 /* Parse args required to build the message */
14802 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14804 if (unformat (input, "bd %d", &bd))
14808 errmsg ("parse error '%U'", format_unformat_error, input);
14815 errmsg ("Expected bridge domain!");
14819 M (ONE_NDP_ENTRIES_GET, mp);
14820 mp->bd = clib_host_to_net_u32 (bd);
14825 /* wait for reply */
14831 api_one_l2_arp_bd_get (vat_main_t * vam)
14833 vl_api_one_l2_arp_bd_get_t *mp;
14836 M (ONE_L2_ARP_BD_GET, mp);
14841 /* wait for reply */
14847 api_one_l2_arp_entries_get (vat_main_t * vam)
14849 vl_api_one_l2_arp_entries_get_t *mp;
14850 unformat_input_t *input = vam->input;
14855 /* Parse args required to build the message */
14856 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14858 if (unformat (input, "bd %d", &bd))
14862 errmsg ("parse error '%U'", format_unformat_error, input);
14869 errmsg ("Expected bridge domain!");
14873 M (ONE_L2_ARP_ENTRIES_GET, mp);
14874 mp->bd = clib_host_to_net_u32 (bd);
14879 /* wait for reply */
14885 api_one_stats_enable_disable (vat_main_t * vam)
14887 vl_api_one_stats_enable_disable_t *mp;
14888 unformat_input_t *input = vam->input;
14893 /* Parse args required to build the message */
14894 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14896 if (unformat (input, "enable"))
14901 else if (unformat (input, "disable"))
14911 errmsg ("Value not set");
14915 M (ONE_STATS_ENABLE_DISABLE, mp);
14916 mp->is_enable = is_enable;
14921 /* wait for reply */
14927 api_show_one_stats_enable_disable (vat_main_t * vam)
14929 vl_api_show_one_stats_enable_disable_t *mp;
14932 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
14937 /* wait for reply */
14943 api_show_one_map_request_mode (vat_main_t * vam)
14945 vl_api_show_one_map_request_mode_t *mp;
14948 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14953 /* wait for reply */
14958 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14961 api_one_map_request_mode (vat_main_t * vam)
14963 unformat_input_t *input = vam->input;
14964 vl_api_one_map_request_mode_t *mp;
14968 /* Parse args required to build the message */
14969 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14971 if (unformat (input, "dst-only"))
14973 else if (unformat (input, "src-dst"))
14977 errmsg ("parse error '%U'", format_unformat_error, input);
14982 M (ONE_MAP_REQUEST_MODE, mp);
14989 /* wait for reply */
14994 #define api_lisp_map_request_mode api_one_map_request_mode
14997 * Enable/disable ONE proxy ITR.
14999 * @param vam vpp API test context
15000 * @return return code
15003 api_one_pitr_set_locator_set (vat_main_t * vam)
15005 u8 ls_name_set = 0;
15006 unformat_input_t *input = vam->input;
15007 vl_api_one_pitr_set_locator_set_t *mp;
15012 /* Parse args required to build the message */
15013 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15015 if (unformat (input, "del"))
15017 else if (unformat (input, "locator-set %s", &ls_name))
15021 errmsg ("parse error '%U'", format_unformat_error, input);
15028 errmsg ("locator-set name not set!");
15032 M (ONE_PITR_SET_LOCATOR_SET, mp);
15034 mp->is_add = is_add;
15035 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15036 vec_free (ls_name);
15041 /* wait for reply */
15046 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15049 api_one_nsh_set_locator_set (vat_main_t * vam)
15051 u8 ls_name_set = 0;
15052 unformat_input_t *input = vam->input;
15053 vl_api_one_nsh_set_locator_set_t *mp;
15058 /* Parse args required to build the message */
15059 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15061 if (unformat (input, "del"))
15063 else if (unformat (input, "ls %s", &ls_name))
15067 errmsg ("parse error '%U'", format_unformat_error, input);
15072 if (!ls_name_set && is_add)
15074 errmsg ("locator-set name not set!");
15078 M (ONE_NSH_SET_LOCATOR_SET, mp);
15080 mp->is_add = is_add;
15081 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15082 vec_free (ls_name);
15087 /* wait for reply */
15093 api_show_one_pitr (vat_main_t * vam)
15095 vl_api_show_one_pitr_t *mp;
15098 if (!vam->json_output)
15100 print (vam->ofp, "%=20s", "lisp status:");
15103 M (SHOW_ONE_PITR, mp);
15107 /* Wait for a reply... */
15112 #define api_show_lisp_pitr api_show_one_pitr
15115 api_one_use_petr (vat_main_t * vam)
15117 unformat_input_t *input = vam->input;
15118 vl_api_one_use_petr_t *mp;
15123 clib_memset (&ip, 0, sizeof (ip));
15125 /* Parse args required to build the message */
15126 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15128 if (unformat (input, "disable"))
15131 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15134 ip_addr_version (&ip) = AF_IP4;
15137 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15140 ip_addr_version (&ip) = AF_IP6;
15144 errmsg ("parse error '%U'", format_unformat_error, input);
15149 M (ONE_USE_PETR, mp);
15151 mp->is_add = is_add;
15154 mp->ip_address.af = ip_addr_version (&ip) == AF_IP4 ? 0 : 1;
15155 if (mp->ip_address.af)
15156 clib_memcpy (mp->ip_address.un.ip6, &ip, 16);
15158 clib_memcpy (mp->ip_address.un.ip4, &ip, 4);
15164 /* wait for reply */
15169 #define api_lisp_use_petr api_one_use_petr
15172 api_show_one_nsh_mapping (vat_main_t * vam)
15174 vl_api_show_one_use_petr_t *mp;
15177 if (!vam->json_output)
15179 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15182 M (SHOW_ONE_NSH_MAPPING, mp);
15186 /* Wait for a reply... */
15192 api_show_one_use_petr (vat_main_t * vam)
15194 vl_api_show_one_use_petr_t *mp;
15197 if (!vam->json_output)
15199 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15202 M (SHOW_ONE_USE_PETR, mp);
15206 /* Wait for a reply... */
15211 #define api_show_lisp_use_petr api_show_one_use_petr
15214 * Add/delete mapping between vni and vrf
15217 api_one_eid_table_add_del_map (vat_main_t * vam)
15219 unformat_input_t *input = vam->input;
15220 vl_api_one_eid_table_add_del_map_t *mp;
15221 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15222 u32 vni, vrf, bd_index;
15225 /* Parse args required to build the message */
15226 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15228 if (unformat (input, "del"))
15230 else if (unformat (input, "vrf %d", &vrf))
15232 else if (unformat (input, "bd_index %d", &bd_index))
15234 else if (unformat (input, "vni %d", &vni))
15240 if (!vni_set || (!vrf_set && !bd_index_set))
15242 errmsg ("missing arguments!");
15246 if (vrf_set && bd_index_set)
15248 errmsg ("error: both vrf and bd entered!");
15252 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15254 mp->is_add = is_add;
15255 mp->vni = htonl (vni);
15256 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15257 mp->is_l2 = bd_index_set;
15262 /* wait for reply */
15267 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15270 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15272 u32 *action = va_arg (*args, u32 *);
15275 if (unformat (input, "%s", &s))
15277 if (!strcmp ((char *) s, "no-action"))
15279 else if (!strcmp ((char *) s, "natively-forward"))
15281 else if (!strcmp ((char *) s, "send-map-request"))
15283 else if (!strcmp ((char *) s, "drop"))
15287 clib_warning ("invalid action: '%s'", s);
15299 * Add/del remote mapping to/from ONE control plane
15301 * @param vam vpp API test context
15302 * @return return code
15305 api_one_add_del_remote_mapping (vat_main_t * vam)
15307 unformat_input_t *input = vam->input;
15308 vl_api_one_add_del_remote_mapping_t *mp;
15310 lisp_eid_vat_t _eid, *eid = &_eid;
15311 lisp_eid_vat_t _seid, *seid = &_seid;
15312 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15313 u32 action = ~0, p, w, data_len;
15314 ip4_address_t rloc4;
15315 ip6_address_t rloc6;
15316 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15319 clib_memset (&rloc, 0, sizeof (rloc));
15321 /* Parse args required to build the message */
15322 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15324 if (unformat (input, "del-all"))
15328 else if (unformat (input, "del"))
15332 else if (unformat (input, "add"))
15336 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15340 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15344 else if (unformat (input, "vni %d", &vni))
15348 else if (unformat (input, "p %d w %d", &p, &w))
15352 errmsg ("No RLOC configured for setting priority/weight!");
15355 curr_rloc->priority = p;
15356 curr_rloc->weight = w;
15358 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15360 rloc.ip_address.af = 0;
15361 clib_memcpy (&rloc.ip_address.un.ip6, &rloc6, sizeof (rloc6));
15362 vec_add1 (rlocs, rloc);
15363 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15365 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15367 rloc.ip_address.af = 1;
15368 clib_memcpy (&rloc.ip_address.un.ip4, &rloc4, sizeof (rloc4));
15369 vec_add1 (rlocs, rloc);
15370 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15372 else if (unformat (input, "action %U",
15373 unformat_negative_mapping_action, &action))
15379 clib_warning ("parse error '%U'", format_unformat_error, input);
15386 errmsg ("missing params!");
15390 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15392 errmsg ("no action set for negative map-reply!");
15396 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15398 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15399 mp->is_add = is_add;
15400 mp->vni = htonl (vni);
15401 mp->action = (u8) action;
15402 mp->is_src_dst = seid_set;
15403 mp->del_all = del_all;
15404 lisp_eid_put_vat (&mp->deid, eid);
15405 lisp_eid_put_vat (&mp->seid, seid);
15407 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15408 clib_memcpy (mp->rlocs, rlocs, data_len);
15414 /* Wait for a reply... */
15419 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15422 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15423 * forwarding entries in data-plane accordingly.
15425 * @param vam vpp API test context
15426 * @return return code
15429 api_one_add_del_adjacency (vat_main_t * vam)
15431 unformat_input_t *input = vam->input;
15432 vl_api_one_add_del_adjacency_t *mp;
15436 lisp_eid_vat_t leid, reid;
15438 leid.type = reid.type = (u8) ~ 0;
15440 /* Parse args required to build the message */
15441 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15443 if (unformat (input, "del"))
15447 else if (unformat (input, "add"))
15451 else if (unformat (input, "reid %U/%d", unformat_ip46_address,
15452 &reid.addr.ip, &reid.len))
15454 reid.type = 0; /* ipv4 */
15456 else if (unformat (input, "reid %U", unformat_ethernet_address,
15459 reid.type = 1; /* mac */
15461 else if (unformat (input, "leid %U/%d", unformat_ip46_address,
15462 &leid.addr.ip, &leid.len))
15464 leid.type = 0; /* ipv4 */
15466 else if (unformat (input, "leid %U", unformat_ethernet_address,
15469 leid.type = 1; /* mac */
15471 else if (unformat (input, "vni %d", &vni))
15477 errmsg ("parse error '%U'", format_unformat_error, input);
15482 if ((u8) ~ 0 == reid.type)
15484 errmsg ("missing params!");
15488 if (leid.type != reid.type)
15490 errmsg ("remote and local EIDs are of different types!");
15494 M (ONE_ADD_DEL_ADJACENCY, mp);
15495 mp->is_add = is_add;
15496 mp->vni = htonl (vni);
15497 lisp_eid_put_vat (&mp->leid, &leid);
15498 lisp_eid_put_vat (&mp->reid, &reid);
15503 /* Wait for a reply... */
15508 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15511 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15513 u32 *mode = va_arg (*args, u32 *);
15515 if (unformat (input, "lisp"))
15517 else if (unformat (input, "vxlan"))
15526 api_gpe_get_encap_mode (vat_main_t * vam)
15528 vl_api_gpe_get_encap_mode_t *mp;
15531 /* Construct the API message */
15532 M (GPE_GET_ENCAP_MODE, mp);
15537 /* Wait for a reply... */
15543 api_gpe_set_encap_mode (vat_main_t * vam)
15545 unformat_input_t *input = vam->input;
15546 vl_api_gpe_set_encap_mode_t *mp;
15550 /* Parse args required to build the message */
15551 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15553 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15559 /* Construct the API message */
15560 M (GPE_SET_ENCAP_MODE, mp);
15562 mp->is_vxlan = mode;
15567 /* Wait for a reply... */
15573 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15575 unformat_input_t *input = vam->input;
15576 vl_api_gpe_add_del_iface_t *mp;
15577 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15578 u32 dp_table = 0, vni = 0;
15581 /* Parse args required to build the message */
15582 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15584 if (unformat (input, "up"))
15589 else if (unformat (input, "down"))
15594 else if (unformat (input, "table_id %d", &dp_table))
15598 else if (unformat (input, "bd_id %d", &dp_table))
15603 else if (unformat (input, "vni %d", &vni))
15611 if (action_set == 0)
15613 errmsg ("Action not set");
15616 if (dp_table_set == 0 || vni_set == 0)
15618 errmsg ("vni and dp_table must be set");
15622 /* Construct the API message */
15623 M (GPE_ADD_DEL_IFACE, mp);
15625 mp->is_add = is_add;
15626 mp->dp_table = clib_host_to_net_u32 (dp_table);
15628 mp->vni = clib_host_to_net_u32 (vni);
15633 /* Wait for a reply... */
15639 api_one_map_register_fallback_threshold (vat_main_t * vam)
15641 unformat_input_t *input = vam->input;
15642 vl_api_one_map_register_fallback_threshold_t *mp;
15647 /* Parse args required to build the message */
15648 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15650 if (unformat (input, "%u", &value))
15654 clib_warning ("parse error '%U'", format_unformat_error, input);
15661 errmsg ("fallback threshold value is missing!");
15665 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
15666 mp->value = clib_host_to_net_u32 (value);
15671 /* Wait for a reply... */
15677 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
15679 vl_api_show_one_map_register_fallback_threshold_t *mp;
15682 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
15687 /* Wait for a reply... */
15693 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
15695 u32 *proto = va_arg (*args, u32 *);
15697 if (unformat (input, "udp"))
15699 else if (unformat (input, "api"))
15708 api_one_set_transport_protocol (vat_main_t * vam)
15710 unformat_input_t *input = vam->input;
15711 vl_api_one_set_transport_protocol_t *mp;
15716 /* Parse args required to build the message */
15717 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15719 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
15723 clib_warning ("parse error '%U'", format_unformat_error, input);
15730 errmsg ("Transport protocol missing!");
15734 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
15735 mp->protocol = (u8) protocol;
15740 /* Wait for a reply... */
15746 api_one_get_transport_protocol (vat_main_t * vam)
15748 vl_api_one_get_transport_protocol_t *mp;
15751 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
15756 /* Wait for a reply... */
15762 api_one_map_register_set_ttl (vat_main_t * vam)
15764 unformat_input_t *input = vam->input;
15765 vl_api_one_map_register_set_ttl_t *mp;
15770 /* Parse args required to build the message */
15771 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15773 if (unformat (input, "%u", &ttl))
15777 clib_warning ("parse error '%U'", format_unformat_error, input);
15784 errmsg ("TTL value missing!");
15788 M (ONE_MAP_REGISTER_SET_TTL, mp);
15789 mp->ttl = clib_host_to_net_u32 (ttl);
15794 /* Wait for a reply... */
15800 api_show_one_map_register_ttl (vat_main_t * vam)
15802 vl_api_show_one_map_register_ttl_t *mp;
15805 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
15810 /* Wait for a reply... */
15816 * Add/del map request itr rlocs from ONE control plane and updates
15818 * @param vam vpp API test context
15819 * @return return code
15822 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
15824 unformat_input_t *input = vam->input;
15825 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
15826 u8 *locator_set_name = 0;
15827 u8 locator_set_name_set = 0;
15831 /* Parse args required to build the message */
15832 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15834 if (unformat (input, "del"))
15838 else if (unformat (input, "%_%v%_", &locator_set_name))
15840 locator_set_name_set = 1;
15844 clib_warning ("parse error '%U'", format_unformat_error, input);
15849 if (is_add && !locator_set_name_set)
15851 errmsg ("itr-rloc is not set!");
15855 if (is_add && vec_len (locator_set_name) > 64)
15857 errmsg ("itr-rloc locator-set name too long");
15858 vec_free (locator_set_name);
15862 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
15863 mp->is_add = is_add;
15866 clib_memcpy (mp->locator_set_name, locator_set_name,
15867 vec_len (locator_set_name));
15871 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
15873 vec_free (locator_set_name);
15878 /* Wait for a reply... */
15883 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
15886 api_one_locator_dump (vat_main_t * vam)
15888 unformat_input_t *input = vam->input;
15889 vl_api_one_locator_dump_t *mp;
15890 vl_api_control_ping_t *mp_ping;
15891 u8 is_index_set = 0, is_name_set = 0;
15896 /* Parse args required to build the message */
15897 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15899 if (unformat (input, "ls_name %_%v%_", &ls_name))
15903 else if (unformat (input, "ls_index %d", &ls_index))
15909 errmsg ("parse error '%U'", format_unformat_error, input);
15914 if (!is_index_set && !is_name_set)
15916 errmsg ("error: expected one of index or name!");
15920 if (is_index_set && is_name_set)
15922 errmsg ("error: only one param expected!");
15926 if (vec_len (ls_name) > 62)
15928 errmsg ("error: locator set name too long!");
15932 if (!vam->json_output)
15934 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15937 M (ONE_LOCATOR_DUMP, mp);
15938 mp->is_index_set = is_index_set;
15941 mp->ls_index = clib_host_to_net_u32 (ls_index);
15944 vec_add1 (ls_name, 0);
15945 strncpy ((char *) mp->ls_name, (char *) ls_name,
15946 sizeof (mp->ls_name) - 1);
15952 /* Use a control ping for synchronization */
15953 MPING (CONTROL_PING, mp_ping);
15956 /* Wait for a reply... */
15961 #define api_lisp_locator_dump api_one_locator_dump
15964 api_one_locator_set_dump (vat_main_t * vam)
15966 vl_api_one_locator_set_dump_t *mp;
15967 vl_api_control_ping_t *mp_ping;
15968 unformat_input_t *input = vam->input;
15972 /* Parse args required to build the message */
15973 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15975 if (unformat (input, "local"))
15979 else if (unformat (input, "remote"))
15985 errmsg ("parse error '%U'", format_unformat_error, input);
15990 if (!vam->json_output)
15992 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15995 M (ONE_LOCATOR_SET_DUMP, mp);
15997 mp->filter = filter;
16002 /* Use a control ping for synchronization */
16003 MPING (CONTROL_PING, mp_ping);
16006 /* Wait for a reply... */
16011 #define api_lisp_locator_set_dump api_one_locator_set_dump
16014 api_one_eid_table_map_dump (vat_main_t * vam)
16018 unformat_input_t *input = vam->input;
16019 vl_api_one_eid_table_map_dump_t *mp;
16020 vl_api_control_ping_t *mp_ping;
16023 /* Parse args required to build the message */
16024 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16026 if (unformat (input, "l2"))
16031 else if (unformat (input, "l3"))
16038 errmsg ("parse error '%U'", format_unformat_error, input);
16045 errmsg ("expected one of 'l2' or 'l3' parameter!");
16049 if (!vam->json_output)
16051 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16054 M (ONE_EID_TABLE_MAP_DUMP, mp);
16060 /* Use a control ping for synchronization */
16061 MPING (CONTROL_PING, mp_ping);
16064 /* Wait for a reply... */
16069 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16072 api_one_eid_table_vni_dump (vat_main_t * vam)
16074 vl_api_one_eid_table_vni_dump_t *mp;
16075 vl_api_control_ping_t *mp_ping;
16078 if (!vam->json_output)
16080 print (vam->ofp, "VNI");
16083 M (ONE_EID_TABLE_VNI_DUMP, mp);
16088 /* Use a control ping for synchronization */
16089 MPING (CONTROL_PING, mp_ping);
16092 /* Wait for a reply... */
16097 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16100 api_one_eid_table_dump (vat_main_t * vam)
16102 unformat_input_t *i = vam->input;
16103 vl_api_one_eid_table_dump_t *mp;
16104 vl_api_control_ping_t *mp_ping;
16108 lisp_eid_vat_t eid;
16111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16114 (i, "eid %U/%d", unformat_ip46_address, &eid.addr.ip, &eid.len))
16120 if (unformat (i, "eid %U", unformat_ethernet_address, &eid.addr.mac))
16125 else if (unformat (i, "eid %U", unformat_nsh_address, &eid.addr.nsh))
16130 else if (unformat (i, "vni %d", &t))
16134 else if (unformat (i, "local"))
16138 else if (unformat (i, "remote"))
16144 errmsg ("parse error '%U'", format_unformat_error, i);
16149 if (!vam->json_output)
16151 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16152 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16155 M (ONE_EID_TABLE_DUMP, mp);
16157 mp->filter = filter;
16161 mp->vni = htonl (vni);
16162 lisp_eid_put_vat (&mp->eid, &eid);
16168 /* Use a control ping for synchronization */
16169 MPING (CONTROL_PING, mp_ping);
16172 /* Wait for a reply... */
16177 #define api_lisp_eid_table_dump api_one_eid_table_dump
16180 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16182 unformat_input_t *i = vam->input;
16183 vl_api_gpe_fwd_entries_get_t *mp;
16188 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16190 if (unformat (i, "vni %d", &vni))
16196 errmsg ("parse error '%U'", format_unformat_error, i);
16203 errmsg ("vni not set!");
16207 if (!vam->json_output)
16209 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16213 M (GPE_FWD_ENTRIES_GET, mp);
16214 mp->vni = clib_host_to_net_u32 (vni);
16219 /* Wait for a reply... */
16224 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16225 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16226 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16227 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16228 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16229 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16230 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16231 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16234 api_one_adjacencies_get (vat_main_t * vam)
16236 unformat_input_t *i = vam->input;
16237 vl_api_one_adjacencies_get_t *mp;
16242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16244 if (unformat (i, "vni %d", &vni))
16250 errmsg ("parse error '%U'", format_unformat_error, i);
16257 errmsg ("vni not set!");
16261 if (!vam->json_output)
16263 print (vam->ofp, "%s %40s", "leid", "reid");
16266 M (ONE_ADJACENCIES_GET, mp);
16267 mp->vni = clib_host_to_net_u32 (vni);
16272 /* Wait for a reply... */
16277 #define api_lisp_adjacencies_get api_one_adjacencies_get
16280 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16282 unformat_input_t *i = vam->input;
16283 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16285 u8 ip_family_set = 0, is_ip4 = 1;
16287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16289 if (unformat (i, "ip4"))
16294 else if (unformat (i, "ip6"))
16301 errmsg ("parse error '%U'", format_unformat_error, i);
16306 if (!ip_family_set)
16308 errmsg ("ip family not set!");
16312 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16313 mp->is_ip4 = is_ip4;
16318 /* Wait for a reply... */
16324 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16326 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16329 if (!vam->json_output)
16331 print (vam->ofp, "VNIs");
16334 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16339 /* Wait for a reply... */
16345 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16347 unformat_input_t *i = vam->input;
16348 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16350 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16351 struct in_addr ip4;
16352 struct in6_addr ip6;
16353 u32 table_id = 0, nh_sw_if_index = ~0;
16355 clib_memset (&ip4, 0, sizeof (ip4));
16356 clib_memset (&ip6, 0, sizeof (ip6));
16358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16360 if (unformat (i, "del"))
16362 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
16363 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16368 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
16369 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16374 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
16378 nh_sw_if_index = ~0;
16380 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
16384 nh_sw_if_index = ~0;
16386 else if (unformat (i, "table %d", &table_id))
16390 errmsg ("parse error '%U'", format_unformat_error, i);
16397 errmsg ("nh addr not set!");
16401 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
16402 mp->is_add = is_add;
16403 mp->table_id = clib_host_to_net_u32 (table_id);
16404 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
16405 mp->nh_addr.af = is_ip4 ? 0 : 1;
16407 clib_memcpy (mp->nh_addr.un.ip4, &ip4, sizeof (ip4));
16409 clib_memcpy (mp->nh_addr.un.ip6, &ip6, sizeof (ip6));
16414 /* Wait for a reply... */
16420 api_one_map_server_dump (vat_main_t * vam)
16422 vl_api_one_map_server_dump_t *mp;
16423 vl_api_control_ping_t *mp_ping;
16426 if (!vam->json_output)
16428 print (vam->ofp, "%=20s", "Map server");
16431 M (ONE_MAP_SERVER_DUMP, mp);
16435 /* Use a control ping for synchronization */
16436 MPING (CONTROL_PING, mp_ping);
16439 /* Wait for a reply... */
16444 #define api_lisp_map_server_dump api_one_map_server_dump
16447 api_one_map_resolver_dump (vat_main_t * vam)
16449 vl_api_one_map_resolver_dump_t *mp;
16450 vl_api_control_ping_t *mp_ping;
16453 if (!vam->json_output)
16455 print (vam->ofp, "%=20s", "Map resolver");
16458 M (ONE_MAP_RESOLVER_DUMP, mp);
16462 /* Use a control ping for synchronization */
16463 MPING (CONTROL_PING, mp_ping);
16466 /* Wait for a reply... */
16471 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16474 api_one_stats_flush (vat_main_t * vam)
16476 vl_api_one_stats_flush_t *mp;
16479 M (ONE_STATS_FLUSH, mp);
16486 api_one_stats_dump (vat_main_t * vam)
16488 vl_api_one_stats_dump_t *mp;
16489 vl_api_control_ping_t *mp_ping;
16492 M (ONE_STATS_DUMP, mp);
16496 /* Use a control ping for synchronization */
16497 MPING (CONTROL_PING, mp_ping);
16500 /* Wait for a reply... */
16506 api_show_one_status (vat_main_t * vam)
16508 vl_api_show_one_status_t *mp;
16511 if (!vam->json_output)
16513 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16516 M (SHOW_ONE_STATUS, mp);
16519 /* Wait for a reply... */
16524 #define api_show_lisp_status api_show_one_status
16527 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16529 vl_api_gpe_fwd_entry_path_dump_t *mp;
16530 vl_api_control_ping_t *mp_ping;
16531 unformat_input_t *i = vam->input;
16532 u32 fwd_entry_index = ~0;
16535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16537 if (unformat (i, "index %d", &fwd_entry_index))
16543 if (~0 == fwd_entry_index)
16545 errmsg ("no index specified!");
16549 if (!vam->json_output)
16551 print (vam->ofp, "first line");
16554 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16558 /* Use a control ping for synchronization */
16559 MPING (CONTROL_PING, mp_ping);
16562 /* Wait for a reply... */
16568 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
16570 vl_api_one_get_map_request_itr_rlocs_t *mp;
16573 if (!vam->json_output)
16575 print (vam->ofp, "%=20s", "itr-rlocs:");
16578 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
16581 /* Wait for a reply... */
16586 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
16589 api_af_packet_create (vat_main_t * vam)
16591 unformat_input_t *i = vam->input;
16592 vl_api_af_packet_create_t *mp;
16593 u8 *host_if_name = 0;
16595 u8 random_hw_addr = 1;
16598 clib_memset (hw_addr, 0, sizeof (hw_addr));
16600 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16602 if (unformat (i, "name %s", &host_if_name))
16603 vec_add1 (host_if_name, 0);
16604 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16605 random_hw_addr = 0;
16610 if (!vec_len (host_if_name))
16612 errmsg ("host-interface name must be specified");
16616 if (vec_len (host_if_name) > 64)
16618 errmsg ("host-interface name too long");
16622 M (AF_PACKET_CREATE, mp);
16624 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16625 clib_memcpy (mp->hw_addr, hw_addr, 6);
16626 mp->use_random_hw_addr = random_hw_addr;
16627 vec_free (host_if_name);
16635 fprintf (vam->ofp ? vam->ofp : stderr,
16636 " new sw_if_index = %d\n", vam->sw_if_index);
16643 api_af_packet_delete (vat_main_t * vam)
16645 unformat_input_t *i = vam->input;
16646 vl_api_af_packet_delete_t *mp;
16647 u8 *host_if_name = 0;
16650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16652 if (unformat (i, "name %s", &host_if_name))
16653 vec_add1 (host_if_name, 0);
16658 if (!vec_len (host_if_name))
16660 errmsg ("host-interface name must be specified");
16664 if (vec_len (host_if_name) > 64)
16666 errmsg ("host-interface name too long");
16670 M (AF_PACKET_DELETE, mp);
16672 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16673 vec_free (host_if_name);
16680 static void vl_api_af_packet_details_t_handler
16681 (vl_api_af_packet_details_t * mp)
16683 vat_main_t *vam = &vat_main;
16685 print (vam->ofp, "%-16s %d",
16686 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
16689 static void vl_api_af_packet_details_t_handler_json
16690 (vl_api_af_packet_details_t * mp)
16692 vat_main_t *vam = &vat_main;
16693 vat_json_node_t *node = NULL;
16695 if (VAT_JSON_ARRAY != vam->json_tree.type)
16697 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16698 vat_json_init_array (&vam->json_tree);
16700 node = vat_json_array_add (&vam->json_tree);
16702 vat_json_init_object (node);
16703 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
16704 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
16708 api_af_packet_dump (vat_main_t * vam)
16710 vl_api_af_packet_dump_t *mp;
16711 vl_api_control_ping_t *mp_ping;
16714 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
16715 /* Get list of tap interfaces */
16716 M (AF_PACKET_DUMP, mp);
16719 /* Use a control ping for synchronization */
16720 MPING (CONTROL_PING, mp_ping);
16728 api_policer_add_del (vat_main_t * vam)
16730 unformat_input_t *i = vam->input;
16731 vl_api_policer_add_del_t *mp;
16741 u8 color_aware = 0;
16742 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
16745 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
16746 conform_action.dscp = 0;
16747 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
16748 exceed_action.dscp = 0;
16749 violate_action.action_type = SSE2_QOS_ACTION_DROP;
16750 violate_action.dscp = 0;
16752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16754 if (unformat (i, "del"))
16756 else if (unformat (i, "name %s", &name))
16757 vec_add1 (name, 0);
16758 else if (unformat (i, "cir %u", &cir))
16760 else if (unformat (i, "eir %u", &eir))
16762 else if (unformat (i, "cb %u", &cb))
16764 else if (unformat (i, "eb %u", &eb))
16766 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
16769 else if (unformat (i, "round_type %U", unformat_policer_round_type,
16772 else if (unformat (i, "type %U", unformat_policer_type, &type))
16774 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
16777 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
16780 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
16783 else if (unformat (i, "color-aware"))
16789 if (!vec_len (name))
16791 errmsg ("policer name must be specified");
16795 if (vec_len (name) > 64)
16797 errmsg ("policer name too long");
16801 M (POLICER_ADD_DEL, mp);
16803 clib_memcpy (mp->name, name, vec_len (name));
16805 mp->is_add = is_add;
16806 mp->cir = ntohl (cir);
16807 mp->eir = ntohl (eir);
16808 mp->cb = clib_net_to_host_u64 (cb);
16809 mp->eb = clib_net_to_host_u64 (eb);
16810 mp->rate_type = rate_type;
16811 mp->round_type = round_type;
16813 mp->conform_action.type = conform_action.action_type;
16814 mp->conform_action.dscp = conform_action.dscp;
16815 mp->exceed_action.type = exceed_action.action_type;
16816 mp->exceed_action.dscp = exceed_action.dscp;
16817 mp->violate_action.type = violate_action.action_type;
16818 mp->violate_action.dscp = violate_action.dscp;
16819 mp->color_aware = color_aware;
16827 api_policer_dump (vat_main_t * vam)
16829 unformat_input_t *i = vam->input;
16830 vl_api_policer_dump_t *mp;
16831 vl_api_control_ping_t *mp_ping;
16832 u8 *match_name = 0;
16833 u8 match_name_valid = 0;
16836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16838 if (unformat (i, "name %s", &match_name))
16840 vec_add1 (match_name, 0);
16841 match_name_valid = 1;
16847 M (POLICER_DUMP, mp);
16848 mp->match_name_valid = match_name_valid;
16849 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
16850 vec_free (match_name);
16854 /* Use a control ping for synchronization */
16855 MPING (CONTROL_PING, mp_ping);
16858 /* Wait for a reply... */
16864 api_policer_classify_set_interface (vat_main_t * vam)
16866 unformat_input_t *i = vam->input;
16867 vl_api_policer_classify_set_interface_t *mp;
16869 int sw_if_index_set;
16870 u32 ip4_table_index = ~0;
16871 u32 ip6_table_index = ~0;
16872 u32 l2_table_index = ~0;
16876 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16878 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16879 sw_if_index_set = 1;
16880 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16881 sw_if_index_set = 1;
16882 else if (unformat (i, "del"))
16884 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16886 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16888 else if (unformat (i, "l2-table %d", &l2_table_index))
16892 clib_warning ("parse error '%U'", format_unformat_error, i);
16897 if (sw_if_index_set == 0)
16899 errmsg ("missing interface name or sw_if_index");
16903 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
16905 mp->sw_if_index = ntohl (sw_if_index);
16906 mp->ip4_table_index = ntohl (ip4_table_index);
16907 mp->ip6_table_index = ntohl (ip6_table_index);
16908 mp->l2_table_index = ntohl (l2_table_index);
16909 mp->is_add = is_add;
16917 api_policer_classify_dump (vat_main_t * vam)
16919 unformat_input_t *i = vam->input;
16920 vl_api_policer_classify_dump_t *mp;
16921 vl_api_control_ping_t *mp_ping;
16922 u8 type = POLICER_CLASSIFY_N_TABLES;
16925 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
16929 errmsg ("classify table type must be specified");
16933 if (!vam->json_output)
16935 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16938 M (POLICER_CLASSIFY_DUMP, mp);
16943 /* Use a control ping for synchronization */
16944 MPING (CONTROL_PING, mp_ping);
16947 /* Wait for a reply... */
16953 format_fib_api_path_nh_proto (u8 * s, va_list * args)
16955 vl_api_fib_path_nh_proto_t proto =
16956 va_arg (*args, vl_api_fib_path_nh_proto_t);
16960 case FIB_API_PATH_NH_PROTO_IP4:
16961 s = format (s, "ip4");
16963 case FIB_API_PATH_NH_PROTO_IP6:
16964 s = format (s, "ip6");
16966 case FIB_API_PATH_NH_PROTO_MPLS:
16967 s = format (s, "mpls");
16969 case FIB_API_PATH_NH_PROTO_BIER:
16970 s = format (s, "bier");
16972 case FIB_API_PATH_NH_PROTO_ETHERNET:
16973 s = format (s, "ethernet");
16981 format_vl_api_ip_address_union (u8 * s, va_list * args)
16983 vl_api_address_family_t af = va_arg (*args, int);
16984 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
16989 s = format (s, "%U", format_ip4_address, u->ip4);
16992 s = format (s, "%U", format_ip6_address, u->ip6);
16999 format_vl_api_fib_path_type (u8 * s, va_list * args)
17001 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
17005 case FIB_API_PATH_TYPE_NORMAL:
17006 s = format (s, "normal");
17008 case FIB_API_PATH_TYPE_LOCAL:
17009 s = format (s, "local");
17011 case FIB_API_PATH_TYPE_DROP:
17012 s = format (s, "drop");
17014 case FIB_API_PATH_TYPE_UDP_ENCAP:
17015 s = format (s, "udp-encap");
17017 case FIB_API_PATH_TYPE_BIER_IMP:
17018 s = format (s, "bier-imp");
17020 case FIB_API_PATH_TYPE_ICMP_UNREACH:
17021 s = format (s, "unreach");
17023 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
17024 s = format (s, "prohibit");
17026 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
17027 s = format (s, "src-lookup");
17029 case FIB_API_PATH_TYPE_DVR:
17030 s = format (s, "dvr");
17032 case FIB_API_PATH_TYPE_INTERFACE_RX:
17033 s = format (s, "interface-rx");
17035 case FIB_API_PATH_TYPE_CLASSIFY:
17036 s = format (s, "classify");
17044 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
17047 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
17048 ntohl (fp->weight), ntohl (fp->sw_if_index),
17049 format_vl_api_fib_path_type, fp->type,
17050 format_fib_api_path_nh_proto, fp->proto,
17051 format_vl_api_ip_address_union, &fp->nh.address);
17055 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17056 vl_api_fib_path_t * fp)
17058 struct in_addr ip4;
17059 struct in6_addr ip6;
17061 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17062 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17063 vat_json_object_add_uint (node, "type", fp->type);
17064 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
17065 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
17067 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
17068 vat_json_object_add_ip4 (node, "next_hop", ip4);
17070 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP6)
17072 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
17073 vat_json_object_add_ip6 (node, "next_hop", ip6);
17078 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17080 vat_main_t *vam = &vat_main;
17081 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17082 vl_api_fib_path_t *fp;
17085 print (vam->ofp, "sw_if_index %d via:",
17086 ntohl (mp->mt_tunnel.mt_sw_if_index));
17087 fp = mp->mt_tunnel.mt_paths;
17088 for (i = 0; i < count; i++)
17090 vl_api_fib_path_print (vam, fp);
17094 print (vam->ofp, "");
17097 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17098 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17101 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17103 vat_main_t *vam = &vat_main;
17104 vat_json_node_t *node = NULL;
17105 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17106 vl_api_fib_path_t *fp;
17109 if (VAT_JSON_ARRAY != vam->json_tree.type)
17111 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17112 vat_json_init_array (&vam->json_tree);
17114 node = vat_json_array_add (&vam->json_tree);
17116 vat_json_init_object (node);
17117 vat_json_object_add_uint (node, "sw_if_index",
17118 ntohl (mp->mt_tunnel.mt_sw_if_index));
17120 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
17122 fp = mp->mt_tunnel.mt_paths;
17123 for (i = 0; i < count; i++)
17125 vl_api_mpls_fib_path_json_print (node, fp);
17131 api_mpls_tunnel_dump (vat_main_t * vam)
17133 vl_api_mpls_tunnel_dump_t *mp;
17134 vl_api_control_ping_t *mp_ping;
17137 M (MPLS_TUNNEL_DUMP, mp);
17141 /* Use a control ping for synchronization */
17142 MPING (CONTROL_PING, mp_ping);
17149 #define vl_api_mpls_table_details_t_endian vl_noop_handler
17150 #define vl_api_mpls_table_details_t_print vl_noop_handler
17154 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
17156 vat_main_t *vam = &vat_main;
17158 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
17161 static void vl_api_mpls_table_details_t_handler_json
17162 (vl_api_mpls_table_details_t * mp)
17164 vat_main_t *vam = &vat_main;
17165 vat_json_node_t *node = NULL;
17167 if (VAT_JSON_ARRAY != vam->json_tree.type)
17169 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17170 vat_json_init_array (&vam->json_tree);
17172 node = vat_json_array_add (&vam->json_tree);
17174 vat_json_init_object (node);
17175 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
17179 api_mpls_table_dump (vat_main_t * vam)
17181 vl_api_mpls_table_dump_t *mp;
17182 vl_api_control_ping_t *mp_ping;
17185 M (MPLS_TABLE_DUMP, mp);
17188 /* Use a control ping for synchronization */
17189 MPING (CONTROL_PING, mp_ping);
17196 #define vl_api_mpls_route_details_t_endian vl_noop_handler
17197 #define vl_api_mpls_route_details_t_print vl_noop_handler
17200 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
17202 vat_main_t *vam = &vat_main;
17203 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
17204 vl_api_fib_path_t *fp;
17208 "table-id %d, label %u, ess_bit %u",
17209 ntohl (mp->mr_route.mr_table_id),
17210 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
17211 fp = mp->mr_route.mr_paths;
17212 for (i = 0; i < count; i++)
17214 vl_api_fib_path_print (vam, fp);
17219 static void vl_api_mpls_route_details_t_handler_json
17220 (vl_api_mpls_route_details_t * mp)
17222 vat_main_t *vam = &vat_main;
17223 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
17224 vat_json_node_t *node = NULL;
17225 vl_api_fib_path_t *fp;
17228 if (VAT_JSON_ARRAY != vam->json_tree.type)
17230 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17231 vat_json_init_array (&vam->json_tree);
17233 node = vat_json_array_add (&vam->json_tree);
17235 vat_json_init_object (node);
17236 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
17237 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
17238 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
17239 vat_json_object_add_uint (node, "path_count", count);
17240 fp = mp->mr_route.mr_paths;
17241 for (i = 0; i < count; i++)
17243 vl_api_mpls_fib_path_json_print (node, fp);
17249 api_mpls_route_dump (vat_main_t * vam)
17251 unformat_input_t *input = vam->input;
17252 vl_api_mpls_route_dump_t *mp;
17253 vl_api_control_ping_t *mp_ping;
17257 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17259 if (unformat (input, "table_id %d", &table_id))
17264 if (table_id == ~0)
17266 errmsg ("missing table id");
17270 M (MPLS_ROUTE_DUMP, mp);
17272 mp->table.mt_table_id = ntohl (table_id);
17275 /* Use a control ping for synchronization */
17276 MPING (CONTROL_PING, mp_ping);
17283 #define vl_api_ip_table_details_t_endian vl_noop_handler
17284 #define vl_api_ip_table_details_t_print vl_noop_handler
17287 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
17289 vat_main_t *vam = &vat_main;
17292 "%s; table-id %d, prefix %U/%d",
17293 mp->table.name, ntohl (mp->table.table_id));
17297 static void vl_api_ip_table_details_t_handler_json
17298 (vl_api_ip_table_details_t * mp)
17300 vat_main_t *vam = &vat_main;
17301 vat_json_node_t *node = NULL;
17303 if (VAT_JSON_ARRAY != vam->json_tree.type)
17305 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17306 vat_json_init_array (&vam->json_tree);
17308 node = vat_json_array_add (&vam->json_tree);
17310 vat_json_init_object (node);
17311 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
17315 api_ip_table_dump (vat_main_t * vam)
17317 vl_api_ip_table_dump_t *mp;
17318 vl_api_control_ping_t *mp_ping;
17321 M (IP_TABLE_DUMP, mp);
17324 /* Use a control ping for synchronization */
17325 MPING (CONTROL_PING, mp_ping);
17333 api_ip_mtable_dump (vat_main_t * vam)
17335 vl_api_ip_mtable_dump_t *mp;
17336 vl_api_control_ping_t *mp_ping;
17339 M (IP_MTABLE_DUMP, mp);
17342 /* Use a control ping for synchronization */
17343 MPING (CONTROL_PING, mp_ping);
17351 api_ip_mroute_dump (vat_main_t * vam)
17353 unformat_input_t *input = vam->input;
17354 vl_api_control_ping_t *mp_ping;
17355 vl_api_ip_mroute_dump_t *mp;
17360 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17362 if (unformat (input, "table_id %d", &table_id))
17364 else if (unformat (input, "ip6"))
17366 else if (unformat (input, "ip4"))
17371 if (table_id == ~0)
17373 errmsg ("missing table id");
17377 M (IP_MROUTE_DUMP, mp);
17378 mp->table.table_id = table_id;
17379 mp->table.is_ip6 = is_ip6;
17382 /* Use a control ping for synchronization */
17383 MPING (CONTROL_PING, mp_ping);
17390 #define vl_api_ip_route_details_t_endian vl_noop_handler
17391 #define vl_api_ip_route_details_t_print vl_noop_handler
17394 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
17396 vat_main_t *vam = &vat_main;
17397 u8 count = mp->route.n_paths;
17398 vl_api_fib_path_t *fp;
17402 "table-id %d, prefix %U/%d",
17403 ntohl (mp->route.table_id),
17404 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
17405 for (i = 0; i < count; i++)
17407 fp = &mp->route.paths[i];
17409 vl_api_fib_path_print (vam, fp);
17414 static void vl_api_ip_route_details_t_handler_json
17415 (vl_api_ip_route_details_t * mp)
17417 vat_main_t *vam = &vat_main;
17418 u8 count = mp->route.n_paths;
17419 vat_json_node_t *node = NULL;
17420 struct in_addr ip4;
17421 struct in6_addr ip6;
17422 vl_api_fib_path_t *fp;
17425 if (VAT_JSON_ARRAY != vam->json_tree.type)
17427 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17428 vat_json_init_array (&vam->json_tree);
17430 node = vat_json_array_add (&vam->json_tree);
17432 vat_json_init_object (node);
17433 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
17434 if (ADDRESS_IP6 == mp->route.prefix.address.af)
17436 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
17437 vat_json_object_add_ip6 (node, "prefix", ip6);
17441 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
17442 vat_json_object_add_ip4 (node, "prefix", ip4);
17444 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
17445 vat_json_object_add_uint (node, "path_count", count);
17446 for (i = 0; i < count; i++)
17448 fp = &mp->route.paths[i];
17449 vl_api_mpls_fib_path_json_print (node, fp);
17454 api_ip_route_dump (vat_main_t * vam)
17456 unformat_input_t *input = vam->input;
17457 vl_api_ip_route_dump_t *mp;
17458 vl_api_control_ping_t *mp_ping;
17464 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17466 if (unformat (input, "table_id %d", &table_id))
17468 else if (unformat (input, "ip6"))
17470 else if (unformat (input, "ip4"))
17475 if (table_id == ~0)
17477 errmsg ("missing table id");
17481 M (IP_ROUTE_DUMP, mp);
17483 mp->table.table_id = table_id;
17484 mp->table.is_ip6 = is_ip6;
17488 /* Use a control ping for synchronization */
17489 MPING (CONTROL_PING, mp_ping);
17497 api_classify_table_ids (vat_main_t * vam)
17499 vl_api_classify_table_ids_t *mp;
17502 /* Construct the API message */
17503 M (CLASSIFY_TABLE_IDS, mp);
17512 api_classify_table_by_interface (vat_main_t * vam)
17514 unformat_input_t *input = vam->input;
17515 vl_api_classify_table_by_interface_t *mp;
17517 u32 sw_if_index = ~0;
17519 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17521 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17523 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17528 if (sw_if_index == ~0)
17530 errmsg ("missing interface name or sw_if_index");
17534 /* Construct the API message */
17535 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
17537 mp->sw_if_index = ntohl (sw_if_index);
17545 api_classify_table_info (vat_main_t * vam)
17547 unformat_input_t *input = vam->input;
17548 vl_api_classify_table_info_t *mp;
17552 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17554 if (unformat (input, "table_id %d", &table_id))
17559 if (table_id == ~0)
17561 errmsg ("missing table id");
17565 /* Construct the API message */
17566 M (CLASSIFY_TABLE_INFO, mp);
17568 mp->table_id = ntohl (table_id);
17576 api_classify_session_dump (vat_main_t * vam)
17578 unformat_input_t *input = vam->input;
17579 vl_api_classify_session_dump_t *mp;
17580 vl_api_control_ping_t *mp_ping;
17584 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17586 if (unformat (input, "table_id %d", &table_id))
17591 if (table_id == ~0)
17593 errmsg ("missing table id");
17597 /* Construct the API message */
17598 M (CLASSIFY_SESSION_DUMP, mp);
17600 mp->table_id = ntohl (table_id);
17603 /* Use a control ping for synchronization */
17604 MPING (CONTROL_PING, mp_ping);
17612 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
17614 vat_main_t *vam = &vat_main;
17616 print (vam->ofp, "collector_address %U, collector_port %d, "
17617 "src_address %U, vrf_id %d, path_mtu %u, "
17618 "template_interval %u, udp_checksum %d",
17619 format_ip4_address, mp->collector_address,
17620 ntohs (mp->collector_port),
17621 format_ip4_address, mp->src_address,
17622 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
17623 ntohl (mp->template_interval), mp->udp_checksum);
17626 vam->result_ready = 1;
17630 vl_api_ipfix_exporter_details_t_handler_json
17631 (vl_api_ipfix_exporter_details_t * mp)
17633 vat_main_t *vam = &vat_main;
17634 vat_json_node_t node;
17635 struct in_addr collector_address;
17636 struct in_addr src_address;
17638 vat_json_init_object (&node);
17639 clib_memcpy (&collector_address, &mp->collector_address,
17640 sizeof (collector_address));
17641 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
17642 vat_json_object_add_uint (&node, "collector_port",
17643 ntohs (mp->collector_port));
17644 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
17645 vat_json_object_add_ip4 (&node, "src_address", src_address);
17646 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
17647 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
17648 vat_json_object_add_uint (&node, "template_interval",
17649 ntohl (mp->template_interval));
17650 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
17652 vat_json_print (vam->ofp, &node);
17653 vat_json_free (&node);
17655 vam->result_ready = 1;
17659 api_ipfix_exporter_dump (vat_main_t * vam)
17661 vl_api_ipfix_exporter_dump_t *mp;
17664 /* Construct the API message */
17665 M (IPFIX_EXPORTER_DUMP, mp);
17674 api_ipfix_classify_stream_dump (vat_main_t * vam)
17676 vl_api_ipfix_classify_stream_dump_t *mp;
17679 /* Construct the API message */
17680 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
17691 vl_api_ipfix_classify_stream_details_t_handler
17692 (vl_api_ipfix_classify_stream_details_t * mp)
17694 vat_main_t *vam = &vat_main;
17695 print (vam->ofp, "domain_id %d, src_port %d",
17696 ntohl (mp->domain_id), ntohs (mp->src_port));
17698 vam->result_ready = 1;
17702 vl_api_ipfix_classify_stream_details_t_handler_json
17703 (vl_api_ipfix_classify_stream_details_t * mp)
17705 vat_main_t *vam = &vat_main;
17706 vat_json_node_t node;
17708 vat_json_init_object (&node);
17709 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
17710 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
17712 vat_json_print (vam->ofp, &node);
17713 vat_json_free (&node);
17715 vam->result_ready = 1;
17719 api_ipfix_classify_table_dump (vat_main_t * vam)
17721 vl_api_ipfix_classify_table_dump_t *mp;
17722 vl_api_control_ping_t *mp_ping;
17725 if (!vam->json_output)
17727 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
17728 "transport_protocol");
17731 /* Construct the API message */
17732 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
17737 /* Use a control ping for synchronization */
17738 MPING (CONTROL_PING, mp_ping);
17746 vl_api_ipfix_classify_table_details_t_handler
17747 (vl_api_ipfix_classify_table_details_t * mp)
17749 vat_main_t *vam = &vat_main;
17750 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
17751 mp->transport_protocol);
17755 vl_api_ipfix_classify_table_details_t_handler_json
17756 (vl_api_ipfix_classify_table_details_t * mp)
17758 vat_json_node_t *node = NULL;
17759 vat_main_t *vam = &vat_main;
17761 if (VAT_JSON_ARRAY != vam->json_tree.type)
17763 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17764 vat_json_init_array (&vam->json_tree);
17767 node = vat_json_array_add (&vam->json_tree);
17768 vat_json_init_object (node);
17770 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
17771 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
17772 vat_json_object_add_uint (node, "transport_protocol",
17773 mp->transport_protocol);
17777 api_sw_interface_span_enable_disable (vat_main_t * vam)
17779 unformat_input_t *i = vam->input;
17780 vl_api_sw_interface_span_enable_disable_t *mp;
17781 u32 src_sw_if_index = ~0;
17782 u32 dst_sw_if_index = ~0;
17787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17790 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
17792 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
17796 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
17798 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
17800 else if (unformat (i, "disable"))
17802 else if (unformat (i, "rx"))
17804 else if (unformat (i, "tx"))
17806 else if (unformat (i, "both"))
17808 else if (unformat (i, "l2"))
17814 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
17816 mp->sw_if_index_from = htonl (src_sw_if_index);
17817 mp->sw_if_index_to = htonl (dst_sw_if_index);
17827 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
17830 vat_main_t *vam = &vat_main;
17831 u8 *sw_if_from_name = 0;
17832 u8 *sw_if_to_name = 0;
17833 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17834 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17835 char *states[] = { "none", "rx", "tx", "both" };
17839 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17841 if ((u32) p->value[0] == sw_if_index_from)
17843 sw_if_from_name = (u8 *)(p->key);
17847 if ((u32) p->value[0] == sw_if_index_to)
17849 sw_if_to_name = (u8 *)(p->key);
17850 if (sw_if_from_name)
17855 print (vam->ofp, "%20s => %20s (%s) %s",
17856 sw_if_from_name, sw_if_to_name, states[mp->state],
17857 mp->is_l2 ? "l2" : "device");
17861 vl_api_sw_interface_span_details_t_handler_json
17862 (vl_api_sw_interface_span_details_t * mp)
17864 vat_main_t *vam = &vat_main;
17865 vat_json_node_t *node = NULL;
17866 u8 *sw_if_from_name = 0;
17867 u8 *sw_if_to_name = 0;
17868 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17869 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17873 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17875 if ((u32) p->value[0] == sw_if_index_from)
17877 sw_if_from_name = (u8 *)(p->key);
17881 if ((u32) p->value[0] == sw_if_index_to)
17883 sw_if_to_name = (u8 *)(p->key);
17884 if (sw_if_from_name)
17890 if (VAT_JSON_ARRAY != vam->json_tree.type)
17892 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17893 vat_json_init_array (&vam->json_tree);
17895 node = vat_json_array_add (&vam->json_tree);
17897 vat_json_init_object (node);
17898 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
17899 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
17900 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
17901 if (0 != sw_if_to_name)
17903 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
17905 vat_json_object_add_uint (node, "state", mp->state);
17906 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
17910 api_sw_interface_span_dump (vat_main_t * vam)
17912 unformat_input_t *input = vam->input;
17913 vl_api_sw_interface_span_dump_t *mp;
17914 vl_api_control_ping_t *mp_ping;
17918 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17920 if (unformat (input, "l2"))
17926 M (SW_INTERFACE_SPAN_DUMP, mp);
17930 /* Use a control ping for synchronization */
17931 MPING (CONTROL_PING, mp_ping);
17939 api_pg_create_interface (vat_main_t * vam)
17941 unformat_input_t *input = vam->input;
17942 vl_api_pg_create_interface_t *mp;
17944 u32 if_id = ~0, gso_size = 0;
17945 u8 gso_enabled = 0;
17947 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17949 if (unformat (input, "if_id %d", &if_id))
17951 else if (unformat (input, "gso-enabled"))
17954 if (unformat (input, "gso-size %u", &gso_size))
17958 errmsg ("missing gso-size");
17967 errmsg ("missing pg interface index");
17971 /* Construct the API message */
17972 M (PG_CREATE_INTERFACE, mp);
17974 mp->interface_id = ntohl (if_id);
17975 mp->gso_enabled = gso_enabled;
17983 api_pg_capture (vat_main_t * vam)
17985 unformat_input_t *input = vam->input;
17986 vl_api_pg_capture_t *mp;
17991 u8 pcap_file_set = 0;
17994 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17996 if (unformat (input, "if_id %d", &if_id))
17998 else if (unformat (input, "pcap %s", &pcap_file))
18000 else if (unformat (input, "count %d", &count))
18002 else if (unformat (input, "disable"))
18009 errmsg ("missing pg interface index");
18012 if (pcap_file_set > 0)
18014 if (vec_len (pcap_file) > 255)
18016 errmsg ("pcap file name is too long");
18021 /* Construct the API message */
18022 M (PG_CAPTURE, mp);
18024 mp->interface_id = ntohl (if_id);
18025 mp->is_enabled = enable;
18026 mp->count = ntohl (count);
18027 if (pcap_file_set != 0)
18029 vl_api_vec_to_api_string (pcap_file, &mp->pcap_file_name);
18031 vec_free (pcap_file);
18039 api_pg_enable_disable (vat_main_t * vam)
18041 unformat_input_t *input = vam->input;
18042 vl_api_pg_enable_disable_t *mp;
18045 u8 stream_name_set = 0;
18046 u8 *stream_name = 0;
18048 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18050 if (unformat (input, "stream %s", &stream_name))
18051 stream_name_set = 1;
18052 else if (unformat (input, "disable"))
18058 if (stream_name_set > 0)
18060 if (vec_len (stream_name) > 255)
18062 errmsg ("stream name too long");
18067 /* Construct the API message */
18068 M (PG_ENABLE_DISABLE, mp);
18070 mp->is_enabled = enable;
18071 if (stream_name_set != 0)
18073 vl_api_vec_to_api_string (stream_name, &mp->stream_name);
18075 vec_free (stream_name);
18083 api_pg_interface_enable_disable_coalesce (vat_main_t * vam)
18085 unformat_input_t *input = vam->input;
18086 vl_api_pg_interface_enable_disable_coalesce_t *mp;
18088 u32 sw_if_index = ~0;
18091 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18093 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18095 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18097 else if (unformat (input, "disable"))
18103 if (sw_if_index == ~0)
18105 errmsg ("Interface required but not specified");
18109 /* Construct the API message */
18110 M (PG_INTERFACE_ENABLE_DISABLE_COALESCE, mp);
18112 mp->coalesce_enabled = enable;
18113 mp->sw_if_index = htonl (sw_if_index);
18121 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18123 unformat_input_t *input = vam->input;
18124 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18126 u16 *low_ports = 0;
18127 u16 *high_ports = 0;
18130 vl_api_prefix_t prefix;
18137 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18139 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
18141 else if (unformat (input, "vrf %d", &vrf_id))
18143 else if (unformat (input, "del"))
18145 else if (unformat (input, "port %d", &tmp))
18147 if (tmp == 0 || tmp > 65535)
18149 errmsg ("port %d out of range", tmp);
18153 this_hi = this_low + 1;
18154 vec_add1 (low_ports, this_low);
18155 vec_add1 (high_ports, this_hi);
18157 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18159 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18161 errmsg ("incorrect range parameters");
18165 /* Note: in debug CLI +1 is added to high before
18166 passing to real fn that does "the work"
18167 (ip_source_and_port_range_check_add_del).
18168 This fn is a wrapper around the binary API fn a
18169 control plane will call, which expects this increment
18170 to have occurred. Hence letting the binary API control
18171 plane fn do the increment for consistency between VAT
18172 and other control planes.
18175 vec_add1 (low_ports, this_low);
18176 vec_add1 (high_ports, this_hi);
18182 if (prefix_set == 0)
18184 errmsg ("<address>/<mask> not specified");
18190 errmsg ("VRF ID required, not specified");
18197 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18201 if (vec_len (low_ports) == 0)
18203 errmsg ("At least one port or port range required");
18207 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18209 mp->is_add = is_add;
18211 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
18213 mp->number_of_ranges = vec_len (low_ports);
18215 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18216 vec_free (low_ports);
18218 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18219 vec_free (high_ports);
18221 mp->vrf_id = ntohl (vrf_id);
18229 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18231 unformat_input_t *input = vam->input;
18232 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18233 u32 sw_if_index = ~0;
18235 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18236 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18240 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18242 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18244 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18246 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18248 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18250 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18252 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18254 else if (unformat (input, "del"))
18260 if (sw_if_index == ~0)
18262 errmsg ("Interface required but not specified");
18268 errmsg ("VRF ID required but not specified");
18272 if (tcp_out_vrf_id == 0
18273 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18276 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18280 /* Construct the API message */
18281 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18283 mp->sw_if_index = ntohl (sw_if_index);
18284 mp->is_add = is_add;
18285 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18286 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18287 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18288 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18293 /* Wait for a reply... */
18299 api_set_punt (vat_main_t * vam)
18301 unformat_input_t *i = vam->input;
18302 vl_api_address_family_t af;
18303 vl_api_set_punt_t *mp;
18309 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18311 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
18313 else if (unformat (i, "protocol %d", &protocol))
18315 else if (unformat (i, "port %d", &port))
18317 else if (unformat (i, "del"))
18321 clib_warning ("parse error '%U'", format_unformat_error, i);
18328 mp->is_add = (u8) is_add;
18329 mp->punt.type = PUNT_API_TYPE_L4;
18330 mp->punt.punt.l4.af = af;
18331 mp->punt.punt.l4.protocol = (u8) protocol;
18332 mp->punt.punt.l4.port = htons ((u16) port);
18340 api_delete_subif (vat_main_t * vam)
18342 unformat_input_t *i = vam->input;
18343 vl_api_delete_subif_t *mp;
18344 u32 sw_if_index = ~0;
18347 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18349 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18351 if (unformat (i, "sw_if_index %d", &sw_if_index))
18357 if (sw_if_index == ~0)
18359 errmsg ("missing sw_if_index");
18363 /* Construct the API message */
18364 M (DELETE_SUBIF, mp);
18365 mp->sw_if_index = ntohl (sw_if_index);
18372 #define foreach_pbb_vtr_op \
18373 _("disable", L2_VTR_DISABLED) \
18374 _("pop", L2_VTR_POP_2) \
18375 _("push", L2_VTR_PUSH_2)
18378 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18380 unformat_input_t *i = vam->input;
18381 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18382 u32 sw_if_index = ~0, vtr_op = ~0;
18383 u16 outer_tag = ~0;
18384 u8 dmac[6], smac[6];
18385 u8 dmac_set = 0, smac_set = 0;
18391 /* Shut up coverity */
18392 clib_memset (dmac, 0, sizeof (dmac));
18393 clib_memset (smac, 0, sizeof (smac));
18395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18397 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18399 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18401 else if (unformat (i, "vtr_op %d", &vtr_op))
18403 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18406 else if (unformat (i, "translate_pbb_stag"))
18408 if (unformat (i, "%d", &tmp))
18410 vtr_op = L2_VTR_TRANSLATE_2_1;
18416 ("translate_pbb_stag operation requires outer tag definition");
18420 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18422 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18424 else if (unformat (i, "sid %d", &sid))
18426 else if (unformat (i, "vlanid %d", &tmp))
18430 clib_warning ("parse error '%U'", format_unformat_error, i);
18435 if ((sw_if_index == ~0) || (vtr_op == ~0))
18437 errmsg ("missing sw_if_index or vtr operation");
18440 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18441 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18444 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18448 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18449 mp->sw_if_index = ntohl (sw_if_index);
18450 mp->vtr_op = ntohl (vtr_op);
18451 mp->outer_tag = ntohs (outer_tag);
18452 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18453 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18454 mp->b_vlanid = ntohs (vlanid);
18455 mp->i_sid = ntohl (sid);
18463 api_flow_classify_set_interface (vat_main_t * vam)
18465 unformat_input_t *i = vam->input;
18466 vl_api_flow_classify_set_interface_t *mp;
18468 int sw_if_index_set;
18469 u32 ip4_table_index = ~0;
18470 u32 ip6_table_index = ~0;
18474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18476 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18477 sw_if_index_set = 1;
18478 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18479 sw_if_index_set = 1;
18480 else if (unformat (i, "del"))
18482 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18484 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18488 clib_warning ("parse error '%U'", format_unformat_error, i);
18493 if (sw_if_index_set == 0)
18495 errmsg ("missing interface name or sw_if_index");
18499 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18501 mp->sw_if_index = ntohl (sw_if_index);
18502 mp->ip4_table_index = ntohl (ip4_table_index);
18503 mp->ip6_table_index = ntohl (ip6_table_index);
18504 mp->is_add = is_add;
18512 api_flow_classify_dump (vat_main_t * vam)
18514 unformat_input_t *i = vam->input;
18515 vl_api_flow_classify_dump_t *mp;
18516 vl_api_control_ping_t *mp_ping;
18517 u8 type = FLOW_CLASSIFY_N_TABLES;
18520 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
18524 errmsg ("classify table type must be specified");
18528 if (!vam->json_output)
18530 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18533 M (FLOW_CLASSIFY_DUMP, mp);
18538 /* Use a control ping for synchronization */
18539 MPING (CONTROL_PING, mp_ping);
18542 /* Wait for a reply... */
18548 api_feature_enable_disable (vat_main_t * vam)
18550 unformat_input_t *i = vam->input;
18551 vl_api_feature_enable_disable_t *mp;
18553 u8 *feature_name = 0;
18554 u32 sw_if_index = ~0;
18558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18560 if (unformat (i, "arc_name %s", &arc_name))
18562 else if (unformat (i, "feature_name %s", &feature_name))
18565 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18567 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18569 else if (unformat (i, "disable"))
18577 errmsg ("missing arc name");
18580 if (vec_len (arc_name) > 63)
18582 errmsg ("arc name too long");
18585 if (feature_name == 0)
18587 errmsg ("missing feature name");
18590 if (vec_len (feature_name) > 63)
18592 errmsg ("feature name too long");
18595 if (sw_if_index == ~0)
18597 errmsg ("missing interface name or sw_if_index");
18601 /* Construct the API message */
18602 M (FEATURE_ENABLE_DISABLE, mp);
18603 mp->sw_if_index = ntohl (sw_if_index);
18604 mp->enable = enable;
18605 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
18606 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
18607 vec_free (arc_name);
18608 vec_free (feature_name);
18616 api_feature_gso_enable_disable (vat_main_t * vam)
18618 unformat_input_t *i = vam->input;
18619 vl_api_feature_gso_enable_disable_t *mp;
18620 u32 sw_if_index = ~0;
18624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18626 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18628 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18630 else if (unformat (i, "enable"))
18632 else if (unformat (i, "disable"))
18638 if (sw_if_index == ~0)
18640 errmsg ("missing interface name or sw_if_index");
18644 /* Construct the API message */
18645 M (FEATURE_GSO_ENABLE_DISABLE, mp);
18646 mp->sw_if_index = ntohl (sw_if_index);
18647 mp->enable_disable = enable;
18655 api_sw_interface_tag_add_del (vat_main_t * vam)
18657 unformat_input_t *i = vam->input;
18658 vl_api_sw_interface_tag_add_del_t *mp;
18659 u32 sw_if_index = ~0;
18664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18666 if (unformat (i, "tag %s", &tag))
18668 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18670 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18672 else if (unformat (i, "del"))
18678 if (sw_if_index == ~0)
18680 errmsg ("missing interface name or sw_if_index");
18684 if (enable && (tag == 0))
18686 errmsg ("no tag specified");
18690 /* Construct the API message */
18691 M (SW_INTERFACE_TAG_ADD_DEL, mp);
18692 mp->sw_if_index = ntohl (sw_if_index);
18693 mp->is_add = enable;
18695 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
18704 api_sw_interface_add_del_mac_address (vat_main_t * vam)
18706 unformat_input_t *i = vam->input;
18707 vl_api_mac_address_t mac = { 0 };
18708 vl_api_sw_interface_add_del_mac_address_t *mp;
18709 u32 sw_if_index = ~0;
18714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18716 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18718 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18720 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
18722 else if (unformat (i, "del"))
18728 if (sw_if_index == ~0)
18730 errmsg ("missing interface name or sw_if_index");
18736 errmsg ("missing MAC address");
18740 /* Construct the API message */
18741 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
18742 mp->sw_if_index = ntohl (sw_if_index);
18743 mp->is_add = is_add;
18744 clib_memcpy (&mp->addr, &mac, sizeof (mac));
18751 static void vl_api_l2_xconnect_details_t_handler
18752 (vl_api_l2_xconnect_details_t * mp)
18754 vat_main_t *vam = &vat_main;
18756 print (vam->ofp, "%15d%15d",
18757 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
18760 static void vl_api_l2_xconnect_details_t_handler_json
18761 (vl_api_l2_xconnect_details_t * mp)
18763 vat_main_t *vam = &vat_main;
18764 vat_json_node_t *node = NULL;
18766 if (VAT_JSON_ARRAY != vam->json_tree.type)
18768 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18769 vat_json_init_array (&vam->json_tree);
18771 node = vat_json_array_add (&vam->json_tree);
18773 vat_json_init_object (node);
18774 vat_json_object_add_uint (node, "rx_sw_if_index",
18775 ntohl (mp->rx_sw_if_index));
18776 vat_json_object_add_uint (node, "tx_sw_if_index",
18777 ntohl (mp->tx_sw_if_index));
18781 api_l2_xconnect_dump (vat_main_t * vam)
18783 vl_api_l2_xconnect_dump_t *mp;
18784 vl_api_control_ping_t *mp_ping;
18787 if (!vam->json_output)
18789 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
18792 M (L2_XCONNECT_DUMP, mp);
18796 /* Use a control ping for synchronization */
18797 MPING (CONTROL_PING, mp_ping);
18805 api_hw_interface_set_mtu (vat_main_t * vam)
18807 unformat_input_t *i = vam->input;
18808 vl_api_hw_interface_set_mtu_t *mp;
18809 u32 sw_if_index = ~0;
18813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18815 if (unformat (i, "mtu %d", &mtu))
18817 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18819 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18825 if (sw_if_index == ~0)
18827 errmsg ("missing interface name or sw_if_index");
18833 errmsg ("no mtu specified");
18837 /* Construct the API message */
18838 M (HW_INTERFACE_SET_MTU, mp);
18839 mp->sw_if_index = ntohl (sw_if_index);
18840 mp->mtu = ntohs ((u16) mtu);
18848 api_p2p_ethernet_add (vat_main_t * vam)
18850 unformat_input_t *i = vam->input;
18851 vl_api_p2p_ethernet_add_t *mp;
18852 u32 parent_if_index = ~0;
18858 clib_memset (remote_mac, 0, sizeof (remote_mac));
18859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18861 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
18863 else if (unformat (i, "sw_if_index %d", &parent_if_index))
18867 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
18869 else if (unformat (i, "sub_id %d", &sub_id))
18873 clib_warning ("parse error '%U'", format_unformat_error, i);
18878 if (parent_if_index == ~0)
18880 errmsg ("missing interface name or sw_if_index");
18885 errmsg ("missing remote mac address");
18890 errmsg ("missing sub-interface id");
18894 M (P2P_ETHERNET_ADD, mp);
18895 mp->parent_if_index = ntohl (parent_if_index);
18896 mp->subif_id = ntohl (sub_id);
18897 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
18905 api_p2p_ethernet_del (vat_main_t * vam)
18907 unformat_input_t *i = vam->input;
18908 vl_api_p2p_ethernet_del_t *mp;
18909 u32 parent_if_index = ~0;
18914 clib_memset (remote_mac, 0, sizeof (remote_mac));
18915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18917 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
18919 else if (unformat (i, "sw_if_index %d", &parent_if_index))
18923 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
18927 clib_warning ("parse error '%U'", format_unformat_error, i);
18932 if (parent_if_index == ~0)
18934 errmsg ("missing interface name or sw_if_index");
18939 errmsg ("missing remote mac address");
18943 M (P2P_ETHERNET_DEL, mp);
18944 mp->parent_if_index = ntohl (parent_if_index);
18945 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
18953 api_tcp_configure_src_addresses (vat_main_t * vam)
18955 vl_api_tcp_configure_src_addresses_t *mp;
18956 unformat_input_t *i = vam->input;
18957 vl_api_address_t first, last;
18962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18964 if (unformat (i, "%U - %U",
18965 unformat_vl_api_address, &first,
18966 unformat_vl_api_address, &last))
18970 errmsg ("one range per message (range already set)");
18975 else if (unformat (i, "vrf %d", &vrf_id))
18981 if (range_set == 0)
18983 errmsg ("address range not set");
18987 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
18989 mp->vrf_id = ntohl (vrf_id);
18990 clib_memcpy (&mp->first_address, &first, sizeof (first));
18991 clib_memcpy (&mp->last_address, &last, sizeof (last));
18998 static void vl_api_app_namespace_add_del_reply_t_handler
18999 (vl_api_app_namespace_add_del_reply_t * mp)
19001 vat_main_t *vam = &vat_main;
19002 i32 retval = ntohl (mp->retval);
19003 if (vam->async_mode)
19005 vam->async_errors += (retval < 0);
19009 vam->retval = retval;
19011 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
19012 vam->result_ready = 1;
19016 static void vl_api_app_namespace_add_del_reply_t_handler_json
19017 (vl_api_app_namespace_add_del_reply_t * mp)
19019 vat_main_t *vam = &vat_main;
19020 vat_json_node_t node;
19022 vat_json_init_object (&node);
19023 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
19024 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
19026 vat_json_print (vam->ofp, &node);
19027 vat_json_free (&node);
19029 vam->retval = ntohl (mp->retval);
19030 vam->result_ready = 1;
19034 api_app_namespace_add_del (vat_main_t * vam)
19036 vl_api_app_namespace_add_del_t *mp;
19037 unformat_input_t *i = vam->input;
19038 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
19039 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
19043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19045 if (unformat (i, "id %_%v%_", &ns_id))
19047 else if (unformat (i, "secret %lu", &secret))
19049 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19050 sw_if_index_set = 1;
19051 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
19053 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
19058 if (!ns_id || !secret_set || !sw_if_index_set)
19060 errmsg ("namespace id, secret and sw_if_index must be set");
19063 if (vec_len (ns_id) > 64)
19065 errmsg ("namespace id too long");
19068 M (APP_NAMESPACE_ADD_DEL, mp);
19070 vl_api_vec_to_api_string (ns_id, &mp->namespace_id);
19071 mp->secret = clib_host_to_net_u64 (secret);
19072 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
19073 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
19074 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
19082 api_sock_init_shm (vat_main_t * vam)
19084 #if VPP_API_TEST_BUILTIN == 0
19085 unformat_input_t *i = vam->input;
19086 vl_api_shm_elem_config_t *config = 0;
19087 u64 size = 64 << 20;
19090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19092 if (unformat (i, "size %U", unformat_memory_size, &size))
19099 * Canned custom ring allocator config.
19100 * Should probably parse all of this
19102 vec_validate (config, 6);
19103 config[0].type = VL_API_VLIB_RING;
19104 config[0].size = 256;
19105 config[0].count = 32;
19107 config[1].type = VL_API_VLIB_RING;
19108 config[1].size = 1024;
19109 config[1].count = 16;
19111 config[2].type = VL_API_VLIB_RING;
19112 config[2].size = 4096;
19113 config[2].count = 2;
19115 config[3].type = VL_API_CLIENT_RING;
19116 config[3].size = 256;
19117 config[3].count = 32;
19119 config[4].type = VL_API_CLIENT_RING;
19120 config[4].size = 1024;
19121 config[4].count = 16;
19123 config[5].type = VL_API_CLIENT_RING;
19124 config[5].size = 4096;
19125 config[5].count = 2;
19127 config[6].type = VL_API_QUEUE;
19128 config[6].count = 128;
19129 config[6].size = sizeof (uword);
19131 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
19133 vam->client_index_invalid = 1;
19141 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
19143 vat_main_t *vam = &vat_main;
19144 fib_prefix_t lcl, rmt;
19146 ip_prefix_decode (&mp->lcl, &lcl);
19147 ip_prefix_decode (&mp->rmt, &rmt);
19149 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19152 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19153 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19154 mp->scope, format_ip4_address, &lcl.fp_addr.ip4, lcl.fp_len,
19155 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
19156 &rmt.fp_addr.ip4, rmt.fp_len,
19157 clib_net_to_host_u16 (mp->rmt_port),
19158 clib_net_to_host_u32 (mp->action_index), mp->tag);
19163 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19164 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19165 mp->scope, format_ip6_address, &lcl.fp_addr.ip6, lcl.fp_len,
19166 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
19167 &rmt.fp_addr.ip6, rmt.fp_len,
19168 clib_net_to_host_u16 (mp->rmt_port),
19169 clib_net_to_host_u32 (mp->action_index), mp->tag);
19174 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
19177 vat_main_t *vam = &vat_main;
19178 vat_json_node_t *node = NULL;
19179 struct in6_addr ip6;
19180 struct in_addr ip4;
19182 fib_prefix_t lcl, rmt;
19184 ip_prefix_decode (&mp->lcl, &lcl);
19185 ip_prefix_decode (&mp->rmt, &rmt);
19187 if (VAT_JSON_ARRAY != vam->json_tree.type)
19189 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19190 vat_json_init_array (&vam->json_tree);
19192 node = vat_json_array_add (&vam->json_tree);
19193 vat_json_init_object (node);
19195 vat_json_object_add_uint (node, "appns_index",
19196 clib_net_to_host_u32 (mp->appns_index));
19197 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
19198 vat_json_object_add_uint (node, "scope", mp->scope);
19199 vat_json_object_add_uint (node, "action_index",
19200 clib_net_to_host_u32 (mp->action_index));
19201 vat_json_object_add_uint (node, "lcl_port",
19202 clib_net_to_host_u16 (mp->lcl_port));
19203 vat_json_object_add_uint (node, "rmt_port",
19204 clib_net_to_host_u16 (mp->rmt_port));
19205 vat_json_object_add_uint (node, "lcl_plen", lcl.fp_len);
19206 vat_json_object_add_uint (node, "rmt_plen", rmt.fp_len);
19207 vat_json_object_add_string_copy (node, "tag", mp->tag);
19208 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19210 clib_memcpy (&ip4, &lcl.fp_addr.ip4, sizeof (ip4));
19211 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
19212 clib_memcpy (&ip4, &rmt.fp_addr.ip4, sizeof (ip4));
19213 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
19217 clib_memcpy (&ip6, &lcl.fp_addr.ip6, sizeof (ip6));
19218 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
19219 clib_memcpy (&ip6, &rmt.fp_addr.ip6, sizeof (ip6));
19220 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
19225 api_session_rule_add_del (vat_main_t * vam)
19227 vl_api_session_rule_add_del_t *mp;
19228 unformat_input_t *i = vam->input;
19229 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
19230 u32 appns_index = 0, scope = 0;
19231 ip4_address_t lcl_ip4, rmt_ip4;
19232 ip6_address_t lcl_ip6, rmt_ip6;
19233 u8 is_ip4 = 1, conn_set = 0;
19234 u8 is_add = 1, *tag = 0;
19236 fib_prefix_t lcl, rmt;
19238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19240 if (unformat (i, "del"))
19242 else if (unformat (i, "add"))
19244 else if (unformat (i, "proto tcp"))
19246 else if (unformat (i, "proto udp"))
19248 else if (unformat (i, "appns %d", &appns_index))
19250 else if (unformat (i, "scope %d", &scope))
19252 else if (unformat (i, "tag %_%v%_", &tag))
19256 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
19257 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
19265 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
19266 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
19272 else if (unformat (i, "action %d", &action))
19277 if (proto == ~0 || !conn_set || action == ~0)
19279 errmsg ("transport proto, connection and action must be set");
19285 errmsg ("scope should be 0-3");
19289 M (SESSION_RULE_ADD_DEL, mp);
19291 clib_memset (&lcl, 0, sizeof (lcl));
19292 clib_memset (&rmt, 0, sizeof (rmt));
19295 ip_set (&lcl.fp_addr, &lcl_ip4, 1);
19296 ip_set (&rmt.fp_addr, &rmt_ip4, 1);
19297 lcl.fp_len = lcl_plen;
19298 rmt.fp_len = rmt_plen;
19302 ip_set (&lcl.fp_addr, &lcl_ip6, 0);
19303 ip_set (&rmt.fp_addr, &rmt_ip6, 0);
19304 lcl.fp_len = lcl_plen;
19305 rmt.fp_len = rmt_plen;
19309 ip_prefix_encode (&lcl, &mp->lcl);
19310 ip_prefix_encode (&rmt, &mp->rmt);
19311 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
19312 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
19313 mp->transport_proto =
19314 proto ? TRANSPORT_PROTO_API_UDP : TRANSPORT_PROTO_API_TCP;
19315 mp->action_index = clib_host_to_net_u32 (action);
19316 mp->appns_index = clib_host_to_net_u32 (appns_index);
19318 mp->is_add = is_add;
19321 clib_memcpy (mp->tag, tag, vec_len (tag));
19331 api_session_rules_dump (vat_main_t * vam)
19333 vl_api_session_rules_dump_t *mp;
19334 vl_api_control_ping_t *mp_ping;
19337 if (!vam->json_output)
19339 print (vam->ofp, "%=20s", "Session Rules");
19342 M (SESSION_RULES_DUMP, mp);
19346 /* Use a control ping for synchronization */
19347 MPING (CONTROL_PING, mp_ping);
19350 /* Wait for a reply... */
19356 api_ip_container_proxy_add_del (vat_main_t * vam)
19358 vl_api_ip_container_proxy_add_del_t *mp;
19359 unformat_input_t *i = vam->input;
19360 u32 sw_if_index = ~0;
19361 vl_api_prefix_t pfx = { };
19365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19367 if (unformat (i, "del"))
19369 else if (unformat (i, "add"))
19371 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
19373 else if (unformat (i, "sw_if_index %u", &sw_if_index))
19378 if (sw_if_index == ~0 || pfx.len == 0)
19380 errmsg ("address and sw_if_index must be set");
19384 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
19386 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
19387 mp->is_add = is_add;
19388 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
19396 api_qos_record_enable_disable (vat_main_t * vam)
19398 unformat_input_t *i = vam->input;
19399 vl_api_qos_record_enable_disable_t *mp;
19400 u32 sw_if_index, qs = 0xff;
19401 u8 sw_if_index_set = 0;
19405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19407 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19408 sw_if_index_set = 1;
19409 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19410 sw_if_index_set = 1;
19411 else if (unformat (i, "%U", unformat_qos_source, &qs))
19413 else if (unformat (i, "disable"))
19417 clib_warning ("parse error '%U'", format_unformat_error, i);
19422 if (sw_if_index_set == 0)
19424 errmsg ("missing interface name or sw_if_index");
19429 errmsg ("input location must be specified");
19433 M (QOS_RECORD_ENABLE_DISABLE, mp);
19435 mp->record.sw_if_index = ntohl (sw_if_index);
19436 mp->record.input_source = qs;
19437 mp->enable = enable;
19446 q_or_quit (vat_main_t * vam)
19448 #if VPP_API_TEST_BUILTIN == 0
19449 longjmp (vam->jump_buf, 1);
19451 return 0; /* not so much */
19455 q (vat_main_t * vam)
19457 return q_or_quit (vam);
19461 quit (vat_main_t * vam)
19463 return q_or_quit (vam);
19467 comment (vat_main_t * vam)
19473 elog_save (vat_main_t * vam)
19475 #if VPP_API_TEST_BUILTIN == 0
19476 elog_main_t *em = &vam->elog_main;
19477 unformat_input_t *i = vam->input;
19478 char *file, *chroot_file;
19479 clib_error_t *error;
19481 if (!unformat (i, "%s", &file))
19483 errmsg ("expected file name, got `%U'", format_unformat_error, i);
19487 /* It's fairly hard to get "../oopsie" through unformat; just in case */
19488 if (strstr (file, "..") || index (file, '/'))
19490 errmsg ("illegal characters in filename '%s'", file);
19494 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
19498 errmsg ("Saving %wd of %wd events to %s",
19499 elog_n_events_in_buffer (em),
19500 elog_buffer_capacity (em), chroot_file);
19502 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
19503 vec_free (chroot_file);
19506 clib_error_report (error);
19508 errmsg ("Use the vpp event loger...");
19515 elog_setup (vat_main_t * vam)
19517 #if VPP_API_TEST_BUILTIN == 0
19518 elog_main_t *em = &vam->elog_main;
19519 unformat_input_t *i = vam->input;
19520 u32 nevents = 128 << 10;
19522 (void) unformat (i, "nevents %d", &nevents);
19524 elog_init (em, nevents);
19525 vl_api_set_elog_main (em);
19526 vl_api_set_elog_trace_api_messages (1);
19527 errmsg ("Event logger initialized with %u events", nevents);
19529 errmsg ("Use the vpp event loger...");
19535 elog_enable (vat_main_t * vam)
19537 #if VPP_API_TEST_BUILTIN == 0
19538 elog_main_t *em = &vam->elog_main;
19540 elog_enable_disable (em, 1 /* enable */ );
19541 vl_api_set_elog_trace_api_messages (1);
19542 errmsg ("Event logger enabled...");
19544 errmsg ("Use the vpp event loger...");
19550 elog_disable (vat_main_t * vam)
19552 #if VPP_API_TEST_BUILTIN == 0
19553 elog_main_t *em = &vam->elog_main;
19555 elog_enable_disable (em, 0 /* enable */ );
19556 vl_api_set_elog_trace_api_messages (1);
19557 errmsg ("Event logger disabled...");
19559 errmsg ("Use the vpp event loger...");
19565 statseg (vat_main_t * vam)
19567 ssvm_private_t *ssvmp = &vam->stat_segment;
19568 ssvm_shared_header_t *shared_header = ssvmp->sh;
19569 vlib_counter_t **counters;
19570 u64 thread0_index1_packets;
19571 u64 thread0_index1_bytes;
19572 f64 vector_rate, input_rate;
19575 uword *counter_vector_by_name;
19576 if (vam->stat_segment_lockp == 0)
19578 errmsg ("Stat segment not mapped...");
19582 /* look up "/if/rx for sw_if_index 1 as a test */
19584 clib_spinlock_lock (vam->stat_segment_lockp);
19586 counter_vector_by_name = (uword *) shared_header->opaque[1];
19588 p = hash_get_mem (counter_vector_by_name, "/if/rx");
19591 clib_spinlock_unlock (vam->stat_segment_lockp);
19592 errmsg ("/if/tx not found?");
19596 /* Fish per-thread vector of combined counters from shared memory */
19597 counters = (vlib_counter_t **) p[0];
19599 if (vec_len (counters[0]) < 2)
19601 clib_spinlock_unlock (vam->stat_segment_lockp);
19602 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
19606 /* Read thread 0 sw_if_index 1 counter */
19607 thread0_index1_packets = counters[0][1].packets;
19608 thread0_index1_bytes = counters[0][1].bytes;
19610 p = hash_get_mem (counter_vector_by_name, "vector_rate");
19613 clib_spinlock_unlock (vam->stat_segment_lockp);
19614 errmsg ("vector_rate not found?");
19618 vector_rate = *(f64 *) (p[0]);
19619 p = hash_get_mem (counter_vector_by_name, "input_rate");
19622 clib_spinlock_unlock (vam->stat_segment_lockp);
19623 errmsg ("input_rate not found?");
19626 input_rate = *(f64 *) (p[0]);
19628 clib_spinlock_unlock (vam->stat_segment_lockp);
19630 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
19631 vector_rate, input_rate);
19632 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
19633 thread0_index1_packets, thread0_index1_bytes);
19639 cmd_cmp (void *a1, void *a2)
19644 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
19648 help (vat_main_t * vam)
19653 unformat_input_t *i = vam->input;
19656 if (unformat (i, "%s", &name))
19660 vec_add1 (name, 0);
19662 hs = hash_get_mem (vam->help_by_name, name);
19664 print (vam->ofp, "usage: %s %s", name, hs[0]);
19666 print (vam->ofp, "No such msg / command '%s'", name);
19671 print (vam->ofp, "Help is available for the following:");
19674 hash_foreach_pair (p, vam->function_by_name,
19676 vec_add1 (cmds, (u8 *)(p->key));
19680 vec_sort_with_function (cmds, cmd_cmp);
19682 for (j = 0; j < vec_len (cmds); j++)
19683 print (vam->ofp, "%s", cmds[j]);
19690 set (vat_main_t * vam)
19692 u8 *name = 0, *value = 0;
19693 unformat_input_t *i = vam->input;
19695 if (unformat (i, "%s", &name))
19697 /* The input buffer is a vector, not a string. */
19698 value = vec_dup (i->buffer);
19699 vec_delete (value, i->index, 0);
19700 /* Almost certainly has a trailing newline */
19701 if (value[vec_len (value) - 1] == '\n')
19702 value[vec_len (value) - 1] = 0;
19703 /* Make sure it's a proper string, one way or the other */
19704 vec_add1 (value, 0);
19705 (void) clib_macro_set_value (&vam->macro_main,
19706 (char *) name, (char *) value);
19709 errmsg ("usage: set <name> <value>");
19717 unset (vat_main_t * vam)
19721 if (unformat (vam->input, "%s", &name))
19722 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
19723 errmsg ("unset: %s wasn't set", name);
19736 macro_sort_cmp (void *a1, void *a2)
19738 macro_sort_t *s1 = a1;
19739 macro_sort_t *s2 = a2;
19741 return strcmp ((char *) (s1->name), (char *) (s2->name));
19745 dump_macro_table (vat_main_t * vam)
19747 macro_sort_t *sort_me = 0, *sm;
19752 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
19754 vec_add2 (sort_me, sm, 1);
19755 sm->name = (u8 *)(p->key);
19756 sm->value = (u8 *) (p->value[0]);
19760 vec_sort_with_function (sort_me, macro_sort_cmp);
19762 if (vec_len (sort_me))
19763 print (vam->ofp, "%-15s%s", "Name", "Value");
19765 print (vam->ofp, "The macro table is empty...");
19767 for (i = 0; i < vec_len (sort_me); i++)
19768 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
19773 dump_node_table (vat_main_t * vam)
19776 vlib_node_t *node, *next_node;
19778 if (vec_len (vam->graph_nodes) == 0)
19780 print (vam->ofp, "Node table empty, issue get_node_graph...");
19784 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
19786 node = vam->graph_nodes[0][i];
19787 print (vam->ofp, "[%d] %s", i, node->name);
19788 for (j = 0; j < vec_len (node->next_nodes); j++)
19790 if (node->next_nodes[j] != ~0)
19792 next_node = vam->graph_nodes[0][node->next_nodes[j]];
19793 print (vam->ofp, " [%d] %s", j, next_node->name);
19801 value_sort_cmp (void *a1, void *a2)
19803 name_sort_t *n1 = a1;
19804 name_sort_t *n2 = a2;
19806 if (n1->value < n2->value)
19808 if (n1->value > n2->value)
19815 dump_msg_api_table (vat_main_t * vam)
19817 api_main_t *am = vlibapi_get_main ();
19818 name_sort_t *nses = 0, *ns;
19823 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
19825 vec_add2 (nses, ns, 1);
19826 ns->name = (u8 *)(hp->key);
19827 ns->value = (u32) hp->value[0];
19831 vec_sort_with_function (nses, value_sort_cmp);
19833 for (i = 0; i < vec_len (nses); i++)
19834 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
19840 get_msg_id (vat_main_t * vam)
19845 if (unformat (vam->input, "%s", &name_and_crc))
19847 message_index = vl_msg_api_get_msg_index (name_and_crc);
19848 if (message_index == ~0)
19850 print (vam->ofp, " '%s' not found", name_and_crc);
19853 print (vam->ofp, " '%s' has message index %d",
19854 name_and_crc, message_index);
19857 errmsg ("name_and_crc required...");
19862 search_node_table (vat_main_t * vam)
19864 unformat_input_t *line_input = vam->input;
19867 vlib_node_t *node, *next_node;
19870 if (vam->graph_node_index_by_name == 0)
19872 print (vam->ofp, "Node table empty, issue get_node_graph...");
19876 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
19878 if (unformat (line_input, "%s", &node_to_find))
19880 vec_add1 (node_to_find, 0);
19881 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
19884 print (vam->ofp, "%s not found...", node_to_find);
19887 node = vam->graph_nodes[0][p[0]];
19888 print (vam->ofp, "[%d] %s", p[0], node->name);
19889 for (j = 0; j < vec_len (node->next_nodes); j++)
19891 if (node->next_nodes[j] != ~0)
19893 next_node = vam->graph_nodes[0][node->next_nodes[j]];
19894 print (vam->ofp, " [%d] %s", j, next_node->name);
19901 clib_warning ("parse error '%U'", format_unformat_error,
19907 vec_free (node_to_find);
19916 script (vat_main_t * vam)
19918 #if (VPP_API_TEST_BUILTIN==0)
19920 char *save_current_file;
19921 unformat_input_t save_input;
19922 jmp_buf save_jump_buf;
19923 u32 save_line_number;
19925 FILE *new_fp, *save_ifp;
19927 if (unformat (vam->input, "%s", &s))
19929 new_fp = fopen ((char *) s, "r");
19932 errmsg ("Couldn't open script file %s", s);
19939 errmsg ("Missing script name");
19943 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
19944 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
19945 save_ifp = vam->ifp;
19946 save_line_number = vam->input_line_number;
19947 save_current_file = (char *) vam->current_file;
19949 vam->input_line_number = 0;
19951 vam->current_file = s;
19954 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
19955 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
19956 vam->ifp = save_ifp;
19957 vam->input_line_number = save_line_number;
19958 vam->current_file = (u8 *) save_current_file;
19963 clib_warning ("use the exec command...");
19969 echo (vat_main_t * vam)
19971 print (vam->ofp, "%v", vam->input->buffer);
19975 /* List of API message constructors, CLI names map to api_xxx */
19976 #define foreach_vpe_api_msg \
19977 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
19978 _(sw_interface_dump,"") \
19979 _(sw_interface_set_flags, \
19980 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
19981 _(sw_interface_add_del_address, \
19982 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
19983 _(sw_interface_set_rx_mode, \
19984 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
19985 _(sw_interface_set_rx_placement, \
19986 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
19987 _(sw_interface_rx_placement_dump, \
19988 "[<intfc> | sw_if_index <id>]") \
19989 _(sw_interface_set_table, \
19990 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
19991 _(sw_interface_set_mpls_enable, \
19992 "<intfc> | sw_if_index [disable | dis]") \
19993 _(sw_interface_set_vpath, \
19994 "<intfc> | sw_if_index <id> enable | disable") \
19995 _(sw_interface_set_vxlan_bypass, \
19996 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
19997 _(sw_interface_set_l2_xconnect, \
19998 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19999 "enable | disable") \
20000 _(sw_interface_set_l2_bridge, \
20001 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
20002 "[shg <split-horizon-group>] [bvi]\n" \
20003 "enable | disable") \
20004 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
20005 _(bridge_domain_add_del, \
20006 "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") \
20007 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
20009 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
20010 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
20011 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
20013 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20015 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20017 "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 | gro-coalesce] [persist] [attach] [tun] [packed] [in-order]") \
20019 "<vpp-if-name> | sw_if_index <id>") \
20020 _(sw_interface_tap_v2_dump, "") \
20021 _(virtio_pci_create_v2, \
20022 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled [gro-coalesce] | csum-offload-enabled] [packed] [in-order]") \
20023 _(virtio_pci_delete, \
20024 "<vpp-if-name> | sw_if_index <id>") \
20025 _(sw_interface_virtio_pci_dump, "") \
20027 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
20028 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
20031 "[hw-addr <mac-addr>] {mode round-robin | active-backup | " \
20032 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
20033 "[id <if-id>] [gso]") \
20035 "<vpp-if-name> | sw_if_index <id>") \
20036 _(bond_add_member, \
20037 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
20038 _(bond_detach_member, \
20039 "sw_if_index <n>") \
20040 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
20041 _(sw_bond_interface_dump, "<intfc> | sw_if_index <nn>") \
20042 _(sw_member_interface_dump, \
20043 "<vpp-if-name> | sw_if_index <id>") \
20044 _(ip_table_add_del, \
20045 "table <n> [ipv6] [add | del]\n") \
20046 _(ip_route_add_del, \
20047 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
20048 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
20049 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
20050 "[multipath] [count <n>] [del]") \
20051 _(ip_mroute_add_del, \
20052 "<src> <grp>/<mask> [table-id <n>]\n" \
20053 "[<intfc> | sw_if_index <id>] [local] [del]") \
20054 _(mpls_table_add_del, \
20055 "table <n> [add | del]\n") \
20056 _(mpls_route_add_del, \
20057 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
20058 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
20059 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
20060 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
20061 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
20062 "[count <n>] [del]") \
20063 _(mpls_ip_bind_unbind, \
20064 "<label> <addr/len>") \
20065 _(mpls_tunnel_add_del, \
20066 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
20067 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
20068 "[l2-only] [out-label <n>]") \
20069 _(sr_mpls_policy_add, \
20070 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
20071 _(sr_mpls_policy_del, \
20073 _(bier_table_add_del, \
20074 "<label> <sub-domain> <set> <bsl> [del]") \
20075 _(bier_route_add_del, \
20076 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
20077 "[<intfc> | sw_if_index <id>]" \
20078 "[weight <n>] [del] [multipath]") \
20079 _(sw_interface_set_unnumbered, \
20080 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
20081 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
20082 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
20083 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
20084 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
20085 "[outer_vlan_id_any][inner_vlan_id_any]") \
20086 _(ip_table_replace_begin, "table <n> [ipv6]") \
20087 _(ip_table_flush, "table <n> [ipv6]") \
20088 _(ip_table_replace_end, "table <n> [ipv6]") \
20089 _(set_ip_flow_hash, \
20090 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
20091 _(sw_interface_ip6_enable_disable, \
20092 "<intfc> | sw_if_index <id> enable | disable") \
20093 _(l2_patch_add_del, \
20094 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20095 "enable | disable") \
20096 _(sr_localsid_add_del, \
20097 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
20098 "fib-table <num> (end.psp) sw_if_index <num>") \
20099 _(classify_add_del_table, \
20100 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
20101 " [del] [del-chain] mask <mask-value>\n" \
20102 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
20103 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
20104 _(classify_add_del_session, \
20105 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
20106 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
20107 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
20108 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
20109 _(classify_set_interface_ip_table, \
20110 "<intfc> | sw_if_index <nn> table <nn>") \
20111 _(classify_set_interface_l2_tables, \
20112 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20113 " [other-table <nn>]") \
20114 _(get_node_index, "node <node-name") \
20115 _(add_node_next, "node <node-name> next <next-node-name>") \
20116 _(vxlan_offload_rx, \
20117 "hw { <interface name> | hw_if_index <nn>} " \
20118 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
20119 _(vxlan_add_del_tunnel, \
20120 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20121 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
20122 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20123 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20124 _(gre_tunnel_add_del, \
20125 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
20126 "[teb | erspan <session-id>] [del]") \
20127 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20128 _(l2_fib_clear_table, "") \
20129 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
20130 _(l2_interface_vlan_tag_rewrite, \
20131 "<intfc> | sw_if_index <nn> \n" \
20132 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
20133 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
20134 _(create_vhost_user_if, \
20135 "socket <filename> [server] [renumber <dev_instance>] " \
20136 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
20137 "[mac <mac_address>] [packed]") \
20138 _(modify_vhost_user_if, \
20139 "<intfc> | sw_if_index <nn> socket <filename>\n" \
20140 "[server] [renumber <dev_instance>] [gso] [packed]") \
20141 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
20142 _(sw_interface_vhost_user_dump, "<intfc> | sw_if_index <nn>") \
20143 _(show_version, "") \
20144 _(show_threads, "") \
20145 _(vxlan_gpe_add_del_tunnel, \
20146 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
20147 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20148 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
20149 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
20150 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20151 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
20152 _(interface_name_renumber, \
20153 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
20154 _(input_acl_set_interface, \
20155 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20156 " [l2-table <nn>] [del]") \
20157 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
20158 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
20159 _(ip_dump, "ipv4 | ipv6") \
20160 _(ipsec_spd_add_del, "spd_id <n> [del]") \
20161 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
20163 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
20164 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
20165 " integ_alg <alg> integ_key <hex>") \
20166 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
20167 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
20168 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
20169 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
20170 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
20171 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
20172 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
20173 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
20174 " [instance <n>]") \
20175 _(ipsec_sa_dump, "[sa_id <n>]") \
20176 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
20177 _(delete_loopback,"sw_if_index <nn>") \
20178 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20179 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
20180 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
20181 _(want_interface_events, "enable|disable") \
20182 _(get_first_msg_id, "client <name>") \
20183 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20184 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20185 "fib-id <nn> [ip4][ip6][default]") \
20186 _(get_node_graph, " ") \
20187 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20188 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20189 _(ioam_disable, "") \
20190 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
20191 " sw_if_index <sw_if_index> p <priority> " \
20192 "w <weight>] [del]") \
20193 _(one_add_del_locator, "locator-set <locator_name> " \
20194 "iface <intf> | sw_if_index <sw_if_index> " \
20195 "p <priority> w <weight> [del]") \
20196 _(one_add_del_local_eid,"vni <vni> eid " \
20197 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20198 "locator-set <locator_name> [del]" \
20199 "[key-id sha1|sha256 secret-key <secret-key>]")\
20200 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
20201 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
20202 _(one_enable_disable, "enable|disable") \
20203 _(one_map_register_enable_disable, "enable|disable") \
20204 _(one_map_register_fallback_threshold, "<value>") \
20205 _(one_rloc_probe_enable_disable, "enable|disable") \
20206 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20208 "rloc <locator> p <prio> " \
20209 "w <weight> [rloc <loc> ... ] " \
20210 "action <action> [del-all]") \
20211 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20213 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20214 _(one_use_petr, "ip-address> | disable") \
20215 _(one_map_request_mode, "src-dst|dst-only") \
20216 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20217 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20218 _(one_locator_set_dump, "[local | remote]") \
20219 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
20220 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20221 "[local] | [remote]") \
20222 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
20223 _(one_ndp_bd_get, "") \
20224 _(one_ndp_entries_get, "bd <bridge-domain>") \
20225 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip <ip4>") \
20226 _(one_l2_arp_bd_get, "") \
20227 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
20228 _(one_stats_enable_disable, "enable|disable") \
20229 _(show_one_stats_enable_disable, "") \
20230 _(one_eid_table_vni_dump, "") \
20231 _(one_eid_table_map_dump, "l2|l3") \
20232 _(one_map_resolver_dump, "") \
20233 _(one_map_server_dump, "") \
20234 _(one_adjacencies_get, "vni <vni>") \
20235 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
20236 _(show_one_rloc_probe_state, "") \
20237 _(show_one_map_register_state, "") \
20238 _(show_one_status, "") \
20239 _(one_stats_dump, "") \
20240 _(one_stats_flush, "") \
20241 _(one_get_map_request_itr_rlocs, "") \
20242 _(one_map_register_set_ttl, "<ttl>") \
20243 _(one_set_transport_protocol, "udp|api") \
20244 _(one_get_transport_protocol, "") \
20245 _(one_enable_disable_xtr_mode, "enable|disable") \
20246 _(one_show_xtr_mode, "") \
20247 _(one_enable_disable_pitr_mode, "enable|disable") \
20248 _(one_show_pitr_mode, "") \
20249 _(one_enable_disable_petr_mode, "enable|disable") \
20250 _(one_show_petr_mode, "") \
20251 _(show_one_nsh_mapping, "") \
20252 _(show_one_pitr, "") \
20253 _(show_one_use_petr, "") \
20254 _(show_one_map_request_mode, "") \
20255 _(show_one_map_register_ttl, "") \
20256 _(show_one_map_register_fallback_threshold, "") \
20257 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
20258 " sw_if_index <sw_if_index> p <priority> " \
20259 "w <weight>] [del]") \
20260 _(lisp_add_del_locator, "locator-set <locator_name> " \
20261 "iface <intf> | sw_if_index <sw_if_index> " \
20262 "p <priority> w <weight> [del]") \
20263 _(lisp_add_del_local_eid,"vni <vni> eid " \
20264 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20265 "locator-set <locator_name> [del]" \
20266 "[key-id sha1|sha256 secret-key <secret-key>]") \
20267 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
20268 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
20269 _(lisp_enable_disable, "enable|disable") \
20270 _(lisp_map_register_enable_disable, "enable|disable") \
20271 _(lisp_rloc_probe_enable_disable, "enable|disable") \
20272 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20274 "rloc <locator> p <prio> " \
20275 "w <weight> [rloc <loc> ... ] " \
20276 "action <action> [del-all]") \
20277 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20279 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20280 _(lisp_use_petr, "<ip-address> | disable") \
20281 _(lisp_map_request_mode, "src-dst|dst-only") \
20282 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20283 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20284 _(lisp_locator_set_dump, "[local | remote]") \
20285 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
20286 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20287 "[local] | [remote]") \
20288 _(lisp_eid_table_vni_dump, "") \
20289 _(lisp_eid_table_map_dump, "l2|l3") \
20290 _(lisp_map_resolver_dump, "") \
20291 _(lisp_map_server_dump, "") \
20292 _(lisp_adjacencies_get, "vni <vni>") \
20293 _(gpe_fwd_entry_vnis_get, "") \
20294 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
20295 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
20296 "[table <table-id>]") \
20297 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
20298 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
20299 _(gpe_set_encap_mode, "lisp|vxlan") \
20300 _(gpe_get_encap_mode, "") \
20301 _(lisp_gpe_add_del_iface, "up|down") \
20302 _(lisp_gpe_enable_disable, "enable|disable") \
20303 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
20304 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
20305 _(show_lisp_rloc_probe_state, "") \
20306 _(show_lisp_map_register_state, "") \
20307 _(show_lisp_status, "") \
20308 _(lisp_get_map_request_itr_rlocs, "") \
20309 _(show_lisp_pitr, "") \
20310 _(show_lisp_use_petr, "") \
20311 _(show_lisp_map_request_mode, "") \
20312 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
20313 _(af_packet_delete, "name <host interface name>") \
20314 _(af_packet_dump, "") \
20315 _(policer_add_del, "name <policer name> <params> [del]") \
20316 _(policer_dump, "[name <policer name>]") \
20317 _(policer_classify_set_interface, \
20318 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20319 " [l2-table <nn>] [del]") \
20320 _(policer_classify_dump, "type [ip4|ip6|l2]") \
20321 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
20322 _(mpls_table_dump, "") \
20323 _(mpls_route_dump, "table-id <ID>") \
20324 _(classify_table_ids, "") \
20325 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
20326 _(classify_table_info, "table_id <nn>") \
20327 _(classify_session_dump, "table_id <nn>") \
20328 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
20329 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
20330 "[template_interval <nn>] [udp_checksum]") \
20331 _(ipfix_exporter_dump, "") \
20332 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
20333 _(ipfix_classify_stream_dump, "") \
20334 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
20335 _(ipfix_classify_table_dump, "") \
20336 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
20337 _(sw_interface_span_dump, "[l2]") \
20338 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
20339 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
20340 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
20341 _(pg_enable_disable, "[stream <id>] disable") \
20342 _(pg_interface_enable_disable_coalesce, "<intf> | sw_if_index <nn> enable | disable") \
20343 _(ip_source_and_port_range_check_add_del, \
20344 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
20345 _(ip_source_and_port_range_check_interface_add_del, \
20346 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
20347 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
20348 _(delete_subif,"<intfc> | sw_if_index <nn>") \
20349 _(l2_interface_pbb_tag_rewrite, \
20350 "<intfc> | sw_if_index <nn> \n" \
20351 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
20352 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
20353 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
20354 _(flow_classify_set_interface, \
20355 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
20356 _(flow_classify_dump, "type [ip4|ip6]") \
20357 _(ip_table_dump, "") \
20358 _(ip_route_dump, "table-id [ip4|ip6]") \
20359 _(ip_mtable_dump, "") \
20360 _(ip_mroute_dump, "table-id [ip4|ip6]") \
20361 _(feature_enable_disable, "arc_name <arc_name> " \
20362 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
20363 _(feature_gso_enable_disable, "<intfc> | sw_if_index <nn> " \
20364 "[enable | disable] ") \
20365 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
20367 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
20368 "mac <mac-address> [del]") \
20369 _(l2_xconnect_dump, "") \
20370 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
20371 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
20372 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
20373 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
20374 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
20375 _(sock_init_shm, "size <nnn>") \
20376 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
20377 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
20378 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
20379 _(session_rules_dump, "") \
20380 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
20381 _(output_acl_set_interface, \
20382 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20383 " [l2-table <nn>] [del]") \
20384 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
20386 /* List of command functions, CLI names map directly to functions */
20387 #define foreach_cli_function \
20388 _(comment, "usage: comment <ignore-rest-of-line>") \
20389 _(dump_interface_table, "usage: dump_interface_table") \
20390 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
20391 _(dump_ipv4_table, "usage: dump_ipv4_table") \
20392 _(dump_ipv6_table, "usage: dump_ipv6_table") \
20393 _(dump_macro_table, "usage: dump_macro_table ") \
20394 _(dump_node_table, "usage: dump_node_table") \
20395 _(dump_msg_api_table, "usage: dump_msg_api_table") \
20396 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
20397 _(elog_disable, "usage: elog_disable") \
20398 _(elog_enable, "usage: elog_enable") \
20399 _(elog_save, "usage: elog_save <filename>") \
20400 _(get_msg_id, "usage: get_msg_id name_and_crc") \
20401 _(echo, "usage: echo <message>") \
20402 _(exec, "usage: exec <vpe-debug-CLI-command>") \
20403 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
20404 _(help, "usage: help") \
20405 _(q, "usage: quit") \
20406 _(quit, "usage: quit") \
20407 _(search_node_table, "usage: search_node_table <name>...") \
20408 _(set, "usage: set <variable-name> <value>") \
20409 _(script, "usage: script <file-name>") \
20410 _(statseg, "usage: statseg") \
20411 _(unset, "usage: unset <variable-name>")
20414 static void vl_api_##n##_t_handler_uni \
20415 (vl_api_##n##_t * mp) \
20417 vat_main_t * vam = &vat_main; \
20418 if (vam->json_output) { \
20419 vl_api_##n##_t_handler_json(mp); \
20421 vl_api_##n##_t_handler(mp); \
20424 foreach_vpe_api_reply_msg;
20425 #if VPP_API_TEST_BUILTIN == 0
20426 foreach_standalone_reply_msg;
20431 vat_api_hookup (vat_main_t * vam)
20434 vl_msg_api_set_handlers(VL_API_##N, #n, \
20435 vl_api_##n##_t_handler_uni, \
20437 vl_api_##n##_t_endian, \
20438 vl_api_##n##_t_print, \
20439 sizeof(vl_api_##n##_t), 1);
20440 foreach_vpe_api_reply_msg;
20441 #if VPP_API_TEST_BUILTIN == 0
20442 foreach_standalone_reply_msg;
20446 #if (VPP_API_TEST_BUILTIN==0)
20447 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
20449 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
20451 vam->function_by_name = hash_create_string (0, sizeof (uword));
20453 vam->help_by_name = hash_create_string (0, sizeof (uword));
20456 /* API messages we can send */
20457 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
20458 foreach_vpe_api_msg;
20462 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20463 foreach_vpe_api_msg;
20466 /* CLI functions */
20467 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
20468 foreach_cli_function;
20472 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20473 foreach_cli_function;
20477 #if VPP_API_TEST_BUILTIN
20478 static clib_error_t *
20479 vat_api_hookup_shim (vlib_main_t * vm)
20481 vat_api_hookup (&vat_main);
20485 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
20489 * fd.io coding-style-patch-verification: ON
20492 * eval: (c-set-style "gnu")