2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlib/pci/pci.h>
22 #include <vpp/api/types.h>
23 #include <vppinfra/socket.h>
24 #include <vlibapi/api.h>
25 #include <vlibmemory/api.h>
26 #include <vnet/ip/ip.h>
27 #include <vnet/ip-neighbor/ip_neighbor.h>
28 #include <vnet/ip/ip_types_api.h>
29 #include <vnet/l2/l2_input.h>
30 #include <vnet/l2tp/l2tp.h>
31 #include <vnet/vxlan/vxlan.h>
32 #include <vnet/geneve/geneve.h>
33 #include <vnet/gre/gre.h>
34 #include <vnet/vxlan-gpe/vxlan_gpe.h>
35 #include <vnet/lisp-gpe/lisp_gpe.h>
37 #include <vpp/api/vpe_msg_enum.h>
38 #include <vnet/l2/l2_classify.h>
39 #include <vnet/l2/l2_vtr.h>
40 #include <vnet/classify/in_out_acl.h>
41 #include <vnet/classify/policer_classify.h>
42 #include <vnet/classify/flow_classify.h>
43 #include <vnet/mpls/mpls.h>
44 #include <vnet/ipsec/ipsec.h>
46 #include <vnet/cop/cop.h>
47 #include <vnet/ip/ip6_hop_by_hop.h>
48 #include <vnet/ip/ip_source_and_port_range_check.h>
49 #include <vnet/policer/xlate.h>
50 #include <vnet/span/span.h>
51 #include <vnet/policer/policer.h>
52 #include <vnet/policer/police.h>
53 #include <vnet/mfib/mfib_types.h>
54 #include <vnet/bonding/node.h>
55 #include <vnet/qos/qos_types.h>
56 #include <vnet/ethernet/ethernet_types_api.h>
57 #include <vnet/ip/ip_types_api.h>
58 #include "vat/json_format.h"
59 #include <vnet/ip/ip_types_api.h>
60 #include <vnet/ethernet/ethernet_types_api.h>
65 #define vl_typedefs /* define message structures */
66 #include <vpp/api/vpe_all_api_h.h>
69 /* declare message handlers for each api */
71 #define vl_endianfun /* define message structures */
72 #include <vpp/api/vpe_all_api_h.h>
75 /* instantiate all the print functions we know about */
76 #if VPP_API_TEST_BUILTIN == 0
77 #define vl_print(handle, ...)
79 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
82 #include <vpp/api/vpe_all_api_h.h>
85 #define __plugin_msg_base 0
86 #include <vlibapi/vat_helper_macros.h>
88 #include <vnet/format_fns.h>
90 void vl_api_set_elog_main (elog_main_t * m);
91 int vl_api_set_elog_trace_api_messages (int enable);
93 #if VPP_API_TEST_BUILTIN == 0
103 vat_socket_connect (vat_main_t * vam)
106 vam->socket_client_main = &socket_client_main;
107 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
109 0 /* default socket rx, tx buffer */ )))
111 /* vpp expects the client index in network order */
112 vam->my_client_index = htonl (socket_client_main.client_index);
115 #else /* vpp built-in case, we don't do sockets... */
117 vat_socket_connect (vat_main_t * vam)
123 vl_socket_client_read (int wait)
129 vl_socket_client_write ()
135 vl_socket_client_msg_alloc (int nbytes)
143 vat_time_now (vat_main_t * vam)
145 #if VPP_API_TEST_BUILTIN
146 return vlib_time_now (vam->vlib_main);
148 return clib_time_now (&vam->clib_time);
153 errmsg (char *fmt, ...)
155 vat_main_t *vam = &vat_main;
160 s = va_format (0, fmt, &va);
165 #if VPP_API_TEST_BUILTIN
166 vlib_cli_output (vam->vlib_main, (char *) s);
169 if (vam->ifp != stdin)
170 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
171 vam->input_line_number);
173 fformat (vam->ofp, "%s\n", (char *) s);
181 #if VPP_API_TEST_BUILTIN == 0
183 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
185 vat_main_t *vam = va_arg (*args, vat_main_t *);
186 u32 *result = va_arg (*args, u32 *);
190 if (!unformat (input, "%s", &if_name))
193 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
201 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
206 /* Parse an IP4 address %d.%d.%d.%d. */
208 unformat_ip4_address (unformat_input_t * input, va_list * args)
210 u8 *result = va_arg (*args, u8 *);
213 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
216 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
228 unformat_ethernet_address (unformat_input_t * input, va_list * args)
230 u8 *result = va_arg (*args, u8 *);
233 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
234 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
238 for (i = 0; i < 6; i++)
239 if (a[i] >= (1 << 8))
242 for (i = 0; i < 6; i++)
248 /* Returns ethernet type as an int in host byte order. */
250 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
253 u16 *result = va_arg (*args, u16 *);
257 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
259 if (type >= (1 << 16))
267 /* Parse an IP6 address. */
269 unformat_ip6_address (unformat_input_t * input, va_list * args)
271 ip6_address_t *result = va_arg (*args, ip6_address_t *);
273 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
274 uword c, n_colon, double_colon_index;
276 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
277 double_colon_index = ARRAY_LEN (hex_quads);
278 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
281 if (c >= '0' && c <= '9')
283 else if (c >= 'a' && c <= 'f')
284 hex_digit = c + 10 - 'a';
285 else if (c >= 'A' && c <= 'F')
286 hex_digit = c + 10 - 'A';
287 else if (c == ':' && n_colon < 2)
291 unformat_put_input (input);
295 /* Too many hex quads. */
296 if (n_hex_quads >= ARRAY_LEN (hex_quads))
301 hex_quad = (hex_quad << 4) | hex_digit;
303 /* Hex quad must fit in 16 bits. */
304 if (n_hex_digits >= 4)
311 /* Save position of :: */
314 /* More than one :: ? */
315 if (double_colon_index < ARRAY_LEN (hex_quads))
317 double_colon_index = n_hex_quads;
320 if (n_colon > 0 && n_hex_digits > 0)
322 hex_quads[n_hex_quads++] = hex_quad;
328 if (n_hex_digits > 0)
329 hex_quads[n_hex_quads++] = hex_quad;
334 /* Expand :: to appropriate number of zero hex quads. */
335 if (double_colon_index < ARRAY_LEN (hex_quads))
337 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
339 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
340 hex_quads[n_zero + i] = hex_quads[i];
342 for (i = 0; i < n_zero; i++)
343 hex_quads[double_colon_index + i] = 0;
345 n_hex_quads = ARRAY_LEN (hex_quads);
348 /* Too few hex quads given. */
349 if (n_hex_quads < ARRAY_LEN (hex_quads))
352 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
353 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
360 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
362 u32 *r = va_arg (*args, u32 *);
365 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
366 foreach_ipsec_policy_action
374 format_ipsec_crypto_alg (u8 * s, va_list * args)
376 u32 i = va_arg (*args, u32);
381 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
382 foreach_ipsec_crypto_alg
385 return format (s, "unknown");
387 return format (s, "%s", t);
391 format_ipsec_integ_alg (u8 * s, va_list * args)
393 u32 i = va_arg (*args, u32);
398 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
399 foreach_ipsec_integ_alg
402 return format (s, "unknown");
404 return format (s, "%s", t);
407 #else /* VPP_API_TEST_BUILTIN == 1 */
409 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
411 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
412 vnet_main_t *vnm = vnet_get_main ();
413 u32 *result = va_arg (*args, u32 *);
415 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
419 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
421 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
422 vnet_main_t *vnm = vnet_get_main ();
423 u32 *result = va_arg (*args, u32 *);
425 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
428 #endif /* VPP_API_TEST_BUILTIN */
431 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
433 u32 *r = va_arg (*args, u32 *);
436 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
437 foreach_ipsec_crypto_alg
445 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
447 u32 *r = va_arg (*args, u32 *);
450 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
451 foreach_ipsec_integ_alg
459 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
461 u8 *r = va_arg (*args, u8 *);
463 if (unformat (input, "kbps"))
464 *r = SSE2_QOS_RATE_KBPS;
465 else if (unformat (input, "pps"))
466 *r = SSE2_QOS_RATE_PPS;
473 unformat_policer_round_type (unformat_input_t * input, va_list * args)
475 u8 *r = va_arg (*args, u8 *);
477 if (unformat (input, "closest"))
478 *r = SSE2_QOS_ROUND_TO_CLOSEST;
479 else if (unformat (input, "up"))
480 *r = SSE2_QOS_ROUND_TO_UP;
481 else if (unformat (input, "down"))
482 *r = SSE2_QOS_ROUND_TO_DOWN;
489 unformat_policer_type (unformat_input_t * input, va_list * args)
491 u8 *r = va_arg (*args, u8 *);
493 if (unformat (input, "1r2c"))
494 *r = SSE2_QOS_POLICER_TYPE_1R2C;
495 else if (unformat (input, "1r3c"))
496 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
497 else if (unformat (input, "2r3c-2698"))
498 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
499 else if (unformat (input, "2r3c-4115"))
500 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
501 else if (unformat (input, "2r3c-mef5cf1"))
502 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
509 unformat_dscp (unformat_input_t * input, va_list * va)
511 u8 *r = va_arg (*va, u8 *);
514 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
523 unformat_policer_action_type (unformat_input_t * input, va_list * va)
525 sse2_qos_pol_action_params_st *a
526 = va_arg (*va, sse2_qos_pol_action_params_st *);
528 if (unformat (input, "drop"))
529 a->action_type = SSE2_QOS_ACTION_DROP;
530 else if (unformat (input, "transmit"))
531 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
532 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
533 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
540 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
542 u32 *r = va_arg (*va, u32 *);
545 if (unformat (input, "ip4"))
546 tid = POLICER_CLASSIFY_TABLE_IP4;
547 else if (unformat (input, "ip6"))
548 tid = POLICER_CLASSIFY_TABLE_IP6;
549 else if (unformat (input, "l2"))
550 tid = POLICER_CLASSIFY_TABLE_L2;
559 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
561 u32 *r = va_arg (*va, u32 *);
564 if (unformat (input, "ip4"))
565 tid = FLOW_CLASSIFY_TABLE_IP4;
566 else if (unformat (input, "ip6"))
567 tid = FLOW_CLASSIFY_TABLE_IP6;
575 #if (VPP_API_TEST_BUILTIN==0)
577 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
578 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
579 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
580 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
583 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
585 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
586 mfib_itf_attribute_t attr;
589 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
591 if (unformat (input, mfib_itf_flag_long_names[attr]))
592 *iflags |= (1 << attr);
594 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
596 if (unformat (input, mfib_itf_flag_names[attr]))
597 *iflags |= (1 << attr);
600 return (old == *iflags ? 0 : 1);
604 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
606 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
607 mfib_entry_attribute_t attr;
610 FOR_EACH_MFIB_ATTRIBUTE (attr)
612 if (unformat (input, mfib_flag_long_names[attr]))
613 *eflags |= (1 << attr);
615 FOR_EACH_MFIB_ATTRIBUTE (attr)
617 if (unformat (input, mfib_flag_names[attr]))
618 *eflags |= (1 << attr);
621 return (old == *eflags ? 0 : 1);
625 format_ip4_address (u8 * s, va_list * args)
627 u8 *a = va_arg (*args, u8 *);
628 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
632 format_ip6_address (u8 * s, va_list * args)
634 ip6_address_t *a = va_arg (*args, ip6_address_t *);
635 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
637 i_max_n_zero = ARRAY_LEN (a->as_u16);
639 i_first_zero = i_max_n_zero;
641 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
643 u32 is_zero = a->as_u16[i] == 0;
644 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
650 if ((!is_zero && n_zeros > max_n_zeros)
651 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
653 i_max_n_zero = i_first_zero;
654 max_n_zeros = n_zeros;
655 i_first_zero = ARRAY_LEN (a->as_u16);
660 last_double_colon = 0;
661 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
663 if (i == i_max_n_zero && max_n_zeros > 1)
665 s = format (s, "::");
666 i += max_n_zeros - 1;
667 last_double_colon = 1;
671 s = format (s, "%s%x",
672 (last_double_colon || i == 0) ? "" : ":",
673 clib_net_to_host_u16 (a->as_u16[i]));
674 last_double_colon = 0;
681 /* Format an IP46 address. */
683 format_ip46_address (u8 * s, va_list * args)
685 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
686 ip46_type_t type = va_arg (*args, ip46_type_t);
692 is_ip4 = ip46_address_is_ip4 (ip46);
703 format (s, "%U", format_ip4_address, &ip46->ip4) :
704 format (s, "%U", format_ip6_address, &ip46->ip6);
708 format_ethernet_address (u8 * s, va_list * args)
710 u8 *a = va_arg (*args, u8 *);
712 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
713 a[0], a[1], a[2], a[3], a[4], a[5]);
718 increment_v4_address (vl_api_ip4_address_t * i)
720 ip4_address_t *a = (ip4_address_t *) i;
723 v = ntohl (a->as_u32) + 1;
724 a->as_u32 = ntohl (v);
728 increment_v6_address (vl_api_ip6_address_t * i)
730 ip6_address_t *a = (ip6_address_t *) i;
733 v0 = clib_net_to_host_u64 (a->as_u64[0]);
734 v1 = clib_net_to_host_u64 (a->as_u64[1]);
739 a->as_u64[0] = clib_net_to_host_u64 (v0);
740 a->as_u64[1] = clib_net_to_host_u64 (v1);
744 increment_address (vl_api_address_t * a)
746 if (clib_net_to_host_u32 (a->af) == ADDRESS_IP4)
747 increment_v4_address (&a->un.ip4);
748 else if (clib_net_to_host_u32 (a->af) == ADDRESS_IP6)
749 increment_v6_address (&a->un.ip6);
753 set_ip4_address (vl_api_address_t * a, u32 v)
755 if (a->af == ADDRESS_IP4)
757 ip4_address_t *i = (ip4_address_t *) & a->un.ip4;
763 increment_mac_address (u8 * mac)
765 u64 tmp = *((u64 *) mac);
766 tmp = clib_net_to_host_u64 (tmp);
767 tmp += 1 << 16; /* skip unused (least significant) octets */
768 tmp = clib_host_to_net_u64 (tmp);
770 clib_memcpy (mac, &tmp, 6);
774 vat_json_object_add_address (vat_json_node_t * node,
775 const char *str, const vl_api_address_t * addr)
777 if (ADDRESS_IP6 == addr->af)
781 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
782 vat_json_object_add_ip6 (node, str, ip6);
788 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
789 vat_json_object_add_ip4 (node, str, ip4);
794 vat_json_object_add_prefix (vat_json_node_t * node,
795 const vl_api_prefix_t * prefix)
797 vat_json_object_add_uint (node, "len", prefix->len);
798 vat_json_object_add_address (node, "address", &prefix->address);
801 static void vl_api_create_loopback_reply_t_handler
802 (vl_api_create_loopback_reply_t * mp)
804 vat_main_t *vam = &vat_main;
805 i32 retval = ntohl (mp->retval);
807 vam->retval = retval;
808 vam->regenerate_interface_table = 1;
809 vam->sw_if_index = ntohl (mp->sw_if_index);
810 vam->result_ready = 1;
813 static void vl_api_create_loopback_reply_t_handler_json
814 (vl_api_create_loopback_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 vat_json_node_t node;
819 vat_json_init_object (&node);
820 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
821 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
823 vat_json_print (vam->ofp, &node);
824 vat_json_free (&node);
825 vam->retval = ntohl (mp->retval);
826 vam->result_ready = 1;
829 static void vl_api_create_loopback_instance_reply_t_handler
830 (vl_api_create_loopback_instance_reply_t * mp)
832 vat_main_t *vam = &vat_main;
833 i32 retval = ntohl (mp->retval);
835 vam->retval = retval;
836 vam->regenerate_interface_table = 1;
837 vam->sw_if_index = ntohl (mp->sw_if_index);
838 vam->result_ready = 1;
841 static void vl_api_create_loopback_instance_reply_t_handler_json
842 (vl_api_create_loopback_instance_reply_t * mp)
844 vat_main_t *vam = &vat_main;
845 vat_json_node_t node;
847 vat_json_init_object (&node);
848 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
849 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
851 vat_json_print (vam->ofp, &node);
852 vat_json_free (&node);
853 vam->retval = ntohl (mp->retval);
854 vam->result_ready = 1;
857 static void vl_api_af_packet_create_reply_t_handler
858 (vl_api_af_packet_create_reply_t * mp)
860 vat_main_t *vam = &vat_main;
861 i32 retval = ntohl (mp->retval);
863 vam->retval = retval;
864 vam->regenerate_interface_table = 1;
865 vam->sw_if_index = ntohl (mp->sw_if_index);
866 vam->result_ready = 1;
869 static void vl_api_af_packet_create_reply_t_handler_json
870 (vl_api_af_packet_create_reply_t * mp)
872 vat_main_t *vam = &vat_main;
873 vat_json_node_t node;
875 vat_json_init_object (&node);
876 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
877 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
879 vat_json_print (vam->ofp, &node);
880 vat_json_free (&node);
882 vam->retval = ntohl (mp->retval);
883 vam->result_ready = 1;
886 static void vl_api_create_vlan_subif_reply_t_handler
887 (vl_api_create_vlan_subif_reply_t * mp)
889 vat_main_t *vam = &vat_main;
890 i32 retval = ntohl (mp->retval);
892 vam->retval = retval;
893 vam->regenerate_interface_table = 1;
894 vam->sw_if_index = ntohl (mp->sw_if_index);
895 vam->result_ready = 1;
898 static void vl_api_create_vlan_subif_reply_t_handler_json
899 (vl_api_create_vlan_subif_reply_t * mp)
901 vat_main_t *vam = &vat_main;
902 vat_json_node_t node;
904 vat_json_init_object (&node);
905 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
906 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
908 vat_json_print (vam->ofp, &node);
909 vat_json_free (&node);
911 vam->retval = ntohl (mp->retval);
912 vam->result_ready = 1;
915 static void vl_api_create_subif_reply_t_handler
916 (vl_api_create_subif_reply_t * mp)
918 vat_main_t *vam = &vat_main;
919 i32 retval = ntohl (mp->retval);
921 vam->retval = retval;
922 vam->regenerate_interface_table = 1;
923 vam->sw_if_index = ntohl (mp->sw_if_index);
924 vam->result_ready = 1;
927 static void vl_api_create_subif_reply_t_handler_json
928 (vl_api_create_subif_reply_t * mp)
930 vat_main_t *vam = &vat_main;
931 vat_json_node_t node;
933 vat_json_init_object (&node);
934 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
935 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
937 vat_json_print (vam->ofp, &node);
938 vat_json_free (&node);
940 vam->retval = ntohl (mp->retval);
941 vam->result_ready = 1;
944 static void vl_api_interface_name_renumber_reply_t_handler
945 (vl_api_interface_name_renumber_reply_t * mp)
947 vat_main_t *vam = &vat_main;
948 i32 retval = ntohl (mp->retval);
950 vam->retval = retval;
951 vam->regenerate_interface_table = 1;
952 vam->result_ready = 1;
955 static void vl_api_interface_name_renumber_reply_t_handler_json
956 (vl_api_interface_name_renumber_reply_t * mp)
958 vat_main_t *vam = &vat_main;
959 vat_json_node_t node;
961 vat_json_init_object (&node);
962 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
964 vat_json_print (vam->ofp, &node);
965 vat_json_free (&node);
967 vam->retval = ntohl (mp->retval);
968 vam->result_ready = 1;
972 * Special-case: build the interface table, maintain
973 * the next loopback sw_if_index vbl.
975 static void vl_api_sw_interface_details_t_handler
976 (vl_api_sw_interface_details_t * mp)
978 vat_main_t *vam = &vat_main;
979 u8 *s = format (0, "%s%c", mp->interface_name, 0);
981 hash_set_mem (vam->sw_if_index_by_interface_name, s,
982 ntohl (mp->sw_if_index));
984 /* In sub interface case, fill the sub interface table entry */
985 if (mp->sw_if_index != mp->sup_sw_if_index)
987 sw_interface_subif_t *sub = NULL;
989 vec_add2 (vam->sw_if_subif_table, sub, 1);
991 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
992 strncpy ((char *) sub->interface_name, (char *) s,
993 vec_len (sub->interface_name));
994 sub->sw_if_index = ntohl (mp->sw_if_index);
995 sub->sub_id = ntohl (mp->sub_id);
997 sub->raw_flags = ntohl (mp->sub_if_flags & SUB_IF_API_FLAG_MASK_VNET);
999 sub->sub_number_of_tags = mp->sub_number_of_tags;
1000 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
1001 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
1003 /* vlan tag rewrite */
1004 sub->vtr_op = ntohl (mp->vtr_op);
1005 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
1006 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
1007 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
1011 static void vl_api_sw_interface_details_t_handler_json
1012 (vl_api_sw_interface_details_t * mp)
1014 vat_main_t *vam = &vat_main;
1015 vat_json_node_t *node = NULL;
1017 if (VAT_JSON_ARRAY != vam->json_tree.type)
1019 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1020 vat_json_init_array (&vam->json_tree);
1022 node = vat_json_array_add (&vam->json_tree);
1024 vat_json_init_object (node);
1025 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1026 vat_json_object_add_uint (node, "sup_sw_if_index",
1027 ntohl (mp->sup_sw_if_index));
1028 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
1029 sizeof (mp->l2_address));
1030 vat_json_object_add_string_copy (node, "interface_name",
1031 mp->interface_name);
1032 vat_json_object_add_string_copy (node, "interface_dev_type",
1033 mp->interface_dev_type);
1034 vat_json_object_add_uint (node, "flags", mp->flags);
1035 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1036 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1037 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1038 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1039 vat_json_object_add_uint (node, "sub_number_of_tags",
1040 mp->sub_number_of_tags);
1041 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1042 ntohs (mp->sub_outer_vlan_id));
1043 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1044 ntohs (mp->sub_inner_vlan_id));
1045 vat_json_object_add_uint (node, "sub_if_flags", ntohl (mp->sub_if_flags));
1046 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1047 vat_json_object_add_uint (node, "vtr_push_dot1q",
1048 ntohl (mp->vtr_push_dot1q));
1049 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1050 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1051 if (ntohl (mp->sub_if_flags) & SUB_IF_API_FLAG_DOT1AH)
1053 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1055 format_ethernet_address,
1057 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1059 format_ethernet_address,
1061 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1062 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1066 #if VPP_API_TEST_BUILTIN == 0
1067 static void vl_api_sw_interface_event_t_handler
1068 (vl_api_sw_interface_event_t * mp)
1070 vat_main_t *vam = &vat_main;
1071 if (vam->interface_event_display)
1072 errmsg ("interface flags: sw_if_index %d %s %s",
1073 ntohl (mp->sw_if_index),
1074 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
1075 "admin-up" : "admin-down",
1076 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_LINK_UP) ?
1077 "link-up" : "link-down");
1081 __clib_unused static void
1082 vl_api_sw_interface_event_t_handler_json (vl_api_sw_interface_event_t * mp)
1084 /* JSON output not supported */
1088 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1090 vat_main_t *vam = &vat_main;
1091 i32 retval = ntohl (mp->retval);
1093 vam->retval = retval;
1094 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1095 vam->result_ready = 1;
1099 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1101 vat_main_t *vam = &vat_main;
1102 vat_json_node_t node;
1106 vat_json_init_object (&node);
1107 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1108 vat_json_object_add_uint (&node, "reply_in_shmem",
1109 ntohl (mp->reply_in_shmem));
1110 /* Toss the shared-memory original... */
1111 oldheap = vl_msg_push_heap ();
1113 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1116 vl_msg_pop_heap (oldheap);
1118 vat_json_print (vam->ofp, &node);
1119 vat_json_free (&node);
1121 vam->retval = ntohl (mp->retval);
1122 vam->result_ready = 1;
1126 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1128 vat_main_t *vam = &vat_main;
1129 i32 retval = ntohl (mp->retval);
1130 u32 length = vl_api_string_len (&mp->reply);
1132 vec_reset_length (vam->cmd_reply);
1134 vam->retval = retval;
1137 vec_validate (vam->cmd_reply, length);
1138 clib_memcpy ((char *) (vam->cmd_reply),
1139 vl_api_from_api_string (&mp->reply), length);
1140 vam->cmd_reply[length] = 0;
1142 vam->result_ready = 1;
1146 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1148 vat_main_t *vam = &vat_main;
1149 vat_json_node_t node;
1151 vec_reset_length (vam->cmd_reply);
1153 vat_json_init_object (&node);
1154 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1155 vat_json_object_add_string_copy (&node, "reply",
1156 vl_api_from_api_string (&mp->reply));
1158 vat_json_print (vam->ofp, &node);
1159 vat_json_free (&node);
1161 vam->retval = ntohl (mp->retval);
1162 vam->result_ready = 1;
1165 static void vl_api_classify_add_del_table_reply_t_handler
1166 (vl_api_classify_add_del_table_reply_t * mp)
1168 vat_main_t *vam = &vat_main;
1169 i32 retval = ntohl (mp->retval);
1170 if (vam->async_mode)
1172 vam->async_errors += (retval < 0);
1176 vam->retval = retval;
1178 ((mp->new_table_index != 0xFFFFFFFF) ||
1179 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1180 (mp->match_n_vectors != 0xFFFFFFFF)))
1182 * Note: this is just barely thread-safe, depends on
1183 * the main thread spinning waiting for an answer...
1185 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1186 ntohl (mp->new_table_index),
1187 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1188 vam->result_ready = 1;
1192 static void vl_api_classify_add_del_table_reply_t_handler_json
1193 (vl_api_classify_add_del_table_reply_t * mp)
1195 vat_main_t *vam = &vat_main;
1196 vat_json_node_t node;
1198 vat_json_init_object (&node);
1199 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1200 vat_json_object_add_uint (&node, "new_table_index",
1201 ntohl (mp->new_table_index));
1202 vat_json_object_add_uint (&node, "skip_n_vectors",
1203 ntohl (mp->skip_n_vectors));
1204 vat_json_object_add_uint (&node, "match_n_vectors",
1205 ntohl (mp->match_n_vectors));
1207 vat_json_print (vam->ofp, &node);
1208 vat_json_free (&node);
1210 vam->retval = ntohl (mp->retval);
1211 vam->result_ready = 1;
1214 static void vl_api_get_node_index_reply_t_handler
1215 (vl_api_get_node_index_reply_t * mp)
1217 vat_main_t *vam = &vat_main;
1218 i32 retval = ntohl (mp->retval);
1219 if (vam->async_mode)
1221 vam->async_errors += (retval < 0);
1225 vam->retval = retval;
1227 errmsg ("node index %d", ntohl (mp->node_index));
1228 vam->result_ready = 1;
1232 static void vl_api_get_node_index_reply_t_handler_json
1233 (vl_api_get_node_index_reply_t * mp)
1235 vat_main_t *vam = &vat_main;
1236 vat_json_node_t node;
1238 vat_json_init_object (&node);
1239 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1240 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1242 vat_json_print (vam->ofp, &node);
1243 vat_json_free (&node);
1245 vam->retval = ntohl (mp->retval);
1246 vam->result_ready = 1;
1249 static void vl_api_get_next_index_reply_t_handler
1250 (vl_api_get_next_index_reply_t * mp)
1252 vat_main_t *vam = &vat_main;
1253 i32 retval = ntohl (mp->retval);
1254 if (vam->async_mode)
1256 vam->async_errors += (retval < 0);
1260 vam->retval = retval;
1262 errmsg ("next node index %d", ntohl (mp->next_index));
1263 vam->result_ready = 1;
1267 static void vl_api_get_next_index_reply_t_handler_json
1268 (vl_api_get_next_index_reply_t * mp)
1270 vat_main_t *vam = &vat_main;
1271 vat_json_node_t node;
1273 vat_json_init_object (&node);
1274 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1275 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1277 vat_json_print (vam->ofp, &node);
1278 vat_json_free (&node);
1280 vam->retval = ntohl (mp->retval);
1281 vam->result_ready = 1;
1284 static void vl_api_add_node_next_reply_t_handler
1285 (vl_api_add_node_next_reply_t * mp)
1287 vat_main_t *vam = &vat_main;
1288 i32 retval = ntohl (mp->retval);
1289 if (vam->async_mode)
1291 vam->async_errors += (retval < 0);
1295 vam->retval = retval;
1297 errmsg ("next index %d", ntohl (mp->next_index));
1298 vam->result_ready = 1;
1302 static void vl_api_add_node_next_reply_t_handler_json
1303 (vl_api_add_node_next_reply_t * mp)
1305 vat_main_t *vam = &vat_main;
1306 vat_json_node_t node;
1308 vat_json_init_object (&node);
1309 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1310 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1312 vat_json_print (vam->ofp, &node);
1313 vat_json_free (&node);
1315 vam->retval = ntohl (mp->retval);
1316 vam->result_ready = 1;
1319 static void vl_api_show_version_reply_t_handler
1320 (vl_api_show_version_reply_t * mp)
1322 vat_main_t *vam = &vat_main;
1323 i32 retval = ntohl (mp->retval);
1327 errmsg (" program: %s", mp->program);
1328 errmsg (" version: %s", mp->version);
1329 errmsg (" build date: %s", mp->build_date);
1330 errmsg ("build directory: %s", mp->build_directory);
1332 vam->retval = retval;
1333 vam->result_ready = 1;
1336 static void vl_api_show_version_reply_t_handler_json
1337 (vl_api_show_version_reply_t * mp)
1339 vat_main_t *vam = &vat_main;
1340 vat_json_node_t node;
1342 vat_json_init_object (&node);
1343 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1344 vat_json_object_add_string_copy (&node, "program", mp->program);
1345 vat_json_object_add_string_copy (&node, "version", mp->version);
1346 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1347 vat_json_object_add_string_copy (&node, "build_directory",
1348 mp->build_directory);
1350 vat_json_print (vam->ofp, &node);
1351 vat_json_free (&node);
1353 vam->retval = ntohl (mp->retval);
1354 vam->result_ready = 1;
1357 static void vl_api_show_threads_reply_t_handler
1358 (vl_api_show_threads_reply_t * mp)
1360 vat_main_t *vam = &vat_main;
1361 i32 retval = ntohl (mp->retval);
1365 count = ntohl (mp->count);
1367 for (i = 0; i < count; i++)
1369 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1370 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1371 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1372 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1373 ntohl (mp->thread_data[i].cpu_socket));
1375 vam->retval = retval;
1376 vam->result_ready = 1;
1379 static void vl_api_show_threads_reply_t_handler_json
1380 (vl_api_show_threads_reply_t * mp)
1382 vat_main_t *vam = &vat_main;
1383 vat_json_node_t node;
1384 vl_api_thread_data_t *td;
1385 i32 retval = ntohl (mp->retval);
1389 count = ntohl (mp->count);
1391 vat_json_init_object (&node);
1392 vat_json_object_add_int (&node, "retval", retval);
1393 vat_json_object_add_uint (&node, "count", count);
1395 for (i = 0; i < count; i++)
1397 td = &mp->thread_data[i];
1398 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1399 vat_json_object_add_string_copy (&node, "name", td->name);
1400 vat_json_object_add_string_copy (&node, "type", td->type);
1401 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1402 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1403 vat_json_object_add_int (&node, "core", ntohl (td->id));
1404 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1407 vat_json_print (vam->ofp, &node);
1408 vat_json_free (&node);
1410 vam->retval = retval;
1411 vam->result_ready = 1;
1415 api_show_threads (vat_main_t * vam)
1417 vl_api_show_threads_t *mp;
1421 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1422 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1424 M (SHOW_THREADS, mp);
1432 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1434 u32 n_macs = ntohl (mp->n_macs);
1435 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1436 ntohl (mp->pid), mp->client_index, n_macs);
1438 for (i = 0; i < n_macs; i++)
1440 vl_api_mac_entry_t *mac = &mp->mac[i];
1441 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1442 i + 1, ntohl (mac->sw_if_index),
1443 format_ethernet_address, mac->mac_addr, mac->action);
1450 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1452 /* JSON output not supported */
1455 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1456 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1459 * Special-case: build the bridge domain table, maintain
1460 * the next bd id vbl.
1462 static void vl_api_bridge_domain_details_t_handler
1463 (vl_api_bridge_domain_details_t * mp)
1465 vat_main_t *vam = &vat_main;
1466 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1469 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1470 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1472 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1473 ntohl (mp->bd_id), mp->learn, mp->forward,
1474 mp->flood, ntohl (mp->bvi_sw_if_index),
1475 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1479 vl_api_bridge_domain_sw_if_t *sw_ifs;
1480 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1483 sw_ifs = mp->sw_if_details;
1484 for (i = 0; i < n_sw_ifs; i++)
1490 sw_if_index = ntohl (sw_ifs->sw_if_index);
1493 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1495 if ((u32) p->value[0] == sw_if_index)
1497 sw_if_name = (u8 *)(p->key);
1502 print (vam->ofp, "%7d %3d %s", sw_if_index,
1503 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1504 "sw_if_index not found!");
1511 static void vl_api_bridge_domain_details_t_handler_json
1512 (vl_api_bridge_domain_details_t * mp)
1514 vat_main_t *vam = &vat_main;
1515 vat_json_node_t *node, *array = NULL;
1516 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1518 if (VAT_JSON_ARRAY != vam->json_tree.type)
1520 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1521 vat_json_init_array (&vam->json_tree);
1523 node = vat_json_array_add (&vam->json_tree);
1525 vat_json_init_object (node);
1526 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1527 vat_json_object_add_uint (node, "flood", mp->flood);
1528 vat_json_object_add_uint (node, "forward", mp->forward);
1529 vat_json_object_add_uint (node, "learn", mp->learn);
1530 vat_json_object_add_uint (node, "bvi_sw_if_index",
1531 ntohl (mp->bvi_sw_if_index));
1532 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1533 array = vat_json_object_add (node, "sw_if");
1534 vat_json_init_array (array);
1540 vl_api_bridge_domain_sw_if_t *sw_ifs;
1543 sw_ifs = mp->sw_if_details;
1544 for (i = 0; i < n_sw_ifs; i++)
1546 node = vat_json_array_add (array);
1547 vat_json_init_object (node);
1548 vat_json_object_add_uint (node, "sw_if_index",
1549 ntohl (sw_ifs->sw_if_index));
1550 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1556 static void vl_api_control_ping_reply_t_handler
1557 (vl_api_control_ping_reply_t * mp)
1559 vat_main_t *vam = &vat_main;
1560 i32 retval = ntohl (mp->retval);
1561 if (vam->async_mode)
1563 vam->async_errors += (retval < 0);
1567 vam->retval = retval;
1568 vam->result_ready = 1;
1570 if (vam->socket_client_main)
1571 vam->socket_client_main->control_pings_outstanding--;
1574 static void vl_api_control_ping_reply_t_handler_json
1575 (vl_api_control_ping_reply_t * mp)
1577 vat_main_t *vam = &vat_main;
1578 i32 retval = ntohl (mp->retval);
1580 if (VAT_JSON_NONE != vam->json_tree.type)
1582 vat_json_print (vam->ofp, &vam->json_tree);
1583 vat_json_free (&vam->json_tree);
1584 vam->json_tree.type = VAT_JSON_NONE;
1589 vat_json_init_array (&vam->json_tree);
1590 vat_json_print (vam->ofp, &vam->json_tree);
1591 vam->json_tree.type = VAT_JSON_NONE;
1594 vam->retval = retval;
1595 vam->result_ready = 1;
1599 vl_api_bridge_domain_set_mac_age_reply_t_handler
1600 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1602 vat_main_t *vam = &vat_main;
1603 i32 retval = ntohl (mp->retval);
1604 if (vam->async_mode)
1606 vam->async_errors += (retval < 0);
1610 vam->retval = retval;
1611 vam->result_ready = 1;
1615 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1616 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1618 vat_main_t *vam = &vat_main;
1619 vat_json_node_t node;
1621 vat_json_init_object (&node);
1622 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1624 vat_json_print (vam->ofp, &node);
1625 vat_json_free (&node);
1627 vam->retval = ntohl (mp->retval);
1628 vam->result_ready = 1;
1632 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1634 vat_main_t *vam = &vat_main;
1635 i32 retval = ntohl (mp->retval);
1636 if (vam->async_mode)
1638 vam->async_errors += (retval < 0);
1642 vam->retval = retval;
1643 vam->result_ready = 1;
1647 static void vl_api_l2_flags_reply_t_handler_json
1648 (vl_api_l2_flags_reply_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 vat_json_node_t node;
1653 vat_json_init_object (&node);
1654 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1655 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1656 ntohl (mp->resulting_feature_bitmap));
1658 vat_json_print (vam->ofp, &node);
1659 vat_json_free (&node);
1661 vam->retval = ntohl (mp->retval);
1662 vam->result_ready = 1;
1665 static void vl_api_bridge_flags_reply_t_handler
1666 (vl_api_bridge_flags_reply_t * mp)
1668 vat_main_t *vam = &vat_main;
1669 i32 retval = ntohl (mp->retval);
1670 if (vam->async_mode)
1672 vam->async_errors += (retval < 0);
1676 vam->retval = retval;
1677 vam->result_ready = 1;
1681 static void vl_api_bridge_flags_reply_t_handler_json
1682 (vl_api_bridge_flags_reply_t * mp)
1684 vat_main_t *vam = &vat_main;
1685 vat_json_node_t node;
1687 vat_json_init_object (&node);
1688 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1689 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1690 ntohl (mp->resulting_feature_bitmap));
1692 vat_json_print (vam->ofp, &node);
1693 vat_json_free (&node);
1695 vam->retval = ntohl (mp->retval);
1696 vam->result_ready = 1;
1700 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1702 vat_main_t *vam = &vat_main;
1703 i32 retval = ntohl (mp->retval);
1704 if (vam->async_mode)
1706 vam->async_errors += (retval < 0);
1710 vam->retval = retval;
1711 vam->sw_if_index = ntohl (mp->sw_if_index);
1712 vam->result_ready = 1;
1717 static void vl_api_tap_create_v2_reply_t_handler_json
1718 (vl_api_tap_create_v2_reply_t * mp)
1720 vat_main_t *vam = &vat_main;
1721 vat_json_node_t node;
1723 vat_json_init_object (&node);
1724 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1725 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1727 vat_json_print (vam->ofp, &node);
1728 vat_json_free (&node);
1730 vam->retval = ntohl (mp->retval);
1731 vam->result_ready = 1;
1736 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1738 vat_main_t *vam = &vat_main;
1739 i32 retval = ntohl (mp->retval);
1740 if (vam->async_mode)
1742 vam->async_errors += (retval < 0);
1746 vam->retval = retval;
1747 vam->result_ready = 1;
1751 static void vl_api_tap_delete_v2_reply_t_handler_json
1752 (vl_api_tap_delete_v2_reply_t * mp)
1754 vat_main_t *vam = &vat_main;
1755 vat_json_node_t node;
1757 vat_json_init_object (&node);
1758 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1760 vat_json_print (vam->ofp, &node);
1761 vat_json_free (&node);
1763 vam->retval = ntohl (mp->retval);
1764 vam->result_ready = 1;
1768 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1771 vat_main_t *vam = &vat_main;
1772 i32 retval = ntohl (mp->retval);
1773 if (vam->async_mode)
1775 vam->async_errors += (retval < 0);
1779 vam->retval = retval;
1780 vam->sw_if_index = ntohl (mp->sw_if_index);
1781 vam->result_ready = 1;
1785 static void vl_api_virtio_pci_create_reply_t_handler_json
1786 (vl_api_virtio_pci_create_reply_t * mp)
1788 vat_main_t *vam = &vat_main;
1789 vat_json_node_t node;
1791 vat_json_init_object (&node);
1792 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1793 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1795 vat_json_print (vam->ofp, &node);
1796 vat_json_free (&node);
1798 vam->retval = ntohl (mp->retval);
1799 vam->result_ready = 1;
1804 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1807 vat_main_t *vam = &vat_main;
1808 i32 retval = ntohl (mp->retval);
1809 if (vam->async_mode)
1811 vam->async_errors += (retval < 0);
1815 vam->retval = retval;
1816 vam->result_ready = 1;
1820 static void vl_api_virtio_pci_delete_reply_t_handler_json
1821 (vl_api_virtio_pci_delete_reply_t * mp)
1823 vat_main_t *vam = &vat_main;
1824 vat_json_node_t node;
1826 vat_json_init_object (&node);
1827 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1829 vat_json_print (vam->ofp, &node);
1830 vat_json_free (&node);
1832 vam->retval = ntohl (mp->retval);
1833 vam->result_ready = 1;
1837 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1839 vat_main_t *vam = &vat_main;
1840 i32 retval = ntohl (mp->retval);
1842 if (vam->async_mode)
1844 vam->async_errors += (retval < 0);
1848 vam->retval = retval;
1849 vam->sw_if_index = ntohl (mp->sw_if_index);
1850 vam->result_ready = 1;
1854 static void vl_api_bond_create_reply_t_handler_json
1855 (vl_api_bond_create_reply_t * mp)
1857 vat_main_t *vam = &vat_main;
1858 vat_json_node_t node;
1860 vat_json_init_object (&node);
1861 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1862 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1864 vat_json_print (vam->ofp, &node);
1865 vat_json_free (&node);
1867 vam->retval = ntohl (mp->retval);
1868 vam->result_ready = 1;
1872 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1874 vat_main_t *vam = &vat_main;
1875 i32 retval = ntohl (mp->retval);
1877 if (vam->async_mode)
1879 vam->async_errors += (retval < 0);
1883 vam->retval = retval;
1884 vam->result_ready = 1;
1888 static void vl_api_bond_delete_reply_t_handler_json
1889 (vl_api_bond_delete_reply_t * mp)
1891 vat_main_t *vam = &vat_main;
1892 vat_json_node_t node;
1894 vat_json_init_object (&node);
1895 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1897 vat_json_print (vam->ofp, &node);
1898 vat_json_free (&node);
1900 vam->retval = ntohl (mp->retval);
1901 vam->result_ready = 1;
1905 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1907 vat_main_t *vam = &vat_main;
1908 i32 retval = ntohl (mp->retval);
1910 if (vam->async_mode)
1912 vam->async_errors += (retval < 0);
1916 vam->retval = retval;
1917 vam->result_ready = 1;
1921 static void vl_api_bond_enslave_reply_t_handler_json
1922 (vl_api_bond_enslave_reply_t * mp)
1924 vat_main_t *vam = &vat_main;
1925 vat_json_node_t node;
1927 vat_json_init_object (&node);
1928 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1930 vat_json_print (vam->ofp, &node);
1931 vat_json_free (&node);
1933 vam->retval = ntohl (mp->retval);
1934 vam->result_ready = 1;
1938 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1941 vat_main_t *vam = &vat_main;
1942 i32 retval = ntohl (mp->retval);
1944 if (vam->async_mode)
1946 vam->async_errors += (retval < 0);
1950 vam->retval = retval;
1951 vam->result_ready = 1;
1955 static void vl_api_bond_detach_slave_reply_t_handler_json
1956 (vl_api_bond_detach_slave_reply_t * mp)
1958 vat_main_t *vam = &vat_main;
1959 vat_json_node_t node;
1961 vat_json_init_object (&node);
1962 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1964 vat_json_print (vam->ofp, &node);
1965 vat_json_free (&node);
1967 vam->retval = ntohl (mp->retval);
1968 vam->result_ready = 1;
1972 api_sw_interface_set_bond_weight (vat_main_t * vam)
1974 unformat_input_t *i = vam->input;
1975 vl_api_sw_interface_set_bond_weight_t *mp;
1976 u32 sw_if_index = ~0;
1978 u8 weight_enter = 0;
1981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
1983 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
1985 else if (unformat (i, "sw_if_index %d", &sw_if_index))
1987 else if (unformat (i, "weight %u", &weight))
1993 if (sw_if_index == ~0)
1995 errmsg ("missing interface name or sw_if_index");
1998 if (weight_enter == 0)
2000 errmsg ("missing valid weight");
2004 /* Construct the API message */
2005 M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
2006 mp->sw_if_index = ntohl (sw_if_index);
2007 mp->weight = ntohl (weight);
2014 static void vl_api_sw_interface_bond_details_t_handler
2015 (vl_api_sw_interface_bond_details_t * mp)
2017 vat_main_t *vam = &vat_main;
2020 "%-16s %-12d %-12U %-13U %-14u %-14u",
2021 mp->interface_name, ntohl (mp->sw_if_index),
2022 format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
2023 ntohl (mp->lb), ntohl (mp->active_slaves), ntohl (mp->slaves));
2026 static void vl_api_sw_interface_bond_details_t_handler_json
2027 (vl_api_sw_interface_bond_details_t * mp)
2029 vat_main_t *vam = &vat_main;
2030 vat_json_node_t *node = NULL;
2032 if (VAT_JSON_ARRAY != vam->json_tree.type)
2034 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2035 vat_json_init_array (&vam->json_tree);
2037 node = vat_json_array_add (&vam->json_tree);
2039 vat_json_init_object (node);
2040 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2041 vat_json_object_add_string_copy (node, "interface_name",
2042 mp->interface_name);
2043 vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
2044 vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
2045 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2046 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2050 api_sw_interface_bond_dump (vat_main_t * vam)
2052 vl_api_sw_interface_bond_dump_t *mp;
2053 vl_api_control_ping_t *mp_ping;
2057 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2058 "interface name", "sw_if_index", "mode", "load balance",
2059 "active slaves", "slaves");
2061 /* Get list of bond interfaces */
2062 M (SW_INTERFACE_BOND_DUMP, mp);
2065 /* Use a control ping for synchronization */
2066 MPING (CONTROL_PING, mp_ping);
2073 static void vl_api_sw_interface_slave_details_t_handler
2074 (vl_api_sw_interface_slave_details_t * mp)
2076 vat_main_t *vam = &vat_main;
2079 "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
2080 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
2081 ntohl (mp->weight), mp->is_local_numa);
2084 static void vl_api_sw_interface_slave_details_t_handler_json
2085 (vl_api_sw_interface_slave_details_t * mp)
2087 vat_main_t *vam = &vat_main;
2088 vat_json_node_t *node = NULL;
2090 if (VAT_JSON_ARRAY != vam->json_tree.type)
2092 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2093 vat_json_init_array (&vam->json_tree);
2095 node = vat_json_array_add (&vam->json_tree);
2097 vat_json_init_object (node);
2098 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2099 vat_json_object_add_string_copy (node, "interface_name",
2100 mp->interface_name);
2101 vat_json_object_add_uint (node, "passive", mp->is_passive);
2102 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2103 vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
2104 vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
2108 api_sw_interface_slave_dump (vat_main_t * vam)
2110 unformat_input_t *i = vam->input;
2111 vl_api_sw_interface_slave_dump_t *mp;
2112 vl_api_control_ping_t *mp_ping;
2113 u32 sw_if_index = ~0;
2114 u8 sw_if_index_set = 0;
2117 /* Parse args required to build the message */
2118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2120 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2121 sw_if_index_set = 1;
2122 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2123 sw_if_index_set = 1;
2128 if (sw_if_index_set == 0)
2130 errmsg ("missing vpp interface name. ");
2135 "\n%-25s %-12s %-7s %-12s %-10s %-10s",
2136 "slave interface name", "sw_if_index", "passive", "long_timeout",
2137 "weight", "local numa");
2139 /* Get list of bond interfaces */
2140 M (SW_INTERFACE_SLAVE_DUMP, mp);
2141 mp->sw_if_index = ntohl (sw_if_index);
2144 /* Use a control ping for synchronization */
2145 MPING (CONTROL_PING, mp_ping);
2152 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2153 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2155 vat_main_t *vam = &vat_main;
2156 i32 retval = ntohl (mp->retval);
2157 if (vam->async_mode)
2159 vam->async_errors += (retval < 0);
2163 vam->retval = retval;
2164 vam->sw_if_index = ntohl (mp->sw_if_index);
2165 vam->result_ready = 1;
2167 vam->regenerate_interface_table = 1;
2170 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2171 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2173 vat_main_t *vam = &vat_main;
2174 vat_json_node_t node;
2176 vat_json_init_object (&node);
2177 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2178 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2179 ntohl (mp->sw_if_index));
2181 vat_json_print (vam->ofp, &node);
2182 vat_json_free (&node);
2184 vam->retval = ntohl (mp->retval);
2185 vam->result_ready = 1;
2188 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2189 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2191 vat_main_t *vam = &vat_main;
2192 i32 retval = ntohl (mp->retval);
2193 if (vam->async_mode)
2195 vam->async_errors += (retval < 0);
2199 vam->retval = retval;
2200 vam->sw_if_index = ntohl (mp->sw_if_index);
2201 vam->result_ready = 1;
2205 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2206 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2208 vat_main_t *vam = &vat_main;
2209 vat_json_node_t node;
2211 vat_json_init_object (&node);
2212 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2213 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2215 vat_json_print (vam->ofp, &node);
2216 vat_json_free (&node);
2218 vam->retval = ntohl (mp->retval);
2219 vam->result_ready = 1;
2222 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2223 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2225 vat_main_t *vam = &vat_main;
2226 i32 retval = ntohl (mp->retval);
2227 if (vam->async_mode)
2229 vam->async_errors += (retval < 0);
2233 vam->retval = retval;
2234 vam->result_ready = 1;
2238 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2239 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2241 vat_main_t *vam = &vat_main;
2242 vat_json_node_t node;
2244 vat_json_init_object (&node);
2245 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2246 vat_json_object_add_uint (&node, "fwd_entry_index",
2247 clib_net_to_host_u32 (mp->fwd_entry_index));
2249 vat_json_print (vam->ofp, &node);
2250 vat_json_free (&node);
2252 vam->retval = ntohl (mp->retval);
2253 vam->result_ready = 1;
2257 format_lisp_transport_protocol (u8 * s, va_list * args)
2259 u32 proto = va_arg (*args, u32);
2264 return format (s, "udp");
2266 return format (s, "api");
2273 static void vl_api_one_get_transport_protocol_reply_t_handler
2274 (vl_api_one_get_transport_protocol_reply_t * mp)
2276 vat_main_t *vam = &vat_main;
2277 i32 retval = ntohl (mp->retval);
2278 if (vam->async_mode)
2280 vam->async_errors += (retval < 0);
2284 u32 proto = mp->protocol;
2285 print (vam->ofp, "Transport protocol: %U",
2286 format_lisp_transport_protocol, proto);
2287 vam->retval = retval;
2288 vam->result_ready = 1;
2292 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2293 (vl_api_one_get_transport_protocol_reply_t * mp)
2295 vat_main_t *vam = &vat_main;
2296 vat_json_node_t node;
2299 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2302 vat_json_init_object (&node);
2303 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2304 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2307 vat_json_print (vam->ofp, &node);
2308 vat_json_free (&node);
2310 vam->retval = ntohl (mp->retval);
2311 vam->result_ready = 1;
2314 static void vl_api_one_add_del_locator_set_reply_t_handler
2315 (vl_api_one_add_del_locator_set_reply_t * mp)
2317 vat_main_t *vam = &vat_main;
2318 i32 retval = ntohl (mp->retval);
2319 if (vam->async_mode)
2321 vam->async_errors += (retval < 0);
2325 vam->retval = retval;
2326 vam->result_ready = 1;
2330 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2331 (vl_api_one_add_del_locator_set_reply_t * mp)
2333 vat_main_t *vam = &vat_main;
2334 vat_json_node_t node;
2336 vat_json_init_object (&node);
2337 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2338 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2340 vat_json_print (vam->ofp, &node);
2341 vat_json_free (&node);
2343 vam->retval = ntohl (mp->retval);
2344 vam->result_ready = 1;
2347 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2348 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2350 vat_main_t *vam = &vat_main;
2351 i32 retval = ntohl (mp->retval);
2352 if (vam->async_mode)
2354 vam->async_errors += (retval < 0);
2358 vam->retval = retval;
2359 vam->sw_if_index = ntohl (mp->sw_if_index);
2360 vam->result_ready = 1;
2362 vam->regenerate_interface_table = 1;
2365 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2366 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2368 vat_main_t *vam = &vat_main;
2369 vat_json_node_t node;
2371 vat_json_init_object (&node);
2372 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2373 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2375 vat_json_print (vam->ofp, &node);
2376 vat_json_free (&node);
2378 vam->retval = ntohl (mp->retval);
2379 vam->result_ready = 1;
2382 static void vl_api_vxlan_offload_rx_reply_t_handler
2383 (vl_api_vxlan_offload_rx_reply_t * mp)
2385 vat_main_t *vam = &vat_main;
2386 i32 retval = ntohl (mp->retval);
2387 if (vam->async_mode)
2389 vam->async_errors += (retval < 0);
2393 vam->retval = retval;
2394 vam->result_ready = 1;
2398 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2399 (vl_api_vxlan_offload_rx_reply_t * mp)
2401 vat_main_t *vam = &vat_main;
2402 vat_json_node_t node;
2404 vat_json_init_object (&node);
2405 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2407 vat_json_print (vam->ofp, &node);
2408 vat_json_free (&node);
2410 vam->retval = ntohl (mp->retval);
2411 vam->result_ready = 1;
2414 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2415 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2417 vat_main_t *vam = &vat_main;
2418 i32 retval = ntohl (mp->retval);
2419 if (vam->async_mode)
2421 vam->async_errors += (retval < 0);
2425 vam->retval = retval;
2426 vam->sw_if_index = ntohl (mp->sw_if_index);
2427 vam->result_ready = 1;
2431 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2432 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2434 vat_main_t *vam = &vat_main;
2435 vat_json_node_t node;
2437 vat_json_init_object (&node);
2438 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2439 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2441 vat_json_print (vam->ofp, &node);
2442 vat_json_free (&node);
2444 vam->retval = ntohl (mp->retval);
2445 vam->result_ready = 1;
2448 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2449 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2451 vat_main_t *vam = &vat_main;
2452 i32 retval = ntohl (mp->retval);
2453 if (vam->async_mode)
2455 vam->async_errors += (retval < 0);
2459 vam->retval = retval;
2460 vam->sw_if_index = ntohl (mp->sw_if_index);
2461 vam->result_ready = 1;
2463 vam->regenerate_interface_table = 1;
2466 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2467 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2469 vat_main_t *vam = &vat_main;
2470 vat_json_node_t node;
2472 vat_json_init_object (&node);
2473 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2474 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2476 vat_json_print (vam->ofp, &node);
2477 vat_json_free (&node);
2479 vam->retval = ntohl (mp->retval);
2480 vam->result_ready = 1;
2483 static void vl_api_gre_tunnel_add_del_reply_t_handler
2484 (vl_api_gre_tunnel_add_del_reply_t * mp)
2486 vat_main_t *vam = &vat_main;
2487 i32 retval = ntohl (mp->retval);
2488 if (vam->async_mode)
2490 vam->async_errors += (retval < 0);
2494 vam->retval = retval;
2495 vam->sw_if_index = ntohl (mp->sw_if_index);
2496 vam->result_ready = 1;
2500 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2501 (vl_api_gre_tunnel_add_del_reply_t * mp)
2503 vat_main_t *vam = &vat_main;
2504 vat_json_node_t node;
2506 vat_json_init_object (&node);
2507 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2508 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2510 vat_json_print (vam->ofp, &node);
2511 vat_json_free (&node);
2513 vam->retval = ntohl (mp->retval);
2514 vam->result_ready = 1;
2517 static void vl_api_create_vhost_user_if_reply_t_handler
2518 (vl_api_create_vhost_user_if_reply_t * mp)
2520 vat_main_t *vam = &vat_main;
2521 i32 retval = ntohl (mp->retval);
2522 if (vam->async_mode)
2524 vam->async_errors += (retval < 0);
2528 vam->retval = retval;
2529 vam->sw_if_index = ntohl (mp->sw_if_index);
2530 vam->result_ready = 1;
2532 vam->regenerate_interface_table = 1;
2535 static void vl_api_create_vhost_user_if_reply_t_handler_json
2536 (vl_api_create_vhost_user_if_reply_t * mp)
2538 vat_main_t *vam = &vat_main;
2539 vat_json_node_t node;
2541 vat_json_init_object (&node);
2542 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2543 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2545 vat_json_print (vam->ofp, &node);
2546 vat_json_free (&node);
2548 vam->retval = ntohl (mp->retval);
2549 vam->result_ready = 1;
2552 static void vl_api_ip_address_details_t_handler
2553 (vl_api_ip_address_details_t * mp)
2555 vat_main_t *vam = &vat_main;
2556 static ip_address_details_t empty_ip_address_details = { {0} };
2557 ip_address_details_t *address = NULL;
2558 ip_details_t *current_ip_details = NULL;
2559 ip_details_t *details = NULL;
2561 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2563 if (!details || vam->current_sw_if_index >= vec_len (details)
2564 || !details[vam->current_sw_if_index].present)
2566 errmsg ("ip address details arrived but not stored");
2567 errmsg ("ip_dump should be called first");
2571 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2573 #define addresses (current_ip_details->addr)
2575 vec_validate_init_empty (addresses, vec_len (addresses),
2576 empty_ip_address_details);
2578 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2580 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2581 address->prefix_length = mp->prefix.len;
2585 static void vl_api_ip_address_details_t_handler_json
2586 (vl_api_ip_address_details_t * mp)
2588 vat_main_t *vam = &vat_main;
2589 vat_json_node_t *node = NULL;
2591 if (VAT_JSON_ARRAY != vam->json_tree.type)
2593 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2594 vat_json_init_array (&vam->json_tree);
2596 node = vat_json_array_add (&vam->json_tree);
2598 vat_json_init_object (node);
2599 vat_json_object_add_prefix (node, &mp->prefix);
2603 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2605 vat_main_t *vam = &vat_main;
2606 static ip_details_t empty_ip_details = { 0 };
2607 ip_details_t *ip = NULL;
2608 u32 sw_if_index = ~0;
2610 sw_if_index = ntohl (mp->sw_if_index);
2612 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2613 sw_if_index, empty_ip_details);
2615 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2622 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2624 vat_main_t *vam = &vat_main;
2626 if (VAT_JSON_ARRAY != vam->json_tree.type)
2628 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2629 vat_json_init_array (&vam->json_tree);
2631 vat_json_array_add_uint (&vam->json_tree,
2632 clib_net_to_host_u32 (mp->sw_if_index));
2635 static void vl_api_get_first_msg_id_reply_t_handler
2636 (vl_api_get_first_msg_id_reply_t * mp)
2638 vat_main_t *vam = &vat_main;
2639 i32 retval = ntohl (mp->retval);
2641 if (vam->async_mode)
2643 vam->async_errors += (retval < 0);
2647 vam->retval = retval;
2648 vam->result_ready = 1;
2652 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2656 static void vl_api_get_first_msg_id_reply_t_handler_json
2657 (vl_api_get_first_msg_id_reply_t * mp)
2659 vat_main_t *vam = &vat_main;
2660 vat_json_node_t node;
2662 vat_json_init_object (&node);
2663 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2664 vat_json_object_add_uint (&node, "first_msg_id",
2665 (uint) ntohs (mp->first_msg_id));
2667 vat_json_print (vam->ofp, &node);
2668 vat_json_free (&node);
2670 vam->retval = ntohl (mp->retval);
2671 vam->result_ready = 1;
2674 static void vl_api_get_node_graph_reply_t_handler
2675 (vl_api_get_node_graph_reply_t * mp)
2677 vat_main_t *vam = &vat_main;
2678 i32 retval = ntohl (mp->retval);
2679 u8 *pvt_copy, *reply;
2684 if (vam->async_mode)
2686 vam->async_errors += (retval < 0);
2690 vam->retval = retval;
2691 vam->result_ready = 1;
2694 /* "Should never happen..." */
2698 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2699 pvt_copy = vec_dup (reply);
2701 /* Toss the shared-memory original... */
2702 oldheap = vl_msg_push_heap ();
2706 vl_msg_pop_heap (oldheap);
2708 if (vam->graph_nodes)
2710 hash_free (vam->graph_node_index_by_name);
2712 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2714 node = vam->graph_nodes[0][i];
2715 vec_free (node->name);
2716 vec_free (node->next_nodes);
2719 vec_free (vam->graph_nodes[0]);
2720 vec_free (vam->graph_nodes);
2723 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2724 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2725 vec_free (pvt_copy);
2727 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2729 node = vam->graph_nodes[0][i];
2730 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2734 static void vl_api_get_node_graph_reply_t_handler_json
2735 (vl_api_get_node_graph_reply_t * mp)
2737 vat_main_t *vam = &vat_main;
2739 vat_json_node_t node;
2742 /* $$$$ make this real? */
2743 vat_json_init_object (&node);
2744 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2745 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2747 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2749 /* Toss the shared-memory original... */
2750 oldheap = vl_msg_push_heap ();
2754 vl_msg_pop_heap (oldheap);
2756 vat_json_print (vam->ofp, &node);
2757 vat_json_free (&node);
2759 vam->retval = ntohl (mp->retval);
2760 vam->result_ready = 1;
2764 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2766 vat_main_t *vam = &vat_main;
2771 s = format (s, "%=16d%=16d%=16d",
2772 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2776 s = format (s, "%=16U%=16d%=16d",
2777 mp->is_ipv6 ? format_ip6_address :
2779 mp->ip_address, mp->priority, mp->weight);
2782 print (vam->ofp, "%v", s);
2787 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2789 vat_main_t *vam = &vat_main;
2790 vat_json_node_t *node = NULL;
2791 struct in6_addr ip6;
2794 if (VAT_JSON_ARRAY != vam->json_tree.type)
2796 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2797 vat_json_init_array (&vam->json_tree);
2799 node = vat_json_array_add (&vam->json_tree);
2800 vat_json_init_object (node);
2802 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2803 vat_json_object_add_uint (node, "priority", mp->priority);
2804 vat_json_object_add_uint (node, "weight", mp->weight);
2807 vat_json_object_add_uint (node, "sw_if_index",
2808 clib_net_to_host_u32 (mp->sw_if_index));
2813 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2814 vat_json_object_add_ip6 (node, "address", ip6);
2818 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2819 vat_json_object_add_ip4 (node, "address", ip4);
2825 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2828 vat_main_t *vam = &vat_main;
2831 ls_name = format (0, "%s", mp->ls_name);
2833 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2839 vl_api_one_locator_set_details_t_handler_json
2840 (vl_api_one_locator_set_details_t * mp)
2842 vat_main_t *vam = &vat_main;
2843 vat_json_node_t *node = 0;
2846 ls_name = format (0, "%s", mp->ls_name);
2847 vec_add1 (ls_name, 0);
2849 if (VAT_JSON_ARRAY != vam->json_tree.type)
2851 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2852 vat_json_init_array (&vam->json_tree);
2854 node = vat_json_array_add (&vam->json_tree);
2856 vat_json_init_object (node);
2857 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2858 vat_json_object_add_uint (node, "ls_index",
2859 clib_net_to_host_u32 (mp->ls_index));
2867 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2870 unformat_nsh_address (unformat_input_t * input, va_list * args)
2872 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2873 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2877 format_nsh_address_vat (u8 * s, va_list * args)
2879 nsh_t *a = va_arg (*args, nsh_t *);
2880 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2884 format_lisp_flat_eid (u8 * s, va_list * args)
2886 u32 type = va_arg (*args, u32);
2887 u8 *eid = va_arg (*args, u8 *);
2888 u32 eid_len = va_arg (*args, u32);
2893 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2895 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2897 return format (s, "%U", format_ethernet_address, eid);
2899 return format (s, "%U", format_nsh_address_vat, eid);
2905 format_lisp_eid_vat (u8 * s, va_list * args)
2907 u32 type = va_arg (*args, u32);
2908 u8 *eid = va_arg (*args, u8 *);
2909 u32 eid_len = va_arg (*args, u32);
2910 u8 *seid = va_arg (*args, u8 *);
2911 u32 seid_len = va_arg (*args, u32);
2912 u32 is_src_dst = va_arg (*args, u32);
2915 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2917 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2923 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2925 vat_main_t *vam = &vat_main;
2926 u8 *s = 0, *eid = 0;
2928 if (~0 == mp->locator_set_index)
2929 s = format (0, "action: %d", mp->action);
2931 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2933 eid = format (0, "%U", format_lisp_eid_vat,
2937 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2940 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2941 clib_net_to_host_u32 (mp->vni),
2943 mp->is_local ? "local" : "remote",
2944 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2945 clib_net_to_host_u16 (mp->key_id), mp->key);
2952 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2955 vat_main_t *vam = &vat_main;
2956 vat_json_node_t *node = 0;
2959 if (VAT_JSON_ARRAY != vam->json_tree.type)
2961 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2962 vat_json_init_array (&vam->json_tree);
2964 node = vat_json_array_add (&vam->json_tree);
2966 vat_json_init_object (node);
2967 if (~0 == mp->locator_set_index)
2968 vat_json_object_add_uint (node, "action", mp->action);
2970 vat_json_object_add_uint (node, "locator_set_index",
2971 clib_net_to_host_u32 (mp->locator_set_index));
2973 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2974 if (mp->eid_type == 3)
2976 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
2977 vat_json_init_object (nsh_json);
2978 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
2979 vat_json_object_add_uint (nsh_json, "spi",
2980 clib_net_to_host_u32 (nsh->spi));
2981 vat_json_object_add_uint (nsh_json, "si", nsh->si);
2985 eid = format (0, "%U", format_lisp_eid_vat,
2989 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2991 vat_json_object_add_string_copy (node, "eid", eid);
2994 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2995 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2996 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3000 vat_json_object_add_uint (node, "key_id",
3001 clib_net_to_host_u16 (mp->key_id));
3002 vat_json_object_add_string_copy (node, "key", mp->key);
3007 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3009 vat_main_t *vam = &vat_main;
3010 u8 *seid = 0, *deid = 0;
3011 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3013 deid = format (0, "%U", format_lisp_eid_vat,
3014 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3016 seid = format (0, "%U", format_lisp_eid_vat,
3017 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3023 format_ip_address_fcn = format_ip4_address;
3025 format_ip_address_fcn = format_ip6_address;
3028 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3029 clib_net_to_host_u32 (mp->vni),
3031 format_ip_address_fcn, mp->lloc,
3032 format_ip_address_fcn, mp->rloc,
3033 clib_net_to_host_u32 (mp->pkt_count),
3034 clib_net_to_host_u32 (mp->bytes));
3041 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3043 struct in6_addr ip6;
3045 vat_main_t *vam = &vat_main;
3046 vat_json_node_t *node = 0;
3047 u8 *deid = 0, *seid = 0;
3049 if (VAT_JSON_ARRAY != vam->json_tree.type)
3051 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3052 vat_json_init_array (&vam->json_tree);
3054 node = vat_json_array_add (&vam->json_tree);
3056 vat_json_init_object (node);
3057 deid = format (0, "%U", format_lisp_eid_vat,
3058 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3060 seid = format (0, "%U", format_lisp_eid_vat,
3061 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3066 vat_json_object_add_string_copy (node, "seid", seid);
3067 vat_json_object_add_string_copy (node, "deid", deid);
3068 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3072 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3073 vat_json_object_add_ip4 (node, "lloc", ip4);
3074 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3075 vat_json_object_add_ip4 (node, "rloc", ip4);
3079 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3080 vat_json_object_add_ip6 (node, "lloc", ip6);
3081 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3082 vat_json_object_add_ip6 (node, "rloc", ip6);
3084 vat_json_object_add_uint (node, "pkt_count",
3085 clib_net_to_host_u32 (mp->pkt_count));
3086 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3093 vl_api_one_eid_table_map_details_t_handler
3094 (vl_api_one_eid_table_map_details_t * mp)
3096 vat_main_t *vam = &vat_main;
3098 u8 *line = format (0, "%=10d%=10d",
3099 clib_net_to_host_u32 (mp->vni),
3100 clib_net_to_host_u32 (mp->dp_table));
3101 print (vam->ofp, "%v", line);
3106 vl_api_one_eid_table_map_details_t_handler_json
3107 (vl_api_one_eid_table_map_details_t * mp)
3109 vat_main_t *vam = &vat_main;
3110 vat_json_node_t *node = NULL;
3112 if (VAT_JSON_ARRAY != vam->json_tree.type)
3114 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3115 vat_json_init_array (&vam->json_tree);
3117 node = vat_json_array_add (&vam->json_tree);
3118 vat_json_init_object (node);
3119 vat_json_object_add_uint (node, "dp_table",
3120 clib_net_to_host_u32 (mp->dp_table));
3121 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3125 vl_api_one_eid_table_vni_details_t_handler
3126 (vl_api_one_eid_table_vni_details_t * mp)
3128 vat_main_t *vam = &vat_main;
3130 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3131 print (vam->ofp, "%v", line);
3136 vl_api_one_eid_table_vni_details_t_handler_json
3137 (vl_api_one_eid_table_vni_details_t * mp)
3139 vat_main_t *vam = &vat_main;
3140 vat_json_node_t *node = NULL;
3142 if (VAT_JSON_ARRAY != vam->json_tree.type)
3144 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3145 vat_json_init_array (&vam->json_tree);
3147 node = vat_json_array_add (&vam->json_tree);
3148 vat_json_init_object (node);
3149 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3153 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3154 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3156 vat_main_t *vam = &vat_main;
3157 int retval = clib_net_to_host_u32 (mp->retval);
3159 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3160 print (vam->ofp, "fallback threshold value: %d", mp->value);
3162 vam->retval = retval;
3163 vam->result_ready = 1;
3167 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3168 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3170 vat_main_t *vam = &vat_main;
3171 vat_json_node_t _node, *node = &_node;
3172 int retval = clib_net_to_host_u32 (mp->retval);
3174 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3175 vat_json_init_object (node);
3176 vat_json_object_add_uint (node, "value", mp->value);
3178 vat_json_print (vam->ofp, node);
3179 vat_json_free (node);
3181 vam->retval = retval;
3182 vam->result_ready = 1;
3186 vl_api_show_one_map_register_state_reply_t_handler
3187 (vl_api_show_one_map_register_state_reply_t * mp)
3189 vat_main_t *vam = &vat_main;
3190 int retval = clib_net_to_host_u32 (mp->retval);
3192 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3194 vam->retval = retval;
3195 vam->result_ready = 1;
3199 vl_api_show_one_map_register_state_reply_t_handler_json
3200 (vl_api_show_one_map_register_state_reply_t * mp)
3202 vat_main_t *vam = &vat_main;
3203 vat_json_node_t _node, *node = &_node;
3204 int retval = clib_net_to_host_u32 (mp->retval);
3206 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3208 vat_json_init_object (node);
3209 vat_json_object_add_string_copy (node, "state", s);
3211 vat_json_print (vam->ofp, node);
3212 vat_json_free (node);
3214 vam->retval = retval;
3215 vam->result_ready = 1;
3220 vl_api_show_one_rloc_probe_state_reply_t_handler
3221 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3223 vat_main_t *vam = &vat_main;
3224 int retval = clib_net_to_host_u32 (mp->retval);
3229 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3231 vam->retval = retval;
3232 vam->result_ready = 1;
3236 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3237 (vl_api_show_one_rloc_probe_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_enabled ? "enabled" : "disabled");
3244 vat_json_init_object (node);
3245 vat_json_object_add_string_copy (node, "state", s);
3247 vat_json_print (vam->ofp, node);
3248 vat_json_free (node);
3250 vam->retval = retval;
3251 vam->result_ready = 1;
3256 vl_api_show_one_stats_enable_disable_reply_t_handler
3257 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3259 vat_main_t *vam = &vat_main;
3260 int retval = clib_net_to_host_u32 (mp->retval);
3265 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3267 vam->retval = retval;
3268 vam->result_ready = 1;
3272 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3273 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3275 vat_main_t *vam = &vat_main;
3276 vat_json_node_t _node, *node = &_node;
3277 int retval = clib_net_to_host_u32 (mp->retval);
3279 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3280 vat_json_init_object (node);
3281 vat_json_object_add_string_copy (node, "state", s);
3283 vat_json_print (vam->ofp, node);
3284 vat_json_free (node);
3286 vam->retval = retval;
3287 vam->result_ready = 1;
3292 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3294 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3295 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3296 e->vni = clib_net_to_host_u32 (e->vni);
3300 gpe_fwd_entries_get_reply_t_net_to_host
3301 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3305 mp->count = clib_net_to_host_u32 (mp->count);
3306 for (i = 0; i < mp->count; i++)
3308 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3313 format_gpe_encap_mode (u8 * s, va_list * args)
3315 u32 mode = va_arg (*args, u32);
3320 return format (s, "lisp");
3322 return format (s, "vxlan");
3328 vl_api_gpe_get_encap_mode_reply_t_handler
3329 (vl_api_gpe_get_encap_mode_reply_t * mp)
3331 vat_main_t *vam = &vat_main;
3333 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3334 vam->retval = ntohl (mp->retval);
3335 vam->result_ready = 1;
3339 vl_api_gpe_get_encap_mode_reply_t_handler_json
3340 (vl_api_gpe_get_encap_mode_reply_t * mp)
3342 vat_main_t *vam = &vat_main;
3343 vat_json_node_t node;
3345 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3346 vec_add1 (encap_mode, 0);
3348 vat_json_init_object (&node);
3349 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3351 vec_free (encap_mode);
3352 vat_json_print (vam->ofp, &node);
3353 vat_json_free (&node);
3355 vam->retval = ntohl (mp->retval);
3356 vam->result_ready = 1;
3360 vl_api_gpe_fwd_entry_path_details_t_handler
3361 (vl_api_gpe_fwd_entry_path_details_t * mp)
3363 vat_main_t *vam = &vat_main;
3364 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3366 if (mp->lcl_loc.is_ip4)
3367 format_ip_address_fcn = format_ip4_address;
3369 format_ip_address_fcn = format_ip6_address;
3371 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3372 format_ip_address_fcn, &mp->lcl_loc,
3373 format_ip_address_fcn, &mp->rmt_loc);
3377 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3379 struct in6_addr ip6;
3384 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3385 vat_json_object_add_ip4 (n, "address", ip4);
3389 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3390 vat_json_object_add_ip6 (n, "address", ip6);
3392 vat_json_object_add_uint (n, "weight", loc->weight);
3396 vl_api_gpe_fwd_entry_path_details_t_handler_json
3397 (vl_api_gpe_fwd_entry_path_details_t * mp)
3399 vat_main_t *vam = &vat_main;
3400 vat_json_node_t *node = NULL;
3401 vat_json_node_t *loc_node;
3403 if (VAT_JSON_ARRAY != vam->json_tree.type)
3405 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3406 vat_json_init_array (&vam->json_tree);
3408 node = vat_json_array_add (&vam->json_tree);
3409 vat_json_init_object (node);
3411 loc_node = vat_json_object_add (node, "local_locator");
3412 vat_json_init_object (loc_node);
3413 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3415 loc_node = vat_json_object_add (node, "remote_locator");
3416 vat_json_init_object (loc_node);
3417 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3421 vl_api_gpe_fwd_entries_get_reply_t_handler
3422 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3424 vat_main_t *vam = &vat_main;
3426 int retval = clib_net_to_host_u32 (mp->retval);
3427 vl_api_gpe_fwd_entry_t *e;
3432 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3434 for (i = 0; i < mp->count; i++)
3436 e = &mp->entries[i];
3437 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3438 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3439 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3443 vam->retval = retval;
3444 vam->result_ready = 1;
3448 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3449 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3452 vat_main_t *vam = &vat_main;
3453 vat_json_node_t *e = 0, root;
3455 int retval = clib_net_to_host_u32 (mp->retval);
3456 vl_api_gpe_fwd_entry_t *fwd;
3461 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3462 vat_json_init_array (&root);
3464 for (i = 0; i < mp->count; i++)
3466 e = vat_json_array_add (&root);
3467 fwd = &mp->entries[i];
3469 vat_json_init_object (e);
3470 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3471 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3472 vat_json_object_add_int (e, "vni", fwd->vni);
3473 vat_json_object_add_int (e, "action", fwd->action);
3475 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3476 fwd->leid_prefix_len);
3478 vat_json_object_add_string_copy (e, "leid", s);
3481 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3482 fwd->reid_prefix_len);
3484 vat_json_object_add_string_copy (e, "reid", s);
3488 vat_json_print (vam->ofp, &root);
3489 vat_json_free (&root);
3492 vam->retval = retval;
3493 vam->result_ready = 1;
3497 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3498 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3500 vat_main_t *vam = &vat_main;
3502 int retval = clib_net_to_host_u32 (mp->retval);
3503 vl_api_gpe_native_fwd_rpath_t *r;
3508 n = clib_net_to_host_u32 (mp->count);
3510 for (i = 0; i < n; i++)
3512 r = &mp->entries[i];
3513 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3514 clib_net_to_host_u32 (r->fib_index),
3515 clib_net_to_host_u32 (r->nh_sw_if_index),
3516 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3520 vam->retval = retval;
3521 vam->result_ready = 1;
3525 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3526 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3528 vat_main_t *vam = &vat_main;
3529 vat_json_node_t root, *e;
3531 int retval = clib_net_to_host_u32 (mp->retval);
3532 vl_api_gpe_native_fwd_rpath_t *r;
3538 n = clib_net_to_host_u32 (mp->count);
3539 vat_json_init_array (&root);
3541 for (i = 0; i < n; i++)
3543 e = vat_json_array_add (&root);
3544 vat_json_init_object (e);
3545 r = &mp->entries[i];
3547 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3550 vat_json_object_add_string_copy (e, "ip4", s);
3553 vat_json_object_add_uint (e, "fib_index",
3554 clib_net_to_host_u32 (r->fib_index));
3555 vat_json_object_add_uint (e, "nh_sw_if_index",
3556 clib_net_to_host_u32 (r->nh_sw_if_index));
3559 vat_json_print (vam->ofp, &root);
3560 vat_json_free (&root);
3563 vam->retval = retval;
3564 vam->result_ready = 1;
3568 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3569 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3571 vat_main_t *vam = &vat_main;
3573 int retval = clib_net_to_host_u32 (mp->retval);
3578 n = clib_net_to_host_u32 (mp->count);
3580 for (i = 0; i < n; i++)
3581 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3584 vam->retval = retval;
3585 vam->result_ready = 1;
3589 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3590 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3592 vat_main_t *vam = &vat_main;
3593 vat_json_node_t root;
3595 int retval = clib_net_to_host_u32 (mp->retval);
3600 n = clib_net_to_host_u32 (mp->count);
3601 vat_json_init_array (&root);
3603 for (i = 0; i < n; i++)
3604 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3606 vat_json_print (vam->ofp, &root);
3607 vat_json_free (&root);
3610 vam->retval = retval;
3611 vam->result_ready = 1;
3615 vl_api_one_ndp_entries_get_reply_t_handler
3616 (vl_api_one_ndp_entries_get_reply_t * mp)
3618 vat_main_t *vam = &vat_main;
3620 int retval = clib_net_to_host_u32 (mp->retval);
3625 n = clib_net_to_host_u32 (mp->count);
3627 for (i = 0; i < n; i++)
3628 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3629 format_ethernet_address, mp->entries[i].mac);
3632 vam->retval = retval;
3633 vam->result_ready = 1;
3637 vl_api_one_ndp_entries_get_reply_t_handler_json
3638 (vl_api_one_ndp_entries_get_reply_t * mp)
3641 vat_main_t *vam = &vat_main;
3642 vat_json_node_t *e = 0, root;
3644 int retval = clib_net_to_host_u32 (mp->retval);
3645 vl_api_one_ndp_entry_t *arp_entry;
3650 n = clib_net_to_host_u32 (mp->count);
3651 vat_json_init_array (&root);
3653 for (i = 0; i < n; i++)
3655 e = vat_json_array_add (&root);
3656 arp_entry = &mp->entries[i];
3658 vat_json_init_object (e);
3659 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3662 vat_json_object_add_string_copy (e, "mac", s);
3665 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3667 vat_json_object_add_string_copy (e, "ip6", s);
3671 vat_json_print (vam->ofp, &root);
3672 vat_json_free (&root);
3675 vam->retval = retval;
3676 vam->result_ready = 1;
3680 vl_api_one_l2_arp_entries_get_reply_t_handler
3681 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3683 vat_main_t *vam = &vat_main;
3685 int retval = clib_net_to_host_u32 (mp->retval);
3690 n = clib_net_to_host_u32 (mp->count);
3692 for (i = 0; i < n; i++)
3693 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3694 format_ethernet_address, mp->entries[i].mac);
3697 vam->retval = retval;
3698 vam->result_ready = 1;
3702 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3703 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3706 vat_main_t *vam = &vat_main;
3707 vat_json_node_t *e = 0, root;
3709 int retval = clib_net_to_host_u32 (mp->retval);
3710 vl_api_one_l2_arp_entry_t *arp_entry;
3715 n = clib_net_to_host_u32 (mp->count);
3716 vat_json_init_array (&root);
3718 for (i = 0; i < n; i++)
3720 e = vat_json_array_add (&root);
3721 arp_entry = &mp->entries[i];
3723 vat_json_init_object (e);
3724 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3727 vat_json_object_add_string_copy (e, "mac", s);
3730 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3732 vat_json_object_add_string_copy (e, "ip4", s);
3736 vat_json_print (vam->ofp, &root);
3737 vat_json_free (&root);
3740 vam->retval = retval;
3741 vam->result_ready = 1;
3745 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3747 vat_main_t *vam = &vat_main;
3749 int retval = clib_net_to_host_u32 (mp->retval);
3754 n = clib_net_to_host_u32 (mp->count);
3756 for (i = 0; i < n; i++)
3758 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3762 vam->retval = retval;
3763 vam->result_ready = 1;
3767 vl_api_one_ndp_bd_get_reply_t_handler_json
3768 (vl_api_one_ndp_bd_get_reply_t * mp)
3770 vat_main_t *vam = &vat_main;
3771 vat_json_node_t root;
3773 int retval = clib_net_to_host_u32 (mp->retval);
3778 n = clib_net_to_host_u32 (mp->count);
3779 vat_json_init_array (&root);
3781 for (i = 0; i < n; i++)
3783 vat_json_array_add_uint (&root,
3784 clib_net_to_host_u32 (mp->bridge_domains[i]));
3787 vat_json_print (vam->ofp, &root);
3788 vat_json_free (&root);
3791 vam->retval = retval;
3792 vam->result_ready = 1;
3796 vl_api_one_l2_arp_bd_get_reply_t_handler
3797 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3799 vat_main_t *vam = &vat_main;
3801 int retval = clib_net_to_host_u32 (mp->retval);
3806 n = clib_net_to_host_u32 (mp->count);
3808 for (i = 0; i < n; i++)
3810 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3814 vam->retval = retval;
3815 vam->result_ready = 1;
3819 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3820 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3822 vat_main_t *vam = &vat_main;
3823 vat_json_node_t root;
3825 int retval = clib_net_to_host_u32 (mp->retval);
3830 n = clib_net_to_host_u32 (mp->count);
3831 vat_json_init_array (&root);
3833 for (i = 0; i < n; i++)
3835 vat_json_array_add_uint (&root,
3836 clib_net_to_host_u32 (mp->bridge_domains[i]));
3839 vat_json_print (vam->ofp, &root);
3840 vat_json_free (&root);
3843 vam->retval = retval;
3844 vam->result_ready = 1;
3848 vl_api_one_adjacencies_get_reply_t_handler
3849 (vl_api_one_adjacencies_get_reply_t * mp)
3851 vat_main_t *vam = &vat_main;
3853 int retval = clib_net_to_host_u32 (mp->retval);
3854 vl_api_one_adjacency_t *a;
3859 n = clib_net_to_host_u32 (mp->count);
3861 for (i = 0; i < n; i++)
3863 a = &mp->adjacencies[i];
3864 print (vam->ofp, "%U %40U",
3865 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3866 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3870 vam->retval = retval;
3871 vam->result_ready = 1;
3875 vl_api_one_adjacencies_get_reply_t_handler_json
3876 (vl_api_one_adjacencies_get_reply_t * mp)
3879 vat_main_t *vam = &vat_main;
3880 vat_json_node_t *e = 0, root;
3882 int retval = clib_net_to_host_u32 (mp->retval);
3883 vl_api_one_adjacency_t *a;
3888 n = clib_net_to_host_u32 (mp->count);
3889 vat_json_init_array (&root);
3891 for (i = 0; i < n; i++)
3893 e = vat_json_array_add (&root);
3894 a = &mp->adjacencies[i];
3896 vat_json_init_object (e);
3897 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3898 a->leid_prefix_len);
3900 vat_json_object_add_string_copy (e, "leid", s);
3903 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3904 a->reid_prefix_len);
3906 vat_json_object_add_string_copy (e, "reid", s);
3910 vat_json_print (vam->ofp, &root);
3911 vat_json_free (&root);
3914 vam->retval = retval;
3915 vam->result_ready = 1;
3919 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3921 vat_main_t *vam = &vat_main;
3923 print (vam->ofp, "%=20U",
3924 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3929 vl_api_one_map_server_details_t_handler_json
3930 (vl_api_one_map_server_details_t * mp)
3932 vat_main_t *vam = &vat_main;
3933 vat_json_node_t *node = NULL;
3934 struct in6_addr ip6;
3937 if (VAT_JSON_ARRAY != vam->json_tree.type)
3939 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3940 vat_json_init_array (&vam->json_tree);
3942 node = vat_json_array_add (&vam->json_tree);
3944 vat_json_init_object (node);
3947 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3948 vat_json_object_add_ip6 (node, "map-server", ip6);
3952 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3953 vat_json_object_add_ip4 (node, "map-server", ip4);
3958 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3961 vat_main_t *vam = &vat_main;
3963 print (vam->ofp, "%=20U",
3964 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3969 vl_api_one_map_resolver_details_t_handler_json
3970 (vl_api_one_map_resolver_details_t * mp)
3972 vat_main_t *vam = &vat_main;
3973 vat_json_node_t *node = NULL;
3974 struct in6_addr ip6;
3977 if (VAT_JSON_ARRAY != vam->json_tree.type)
3979 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3980 vat_json_init_array (&vam->json_tree);
3982 node = vat_json_array_add (&vam->json_tree);
3984 vat_json_init_object (node);
3987 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3988 vat_json_object_add_ip6 (node, "map resolver", ip6);
3992 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3993 vat_json_object_add_ip4 (node, "map resolver", ip4);
3998 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4000 vat_main_t *vam = &vat_main;
4001 i32 retval = ntohl (mp->retval);
4005 print (vam->ofp, "feature: %s\ngpe: %s",
4006 mp->feature_status ? "enabled" : "disabled",
4007 mp->gpe_status ? "enabled" : "disabled");
4010 vam->retval = retval;
4011 vam->result_ready = 1;
4015 vl_api_show_one_status_reply_t_handler_json
4016 (vl_api_show_one_status_reply_t * mp)
4018 vat_main_t *vam = &vat_main;
4019 vat_json_node_t node;
4020 u8 *gpe_status = NULL;
4021 u8 *feature_status = NULL;
4023 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4024 feature_status = format (0, "%s",
4025 mp->feature_status ? "enabled" : "disabled");
4026 vec_add1 (gpe_status, 0);
4027 vec_add1 (feature_status, 0);
4029 vat_json_init_object (&node);
4030 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4031 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4033 vec_free (gpe_status);
4034 vec_free (feature_status);
4036 vat_json_print (vam->ofp, &node);
4037 vat_json_free (&node);
4039 vam->retval = ntohl (mp->retval);
4040 vam->result_ready = 1;
4044 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4045 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4047 vat_main_t *vam = &vat_main;
4048 i32 retval = ntohl (mp->retval);
4052 print (vam->ofp, "%=20s", mp->locator_set_name);
4055 vam->retval = retval;
4056 vam->result_ready = 1;
4060 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4061 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4063 vat_main_t *vam = &vat_main;
4064 vat_json_node_t *node = NULL;
4066 if (VAT_JSON_ARRAY != vam->json_tree.type)
4068 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4069 vat_json_init_array (&vam->json_tree);
4071 node = vat_json_array_add (&vam->json_tree);
4073 vat_json_init_object (node);
4074 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4076 vat_json_print (vam->ofp, node);
4077 vat_json_free (node);
4079 vam->retval = ntohl (mp->retval);
4080 vam->result_ready = 1;
4084 format_lisp_map_request_mode (u8 * s, va_list * args)
4086 u32 mode = va_arg (*args, u32);
4091 return format (0, "dst-only");
4093 return format (0, "src-dst");
4099 vl_api_show_one_map_request_mode_reply_t_handler
4100 (vl_api_show_one_map_request_mode_reply_t * mp)
4102 vat_main_t *vam = &vat_main;
4103 i32 retval = ntohl (mp->retval);
4107 u32 mode = mp->mode;
4108 print (vam->ofp, "map_request_mode: %U",
4109 format_lisp_map_request_mode, mode);
4112 vam->retval = retval;
4113 vam->result_ready = 1;
4117 vl_api_show_one_map_request_mode_reply_t_handler_json
4118 (vl_api_show_one_map_request_mode_reply_t * mp)
4120 vat_main_t *vam = &vat_main;
4121 vat_json_node_t node;
4126 s = format (0, "%U", format_lisp_map_request_mode, mode);
4129 vat_json_init_object (&node);
4130 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4131 vat_json_print (vam->ofp, &node);
4132 vat_json_free (&node);
4135 vam->retval = ntohl (mp->retval);
4136 vam->result_ready = 1;
4140 vl_api_one_show_xtr_mode_reply_t_handler
4141 (vl_api_one_show_xtr_mode_reply_t * mp)
4143 vat_main_t *vam = &vat_main;
4144 i32 retval = ntohl (mp->retval);
4148 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4151 vam->retval = retval;
4152 vam->result_ready = 1;
4156 vl_api_one_show_xtr_mode_reply_t_handler_json
4157 (vl_api_one_show_xtr_mode_reply_t * mp)
4159 vat_main_t *vam = &vat_main;
4160 vat_json_node_t node;
4163 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4164 vec_add1 (status, 0);
4166 vat_json_init_object (&node);
4167 vat_json_object_add_string_copy (&node, "status", status);
4171 vat_json_print (vam->ofp, &node);
4172 vat_json_free (&node);
4174 vam->retval = ntohl (mp->retval);
4175 vam->result_ready = 1;
4179 vl_api_one_show_pitr_mode_reply_t_handler
4180 (vl_api_one_show_pitr_mode_reply_t * mp)
4182 vat_main_t *vam = &vat_main;
4183 i32 retval = ntohl (mp->retval);
4187 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4190 vam->retval = retval;
4191 vam->result_ready = 1;
4195 vl_api_one_show_pitr_mode_reply_t_handler_json
4196 (vl_api_one_show_pitr_mode_reply_t * mp)
4198 vat_main_t *vam = &vat_main;
4199 vat_json_node_t node;
4202 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4203 vec_add1 (status, 0);
4205 vat_json_init_object (&node);
4206 vat_json_object_add_string_copy (&node, "status", status);
4210 vat_json_print (vam->ofp, &node);
4211 vat_json_free (&node);
4213 vam->retval = ntohl (mp->retval);
4214 vam->result_ready = 1;
4218 vl_api_one_show_petr_mode_reply_t_handler
4219 (vl_api_one_show_petr_mode_reply_t * mp)
4221 vat_main_t *vam = &vat_main;
4222 i32 retval = ntohl (mp->retval);
4226 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4229 vam->retval = retval;
4230 vam->result_ready = 1;
4234 vl_api_one_show_petr_mode_reply_t_handler_json
4235 (vl_api_one_show_petr_mode_reply_t * mp)
4237 vat_main_t *vam = &vat_main;
4238 vat_json_node_t node;
4241 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4242 vec_add1 (status, 0);
4244 vat_json_init_object (&node);
4245 vat_json_object_add_string_copy (&node, "status", status);
4249 vat_json_print (vam->ofp, &node);
4250 vat_json_free (&node);
4252 vam->retval = ntohl (mp->retval);
4253 vam->result_ready = 1;
4257 vl_api_show_one_use_petr_reply_t_handler
4258 (vl_api_show_one_use_petr_reply_t * mp)
4260 vat_main_t *vam = &vat_main;
4261 i32 retval = ntohl (mp->retval);
4265 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4268 print (vam->ofp, "Proxy-ETR address; %U",
4269 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4274 vam->retval = retval;
4275 vam->result_ready = 1;
4279 vl_api_show_one_use_petr_reply_t_handler_json
4280 (vl_api_show_one_use_petr_reply_t * mp)
4282 vat_main_t *vam = &vat_main;
4283 vat_json_node_t node;
4286 struct in6_addr ip6;
4288 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4289 vec_add1 (status, 0);
4291 vat_json_init_object (&node);
4292 vat_json_object_add_string_copy (&node, "status", status);
4297 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4298 vat_json_object_add_ip6 (&node, "address", ip6);
4302 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4303 vat_json_object_add_ip4 (&node, "address", ip4);
4309 vat_json_print (vam->ofp, &node);
4310 vat_json_free (&node);
4312 vam->retval = ntohl (mp->retval);
4313 vam->result_ready = 1;
4317 vl_api_show_one_nsh_mapping_reply_t_handler
4318 (vl_api_show_one_nsh_mapping_reply_t * mp)
4320 vat_main_t *vam = &vat_main;
4321 i32 retval = ntohl (mp->retval);
4325 print (vam->ofp, "%-20s%-16s",
4326 mp->is_set ? "set" : "not-set",
4327 mp->is_set ? (char *) mp->locator_set_name : "");
4330 vam->retval = retval;
4331 vam->result_ready = 1;
4335 vl_api_show_one_nsh_mapping_reply_t_handler_json
4336 (vl_api_show_one_nsh_mapping_reply_t * mp)
4338 vat_main_t *vam = &vat_main;
4339 vat_json_node_t node;
4342 status = format (0, "%s", mp->is_set ? "yes" : "no");
4343 vec_add1 (status, 0);
4345 vat_json_init_object (&node);
4346 vat_json_object_add_string_copy (&node, "is_set", status);
4349 vat_json_object_add_string_copy (&node, "locator_set",
4350 mp->locator_set_name);
4355 vat_json_print (vam->ofp, &node);
4356 vat_json_free (&node);
4358 vam->retval = ntohl (mp->retval);
4359 vam->result_ready = 1;
4363 vl_api_show_one_map_register_ttl_reply_t_handler
4364 (vl_api_show_one_map_register_ttl_reply_t * mp)
4366 vat_main_t *vam = &vat_main;
4367 i32 retval = ntohl (mp->retval);
4369 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4373 print (vam->ofp, "ttl: %u", mp->ttl);
4376 vam->retval = retval;
4377 vam->result_ready = 1;
4381 vl_api_show_one_map_register_ttl_reply_t_handler_json
4382 (vl_api_show_one_map_register_ttl_reply_t * mp)
4384 vat_main_t *vam = &vat_main;
4385 vat_json_node_t node;
4387 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4388 vat_json_init_object (&node);
4389 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4391 vat_json_print (vam->ofp, &node);
4392 vat_json_free (&node);
4394 vam->retval = ntohl (mp->retval);
4395 vam->result_ready = 1;
4399 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4401 vat_main_t *vam = &vat_main;
4402 i32 retval = ntohl (mp->retval);
4406 print (vam->ofp, "%-20s%-16s",
4407 mp->status ? "enabled" : "disabled",
4408 mp->status ? (char *) mp->locator_set_name : "");
4411 vam->retval = retval;
4412 vam->result_ready = 1;
4416 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4418 vat_main_t *vam = &vat_main;
4419 vat_json_node_t node;
4422 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4423 vec_add1 (status, 0);
4425 vat_json_init_object (&node);
4426 vat_json_object_add_string_copy (&node, "status", status);
4429 vat_json_object_add_string_copy (&node, "locator_set",
4430 mp->locator_set_name);
4435 vat_json_print (vam->ofp, &node);
4436 vat_json_free (&node);
4438 vam->retval = ntohl (mp->retval);
4439 vam->result_ready = 1;
4443 format_policer_type (u8 * s, va_list * va)
4445 u32 i = va_arg (*va, u32);
4447 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4448 s = format (s, "1r2c");
4449 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4450 s = format (s, "1r3c");
4451 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4452 s = format (s, "2r3c-2698");
4453 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4454 s = format (s, "2r3c-4115");
4455 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4456 s = format (s, "2r3c-mef5cf1");
4458 s = format (s, "ILLEGAL");
4463 format_policer_rate_type (u8 * s, va_list * va)
4465 u32 i = va_arg (*va, u32);
4467 if (i == SSE2_QOS_RATE_KBPS)
4468 s = format (s, "kbps");
4469 else if (i == SSE2_QOS_RATE_PPS)
4470 s = format (s, "pps");
4472 s = format (s, "ILLEGAL");
4477 format_policer_round_type (u8 * s, va_list * va)
4479 u32 i = va_arg (*va, u32);
4481 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4482 s = format (s, "closest");
4483 else if (i == SSE2_QOS_ROUND_TO_UP)
4484 s = format (s, "up");
4485 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4486 s = format (s, "down");
4488 s = format (s, "ILLEGAL");
4493 format_policer_action_type (u8 * s, va_list * va)
4495 u32 i = va_arg (*va, u32);
4497 if (i == SSE2_QOS_ACTION_DROP)
4498 s = format (s, "drop");
4499 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4500 s = format (s, "transmit");
4501 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4502 s = format (s, "mark-and-transmit");
4504 s = format (s, "ILLEGAL");
4509 format_dscp (u8 * s, va_list * va)
4511 u32 i = va_arg (*va, u32);
4516 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4520 return format (s, "ILLEGAL");
4522 s = format (s, "%s", t);
4527 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4529 vat_main_t *vam = &vat_main;
4530 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4532 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4533 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4535 conform_dscp_str = format (0, "");
4537 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4538 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4540 exceed_dscp_str = format (0, "");
4542 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4543 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4545 violate_dscp_str = format (0, "");
4547 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4548 "rate type %U, round type %U, %s rate, %s color-aware, "
4549 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4550 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4551 "conform action %U%s, exceed action %U%s, violate action %U%s",
4553 format_policer_type, mp->type,
4556 clib_net_to_host_u64 (mp->cb),
4557 clib_net_to_host_u64 (mp->eb),
4558 format_policer_rate_type, mp->rate_type,
4559 format_policer_round_type, mp->round_type,
4560 mp->single_rate ? "single" : "dual",
4561 mp->color_aware ? "is" : "not",
4562 ntohl (mp->cir_tokens_per_period),
4563 ntohl (mp->pir_tokens_per_period),
4565 ntohl (mp->current_limit),
4566 ntohl (mp->current_bucket),
4567 ntohl (mp->extended_limit),
4568 ntohl (mp->extended_bucket),
4569 clib_net_to_host_u64 (mp->last_update_time),
4570 format_policer_action_type, mp->conform_action_type,
4572 format_policer_action_type, mp->exceed_action_type,
4574 format_policer_action_type, mp->violate_action_type,
4577 vec_free (conform_dscp_str);
4578 vec_free (exceed_dscp_str);
4579 vec_free (violate_dscp_str);
4582 static void vl_api_policer_details_t_handler_json
4583 (vl_api_policer_details_t * mp)
4585 vat_main_t *vam = &vat_main;
4586 vat_json_node_t *node;
4587 u8 *rate_type_str, *round_type_str, *type_str;
4588 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4590 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4592 format (0, "%U", format_policer_round_type, mp->round_type);
4593 type_str = format (0, "%U", format_policer_type, mp->type);
4594 conform_action_str = format (0, "%U", format_policer_action_type,
4595 mp->conform_action_type);
4596 exceed_action_str = format (0, "%U", format_policer_action_type,
4597 mp->exceed_action_type);
4598 violate_action_str = format (0, "%U", format_policer_action_type,
4599 mp->violate_action_type);
4601 if (VAT_JSON_ARRAY != vam->json_tree.type)
4603 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4604 vat_json_init_array (&vam->json_tree);
4606 node = vat_json_array_add (&vam->json_tree);
4608 vat_json_init_object (node);
4609 vat_json_object_add_string_copy (node, "name", mp->name);
4610 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4611 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4612 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4613 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4614 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4615 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4616 vat_json_object_add_string_copy (node, "type", type_str);
4617 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4618 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4619 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4620 vat_json_object_add_uint (node, "cir_tokens_per_period",
4621 ntohl (mp->cir_tokens_per_period));
4622 vat_json_object_add_uint (node, "eir_tokens_per_period",
4623 ntohl (mp->pir_tokens_per_period));
4624 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4625 vat_json_object_add_uint (node, "current_bucket",
4626 ntohl (mp->current_bucket));
4627 vat_json_object_add_uint (node, "extended_limit",
4628 ntohl (mp->extended_limit));
4629 vat_json_object_add_uint (node, "extended_bucket",
4630 ntohl (mp->extended_bucket));
4631 vat_json_object_add_uint (node, "last_update_time",
4632 ntohl (mp->last_update_time));
4633 vat_json_object_add_string_copy (node, "conform_action",
4634 conform_action_str);
4635 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4637 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4638 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4639 vec_free (dscp_str);
4641 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4642 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4644 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4645 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4646 vec_free (dscp_str);
4648 vat_json_object_add_string_copy (node, "violate_action",
4649 violate_action_str);
4650 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4652 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4653 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4654 vec_free (dscp_str);
4657 vec_free (rate_type_str);
4658 vec_free (round_type_str);
4659 vec_free (type_str);
4660 vec_free (conform_action_str);
4661 vec_free (exceed_action_str);
4662 vec_free (violate_action_str);
4666 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4669 vat_main_t *vam = &vat_main;
4670 int i, count = ntohl (mp->count);
4673 print (vam->ofp, "classify table ids (%d) : ", count);
4674 for (i = 0; i < count; i++)
4676 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4677 print (vam->ofp, (i < count - 1) ? "," : "");
4679 vam->retval = ntohl (mp->retval);
4680 vam->result_ready = 1;
4684 vl_api_classify_table_ids_reply_t_handler_json
4685 (vl_api_classify_table_ids_reply_t * mp)
4687 vat_main_t *vam = &vat_main;
4688 int i, count = ntohl (mp->count);
4692 vat_json_node_t node;
4694 vat_json_init_object (&node);
4695 for (i = 0; i < count; i++)
4697 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4699 vat_json_print (vam->ofp, &node);
4700 vat_json_free (&node);
4702 vam->retval = ntohl (mp->retval);
4703 vam->result_ready = 1;
4707 vl_api_classify_table_by_interface_reply_t_handler
4708 (vl_api_classify_table_by_interface_reply_t * mp)
4710 vat_main_t *vam = &vat_main;
4713 table_id = ntohl (mp->l2_table_id);
4715 print (vam->ofp, "l2 table id : %d", table_id);
4717 print (vam->ofp, "l2 table id : No input ACL tables configured");
4718 table_id = ntohl (mp->ip4_table_id);
4720 print (vam->ofp, "ip4 table id : %d", table_id);
4722 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4723 table_id = ntohl (mp->ip6_table_id);
4725 print (vam->ofp, "ip6 table id : %d", table_id);
4727 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4728 vam->retval = ntohl (mp->retval);
4729 vam->result_ready = 1;
4733 vl_api_classify_table_by_interface_reply_t_handler_json
4734 (vl_api_classify_table_by_interface_reply_t * mp)
4736 vat_main_t *vam = &vat_main;
4737 vat_json_node_t node;
4739 vat_json_init_object (&node);
4741 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4742 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4743 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4745 vat_json_print (vam->ofp, &node);
4746 vat_json_free (&node);
4748 vam->retval = ntohl (mp->retval);
4749 vam->result_ready = 1;
4752 static void vl_api_policer_add_del_reply_t_handler
4753 (vl_api_policer_add_del_reply_t * mp)
4755 vat_main_t *vam = &vat_main;
4756 i32 retval = ntohl (mp->retval);
4757 if (vam->async_mode)
4759 vam->async_errors += (retval < 0);
4763 vam->retval = retval;
4764 vam->result_ready = 1;
4765 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4767 * Note: this is just barely thread-safe, depends on
4768 * the main thread spinning waiting for an answer...
4770 errmsg ("policer index %d", ntohl (mp->policer_index));
4774 static void vl_api_policer_add_del_reply_t_handler_json
4775 (vl_api_policer_add_del_reply_t * mp)
4777 vat_main_t *vam = &vat_main;
4778 vat_json_node_t node;
4780 vat_json_init_object (&node);
4781 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4782 vat_json_object_add_uint (&node, "policer_index",
4783 ntohl (mp->policer_index));
4785 vat_json_print (vam->ofp, &node);
4786 vat_json_free (&node);
4788 vam->retval = ntohl (mp->retval);
4789 vam->result_ready = 1;
4792 /* Format hex dump. */
4794 format_hex_bytes (u8 * s, va_list * va)
4796 u8 *bytes = va_arg (*va, u8 *);
4797 int n_bytes = va_arg (*va, int);
4800 /* Print short or long form depending on byte count. */
4801 uword short_form = n_bytes <= 32;
4802 u32 indent = format_get_indent (s);
4807 for (i = 0; i < n_bytes; i++)
4809 if (!short_form && (i % 32) == 0)
4810 s = format (s, "%08x: ", i);
4811 s = format (s, "%02x", bytes[i]);
4812 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4813 s = format (s, "\n%U", format_white_space, indent);
4820 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4823 vat_main_t *vam = &vat_main;
4824 i32 retval = ntohl (mp->retval);
4827 print (vam->ofp, "classify table info :");
4828 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4829 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4830 ntohl (mp->miss_next_index));
4831 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4832 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4833 ntohl (mp->match_n_vectors));
4834 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4835 ntohl (mp->mask_length));
4837 vam->retval = retval;
4838 vam->result_ready = 1;
4842 vl_api_classify_table_info_reply_t_handler_json
4843 (vl_api_classify_table_info_reply_t * mp)
4845 vat_main_t *vam = &vat_main;
4846 vat_json_node_t node;
4848 i32 retval = ntohl (mp->retval);
4851 vat_json_init_object (&node);
4853 vat_json_object_add_int (&node, "sessions",
4854 ntohl (mp->active_sessions));
4855 vat_json_object_add_int (&node, "nexttbl",
4856 ntohl (mp->next_table_index));
4857 vat_json_object_add_int (&node, "nextnode",
4858 ntohl (mp->miss_next_index));
4859 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4860 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4861 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4862 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4863 ntohl (mp->mask_length), 0);
4864 vat_json_object_add_string_copy (&node, "mask", s);
4866 vat_json_print (vam->ofp, &node);
4867 vat_json_free (&node);
4869 vam->retval = ntohl (mp->retval);
4870 vam->result_ready = 1;
4874 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4877 vat_main_t *vam = &vat_main;
4879 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4880 ntohl (mp->hit_next_index), ntohl (mp->advance),
4881 ntohl (mp->opaque_index));
4882 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4883 ntohl (mp->match_length));
4887 vl_api_classify_session_details_t_handler_json
4888 (vl_api_classify_session_details_t * mp)
4890 vat_main_t *vam = &vat_main;
4891 vat_json_node_t *node = NULL;
4893 if (VAT_JSON_ARRAY != vam->json_tree.type)
4895 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4896 vat_json_init_array (&vam->json_tree);
4898 node = vat_json_array_add (&vam->json_tree);
4900 vat_json_init_object (node);
4901 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4902 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4903 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4905 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4907 vat_json_object_add_string_copy (node, "match", s);
4910 static void vl_api_pg_create_interface_reply_t_handler
4911 (vl_api_pg_create_interface_reply_t * mp)
4913 vat_main_t *vam = &vat_main;
4915 vam->retval = ntohl (mp->retval);
4916 vam->result_ready = 1;
4919 static void vl_api_pg_create_interface_reply_t_handler_json
4920 (vl_api_pg_create_interface_reply_t * mp)
4922 vat_main_t *vam = &vat_main;
4923 vat_json_node_t node;
4925 i32 retval = ntohl (mp->retval);
4928 vat_json_init_object (&node);
4930 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4932 vat_json_print (vam->ofp, &node);
4933 vat_json_free (&node);
4935 vam->retval = ntohl (mp->retval);
4936 vam->result_ready = 1;
4939 static void vl_api_policer_classify_details_t_handler
4940 (vl_api_policer_classify_details_t * mp)
4942 vat_main_t *vam = &vat_main;
4944 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4945 ntohl (mp->table_index));
4948 static void vl_api_policer_classify_details_t_handler_json
4949 (vl_api_policer_classify_details_t * mp)
4951 vat_main_t *vam = &vat_main;
4952 vat_json_node_t *node;
4954 if (VAT_JSON_ARRAY != vam->json_tree.type)
4956 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4957 vat_json_init_array (&vam->json_tree);
4959 node = vat_json_array_add (&vam->json_tree);
4961 vat_json_init_object (node);
4962 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4963 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4966 static void vl_api_flow_classify_details_t_handler
4967 (vl_api_flow_classify_details_t * mp)
4969 vat_main_t *vam = &vat_main;
4971 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4972 ntohl (mp->table_index));
4975 static void vl_api_flow_classify_details_t_handler_json
4976 (vl_api_flow_classify_details_t * mp)
4978 vat_main_t *vam = &vat_main;
4979 vat_json_node_t *node;
4981 if (VAT_JSON_ARRAY != vam->json_tree.type)
4983 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4984 vat_json_init_array (&vam->json_tree);
4986 node = vat_json_array_add (&vam->json_tree);
4988 vat_json_init_object (node);
4989 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4990 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4993 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4994 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4995 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4996 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4997 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
4998 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
4999 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5000 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5001 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5002 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5005 * Generate boilerplate reply handlers, which
5006 * dig the return value out of the xxx_reply_t API message,
5007 * stick it into vam->retval, and set vam->result_ready
5009 * Could also do this by pointing N message decode slots at
5010 * a single function, but that could break in subtle ways.
5013 #define foreach_standard_reply_retval_handler \
5014 _(sw_interface_set_flags_reply) \
5015 _(sw_interface_add_del_address_reply) \
5016 _(sw_interface_set_rx_mode_reply) \
5017 _(sw_interface_set_rx_placement_reply) \
5018 _(sw_interface_set_table_reply) \
5019 _(sw_interface_set_mpls_enable_reply) \
5020 _(sw_interface_set_vpath_reply) \
5021 _(sw_interface_set_vxlan_bypass_reply) \
5022 _(sw_interface_set_geneve_bypass_reply) \
5023 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5024 _(sw_interface_set_l2_bridge_reply) \
5025 _(sw_interface_set_bond_weight_reply) \
5026 _(bridge_domain_add_del_reply) \
5027 _(sw_interface_set_l2_xconnect_reply) \
5028 _(l2fib_add_del_reply) \
5029 _(l2fib_flush_int_reply) \
5030 _(l2fib_flush_bd_reply) \
5031 _(ip_route_add_del_reply) \
5032 _(ip_table_add_del_reply) \
5033 _(ip_table_replace_begin_reply) \
5034 _(ip_table_flush_reply) \
5035 _(ip_table_replace_end_reply) \
5036 _(ip_mroute_add_del_reply) \
5037 _(mpls_route_add_del_reply) \
5038 _(mpls_table_add_del_reply) \
5039 _(mpls_ip_bind_unbind_reply) \
5040 _(bier_route_add_del_reply) \
5041 _(bier_table_add_del_reply) \
5042 _(sw_interface_set_unnumbered_reply) \
5043 _(set_ip_flow_hash_reply) \
5044 _(sw_interface_ip6_enable_disable_reply) \
5045 _(l2_patch_add_del_reply) \
5046 _(sr_mpls_policy_add_reply) \
5047 _(sr_mpls_policy_mod_reply) \
5048 _(sr_mpls_policy_del_reply) \
5049 _(sr_policy_add_reply) \
5050 _(sr_policy_mod_reply) \
5051 _(sr_policy_del_reply) \
5052 _(sr_localsid_add_del_reply) \
5053 _(sr_steering_add_del_reply) \
5054 _(classify_add_del_session_reply) \
5055 _(classify_set_interface_ip_table_reply) \
5056 _(classify_set_interface_l2_tables_reply) \
5057 _(l2tpv3_set_tunnel_cookies_reply) \
5058 _(l2tpv3_interface_enable_disable_reply) \
5059 _(l2tpv3_set_lookup_key_reply) \
5060 _(l2_fib_clear_table_reply) \
5061 _(l2_interface_efp_filter_reply) \
5062 _(l2_interface_vlan_tag_rewrite_reply) \
5063 _(modify_vhost_user_if_reply) \
5064 _(delete_vhost_user_if_reply) \
5065 _(want_l2_macs_events_reply) \
5066 _(input_acl_set_interface_reply) \
5067 _(ipsec_spd_add_del_reply) \
5068 _(ipsec_interface_add_del_spd_reply) \
5069 _(ipsec_spd_entry_add_del_reply) \
5070 _(ipsec_sad_entry_add_del_reply) \
5071 _(ipsec_tunnel_if_add_del_reply) \
5072 _(ipsec_tunnel_if_set_sa_reply) \
5073 _(delete_loopback_reply) \
5074 _(bd_ip_mac_add_del_reply) \
5075 _(bd_ip_mac_flush_reply) \
5076 _(want_interface_events_reply) \
5077 _(cop_interface_enable_disable_reply) \
5078 _(cop_whitelist_enable_disable_reply) \
5079 _(sw_interface_clear_stats_reply) \
5080 _(ioam_enable_reply) \
5081 _(ioam_disable_reply) \
5082 _(one_add_del_locator_reply) \
5083 _(one_add_del_local_eid_reply) \
5084 _(one_add_del_remote_mapping_reply) \
5085 _(one_add_del_adjacency_reply) \
5086 _(one_add_del_map_resolver_reply) \
5087 _(one_add_del_map_server_reply) \
5088 _(one_enable_disable_reply) \
5089 _(one_rloc_probe_enable_disable_reply) \
5090 _(one_map_register_enable_disable_reply) \
5091 _(one_map_register_set_ttl_reply) \
5092 _(one_set_transport_protocol_reply) \
5093 _(one_map_register_fallback_threshold_reply) \
5094 _(one_pitr_set_locator_set_reply) \
5095 _(one_map_request_mode_reply) \
5096 _(one_add_del_map_request_itr_rlocs_reply) \
5097 _(one_eid_table_add_del_map_reply) \
5098 _(one_use_petr_reply) \
5099 _(one_stats_enable_disable_reply) \
5100 _(one_add_del_l2_arp_entry_reply) \
5101 _(one_add_del_ndp_entry_reply) \
5102 _(one_stats_flush_reply) \
5103 _(one_enable_disable_xtr_mode_reply) \
5104 _(one_enable_disable_pitr_mode_reply) \
5105 _(one_enable_disable_petr_mode_reply) \
5106 _(gpe_enable_disable_reply) \
5107 _(gpe_set_encap_mode_reply) \
5108 _(gpe_add_del_iface_reply) \
5109 _(gpe_add_del_native_fwd_rpath_reply) \
5110 _(af_packet_delete_reply) \
5111 _(policer_classify_set_interface_reply) \
5112 _(netmap_create_reply) \
5113 _(netmap_delete_reply) \
5114 _(set_ipfix_exporter_reply) \
5115 _(set_ipfix_classify_stream_reply) \
5116 _(ipfix_classify_table_add_del_reply) \
5117 _(flow_classify_set_interface_reply) \
5118 _(sw_interface_span_enable_disable_reply) \
5119 _(pg_capture_reply) \
5120 _(pg_enable_disable_reply) \
5121 _(ip_source_and_port_range_check_add_del_reply) \
5122 _(ip_source_and_port_range_check_interface_add_del_reply)\
5123 _(delete_subif_reply) \
5124 _(l2_interface_pbb_tag_rewrite_reply) \
5126 _(feature_enable_disable_reply) \
5127 _(feature_gso_enable_disable_reply) \
5128 _(sw_interface_tag_add_del_reply) \
5129 _(sw_interface_add_del_mac_address_reply) \
5130 _(hw_interface_set_mtu_reply) \
5131 _(p2p_ethernet_add_reply) \
5132 _(p2p_ethernet_del_reply) \
5133 _(lldp_config_reply) \
5134 _(sw_interface_set_lldp_reply) \
5135 _(tcp_configure_src_addresses_reply) \
5136 _(session_rule_add_del_reply) \
5137 _(ip_container_proxy_add_del_reply) \
5138 _(output_acl_set_interface_reply) \
5139 _(qos_record_enable_disable_reply)
5142 static void vl_api_##n##_t_handler \
5143 (vl_api_##n##_t * mp) \
5145 vat_main_t * vam = &vat_main; \
5146 i32 retval = ntohl(mp->retval); \
5147 if (vam->async_mode) { \
5148 vam->async_errors += (retval < 0); \
5150 vam->retval = retval; \
5151 vam->result_ready = 1; \
5154 foreach_standard_reply_retval_handler;
5158 static void vl_api_##n##_t_handler_json \
5159 (vl_api_##n##_t * mp) \
5161 vat_main_t * vam = &vat_main; \
5162 vat_json_node_t node; \
5163 vat_json_init_object(&node); \
5164 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5165 vat_json_print(vam->ofp, &node); \
5166 vam->retval = ntohl(mp->retval); \
5167 vam->result_ready = 1; \
5169 foreach_standard_reply_retval_handler;
5173 * Table of message reply handlers, must include boilerplate handlers
5177 #define foreach_vpe_api_reply_msg \
5178 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5179 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5180 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5181 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5182 _(CONTROL_PING_REPLY, control_ping_reply) \
5183 _(CLI_REPLY, cli_reply) \
5184 _(CLI_INBAND_REPLY, cli_inband_reply) \
5185 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5186 sw_interface_add_del_address_reply) \
5187 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5188 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5189 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5190 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5191 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5192 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5193 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5194 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5195 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5196 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5197 sw_interface_set_l2_xconnect_reply) \
5198 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5199 sw_interface_set_l2_bridge_reply) \
5200 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5201 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5202 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5203 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5204 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5205 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5206 _(L2_FLAGS_REPLY, l2_flags_reply) \
5207 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5208 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5209 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5210 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5211 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5212 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5213 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5214 _(BOND_CREATE_REPLY, bond_create_reply) \
5215 _(BOND_DELETE_REPLY, bond_delete_reply) \
5216 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5217 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5218 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5219 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5220 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5221 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5222 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5223 _(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
5224 _(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
5225 _(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_reply) \
5226 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5227 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5228 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5229 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5230 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5231 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5232 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5233 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5234 sw_interface_set_unnumbered_reply) \
5235 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5236 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5237 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5238 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5239 sw_interface_ip6_enable_disable_reply) \
5240 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5241 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5242 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5243 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5244 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5245 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5246 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5247 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5248 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5249 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5250 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5251 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5252 classify_set_interface_ip_table_reply) \
5253 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5254 classify_set_interface_l2_tables_reply) \
5255 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5256 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5257 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5258 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5259 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5260 l2tpv3_interface_enable_disable_reply) \
5261 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5262 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5263 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5264 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5265 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5266 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5267 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5268 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5269 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5270 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5271 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5272 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5273 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5274 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5275 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5276 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5277 _(SHOW_VERSION_REPLY, show_version_reply) \
5278 _(SHOW_THREADS_REPLY, show_threads_reply) \
5279 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5280 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5281 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5282 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5283 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5284 _(L2_MACS_EVENT, l2_macs_event) \
5285 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5286 _(IP_ADDRESS_DETAILS, ip_address_details) \
5287 _(IP_DETAILS, ip_details) \
5288 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5289 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5290 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5291 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5292 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5293 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5294 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5295 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5296 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5297 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5298 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5299 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5300 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5301 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5302 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5303 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5304 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5305 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5306 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5307 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5308 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5309 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5310 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5311 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5312 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5313 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5314 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5315 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5316 one_map_register_enable_disable_reply) \
5317 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5318 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5319 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5320 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5321 one_map_register_fallback_threshold_reply) \
5322 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5323 one_rloc_probe_enable_disable_reply) \
5324 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5325 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5326 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5327 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5328 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5329 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5330 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5331 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5332 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5333 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5334 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5335 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5336 _(ONE_STATS_DETAILS, one_stats_details) \
5337 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5338 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5339 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5340 show_one_stats_enable_disable_reply) \
5341 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5342 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5343 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5344 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5345 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5346 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5347 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5348 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5349 one_enable_disable_pitr_mode_reply) \
5350 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5351 one_enable_disable_petr_mode_reply) \
5352 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5353 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5354 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5355 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5356 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5357 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5358 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5359 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5360 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5361 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5362 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5363 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5364 gpe_add_del_native_fwd_rpath_reply) \
5365 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5366 gpe_fwd_entry_path_details) \
5367 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5368 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5369 one_add_del_map_request_itr_rlocs_reply) \
5370 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5371 one_get_map_request_itr_rlocs_reply) \
5372 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5373 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5374 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5375 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5376 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5377 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5378 show_one_map_register_state_reply) \
5379 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5380 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5381 show_one_map_register_fallback_threshold_reply) \
5382 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5383 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5384 _(AF_PACKET_DETAILS, af_packet_details) \
5385 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5386 _(POLICER_DETAILS, policer_details) \
5387 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5388 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5389 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5390 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5391 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5392 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5393 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5394 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5395 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5396 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5397 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5398 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5399 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5400 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5401 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5402 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5403 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5404 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5405 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5406 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5407 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5408 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5409 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5410 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5411 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5412 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5413 ip_source_and_port_range_check_add_del_reply) \
5414 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5415 ip_source_and_port_range_check_interface_add_del_reply) \
5416 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5417 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5418 _(SET_PUNT_REPLY, set_punt_reply) \
5419 _(IP_TABLE_DETAILS, ip_table_details) \
5420 _(IP_ROUTE_DETAILS, ip_route_details) \
5421 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5422 _(FEATURE_GSO_ENABLE_DISABLE_REPLY, feature_gso_enable_disable_reply) \
5423 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5424 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
5425 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5426 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5427 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5428 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5429 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5430 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5431 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5432 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5433 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5434 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5435 _(SESSION_RULES_DETAILS, session_rules_details) \
5436 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5437 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5438 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5440 #define foreach_standalone_reply_msg \
5441 _(SW_INTERFACE_EVENT, sw_interface_event)
5449 #define STR_VTR_OP_CASE(op) \
5450 case L2_VTR_ ## op: \
5454 str_vtr_op (u32 vtr_op)
5458 STR_VTR_OP_CASE (DISABLED);
5459 STR_VTR_OP_CASE (PUSH_1);
5460 STR_VTR_OP_CASE (PUSH_2);
5461 STR_VTR_OP_CASE (POP_1);
5462 STR_VTR_OP_CASE (POP_2);
5463 STR_VTR_OP_CASE (TRANSLATE_1_1);
5464 STR_VTR_OP_CASE (TRANSLATE_1_2);
5465 STR_VTR_OP_CASE (TRANSLATE_2_1);
5466 STR_VTR_OP_CASE (TRANSLATE_2_2);
5473 dump_sub_interface_table (vat_main_t * vam)
5475 const sw_interface_subif_t *sub = NULL;
5477 if (vam->json_output)
5480 ("JSON output supported only for VPE API calls and dump_stats_table");
5485 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5486 "Interface", "sw_if_index",
5487 "sub id", "dot1ad", "tags", "outer id",
5488 "inner id", "exact", "default", "outer any", "inner any");
5490 vec_foreach (sub, vam->sw_if_subif_table)
5493 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5494 sub->interface_name,
5496 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5497 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5498 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5499 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5500 if (sub->vtr_op != L2_VTR_DISABLED)
5503 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5504 "tag1: %d tag2: %d ]",
5505 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5506 sub->vtr_tag1, sub->vtr_tag2);
5514 name_sort_cmp (void *a1, void *a2)
5516 name_sort_t *n1 = a1;
5517 name_sort_t *n2 = a2;
5519 return strcmp ((char *) n1->name, (char *) n2->name);
5523 dump_interface_table (vat_main_t * vam)
5526 name_sort_t *nses = 0, *ns;
5528 if (vam->json_output)
5531 ("JSON output supported only for VPE API calls and dump_stats_table");
5536 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5538 vec_add2 (nses, ns, 1);
5539 ns->name = (u8 *)(p->key);
5540 ns->value = (u32) p->value[0];
5544 vec_sort_with_function (nses, name_sort_cmp);
5546 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5547 vec_foreach (ns, nses)
5549 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5556 dump_ip_table (vat_main_t * vam, int is_ipv6)
5558 const ip_details_t *det = NULL;
5559 const ip_address_details_t *address = NULL;
5562 print (vam->ofp, "%-12s", "sw_if_index");
5564 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5571 print (vam->ofp, "%-12d", i);
5572 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5577 vec_foreach (address, det->addr)
5581 is_ipv6 ? format_ip6_address : format_ip4_address,
5582 address->ip, address->prefix_length);
5590 dump_ipv4_table (vat_main_t * vam)
5592 if (vam->json_output)
5595 ("JSON output supported only for VPE API calls and dump_stats_table");
5599 return dump_ip_table (vam, 0);
5603 dump_ipv6_table (vat_main_t * vam)
5605 if (vam->json_output)
5608 ("JSON output supported only for VPE API calls and dump_stats_table");
5612 return dump_ip_table (vam, 1);
5616 * Pass CLI buffers directly in the CLI_INBAND API message,
5617 * instead of an additional shared memory area.
5620 exec_inband (vat_main_t * vam)
5622 vl_api_cli_inband_t *mp;
5623 unformat_input_t *i = vam->input;
5626 if (vec_len (i->buffer) == 0)
5629 if (vam->exec_mode == 0 && unformat (i, "mode"))
5634 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5641 * In order for the CLI command to work, it
5642 * must be a vector ending in \n, not a C-string ending
5645 u32 len = vec_len (vam->input->buffer);
5646 M2 (CLI_INBAND, mp, len);
5647 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5651 /* json responses may or may not include a useful reply... */
5652 if (vec_len (vam->cmd_reply))
5653 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5658 exec (vat_main_t * vam)
5660 return exec_inband (vam);
5664 api_create_loopback (vat_main_t * vam)
5666 unformat_input_t *i = vam->input;
5667 vl_api_create_loopback_t *mp;
5668 vl_api_create_loopback_instance_t *mp_lbi;
5671 u8 is_specified = 0;
5672 u32 user_instance = 0;
5675 clib_memset (mac_address, 0, sizeof (mac_address));
5677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5679 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5681 if (unformat (i, "instance %d", &user_instance))
5689 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5690 mp_lbi->is_specified = is_specified;
5692 mp_lbi->user_instance = htonl (user_instance);
5694 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5699 /* Construct the API message */
5700 M (CREATE_LOOPBACK, mp);
5702 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5711 api_delete_loopback (vat_main_t * vam)
5713 unformat_input_t *i = vam->input;
5714 vl_api_delete_loopback_t *mp;
5715 u32 sw_if_index = ~0;
5718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5720 if (unformat (i, "sw_if_index %d", &sw_if_index))
5726 if (sw_if_index == ~0)
5728 errmsg ("missing sw_if_index");
5732 /* Construct the API message */
5733 M (DELETE_LOOPBACK, mp);
5734 mp->sw_if_index = ntohl (sw_if_index);
5742 api_want_interface_events (vat_main_t * vam)
5744 unformat_input_t *i = vam->input;
5745 vl_api_want_interface_events_t *mp;
5749 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5751 if (unformat (i, "enable"))
5753 else if (unformat (i, "disable"))
5761 errmsg ("missing enable|disable");
5765 M (WANT_INTERFACE_EVENTS, mp);
5766 mp->enable_disable = enable;
5768 vam->interface_event_display = enable;
5776 /* Note: non-static, called once to set up the initial intfc table */
5778 api_sw_interface_dump (vat_main_t * vam)
5780 vl_api_sw_interface_dump_t *mp;
5781 vl_api_control_ping_t *mp_ping;
5783 name_sort_t *nses = 0, *ns;
5784 sw_interface_subif_t *sub = NULL;
5787 /* Toss the old name table */
5789 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5791 vec_add2 (nses, ns, 1);
5792 ns->name = (u8 *)(p->key);
5793 ns->value = (u32) p->value[0];
5797 hash_free (vam->sw_if_index_by_interface_name);
5799 vec_foreach (ns, nses) vec_free (ns->name);
5803 vec_foreach (sub, vam->sw_if_subif_table)
5805 vec_free (sub->interface_name);
5807 vec_free (vam->sw_if_subif_table);
5809 /* recreate the interface name hash table */
5810 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5813 * Ask for all interface names. Otherwise, the epic catalog of
5814 * name filters becomes ridiculously long, and vat ends up needing
5815 * to be taught about new interface types.
5817 M (SW_INTERFACE_DUMP, mp);
5820 /* Use a control ping for synchronization */
5821 MPING (CONTROL_PING, mp_ping);
5829 api_sw_interface_set_flags (vat_main_t * vam)
5831 unformat_input_t *i = vam->input;
5832 vl_api_sw_interface_set_flags_t *mp;
5834 u8 sw_if_index_set = 0;
5838 /* Parse args required to build the message */
5839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5841 if (unformat (i, "admin-up"))
5843 else if (unformat (i, "admin-down"))
5846 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5847 sw_if_index_set = 1;
5848 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5849 sw_if_index_set = 1;
5854 if (sw_if_index_set == 0)
5856 errmsg ("missing interface name or sw_if_index");
5860 /* Construct the API message */
5861 M (SW_INTERFACE_SET_FLAGS, mp);
5862 mp->sw_if_index = ntohl (sw_if_index);
5863 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5868 /* Wait for a reply, return the good/bad news... */
5874 api_sw_interface_set_rx_mode (vat_main_t * vam)
5876 unformat_input_t *i = vam->input;
5877 vl_api_sw_interface_set_rx_mode_t *mp;
5879 u8 sw_if_index_set = 0;
5881 u8 queue_id_valid = 0;
5883 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5885 /* Parse args required to build the message */
5886 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5888 if (unformat (i, "queue %d", &queue_id))
5890 else if (unformat (i, "polling"))
5891 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5892 else if (unformat (i, "interrupt"))
5893 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5894 else if (unformat (i, "adaptive"))
5895 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5897 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5898 sw_if_index_set = 1;
5899 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5900 sw_if_index_set = 1;
5905 if (sw_if_index_set == 0)
5907 errmsg ("missing interface name or sw_if_index");
5910 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
5912 errmsg ("missing rx-mode");
5916 /* Construct the API message */
5917 M (SW_INTERFACE_SET_RX_MODE, mp);
5918 mp->sw_if_index = ntohl (sw_if_index);
5919 mp->mode = (vl_api_rx_mode_t) mode;
5920 mp->queue_id_valid = queue_id_valid;
5921 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
5926 /* Wait for a reply, return the good/bad news... */
5932 api_sw_interface_set_rx_placement (vat_main_t * vam)
5934 unformat_input_t *i = vam->input;
5935 vl_api_sw_interface_set_rx_placement_t *mp;
5937 u8 sw_if_index_set = 0;
5940 u32 queue_id, thread_index;
5942 /* Parse args required to build the message */
5943 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5945 if (unformat (i, "queue %d", &queue_id))
5947 else if (unformat (i, "main"))
5949 else if (unformat (i, "worker %d", &thread_index))
5952 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5953 sw_if_index_set = 1;
5954 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5955 sw_if_index_set = 1;
5960 if (sw_if_index_set == 0)
5962 errmsg ("missing interface name or sw_if_index");
5968 /* Construct the API message */
5969 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
5970 mp->sw_if_index = ntohl (sw_if_index);
5971 mp->worker_id = ntohl (thread_index);
5972 mp->queue_id = ntohl (queue_id);
5973 mp->is_main = is_main;
5977 /* Wait for a reply, return the good/bad news... */
5982 static void vl_api_sw_interface_rx_placement_details_t_handler
5983 (vl_api_sw_interface_rx_placement_details_t * mp)
5985 vat_main_t *vam = &vat_main;
5986 u32 worker_id = ntohl (mp->worker_id);
5989 "\n%-11d %-11s %-6d %-5d %-9s",
5990 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
5991 worker_id, ntohl (mp->queue_id),
5993 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
5996 static void vl_api_sw_interface_rx_placement_details_t_handler_json
5997 (vl_api_sw_interface_rx_placement_details_t * mp)
5999 vat_main_t *vam = &vat_main;
6000 vat_json_node_t *node = NULL;
6002 if (VAT_JSON_ARRAY != vam->json_tree.type)
6004 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6005 vat_json_init_array (&vam->json_tree);
6007 node = vat_json_array_add (&vam->json_tree);
6009 vat_json_init_object (node);
6010 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6011 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6012 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6013 vat_json_object_add_uint (node, "mode", mp->mode);
6017 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6019 unformat_input_t *i = vam->input;
6020 vl_api_sw_interface_rx_placement_dump_t *mp;
6021 vl_api_control_ping_t *mp_ping;
6024 u8 sw_if_index_set = 0;
6026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6028 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6030 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6037 "\n%-11s %-11s %-6s %-5s %-4s",
6038 "sw_if_index", "main/worker", "thread", "queue", "mode");
6040 /* Dump Interface rx placement */
6041 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6043 if (sw_if_index_set)
6044 mp->sw_if_index = htonl (sw_if_index);
6046 mp->sw_if_index = ~0;
6050 /* Use a control ping for synchronization */
6051 MPING (CONTROL_PING, mp_ping);
6059 api_sw_interface_clear_stats (vat_main_t * vam)
6061 unformat_input_t *i = vam->input;
6062 vl_api_sw_interface_clear_stats_t *mp;
6064 u8 sw_if_index_set = 0;
6067 /* Parse args required to build the message */
6068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6070 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6071 sw_if_index_set = 1;
6072 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6073 sw_if_index_set = 1;
6078 /* Construct the API message */
6079 M (SW_INTERFACE_CLEAR_STATS, mp);
6081 if (sw_if_index_set == 1)
6082 mp->sw_if_index = ntohl (sw_if_index);
6084 mp->sw_if_index = ~0;
6089 /* Wait for a reply, return the good/bad news... */
6095 api_sw_interface_add_del_address (vat_main_t * vam)
6097 unformat_input_t *i = vam->input;
6098 vl_api_sw_interface_add_del_address_t *mp;
6100 u8 sw_if_index_set = 0;
6101 u8 is_add = 1, del_all = 0;
6102 u32 address_length = 0;
6103 u8 v4_address_set = 0;
6104 u8 v6_address_set = 0;
6105 ip4_address_t v4address;
6106 ip6_address_t v6address;
6109 /* Parse args required to build the message */
6110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6112 if (unformat (i, "del-all"))
6114 else if (unformat (i, "del"))
6117 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6118 sw_if_index_set = 1;
6119 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6120 sw_if_index_set = 1;
6121 else if (unformat (i, "%U/%d",
6122 unformat_ip4_address, &v4address, &address_length))
6124 else if (unformat (i, "%U/%d",
6125 unformat_ip6_address, &v6address, &address_length))
6131 if (sw_if_index_set == 0)
6133 errmsg ("missing interface name or sw_if_index");
6136 if (v4_address_set && v6_address_set)
6138 errmsg ("both v4 and v6 addresses set");
6141 if (!v4_address_set && !v6_address_set && !del_all)
6143 errmsg ("no addresses set");
6147 /* Construct the API message */
6148 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6150 mp->sw_if_index = ntohl (sw_if_index);
6151 mp->is_add = is_add;
6152 mp->del_all = del_all;
6155 mp->prefix.address.af = ADDRESS_IP6;
6156 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6160 mp->prefix.address.af = ADDRESS_IP4;
6161 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6163 mp->prefix.len = address_length;
6168 /* Wait for a reply, return good/bad news */
6174 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6176 unformat_input_t *i = vam->input;
6177 vl_api_sw_interface_set_mpls_enable_t *mp;
6179 u8 sw_if_index_set = 0;
6183 /* Parse args required to build the message */
6184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6186 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6187 sw_if_index_set = 1;
6188 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6189 sw_if_index_set = 1;
6190 else if (unformat (i, "disable"))
6192 else if (unformat (i, "dis"))
6198 if (sw_if_index_set == 0)
6200 errmsg ("missing interface name or sw_if_index");
6204 /* Construct the API message */
6205 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6207 mp->sw_if_index = ntohl (sw_if_index);
6208 mp->enable = enable;
6213 /* Wait for a reply... */
6219 api_sw_interface_set_table (vat_main_t * vam)
6221 unformat_input_t *i = vam->input;
6222 vl_api_sw_interface_set_table_t *mp;
6223 u32 sw_if_index, vrf_id = 0;
6224 u8 sw_if_index_set = 0;
6228 /* Parse args required to build the message */
6229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6231 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6232 sw_if_index_set = 1;
6233 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6234 sw_if_index_set = 1;
6235 else if (unformat (i, "vrf %d", &vrf_id))
6237 else if (unformat (i, "ipv6"))
6243 if (sw_if_index_set == 0)
6245 errmsg ("missing interface name or sw_if_index");
6249 /* Construct the API message */
6250 M (SW_INTERFACE_SET_TABLE, mp);
6252 mp->sw_if_index = ntohl (sw_if_index);
6253 mp->is_ipv6 = is_ipv6;
6254 mp->vrf_id = ntohl (vrf_id);
6259 /* Wait for a reply... */
6264 static void vl_api_sw_interface_get_table_reply_t_handler
6265 (vl_api_sw_interface_get_table_reply_t * mp)
6267 vat_main_t *vam = &vat_main;
6269 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6271 vam->retval = ntohl (mp->retval);
6272 vam->result_ready = 1;
6276 static void vl_api_sw_interface_get_table_reply_t_handler_json
6277 (vl_api_sw_interface_get_table_reply_t * mp)
6279 vat_main_t *vam = &vat_main;
6280 vat_json_node_t node;
6282 vat_json_init_object (&node);
6283 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6284 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6286 vat_json_print (vam->ofp, &node);
6287 vat_json_free (&node);
6289 vam->retval = ntohl (mp->retval);
6290 vam->result_ready = 1;
6294 api_sw_interface_get_table (vat_main_t * vam)
6296 unformat_input_t *i = vam->input;
6297 vl_api_sw_interface_get_table_t *mp;
6299 u8 sw_if_index_set = 0;
6303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6305 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6306 sw_if_index_set = 1;
6307 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6308 sw_if_index_set = 1;
6309 else if (unformat (i, "ipv6"))
6315 if (sw_if_index_set == 0)
6317 errmsg ("missing interface name or sw_if_index");
6321 M (SW_INTERFACE_GET_TABLE, mp);
6322 mp->sw_if_index = htonl (sw_if_index);
6323 mp->is_ipv6 = is_ipv6;
6331 api_sw_interface_set_vpath (vat_main_t * vam)
6333 unformat_input_t *i = vam->input;
6334 vl_api_sw_interface_set_vpath_t *mp;
6335 u32 sw_if_index = 0;
6336 u8 sw_if_index_set = 0;
6340 /* Parse args required to build the message */
6341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6343 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6344 sw_if_index_set = 1;
6345 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6346 sw_if_index_set = 1;
6347 else if (unformat (i, "enable"))
6349 else if (unformat (i, "disable"))
6355 if (sw_if_index_set == 0)
6357 errmsg ("missing interface name or sw_if_index");
6361 /* Construct the API message */
6362 M (SW_INTERFACE_SET_VPATH, mp);
6364 mp->sw_if_index = ntohl (sw_if_index);
6365 mp->enable = is_enable;
6370 /* Wait for a reply... */
6376 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6378 unformat_input_t *i = vam->input;
6379 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6380 u32 sw_if_index = 0;
6381 u8 sw_if_index_set = 0;
6386 /* Parse args required to build the message */
6387 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6389 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6390 sw_if_index_set = 1;
6391 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6392 sw_if_index_set = 1;
6393 else if (unformat (i, "enable"))
6395 else if (unformat (i, "disable"))
6397 else if (unformat (i, "ip4"))
6399 else if (unformat (i, "ip6"))
6405 if (sw_if_index_set == 0)
6407 errmsg ("missing interface name or sw_if_index");
6411 /* Construct the API message */
6412 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6414 mp->sw_if_index = ntohl (sw_if_index);
6415 mp->enable = is_enable;
6416 mp->is_ipv6 = is_ipv6;
6421 /* Wait for a reply... */
6427 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6429 unformat_input_t *i = vam->input;
6430 vl_api_sw_interface_set_geneve_bypass_t *mp;
6431 u32 sw_if_index = 0;
6432 u8 sw_if_index_set = 0;
6437 /* Parse args required to build the message */
6438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6440 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6441 sw_if_index_set = 1;
6442 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6443 sw_if_index_set = 1;
6444 else if (unformat (i, "enable"))
6446 else if (unformat (i, "disable"))
6448 else if (unformat (i, "ip4"))
6450 else if (unformat (i, "ip6"))
6456 if (sw_if_index_set == 0)
6458 errmsg ("missing interface name or sw_if_index");
6462 /* Construct the API message */
6463 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6465 mp->sw_if_index = ntohl (sw_if_index);
6466 mp->enable = is_enable;
6467 mp->is_ipv6 = is_ipv6;
6472 /* Wait for a reply... */
6478 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6480 unformat_input_t *i = vam->input;
6481 vl_api_sw_interface_set_l2_xconnect_t *mp;
6483 u8 rx_sw_if_index_set = 0;
6485 u8 tx_sw_if_index_set = 0;
6489 /* Parse args required to build the message */
6490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6492 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6493 rx_sw_if_index_set = 1;
6494 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6495 tx_sw_if_index_set = 1;
6496 else if (unformat (i, "rx"))
6498 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6500 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6502 rx_sw_if_index_set = 1;
6507 else if (unformat (i, "tx"))
6509 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6511 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6513 tx_sw_if_index_set = 1;
6518 else if (unformat (i, "enable"))
6520 else if (unformat (i, "disable"))
6526 if (rx_sw_if_index_set == 0)
6528 errmsg ("missing rx interface name or rx_sw_if_index");
6532 if (enable && (tx_sw_if_index_set == 0))
6534 errmsg ("missing tx interface name or tx_sw_if_index");
6538 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6540 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6541 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6542 mp->enable = enable;
6550 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6552 unformat_input_t *i = vam->input;
6553 vl_api_sw_interface_set_l2_bridge_t *mp;
6554 vl_api_l2_port_type_t port_type;
6556 u8 rx_sw_if_index_set = 0;
6563 port_type = L2_API_PORT_TYPE_NORMAL;
6565 /* Parse args required to build the message */
6566 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6568 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6569 rx_sw_if_index_set = 1;
6570 else if (unformat (i, "bd_id %d", &bd_id))
6574 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6575 rx_sw_if_index_set = 1;
6576 else if (unformat (i, "shg %d", &shg))
6578 else if (unformat (i, "bvi"))
6579 port_type = L2_API_PORT_TYPE_BVI;
6580 else if (unformat (i, "uu-fwd"))
6581 port_type = L2_API_PORT_TYPE_UU_FWD;
6582 else if (unformat (i, "enable"))
6584 else if (unformat (i, "disable"))
6590 if (rx_sw_if_index_set == 0)
6592 errmsg ("missing rx interface name or sw_if_index");
6596 if (enable && (bd_id_set == 0))
6598 errmsg ("missing bridge domain");
6602 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6604 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6605 mp->bd_id = ntohl (bd_id);
6607 mp->port_type = ntohl (port_type);
6608 mp->enable = enable;
6616 api_bridge_domain_dump (vat_main_t * vam)
6618 unformat_input_t *i = vam->input;
6619 vl_api_bridge_domain_dump_t *mp;
6620 vl_api_control_ping_t *mp_ping;
6624 /* Parse args required to build the message */
6625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6627 if (unformat (i, "bd_id %d", &bd_id))
6633 M (BRIDGE_DOMAIN_DUMP, mp);
6634 mp->bd_id = ntohl (bd_id);
6637 /* Use a control ping for synchronization */
6638 MPING (CONTROL_PING, mp_ping);
6646 api_bridge_domain_add_del (vat_main_t * vam)
6648 unformat_input_t *i = vam->input;
6649 vl_api_bridge_domain_add_del_t *mp;
6652 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6657 /* Parse args required to build the message */
6658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6660 if (unformat (i, "bd_id %d", &bd_id))
6662 else if (unformat (i, "flood %d", &flood))
6664 else if (unformat (i, "uu-flood %d", &uu_flood))
6666 else if (unformat (i, "forward %d", &forward))
6668 else if (unformat (i, "learn %d", &learn))
6670 else if (unformat (i, "arp-term %d", &arp_term))
6672 else if (unformat (i, "mac-age %d", &mac_age))
6674 else if (unformat (i, "bd-tag %s", &bd_tag))
6676 else if (unformat (i, "del"))
6679 flood = uu_flood = forward = learn = 0;
6687 errmsg ("missing bridge domain");
6694 errmsg ("mac age must be less than 256 ");
6699 if ((bd_tag) && (vec_len (bd_tag) > 63))
6701 errmsg ("bd-tag cannot be longer than 63");
6706 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6708 mp->bd_id = ntohl (bd_id);
6710 mp->uu_flood = uu_flood;
6711 mp->forward = forward;
6713 mp->arp_term = arp_term;
6714 mp->is_add = is_add;
6715 mp->mac_age = (u8) mac_age;
6718 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6719 mp->bd_tag[vec_len (bd_tag)] = 0;
6730 api_l2fib_flush_bd (vat_main_t * vam)
6732 unformat_input_t *i = vam->input;
6733 vl_api_l2fib_flush_bd_t *mp;
6737 /* Parse args required to build the message */
6738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6740 if (unformat (i, "bd_id %d", &bd_id));
6747 errmsg ("missing bridge domain");
6751 M (L2FIB_FLUSH_BD, mp);
6753 mp->bd_id = htonl (bd_id);
6761 api_l2fib_flush_int (vat_main_t * vam)
6763 unformat_input_t *i = vam->input;
6764 vl_api_l2fib_flush_int_t *mp;
6765 u32 sw_if_index = ~0;
6768 /* Parse args required to build the message */
6769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6771 if (unformat (i, "sw_if_index %d", &sw_if_index));
6773 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6778 if (sw_if_index == ~0)
6780 errmsg ("missing interface name or sw_if_index");
6784 M (L2FIB_FLUSH_INT, mp);
6786 mp->sw_if_index = ntohl (sw_if_index);
6794 api_l2fib_add_del (vat_main_t * vam)
6796 unformat_input_t *i = vam->input;
6797 vl_api_l2fib_add_del_t *mp;
6803 u32 sw_if_index = 0;
6804 u8 sw_if_index_set = 0;
6813 /* Parse args required to build the message */
6814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6816 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6818 else if (unformat (i, "bd_id %d", &bd_id))
6820 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6821 sw_if_index_set = 1;
6822 else if (unformat (i, "sw_if"))
6824 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6827 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6828 sw_if_index_set = 1;
6833 else if (unformat (i, "static"))
6835 else if (unformat (i, "filter"))
6840 else if (unformat (i, "bvi"))
6845 else if (unformat (i, "del"))
6847 else if (unformat (i, "count %d", &count))
6855 errmsg ("missing mac address");
6861 errmsg ("missing bridge domain");
6865 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6867 errmsg ("missing interface name or sw_if_index");
6873 /* Turn on async mode */
6874 vam->async_mode = 1;
6875 vam->async_errors = 0;
6876 before = vat_time_now (vam);
6879 for (j = 0; j < count; j++)
6881 M (L2FIB_ADD_DEL, mp);
6883 clib_memcpy (mp->mac, mac, 6);
6884 mp->bd_id = ntohl (bd_id);
6885 mp->is_add = is_add;
6886 mp->sw_if_index = ntohl (sw_if_index);
6890 mp->static_mac = static_mac;
6891 mp->filter_mac = filter_mac;
6892 mp->bvi_mac = bvi_mac;
6894 increment_mac_address (mac);
6901 vl_api_control_ping_t *mp_ping;
6904 /* Shut off async mode */
6905 vam->async_mode = 0;
6907 MPING (CONTROL_PING, mp_ping);
6910 timeout = vat_time_now (vam) + 1.0;
6911 while (vat_time_now (vam) < timeout)
6912 if (vam->result_ready == 1)
6917 if (vam->retval == -99)
6920 if (vam->async_errors > 0)
6922 errmsg ("%d asynchronous errors", vam->async_errors);
6925 vam->async_errors = 0;
6926 after = vat_time_now (vam);
6928 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6929 count, after - before, count / (after - before));
6935 /* Wait for a reply... */
6939 /* Return the good/bad news */
6940 return (vam->retval);
6944 api_bridge_domain_set_mac_age (vat_main_t * vam)
6946 unformat_input_t *i = vam->input;
6947 vl_api_bridge_domain_set_mac_age_t *mp;
6952 /* Parse args required to build the message */
6953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6955 if (unformat (i, "bd_id %d", &bd_id));
6956 else if (unformat (i, "mac-age %d", &mac_age));
6963 errmsg ("missing bridge domain");
6969 errmsg ("mac age must be less than 256 ");
6973 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6975 mp->bd_id = htonl (bd_id);
6976 mp->mac_age = (u8) mac_age;
6984 api_l2_flags (vat_main_t * vam)
6986 unformat_input_t *i = vam->input;
6987 vl_api_l2_flags_t *mp;
6990 u8 sw_if_index_set = 0;
6994 /* Parse args required to build the message */
6995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6997 if (unformat (i, "sw_if_index %d", &sw_if_index))
6998 sw_if_index_set = 1;
6999 else if (unformat (i, "sw_if"))
7001 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7004 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7005 sw_if_index_set = 1;
7010 else if (unformat (i, "learn"))
7012 else if (unformat (i, "forward"))
7014 else if (unformat (i, "flood"))
7016 else if (unformat (i, "uu-flood"))
7017 flags |= L2_UU_FLOOD;
7018 else if (unformat (i, "arp-term"))
7019 flags |= L2_ARP_TERM;
7020 else if (unformat (i, "off"))
7022 else if (unformat (i, "disable"))
7028 if (sw_if_index_set == 0)
7030 errmsg ("missing interface name or sw_if_index");
7036 mp->sw_if_index = ntohl (sw_if_index);
7037 mp->feature_bitmap = ntohl (flags);
7038 mp->is_set = is_set;
7046 api_bridge_flags (vat_main_t * vam)
7048 unformat_input_t *i = vam->input;
7049 vl_api_bridge_flags_t *mp;
7053 bd_flags_t flags = 0;
7056 /* Parse args required to build the message */
7057 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7059 if (unformat (i, "bd_id %d", &bd_id))
7061 else if (unformat (i, "learn"))
7062 flags |= BRIDGE_API_FLAG_LEARN;
7063 else if (unformat (i, "forward"))
7064 flags |= BRIDGE_API_FLAG_FWD;
7065 else if (unformat (i, "flood"))
7066 flags |= BRIDGE_API_FLAG_FLOOD;
7067 else if (unformat (i, "uu-flood"))
7068 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7069 else if (unformat (i, "arp-term"))
7070 flags |= BRIDGE_API_FLAG_ARP_TERM;
7071 else if (unformat (i, "off"))
7073 else if (unformat (i, "disable"))
7081 errmsg ("missing bridge domain");
7085 M (BRIDGE_FLAGS, mp);
7087 mp->bd_id = ntohl (bd_id);
7088 mp->flags = ntohl (flags);
7089 mp->is_set = is_set;
7097 api_bd_ip_mac_add_del (vat_main_t * vam)
7099 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7100 vl_api_mac_address_t mac = { 0 };
7101 unformat_input_t *i = vam->input;
7102 vl_api_bd_ip_mac_add_del_t *mp;
7111 /* Parse args required to build the message */
7112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7114 if (unformat (i, "bd_id %d", &bd_id))
7118 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7122 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7126 else if (unformat (i, "del"))
7134 errmsg ("missing bridge domain");
7137 else if (ip_set == 0)
7139 errmsg ("missing IP address");
7142 else if (mac_set == 0)
7144 errmsg ("missing MAC address");
7148 M (BD_IP_MAC_ADD_DEL, mp);
7150 mp->entry.bd_id = ntohl (bd_id);
7151 mp->is_add = is_add;
7153 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7154 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7162 api_bd_ip_mac_flush (vat_main_t * vam)
7164 unformat_input_t *i = vam->input;
7165 vl_api_bd_ip_mac_flush_t *mp;
7170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7172 if (unformat (i, "bd_id %d", &bd_id))
7182 errmsg ("missing bridge domain");
7186 M (BD_IP_MAC_FLUSH, mp);
7188 mp->bd_id = ntohl (bd_id);
7195 static void vl_api_bd_ip_mac_details_t_handler
7196 (vl_api_bd_ip_mac_details_t * mp)
7198 vat_main_t *vam = &vat_main;
7202 ntohl (mp->entry.bd_id),
7203 format_vl_api_mac_address, mp->entry.mac,
7204 format_vl_api_address, &mp->entry.ip);
7207 static void vl_api_bd_ip_mac_details_t_handler_json
7208 (vl_api_bd_ip_mac_details_t * mp)
7210 vat_main_t *vam = &vat_main;
7211 vat_json_node_t *node = NULL;
7213 if (VAT_JSON_ARRAY != vam->json_tree.type)
7215 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7216 vat_json_init_array (&vam->json_tree);
7218 node = vat_json_array_add (&vam->json_tree);
7220 vat_json_init_object (node);
7221 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7222 vat_json_object_add_string_copy (node, "mac_address",
7223 format (0, "%U", format_vl_api_mac_address,
7227 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7228 vat_json_object_add_string_copy (node, "ip_address", ip);
7233 api_bd_ip_mac_dump (vat_main_t * vam)
7235 unformat_input_t *i = vam->input;
7236 vl_api_bd_ip_mac_dump_t *mp;
7237 vl_api_control_ping_t *mp_ping;
7242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7244 if (unformat (i, "bd_id %d", &bd_id))
7253 "\n%-5s %-7s %-20s %-30s",
7254 "bd_id", "is_ipv6", "mac_address", "ip_address");
7256 /* Dump Bridge Domain Ip to Mac entries */
7257 M (BD_IP_MAC_DUMP, mp);
7260 mp->bd_id = htonl (bd_id);
7266 /* Use a control ping for synchronization */
7267 MPING (CONTROL_PING, mp_ping);
7275 api_tap_create_v2 (vat_main_t * vam)
7277 unformat_input_t *i = vam->input;
7278 vl_api_tap_create_v2_t *mp;
7279 #define TAP_FLAG_GSO (1 << 0)
7283 u8 *host_if_name = 0;
7285 u8 host_mac_addr[6];
7286 u8 host_mac_addr_set = 0;
7287 u8 *host_bridge = 0;
7288 ip4_address_t host_ip4_addr;
7289 ip4_address_t host_ip4_gw;
7290 u8 host_ip4_gw_set = 0;
7291 u32 host_ip4_prefix_len = 0;
7292 ip6_address_t host_ip6_addr;
7293 ip6_address_t host_ip6_gw;
7294 u8 host_ip6_gw_set = 0;
7295 u32 host_ip6_prefix_len = 0;
7296 u8 host_mtu_set = 0;
7297 u32 host_mtu_size = 0;
7300 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7302 clib_memset (mac_address, 0, sizeof (mac_address));
7304 /* Parse args required to build the message */
7305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7307 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7311 else if (unformat (i, "id %u", &id))
7313 else if (unformat (i, "host-if-name %s", &host_if_name))
7315 else if (unformat (i, "host-ns %s", &host_ns))
7317 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7319 host_mac_addr_set = 1;
7320 else if (unformat (i, "host-bridge %s", &host_bridge))
7322 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7323 &host_ip4_addr, &host_ip4_prefix_len))
7325 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7326 &host_ip6_addr, &host_ip6_prefix_len))
7328 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7330 host_ip4_gw_set = 1;
7331 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7333 host_ip6_gw_set = 1;
7334 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7336 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7338 else if (unformat (i, "host-mtu-size %d", &host_mtu_size))
7340 else if (unformat (i, "no-gso"))
7341 tap_flags &= ~TAP_FLAG_GSO;
7342 else if (unformat (i, "gso"))
7343 tap_flags |= TAP_FLAG_GSO;
7348 if (vec_len (host_if_name) > 63)
7350 errmsg ("tap name too long. ");
7353 if (vec_len (host_ns) > 63)
7355 errmsg ("host name space too long. ");
7358 if (vec_len (host_bridge) > 63)
7360 errmsg ("host bridge name too long. ");
7363 if (host_ip4_prefix_len > 32)
7365 errmsg ("host ip4 prefix length not valid. ");
7368 if (host_ip6_prefix_len > 128)
7370 errmsg ("host ip6 prefix length not valid. ");
7373 if (!is_pow2 (rx_ring_sz))
7375 errmsg ("rx ring size must be power of 2. ");
7378 if (rx_ring_sz > 32768)
7380 errmsg ("rx ring size must be 32768 or lower. ");
7383 if (!is_pow2 (tx_ring_sz))
7385 errmsg ("tx ring size must be power of 2. ");
7388 if (tx_ring_sz > 32768)
7390 errmsg ("tx ring size must be 32768 or lower. ");
7393 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7395 errmsg ("host MTU size must be in between 64 and 65355. ");
7399 /* Construct the API message */
7400 M (TAP_CREATE_V2, mp);
7402 mp->use_random_mac = random_mac;
7404 mp->id = ntohl (id);
7405 mp->host_namespace_set = host_ns != 0;
7406 mp->host_bridge_set = host_bridge != 0;
7407 mp->host_ip4_prefix_set = host_ip4_prefix_len != 0;
7408 mp->host_ip6_prefix_set = host_ip6_prefix_len != 0;
7409 mp->rx_ring_sz = ntohs (rx_ring_sz);
7410 mp->tx_ring_sz = ntohs (tx_ring_sz);
7411 mp->host_mtu_set = host_mtu_set;
7412 mp->host_mtu_size = ntohl (host_mtu_size);
7413 mp->tap_flags = ntohl (tap_flags);
7415 if (random_mac == 0)
7416 clib_memcpy (mp->mac_address, mac_address, 6);
7417 if (host_mac_addr_set)
7418 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7420 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7422 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7424 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7425 if (host_ip4_prefix_len)
7426 clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
7427 if (host_ip6_prefix_len)
7428 clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
7429 if (host_ip4_gw_set)
7430 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7431 if (host_ip6_gw_set)
7432 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7435 vec_free (host_if_name);
7436 vec_free (host_bridge);
7441 /* Wait for a reply... */
7447 api_tap_delete_v2 (vat_main_t * vam)
7449 unformat_input_t *i = vam->input;
7450 vl_api_tap_delete_v2_t *mp;
7451 u32 sw_if_index = ~0;
7452 u8 sw_if_index_set = 0;
7455 /* Parse args required to build the message */
7456 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7458 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7459 sw_if_index_set = 1;
7460 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7461 sw_if_index_set = 1;
7466 if (sw_if_index_set == 0)
7468 errmsg ("missing vpp interface name. ");
7472 /* Construct the API message */
7473 M (TAP_DELETE_V2, mp);
7475 mp->sw_if_index = ntohl (sw_if_index);
7480 /* Wait for a reply... */
7486 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7488 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7491 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7494 addr->domain = x[0];
7497 addr->function = x[3];
7503 api_virtio_pci_create (vat_main_t * vam)
7505 unformat_input_t *i = vam->input;
7506 vl_api_virtio_pci_create_t *mp;
7511 u64 features = (u64) ~ (0ULL);
7514 clib_memset (mac_address, 0, sizeof (mac_address));
7516 /* Parse args required to build the message */
7517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7519 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7523 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7525 else if (unformat (i, "features 0x%llx", &features))
7527 else if (unformat (i, "gso-enabled"))
7535 errmsg ("pci address must be non zero. ");
7539 /* Construct the API message */
7540 M (VIRTIO_PCI_CREATE, mp);
7542 mp->use_random_mac = random_mac;
7544 mp->pci_addr.domain = htons (((vlib_pci_addr_t) pci_addr).domain);
7545 mp->pci_addr.bus = ((vlib_pci_addr_t) pci_addr).bus;
7546 mp->pci_addr.slot = ((vlib_pci_addr_t) pci_addr).slot;
7547 mp->pci_addr.function = ((vlib_pci_addr_t) pci_addr).function;
7549 mp->features = clib_host_to_net_u64 (features);
7550 mp->gso_enabled = gso_enabled;
7552 if (random_mac == 0)
7553 clib_memcpy (mp->mac_address, mac_address, 6);
7558 /* Wait for a reply... */
7564 api_virtio_pci_delete (vat_main_t * vam)
7566 unformat_input_t *i = vam->input;
7567 vl_api_virtio_pci_delete_t *mp;
7568 u32 sw_if_index = ~0;
7569 u8 sw_if_index_set = 0;
7572 /* Parse args required to build the message */
7573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7575 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7576 sw_if_index_set = 1;
7577 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7578 sw_if_index_set = 1;
7583 if (sw_if_index_set == 0)
7585 errmsg ("missing vpp interface name. ");
7589 /* Construct the API message */
7590 M (VIRTIO_PCI_DELETE, mp);
7592 mp->sw_if_index = htonl (sw_if_index);
7597 /* Wait for a reply... */
7603 api_bond_create (vat_main_t * vam)
7605 unformat_input_t *i = vam->input;
7606 vl_api_bond_create_t *mp;
7616 clib_memset (mac_address, 0, sizeof (mac_address));
7619 /* Parse args required to build the message */
7620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7622 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7624 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7625 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7627 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7630 else if (unformat (i, "numa-only"))
7632 else if (unformat (i, "id %u", &id))
7638 if (mode_is_set == 0)
7640 errmsg ("Missing bond mode. ");
7644 /* Construct the API message */
7645 M (BOND_CREATE, mp);
7647 mp->use_custom_mac = custom_mac;
7649 mp->mode = htonl (mode);
7650 mp->lb = htonl (lb);
7651 mp->id = htonl (id);
7652 mp->numa_only = numa_only;
7655 clib_memcpy (mp->mac_address, mac_address, 6);
7660 /* Wait for a reply... */
7666 api_bond_delete (vat_main_t * vam)
7668 unformat_input_t *i = vam->input;
7669 vl_api_bond_delete_t *mp;
7670 u32 sw_if_index = ~0;
7671 u8 sw_if_index_set = 0;
7674 /* Parse args required to build the message */
7675 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7677 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7678 sw_if_index_set = 1;
7679 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7680 sw_if_index_set = 1;
7685 if (sw_if_index_set == 0)
7687 errmsg ("missing vpp interface name. ");
7691 /* Construct the API message */
7692 M (BOND_DELETE, mp);
7694 mp->sw_if_index = ntohl (sw_if_index);
7699 /* Wait for a reply... */
7705 api_bond_enslave (vat_main_t * vam)
7707 unformat_input_t *i = vam->input;
7708 vl_api_bond_enslave_t *mp;
7709 u32 bond_sw_if_index;
7713 u32 bond_sw_if_index_is_set = 0;
7715 u8 sw_if_index_is_set = 0;
7717 /* Parse args required to build the message */
7718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7720 if (unformat (i, "sw_if_index %d", &sw_if_index))
7721 sw_if_index_is_set = 1;
7722 else if (unformat (i, "bond %u", &bond_sw_if_index))
7723 bond_sw_if_index_is_set = 1;
7724 else if (unformat (i, "passive %d", &is_passive))
7726 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7732 if (bond_sw_if_index_is_set == 0)
7734 errmsg ("Missing bond sw_if_index. ");
7737 if (sw_if_index_is_set == 0)
7739 errmsg ("Missing slave sw_if_index. ");
7743 /* Construct the API message */
7744 M (BOND_ENSLAVE, mp);
7746 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7747 mp->sw_if_index = ntohl (sw_if_index);
7748 mp->is_long_timeout = is_long_timeout;
7749 mp->is_passive = is_passive;
7754 /* Wait for a reply... */
7760 api_bond_detach_slave (vat_main_t * vam)
7762 unformat_input_t *i = vam->input;
7763 vl_api_bond_detach_slave_t *mp;
7764 u32 sw_if_index = ~0;
7765 u8 sw_if_index_set = 0;
7768 /* Parse args required to build the message */
7769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7771 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7772 sw_if_index_set = 1;
7773 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7774 sw_if_index_set = 1;
7779 if (sw_if_index_set == 0)
7781 errmsg ("missing vpp interface name. ");
7785 /* Construct the API message */
7786 M (BOND_DETACH_SLAVE, mp);
7788 mp->sw_if_index = ntohl (sw_if_index);
7793 /* Wait for a reply... */
7799 api_ip_table_add_del (vat_main_t * vam)
7801 unformat_input_t *i = vam->input;
7802 vl_api_ip_table_add_del_t *mp;
7808 /* Parse args required to build the message */
7809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7811 if (unformat (i, "ipv6"))
7813 else if (unformat (i, "del"))
7815 else if (unformat (i, "add"))
7817 else if (unformat (i, "table %d", &table_id))
7821 clib_warning ("parse error '%U'", format_unformat_error, i);
7828 errmsg ("missing table-ID");
7832 /* Construct the API message */
7833 M (IP_TABLE_ADD_DEL, mp);
7835 mp->table.table_id = ntohl (table_id);
7836 mp->table.is_ip6 = is_ipv6;
7837 mp->is_add = is_add;
7842 /* Wait for a reply... */
7849 unformat_fib_path (unformat_input_t * input, va_list * args)
7851 vat_main_t *vam = va_arg (*args, vat_main_t *);
7852 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7853 u32 weight, preference;
7854 mpls_label_t out_label;
7856 clib_memset (path, 0, sizeof (*path));
7858 path->sw_if_index = ~0;
7862 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7864 if (unformat (input, "%U %U",
7865 unformat_vl_api_ip4_address,
7866 &path->nh.address.ip4,
7867 api_unformat_sw_if_index, vam, &path->sw_if_index))
7869 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7871 else if (unformat (input, "%U %U",
7872 unformat_vl_api_ip6_address,
7873 &path->nh.address.ip6,
7874 api_unformat_sw_if_index, vam, &path->sw_if_index))
7876 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7878 else if (unformat (input, "weight %u", &weight))
7880 path->weight = weight;
7882 else if (unformat (input, "preference %u", &preference))
7884 path->preference = preference;
7886 else if (unformat (input, "%U next-hop-table %d",
7887 unformat_vl_api_ip4_address,
7888 &path->nh.address.ip4, &path->table_id))
7890 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7892 else if (unformat (input, "%U next-hop-table %d",
7893 unformat_vl_api_ip6_address,
7894 &path->nh.address.ip6, &path->table_id))
7896 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7898 else if (unformat (input, "%U",
7899 unformat_vl_api_ip4_address, &path->nh.address.ip4))
7902 * the recursive next-hops are by default in the default table
7905 path->sw_if_index = ~0;
7906 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7908 else if (unformat (input, "%U",
7909 unformat_vl_api_ip6_address, &path->nh.address.ip6))
7912 * the recursive next-hops are by default in the default table
7915 path->sw_if_index = ~0;
7916 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7918 else if (unformat (input, "resolve-via-host"))
7920 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
7922 else if (unformat (input, "resolve-via-attached"))
7924 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
7926 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
7928 path->type = FIB_API_PATH_TYPE_LOCAL;
7929 path->sw_if_index = ~0;
7930 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7932 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
7934 path->type = FIB_API_PATH_TYPE_LOCAL;
7935 path->sw_if_index = ~0;
7936 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7938 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
7940 else if (unformat (input, "via-label %d", &path->nh.via_label))
7942 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
7943 path->sw_if_index = ~0;
7945 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
7947 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
7948 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
7950 else if (unformat (input, "local"))
7952 path->type = FIB_API_PATH_TYPE_LOCAL;
7954 else if (unformat (input, "out-labels"))
7956 while (unformat (input, "%d", &out_label))
7958 path->label_stack[path->n_labels].label = out_label;
7959 path->label_stack[path->n_labels].is_uniform = 0;
7960 path->label_stack[path->n_labels].ttl = 64;
7964 else if (unformat (input, "via"))
7966 /* new path, back up and return */
7967 unformat_put_input (input);
7968 unformat_put_input (input);
7969 unformat_put_input (input);
7970 unformat_put_input (input);
7979 path->proto = ntohl (path->proto);
7980 path->type = ntohl (path->type);
7981 path->flags = ntohl (path->flags);
7982 path->table_id = ntohl (path->table_id);
7983 path->sw_if_index = ntohl (path->sw_if_index);
7989 api_ip_route_add_del (vat_main_t * vam)
7991 unformat_input_t *i = vam->input;
7992 vl_api_ip_route_add_del_t *mp;
7995 u8 is_multipath = 0;
7998 vl_api_prefix_t pfx = { };
7999 vl_api_fib_path_t paths[8];
8003 u32 random_add_del = 0;
8004 u32 *random_vector = 0;
8005 u32 random_seed = 0xdeaddabe;
8007 /* Parse args required to build the message */
8008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8010 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8012 else if (unformat (i, "del"))
8014 else if (unformat (i, "add"))
8016 else if (unformat (i, "vrf %d", &vrf_id))
8018 else if (unformat (i, "count %d", &count))
8020 else if (unformat (i, "random"))
8022 else if (unformat (i, "multipath"))
8024 else if (unformat (i, "seed %d", &random_seed))
8028 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8031 if (8 == path_count)
8033 errmsg ("max 8 paths");
8039 clib_warning ("parse error '%U'", format_unformat_error, i);
8046 errmsg ("specify a path; via ...");
8049 if (prefix_set == 0)
8051 errmsg ("missing prefix");
8055 /* Generate a pile of unique, random routes */
8058 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8059 u32 this_random_address;
8062 random_hash = hash_create (count, sizeof (uword));
8064 hash_set (random_hash, i->as_u32, 1);
8065 for (j = 0; j <= count; j++)
8069 this_random_address = random_u32 (&random_seed);
8070 this_random_address =
8071 clib_host_to_net_u32 (this_random_address);
8073 while (hash_get (random_hash, this_random_address));
8074 vec_add1 (random_vector, this_random_address);
8075 hash_set (random_hash, this_random_address, 1);
8077 hash_free (random_hash);
8078 set_ip4_address (&pfx.address, random_vector[0]);
8083 /* Turn on async mode */
8084 vam->async_mode = 1;
8085 vam->async_errors = 0;
8086 before = vat_time_now (vam);
8089 for (j = 0; j < count; j++)
8091 /* Construct the API message */
8092 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8094 mp->is_add = is_add;
8095 mp->is_multipath = is_multipath;
8097 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8098 mp->route.table_id = ntohl (vrf_id);
8099 mp->route.n_paths = path_count;
8101 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8104 set_ip4_address (&pfx.address, random_vector[j + 1]);
8106 increment_address (&pfx.address);
8109 /* If we receive SIGTERM, stop now... */
8114 /* When testing multiple add/del ops, use a control-ping to sync */
8117 vl_api_control_ping_t *mp_ping;
8121 /* Shut off async mode */
8122 vam->async_mode = 0;
8124 MPING (CONTROL_PING, mp_ping);
8127 timeout = vat_time_now (vam) + 1.0;
8128 while (vat_time_now (vam) < timeout)
8129 if (vam->result_ready == 1)
8134 if (vam->retval == -99)
8137 if (vam->async_errors > 0)
8139 errmsg ("%d asynchronous errors", vam->async_errors);
8142 vam->async_errors = 0;
8143 after = vat_time_now (vam);
8145 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8149 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8150 count, after - before, count / (after - before));
8156 /* Wait for a reply... */
8161 /* Return the good/bad news */
8162 return (vam->retval);
8166 api_ip_mroute_add_del (vat_main_t * vam)
8168 unformat_input_t *i = vam->input;
8169 u8 path_set = 0, prefix_set = 0, is_add = 1;
8170 vl_api_ip_mroute_add_del_t *mp;
8171 mfib_entry_flags_t eflags = 0;
8172 vl_api_mfib_path_t path;
8173 vl_api_mprefix_t pfx = { };
8177 /* Parse args required to build the message */
8178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8180 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8183 pfx.grp_address_length = htons (pfx.grp_address_length);
8185 else if (unformat (i, "del"))
8187 else if (unformat (i, "add"))
8189 else if (unformat (i, "vrf %d", &vrf_id))
8191 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8192 path.itf_flags = htonl (path.itf_flags);
8193 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8195 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8199 clib_warning ("parse error '%U'", format_unformat_error, i);
8204 if (prefix_set == 0)
8206 errmsg ("missing addresses\n");
8211 errmsg ("missing path\n");
8215 /* Construct the API message */
8216 M (IP_MROUTE_ADD_DEL, mp);
8218 mp->is_add = is_add;
8219 mp->is_multipath = 1;
8221 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8222 mp->route.table_id = htonl (vrf_id);
8223 mp->route.n_paths = 1;
8224 mp->route.entry_flags = htonl (eflags);
8226 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8230 /* Wait for a reply... */
8236 api_mpls_table_add_del (vat_main_t * vam)
8238 unformat_input_t *i = vam->input;
8239 vl_api_mpls_table_add_del_t *mp;
8244 /* Parse args required to build the message */
8245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8247 if (unformat (i, "table %d", &table_id))
8249 else if (unformat (i, "del"))
8251 else if (unformat (i, "add"))
8255 clib_warning ("parse error '%U'", format_unformat_error, i);
8262 errmsg ("missing table-ID");
8266 /* Construct the API message */
8267 M (MPLS_TABLE_ADD_DEL, mp);
8269 mp->mt_table.mt_table_id = ntohl (table_id);
8270 mp->mt_is_add = is_add;
8275 /* Wait for a reply... */
8282 api_mpls_route_add_del (vat_main_t * vam)
8284 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8285 mpls_label_t local_label = MPLS_LABEL_INVALID;
8286 unformat_input_t *i = vam->input;
8287 vl_api_mpls_route_add_del_t *mp;
8288 vl_api_fib_path_t paths[8];
8292 /* Parse args required to build the message */
8293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8295 if (unformat (i, "%d", &local_label))
8297 else if (unformat (i, "eos"))
8299 else if (unformat (i, "non-eos"))
8301 else if (unformat (i, "del"))
8303 else if (unformat (i, "add"))
8305 else if (unformat (i, "multipath"))
8307 else if (unformat (i, "count %d", &count))
8311 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8314 if (8 == path_count)
8316 errmsg ("max 8 paths");
8322 clib_warning ("parse error '%U'", format_unformat_error, i);
8329 errmsg ("specify a path; via ...");
8333 if (MPLS_LABEL_INVALID == local_label)
8335 errmsg ("missing label");
8341 /* Turn on async mode */
8342 vam->async_mode = 1;
8343 vam->async_errors = 0;
8344 before = vat_time_now (vam);
8347 for (j = 0; j < count; j++)
8349 /* Construct the API message */
8350 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8352 mp->mr_is_add = is_add;
8353 mp->mr_is_multipath = is_multipath;
8355 mp->mr_route.mr_label = local_label;
8356 mp->mr_route.mr_eos = is_eos;
8357 mp->mr_route.mr_table_id = 0;
8358 mp->mr_route.mr_n_paths = path_count;
8360 clib_memcpy (&mp->mr_route.mr_paths, paths,
8361 sizeof (paths[0]) * path_count);
8367 /* If we receive SIGTERM, stop now... */
8372 /* When testing multiple add/del ops, use a control-ping to sync */
8375 vl_api_control_ping_t *mp_ping;
8379 /* Shut off async mode */
8380 vam->async_mode = 0;
8382 MPING (CONTROL_PING, mp_ping);
8385 timeout = vat_time_now (vam) + 1.0;
8386 while (vat_time_now (vam) < timeout)
8387 if (vam->result_ready == 1)
8392 if (vam->retval == -99)
8395 if (vam->async_errors > 0)
8397 errmsg ("%d asynchronous errors", vam->async_errors);
8400 vam->async_errors = 0;
8401 after = vat_time_now (vam);
8403 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8407 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8408 count, after - before, count / (after - before));
8414 /* Wait for a reply... */
8419 /* Return the good/bad news */
8420 return (vam->retval);
8425 api_mpls_ip_bind_unbind (vat_main_t * vam)
8427 unformat_input_t *i = vam->input;
8428 vl_api_mpls_ip_bind_unbind_t *mp;
8429 u32 ip_table_id = 0;
8431 vl_api_prefix_t pfx;
8433 mpls_label_t local_label = MPLS_LABEL_INVALID;
8436 /* Parse args required to build the message */
8437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8439 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8441 else if (unformat (i, "%d", &local_label))
8443 else if (unformat (i, "table-id %d", &ip_table_id))
8445 else if (unformat (i, "unbind"))
8447 else if (unformat (i, "bind"))
8451 clib_warning ("parse error '%U'", format_unformat_error, i);
8458 errmsg ("IP prefix not set");
8462 if (MPLS_LABEL_INVALID == local_label)
8464 errmsg ("missing label");
8468 /* Construct the API message */
8469 M (MPLS_IP_BIND_UNBIND, mp);
8471 mp->mb_is_bind = is_bind;
8472 mp->mb_ip_table_id = ntohl (ip_table_id);
8473 mp->mb_mpls_table_id = 0;
8474 mp->mb_label = ntohl (local_label);
8475 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8480 /* Wait for a reply... */
8487 api_sr_mpls_policy_add (vat_main_t * vam)
8489 unformat_input_t *i = vam->input;
8490 vl_api_sr_mpls_policy_add_t *mp;
8496 u32 *segments = NULL;
8499 /* Parse args required to build the message */
8500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8502 if (unformat (i, "bsid %d", &bsid))
8504 else if (unformat (i, "weight %d", &weight))
8506 else if (unformat (i, "spray"))
8508 else if (unformat (i, "next %d", &sid))
8511 vec_add1 (segments, htonl (sid));
8515 clib_warning ("parse error '%U'", format_unformat_error, i);
8522 errmsg ("bsid not set");
8526 if (n_segments == 0)
8528 errmsg ("no sid in segment stack");
8532 /* Construct the API message */
8533 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8535 mp->bsid = htonl (bsid);
8536 mp->weight = htonl (weight);
8538 mp->n_segments = n_segments;
8539 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8540 vec_free (segments);
8545 /* Wait for a reply... */
8551 api_sr_mpls_policy_del (vat_main_t * vam)
8553 unformat_input_t *i = vam->input;
8554 vl_api_sr_mpls_policy_del_t *mp;
8558 /* Parse args required to build the message */
8559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8561 if (unformat (i, "bsid %d", &bsid))
8565 clib_warning ("parse error '%U'", format_unformat_error, i);
8572 errmsg ("bsid not set");
8576 /* Construct the API message */
8577 M (SR_MPLS_POLICY_DEL, mp);
8579 mp->bsid = htonl (bsid);
8584 /* Wait for a reply... */
8590 api_bier_table_add_del (vat_main_t * vam)
8592 unformat_input_t *i = vam->input;
8593 vl_api_bier_table_add_del_t *mp;
8595 u32 set = 0, sub_domain = 0, hdr_len = 3;
8596 mpls_label_t local_label = MPLS_LABEL_INVALID;
8599 /* Parse args required to build the message */
8600 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8602 if (unformat (i, "sub-domain %d", &sub_domain))
8604 else if (unformat (i, "set %d", &set))
8606 else if (unformat (i, "label %d", &local_label))
8608 else if (unformat (i, "hdr-len %d", &hdr_len))
8610 else if (unformat (i, "add"))
8612 else if (unformat (i, "del"))
8616 clib_warning ("parse error '%U'", format_unformat_error, i);
8621 if (MPLS_LABEL_INVALID == local_label)
8623 errmsg ("missing label\n");
8627 /* Construct the API message */
8628 M (BIER_TABLE_ADD_DEL, mp);
8630 mp->bt_is_add = is_add;
8631 mp->bt_label = ntohl (local_label);
8632 mp->bt_tbl_id.bt_set = set;
8633 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8634 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8639 /* Wait for a reply... */
8646 api_bier_route_add_del (vat_main_t * vam)
8648 unformat_input_t *i = vam->input;
8649 vl_api_bier_route_add_del_t *mp;
8651 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8652 ip4_address_t v4_next_hop_address;
8653 ip6_address_t v6_next_hop_address;
8654 u8 next_hop_set = 0;
8655 u8 next_hop_proto_is_ip4 = 1;
8656 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8659 /* Parse args required to build the message */
8660 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8662 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8664 next_hop_proto_is_ip4 = 1;
8667 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8669 next_hop_proto_is_ip4 = 0;
8672 if (unformat (i, "sub-domain %d", &sub_domain))
8674 else if (unformat (i, "set %d", &set))
8676 else if (unformat (i, "hdr-len %d", &hdr_len))
8678 else if (unformat (i, "bp %d", &bp))
8680 else if (unformat (i, "add"))
8682 else if (unformat (i, "del"))
8684 else if (unformat (i, "out-label %d", &next_hop_out_label))
8688 clib_warning ("parse error '%U'", format_unformat_error, i);
8693 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8695 errmsg ("next hop / label set\n");
8700 errmsg ("bit=position not set\n");
8704 /* Construct the API message */
8705 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8707 mp->br_is_add = is_add;
8708 mp->br_route.br_tbl_id.bt_set = set;
8709 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8710 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8711 mp->br_route.br_bp = ntohs (bp);
8712 mp->br_route.br_n_paths = 1;
8713 mp->br_route.br_paths[0].n_labels = 1;
8714 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8715 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8716 FIB_API_PATH_NH_PROTO_IP4 :
8717 FIB_API_PATH_NH_PROTO_IP6);
8719 if (next_hop_proto_is_ip4)
8721 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8722 &v4_next_hop_address, sizeof (v4_next_hop_address));
8726 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8727 &v6_next_hop_address, sizeof (v6_next_hop_address));
8733 /* Wait for a reply... */
8740 api_mpls_tunnel_add_del (vat_main_t * vam)
8742 unformat_input_t *i = vam->input;
8743 vl_api_mpls_tunnel_add_del_t *mp;
8745 vl_api_fib_path_t paths[8];
8746 u32 sw_if_index = ~0;
8752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8754 if (unformat (i, "add"))
8758 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8760 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8762 else if (unformat (i, "l2-only"))
8766 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8769 if (8 == path_count)
8771 errmsg ("max 8 paths");
8777 clib_warning ("parse error '%U'", format_unformat_error, i);
8782 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8784 mp->mt_is_add = is_add;
8785 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8786 mp->mt_tunnel.mt_l2_only = l2_only;
8787 mp->mt_tunnel.mt_is_multicast = 0;
8788 mp->mt_tunnel.mt_n_paths = path_count;
8790 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8791 sizeof (paths[0]) * path_count);
8799 api_sw_interface_set_unnumbered (vat_main_t * vam)
8801 unformat_input_t *i = vam->input;
8802 vl_api_sw_interface_set_unnumbered_t *mp;
8804 u32 unnum_sw_index = ~0;
8806 u8 sw_if_index_set = 0;
8809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8811 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8812 sw_if_index_set = 1;
8813 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8814 sw_if_index_set = 1;
8815 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8817 else if (unformat (i, "del"))
8821 clib_warning ("parse error '%U'", format_unformat_error, i);
8826 if (sw_if_index_set == 0)
8828 errmsg ("missing interface name or sw_if_index");
8832 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8834 mp->sw_if_index = ntohl (sw_if_index);
8835 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8836 mp->is_add = is_add;
8845 api_create_vlan_subif (vat_main_t * vam)
8847 unformat_input_t *i = vam->input;
8848 vl_api_create_vlan_subif_t *mp;
8850 u8 sw_if_index_set = 0;
8855 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8857 if (unformat (i, "sw_if_index %d", &sw_if_index))
8858 sw_if_index_set = 1;
8860 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8861 sw_if_index_set = 1;
8862 else if (unformat (i, "vlan %d", &vlan_id))
8866 clib_warning ("parse error '%U'", format_unformat_error, i);
8871 if (sw_if_index_set == 0)
8873 errmsg ("missing interface name or sw_if_index");
8877 if (vlan_id_set == 0)
8879 errmsg ("missing vlan_id");
8882 M (CREATE_VLAN_SUBIF, mp);
8884 mp->sw_if_index = ntohl (sw_if_index);
8885 mp->vlan_id = ntohl (vlan_id);
8892 #define foreach_create_subif_bit \
8899 _(outer_vlan_id_any) \
8900 _(inner_vlan_id_any)
8902 #define foreach_create_subif_flag \
8907 _(4, "exact_match") \
8908 _(5, "default_sub") \
8909 _(6, "outer_vlan_id_any") \
8910 _(7, "inner_vlan_id_any")
8913 api_create_subif (vat_main_t * vam)
8915 unformat_input_t *i = vam->input;
8916 vl_api_create_subif_t *mp;
8918 u8 sw_if_index_set = 0;
8921 u32 __attribute__ ((unused)) no_tags = 0;
8922 u32 __attribute__ ((unused)) one_tag = 0;
8923 u32 __attribute__ ((unused)) two_tags = 0;
8924 u32 __attribute__ ((unused)) dot1ad = 0;
8925 u32 __attribute__ ((unused)) exact_match = 0;
8926 u32 __attribute__ ((unused)) default_sub = 0;
8927 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
8928 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
8930 u16 outer_vlan_id = 0;
8931 u16 inner_vlan_id = 0;
8934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8936 if (unformat (i, "sw_if_index %d", &sw_if_index))
8937 sw_if_index_set = 1;
8939 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8940 sw_if_index_set = 1;
8941 else if (unformat (i, "sub_id %d", &sub_id))
8943 else if (unformat (i, "outer_vlan_id %d", &tmp))
8944 outer_vlan_id = tmp;
8945 else if (unformat (i, "inner_vlan_id %d", &tmp))
8946 inner_vlan_id = tmp;
8948 #define _(a) else if (unformat (i, #a)) a = 1 ;
8949 foreach_create_subif_bit
8953 clib_warning ("parse error '%U'", format_unformat_error, i);
8958 if (sw_if_index_set == 0)
8960 errmsg ("missing interface name or sw_if_index");
8964 if (sub_id_set == 0)
8966 errmsg ("missing sub_id");
8969 M (CREATE_SUBIF, mp);
8971 mp->sw_if_index = ntohl (sw_if_index);
8972 mp->sub_id = ntohl (sub_id);
8974 #define _(a,b) mp->sub_if_flags |= (1 << a);
8975 foreach_create_subif_flag;
8978 mp->outer_vlan_id = ntohs (outer_vlan_id);
8979 mp->inner_vlan_id = ntohs (inner_vlan_id);
8987 api_ip_table_replace_begin (vat_main_t * vam)
8989 unformat_input_t *i = vam->input;
8990 vl_api_ip_table_replace_begin_t *mp;
8995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8997 if (unformat (i, "table %d", &table_id))
8999 else if (unformat (i, "ipv6"))
9003 clib_warning ("parse error '%U'", format_unformat_error, i);
9008 M (IP_TABLE_REPLACE_BEGIN, mp);
9010 mp->table.table_id = ntohl (table_id);
9011 mp->table.is_ip6 = is_ipv6;
9019 api_ip_table_flush (vat_main_t * vam)
9021 unformat_input_t *i = vam->input;
9022 vl_api_ip_table_flush_t *mp;
9027 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9029 if (unformat (i, "table %d", &table_id))
9031 else if (unformat (i, "ipv6"))
9035 clib_warning ("parse error '%U'", format_unformat_error, i);
9040 M (IP_TABLE_FLUSH, mp);
9042 mp->table.table_id = ntohl (table_id);
9043 mp->table.is_ip6 = is_ipv6;
9051 api_ip_table_replace_end (vat_main_t * vam)
9053 unformat_input_t *i = vam->input;
9054 vl_api_ip_table_replace_end_t *mp;
9059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9061 if (unformat (i, "table %d", &table_id))
9063 else if (unformat (i, "ipv6"))
9067 clib_warning ("parse error '%U'", format_unformat_error, i);
9072 M (IP_TABLE_REPLACE_END, mp);
9074 mp->table.table_id = ntohl (table_id);
9075 mp->table.is_ip6 = is_ipv6;
9083 api_set_ip_flow_hash (vat_main_t * vam)
9085 unformat_input_t *i = vam->input;
9086 vl_api_set_ip_flow_hash_t *mp;
9098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9100 if (unformat (i, "vrf %d", &vrf_id))
9102 else if (unformat (i, "ipv6"))
9104 else if (unformat (i, "src"))
9106 else if (unformat (i, "dst"))
9108 else if (unformat (i, "sport"))
9110 else if (unformat (i, "dport"))
9112 else if (unformat (i, "proto"))
9114 else if (unformat (i, "reverse"))
9119 clib_warning ("parse error '%U'", format_unformat_error, i);
9124 if (vrf_id_set == 0)
9126 errmsg ("missing vrf id");
9130 M (SET_IP_FLOW_HASH, mp);
9136 mp->reverse = reverse;
9137 mp->vrf_id = ntohl (vrf_id);
9138 mp->is_ipv6 = is_ipv6;
9146 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9148 unformat_input_t *i = vam->input;
9149 vl_api_sw_interface_ip6_enable_disable_t *mp;
9151 u8 sw_if_index_set = 0;
9155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9157 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9158 sw_if_index_set = 1;
9159 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9160 sw_if_index_set = 1;
9161 else if (unformat (i, "enable"))
9163 else if (unformat (i, "disable"))
9167 clib_warning ("parse error '%U'", format_unformat_error, i);
9172 if (sw_if_index_set == 0)
9174 errmsg ("missing interface name or sw_if_index");
9178 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9180 mp->sw_if_index = ntohl (sw_if_index);
9181 mp->enable = enable;
9190 api_l2_patch_add_del (vat_main_t * vam)
9192 unformat_input_t *i = vam->input;
9193 vl_api_l2_patch_add_del_t *mp;
9195 u8 rx_sw_if_index_set = 0;
9197 u8 tx_sw_if_index_set = 0;
9201 /* Parse args required to build the message */
9202 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9204 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9205 rx_sw_if_index_set = 1;
9206 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9207 tx_sw_if_index_set = 1;
9208 else if (unformat (i, "rx"))
9210 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9212 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9214 rx_sw_if_index_set = 1;
9219 else if (unformat (i, "tx"))
9221 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9223 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9225 tx_sw_if_index_set = 1;
9230 else if (unformat (i, "del"))
9236 if (rx_sw_if_index_set == 0)
9238 errmsg ("missing rx interface name or rx_sw_if_index");
9242 if (tx_sw_if_index_set == 0)
9244 errmsg ("missing tx interface name or tx_sw_if_index");
9248 M (L2_PATCH_ADD_DEL, mp);
9250 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9251 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9252 mp->is_add = is_add;
9260 u8 localsid_addr[16];
9269 api_sr_localsid_add_del (vat_main_t * vam)
9271 unformat_input_t *i = vam->input;
9272 vl_api_sr_localsid_add_del_t *mp;
9275 ip6_address_t localsid;
9279 u32 fib_table = ~(u32) 0;
9280 ip6_address_t nh_addr6;
9281 ip4_address_t nh_addr4;
9282 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
9283 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
9285 bool nexthop_set = 0;
9289 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9291 if (unformat (i, "del"))
9293 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9294 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
9296 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
9298 else if (unformat (i, "behavior %u", &behavior));
9299 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9300 else if (unformat (i, "fib-table %u", &fib_table));
9301 else if (unformat (i, "end.psp %u", &behavior));
9306 M (SR_LOCALSID_ADD_DEL, mp);
9308 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
9312 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
9313 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
9315 mp->behavior = behavior;
9316 mp->sw_if_index = ntohl (sw_if_index);
9317 mp->fib_table = ntohl (fib_table);
9318 mp->end_psp = end_psp;
9319 mp->is_del = is_del;
9327 api_ioam_enable (vat_main_t * vam)
9329 unformat_input_t *input = vam->input;
9330 vl_api_ioam_enable_t *mp;
9332 int has_trace_option = 0;
9333 int has_pot_option = 0;
9334 int has_seqno_option = 0;
9335 int has_analyse_option = 0;
9338 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9340 if (unformat (input, "trace"))
9341 has_trace_option = 1;
9342 else if (unformat (input, "pot"))
9344 else if (unformat (input, "seqno"))
9345 has_seqno_option = 1;
9346 else if (unformat (input, "analyse"))
9347 has_analyse_option = 1;
9351 M (IOAM_ENABLE, mp);
9352 mp->id = htons (id);
9353 mp->seqno = has_seqno_option;
9354 mp->analyse = has_analyse_option;
9355 mp->pot_enable = has_pot_option;
9356 mp->trace_enable = has_trace_option;
9365 api_ioam_disable (vat_main_t * vam)
9367 vl_api_ioam_disable_t *mp;
9370 M (IOAM_DISABLE, mp);
9376 #define foreach_tcp_proto_field \
9380 #define foreach_udp_proto_field \
9384 #define foreach_ip4_proto_field \
9396 u16 src_port, dst_port;
9399 #if VPP_API_TEST_BUILTIN == 0
9401 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9403 u8 **maskp = va_arg (*args, u8 **);
9405 u8 found_something = 0;
9408 #define _(a) u8 a=0;
9409 foreach_tcp_proto_field;
9412 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9415 #define _(a) else if (unformat (input, #a)) a=1;
9416 foreach_tcp_proto_field
9422 #define _(a) found_something += a;
9423 foreach_tcp_proto_field;
9426 if (found_something == 0)
9429 vec_validate (mask, sizeof (*tcp) - 1);
9431 tcp = (tcp_header_t *) mask;
9433 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
9434 foreach_tcp_proto_field;
9442 unformat_udp_mask (unformat_input_t * input, va_list * args)
9444 u8 **maskp = va_arg (*args, u8 **);
9446 u8 found_something = 0;
9449 #define _(a) u8 a=0;
9450 foreach_udp_proto_field;
9453 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9456 #define _(a) else if (unformat (input, #a)) a=1;
9457 foreach_udp_proto_field
9463 #define _(a) found_something += a;
9464 foreach_udp_proto_field;
9467 if (found_something == 0)
9470 vec_validate (mask, sizeof (*udp) - 1);
9472 udp = (udp_header_t *) mask;
9474 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
9475 foreach_udp_proto_field;
9483 unformat_l4_mask (unformat_input_t * input, va_list * args)
9485 u8 **maskp = va_arg (*args, u8 **);
9486 u16 src_port = 0, dst_port = 0;
9487 tcpudp_header_t *tcpudp;
9489 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9491 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9493 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9495 else if (unformat (input, "src_port"))
9497 else if (unformat (input, "dst_port"))
9503 if (!src_port && !dst_port)
9507 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9509 tcpudp = (tcpudp_header_t *) mask;
9510 tcpudp->src_port = src_port;
9511 tcpudp->dst_port = dst_port;
9519 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9521 u8 **maskp = va_arg (*args, u8 **);
9523 u8 found_something = 0;
9526 #define _(a) u8 a=0;
9527 foreach_ip4_proto_field;
9533 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9535 if (unformat (input, "version"))
9537 else if (unformat (input, "hdr_length"))
9539 else if (unformat (input, "src"))
9541 else if (unformat (input, "dst"))
9543 else if (unformat (input, "proto"))
9546 #define _(a) else if (unformat (input, #a)) a=1;
9547 foreach_ip4_proto_field
9553 #define _(a) found_something += a;
9554 foreach_ip4_proto_field;
9557 if (found_something == 0)
9560 vec_validate (mask, sizeof (*ip) - 1);
9562 ip = (ip4_header_t *) mask;
9564 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9565 foreach_ip4_proto_field;
9568 ip->ip_version_and_header_length = 0;
9571 ip->ip_version_and_header_length |= 0xF0;
9574 ip->ip_version_and_header_length |= 0x0F;
9580 #define foreach_ip6_proto_field \
9588 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9590 u8 **maskp = va_arg (*args, u8 **);
9592 u8 found_something = 0;
9594 u32 ip_version_traffic_class_and_flow_label;
9596 #define _(a) u8 a=0;
9597 foreach_ip6_proto_field;
9600 u8 traffic_class = 0;
9603 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9605 if (unformat (input, "version"))
9607 else if (unformat (input, "traffic-class"))
9609 else if (unformat (input, "flow-label"))
9611 else if (unformat (input, "src"))
9613 else if (unformat (input, "dst"))
9615 else if (unformat (input, "proto"))
9618 #define _(a) else if (unformat (input, #a)) a=1;
9619 foreach_ip6_proto_field
9625 #define _(a) found_something += a;
9626 foreach_ip6_proto_field;
9629 if (found_something == 0)
9632 vec_validate (mask, sizeof (*ip) - 1);
9634 ip = (ip6_header_t *) mask;
9636 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9637 foreach_ip6_proto_field;
9640 ip_version_traffic_class_and_flow_label = 0;
9643 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9646 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9649 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9651 ip->ip_version_traffic_class_and_flow_label =
9652 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9659 unformat_l3_mask (unformat_input_t * input, va_list * args)
9661 u8 **maskp = va_arg (*args, u8 **);
9663 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9665 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9667 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9676 unformat_l2_mask (unformat_input_t * input, va_list * args)
9678 u8 **maskp = va_arg (*args, u8 **);
9693 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9695 if (unformat (input, "src"))
9697 else if (unformat (input, "dst"))
9699 else if (unformat (input, "proto"))
9701 else if (unformat (input, "tag1"))
9703 else if (unformat (input, "tag2"))
9705 else if (unformat (input, "ignore-tag1"))
9707 else if (unformat (input, "ignore-tag2"))
9709 else if (unformat (input, "cos1"))
9711 else if (unformat (input, "cos2"))
9713 else if (unformat (input, "dot1q"))
9715 else if (unformat (input, "dot1ad"))
9720 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9721 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9724 if (tag1 || ignore_tag1 || cos1 || dot1q)
9726 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9729 vec_validate (mask, len - 1);
9732 clib_memset (mask, 0xff, 6);
9735 clib_memset (mask + 6, 0xff, 6);
9739 /* inner vlan tag */
9748 mask[21] = mask[20] = 0xff;
9769 mask[16] = mask[17] = 0xff;
9779 mask[12] = mask[13] = 0xff;
9786 unformat_classify_mask (unformat_input_t * input, va_list * args)
9788 u8 **maskp = va_arg (*args, u8 **);
9789 u32 *skipp = va_arg (*args, u32 *);
9790 u32 *matchp = va_arg (*args, u32 *);
9798 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9800 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9802 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9804 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9806 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9820 if (mask || l2 || l3 || l4)
9824 /* "With a free Ethernet header in every package" */
9826 vec_validate (l2, 13);
9830 vec_append (mask, l3);
9835 vec_append (mask, l4);
9840 /* Scan forward looking for the first significant mask octet */
9841 for (i = 0; i < vec_len (mask); i++)
9845 /* compute (skip, match) params */
9846 *skipp = i / sizeof (u32x4);
9847 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9849 /* Pad mask to an even multiple of the vector size */
9850 while (vec_len (mask) % sizeof (u32x4))
9853 match = vec_len (mask) / sizeof (u32x4);
9855 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9857 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9858 if (*tmp || *(tmp + 1))
9863 clib_warning ("BUG: match 0");
9865 _vec_len (mask) = match * sizeof (u32x4);
9875 #endif /* VPP_API_TEST_BUILTIN */
9877 #define foreach_l2_next \
9879 _(ethernet, ETHERNET_INPUT) \
9884 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9886 u32 *miss_next_indexp = va_arg (*args, u32 *);
9891 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9895 if (unformat (input, "%d", &tmp))
9904 *miss_next_indexp = next_index;
9908 #define foreach_ip_next \
9914 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9916 u32 *miss_next_indexp = va_arg (*args, u32 *);
9921 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9925 if (unformat (input, "%d", &tmp))
9934 *miss_next_indexp = next_index;
9938 #define foreach_acl_next \
9942 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9944 u32 *miss_next_indexp = va_arg (*args, u32 *);
9949 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9953 if (unformat (input, "permit"))
9958 else if (unformat (input, "%d", &tmp))
9967 *miss_next_indexp = next_index;
9972 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9974 u32 *r = va_arg (*args, u32 *);
9976 if (unformat (input, "conform-color"))
9977 *r = POLICE_CONFORM;
9978 else if (unformat (input, "exceed-color"))
9987 api_classify_add_del_table (vat_main_t * vam)
9989 unformat_input_t *i = vam->input;
9990 vl_api_classify_add_del_table_t *mp;
9997 u32 table_index = ~0;
9998 u32 next_table_index = ~0;
9999 u32 miss_next_index = ~0;
10000 u32 memory_size = 32 << 20;
10002 u32 current_data_flag = 0;
10003 int current_data_offset = 0;
10006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10008 if (unformat (i, "del"))
10010 else if (unformat (i, "del-chain"))
10015 else if (unformat (i, "buckets %d", &nbuckets))
10017 else if (unformat (i, "memory_size %d", &memory_size))
10019 else if (unformat (i, "skip %d", &skip))
10021 else if (unformat (i, "match %d", &match))
10023 else if (unformat (i, "table %d", &table_index))
10025 else if (unformat (i, "mask %U", unformat_classify_mask,
10026 &mask, &skip, &match))
10028 else if (unformat (i, "next-table %d", &next_table_index))
10030 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10033 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10036 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10039 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10041 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10047 if (is_add && mask == 0)
10049 errmsg ("Mask required");
10053 if (is_add && skip == ~0)
10055 errmsg ("skip count required");
10059 if (is_add && match == ~0)
10061 errmsg ("match count required");
10065 if (!is_add && table_index == ~0)
10067 errmsg ("table index required for delete");
10071 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10073 mp->is_add = is_add;
10074 mp->del_chain = del_chain;
10075 mp->table_index = ntohl (table_index);
10076 mp->nbuckets = ntohl (nbuckets);
10077 mp->memory_size = ntohl (memory_size);
10078 mp->skip_n_vectors = ntohl (skip);
10079 mp->match_n_vectors = ntohl (match);
10080 mp->next_table_index = ntohl (next_table_index);
10081 mp->miss_next_index = ntohl (miss_next_index);
10082 mp->current_data_flag = ntohl (current_data_flag);
10083 mp->current_data_offset = ntohl (current_data_offset);
10084 mp->mask_len = ntohl (vec_len (mask));
10085 clib_memcpy (mp->mask, mask, vec_len (mask));
10094 #if VPP_API_TEST_BUILTIN == 0
10096 unformat_l4_match (unformat_input_t * input, va_list * args)
10098 u8 **matchp = va_arg (*args, u8 **);
10100 u8 *proto_header = 0;
10106 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10108 if (unformat (input, "src_port %d", &src_port))
10110 else if (unformat (input, "dst_port %d", &dst_port))
10116 h.src_port = clib_host_to_net_u16 (src_port);
10117 h.dst_port = clib_host_to_net_u16 (dst_port);
10118 vec_validate (proto_header, sizeof (h) - 1);
10119 memcpy (proto_header, &h, sizeof (h));
10121 *matchp = proto_header;
10127 unformat_ip4_match (unformat_input_t * input, va_list * args)
10129 u8 **matchp = va_arg (*args, u8 **);
10134 int hdr_length = 0;
10135 u32 hdr_length_val;
10136 int src = 0, dst = 0;
10137 ip4_address_t src_val, dst_val;
10144 int fragment_id = 0;
10145 u32 fragment_id_val;
10151 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10153 if (unformat (input, "version %d", &version_val))
10155 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10157 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10159 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10161 else if (unformat (input, "proto %d", &proto_val))
10163 else if (unformat (input, "tos %d", &tos_val))
10165 else if (unformat (input, "length %d", &length_val))
10167 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10169 else if (unformat (input, "ttl %d", &ttl_val))
10171 else if (unformat (input, "checksum %d", &checksum_val))
10177 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10178 + ttl + checksum == 0)
10182 * Aligned because we use the real comparison functions
10184 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10186 ip = (ip4_header_t *) match;
10188 /* These are realistically matched in practice */
10190 ip->src_address.as_u32 = src_val.as_u32;
10193 ip->dst_address.as_u32 = dst_val.as_u32;
10196 ip->protocol = proto_val;
10199 /* These are not, but they're included for completeness */
10201 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10204 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10210 ip->length = clib_host_to_net_u16 (length_val);
10216 ip->checksum = clib_host_to_net_u16 (checksum_val);
10223 unformat_ip6_match (unformat_input_t * input, va_list * args)
10225 u8 **matchp = va_arg (*args, u8 **);
10230 u8 traffic_class = 0;
10231 u32 traffic_class_val = 0;
10234 int src = 0, dst = 0;
10235 ip6_address_t src_val, dst_val;
10238 int payload_length = 0;
10239 u32 payload_length_val;
10242 u32 ip_version_traffic_class_and_flow_label;
10244 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10246 if (unformat (input, "version %d", &version_val))
10248 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10250 else if (unformat (input, "flow_label %d", &flow_label_val))
10252 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10254 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10256 else if (unformat (input, "proto %d", &proto_val))
10258 else if (unformat (input, "payload_length %d", &payload_length_val))
10259 payload_length = 1;
10260 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10266 if (version + traffic_class + flow_label + src + dst + proto +
10267 payload_length + hop_limit == 0)
10271 * Aligned because we use the real comparison functions
10273 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10275 ip = (ip6_header_t *) match;
10278 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10281 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10284 ip->protocol = proto_val;
10286 ip_version_traffic_class_and_flow_label = 0;
10289 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10292 ip_version_traffic_class_and_flow_label |=
10293 (traffic_class_val & 0xFF) << 20;
10296 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10298 ip->ip_version_traffic_class_and_flow_label =
10299 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10301 if (payload_length)
10302 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10305 ip->hop_limit = hop_limit_val;
10312 unformat_l3_match (unformat_input_t * input, va_list * args)
10314 u8 **matchp = va_arg (*args, u8 **);
10316 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10318 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10320 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10329 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10331 u8 *tagp = va_arg (*args, u8 *);
10334 if (unformat (input, "%d", &tag))
10336 tagp[0] = (tag >> 8) & 0x0F;
10337 tagp[1] = tag & 0xFF;
10345 unformat_l2_match (unformat_input_t * input, va_list * args)
10347 u8 **matchp = va_arg (*args, u8 **);
10360 u8 ignore_tag1 = 0;
10361 u8 ignore_tag2 = 0;
10367 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10369 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10372 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10374 else if (unformat (input, "proto %U",
10375 unformat_ethernet_type_host_byte_order, &proto_val))
10377 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10379 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10381 else if (unformat (input, "ignore-tag1"))
10383 else if (unformat (input, "ignore-tag2"))
10385 else if (unformat (input, "cos1 %d", &cos1_val))
10387 else if (unformat (input, "cos2 %d", &cos2_val))
10392 if ((src + dst + proto + tag1 + tag2 +
10393 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10396 if (tag1 || ignore_tag1 || cos1)
10398 if (tag2 || ignore_tag2 || cos2)
10401 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10404 clib_memcpy (match, dst_val, 6);
10407 clib_memcpy (match + 6, src_val, 6);
10411 /* inner vlan tag */
10412 match[19] = tag2_val[1];
10413 match[18] = tag2_val[0];
10415 match[18] |= (cos2_val & 0x7) << 5;
10418 match[21] = proto_val & 0xff;
10419 match[20] = proto_val >> 8;
10423 match[15] = tag1_val[1];
10424 match[14] = tag1_val[0];
10427 match[14] |= (cos1_val & 0x7) << 5;
10433 match[15] = tag1_val[1];
10434 match[14] = tag1_val[0];
10437 match[17] = proto_val & 0xff;
10438 match[16] = proto_val >> 8;
10441 match[14] |= (cos1_val & 0x7) << 5;
10447 match[18] |= (cos2_val & 0x7) << 5;
10449 match[14] |= (cos1_val & 0x7) << 5;
10452 match[13] = proto_val & 0xff;
10453 match[12] = proto_val >> 8;
10461 unformat_qos_source (unformat_input_t * input, va_list * args)
10463 int *qs = va_arg (*args, int *);
10465 if (unformat (input, "ip"))
10466 *qs = QOS_SOURCE_IP;
10467 else if (unformat (input, "mpls"))
10468 *qs = QOS_SOURCE_MPLS;
10469 else if (unformat (input, "ext"))
10470 *qs = QOS_SOURCE_EXT;
10471 else if (unformat (input, "vlan"))
10472 *qs = QOS_SOURCE_VLAN;
10481 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10483 u8 **matchp = va_arg (*args, u8 **);
10484 u32 skip_n_vectors = va_arg (*args, u32);
10485 u32 match_n_vectors = va_arg (*args, u32);
10492 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10494 if (unformat (input, "hex %U", unformat_hex_string, &match))
10496 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10498 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10500 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10514 if (match || l2 || l3 || l4)
10516 if (l2 || l3 || l4)
10518 /* "Win a free Ethernet header in every packet" */
10520 vec_validate_aligned (l2, 13, sizeof (u32x4));
10524 vec_append_aligned (match, l3, sizeof (u32x4));
10529 vec_append_aligned (match, l4, sizeof (u32x4));
10534 /* Make sure the vector is big enough even if key is all 0's */
10535 vec_validate_aligned
10536 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10539 /* Set size, include skipped vectors */
10540 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10551 api_classify_add_del_session (vat_main_t * vam)
10553 unformat_input_t *i = vam->input;
10554 vl_api_classify_add_del_session_t *mp;
10556 u32 table_index = ~0;
10557 u32 hit_next_index = ~0;
10558 u32 opaque_index = ~0;
10561 u32 skip_n_vectors = 0;
10562 u32 match_n_vectors = 0;
10568 * Warning: you have to supply skip_n and match_n
10569 * because the API client cant simply look at the classify
10573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10575 if (unformat (i, "del"))
10577 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10580 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10583 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10586 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10588 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10590 else if (unformat (i, "opaque-index %d", &opaque_index))
10592 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10594 else if (unformat (i, "match_n %d", &match_n_vectors))
10596 else if (unformat (i, "match %U", api_unformat_classify_match,
10597 &match, skip_n_vectors, match_n_vectors))
10599 else if (unformat (i, "advance %d", &advance))
10601 else if (unformat (i, "table-index %d", &table_index))
10603 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10605 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10607 else if (unformat (i, "action %d", &action))
10609 else if (unformat (i, "metadata %d", &metadata))
10615 if (table_index == ~0)
10617 errmsg ("Table index required");
10621 if (is_add && match == 0)
10623 errmsg ("Match value required");
10627 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10629 mp->is_add = is_add;
10630 mp->table_index = ntohl (table_index);
10631 mp->hit_next_index = ntohl (hit_next_index);
10632 mp->opaque_index = ntohl (opaque_index);
10633 mp->advance = ntohl (advance);
10634 mp->action = action;
10635 mp->metadata = ntohl (metadata);
10636 mp->match_len = ntohl (vec_len (match));
10637 clib_memcpy (mp->match, match, vec_len (match));
10646 api_classify_set_interface_ip_table (vat_main_t * vam)
10648 unformat_input_t *i = vam->input;
10649 vl_api_classify_set_interface_ip_table_t *mp;
10651 int sw_if_index_set;
10652 u32 table_index = ~0;
10656 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10658 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10659 sw_if_index_set = 1;
10660 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10661 sw_if_index_set = 1;
10662 else if (unformat (i, "table %d", &table_index))
10666 clib_warning ("parse error '%U'", format_unformat_error, i);
10671 if (sw_if_index_set == 0)
10673 errmsg ("missing interface name or sw_if_index");
10678 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10680 mp->sw_if_index = ntohl (sw_if_index);
10681 mp->table_index = ntohl (table_index);
10682 mp->is_ipv6 = is_ipv6;
10690 api_classify_set_interface_l2_tables (vat_main_t * vam)
10692 unformat_input_t *i = vam->input;
10693 vl_api_classify_set_interface_l2_tables_t *mp;
10695 int sw_if_index_set;
10696 u32 ip4_table_index = ~0;
10697 u32 ip6_table_index = ~0;
10698 u32 other_table_index = ~0;
10702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10704 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10705 sw_if_index_set = 1;
10706 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10707 sw_if_index_set = 1;
10708 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10710 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10712 else if (unformat (i, "other-table %d", &other_table_index))
10714 else if (unformat (i, "is-input %d", &is_input))
10718 clib_warning ("parse error '%U'", format_unformat_error, i);
10723 if (sw_if_index_set == 0)
10725 errmsg ("missing interface name or sw_if_index");
10730 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10732 mp->sw_if_index = ntohl (sw_if_index);
10733 mp->ip4_table_index = ntohl (ip4_table_index);
10734 mp->ip6_table_index = ntohl (ip6_table_index);
10735 mp->other_table_index = ntohl (other_table_index);
10736 mp->is_input = (u8) is_input;
10744 api_set_ipfix_exporter (vat_main_t * vam)
10746 unformat_input_t *i = vam->input;
10747 vl_api_set_ipfix_exporter_t *mp;
10748 ip4_address_t collector_address;
10749 u8 collector_address_set = 0;
10750 u32 collector_port = ~0;
10751 ip4_address_t src_address;
10752 u8 src_address_set = 0;
10755 u32 template_interval = ~0;
10756 u8 udp_checksum = 0;
10759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10761 if (unformat (i, "collector_address %U", unformat_ip4_address,
10762 &collector_address))
10763 collector_address_set = 1;
10764 else if (unformat (i, "collector_port %d", &collector_port))
10766 else if (unformat (i, "src_address %U", unformat_ip4_address,
10768 src_address_set = 1;
10769 else if (unformat (i, "vrf_id %d", &vrf_id))
10771 else if (unformat (i, "path_mtu %d", &path_mtu))
10773 else if (unformat (i, "template_interval %d", &template_interval))
10775 else if (unformat (i, "udp_checksum"))
10781 if (collector_address_set == 0)
10783 errmsg ("collector_address required");
10787 if (src_address_set == 0)
10789 errmsg ("src_address required");
10793 M (SET_IPFIX_EXPORTER, mp);
10795 memcpy (mp->collector_address.un.ip4, collector_address.data,
10796 sizeof (collector_address.data));
10797 mp->collector_port = htons ((u16) collector_port);
10798 memcpy (mp->src_address.un.ip4, src_address.data,
10799 sizeof (src_address.data));
10800 mp->vrf_id = htonl (vrf_id);
10801 mp->path_mtu = htonl (path_mtu);
10802 mp->template_interval = htonl (template_interval);
10803 mp->udp_checksum = udp_checksum;
10811 api_set_ipfix_classify_stream (vat_main_t * vam)
10813 unformat_input_t *i = vam->input;
10814 vl_api_set_ipfix_classify_stream_t *mp;
10816 u32 src_port = UDP_DST_PORT_ipfix;
10819 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10821 if (unformat (i, "domain %d", &domain_id))
10823 else if (unformat (i, "src_port %d", &src_port))
10827 errmsg ("unknown input `%U'", format_unformat_error, i);
10832 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10834 mp->domain_id = htonl (domain_id);
10835 mp->src_port = htons ((u16) src_port);
10843 api_ipfix_classify_table_add_del (vat_main_t * vam)
10845 unformat_input_t *i = vam->input;
10846 vl_api_ipfix_classify_table_add_del_t *mp;
10848 u32 classify_table_index = ~0;
10850 u8 transport_protocol = 255;
10853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10855 if (unformat (i, "add"))
10857 else if (unformat (i, "del"))
10859 else if (unformat (i, "table %d", &classify_table_index))
10861 else if (unformat (i, "ip4"))
10863 else if (unformat (i, "ip6"))
10865 else if (unformat (i, "tcp"))
10866 transport_protocol = 6;
10867 else if (unformat (i, "udp"))
10868 transport_protocol = 17;
10871 errmsg ("unknown input `%U'", format_unformat_error, i);
10878 errmsg ("expecting: add|del");
10881 if (classify_table_index == ~0)
10883 errmsg ("classifier table not specified");
10886 if (ip_version == 0)
10888 errmsg ("IP version not specified");
10892 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10894 mp->is_add = is_add;
10895 mp->table_id = htonl (classify_table_index);
10896 mp->ip_version = ip_version;
10897 mp->transport_protocol = transport_protocol;
10905 api_get_node_index (vat_main_t * vam)
10907 unformat_input_t *i = vam->input;
10908 vl_api_get_node_index_t *mp;
10912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10914 if (unformat (i, "node %s", &name))
10921 errmsg ("node name required");
10924 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10926 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10930 M (GET_NODE_INDEX, mp);
10931 clib_memcpy (mp->node_name, name, vec_len (name));
10940 api_get_next_index (vat_main_t * vam)
10942 unformat_input_t *i = vam->input;
10943 vl_api_get_next_index_t *mp;
10944 u8 *node_name = 0, *next_node_name = 0;
10947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10949 if (unformat (i, "node-name %s", &node_name))
10951 else if (unformat (i, "next-node-name %s", &next_node_name))
10955 if (node_name == 0)
10957 errmsg ("node name required");
10960 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10962 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10966 if (next_node_name == 0)
10968 errmsg ("next node name required");
10971 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10973 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10977 M (GET_NEXT_INDEX, mp);
10978 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10979 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10980 vec_free (node_name);
10981 vec_free (next_node_name);
10989 api_add_node_next (vat_main_t * vam)
10991 unformat_input_t *i = vam->input;
10992 vl_api_add_node_next_t *mp;
10997 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10999 if (unformat (i, "node %s", &name))
11001 else if (unformat (i, "next %s", &next))
11008 errmsg ("node name required");
11011 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11013 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11018 errmsg ("next node required");
11021 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11023 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11027 M (ADD_NODE_NEXT, mp);
11028 clib_memcpy (mp->node_name, name, vec_len (name));
11029 clib_memcpy (mp->next_name, next, vec_len (next));
11039 api_l2tpv3_create_tunnel (vat_main_t * vam)
11041 unformat_input_t *i = vam->input;
11042 ip6_address_t client_address, our_address;
11043 int client_address_set = 0;
11044 int our_address_set = 0;
11045 u32 local_session_id = 0;
11046 u32 remote_session_id = 0;
11047 u64 local_cookie = 0;
11048 u64 remote_cookie = 0;
11049 u8 l2_sublayer_present = 0;
11050 vl_api_l2tpv3_create_tunnel_t *mp;
11053 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11055 if (unformat (i, "client_address %U", unformat_ip6_address,
11057 client_address_set = 1;
11058 else if (unformat (i, "our_address %U", unformat_ip6_address,
11060 our_address_set = 1;
11061 else if (unformat (i, "local_session_id %d", &local_session_id))
11063 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11065 else if (unformat (i, "local_cookie %lld", &local_cookie))
11067 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11069 else if (unformat (i, "l2-sublayer-present"))
11070 l2_sublayer_present = 1;
11075 if (client_address_set == 0)
11077 errmsg ("client_address required");
11081 if (our_address_set == 0)
11083 errmsg ("our_address required");
11087 M (L2TPV3_CREATE_TUNNEL, mp);
11089 clib_memcpy (mp->client_address.un.ip6, client_address.as_u8,
11090 sizeof (ip6_address_t));
11092 clib_memcpy (mp->our_address.un.ip6, our_address.as_u8,
11093 sizeof (ip6_address_t));
11095 mp->local_session_id = ntohl (local_session_id);
11096 mp->remote_session_id = ntohl (remote_session_id);
11097 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11098 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11099 mp->l2_sublayer_present = l2_sublayer_present;
11107 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11109 unformat_input_t *i = vam->input;
11111 u8 sw_if_index_set = 0;
11112 u64 new_local_cookie = 0;
11113 u64 new_remote_cookie = 0;
11114 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11119 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11120 sw_if_index_set = 1;
11121 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11122 sw_if_index_set = 1;
11123 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11125 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11131 if (sw_if_index_set == 0)
11133 errmsg ("missing interface name or sw_if_index");
11137 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11139 mp->sw_if_index = ntohl (sw_if_index);
11140 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11141 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11149 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11151 unformat_input_t *i = vam->input;
11152 vl_api_l2tpv3_interface_enable_disable_t *mp;
11154 u8 sw_if_index_set = 0;
11155 u8 enable_disable = 1;
11158 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11160 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11161 sw_if_index_set = 1;
11162 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11163 sw_if_index_set = 1;
11164 else if (unformat (i, "enable"))
11165 enable_disable = 1;
11166 else if (unformat (i, "disable"))
11167 enable_disable = 0;
11172 if (sw_if_index_set == 0)
11174 errmsg ("missing interface name or sw_if_index");
11178 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11180 mp->sw_if_index = ntohl (sw_if_index);
11181 mp->enable_disable = enable_disable;
11189 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11191 unformat_input_t *i = vam->input;
11192 vl_api_l2tpv3_set_lookup_key_t *mp;
11196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11198 if (unformat (i, "lookup_v6_src"))
11199 key = L2T_LOOKUP_SRC_ADDRESS;
11200 else if (unformat (i, "lookup_v6_dst"))
11201 key = L2T_LOOKUP_DST_ADDRESS;
11202 else if (unformat (i, "lookup_session_id"))
11203 key = L2T_LOOKUP_SESSION_ID;
11208 if (key == (u8) ~ 0)
11210 errmsg ("l2tp session lookup key unset");
11214 M (L2TPV3_SET_LOOKUP_KEY, mp);
11223 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11224 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11226 vat_main_t *vam = &vat_main;
11228 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11229 format_ip6_address, mp->our_address,
11230 format_ip6_address, mp->client_address,
11231 clib_net_to_host_u32 (mp->sw_if_index));
11234 " local cookies %016llx %016llx remote cookie %016llx",
11235 clib_net_to_host_u64 (mp->local_cookie[0]),
11236 clib_net_to_host_u64 (mp->local_cookie[1]),
11237 clib_net_to_host_u64 (mp->remote_cookie));
11239 print (vam->ofp, " local session-id %d remote session-id %d",
11240 clib_net_to_host_u32 (mp->local_session_id),
11241 clib_net_to_host_u32 (mp->remote_session_id));
11243 print (vam->ofp, " l2 specific sublayer %s\n",
11244 mp->l2_sublayer_present ? "preset" : "absent");
11248 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11249 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11251 vat_main_t *vam = &vat_main;
11252 vat_json_node_t *node = NULL;
11253 struct in6_addr addr;
11255 if (VAT_JSON_ARRAY != vam->json_tree.type)
11257 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11258 vat_json_init_array (&vam->json_tree);
11260 node = vat_json_array_add (&vam->json_tree);
11262 vat_json_init_object (node);
11264 clib_memcpy (&addr, mp->our_address.un.ip6, sizeof (addr));
11265 vat_json_object_add_ip6 (node, "our_address", addr);
11266 clib_memcpy (&addr, mp->client_address.un.ip6, sizeof (addr));
11267 vat_json_object_add_ip6 (node, "client_address", addr);
11269 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11270 vat_json_init_array (lc);
11271 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11272 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11273 vat_json_object_add_uint (node, "remote_cookie",
11274 clib_net_to_host_u64 (mp->remote_cookie));
11276 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11277 vat_json_object_add_uint (node, "local_session_id",
11278 clib_net_to_host_u32 (mp->local_session_id));
11279 vat_json_object_add_uint (node, "remote_session_id",
11280 clib_net_to_host_u32 (mp->remote_session_id));
11281 vat_json_object_add_string_copy (node, "l2_sublayer",
11282 mp->l2_sublayer_present ? (u8 *) "present"
11283 : (u8 *) "absent");
11287 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11289 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11290 vl_api_control_ping_t *mp_ping;
11293 /* Get list of l2tpv3-tunnel interfaces */
11294 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11297 /* Use a control ping for synchronization */
11298 MPING (CONTROL_PING, mp_ping);
11306 static void vl_api_sw_interface_tap_v2_details_t_handler
11307 (vl_api_sw_interface_tap_v2_details_t * mp)
11309 vat_main_t *vam = &vat_main;
11312 format (0, "%U/%d", format_ip4_address, mp->host_ip4_prefix.address,
11313 mp->host_ip4_prefix.len);
11315 format (0, "%U/%d", format_ip6_address, mp->host_ip6_prefix.address,
11316 mp->host_ip6_prefix.len);
11319 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
11320 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
11321 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11322 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
11323 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
11329 static void vl_api_sw_interface_tap_v2_details_t_handler_json
11330 (vl_api_sw_interface_tap_v2_details_t * mp)
11332 vat_main_t *vam = &vat_main;
11333 vat_json_node_t *node = NULL;
11335 if (VAT_JSON_ARRAY != vam->json_tree.type)
11337 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11338 vat_json_init_array (&vam->json_tree);
11340 node = vat_json_array_add (&vam->json_tree);
11342 vat_json_init_object (node);
11343 vat_json_object_add_uint (node, "id", ntohl (mp->id));
11344 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11345 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
11346 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11347 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11348 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11349 vat_json_object_add_string_copy (node, "host_mac_addr",
11350 format (0, "%U", format_ethernet_address,
11351 &mp->host_mac_addr));
11352 vat_json_object_add_string_copy (node, "host_namespace",
11353 mp->host_namespace);
11354 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
11355 vat_json_object_add_string_copy (node, "host_ip4_addr",
11356 format (0, "%U/%d", format_ip4_address,
11357 mp->host_ip4_prefix.address,
11358 mp->host_ip4_prefix.len));
11359 vat_json_object_add_string_copy (node, "host_ip6_prefix",
11360 format (0, "%U/%d", format_ip6_address,
11361 mp->host_ip6_prefix.address,
11362 mp->host_ip6_prefix.len));
11367 api_sw_interface_tap_v2_dump (vat_main_t * vam)
11369 vl_api_sw_interface_tap_v2_dump_t *mp;
11370 vl_api_control_ping_t *mp_ping;
11374 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
11375 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
11376 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
11379 /* Get list of tap interfaces */
11380 M (SW_INTERFACE_TAP_V2_DUMP, mp);
11383 /* Use a control ping for synchronization */
11384 MPING (CONTROL_PING, mp_ping);
11391 static void vl_api_sw_interface_virtio_pci_details_t_handler
11392 (vl_api_sw_interface_virtio_pci_details_t * mp)
11394 vat_main_t *vam = &vat_main;
11409 addr.domain = ntohs (mp->pci_addr.domain);
11410 addr.bus = mp->pci_addr.bus;
11411 addr.slot = mp->pci_addr.slot;
11412 addr.function = mp->pci_addr.function;
11414 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
11415 addr.slot, addr.function);
11418 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
11419 pci_addr, ntohl (mp->sw_if_index),
11420 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11421 format_ethernet_address, mp->mac_addr,
11422 clib_net_to_host_u64 (mp->features));
11423 vec_free (pci_addr);
11426 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
11427 (vl_api_sw_interface_virtio_pci_details_t * mp)
11429 vat_main_t *vam = &vat_main;
11430 vat_json_node_t *node = NULL;
11431 vlib_pci_addr_t pci_addr;
11433 if (VAT_JSON_ARRAY != vam->json_tree.type)
11435 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11436 vat_json_init_array (&vam->json_tree);
11438 node = vat_json_array_add (&vam->json_tree);
11440 pci_addr.domain = ntohs (mp->pci_addr.domain);
11441 pci_addr.bus = mp->pci_addr.bus;
11442 pci_addr.slot = mp->pci_addr.slot;
11443 pci_addr.function = mp->pci_addr.function;
11445 vat_json_init_object (node);
11446 vat_json_object_add_uint (node, "pci-addr", pci_addr.as_u32);
11447 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11448 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11449 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11450 vat_json_object_add_uint (node, "features",
11451 clib_net_to_host_u64 (mp->features));
11452 vat_json_object_add_string_copy (node, "mac_addr",
11453 format (0, "%U", format_ethernet_address,
11458 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
11460 vl_api_sw_interface_virtio_pci_dump_t *mp;
11461 vl_api_control_ping_t *mp_ping;
11465 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
11466 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
11467 "mac_addr", "features");
11469 /* Get list of tap interfaces */
11470 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
11473 /* Use a control ping for synchronization */
11474 MPING (CONTROL_PING, mp_ping);
11482 api_vxlan_offload_rx (vat_main_t * vam)
11484 unformat_input_t *line_input = vam->input;
11485 vl_api_vxlan_offload_rx_t *mp;
11486 u32 hw_if_index = ~0, rx_if_index = ~0;
11490 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11492 if (unformat (line_input, "del"))
11494 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
11497 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
11499 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
11502 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
11506 errmsg ("parse error '%U'", format_unformat_error, line_input);
11511 if (hw_if_index == ~0)
11513 errmsg ("no hw interface");
11517 if (rx_if_index == ~0)
11519 errmsg ("no rx tunnel");
11523 M (VXLAN_OFFLOAD_RX, mp);
11525 mp->hw_if_index = ntohl (hw_if_index);
11526 mp->sw_if_index = ntohl (rx_if_index);
11527 mp->enable = is_add;
11534 static uword unformat_vxlan_decap_next
11535 (unformat_input_t * input, va_list * args)
11537 u32 *result = va_arg (*args, u32 *);
11540 if (unformat (input, "l2"))
11541 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11542 else if (unformat (input, "%d", &tmp))
11550 api_vxlan_add_del_tunnel (vat_main_t * vam)
11552 unformat_input_t *line_input = vam->input;
11553 vl_api_vxlan_add_del_tunnel_t *mp;
11554 ip46_address_t src, dst;
11556 u8 ipv4_set = 0, ipv6_set = 0;
11561 u32 mcast_sw_if_index = ~0;
11562 u32 encap_vrf_id = 0;
11563 u32 decap_next_index = ~0;
11567 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11568 clib_memset (&src, 0, sizeof src);
11569 clib_memset (&dst, 0, sizeof dst);
11571 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11573 if (unformat (line_input, "del"))
11575 else if (unformat (line_input, "instance %d", &instance))
11578 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11584 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11590 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11596 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11601 else if (unformat (line_input, "group %U %U",
11602 unformat_ip4_address, &dst.ip4,
11603 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11605 grp_set = dst_set = 1;
11608 else if (unformat (line_input, "group %U",
11609 unformat_ip4_address, &dst.ip4))
11611 grp_set = dst_set = 1;
11614 else if (unformat (line_input, "group %U %U",
11615 unformat_ip6_address, &dst.ip6,
11616 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11618 grp_set = dst_set = 1;
11621 else if (unformat (line_input, "group %U",
11622 unformat_ip6_address, &dst.ip6))
11624 grp_set = dst_set = 1;
11628 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11630 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11632 else if (unformat (line_input, "decap-next %U",
11633 unformat_vxlan_decap_next, &decap_next_index))
11635 else if (unformat (line_input, "vni %d", &vni))
11639 errmsg ("parse error '%U'", format_unformat_error, line_input);
11646 errmsg ("tunnel src address not specified");
11651 errmsg ("tunnel dst address not specified");
11655 if (grp_set && !ip46_address_is_multicast (&dst))
11657 errmsg ("tunnel group address not multicast");
11660 if (grp_set && mcast_sw_if_index == ~0)
11662 errmsg ("tunnel nonexistent multicast device");
11665 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11667 errmsg ("tunnel dst address must be unicast");
11672 if (ipv4_set && ipv6_set)
11674 errmsg ("both IPv4 and IPv6 addresses specified");
11678 if ((vni == 0) || (vni >> 24))
11680 errmsg ("vni not specified or out of range");
11684 M (VXLAN_ADD_DEL_TUNNEL, mp);
11688 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11689 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11693 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11694 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11697 mp->instance = htonl (instance);
11698 mp->encap_vrf_id = ntohl (encap_vrf_id);
11699 mp->decap_next_index = ntohl (decap_next_index);
11700 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11701 mp->vni = ntohl (vni);
11702 mp->is_add = is_add;
11703 mp->is_ipv6 = ipv6_set;
11710 static void vl_api_vxlan_tunnel_details_t_handler
11711 (vl_api_vxlan_tunnel_details_t * mp)
11713 vat_main_t *vam = &vat_main;
11714 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11715 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11717 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
11718 ntohl (mp->sw_if_index),
11719 ntohl (mp->instance),
11720 format_ip46_address, &src, IP46_TYPE_ANY,
11721 format_ip46_address, &dst, IP46_TYPE_ANY,
11722 ntohl (mp->encap_vrf_id),
11723 ntohl (mp->decap_next_index), ntohl (mp->vni),
11724 ntohl (mp->mcast_sw_if_index));
11727 static void vl_api_vxlan_tunnel_details_t_handler_json
11728 (vl_api_vxlan_tunnel_details_t * mp)
11730 vat_main_t *vam = &vat_main;
11731 vat_json_node_t *node = NULL;
11733 if (VAT_JSON_ARRAY != vam->json_tree.type)
11735 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11736 vat_json_init_array (&vam->json_tree);
11738 node = vat_json_array_add (&vam->json_tree);
11740 vat_json_init_object (node);
11741 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11743 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
11747 struct in6_addr ip6;
11749 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11750 vat_json_object_add_ip6 (node, "src_address", ip6);
11751 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11752 vat_json_object_add_ip6 (node, "dst_address", ip6);
11756 struct in_addr ip4;
11758 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11759 vat_json_object_add_ip4 (node, "src_address", ip4);
11760 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11761 vat_json_object_add_ip4 (node, "dst_address", ip4);
11763 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11764 vat_json_object_add_uint (node, "decap_next_index",
11765 ntohl (mp->decap_next_index));
11766 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11767 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11768 vat_json_object_add_uint (node, "mcast_sw_if_index",
11769 ntohl (mp->mcast_sw_if_index));
11773 api_vxlan_tunnel_dump (vat_main_t * vam)
11775 unformat_input_t *i = vam->input;
11776 vl_api_vxlan_tunnel_dump_t *mp;
11777 vl_api_control_ping_t *mp_ping;
11779 u8 sw_if_index_set = 0;
11782 /* Parse args required to build the message */
11783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11785 if (unformat (i, "sw_if_index %d", &sw_if_index))
11786 sw_if_index_set = 1;
11791 if (sw_if_index_set == 0)
11796 if (!vam->json_output)
11798 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
11799 "sw_if_index", "instance", "src_address", "dst_address",
11800 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11803 /* Get list of vxlan-tunnel interfaces */
11804 M (VXLAN_TUNNEL_DUMP, mp);
11806 mp->sw_if_index = htonl (sw_if_index);
11810 /* Use a control ping for synchronization */
11811 MPING (CONTROL_PING, mp_ping);
11818 static uword unformat_geneve_decap_next
11819 (unformat_input_t * input, va_list * args)
11821 u32 *result = va_arg (*args, u32 *);
11824 if (unformat (input, "l2"))
11825 *result = GENEVE_INPUT_NEXT_L2_INPUT;
11826 else if (unformat (input, "%d", &tmp))
11834 api_geneve_add_del_tunnel (vat_main_t * vam)
11836 unformat_input_t *line_input = vam->input;
11837 vl_api_geneve_add_del_tunnel_t *mp;
11838 ip46_address_t src, dst;
11840 u8 ipv4_set = 0, ipv6_set = 0;
11844 u32 mcast_sw_if_index = ~0;
11845 u32 encap_vrf_id = 0;
11846 u32 decap_next_index = ~0;
11850 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11851 clib_memset (&src, 0, sizeof src);
11852 clib_memset (&dst, 0, sizeof dst);
11854 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11856 if (unformat (line_input, "del"))
11859 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11865 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11871 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11877 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11882 else if (unformat (line_input, "group %U %U",
11883 unformat_ip4_address, &dst.ip4,
11884 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11886 grp_set = dst_set = 1;
11889 else if (unformat (line_input, "group %U",
11890 unformat_ip4_address, &dst.ip4))
11892 grp_set = dst_set = 1;
11895 else if (unformat (line_input, "group %U %U",
11896 unformat_ip6_address, &dst.ip6,
11897 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11899 grp_set = dst_set = 1;
11902 else if (unformat (line_input, "group %U",
11903 unformat_ip6_address, &dst.ip6))
11905 grp_set = dst_set = 1;
11909 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11911 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11913 else if (unformat (line_input, "decap-next %U",
11914 unformat_geneve_decap_next, &decap_next_index))
11916 else if (unformat (line_input, "vni %d", &vni))
11920 errmsg ("parse error '%U'", format_unformat_error, line_input);
11927 errmsg ("tunnel src address not specified");
11932 errmsg ("tunnel dst address not specified");
11936 if (grp_set && !ip46_address_is_multicast (&dst))
11938 errmsg ("tunnel group address not multicast");
11941 if (grp_set && mcast_sw_if_index == ~0)
11943 errmsg ("tunnel nonexistent multicast device");
11946 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11948 errmsg ("tunnel dst address must be unicast");
11953 if (ipv4_set && ipv6_set)
11955 errmsg ("both IPv4 and IPv6 addresses specified");
11959 if ((vni == 0) || (vni >> 24))
11961 errmsg ("vni not specified or out of range");
11965 M (GENEVE_ADD_DEL_TUNNEL, mp);
11969 clib_memcpy (&mp->local_address.un.ip6, &src.ip6, sizeof (src.ip6));
11970 clib_memcpy (&mp->remote_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
11974 clib_memcpy (&mp->local_address.un.ip4, &src.ip4, sizeof (src.ip4));
11975 clib_memcpy (&mp->remote_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
11977 mp->encap_vrf_id = ntohl (encap_vrf_id);
11978 mp->decap_next_index = ntohl (decap_next_index);
11979 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11980 mp->vni = ntohl (vni);
11981 mp->is_add = is_add;
11988 static void vl_api_geneve_tunnel_details_t_handler
11989 (vl_api_geneve_tunnel_details_t * mp)
11991 vat_main_t *vam = &vat_main;
11992 ip46_address_t src = {.as_u64[0] = 0,.as_u64[1] = 0 };
11993 ip46_address_t dst = {.as_u64[0] = 0,.as_u64[1] = 0 };
11995 if (mp->src_address.af == ADDRESS_IP6)
11997 clib_memcpy (&src.ip6, &mp->src_address.un.ip6, sizeof (ip6_address_t));
11998 clib_memcpy (&dst.ip6, &mp->dst_address.un.ip6, sizeof (ip6_address_t));
12002 clib_memcpy (&src.ip4, &mp->src_address.un.ip4, sizeof (ip4_address_t));
12003 clib_memcpy (&dst.ip4, &mp->dst_address.un.ip4, sizeof (ip4_address_t));
12006 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12007 ntohl (mp->sw_if_index),
12008 format_ip46_address, &src, IP46_TYPE_ANY,
12009 format_ip46_address, &dst, IP46_TYPE_ANY,
12010 ntohl (mp->encap_vrf_id),
12011 ntohl (mp->decap_next_index), ntohl (mp->vni),
12012 ntohl (mp->mcast_sw_if_index));
12015 static void vl_api_geneve_tunnel_details_t_handler_json
12016 (vl_api_geneve_tunnel_details_t * mp)
12018 vat_main_t *vam = &vat_main;
12019 vat_json_node_t *node = NULL;
12022 if (VAT_JSON_ARRAY != vam->json_tree.type)
12024 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12025 vat_json_init_array (&vam->json_tree);
12027 node = vat_json_array_add (&vam->json_tree);
12029 vat_json_init_object (node);
12030 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12031 is_ipv6 = mp->src_address.af == ADDRESS_IP6;
12034 struct in6_addr ip6;
12036 clib_memcpy (&ip6, &mp->src_address.un.ip6, sizeof (ip6));
12037 vat_json_object_add_ip6 (node, "src_address", ip6);
12038 clib_memcpy (&ip6, &mp->dst_address.un.ip6, sizeof (ip6));
12039 vat_json_object_add_ip6 (node, "dst_address", ip6);
12043 struct in_addr ip4;
12045 clib_memcpy (&ip4, &mp->src_address.un.ip4, sizeof (ip4));
12046 vat_json_object_add_ip4 (node, "src_address", ip4);
12047 clib_memcpy (&ip4, &mp->dst_address.un.ip4, sizeof (ip4));
12048 vat_json_object_add_ip4 (node, "dst_address", ip4);
12050 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12051 vat_json_object_add_uint (node, "decap_next_index",
12052 ntohl (mp->decap_next_index));
12053 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12054 vat_json_object_add_uint (node, "mcast_sw_if_index",
12055 ntohl (mp->mcast_sw_if_index));
12059 api_geneve_tunnel_dump (vat_main_t * vam)
12061 unformat_input_t *i = vam->input;
12062 vl_api_geneve_tunnel_dump_t *mp;
12063 vl_api_control_ping_t *mp_ping;
12065 u8 sw_if_index_set = 0;
12068 /* Parse args required to build the message */
12069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12071 if (unformat (i, "sw_if_index %d", &sw_if_index))
12072 sw_if_index_set = 1;
12077 if (sw_if_index_set == 0)
12082 if (!vam->json_output)
12084 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12085 "sw_if_index", "local_address", "remote_address",
12086 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12089 /* Get list of geneve-tunnel interfaces */
12090 M (GENEVE_TUNNEL_DUMP, mp);
12092 mp->sw_if_index = htonl (sw_if_index);
12096 /* Use a control ping for synchronization */
12097 M (CONTROL_PING, mp_ping);
12105 api_gre_tunnel_add_del (vat_main_t * vam)
12107 unformat_input_t *line_input = vam->input;
12108 vl_api_address_t src = { }, dst =
12111 vl_api_gre_tunnel_add_del_t *mp;
12112 vl_api_gre_tunnel_type_t t_type;
12116 u32 outer_table_id = 0;
12117 u32 session_id = 0;
12121 t_type = GRE_API_TUNNEL_TYPE_L3;
12123 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12125 if (unformat (line_input, "del"))
12127 else if (unformat (line_input, "instance %d", &instance))
12129 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
12133 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
12137 else if (unformat (line_input, "outer-table-id %d", &outer_table_id))
12139 else if (unformat (line_input, "teb"))
12140 t_type = GRE_API_TUNNEL_TYPE_TEB;
12141 else if (unformat (line_input, "erspan %d", &session_id))
12142 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
12145 errmsg ("parse error '%U'", format_unformat_error, line_input);
12152 errmsg ("tunnel src address not specified");
12157 errmsg ("tunnel dst address not specified");
12161 M (GRE_TUNNEL_ADD_DEL, mp);
12163 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
12164 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
12166 mp->tunnel.instance = htonl (instance);
12167 mp->tunnel.outer_table_id = htonl (outer_table_id);
12168 mp->is_add = is_add;
12169 mp->tunnel.session_id = htons ((u16) session_id);
12170 mp->tunnel.type = htonl (t_type);
12177 static void vl_api_gre_tunnel_details_t_handler
12178 (vl_api_gre_tunnel_details_t * mp)
12180 vat_main_t *vam = &vat_main;
12182 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
12183 ntohl (mp->tunnel.sw_if_index),
12184 ntohl (mp->tunnel.instance),
12185 format_vl_api_address, &mp->tunnel.src,
12186 format_vl_api_address, &mp->tunnel.dst,
12187 mp->tunnel.type, ntohl (mp->tunnel.outer_table_id),
12188 ntohl (mp->tunnel.session_id));
12191 static void vl_api_gre_tunnel_details_t_handler_json
12192 (vl_api_gre_tunnel_details_t * mp)
12194 vat_main_t *vam = &vat_main;
12195 vat_json_node_t *node = NULL;
12197 if (VAT_JSON_ARRAY != vam->json_tree.type)
12199 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12200 vat_json_init_array (&vam->json_tree);
12202 node = vat_json_array_add (&vam->json_tree);
12204 vat_json_init_object (node);
12205 vat_json_object_add_uint (node, "sw_if_index",
12206 ntohl (mp->tunnel.sw_if_index));
12207 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
12209 vat_json_object_add_address (node, "src", &mp->tunnel.src);
12210 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
12211 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
12212 vat_json_object_add_uint (node, "outer_table_id",
12213 ntohl (mp->tunnel.outer_table_id));
12214 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
12218 api_gre_tunnel_dump (vat_main_t * vam)
12220 unformat_input_t *i = vam->input;
12221 vl_api_gre_tunnel_dump_t *mp;
12222 vl_api_control_ping_t *mp_ping;
12224 u8 sw_if_index_set = 0;
12227 /* Parse args required to build the message */
12228 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12230 if (unformat (i, "sw_if_index %d", &sw_if_index))
12231 sw_if_index_set = 1;
12236 if (sw_if_index_set == 0)
12241 if (!vam->json_output)
12243 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
12244 "sw_if_index", "instance", "src_address", "dst_address",
12245 "tunnel_type", "outer_fib_id", "session_id");
12248 /* Get list of gre-tunnel interfaces */
12249 M (GRE_TUNNEL_DUMP, mp);
12251 mp->sw_if_index = htonl (sw_if_index);
12255 /* Use a control ping for synchronization */
12256 MPING (CONTROL_PING, mp_ping);
12264 api_l2_fib_clear_table (vat_main_t * vam)
12266 // unformat_input_t * i = vam->input;
12267 vl_api_l2_fib_clear_table_t *mp;
12270 M (L2_FIB_CLEAR_TABLE, mp);
12278 api_l2_interface_efp_filter (vat_main_t * vam)
12280 unformat_input_t *i = vam->input;
12281 vl_api_l2_interface_efp_filter_t *mp;
12284 u8 sw_if_index_set = 0;
12287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12289 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12290 sw_if_index_set = 1;
12291 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12292 sw_if_index_set = 1;
12293 else if (unformat (i, "enable"))
12295 else if (unformat (i, "disable"))
12299 clib_warning ("parse error '%U'", format_unformat_error, i);
12304 if (sw_if_index_set == 0)
12306 errmsg ("missing sw_if_index");
12310 M (L2_INTERFACE_EFP_FILTER, mp);
12312 mp->sw_if_index = ntohl (sw_if_index);
12313 mp->enable_disable = enable;
12320 #define foreach_vtr_op \
12321 _("disable", L2_VTR_DISABLED) \
12322 _("push-1", L2_VTR_PUSH_1) \
12323 _("push-2", L2_VTR_PUSH_2) \
12324 _("pop-1", L2_VTR_POP_1) \
12325 _("pop-2", L2_VTR_POP_2) \
12326 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12327 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12328 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12329 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12332 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12334 unformat_input_t *i = vam->input;
12335 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12337 u8 sw_if_index_set = 0;
12340 u32 push_dot1q = 1;
12345 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12347 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12348 sw_if_index_set = 1;
12349 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12350 sw_if_index_set = 1;
12351 else if (unformat (i, "vtr_op %d", &vtr_op))
12353 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12356 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12358 else if (unformat (i, "tag1 %d", &tag1))
12360 else if (unformat (i, "tag2 %d", &tag2))
12364 clib_warning ("parse error '%U'", format_unformat_error, i);
12369 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12371 errmsg ("missing vtr operation or sw_if_index");
12375 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12376 mp->sw_if_index = ntohl (sw_if_index);
12377 mp->vtr_op = ntohl (vtr_op);
12378 mp->push_dot1q = ntohl (push_dot1q);
12379 mp->tag1 = ntohl (tag1);
12380 mp->tag2 = ntohl (tag2);
12388 api_create_vhost_user_if (vat_main_t * vam)
12390 unformat_input_t *i = vam->input;
12391 vl_api_create_vhost_user_if_t *mp;
12394 u8 file_name_set = 0;
12395 u32 custom_dev_instance = ~0;
12397 u8 use_custom_mac = 0;
12398 u8 disable_mrg_rxbuf = 0;
12399 u8 disable_indirect_desc = 0;
12404 /* Shut up coverity */
12405 clib_memset (hwaddr, 0, sizeof (hwaddr));
12407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12409 if (unformat (i, "socket %s", &file_name))
12413 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12415 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12416 use_custom_mac = 1;
12417 else if (unformat (i, "server"))
12419 else if (unformat (i, "disable_mrg_rxbuf"))
12420 disable_mrg_rxbuf = 1;
12421 else if (unformat (i, "disable_indirect_desc"))
12422 disable_indirect_desc = 1;
12423 else if (unformat (i, "gso"))
12425 else if (unformat (i, "tag %s", &tag))
12431 if (file_name_set == 0)
12433 errmsg ("missing socket file name");
12437 if (vec_len (file_name) > 255)
12439 errmsg ("socket file name too long");
12442 vec_add1 (file_name, 0);
12444 M (CREATE_VHOST_USER_IF, mp);
12446 mp->is_server = is_server;
12447 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
12448 mp->disable_indirect_desc = disable_indirect_desc;
12449 mp->enable_gso = enable_gso;
12450 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12451 vec_free (file_name);
12452 if (custom_dev_instance != ~0)
12455 mp->custom_dev_instance = ntohl (custom_dev_instance);
12458 mp->use_custom_mac = use_custom_mac;
12459 clib_memcpy (mp->mac_address, hwaddr, 6);
12461 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12470 api_modify_vhost_user_if (vat_main_t * vam)
12472 unformat_input_t *i = vam->input;
12473 vl_api_modify_vhost_user_if_t *mp;
12476 u8 file_name_set = 0;
12477 u32 custom_dev_instance = ~0;
12478 u8 sw_if_index_set = 0;
12479 u32 sw_if_index = (u32) ~ 0;
12483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12485 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12486 sw_if_index_set = 1;
12487 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12488 sw_if_index_set = 1;
12489 else if (unformat (i, "socket %s", &file_name))
12493 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12495 else if (unformat (i, "server"))
12497 else if (unformat (i, "gso"))
12503 if (sw_if_index_set == 0)
12505 errmsg ("missing sw_if_index or interface name");
12509 if (file_name_set == 0)
12511 errmsg ("missing socket file name");
12515 if (vec_len (file_name) > 255)
12517 errmsg ("socket file name too long");
12520 vec_add1 (file_name, 0);
12522 M (MODIFY_VHOST_USER_IF, mp);
12524 mp->sw_if_index = ntohl (sw_if_index);
12525 mp->is_server = is_server;
12526 mp->enable_gso = enable_gso;
12527 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12528 vec_free (file_name);
12529 if (custom_dev_instance != ~0)
12532 mp->custom_dev_instance = ntohl (custom_dev_instance);
12541 api_delete_vhost_user_if (vat_main_t * vam)
12543 unformat_input_t *i = vam->input;
12544 vl_api_delete_vhost_user_if_t *mp;
12545 u32 sw_if_index = ~0;
12546 u8 sw_if_index_set = 0;
12549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12551 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12552 sw_if_index_set = 1;
12553 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12554 sw_if_index_set = 1;
12559 if (sw_if_index_set == 0)
12561 errmsg ("missing sw_if_index or interface name");
12566 M (DELETE_VHOST_USER_IF, mp);
12568 mp->sw_if_index = ntohl (sw_if_index);
12575 static void vl_api_sw_interface_vhost_user_details_t_handler
12576 (vl_api_sw_interface_vhost_user_details_t * mp)
12578 vat_main_t *vam = &vat_main;
12582 clib_net_to_host_u32 (mp->features_first_32) | ((u64)
12583 clib_net_to_host_u32
12584 (mp->features_last_32) <<
12587 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12588 (char *) mp->interface_name,
12589 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12590 features, mp->is_server,
12591 ntohl (mp->num_regions), (char *) mp->sock_filename);
12592 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12595 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12596 (vl_api_sw_interface_vhost_user_details_t * mp)
12598 vat_main_t *vam = &vat_main;
12599 vat_json_node_t *node = NULL;
12601 if (VAT_JSON_ARRAY != vam->json_tree.type)
12603 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12604 vat_json_init_array (&vam->json_tree);
12606 node = vat_json_array_add (&vam->json_tree);
12608 vat_json_init_object (node);
12609 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12610 vat_json_object_add_string_copy (node, "interface_name",
12611 mp->interface_name);
12612 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12613 ntohl (mp->virtio_net_hdr_sz));
12614 vat_json_object_add_uint (node, "features_first_32",
12615 clib_net_to_host_u32 (mp->features_first_32));
12616 vat_json_object_add_uint (node, "features_last_32",
12617 clib_net_to_host_u32 (mp->features_last_32));
12618 vat_json_object_add_uint (node, "is_server", mp->is_server);
12619 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12620 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12621 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12625 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12627 vl_api_sw_interface_vhost_user_dump_t *mp;
12628 vl_api_control_ping_t *mp_ping;
12631 "Interface name idx hdr_sz features server regions filename");
12633 /* Get list of vhost-user interfaces */
12634 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12637 /* Use a control ping for synchronization */
12638 MPING (CONTROL_PING, mp_ping);
12646 api_show_version (vat_main_t * vam)
12648 vl_api_show_version_t *mp;
12651 M (SHOW_VERSION, mp);
12660 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12662 unformat_input_t *line_input = vam->input;
12663 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12664 ip4_address_t local4, remote4;
12665 ip6_address_t local6, remote6;
12667 u8 ipv4_set = 0, ipv6_set = 0;
12671 u32 mcast_sw_if_index = ~0;
12672 u32 encap_vrf_id = 0;
12673 u32 decap_vrf_id = 0;
12679 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12680 clib_memset (&local4, 0, sizeof local4);
12681 clib_memset (&remote4, 0, sizeof remote4);
12682 clib_memset (&local6, 0, sizeof local6);
12683 clib_memset (&remote6, 0, sizeof remote6);
12685 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12687 if (unformat (line_input, "del"))
12689 else if (unformat (line_input, "local %U",
12690 unformat_ip4_address, &local4))
12695 else if (unformat (line_input, "remote %U",
12696 unformat_ip4_address, &remote4))
12701 else if (unformat (line_input, "local %U",
12702 unformat_ip6_address, &local6))
12707 else if (unformat (line_input, "remote %U",
12708 unformat_ip6_address, &remote6))
12713 else if (unformat (line_input, "group %U %U",
12714 unformat_ip4_address, &remote4,
12715 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12717 grp_set = remote_set = 1;
12720 else if (unformat (line_input, "group %U",
12721 unformat_ip4_address, &remote4))
12723 grp_set = remote_set = 1;
12726 else if (unformat (line_input, "group %U %U",
12727 unformat_ip6_address, &remote6,
12728 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12730 grp_set = remote_set = 1;
12733 else if (unformat (line_input, "group %U",
12734 unformat_ip6_address, &remote6))
12736 grp_set = remote_set = 1;
12740 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12742 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12744 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12746 else if (unformat (line_input, "vni %d", &vni))
12748 else if (unformat (line_input, "next-ip4"))
12750 else if (unformat (line_input, "next-ip6"))
12752 else if (unformat (line_input, "next-ethernet"))
12754 else if (unformat (line_input, "next-nsh"))
12758 errmsg ("parse error '%U'", format_unformat_error, line_input);
12763 if (local_set == 0)
12765 errmsg ("tunnel local address not specified");
12768 if (remote_set == 0)
12770 errmsg ("tunnel remote address not specified");
12773 if (grp_set && mcast_sw_if_index == ~0)
12775 errmsg ("tunnel nonexistent multicast device");
12778 if (ipv4_set && ipv6_set)
12780 errmsg ("both IPv4 and IPv6 addresses specified");
12786 errmsg ("vni not specified");
12790 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12795 clib_memcpy (&mp->local, &local6, sizeof (local6));
12796 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
12800 clib_memcpy (&mp->local, &local4, sizeof (local4));
12801 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
12804 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12805 mp->encap_vrf_id = ntohl (encap_vrf_id);
12806 mp->decap_vrf_id = ntohl (decap_vrf_id);
12807 mp->protocol = protocol;
12808 mp->vni = ntohl (vni);
12809 mp->is_add = is_add;
12810 mp->is_ipv6 = ipv6_set;
12817 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12818 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12820 vat_main_t *vam = &vat_main;
12821 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
12822 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
12824 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12825 ntohl (mp->sw_if_index),
12826 format_ip46_address, &local, IP46_TYPE_ANY,
12827 format_ip46_address, &remote, IP46_TYPE_ANY,
12828 ntohl (mp->vni), mp->protocol,
12829 ntohl (mp->mcast_sw_if_index),
12830 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12834 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12835 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12837 vat_main_t *vam = &vat_main;
12838 vat_json_node_t *node = NULL;
12839 struct in_addr ip4;
12840 struct in6_addr ip6;
12842 if (VAT_JSON_ARRAY != vam->json_tree.type)
12844 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12845 vat_json_init_array (&vam->json_tree);
12847 node = vat_json_array_add (&vam->json_tree);
12849 vat_json_init_object (node);
12850 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12853 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
12854 vat_json_object_add_ip6 (node, "local", ip6);
12855 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
12856 vat_json_object_add_ip6 (node, "remote", ip6);
12860 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
12861 vat_json_object_add_ip4 (node, "local", ip4);
12862 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
12863 vat_json_object_add_ip4 (node, "remote", ip4);
12865 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12866 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12867 vat_json_object_add_uint (node, "mcast_sw_if_index",
12868 ntohl (mp->mcast_sw_if_index));
12869 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12870 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12871 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12875 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12877 unformat_input_t *i = vam->input;
12878 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12879 vl_api_control_ping_t *mp_ping;
12881 u8 sw_if_index_set = 0;
12884 /* Parse args required to build the message */
12885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12887 if (unformat (i, "sw_if_index %d", &sw_if_index))
12888 sw_if_index_set = 1;
12893 if (sw_if_index_set == 0)
12898 if (!vam->json_output)
12900 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12901 "sw_if_index", "local", "remote", "vni",
12902 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12905 /* Get list of vxlan-tunnel interfaces */
12906 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12908 mp->sw_if_index = htonl (sw_if_index);
12912 /* Use a control ping for synchronization */
12913 MPING (CONTROL_PING, mp_ping);
12920 static void vl_api_l2_fib_table_details_t_handler
12921 (vl_api_l2_fib_table_details_t * mp)
12923 vat_main_t *vam = &vat_main;
12925 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12927 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
12928 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12932 static void vl_api_l2_fib_table_details_t_handler_json
12933 (vl_api_l2_fib_table_details_t * mp)
12935 vat_main_t *vam = &vat_main;
12936 vat_json_node_t *node = NULL;
12938 if (VAT_JSON_ARRAY != vam->json_tree.type)
12940 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12941 vat_json_init_array (&vam->json_tree);
12943 node = vat_json_array_add (&vam->json_tree);
12945 vat_json_init_object (node);
12946 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12947 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
12948 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12949 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12950 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12951 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12955 api_l2_fib_table_dump (vat_main_t * vam)
12957 unformat_input_t *i = vam->input;
12958 vl_api_l2_fib_table_dump_t *mp;
12959 vl_api_control_ping_t *mp_ping;
12964 /* Parse args required to build the message */
12965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12967 if (unformat (i, "bd_id %d", &bd_id))
12973 if (bd_id_set == 0)
12975 errmsg ("missing bridge domain");
12979 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12981 /* Get list of l2 fib entries */
12982 M (L2_FIB_TABLE_DUMP, mp);
12984 mp->bd_id = ntohl (bd_id);
12987 /* Use a control ping for synchronization */
12988 MPING (CONTROL_PING, mp_ping);
12997 api_interface_name_renumber (vat_main_t * vam)
12999 unformat_input_t *line_input = vam->input;
13000 vl_api_interface_name_renumber_t *mp;
13001 u32 sw_if_index = ~0;
13002 u32 new_show_dev_instance = ~0;
13005 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13007 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13010 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13012 else if (unformat (line_input, "new_show_dev_instance %d",
13013 &new_show_dev_instance))
13019 if (sw_if_index == ~0)
13021 errmsg ("missing interface name or sw_if_index");
13025 if (new_show_dev_instance == ~0)
13027 errmsg ("missing new_show_dev_instance");
13031 M (INTERFACE_NAME_RENUMBER, mp);
13033 mp->sw_if_index = ntohl (sw_if_index);
13034 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13042 api_want_l2_macs_events (vat_main_t * vam)
13044 unformat_input_t *line_input = vam->input;
13045 vl_api_want_l2_macs_events_t *mp;
13046 u8 enable_disable = 1;
13047 u32 scan_delay = 0;
13048 u32 max_macs_in_event = 0;
13049 u32 learn_limit = 0;
13052 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13054 if (unformat (line_input, "learn-limit %d", &learn_limit))
13056 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13058 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13060 else if (unformat (line_input, "disable"))
13061 enable_disable = 0;
13066 M (WANT_L2_MACS_EVENTS, mp);
13067 mp->enable_disable = enable_disable;
13068 mp->pid = htonl (getpid ());
13069 mp->learn_limit = htonl (learn_limit);
13070 mp->scan_delay = (u8) scan_delay;
13071 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13078 api_input_acl_set_interface (vat_main_t * vam)
13080 unformat_input_t *i = vam->input;
13081 vl_api_input_acl_set_interface_t *mp;
13083 int sw_if_index_set;
13084 u32 ip4_table_index = ~0;
13085 u32 ip6_table_index = ~0;
13086 u32 l2_table_index = ~0;
13090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13092 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13093 sw_if_index_set = 1;
13094 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13095 sw_if_index_set = 1;
13096 else if (unformat (i, "del"))
13098 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13100 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13102 else if (unformat (i, "l2-table %d", &l2_table_index))
13106 clib_warning ("parse error '%U'", format_unformat_error, i);
13111 if (sw_if_index_set == 0)
13113 errmsg ("missing interface name or sw_if_index");
13117 M (INPUT_ACL_SET_INTERFACE, mp);
13119 mp->sw_if_index = ntohl (sw_if_index);
13120 mp->ip4_table_index = ntohl (ip4_table_index);
13121 mp->ip6_table_index = ntohl (ip6_table_index);
13122 mp->l2_table_index = ntohl (l2_table_index);
13123 mp->is_add = is_add;
13131 api_output_acl_set_interface (vat_main_t * vam)
13133 unformat_input_t *i = vam->input;
13134 vl_api_output_acl_set_interface_t *mp;
13136 int sw_if_index_set;
13137 u32 ip4_table_index = ~0;
13138 u32 ip6_table_index = ~0;
13139 u32 l2_table_index = ~0;
13143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13145 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13146 sw_if_index_set = 1;
13147 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13148 sw_if_index_set = 1;
13149 else if (unformat (i, "del"))
13151 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13153 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13155 else if (unformat (i, "l2-table %d", &l2_table_index))
13159 clib_warning ("parse error '%U'", format_unformat_error, i);
13164 if (sw_if_index_set == 0)
13166 errmsg ("missing interface name or sw_if_index");
13170 M (OUTPUT_ACL_SET_INTERFACE, mp);
13172 mp->sw_if_index = ntohl (sw_if_index);
13173 mp->ip4_table_index = ntohl (ip4_table_index);
13174 mp->ip6_table_index = ntohl (ip6_table_index);
13175 mp->l2_table_index = ntohl (l2_table_index);
13176 mp->is_add = is_add;
13184 api_ip_address_dump (vat_main_t * vam)
13186 unformat_input_t *i = vam->input;
13187 vl_api_ip_address_dump_t *mp;
13188 vl_api_control_ping_t *mp_ping;
13189 u32 sw_if_index = ~0;
13190 u8 sw_if_index_set = 0;
13195 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13197 if (unformat (i, "sw_if_index %d", &sw_if_index))
13198 sw_if_index_set = 1;
13200 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13201 sw_if_index_set = 1;
13202 else if (unformat (i, "ipv4"))
13204 else if (unformat (i, "ipv6"))
13210 if (ipv4_set && ipv6_set)
13212 errmsg ("ipv4 and ipv6 flags cannot be both set");
13216 if ((!ipv4_set) && (!ipv6_set))
13218 errmsg ("no ipv4 nor ipv6 flag set");
13222 if (sw_if_index_set == 0)
13224 errmsg ("missing interface name or sw_if_index");
13228 vam->current_sw_if_index = sw_if_index;
13229 vam->is_ipv6 = ipv6_set;
13231 M (IP_ADDRESS_DUMP, mp);
13232 mp->sw_if_index = ntohl (sw_if_index);
13233 mp->is_ipv6 = ipv6_set;
13236 /* Use a control ping for synchronization */
13237 MPING (CONTROL_PING, mp_ping);
13245 api_ip_dump (vat_main_t * vam)
13247 vl_api_ip_dump_t *mp;
13248 vl_api_control_ping_t *mp_ping;
13249 unformat_input_t *in = vam->input;
13256 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13258 if (unformat (in, "ipv4"))
13260 else if (unformat (in, "ipv6"))
13266 if (ipv4_set && ipv6_set)
13268 errmsg ("ipv4 and ipv6 flags cannot be both set");
13272 if ((!ipv4_set) && (!ipv6_set))
13274 errmsg ("no ipv4 nor ipv6 flag set");
13278 is_ipv6 = ipv6_set;
13279 vam->is_ipv6 = is_ipv6;
13281 /* free old data */
13282 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13284 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13286 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13289 mp->is_ipv6 = ipv6_set;
13292 /* Use a control ping for synchronization */
13293 MPING (CONTROL_PING, mp_ping);
13301 api_ipsec_spd_add_del (vat_main_t * vam)
13303 unformat_input_t *i = vam->input;
13304 vl_api_ipsec_spd_add_del_t *mp;
13309 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13311 if (unformat (i, "spd_id %d", &spd_id))
13313 else if (unformat (i, "del"))
13317 clib_warning ("parse error '%U'", format_unformat_error, i);
13323 errmsg ("spd_id must be set");
13327 M (IPSEC_SPD_ADD_DEL, mp);
13329 mp->spd_id = ntohl (spd_id);
13330 mp->is_add = is_add;
13338 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13340 unformat_input_t *i = vam->input;
13341 vl_api_ipsec_interface_add_del_spd_t *mp;
13343 u8 sw_if_index_set = 0;
13344 u32 spd_id = (u32) ~ 0;
13348 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13350 if (unformat (i, "del"))
13352 else if (unformat (i, "spd_id %d", &spd_id))
13355 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13356 sw_if_index_set = 1;
13357 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13358 sw_if_index_set = 1;
13361 clib_warning ("parse error '%U'", format_unformat_error, i);
13367 if (spd_id == (u32) ~ 0)
13369 errmsg ("spd_id must be set");
13373 if (sw_if_index_set == 0)
13375 errmsg ("missing interface name or sw_if_index");
13379 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13381 mp->spd_id = ntohl (spd_id);
13382 mp->sw_if_index = ntohl (sw_if_index);
13383 mp->is_add = is_add;
13391 api_ipsec_spd_entry_add_del (vat_main_t * vam)
13393 unformat_input_t *i = vam->input;
13394 vl_api_ipsec_spd_entry_add_del_t *mp;
13395 u8 is_add = 1, is_outbound = 0;
13396 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13398 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13399 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13400 vl_api_address_t laddr_start = { }, laddr_stop =
13409 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13411 if (unformat (i, "del"))
13413 if (unformat (i, "outbound"))
13415 if (unformat (i, "inbound"))
13417 else if (unformat (i, "spd_id %d", &spd_id))
13419 else if (unformat (i, "sa_id %d", &sa_id))
13421 else if (unformat (i, "priority %d", &priority))
13423 else if (unformat (i, "protocol %d", &protocol))
13425 else if (unformat (i, "lport_start %d", &lport_start))
13427 else if (unformat (i, "lport_stop %d", &lport_stop))
13429 else if (unformat (i, "rport_start %d", &rport_start))
13431 else if (unformat (i, "rport_stop %d", &rport_stop))
13433 else if (unformat (i, "laddr_start %U",
13434 unformat_vl_api_address, &laddr_start))
13436 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
13439 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
13442 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
13446 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13448 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13450 clib_warning ("unsupported action: 'resolve'");
13456 clib_warning ("parse error '%U'", format_unformat_error, i);
13462 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
13464 mp->is_add = is_add;
13466 mp->entry.spd_id = ntohl (spd_id);
13467 mp->entry.priority = ntohl (priority);
13468 mp->entry.is_outbound = is_outbound;
13470 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
13471 sizeof (vl_api_address_t));
13472 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
13473 sizeof (vl_api_address_t));
13474 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
13475 sizeof (vl_api_address_t));
13476 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
13477 sizeof (vl_api_address_t));
13479 mp->entry.protocol = (u8) protocol;
13480 mp->entry.local_port_start = ntohs ((u16) lport_start);
13481 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
13482 mp->entry.remote_port_start = ntohs ((u16) rport_start);
13483 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
13484 mp->entry.policy = (u8) policy;
13485 mp->entry.sa_id = ntohl (sa_id);
13493 api_ipsec_sad_entry_add_del (vat_main_t * vam)
13495 unformat_input_t *i = vam->input;
13496 vl_api_ipsec_sad_entry_add_del_t *mp;
13497 u32 sad_id = 0, spi = 0;
13498 u8 *ck = 0, *ik = 0;
13501 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
13502 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
13503 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
13504 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
13505 vl_api_address_t tun_src, tun_dst;
13508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13510 if (unformat (i, "del"))
13512 else if (unformat (i, "sad_id %d", &sad_id))
13514 else if (unformat (i, "spi %d", &spi))
13516 else if (unformat (i, "esp"))
13517 protocol = IPSEC_API_PROTO_ESP;
13519 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
13521 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13522 if (ADDRESS_IP6 == tun_src.af)
13523 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13526 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
13528 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13529 if (ADDRESS_IP6 == tun_src.af)
13530 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13533 if (unformat (i, "crypto_alg %U",
13534 unformat_ipsec_api_crypto_alg, &crypto_alg))
13536 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13538 else if (unformat (i, "integ_alg %U",
13539 unformat_ipsec_api_integ_alg, &integ_alg))
13541 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13545 clib_warning ("parse error '%U'", format_unformat_error, i);
13551 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
13553 mp->is_add = is_add;
13554 mp->entry.sad_id = ntohl (sad_id);
13555 mp->entry.protocol = protocol;
13556 mp->entry.spi = ntohl (spi);
13557 mp->entry.flags = flags;
13559 mp->entry.crypto_algorithm = crypto_alg;
13560 mp->entry.integrity_algorithm = integ_alg;
13561 mp->entry.crypto_key.length = vec_len (ck);
13562 mp->entry.integrity_key.length = vec_len (ik);
13564 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
13565 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
13567 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
13568 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
13571 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
13573 clib_memcpy (mp->entry.integrity_key.data, ik,
13574 mp->entry.integrity_key.length);
13576 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
13578 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
13579 sizeof (mp->entry.tunnel_src));
13580 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
13581 sizeof (mp->entry.tunnel_dst));
13590 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13592 unformat_input_t *i = vam->input;
13593 vl_api_ipsec_tunnel_if_add_del_t *mp;
13594 u32 local_spi = 0, remote_spi = 0;
13595 u32 crypto_alg = 0, integ_alg = 0;
13596 u8 *lck = NULL, *rck = NULL;
13597 u8 *lik = NULL, *rik = NULL;
13598 vl_api_address_t local_ip = { 0 };
13599 vl_api_address_t remote_ip = { 0 };
13603 u8 anti_replay = 0;
13609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13611 if (unformat (i, "del"))
13613 else if (unformat (i, "esn"))
13615 else if (unformat (i, "anti-replay"))
13617 else if (unformat (i, "count %d", &count))
13619 else if (unformat (i, "local_spi %d", &local_spi))
13621 else if (unformat (i, "remote_spi %d", &remote_spi))
13624 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
13627 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
13629 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13632 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13634 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13636 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13640 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
13642 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
13644 errmsg ("unsupported crypto-alg: '%U'\n",
13645 format_ipsec_crypto_alg, crypto_alg);
13651 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
13653 if (integ_alg >= IPSEC_INTEG_N_ALG)
13655 errmsg ("unsupported integ-alg: '%U'\n",
13656 format_ipsec_integ_alg, integ_alg);
13660 else if (unformat (i, "instance %u", &instance))
13664 errmsg ("parse error '%U'\n", format_unformat_error, i);
13671 /* Turn on async mode */
13672 vam->async_mode = 1;
13673 vam->async_errors = 0;
13674 before = vat_time_now (vam);
13677 for (jj = 0; jj < count; jj++)
13679 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13681 mp->is_add = is_add;
13683 mp->anti_replay = anti_replay;
13686 increment_address (&remote_ip);
13688 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
13689 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
13691 mp->local_spi = htonl (local_spi + jj);
13692 mp->remote_spi = htonl (remote_spi + jj);
13693 mp->crypto_alg = (u8) crypto_alg;
13695 mp->local_crypto_key_len = 0;
13698 mp->local_crypto_key_len = vec_len (lck);
13699 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13700 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13701 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13704 mp->remote_crypto_key_len = 0;
13707 mp->remote_crypto_key_len = vec_len (rck);
13708 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13709 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13710 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13713 mp->integ_alg = (u8) integ_alg;
13715 mp->local_integ_key_len = 0;
13718 mp->local_integ_key_len = vec_len (lik);
13719 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13720 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13721 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13724 mp->remote_integ_key_len = 0;
13727 mp->remote_integ_key_len = vec_len (rik);
13728 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13729 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13730 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13735 mp->renumber = renumber;
13736 mp->show_instance = ntohl (instance);
13741 /* When testing multiple add/del ops, use a control-ping to sync */
13744 vl_api_control_ping_t *mp_ping;
13748 /* Shut off async mode */
13749 vam->async_mode = 0;
13751 MPING (CONTROL_PING, mp_ping);
13754 timeout = vat_time_now (vam) + 1.0;
13755 while (vat_time_now (vam) < timeout)
13756 if (vam->result_ready == 1)
13761 if (vam->retval == -99)
13762 errmsg ("timeout");
13764 if (vam->async_errors > 0)
13766 errmsg ("%d asynchronous errors", vam->async_errors);
13769 vam->async_errors = 0;
13770 after = vat_time_now (vam);
13772 /* slim chance, but we might have eaten SIGTERM on the first iteration */
13776 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
13777 count, after - before, count / (after - before));
13781 /* Wait for a reply... */
13790 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
13792 vat_main_t *vam = &vat_main;
13794 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
13795 "crypto_key %U integ_alg %u integ_key %U flags %x "
13796 "tunnel_src_addr %U tunnel_dst_addr %U "
13797 "salt %u seq_outbound %lu last_seq_inbound %lu "
13798 "replay_window %lu\n",
13799 ntohl (mp->entry.sad_id),
13800 ntohl (mp->sw_if_index),
13801 ntohl (mp->entry.spi),
13802 ntohl (mp->entry.protocol),
13803 ntohl (mp->entry.crypto_algorithm),
13804 format_hex_bytes, mp->entry.crypto_key.data,
13805 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
13806 format_hex_bytes, mp->entry.integrity_key.data,
13807 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
13808 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
13809 &mp->entry.tunnel_dst, ntohl (mp->salt),
13810 clib_net_to_host_u64 (mp->seq_outbound),
13811 clib_net_to_host_u64 (mp->last_seq_inbound),
13812 clib_net_to_host_u64 (mp->replay_window));
13815 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
13816 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
13818 static void vl_api_ipsec_sa_details_t_handler_json
13819 (vl_api_ipsec_sa_details_t * mp)
13821 vat_main_t *vam = &vat_main;
13822 vat_json_node_t *node = NULL;
13823 vl_api_ipsec_sad_flags_t flags;
13825 if (VAT_JSON_ARRAY != vam->json_tree.type)
13827 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13828 vat_json_init_array (&vam->json_tree);
13830 node = vat_json_array_add (&vam->json_tree);
13832 vat_json_init_object (node);
13833 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
13834 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13835 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
13836 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
13837 vat_json_object_add_uint (node, "crypto_alg",
13838 ntohl (mp->entry.crypto_algorithm));
13839 vat_json_object_add_uint (node, "integ_alg",
13840 ntohl (mp->entry.integrity_algorithm));
13841 flags = ntohl (mp->entry.flags);
13842 vat_json_object_add_uint (node, "use_esn",
13843 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
13844 vat_json_object_add_uint (node, "use_anti_replay",
13845 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
13846 vat_json_object_add_uint (node, "is_tunnel",
13847 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
13848 vat_json_object_add_uint (node, "is_tunnel_ip6",
13849 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
13850 vat_json_object_add_uint (node, "udp_encap",
13851 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
13852 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
13853 mp->entry.crypto_key.length);
13854 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
13855 mp->entry.integrity_key.length);
13856 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
13857 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
13858 vat_json_object_add_uint (node, "replay_window",
13859 clib_net_to_host_u64 (mp->replay_window));
13863 api_ipsec_sa_dump (vat_main_t * vam)
13865 unformat_input_t *i = vam->input;
13866 vl_api_ipsec_sa_dump_t *mp;
13867 vl_api_control_ping_t *mp_ping;
13871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13873 if (unformat (i, "sa_id %d", &sa_id))
13877 clib_warning ("parse error '%U'", format_unformat_error, i);
13882 M (IPSEC_SA_DUMP, mp);
13884 mp->sa_id = ntohl (sa_id);
13888 /* Use a control ping for synchronization */
13889 M (CONTROL_PING, mp_ping);
13897 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
13899 unformat_input_t *i = vam->input;
13900 vl_api_ipsec_tunnel_if_set_sa_t *mp;
13901 u32 sw_if_index = ~0;
13903 u8 is_outbound = (u8) ~ 0;
13906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13908 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13910 else if (unformat (i, "sa_id %d", &sa_id))
13912 else if (unformat (i, "outbound"))
13914 else if (unformat (i, "inbound"))
13918 clib_warning ("parse error '%U'", format_unformat_error, i);
13923 if (sw_if_index == ~0)
13925 errmsg ("interface must be specified");
13931 errmsg ("SA ID must be specified");
13935 M (IPSEC_TUNNEL_IF_SET_SA, mp);
13937 mp->sw_if_index = htonl (sw_if_index);
13938 mp->sa_id = htonl (sa_id);
13939 mp->is_outbound = is_outbound;
13948 api_get_first_msg_id (vat_main_t * vam)
13950 vl_api_get_first_msg_id_t *mp;
13951 unformat_input_t *i = vam->input;
13956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13958 if (unformat (i, "client %s", &name))
13966 errmsg ("missing client name");
13969 vec_add1 (name, 0);
13971 if (vec_len (name) > 63)
13973 errmsg ("client name too long");
13977 M (GET_FIRST_MSG_ID, mp);
13978 clib_memcpy (mp->name, name, vec_len (name));
13985 api_cop_interface_enable_disable (vat_main_t * vam)
13987 unformat_input_t *line_input = vam->input;
13988 vl_api_cop_interface_enable_disable_t *mp;
13989 u32 sw_if_index = ~0;
13990 u8 enable_disable = 1;
13993 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13995 if (unformat (line_input, "disable"))
13996 enable_disable = 0;
13997 if (unformat (line_input, "enable"))
13998 enable_disable = 1;
13999 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14000 vam, &sw_if_index))
14002 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14008 if (sw_if_index == ~0)
14010 errmsg ("missing interface name or sw_if_index");
14014 /* Construct the API message */
14015 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14016 mp->sw_if_index = ntohl (sw_if_index);
14017 mp->enable_disable = enable_disable;
14021 /* Wait for the reply */
14027 api_cop_whitelist_enable_disable (vat_main_t * vam)
14029 unformat_input_t *line_input = vam->input;
14030 vl_api_cop_whitelist_enable_disable_t *mp;
14031 u32 sw_if_index = ~0;
14032 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14036 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14038 if (unformat (line_input, "ip4"))
14040 else if (unformat (line_input, "ip6"))
14042 else if (unformat (line_input, "default"))
14044 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14045 vam, &sw_if_index))
14047 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14049 else if (unformat (line_input, "fib-id %d", &fib_id))
14055 if (sw_if_index == ~0)
14057 errmsg ("missing interface name or sw_if_index");
14061 /* Construct the API message */
14062 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14063 mp->sw_if_index = ntohl (sw_if_index);
14064 mp->fib_id = ntohl (fib_id);
14067 mp->default_cop = default_cop;
14071 /* Wait for the reply */
14077 api_get_node_graph (vat_main_t * vam)
14079 vl_api_get_node_graph_t *mp;
14082 M (GET_NODE_GRAPH, mp);
14086 /* Wait for the reply */
14092 /** Used for parsing LISP eids */
14093 typedef CLIB_PACKED(struct{
14094 u8 addr[16]; /**< eid address */
14095 u32 len; /**< prefix length if IP */
14096 u8 type; /**< type of eid */
14101 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14103 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14105 clib_memset (a, 0, sizeof (a[0]));
14107 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14109 a->type = 0; /* ipv4 type */
14111 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14113 a->type = 1; /* ipv6 type */
14115 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14117 a->type = 2; /* mac type */
14119 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14121 a->type = 3; /* NSH type */
14122 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14123 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14130 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14139 lisp_eid_size_vat (u8 type)
14156 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14158 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14162 api_one_add_del_locator_set (vat_main_t * vam)
14164 unformat_input_t *input = vam->input;
14165 vl_api_one_add_del_locator_set_t *mp;
14167 u8 *locator_set_name = NULL;
14168 u8 locator_set_name_set = 0;
14169 vl_api_local_locator_t locator, *locators = 0;
14170 u32 sw_if_index, priority, weight;
14174 /* Parse args required to build the message */
14175 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14177 if (unformat (input, "del"))
14181 else if (unformat (input, "locator-set %s", &locator_set_name))
14183 locator_set_name_set = 1;
14185 else if (unformat (input, "sw_if_index %u p %u w %u",
14186 &sw_if_index, &priority, &weight))
14188 locator.sw_if_index = htonl (sw_if_index);
14189 locator.priority = priority;
14190 locator.weight = weight;
14191 vec_add1 (locators, locator);
14195 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14196 &sw_if_index, &priority, &weight))
14198 locator.sw_if_index = htonl (sw_if_index);
14199 locator.priority = priority;
14200 locator.weight = weight;
14201 vec_add1 (locators, locator);
14207 if (locator_set_name_set == 0)
14209 errmsg ("missing locator-set name");
14210 vec_free (locators);
14214 if (vec_len (locator_set_name) > 64)
14216 errmsg ("locator-set name too long");
14217 vec_free (locator_set_name);
14218 vec_free (locators);
14221 vec_add1 (locator_set_name, 0);
14223 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14225 /* Construct the API message */
14226 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14228 mp->is_add = is_add;
14229 clib_memcpy (mp->locator_set_name, locator_set_name,
14230 vec_len (locator_set_name));
14231 vec_free (locator_set_name);
14233 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14235 clib_memcpy (mp->locators, locators, data_len);
14236 vec_free (locators);
14241 /* Wait for a reply... */
14246 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14249 api_one_add_del_locator (vat_main_t * vam)
14251 unformat_input_t *input = vam->input;
14252 vl_api_one_add_del_locator_t *mp;
14253 u32 tmp_if_index = ~0;
14254 u32 sw_if_index = ~0;
14255 u8 sw_if_index_set = 0;
14256 u8 sw_if_index_if_name_set = 0;
14258 u8 priority_set = 0;
14262 u8 *locator_set_name = NULL;
14263 u8 locator_set_name_set = 0;
14266 /* Parse args required to build the message */
14267 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14269 if (unformat (input, "del"))
14273 else if (unformat (input, "locator-set %s", &locator_set_name))
14275 locator_set_name_set = 1;
14277 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14280 sw_if_index_if_name_set = 1;
14281 sw_if_index = tmp_if_index;
14283 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14285 sw_if_index_set = 1;
14286 sw_if_index = tmp_if_index;
14288 else if (unformat (input, "p %d", &priority))
14292 else if (unformat (input, "w %d", &weight))
14300 if (locator_set_name_set == 0)
14302 errmsg ("missing locator-set name");
14306 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14308 errmsg ("missing sw_if_index");
14309 vec_free (locator_set_name);
14313 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14315 errmsg ("cannot use both params interface name and sw_if_index");
14316 vec_free (locator_set_name);
14320 if (priority_set == 0)
14322 errmsg ("missing locator-set priority");
14323 vec_free (locator_set_name);
14327 if (weight_set == 0)
14329 errmsg ("missing locator-set weight");
14330 vec_free (locator_set_name);
14334 if (vec_len (locator_set_name) > 64)
14336 errmsg ("locator-set name too long");
14337 vec_free (locator_set_name);
14340 vec_add1 (locator_set_name, 0);
14342 /* Construct the API message */
14343 M (ONE_ADD_DEL_LOCATOR, mp);
14345 mp->is_add = is_add;
14346 mp->sw_if_index = ntohl (sw_if_index);
14347 mp->priority = priority;
14348 mp->weight = weight;
14349 clib_memcpy (mp->locator_set_name, locator_set_name,
14350 vec_len (locator_set_name));
14351 vec_free (locator_set_name);
14356 /* Wait for a reply... */
14361 #define api_lisp_add_del_locator api_one_add_del_locator
14364 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14366 u32 *key_id = va_arg (*args, u32 *);
14369 if (unformat (input, "%s", &s))
14371 if (!strcmp ((char *) s, "sha1"))
14372 key_id[0] = HMAC_SHA_1_96;
14373 else if (!strcmp ((char *) s, "sha256"))
14374 key_id[0] = HMAC_SHA_256_128;
14377 clib_warning ("invalid key_id: '%s'", s);
14378 key_id[0] = HMAC_NO_KEY;
14389 api_one_add_del_local_eid (vat_main_t * vam)
14391 unformat_input_t *input = vam->input;
14392 vl_api_one_add_del_local_eid_t *mp;
14395 lisp_eid_vat_t _eid, *eid = &_eid;
14396 u8 *locator_set_name = 0;
14397 u8 locator_set_name_set = 0;
14403 /* Parse args required to build the message */
14404 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14406 if (unformat (input, "del"))
14410 else if (unformat (input, "vni %d", &vni))
14414 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14418 else if (unformat (input, "locator-set %s", &locator_set_name))
14420 locator_set_name_set = 1;
14422 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14424 else if (unformat (input, "secret-key %_%v%_", &key))
14430 if (locator_set_name_set == 0)
14432 errmsg ("missing locator-set name");
14438 errmsg ("EID address not set!");
14439 vec_free (locator_set_name);
14443 if (key && (0 == key_id))
14445 errmsg ("invalid key_id!");
14449 if (vec_len (key) > 64)
14451 errmsg ("key too long");
14456 if (vec_len (locator_set_name) > 64)
14458 errmsg ("locator-set name too long");
14459 vec_free (locator_set_name);
14462 vec_add1 (locator_set_name, 0);
14464 /* Construct the API message */
14465 M (ONE_ADD_DEL_LOCAL_EID, mp);
14467 mp->is_add = is_add;
14468 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14469 mp->eid_type = eid->type;
14470 mp->prefix_len = eid->len;
14471 mp->vni = clib_host_to_net_u32 (vni);
14472 mp->key_id = clib_host_to_net_u16 (key_id);
14473 clib_memcpy (mp->locator_set_name, locator_set_name,
14474 vec_len (locator_set_name));
14475 clib_memcpy (mp->key, key, vec_len (key));
14477 vec_free (locator_set_name);
14483 /* Wait for a reply... */
14488 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14491 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14493 u32 dp_table = 0, vni = 0;;
14494 unformat_input_t *input = vam->input;
14495 vl_api_gpe_add_del_fwd_entry_t *mp;
14497 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14498 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14499 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14500 u32 action = ~0, w;
14501 ip4_address_t rmt_rloc4, lcl_rloc4;
14502 ip6_address_t rmt_rloc6, lcl_rloc6;
14503 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14506 clib_memset (&rloc, 0, sizeof (rloc));
14508 /* Parse args required to build the message */
14509 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14511 if (unformat (input, "del"))
14513 else if (unformat (input, "add"))
14515 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14519 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14523 else if (unformat (input, "vrf %d", &dp_table))
14525 else if (unformat (input, "bd %d", &dp_table))
14527 else if (unformat (input, "vni %d", &vni))
14529 else if (unformat (input, "w %d", &w))
14533 errmsg ("No RLOC configured for setting priority/weight!");
14536 curr_rloc->weight = w;
14538 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14539 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14543 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14545 vec_add1 (lcl_locs, rloc);
14547 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14548 vec_add1 (rmt_locs, rloc);
14549 /* weight saved in rmt loc */
14550 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14552 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14553 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14556 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14558 vec_add1 (lcl_locs, rloc);
14560 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14561 vec_add1 (rmt_locs, rloc);
14562 /* weight saved in rmt loc */
14563 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14565 else if (unformat (input, "action %d", &action))
14571 clib_warning ("parse error '%U'", format_unformat_error, input);
14578 errmsg ("remote eid addresses not set");
14582 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14584 errmsg ("eid types don't match");
14588 if (0 == rmt_locs && (u32) ~ 0 == action)
14590 errmsg ("action not set for negative mapping");
14594 /* Construct the API message */
14595 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14596 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14598 mp->is_add = is_add;
14599 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14600 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14601 mp->eid_type = rmt_eid->type;
14602 mp->dp_table = clib_host_to_net_u32 (dp_table);
14603 mp->vni = clib_host_to_net_u32 (vni);
14604 mp->rmt_len = rmt_eid->len;
14605 mp->lcl_len = lcl_eid->len;
14606 mp->action = action;
14608 if (0 != rmt_locs && 0 != lcl_locs)
14610 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14611 clib_memcpy (mp->locs, lcl_locs,
14612 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14614 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14615 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14616 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14618 vec_free (lcl_locs);
14619 vec_free (rmt_locs);
14624 /* Wait for a reply... */
14630 api_one_add_del_map_server (vat_main_t * vam)
14632 unformat_input_t *input = vam->input;
14633 vl_api_one_add_del_map_server_t *mp;
14637 ip4_address_t ipv4;
14638 ip6_address_t ipv6;
14641 /* Parse args required to build the message */
14642 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14644 if (unformat (input, "del"))
14648 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14652 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14660 if (ipv4_set && ipv6_set)
14662 errmsg ("both eid v4 and v6 addresses set");
14666 if (!ipv4_set && !ipv6_set)
14668 errmsg ("eid addresses not set");
14672 /* Construct the API message */
14673 M (ONE_ADD_DEL_MAP_SERVER, mp);
14675 mp->is_add = is_add;
14679 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14684 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14690 /* Wait for a reply... */
14695 #define api_lisp_add_del_map_server api_one_add_del_map_server
14698 api_one_add_del_map_resolver (vat_main_t * vam)
14700 unformat_input_t *input = vam->input;
14701 vl_api_one_add_del_map_resolver_t *mp;
14705 ip4_address_t ipv4;
14706 ip6_address_t ipv6;
14709 /* Parse args required to build the message */
14710 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14712 if (unformat (input, "del"))
14716 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14720 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14728 if (ipv4_set && ipv6_set)
14730 errmsg ("both eid v4 and v6 addresses set");
14734 if (!ipv4_set && !ipv6_set)
14736 errmsg ("eid addresses not set");
14740 /* Construct the API message */
14741 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14743 mp->is_add = is_add;
14747 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14752 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14758 /* Wait for a reply... */
14763 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14766 api_lisp_gpe_enable_disable (vat_main_t * vam)
14768 unformat_input_t *input = vam->input;
14769 vl_api_gpe_enable_disable_t *mp;
14774 /* Parse args required to build the message */
14775 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14777 if (unformat (input, "enable"))
14782 else if (unformat (input, "disable"))
14793 errmsg ("Value not set");
14797 /* Construct the API message */
14798 M (GPE_ENABLE_DISABLE, mp);
14805 /* Wait for a reply... */
14811 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14813 unformat_input_t *input = vam->input;
14814 vl_api_one_rloc_probe_enable_disable_t *mp;
14819 /* Parse args required to build the message */
14820 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14822 if (unformat (input, "enable"))
14827 else if (unformat (input, "disable"))
14835 errmsg ("Value not set");
14839 /* Construct the API message */
14840 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14842 mp->is_enabled = is_en;
14847 /* Wait for a reply... */
14852 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14855 api_one_map_register_enable_disable (vat_main_t * vam)
14857 unformat_input_t *input = vam->input;
14858 vl_api_one_map_register_enable_disable_t *mp;
14863 /* Parse args required to build the message */
14864 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14866 if (unformat (input, "enable"))
14871 else if (unformat (input, "disable"))
14879 errmsg ("Value not set");
14883 /* Construct the API message */
14884 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14886 mp->is_enabled = is_en;
14891 /* Wait for a reply... */
14896 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14899 api_one_enable_disable (vat_main_t * vam)
14901 unformat_input_t *input = vam->input;
14902 vl_api_one_enable_disable_t *mp;
14907 /* Parse args required to build the message */
14908 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14910 if (unformat (input, "enable"))
14915 else if (unformat (input, "disable"))
14925 errmsg ("Value not set");
14929 /* Construct the API message */
14930 M (ONE_ENABLE_DISABLE, mp);
14937 /* Wait for a reply... */
14942 #define api_lisp_enable_disable api_one_enable_disable
14945 api_one_enable_disable_xtr_mode (vat_main_t * vam)
14947 unformat_input_t *input = vam->input;
14948 vl_api_one_enable_disable_xtr_mode_t *mp;
14953 /* Parse args required to build the message */
14954 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14956 if (unformat (input, "enable"))
14961 else if (unformat (input, "disable"))
14971 errmsg ("Value not set");
14975 /* Construct the API message */
14976 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
14983 /* Wait for a reply... */
14989 api_one_show_xtr_mode (vat_main_t * vam)
14991 vl_api_one_show_xtr_mode_t *mp;
14994 /* Construct the API message */
14995 M (ONE_SHOW_XTR_MODE, mp);
15000 /* Wait for a reply... */
15006 api_one_enable_disable_pitr_mode (vat_main_t * vam)
15008 unformat_input_t *input = vam->input;
15009 vl_api_one_enable_disable_pitr_mode_t *mp;
15014 /* Parse args required to build the message */
15015 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15017 if (unformat (input, "enable"))
15022 else if (unformat (input, "disable"))
15032 errmsg ("Value not set");
15036 /* Construct the API message */
15037 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
15044 /* Wait for a reply... */
15050 api_one_show_pitr_mode (vat_main_t * vam)
15052 vl_api_one_show_pitr_mode_t *mp;
15055 /* Construct the API message */
15056 M (ONE_SHOW_PITR_MODE, mp);
15061 /* Wait for a reply... */
15067 api_one_enable_disable_petr_mode (vat_main_t * vam)
15069 unformat_input_t *input = vam->input;
15070 vl_api_one_enable_disable_petr_mode_t *mp;
15075 /* Parse args required to build the message */
15076 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15078 if (unformat (input, "enable"))
15083 else if (unformat (input, "disable"))
15093 errmsg ("Value not set");
15097 /* Construct the API message */
15098 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
15105 /* Wait for a reply... */
15111 api_one_show_petr_mode (vat_main_t * vam)
15113 vl_api_one_show_petr_mode_t *mp;
15116 /* Construct the API message */
15117 M (ONE_SHOW_PETR_MODE, mp);
15122 /* Wait for a reply... */
15128 api_show_one_map_register_state (vat_main_t * vam)
15130 vl_api_show_one_map_register_state_t *mp;
15133 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15138 /* wait for reply */
15143 #define api_show_lisp_map_register_state api_show_one_map_register_state
15146 api_show_one_rloc_probe_state (vat_main_t * vam)
15148 vl_api_show_one_rloc_probe_state_t *mp;
15151 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15156 /* wait for reply */
15161 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15164 api_one_add_del_ndp_entry (vat_main_t * vam)
15166 vl_api_one_add_del_ndp_entry_t *mp;
15167 unformat_input_t *input = vam->input;
15172 u8 mac[6] = { 0, };
15173 u8 ip6[16] = { 0, };
15177 /* Parse args required to build the message */
15178 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15180 if (unformat (input, "del"))
15182 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15184 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15186 else if (unformat (input, "bd %d", &bd))
15190 errmsg ("parse error '%U'", format_unformat_error, input);
15195 if (!bd_set || !ip_set || (!mac_set && is_add))
15197 errmsg ("Missing BD, IP or MAC!");
15201 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15202 mp->is_add = is_add;
15203 clib_memcpy (mp->mac, mac, 6);
15204 mp->bd = clib_host_to_net_u32 (bd);
15205 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
15210 /* wait for reply */
15216 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15218 vl_api_one_add_del_l2_arp_entry_t *mp;
15219 unformat_input_t *input = vam->input;
15224 u8 mac[6] = { 0, };
15225 u32 ip4 = 0, bd = ~0;
15228 /* Parse args required to build the message */
15229 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15231 if (unformat (input, "del"))
15233 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15235 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15237 else if (unformat (input, "bd %d", &bd))
15241 errmsg ("parse error '%U'", format_unformat_error, input);
15246 if (!bd_set || !ip_set || (!mac_set && is_add))
15248 errmsg ("Missing BD, IP or MAC!");
15252 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15253 mp->is_add = is_add;
15254 clib_memcpy (mp->mac, mac, 6);
15255 mp->bd = clib_host_to_net_u32 (bd);
15261 /* wait for reply */
15267 api_one_ndp_bd_get (vat_main_t * vam)
15269 vl_api_one_ndp_bd_get_t *mp;
15272 M (ONE_NDP_BD_GET, mp);
15277 /* wait for reply */
15283 api_one_ndp_entries_get (vat_main_t * vam)
15285 vl_api_one_ndp_entries_get_t *mp;
15286 unformat_input_t *input = vam->input;
15291 /* Parse args required to build the message */
15292 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15294 if (unformat (input, "bd %d", &bd))
15298 errmsg ("parse error '%U'", format_unformat_error, input);
15305 errmsg ("Expected bridge domain!");
15309 M (ONE_NDP_ENTRIES_GET, mp);
15310 mp->bd = clib_host_to_net_u32 (bd);
15315 /* wait for reply */
15321 api_one_l2_arp_bd_get (vat_main_t * vam)
15323 vl_api_one_l2_arp_bd_get_t *mp;
15326 M (ONE_L2_ARP_BD_GET, mp);
15331 /* wait for reply */
15337 api_one_l2_arp_entries_get (vat_main_t * vam)
15339 vl_api_one_l2_arp_entries_get_t *mp;
15340 unformat_input_t *input = vam->input;
15345 /* Parse args required to build the message */
15346 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15348 if (unformat (input, "bd %d", &bd))
15352 errmsg ("parse error '%U'", format_unformat_error, input);
15359 errmsg ("Expected bridge domain!");
15363 M (ONE_L2_ARP_ENTRIES_GET, mp);
15364 mp->bd = clib_host_to_net_u32 (bd);
15369 /* wait for reply */
15375 api_one_stats_enable_disable (vat_main_t * vam)
15377 vl_api_one_stats_enable_disable_t *mp;
15378 unformat_input_t *input = vam->input;
15383 /* Parse args required to build the message */
15384 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15386 if (unformat (input, "enable"))
15391 else if (unformat (input, "disable"))
15401 errmsg ("Value not set");
15405 M (ONE_STATS_ENABLE_DISABLE, mp);
15411 /* wait for reply */
15417 api_show_one_stats_enable_disable (vat_main_t * vam)
15419 vl_api_show_one_stats_enable_disable_t *mp;
15422 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15427 /* wait for reply */
15433 api_show_one_map_request_mode (vat_main_t * vam)
15435 vl_api_show_one_map_request_mode_t *mp;
15438 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15443 /* wait for reply */
15448 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15451 api_one_map_request_mode (vat_main_t * vam)
15453 unformat_input_t *input = vam->input;
15454 vl_api_one_map_request_mode_t *mp;
15458 /* Parse args required to build the message */
15459 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15461 if (unformat (input, "dst-only"))
15463 else if (unformat (input, "src-dst"))
15467 errmsg ("parse error '%U'", format_unformat_error, input);
15472 M (ONE_MAP_REQUEST_MODE, mp);
15479 /* wait for reply */
15484 #define api_lisp_map_request_mode api_one_map_request_mode
15487 * Enable/disable ONE proxy ITR.
15489 * @param vam vpp API test context
15490 * @return return code
15493 api_one_pitr_set_locator_set (vat_main_t * vam)
15495 u8 ls_name_set = 0;
15496 unformat_input_t *input = vam->input;
15497 vl_api_one_pitr_set_locator_set_t *mp;
15502 /* Parse args required to build the message */
15503 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15505 if (unformat (input, "del"))
15507 else if (unformat (input, "locator-set %s", &ls_name))
15511 errmsg ("parse error '%U'", format_unformat_error, input);
15518 errmsg ("locator-set name not set!");
15522 M (ONE_PITR_SET_LOCATOR_SET, mp);
15524 mp->is_add = is_add;
15525 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15526 vec_free (ls_name);
15531 /* wait for reply */
15536 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15539 api_one_nsh_set_locator_set (vat_main_t * vam)
15541 u8 ls_name_set = 0;
15542 unformat_input_t *input = vam->input;
15543 vl_api_one_nsh_set_locator_set_t *mp;
15548 /* Parse args required to build the message */
15549 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15551 if (unformat (input, "del"))
15553 else if (unformat (input, "ls %s", &ls_name))
15557 errmsg ("parse error '%U'", format_unformat_error, input);
15562 if (!ls_name_set && is_add)
15564 errmsg ("locator-set name not set!");
15568 M (ONE_NSH_SET_LOCATOR_SET, mp);
15570 mp->is_add = is_add;
15571 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15572 vec_free (ls_name);
15577 /* wait for reply */
15583 api_show_one_pitr (vat_main_t * vam)
15585 vl_api_show_one_pitr_t *mp;
15588 if (!vam->json_output)
15590 print (vam->ofp, "%=20s", "lisp status:");
15593 M (SHOW_ONE_PITR, mp);
15597 /* Wait for a reply... */
15602 #define api_show_lisp_pitr api_show_one_pitr
15605 api_one_use_petr (vat_main_t * vam)
15607 unformat_input_t *input = vam->input;
15608 vl_api_one_use_petr_t *mp;
15613 clib_memset (&ip, 0, sizeof (ip));
15615 /* Parse args required to build the message */
15616 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15618 if (unformat (input, "disable"))
15621 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15624 ip_addr_version (&ip) = AF_IP4;
15627 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15630 ip_addr_version (&ip) = AF_IP6;
15634 errmsg ("parse error '%U'", format_unformat_error, input);
15639 M (ONE_USE_PETR, mp);
15641 mp->is_add = is_add;
15644 mp->is_ip4 = ip_addr_version (&ip) == AF_IP4 ? 1 : 0;
15646 clib_memcpy (mp->address, &ip, 4);
15648 clib_memcpy (mp->address, &ip, 16);
15654 /* wait for reply */
15659 #define api_lisp_use_petr api_one_use_petr
15662 api_show_one_nsh_mapping (vat_main_t * vam)
15664 vl_api_show_one_use_petr_t *mp;
15667 if (!vam->json_output)
15669 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15672 M (SHOW_ONE_NSH_MAPPING, mp);
15676 /* Wait for a reply... */
15682 api_show_one_use_petr (vat_main_t * vam)
15684 vl_api_show_one_use_petr_t *mp;
15687 if (!vam->json_output)
15689 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15692 M (SHOW_ONE_USE_PETR, mp);
15696 /* Wait for a reply... */
15701 #define api_show_lisp_use_petr api_show_one_use_petr
15704 * Add/delete mapping between vni and vrf
15707 api_one_eid_table_add_del_map (vat_main_t * vam)
15709 unformat_input_t *input = vam->input;
15710 vl_api_one_eid_table_add_del_map_t *mp;
15711 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15712 u32 vni, vrf, bd_index;
15715 /* Parse args required to build the message */
15716 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15718 if (unformat (input, "del"))
15720 else if (unformat (input, "vrf %d", &vrf))
15722 else if (unformat (input, "bd_index %d", &bd_index))
15724 else if (unformat (input, "vni %d", &vni))
15730 if (!vni_set || (!vrf_set && !bd_index_set))
15732 errmsg ("missing arguments!");
15736 if (vrf_set && bd_index_set)
15738 errmsg ("error: both vrf and bd entered!");
15742 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15744 mp->is_add = is_add;
15745 mp->vni = htonl (vni);
15746 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15747 mp->is_l2 = bd_index_set;
15752 /* wait for reply */
15757 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15760 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15762 u32 *action = va_arg (*args, u32 *);
15765 if (unformat (input, "%s", &s))
15767 if (!strcmp ((char *) s, "no-action"))
15769 else if (!strcmp ((char *) s, "natively-forward"))
15771 else if (!strcmp ((char *) s, "send-map-request"))
15773 else if (!strcmp ((char *) s, "drop"))
15777 clib_warning ("invalid action: '%s'", s);
15789 * Add/del remote mapping to/from ONE control plane
15791 * @param vam vpp API test context
15792 * @return return code
15795 api_one_add_del_remote_mapping (vat_main_t * vam)
15797 unformat_input_t *input = vam->input;
15798 vl_api_one_add_del_remote_mapping_t *mp;
15800 lisp_eid_vat_t _eid, *eid = &_eid;
15801 lisp_eid_vat_t _seid, *seid = &_seid;
15802 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15803 u32 action = ~0, p, w, data_len;
15804 ip4_address_t rloc4;
15805 ip6_address_t rloc6;
15806 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15809 clib_memset (&rloc, 0, sizeof (rloc));
15811 /* Parse args required to build the message */
15812 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15814 if (unformat (input, "del-all"))
15818 else if (unformat (input, "del"))
15822 else if (unformat (input, "add"))
15826 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15830 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15834 else if (unformat (input, "vni %d", &vni))
15838 else if (unformat (input, "p %d w %d", &p, &w))
15842 errmsg ("No RLOC configured for setting priority/weight!");
15845 curr_rloc->priority = p;
15846 curr_rloc->weight = w;
15848 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15851 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15852 vec_add1 (rlocs, rloc);
15853 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15855 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15858 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15859 vec_add1 (rlocs, rloc);
15860 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15862 else if (unformat (input, "action %U",
15863 unformat_negative_mapping_action, &action))
15869 clib_warning ("parse error '%U'", format_unformat_error, input);
15876 errmsg ("missing params!");
15880 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15882 errmsg ("no action set for negative map-reply!");
15886 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15888 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15889 mp->is_add = is_add;
15890 mp->vni = htonl (vni);
15891 mp->action = (u8) action;
15892 mp->is_src_dst = seid_set;
15893 mp->eid_len = eid->len;
15894 mp->seid_len = seid->len;
15895 mp->del_all = del_all;
15896 mp->eid_type = eid->type;
15897 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15898 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15900 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15901 clib_memcpy (mp->rlocs, rlocs, data_len);
15907 /* Wait for a reply... */
15912 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15915 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15916 * forwarding entries in data-plane accordingly.
15918 * @param vam vpp API test context
15919 * @return return code
15922 api_one_add_del_adjacency (vat_main_t * vam)
15924 unformat_input_t *input = vam->input;
15925 vl_api_one_add_del_adjacency_t *mp;
15927 ip4_address_t leid4, reid4;
15928 ip6_address_t leid6, reid6;
15929 u8 reid_mac[6] = { 0 };
15930 u8 leid_mac[6] = { 0 };
15931 u8 reid_type, leid_type;
15932 u32 leid_len = 0, reid_len = 0, len;
15936 leid_type = reid_type = (u8) ~ 0;
15938 /* Parse args required to build the message */
15939 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15941 if (unformat (input, "del"))
15945 else if (unformat (input, "add"))
15949 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15952 reid_type = 0; /* ipv4 */
15955 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15958 reid_type = 1; /* ipv6 */
15961 else if (unformat (input, "reid %U", unformat_ethernet_address,
15964 reid_type = 2; /* mac */
15966 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15969 leid_type = 0; /* ipv4 */
15972 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15975 leid_type = 1; /* ipv6 */
15978 else if (unformat (input, "leid %U", unformat_ethernet_address,
15981 leid_type = 2; /* mac */
15983 else if (unformat (input, "vni %d", &vni))
15989 errmsg ("parse error '%U'", format_unformat_error, input);
15994 if ((u8) ~ 0 == reid_type)
15996 errmsg ("missing params!");
16000 if (leid_type != reid_type)
16002 errmsg ("remote and local EIDs are of different types!");
16006 M (ONE_ADD_DEL_ADJACENCY, mp);
16007 mp->is_add = is_add;
16008 mp->vni = htonl (vni);
16009 mp->leid_len = leid_len;
16010 mp->reid_len = reid_len;
16011 mp->eid_type = reid_type;
16013 switch (mp->eid_type)
16016 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
16017 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
16020 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
16021 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
16024 clib_memcpy (mp->leid, leid_mac, 6);
16025 clib_memcpy (mp->reid, reid_mac, 6);
16028 errmsg ("unknown EID type %d!", mp->eid_type);
16035 /* Wait for a reply... */
16040 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16043 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16045 u32 *mode = va_arg (*args, u32 *);
16047 if (unformat (input, "lisp"))
16049 else if (unformat (input, "vxlan"))
16058 api_gpe_get_encap_mode (vat_main_t * vam)
16060 vl_api_gpe_get_encap_mode_t *mp;
16063 /* Construct the API message */
16064 M (GPE_GET_ENCAP_MODE, mp);
16069 /* Wait for a reply... */
16075 api_gpe_set_encap_mode (vat_main_t * vam)
16077 unformat_input_t *input = vam->input;
16078 vl_api_gpe_set_encap_mode_t *mp;
16082 /* Parse args required to build the message */
16083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16085 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16091 /* Construct the API message */
16092 M (GPE_SET_ENCAP_MODE, mp);
16099 /* Wait for a reply... */
16105 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16107 unformat_input_t *input = vam->input;
16108 vl_api_gpe_add_del_iface_t *mp;
16109 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16110 u32 dp_table = 0, vni = 0;
16113 /* Parse args required to build the message */
16114 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16116 if (unformat (input, "up"))
16121 else if (unformat (input, "down"))
16126 else if (unformat (input, "table_id %d", &dp_table))
16130 else if (unformat (input, "bd_id %d", &dp_table))
16135 else if (unformat (input, "vni %d", &vni))
16143 if (action_set == 0)
16145 errmsg ("Action not set");
16148 if (dp_table_set == 0 || vni_set == 0)
16150 errmsg ("vni and dp_table must be set");
16154 /* Construct the API message */
16155 M (GPE_ADD_DEL_IFACE, mp);
16157 mp->is_add = is_add;
16158 mp->dp_table = clib_host_to_net_u32 (dp_table);
16160 mp->vni = clib_host_to_net_u32 (vni);
16165 /* Wait for a reply... */
16171 api_one_map_register_fallback_threshold (vat_main_t * vam)
16173 unformat_input_t *input = vam->input;
16174 vl_api_one_map_register_fallback_threshold_t *mp;
16179 /* Parse args required to build the message */
16180 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16182 if (unformat (input, "%u", &value))
16186 clib_warning ("parse error '%U'", format_unformat_error, input);
16193 errmsg ("fallback threshold value is missing!");
16197 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16198 mp->value = clib_host_to_net_u32 (value);
16203 /* Wait for a reply... */
16209 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16211 vl_api_show_one_map_register_fallback_threshold_t *mp;
16214 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16219 /* Wait for a reply... */
16225 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
16227 u32 *proto = va_arg (*args, u32 *);
16229 if (unformat (input, "udp"))
16231 else if (unformat (input, "api"))
16240 api_one_set_transport_protocol (vat_main_t * vam)
16242 unformat_input_t *input = vam->input;
16243 vl_api_one_set_transport_protocol_t *mp;
16248 /* Parse args required to build the message */
16249 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16251 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
16255 clib_warning ("parse error '%U'", format_unformat_error, input);
16262 errmsg ("Transport protocol missing!");
16266 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
16267 mp->protocol = (u8) protocol;
16272 /* Wait for a reply... */
16278 api_one_get_transport_protocol (vat_main_t * vam)
16280 vl_api_one_get_transport_protocol_t *mp;
16283 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
16288 /* Wait for a reply... */
16294 api_one_map_register_set_ttl (vat_main_t * vam)
16296 unformat_input_t *input = vam->input;
16297 vl_api_one_map_register_set_ttl_t *mp;
16302 /* Parse args required to build the message */
16303 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16305 if (unformat (input, "%u", &ttl))
16309 clib_warning ("parse error '%U'", format_unformat_error, input);
16316 errmsg ("TTL value missing!");
16320 M (ONE_MAP_REGISTER_SET_TTL, mp);
16321 mp->ttl = clib_host_to_net_u32 (ttl);
16326 /* Wait for a reply... */
16332 api_show_one_map_register_ttl (vat_main_t * vam)
16334 vl_api_show_one_map_register_ttl_t *mp;
16337 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16342 /* Wait for a reply... */
16348 * Add/del map request itr rlocs from ONE control plane and updates
16350 * @param vam vpp API test context
16351 * @return return code
16354 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16356 unformat_input_t *input = vam->input;
16357 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16358 u8 *locator_set_name = 0;
16359 u8 locator_set_name_set = 0;
16363 /* Parse args required to build the message */
16364 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16366 if (unformat (input, "del"))
16370 else if (unformat (input, "%_%v%_", &locator_set_name))
16372 locator_set_name_set = 1;
16376 clib_warning ("parse error '%U'", format_unformat_error, input);
16381 if (is_add && !locator_set_name_set)
16383 errmsg ("itr-rloc is not set!");
16387 if (is_add && vec_len (locator_set_name) > 64)
16389 errmsg ("itr-rloc locator-set name too long");
16390 vec_free (locator_set_name);
16394 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16395 mp->is_add = is_add;
16398 clib_memcpy (mp->locator_set_name, locator_set_name,
16399 vec_len (locator_set_name));
16403 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16405 vec_free (locator_set_name);
16410 /* Wait for a reply... */
16415 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16418 api_one_locator_dump (vat_main_t * vam)
16420 unformat_input_t *input = vam->input;
16421 vl_api_one_locator_dump_t *mp;
16422 vl_api_control_ping_t *mp_ping;
16423 u8 is_index_set = 0, is_name_set = 0;
16428 /* Parse args required to build the message */
16429 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16431 if (unformat (input, "ls_name %_%v%_", &ls_name))
16435 else if (unformat (input, "ls_index %d", &ls_index))
16441 errmsg ("parse error '%U'", format_unformat_error, input);
16446 if (!is_index_set && !is_name_set)
16448 errmsg ("error: expected one of index or name!");
16452 if (is_index_set && is_name_set)
16454 errmsg ("error: only one param expected!");
16458 if (vec_len (ls_name) > 62)
16460 errmsg ("error: locator set name too long!");
16464 if (!vam->json_output)
16466 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16469 M (ONE_LOCATOR_DUMP, mp);
16470 mp->is_index_set = is_index_set;
16473 mp->ls_index = clib_host_to_net_u32 (ls_index);
16476 vec_add1 (ls_name, 0);
16477 strncpy ((char *) mp->ls_name, (char *) ls_name,
16478 sizeof (mp->ls_name) - 1);
16484 /* Use a control ping for synchronization */
16485 MPING (CONTROL_PING, mp_ping);
16488 /* Wait for a reply... */
16493 #define api_lisp_locator_dump api_one_locator_dump
16496 api_one_locator_set_dump (vat_main_t * vam)
16498 vl_api_one_locator_set_dump_t *mp;
16499 vl_api_control_ping_t *mp_ping;
16500 unformat_input_t *input = vam->input;
16504 /* Parse args required to build the message */
16505 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16507 if (unformat (input, "local"))
16511 else if (unformat (input, "remote"))
16517 errmsg ("parse error '%U'", format_unformat_error, input);
16522 if (!vam->json_output)
16524 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16527 M (ONE_LOCATOR_SET_DUMP, mp);
16529 mp->filter = filter;
16534 /* Use a control ping for synchronization */
16535 MPING (CONTROL_PING, mp_ping);
16538 /* Wait for a reply... */
16543 #define api_lisp_locator_set_dump api_one_locator_set_dump
16546 api_one_eid_table_map_dump (vat_main_t * vam)
16550 unformat_input_t *input = vam->input;
16551 vl_api_one_eid_table_map_dump_t *mp;
16552 vl_api_control_ping_t *mp_ping;
16555 /* Parse args required to build the message */
16556 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16558 if (unformat (input, "l2"))
16563 else if (unformat (input, "l3"))
16570 errmsg ("parse error '%U'", format_unformat_error, input);
16577 errmsg ("expected one of 'l2' or 'l3' parameter!");
16581 if (!vam->json_output)
16583 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16586 M (ONE_EID_TABLE_MAP_DUMP, mp);
16592 /* Use a control ping for synchronization */
16593 MPING (CONTROL_PING, mp_ping);
16596 /* Wait for a reply... */
16601 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16604 api_one_eid_table_vni_dump (vat_main_t * vam)
16606 vl_api_one_eid_table_vni_dump_t *mp;
16607 vl_api_control_ping_t *mp_ping;
16610 if (!vam->json_output)
16612 print (vam->ofp, "VNI");
16615 M (ONE_EID_TABLE_VNI_DUMP, mp);
16620 /* Use a control ping for synchronization */
16621 MPING (CONTROL_PING, mp_ping);
16624 /* Wait for a reply... */
16629 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16632 api_one_eid_table_dump (vat_main_t * vam)
16634 unformat_input_t *i = vam->input;
16635 vl_api_one_eid_table_dump_t *mp;
16636 vl_api_control_ping_t *mp_ping;
16637 struct in_addr ip4;
16638 struct in6_addr ip6;
16640 u8 eid_type = ~0, eid_set = 0;
16641 u32 prefix_length = ~0, t, vni = 0;
16644 lisp_nsh_api_t nsh;
16646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16648 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
16654 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
16660 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
16665 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
16670 else if (unformat (i, "vni %d", &t))
16674 else if (unformat (i, "local"))
16678 else if (unformat (i, "remote"))
16684 errmsg ("parse error '%U'", format_unformat_error, i);
16689 if (!vam->json_output)
16691 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16692 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16695 M (ONE_EID_TABLE_DUMP, mp);
16697 mp->filter = filter;
16701 mp->vni = htonl (vni);
16702 mp->eid_type = eid_type;
16706 mp->prefix_length = prefix_length;
16707 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
16710 mp->prefix_length = prefix_length;
16711 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
16714 clib_memcpy (mp->eid, mac, sizeof (mac));
16717 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
16720 errmsg ("unknown EID type %d!", eid_type);
16728 /* Use a control ping for synchronization */
16729 MPING (CONTROL_PING, mp_ping);
16732 /* Wait for a reply... */
16737 #define api_lisp_eid_table_dump api_one_eid_table_dump
16740 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16742 unformat_input_t *i = vam->input;
16743 vl_api_gpe_fwd_entries_get_t *mp;
16748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16750 if (unformat (i, "vni %d", &vni))
16756 errmsg ("parse error '%U'", format_unformat_error, i);
16763 errmsg ("vni not set!");
16767 if (!vam->json_output)
16769 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16773 M (GPE_FWD_ENTRIES_GET, mp);
16774 mp->vni = clib_host_to_net_u32 (vni);
16779 /* Wait for a reply... */
16784 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16785 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16786 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16787 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16788 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16789 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16790 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16791 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16794 api_one_adjacencies_get (vat_main_t * vam)
16796 unformat_input_t *i = vam->input;
16797 vl_api_one_adjacencies_get_t *mp;
16802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16804 if (unformat (i, "vni %d", &vni))
16810 errmsg ("parse error '%U'", format_unformat_error, i);
16817 errmsg ("vni not set!");
16821 if (!vam->json_output)
16823 print (vam->ofp, "%s %40s", "leid", "reid");
16826 M (ONE_ADJACENCIES_GET, mp);
16827 mp->vni = clib_host_to_net_u32 (vni);
16832 /* Wait for a reply... */
16837 #define api_lisp_adjacencies_get api_one_adjacencies_get
16840 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16842 unformat_input_t *i = vam->input;
16843 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16845 u8 ip_family_set = 0, is_ip4 = 1;
16847 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16849 if (unformat (i, "ip4"))
16854 else if (unformat (i, "ip6"))
16861 errmsg ("parse error '%U'", format_unformat_error, i);
16866 if (!ip_family_set)
16868 errmsg ("ip family not set!");
16872 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16873 mp->is_ip4 = is_ip4;
16878 /* Wait for a reply... */
16884 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16886 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16889 if (!vam->json_output)
16891 print (vam->ofp, "VNIs");
16894 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16899 /* Wait for a reply... */
16905 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16907 unformat_input_t *i = vam->input;
16908 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16910 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16911 struct in_addr ip4;
16912 struct in6_addr ip6;
16913 u32 table_id = 0, nh_sw_if_index = ~0;
16915 clib_memset (&ip4, 0, sizeof (ip4));
16916 clib_memset (&ip6, 0, sizeof (ip6));
16918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16920 if (unformat (i, "del"))
16922 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
16923 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16928 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
16929 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16934 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
16938 nh_sw_if_index = ~0;
16940 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
16944 nh_sw_if_index = ~0;
16946 else if (unformat (i, "table %d", &table_id))
16950 errmsg ("parse error '%U'", format_unformat_error, i);
16957 errmsg ("nh addr not set!");
16961 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
16962 mp->is_add = is_add;
16963 mp->table_id = clib_host_to_net_u32 (table_id);
16964 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
16965 mp->is_ip4 = is_ip4;
16967 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
16969 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
16974 /* Wait for a reply... */
16980 api_one_map_server_dump (vat_main_t * vam)
16982 vl_api_one_map_server_dump_t *mp;
16983 vl_api_control_ping_t *mp_ping;
16986 if (!vam->json_output)
16988 print (vam->ofp, "%=20s", "Map server");
16991 M (ONE_MAP_SERVER_DUMP, mp);
16995 /* Use a control ping for synchronization */
16996 MPING (CONTROL_PING, mp_ping);
16999 /* Wait for a reply... */
17004 #define api_lisp_map_server_dump api_one_map_server_dump
17007 api_one_map_resolver_dump (vat_main_t * vam)
17009 vl_api_one_map_resolver_dump_t *mp;
17010 vl_api_control_ping_t *mp_ping;
17013 if (!vam->json_output)
17015 print (vam->ofp, "%=20s", "Map resolver");
17018 M (ONE_MAP_RESOLVER_DUMP, mp);
17022 /* Use a control ping for synchronization */
17023 MPING (CONTROL_PING, mp_ping);
17026 /* Wait for a reply... */
17031 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
17034 api_one_stats_flush (vat_main_t * vam)
17036 vl_api_one_stats_flush_t *mp;
17039 M (ONE_STATS_FLUSH, mp);
17046 api_one_stats_dump (vat_main_t * vam)
17048 vl_api_one_stats_dump_t *mp;
17049 vl_api_control_ping_t *mp_ping;
17052 M (ONE_STATS_DUMP, mp);
17056 /* Use a control ping for synchronization */
17057 MPING (CONTROL_PING, mp_ping);
17060 /* Wait for a reply... */
17066 api_show_one_status (vat_main_t * vam)
17068 vl_api_show_one_status_t *mp;
17071 if (!vam->json_output)
17073 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17076 M (SHOW_ONE_STATUS, mp);
17079 /* Wait for a reply... */
17084 #define api_show_lisp_status api_show_one_status
17087 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17089 vl_api_gpe_fwd_entry_path_dump_t *mp;
17090 vl_api_control_ping_t *mp_ping;
17091 unformat_input_t *i = vam->input;
17092 u32 fwd_entry_index = ~0;
17095 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17097 if (unformat (i, "index %d", &fwd_entry_index))
17103 if (~0 == fwd_entry_index)
17105 errmsg ("no index specified!");
17109 if (!vam->json_output)
17111 print (vam->ofp, "first line");
17114 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17118 /* Use a control ping for synchronization */
17119 MPING (CONTROL_PING, mp_ping);
17122 /* Wait for a reply... */
17128 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17130 vl_api_one_get_map_request_itr_rlocs_t *mp;
17133 if (!vam->json_output)
17135 print (vam->ofp, "%=20s", "itr-rlocs:");
17138 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17141 /* Wait for a reply... */
17146 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17149 api_af_packet_create (vat_main_t * vam)
17151 unformat_input_t *i = vam->input;
17152 vl_api_af_packet_create_t *mp;
17153 u8 *host_if_name = 0;
17155 u8 random_hw_addr = 1;
17158 clib_memset (hw_addr, 0, sizeof (hw_addr));
17160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17162 if (unformat (i, "name %s", &host_if_name))
17163 vec_add1 (host_if_name, 0);
17164 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17165 random_hw_addr = 0;
17170 if (!vec_len (host_if_name))
17172 errmsg ("host-interface name must be specified");
17176 if (vec_len (host_if_name) > 64)
17178 errmsg ("host-interface name too long");
17182 M (AF_PACKET_CREATE, mp);
17184 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17185 clib_memcpy (mp->hw_addr, hw_addr, 6);
17186 mp->use_random_hw_addr = random_hw_addr;
17187 vec_free (host_if_name);
17195 fprintf (vam->ofp ? vam->ofp : stderr,
17196 " new sw_if_index = %d\n", vam->sw_if_index);
17203 api_af_packet_delete (vat_main_t * vam)
17205 unformat_input_t *i = vam->input;
17206 vl_api_af_packet_delete_t *mp;
17207 u8 *host_if_name = 0;
17210 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17212 if (unformat (i, "name %s", &host_if_name))
17213 vec_add1 (host_if_name, 0);
17218 if (!vec_len (host_if_name))
17220 errmsg ("host-interface name must be specified");
17224 if (vec_len (host_if_name) > 64)
17226 errmsg ("host-interface name too long");
17230 M (AF_PACKET_DELETE, mp);
17232 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17233 vec_free (host_if_name);
17240 static void vl_api_af_packet_details_t_handler
17241 (vl_api_af_packet_details_t * mp)
17243 vat_main_t *vam = &vat_main;
17245 print (vam->ofp, "%-16s %d",
17246 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
17249 static void vl_api_af_packet_details_t_handler_json
17250 (vl_api_af_packet_details_t * mp)
17252 vat_main_t *vam = &vat_main;
17253 vat_json_node_t *node = NULL;
17255 if (VAT_JSON_ARRAY != vam->json_tree.type)
17257 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17258 vat_json_init_array (&vam->json_tree);
17260 node = vat_json_array_add (&vam->json_tree);
17262 vat_json_init_object (node);
17263 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17264 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
17268 api_af_packet_dump (vat_main_t * vam)
17270 vl_api_af_packet_dump_t *mp;
17271 vl_api_control_ping_t *mp_ping;
17274 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
17275 /* Get list of tap interfaces */
17276 M (AF_PACKET_DUMP, mp);
17279 /* Use a control ping for synchronization */
17280 MPING (CONTROL_PING, mp_ping);
17288 api_policer_add_del (vat_main_t * vam)
17290 unformat_input_t *i = vam->input;
17291 vl_api_policer_add_del_t *mp;
17301 u8 color_aware = 0;
17302 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17305 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17306 conform_action.dscp = 0;
17307 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17308 exceed_action.dscp = 0;
17309 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17310 violate_action.dscp = 0;
17312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17314 if (unformat (i, "del"))
17316 else if (unformat (i, "name %s", &name))
17317 vec_add1 (name, 0);
17318 else if (unformat (i, "cir %u", &cir))
17320 else if (unformat (i, "eir %u", &eir))
17322 else if (unformat (i, "cb %u", &cb))
17324 else if (unformat (i, "eb %u", &eb))
17326 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17329 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17332 else if (unformat (i, "type %U", unformat_policer_type, &type))
17334 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17337 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17340 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17343 else if (unformat (i, "color-aware"))
17349 if (!vec_len (name))
17351 errmsg ("policer name must be specified");
17355 if (vec_len (name) > 64)
17357 errmsg ("policer name too long");
17361 M (POLICER_ADD_DEL, mp);
17363 clib_memcpy (mp->name, name, vec_len (name));
17365 mp->is_add = is_add;
17366 mp->cir = ntohl (cir);
17367 mp->eir = ntohl (eir);
17368 mp->cb = clib_net_to_host_u64 (cb);
17369 mp->eb = clib_net_to_host_u64 (eb);
17370 mp->rate_type = rate_type;
17371 mp->round_type = round_type;
17373 mp->conform_action_type = conform_action.action_type;
17374 mp->conform_dscp = conform_action.dscp;
17375 mp->exceed_action_type = exceed_action.action_type;
17376 mp->exceed_dscp = exceed_action.dscp;
17377 mp->violate_action_type = violate_action.action_type;
17378 mp->violate_dscp = violate_action.dscp;
17379 mp->color_aware = color_aware;
17387 api_policer_dump (vat_main_t * vam)
17389 unformat_input_t *i = vam->input;
17390 vl_api_policer_dump_t *mp;
17391 vl_api_control_ping_t *mp_ping;
17392 u8 *match_name = 0;
17393 u8 match_name_valid = 0;
17396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17398 if (unformat (i, "name %s", &match_name))
17400 vec_add1 (match_name, 0);
17401 match_name_valid = 1;
17407 M (POLICER_DUMP, mp);
17408 mp->match_name_valid = match_name_valid;
17409 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17410 vec_free (match_name);
17414 /* Use a control ping for synchronization */
17415 MPING (CONTROL_PING, mp_ping);
17418 /* Wait for a reply... */
17424 api_policer_classify_set_interface (vat_main_t * vam)
17426 unformat_input_t *i = vam->input;
17427 vl_api_policer_classify_set_interface_t *mp;
17429 int sw_if_index_set;
17430 u32 ip4_table_index = ~0;
17431 u32 ip6_table_index = ~0;
17432 u32 l2_table_index = ~0;
17436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17438 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17439 sw_if_index_set = 1;
17440 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17441 sw_if_index_set = 1;
17442 else if (unformat (i, "del"))
17444 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17446 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17448 else if (unformat (i, "l2-table %d", &l2_table_index))
17452 clib_warning ("parse error '%U'", format_unformat_error, i);
17457 if (sw_if_index_set == 0)
17459 errmsg ("missing interface name or sw_if_index");
17463 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17465 mp->sw_if_index = ntohl (sw_if_index);
17466 mp->ip4_table_index = ntohl (ip4_table_index);
17467 mp->ip6_table_index = ntohl (ip6_table_index);
17468 mp->l2_table_index = ntohl (l2_table_index);
17469 mp->is_add = is_add;
17477 api_policer_classify_dump (vat_main_t * vam)
17479 unformat_input_t *i = vam->input;
17480 vl_api_policer_classify_dump_t *mp;
17481 vl_api_control_ping_t *mp_ping;
17482 u8 type = POLICER_CLASSIFY_N_TABLES;
17485 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17489 errmsg ("classify table type must be specified");
17493 if (!vam->json_output)
17495 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17498 M (POLICER_CLASSIFY_DUMP, mp);
17503 /* Use a control ping for synchronization */
17504 MPING (CONTROL_PING, mp_ping);
17507 /* Wait for a reply... */
17513 api_netmap_create (vat_main_t * vam)
17515 unformat_input_t *i = vam->input;
17516 vl_api_netmap_create_t *mp;
17519 u8 random_hw_addr = 1;
17524 clib_memset (hw_addr, 0, sizeof (hw_addr));
17526 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17528 if (unformat (i, "name %s", &if_name))
17529 vec_add1 (if_name, 0);
17530 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17531 random_hw_addr = 0;
17532 else if (unformat (i, "pipe"))
17534 else if (unformat (i, "master"))
17536 else if (unformat (i, "slave"))
17542 if (!vec_len (if_name))
17544 errmsg ("interface name must be specified");
17548 if (vec_len (if_name) > 64)
17550 errmsg ("interface name too long");
17554 M (NETMAP_CREATE, mp);
17556 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17557 clib_memcpy (mp->hw_addr, hw_addr, 6);
17558 mp->use_random_hw_addr = random_hw_addr;
17559 mp->is_pipe = is_pipe;
17560 mp->is_master = is_master;
17561 vec_free (if_name);
17569 api_netmap_delete (vat_main_t * vam)
17571 unformat_input_t *i = vam->input;
17572 vl_api_netmap_delete_t *mp;
17576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17578 if (unformat (i, "name %s", &if_name))
17579 vec_add1 (if_name, 0);
17584 if (!vec_len (if_name))
17586 errmsg ("interface name must be specified");
17590 if (vec_len (if_name) > 64)
17592 errmsg ("interface name too long");
17596 M (NETMAP_DELETE, mp);
17598 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17599 vec_free (if_name);
17607 format_fib_api_path_nh_proto (u8 * s, va_list * args)
17609 vl_api_fib_path_nh_proto_t proto =
17610 va_arg (*args, vl_api_fib_path_nh_proto_t);
17614 case FIB_API_PATH_NH_PROTO_IP4:
17615 s = format (s, "ip4");
17617 case FIB_API_PATH_NH_PROTO_IP6:
17618 s = format (s, "ip6");
17620 case FIB_API_PATH_NH_PROTO_MPLS:
17621 s = format (s, "mpls");
17623 case FIB_API_PATH_NH_PROTO_BIER:
17624 s = format (s, "bier");
17626 case FIB_API_PATH_NH_PROTO_ETHERNET:
17627 s = format (s, "ethernet");
17635 format_vl_api_ip_address_union (u8 * s, va_list * args)
17637 vl_api_address_family_t af = va_arg (*args, vl_api_address_family_t);
17638 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
17643 s = format (s, "%U", format_ip4_address, u->ip4);
17646 s = format (s, "%U", format_ip6_address, u->ip6);
17653 format_vl_api_fib_path_type (u8 * s, va_list * args)
17655 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
17659 case FIB_API_PATH_TYPE_NORMAL:
17660 s = format (s, "normal");
17662 case FIB_API_PATH_TYPE_LOCAL:
17663 s = format (s, "local");
17665 case FIB_API_PATH_TYPE_DROP:
17666 s = format (s, "drop");
17668 case FIB_API_PATH_TYPE_UDP_ENCAP:
17669 s = format (s, "udp-encap");
17671 case FIB_API_PATH_TYPE_BIER_IMP:
17672 s = format (s, "bier-imp");
17674 case FIB_API_PATH_TYPE_ICMP_UNREACH:
17675 s = format (s, "unreach");
17677 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
17678 s = format (s, "prohibit");
17680 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
17681 s = format (s, "src-lookup");
17683 case FIB_API_PATH_TYPE_DVR:
17684 s = format (s, "dvr");
17686 case FIB_API_PATH_TYPE_INTERFACE_RX:
17687 s = format (s, "interface-rx");
17689 case FIB_API_PATH_TYPE_CLASSIFY:
17690 s = format (s, "classify");
17698 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
17701 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
17702 ntohl (fp->weight), ntohl (fp->sw_if_index),
17703 format_vl_api_fib_path_type, fp->type,
17704 format_fib_api_path_nh_proto, fp->proto,
17705 format_vl_api_ip_address_union, &fp->nh.address);
17709 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17710 vl_api_fib_path_t * fp)
17712 struct in_addr ip4;
17713 struct in6_addr ip6;
17715 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17716 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17717 vat_json_object_add_uint (node, "type", fp->type);
17718 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
17719 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
17721 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
17722 vat_json_object_add_ip4 (node, "next_hop", ip4);
17724 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
17726 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
17727 vat_json_object_add_ip6 (node, "next_hop", ip6);
17732 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17734 vat_main_t *vam = &vat_main;
17735 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17736 vl_api_fib_path_t *fp;
17739 print (vam->ofp, "sw_if_index %d via:",
17740 ntohl (mp->mt_tunnel.mt_sw_if_index));
17741 fp = mp->mt_tunnel.mt_paths;
17742 for (i = 0; i < count; i++)
17744 vl_api_fib_path_print (vam, fp);
17748 print (vam->ofp, "");
17751 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17752 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17755 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17757 vat_main_t *vam = &vat_main;
17758 vat_json_node_t *node = NULL;
17759 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17760 vl_api_fib_path_t *fp;
17763 if (VAT_JSON_ARRAY != vam->json_tree.type)
17765 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17766 vat_json_init_array (&vam->json_tree);
17768 node = vat_json_array_add (&vam->json_tree);
17770 vat_json_init_object (node);
17771 vat_json_object_add_uint (node, "sw_if_index",
17772 ntohl (mp->mt_tunnel.mt_sw_if_index));
17774 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
17776 fp = mp->mt_tunnel.mt_paths;
17777 for (i = 0; i < count; i++)
17779 vl_api_mpls_fib_path_json_print (node, fp);
17785 api_mpls_tunnel_dump (vat_main_t * vam)
17787 vl_api_mpls_tunnel_dump_t *mp;
17788 vl_api_control_ping_t *mp_ping;
17791 M (MPLS_TUNNEL_DUMP, mp);
17795 /* Use a control ping for synchronization */
17796 MPING (CONTROL_PING, mp_ping);
17803 #define vl_api_mpls_table_details_t_endian vl_noop_handler
17804 #define vl_api_mpls_table_details_t_print vl_noop_handler
17808 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
17810 vat_main_t *vam = &vat_main;
17812 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
17815 static void vl_api_mpls_table_details_t_handler_json
17816 (vl_api_mpls_table_details_t * mp)
17818 vat_main_t *vam = &vat_main;
17819 vat_json_node_t *node = NULL;
17821 if (VAT_JSON_ARRAY != vam->json_tree.type)
17823 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17824 vat_json_init_array (&vam->json_tree);
17826 node = vat_json_array_add (&vam->json_tree);
17828 vat_json_init_object (node);
17829 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
17833 api_mpls_table_dump (vat_main_t * vam)
17835 vl_api_mpls_table_dump_t *mp;
17836 vl_api_control_ping_t *mp_ping;
17839 M (MPLS_TABLE_DUMP, mp);
17842 /* Use a control ping for synchronization */
17843 MPING (CONTROL_PING, mp_ping);
17850 #define vl_api_mpls_route_details_t_endian vl_noop_handler
17851 #define vl_api_mpls_route_details_t_print vl_noop_handler
17854 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
17856 vat_main_t *vam = &vat_main;
17857 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
17858 vl_api_fib_path_t *fp;
17862 "table-id %d, label %u, ess_bit %u",
17863 ntohl (mp->mr_route.mr_table_id),
17864 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
17865 fp = mp->mr_route.mr_paths;
17866 for (i = 0; i < count; i++)
17868 vl_api_fib_path_print (vam, fp);
17873 static void vl_api_mpls_route_details_t_handler_json
17874 (vl_api_mpls_route_details_t * mp)
17876 vat_main_t *vam = &vat_main;
17877 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
17878 vat_json_node_t *node = NULL;
17879 vl_api_fib_path_t *fp;
17882 if (VAT_JSON_ARRAY != vam->json_tree.type)
17884 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17885 vat_json_init_array (&vam->json_tree);
17887 node = vat_json_array_add (&vam->json_tree);
17889 vat_json_init_object (node);
17890 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
17891 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
17892 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
17893 vat_json_object_add_uint (node, "path_count", count);
17894 fp = mp->mr_route.mr_paths;
17895 for (i = 0; i < count; i++)
17897 vl_api_mpls_fib_path_json_print (node, fp);
17903 api_mpls_route_dump (vat_main_t * vam)
17905 unformat_input_t *input = vam->input;
17906 vl_api_mpls_route_dump_t *mp;
17907 vl_api_control_ping_t *mp_ping;
17911 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17913 if (unformat (input, "table_id %d", &table_id))
17918 if (table_id == ~0)
17920 errmsg ("missing table id");
17924 M (MPLS_ROUTE_DUMP, mp);
17926 mp->table.mt_table_id = ntohl (table_id);
17929 /* Use a control ping for synchronization */
17930 MPING (CONTROL_PING, mp_ping);
17937 #define vl_api_ip_table_details_t_endian vl_noop_handler
17938 #define vl_api_ip_table_details_t_print vl_noop_handler
17941 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
17943 vat_main_t *vam = &vat_main;
17946 "%s; table-id %d, prefix %U/%d",
17947 mp->table.name, ntohl (mp->table.table_id));
17951 static void vl_api_ip_table_details_t_handler_json
17952 (vl_api_ip_table_details_t * mp)
17954 vat_main_t *vam = &vat_main;
17955 vat_json_node_t *node = NULL;
17957 if (VAT_JSON_ARRAY != vam->json_tree.type)
17959 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17960 vat_json_init_array (&vam->json_tree);
17962 node = vat_json_array_add (&vam->json_tree);
17964 vat_json_init_object (node);
17965 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
17969 api_ip_table_dump (vat_main_t * vam)
17971 vl_api_ip_table_dump_t *mp;
17972 vl_api_control_ping_t *mp_ping;
17975 M (IP_TABLE_DUMP, mp);
17978 /* Use a control ping for synchronization */
17979 MPING (CONTROL_PING, mp_ping);
17987 api_ip_mtable_dump (vat_main_t * vam)
17989 vl_api_ip_mtable_dump_t *mp;
17990 vl_api_control_ping_t *mp_ping;
17993 M (IP_MTABLE_DUMP, mp);
17996 /* Use a control ping for synchronization */
17997 MPING (CONTROL_PING, mp_ping);
18005 api_ip_mroute_dump (vat_main_t * vam)
18007 unformat_input_t *input = vam->input;
18008 vl_api_control_ping_t *mp_ping;
18009 vl_api_ip_mroute_dump_t *mp;
18014 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18016 if (unformat (input, "table_id %d", &table_id))
18018 else if (unformat (input, "ip6"))
18020 else if (unformat (input, "ip4"))
18025 if (table_id == ~0)
18027 errmsg ("missing table id");
18031 M (IP_MROUTE_DUMP, mp);
18032 mp->table.table_id = table_id;
18033 mp->table.is_ip6 = is_ip6;
18036 /* Use a control ping for synchronization */
18037 MPING (CONTROL_PING, mp_ping);
18044 #define vl_api_ip_route_details_t_endian vl_noop_handler
18045 #define vl_api_ip_route_details_t_print vl_noop_handler
18048 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
18050 vat_main_t *vam = &vat_main;
18051 u8 count = mp->route.n_paths;
18052 vl_api_fib_path_t *fp;
18056 "table-id %d, prefix %U/%d",
18057 ntohl (mp->route.table_id),
18058 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
18059 for (i = 0; i < count; i++)
18061 fp = &mp->route.paths[i];
18063 vl_api_fib_path_print (vam, fp);
18068 static void vl_api_ip_route_details_t_handler_json
18069 (vl_api_ip_route_details_t * mp)
18071 vat_main_t *vam = &vat_main;
18072 u8 count = mp->route.n_paths;
18073 vat_json_node_t *node = NULL;
18074 struct in_addr ip4;
18075 struct in6_addr ip6;
18076 vl_api_fib_path_t *fp;
18079 if (VAT_JSON_ARRAY != vam->json_tree.type)
18081 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18082 vat_json_init_array (&vam->json_tree);
18084 node = vat_json_array_add (&vam->json_tree);
18086 vat_json_init_object (node);
18087 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
18088 if (ADDRESS_IP6 == mp->route.prefix.address.af)
18090 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
18091 vat_json_object_add_ip6 (node, "prefix", ip6);
18095 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
18096 vat_json_object_add_ip4 (node, "prefix", ip4);
18098 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
18099 vat_json_object_add_uint (node, "path_count", count);
18100 for (i = 0; i < count; i++)
18102 fp = &mp->route.paths[i];
18103 vl_api_mpls_fib_path_json_print (node, fp);
18108 api_ip_route_dump (vat_main_t * vam)
18110 unformat_input_t *input = vam->input;
18111 vl_api_ip_route_dump_t *mp;
18112 vl_api_control_ping_t *mp_ping;
18118 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18120 if (unformat (input, "table_id %d", &table_id))
18122 else if (unformat (input, "ip6"))
18124 else if (unformat (input, "ip4"))
18129 if (table_id == ~0)
18131 errmsg ("missing table id");
18135 M (IP_ROUTE_DUMP, mp);
18137 mp->table.table_id = table_id;
18138 mp->table.is_ip6 = is_ip6;
18142 /* Use a control ping for synchronization */
18143 MPING (CONTROL_PING, mp_ping);
18151 api_classify_table_ids (vat_main_t * vam)
18153 vl_api_classify_table_ids_t *mp;
18156 /* Construct the API message */
18157 M (CLASSIFY_TABLE_IDS, mp);
18166 api_classify_table_by_interface (vat_main_t * vam)
18168 unformat_input_t *input = vam->input;
18169 vl_api_classify_table_by_interface_t *mp;
18171 u32 sw_if_index = ~0;
18173 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18175 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18177 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18182 if (sw_if_index == ~0)
18184 errmsg ("missing interface name or sw_if_index");
18188 /* Construct the API message */
18189 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18191 mp->sw_if_index = ntohl (sw_if_index);
18199 api_classify_table_info (vat_main_t * vam)
18201 unformat_input_t *input = vam->input;
18202 vl_api_classify_table_info_t *mp;
18206 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18208 if (unformat (input, "table_id %d", &table_id))
18213 if (table_id == ~0)
18215 errmsg ("missing table id");
18219 /* Construct the API message */
18220 M (CLASSIFY_TABLE_INFO, mp);
18222 mp->table_id = ntohl (table_id);
18230 api_classify_session_dump (vat_main_t * vam)
18232 unformat_input_t *input = vam->input;
18233 vl_api_classify_session_dump_t *mp;
18234 vl_api_control_ping_t *mp_ping;
18238 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18240 if (unformat (input, "table_id %d", &table_id))
18245 if (table_id == ~0)
18247 errmsg ("missing table id");
18251 /* Construct the API message */
18252 M (CLASSIFY_SESSION_DUMP, mp);
18254 mp->table_id = ntohl (table_id);
18257 /* Use a control ping for synchronization */
18258 MPING (CONTROL_PING, mp_ping);
18266 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
18268 vat_main_t *vam = &vat_main;
18270 print (vam->ofp, "collector_address %U, collector_port %d, "
18271 "src_address %U, vrf_id %d, path_mtu %u, "
18272 "template_interval %u, udp_checksum %d",
18273 format_ip4_address, mp->collector_address,
18274 ntohs (mp->collector_port),
18275 format_ip4_address, mp->src_address,
18276 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
18277 ntohl (mp->template_interval), mp->udp_checksum);
18280 vam->result_ready = 1;
18284 vl_api_ipfix_exporter_details_t_handler_json
18285 (vl_api_ipfix_exporter_details_t * mp)
18287 vat_main_t *vam = &vat_main;
18288 vat_json_node_t node;
18289 struct in_addr collector_address;
18290 struct in_addr src_address;
18292 vat_json_init_object (&node);
18293 clib_memcpy (&collector_address, &mp->collector_address,
18294 sizeof (collector_address));
18295 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
18296 vat_json_object_add_uint (&node, "collector_port",
18297 ntohs (mp->collector_port));
18298 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
18299 vat_json_object_add_ip4 (&node, "src_address", src_address);
18300 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
18301 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
18302 vat_json_object_add_uint (&node, "template_interval",
18303 ntohl (mp->template_interval));
18304 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
18306 vat_json_print (vam->ofp, &node);
18307 vat_json_free (&node);
18309 vam->result_ready = 1;
18313 api_ipfix_exporter_dump (vat_main_t * vam)
18315 vl_api_ipfix_exporter_dump_t *mp;
18318 /* Construct the API message */
18319 M (IPFIX_EXPORTER_DUMP, mp);
18328 api_ipfix_classify_stream_dump (vat_main_t * vam)
18330 vl_api_ipfix_classify_stream_dump_t *mp;
18333 /* Construct the API message */
18334 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
18345 vl_api_ipfix_classify_stream_details_t_handler
18346 (vl_api_ipfix_classify_stream_details_t * mp)
18348 vat_main_t *vam = &vat_main;
18349 print (vam->ofp, "domain_id %d, src_port %d",
18350 ntohl (mp->domain_id), ntohs (mp->src_port));
18352 vam->result_ready = 1;
18356 vl_api_ipfix_classify_stream_details_t_handler_json
18357 (vl_api_ipfix_classify_stream_details_t * mp)
18359 vat_main_t *vam = &vat_main;
18360 vat_json_node_t node;
18362 vat_json_init_object (&node);
18363 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18364 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18366 vat_json_print (vam->ofp, &node);
18367 vat_json_free (&node);
18369 vam->result_ready = 1;
18373 api_ipfix_classify_table_dump (vat_main_t * vam)
18375 vl_api_ipfix_classify_table_dump_t *mp;
18376 vl_api_control_ping_t *mp_ping;
18379 if (!vam->json_output)
18381 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18382 "transport_protocol");
18385 /* Construct the API message */
18386 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18391 /* Use a control ping for synchronization */
18392 MPING (CONTROL_PING, mp_ping);
18400 vl_api_ipfix_classify_table_details_t_handler
18401 (vl_api_ipfix_classify_table_details_t * mp)
18403 vat_main_t *vam = &vat_main;
18404 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18405 mp->transport_protocol);
18409 vl_api_ipfix_classify_table_details_t_handler_json
18410 (vl_api_ipfix_classify_table_details_t * mp)
18412 vat_json_node_t *node = NULL;
18413 vat_main_t *vam = &vat_main;
18415 if (VAT_JSON_ARRAY != vam->json_tree.type)
18417 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18418 vat_json_init_array (&vam->json_tree);
18421 node = vat_json_array_add (&vam->json_tree);
18422 vat_json_init_object (node);
18424 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18425 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18426 vat_json_object_add_uint (node, "transport_protocol",
18427 mp->transport_protocol);
18431 api_sw_interface_span_enable_disable (vat_main_t * vam)
18433 unformat_input_t *i = vam->input;
18434 vl_api_sw_interface_span_enable_disable_t *mp;
18435 u32 src_sw_if_index = ~0;
18436 u32 dst_sw_if_index = ~0;
18441 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18444 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18446 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18450 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18452 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18454 else if (unformat (i, "disable"))
18456 else if (unformat (i, "rx"))
18458 else if (unformat (i, "tx"))
18460 else if (unformat (i, "both"))
18462 else if (unformat (i, "l2"))
18468 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18470 mp->sw_if_index_from = htonl (src_sw_if_index);
18471 mp->sw_if_index_to = htonl (dst_sw_if_index);
18481 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18484 vat_main_t *vam = &vat_main;
18485 u8 *sw_if_from_name = 0;
18486 u8 *sw_if_to_name = 0;
18487 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18488 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18489 char *states[] = { "none", "rx", "tx", "both" };
18493 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18495 if ((u32) p->value[0] == sw_if_index_from)
18497 sw_if_from_name = (u8 *)(p->key);
18501 if ((u32) p->value[0] == sw_if_index_to)
18503 sw_if_to_name = (u8 *)(p->key);
18504 if (sw_if_from_name)
18509 print (vam->ofp, "%20s => %20s (%s) %s",
18510 sw_if_from_name, sw_if_to_name, states[mp->state],
18511 mp->is_l2 ? "l2" : "device");
18515 vl_api_sw_interface_span_details_t_handler_json
18516 (vl_api_sw_interface_span_details_t * mp)
18518 vat_main_t *vam = &vat_main;
18519 vat_json_node_t *node = NULL;
18520 u8 *sw_if_from_name = 0;
18521 u8 *sw_if_to_name = 0;
18522 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18523 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18527 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18529 if ((u32) p->value[0] == sw_if_index_from)
18531 sw_if_from_name = (u8 *)(p->key);
18535 if ((u32) p->value[0] == sw_if_index_to)
18537 sw_if_to_name = (u8 *)(p->key);
18538 if (sw_if_from_name)
18544 if (VAT_JSON_ARRAY != vam->json_tree.type)
18546 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18547 vat_json_init_array (&vam->json_tree);
18549 node = vat_json_array_add (&vam->json_tree);
18551 vat_json_init_object (node);
18552 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18553 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18554 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18555 if (0 != sw_if_to_name)
18557 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18559 vat_json_object_add_uint (node, "state", mp->state);
18560 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
18564 api_sw_interface_span_dump (vat_main_t * vam)
18566 unformat_input_t *input = vam->input;
18567 vl_api_sw_interface_span_dump_t *mp;
18568 vl_api_control_ping_t *mp_ping;
18572 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18574 if (unformat (input, "l2"))
18580 M (SW_INTERFACE_SPAN_DUMP, mp);
18584 /* Use a control ping for synchronization */
18585 MPING (CONTROL_PING, mp_ping);
18593 api_pg_create_interface (vat_main_t * vam)
18595 unformat_input_t *input = vam->input;
18596 vl_api_pg_create_interface_t *mp;
18598 u32 if_id = ~0, gso_size = 0;
18599 u8 gso_enabled = 0;
18601 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18603 if (unformat (input, "if_id %d", &if_id))
18605 else if (unformat (input, "gso-enabled"))
18608 if (unformat (input, "gso-size %u", &gso_size))
18612 errmsg ("missing gso-size");
18621 errmsg ("missing pg interface index");
18625 /* Construct the API message */
18626 M (PG_CREATE_INTERFACE, mp);
18628 mp->interface_id = ntohl (if_id);
18629 mp->gso_enabled = gso_enabled;
18637 api_pg_capture (vat_main_t * vam)
18639 unformat_input_t *input = vam->input;
18640 vl_api_pg_capture_t *mp;
18645 u8 pcap_file_set = 0;
18648 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18650 if (unformat (input, "if_id %d", &if_id))
18652 else if (unformat (input, "pcap %s", &pcap_file))
18654 else if (unformat (input, "count %d", &count))
18656 else if (unformat (input, "disable"))
18663 errmsg ("missing pg interface index");
18666 if (pcap_file_set > 0)
18668 if (vec_len (pcap_file) > 255)
18670 errmsg ("pcap file name is too long");
18675 u32 name_len = vec_len (pcap_file);
18676 /* Construct the API message */
18677 M (PG_CAPTURE, mp);
18679 mp->interface_id = ntohl (if_id);
18680 mp->is_enabled = enable;
18681 mp->count = ntohl (count);
18682 mp->pcap_name_length = ntohl (name_len);
18683 if (pcap_file_set != 0)
18685 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
18687 vec_free (pcap_file);
18695 api_pg_enable_disable (vat_main_t * vam)
18697 unformat_input_t *input = vam->input;
18698 vl_api_pg_enable_disable_t *mp;
18701 u8 stream_name_set = 0;
18702 u8 *stream_name = 0;
18704 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18706 if (unformat (input, "stream %s", &stream_name))
18707 stream_name_set = 1;
18708 else if (unformat (input, "disable"))
18714 if (stream_name_set > 0)
18716 if (vec_len (stream_name) > 255)
18718 errmsg ("stream name too long");
18723 u32 name_len = vec_len (stream_name);
18724 /* Construct the API message */
18725 M (PG_ENABLE_DISABLE, mp);
18727 mp->is_enabled = enable;
18728 if (stream_name_set != 0)
18730 mp->stream_name_length = ntohl (name_len);
18731 clib_memcpy (mp->stream_name, stream_name, name_len);
18733 vec_free (stream_name);
18741 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18743 unformat_input_t *input = vam->input;
18744 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18746 u16 *low_ports = 0;
18747 u16 *high_ports = 0;
18750 vl_api_prefix_t prefix;
18757 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18759 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
18761 else if (unformat (input, "vrf %d", &vrf_id))
18763 else if (unformat (input, "del"))
18765 else if (unformat (input, "port %d", &tmp))
18767 if (tmp == 0 || tmp > 65535)
18769 errmsg ("port %d out of range", tmp);
18773 this_hi = this_low + 1;
18774 vec_add1 (low_ports, this_low);
18775 vec_add1 (high_ports, this_hi);
18777 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18779 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18781 errmsg ("incorrect range parameters");
18785 /* Note: in debug CLI +1 is added to high before
18786 passing to real fn that does "the work"
18787 (ip_source_and_port_range_check_add_del).
18788 This fn is a wrapper around the binary API fn a
18789 control plane will call, which expects this increment
18790 to have occurred. Hence letting the binary API control
18791 plane fn do the increment for consistency between VAT
18792 and other control planes.
18795 vec_add1 (low_ports, this_low);
18796 vec_add1 (high_ports, this_hi);
18802 if (prefix_set == 0)
18804 errmsg ("<address>/<mask> not specified");
18810 errmsg ("VRF ID required, not specified");
18817 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18821 if (vec_len (low_ports) == 0)
18823 errmsg ("At least one port or port range required");
18827 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18829 mp->is_add = is_add;
18831 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
18833 mp->number_of_ranges = vec_len (low_ports);
18835 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18836 vec_free (low_ports);
18838 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18839 vec_free (high_ports);
18841 mp->vrf_id = ntohl (vrf_id);
18849 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18851 unformat_input_t *input = vam->input;
18852 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18853 u32 sw_if_index = ~0;
18855 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18856 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18860 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18862 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18864 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18866 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18868 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18870 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18872 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18874 else if (unformat (input, "del"))
18880 if (sw_if_index == ~0)
18882 errmsg ("Interface required but not specified");
18888 errmsg ("VRF ID required but not specified");
18892 if (tcp_out_vrf_id == 0
18893 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18896 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18900 /* Construct the API message */
18901 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18903 mp->sw_if_index = ntohl (sw_if_index);
18904 mp->is_add = is_add;
18905 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18906 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18907 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18908 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18913 /* Wait for a reply... */
18919 api_set_punt (vat_main_t * vam)
18921 unformat_input_t *i = vam->input;
18922 vl_api_address_family_t af;
18923 vl_api_set_punt_t *mp;
18929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18931 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
18933 else if (unformat (i, "protocol %d", &protocol))
18935 else if (unformat (i, "port %d", &port))
18937 else if (unformat (i, "del"))
18941 clib_warning ("parse error '%U'", format_unformat_error, i);
18948 mp->is_add = (u8) is_add;
18949 mp->punt.type = PUNT_API_TYPE_L4;
18950 mp->punt.punt.l4.af = af;
18951 mp->punt.punt.l4.protocol = (u8) protocol;
18952 mp->punt.punt.l4.port = htons ((u16) port);
18960 api_delete_subif (vat_main_t * vam)
18962 unformat_input_t *i = vam->input;
18963 vl_api_delete_subif_t *mp;
18964 u32 sw_if_index = ~0;
18967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18969 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18971 if (unformat (i, "sw_if_index %d", &sw_if_index))
18977 if (sw_if_index == ~0)
18979 errmsg ("missing sw_if_index");
18983 /* Construct the API message */
18984 M (DELETE_SUBIF, mp);
18985 mp->sw_if_index = ntohl (sw_if_index);
18992 #define foreach_pbb_vtr_op \
18993 _("disable", L2_VTR_DISABLED) \
18994 _("pop", L2_VTR_POP_2) \
18995 _("push", L2_VTR_PUSH_2)
18998 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
19000 unformat_input_t *i = vam->input;
19001 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
19002 u32 sw_if_index = ~0, vtr_op = ~0;
19003 u16 outer_tag = ~0;
19004 u8 dmac[6], smac[6];
19005 u8 dmac_set = 0, smac_set = 0;
19011 /* Shut up coverity */
19012 clib_memset (dmac, 0, sizeof (dmac));
19013 clib_memset (smac, 0, sizeof (smac));
19015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19017 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19019 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19021 else if (unformat (i, "vtr_op %d", &vtr_op))
19023 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
19026 else if (unformat (i, "translate_pbb_stag"))
19028 if (unformat (i, "%d", &tmp))
19030 vtr_op = L2_VTR_TRANSLATE_2_1;
19036 ("translate_pbb_stag operation requires outer tag definition");
19040 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
19042 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
19044 else if (unformat (i, "sid %d", &sid))
19046 else if (unformat (i, "vlanid %d", &tmp))
19050 clib_warning ("parse error '%U'", format_unformat_error, i);
19055 if ((sw_if_index == ~0) || (vtr_op == ~0))
19057 errmsg ("missing sw_if_index or vtr operation");
19060 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
19061 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
19064 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
19068 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
19069 mp->sw_if_index = ntohl (sw_if_index);
19070 mp->vtr_op = ntohl (vtr_op);
19071 mp->outer_tag = ntohs (outer_tag);
19072 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
19073 clib_memcpy (mp->b_smac, smac, sizeof (smac));
19074 mp->b_vlanid = ntohs (vlanid);
19075 mp->i_sid = ntohl (sid);
19083 api_flow_classify_set_interface (vat_main_t * vam)
19085 unformat_input_t *i = vam->input;
19086 vl_api_flow_classify_set_interface_t *mp;
19088 int sw_if_index_set;
19089 u32 ip4_table_index = ~0;
19090 u32 ip6_table_index = ~0;
19094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19096 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19097 sw_if_index_set = 1;
19098 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19099 sw_if_index_set = 1;
19100 else if (unformat (i, "del"))
19102 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19104 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19108 clib_warning ("parse error '%U'", format_unformat_error, i);
19113 if (sw_if_index_set == 0)
19115 errmsg ("missing interface name or sw_if_index");
19119 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19121 mp->sw_if_index = ntohl (sw_if_index);
19122 mp->ip4_table_index = ntohl (ip4_table_index);
19123 mp->ip6_table_index = ntohl (ip6_table_index);
19124 mp->is_add = is_add;
19132 api_flow_classify_dump (vat_main_t * vam)
19134 unformat_input_t *i = vam->input;
19135 vl_api_flow_classify_dump_t *mp;
19136 vl_api_control_ping_t *mp_ping;
19137 u8 type = FLOW_CLASSIFY_N_TABLES;
19140 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19144 errmsg ("classify table type must be specified");
19148 if (!vam->json_output)
19150 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19153 M (FLOW_CLASSIFY_DUMP, mp);
19158 /* Use a control ping for synchronization */
19159 MPING (CONTROL_PING, mp_ping);
19162 /* Wait for a reply... */
19168 api_feature_enable_disable (vat_main_t * vam)
19170 unformat_input_t *i = vam->input;
19171 vl_api_feature_enable_disable_t *mp;
19173 u8 *feature_name = 0;
19174 u32 sw_if_index = ~0;
19178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19180 if (unformat (i, "arc_name %s", &arc_name))
19182 else if (unformat (i, "feature_name %s", &feature_name))
19185 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19187 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19189 else if (unformat (i, "disable"))
19197 errmsg ("missing arc name");
19200 if (vec_len (arc_name) > 63)
19202 errmsg ("arc name too long");
19205 if (feature_name == 0)
19207 errmsg ("missing feature name");
19210 if (vec_len (feature_name) > 63)
19212 errmsg ("feature name too long");
19215 if (sw_if_index == ~0)
19217 errmsg ("missing interface name or sw_if_index");
19221 /* Construct the API message */
19222 M (FEATURE_ENABLE_DISABLE, mp);
19223 mp->sw_if_index = ntohl (sw_if_index);
19224 mp->enable = enable;
19225 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19226 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19227 vec_free (arc_name);
19228 vec_free (feature_name);
19236 api_feature_gso_enable_disable (vat_main_t * vam)
19238 unformat_input_t *i = vam->input;
19239 vl_api_feature_gso_enable_disable_t *mp;
19240 u32 sw_if_index = ~0;
19244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19246 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19248 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19250 else if (unformat (i, "enable"))
19252 else if (unformat (i, "disable"))
19258 if (sw_if_index == ~0)
19260 errmsg ("missing interface name or sw_if_index");
19264 /* Construct the API message */
19265 M (FEATURE_GSO_ENABLE_DISABLE, mp);
19266 mp->sw_if_index = ntohl (sw_if_index);
19267 mp->enable_disable = enable;
19275 api_sw_interface_tag_add_del (vat_main_t * vam)
19277 unformat_input_t *i = vam->input;
19278 vl_api_sw_interface_tag_add_del_t *mp;
19279 u32 sw_if_index = ~0;
19284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19286 if (unformat (i, "tag %s", &tag))
19288 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19290 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19292 else if (unformat (i, "del"))
19298 if (sw_if_index == ~0)
19300 errmsg ("missing interface name or sw_if_index");
19304 if (enable && (tag == 0))
19306 errmsg ("no tag specified");
19310 /* Construct the API message */
19311 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19312 mp->sw_if_index = ntohl (sw_if_index);
19313 mp->is_add = enable;
19315 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19324 api_sw_interface_add_del_mac_address (vat_main_t * vam)
19326 unformat_input_t *i = vam->input;
19327 vl_api_mac_address_t mac = { 0 };
19328 vl_api_sw_interface_add_del_mac_address_t *mp;
19329 u32 sw_if_index = ~0;
19334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19336 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19338 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19340 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
19342 else if (unformat (i, "del"))
19348 if (sw_if_index == ~0)
19350 errmsg ("missing interface name or sw_if_index");
19356 errmsg ("missing MAC address");
19360 /* Construct the API message */
19361 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
19362 mp->sw_if_index = ntohl (sw_if_index);
19363 mp->is_add = is_add;
19364 clib_memcpy (&mp->addr, &mac, sizeof (mac));
19371 static void vl_api_l2_xconnect_details_t_handler
19372 (vl_api_l2_xconnect_details_t * mp)
19374 vat_main_t *vam = &vat_main;
19376 print (vam->ofp, "%15d%15d",
19377 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19380 static void vl_api_l2_xconnect_details_t_handler_json
19381 (vl_api_l2_xconnect_details_t * mp)
19383 vat_main_t *vam = &vat_main;
19384 vat_json_node_t *node = NULL;
19386 if (VAT_JSON_ARRAY != vam->json_tree.type)
19388 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19389 vat_json_init_array (&vam->json_tree);
19391 node = vat_json_array_add (&vam->json_tree);
19393 vat_json_init_object (node);
19394 vat_json_object_add_uint (node, "rx_sw_if_index",
19395 ntohl (mp->rx_sw_if_index));
19396 vat_json_object_add_uint (node, "tx_sw_if_index",
19397 ntohl (mp->tx_sw_if_index));
19401 api_l2_xconnect_dump (vat_main_t * vam)
19403 vl_api_l2_xconnect_dump_t *mp;
19404 vl_api_control_ping_t *mp_ping;
19407 if (!vam->json_output)
19409 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19412 M (L2_XCONNECT_DUMP, mp);
19416 /* Use a control ping for synchronization */
19417 MPING (CONTROL_PING, mp_ping);
19425 api_hw_interface_set_mtu (vat_main_t * vam)
19427 unformat_input_t *i = vam->input;
19428 vl_api_hw_interface_set_mtu_t *mp;
19429 u32 sw_if_index = ~0;
19433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19435 if (unformat (i, "mtu %d", &mtu))
19437 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19439 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19445 if (sw_if_index == ~0)
19447 errmsg ("missing interface name or sw_if_index");
19453 errmsg ("no mtu specified");
19457 /* Construct the API message */
19458 M (HW_INTERFACE_SET_MTU, mp);
19459 mp->sw_if_index = ntohl (sw_if_index);
19460 mp->mtu = ntohs ((u16) mtu);
19468 api_p2p_ethernet_add (vat_main_t * vam)
19470 unformat_input_t *i = vam->input;
19471 vl_api_p2p_ethernet_add_t *mp;
19472 u32 parent_if_index = ~0;
19478 clib_memset (remote_mac, 0, sizeof (remote_mac));
19479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19481 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19483 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19487 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19489 else if (unformat (i, "sub_id %d", &sub_id))
19493 clib_warning ("parse error '%U'", format_unformat_error, i);
19498 if (parent_if_index == ~0)
19500 errmsg ("missing interface name or sw_if_index");
19505 errmsg ("missing remote mac address");
19510 errmsg ("missing sub-interface id");
19514 M (P2P_ETHERNET_ADD, mp);
19515 mp->parent_if_index = ntohl (parent_if_index);
19516 mp->subif_id = ntohl (sub_id);
19517 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19525 api_p2p_ethernet_del (vat_main_t * vam)
19527 unformat_input_t *i = vam->input;
19528 vl_api_p2p_ethernet_del_t *mp;
19529 u32 parent_if_index = ~0;
19534 clib_memset (remote_mac, 0, sizeof (remote_mac));
19535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19537 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19539 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19543 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19547 clib_warning ("parse error '%U'", format_unformat_error, i);
19552 if (parent_if_index == ~0)
19554 errmsg ("missing interface name or sw_if_index");
19559 errmsg ("missing remote mac address");
19563 M (P2P_ETHERNET_DEL, mp);
19564 mp->parent_if_index = ntohl (parent_if_index);
19565 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19573 api_lldp_config (vat_main_t * vam)
19575 unformat_input_t *i = vam->input;
19576 vl_api_lldp_config_t *mp;
19578 int tx_interval = 0;
19579 u8 *sys_name = NULL;
19582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19584 if (unformat (i, "system-name %s", &sys_name))
19586 else if (unformat (i, "tx-hold %d", &tx_hold))
19588 else if (unformat (i, "tx-interval %d", &tx_interval))
19592 clib_warning ("parse error '%U'", format_unformat_error, i);
19597 vec_add1 (sys_name, 0);
19599 M (LLDP_CONFIG, mp);
19600 mp->tx_hold = htonl (tx_hold);
19601 mp->tx_interval = htonl (tx_interval);
19602 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
19603 vec_free (sys_name);
19611 api_sw_interface_set_lldp (vat_main_t * vam)
19613 unformat_input_t *i = vam->input;
19614 vl_api_sw_interface_set_lldp_t *mp;
19615 u32 sw_if_index = ~0;
19617 u8 *port_desc = NULL, *mgmt_oid = NULL;
19618 ip4_address_t ip4_addr;
19619 ip6_address_t ip6_addr;
19622 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
19623 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
19625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19627 if (unformat (i, "disable"))
19630 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19632 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19634 else if (unformat (i, "port-desc %s", &port_desc))
19636 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
19638 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
19640 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
19646 if (sw_if_index == ~0)
19648 errmsg ("missing interface name or sw_if_index");
19652 /* Construct the API message */
19653 vec_add1 (port_desc, 0);
19654 vec_add1 (mgmt_oid, 0);
19655 M (SW_INTERFACE_SET_LLDP, mp);
19656 mp->sw_if_index = ntohl (sw_if_index);
19657 mp->enable = enable;
19658 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
19659 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
19660 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
19661 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
19662 vec_free (port_desc);
19663 vec_free (mgmt_oid);
19671 api_tcp_configure_src_addresses (vat_main_t * vam)
19673 vl_api_tcp_configure_src_addresses_t *mp;
19674 unformat_input_t *i = vam->input;
19675 vl_api_address_t first, last;
19680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19682 if (unformat (i, "%U - %U",
19683 unformat_vl_api_address, &first,
19684 unformat_vl_api_address, &last))
19688 errmsg ("one range per message (range already set)");
19693 else if (unformat (i, "vrf %d", &vrf_id))
19699 if (range_set == 0)
19701 errmsg ("address range not set");
19705 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
19707 mp->vrf_id = ntohl (vrf_id);
19708 clib_memcpy (&mp->first_address, &first, sizeof (first));
19709 clib_memcpy (&mp->last_address, &last, sizeof (last));
19716 static void vl_api_app_namespace_add_del_reply_t_handler
19717 (vl_api_app_namespace_add_del_reply_t * mp)
19719 vat_main_t *vam = &vat_main;
19720 i32 retval = ntohl (mp->retval);
19721 if (vam->async_mode)
19723 vam->async_errors += (retval < 0);
19727 vam->retval = retval;
19729 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
19730 vam->result_ready = 1;
19734 static void vl_api_app_namespace_add_del_reply_t_handler_json
19735 (vl_api_app_namespace_add_del_reply_t * mp)
19737 vat_main_t *vam = &vat_main;
19738 vat_json_node_t node;
19740 vat_json_init_object (&node);
19741 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
19742 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
19744 vat_json_print (vam->ofp, &node);
19745 vat_json_free (&node);
19747 vam->retval = ntohl (mp->retval);
19748 vam->result_ready = 1;
19752 api_app_namespace_add_del (vat_main_t * vam)
19754 vl_api_app_namespace_add_del_t *mp;
19755 unformat_input_t *i = vam->input;
19756 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
19757 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
19761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19763 if (unformat (i, "id %_%v%_", &ns_id))
19765 else if (unformat (i, "secret %lu", &secret))
19767 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19768 sw_if_index_set = 1;
19769 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
19771 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
19776 if (!ns_id || !secret_set || !sw_if_index_set)
19778 errmsg ("namespace id, secret and sw_if_index must be set");
19781 if (vec_len (ns_id) > 64)
19783 errmsg ("namespace id too long");
19786 M (APP_NAMESPACE_ADD_DEL, mp);
19788 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
19789 mp->namespace_id_len = vec_len (ns_id);
19790 mp->secret = clib_host_to_net_u64 (secret);
19791 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
19792 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
19793 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
19801 api_sock_init_shm (vat_main_t * vam)
19803 #if VPP_API_TEST_BUILTIN == 0
19804 unformat_input_t *i = vam->input;
19805 vl_api_shm_elem_config_t *config = 0;
19806 u64 size = 64 << 20;
19809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19811 if (unformat (i, "size %U", unformat_memory_size, &size))
19818 * Canned custom ring allocator config.
19819 * Should probably parse all of this
19821 vec_validate (config, 6);
19822 config[0].type = VL_API_VLIB_RING;
19823 config[0].size = 256;
19824 config[0].count = 32;
19826 config[1].type = VL_API_VLIB_RING;
19827 config[1].size = 1024;
19828 config[1].count = 16;
19830 config[2].type = VL_API_VLIB_RING;
19831 config[2].size = 4096;
19832 config[2].count = 2;
19834 config[3].type = VL_API_CLIENT_RING;
19835 config[3].size = 256;
19836 config[3].count = 32;
19838 config[4].type = VL_API_CLIENT_RING;
19839 config[4].size = 1024;
19840 config[4].count = 16;
19842 config[5].type = VL_API_CLIENT_RING;
19843 config[5].size = 4096;
19844 config[5].count = 2;
19846 config[6].type = VL_API_QUEUE;
19847 config[6].count = 128;
19848 config[6].size = sizeof (uword);
19850 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
19852 vam->client_index_invalid = 1;
19860 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
19862 vat_main_t *vam = &vat_main;
19867 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19868 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19869 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
19870 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
19871 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
19872 clib_net_to_host_u32 (mp->action_index), mp->tag);
19877 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19878 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19879 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
19880 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
19881 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
19882 clib_net_to_host_u32 (mp->action_index), mp->tag);
19887 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
19890 vat_main_t *vam = &vat_main;
19891 vat_json_node_t *node = NULL;
19892 struct in6_addr ip6;
19893 struct in_addr ip4;
19895 if (VAT_JSON_ARRAY != vam->json_tree.type)
19897 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19898 vat_json_init_array (&vam->json_tree);
19900 node = vat_json_array_add (&vam->json_tree);
19901 vat_json_init_object (node);
19903 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
19904 vat_json_object_add_uint (node, "appns_index",
19905 clib_net_to_host_u32 (mp->appns_index));
19906 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
19907 vat_json_object_add_uint (node, "scope", mp->scope);
19908 vat_json_object_add_uint (node, "action_index",
19909 clib_net_to_host_u32 (mp->action_index));
19910 vat_json_object_add_uint (node, "lcl_port",
19911 clib_net_to_host_u16 (mp->lcl_port));
19912 vat_json_object_add_uint (node, "rmt_port",
19913 clib_net_to_host_u16 (mp->rmt_port));
19914 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
19915 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
19916 vat_json_object_add_string_copy (node, "tag", mp->tag);
19919 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
19920 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
19921 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
19922 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
19926 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
19927 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
19928 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
19929 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
19934 api_session_rule_add_del (vat_main_t * vam)
19936 vl_api_session_rule_add_del_t *mp;
19937 unformat_input_t *i = vam->input;
19938 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
19939 u32 appns_index = 0, scope = 0;
19940 ip4_address_t lcl_ip4, rmt_ip4;
19941 ip6_address_t lcl_ip6, rmt_ip6;
19942 u8 is_ip4 = 1, conn_set = 0;
19943 u8 is_add = 1, *tag = 0;
19946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19948 if (unformat (i, "del"))
19950 else if (unformat (i, "add"))
19952 else if (unformat (i, "proto tcp"))
19954 else if (unformat (i, "proto udp"))
19956 else if (unformat (i, "appns %d", &appns_index))
19958 else if (unformat (i, "scope %d", &scope))
19960 else if (unformat (i, "tag %_%v%_", &tag))
19964 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
19965 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
19973 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
19974 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
19980 else if (unformat (i, "action %d", &action))
19985 if (proto == ~0 || !conn_set || action == ~0)
19987 errmsg ("transport proto, connection and action must be set");
19993 errmsg ("scope should be 0-3");
19997 M (SESSION_RULE_ADD_DEL, mp);
19999 mp->is_ip4 = is_ip4;
20000 mp->transport_proto = proto;
20001 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
20002 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
20003 mp->lcl_plen = lcl_plen;
20004 mp->rmt_plen = rmt_plen;
20005 mp->action_index = clib_host_to_net_u32 (action);
20006 mp->appns_index = clib_host_to_net_u32 (appns_index);
20008 mp->is_add = is_add;
20011 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
20012 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
20016 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
20017 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
20021 clib_memcpy (mp->tag, tag, vec_len (tag));
20031 api_session_rules_dump (vat_main_t * vam)
20033 vl_api_session_rules_dump_t *mp;
20034 vl_api_control_ping_t *mp_ping;
20037 if (!vam->json_output)
20039 print (vam->ofp, "%=20s", "Session Rules");
20042 M (SESSION_RULES_DUMP, mp);
20046 /* Use a control ping for synchronization */
20047 MPING (CONTROL_PING, mp_ping);
20050 /* Wait for a reply... */
20056 api_ip_container_proxy_add_del (vat_main_t * vam)
20058 vl_api_ip_container_proxy_add_del_t *mp;
20059 unformat_input_t *i = vam->input;
20060 u32 sw_if_index = ~0;
20061 vl_api_prefix_t pfx = { };
20065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20067 if (unformat (i, "del"))
20069 else if (unformat (i, "add"))
20071 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
20073 else if (unformat (i, "sw_if_index %u", &sw_if_index))
20078 if (sw_if_index == ~0 || pfx.len == 0)
20080 errmsg ("address and sw_if_index must be set");
20084 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
20086 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20087 mp->is_add = is_add;
20088 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
20096 api_qos_record_enable_disable (vat_main_t * vam)
20098 unformat_input_t *i = vam->input;
20099 vl_api_qos_record_enable_disable_t *mp;
20100 u32 sw_if_index, qs = 0xff;
20101 u8 sw_if_index_set = 0;
20105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20107 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20108 sw_if_index_set = 1;
20109 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20110 sw_if_index_set = 1;
20111 else if (unformat (i, "%U", unformat_qos_source, &qs))
20113 else if (unformat (i, "disable"))
20117 clib_warning ("parse error '%U'", format_unformat_error, i);
20122 if (sw_if_index_set == 0)
20124 errmsg ("missing interface name or sw_if_index");
20129 errmsg ("input location must be specified");
20133 M (QOS_RECORD_ENABLE_DISABLE, mp);
20135 mp->record.sw_if_index = ntohl (sw_if_index);
20136 mp->record.input_source = qs;
20137 mp->enable = enable;
20146 q_or_quit (vat_main_t * vam)
20148 #if VPP_API_TEST_BUILTIN == 0
20149 longjmp (vam->jump_buf, 1);
20151 return 0; /* not so much */
20155 q (vat_main_t * vam)
20157 return q_or_quit (vam);
20161 quit (vat_main_t * vam)
20163 return q_or_quit (vam);
20167 comment (vat_main_t * vam)
20173 elog_save (vat_main_t * vam)
20175 #if VPP_API_TEST_BUILTIN == 0
20176 elog_main_t *em = &vam->elog_main;
20177 unformat_input_t *i = vam->input;
20178 char *file, *chroot_file;
20179 clib_error_t *error;
20181 if (!unformat (i, "%s", &file))
20183 errmsg ("expected file name, got `%U'", format_unformat_error, i);
20187 /* It's fairly hard to get "../oopsie" through unformat; just in case */
20188 if (strstr (file, "..") || index (file, '/'))
20190 errmsg ("illegal characters in filename '%s'", file);
20194 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
20198 errmsg ("Saving %wd of %wd events to %s",
20199 elog_n_events_in_buffer (em),
20200 elog_buffer_capacity (em), chroot_file);
20202 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
20203 vec_free (chroot_file);
20206 clib_error_report (error);
20208 errmsg ("Use the vpp event loger...");
20215 elog_setup (vat_main_t * vam)
20217 #if VPP_API_TEST_BUILTIN == 0
20218 elog_main_t *em = &vam->elog_main;
20219 unformat_input_t *i = vam->input;
20220 u32 nevents = 128 << 10;
20222 (void) unformat (i, "nevents %d", &nevents);
20224 elog_init (em, nevents);
20225 vl_api_set_elog_main (em);
20226 vl_api_set_elog_trace_api_messages (1);
20227 errmsg ("Event logger initialized with %u events", nevents);
20229 errmsg ("Use the vpp event loger...");
20235 elog_enable (vat_main_t * vam)
20237 #if VPP_API_TEST_BUILTIN == 0
20238 elog_main_t *em = &vam->elog_main;
20240 elog_enable_disable (em, 1 /* enable */ );
20241 vl_api_set_elog_trace_api_messages (1);
20242 errmsg ("Event logger enabled...");
20244 errmsg ("Use the vpp event loger...");
20250 elog_disable (vat_main_t * vam)
20252 #if VPP_API_TEST_BUILTIN == 0
20253 elog_main_t *em = &vam->elog_main;
20255 elog_enable_disable (em, 0 /* enable */ );
20256 vl_api_set_elog_trace_api_messages (1);
20257 errmsg ("Event logger disabled...");
20259 errmsg ("Use the vpp event loger...");
20265 statseg (vat_main_t * vam)
20267 ssvm_private_t *ssvmp = &vam->stat_segment;
20268 ssvm_shared_header_t *shared_header = ssvmp->sh;
20269 vlib_counter_t **counters;
20270 u64 thread0_index1_packets;
20271 u64 thread0_index1_bytes;
20272 f64 vector_rate, input_rate;
20275 uword *counter_vector_by_name;
20276 if (vam->stat_segment_lockp == 0)
20278 errmsg ("Stat segment not mapped...");
20282 /* look up "/if/rx for sw_if_index 1 as a test */
20284 clib_spinlock_lock (vam->stat_segment_lockp);
20286 counter_vector_by_name = (uword *) shared_header->opaque[1];
20288 p = hash_get_mem (counter_vector_by_name, "/if/rx");
20291 clib_spinlock_unlock (vam->stat_segment_lockp);
20292 errmsg ("/if/tx not found?");
20296 /* Fish per-thread vector of combined counters from shared memory */
20297 counters = (vlib_counter_t **) p[0];
20299 if (vec_len (counters[0]) < 2)
20301 clib_spinlock_unlock (vam->stat_segment_lockp);
20302 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
20306 /* Read thread 0 sw_if_index 1 counter */
20307 thread0_index1_packets = counters[0][1].packets;
20308 thread0_index1_bytes = counters[0][1].bytes;
20310 p = hash_get_mem (counter_vector_by_name, "vector_rate");
20313 clib_spinlock_unlock (vam->stat_segment_lockp);
20314 errmsg ("vector_rate not found?");
20318 vector_rate = *(f64 *) (p[0]);
20319 p = hash_get_mem (counter_vector_by_name, "input_rate");
20322 clib_spinlock_unlock (vam->stat_segment_lockp);
20323 errmsg ("input_rate not found?");
20326 input_rate = *(f64 *) (p[0]);
20328 clib_spinlock_unlock (vam->stat_segment_lockp);
20330 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
20331 vector_rate, input_rate);
20332 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
20333 thread0_index1_packets, thread0_index1_bytes);
20339 cmd_cmp (void *a1, void *a2)
20344 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
20348 help (vat_main_t * vam)
20353 unformat_input_t *i = vam->input;
20356 if (unformat (i, "%s", &name))
20360 vec_add1 (name, 0);
20362 hs = hash_get_mem (vam->help_by_name, name);
20364 print (vam->ofp, "usage: %s %s", name, hs[0]);
20366 print (vam->ofp, "No such msg / command '%s'", name);
20371 print (vam->ofp, "Help is available for the following:");
20374 hash_foreach_pair (p, vam->function_by_name,
20376 vec_add1 (cmds, (u8 *)(p->key));
20380 vec_sort_with_function (cmds, cmd_cmp);
20382 for (j = 0; j < vec_len (cmds); j++)
20383 print (vam->ofp, "%s", cmds[j]);
20390 set (vat_main_t * vam)
20392 u8 *name = 0, *value = 0;
20393 unformat_input_t *i = vam->input;
20395 if (unformat (i, "%s", &name))
20397 /* The input buffer is a vector, not a string. */
20398 value = vec_dup (i->buffer);
20399 vec_delete (value, i->index, 0);
20400 /* Almost certainly has a trailing newline */
20401 if (value[vec_len (value) - 1] == '\n')
20402 value[vec_len (value) - 1] = 0;
20403 /* Make sure it's a proper string, one way or the other */
20404 vec_add1 (value, 0);
20405 (void) clib_macro_set_value (&vam->macro_main,
20406 (char *) name, (char *) value);
20409 errmsg ("usage: set <name> <value>");
20417 unset (vat_main_t * vam)
20421 if (unformat (vam->input, "%s", &name))
20422 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
20423 errmsg ("unset: %s wasn't set", name);
20436 macro_sort_cmp (void *a1, void *a2)
20438 macro_sort_t *s1 = a1;
20439 macro_sort_t *s2 = a2;
20441 return strcmp ((char *) (s1->name), (char *) (s2->name));
20445 dump_macro_table (vat_main_t * vam)
20447 macro_sort_t *sort_me = 0, *sm;
20452 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
20454 vec_add2 (sort_me, sm, 1);
20455 sm->name = (u8 *)(p->key);
20456 sm->value = (u8 *) (p->value[0]);
20460 vec_sort_with_function (sort_me, macro_sort_cmp);
20462 if (vec_len (sort_me))
20463 print (vam->ofp, "%-15s%s", "Name", "Value");
20465 print (vam->ofp, "The macro table is empty...");
20467 for (i = 0; i < vec_len (sort_me); i++)
20468 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
20473 dump_node_table (vat_main_t * vam)
20476 vlib_node_t *node, *next_node;
20478 if (vec_len (vam->graph_nodes) == 0)
20480 print (vam->ofp, "Node table empty, issue get_node_graph...");
20484 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
20486 node = vam->graph_nodes[0][i];
20487 print (vam->ofp, "[%d] %s", i, node->name);
20488 for (j = 0; j < vec_len (node->next_nodes); j++)
20490 if (node->next_nodes[j] != ~0)
20492 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20493 print (vam->ofp, " [%d] %s", j, next_node->name);
20501 value_sort_cmp (void *a1, void *a2)
20503 name_sort_t *n1 = a1;
20504 name_sort_t *n2 = a2;
20506 if (n1->value < n2->value)
20508 if (n1->value > n2->value)
20515 dump_msg_api_table (vat_main_t * vam)
20517 api_main_t *am = vlibapi_get_main ();
20518 name_sort_t *nses = 0, *ns;
20523 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
20525 vec_add2 (nses, ns, 1);
20526 ns->name = (u8 *)(hp->key);
20527 ns->value = (u32) hp->value[0];
20531 vec_sort_with_function (nses, value_sort_cmp);
20533 for (i = 0; i < vec_len (nses); i++)
20534 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
20540 get_msg_id (vat_main_t * vam)
20545 if (unformat (vam->input, "%s", &name_and_crc))
20547 message_index = vl_msg_api_get_msg_index (name_and_crc);
20548 if (message_index == ~0)
20550 print (vam->ofp, " '%s' not found", name_and_crc);
20553 print (vam->ofp, " '%s' has message index %d",
20554 name_and_crc, message_index);
20557 errmsg ("name_and_crc required...");
20562 search_node_table (vat_main_t * vam)
20564 unformat_input_t *line_input = vam->input;
20567 vlib_node_t *node, *next_node;
20570 if (vam->graph_node_index_by_name == 0)
20572 print (vam->ofp, "Node table empty, issue get_node_graph...");
20576 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20578 if (unformat (line_input, "%s", &node_to_find))
20580 vec_add1 (node_to_find, 0);
20581 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
20584 print (vam->ofp, "%s not found...", node_to_find);
20587 node = vam->graph_nodes[0][p[0]];
20588 print (vam->ofp, "[%d] %s", p[0], node->name);
20589 for (j = 0; j < vec_len (node->next_nodes); j++)
20591 if (node->next_nodes[j] != ~0)
20593 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20594 print (vam->ofp, " [%d] %s", j, next_node->name);
20601 clib_warning ("parse error '%U'", format_unformat_error,
20607 vec_free (node_to_find);
20616 script (vat_main_t * vam)
20618 #if (VPP_API_TEST_BUILTIN==0)
20620 char *save_current_file;
20621 unformat_input_t save_input;
20622 jmp_buf save_jump_buf;
20623 u32 save_line_number;
20625 FILE *new_fp, *save_ifp;
20627 if (unformat (vam->input, "%s", &s))
20629 new_fp = fopen ((char *) s, "r");
20632 errmsg ("Couldn't open script file %s", s);
20639 errmsg ("Missing script name");
20643 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
20644 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
20645 save_ifp = vam->ifp;
20646 save_line_number = vam->input_line_number;
20647 save_current_file = (char *) vam->current_file;
20649 vam->input_line_number = 0;
20651 vam->current_file = s;
20654 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
20655 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
20656 vam->ifp = save_ifp;
20657 vam->input_line_number = save_line_number;
20658 vam->current_file = (u8 *) save_current_file;
20663 clib_warning ("use the exec command...");
20669 echo (vat_main_t * vam)
20671 print (vam->ofp, "%v", vam->input->buffer);
20675 /* List of API message constructors, CLI names map to api_xxx */
20676 #define foreach_vpe_api_msg \
20677 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
20678 _(sw_interface_dump,"") \
20679 _(sw_interface_set_flags, \
20680 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
20681 _(sw_interface_add_del_address, \
20682 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
20683 _(sw_interface_set_rx_mode, \
20684 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
20685 _(sw_interface_set_rx_placement, \
20686 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
20687 _(sw_interface_rx_placement_dump, \
20688 "[<intfc> | sw_if_index <id>]") \
20689 _(sw_interface_set_table, \
20690 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
20691 _(sw_interface_set_mpls_enable, \
20692 "<intfc> | sw_if_index [disable | dis]") \
20693 _(sw_interface_set_vpath, \
20694 "<intfc> | sw_if_index <id> enable | disable") \
20695 _(sw_interface_set_vxlan_bypass, \
20696 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20697 _(sw_interface_set_geneve_bypass, \
20698 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20699 _(sw_interface_set_l2_xconnect, \
20700 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20701 "enable | disable") \
20702 _(sw_interface_set_l2_bridge, \
20703 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
20704 "[shg <split-horizon-group>] [bvi]\n" \
20705 "enable | disable") \
20706 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
20707 _(bridge_domain_add_del, \
20708 "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") \
20709 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
20711 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
20712 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
20713 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
20715 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20717 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20719 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
20721 "<vpp-if-name> | sw_if_index <id>") \
20722 _(sw_interface_tap_v2_dump, "") \
20723 _(virtio_pci_create, \
20724 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled]") \
20725 _(virtio_pci_delete, \
20726 "<vpp-if-name> | sw_if_index <id>") \
20727 _(sw_interface_virtio_pci_dump, "") \
20729 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
20730 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
20733 "<vpp-if-name> | sw_if_index <id>") \
20735 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
20736 _(bond_detach_slave, \
20737 "sw_if_index <n>") \
20738 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
20739 _(sw_interface_bond_dump, "") \
20740 _(sw_interface_slave_dump, \
20741 "<vpp-if-name> | sw_if_index <id>") \
20742 _(ip_table_add_del, \
20743 "table <n> [ipv6] [add | del]\n") \
20744 _(ip_route_add_del, \
20745 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
20746 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
20747 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
20748 "[multipath] [count <n>] [del]") \
20749 _(ip_mroute_add_del, \
20750 "<src> <grp>/<mask> [table-id <n>]\n" \
20751 "[<intfc> | sw_if_index <id>] [local] [del]") \
20752 _(mpls_table_add_del, \
20753 "table <n> [add | del]\n") \
20754 _(mpls_route_add_del, \
20755 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
20756 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
20757 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
20758 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
20759 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
20760 "[count <n>] [del]") \
20761 _(mpls_ip_bind_unbind, \
20762 "<label> <addr/len>") \
20763 _(mpls_tunnel_add_del, \
20764 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
20765 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
20766 "[l2-only] [out-label <n>]") \
20767 _(sr_mpls_policy_add, \
20768 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
20769 _(sr_mpls_policy_del, \
20771 _(bier_table_add_del, \
20772 "<label> <sub-domain> <set> <bsl> [del]") \
20773 _(bier_route_add_del, \
20774 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
20775 "[<intfc> | sw_if_index <id>]" \
20776 "[weight <n>] [del] [multipath]") \
20777 _(sw_interface_set_unnumbered, \
20778 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
20779 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
20780 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
20781 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
20782 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
20783 "[outer_vlan_id_any][inner_vlan_id_any]") \
20784 _(ip_table_replace_begin, "table <n> [ipv6]") \
20785 _(ip_table_flush, "table <n> [ipv6]") \
20786 _(ip_table_replace_end, "table <n> [ipv6]") \
20787 _(set_ip_flow_hash, \
20788 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
20789 _(sw_interface_ip6_enable_disable, \
20790 "<intfc> | sw_if_index <id> enable | disable") \
20791 _(l2_patch_add_del, \
20792 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20793 "enable | disable") \
20794 _(sr_localsid_add_del, \
20795 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
20796 "fib-table <num> (end.psp) sw_if_index <num>") \
20797 _(classify_add_del_table, \
20798 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
20799 " [del] [del-chain] mask <mask-value>\n" \
20800 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
20801 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
20802 _(classify_add_del_session, \
20803 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
20804 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
20805 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
20806 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
20807 _(classify_set_interface_ip_table, \
20808 "<intfc> | sw_if_index <nn> table <nn>") \
20809 _(classify_set_interface_l2_tables, \
20810 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20811 " [other-table <nn>]") \
20812 _(get_node_index, "node <node-name") \
20813 _(add_node_next, "node <node-name> next <next-node-name>") \
20814 _(l2tpv3_create_tunnel, \
20815 "client_address <ip6-addr> our_address <ip6-addr>\n" \
20816 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
20817 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
20818 _(l2tpv3_set_tunnel_cookies, \
20819 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
20820 "[new_remote_cookie <nn>]\n") \
20821 _(l2tpv3_interface_enable_disable, \
20822 "<intfc> | sw_if_index <nn> enable | disable") \
20823 _(l2tpv3_set_lookup_key, \
20824 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
20825 _(sw_if_l2tpv3_tunnel_dump, "") \
20826 _(vxlan_offload_rx, \
20827 "hw { <interface name> | hw_if_index <nn>} " \
20828 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
20829 _(vxlan_add_del_tunnel, \
20830 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20831 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
20832 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20833 _(geneve_add_del_tunnel, \
20834 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20835 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20836 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20837 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20838 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20839 _(gre_tunnel_add_del, \
20840 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
20841 "[teb | erspan <session-id>] [del]") \
20842 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20843 _(l2_fib_clear_table, "") \
20844 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
20845 _(l2_interface_vlan_tag_rewrite, \
20846 "<intfc> | sw_if_index <nn> \n" \
20847 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
20848 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
20849 _(create_vhost_user_if, \
20850 "socket <filename> [server] [renumber <dev_instance>] " \
20851 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
20852 "[mac <mac_address>]") \
20853 _(modify_vhost_user_if, \
20854 "<intfc> | sw_if_index <nn> socket <filename>\n" \
20855 "[server] [renumber <dev_instance>] [gso]") \
20856 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
20857 _(sw_interface_vhost_user_dump, "") \
20858 _(show_version, "") \
20859 _(show_threads, "") \
20860 _(vxlan_gpe_add_del_tunnel, \
20861 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
20862 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20863 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
20864 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
20865 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20866 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
20867 _(interface_name_renumber, \
20868 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
20869 _(input_acl_set_interface, \
20870 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20871 " [l2-table <nn>] [del]") \
20872 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
20873 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
20874 _(ip_dump, "ipv4 | ipv6") \
20875 _(ipsec_spd_add_del, "spd_id <n> [del]") \
20876 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
20878 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
20879 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
20880 " integ_alg <alg> integ_key <hex>") \
20881 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
20882 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
20883 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
20884 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
20885 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
20886 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
20887 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
20888 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
20889 " [instance <n>]") \
20890 _(ipsec_sa_dump, "[sa_id <n>]") \
20891 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
20892 _(delete_loopback,"sw_if_index <nn>") \
20893 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20894 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
20895 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
20896 _(want_interface_events, "enable|disable") \
20897 _(get_first_msg_id, "client <name>") \
20898 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20899 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20900 "fib-id <nn> [ip4][ip6][default]") \
20901 _(get_node_graph, " ") \
20902 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20903 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20904 _(ioam_disable, "") \
20905 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
20906 " sw_if_index <sw_if_index> p <priority> " \
20907 "w <weight>] [del]") \
20908 _(one_add_del_locator, "locator-set <locator_name> " \
20909 "iface <intf> | sw_if_index <sw_if_index> " \
20910 "p <priority> w <weight> [del]") \
20911 _(one_add_del_local_eid,"vni <vni> eid " \
20912 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20913 "locator-set <locator_name> [del]" \
20914 "[key-id sha1|sha256 secret-key <secret-key>]")\
20915 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
20916 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
20917 _(one_enable_disable, "enable|disable") \
20918 _(one_map_register_enable_disable, "enable|disable") \
20919 _(one_map_register_fallback_threshold, "<value>") \
20920 _(one_rloc_probe_enable_disable, "enable|disable") \
20921 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20923 "rloc <locator> p <prio> " \
20924 "w <weight> [rloc <loc> ... ] " \
20925 "action <action> [del-all]") \
20926 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20928 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20929 _(one_use_petr, "ip-address> | disable") \
20930 _(one_map_request_mode, "src-dst|dst-only") \
20931 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20932 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20933 _(one_locator_set_dump, "[local | remote]") \
20934 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
20935 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20936 "[local] | [remote]") \
20937 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
20938 _(one_ndp_bd_get, "") \
20939 _(one_ndp_entries_get, "bd <bridge-domain>") \
20940 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
20941 _(one_l2_arp_bd_get, "") \
20942 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
20943 _(one_stats_enable_disable, "enable|disable") \
20944 _(show_one_stats_enable_disable, "") \
20945 _(one_eid_table_vni_dump, "") \
20946 _(one_eid_table_map_dump, "l2|l3") \
20947 _(one_map_resolver_dump, "") \
20948 _(one_map_server_dump, "") \
20949 _(one_adjacencies_get, "vni <vni>") \
20950 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
20951 _(show_one_rloc_probe_state, "") \
20952 _(show_one_map_register_state, "") \
20953 _(show_one_status, "") \
20954 _(one_stats_dump, "") \
20955 _(one_stats_flush, "") \
20956 _(one_get_map_request_itr_rlocs, "") \
20957 _(one_map_register_set_ttl, "<ttl>") \
20958 _(one_set_transport_protocol, "udp|api") \
20959 _(one_get_transport_protocol, "") \
20960 _(one_enable_disable_xtr_mode, "enable|disable") \
20961 _(one_show_xtr_mode, "") \
20962 _(one_enable_disable_pitr_mode, "enable|disable") \
20963 _(one_show_pitr_mode, "") \
20964 _(one_enable_disable_petr_mode, "enable|disable") \
20965 _(one_show_petr_mode, "") \
20966 _(show_one_nsh_mapping, "") \
20967 _(show_one_pitr, "") \
20968 _(show_one_use_petr, "") \
20969 _(show_one_map_request_mode, "") \
20970 _(show_one_map_register_ttl, "") \
20971 _(show_one_map_register_fallback_threshold, "") \
20972 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
20973 " sw_if_index <sw_if_index> p <priority> " \
20974 "w <weight>] [del]") \
20975 _(lisp_add_del_locator, "locator-set <locator_name> " \
20976 "iface <intf> | sw_if_index <sw_if_index> " \
20977 "p <priority> w <weight> [del]") \
20978 _(lisp_add_del_local_eid,"vni <vni> eid " \
20979 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20980 "locator-set <locator_name> [del]" \
20981 "[key-id sha1|sha256 secret-key <secret-key>]") \
20982 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
20983 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
20984 _(lisp_enable_disable, "enable|disable") \
20985 _(lisp_map_register_enable_disable, "enable|disable") \
20986 _(lisp_rloc_probe_enable_disable, "enable|disable") \
20987 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20989 "rloc <locator> p <prio> " \
20990 "w <weight> [rloc <loc> ... ] " \
20991 "action <action> [del-all]") \
20992 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20994 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20995 _(lisp_use_petr, "<ip-address> | disable") \
20996 _(lisp_map_request_mode, "src-dst|dst-only") \
20997 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20998 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20999 _(lisp_locator_set_dump, "[local | remote]") \
21000 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21001 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21002 "[local] | [remote]") \
21003 _(lisp_eid_table_vni_dump, "") \
21004 _(lisp_eid_table_map_dump, "l2|l3") \
21005 _(lisp_map_resolver_dump, "") \
21006 _(lisp_map_server_dump, "") \
21007 _(lisp_adjacencies_get, "vni <vni>") \
21008 _(gpe_fwd_entry_vnis_get, "") \
21009 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21010 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21011 "[table <table-id>]") \
21012 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21013 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21014 _(gpe_set_encap_mode, "lisp|vxlan") \
21015 _(gpe_get_encap_mode, "") \
21016 _(lisp_gpe_add_del_iface, "up|down") \
21017 _(lisp_gpe_enable_disable, "enable|disable") \
21018 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21019 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21020 _(show_lisp_rloc_probe_state, "") \
21021 _(show_lisp_map_register_state, "") \
21022 _(show_lisp_status, "") \
21023 _(lisp_get_map_request_itr_rlocs, "") \
21024 _(show_lisp_pitr, "") \
21025 _(show_lisp_use_petr, "") \
21026 _(show_lisp_map_request_mode, "") \
21027 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21028 _(af_packet_delete, "name <host interface name>") \
21029 _(af_packet_dump, "") \
21030 _(policer_add_del, "name <policer name> <params> [del]") \
21031 _(policer_dump, "[name <policer name>]") \
21032 _(policer_classify_set_interface, \
21033 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21034 " [l2-table <nn>] [del]") \
21035 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21036 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21037 "[master|slave]") \
21038 _(netmap_delete, "name <interface name>") \
21039 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21040 _(mpls_table_dump, "") \
21041 _(mpls_route_dump, "table-id <ID>") \
21042 _(classify_table_ids, "") \
21043 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21044 _(classify_table_info, "table_id <nn>") \
21045 _(classify_session_dump, "table_id <nn>") \
21046 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21047 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21048 "[template_interval <nn>] [udp_checksum]") \
21049 _(ipfix_exporter_dump, "") \
21050 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21051 _(ipfix_classify_stream_dump, "") \
21052 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21053 _(ipfix_classify_table_dump, "") \
21054 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21055 _(sw_interface_span_dump, "[l2]") \
21056 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21057 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
21058 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21059 _(pg_enable_disable, "[stream <id>] disable") \
21060 _(ip_source_and_port_range_check_add_del, \
21061 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21062 _(ip_source_and_port_range_check_interface_add_del, \
21063 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21064 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21065 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21066 _(l2_interface_pbb_tag_rewrite, \
21067 "<intfc> | sw_if_index <nn> \n" \
21068 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21069 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21070 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21071 _(flow_classify_set_interface, \
21072 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21073 _(flow_classify_dump, "type [ip4|ip6]") \
21074 _(ip_table_dump, "") \
21075 _(ip_route_dump, "table-id [ip4|ip6]") \
21076 _(ip_mtable_dump, "") \
21077 _(ip_mroute_dump, "table-id [ip4|ip6]") \
21078 _(feature_enable_disable, "arc_name <arc_name> " \
21079 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21080 _(feature_gso_enable_disable, "<intfc> | sw_if_index <nn> " \
21081 "[enable | disable] ") \
21082 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21084 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
21085 "mac <mac-address> [del]") \
21086 _(l2_xconnect_dump, "") \
21087 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
21088 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21089 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21090 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21091 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21092 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21093 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21094 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21095 _(sock_init_shm, "size <nnn>") \
21096 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21097 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
21098 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
21099 _(session_rules_dump, "") \
21100 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
21101 _(output_acl_set_interface, \
21102 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21103 " [l2-table <nn>] [del]") \
21104 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
21106 /* List of command functions, CLI names map directly to functions */
21107 #define foreach_cli_function \
21108 _(comment, "usage: comment <ignore-rest-of-line>") \
21109 _(dump_interface_table, "usage: dump_interface_table") \
21110 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21111 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21112 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21113 _(dump_macro_table, "usage: dump_macro_table ") \
21114 _(dump_node_table, "usage: dump_node_table") \
21115 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21116 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
21117 _(elog_disable, "usage: elog_disable") \
21118 _(elog_enable, "usage: elog_enable") \
21119 _(elog_save, "usage: elog_save <filename>") \
21120 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21121 _(echo, "usage: echo <message>") \
21122 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21123 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21124 _(help, "usage: help") \
21125 _(q, "usage: quit") \
21126 _(quit, "usage: quit") \
21127 _(search_node_table, "usage: search_node_table <name>...") \
21128 _(set, "usage: set <variable-name> <value>") \
21129 _(script, "usage: script <file-name>") \
21130 _(statseg, "usage: statseg") \
21131 _(unset, "usage: unset <variable-name>")
21134 static void vl_api_##n##_t_handler_uni \
21135 (vl_api_##n##_t * mp) \
21137 vat_main_t * vam = &vat_main; \
21138 if (vam->json_output) { \
21139 vl_api_##n##_t_handler_json(mp); \
21141 vl_api_##n##_t_handler(mp); \
21144 foreach_vpe_api_reply_msg;
21145 #if VPP_API_TEST_BUILTIN == 0
21146 foreach_standalone_reply_msg;
21151 vat_api_hookup (vat_main_t * vam)
21154 vl_msg_api_set_handlers(VL_API_##N, #n, \
21155 vl_api_##n##_t_handler_uni, \
21157 vl_api_##n##_t_endian, \
21158 vl_api_##n##_t_print, \
21159 sizeof(vl_api_##n##_t), 1);
21160 foreach_vpe_api_reply_msg;
21161 #if VPP_API_TEST_BUILTIN == 0
21162 foreach_standalone_reply_msg;
21166 #if (VPP_API_TEST_BUILTIN==0)
21167 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21169 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21171 vam->function_by_name = hash_create_string (0, sizeof (uword));
21173 vam->help_by_name = hash_create_string (0, sizeof (uword));
21176 /* API messages we can send */
21177 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21178 foreach_vpe_api_msg;
21182 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21183 foreach_vpe_api_msg;
21186 /* CLI functions */
21187 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21188 foreach_cli_function;
21192 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21193 foreach_cli_function;
21197 #if VPP_API_TEST_BUILTIN
21198 static clib_error_t *
21199 vat_api_hookup_shim (vlib_main_t * vm)
21201 vat_api_hookup (&vat_main);
21205 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21209 * fd.io coding-style-patch-verification: ON
21212 * eval: (c-set-style "gnu")