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/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;
1103 api_main_t *am = vlibapi_get_main ();
1107 vat_json_init_object (&node);
1108 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1109 vat_json_object_add_uint (&node, "reply_in_shmem",
1110 ntohl (mp->reply_in_shmem));
1111 /* Toss the shared-memory original... */
1112 pthread_mutex_lock (&am->vlib_rp->mutex);
1113 oldheap = svm_push_data_heap (am->vlib_rp);
1115 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1118 svm_pop_heap (oldheap);
1119 pthread_mutex_unlock (&am->vlib_rp->mutex);
1121 vat_json_print (vam->ofp, &node);
1122 vat_json_free (&node);
1124 vam->retval = ntohl (mp->retval);
1125 vam->result_ready = 1;
1129 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1131 vat_main_t *vam = &vat_main;
1132 i32 retval = ntohl (mp->retval);
1133 u32 length = vl_api_string_len (&mp->reply);
1135 vec_reset_length (vam->cmd_reply);
1137 vam->retval = retval;
1140 vec_validate (vam->cmd_reply, length);
1141 clib_memcpy ((char *) (vam->cmd_reply),
1142 vl_api_from_api_string (&mp->reply), length);
1143 vam->cmd_reply[length] = 0;
1145 vam->result_ready = 1;
1149 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1151 vat_main_t *vam = &vat_main;
1152 vat_json_node_t node;
1154 vec_reset_length (vam->cmd_reply);
1156 vat_json_init_object (&node);
1157 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1158 vat_json_object_add_string_copy (&node, "reply",
1159 vl_api_from_api_string (&mp->reply));
1161 vat_json_print (vam->ofp, &node);
1162 vat_json_free (&node);
1164 vam->retval = ntohl (mp->retval);
1165 vam->result_ready = 1;
1168 static void vl_api_classify_add_del_table_reply_t_handler
1169 (vl_api_classify_add_del_table_reply_t * mp)
1171 vat_main_t *vam = &vat_main;
1172 i32 retval = ntohl (mp->retval);
1173 if (vam->async_mode)
1175 vam->async_errors += (retval < 0);
1179 vam->retval = retval;
1181 ((mp->new_table_index != 0xFFFFFFFF) ||
1182 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1183 (mp->match_n_vectors != 0xFFFFFFFF)))
1185 * Note: this is just barely thread-safe, depends on
1186 * the main thread spinning waiting for an answer...
1188 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1189 ntohl (mp->new_table_index),
1190 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1191 vam->result_ready = 1;
1195 static void vl_api_classify_add_del_table_reply_t_handler_json
1196 (vl_api_classify_add_del_table_reply_t * mp)
1198 vat_main_t *vam = &vat_main;
1199 vat_json_node_t node;
1201 vat_json_init_object (&node);
1202 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1203 vat_json_object_add_uint (&node, "new_table_index",
1204 ntohl (mp->new_table_index));
1205 vat_json_object_add_uint (&node, "skip_n_vectors",
1206 ntohl (mp->skip_n_vectors));
1207 vat_json_object_add_uint (&node, "match_n_vectors",
1208 ntohl (mp->match_n_vectors));
1210 vat_json_print (vam->ofp, &node);
1211 vat_json_free (&node);
1213 vam->retval = ntohl (mp->retval);
1214 vam->result_ready = 1;
1217 static void vl_api_get_node_index_reply_t_handler
1218 (vl_api_get_node_index_reply_t * mp)
1220 vat_main_t *vam = &vat_main;
1221 i32 retval = ntohl (mp->retval);
1222 if (vam->async_mode)
1224 vam->async_errors += (retval < 0);
1228 vam->retval = retval;
1230 errmsg ("node index %d", ntohl (mp->node_index));
1231 vam->result_ready = 1;
1235 static void vl_api_get_node_index_reply_t_handler_json
1236 (vl_api_get_node_index_reply_t * mp)
1238 vat_main_t *vam = &vat_main;
1239 vat_json_node_t node;
1241 vat_json_init_object (&node);
1242 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1243 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1245 vat_json_print (vam->ofp, &node);
1246 vat_json_free (&node);
1248 vam->retval = ntohl (mp->retval);
1249 vam->result_ready = 1;
1252 static void vl_api_get_next_index_reply_t_handler
1253 (vl_api_get_next_index_reply_t * mp)
1255 vat_main_t *vam = &vat_main;
1256 i32 retval = ntohl (mp->retval);
1257 if (vam->async_mode)
1259 vam->async_errors += (retval < 0);
1263 vam->retval = retval;
1265 errmsg ("next node index %d", ntohl (mp->next_index));
1266 vam->result_ready = 1;
1270 static void vl_api_get_next_index_reply_t_handler_json
1271 (vl_api_get_next_index_reply_t * mp)
1273 vat_main_t *vam = &vat_main;
1274 vat_json_node_t node;
1276 vat_json_init_object (&node);
1277 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1278 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1280 vat_json_print (vam->ofp, &node);
1281 vat_json_free (&node);
1283 vam->retval = ntohl (mp->retval);
1284 vam->result_ready = 1;
1287 static void vl_api_add_node_next_reply_t_handler
1288 (vl_api_add_node_next_reply_t * mp)
1290 vat_main_t *vam = &vat_main;
1291 i32 retval = ntohl (mp->retval);
1292 if (vam->async_mode)
1294 vam->async_errors += (retval < 0);
1298 vam->retval = retval;
1300 errmsg ("next index %d", ntohl (mp->next_index));
1301 vam->result_ready = 1;
1305 static void vl_api_add_node_next_reply_t_handler_json
1306 (vl_api_add_node_next_reply_t * mp)
1308 vat_main_t *vam = &vat_main;
1309 vat_json_node_t node;
1311 vat_json_init_object (&node);
1312 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1313 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1315 vat_json_print (vam->ofp, &node);
1316 vat_json_free (&node);
1318 vam->retval = ntohl (mp->retval);
1319 vam->result_ready = 1;
1322 static void vl_api_show_version_reply_t_handler
1323 (vl_api_show_version_reply_t * mp)
1325 vat_main_t *vam = &vat_main;
1326 i32 retval = ntohl (mp->retval);
1330 errmsg (" program: %s", mp->program);
1331 errmsg (" version: %s", mp->version);
1332 errmsg (" build date: %s", mp->build_date);
1333 errmsg ("build directory: %s", mp->build_directory);
1335 vam->retval = retval;
1336 vam->result_ready = 1;
1339 static void vl_api_show_version_reply_t_handler_json
1340 (vl_api_show_version_reply_t * mp)
1342 vat_main_t *vam = &vat_main;
1343 vat_json_node_t node;
1345 vat_json_init_object (&node);
1346 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1347 vat_json_object_add_string_copy (&node, "program", mp->program);
1348 vat_json_object_add_string_copy (&node, "version", mp->version);
1349 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1350 vat_json_object_add_string_copy (&node, "build_directory",
1351 mp->build_directory);
1353 vat_json_print (vam->ofp, &node);
1354 vat_json_free (&node);
1356 vam->retval = ntohl (mp->retval);
1357 vam->result_ready = 1;
1360 static void vl_api_show_threads_reply_t_handler
1361 (vl_api_show_threads_reply_t * mp)
1363 vat_main_t *vam = &vat_main;
1364 i32 retval = ntohl (mp->retval);
1368 count = ntohl (mp->count);
1370 for (i = 0; i < count; i++)
1372 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1373 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1374 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1375 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1376 ntohl (mp->thread_data[i].cpu_socket));
1378 vam->retval = retval;
1379 vam->result_ready = 1;
1382 static void vl_api_show_threads_reply_t_handler_json
1383 (vl_api_show_threads_reply_t * mp)
1385 vat_main_t *vam = &vat_main;
1386 vat_json_node_t node;
1387 vl_api_thread_data_t *td;
1388 i32 retval = ntohl (mp->retval);
1392 count = ntohl (mp->count);
1394 vat_json_init_object (&node);
1395 vat_json_object_add_int (&node, "retval", retval);
1396 vat_json_object_add_uint (&node, "count", count);
1398 for (i = 0; i < count; i++)
1400 td = &mp->thread_data[i];
1401 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1402 vat_json_object_add_string_copy (&node, "name", td->name);
1403 vat_json_object_add_string_copy (&node, "type", td->type);
1404 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1405 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1406 vat_json_object_add_int (&node, "core", ntohl (td->id));
1407 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1410 vat_json_print (vam->ofp, &node);
1411 vat_json_free (&node);
1413 vam->retval = retval;
1414 vam->result_ready = 1;
1418 api_show_threads (vat_main_t * vam)
1420 vl_api_show_threads_t *mp;
1424 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1425 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1427 M (SHOW_THREADS, mp);
1435 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1437 u32 sw_if_index = ntohl (mp->sw_if_index);
1438 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1439 mp->mac_ip ? "mac/ip binding" : "address resolution",
1440 ntohl (mp->pid), format_ip4_address, mp->ip,
1441 format_vl_api_mac_address, &mp->mac, sw_if_index);
1445 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1447 /* JSON output not supported */
1451 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1453 u32 sw_if_index = ntohl (mp->sw_if_index);
1454 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1455 mp->mac_ip ? "mac/ip binding" : "address resolution",
1456 ntohl (mp->pid), format_vl_api_ip6_address, mp->ip,
1457 format_vl_api_mac_address, mp->mac, sw_if_index);
1461 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1463 /* JSON output not supported */
1467 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1469 u32 n_macs = ntohl (mp->n_macs);
1470 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1471 ntohl (mp->pid), mp->client_index, n_macs);
1473 for (i = 0; i < n_macs; i++)
1475 vl_api_mac_entry_t *mac = &mp->mac[i];
1476 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1477 i + 1, ntohl (mac->sw_if_index),
1478 format_ethernet_address, mac->mac_addr, mac->action);
1485 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1487 /* JSON output not supported */
1490 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1491 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1494 * Special-case: build the bridge domain table, maintain
1495 * the next bd id vbl.
1497 static void vl_api_bridge_domain_details_t_handler
1498 (vl_api_bridge_domain_details_t * mp)
1500 vat_main_t *vam = &vat_main;
1501 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1504 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1505 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1507 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1508 ntohl (mp->bd_id), mp->learn, mp->forward,
1509 mp->flood, ntohl (mp->bvi_sw_if_index),
1510 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1514 vl_api_bridge_domain_sw_if_t *sw_ifs;
1515 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1518 sw_ifs = mp->sw_if_details;
1519 for (i = 0; i < n_sw_ifs; i++)
1525 sw_if_index = ntohl (sw_ifs->sw_if_index);
1528 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1530 if ((u32) p->value[0] == sw_if_index)
1532 sw_if_name = (u8 *)(p->key);
1537 print (vam->ofp, "%7d %3d %s", sw_if_index,
1538 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1539 "sw_if_index not found!");
1546 static void vl_api_bridge_domain_details_t_handler_json
1547 (vl_api_bridge_domain_details_t * mp)
1549 vat_main_t *vam = &vat_main;
1550 vat_json_node_t *node, *array = NULL;
1551 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1553 if (VAT_JSON_ARRAY != vam->json_tree.type)
1555 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1556 vat_json_init_array (&vam->json_tree);
1558 node = vat_json_array_add (&vam->json_tree);
1560 vat_json_init_object (node);
1561 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1562 vat_json_object_add_uint (node, "flood", mp->flood);
1563 vat_json_object_add_uint (node, "forward", mp->forward);
1564 vat_json_object_add_uint (node, "learn", mp->learn);
1565 vat_json_object_add_uint (node, "bvi_sw_if_index",
1566 ntohl (mp->bvi_sw_if_index));
1567 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1568 array = vat_json_object_add (node, "sw_if");
1569 vat_json_init_array (array);
1575 vl_api_bridge_domain_sw_if_t *sw_ifs;
1578 sw_ifs = mp->sw_if_details;
1579 for (i = 0; i < n_sw_ifs; i++)
1581 node = vat_json_array_add (array);
1582 vat_json_init_object (node);
1583 vat_json_object_add_uint (node, "sw_if_index",
1584 ntohl (sw_ifs->sw_if_index));
1585 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1591 static void vl_api_control_ping_reply_t_handler
1592 (vl_api_control_ping_reply_t * mp)
1594 vat_main_t *vam = &vat_main;
1595 i32 retval = ntohl (mp->retval);
1596 if (vam->async_mode)
1598 vam->async_errors += (retval < 0);
1602 vam->retval = retval;
1603 vam->result_ready = 1;
1605 if (vam->socket_client_main)
1606 vam->socket_client_main->control_pings_outstanding--;
1609 static void vl_api_control_ping_reply_t_handler_json
1610 (vl_api_control_ping_reply_t * mp)
1612 vat_main_t *vam = &vat_main;
1613 i32 retval = ntohl (mp->retval);
1615 if (VAT_JSON_NONE != vam->json_tree.type)
1617 vat_json_print (vam->ofp, &vam->json_tree);
1618 vat_json_free (&vam->json_tree);
1619 vam->json_tree.type = VAT_JSON_NONE;
1624 vat_json_init_array (&vam->json_tree);
1625 vat_json_print (vam->ofp, &vam->json_tree);
1626 vam->json_tree.type = VAT_JSON_NONE;
1629 vam->retval = retval;
1630 vam->result_ready = 1;
1634 vl_api_bridge_domain_set_mac_age_reply_t_handler
1635 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1637 vat_main_t *vam = &vat_main;
1638 i32 retval = ntohl (mp->retval);
1639 if (vam->async_mode)
1641 vam->async_errors += (retval < 0);
1645 vam->retval = retval;
1646 vam->result_ready = 1;
1650 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1651 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1653 vat_main_t *vam = &vat_main;
1654 vat_json_node_t node;
1656 vat_json_init_object (&node);
1657 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1659 vat_json_print (vam->ofp, &node);
1660 vat_json_free (&node);
1662 vam->retval = ntohl (mp->retval);
1663 vam->result_ready = 1;
1667 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1669 vat_main_t *vam = &vat_main;
1670 i32 retval = ntohl (mp->retval);
1671 if (vam->async_mode)
1673 vam->async_errors += (retval < 0);
1677 vam->retval = retval;
1678 vam->result_ready = 1;
1682 static void vl_api_l2_flags_reply_t_handler_json
1683 (vl_api_l2_flags_reply_t * mp)
1685 vat_main_t *vam = &vat_main;
1686 vat_json_node_t node;
1688 vat_json_init_object (&node);
1689 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1690 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1691 ntohl (mp->resulting_feature_bitmap));
1693 vat_json_print (vam->ofp, &node);
1694 vat_json_free (&node);
1696 vam->retval = ntohl (mp->retval);
1697 vam->result_ready = 1;
1700 static void vl_api_bridge_flags_reply_t_handler
1701 (vl_api_bridge_flags_reply_t * mp)
1703 vat_main_t *vam = &vat_main;
1704 i32 retval = ntohl (mp->retval);
1705 if (vam->async_mode)
1707 vam->async_errors += (retval < 0);
1711 vam->retval = retval;
1712 vam->result_ready = 1;
1716 static void vl_api_bridge_flags_reply_t_handler_json
1717 (vl_api_bridge_flags_reply_t * mp)
1719 vat_main_t *vam = &vat_main;
1720 vat_json_node_t node;
1722 vat_json_init_object (&node);
1723 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1724 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1725 ntohl (mp->resulting_feature_bitmap));
1727 vat_json_print (vam->ofp, &node);
1728 vat_json_free (&node);
1730 vam->retval = ntohl (mp->retval);
1731 vam->result_ready = 1;
1735 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1737 vat_main_t *vam = &vat_main;
1738 i32 retval = ntohl (mp->retval);
1739 if (vam->async_mode)
1741 vam->async_errors += (retval < 0);
1745 vam->retval = retval;
1746 vam->sw_if_index = ntohl (mp->sw_if_index);
1747 vam->result_ready = 1;
1752 static void vl_api_tap_create_v2_reply_t_handler_json
1753 (vl_api_tap_create_v2_reply_t * mp)
1755 vat_main_t *vam = &vat_main;
1756 vat_json_node_t node;
1758 vat_json_init_object (&node);
1759 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1760 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1762 vat_json_print (vam->ofp, &node);
1763 vat_json_free (&node);
1765 vam->retval = ntohl (mp->retval);
1766 vam->result_ready = 1;
1771 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1773 vat_main_t *vam = &vat_main;
1774 i32 retval = ntohl (mp->retval);
1775 if (vam->async_mode)
1777 vam->async_errors += (retval < 0);
1781 vam->retval = retval;
1782 vam->result_ready = 1;
1786 static void vl_api_tap_delete_v2_reply_t_handler_json
1787 (vl_api_tap_delete_v2_reply_t * mp)
1789 vat_main_t *vam = &vat_main;
1790 vat_json_node_t node;
1792 vat_json_init_object (&node);
1793 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1795 vat_json_print (vam->ofp, &node);
1796 vat_json_free (&node);
1798 vam->retval = ntohl (mp->retval);
1799 vam->result_ready = 1;
1803 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1806 vat_main_t *vam = &vat_main;
1807 i32 retval = ntohl (mp->retval);
1808 if (vam->async_mode)
1810 vam->async_errors += (retval < 0);
1814 vam->retval = retval;
1815 vam->sw_if_index = ntohl (mp->sw_if_index);
1816 vam->result_ready = 1;
1820 static void vl_api_virtio_pci_create_reply_t_handler_json
1821 (vl_api_virtio_pci_create_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));
1828 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1830 vat_json_print (vam->ofp, &node);
1831 vat_json_free (&node);
1833 vam->retval = ntohl (mp->retval);
1834 vam->result_ready = 1;
1839 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1842 vat_main_t *vam = &vat_main;
1843 i32 retval = ntohl (mp->retval);
1844 if (vam->async_mode)
1846 vam->async_errors += (retval < 0);
1850 vam->retval = retval;
1851 vam->result_ready = 1;
1855 static void vl_api_virtio_pci_delete_reply_t_handler_json
1856 (vl_api_virtio_pci_delete_reply_t * mp)
1858 vat_main_t *vam = &vat_main;
1859 vat_json_node_t node;
1861 vat_json_init_object (&node);
1862 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
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_create_reply_t_handler (vl_api_bond_create_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->sw_if_index = ntohl (mp->sw_if_index);
1885 vam->result_ready = 1;
1889 static void vl_api_bond_create_reply_t_handler_json
1890 (vl_api_bond_create_reply_t * mp)
1892 vat_main_t *vam = &vat_main;
1893 vat_json_node_t node;
1895 vat_json_init_object (&node);
1896 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1897 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1899 vat_json_print (vam->ofp, &node);
1900 vat_json_free (&node);
1902 vam->retval = ntohl (mp->retval);
1903 vam->result_ready = 1;
1907 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1909 vat_main_t *vam = &vat_main;
1910 i32 retval = ntohl (mp->retval);
1912 if (vam->async_mode)
1914 vam->async_errors += (retval < 0);
1918 vam->retval = retval;
1919 vam->result_ready = 1;
1923 static void vl_api_bond_delete_reply_t_handler_json
1924 (vl_api_bond_delete_reply_t * mp)
1926 vat_main_t *vam = &vat_main;
1927 vat_json_node_t node;
1929 vat_json_init_object (&node);
1930 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1932 vat_json_print (vam->ofp, &node);
1933 vat_json_free (&node);
1935 vam->retval = ntohl (mp->retval);
1936 vam->result_ready = 1;
1940 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1942 vat_main_t *vam = &vat_main;
1943 i32 retval = ntohl (mp->retval);
1945 if (vam->async_mode)
1947 vam->async_errors += (retval < 0);
1951 vam->retval = retval;
1952 vam->result_ready = 1;
1956 static void vl_api_bond_enslave_reply_t_handler_json
1957 (vl_api_bond_enslave_reply_t * mp)
1959 vat_main_t *vam = &vat_main;
1960 vat_json_node_t node;
1962 vat_json_init_object (&node);
1963 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1965 vat_json_print (vam->ofp, &node);
1966 vat_json_free (&node);
1968 vam->retval = ntohl (mp->retval);
1969 vam->result_ready = 1;
1973 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1976 vat_main_t *vam = &vat_main;
1977 i32 retval = ntohl (mp->retval);
1979 if (vam->async_mode)
1981 vam->async_errors += (retval < 0);
1985 vam->retval = retval;
1986 vam->result_ready = 1;
1990 static void vl_api_bond_detach_slave_reply_t_handler_json
1991 (vl_api_bond_detach_slave_reply_t * mp)
1993 vat_main_t *vam = &vat_main;
1994 vat_json_node_t node;
1996 vat_json_init_object (&node);
1997 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1999 vat_json_print (vam->ofp, &node);
2000 vat_json_free (&node);
2002 vam->retval = ntohl (mp->retval);
2003 vam->result_ready = 1;
2007 api_sw_interface_set_bond_weight (vat_main_t * vam)
2009 unformat_input_t *i = vam->input;
2010 vl_api_sw_interface_set_bond_weight_t *mp;
2011 u32 sw_if_index = ~0;
2013 u8 weight_enter = 0;
2016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2018 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2020 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2022 else if (unformat (i, "weight %u", &weight))
2028 if (sw_if_index == ~0)
2030 errmsg ("missing interface name or sw_if_index");
2033 if (weight_enter == 0)
2035 errmsg ("missing valid weight");
2039 /* Construct the API message */
2040 M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
2041 mp->sw_if_index = ntohl (sw_if_index);
2042 mp->weight = ntohl (weight);
2049 static void vl_api_sw_interface_bond_details_t_handler
2050 (vl_api_sw_interface_bond_details_t * mp)
2052 vat_main_t *vam = &vat_main;
2055 "%-16s %-12d %-12U %-13U %-14u %-14u",
2056 mp->interface_name, ntohl (mp->sw_if_index),
2057 format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
2058 ntohl (mp->lb), ntohl (mp->active_slaves), ntohl (mp->slaves));
2061 static void vl_api_sw_interface_bond_details_t_handler_json
2062 (vl_api_sw_interface_bond_details_t * mp)
2064 vat_main_t *vam = &vat_main;
2065 vat_json_node_t *node = NULL;
2067 if (VAT_JSON_ARRAY != vam->json_tree.type)
2069 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2070 vat_json_init_array (&vam->json_tree);
2072 node = vat_json_array_add (&vam->json_tree);
2074 vat_json_init_object (node);
2075 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2076 vat_json_object_add_string_copy (node, "interface_name",
2077 mp->interface_name);
2078 vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
2079 vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
2080 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2081 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2085 api_sw_interface_bond_dump (vat_main_t * vam)
2087 vl_api_sw_interface_bond_dump_t *mp;
2088 vl_api_control_ping_t *mp_ping;
2092 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2093 "interface name", "sw_if_index", "mode", "load balance",
2094 "active slaves", "slaves");
2096 /* Get list of bond interfaces */
2097 M (SW_INTERFACE_BOND_DUMP, mp);
2100 /* Use a control ping for synchronization */
2101 MPING (CONTROL_PING, mp_ping);
2108 static void vl_api_sw_interface_slave_details_t_handler
2109 (vl_api_sw_interface_slave_details_t * mp)
2111 vat_main_t *vam = &vat_main;
2114 "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
2115 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
2116 ntohl (mp->weight), mp->is_local_numa);
2119 static void vl_api_sw_interface_slave_details_t_handler_json
2120 (vl_api_sw_interface_slave_details_t * mp)
2122 vat_main_t *vam = &vat_main;
2123 vat_json_node_t *node = NULL;
2125 if (VAT_JSON_ARRAY != vam->json_tree.type)
2127 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2128 vat_json_init_array (&vam->json_tree);
2130 node = vat_json_array_add (&vam->json_tree);
2132 vat_json_init_object (node);
2133 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2134 vat_json_object_add_string_copy (node, "interface_name",
2135 mp->interface_name);
2136 vat_json_object_add_uint (node, "passive", mp->is_passive);
2137 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2138 vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
2139 vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
2143 api_sw_interface_slave_dump (vat_main_t * vam)
2145 unformat_input_t *i = vam->input;
2146 vl_api_sw_interface_slave_dump_t *mp;
2147 vl_api_control_ping_t *mp_ping;
2148 u32 sw_if_index = ~0;
2149 u8 sw_if_index_set = 0;
2152 /* Parse args required to build the message */
2153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2155 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2156 sw_if_index_set = 1;
2157 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2158 sw_if_index_set = 1;
2163 if (sw_if_index_set == 0)
2165 errmsg ("missing vpp interface name. ");
2170 "\n%-25s %-12s %-7s %-12s %-10s %-10s",
2171 "slave interface name", "sw_if_index", "passive", "long_timeout",
2172 "weight", "local numa");
2174 /* Get list of bond interfaces */
2175 M (SW_INTERFACE_SLAVE_DUMP, mp);
2176 mp->sw_if_index = ntohl (sw_if_index);
2179 /* Use a control ping for synchronization */
2180 MPING (CONTROL_PING, mp_ping);
2187 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2188 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2190 vat_main_t *vam = &vat_main;
2191 i32 retval = ntohl (mp->retval);
2192 if (vam->async_mode)
2194 vam->async_errors += (retval < 0);
2198 vam->retval = retval;
2199 vam->sw_if_index = ntohl (mp->sw_if_index);
2200 vam->result_ready = 1;
2202 vam->regenerate_interface_table = 1;
2205 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2206 (vl_api_mpls_tunnel_add_del_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, "tunnel_sw_if_index",
2214 ntohl (mp->sw_if_index));
2216 vat_json_print (vam->ofp, &node);
2217 vat_json_free (&node);
2219 vam->retval = ntohl (mp->retval);
2220 vam->result_ready = 1;
2223 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2224 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2226 vat_main_t *vam = &vat_main;
2227 i32 retval = ntohl (mp->retval);
2228 if (vam->async_mode)
2230 vam->async_errors += (retval < 0);
2234 vam->retval = retval;
2235 vam->sw_if_index = ntohl (mp->sw_if_index);
2236 vam->result_ready = 1;
2240 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2241 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2243 vat_main_t *vam = &vat_main;
2244 vat_json_node_t node;
2246 vat_json_init_object (&node);
2247 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2248 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2250 vat_json_print (vam->ofp, &node);
2251 vat_json_free (&node);
2253 vam->retval = ntohl (mp->retval);
2254 vam->result_ready = 1;
2257 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2258 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2260 vat_main_t *vam = &vat_main;
2261 i32 retval = ntohl (mp->retval);
2262 if (vam->async_mode)
2264 vam->async_errors += (retval < 0);
2268 vam->retval = retval;
2269 vam->result_ready = 1;
2273 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2274 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2276 vat_main_t *vam = &vat_main;
2277 vat_json_node_t node;
2279 vat_json_init_object (&node);
2280 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2281 vat_json_object_add_uint (&node, "fwd_entry_index",
2282 clib_net_to_host_u32 (mp->fwd_entry_index));
2284 vat_json_print (vam->ofp, &node);
2285 vat_json_free (&node);
2287 vam->retval = ntohl (mp->retval);
2288 vam->result_ready = 1;
2292 format_lisp_transport_protocol (u8 * s, va_list * args)
2294 u32 proto = va_arg (*args, u32);
2299 return format (s, "udp");
2301 return format (s, "api");
2308 static void vl_api_one_get_transport_protocol_reply_t_handler
2309 (vl_api_one_get_transport_protocol_reply_t * mp)
2311 vat_main_t *vam = &vat_main;
2312 i32 retval = ntohl (mp->retval);
2313 if (vam->async_mode)
2315 vam->async_errors += (retval < 0);
2319 u32 proto = mp->protocol;
2320 print (vam->ofp, "Transport protocol: %U",
2321 format_lisp_transport_protocol, proto);
2322 vam->retval = retval;
2323 vam->result_ready = 1;
2327 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2328 (vl_api_one_get_transport_protocol_reply_t * mp)
2330 vat_main_t *vam = &vat_main;
2331 vat_json_node_t node;
2334 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2337 vat_json_init_object (&node);
2338 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2339 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2342 vat_json_print (vam->ofp, &node);
2343 vat_json_free (&node);
2345 vam->retval = ntohl (mp->retval);
2346 vam->result_ready = 1;
2349 static void vl_api_one_add_del_locator_set_reply_t_handler
2350 (vl_api_one_add_del_locator_set_reply_t * mp)
2352 vat_main_t *vam = &vat_main;
2353 i32 retval = ntohl (mp->retval);
2354 if (vam->async_mode)
2356 vam->async_errors += (retval < 0);
2360 vam->retval = retval;
2361 vam->result_ready = 1;
2365 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2366 (vl_api_one_add_del_locator_set_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, "locator_set_index", ntohl (mp->ls_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_add_del_tunnel_reply_t_handler
2383 (vl_api_vxlan_add_del_tunnel_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->sw_if_index = ntohl (mp->sw_if_index);
2395 vam->result_ready = 1;
2397 vam->regenerate_interface_table = 1;
2400 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2401 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2403 vat_main_t *vam = &vat_main;
2404 vat_json_node_t node;
2406 vat_json_init_object (&node);
2407 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2408 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2410 vat_json_print (vam->ofp, &node);
2411 vat_json_free (&node);
2413 vam->retval = ntohl (mp->retval);
2414 vam->result_ready = 1;
2417 static void vl_api_vxlan_offload_rx_reply_t_handler
2418 (vl_api_vxlan_offload_rx_reply_t * mp)
2420 vat_main_t *vam = &vat_main;
2421 i32 retval = ntohl (mp->retval);
2422 if (vam->async_mode)
2424 vam->async_errors += (retval < 0);
2428 vam->retval = retval;
2429 vam->result_ready = 1;
2433 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2434 (vl_api_vxlan_offload_rx_reply_t * mp)
2436 vat_main_t *vam = &vat_main;
2437 vat_json_node_t node;
2439 vat_json_init_object (&node);
2440 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2442 vat_json_print (vam->ofp, &node);
2443 vat_json_free (&node);
2445 vam->retval = ntohl (mp->retval);
2446 vam->result_ready = 1;
2449 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2450 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2452 vat_main_t *vam = &vat_main;
2453 i32 retval = ntohl (mp->retval);
2454 if (vam->async_mode)
2456 vam->async_errors += (retval < 0);
2460 vam->retval = retval;
2461 vam->sw_if_index = ntohl (mp->sw_if_index);
2462 vam->result_ready = 1;
2466 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2467 (vl_api_geneve_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_vxlan_gpe_add_del_tunnel_reply_t_handler
2484 (vl_api_vxlan_gpe_add_del_tunnel_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;
2498 vam->regenerate_interface_table = 1;
2501 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2502 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2504 vat_main_t *vam = &vat_main;
2505 vat_json_node_t node;
2507 vat_json_init_object (&node);
2508 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2509 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2511 vat_json_print (vam->ofp, &node);
2512 vat_json_free (&node);
2514 vam->retval = ntohl (mp->retval);
2515 vam->result_ready = 1;
2518 static void vl_api_gre_tunnel_add_del_reply_t_handler
2519 (vl_api_gre_tunnel_add_del_reply_t * mp)
2521 vat_main_t *vam = &vat_main;
2522 i32 retval = ntohl (mp->retval);
2523 if (vam->async_mode)
2525 vam->async_errors += (retval < 0);
2529 vam->retval = retval;
2530 vam->sw_if_index = ntohl (mp->sw_if_index);
2531 vam->result_ready = 1;
2535 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2536 (vl_api_gre_tunnel_add_del_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_create_vhost_user_if_reply_t_handler
2553 (vl_api_create_vhost_user_if_reply_t * mp)
2555 vat_main_t *vam = &vat_main;
2556 i32 retval = ntohl (mp->retval);
2557 if (vam->async_mode)
2559 vam->async_errors += (retval < 0);
2563 vam->retval = retval;
2564 vam->sw_if_index = ntohl (mp->sw_if_index);
2565 vam->result_ready = 1;
2567 vam->regenerate_interface_table = 1;
2570 static void vl_api_create_vhost_user_if_reply_t_handler_json
2571 (vl_api_create_vhost_user_if_reply_t * mp)
2573 vat_main_t *vam = &vat_main;
2574 vat_json_node_t node;
2576 vat_json_init_object (&node);
2577 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2578 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2580 vat_json_print (vam->ofp, &node);
2581 vat_json_free (&node);
2583 vam->retval = ntohl (mp->retval);
2584 vam->result_ready = 1;
2587 static void vl_api_ip_address_details_t_handler
2588 (vl_api_ip_address_details_t * mp)
2590 vat_main_t *vam = &vat_main;
2591 static ip_address_details_t empty_ip_address_details = { {0} };
2592 ip_address_details_t *address = NULL;
2593 ip_details_t *current_ip_details = NULL;
2594 ip_details_t *details = NULL;
2596 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2598 if (!details || vam->current_sw_if_index >= vec_len (details)
2599 || !details[vam->current_sw_if_index].present)
2601 errmsg ("ip address details arrived but not stored");
2602 errmsg ("ip_dump should be called first");
2606 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2608 #define addresses (current_ip_details->addr)
2610 vec_validate_init_empty (addresses, vec_len (addresses),
2611 empty_ip_address_details);
2613 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2615 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2616 address->prefix_length = mp->prefix.len;
2620 static void vl_api_ip_address_details_t_handler_json
2621 (vl_api_ip_address_details_t * mp)
2623 vat_main_t *vam = &vat_main;
2624 vat_json_node_t *node = NULL;
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 node = vat_json_array_add (&vam->json_tree);
2633 vat_json_init_object (node);
2634 vat_json_object_add_prefix (node, &mp->prefix);
2638 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2640 vat_main_t *vam = &vat_main;
2641 static ip_details_t empty_ip_details = { 0 };
2642 ip_details_t *ip = NULL;
2643 u32 sw_if_index = ~0;
2645 sw_if_index = ntohl (mp->sw_if_index);
2647 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2648 sw_if_index, empty_ip_details);
2650 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2657 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2659 vat_main_t *vam = &vat_main;
2661 if (VAT_JSON_ARRAY != vam->json_tree.type)
2663 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2664 vat_json_init_array (&vam->json_tree);
2666 vat_json_array_add_uint (&vam->json_tree,
2667 clib_net_to_host_u32 (mp->sw_if_index));
2670 static void vl_api_get_first_msg_id_reply_t_handler
2671 (vl_api_get_first_msg_id_reply_t * mp)
2673 vat_main_t *vam = &vat_main;
2674 i32 retval = ntohl (mp->retval);
2676 if (vam->async_mode)
2678 vam->async_errors += (retval < 0);
2682 vam->retval = retval;
2683 vam->result_ready = 1;
2687 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2691 static void vl_api_get_first_msg_id_reply_t_handler_json
2692 (vl_api_get_first_msg_id_reply_t * mp)
2694 vat_main_t *vam = &vat_main;
2695 vat_json_node_t node;
2697 vat_json_init_object (&node);
2698 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2699 vat_json_object_add_uint (&node, "first_msg_id",
2700 (uint) ntohs (mp->first_msg_id));
2702 vat_json_print (vam->ofp, &node);
2703 vat_json_free (&node);
2705 vam->retval = ntohl (mp->retval);
2706 vam->result_ready = 1;
2709 static void vl_api_get_node_graph_reply_t_handler
2710 (vl_api_get_node_graph_reply_t * mp)
2712 vat_main_t *vam = &vat_main;
2713 api_main_t *am = vlibapi_get_main ();
2714 i32 retval = ntohl (mp->retval);
2715 u8 *pvt_copy, *reply;
2720 if (vam->async_mode)
2722 vam->async_errors += (retval < 0);
2726 vam->retval = retval;
2727 vam->result_ready = 1;
2730 /* "Should never happen..." */
2734 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2735 pvt_copy = vec_dup (reply);
2737 /* Toss the shared-memory original... */
2738 pthread_mutex_lock (&am->vlib_rp->mutex);
2739 oldheap = svm_push_data_heap (am->vlib_rp);
2743 svm_pop_heap (oldheap);
2744 pthread_mutex_unlock (&am->vlib_rp->mutex);
2746 if (vam->graph_nodes)
2748 hash_free (vam->graph_node_index_by_name);
2750 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2752 node = vam->graph_nodes[0][i];
2753 vec_free (node->name);
2754 vec_free (node->next_nodes);
2757 vec_free (vam->graph_nodes[0]);
2758 vec_free (vam->graph_nodes);
2761 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2762 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2763 vec_free (pvt_copy);
2765 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2767 node = vam->graph_nodes[0][i];
2768 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2772 static void vl_api_get_node_graph_reply_t_handler_json
2773 (vl_api_get_node_graph_reply_t * mp)
2775 vat_main_t *vam = &vat_main;
2776 api_main_t *am = vlibapi_get_main ();
2778 vat_json_node_t node;
2781 /* $$$$ make this real? */
2782 vat_json_init_object (&node);
2783 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2784 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2786 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2788 /* Toss the shared-memory original... */
2789 pthread_mutex_lock (&am->vlib_rp->mutex);
2790 oldheap = svm_push_data_heap (am->vlib_rp);
2794 svm_pop_heap (oldheap);
2795 pthread_mutex_unlock (&am->vlib_rp->mutex);
2797 vat_json_print (vam->ofp, &node);
2798 vat_json_free (&node);
2800 vam->retval = ntohl (mp->retval);
2801 vam->result_ready = 1;
2805 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2807 vat_main_t *vam = &vat_main;
2812 s = format (s, "%=16d%=16d%=16d",
2813 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2817 s = format (s, "%=16U%=16d%=16d",
2818 mp->is_ipv6 ? format_ip6_address :
2820 mp->ip_address, mp->priority, mp->weight);
2823 print (vam->ofp, "%v", s);
2828 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2830 vat_main_t *vam = &vat_main;
2831 vat_json_node_t *node = NULL;
2832 struct in6_addr ip6;
2835 if (VAT_JSON_ARRAY != vam->json_tree.type)
2837 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2838 vat_json_init_array (&vam->json_tree);
2840 node = vat_json_array_add (&vam->json_tree);
2841 vat_json_init_object (node);
2843 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2844 vat_json_object_add_uint (node, "priority", mp->priority);
2845 vat_json_object_add_uint (node, "weight", mp->weight);
2848 vat_json_object_add_uint (node, "sw_if_index",
2849 clib_net_to_host_u32 (mp->sw_if_index));
2854 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2855 vat_json_object_add_ip6 (node, "address", ip6);
2859 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2860 vat_json_object_add_ip4 (node, "address", ip4);
2866 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2869 vat_main_t *vam = &vat_main;
2872 ls_name = format (0, "%s", mp->ls_name);
2874 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2880 vl_api_one_locator_set_details_t_handler_json
2881 (vl_api_one_locator_set_details_t * mp)
2883 vat_main_t *vam = &vat_main;
2884 vat_json_node_t *node = 0;
2887 ls_name = format (0, "%s", mp->ls_name);
2888 vec_add1 (ls_name, 0);
2890 if (VAT_JSON_ARRAY != vam->json_tree.type)
2892 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2893 vat_json_init_array (&vam->json_tree);
2895 node = vat_json_array_add (&vam->json_tree);
2897 vat_json_init_object (node);
2898 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2899 vat_json_object_add_uint (node, "ls_index",
2900 clib_net_to_host_u32 (mp->ls_index));
2908 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2911 unformat_nsh_address (unformat_input_t * input, va_list * args)
2913 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2914 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2918 format_nsh_address_vat (u8 * s, va_list * args)
2920 nsh_t *a = va_arg (*args, nsh_t *);
2921 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2925 format_lisp_flat_eid (u8 * s, va_list * args)
2927 u32 type = va_arg (*args, u32);
2928 u8 *eid = va_arg (*args, u8 *);
2929 u32 eid_len = va_arg (*args, u32);
2934 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2936 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2938 return format (s, "%U", format_ethernet_address, eid);
2940 return format (s, "%U", format_nsh_address_vat, eid);
2946 format_lisp_eid_vat (u8 * s, va_list * args)
2948 u32 type = va_arg (*args, u32);
2949 u8 *eid = va_arg (*args, u8 *);
2950 u32 eid_len = va_arg (*args, u32);
2951 u8 *seid = va_arg (*args, u8 *);
2952 u32 seid_len = va_arg (*args, u32);
2953 u32 is_src_dst = va_arg (*args, u32);
2956 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2958 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2964 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2966 vat_main_t *vam = &vat_main;
2967 u8 *s = 0, *eid = 0;
2969 if (~0 == mp->locator_set_index)
2970 s = format (0, "action: %d", mp->action);
2972 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2974 eid = format (0, "%U", format_lisp_eid_vat,
2978 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2981 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2982 clib_net_to_host_u32 (mp->vni),
2984 mp->is_local ? "local" : "remote",
2985 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2986 clib_net_to_host_u16 (mp->key_id), mp->key);
2993 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2996 vat_main_t *vam = &vat_main;
2997 vat_json_node_t *node = 0;
3000 if (VAT_JSON_ARRAY != vam->json_tree.type)
3002 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3003 vat_json_init_array (&vam->json_tree);
3005 node = vat_json_array_add (&vam->json_tree);
3007 vat_json_init_object (node);
3008 if (~0 == mp->locator_set_index)
3009 vat_json_object_add_uint (node, "action", mp->action);
3011 vat_json_object_add_uint (node, "locator_set_index",
3012 clib_net_to_host_u32 (mp->locator_set_index));
3014 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3015 if (mp->eid_type == 3)
3017 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3018 vat_json_init_object (nsh_json);
3019 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3020 vat_json_object_add_uint (nsh_json, "spi",
3021 clib_net_to_host_u32 (nsh->spi));
3022 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3026 eid = format (0, "%U", format_lisp_eid_vat,
3030 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3032 vat_json_object_add_string_copy (node, "eid", eid);
3035 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3036 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3037 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3041 vat_json_object_add_uint (node, "key_id",
3042 clib_net_to_host_u16 (mp->key_id));
3043 vat_json_object_add_string_copy (node, "key", mp->key);
3048 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3050 vat_main_t *vam = &vat_main;
3051 u8 *seid = 0, *deid = 0;
3052 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3054 deid = format (0, "%U", format_lisp_eid_vat,
3055 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3057 seid = format (0, "%U", format_lisp_eid_vat,
3058 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3064 format_ip_address_fcn = format_ip4_address;
3066 format_ip_address_fcn = format_ip6_address;
3069 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3070 clib_net_to_host_u32 (mp->vni),
3072 format_ip_address_fcn, mp->lloc,
3073 format_ip_address_fcn, mp->rloc,
3074 clib_net_to_host_u32 (mp->pkt_count),
3075 clib_net_to_host_u32 (mp->bytes));
3082 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3084 struct in6_addr ip6;
3086 vat_main_t *vam = &vat_main;
3087 vat_json_node_t *node = 0;
3088 u8 *deid = 0, *seid = 0;
3090 if (VAT_JSON_ARRAY != vam->json_tree.type)
3092 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3093 vat_json_init_array (&vam->json_tree);
3095 node = vat_json_array_add (&vam->json_tree);
3097 vat_json_init_object (node);
3098 deid = format (0, "%U", format_lisp_eid_vat,
3099 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3101 seid = format (0, "%U", format_lisp_eid_vat,
3102 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3107 vat_json_object_add_string_copy (node, "seid", seid);
3108 vat_json_object_add_string_copy (node, "deid", deid);
3109 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3113 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3114 vat_json_object_add_ip4 (node, "lloc", ip4);
3115 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3116 vat_json_object_add_ip4 (node, "rloc", ip4);
3120 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3121 vat_json_object_add_ip6 (node, "lloc", ip6);
3122 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3123 vat_json_object_add_ip6 (node, "rloc", ip6);
3125 vat_json_object_add_uint (node, "pkt_count",
3126 clib_net_to_host_u32 (mp->pkt_count));
3127 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3134 vl_api_one_eid_table_map_details_t_handler
3135 (vl_api_one_eid_table_map_details_t * mp)
3137 vat_main_t *vam = &vat_main;
3139 u8 *line = format (0, "%=10d%=10d",
3140 clib_net_to_host_u32 (mp->vni),
3141 clib_net_to_host_u32 (mp->dp_table));
3142 print (vam->ofp, "%v", line);
3147 vl_api_one_eid_table_map_details_t_handler_json
3148 (vl_api_one_eid_table_map_details_t * mp)
3150 vat_main_t *vam = &vat_main;
3151 vat_json_node_t *node = NULL;
3153 if (VAT_JSON_ARRAY != vam->json_tree.type)
3155 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3156 vat_json_init_array (&vam->json_tree);
3158 node = vat_json_array_add (&vam->json_tree);
3159 vat_json_init_object (node);
3160 vat_json_object_add_uint (node, "dp_table",
3161 clib_net_to_host_u32 (mp->dp_table));
3162 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3166 vl_api_one_eid_table_vni_details_t_handler
3167 (vl_api_one_eid_table_vni_details_t * mp)
3169 vat_main_t *vam = &vat_main;
3171 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3172 print (vam->ofp, "%v", line);
3177 vl_api_one_eid_table_vni_details_t_handler_json
3178 (vl_api_one_eid_table_vni_details_t * mp)
3180 vat_main_t *vam = &vat_main;
3181 vat_json_node_t *node = NULL;
3183 if (VAT_JSON_ARRAY != vam->json_tree.type)
3185 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3186 vat_json_init_array (&vam->json_tree);
3188 node = vat_json_array_add (&vam->json_tree);
3189 vat_json_init_object (node);
3190 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3194 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3195 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3197 vat_main_t *vam = &vat_main;
3198 int retval = clib_net_to_host_u32 (mp->retval);
3200 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3201 print (vam->ofp, "fallback threshold value: %d", mp->value);
3203 vam->retval = retval;
3204 vam->result_ready = 1;
3208 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3209 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3211 vat_main_t *vam = &vat_main;
3212 vat_json_node_t _node, *node = &_node;
3213 int retval = clib_net_to_host_u32 (mp->retval);
3215 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3216 vat_json_init_object (node);
3217 vat_json_object_add_uint (node, "value", mp->value);
3219 vat_json_print (vam->ofp, node);
3220 vat_json_free (node);
3222 vam->retval = retval;
3223 vam->result_ready = 1;
3227 vl_api_show_one_map_register_state_reply_t_handler
3228 (vl_api_show_one_map_register_state_reply_t * mp)
3230 vat_main_t *vam = &vat_main;
3231 int retval = clib_net_to_host_u32 (mp->retval);
3233 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3235 vam->retval = retval;
3236 vam->result_ready = 1;
3240 vl_api_show_one_map_register_state_reply_t_handler_json
3241 (vl_api_show_one_map_register_state_reply_t * mp)
3243 vat_main_t *vam = &vat_main;
3244 vat_json_node_t _node, *node = &_node;
3245 int retval = clib_net_to_host_u32 (mp->retval);
3247 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3249 vat_json_init_object (node);
3250 vat_json_object_add_string_copy (node, "state", s);
3252 vat_json_print (vam->ofp, node);
3253 vat_json_free (node);
3255 vam->retval = retval;
3256 vam->result_ready = 1;
3261 vl_api_show_one_rloc_probe_state_reply_t_handler
3262 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3264 vat_main_t *vam = &vat_main;
3265 int retval = clib_net_to_host_u32 (mp->retval);
3270 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3272 vam->retval = retval;
3273 vam->result_ready = 1;
3277 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3278 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3280 vat_main_t *vam = &vat_main;
3281 vat_json_node_t _node, *node = &_node;
3282 int retval = clib_net_to_host_u32 (mp->retval);
3284 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3285 vat_json_init_object (node);
3286 vat_json_object_add_string_copy (node, "state", s);
3288 vat_json_print (vam->ofp, node);
3289 vat_json_free (node);
3291 vam->retval = retval;
3292 vam->result_ready = 1;
3297 vl_api_show_one_stats_enable_disable_reply_t_handler
3298 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3300 vat_main_t *vam = &vat_main;
3301 int retval = clib_net_to_host_u32 (mp->retval);
3306 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3308 vam->retval = retval;
3309 vam->result_ready = 1;
3313 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3314 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3316 vat_main_t *vam = &vat_main;
3317 vat_json_node_t _node, *node = &_node;
3318 int retval = clib_net_to_host_u32 (mp->retval);
3320 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3321 vat_json_init_object (node);
3322 vat_json_object_add_string_copy (node, "state", s);
3324 vat_json_print (vam->ofp, node);
3325 vat_json_free (node);
3327 vam->retval = retval;
3328 vam->result_ready = 1;
3333 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3335 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3336 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3337 e->vni = clib_net_to_host_u32 (e->vni);
3341 gpe_fwd_entries_get_reply_t_net_to_host
3342 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3346 mp->count = clib_net_to_host_u32 (mp->count);
3347 for (i = 0; i < mp->count; i++)
3349 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3354 format_gpe_encap_mode (u8 * s, va_list * args)
3356 u32 mode = va_arg (*args, u32);
3361 return format (s, "lisp");
3363 return format (s, "vxlan");
3369 vl_api_gpe_get_encap_mode_reply_t_handler
3370 (vl_api_gpe_get_encap_mode_reply_t * mp)
3372 vat_main_t *vam = &vat_main;
3374 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3375 vam->retval = ntohl (mp->retval);
3376 vam->result_ready = 1;
3380 vl_api_gpe_get_encap_mode_reply_t_handler_json
3381 (vl_api_gpe_get_encap_mode_reply_t * mp)
3383 vat_main_t *vam = &vat_main;
3384 vat_json_node_t node;
3386 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3387 vec_add1 (encap_mode, 0);
3389 vat_json_init_object (&node);
3390 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3392 vec_free (encap_mode);
3393 vat_json_print (vam->ofp, &node);
3394 vat_json_free (&node);
3396 vam->retval = ntohl (mp->retval);
3397 vam->result_ready = 1;
3401 vl_api_gpe_fwd_entry_path_details_t_handler
3402 (vl_api_gpe_fwd_entry_path_details_t * mp)
3404 vat_main_t *vam = &vat_main;
3405 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3407 if (mp->lcl_loc.is_ip4)
3408 format_ip_address_fcn = format_ip4_address;
3410 format_ip_address_fcn = format_ip6_address;
3412 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3413 format_ip_address_fcn, &mp->lcl_loc,
3414 format_ip_address_fcn, &mp->rmt_loc);
3418 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3420 struct in6_addr ip6;
3425 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3426 vat_json_object_add_ip4 (n, "address", ip4);
3430 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3431 vat_json_object_add_ip6 (n, "address", ip6);
3433 vat_json_object_add_uint (n, "weight", loc->weight);
3437 vl_api_gpe_fwd_entry_path_details_t_handler_json
3438 (vl_api_gpe_fwd_entry_path_details_t * mp)
3440 vat_main_t *vam = &vat_main;
3441 vat_json_node_t *node = NULL;
3442 vat_json_node_t *loc_node;
3444 if (VAT_JSON_ARRAY != vam->json_tree.type)
3446 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3447 vat_json_init_array (&vam->json_tree);
3449 node = vat_json_array_add (&vam->json_tree);
3450 vat_json_init_object (node);
3452 loc_node = vat_json_object_add (node, "local_locator");
3453 vat_json_init_object (loc_node);
3454 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3456 loc_node = vat_json_object_add (node, "remote_locator");
3457 vat_json_init_object (loc_node);
3458 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3462 vl_api_gpe_fwd_entries_get_reply_t_handler
3463 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3465 vat_main_t *vam = &vat_main;
3467 int retval = clib_net_to_host_u32 (mp->retval);
3468 vl_api_gpe_fwd_entry_t *e;
3473 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3475 for (i = 0; i < mp->count; i++)
3477 e = &mp->entries[i];
3478 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3479 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3480 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3484 vam->retval = retval;
3485 vam->result_ready = 1;
3489 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3490 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3493 vat_main_t *vam = &vat_main;
3494 vat_json_node_t *e = 0, root;
3496 int retval = clib_net_to_host_u32 (mp->retval);
3497 vl_api_gpe_fwd_entry_t *fwd;
3502 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3503 vat_json_init_array (&root);
3505 for (i = 0; i < mp->count; i++)
3507 e = vat_json_array_add (&root);
3508 fwd = &mp->entries[i];
3510 vat_json_init_object (e);
3511 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3512 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3513 vat_json_object_add_int (e, "vni", fwd->vni);
3514 vat_json_object_add_int (e, "action", fwd->action);
3516 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3517 fwd->leid_prefix_len);
3519 vat_json_object_add_string_copy (e, "leid", s);
3522 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3523 fwd->reid_prefix_len);
3525 vat_json_object_add_string_copy (e, "reid", s);
3529 vat_json_print (vam->ofp, &root);
3530 vat_json_free (&root);
3533 vam->retval = retval;
3534 vam->result_ready = 1;
3538 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3539 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3541 vat_main_t *vam = &vat_main;
3543 int retval = clib_net_to_host_u32 (mp->retval);
3544 vl_api_gpe_native_fwd_rpath_t *r;
3549 n = clib_net_to_host_u32 (mp->count);
3551 for (i = 0; i < n; i++)
3553 r = &mp->entries[i];
3554 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3555 clib_net_to_host_u32 (r->fib_index),
3556 clib_net_to_host_u32 (r->nh_sw_if_index),
3557 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3561 vam->retval = retval;
3562 vam->result_ready = 1;
3566 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3567 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3569 vat_main_t *vam = &vat_main;
3570 vat_json_node_t root, *e;
3572 int retval = clib_net_to_host_u32 (mp->retval);
3573 vl_api_gpe_native_fwd_rpath_t *r;
3579 n = clib_net_to_host_u32 (mp->count);
3580 vat_json_init_array (&root);
3582 for (i = 0; i < n; i++)
3584 e = vat_json_array_add (&root);
3585 vat_json_init_object (e);
3586 r = &mp->entries[i];
3588 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3591 vat_json_object_add_string_copy (e, "ip4", s);
3594 vat_json_object_add_uint (e, "fib_index",
3595 clib_net_to_host_u32 (r->fib_index));
3596 vat_json_object_add_uint (e, "nh_sw_if_index",
3597 clib_net_to_host_u32 (r->nh_sw_if_index));
3600 vat_json_print (vam->ofp, &root);
3601 vat_json_free (&root);
3604 vam->retval = retval;
3605 vam->result_ready = 1;
3609 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3610 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3612 vat_main_t *vam = &vat_main;
3614 int retval = clib_net_to_host_u32 (mp->retval);
3619 n = clib_net_to_host_u32 (mp->count);
3621 for (i = 0; i < n; i++)
3622 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3625 vam->retval = retval;
3626 vam->result_ready = 1;
3630 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3631 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3633 vat_main_t *vam = &vat_main;
3634 vat_json_node_t root;
3636 int retval = clib_net_to_host_u32 (mp->retval);
3641 n = clib_net_to_host_u32 (mp->count);
3642 vat_json_init_array (&root);
3644 for (i = 0; i < n; i++)
3645 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3647 vat_json_print (vam->ofp, &root);
3648 vat_json_free (&root);
3651 vam->retval = retval;
3652 vam->result_ready = 1;
3656 vl_api_one_ndp_entries_get_reply_t_handler
3657 (vl_api_one_ndp_entries_get_reply_t * mp)
3659 vat_main_t *vam = &vat_main;
3661 int retval = clib_net_to_host_u32 (mp->retval);
3666 n = clib_net_to_host_u32 (mp->count);
3668 for (i = 0; i < n; i++)
3669 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3670 format_ethernet_address, mp->entries[i].mac);
3673 vam->retval = retval;
3674 vam->result_ready = 1;
3678 vl_api_one_ndp_entries_get_reply_t_handler_json
3679 (vl_api_one_ndp_entries_get_reply_t * mp)
3682 vat_main_t *vam = &vat_main;
3683 vat_json_node_t *e = 0, root;
3685 int retval = clib_net_to_host_u32 (mp->retval);
3686 vl_api_one_ndp_entry_t *arp_entry;
3691 n = clib_net_to_host_u32 (mp->count);
3692 vat_json_init_array (&root);
3694 for (i = 0; i < n; i++)
3696 e = vat_json_array_add (&root);
3697 arp_entry = &mp->entries[i];
3699 vat_json_init_object (e);
3700 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3703 vat_json_object_add_string_copy (e, "mac", s);
3706 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3708 vat_json_object_add_string_copy (e, "ip6", s);
3712 vat_json_print (vam->ofp, &root);
3713 vat_json_free (&root);
3716 vam->retval = retval;
3717 vam->result_ready = 1;
3721 vl_api_one_l2_arp_entries_get_reply_t_handler
3722 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3724 vat_main_t *vam = &vat_main;
3726 int retval = clib_net_to_host_u32 (mp->retval);
3731 n = clib_net_to_host_u32 (mp->count);
3733 for (i = 0; i < n; i++)
3734 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3735 format_ethernet_address, mp->entries[i].mac);
3738 vam->retval = retval;
3739 vam->result_ready = 1;
3743 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3744 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3747 vat_main_t *vam = &vat_main;
3748 vat_json_node_t *e = 0, root;
3750 int retval = clib_net_to_host_u32 (mp->retval);
3751 vl_api_one_l2_arp_entry_t *arp_entry;
3756 n = clib_net_to_host_u32 (mp->count);
3757 vat_json_init_array (&root);
3759 for (i = 0; i < n; i++)
3761 e = vat_json_array_add (&root);
3762 arp_entry = &mp->entries[i];
3764 vat_json_init_object (e);
3765 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3768 vat_json_object_add_string_copy (e, "mac", s);
3771 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3773 vat_json_object_add_string_copy (e, "ip4", s);
3777 vat_json_print (vam->ofp, &root);
3778 vat_json_free (&root);
3781 vam->retval = retval;
3782 vam->result_ready = 1;
3786 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3788 vat_main_t *vam = &vat_main;
3790 int retval = clib_net_to_host_u32 (mp->retval);
3795 n = clib_net_to_host_u32 (mp->count);
3797 for (i = 0; i < n; i++)
3799 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3803 vam->retval = retval;
3804 vam->result_ready = 1;
3808 vl_api_one_ndp_bd_get_reply_t_handler_json
3809 (vl_api_one_ndp_bd_get_reply_t * mp)
3811 vat_main_t *vam = &vat_main;
3812 vat_json_node_t root;
3814 int retval = clib_net_to_host_u32 (mp->retval);
3819 n = clib_net_to_host_u32 (mp->count);
3820 vat_json_init_array (&root);
3822 for (i = 0; i < n; i++)
3824 vat_json_array_add_uint (&root,
3825 clib_net_to_host_u32 (mp->bridge_domains[i]));
3828 vat_json_print (vam->ofp, &root);
3829 vat_json_free (&root);
3832 vam->retval = retval;
3833 vam->result_ready = 1;
3837 vl_api_one_l2_arp_bd_get_reply_t_handler
3838 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3840 vat_main_t *vam = &vat_main;
3842 int retval = clib_net_to_host_u32 (mp->retval);
3847 n = clib_net_to_host_u32 (mp->count);
3849 for (i = 0; i < n; i++)
3851 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3855 vam->retval = retval;
3856 vam->result_ready = 1;
3860 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3861 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3863 vat_main_t *vam = &vat_main;
3864 vat_json_node_t root;
3866 int retval = clib_net_to_host_u32 (mp->retval);
3871 n = clib_net_to_host_u32 (mp->count);
3872 vat_json_init_array (&root);
3874 for (i = 0; i < n; i++)
3876 vat_json_array_add_uint (&root,
3877 clib_net_to_host_u32 (mp->bridge_domains[i]));
3880 vat_json_print (vam->ofp, &root);
3881 vat_json_free (&root);
3884 vam->retval = retval;
3885 vam->result_ready = 1;
3889 vl_api_one_adjacencies_get_reply_t_handler
3890 (vl_api_one_adjacencies_get_reply_t * mp)
3892 vat_main_t *vam = &vat_main;
3894 int retval = clib_net_to_host_u32 (mp->retval);
3895 vl_api_one_adjacency_t *a;
3900 n = clib_net_to_host_u32 (mp->count);
3902 for (i = 0; i < n; i++)
3904 a = &mp->adjacencies[i];
3905 print (vam->ofp, "%U %40U",
3906 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3907 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3911 vam->retval = retval;
3912 vam->result_ready = 1;
3916 vl_api_one_adjacencies_get_reply_t_handler_json
3917 (vl_api_one_adjacencies_get_reply_t * mp)
3920 vat_main_t *vam = &vat_main;
3921 vat_json_node_t *e = 0, root;
3923 int retval = clib_net_to_host_u32 (mp->retval);
3924 vl_api_one_adjacency_t *a;
3929 n = clib_net_to_host_u32 (mp->count);
3930 vat_json_init_array (&root);
3932 for (i = 0; i < n; i++)
3934 e = vat_json_array_add (&root);
3935 a = &mp->adjacencies[i];
3937 vat_json_init_object (e);
3938 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3939 a->leid_prefix_len);
3941 vat_json_object_add_string_copy (e, "leid", s);
3944 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3945 a->reid_prefix_len);
3947 vat_json_object_add_string_copy (e, "reid", s);
3951 vat_json_print (vam->ofp, &root);
3952 vat_json_free (&root);
3955 vam->retval = retval;
3956 vam->result_ready = 1;
3960 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3962 vat_main_t *vam = &vat_main;
3964 print (vam->ofp, "%=20U",
3965 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3970 vl_api_one_map_server_details_t_handler_json
3971 (vl_api_one_map_server_details_t * mp)
3973 vat_main_t *vam = &vat_main;
3974 vat_json_node_t *node = NULL;
3975 struct in6_addr ip6;
3978 if (VAT_JSON_ARRAY != vam->json_tree.type)
3980 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3981 vat_json_init_array (&vam->json_tree);
3983 node = vat_json_array_add (&vam->json_tree);
3985 vat_json_init_object (node);
3988 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3989 vat_json_object_add_ip6 (node, "map-server", ip6);
3993 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3994 vat_json_object_add_ip4 (node, "map-server", ip4);
3999 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4002 vat_main_t *vam = &vat_main;
4004 print (vam->ofp, "%=20U",
4005 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4010 vl_api_one_map_resolver_details_t_handler_json
4011 (vl_api_one_map_resolver_details_t * mp)
4013 vat_main_t *vam = &vat_main;
4014 vat_json_node_t *node = NULL;
4015 struct in6_addr ip6;
4018 if (VAT_JSON_ARRAY != vam->json_tree.type)
4020 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4021 vat_json_init_array (&vam->json_tree);
4023 node = vat_json_array_add (&vam->json_tree);
4025 vat_json_init_object (node);
4028 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4029 vat_json_object_add_ip6 (node, "map resolver", ip6);
4033 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4034 vat_json_object_add_ip4 (node, "map resolver", ip4);
4039 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4041 vat_main_t *vam = &vat_main;
4042 i32 retval = ntohl (mp->retval);
4046 print (vam->ofp, "feature: %s\ngpe: %s",
4047 mp->feature_status ? "enabled" : "disabled",
4048 mp->gpe_status ? "enabled" : "disabled");
4051 vam->retval = retval;
4052 vam->result_ready = 1;
4056 vl_api_show_one_status_reply_t_handler_json
4057 (vl_api_show_one_status_reply_t * mp)
4059 vat_main_t *vam = &vat_main;
4060 vat_json_node_t node;
4061 u8 *gpe_status = NULL;
4062 u8 *feature_status = NULL;
4064 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4065 feature_status = format (0, "%s",
4066 mp->feature_status ? "enabled" : "disabled");
4067 vec_add1 (gpe_status, 0);
4068 vec_add1 (feature_status, 0);
4070 vat_json_init_object (&node);
4071 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4072 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4074 vec_free (gpe_status);
4075 vec_free (feature_status);
4077 vat_json_print (vam->ofp, &node);
4078 vat_json_free (&node);
4080 vam->retval = ntohl (mp->retval);
4081 vam->result_ready = 1;
4085 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4086 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4088 vat_main_t *vam = &vat_main;
4089 i32 retval = ntohl (mp->retval);
4093 print (vam->ofp, "%=20s", mp->locator_set_name);
4096 vam->retval = retval;
4097 vam->result_ready = 1;
4101 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4102 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4104 vat_main_t *vam = &vat_main;
4105 vat_json_node_t *node = NULL;
4107 if (VAT_JSON_ARRAY != vam->json_tree.type)
4109 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4110 vat_json_init_array (&vam->json_tree);
4112 node = vat_json_array_add (&vam->json_tree);
4114 vat_json_init_object (node);
4115 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4117 vat_json_print (vam->ofp, node);
4118 vat_json_free (node);
4120 vam->retval = ntohl (mp->retval);
4121 vam->result_ready = 1;
4125 format_lisp_map_request_mode (u8 * s, va_list * args)
4127 u32 mode = va_arg (*args, u32);
4132 return format (0, "dst-only");
4134 return format (0, "src-dst");
4140 vl_api_show_one_map_request_mode_reply_t_handler
4141 (vl_api_show_one_map_request_mode_reply_t * mp)
4143 vat_main_t *vam = &vat_main;
4144 i32 retval = ntohl (mp->retval);
4148 u32 mode = mp->mode;
4149 print (vam->ofp, "map_request_mode: %U",
4150 format_lisp_map_request_mode, mode);
4153 vam->retval = retval;
4154 vam->result_ready = 1;
4158 vl_api_show_one_map_request_mode_reply_t_handler_json
4159 (vl_api_show_one_map_request_mode_reply_t * mp)
4161 vat_main_t *vam = &vat_main;
4162 vat_json_node_t node;
4167 s = format (0, "%U", format_lisp_map_request_mode, mode);
4170 vat_json_init_object (&node);
4171 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4172 vat_json_print (vam->ofp, &node);
4173 vat_json_free (&node);
4176 vam->retval = ntohl (mp->retval);
4177 vam->result_ready = 1;
4181 vl_api_one_show_xtr_mode_reply_t_handler
4182 (vl_api_one_show_xtr_mode_reply_t * mp)
4184 vat_main_t *vam = &vat_main;
4185 i32 retval = ntohl (mp->retval);
4189 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4192 vam->retval = retval;
4193 vam->result_ready = 1;
4197 vl_api_one_show_xtr_mode_reply_t_handler_json
4198 (vl_api_one_show_xtr_mode_reply_t * mp)
4200 vat_main_t *vam = &vat_main;
4201 vat_json_node_t node;
4204 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4205 vec_add1 (status, 0);
4207 vat_json_init_object (&node);
4208 vat_json_object_add_string_copy (&node, "status", status);
4212 vat_json_print (vam->ofp, &node);
4213 vat_json_free (&node);
4215 vam->retval = ntohl (mp->retval);
4216 vam->result_ready = 1;
4220 vl_api_one_show_pitr_mode_reply_t_handler
4221 (vl_api_one_show_pitr_mode_reply_t * mp)
4223 vat_main_t *vam = &vat_main;
4224 i32 retval = ntohl (mp->retval);
4228 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4231 vam->retval = retval;
4232 vam->result_ready = 1;
4236 vl_api_one_show_pitr_mode_reply_t_handler_json
4237 (vl_api_one_show_pitr_mode_reply_t * mp)
4239 vat_main_t *vam = &vat_main;
4240 vat_json_node_t node;
4243 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4244 vec_add1 (status, 0);
4246 vat_json_init_object (&node);
4247 vat_json_object_add_string_copy (&node, "status", status);
4251 vat_json_print (vam->ofp, &node);
4252 vat_json_free (&node);
4254 vam->retval = ntohl (mp->retval);
4255 vam->result_ready = 1;
4259 vl_api_one_show_petr_mode_reply_t_handler
4260 (vl_api_one_show_petr_mode_reply_t * mp)
4262 vat_main_t *vam = &vat_main;
4263 i32 retval = ntohl (mp->retval);
4267 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4270 vam->retval = retval;
4271 vam->result_ready = 1;
4275 vl_api_one_show_petr_mode_reply_t_handler_json
4276 (vl_api_one_show_petr_mode_reply_t * mp)
4278 vat_main_t *vam = &vat_main;
4279 vat_json_node_t node;
4282 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4283 vec_add1 (status, 0);
4285 vat_json_init_object (&node);
4286 vat_json_object_add_string_copy (&node, "status", status);
4290 vat_json_print (vam->ofp, &node);
4291 vat_json_free (&node);
4293 vam->retval = ntohl (mp->retval);
4294 vam->result_ready = 1;
4298 vl_api_show_one_use_petr_reply_t_handler
4299 (vl_api_show_one_use_petr_reply_t * mp)
4301 vat_main_t *vam = &vat_main;
4302 i32 retval = ntohl (mp->retval);
4306 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4309 print (vam->ofp, "Proxy-ETR address; %U",
4310 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4315 vam->retval = retval;
4316 vam->result_ready = 1;
4320 vl_api_show_one_use_petr_reply_t_handler_json
4321 (vl_api_show_one_use_petr_reply_t * mp)
4323 vat_main_t *vam = &vat_main;
4324 vat_json_node_t node;
4327 struct in6_addr ip6;
4329 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4330 vec_add1 (status, 0);
4332 vat_json_init_object (&node);
4333 vat_json_object_add_string_copy (&node, "status", status);
4338 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4339 vat_json_object_add_ip6 (&node, "address", ip6);
4343 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4344 vat_json_object_add_ip4 (&node, "address", ip4);
4350 vat_json_print (vam->ofp, &node);
4351 vat_json_free (&node);
4353 vam->retval = ntohl (mp->retval);
4354 vam->result_ready = 1;
4358 vl_api_show_one_nsh_mapping_reply_t_handler
4359 (vl_api_show_one_nsh_mapping_reply_t * mp)
4361 vat_main_t *vam = &vat_main;
4362 i32 retval = ntohl (mp->retval);
4366 print (vam->ofp, "%-20s%-16s",
4367 mp->is_set ? "set" : "not-set",
4368 mp->is_set ? (char *) mp->locator_set_name : "");
4371 vam->retval = retval;
4372 vam->result_ready = 1;
4376 vl_api_show_one_nsh_mapping_reply_t_handler_json
4377 (vl_api_show_one_nsh_mapping_reply_t * mp)
4379 vat_main_t *vam = &vat_main;
4380 vat_json_node_t node;
4383 status = format (0, "%s", mp->is_set ? "yes" : "no");
4384 vec_add1 (status, 0);
4386 vat_json_init_object (&node);
4387 vat_json_object_add_string_copy (&node, "is_set", status);
4390 vat_json_object_add_string_copy (&node, "locator_set",
4391 mp->locator_set_name);
4396 vat_json_print (vam->ofp, &node);
4397 vat_json_free (&node);
4399 vam->retval = ntohl (mp->retval);
4400 vam->result_ready = 1;
4404 vl_api_show_one_map_register_ttl_reply_t_handler
4405 (vl_api_show_one_map_register_ttl_reply_t * mp)
4407 vat_main_t *vam = &vat_main;
4408 i32 retval = ntohl (mp->retval);
4410 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4414 print (vam->ofp, "ttl: %u", mp->ttl);
4417 vam->retval = retval;
4418 vam->result_ready = 1;
4422 vl_api_show_one_map_register_ttl_reply_t_handler_json
4423 (vl_api_show_one_map_register_ttl_reply_t * mp)
4425 vat_main_t *vam = &vat_main;
4426 vat_json_node_t node;
4428 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4429 vat_json_init_object (&node);
4430 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4432 vat_json_print (vam->ofp, &node);
4433 vat_json_free (&node);
4435 vam->retval = ntohl (mp->retval);
4436 vam->result_ready = 1;
4440 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4442 vat_main_t *vam = &vat_main;
4443 i32 retval = ntohl (mp->retval);
4447 print (vam->ofp, "%-20s%-16s",
4448 mp->status ? "enabled" : "disabled",
4449 mp->status ? (char *) mp->locator_set_name : "");
4452 vam->retval = retval;
4453 vam->result_ready = 1;
4457 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4459 vat_main_t *vam = &vat_main;
4460 vat_json_node_t node;
4463 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4464 vec_add1 (status, 0);
4466 vat_json_init_object (&node);
4467 vat_json_object_add_string_copy (&node, "status", status);
4470 vat_json_object_add_string_copy (&node, "locator_set",
4471 mp->locator_set_name);
4476 vat_json_print (vam->ofp, &node);
4477 vat_json_free (&node);
4479 vam->retval = ntohl (mp->retval);
4480 vam->result_ready = 1;
4484 format_policer_type (u8 * s, va_list * va)
4486 u32 i = va_arg (*va, u32);
4488 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4489 s = format (s, "1r2c");
4490 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4491 s = format (s, "1r3c");
4492 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4493 s = format (s, "2r3c-2698");
4494 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4495 s = format (s, "2r3c-4115");
4496 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4497 s = format (s, "2r3c-mef5cf1");
4499 s = format (s, "ILLEGAL");
4504 format_policer_rate_type (u8 * s, va_list * va)
4506 u32 i = va_arg (*va, u32);
4508 if (i == SSE2_QOS_RATE_KBPS)
4509 s = format (s, "kbps");
4510 else if (i == SSE2_QOS_RATE_PPS)
4511 s = format (s, "pps");
4513 s = format (s, "ILLEGAL");
4518 format_policer_round_type (u8 * s, va_list * va)
4520 u32 i = va_arg (*va, u32);
4522 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4523 s = format (s, "closest");
4524 else if (i == SSE2_QOS_ROUND_TO_UP)
4525 s = format (s, "up");
4526 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4527 s = format (s, "down");
4529 s = format (s, "ILLEGAL");
4534 format_policer_action_type (u8 * s, va_list * va)
4536 u32 i = va_arg (*va, u32);
4538 if (i == SSE2_QOS_ACTION_DROP)
4539 s = format (s, "drop");
4540 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4541 s = format (s, "transmit");
4542 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4543 s = format (s, "mark-and-transmit");
4545 s = format (s, "ILLEGAL");
4550 format_dscp (u8 * s, va_list * va)
4552 u32 i = va_arg (*va, u32);
4557 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4561 return format (s, "ILLEGAL");
4563 s = format (s, "%s", t);
4568 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4570 vat_main_t *vam = &vat_main;
4571 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4573 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4574 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4576 conform_dscp_str = format (0, "");
4578 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4579 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4581 exceed_dscp_str = format (0, "");
4583 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4584 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4586 violate_dscp_str = format (0, "");
4588 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4589 "rate type %U, round type %U, %s rate, %s color-aware, "
4590 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4591 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4592 "conform action %U%s, exceed action %U%s, violate action %U%s",
4594 format_policer_type, mp->type,
4597 clib_net_to_host_u64 (mp->cb),
4598 clib_net_to_host_u64 (mp->eb),
4599 format_policer_rate_type, mp->rate_type,
4600 format_policer_round_type, mp->round_type,
4601 mp->single_rate ? "single" : "dual",
4602 mp->color_aware ? "is" : "not",
4603 ntohl (mp->cir_tokens_per_period),
4604 ntohl (mp->pir_tokens_per_period),
4606 ntohl (mp->current_limit),
4607 ntohl (mp->current_bucket),
4608 ntohl (mp->extended_limit),
4609 ntohl (mp->extended_bucket),
4610 clib_net_to_host_u64 (mp->last_update_time),
4611 format_policer_action_type, mp->conform_action_type,
4613 format_policer_action_type, mp->exceed_action_type,
4615 format_policer_action_type, mp->violate_action_type,
4618 vec_free (conform_dscp_str);
4619 vec_free (exceed_dscp_str);
4620 vec_free (violate_dscp_str);
4623 static void vl_api_policer_details_t_handler_json
4624 (vl_api_policer_details_t * mp)
4626 vat_main_t *vam = &vat_main;
4627 vat_json_node_t *node;
4628 u8 *rate_type_str, *round_type_str, *type_str;
4629 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4631 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4633 format (0, "%U", format_policer_round_type, mp->round_type);
4634 type_str = format (0, "%U", format_policer_type, mp->type);
4635 conform_action_str = format (0, "%U", format_policer_action_type,
4636 mp->conform_action_type);
4637 exceed_action_str = format (0, "%U", format_policer_action_type,
4638 mp->exceed_action_type);
4639 violate_action_str = format (0, "%U", format_policer_action_type,
4640 mp->violate_action_type);
4642 if (VAT_JSON_ARRAY != vam->json_tree.type)
4644 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4645 vat_json_init_array (&vam->json_tree);
4647 node = vat_json_array_add (&vam->json_tree);
4649 vat_json_init_object (node);
4650 vat_json_object_add_string_copy (node, "name", mp->name);
4651 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4652 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4653 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4654 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4655 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4656 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4657 vat_json_object_add_string_copy (node, "type", type_str);
4658 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4659 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4660 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4661 vat_json_object_add_uint (node, "cir_tokens_per_period",
4662 ntohl (mp->cir_tokens_per_period));
4663 vat_json_object_add_uint (node, "eir_tokens_per_period",
4664 ntohl (mp->pir_tokens_per_period));
4665 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4666 vat_json_object_add_uint (node, "current_bucket",
4667 ntohl (mp->current_bucket));
4668 vat_json_object_add_uint (node, "extended_limit",
4669 ntohl (mp->extended_limit));
4670 vat_json_object_add_uint (node, "extended_bucket",
4671 ntohl (mp->extended_bucket));
4672 vat_json_object_add_uint (node, "last_update_time",
4673 ntohl (mp->last_update_time));
4674 vat_json_object_add_string_copy (node, "conform_action",
4675 conform_action_str);
4676 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4678 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4679 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4680 vec_free (dscp_str);
4682 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4683 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4685 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4686 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4687 vec_free (dscp_str);
4689 vat_json_object_add_string_copy (node, "violate_action",
4690 violate_action_str);
4691 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4693 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4694 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4695 vec_free (dscp_str);
4698 vec_free (rate_type_str);
4699 vec_free (round_type_str);
4700 vec_free (type_str);
4701 vec_free (conform_action_str);
4702 vec_free (exceed_action_str);
4703 vec_free (violate_action_str);
4707 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4710 vat_main_t *vam = &vat_main;
4711 int i, count = ntohl (mp->count);
4714 print (vam->ofp, "classify table ids (%d) : ", count);
4715 for (i = 0; i < count; i++)
4717 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4718 print (vam->ofp, (i < count - 1) ? "," : "");
4720 vam->retval = ntohl (mp->retval);
4721 vam->result_ready = 1;
4725 vl_api_classify_table_ids_reply_t_handler_json
4726 (vl_api_classify_table_ids_reply_t * mp)
4728 vat_main_t *vam = &vat_main;
4729 int i, count = ntohl (mp->count);
4733 vat_json_node_t node;
4735 vat_json_init_object (&node);
4736 for (i = 0; i < count; i++)
4738 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4740 vat_json_print (vam->ofp, &node);
4741 vat_json_free (&node);
4743 vam->retval = ntohl (mp->retval);
4744 vam->result_ready = 1;
4748 vl_api_classify_table_by_interface_reply_t_handler
4749 (vl_api_classify_table_by_interface_reply_t * mp)
4751 vat_main_t *vam = &vat_main;
4754 table_id = ntohl (mp->l2_table_id);
4756 print (vam->ofp, "l2 table id : %d", table_id);
4758 print (vam->ofp, "l2 table id : No input ACL tables configured");
4759 table_id = ntohl (mp->ip4_table_id);
4761 print (vam->ofp, "ip4 table id : %d", table_id);
4763 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4764 table_id = ntohl (mp->ip6_table_id);
4766 print (vam->ofp, "ip6 table id : %d", table_id);
4768 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4769 vam->retval = ntohl (mp->retval);
4770 vam->result_ready = 1;
4774 vl_api_classify_table_by_interface_reply_t_handler_json
4775 (vl_api_classify_table_by_interface_reply_t * mp)
4777 vat_main_t *vam = &vat_main;
4778 vat_json_node_t node;
4780 vat_json_init_object (&node);
4782 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4783 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4784 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4786 vat_json_print (vam->ofp, &node);
4787 vat_json_free (&node);
4789 vam->retval = ntohl (mp->retval);
4790 vam->result_ready = 1;
4793 static void vl_api_policer_add_del_reply_t_handler
4794 (vl_api_policer_add_del_reply_t * mp)
4796 vat_main_t *vam = &vat_main;
4797 i32 retval = ntohl (mp->retval);
4798 if (vam->async_mode)
4800 vam->async_errors += (retval < 0);
4804 vam->retval = retval;
4805 vam->result_ready = 1;
4806 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4808 * Note: this is just barely thread-safe, depends on
4809 * the main thread spinning waiting for an answer...
4811 errmsg ("policer index %d", ntohl (mp->policer_index));
4815 static void vl_api_policer_add_del_reply_t_handler_json
4816 (vl_api_policer_add_del_reply_t * mp)
4818 vat_main_t *vam = &vat_main;
4819 vat_json_node_t node;
4821 vat_json_init_object (&node);
4822 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4823 vat_json_object_add_uint (&node, "policer_index",
4824 ntohl (mp->policer_index));
4826 vat_json_print (vam->ofp, &node);
4827 vat_json_free (&node);
4829 vam->retval = ntohl (mp->retval);
4830 vam->result_ready = 1;
4833 /* Format hex dump. */
4835 format_hex_bytes (u8 * s, va_list * va)
4837 u8 *bytes = va_arg (*va, u8 *);
4838 int n_bytes = va_arg (*va, int);
4841 /* Print short or long form depending on byte count. */
4842 uword short_form = n_bytes <= 32;
4843 u32 indent = format_get_indent (s);
4848 for (i = 0; i < n_bytes; i++)
4850 if (!short_form && (i % 32) == 0)
4851 s = format (s, "%08x: ", i);
4852 s = format (s, "%02x", bytes[i]);
4853 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4854 s = format (s, "\n%U", format_white_space, indent);
4861 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4864 vat_main_t *vam = &vat_main;
4865 i32 retval = ntohl (mp->retval);
4868 print (vam->ofp, "classify table info :");
4869 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4870 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4871 ntohl (mp->miss_next_index));
4872 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4873 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4874 ntohl (mp->match_n_vectors));
4875 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4876 ntohl (mp->mask_length));
4878 vam->retval = retval;
4879 vam->result_ready = 1;
4883 vl_api_classify_table_info_reply_t_handler_json
4884 (vl_api_classify_table_info_reply_t * mp)
4886 vat_main_t *vam = &vat_main;
4887 vat_json_node_t node;
4889 i32 retval = ntohl (mp->retval);
4892 vat_json_init_object (&node);
4894 vat_json_object_add_int (&node, "sessions",
4895 ntohl (mp->active_sessions));
4896 vat_json_object_add_int (&node, "nexttbl",
4897 ntohl (mp->next_table_index));
4898 vat_json_object_add_int (&node, "nextnode",
4899 ntohl (mp->miss_next_index));
4900 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4901 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4902 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4903 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4904 ntohl (mp->mask_length), 0);
4905 vat_json_object_add_string_copy (&node, "mask", s);
4907 vat_json_print (vam->ofp, &node);
4908 vat_json_free (&node);
4910 vam->retval = ntohl (mp->retval);
4911 vam->result_ready = 1;
4915 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4918 vat_main_t *vam = &vat_main;
4920 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4921 ntohl (mp->hit_next_index), ntohl (mp->advance),
4922 ntohl (mp->opaque_index));
4923 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4924 ntohl (mp->match_length));
4928 vl_api_classify_session_details_t_handler_json
4929 (vl_api_classify_session_details_t * mp)
4931 vat_main_t *vam = &vat_main;
4932 vat_json_node_t *node = NULL;
4934 if (VAT_JSON_ARRAY != vam->json_tree.type)
4936 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4937 vat_json_init_array (&vam->json_tree);
4939 node = vat_json_array_add (&vam->json_tree);
4941 vat_json_init_object (node);
4942 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4943 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4944 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4946 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4948 vat_json_object_add_string_copy (node, "match", s);
4951 static void vl_api_pg_create_interface_reply_t_handler
4952 (vl_api_pg_create_interface_reply_t * mp)
4954 vat_main_t *vam = &vat_main;
4956 vam->retval = ntohl (mp->retval);
4957 vam->result_ready = 1;
4960 static void vl_api_pg_create_interface_reply_t_handler_json
4961 (vl_api_pg_create_interface_reply_t * mp)
4963 vat_main_t *vam = &vat_main;
4964 vat_json_node_t node;
4966 i32 retval = ntohl (mp->retval);
4969 vat_json_init_object (&node);
4971 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4973 vat_json_print (vam->ofp, &node);
4974 vat_json_free (&node);
4976 vam->retval = ntohl (mp->retval);
4977 vam->result_ready = 1;
4980 static void vl_api_policer_classify_details_t_handler
4981 (vl_api_policer_classify_details_t * mp)
4983 vat_main_t *vam = &vat_main;
4985 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4986 ntohl (mp->table_index));
4989 static void vl_api_policer_classify_details_t_handler_json
4990 (vl_api_policer_classify_details_t * mp)
4992 vat_main_t *vam = &vat_main;
4993 vat_json_node_t *node;
4995 if (VAT_JSON_ARRAY != vam->json_tree.type)
4997 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4998 vat_json_init_array (&vam->json_tree);
5000 node = vat_json_array_add (&vam->json_tree);
5002 vat_json_init_object (node);
5003 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5004 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5007 static void vl_api_flow_classify_details_t_handler
5008 (vl_api_flow_classify_details_t * mp)
5010 vat_main_t *vam = &vat_main;
5012 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5013 ntohl (mp->table_index));
5016 static void vl_api_flow_classify_details_t_handler_json
5017 (vl_api_flow_classify_details_t * mp)
5019 vat_main_t *vam = &vat_main;
5020 vat_json_node_t *node;
5022 if (VAT_JSON_ARRAY != vam->json_tree.type)
5024 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5025 vat_json_init_array (&vam->json_tree);
5027 node = vat_json_array_add (&vam->json_tree);
5029 vat_json_init_object (node);
5030 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5031 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5034 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5035 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5036 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5037 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5038 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5039 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5040 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5041 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5042 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5043 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5046 * Generate boilerplate reply handlers, which
5047 * dig the return value out of the xxx_reply_t API message,
5048 * stick it into vam->retval, and set vam->result_ready
5050 * Could also do this by pointing N message decode slots at
5051 * a single function, but that could break in subtle ways.
5054 #define foreach_standard_reply_retval_handler \
5055 _(sw_interface_set_flags_reply) \
5056 _(sw_interface_add_del_address_reply) \
5057 _(sw_interface_set_rx_mode_reply) \
5058 _(sw_interface_set_rx_placement_reply) \
5059 _(sw_interface_set_table_reply) \
5060 _(sw_interface_set_mpls_enable_reply) \
5061 _(sw_interface_set_vpath_reply) \
5062 _(sw_interface_set_vxlan_bypass_reply) \
5063 _(sw_interface_set_geneve_bypass_reply) \
5064 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5065 _(sw_interface_set_l2_bridge_reply) \
5066 _(sw_interface_set_bond_weight_reply) \
5067 _(bridge_domain_add_del_reply) \
5068 _(sw_interface_set_l2_xconnect_reply) \
5069 _(l2fib_add_del_reply) \
5070 _(l2fib_flush_int_reply) \
5071 _(l2fib_flush_bd_reply) \
5072 _(ip_route_add_del_reply) \
5073 _(ip_table_add_del_reply) \
5074 _(ip_table_replace_begin_reply) \
5075 _(ip_table_flush_reply) \
5076 _(ip_table_replace_end_reply) \
5077 _(ip_mroute_add_del_reply) \
5078 _(mpls_route_add_del_reply) \
5079 _(mpls_table_add_del_reply) \
5080 _(mpls_ip_bind_unbind_reply) \
5081 _(bier_route_add_del_reply) \
5082 _(bier_table_add_del_reply) \
5083 _(proxy_arp_add_del_reply) \
5084 _(proxy_arp_intfc_enable_disable_reply) \
5085 _(sw_interface_set_unnumbered_reply) \
5086 _(ip_neighbor_add_del_reply) \
5087 _(set_ip_flow_hash_reply) \
5088 _(sw_interface_ip6_enable_disable_reply) \
5089 _(ip6nd_proxy_add_del_reply) \
5090 _(sw_interface_ip6nd_ra_prefix_reply) \
5091 _(sw_interface_ip6nd_ra_config_reply) \
5092 _(set_arp_neighbor_limit_reply) \
5093 _(l2_patch_add_del_reply) \
5094 _(sr_mpls_policy_add_reply) \
5095 _(sr_mpls_policy_mod_reply) \
5096 _(sr_mpls_policy_del_reply) \
5097 _(sr_policy_add_reply) \
5098 _(sr_policy_mod_reply) \
5099 _(sr_policy_del_reply) \
5100 _(sr_localsid_add_del_reply) \
5101 _(sr_steering_add_del_reply) \
5102 _(classify_add_del_session_reply) \
5103 _(classify_set_interface_ip_table_reply) \
5104 _(classify_set_interface_l2_tables_reply) \
5105 _(l2tpv3_set_tunnel_cookies_reply) \
5106 _(l2tpv3_interface_enable_disable_reply) \
5107 _(l2tpv3_set_lookup_key_reply) \
5108 _(l2_fib_clear_table_reply) \
5109 _(l2_interface_efp_filter_reply) \
5110 _(l2_interface_vlan_tag_rewrite_reply) \
5111 _(modify_vhost_user_if_reply) \
5112 _(delete_vhost_user_if_reply) \
5113 _(ip_probe_neighbor_reply) \
5114 _(ip_scan_neighbor_enable_disable_reply) \
5115 _(want_ip4_arp_events_reply) \
5116 _(want_ip6_nd_events_reply) \
5117 _(want_l2_macs_events_reply) \
5118 _(input_acl_set_interface_reply) \
5119 _(ipsec_spd_add_del_reply) \
5120 _(ipsec_interface_add_del_spd_reply) \
5121 _(ipsec_spd_entry_add_del_reply) \
5122 _(ipsec_sad_entry_add_del_reply) \
5123 _(ipsec_tunnel_if_add_del_reply) \
5124 _(ipsec_tunnel_if_set_sa_reply) \
5125 _(delete_loopback_reply) \
5126 _(bd_ip_mac_add_del_reply) \
5127 _(bd_ip_mac_flush_reply) \
5128 _(want_interface_events_reply) \
5129 _(cop_interface_enable_disable_reply) \
5130 _(cop_whitelist_enable_disable_reply) \
5131 _(sw_interface_clear_stats_reply) \
5132 _(ioam_enable_reply) \
5133 _(ioam_disable_reply) \
5134 _(one_add_del_locator_reply) \
5135 _(one_add_del_local_eid_reply) \
5136 _(one_add_del_remote_mapping_reply) \
5137 _(one_add_del_adjacency_reply) \
5138 _(one_add_del_map_resolver_reply) \
5139 _(one_add_del_map_server_reply) \
5140 _(one_enable_disable_reply) \
5141 _(one_rloc_probe_enable_disable_reply) \
5142 _(one_map_register_enable_disable_reply) \
5143 _(one_map_register_set_ttl_reply) \
5144 _(one_set_transport_protocol_reply) \
5145 _(one_map_register_fallback_threshold_reply) \
5146 _(one_pitr_set_locator_set_reply) \
5147 _(one_map_request_mode_reply) \
5148 _(one_add_del_map_request_itr_rlocs_reply) \
5149 _(one_eid_table_add_del_map_reply) \
5150 _(one_use_petr_reply) \
5151 _(one_stats_enable_disable_reply) \
5152 _(one_add_del_l2_arp_entry_reply) \
5153 _(one_add_del_ndp_entry_reply) \
5154 _(one_stats_flush_reply) \
5155 _(one_enable_disable_xtr_mode_reply) \
5156 _(one_enable_disable_pitr_mode_reply) \
5157 _(one_enable_disable_petr_mode_reply) \
5158 _(gpe_enable_disable_reply) \
5159 _(gpe_set_encap_mode_reply) \
5160 _(gpe_add_del_iface_reply) \
5161 _(gpe_add_del_native_fwd_rpath_reply) \
5162 _(af_packet_delete_reply) \
5163 _(policer_classify_set_interface_reply) \
5164 _(netmap_create_reply) \
5165 _(netmap_delete_reply) \
5166 _(set_ipfix_exporter_reply) \
5167 _(set_ipfix_classify_stream_reply) \
5168 _(ipfix_classify_table_add_del_reply) \
5169 _(flow_classify_set_interface_reply) \
5170 _(sw_interface_span_enable_disable_reply) \
5171 _(pg_capture_reply) \
5172 _(pg_enable_disable_reply) \
5173 _(ip_source_and_port_range_check_add_del_reply) \
5174 _(ip_source_and_port_range_check_interface_add_del_reply)\
5175 _(delete_subif_reply) \
5176 _(l2_interface_pbb_tag_rewrite_reply) \
5178 _(feature_enable_disable_reply) \
5179 _(feature_gso_enable_disable_reply) \
5180 _(sw_interface_tag_add_del_reply) \
5181 _(sw_interface_add_del_mac_address_reply) \
5182 _(hw_interface_set_mtu_reply) \
5183 _(p2p_ethernet_add_reply) \
5184 _(p2p_ethernet_del_reply) \
5185 _(lldp_config_reply) \
5186 _(sw_interface_set_lldp_reply) \
5187 _(tcp_configure_src_addresses_reply) \
5188 _(session_rule_add_del_reply) \
5189 _(ip_container_proxy_add_del_reply) \
5190 _(output_acl_set_interface_reply) \
5191 _(qos_record_enable_disable_reply)
5194 static void vl_api_##n##_t_handler \
5195 (vl_api_##n##_t * mp) \
5197 vat_main_t * vam = &vat_main; \
5198 i32 retval = ntohl(mp->retval); \
5199 if (vam->async_mode) { \
5200 vam->async_errors += (retval < 0); \
5202 vam->retval = retval; \
5203 vam->result_ready = 1; \
5206 foreach_standard_reply_retval_handler;
5210 static void vl_api_##n##_t_handler_json \
5211 (vl_api_##n##_t * mp) \
5213 vat_main_t * vam = &vat_main; \
5214 vat_json_node_t node; \
5215 vat_json_init_object(&node); \
5216 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5217 vat_json_print(vam->ofp, &node); \
5218 vam->retval = ntohl(mp->retval); \
5219 vam->result_ready = 1; \
5221 foreach_standard_reply_retval_handler;
5225 * Table of message reply handlers, must include boilerplate handlers
5229 #define foreach_vpe_api_reply_msg \
5230 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5231 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5232 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5233 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5234 _(CONTROL_PING_REPLY, control_ping_reply) \
5235 _(CLI_REPLY, cli_reply) \
5236 _(CLI_INBAND_REPLY, cli_inband_reply) \
5237 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5238 sw_interface_add_del_address_reply) \
5239 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5240 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5241 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5242 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5243 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5244 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5245 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5246 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5247 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5248 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5249 sw_interface_set_l2_xconnect_reply) \
5250 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5251 sw_interface_set_l2_bridge_reply) \
5252 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5253 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5254 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5255 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5256 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5257 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5258 _(L2_FLAGS_REPLY, l2_flags_reply) \
5259 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5260 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5261 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5262 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5263 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5264 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5265 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5266 _(BOND_CREATE_REPLY, bond_create_reply) \
5267 _(BOND_DELETE_REPLY, bond_delete_reply) \
5268 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5269 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5270 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5271 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5272 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5273 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5274 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5275 _(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
5276 _(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
5277 _(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_reply) \
5278 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5279 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5280 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5281 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5282 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5283 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5284 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5285 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5286 proxy_arp_intfc_enable_disable_reply) \
5287 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5288 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5289 sw_interface_set_unnumbered_reply) \
5290 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5291 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5292 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5293 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5294 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5295 sw_interface_ip6_enable_disable_reply) \
5296 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5297 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5298 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5299 sw_interface_ip6nd_ra_prefix_reply) \
5300 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5301 sw_interface_ip6nd_ra_config_reply) \
5302 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5303 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5304 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5305 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5306 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5307 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5308 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5309 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5310 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5311 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5312 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5313 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5314 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5315 classify_set_interface_ip_table_reply) \
5316 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5317 classify_set_interface_l2_tables_reply) \
5318 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5319 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5320 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5321 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5322 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5323 l2tpv3_interface_enable_disable_reply) \
5324 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5325 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5326 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5327 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5328 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5329 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5330 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5331 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5332 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5333 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5334 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5335 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5336 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5337 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5338 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5339 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5340 _(SHOW_VERSION_REPLY, show_version_reply) \
5341 _(SHOW_THREADS_REPLY, show_threads_reply) \
5342 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5343 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5344 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5345 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5346 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5347 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5348 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5349 _(IP4_ARP_EVENT, ip4_arp_event) \
5350 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5351 _(IP6_ND_EVENT, ip6_nd_event) \
5352 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5353 _(L2_MACS_EVENT, l2_macs_event) \
5354 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5355 _(IP_ADDRESS_DETAILS, ip_address_details) \
5356 _(IP_DETAILS, ip_details) \
5357 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5358 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5359 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5360 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5361 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5362 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5363 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5364 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5365 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5366 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5367 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5368 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5369 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5370 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5371 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5372 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5373 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5374 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5375 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5376 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5377 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5378 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5379 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5380 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5381 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5382 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5383 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5384 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5385 one_map_register_enable_disable_reply) \
5386 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5387 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5388 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5389 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5390 one_map_register_fallback_threshold_reply) \
5391 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5392 one_rloc_probe_enable_disable_reply) \
5393 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5394 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5395 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5396 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5397 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5398 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5399 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5400 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5401 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5402 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5403 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5404 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5405 _(ONE_STATS_DETAILS, one_stats_details) \
5406 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5407 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5408 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5409 show_one_stats_enable_disable_reply) \
5410 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5411 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5412 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5413 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5414 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5415 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5416 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5417 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5418 one_enable_disable_pitr_mode_reply) \
5419 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5420 one_enable_disable_petr_mode_reply) \
5421 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5422 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5423 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5424 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5425 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5426 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5427 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5428 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5429 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5430 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5431 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5432 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5433 gpe_add_del_native_fwd_rpath_reply) \
5434 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5435 gpe_fwd_entry_path_details) \
5436 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5437 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5438 one_add_del_map_request_itr_rlocs_reply) \
5439 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5440 one_get_map_request_itr_rlocs_reply) \
5441 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5442 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5443 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5444 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5445 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5446 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5447 show_one_map_register_state_reply) \
5448 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5449 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5450 show_one_map_register_fallback_threshold_reply) \
5451 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5452 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5453 _(AF_PACKET_DETAILS, af_packet_details) \
5454 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5455 _(POLICER_DETAILS, policer_details) \
5456 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5457 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5458 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5459 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5460 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5461 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5462 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5463 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5464 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5465 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5466 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5467 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5468 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5469 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5470 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5471 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5472 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5473 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5474 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5475 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5476 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5477 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5478 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5479 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5480 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5481 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5482 ip_source_and_port_range_check_add_del_reply) \
5483 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5484 ip_source_and_port_range_check_interface_add_del_reply) \
5485 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5486 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5487 _(SET_PUNT_REPLY, set_punt_reply) \
5488 _(IP_TABLE_DETAILS, ip_table_details) \
5489 _(IP_ROUTE_DETAILS, ip_route_details) \
5490 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5491 _(FEATURE_GSO_ENABLE_DISABLE_REPLY, feature_gso_enable_disable_reply) \
5492 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5493 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
5494 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5495 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5496 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5497 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5498 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5499 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5500 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5501 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5502 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5503 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5504 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5505 _(SESSION_RULES_DETAILS, session_rules_details) \
5506 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5507 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5508 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5510 #define foreach_standalone_reply_msg \
5511 _(SW_INTERFACE_EVENT, sw_interface_event)
5519 #define STR_VTR_OP_CASE(op) \
5520 case L2_VTR_ ## op: \
5524 str_vtr_op (u32 vtr_op)
5528 STR_VTR_OP_CASE (DISABLED);
5529 STR_VTR_OP_CASE (PUSH_1);
5530 STR_VTR_OP_CASE (PUSH_2);
5531 STR_VTR_OP_CASE (POP_1);
5532 STR_VTR_OP_CASE (POP_2);
5533 STR_VTR_OP_CASE (TRANSLATE_1_1);
5534 STR_VTR_OP_CASE (TRANSLATE_1_2);
5535 STR_VTR_OP_CASE (TRANSLATE_2_1);
5536 STR_VTR_OP_CASE (TRANSLATE_2_2);
5543 dump_sub_interface_table (vat_main_t * vam)
5545 const sw_interface_subif_t *sub = NULL;
5547 if (vam->json_output)
5550 ("JSON output supported only for VPE API calls and dump_stats_table");
5555 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5556 "Interface", "sw_if_index",
5557 "sub id", "dot1ad", "tags", "outer id",
5558 "inner id", "exact", "default", "outer any", "inner any");
5560 vec_foreach (sub, vam->sw_if_subif_table)
5563 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5564 sub->interface_name,
5566 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5567 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5568 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5569 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5570 if (sub->vtr_op != L2_VTR_DISABLED)
5573 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5574 "tag1: %d tag2: %d ]",
5575 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5576 sub->vtr_tag1, sub->vtr_tag2);
5584 name_sort_cmp (void *a1, void *a2)
5586 name_sort_t *n1 = a1;
5587 name_sort_t *n2 = a2;
5589 return strcmp ((char *) n1->name, (char *) n2->name);
5593 dump_interface_table (vat_main_t * vam)
5596 name_sort_t *nses = 0, *ns;
5598 if (vam->json_output)
5601 ("JSON output supported only for VPE API calls and dump_stats_table");
5606 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5608 vec_add2 (nses, ns, 1);
5609 ns->name = (u8 *)(p->key);
5610 ns->value = (u32) p->value[0];
5614 vec_sort_with_function (nses, name_sort_cmp);
5616 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5617 vec_foreach (ns, nses)
5619 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5626 dump_ip_table (vat_main_t * vam, int is_ipv6)
5628 const ip_details_t *det = NULL;
5629 const ip_address_details_t *address = NULL;
5632 print (vam->ofp, "%-12s", "sw_if_index");
5634 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5641 print (vam->ofp, "%-12d", i);
5642 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5647 vec_foreach (address, det->addr)
5651 is_ipv6 ? format_ip6_address : format_ip4_address,
5652 address->ip, address->prefix_length);
5660 dump_ipv4_table (vat_main_t * vam)
5662 if (vam->json_output)
5665 ("JSON output supported only for VPE API calls and dump_stats_table");
5669 return dump_ip_table (vam, 0);
5673 dump_ipv6_table (vat_main_t * vam)
5675 if (vam->json_output)
5678 ("JSON output supported only for VPE API calls and dump_stats_table");
5682 return dump_ip_table (vam, 1);
5686 * Pass CLI buffers directly in the CLI_INBAND API message,
5687 * instead of an additional shared memory area.
5690 exec_inband (vat_main_t * vam)
5692 vl_api_cli_inband_t *mp;
5693 unformat_input_t *i = vam->input;
5696 if (vec_len (i->buffer) == 0)
5699 if (vam->exec_mode == 0 && unformat (i, "mode"))
5704 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5711 * In order for the CLI command to work, it
5712 * must be a vector ending in \n, not a C-string ending
5715 u32 len = vec_len (vam->input->buffer);
5716 M2 (CLI_INBAND, mp, len);
5717 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5721 /* json responses may or may not include a useful reply... */
5722 if (vec_len (vam->cmd_reply))
5723 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5728 exec (vat_main_t * vam)
5730 return exec_inband (vam);
5734 api_create_loopback (vat_main_t * vam)
5736 unformat_input_t *i = vam->input;
5737 vl_api_create_loopback_t *mp;
5738 vl_api_create_loopback_instance_t *mp_lbi;
5741 u8 is_specified = 0;
5742 u32 user_instance = 0;
5745 clib_memset (mac_address, 0, sizeof (mac_address));
5747 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5749 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5751 if (unformat (i, "instance %d", &user_instance))
5759 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5760 mp_lbi->is_specified = is_specified;
5762 mp_lbi->user_instance = htonl (user_instance);
5764 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5769 /* Construct the API message */
5770 M (CREATE_LOOPBACK, mp);
5772 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5781 api_delete_loopback (vat_main_t * vam)
5783 unformat_input_t *i = vam->input;
5784 vl_api_delete_loopback_t *mp;
5785 u32 sw_if_index = ~0;
5788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5790 if (unformat (i, "sw_if_index %d", &sw_if_index))
5796 if (sw_if_index == ~0)
5798 errmsg ("missing sw_if_index");
5802 /* Construct the API message */
5803 M (DELETE_LOOPBACK, mp);
5804 mp->sw_if_index = ntohl (sw_if_index);
5812 api_want_interface_events (vat_main_t * vam)
5814 unformat_input_t *i = vam->input;
5815 vl_api_want_interface_events_t *mp;
5819 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5821 if (unformat (i, "enable"))
5823 else if (unformat (i, "disable"))
5831 errmsg ("missing enable|disable");
5835 M (WANT_INTERFACE_EVENTS, mp);
5836 mp->enable_disable = enable;
5838 vam->interface_event_display = enable;
5846 /* Note: non-static, called once to set up the initial intfc table */
5848 api_sw_interface_dump (vat_main_t * vam)
5850 vl_api_sw_interface_dump_t *mp;
5851 vl_api_control_ping_t *mp_ping;
5853 name_sort_t *nses = 0, *ns;
5854 sw_interface_subif_t *sub = NULL;
5857 /* Toss the old name table */
5859 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5861 vec_add2 (nses, ns, 1);
5862 ns->name = (u8 *)(p->key);
5863 ns->value = (u32) p->value[0];
5867 hash_free (vam->sw_if_index_by_interface_name);
5869 vec_foreach (ns, nses) vec_free (ns->name);
5873 vec_foreach (sub, vam->sw_if_subif_table)
5875 vec_free (sub->interface_name);
5877 vec_free (vam->sw_if_subif_table);
5879 /* recreate the interface name hash table */
5880 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5883 * Ask for all interface names. Otherwise, the epic catalog of
5884 * name filters becomes ridiculously long, and vat ends up needing
5885 * to be taught about new interface types.
5887 M (SW_INTERFACE_DUMP, mp);
5890 /* Use a control ping for synchronization */
5891 MPING (CONTROL_PING, mp_ping);
5899 api_sw_interface_set_flags (vat_main_t * vam)
5901 unformat_input_t *i = vam->input;
5902 vl_api_sw_interface_set_flags_t *mp;
5904 u8 sw_if_index_set = 0;
5908 /* Parse args required to build the message */
5909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5911 if (unformat (i, "admin-up"))
5913 else if (unformat (i, "admin-down"))
5916 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5917 sw_if_index_set = 1;
5918 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5919 sw_if_index_set = 1;
5924 if (sw_if_index_set == 0)
5926 errmsg ("missing interface name or sw_if_index");
5930 /* Construct the API message */
5931 M (SW_INTERFACE_SET_FLAGS, mp);
5932 mp->sw_if_index = ntohl (sw_if_index);
5933 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5938 /* Wait for a reply, return the good/bad news... */
5944 api_sw_interface_set_rx_mode (vat_main_t * vam)
5946 unformat_input_t *i = vam->input;
5947 vl_api_sw_interface_set_rx_mode_t *mp;
5949 u8 sw_if_index_set = 0;
5951 u8 queue_id_valid = 0;
5953 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5955 /* Parse args required to build the message */
5956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5958 if (unformat (i, "queue %d", &queue_id))
5960 else if (unformat (i, "polling"))
5961 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5962 else if (unformat (i, "interrupt"))
5963 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5964 else if (unformat (i, "adaptive"))
5965 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5967 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5968 sw_if_index_set = 1;
5969 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5970 sw_if_index_set = 1;
5975 if (sw_if_index_set == 0)
5977 errmsg ("missing interface name or sw_if_index");
5980 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
5982 errmsg ("missing rx-mode");
5986 /* Construct the API message */
5987 M (SW_INTERFACE_SET_RX_MODE, mp);
5988 mp->sw_if_index = ntohl (sw_if_index);
5989 mp->mode = (vl_api_rx_mode_t) mode;
5990 mp->queue_id_valid = queue_id_valid;
5991 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
5996 /* Wait for a reply, return the good/bad news... */
6002 api_sw_interface_set_rx_placement (vat_main_t * vam)
6004 unformat_input_t *i = vam->input;
6005 vl_api_sw_interface_set_rx_placement_t *mp;
6007 u8 sw_if_index_set = 0;
6010 u32 queue_id, thread_index;
6012 /* Parse args required to build the message */
6013 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6015 if (unformat (i, "queue %d", &queue_id))
6017 else if (unformat (i, "main"))
6019 else if (unformat (i, "worker %d", &thread_index))
6022 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6023 sw_if_index_set = 1;
6024 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6025 sw_if_index_set = 1;
6030 if (sw_if_index_set == 0)
6032 errmsg ("missing interface name or sw_if_index");
6038 /* Construct the API message */
6039 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6040 mp->sw_if_index = ntohl (sw_if_index);
6041 mp->worker_id = ntohl (thread_index);
6042 mp->queue_id = ntohl (queue_id);
6043 mp->is_main = is_main;
6047 /* Wait for a reply, return the good/bad news... */
6052 static void vl_api_sw_interface_rx_placement_details_t_handler
6053 (vl_api_sw_interface_rx_placement_details_t * mp)
6055 vat_main_t *vam = &vat_main;
6056 u32 worker_id = ntohl (mp->worker_id);
6059 "\n%-11d %-11s %-6d %-5d %-9s",
6060 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6061 worker_id, ntohl (mp->queue_id),
6063 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6066 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6067 (vl_api_sw_interface_rx_placement_details_t * mp)
6069 vat_main_t *vam = &vat_main;
6070 vat_json_node_t *node = NULL;
6072 if (VAT_JSON_ARRAY != vam->json_tree.type)
6074 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6075 vat_json_init_array (&vam->json_tree);
6077 node = vat_json_array_add (&vam->json_tree);
6079 vat_json_init_object (node);
6080 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6081 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6082 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6083 vat_json_object_add_uint (node, "mode", mp->mode);
6087 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6089 unformat_input_t *i = vam->input;
6090 vl_api_sw_interface_rx_placement_dump_t *mp;
6091 vl_api_control_ping_t *mp_ping;
6094 u8 sw_if_index_set = 0;
6096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6098 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6100 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6107 "\n%-11s %-11s %-6s %-5s %-4s",
6108 "sw_if_index", "main/worker", "thread", "queue", "mode");
6110 /* Dump Interface rx placement */
6111 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6113 if (sw_if_index_set)
6114 mp->sw_if_index = htonl (sw_if_index);
6116 mp->sw_if_index = ~0;
6120 /* Use a control ping for synchronization */
6121 MPING (CONTROL_PING, mp_ping);
6129 api_sw_interface_clear_stats (vat_main_t * vam)
6131 unformat_input_t *i = vam->input;
6132 vl_api_sw_interface_clear_stats_t *mp;
6134 u8 sw_if_index_set = 0;
6137 /* Parse args required to build the message */
6138 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6140 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6141 sw_if_index_set = 1;
6142 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6143 sw_if_index_set = 1;
6148 /* Construct the API message */
6149 M (SW_INTERFACE_CLEAR_STATS, mp);
6151 if (sw_if_index_set == 1)
6152 mp->sw_if_index = ntohl (sw_if_index);
6154 mp->sw_if_index = ~0;
6159 /* Wait for a reply, return the good/bad news... */
6165 api_sw_interface_add_del_address (vat_main_t * vam)
6167 unformat_input_t *i = vam->input;
6168 vl_api_sw_interface_add_del_address_t *mp;
6170 u8 sw_if_index_set = 0;
6171 u8 is_add = 1, del_all = 0;
6172 u32 address_length = 0;
6173 u8 v4_address_set = 0;
6174 u8 v6_address_set = 0;
6175 ip4_address_t v4address;
6176 ip6_address_t v6address;
6179 /* Parse args required to build the message */
6180 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6182 if (unformat (i, "del-all"))
6184 else if (unformat (i, "del"))
6187 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6188 sw_if_index_set = 1;
6189 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6190 sw_if_index_set = 1;
6191 else if (unformat (i, "%U/%d",
6192 unformat_ip4_address, &v4address, &address_length))
6194 else if (unformat (i, "%U/%d",
6195 unformat_ip6_address, &v6address, &address_length))
6201 if (sw_if_index_set == 0)
6203 errmsg ("missing interface name or sw_if_index");
6206 if (v4_address_set && v6_address_set)
6208 errmsg ("both v4 and v6 addresses set");
6211 if (!v4_address_set && !v6_address_set && !del_all)
6213 errmsg ("no addresses set");
6217 /* Construct the API message */
6218 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6220 mp->sw_if_index = ntohl (sw_if_index);
6221 mp->is_add = is_add;
6222 mp->del_all = del_all;
6225 mp->prefix.address.af = ADDRESS_IP6;
6226 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6230 mp->prefix.address.af = ADDRESS_IP4;
6231 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6233 mp->prefix.len = address_length;
6238 /* Wait for a reply, return good/bad news */
6244 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6246 unformat_input_t *i = vam->input;
6247 vl_api_sw_interface_set_mpls_enable_t *mp;
6249 u8 sw_if_index_set = 0;
6253 /* Parse args required to build the message */
6254 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6256 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6257 sw_if_index_set = 1;
6258 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6259 sw_if_index_set = 1;
6260 else if (unformat (i, "disable"))
6262 else if (unformat (i, "dis"))
6268 if (sw_if_index_set == 0)
6270 errmsg ("missing interface name or sw_if_index");
6274 /* Construct the API message */
6275 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6277 mp->sw_if_index = ntohl (sw_if_index);
6278 mp->enable = enable;
6283 /* Wait for a reply... */
6289 api_sw_interface_set_table (vat_main_t * vam)
6291 unformat_input_t *i = vam->input;
6292 vl_api_sw_interface_set_table_t *mp;
6293 u32 sw_if_index, vrf_id = 0;
6294 u8 sw_if_index_set = 0;
6298 /* Parse args required to build the message */
6299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6301 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6302 sw_if_index_set = 1;
6303 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6304 sw_if_index_set = 1;
6305 else if (unformat (i, "vrf %d", &vrf_id))
6307 else if (unformat (i, "ipv6"))
6313 if (sw_if_index_set == 0)
6315 errmsg ("missing interface name or sw_if_index");
6319 /* Construct the API message */
6320 M (SW_INTERFACE_SET_TABLE, mp);
6322 mp->sw_if_index = ntohl (sw_if_index);
6323 mp->is_ipv6 = is_ipv6;
6324 mp->vrf_id = ntohl (vrf_id);
6329 /* Wait for a reply... */
6334 static void vl_api_sw_interface_get_table_reply_t_handler
6335 (vl_api_sw_interface_get_table_reply_t * mp)
6337 vat_main_t *vam = &vat_main;
6339 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6341 vam->retval = ntohl (mp->retval);
6342 vam->result_ready = 1;
6346 static void vl_api_sw_interface_get_table_reply_t_handler_json
6347 (vl_api_sw_interface_get_table_reply_t * mp)
6349 vat_main_t *vam = &vat_main;
6350 vat_json_node_t node;
6352 vat_json_init_object (&node);
6353 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6354 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6356 vat_json_print (vam->ofp, &node);
6357 vat_json_free (&node);
6359 vam->retval = ntohl (mp->retval);
6360 vam->result_ready = 1;
6364 api_sw_interface_get_table (vat_main_t * vam)
6366 unformat_input_t *i = vam->input;
6367 vl_api_sw_interface_get_table_t *mp;
6369 u8 sw_if_index_set = 0;
6373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6375 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6376 sw_if_index_set = 1;
6377 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6378 sw_if_index_set = 1;
6379 else if (unformat (i, "ipv6"))
6385 if (sw_if_index_set == 0)
6387 errmsg ("missing interface name or sw_if_index");
6391 M (SW_INTERFACE_GET_TABLE, mp);
6392 mp->sw_if_index = htonl (sw_if_index);
6393 mp->is_ipv6 = is_ipv6;
6401 api_sw_interface_set_vpath (vat_main_t * vam)
6403 unformat_input_t *i = vam->input;
6404 vl_api_sw_interface_set_vpath_t *mp;
6405 u32 sw_if_index = 0;
6406 u8 sw_if_index_set = 0;
6410 /* Parse args required to build the message */
6411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6413 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6414 sw_if_index_set = 1;
6415 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6416 sw_if_index_set = 1;
6417 else if (unformat (i, "enable"))
6419 else if (unformat (i, "disable"))
6425 if (sw_if_index_set == 0)
6427 errmsg ("missing interface name or sw_if_index");
6431 /* Construct the API message */
6432 M (SW_INTERFACE_SET_VPATH, mp);
6434 mp->sw_if_index = ntohl (sw_if_index);
6435 mp->enable = is_enable;
6440 /* Wait for a reply... */
6446 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6448 unformat_input_t *i = vam->input;
6449 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6450 u32 sw_if_index = 0;
6451 u8 sw_if_index_set = 0;
6456 /* Parse args required to build the message */
6457 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6459 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6460 sw_if_index_set = 1;
6461 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6462 sw_if_index_set = 1;
6463 else if (unformat (i, "enable"))
6465 else if (unformat (i, "disable"))
6467 else if (unformat (i, "ip4"))
6469 else if (unformat (i, "ip6"))
6475 if (sw_if_index_set == 0)
6477 errmsg ("missing interface name or sw_if_index");
6481 /* Construct the API message */
6482 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6484 mp->sw_if_index = ntohl (sw_if_index);
6485 mp->enable = is_enable;
6486 mp->is_ipv6 = is_ipv6;
6491 /* Wait for a reply... */
6497 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6499 unformat_input_t *i = vam->input;
6500 vl_api_sw_interface_set_geneve_bypass_t *mp;
6501 u32 sw_if_index = 0;
6502 u8 sw_if_index_set = 0;
6507 /* Parse args required to build the message */
6508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6510 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6511 sw_if_index_set = 1;
6512 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6513 sw_if_index_set = 1;
6514 else if (unformat (i, "enable"))
6516 else if (unformat (i, "disable"))
6518 else if (unformat (i, "ip4"))
6520 else if (unformat (i, "ip6"))
6526 if (sw_if_index_set == 0)
6528 errmsg ("missing interface name or sw_if_index");
6532 /* Construct the API message */
6533 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6535 mp->sw_if_index = ntohl (sw_if_index);
6536 mp->enable = is_enable;
6537 mp->is_ipv6 = is_ipv6;
6542 /* Wait for a reply... */
6548 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6550 unformat_input_t *i = vam->input;
6551 vl_api_sw_interface_set_l2_xconnect_t *mp;
6553 u8 rx_sw_if_index_set = 0;
6555 u8 tx_sw_if_index_set = 0;
6559 /* Parse args required to build the message */
6560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6562 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6563 rx_sw_if_index_set = 1;
6564 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6565 tx_sw_if_index_set = 1;
6566 else if (unformat (i, "rx"))
6568 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6570 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6572 rx_sw_if_index_set = 1;
6577 else if (unformat (i, "tx"))
6579 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6581 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6583 tx_sw_if_index_set = 1;
6588 else if (unformat (i, "enable"))
6590 else if (unformat (i, "disable"))
6596 if (rx_sw_if_index_set == 0)
6598 errmsg ("missing rx interface name or rx_sw_if_index");
6602 if (enable && (tx_sw_if_index_set == 0))
6604 errmsg ("missing tx interface name or tx_sw_if_index");
6608 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6610 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6611 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6612 mp->enable = enable;
6620 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6622 unformat_input_t *i = vam->input;
6623 vl_api_sw_interface_set_l2_bridge_t *mp;
6624 vl_api_l2_port_type_t port_type;
6626 u8 rx_sw_if_index_set = 0;
6633 port_type = L2_API_PORT_TYPE_NORMAL;
6635 /* Parse args required to build the message */
6636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6638 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6639 rx_sw_if_index_set = 1;
6640 else if (unformat (i, "bd_id %d", &bd_id))
6644 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6645 rx_sw_if_index_set = 1;
6646 else if (unformat (i, "shg %d", &shg))
6648 else if (unformat (i, "bvi"))
6649 port_type = L2_API_PORT_TYPE_BVI;
6650 else if (unformat (i, "uu-fwd"))
6651 port_type = L2_API_PORT_TYPE_UU_FWD;
6652 else if (unformat (i, "enable"))
6654 else if (unformat (i, "disable"))
6660 if (rx_sw_if_index_set == 0)
6662 errmsg ("missing rx interface name or sw_if_index");
6666 if (enable && (bd_id_set == 0))
6668 errmsg ("missing bridge domain");
6672 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6674 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6675 mp->bd_id = ntohl (bd_id);
6677 mp->port_type = ntohl (port_type);
6678 mp->enable = enable;
6686 api_bridge_domain_dump (vat_main_t * vam)
6688 unformat_input_t *i = vam->input;
6689 vl_api_bridge_domain_dump_t *mp;
6690 vl_api_control_ping_t *mp_ping;
6694 /* Parse args required to build the message */
6695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6697 if (unformat (i, "bd_id %d", &bd_id))
6703 M (BRIDGE_DOMAIN_DUMP, mp);
6704 mp->bd_id = ntohl (bd_id);
6707 /* Use a control ping for synchronization */
6708 MPING (CONTROL_PING, mp_ping);
6716 api_bridge_domain_add_del (vat_main_t * vam)
6718 unformat_input_t *i = vam->input;
6719 vl_api_bridge_domain_add_del_t *mp;
6722 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6727 /* Parse args required to build the message */
6728 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6730 if (unformat (i, "bd_id %d", &bd_id))
6732 else if (unformat (i, "flood %d", &flood))
6734 else if (unformat (i, "uu-flood %d", &uu_flood))
6736 else if (unformat (i, "forward %d", &forward))
6738 else if (unformat (i, "learn %d", &learn))
6740 else if (unformat (i, "arp-term %d", &arp_term))
6742 else if (unformat (i, "mac-age %d", &mac_age))
6744 else if (unformat (i, "bd-tag %s", &bd_tag))
6746 else if (unformat (i, "del"))
6749 flood = uu_flood = forward = learn = 0;
6757 errmsg ("missing bridge domain");
6764 errmsg ("mac age must be less than 256 ");
6769 if ((bd_tag) && (vec_len (bd_tag) > 63))
6771 errmsg ("bd-tag cannot be longer than 63");
6776 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6778 mp->bd_id = ntohl (bd_id);
6780 mp->uu_flood = uu_flood;
6781 mp->forward = forward;
6783 mp->arp_term = arp_term;
6784 mp->is_add = is_add;
6785 mp->mac_age = (u8) mac_age;
6788 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6789 mp->bd_tag[vec_len (bd_tag)] = 0;
6800 api_l2fib_flush_bd (vat_main_t * vam)
6802 unformat_input_t *i = vam->input;
6803 vl_api_l2fib_flush_bd_t *mp;
6807 /* Parse args required to build the message */
6808 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6810 if (unformat (i, "bd_id %d", &bd_id));
6817 errmsg ("missing bridge domain");
6821 M (L2FIB_FLUSH_BD, mp);
6823 mp->bd_id = htonl (bd_id);
6831 api_l2fib_flush_int (vat_main_t * vam)
6833 unformat_input_t *i = vam->input;
6834 vl_api_l2fib_flush_int_t *mp;
6835 u32 sw_if_index = ~0;
6838 /* Parse args required to build the message */
6839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6841 if (unformat (i, "sw_if_index %d", &sw_if_index));
6843 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6848 if (sw_if_index == ~0)
6850 errmsg ("missing interface name or sw_if_index");
6854 M (L2FIB_FLUSH_INT, mp);
6856 mp->sw_if_index = ntohl (sw_if_index);
6864 api_l2fib_add_del (vat_main_t * vam)
6866 unformat_input_t *i = vam->input;
6867 vl_api_l2fib_add_del_t *mp;
6873 u32 sw_if_index = 0;
6874 u8 sw_if_index_set = 0;
6883 /* Parse args required to build the message */
6884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6886 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6888 else if (unformat (i, "bd_id %d", &bd_id))
6890 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6891 sw_if_index_set = 1;
6892 else if (unformat (i, "sw_if"))
6894 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6897 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6898 sw_if_index_set = 1;
6903 else if (unformat (i, "static"))
6905 else if (unformat (i, "filter"))
6910 else if (unformat (i, "bvi"))
6915 else if (unformat (i, "del"))
6917 else if (unformat (i, "count %d", &count))
6925 errmsg ("missing mac address");
6931 errmsg ("missing bridge domain");
6935 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6937 errmsg ("missing interface name or sw_if_index");
6943 /* Turn on async mode */
6944 vam->async_mode = 1;
6945 vam->async_errors = 0;
6946 before = vat_time_now (vam);
6949 for (j = 0; j < count; j++)
6951 M (L2FIB_ADD_DEL, mp);
6953 clib_memcpy (mp->mac, mac, 6);
6954 mp->bd_id = ntohl (bd_id);
6955 mp->is_add = is_add;
6956 mp->sw_if_index = ntohl (sw_if_index);
6960 mp->static_mac = static_mac;
6961 mp->filter_mac = filter_mac;
6962 mp->bvi_mac = bvi_mac;
6964 increment_mac_address (mac);
6971 vl_api_control_ping_t *mp_ping;
6974 /* Shut off async mode */
6975 vam->async_mode = 0;
6977 MPING (CONTROL_PING, mp_ping);
6980 timeout = vat_time_now (vam) + 1.0;
6981 while (vat_time_now (vam) < timeout)
6982 if (vam->result_ready == 1)
6987 if (vam->retval == -99)
6990 if (vam->async_errors > 0)
6992 errmsg ("%d asynchronous errors", vam->async_errors);
6995 vam->async_errors = 0;
6996 after = vat_time_now (vam);
6998 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6999 count, after - before, count / (after - before));
7005 /* Wait for a reply... */
7009 /* Return the good/bad news */
7010 return (vam->retval);
7014 api_bridge_domain_set_mac_age (vat_main_t * vam)
7016 unformat_input_t *i = vam->input;
7017 vl_api_bridge_domain_set_mac_age_t *mp;
7022 /* Parse args required to build the message */
7023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7025 if (unformat (i, "bd_id %d", &bd_id));
7026 else if (unformat (i, "mac-age %d", &mac_age));
7033 errmsg ("missing bridge domain");
7039 errmsg ("mac age must be less than 256 ");
7043 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7045 mp->bd_id = htonl (bd_id);
7046 mp->mac_age = (u8) mac_age;
7054 api_l2_flags (vat_main_t * vam)
7056 unformat_input_t *i = vam->input;
7057 vl_api_l2_flags_t *mp;
7060 u8 sw_if_index_set = 0;
7064 /* Parse args required to build the message */
7065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7067 if (unformat (i, "sw_if_index %d", &sw_if_index))
7068 sw_if_index_set = 1;
7069 else if (unformat (i, "sw_if"))
7071 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7074 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7075 sw_if_index_set = 1;
7080 else if (unformat (i, "learn"))
7082 else if (unformat (i, "forward"))
7084 else if (unformat (i, "flood"))
7086 else if (unformat (i, "uu-flood"))
7087 flags |= L2_UU_FLOOD;
7088 else if (unformat (i, "arp-term"))
7089 flags |= L2_ARP_TERM;
7090 else if (unformat (i, "off"))
7092 else if (unformat (i, "disable"))
7098 if (sw_if_index_set == 0)
7100 errmsg ("missing interface name or sw_if_index");
7106 mp->sw_if_index = ntohl (sw_if_index);
7107 mp->feature_bitmap = ntohl (flags);
7108 mp->is_set = is_set;
7116 api_bridge_flags (vat_main_t * vam)
7118 unformat_input_t *i = vam->input;
7119 vl_api_bridge_flags_t *mp;
7123 bd_flags_t flags = 0;
7126 /* Parse args required to build the message */
7127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7129 if (unformat (i, "bd_id %d", &bd_id))
7131 else if (unformat (i, "learn"))
7132 flags |= BRIDGE_API_FLAG_LEARN;
7133 else if (unformat (i, "forward"))
7134 flags |= BRIDGE_API_FLAG_FWD;
7135 else if (unformat (i, "flood"))
7136 flags |= BRIDGE_API_FLAG_FLOOD;
7137 else if (unformat (i, "uu-flood"))
7138 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7139 else if (unformat (i, "arp-term"))
7140 flags |= BRIDGE_API_FLAG_ARP_TERM;
7141 else if (unformat (i, "off"))
7143 else if (unformat (i, "disable"))
7151 errmsg ("missing bridge domain");
7155 M (BRIDGE_FLAGS, mp);
7157 mp->bd_id = ntohl (bd_id);
7158 mp->flags = ntohl (flags);
7159 mp->is_set = is_set;
7167 api_bd_ip_mac_add_del (vat_main_t * vam)
7169 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7170 vl_api_mac_address_t mac = { 0 };
7171 unformat_input_t *i = vam->input;
7172 vl_api_bd_ip_mac_add_del_t *mp;
7181 /* Parse args required to build the message */
7182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7184 if (unformat (i, "bd_id %d", &bd_id))
7188 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7192 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7196 else if (unformat (i, "del"))
7204 errmsg ("missing bridge domain");
7207 else if (ip_set == 0)
7209 errmsg ("missing IP address");
7212 else if (mac_set == 0)
7214 errmsg ("missing MAC address");
7218 M (BD_IP_MAC_ADD_DEL, mp);
7220 mp->entry.bd_id = ntohl (bd_id);
7221 mp->is_add = is_add;
7223 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7224 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7232 api_bd_ip_mac_flush (vat_main_t * vam)
7234 unformat_input_t *i = vam->input;
7235 vl_api_bd_ip_mac_flush_t *mp;
7240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7242 if (unformat (i, "bd_id %d", &bd_id))
7252 errmsg ("missing bridge domain");
7256 M (BD_IP_MAC_FLUSH, mp);
7258 mp->bd_id = ntohl (bd_id);
7265 static void vl_api_bd_ip_mac_details_t_handler
7266 (vl_api_bd_ip_mac_details_t * mp)
7268 vat_main_t *vam = &vat_main;
7272 ntohl (mp->entry.bd_id),
7273 format_vl_api_mac_address, mp->entry.mac,
7274 format_vl_api_address, &mp->entry.ip);
7277 static void vl_api_bd_ip_mac_details_t_handler_json
7278 (vl_api_bd_ip_mac_details_t * mp)
7280 vat_main_t *vam = &vat_main;
7281 vat_json_node_t *node = NULL;
7283 if (VAT_JSON_ARRAY != vam->json_tree.type)
7285 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7286 vat_json_init_array (&vam->json_tree);
7288 node = vat_json_array_add (&vam->json_tree);
7290 vat_json_init_object (node);
7291 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7292 vat_json_object_add_string_copy (node, "mac_address",
7293 format (0, "%U", format_vl_api_mac_address,
7297 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7298 vat_json_object_add_string_copy (node, "ip_address", ip);
7303 api_bd_ip_mac_dump (vat_main_t * vam)
7305 unformat_input_t *i = vam->input;
7306 vl_api_bd_ip_mac_dump_t *mp;
7307 vl_api_control_ping_t *mp_ping;
7312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7314 if (unformat (i, "bd_id %d", &bd_id))
7323 "\n%-5s %-7s %-20s %-30s",
7324 "bd_id", "is_ipv6", "mac_address", "ip_address");
7326 /* Dump Bridge Domain Ip to Mac entries */
7327 M (BD_IP_MAC_DUMP, mp);
7330 mp->bd_id = htonl (bd_id);
7336 /* Use a control ping for synchronization */
7337 MPING (CONTROL_PING, mp_ping);
7345 api_tap_create_v2 (vat_main_t * vam)
7347 unformat_input_t *i = vam->input;
7348 vl_api_tap_create_v2_t *mp;
7349 #define TAP_FLAG_GSO (1 << 0)
7353 u8 *host_if_name = 0;
7355 u8 host_mac_addr[6];
7356 u8 host_mac_addr_set = 0;
7357 u8 *host_bridge = 0;
7358 ip4_address_t host_ip4_addr;
7359 ip4_address_t host_ip4_gw;
7360 u8 host_ip4_gw_set = 0;
7361 u32 host_ip4_prefix_len = 0;
7362 ip6_address_t host_ip6_addr;
7363 ip6_address_t host_ip6_gw;
7364 u8 host_ip6_gw_set = 0;
7365 u32 host_ip6_prefix_len = 0;
7366 u8 host_mtu_set = 0;
7367 u32 host_mtu_size = 0;
7370 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7372 clib_memset (mac_address, 0, sizeof (mac_address));
7374 /* Parse args required to build the message */
7375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7377 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7381 else if (unformat (i, "id %u", &id))
7383 else if (unformat (i, "host-if-name %s", &host_if_name))
7385 else if (unformat (i, "host-ns %s", &host_ns))
7387 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7389 host_mac_addr_set = 1;
7390 else if (unformat (i, "host-bridge %s", &host_bridge))
7392 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7393 &host_ip4_addr, &host_ip4_prefix_len))
7395 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7396 &host_ip6_addr, &host_ip6_prefix_len))
7398 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7400 host_ip4_gw_set = 1;
7401 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7403 host_ip6_gw_set = 1;
7404 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7406 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7408 else if (unformat (i, "host-mtu-size %d", &host_mtu_size))
7410 else if (unformat (i, "no-gso"))
7411 tap_flags &= ~TAP_FLAG_GSO;
7412 else if (unformat (i, "gso"))
7413 tap_flags |= TAP_FLAG_GSO;
7418 if (vec_len (host_if_name) > 63)
7420 errmsg ("tap name too long. ");
7423 if (vec_len (host_ns) > 63)
7425 errmsg ("host name space too long. ");
7428 if (vec_len (host_bridge) > 63)
7430 errmsg ("host bridge name too long. ");
7433 if (host_ip4_prefix_len > 32)
7435 errmsg ("host ip4 prefix length not valid. ");
7438 if (host_ip6_prefix_len > 128)
7440 errmsg ("host ip6 prefix length not valid. ");
7443 if (!is_pow2 (rx_ring_sz))
7445 errmsg ("rx ring size must be power of 2. ");
7448 if (rx_ring_sz > 32768)
7450 errmsg ("rx ring size must be 32768 or lower. ");
7453 if (!is_pow2 (tx_ring_sz))
7455 errmsg ("tx ring size must be power of 2. ");
7458 if (tx_ring_sz > 32768)
7460 errmsg ("tx ring size must be 32768 or lower. ");
7463 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7465 errmsg ("host MTU size must be in between 64 and 65355. ");
7469 /* Construct the API message */
7470 M (TAP_CREATE_V2, mp);
7472 mp->use_random_mac = random_mac;
7474 mp->id = ntohl (id);
7475 mp->host_namespace_set = host_ns != 0;
7476 mp->host_bridge_set = host_bridge != 0;
7477 mp->host_ip4_prefix_set = host_ip4_prefix_len != 0;
7478 mp->host_ip6_prefix_set = host_ip6_prefix_len != 0;
7479 mp->rx_ring_sz = ntohs (rx_ring_sz);
7480 mp->tx_ring_sz = ntohs (tx_ring_sz);
7481 mp->host_mtu_set = host_mtu_set;
7482 mp->host_mtu_size = ntohl (host_mtu_size);
7483 mp->tap_flags = ntohl (tap_flags);
7485 if (random_mac == 0)
7486 clib_memcpy (mp->mac_address, mac_address, 6);
7487 if (host_mac_addr_set)
7488 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7490 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7492 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7494 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7495 if (host_ip4_prefix_len)
7496 clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
7497 if (host_ip6_prefix_len)
7498 clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
7499 if (host_ip4_gw_set)
7500 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7501 if (host_ip6_gw_set)
7502 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7505 vec_free (host_if_name);
7506 vec_free (host_bridge);
7511 /* Wait for a reply... */
7517 api_tap_delete_v2 (vat_main_t * vam)
7519 unformat_input_t *i = vam->input;
7520 vl_api_tap_delete_v2_t *mp;
7521 u32 sw_if_index = ~0;
7522 u8 sw_if_index_set = 0;
7525 /* Parse args required to build the message */
7526 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7528 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7529 sw_if_index_set = 1;
7530 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7531 sw_if_index_set = 1;
7536 if (sw_if_index_set == 0)
7538 errmsg ("missing vpp interface name. ");
7542 /* Construct the API message */
7543 M (TAP_DELETE_V2, mp);
7545 mp->sw_if_index = ntohl (sw_if_index);
7550 /* Wait for a reply... */
7556 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7558 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7561 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7564 addr->domain = x[0];
7567 addr->function = x[3];
7573 api_virtio_pci_create (vat_main_t * vam)
7575 unformat_input_t *i = vam->input;
7576 vl_api_virtio_pci_create_t *mp;
7581 u64 features = (u64) ~ (0ULL);
7584 clib_memset (mac_address, 0, sizeof (mac_address));
7586 /* Parse args required to build the message */
7587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7589 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7593 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7595 else if (unformat (i, "features 0x%llx", &features))
7597 else if (unformat (i, "gso-enabled"))
7605 errmsg ("pci address must be non zero. ");
7609 /* Construct the API message */
7610 M (VIRTIO_PCI_CREATE, mp);
7612 mp->use_random_mac = random_mac;
7614 mp->pci_addr = htonl (pci_addr);
7615 mp->features = clib_host_to_net_u64 (features);
7616 mp->gso_enabled = gso_enabled;
7618 if (random_mac == 0)
7619 clib_memcpy (mp->mac_address, mac_address, 6);
7624 /* Wait for a reply... */
7630 api_virtio_pci_delete (vat_main_t * vam)
7632 unformat_input_t *i = vam->input;
7633 vl_api_virtio_pci_delete_t *mp;
7634 u32 sw_if_index = ~0;
7635 u8 sw_if_index_set = 0;
7638 /* Parse args required to build the message */
7639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7641 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7642 sw_if_index_set = 1;
7643 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7644 sw_if_index_set = 1;
7649 if (sw_if_index_set == 0)
7651 errmsg ("missing vpp interface name. ");
7655 /* Construct the API message */
7656 M (VIRTIO_PCI_DELETE, mp);
7658 mp->sw_if_index = htonl (sw_if_index);
7663 /* Wait for a reply... */
7669 api_bond_create (vat_main_t * vam)
7671 unformat_input_t *i = vam->input;
7672 vl_api_bond_create_t *mp;
7682 clib_memset (mac_address, 0, sizeof (mac_address));
7685 /* Parse args required to build the message */
7686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7688 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7690 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7691 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7693 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7696 else if (unformat (i, "numa-only"))
7698 else if (unformat (i, "id %u", &id))
7704 if (mode_is_set == 0)
7706 errmsg ("Missing bond mode. ");
7710 /* Construct the API message */
7711 M (BOND_CREATE, mp);
7713 mp->use_custom_mac = custom_mac;
7715 mp->mode = htonl (mode);
7716 mp->lb = htonl (lb);
7717 mp->id = htonl (id);
7718 mp->numa_only = numa_only;
7721 clib_memcpy (mp->mac_address, mac_address, 6);
7726 /* Wait for a reply... */
7732 api_bond_delete (vat_main_t * vam)
7734 unformat_input_t *i = vam->input;
7735 vl_api_bond_delete_t *mp;
7736 u32 sw_if_index = ~0;
7737 u8 sw_if_index_set = 0;
7740 /* Parse args required to build the message */
7741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7743 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7744 sw_if_index_set = 1;
7745 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7746 sw_if_index_set = 1;
7751 if (sw_if_index_set == 0)
7753 errmsg ("missing vpp interface name. ");
7757 /* Construct the API message */
7758 M (BOND_DELETE, mp);
7760 mp->sw_if_index = ntohl (sw_if_index);
7765 /* Wait for a reply... */
7771 api_bond_enslave (vat_main_t * vam)
7773 unformat_input_t *i = vam->input;
7774 vl_api_bond_enslave_t *mp;
7775 u32 bond_sw_if_index;
7779 u32 bond_sw_if_index_is_set = 0;
7781 u8 sw_if_index_is_set = 0;
7783 /* Parse args required to build the message */
7784 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7786 if (unformat (i, "sw_if_index %d", &sw_if_index))
7787 sw_if_index_is_set = 1;
7788 else if (unformat (i, "bond %u", &bond_sw_if_index))
7789 bond_sw_if_index_is_set = 1;
7790 else if (unformat (i, "passive %d", &is_passive))
7792 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7798 if (bond_sw_if_index_is_set == 0)
7800 errmsg ("Missing bond sw_if_index. ");
7803 if (sw_if_index_is_set == 0)
7805 errmsg ("Missing slave sw_if_index. ");
7809 /* Construct the API message */
7810 M (BOND_ENSLAVE, mp);
7812 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7813 mp->sw_if_index = ntohl (sw_if_index);
7814 mp->is_long_timeout = is_long_timeout;
7815 mp->is_passive = is_passive;
7820 /* Wait for a reply... */
7826 api_bond_detach_slave (vat_main_t * vam)
7828 unformat_input_t *i = vam->input;
7829 vl_api_bond_detach_slave_t *mp;
7830 u32 sw_if_index = ~0;
7831 u8 sw_if_index_set = 0;
7834 /* Parse args required to build the message */
7835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7837 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7838 sw_if_index_set = 1;
7839 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7840 sw_if_index_set = 1;
7845 if (sw_if_index_set == 0)
7847 errmsg ("missing vpp interface name. ");
7851 /* Construct the API message */
7852 M (BOND_DETACH_SLAVE, mp);
7854 mp->sw_if_index = ntohl (sw_if_index);
7859 /* Wait for a reply... */
7865 api_ip_table_add_del (vat_main_t * vam)
7867 unformat_input_t *i = vam->input;
7868 vl_api_ip_table_add_del_t *mp;
7874 /* Parse args required to build the message */
7875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7877 if (unformat (i, "ipv6"))
7879 else if (unformat (i, "del"))
7881 else if (unformat (i, "add"))
7883 else if (unformat (i, "table %d", &table_id))
7887 clib_warning ("parse error '%U'", format_unformat_error, i);
7894 errmsg ("missing table-ID");
7898 /* Construct the API message */
7899 M (IP_TABLE_ADD_DEL, mp);
7901 mp->table.table_id = ntohl (table_id);
7902 mp->table.is_ip6 = is_ipv6;
7903 mp->is_add = is_add;
7908 /* Wait for a reply... */
7915 unformat_fib_path (unformat_input_t * input, va_list * args)
7917 vat_main_t *vam = va_arg (*args, vat_main_t *);
7918 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7919 u32 weight, preference;
7920 mpls_label_t out_label;
7922 clib_memset (path, 0, sizeof (*path));
7924 path->sw_if_index = ~0;
7928 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7930 if (unformat (input, "%U %U",
7931 unformat_vl_api_ip4_address,
7932 &path->nh.address.ip4,
7933 api_unformat_sw_if_index, vam, &path->sw_if_index))
7935 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7937 else if (unformat (input, "%U %U",
7938 unformat_vl_api_ip6_address,
7939 &path->nh.address.ip6,
7940 api_unformat_sw_if_index, vam, &path->sw_if_index))
7942 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7944 else if (unformat (input, "weight %u", &weight))
7946 path->weight = weight;
7948 else if (unformat (input, "preference %u", &preference))
7950 path->preference = preference;
7952 else if (unformat (input, "%U next-hop-table %d",
7953 unformat_vl_api_ip4_address,
7954 &path->nh.address.ip4, &path->table_id))
7956 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7958 else if (unformat (input, "%U next-hop-table %d",
7959 unformat_vl_api_ip6_address,
7960 &path->nh.address.ip6, &path->table_id))
7962 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7964 else if (unformat (input, "%U",
7965 unformat_vl_api_ip4_address, &path->nh.address.ip4))
7968 * the recursive next-hops are by default in the default table
7971 path->sw_if_index = ~0;
7972 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7974 else if (unformat (input, "%U",
7975 unformat_vl_api_ip6_address, &path->nh.address.ip6))
7978 * the recursive next-hops are by default in the default table
7981 path->sw_if_index = ~0;
7982 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7984 else if (unformat (input, "resolve-via-host"))
7986 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
7988 else if (unformat (input, "resolve-via-attached"))
7990 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
7992 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
7994 path->type = FIB_API_PATH_TYPE_LOCAL;
7995 path->sw_if_index = ~0;
7996 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7998 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
8000 path->type = FIB_API_PATH_TYPE_LOCAL;
8001 path->sw_if_index = ~0;
8002 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8004 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8006 else if (unformat (input, "via-label %d", &path->nh.via_label))
8008 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8009 path->sw_if_index = ~0;
8011 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8013 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8014 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8016 else if (unformat (input, "local"))
8018 path->type = FIB_API_PATH_TYPE_LOCAL;
8020 else if (unformat (input, "out-labels"))
8022 while (unformat (input, "%d", &out_label))
8024 path->label_stack[path->n_labels].label = out_label;
8025 path->label_stack[path->n_labels].is_uniform = 0;
8026 path->label_stack[path->n_labels].ttl = 64;
8030 else if (unformat (input, "via"))
8032 /* new path, back up and return */
8033 unformat_put_input (input);
8034 unformat_put_input (input);
8035 unformat_put_input (input);
8036 unformat_put_input (input);
8045 path->proto = ntohl (path->proto);
8046 path->type = ntohl (path->type);
8047 path->flags = ntohl (path->flags);
8048 path->table_id = ntohl (path->table_id);
8049 path->sw_if_index = ntohl (path->sw_if_index);
8055 api_ip_route_add_del (vat_main_t * vam)
8057 unformat_input_t *i = vam->input;
8058 vl_api_ip_route_add_del_t *mp;
8061 u8 is_multipath = 0;
8064 vl_api_prefix_t pfx = { };
8065 vl_api_fib_path_t paths[8];
8069 u32 random_add_del = 0;
8070 u32 *random_vector = 0;
8071 u32 random_seed = 0xdeaddabe;
8073 /* Parse args required to build the message */
8074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8076 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8078 else if (unformat (i, "del"))
8080 else if (unformat (i, "add"))
8082 else if (unformat (i, "vrf %d", &vrf_id))
8084 else if (unformat (i, "count %d", &count))
8086 else if (unformat (i, "random"))
8088 else if (unformat (i, "multipath"))
8090 else if (unformat (i, "seed %d", &random_seed))
8094 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8097 if (8 == path_count)
8099 errmsg ("max 8 paths");
8105 clib_warning ("parse error '%U'", format_unformat_error, i);
8112 errmsg ("specify a path; via ...");
8115 if (prefix_set == 0)
8117 errmsg ("missing prefix");
8121 /* Generate a pile of unique, random routes */
8124 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8125 u32 this_random_address;
8128 random_hash = hash_create (count, sizeof (uword));
8130 hash_set (random_hash, i->as_u32, 1);
8131 for (j = 0; j <= count; j++)
8135 this_random_address = random_u32 (&random_seed);
8136 this_random_address =
8137 clib_host_to_net_u32 (this_random_address);
8139 while (hash_get (random_hash, this_random_address));
8140 vec_add1 (random_vector, this_random_address);
8141 hash_set (random_hash, this_random_address, 1);
8143 hash_free (random_hash);
8144 set_ip4_address (&pfx.address, random_vector[0]);
8149 /* Turn on async mode */
8150 vam->async_mode = 1;
8151 vam->async_errors = 0;
8152 before = vat_time_now (vam);
8155 for (j = 0; j < count; j++)
8157 /* Construct the API message */
8158 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8160 mp->is_add = is_add;
8161 mp->is_multipath = is_multipath;
8163 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8164 mp->route.table_id = ntohl (vrf_id);
8165 mp->route.n_paths = path_count;
8167 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8170 set_ip4_address (&pfx.address, random_vector[j + 1]);
8172 increment_address (&pfx.address);
8175 /* If we receive SIGTERM, stop now... */
8180 /* When testing multiple add/del ops, use a control-ping to sync */
8183 vl_api_control_ping_t *mp_ping;
8187 /* Shut off async mode */
8188 vam->async_mode = 0;
8190 MPING (CONTROL_PING, mp_ping);
8193 timeout = vat_time_now (vam) + 1.0;
8194 while (vat_time_now (vam) < timeout)
8195 if (vam->result_ready == 1)
8200 if (vam->retval == -99)
8203 if (vam->async_errors > 0)
8205 errmsg ("%d asynchronous errors", vam->async_errors);
8208 vam->async_errors = 0;
8209 after = vat_time_now (vam);
8211 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8215 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8216 count, after - before, count / (after - before));
8222 /* Wait for a reply... */
8227 /* Return the good/bad news */
8228 return (vam->retval);
8232 api_ip_mroute_add_del (vat_main_t * vam)
8234 unformat_input_t *i = vam->input;
8235 u8 path_set = 0, prefix_set = 0, is_add = 1;
8236 vl_api_ip_mroute_add_del_t *mp;
8237 mfib_entry_flags_t eflags = 0;
8238 vl_api_mfib_path_t path;
8239 vl_api_mprefix_t pfx = { };
8243 /* Parse args required to build the message */
8244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8246 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8249 pfx.grp_address_length = htons (pfx.grp_address_length);
8251 else if (unformat (i, "del"))
8253 else if (unformat (i, "add"))
8255 else if (unformat (i, "vrf %d", &vrf_id))
8257 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8258 path.itf_flags = htonl (path.itf_flags);
8259 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8261 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8265 clib_warning ("parse error '%U'", format_unformat_error, i);
8270 if (prefix_set == 0)
8272 errmsg ("missing addresses\n");
8277 errmsg ("missing path\n");
8281 /* Construct the API message */
8282 M (IP_MROUTE_ADD_DEL, mp);
8284 mp->is_add = is_add;
8285 mp->is_multipath = 1;
8287 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8288 mp->route.table_id = htonl (vrf_id);
8289 mp->route.n_paths = 1;
8290 mp->route.entry_flags = htonl (eflags);
8292 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8296 /* Wait for a reply... */
8302 api_mpls_table_add_del (vat_main_t * vam)
8304 unformat_input_t *i = vam->input;
8305 vl_api_mpls_table_add_del_t *mp;
8310 /* Parse args required to build the message */
8311 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8313 if (unformat (i, "table %d", &table_id))
8315 else if (unformat (i, "del"))
8317 else if (unformat (i, "add"))
8321 clib_warning ("parse error '%U'", format_unformat_error, i);
8328 errmsg ("missing table-ID");
8332 /* Construct the API message */
8333 M (MPLS_TABLE_ADD_DEL, mp);
8335 mp->mt_table.mt_table_id = ntohl (table_id);
8336 mp->mt_is_add = is_add;
8341 /* Wait for a reply... */
8348 api_mpls_route_add_del (vat_main_t * vam)
8350 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8351 mpls_label_t local_label = MPLS_LABEL_INVALID;
8352 unformat_input_t *i = vam->input;
8353 vl_api_mpls_route_add_del_t *mp;
8354 vl_api_fib_path_t paths[8];
8358 /* Parse args required to build the message */
8359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8361 if (unformat (i, "%d", &local_label))
8363 else if (unformat (i, "eos"))
8365 else if (unformat (i, "non-eos"))
8367 else if (unformat (i, "del"))
8369 else if (unformat (i, "add"))
8371 else if (unformat (i, "multipath"))
8373 else if (unformat (i, "count %d", &count))
8377 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8380 if (8 == path_count)
8382 errmsg ("max 8 paths");
8388 clib_warning ("parse error '%U'", format_unformat_error, i);
8395 errmsg ("specify a path; via ...");
8399 if (MPLS_LABEL_INVALID == local_label)
8401 errmsg ("missing label");
8407 /* Turn on async mode */
8408 vam->async_mode = 1;
8409 vam->async_errors = 0;
8410 before = vat_time_now (vam);
8413 for (j = 0; j < count; j++)
8415 /* Construct the API message */
8416 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8418 mp->mr_is_add = is_add;
8419 mp->mr_is_multipath = is_multipath;
8421 mp->mr_route.mr_label = local_label;
8422 mp->mr_route.mr_eos = is_eos;
8423 mp->mr_route.mr_table_id = 0;
8424 mp->mr_route.mr_n_paths = path_count;
8426 clib_memcpy (&mp->mr_route.mr_paths, paths,
8427 sizeof (paths[0]) * path_count);
8433 /* If we receive SIGTERM, stop now... */
8438 /* When testing multiple add/del ops, use a control-ping to sync */
8441 vl_api_control_ping_t *mp_ping;
8445 /* Shut off async mode */
8446 vam->async_mode = 0;
8448 MPING (CONTROL_PING, mp_ping);
8451 timeout = vat_time_now (vam) + 1.0;
8452 while (vat_time_now (vam) < timeout)
8453 if (vam->result_ready == 1)
8458 if (vam->retval == -99)
8461 if (vam->async_errors > 0)
8463 errmsg ("%d asynchronous errors", vam->async_errors);
8466 vam->async_errors = 0;
8467 after = vat_time_now (vam);
8469 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8473 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8474 count, after - before, count / (after - before));
8480 /* Wait for a reply... */
8485 /* Return the good/bad news */
8486 return (vam->retval);
8491 api_mpls_ip_bind_unbind (vat_main_t * vam)
8493 unformat_input_t *i = vam->input;
8494 vl_api_mpls_ip_bind_unbind_t *mp;
8495 u32 ip_table_id = 0;
8497 vl_api_prefix_t pfx;
8499 mpls_label_t local_label = MPLS_LABEL_INVALID;
8502 /* Parse args required to build the message */
8503 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8505 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8507 else if (unformat (i, "%d", &local_label))
8509 else if (unformat (i, "table-id %d", &ip_table_id))
8511 else if (unformat (i, "unbind"))
8513 else if (unformat (i, "bind"))
8517 clib_warning ("parse error '%U'", format_unformat_error, i);
8524 errmsg ("IP prefix not set");
8528 if (MPLS_LABEL_INVALID == local_label)
8530 errmsg ("missing label");
8534 /* Construct the API message */
8535 M (MPLS_IP_BIND_UNBIND, mp);
8537 mp->mb_is_bind = is_bind;
8538 mp->mb_ip_table_id = ntohl (ip_table_id);
8539 mp->mb_mpls_table_id = 0;
8540 mp->mb_label = ntohl (local_label);
8541 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8546 /* Wait for a reply... */
8553 api_sr_mpls_policy_add (vat_main_t * vam)
8555 unformat_input_t *i = vam->input;
8556 vl_api_sr_mpls_policy_add_t *mp;
8562 u32 *segments = NULL;
8565 /* Parse args required to build the message */
8566 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8568 if (unformat (i, "bsid %d", &bsid))
8570 else if (unformat (i, "weight %d", &weight))
8572 else if (unformat (i, "spray"))
8574 else if (unformat (i, "next %d", &sid))
8577 vec_add1 (segments, htonl (sid));
8581 clib_warning ("parse error '%U'", format_unformat_error, i);
8588 errmsg ("bsid not set");
8592 if (n_segments == 0)
8594 errmsg ("no sid in segment stack");
8598 /* Construct the API message */
8599 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8601 mp->bsid = htonl (bsid);
8602 mp->weight = htonl (weight);
8604 mp->n_segments = n_segments;
8605 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8606 vec_free (segments);
8611 /* Wait for a reply... */
8617 api_sr_mpls_policy_del (vat_main_t * vam)
8619 unformat_input_t *i = vam->input;
8620 vl_api_sr_mpls_policy_del_t *mp;
8624 /* Parse args required to build the message */
8625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8627 if (unformat (i, "bsid %d", &bsid))
8631 clib_warning ("parse error '%U'", format_unformat_error, i);
8638 errmsg ("bsid not set");
8642 /* Construct the API message */
8643 M (SR_MPLS_POLICY_DEL, mp);
8645 mp->bsid = htonl (bsid);
8650 /* Wait for a reply... */
8656 api_bier_table_add_del (vat_main_t * vam)
8658 unformat_input_t *i = vam->input;
8659 vl_api_bier_table_add_del_t *mp;
8661 u32 set = 0, sub_domain = 0, hdr_len = 3;
8662 mpls_label_t local_label = MPLS_LABEL_INVALID;
8665 /* Parse args required to build the message */
8666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8668 if (unformat (i, "sub-domain %d", &sub_domain))
8670 else if (unformat (i, "set %d", &set))
8672 else if (unformat (i, "label %d", &local_label))
8674 else if (unformat (i, "hdr-len %d", &hdr_len))
8676 else if (unformat (i, "add"))
8678 else if (unformat (i, "del"))
8682 clib_warning ("parse error '%U'", format_unformat_error, i);
8687 if (MPLS_LABEL_INVALID == local_label)
8689 errmsg ("missing label\n");
8693 /* Construct the API message */
8694 M (BIER_TABLE_ADD_DEL, mp);
8696 mp->bt_is_add = is_add;
8697 mp->bt_label = ntohl (local_label);
8698 mp->bt_tbl_id.bt_set = set;
8699 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8700 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8705 /* Wait for a reply... */
8712 api_bier_route_add_del (vat_main_t * vam)
8714 unformat_input_t *i = vam->input;
8715 vl_api_bier_route_add_del_t *mp;
8717 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8718 ip4_address_t v4_next_hop_address;
8719 ip6_address_t v6_next_hop_address;
8720 u8 next_hop_set = 0;
8721 u8 next_hop_proto_is_ip4 = 1;
8722 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8725 /* Parse args required to build the message */
8726 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8728 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8730 next_hop_proto_is_ip4 = 1;
8733 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8735 next_hop_proto_is_ip4 = 0;
8738 if (unformat (i, "sub-domain %d", &sub_domain))
8740 else if (unformat (i, "set %d", &set))
8742 else if (unformat (i, "hdr-len %d", &hdr_len))
8744 else if (unformat (i, "bp %d", &bp))
8746 else if (unformat (i, "add"))
8748 else if (unformat (i, "del"))
8750 else if (unformat (i, "out-label %d", &next_hop_out_label))
8754 clib_warning ("parse error '%U'", format_unformat_error, i);
8759 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8761 errmsg ("next hop / label set\n");
8766 errmsg ("bit=position not set\n");
8770 /* Construct the API message */
8771 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8773 mp->br_is_add = is_add;
8774 mp->br_route.br_tbl_id.bt_set = set;
8775 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8776 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8777 mp->br_route.br_bp = ntohs (bp);
8778 mp->br_route.br_n_paths = 1;
8779 mp->br_route.br_paths[0].n_labels = 1;
8780 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8781 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8782 FIB_API_PATH_NH_PROTO_IP4 :
8783 FIB_API_PATH_NH_PROTO_IP6);
8785 if (next_hop_proto_is_ip4)
8787 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8788 &v4_next_hop_address, sizeof (v4_next_hop_address));
8792 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8793 &v6_next_hop_address, sizeof (v6_next_hop_address));
8799 /* Wait for a reply... */
8806 api_proxy_arp_add_del (vat_main_t * vam)
8808 unformat_input_t *i = vam->input;
8809 vl_api_proxy_arp_add_del_t *mp;
8812 vl_api_ip4_address_t lo, hi;
8816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8818 if (unformat (i, "vrf %d", &vrf_id))
8820 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
8821 unformat_vl_api_ip4_address, &hi))
8823 else if (unformat (i, "del"))
8827 clib_warning ("parse error '%U'", format_unformat_error, i);
8834 errmsg ("address range not set");
8838 M (PROXY_ARP_ADD_DEL, mp);
8840 mp->proxy.table_id = ntohl (vrf_id);
8841 mp->is_add = is_add;
8842 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
8843 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
8851 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8853 unformat_input_t *i = vam->input;
8854 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8857 u8 sw_if_index_set = 0;
8860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8862 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8863 sw_if_index_set = 1;
8864 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8865 sw_if_index_set = 1;
8866 else if (unformat (i, "enable"))
8868 else if (unformat (i, "disable"))
8872 clib_warning ("parse error '%U'", format_unformat_error, i);
8877 if (sw_if_index_set == 0)
8879 errmsg ("missing interface name or sw_if_index");
8883 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8885 mp->sw_if_index = ntohl (sw_if_index);
8886 mp->enable_disable = enable;
8894 api_mpls_tunnel_add_del (vat_main_t * vam)
8896 unformat_input_t *i = vam->input;
8897 vl_api_mpls_tunnel_add_del_t *mp;
8899 vl_api_fib_path_t paths[8];
8900 u32 sw_if_index = ~0;
8906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8908 if (unformat (i, "add"))
8912 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8914 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8916 else if (unformat (i, "l2-only"))
8920 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8923 if (8 == path_count)
8925 errmsg ("max 8 paths");
8931 clib_warning ("parse error '%U'", format_unformat_error, i);
8936 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8938 mp->mt_is_add = is_add;
8939 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8940 mp->mt_tunnel.mt_l2_only = l2_only;
8941 mp->mt_tunnel.mt_is_multicast = 0;
8942 mp->mt_tunnel.mt_n_paths = path_count;
8944 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8945 sizeof (paths[0]) * path_count);
8953 api_sw_interface_set_unnumbered (vat_main_t * vam)
8955 unformat_input_t *i = vam->input;
8956 vl_api_sw_interface_set_unnumbered_t *mp;
8958 u32 unnum_sw_index = ~0;
8960 u8 sw_if_index_set = 0;
8963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8965 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8966 sw_if_index_set = 1;
8967 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8968 sw_if_index_set = 1;
8969 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8971 else if (unformat (i, "del"))
8975 clib_warning ("parse error '%U'", format_unformat_error, i);
8980 if (sw_if_index_set == 0)
8982 errmsg ("missing interface name or sw_if_index");
8986 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8988 mp->sw_if_index = ntohl (sw_if_index);
8989 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8990 mp->is_add = is_add;
8998 api_ip_neighbor_add_del (vat_main_t * vam)
9000 vl_api_mac_address_t mac_address;
9001 unformat_input_t *i = vam->input;
9002 vl_api_ip_neighbor_add_del_t *mp;
9003 vl_api_address_t ip_address;
9005 u8 sw_if_index_set = 0;
9010 ip_neighbor_flags_t flags;
9012 flags = IP_NEIGHBOR_FLAG_NONE;
9013 clib_memset (&ip_address, 0, sizeof (ip_address));
9014 clib_memset (&mac_address, 0, sizeof (mac_address));
9016 /* Parse args required to build the message */
9017 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9019 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9023 else if (unformat (i, "del"))
9026 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9027 sw_if_index_set = 1;
9028 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9029 sw_if_index_set = 1;
9030 else if (unformat (i, "static"))
9031 flags |= IP_NEIGHBOR_FLAG_STATIC;
9032 else if (unformat (i, "no-fib-entry"))
9033 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9034 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9038 clib_warning ("parse error '%U'", format_unformat_error, i);
9043 if (sw_if_index_set == 0)
9045 errmsg ("missing interface name or sw_if_index");
9050 errmsg ("no address set");
9054 /* Construct the API message */
9055 M (IP_NEIGHBOR_ADD_DEL, mp);
9057 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9058 mp->is_add = is_add;
9059 mp->neighbor.flags = htonl (flags);
9061 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9062 sizeof (mac_address));
9064 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9069 /* Wait for a reply, return good/bad news */
9075 api_create_vlan_subif (vat_main_t * vam)
9077 unformat_input_t *i = vam->input;
9078 vl_api_create_vlan_subif_t *mp;
9080 u8 sw_if_index_set = 0;
9085 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9087 if (unformat (i, "sw_if_index %d", &sw_if_index))
9088 sw_if_index_set = 1;
9090 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9091 sw_if_index_set = 1;
9092 else if (unformat (i, "vlan %d", &vlan_id))
9096 clib_warning ("parse error '%U'", format_unformat_error, i);
9101 if (sw_if_index_set == 0)
9103 errmsg ("missing interface name or sw_if_index");
9107 if (vlan_id_set == 0)
9109 errmsg ("missing vlan_id");
9112 M (CREATE_VLAN_SUBIF, mp);
9114 mp->sw_if_index = ntohl (sw_if_index);
9115 mp->vlan_id = ntohl (vlan_id);
9122 #define foreach_create_subif_bit \
9129 _(outer_vlan_id_any) \
9130 _(inner_vlan_id_any)
9132 #define foreach_create_subif_flag \
9137 _(4, "exact_match") \
9138 _(5, "default_sub") \
9139 _(6, "outer_vlan_id_any") \
9140 _(7, "inner_vlan_id_any")
9143 api_create_subif (vat_main_t * vam)
9145 unformat_input_t *i = vam->input;
9146 vl_api_create_subif_t *mp;
9148 u8 sw_if_index_set = 0;
9151 u32 __attribute__ ((unused)) no_tags = 0;
9152 u32 __attribute__ ((unused)) one_tag = 0;
9153 u32 __attribute__ ((unused)) two_tags = 0;
9154 u32 __attribute__ ((unused)) dot1ad = 0;
9155 u32 __attribute__ ((unused)) exact_match = 0;
9156 u32 __attribute__ ((unused)) default_sub = 0;
9157 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
9158 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
9160 u16 outer_vlan_id = 0;
9161 u16 inner_vlan_id = 0;
9164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9166 if (unformat (i, "sw_if_index %d", &sw_if_index))
9167 sw_if_index_set = 1;
9169 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9170 sw_if_index_set = 1;
9171 else if (unformat (i, "sub_id %d", &sub_id))
9173 else if (unformat (i, "outer_vlan_id %d", &tmp))
9174 outer_vlan_id = tmp;
9175 else if (unformat (i, "inner_vlan_id %d", &tmp))
9176 inner_vlan_id = tmp;
9178 #define _(a) else if (unformat (i, #a)) a = 1 ;
9179 foreach_create_subif_bit
9183 clib_warning ("parse error '%U'", format_unformat_error, i);
9188 if (sw_if_index_set == 0)
9190 errmsg ("missing interface name or sw_if_index");
9194 if (sub_id_set == 0)
9196 errmsg ("missing sub_id");
9199 M (CREATE_SUBIF, mp);
9201 mp->sw_if_index = ntohl (sw_if_index);
9202 mp->sub_id = ntohl (sub_id);
9204 #define _(a,b) mp->sub_if_flags |= (1 << a);
9205 foreach_create_subif_flag;
9208 mp->outer_vlan_id = ntohs (outer_vlan_id);
9209 mp->inner_vlan_id = ntohs (inner_vlan_id);
9217 api_ip_table_replace_begin (vat_main_t * vam)
9219 unformat_input_t *i = vam->input;
9220 vl_api_ip_table_replace_begin_t *mp;
9225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9227 if (unformat (i, "table %d", &table_id))
9229 else if (unformat (i, "ipv6"))
9233 clib_warning ("parse error '%U'", format_unformat_error, i);
9238 M (IP_TABLE_REPLACE_BEGIN, mp);
9240 mp->table.table_id = ntohl (table_id);
9241 mp->table.is_ip6 = is_ipv6;
9249 api_ip_table_flush (vat_main_t * vam)
9251 unformat_input_t *i = vam->input;
9252 vl_api_ip_table_flush_t *mp;
9257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9259 if (unformat (i, "table %d", &table_id))
9261 else if (unformat (i, "ipv6"))
9265 clib_warning ("parse error '%U'", format_unformat_error, i);
9270 M (IP_TABLE_FLUSH, mp);
9272 mp->table.table_id = ntohl (table_id);
9273 mp->table.is_ip6 = is_ipv6;
9281 api_ip_table_replace_end (vat_main_t * vam)
9283 unformat_input_t *i = vam->input;
9284 vl_api_ip_table_replace_end_t *mp;
9289 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9291 if (unformat (i, "table %d", &table_id))
9293 else if (unformat (i, "ipv6"))
9297 clib_warning ("parse error '%U'", format_unformat_error, i);
9302 M (IP_TABLE_REPLACE_END, mp);
9304 mp->table.table_id = ntohl (table_id);
9305 mp->table.is_ip6 = is_ipv6;
9313 api_set_ip_flow_hash (vat_main_t * vam)
9315 unformat_input_t *i = vam->input;
9316 vl_api_set_ip_flow_hash_t *mp;
9328 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9330 if (unformat (i, "vrf %d", &vrf_id))
9332 else if (unformat (i, "ipv6"))
9334 else if (unformat (i, "src"))
9336 else if (unformat (i, "dst"))
9338 else if (unformat (i, "sport"))
9340 else if (unformat (i, "dport"))
9342 else if (unformat (i, "proto"))
9344 else if (unformat (i, "reverse"))
9349 clib_warning ("parse error '%U'", format_unformat_error, i);
9354 if (vrf_id_set == 0)
9356 errmsg ("missing vrf id");
9360 M (SET_IP_FLOW_HASH, mp);
9366 mp->reverse = reverse;
9367 mp->vrf_id = ntohl (vrf_id);
9368 mp->is_ipv6 = is_ipv6;
9376 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9378 unformat_input_t *i = vam->input;
9379 vl_api_sw_interface_ip6_enable_disable_t *mp;
9381 u8 sw_if_index_set = 0;
9385 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9387 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9388 sw_if_index_set = 1;
9389 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9390 sw_if_index_set = 1;
9391 else if (unformat (i, "enable"))
9393 else if (unformat (i, "disable"))
9397 clib_warning ("parse error '%U'", format_unformat_error, i);
9402 if (sw_if_index_set == 0)
9404 errmsg ("missing interface name or sw_if_index");
9408 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9410 mp->sw_if_index = ntohl (sw_if_index);
9411 mp->enable = enable;
9419 api_ip6nd_proxy_add_del (vat_main_t * vam)
9421 unformat_input_t *i = vam->input;
9422 vl_api_ip6nd_proxy_add_del_t *mp;
9423 u32 sw_if_index = ~0;
9424 u8 v6_address_set = 0;
9425 vl_api_ip6_address_t v6address;
9429 /* Parse args required to build the message */
9430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9432 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9434 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9436 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
9438 if (unformat (i, "del"))
9442 clib_warning ("parse error '%U'", format_unformat_error, i);
9447 if (sw_if_index == ~0)
9449 errmsg ("missing interface name or sw_if_index");
9452 if (!v6_address_set)
9454 errmsg ("no address set");
9458 /* Construct the API message */
9459 M (IP6ND_PROXY_ADD_DEL, mp);
9461 mp->is_del = is_del;
9462 mp->sw_if_index = ntohl (sw_if_index);
9463 clib_memcpy (mp->ip, v6address, sizeof (v6address));
9468 /* Wait for a reply, return good/bad news */
9474 api_ip6nd_proxy_dump (vat_main_t * vam)
9476 vl_api_ip6nd_proxy_dump_t *mp;
9477 vl_api_control_ping_t *mp_ping;
9480 M (IP6ND_PROXY_DUMP, mp);
9484 /* Use a control ping for synchronization */
9485 MPING (CONTROL_PING, mp_ping);
9492 static void vl_api_ip6nd_proxy_details_t_handler
9493 (vl_api_ip6nd_proxy_details_t * mp)
9495 vat_main_t *vam = &vat_main;
9497 print (vam->ofp, "host %U sw_if_index %d",
9498 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
9501 static void vl_api_ip6nd_proxy_details_t_handler_json
9502 (vl_api_ip6nd_proxy_details_t * mp)
9504 vat_main_t *vam = &vat_main;
9505 struct in6_addr ip6;
9506 vat_json_node_t *node = NULL;
9508 if (VAT_JSON_ARRAY != vam->json_tree.type)
9510 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9511 vat_json_init_array (&vam->json_tree);
9513 node = vat_json_array_add (&vam->json_tree);
9515 vat_json_init_object (node);
9516 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9518 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
9519 vat_json_object_add_ip6 (node, "host", ip6);
9523 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9525 unformat_input_t *i = vam->input;
9526 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9528 u8 sw_if_index_set = 0;
9529 u8 v6_address_set = 0;
9530 vl_api_prefix_t pfx;
9532 u8 no_advertise = 0;
9534 u8 no_autoconfig = 0;
9537 u32 val_lifetime = 0;
9538 u32 pref_lifetime = 0;
9541 /* Parse args required to build the message */
9542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9544 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9545 sw_if_index_set = 1;
9546 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9547 sw_if_index_set = 1;
9548 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
9550 else if (unformat (i, "val_life %d", &val_lifetime))
9552 else if (unformat (i, "pref_life %d", &pref_lifetime))
9554 else if (unformat (i, "def"))
9556 else if (unformat (i, "noadv"))
9558 else if (unformat (i, "offl"))
9560 else if (unformat (i, "noauto"))
9562 else if (unformat (i, "nolink"))
9564 else if (unformat (i, "isno"))
9568 clib_warning ("parse error '%U'", format_unformat_error, i);
9573 if (sw_if_index_set == 0)
9575 errmsg ("missing interface name or sw_if_index");
9578 if (!v6_address_set)
9580 errmsg ("no address set");
9584 /* Construct the API message */
9585 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9587 mp->sw_if_index = ntohl (sw_if_index);
9588 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
9589 mp->use_default = use_default;
9590 mp->no_advertise = no_advertise;
9591 mp->off_link = off_link;
9592 mp->no_autoconfig = no_autoconfig;
9593 mp->no_onlink = no_onlink;
9595 mp->val_lifetime = ntohl (val_lifetime);
9596 mp->pref_lifetime = ntohl (pref_lifetime);
9601 /* Wait for a reply, return good/bad news */
9607 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9609 unformat_input_t *i = vam->input;
9610 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9612 u8 sw_if_index_set = 0;
9617 u8 send_unicast = 0;
9620 u8 default_router = 0;
9621 u32 max_interval = 0;
9622 u32 min_interval = 0;
9624 u32 initial_count = 0;
9625 u32 initial_interval = 0;
9629 /* Parse args required to build the message */
9630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9632 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9633 sw_if_index_set = 1;
9634 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9635 sw_if_index_set = 1;
9636 else if (unformat (i, "maxint %d", &max_interval))
9638 else if (unformat (i, "minint %d", &min_interval))
9640 else if (unformat (i, "life %d", &lifetime))
9642 else if (unformat (i, "count %d", &initial_count))
9644 else if (unformat (i, "interval %d", &initial_interval))
9646 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9648 else if (unformat (i, "managed"))
9650 else if (unformat (i, "other"))
9652 else if (unformat (i, "ll"))
9654 else if (unformat (i, "send"))
9656 else if (unformat (i, "cease"))
9658 else if (unformat (i, "isno"))
9660 else if (unformat (i, "def"))
9664 clib_warning ("parse error '%U'", format_unformat_error, i);
9669 if (sw_if_index_set == 0)
9671 errmsg ("missing interface name or sw_if_index");
9675 /* Construct the API message */
9676 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9678 mp->sw_if_index = ntohl (sw_if_index);
9679 mp->max_interval = ntohl (max_interval);
9680 mp->min_interval = ntohl (min_interval);
9681 mp->lifetime = ntohl (lifetime);
9682 mp->initial_count = ntohl (initial_count);
9683 mp->initial_interval = ntohl (initial_interval);
9684 mp->suppress = suppress;
9685 mp->managed = managed;
9687 mp->ll_option = ll_option;
9688 mp->send_unicast = send_unicast;
9691 mp->default_router = default_router;
9696 /* Wait for a reply, return good/bad news */
9702 api_set_arp_neighbor_limit (vat_main_t * vam)
9704 unformat_input_t *i = vam->input;
9705 vl_api_set_arp_neighbor_limit_t *mp;
9711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9713 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9715 else if (unformat (i, "ipv6"))
9719 clib_warning ("parse error '%U'", format_unformat_error, i);
9726 errmsg ("missing limit value");
9730 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9732 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9733 mp->is_ipv6 = is_ipv6;
9741 api_l2_patch_add_del (vat_main_t * vam)
9743 unformat_input_t *i = vam->input;
9744 vl_api_l2_patch_add_del_t *mp;
9746 u8 rx_sw_if_index_set = 0;
9748 u8 tx_sw_if_index_set = 0;
9752 /* Parse args required to build the message */
9753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9755 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9756 rx_sw_if_index_set = 1;
9757 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9758 tx_sw_if_index_set = 1;
9759 else if (unformat (i, "rx"))
9761 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9763 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9765 rx_sw_if_index_set = 1;
9770 else if (unformat (i, "tx"))
9772 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9774 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9776 tx_sw_if_index_set = 1;
9781 else if (unformat (i, "del"))
9787 if (rx_sw_if_index_set == 0)
9789 errmsg ("missing rx interface name or rx_sw_if_index");
9793 if (tx_sw_if_index_set == 0)
9795 errmsg ("missing tx interface name or tx_sw_if_index");
9799 M (L2_PATCH_ADD_DEL, mp);
9801 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9802 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9803 mp->is_add = is_add;
9811 u8 localsid_addr[16];
9820 api_sr_localsid_add_del (vat_main_t * vam)
9822 unformat_input_t *i = vam->input;
9823 vl_api_sr_localsid_add_del_t *mp;
9826 ip6_address_t localsid;
9830 u32 fib_table = ~(u32) 0;
9831 ip6_address_t nh_addr6;
9832 ip4_address_t nh_addr4;
9833 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
9834 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
9836 bool nexthop_set = 0;
9840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9842 if (unformat (i, "del"))
9844 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9845 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
9847 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
9849 else if (unformat (i, "behavior %u", &behavior));
9850 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9851 else if (unformat (i, "fib-table %u", &fib_table));
9852 else if (unformat (i, "end.psp %u", &behavior));
9857 M (SR_LOCALSID_ADD_DEL, mp);
9859 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
9863 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
9864 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
9866 mp->behavior = behavior;
9867 mp->sw_if_index = ntohl (sw_if_index);
9868 mp->fib_table = ntohl (fib_table);
9869 mp->end_psp = end_psp;
9870 mp->is_del = is_del;
9878 api_ioam_enable (vat_main_t * vam)
9880 unformat_input_t *input = vam->input;
9881 vl_api_ioam_enable_t *mp;
9883 int has_trace_option = 0;
9884 int has_pot_option = 0;
9885 int has_seqno_option = 0;
9886 int has_analyse_option = 0;
9889 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9891 if (unformat (input, "trace"))
9892 has_trace_option = 1;
9893 else if (unformat (input, "pot"))
9895 else if (unformat (input, "seqno"))
9896 has_seqno_option = 1;
9897 else if (unformat (input, "analyse"))
9898 has_analyse_option = 1;
9902 M (IOAM_ENABLE, mp);
9903 mp->id = htons (id);
9904 mp->seqno = has_seqno_option;
9905 mp->analyse = has_analyse_option;
9906 mp->pot_enable = has_pot_option;
9907 mp->trace_enable = has_trace_option;
9916 api_ioam_disable (vat_main_t * vam)
9918 vl_api_ioam_disable_t *mp;
9921 M (IOAM_DISABLE, mp);
9927 #define foreach_tcp_proto_field \
9931 #define foreach_udp_proto_field \
9935 #define foreach_ip4_proto_field \
9947 u16 src_port, dst_port;
9950 #if VPP_API_TEST_BUILTIN == 0
9952 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9954 u8 **maskp = va_arg (*args, u8 **);
9956 u8 found_something = 0;
9959 #define _(a) u8 a=0;
9960 foreach_tcp_proto_field;
9963 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9966 #define _(a) else if (unformat (input, #a)) a=1;
9967 foreach_tcp_proto_field
9973 #define _(a) found_something += a;
9974 foreach_tcp_proto_field;
9977 if (found_something == 0)
9980 vec_validate (mask, sizeof (*tcp) - 1);
9982 tcp = (tcp_header_t *) mask;
9984 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
9985 foreach_tcp_proto_field;
9993 unformat_udp_mask (unformat_input_t * input, va_list * args)
9995 u8 **maskp = va_arg (*args, u8 **);
9997 u8 found_something = 0;
10000 #define _(a) u8 a=0;
10001 foreach_udp_proto_field;
10004 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10007 #define _(a) else if (unformat (input, #a)) a=1;
10008 foreach_udp_proto_field
10014 #define _(a) found_something += a;
10015 foreach_udp_proto_field;
10018 if (found_something == 0)
10021 vec_validate (mask, sizeof (*udp) - 1);
10023 udp = (udp_header_t *) mask;
10025 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10026 foreach_udp_proto_field;
10034 unformat_l4_mask (unformat_input_t * input, va_list * args)
10036 u8 **maskp = va_arg (*args, u8 **);
10037 u16 src_port = 0, dst_port = 0;
10038 tcpudp_header_t *tcpudp;
10040 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10042 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10044 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10046 else if (unformat (input, "src_port"))
10048 else if (unformat (input, "dst_port"))
10054 if (!src_port && !dst_port)
10058 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10060 tcpudp = (tcpudp_header_t *) mask;
10061 tcpudp->src_port = src_port;
10062 tcpudp->dst_port = dst_port;
10070 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10072 u8 **maskp = va_arg (*args, u8 **);
10074 u8 found_something = 0;
10077 #define _(a) u8 a=0;
10078 foreach_ip4_proto_field;
10084 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10086 if (unformat (input, "version"))
10088 else if (unformat (input, "hdr_length"))
10090 else if (unformat (input, "src"))
10092 else if (unformat (input, "dst"))
10094 else if (unformat (input, "proto"))
10097 #define _(a) else if (unformat (input, #a)) a=1;
10098 foreach_ip4_proto_field
10104 #define _(a) found_something += a;
10105 foreach_ip4_proto_field;
10108 if (found_something == 0)
10111 vec_validate (mask, sizeof (*ip) - 1);
10113 ip = (ip4_header_t *) mask;
10115 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10116 foreach_ip4_proto_field;
10119 ip->ip_version_and_header_length = 0;
10122 ip->ip_version_and_header_length |= 0xF0;
10125 ip->ip_version_and_header_length |= 0x0F;
10131 #define foreach_ip6_proto_field \
10134 _(payload_length) \
10139 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10141 u8 **maskp = va_arg (*args, u8 **);
10143 u8 found_something = 0;
10145 u32 ip_version_traffic_class_and_flow_label;
10147 #define _(a) u8 a=0;
10148 foreach_ip6_proto_field;
10151 u8 traffic_class = 0;
10154 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10156 if (unformat (input, "version"))
10158 else if (unformat (input, "traffic-class"))
10160 else if (unformat (input, "flow-label"))
10162 else if (unformat (input, "src"))
10164 else if (unformat (input, "dst"))
10166 else if (unformat (input, "proto"))
10169 #define _(a) else if (unformat (input, #a)) a=1;
10170 foreach_ip6_proto_field
10176 #define _(a) found_something += a;
10177 foreach_ip6_proto_field;
10180 if (found_something == 0)
10183 vec_validate (mask, sizeof (*ip) - 1);
10185 ip = (ip6_header_t *) mask;
10187 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10188 foreach_ip6_proto_field;
10191 ip_version_traffic_class_and_flow_label = 0;
10194 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10197 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10200 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10202 ip->ip_version_traffic_class_and_flow_label =
10203 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10210 unformat_l3_mask (unformat_input_t * input, va_list * args)
10212 u8 **maskp = va_arg (*args, u8 **);
10214 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10216 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10218 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10227 unformat_l2_mask (unformat_input_t * input, va_list * args)
10229 u8 **maskp = va_arg (*args, u8 **);
10236 u8 ignore_tag1 = 0;
10237 u8 ignore_tag2 = 0;
10244 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10246 if (unformat (input, "src"))
10248 else if (unformat (input, "dst"))
10250 else if (unformat (input, "proto"))
10252 else if (unformat (input, "tag1"))
10254 else if (unformat (input, "tag2"))
10256 else if (unformat (input, "ignore-tag1"))
10258 else if (unformat (input, "ignore-tag2"))
10260 else if (unformat (input, "cos1"))
10262 else if (unformat (input, "cos2"))
10264 else if (unformat (input, "dot1q"))
10266 else if (unformat (input, "dot1ad"))
10271 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10272 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10275 if (tag1 || ignore_tag1 || cos1 || dot1q)
10277 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10280 vec_validate (mask, len - 1);
10283 clib_memset (mask, 0xff, 6);
10286 clib_memset (mask + 6, 0xff, 6);
10288 if (tag2 || dot1ad)
10290 /* inner vlan tag */
10299 mask[21] = mask[20] = 0xff;
10320 mask[16] = mask[17] = 0xff;
10330 mask[12] = mask[13] = 0xff;
10337 unformat_classify_mask (unformat_input_t * input, va_list * args)
10339 u8 **maskp = va_arg (*args, u8 **);
10340 u32 *skipp = va_arg (*args, u32 *);
10341 u32 *matchp = va_arg (*args, u32 *);
10349 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10351 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10353 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10355 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10357 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10371 if (mask || l2 || l3 || l4)
10373 if (l2 || l3 || l4)
10375 /* "With a free Ethernet header in every package" */
10377 vec_validate (l2, 13);
10381 vec_append (mask, l3);
10386 vec_append (mask, l4);
10391 /* Scan forward looking for the first significant mask octet */
10392 for (i = 0; i < vec_len (mask); i++)
10396 /* compute (skip, match) params */
10397 *skipp = i / sizeof (u32x4);
10398 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10400 /* Pad mask to an even multiple of the vector size */
10401 while (vec_len (mask) % sizeof (u32x4))
10402 vec_add1 (mask, 0);
10404 match = vec_len (mask) / sizeof (u32x4);
10406 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10408 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10409 if (*tmp || *(tmp + 1))
10414 clib_warning ("BUG: match 0");
10416 _vec_len (mask) = match * sizeof (u32x4);
10426 #endif /* VPP_API_TEST_BUILTIN */
10428 #define foreach_l2_next \
10430 _(ethernet, ETHERNET_INPUT) \
10431 _(ip4, IP4_INPUT) \
10435 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10437 u32 *miss_next_indexp = va_arg (*args, u32 *);
10438 u32 next_index = 0;
10442 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10446 if (unformat (input, "%d", &tmp))
10455 *miss_next_indexp = next_index;
10459 #define foreach_ip_next \
10462 _(rewrite, REWRITE)
10465 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10467 u32 *miss_next_indexp = va_arg (*args, u32 *);
10468 u32 next_index = 0;
10472 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10476 if (unformat (input, "%d", &tmp))
10485 *miss_next_indexp = next_index;
10489 #define foreach_acl_next \
10493 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10495 u32 *miss_next_indexp = va_arg (*args, u32 *);
10496 u32 next_index = 0;
10500 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10504 if (unformat (input, "permit"))
10509 else if (unformat (input, "%d", &tmp))
10518 *miss_next_indexp = next_index;
10523 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10525 u32 *r = va_arg (*args, u32 *);
10527 if (unformat (input, "conform-color"))
10528 *r = POLICE_CONFORM;
10529 else if (unformat (input, "exceed-color"))
10530 *r = POLICE_EXCEED;
10538 api_classify_add_del_table (vat_main_t * vam)
10540 unformat_input_t *i = vam->input;
10541 vl_api_classify_add_del_table_t *mp;
10548 u32 table_index = ~0;
10549 u32 next_table_index = ~0;
10550 u32 miss_next_index = ~0;
10551 u32 memory_size = 32 << 20;
10553 u32 current_data_flag = 0;
10554 int current_data_offset = 0;
10557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10559 if (unformat (i, "del"))
10561 else if (unformat (i, "del-chain"))
10566 else if (unformat (i, "buckets %d", &nbuckets))
10568 else if (unformat (i, "memory_size %d", &memory_size))
10570 else if (unformat (i, "skip %d", &skip))
10572 else if (unformat (i, "match %d", &match))
10574 else if (unformat (i, "table %d", &table_index))
10576 else if (unformat (i, "mask %U", unformat_classify_mask,
10577 &mask, &skip, &match))
10579 else if (unformat (i, "next-table %d", &next_table_index))
10581 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10584 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10587 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10590 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10592 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10598 if (is_add && mask == 0)
10600 errmsg ("Mask required");
10604 if (is_add && skip == ~0)
10606 errmsg ("skip count required");
10610 if (is_add && match == ~0)
10612 errmsg ("match count required");
10616 if (!is_add && table_index == ~0)
10618 errmsg ("table index required for delete");
10622 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10624 mp->is_add = is_add;
10625 mp->del_chain = del_chain;
10626 mp->table_index = ntohl (table_index);
10627 mp->nbuckets = ntohl (nbuckets);
10628 mp->memory_size = ntohl (memory_size);
10629 mp->skip_n_vectors = ntohl (skip);
10630 mp->match_n_vectors = ntohl (match);
10631 mp->next_table_index = ntohl (next_table_index);
10632 mp->miss_next_index = ntohl (miss_next_index);
10633 mp->current_data_flag = ntohl (current_data_flag);
10634 mp->current_data_offset = ntohl (current_data_offset);
10635 mp->mask_len = ntohl (vec_len (mask));
10636 clib_memcpy (mp->mask, mask, vec_len (mask));
10645 #if VPP_API_TEST_BUILTIN == 0
10647 unformat_l4_match (unformat_input_t * input, va_list * args)
10649 u8 **matchp = va_arg (*args, u8 **);
10651 u8 *proto_header = 0;
10657 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10659 if (unformat (input, "src_port %d", &src_port))
10661 else if (unformat (input, "dst_port %d", &dst_port))
10667 h.src_port = clib_host_to_net_u16 (src_port);
10668 h.dst_port = clib_host_to_net_u16 (dst_port);
10669 vec_validate (proto_header, sizeof (h) - 1);
10670 memcpy (proto_header, &h, sizeof (h));
10672 *matchp = proto_header;
10678 unformat_ip4_match (unformat_input_t * input, va_list * args)
10680 u8 **matchp = va_arg (*args, u8 **);
10685 int hdr_length = 0;
10686 u32 hdr_length_val;
10687 int src = 0, dst = 0;
10688 ip4_address_t src_val, dst_val;
10695 int fragment_id = 0;
10696 u32 fragment_id_val;
10702 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10704 if (unformat (input, "version %d", &version_val))
10706 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10708 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10710 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10712 else if (unformat (input, "proto %d", &proto_val))
10714 else if (unformat (input, "tos %d", &tos_val))
10716 else if (unformat (input, "length %d", &length_val))
10718 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10720 else if (unformat (input, "ttl %d", &ttl_val))
10722 else if (unformat (input, "checksum %d", &checksum_val))
10728 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10729 + ttl + checksum == 0)
10733 * Aligned because we use the real comparison functions
10735 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10737 ip = (ip4_header_t *) match;
10739 /* These are realistically matched in practice */
10741 ip->src_address.as_u32 = src_val.as_u32;
10744 ip->dst_address.as_u32 = dst_val.as_u32;
10747 ip->protocol = proto_val;
10750 /* These are not, but they're included for completeness */
10752 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10755 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10761 ip->length = clib_host_to_net_u16 (length_val);
10767 ip->checksum = clib_host_to_net_u16 (checksum_val);
10774 unformat_ip6_match (unformat_input_t * input, va_list * args)
10776 u8 **matchp = va_arg (*args, u8 **);
10781 u8 traffic_class = 0;
10782 u32 traffic_class_val = 0;
10785 int src = 0, dst = 0;
10786 ip6_address_t src_val, dst_val;
10789 int payload_length = 0;
10790 u32 payload_length_val;
10793 u32 ip_version_traffic_class_and_flow_label;
10795 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10797 if (unformat (input, "version %d", &version_val))
10799 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10801 else if (unformat (input, "flow_label %d", &flow_label_val))
10803 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10805 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10807 else if (unformat (input, "proto %d", &proto_val))
10809 else if (unformat (input, "payload_length %d", &payload_length_val))
10810 payload_length = 1;
10811 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10817 if (version + traffic_class + flow_label + src + dst + proto +
10818 payload_length + hop_limit == 0)
10822 * Aligned because we use the real comparison functions
10824 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10826 ip = (ip6_header_t *) match;
10829 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10832 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10835 ip->protocol = proto_val;
10837 ip_version_traffic_class_and_flow_label = 0;
10840 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10843 ip_version_traffic_class_and_flow_label |=
10844 (traffic_class_val & 0xFF) << 20;
10847 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10849 ip->ip_version_traffic_class_and_flow_label =
10850 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10852 if (payload_length)
10853 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10856 ip->hop_limit = hop_limit_val;
10863 unformat_l3_match (unformat_input_t * input, va_list * args)
10865 u8 **matchp = va_arg (*args, u8 **);
10867 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10869 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10871 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10880 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10882 u8 *tagp = va_arg (*args, u8 *);
10885 if (unformat (input, "%d", &tag))
10887 tagp[0] = (tag >> 8) & 0x0F;
10888 tagp[1] = tag & 0xFF;
10896 unformat_l2_match (unformat_input_t * input, va_list * args)
10898 u8 **matchp = va_arg (*args, u8 **);
10911 u8 ignore_tag1 = 0;
10912 u8 ignore_tag2 = 0;
10918 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10920 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10923 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10925 else if (unformat (input, "proto %U",
10926 unformat_ethernet_type_host_byte_order, &proto_val))
10928 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10930 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10932 else if (unformat (input, "ignore-tag1"))
10934 else if (unformat (input, "ignore-tag2"))
10936 else if (unformat (input, "cos1 %d", &cos1_val))
10938 else if (unformat (input, "cos2 %d", &cos2_val))
10943 if ((src + dst + proto + tag1 + tag2 +
10944 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10947 if (tag1 || ignore_tag1 || cos1)
10949 if (tag2 || ignore_tag2 || cos2)
10952 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10955 clib_memcpy (match, dst_val, 6);
10958 clib_memcpy (match + 6, src_val, 6);
10962 /* inner vlan tag */
10963 match[19] = tag2_val[1];
10964 match[18] = tag2_val[0];
10966 match[18] |= (cos2_val & 0x7) << 5;
10969 match[21] = proto_val & 0xff;
10970 match[20] = proto_val >> 8;
10974 match[15] = tag1_val[1];
10975 match[14] = tag1_val[0];
10978 match[14] |= (cos1_val & 0x7) << 5;
10984 match[15] = tag1_val[1];
10985 match[14] = tag1_val[0];
10988 match[17] = proto_val & 0xff;
10989 match[16] = proto_val >> 8;
10992 match[14] |= (cos1_val & 0x7) << 5;
10998 match[18] |= (cos2_val & 0x7) << 5;
11000 match[14] |= (cos1_val & 0x7) << 5;
11003 match[13] = proto_val & 0xff;
11004 match[12] = proto_val >> 8;
11012 unformat_qos_source (unformat_input_t * input, va_list * args)
11014 int *qs = va_arg (*args, int *);
11016 if (unformat (input, "ip"))
11017 *qs = QOS_SOURCE_IP;
11018 else if (unformat (input, "mpls"))
11019 *qs = QOS_SOURCE_MPLS;
11020 else if (unformat (input, "ext"))
11021 *qs = QOS_SOURCE_EXT;
11022 else if (unformat (input, "vlan"))
11023 *qs = QOS_SOURCE_VLAN;
11032 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11034 u8 **matchp = va_arg (*args, u8 **);
11035 u32 skip_n_vectors = va_arg (*args, u32);
11036 u32 match_n_vectors = va_arg (*args, u32);
11043 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11045 if (unformat (input, "hex %U", unformat_hex_string, &match))
11047 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11049 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11051 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11065 if (match || l2 || l3 || l4)
11067 if (l2 || l3 || l4)
11069 /* "Win a free Ethernet header in every packet" */
11071 vec_validate_aligned (l2, 13, sizeof (u32x4));
11075 vec_append_aligned (match, l3, sizeof (u32x4));
11080 vec_append_aligned (match, l4, sizeof (u32x4));
11085 /* Make sure the vector is big enough even if key is all 0's */
11086 vec_validate_aligned
11087 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11090 /* Set size, include skipped vectors */
11091 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11102 api_classify_add_del_session (vat_main_t * vam)
11104 unformat_input_t *i = vam->input;
11105 vl_api_classify_add_del_session_t *mp;
11107 u32 table_index = ~0;
11108 u32 hit_next_index = ~0;
11109 u32 opaque_index = ~0;
11112 u32 skip_n_vectors = 0;
11113 u32 match_n_vectors = 0;
11119 * Warning: you have to supply skip_n and match_n
11120 * because the API client cant simply look at the classify
11124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11126 if (unformat (i, "del"))
11128 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11131 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11134 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11137 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11139 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11141 else if (unformat (i, "opaque-index %d", &opaque_index))
11143 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11145 else if (unformat (i, "match_n %d", &match_n_vectors))
11147 else if (unformat (i, "match %U", api_unformat_classify_match,
11148 &match, skip_n_vectors, match_n_vectors))
11150 else if (unformat (i, "advance %d", &advance))
11152 else if (unformat (i, "table-index %d", &table_index))
11154 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11156 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11158 else if (unformat (i, "action %d", &action))
11160 else if (unformat (i, "metadata %d", &metadata))
11166 if (table_index == ~0)
11168 errmsg ("Table index required");
11172 if (is_add && match == 0)
11174 errmsg ("Match value required");
11178 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11180 mp->is_add = is_add;
11181 mp->table_index = ntohl (table_index);
11182 mp->hit_next_index = ntohl (hit_next_index);
11183 mp->opaque_index = ntohl (opaque_index);
11184 mp->advance = ntohl (advance);
11185 mp->action = action;
11186 mp->metadata = ntohl (metadata);
11187 mp->match_len = ntohl (vec_len (match));
11188 clib_memcpy (mp->match, match, vec_len (match));
11197 api_classify_set_interface_ip_table (vat_main_t * vam)
11199 unformat_input_t *i = vam->input;
11200 vl_api_classify_set_interface_ip_table_t *mp;
11202 int sw_if_index_set;
11203 u32 table_index = ~0;
11207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11209 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11210 sw_if_index_set = 1;
11211 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11212 sw_if_index_set = 1;
11213 else if (unformat (i, "table %d", &table_index))
11217 clib_warning ("parse error '%U'", format_unformat_error, i);
11222 if (sw_if_index_set == 0)
11224 errmsg ("missing interface name or sw_if_index");
11229 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11231 mp->sw_if_index = ntohl (sw_if_index);
11232 mp->table_index = ntohl (table_index);
11233 mp->is_ipv6 = is_ipv6;
11241 api_classify_set_interface_l2_tables (vat_main_t * vam)
11243 unformat_input_t *i = vam->input;
11244 vl_api_classify_set_interface_l2_tables_t *mp;
11246 int sw_if_index_set;
11247 u32 ip4_table_index = ~0;
11248 u32 ip6_table_index = ~0;
11249 u32 other_table_index = ~0;
11253 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11255 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11256 sw_if_index_set = 1;
11257 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11258 sw_if_index_set = 1;
11259 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11261 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11263 else if (unformat (i, "other-table %d", &other_table_index))
11265 else if (unformat (i, "is-input %d", &is_input))
11269 clib_warning ("parse error '%U'", format_unformat_error, i);
11274 if (sw_if_index_set == 0)
11276 errmsg ("missing interface name or sw_if_index");
11281 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11283 mp->sw_if_index = ntohl (sw_if_index);
11284 mp->ip4_table_index = ntohl (ip4_table_index);
11285 mp->ip6_table_index = ntohl (ip6_table_index);
11286 mp->other_table_index = ntohl (other_table_index);
11287 mp->is_input = (u8) is_input;
11295 api_set_ipfix_exporter (vat_main_t * vam)
11297 unformat_input_t *i = vam->input;
11298 vl_api_set_ipfix_exporter_t *mp;
11299 ip4_address_t collector_address;
11300 u8 collector_address_set = 0;
11301 u32 collector_port = ~0;
11302 ip4_address_t src_address;
11303 u8 src_address_set = 0;
11306 u32 template_interval = ~0;
11307 u8 udp_checksum = 0;
11310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11312 if (unformat (i, "collector_address %U", unformat_ip4_address,
11313 &collector_address))
11314 collector_address_set = 1;
11315 else if (unformat (i, "collector_port %d", &collector_port))
11317 else if (unformat (i, "src_address %U", unformat_ip4_address,
11319 src_address_set = 1;
11320 else if (unformat (i, "vrf_id %d", &vrf_id))
11322 else if (unformat (i, "path_mtu %d", &path_mtu))
11324 else if (unformat (i, "template_interval %d", &template_interval))
11326 else if (unformat (i, "udp_checksum"))
11332 if (collector_address_set == 0)
11334 errmsg ("collector_address required");
11338 if (src_address_set == 0)
11340 errmsg ("src_address required");
11344 M (SET_IPFIX_EXPORTER, mp);
11346 memcpy (mp->collector_address.un.ip4, collector_address.data,
11347 sizeof (collector_address.data));
11348 mp->collector_port = htons ((u16) collector_port);
11349 memcpy (mp->src_address.un.ip4, src_address.data,
11350 sizeof (src_address.data));
11351 mp->vrf_id = htonl (vrf_id);
11352 mp->path_mtu = htonl (path_mtu);
11353 mp->template_interval = htonl (template_interval);
11354 mp->udp_checksum = udp_checksum;
11362 api_set_ipfix_classify_stream (vat_main_t * vam)
11364 unformat_input_t *i = vam->input;
11365 vl_api_set_ipfix_classify_stream_t *mp;
11367 u32 src_port = UDP_DST_PORT_ipfix;
11370 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11372 if (unformat (i, "domain %d", &domain_id))
11374 else if (unformat (i, "src_port %d", &src_port))
11378 errmsg ("unknown input `%U'", format_unformat_error, i);
11383 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11385 mp->domain_id = htonl (domain_id);
11386 mp->src_port = htons ((u16) src_port);
11394 api_ipfix_classify_table_add_del (vat_main_t * vam)
11396 unformat_input_t *i = vam->input;
11397 vl_api_ipfix_classify_table_add_del_t *mp;
11399 u32 classify_table_index = ~0;
11401 u8 transport_protocol = 255;
11404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11406 if (unformat (i, "add"))
11408 else if (unformat (i, "del"))
11410 else if (unformat (i, "table %d", &classify_table_index))
11412 else if (unformat (i, "ip4"))
11414 else if (unformat (i, "ip6"))
11416 else if (unformat (i, "tcp"))
11417 transport_protocol = 6;
11418 else if (unformat (i, "udp"))
11419 transport_protocol = 17;
11422 errmsg ("unknown input `%U'", format_unformat_error, i);
11429 errmsg ("expecting: add|del");
11432 if (classify_table_index == ~0)
11434 errmsg ("classifier table not specified");
11437 if (ip_version == 0)
11439 errmsg ("IP version not specified");
11443 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11445 mp->is_add = is_add;
11446 mp->table_id = htonl (classify_table_index);
11447 mp->ip_version = ip_version;
11448 mp->transport_protocol = transport_protocol;
11456 api_get_node_index (vat_main_t * vam)
11458 unformat_input_t *i = vam->input;
11459 vl_api_get_node_index_t *mp;
11463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11465 if (unformat (i, "node %s", &name))
11472 errmsg ("node name required");
11475 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11477 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11481 M (GET_NODE_INDEX, mp);
11482 clib_memcpy (mp->node_name, name, vec_len (name));
11491 api_get_next_index (vat_main_t * vam)
11493 unformat_input_t *i = vam->input;
11494 vl_api_get_next_index_t *mp;
11495 u8 *node_name = 0, *next_node_name = 0;
11498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11500 if (unformat (i, "node-name %s", &node_name))
11502 else if (unformat (i, "next-node-name %s", &next_node_name))
11506 if (node_name == 0)
11508 errmsg ("node name required");
11511 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11513 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11517 if (next_node_name == 0)
11519 errmsg ("next node name required");
11522 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11524 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11528 M (GET_NEXT_INDEX, mp);
11529 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11530 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11531 vec_free (node_name);
11532 vec_free (next_node_name);
11540 api_add_node_next (vat_main_t * vam)
11542 unformat_input_t *i = vam->input;
11543 vl_api_add_node_next_t *mp;
11548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11550 if (unformat (i, "node %s", &name))
11552 else if (unformat (i, "next %s", &next))
11559 errmsg ("node name required");
11562 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11564 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11569 errmsg ("next node required");
11572 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11574 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11578 M (ADD_NODE_NEXT, mp);
11579 clib_memcpy (mp->node_name, name, vec_len (name));
11580 clib_memcpy (mp->next_name, next, vec_len (next));
11590 api_l2tpv3_create_tunnel (vat_main_t * vam)
11592 unformat_input_t *i = vam->input;
11593 ip6_address_t client_address, our_address;
11594 int client_address_set = 0;
11595 int our_address_set = 0;
11596 u32 local_session_id = 0;
11597 u32 remote_session_id = 0;
11598 u64 local_cookie = 0;
11599 u64 remote_cookie = 0;
11600 u8 l2_sublayer_present = 0;
11601 vl_api_l2tpv3_create_tunnel_t *mp;
11604 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11606 if (unformat (i, "client_address %U", unformat_ip6_address,
11608 client_address_set = 1;
11609 else if (unformat (i, "our_address %U", unformat_ip6_address,
11611 our_address_set = 1;
11612 else if (unformat (i, "local_session_id %d", &local_session_id))
11614 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11616 else if (unformat (i, "local_cookie %lld", &local_cookie))
11618 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11620 else if (unformat (i, "l2-sublayer-present"))
11621 l2_sublayer_present = 1;
11626 if (client_address_set == 0)
11628 errmsg ("client_address required");
11632 if (our_address_set == 0)
11634 errmsg ("our_address required");
11638 M (L2TPV3_CREATE_TUNNEL, mp);
11640 clib_memcpy (mp->client_address.un.ip6, client_address.as_u8,
11641 sizeof (ip6_address_t));
11643 clib_memcpy (mp->our_address.un.ip6, our_address.as_u8,
11644 sizeof (ip6_address_t));
11646 mp->local_session_id = ntohl (local_session_id);
11647 mp->remote_session_id = ntohl (remote_session_id);
11648 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11649 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11650 mp->l2_sublayer_present = l2_sublayer_present;
11658 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11660 unformat_input_t *i = vam->input;
11662 u8 sw_if_index_set = 0;
11663 u64 new_local_cookie = 0;
11664 u64 new_remote_cookie = 0;
11665 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11670 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11671 sw_if_index_set = 1;
11672 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11673 sw_if_index_set = 1;
11674 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11676 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11682 if (sw_if_index_set == 0)
11684 errmsg ("missing interface name or sw_if_index");
11688 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11690 mp->sw_if_index = ntohl (sw_if_index);
11691 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11692 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11700 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11702 unformat_input_t *i = vam->input;
11703 vl_api_l2tpv3_interface_enable_disable_t *mp;
11705 u8 sw_if_index_set = 0;
11706 u8 enable_disable = 1;
11709 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11711 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11712 sw_if_index_set = 1;
11713 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11714 sw_if_index_set = 1;
11715 else if (unformat (i, "enable"))
11716 enable_disable = 1;
11717 else if (unformat (i, "disable"))
11718 enable_disable = 0;
11723 if (sw_if_index_set == 0)
11725 errmsg ("missing interface name or sw_if_index");
11729 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11731 mp->sw_if_index = ntohl (sw_if_index);
11732 mp->enable_disable = enable_disable;
11740 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11742 unformat_input_t *i = vam->input;
11743 vl_api_l2tpv3_set_lookup_key_t *mp;
11747 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11749 if (unformat (i, "lookup_v6_src"))
11750 key = L2T_LOOKUP_SRC_ADDRESS;
11751 else if (unformat (i, "lookup_v6_dst"))
11752 key = L2T_LOOKUP_DST_ADDRESS;
11753 else if (unformat (i, "lookup_session_id"))
11754 key = L2T_LOOKUP_SESSION_ID;
11759 if (key == (u8) ~ 0)
11761 errmsg ("l2tp session lookup key unset");
11765 M (L2TPV3_SET_LOOKUP_KEY, mp);
11774 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11775 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11777 vat_main_t *vam = &vat_main;
11779 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11780 format_ip6_address, mp->our_address,
11781 format_ip6_address, mp->client_address,
11782 clib_net_to_host_u32 (mp->sw_if_index));
11785 " local cookies %016llx %016llx remote cookie %016llx",
11786 clib_net_to_host_u64 (mp->local_cookie[0]),
11787 clib_net_to_host_u64 (mp->local_cookie[1]),
11788 clib_net_to_host_u64 (mp->remote_cookie));
11790 print (vam->ofp, " local session-id %d remote session-id %d",
11791 clib_net_to_host_u32 (mp->local_session_id),
11792 clib_net_to_host_u32 (mp->remote_session_id));
11794 print (vam->ofp, " l2 specific sublayer %s\n",
11795 mp->l2_sublayer_present ? "preset" : "absent");
11799 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11800 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11802 vat_main_t *vam = &vat_main;
11803 vat_json_node_t *node = NULL;
11804 struct in6_addr addr;
11806 if (VAT_JSON_ARRAY != vam->json_tree.type)
11808 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11809 vat_json_init_array (&vam->json_tree);
11811 node = vat_json_array_add (&vam->json_tree);
11813 vat_json_init_object (node);
11815 clib_memcpy (&addr, mp->our_address.un.ip6, sizeof (addr));
11816 vat_json_object_add_ip6 (node, "our_address", addr);
11817 clib_memcpy (&addr, mp->client_address.un.ip6, sizeof (addr));
11818 vat_json_object_add_ip6 (node, "client_address", addr);
11820 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11821 vat_json_init_array (lc);
11822 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11823 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11824 vat_json_object_add_uint (node, "remote_cookie",
11825 clib_net_to_host_u64 (mp->remote_cookie));
11827 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11828 vat_json_object_add_uint (node, "local_session_id",
11829 clib_net_to_host_u32 (mp->local_session_id));
11830 vat_json_object_add_uint (node, "remote_session_id",
11831 clib_net_to_host_u32 (mp->remote_session_id));
11832 vat_json_object_add_string_copy (node, "l2_sublayer",
11833 mp->l2_sublayer_present ? (u8 *) "present"
11834 : (u8 *) "absent");
11838 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11840 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11841 vl_api_control_ping_t *mp_ping;
11844 /* Get list of l2tpv3-tunnel interfaces */
11845 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11848 /* Use a control ping for synchronization */
11849 MPING (CONTROL_PING, mp_ping);
11857 static void vl_api_sw_interface_tap_v2_details_t_handler
11858 (vl_api_sw_interface_tap_v2_details_t * mp)
11860 vat_main_t *vam = &vat_main;
11863 format (0, "%U/%d", format_ip4_address, mp->host_ip4_prefix.address,
11864 mp->host_ip4_prefix.len);
11866 format (0, "%U/%d", format_ip6_address, mp->host_ip6_prefix.address,
11867 mp->host_ip6_prefix.len);
11870 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
11871 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
11872 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11873 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
11874 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
11880 static void vl_api_sw_interface_tap_v2_details_t_handler_json
11881 (vl_api_sw_interface_tap_v2_details_t * mp)
11883 vat_main_t *vam = &vat_main;
11884 vat_json_node_t *node = NULL;
11886 if (VAT_JSON_ARRAY != vam->json_tree.type)
11888 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11889 vat_json_init_array (&vam->json_tree);
11891 node = vat_json_array_add (&vam->json_tree);
11893 vat_json_init_object (node);
11894 vat_json_object_add_uint (node, "id", ntohl (mp->id));
11895 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11896 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
11897 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11898 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11899 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11900 vat_json_object_add_string_copy (node, "host_mac_addr",
11901 format (0, "%U", format_ethernet_address,
11902 &mp->host_mac_addr));
11903 vat_json_object_add_string_copy (node, "host_namespace",
11904 mp->host_namespace);
11905 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
11906 vat_json_object_add_string_copy (node, "host_ip4_addr",
11907 format (0, "%U/%d", format_ip4_address,
11908 mp->host_ip4_prefix.address,
11909 mp->host_ip4_prefix.len));
11910 vat_json_object_add_string_copy (node, "host_ip6_prefix",
11911 format (0, "%U/%d", format_ip6_address,
11912 mp->host_ip6_prefix.address,
11913 mp->host_ip6_prefix.len));
11918 api_sw_interface_tap_v2_dump (vat_main_t * vam)
11920 vl_api_sw_interface_tap_v2_dump_t *mp;
11921 vl_api_control_ping_t *mp_ping;
11925 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
11926 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
11927 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
11930 /* Get list of tap interfaces */
11931 M (SW_INTERFACE_TAP_V2_DUMP, mp);
11934 /* Use a control ping for synchronization */
11935 MPING (CONTROL_PING, mp_ping);
11942 static void vl_api_sw_interface_virtio_pci_details_t_handler
11943 (vl_api_sw_interface_virtio_pci_details_t * mp)
11945 vat_main_t *vam = &vat_main;
11959 addr.as_u32 = ntohl (mp->pci_addr);
11960 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
11961 addr.slot, addr.function);
11964 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
11965 pci_addr, ntohl (mp->sw_if_index),
11966 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11967 format_ethernet_address, mp->mac_addr,
11968 clib_net_to_host_u64 (mp->features));
11969 vec_free (pci_addr);
11972 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
11973 (vl_api_sw_interface_virtio_pci_details_t * mp)
11975 vat_main_t *vam = &vat_main;
11976 vat_json_node_t *node = NULL;
11978 if (VAT_JSON_ARRAY != vam->json_tree.type)
11980 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11981 vat_json_init_array (&vam->json_tree);
11983 node = vat_json_array_add (&vam->json_tree);
11985 vat_json_init_object (node);
11986 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
11987 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11988 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11989 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11990 vat_json_object_add_uint (node, "features",
11991 clib_net_to_host_u64 (mp->features));
11992 vat_json_object_add_string_copy (node, "mac_addr",
11993 format (0, "%U", format_ethernet_address,
11998 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12000 vl_api_sw_interface_virtio_pci_dump_t *mp;
12001 vl_api_control_ping_t *mp_ping;
12005 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12006 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12007 "mac_addr", "features");
12009 /* Get list of tap interfaces */
12010 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12013 /* Use a control ping for synchronization */
12014 MPING (CONTROL_PING, mp_ping);
12022 api_vxlan_offload_rx (vat_main_t * vam)
12024 unformat_input_t *line_input = vam->input;
12025 vl_api_vxlan_offload_rx_t *mp;
12026 u32 hw_if_index = ~0, rx_if_index = ~0;
12030 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12032 if (unformat (line_input, "del"))
12034 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12037 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12039 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12042 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12046 errmsg ("parse error '%U'", format_unformat_error, line_input);
12051 if (hw_if_index == ~0)
12053 errmsg ("no hw interface");
12057 if (rx_if_index == ~0)
12059 errmsg ("no rx tunnel");
12063 M (VXLAN_OFFLOAD_RX, mp);
12065 mp->hw_if_index = ntohl (hw_if_index);
12066 mp->sw_if_index = ntohl (rx_if_index);
12067 mp->enable = is_add;
12074 static uword unformat_vxlan_decap_next
12075 (unformat_input_t * input, va_list * args)
12077 u32 *result = va_arg (*args, u32 *);
12080 if (unformat (input, "l2"))
12081 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12082 else if (unformat (input, "%d", &tmp))
12090 api_vxlan_add_del_tunnel (vat_main_t * vam)
12092 unformat_input_t *line_input = vam->input;
12093 vl_api_vxlan_add_del_tunnel_t *mp;
12094 ip46_address_t src, dst;
12096 u8 ipv4_set = 0, ipv6_set = 0;
12101 u32 mcast_sw_if_index = ~0;
12102 u32 encap_vrf_id = 0;
12103 u32 decap_next_index = ~0;
12107 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12108 clib_memset (&src, 0, sizeof src);
12109 clib_memset (&dst, 0, sizeof dst);
12111 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12113 if (unformat (line_input, "del"))
12115 else if (unformat (line_input, "instance %d", &instance))
12118 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12124 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12130 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12136 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12141 else if (unformat (line_input, "group %U %U",
12142 unformat_ip4_address, &dst.ip4,
12143 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12145 grp_set = dst_set = 1;
12148 else if (unformat (line_input, "group %U",
12149 unformat_ip4_address, &dst.ip4))
12151 grp_set = dst_set = 1;
12154 else if (unformat (line_input, "group %U %U",
12155 unformat_ip6_address, &dst.ip6,
12156 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12158 grp_set = dst_set = 1;
12161 else if (unformat (line_input, "group %U",
12162 unformat_ip6_address, &dst.ip6))
12164 grp_set = dst_set = 1;
12168 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12170 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12172 else if (unformat (line_input, "decap-next %U",
12173 unformat_vxlan_decap_next, &decap_next_index))
12175 else if (unformat (line_input, "vni %d", &vni))
12179 errmsg ("parse error '%U'", format_unformat_error, line_input);
12186 errmsg ("tunnel src address not specified");
12191 errmsg ("tunnel dst address not specified");
12195 if (grp_set && !ip46_address_is_multicast (&dst))
12197 errmsg ("tunnel group address not multicast");
12200 if (grp_set && mcast_sw_if_index == ~0)
12202 errmsg ("tunnel nonexistent multicast device");
12205 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12207 errmsg ("tunnel dst address must be unicast");
12212 if (ipv4_set && ipv6_set)
12214 errmsg ("both IPv4 and IPv6 addresses specified");
12218 if ((vni == 0) || (vni >> 24))
12220 errmsg ("vni not specified or out of range");
12224 M (VXLAN_ADD_DEL_TUNNEL, mp);
12228 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12229 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12233 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12234 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12237 mp->instance = htonl (instance);
12238 mp->encap_vrf_id = ntohl (encap_vrf_id);
12239 mp->decap_next_index = ntohl (decap_next_index);
12240 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12241 mp->vni = ntohl (vni);
12242 mp->is_add = is_add;
12243 mp->is_ipv6 = ipv6_set;
12250 static void vl_api_vxlan_tunnel_details_t_handler
12251 (vl_api_vxlan_tunnel_details_t * mp)
12253 vat_main_t *vam = &vat_main;
12254 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12255 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12257 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12258 ntohl (mp->sw_if_index),
12259 ntohl (mp->instance),
12260 format_ip46_address, &src, IP46_TYPE_ANY,
12261 format_ip46_address, &dst, IP46_TYPE_ANY,
12262 ntohl (mp->encap_vrf_id),
12263 ntohl (mp->decap_next_index), ntohl (mp->vni),
12264 ntohl (mp->mcast_sw_if_index));
12267 static void vl_api_vxlan_tunnel_details_t_handler_json
12268 (vl_api_vxlan_tunnel_details_t * mp)
12270 vat_main_t *vam = &vat_main;
12271 vat_json_node_t *node = NULL;
12273 if (VAT_JSON_ARRAY != vam->json_tree.type)
12275 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12276 vat_json_init_array (&vam->json_tree);
12278 node = vat_json_array_add (&vam->json_tree);
12280 vat_json_init_object (node);
12281 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12283 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12287 struct in6_addr ip6;
12289 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12290 vat_json_object_add_ip6 (node, "src_address", ip6);
12291 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12292 vat_json_object_add_ip6 (node, "dst_address", ip6);
12296 struct in_addr ip4;
12298 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12299 vat_json_object_add_ip4 (node, "src_address", ip4);
12300 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12301 vat_json_object_add_ip4 (node, "dst_address", ip4);
12303 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12304 vat_json_object_add_uint (node, "decap_next_index",
12305 ntohl (mp->decap_next_index));
12306 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12307 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12308 vat_json_object_add_uint (node, "mcast_sw_if_index",
12309 ntohl (mp->mcast_sw_if_index));
12313 api_vxlan_tunnel_dump (vat_main_t * vam)
12315 unformat_input_t *i = vam->input;
12316 vl_api_vxlan_tunnel_dump_t *mp;
12317 vl_api_control_ping_t *mp_ping;
12319 u8 sw_if_index_set = 0;
12322 /* Parse args required to build the message */
12323 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12325 if (unformat (i, "sw_if_index %d", &sw_if_index))
12326 sw_if_index_set = 1;
12331 if (sw_if_index_set == 0)
12336 if (!vam->json_output)
12338 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12339 "sw_if_index", "instance", "src_address", "dst_address",
12340 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12343 /* Get list of vxlan-tunnel interfaces */
12344 M (VXLAN_TUNNEL_DUMP, mp);
12346 mp->sw_if_index = htonl (sw_if_index);
12350 /* Use a control ping for synchronization */
12351 MPING (CONTROL_PING, mp_ping);
12358 static uword unformat_geneve_decap_next
12359 (unformat_input_t * input, va_list * args)
12361 u32 *result = va_arg (*args, u32 *);
12364 if (unformat (input, "l2"))
12365 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12366 else if (unformat (input, "%d", &tmp))
12374 api_geneve_add_del_tunnel (vat_main_t * vam)
12376 unformat_input_t *line_input = vam->input;
12377 vl_api_geneve_add_del_tunnel_t *mp;
12378 ip46_address_t src, dst;
12380 u8 ipv4_set = 0, ipv6_set = 0;
12384 u32 mcast_sw_if_index = ~0;
12385 u32 encap_vrf_id = 0;
12386 u32 decap_next_index = ~0;
12390 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12391 clib_memset (&src, 0, sizeof src);
12392 clib_memset (&dst, 0, sizeof dst);
12394 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12396 if (unformat (line_input, "del"))
12399 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12405 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12411 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12417 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12422 else if (unformat (line_input, "group %U %U",
12423 unformat_ip4_address, &dst.ip4,
12424 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12426 grp_set = dst_set = 1;
12429 else if (unformat (line_input, "group %U",
12430 unformat_ip4_address, &dst.ip4))
12432 grp_set = dst_set = 1;
12435 else if (unformat (line_input, "group %U %U",
12436 unformat_ip6_address, &dst.ip6,
12437 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12439 grp_set = dst_set = 1;
12442 else if (unformat (line_input, "group %U",
12443 unformat_ip6_address, &dst.ip6))
12445 grp_set = dst_set = 1;
12449 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12451 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12453 else if (unformat (line_input, "decap-next %U",
12454 unformat_geneve_decap_next, &decap_next_index))
12456 else if (unformat (line_input, "vni %d", &vni))
12460 errmsg ("parse error '%U'", format_unformat_error, line_input);
12467 errmsg ("tunnel src address not specified");
12472 errmsg ("tunnel dst address not specified");
12476 if (grp_set && !ip46_address_is_multicast (&dst))
12478 errmsg ("tunnel group address not multicast");
12481 if (grp_set && mcast_sw_if_index == ~0)
12483 errmsg ("tunnel nonexistent multicast device");
12486 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12488 errmsg ("tunnel dst address must be unicast");
12493 if (ipv4_set && ipv6_set)
12495 errmsg ("both IPv4 and IPv6 addresses specified");
12499 if ((vni == 0) || (vni >> 24))
12501 errmsg ("vni not specified or out of range");
12505 M (GENEVE_ADD_DEL_TUNNEL, mp);
12509 clib_memcpy (&mp->local_address.un.ip6, &src.ip6, sizeof (src.ip6));
12510 clib_memcpy (&mp->remote_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
12514 clib_memcpy (&mp->local_address.un.ip4, &src.ip4, sizeof (src.ip4));
12515 clib_memcpy (&mp->remote_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
12517 mp->encap_vrf_id = ntohl (encap_vrf_id);
12518 mp->decap_next_index = ntohl (decap_next_index);
12519 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12520 mp->vni = ntohl (vni);
12521 mp->is_add = is_add;
12528 static void vl_api_geneve_tunnel_details_t_handler
12529 (vl_api_geneve_tunnel_details_t * mp)
12531 vat_main_t *vam = &vat_main;
12532 ip46_address_t src = {.as_u64[0] = 0,.as_u64[1] = 0 };
12533 ip46_address_t dst = {.as_u64[0] = 0,.as_u64[1] = 0 };
12535 if (mp->src_address.af == ADDRESS_IP6)
12537 clib_memcpy (&src.ip6, &mp->src_address.un.ip6, sizeof (ip6_address_t));
12538 clib_memcpy (&dst.ip6, &mp->dst_address.un.ip6, sizeof (ip6_address_t));
12542 clib_memcpy (&src.ip4, &mp->src_address.un.ip4, sizeof (ip4_address_t));
12543 clib_memcpy (&dst.ip4, &mp->dst_address.un.ip4, sizeof (ip4_address_t));
12546 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12547 ntohl (mp->sw_if_index),
12548 format_ip46_address, &src, IP46_TYPE_ANY,
12549 format_ip46_address, &dst, IP46_TYPE_ANY,
12550 ntohl (mp->encap_vrf_id),
12551 ntohl (mp->decap_next_index), ntohl (mp->vni),
12552 ntohl (mp->mcast_sw_if_index));
12555 static void vl_api_geneve_tunnel_details_t_handler_json
12556 (vl_api_geneve_tunnel_details_t * mp)
12558 vat_main_t *vam = &vat_main;
12559 vat_json_node_t *node = NULL;
12562 if (VAT_JSON_ARRAY != vam->json_tree.type)
12564 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12565 vat_json_init_array (&vam->json_tree);
12567 node = vat_json_array_add (&vam->json_tree);
12569 vat_json_init_object (node);
12570 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12571 is_ipv6 = mp->src_address.af == ADDRESS_IP6;
12574 struct in6_addr ip6;
12576 clib_memcpy (&ip6, &mp->src_address.un.ip6, sizeof (ip6));
12577 vat_json_object_add_ip6 (node, "src_address", ip6);
12578 clib_memcpy (&ip6, &mp->dst_address.un.ip6, sizeof (ip6));
12579 vat_json_object_add_ip6 (node, "dst_address", ip6);
12583 struct in_addr ip4;
12585 clib_memcpy (&ip4, &mp->src_address.un.ip4, sizeof (ip4));
12586 vat_json_object_add_ip4 (node, "src_address", ip4);
12587 clib_memcpy (&ip4, &mp->dst_address.un.ip4, sizeof (ip4));
12588 vat_json_object_add_ip4 (node, "dst_address", ip4);
12590 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12591 vat_json_object_add_uint (node, "decap_next_index",
12592 ntohl (mp->decap_next_index));
12593 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12594 vat_json_object_add_uint (node, "mcast_sw_if_index",
12595 ntohl (mp->mcast_sw_if_index));
12599 api_geneve_tunnel_dump (vat_main_t * vam)
12601 unformat_input_t *i = vam->input;
12602 vl_api_geneve_tunnel_dump_t *mp;
12603 vl_api_control_ping_t *mp_ping;
12605 u8 sw_if_index_set = 0;
12608 /* Parse args required to build the message */
12609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12611 if (unformat (i, "sw_if_index %d", &sw_if_index))
12612 sw_if_index_set = 1;
12617 if (sw_if_index_set == 0)
12622 if (!vam->json_output)
12624 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12625 "sw_if_index", "local_address", "remote_address",
12626 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12629 /* Get list of geneve-tunnel interfaces */
12630 M (GENEVE_TUNNEL_DUMP, mp);
12632 mp->sw_if_index = htonl (sw_if_index);
12636 /* Use a control ping for synchronization */
12637 M (CONTROL_PING, mp_ping);
12645 api_gre_tunnel_add_del (vat_main_t * vam)
12647 unformat_input_t *line_input = vam->input;
12648 vl_api_address_t src = { }, dst =
12651 vl_api_gre_tunnel_add_del_t *mp;
12652 vl_api_gre_tunnel_type_t t_type;
12656 u32 outer_table_id = 0;
12657 u32 session_id = 0;
12661 t_type = GRE_API_TUNNEL_TYPE_L3;
12663 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12665 if (unformat (line_input, "del"))
12667 else if (unformat (line_input, "instance %d", &instance))
12669 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
12673 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
12677 else if (unformat (line_input, "outer-table-id %d", &outer_table_id))
12679 else if (unformat (line_input, "teb"))
12680 t_type = GRE_API_TUNNEL_TYPE_TEB;
12681 else if (unformat (line_input, "erspan %d", &session_id))
12682 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
12685 errmsg ("parse error '%U'", format_unformat_error, line_input);
12692 errmsg ("tunnel src address not specified");
12697 errmsg ("tunnel dst address not specified");
12701 M (GRE_TUNNEL_ADD_DEL, mp);
12703 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
12704 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
12706 mp->tunnel.instance = htonl (instance);
12707 mp->tunnel.outer_table_id = htonl (outer_table_id);
12708 mp->is_add = is_add;
12709 mp->tunnel.session_id = htons ((u16) session_id);
12710 mp->tunnel.type = htonl (t_type);
12717 static void vl_api_gre_tunnel_details_t_handler
12718 (vl_api_gre_tunnel_details_t * mp)
12720 vat_main_t *vam = &vat_main;
12722 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
12723 ntohl (mp->tunnel.sw_if_index),
12724 ntohl (mp->tunnel.instance),
12725 format_vl_api_address, &mp->tunnel.src,
12726 format_vl_api_address, &mp->tunnel.dst,
12727 mp->tunnel.type, ntohl (mp->tunnel.outer_table_id),
12728 ntohl (mp->tunnel.session_id));
12731 static void vl_api_gre_tunnel_details_t_handler_json
12732 (vl_api_gre_tunnel_details_t * mp)
12734 vat_main_t *vam = &vat_main;
12735 vat_json_node_t *node = NULL;
12737 if (VAT_JSON_ARRAY != vam->json_tree.type)
12739 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12740 vat_json_init_array (&vam->json_tree);
12742 node = vat_json_array_add (&vam->json_tree);
12744 vat_json_init_object (node);
12745 vat_json_object_add_uint (node, "sw_if_index",
12746 ntohl (mp->tunnel.sw_if_index));
12747 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
12749 vat_json_object_add_address (node, "src", &mp->tunnel.src);
12750 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
12751 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
12752 vat_json_object_add_uint (node, "outer_table_id",
12753 ntohl (mp->tunnel.outer_table_id));
12754 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
12758 api_gre_tunnel_dump (vat_main_t * vam)
12760 unformat_input_t *i = vam->input;
12761 vl_api_gre_tunnel_dump_t *mp;
12762 vl_api_control_ping_t *mp_ping;
12764 u8 sw_if_index_set = 0;
12767 /* Parse args required to build the message */
12768 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12770 if (unformat (i, "sw_if_index %d", &sw_if_index))
12771 sw_if_index_set = 1;
12776 if (sw_if_index_set == 0)
12781 if (!vam->json_output)
12783 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
12784 "sw_if_index", "instance", "src_address", "dst_address",
12785 "tunnel_type", "outer_fib_id", "session_id");
12788 /* Get list of gre-tunnel interfaces */
12789 M (GRE_TUNNEL_DUMP, mp);
12791 mp->sw_if_index = htonl (sw_if_index);
12795 /* Use a control ping for synchronization */
12796 MPING (CONTROL_PING, mp_ping);
12804 api_l2_fib_clear_table (vat_main_t * vam)
12806 // unformat_input_t * i = vam->input;
12807 vl_api_l2_fib_clear_table_t *mp;
12810 M (L2_FIB_CLEAR_TABLE, mp);
12818 api_l2_interface_efp_filter (vat_main_t * vam)
12820 unformat_input_t *i = vam->input;
12821 vl_api_l2_interface_efp_filter_t *mp;
12824 u8 sw_if_index_set = 0;
12827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12829 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12830 sw_if_index_set = 1;
12831 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12832 sw_if_index_set = 1;
12833 else if (unformat (i, "enable"))
12835 else if (unformat (i, "disable"))
12839 clib_warning ("parse error '%U'", format_unformat_error, i);
12844 if (sw_if_index_set == 0)
12846 errmsg ("missing sw_if_index");
12850 M (L2_INTERFACE_EFP_FILTER, mp);
12852 mp->sw_if_index = ntohl (sw_if_index);
12853 mp->enable_disable = enable;
12860 #define foreach_vtr_op \
12861 _("disable", L2_VTR_DISABLED) \
12862 _("push-1", L2_VTR_PUSH_1) \
12863 _("push-2", L2_VTR_PUSH_2) \
12864 _("pop-1", L2_VTR_POP_1) \
12865 _("pop-2", L2_VTR_POP_2) \
12866 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12867 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12868 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12869 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12872 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12874 unformat_input_t *i = vam->input;
12875 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12877 u8 sw_if_index_set = 0;
12880 u32 push_dot1q = 1;
12885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12887 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12888 sw_if_index_set = 1;
12889 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12890 sw_if_index_set = 1;
12891 else if (unformat (i, "vtr_op %d", &vtr_op))
12893 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12896 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12898 else if (unformat (i, "tag1 %d", &tag1))
12900 else if (unformat (i, "tag2 %d", &tag2))
12904 clib_warning ("parse error '%U'", format_unformat_error, i);
12909 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12911 errmsg ("missing vtr operation or sw_if_index");
12915 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12916 mp->sw_if_index = ntohl (sw_if_index);
12917 mp->vtr_op = ntohl (vtr_op);
12918 mp->push_dot1q = ntohl (push_dot1q);
12919 mp->tag1 = ntohl (tag1);
12920 mp->tag2 = ntohl (tag2);
12928 api_create_vhost_user_if (vat_main_t * vam)
12930 unformat_input_t *i = vam->input;
12931 vl_api_create_vhost_user_if_t *mp;
12934 u8 file_name_set = 0;
12935 u32 custom_dev_instance = ~0;
12937 u8 use_custom_mac = 0;
12938 u8 disable_mrg_rxbuf = 0;
12939 u8 disable_indirect_desc = 0;
12944 /* Shut up coverity */
12945 clib_memset (hwaddr, 0, sizeof (hwaddr));
12947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12949 if (unformat (i, "socket %s", &file_name))
12953 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12955 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12956 use_custom_mac = 1;
12957 else if (unformat (i, "server"))
12959 else if (unformat (i, "disable_mrg_rxbuf"))
12960 disable_mrg_rxbuf = 1;
12961 else if (unformat (i, "disable_indirect_desc"))
12962 disable_indirect_desc = 1;
12963 else if (unformat (i, "gso"))
12965 else if (unformat (i, "tag %s", &tag))
12971 if (file_name_set == 0)
12973 errmsg ("missing socket file name");
12977 if (vec_len (file_name) > 255)
12979 errmsg ("socket file name too long");
12982 vec_add1 (file_name, 0);
12984 M (CREATE_VHOST_USER_IF, mp);
12986 mp->is_server = is_server;
12987 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
12988 mp->disable_indirect_desc = disable_indirect_desc;
12989 mp->enable_gso = enable_gso;
12990 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12991 vec_free (file_name);
12992 if (custom_dev_instance != ~0)
12995 mp->custom_dev_instance = ntohl (custom_dev_instance);
12998 mp->use_custom_mac = use_custom_mac;
12999 clib_memcpy (mp->mac_address, hwaddr, 6);
13001 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13010 api_modify_vhost_user_if (vat_main_t * vam)
13012 unformat_input_t *i = vam->input;
13013 vl_api_modify_vhost_user_if_t *mp;
13016 u8 file_name_set = 0;
13017 u32 custom_dev_instance = ~0;
13018 u8 sw_if_index_set = 0;
13019 u32 sw_if_index = (u32) ~ 0;
13023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13025 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13026 sw_if_index_set = 1;
13027 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13028 sw_if_index_set = 1;
13029 else if (unformat (i, "socket %s", &file_name))
13033 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13035 else if (unformat (i, "server"))
13037 else if (unformat (i, "gso"))
13043 if (sw_if_index_set == 0)
13045 errmsg ("missing sw_if_index or interface name");
13049 if (file_name_set == 0)
13051 errmsg ("missing socket file name");
13055 if (vec_len (file_name) > 255)
13057 errmsg ("socket file name too long");
13060 vec_add1 (file_name, 0);
13062 M (MODIFY_VHOST_USER_IF, mp);
13064 mp->sw_if_index = ntohl (sw_if_index);
13065 mp->is_server = is_server;
13066 mp->enable_gso = enable_gso;
13067 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13068 vec_free (file_name);
13069 if (custom_dev_instance != ~0)
13072 mp->custom_dev_instance = ntohl (custom_dev_instance);
13081 api_delete_vhost_user_if (vat_main_t * vam)
13083 unformat_input_t *i = vam->input;
13084 vl_api_delete_vhost_user_if_t *mp;
13085 u32 sw_if_index = ~0;
13086 u8 sw_if_index_set = 0;
13089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13091 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13092 sw_if_index_set = 1;
13093 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13094 sw_if_index_set = 1;
13099 if (sw_if_index_set == 0)
13101 errmsg ("missing sw_if_index or interface name");
13106 M (DELETE_VHOST_USER_IF, mp);
13108 mp->sw_if_index = ntohl (sw_if_index);
13115 static void vl_api_sw_interface_vhost_user_details_t_handler
13116 (vl_api_sw_interface_vhost_user_details_t * mp)
13118 vat_main_t *vam = &vat_main;
13122 clib_net_to_host_u32 (mp->features_first_32) | ((u64)
13123 clib_net_to_host_u32
13124 (mp->features_last_32) <<
13127 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13128 (char *) mp->interface_name,
13129 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13130 features, mp->is_server,
13131 ntohl (mp->num_regions), (char *) mp->sock_filename);
13132 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13135 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13136 (vl_api_sw_interface_vhost_user_details_t * mp)
13138 vat_main_t *vam = &vat_main;
13139 vat_json_node_t *node = NULL;
13141 if (VAT_JSON_ARRAY != vam->json_tree.type)
13143 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13144 vat_json_init_array (&vam->json_tree);
13146 node = vat_json_array_add (&vam->json_tree);
13148 vat_json_init_object (node);
13149 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13150 vat_json_object_add_string_copy (node, "interface_name",
13151 mp->interface_name);
13152 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13153 ntohl (mp->virtio_net_hdr_sz));
13154 vat_json_object_add_uint (node, "features_first_32",
13155 clib_net_to_host_u32 (mp->features_first_32));
13156 vat_json_object_add_uint (node, "features_last_32",
13157 clib_net_to_host_u32 (mp->features_last_32));
13158 vat_json_object_add_uint (node, "is_server", mp->is_server);
13159 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13160 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13161 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13165 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13167 vl_api_sw_interface_vhost_user_dump_t *mp;
13168 vl_api_control_ping_t *mp_ping;
13171 "Interface name idx hdr_sz features server regions filename");
13173 /* Get list of vhost-user interfaces */
13174 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13177 /* Use a control ping for synchronization */
13178 MPING (CONTROL_PING, mp_ping);
13186 api_show_version (vat_main_t * vam)
13188 vl_api_show_version_t *mp;
13191 M (SHOW_VERSION, mp);
13200 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13202 unformat_input_t *line_input = vam->input;
13203 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13204 ip4_address_t local4, remote4;
13205 ip6_address_t local6, remote6;
13207 u8 ipv4_set = 0, ipv6_set = 0;
13211 u32 mcast_sw_if_index = ~0;
13212 u32 encap_vrf_id = 0;
13213 u32 decap_vrf_id = 0;
13219 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13220 clib_memset (&local4, 0, sizeof local4);
13221 clib_memset (&remote4, 0, sizeof remote4);
13222 clib_memset (&local6, 0, sizeof local6);
13223 clib_memset (&remote6, 0, sizeof remote6);
13225 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13227 if (unformat (line_input, "del"))
13229 else if (unformat (line_input, "local %U",
13230 unformat_ip4_address, &local4))
13235 else if (unformat (line_input, "remote %U",
13236 unformat_ip4_address, &remote4))
13241 else if (unformat (line_input, "local %U",
13242 unformat_ip6_address, &local6))
13247 else if (unformat (line_input, "remote %U",
13248 unformat_ip6_address, &remote6))
13253 else if (unformat (line_input, "group %U %U",
13254 unformat_ip4_address, &remote4,
13255 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13257 grp_set = remote_set = 1;
13260 else if (unformat (line_input, "group %U",
13261 unformat_ip4_address, &remote4))
13263 grp_set = remote_set = 1;
13266 else if (unformat (line_input, "group %U %U",
13267 unformat_ip6_address, &remote6,
13268 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13270 grp_set = remote_set = 1;
13273 else if (unformat (line_input, "group %U",
13274 unformat_ip6_address, &remote6))
13276 grp_set = remote_set = 1;
13280 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13282 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13284 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13286 else if (unformat (line_input, "vni %d", &vni))
13288 else if (unformat (line_input, "next-ip4"))
13290 else if (unformat (line_input, "next-ip6"))
13292 else if (unformat (line_input, "next-ethernet"))
13294 else if (unformat (line_input, "next-nsh"))
13298 errmsg ("parse error '%U'", format_unformat_error, line_input);
13303 if (local_set == 0)
13305 errmsg ("tunnel local address not specified");
13308 if (remote_set == 0)
13310 errmsg ("tunnel remote address not specified");
13313 if (grp_set && mcast_sw_if_index == ~0)
13315 errmsg ("tunnel nonexistent multicast device");
13318 if (ipv4_set && ipv6_set)
13320 errmsg ("both IPv4 and IPv6 addresses specified");
13326 errmsg ("vni not specified");
13330 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13335 clib_memcpy (&mp->local, &local6, sizeof (local6));
13336 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13340 clib_memcpy (&mp->local, &local4, sizeof (local4));
13341 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13344 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13345 mp->encap_vrf_id = ntohl (encap_vrf_id);
13346 mp->decap_vrf_id = ntohl (decap_vrf_id);
13347 mp->protocol = protocol;
13348 mp->vni = ntohl (vni);
13349 mp->is_add = is_add;
13350 mp->is_ipv6 = ipv6_set;
13357 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13358 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13360 vat_main_t *vam = &vat_main;
13361 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13362 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13364 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13365 ntohl (mp->sw_if_index),
13366 format_ip46_address, &local, IP46_TYPE_ANY,
13367 format_ip46_address, &remote, IP46_TYPE_ANY,
13368 ntohl (mp->vni), mp->protocol,
13369 ntohl (mp->mcast_sw_if_index),
13370 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13374 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13375 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13377 vat_main_t *vam = &vat_main;
13378 vat_json_node_t *node = NULL;
13379 struct in_addr ip4;
13380 struct in6_addr ip6;
13382 if (VAT_JSON_ARRAY != vam->json_tree.type)
13384 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13385 vat_json_init_array (&vam->json_tree);
13387 node = vat_json_array_add (&vam->json_tree);
13389 vat_json_init_object (node);
13390 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13393 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13394 vat_json_object_add_ip6 (node, "local", ip6);
13395 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13396 vat_json_object_add_ip6 (node, "remote", ip6);
13400 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13401 vat_json_object_add_ip4 (node, "local", ip4);
13402 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13403 vat_json_object_add_ip4 (node, "remote", ip4);
13405 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13406 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13407 vat_json_object_add_uint (node, "mcast_sw_if_index",
13408 ntohl (mp->mcast_sw_if_index));
13409 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13410 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13411 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13415 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13417 unformat_input_t *i = vam->input;
13418 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13419 vl_api_control_ping_t *mp_ping;
13421 u8 sw_if_index_set = 0;
13424 /* Parse args required to build the message */
13425 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13427 if (unformat (i, "sw_if_index %d", &sw_if_index))
13428 sw_if_index_set = 1;
13433 if (sw_if_index_set == 0)
13438 if (!vam->json_output)
13440 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13441 "sw_if_index", "local", "remote", "vni",
13442 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13445 /* Get list of vxlan-tunnel interfaces */
13446 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13448 mp->sw_if_index = htonl (sw_if_index);
13452 /* Use a control ping for synchronization */
13453 MPING (CONTROL_PING, mp_ping);
13460 static void vl_api_l2_fib_table_details_t_handler
13461 (vl_api_l2_fib_table_details_t * mp)
13463 vat_main_t *vam = &vat_main;
13465 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13467 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13468 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13472 static void vl_api_l2_fib_table_details_t_handler_json
13473 (vl_api_l2_fib_table_details_t * mp)
13475 vat_main_t *vam = &vat_main;
13476 vat_json_node_t *node = NULL;
13478 if (VAT_JSON_ARRAY != vam->json_tree.type)
13480 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13481 vat_json_init_array (&vam->json_tree);
13483 node = vat_json_array_add (&vam->json_tree);
13485 vat_json_init_object (node);
13486 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13487 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13488 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13489 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13490 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13491 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13495 api_l2_fib_table_dump (vat_main_t * vam)
13497 unformat_input_t *i = vam->input;
13498 vl_api_l2_fib_table_dump_t *mp;
13499 vl_api_control_ping_t *mp_ping;
13504 /* Parse args required to build the message */
13505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13507 if (unformat (i, "bd_id %d", &bd_id))
13513 if (bd_id_set == 0)
13515 errmsg ("missing bridge domain");
13519 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13521 /* Get list of l2 fib entries */
13522 M (L2_FIB_TABLE_DUMP, mp);
13524 mp->bd_id = ntohl (bd_id);
13527 /* Use a control ping for synchronization */
13528 MPING (CONTROL_PING, mp_ping);
13537 api_interface_name_renumber (vat_main_t * vam)
13539 unformat_input_t *line_input = vam->input;
13540 vl_api_interface_name_renumber_t *mp;
13541 u32 sw_if_index = ~0;
13542 u32 new_show_dev_instance = ~0;
13545 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13547 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13550 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13552 else if (unformat (line_input, "new_show_dev_instance %d",
13553 &new_show_dev_instance))
13559 if (sw_if_index == ~0)
13561 errmsg ("missing interface name or sw_if_index");
13565 if (new_show_dev_instance == ~0)
13567 errmsg ("missing new_show_dev_instance");
13571 M (INTERFACE_NAME_RENUMBER, mp);
13573 mp->sw_if_index = ntohl (sw_if_index);
13574 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13582 api_ip_probe_neighbor (vat_main_t * vam)
13584 unformat_input_t *i = vam->input;
13585 vl_api_ip_probe_neighbor_t *mp;
13586 vl_api_address_t dst_adr = { };
13592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13594 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13596 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13598 else if (unformat (i, "address %U", unformat_vl_api_address, &dst_adr))
13606 errmsg ("missing interface");
13612 errmsg ("missing addresses");
13616 M (IP_PROBE_NEIGHBOR, mp);
13618 mp->sw_if_index = ntohl (sw_if_index);
13619 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
13627 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
13629 unformat_input_t *i = vam->input;
13630 vl_api_ip_scan_neighbor_enable_disable_t *mp;
13631 u8 mode = IP_SCAN_V46_NEIGHBORS;
13632 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
13635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13637 if (unformat (i, "ip4"))
13638 mode = IP_SCAN_V4_NEIGHBORS;
13639 else if (unformat (i, "ip6"))
13640 mode = IP_SCAN_V6_NEIGHBORS;
13641 if (unformat (i, "both"))
13642 mode = IP_SCAN_V46_NEIGHBORS;
13643 else if (unformat (i, "disable"))
13644 mode = IP_SCAN_DISABLED;
13645 else if (unformat (i, "interval %d", &interval))
13647 else if (unformat (i, "max-time %d", &time))
13649 else if (unformat (i, "max-update %d", &update))
13651 else if (unformat (i, "delay %d", &delay))
13653 else if (unformat (i, "stale %d", &stale))
13659 if (interval > 255)
13661 errmsg ("interval cannot exceed 255 minutes.");
13666 errmsg ("max-time cannot exceed 255 usec.");
13671 errmsg ("max-update cannot exceed 255.");
13676 errmsg ("delay cannot exceed 255 msec.");
13681 errmsg ("stale cannot exceed 255 minutes.");
13685 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
13687 mp->scan_interval = interval;
13688 mp->max_proc_time = time;
13689 mp->max_update = update;
13690 mp->scan_int_delay = delay;
13691 mp->stale_threshold = stale;
13699 api_want_ip4_arp_events (vat_main_t * vam)
13701 unformat_input_t *line_input = vam->input;
13702 vl_api_want_ip4_arp_events_t *mp;
13703 ip4_address_t address;
13704 int address_set = 0;
13705 u32 enable_disable = 1;
13708 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13710 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13712 else if (unformat (line_input, "del"))
13713 enable_disable = 0;
13718 if (address_set == 0)
13720 errmsg ("missing addresses");
13724 M (WANT_IP4_ARP_EVENTS, mp);
13725 mp->enable_disable = enable_disable;
13726 mp->pid = htonl (getpid ());
13727 clib_memcpy (mp->ip, &address, sizeof (address));
13735 api_want_ip6_nd_events (vat_main_t * vam)
13737 unformat_input_t *line_input = vam->input;
13738 vl_api_want_ip6_nd_events_t *mp;
13739 vl_api_ip6_address_t address;
13740 int address_set = 0;
13741 u32 enable_disable = 1;
13744 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13747 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
13749 else if (unformat (line_input, "del"))
13750 enable_disable = 0;
13755 if (address_set == 0)
13757 errmsg ("missing addresses");
13761 M (WANT_IP6_ND_EVENTS, mp);
13762 mp->enable_disable = enable_disable;
13763 mp->pid = htonl (getpid ());
13764 clib_memcpy (&mp->ip, &address, sizeof (address));
13772 api_want_l2_macs_events (vat_main_t * vam)
13774 unformat_input_t *line_input = vam->input;
13775 vl_api_want_l2_macs_events_t *mp;
13776 u8 enable_disable = 1;
13777 u32 scan_delay = 0;
13778 u32 max_macs_in_event = 0;
13779 u32 learn_limit = 0;
13782 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13784 if (unformat (line_input, "learn-limit %d", &learn_limit))
13786 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13788 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13790 else if (unformat (line_input, "disable"))
13791 enable_disable = 0;
13796 M (WANT_L2_MACS_EVENTS, mp);
13797 mp->enable_disable = enable_disable;
13798 mp->pid = htonl (getpid ());
13799 mp->learn_limit = htonl (learn_limit);
13800 mp->scan_delay = (u8) scan_delay;
13801 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13808 api_input_acl_set_interface (vat_main_t * vam)
13810 unformat_input_t *i = vam->input;
13811 vl_api_input_acl_set_interface_t *mp;
13813 int sw_if_index_set;
13814 u32 ip4_table_index = ~0;
13815 u32 ip6_table_index = ~0;
13816 u32 l2_table_index = ~0;
13820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13822 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13823 sw_if_index_set = 1;
13824 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13825 sw_if_index_set = 1;
13826 else if (unformat (i, "del"))
13828 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13830 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13832 else if (unformat (i, "l2-table %d", &l2_table_index))
13836 clib_warning ("parse error '%U'", format_unformat_error, i);
13841 if (sw_if_index_set == 0)
13843 errmsg ("missing interface name or sw_if_index");
13847 M (INPUT_ACL_SET_INTERFACE, mp);
13849 mp->sw_if_index = ntohl (sw_if_index);
13850 mp->ip4_table_index = ntohl (ip4_table_index);
13851 mp->ip6_table_index = ntohl (ip6_table_index);
13852 mp->l2_table_index = ntohl (l2_table_index);
13853 mp->is_add = is_add;
13861 api_output_acl_set_interface (vat_main_t * vam)
13863 unformat_input_t *i = vam->input;
13864 vl_api_output_acl_set_interface_t *mp;
13866 int sw_if_index_set;
13867 u32 ip4_table_index = ~0;
13868 u32 ip6_table_index = ~0;
13869 u32 l2_table_index = ~0;
13873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13875 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13876 sw_if_index_set = 1;
13877 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13878 sw_if_index_set = 1;
13879 else if (unformat (i, "del"))
13881 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13883 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13885 else if (unformat (i, "l2-table %d", &l2_table_index))
13889 clib_warning ("parse error '%U'", format_unformat_error, i);
13894 if (sw_if_index_set == 0)
13896 errmsg ("missing interface name or sw_if_index");
13900 M (OUTPUT_ACL_SET_INTERFACE, mp);
13902 mp->sw_if_index = ntohl (sw_if_index);
13903 mp->ip4_table_index = ntohl (ip4_table_index);
13904 mp->ip6_table_index = ntohl (ip6_table_index);
13905 mp->l2_table_index = ntohl (l2_table_index);
13906 mp->is_add = is_add;
13914 api_ip_address_dump (vat_main_t * vam)
13916 unformat_input_t *i = vam->input;
13917 vl_api_ip_address_dump_t *mp;
13918 vl_api_control_ping_t *mp_ping;
13919 u32 sw_if_index = ~0;
13920 u8 sw_if_index_set = 0;
13925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13927 if (unformat (i, "sw_if_index %d", &sw_if_index))
13928 sw_if_index_set = 1;
13930 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13931 sw_if_index_set = 1;
13932 else if (unformat (i, "ipv4"))
13934 else if (unformat (i, "ipv6"))
13940 if (ipv4_set && ipv6_set)
13942 errmsg ("ipv4 and ipv6 flags cannot be both set");
13946 if ((!ipv4_set) && (!ipv6_set))
13948 errmsg ("no ipv4 nor ipv6 flag set");
13952 if (sw_if_index_set == 0)
13954 errmsg ("missing interface name or sw_if_index");
13958 vam->current_sw_if_index = sw_if_index;
13959 vam->is_ipv6 = ipv6_set;
13961 M (IP_ADDRESS_DUMP, mp);
13962 mp->sw_if_index = ntohl (sw_if_index);
13963 mp->is_ipv6 = ipv6_set;
13966 /* Use a control ping for synchronization */
13967 MPING (CONTROL_PING, mp_ping);
13975 api_ip_dump (vat_main_t * vam)
13977 vl_api_ip_dump_t *mp;
13978 vl_api_control_ping_t *mp_ping;
13979 unformat_input_t *in = vam->input;
13986 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13988 if (unformat (in, "ipv4"))
13990 else if (unformat (in, "ipv6"))
13996 if (ipv4_set && ipv6_set)
13998 errmsg ("ipv4 and ipv6 flags cannot be both set");
14002 if ((!ipv4_set) && (!ipv6_set))
14004 errmsg ("no ipv4 nor ipv6 flag set");
14008 is_ipv6 = ipv6_set;
14009 vam->is_ipv6 = is_ipv6;
14011 /* free old data */
14012 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14014 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14016 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14019 mp->is_ipv6 = ipv6_set;
14022 /* Use a control ping for synchronization */
14023 MPING (CONTROL_PING, mp_ping);
14031 api_ipsec_spd_add_del (vat_main_t * vam)
14033 unformat_input_t *i = vam->input;
14034 vl_api_ipsec_spd_add_del_t *mp;
14039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14041 if (unformat (i, "spd_id %d", &spd_id))
14043 else if (unformat (i, "del"))
14047 clib_warning ("parse error '%U'", format_unformat_error, i);
14053 errmsg ("spd_id must be set");
14057 M (IPSEC_SPD_ADD_DEL, mp);
14059 mp->spd_id = ntohl (spd_id);
14060 mp->is_add = is_add;
14068 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14070 unformat_input_t *i = vam->input;
14071 vl_api_ipsec_interface_add_del_spd_t *mp;
14073 u8 sw_if_index_set = 0;
14074 u32 spd_id = (u32) ~ 0;
14078 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14080 if (unformat (i, "del"))
14082 else if (unformat (i, "spd_id %d", &spd_id))
14085 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14086 sw_if_index_set = 1;
14087 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14088 sw_if_index_set = 1;
14091 clib_warning ("parse error '%U'", format_unformat_error, i);
14097 if (spd_id == (u32) ~ 0)
14099 errmsg ("spd_id must be set");
14103 if (sw_if_index_set == 0)
14105 errmsg ("missing interface name or sw_if_index");
14109 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14111 mp->spd_id = ntohl (spd_id);
14112 mp->sw_if_index = ntohl (sw_if_index);
14113 mp->is_add = is_add;
14121 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14123 unformat_input_t *i = vam->input;
14124 vl_api_ipsec_spd_entry_add_del_t *mp;
14125 u8 is_add = 1, is_outbound = 0;
14126 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14128 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14129 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14130 vl_api_address_t laddr_start = { }, laddr_stop =
14139 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14141 if (unformat (i, "del"))
14143 if (unformat (i, "outbound"))
14145 if (unformat (i, "inbound"))
14147 else if (unformat (i, "spd_id %d", &spd_id))
14149 else if (unformat (i, "sa_id %d", &sa_id))
14151 else if (unformat (i, "priority %d", &priority))
14153 else if (unformat (i, "protocol %d", &protocol))
14155 else if (unformat (i, "lport_start %d", &lport_start))
14157 else if (unformat (i, "lport_stop %d", &lport_stop))
14159 else if (unformat (i, "rport_start %d", &rport_start))
14161 else if (unformat (i, "rport_stop %d", &rport_stop))
14163 else if (unformat (i, "laddr_start %U",
14164 unformat_vl_api_address, &laddr_start))
14166 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14169 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14172 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14176 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14178 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14180 clib_warning ("unsupported action: 'resolve'");
14186 clib_warning ("parse error '%U'", format_unformat_error, i);
14192 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14194 mp->is_add = is_add;
14196 mp->entry.spd_id = ntohl (spd_id);
14197 mp->entry.priority = ntohl (priority);
14198 mp->entry.is_outbound = is_outbound;
14200 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14201 sizeof (vl_api_address_t));
14202 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14203 sizeof (vl_api_address_t));
14204 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14205 sizeof (vl_api_address_t));
14206 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14207 sizeof (vl_api_address_t));
14209 mp->entry.protocol = (u8) protocol;
14210 mp->entry.local_port_start = ntohs ((u16) lport_start);
14211 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14212 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14213 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14214 mp->entry.policy = (u8) policy;
14215 mp->entry.sa_id = ntohl (sa_id);
14223 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14225 unformat_input_t *i = vam->input;
14226 vl_api_ipsec_sad_entry_add_del_t *mp;
14227 u32 sad_id = 0, spi = 0;
14228 u8 *ck = 0, *ik = 0;
14231 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14232 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14233 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14234 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14235 vl_api_address_t tun_src, tun_dst;
14238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14240 if (unformat (i, "del"))
14242 else if (unformat (i, "sad_id %d", &sad_id))
14244 else if (unformat (i, "spi %d", &spi))
14246 else if (unformat (i, "esp"))
14247 protocol = IPSEC_API_PROTO_ESP;
14249 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14251 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14252 if (ADDRESS_IP6 == tun_src.af)
14253 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14256 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14258 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14259 if (ADDRESS_IP6 == tun_src.af)
14260 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14263 if (unformat (i, "crypto_alg %U",
14264 unformat_ipsec_api_crypto_alg, &crypto_alg))
14266 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14268 else if (unformat (i, "integ_alg %U",
14269 unformat_ipsec_api_integ_alg, &integ_alg))
14271 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14275 clib_warning ("parse error '%U'", format_unformat_error, i);
14281 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14283 mp->is_add = is_add;
14284 mp->entry.sad_id = ntohl (sad_id);
14285 mp->entry.protocol = protocol;
14286 mp->entry.spi = ntohl (spi);
14287 mp->entry.flags = flags;
14289 mp->entry.crypto_algorithm = crypto_alg;
14290 mp->entry.integrity_algorithm = integ_alg;
14291 mp->entry.crypto_key.length = vec_len (ck);
14292 mp->entry.integrity_key.length = vec_len (ik);
14294 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14295 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14297 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14298 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14301 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14303 clib_memcpy (mp->entry.integrity_key.data, ik,
14304 mp->entry.integrity_key.length);
14306 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14308 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14309 sizeof (mp->entry.tunnel_src));
14310 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14311 sizeof (mp->entry.tunnel_dst));
14320 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14322 unformat_input_t *i = vam->input;
14323 vl_api_ipsec_tunnel_if_add_del_t *mp;
14324 u32 local_spi = 0, remote_spi = 0;
14325 u32 crypto_alg = 0, integ_alg = 0;
14326 u8 *lck = NULL, *rck = NULL;
14327 u8 *lik = NULL, *rik = NULL;
14328 vl_api_address_t local_ip = { 0 };
14329 vl_api_address_t remote_ip = { 0 };
14333 u8 anti_replay = 0;
14339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14341 if (unformat (i, "del"))
14343 else if (unformat (i, "esn"))
14345 else if (unformat (i, "anti-replay"))
14347 else if (unformat (i, "count %d", &count))
14349 else if (unformat (i, "local_spi %d", &local_spi))
14351 else if (unformat (i, "remote_spi %d", &remote_spi))
14354 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
14357 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
14359 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14362 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14364 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14366 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14370 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
14372 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
14374 errmsg ("unsupported crypto-alg: '%U'\n",
14375 format_ipsec_crypto_alg, crypto_alg);
14381 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
14383 if (integ_alg >= IPSEC_INTEG_N_ALG)
14385 errmsg ("unsupported integ-alg: '%U'\n",
14386 format_ipsec_integ_alg, integ_alg);
14390 else if (unformat (i, "instance %u", &instance))
14394 errmsg ("parse error '%U'\n", format_unformat_error, i);
14401 /* Turn on async mode */
14402 vam->async_mode = 1;
14403 vam->async_errors = 0;
14404 before = vat_time_now (vam);
14407 for (jj = 0; jj < count; jj++)
14409 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14411 mp->is_add = is_add;
14413 mp->anti_replay = anti_replay;
14416 increment_address (&remote_ip);
14418 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
14419 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
14421 mp->local_spi = htonl (local_spi + jj);
14422 mp->remote_spi = htonl (remote_spi + jj);
14423 mp->crypto_alg = (u8) crypto_alg;
14425 mp->local_crypto_key_len = 0;
14428 mp->local_crypto_key_len = vec_len (lck);
14429 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14430 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14431 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14434 mp->remote_crypto_key_len = 0;
14437 mp->remote_crypto_key_len = vec_len (rck);
14438 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14439 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14440 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14443 mp->integ_alg = (u8) integ_alg;
14445 mp->local_integ_key_len = 0;
14448 mp->local_integ_key_len = vec_len (lik);
14449 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14450 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14451 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14454 mp->remote_integ_key_len = 0;
14457 mp->remote_integ_key_len = vec_len (rik);
14458 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14459 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14460 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14465 mp->renumber = renumber;
14466 mp->show_instance = ntohl (instance);
14471 /* When testing multiple add/del ops, use a control-ping to sync */
14474 vl_api_control_ping_t *mp_ping;
14478 /* Shut off async mode */
14479 vam->async_mode = 0;
14481 MPING (CONTROL_PING, mp_ping);
14484 timeout = vat_time_now (vam) + 1.0;
14485 while (vat_time_now (vam) < timeout)
14486 if (vam->result_ready == 1)
14491 if (vam->retval == -99)
14492 errmsg ("timeout");
14494 if (vam->async_errors > 0)
14496 errmsg ("%d asynchronous errors", vam->async_errors);
14499 vam->async_errors = 0;
14500 after = vat_time_now (vam);
14502 /* slim chance, but we might have eaten SIGTERM on the first iteration */
14506 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
14507 count, after - before, count / (after - before));
14511 /* Wait for a reply... */
14520 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14522 vat_main_t *vam = &vat_main;
14524 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14525 "crypto_key %U integ_alg %u integ_key %U flags %x "
14526 "tunnel_src_addr %U tunnel_dst_addr %U "
14527 "salt %u seq_outbound %lu last_seq_inbound %lu "
14528 "replay_window %lu\n",
14529 ntohl (mp->entry.sad_id),
14530 ntohl (mp->sw_if_index),
14531 ntohl (mp->entry.spi),
14532 ntohl (mp->entry.protocol),
14533 ntohl (mp->entry.crypto_algorithm),
14534 format_hex_bytes, mp->entry.crypto_key.data,
14535 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
14536 format_hex_bytes, mp->entry.integrity_key.data,
14537 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
14538 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
14539 &mp->entry.tunnel_dst, ntohl (mp->salt),
14540 clib_net_to_host_u64 (mp->seq_outbound),
14541 clib_net_to_host_u64 (mp->last_seq_inbound),
14542 clib_net_to_host_u64 (mp->replay_window));
14545 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14546 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14548 static void vl_api_ipsec_sa_details_t_handler_json
14549 (vl_api_ipsec_sa_details_t * mp)
14551 vat_main_t *vam = &vat_main;
14552 vat_json_node_t *node = NULL;
14553 vl_api_ipsec_sad_flags_t flags;
14555 if (VAT_JSON_ARRAY != vam->json_tree.type)
14557 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14558 vat_json_init_array (&vam->json_tree);
14560 node = vat_json_array_add (&vam->json_tree);
14562 vat_json_init_object (node);
14563 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
14564 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14565 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
14566 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
14567 vat_json_object_add_uint (node, "crypto_alg",
14568 ntohl (mp->entry.crypto_algorithm));
14569 vat_json_object_add_uint (node, "integ_alg",
14570 ntohl (mp->entry.integrity_algorithm));
14571 flags = ntohl (mp->entry.flags);
14572 vat_json_object_add_uint (node, "use_esn",
14573 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
14574 vat_json_object_add_uint (node, "use_anti_replay",
14575 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
14576 vat_json_object_add_uint (node, "is_tunnel",
14577 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
14578 vat_json_object_add_uint (node, "is_tunnel_ip6",
14579 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
14580 vat_json_object_add_uint (node, "udp_encap",
14581 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
14582 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
14583 mp->entry.crypto_key.length);
14584 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
14585 mp->entry.integrity_key.length);
14586 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
14587 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
14588 vat_json_object_add_uint (node, "replay_window",
14589 clib_net_to_host_u64 (mp->replay_window));
14593 api_ipsec_sa_dump (vat_main_t * vam)
14595 unformat_input_t *i = vam->input;
14596 vl_api_ipsec_sa_dump_t *mp;
14597 vl_api_control_ping_t *mp_ping;
14601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14603 if (unformat (i, "sa_id %d", &sa_id))
14607 clib_warning ("parse error '%U'", format_unformat_error, i);
14612 M (IPSEC_SA_DUMP, mp);
14614 mp->sa_id = ntohl (sa_id);
14618 /* Use a control ping for synchronization */
14619 M (CONTROL_PING, mp_ping);
14627 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14629 unformat_input_t *i = vam->input;
14630 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14631 u32 sw_if_index = ~0;
14633 u8 is_outbound = (u8) ~ 0;
14636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14638 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14640 else if (unformat (i, "sa_id %d", &sa_id))
14642 else if (unformat (i, "outbound"))
14644 else if (unformat (i, "inbound"))
14648 clib_warning ("parse error '%U'", format_unformat_error, i);
14653 if (sw_if_index == ~0)
14655 errmsg ("interface must be specified");
14661 errmsg ("SA ID must be specified");
14665 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14667 mp->sw_if_index = htonl (sw_if_index);
14668 mp->sa_id = htonl (sa_id);
14669 mp->is_outbound = is_outbound;
14678 api_get_first_msg_id (vat_main_t * vam)
14680 vl_api_get_first_msg_id_t *mp;
14681 unformat_input_t *i = vam->input;
14686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14688 if (unformat (i, "client %s", &name))
14696 errmsg ("missing client name");
14699 vec_add1 (name, 0);
14701 if (vec_len (name) > 63)
14703 errmsg ("client name too long");
14707 M (GET_FIRST_MSG_ID, mp);
14708 clib_memcpy (mp->name, name, vec_len (name));
14715 api_cop_interface_enable_disable (vat_main_t * vam)
14717 unformat_input_t *line_input = vam->input;
14718 vl_api_cop_interface_enable_disable_t *mp;
14719 u32 sw_if_index = ~0;
14720 u8 enable_disable = 1;
14723 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14725 if (unformat (line_input, "disable"))
14726 enable_disable = 0;
14727 if (unformat (line_input, "enable"))
14728 enable_disable = 1;
14729 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14730 vam, &sw_if_index))
14732 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14738 if (sw_if_index == ~0)
14740 errmsg ("missing interface name or sw_if_index");
14744 /* Construct the API message */
14745 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14746 mp->sw_if_index = ntohl (sw_if_index);
14747 mp->enable_disable = enable_disable;
14751 /* Wait for the reply */
14757 api_cop_whitelist_enable_disable (vat_main_t * vam)
14759 unformat_input_t *line_input = vam->input;
14760 vl_api_cop_whitelist_enable_disable_t *mp;
14761 u32 sw_if_index = ~0;
14762 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14766 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14768 if (unformat (line_input, "ip4"))
14770 else if (unformat (line_input, "ip6"))
14772 else if (unformat (line_input, "default"))
14774 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14775 vam, &sw_if_index))
14777 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14779 else if (unformat (line_input, "fib-id %d", &fib_id))
14785 if (sw_if_index == ~0)
14787 errmsg ("missing interface name or sw_if_index");
14791 /* Construct the API message */
14792 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14793 mp->sw_if_index = ntohl (sw_if_index);
14794 mp->fib_id = ntohl (fib_id);
14797 mp->default_cop = default_cop;
14801 /* Wait for the reply */
14807 api_get_node_graph (vat_main_t * vam)
14809 vl_api_get_node_graph_t *mp;
14812 M (GET_NODE_GRAPH, mp);
14816 /* Wait for the reply */
14822 /** Used for parsing LISP eids */
14823 typedef CLIB_PACKED(struct{
14824 u8 addr[16]; /**< eid address */
14825 u32 len; /**< prefix length if IP */
14826 u8 type; /**< type of eid */
14831 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14833 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14835 clib_memset (a, 0, sizeof (a[0]));
14837 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14839 a->type = 0; /* ipv4 type */
14841 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14843 a->type = 1; /* ipv6 type */
14845 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14847 a->type = 2; /* mac type */
14849 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14851 a->type = 3; /* NSH type */
14852 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14853 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14860 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14869 lisp_eid_size_vat (u8 type)
14886 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14888 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14892 api_one_add_del_locator_set (vat_main_t * vam)
14894 unformat_input_t *input = vam->input;
14895 vl_api_one_add_del_locator_set_t *mp;
14897 u8 *locator_set_name = NULL;
14898 u8 locator_set_name_set = 0;
14899 vl_api_local_locator_t locator, *locators = 0;
14900 u32 sw_if_index, priority, weight;
14904 /* Parse args required to build the message */
14905 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14907 if (unformat (input, "del"))
14911 else if (unformat (input, "locator-set %s", &locator_set_name))
14913 locator_set_name_set = 1;
14915 else if (unformat (input, "sw_if_index %u p %u w %u",
14916 &sw_if_index, &priority, &weight))
14918 locator.sw_if_index = htonl (sw_if_index);
14919 locator.priority = priority;
14920 locator.weight = weight;
14921 vec_add1 (locators, locator);
14925 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14926 &sw_if_index, &priority, &weight))
14928 locator.sw_if_index = htonl (sw_if_index);
14929 locator.priority = priority;
14930 locator.weight = weight;
14931 vec_add1 (locators, locator);
14937 if (locator_set_name_set == 0)
14939 errmsg ("missing locator-set name");
14940 vec_free (locators);
14944 if (vec_len (locator_set_name) > 64)
14946 errmsg ("locator-set name too long");
14947 vec_free (locator_set_name);
14948 vec_free (locators);
14951 vec_add1 (locator_set_name, 0);
14953 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14955 /* Construct the API message */
14956 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14958 mp->is_add = is_add;
14959 clib_memcpy (mp->locator_set_name, locator_set_name,
14960 vec_len (locator_set_name));
14961 vec_free (locator_set_name);
14963 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14965 clib_memcpy (mp->locators, locators, data_len);
14966 vec_free (locators);
14971 /* Wait for a reply... */
14976 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14979 api_one_add_del_locator (vat_main_t * vam)
14981 unformat_input_t *input = vam->input;
14982 vl_api_one_add_del_locator_t *mp;
14983 u32 tmp_if_index = ~0;
14984 u32 sw_if_index = ~0;
14985 u8 sw_if_index_set = 0;
14986 u8 sw_if_index_if_name_set = 0;
14988 u8 priority_set = 0;
14992 u8 *locator_set_name = NULL;
14993 u8 locator_set_name_set = 0;
14996 /* Parse args required to build the message */
14997 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14999 if (unformat (input, "del"))
15003 else if (unformat (input, "locator-set %s", &locator_set_name))
15005 locator_set_name_set = 1;
15007 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15010 sw_if_index_if_name_set = 1;
15011 sw_if_index = tmp_if_index;
15013 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15015 sw_if_index_set = 1;
15016 sw_if_index = tmp_if_index;
15018 else if (unformat (input, "p %d", &priority))
15022 else if (unformat (input, "w %d", &weight))
15030 if (locator_set_name_set == 0)
15032 errmsg ("missing locator-set name");
15036 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15038 errmsg ("missing sw_if_index");
15039 vec_free (locator_set_name);
15043 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15045 errmsg ("cannot use both params interface name and sw_if_index");
15046 vec_free (locator_set_name);
15050 if (priority_set == 0)
15052 errmsg ("missing locator-set priority");
15053 vec_free (locator_set_name);
15057 if (weight_set == 0)
15059 errmsg ("missing locator-set weight");
15060 vec_free (locator_set_name);
15064 if (vec_len (locator_set_name) > 64)
15066 errmsg ("locator-set name too long");
15067 vec_free (locator_set_name);
15070 vec_add1 (locator_set_name, 0);
15072 /* Construct the API message */
15073 M (ONE_ADD_DEL_LOCATOR, mp);
15075 mp->is_add = is_add;
15076 mp->sw_if_index = ntohl (sw_if_index);
15077 mp->priority = priority;
15078 mp->weight = weight;
15079 clib_memcpy (mp->locator_set_name, locator_set_name,
15080 vec_len (locator_set_name));
15081 vec_free (locator_set_name);
15086 /* Wait for a reply... */
15091 #define api_lisp_add_del_locator api_one_add_del_locator
15094 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15096 u32 *key_id = va_arg (*args, u32 *);
15099 if (unformat (input, "%s", &s))
15101 if (!strcmp ((char *) s, "sha1"))
15102 key_id[0] = HMAC_SHA_1_96;
15103 else if (!strcmp ((char *) s, "sha256"))
15104 key_id[0] = HMAC_SHA_256_128;
15107 clib_warning ("invalid key_id: '%s'", s);
15108 key_id[0] = HMAC_NO_KEY;
15119 api_one_add_del_local_eid (vat_main_t * vam)
15121 unformat_input_t *input = vam->input;
15122 vl_api_one_add_del_local_eid_t *mp;
15125 lisp_eid_vat_t _eid, *eid = &_eid;
15126 u8 *locator_set_name = 0;
15127 u8 locator_set_name_set = 0;
15133 /* Parse args required to build the message */
15134 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15136 if (unformat (input, "del"))
15140 else if (unformat (input, "vni %d", &vni))
15144 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15148 else if (unformat (input, "locator-set %s", &locator_set_name))
15150 locator_set_name_set = 1;
15152 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15154 else if (unformat (input, "secret-key %_%v%_", &key))
15160 if (locator_set_name_set == 0)
15162 errmsg ("missing locator-set name");
15168 errmsg ("EID address not set!");
15169 vec_free (locator_set_name);
15173 if (key && (0 == key_id))
15175 errmsg ("invalid key_id!");
15179 if (vec_len (key) > 64)
15181 errmsg ("key too long");
15186 if (vec_len (locator_set_name) > 64)
15188 errmsg ("locator-set name too long");
15189 vec_free (locator_set_name);
15192 vec_add1 (locator_set_name, 0);
15194 /* Construct the API message */
15195 M (ONE_ADD_DEL_LOCAL_EID, mp);
15197 mp->is_add = is_add;
15198 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15199 mp->eid_type = eid->type;
15200 mp->prefix_len = eid->len;
15201 mp->vni = clib_host_to_net_u32 (vni);
15202 mp->key_id = clib_host_to_net_u16 (key_id);
15203 clib_memcpy (mp->locator_set_name, locator_set_name,
15204 vec_len (locator_set_name));
15205 clib_memcpy (mp->key, key, vec_len (key));
15207 vec_free (locator_set_name);
15213 /* Wait for a reply... */
15218 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15221 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15223 u32 dp_table = 0, vni = 0;;
15224 unformat_input_t *input = vam->input;
15225 vl_api_gpe_add_del_fwd_entry_t *mp;
15227 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15228 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15229 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15230 u32 action = ~0, w;
15231 ip4_address_t rmt_rloc4, lcl_rloc4;
15232 ip6_address_t rmt_rloc6, lcl_rloc6;
15233 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15236 clib_memset (&rloc, 0, sizeof (rloc));
15238 /* Parse args required to build the message */
15239 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15241 if (unformat (input, "del"))
15243 else if (unformat (input, "add"))
15245 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15249 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15253 else if (unformat (input, "vrf %d", &dp_table))
15255 else if (unformat (input, "bd %d", &dp_table))
15257 else if (unformat (input, "vni %d", &vni))
15259 else if (unformat (input, "w %d", &w))
15263 errmsg ("No RLOC configured for setting priority/weight!");
15266 curr_rloc->weight = w;
15268 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15269 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15273 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15275 vec_add1 (lcl_locs, rloc);
15277 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15278 vec_add1 (rmt_locs, rloc);
15279 /* weight saved in rmt loc */
15280 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15282 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15283 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15286 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15288 vec_add1 (lcl_locs, rloc);
15290 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15291 vec_add1 (rmt_locs, rloc);
15292 /* weight saved in rmt loc */
15293 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15295 else if (unformat (input, "action %d", &action))
15301 clib_warning ("parse error '%U'", format_unformat_error, input);
15308 errmsg ("remote eid addresses not set");
15312 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15314 errmsg ("eid types don't match");
15318 if (0 == rmt_locs && (u32) ~ 0 == action)
15320 errmsg ("action not set for negative mapping");
15324 /* Construct the API message */
15325 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15326 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15328 mp->is_add = is_add;
15329 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15330 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15331 mp->eid_type = rmt_eid->type;
15332 mp->dp_table = clib_host_to_net_u32 (dp_table);
15333 mp->vni = clib_host_to_net_u32 (vni);
15334 mp->rmt_len = rmt_eid->len;
15335 mp->lcl_len = lcl_eid->len;
15336 mp->action = action;
15338 if (0 != rmt_locs && 0 != lcl_locs)
15340 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15341 clib_memcpy (mp->locs, lcl_locs,
15342 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15344 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15345 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15346 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15348 vec_free (lcl_locs);
15349 vec_free (rmt_locs);
15354 /* Wait for a reply... */
15360 api_one_add_del_map_server (vat_main_t * vam)
15362 unformat_input_t *input = vam->input;
15363 vl_api_one_add_del_map_server_t *mp;
15367 ip4_address_t ipv4;
15368 ip6_address_t ipv6;
15371 /* Parse args required to build the message */
15372 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15374 if (unformat (input, "del"))
15378 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15382 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15390 if (ipv4_set && ipv6_set)
15392 errmsg ("both eid v4 and v6 addresses set");
15396 if (!ipv4_set && !ipv6_set)
15398 errmsg ("eid addresses not set");
15402 /* Construct the API message */
15403 M (ONE_ADD_DEL_MAP_SERVER, mp);
15405 mp->is_add = is_add;
15409 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15414 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15420 /* Wait for a reply... */
15425 #define api_lisp_add_del_map_server api_one_add_del_map_server
15428 api_one_add_del_map_resolver (vat_main_t * vam)
15430 unformat_input_t *input = vam->input;
15431 vl_api_one_add_del_map_resolver_t *mp;
15435 ip4_address_t ipv4;
15436 ip6_address_t ipv6;
15439 /* Parse args required to build the message */
15440 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15442 if (unformat (input, "del"))
15446 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15450 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15458 if (ipv4_set && ipv6_set)
15460 errmsg ("both eid v4 and v6 addresses set");
15464 if (!ipv4_set && !ipv6_set)
15466 errmsg ("eid addresses not set");
15470 /* Construct the API message */
15471 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15473 mp->is_add = is_add;
15477 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15482 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15488 /* Wait for a reply... */
15493 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15496 api_lisp_gpe_enable_disable (vat_main_t * vam)
15498 unformat_input_t *input = vam->input;
15499 vl_api_gpe_enable_disable_t *mp;
15504 /* Parse args required to build the message */
15505 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15507 if (unformat (input, "enable"))
15512 else if (unformat (input, "disable"))
15523 errmsg ("Value not set");
15527 /* Construct the API message */
15528 M (GPE_ENABLE_DISABLE, mp);
15535 /* Wait for a reply... */
15541 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15543 unformat_input_t *input = vam->input;
15544 vl_api_one_rloc_probe_enable_disable_t *mp;
15549 /* Parse args required to build the message */
15550 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15552 if (unformat (input, "enable"))
15557 else if (unformat (input, "disable"))
15565 errmsg ("Value not set");
15569 /* Construct the API message */
15570 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15572 mp->is_enabled = is_en;
15577 /* Wait for a reply... */
15582 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15585 api_one_map_register_enable_disable (vat_main_t * vam)
15587 unformat_input_t *input = vam->input;
15588 vl_api_one_map_register_enable_disable_t *mp;
15593 /* Parse args required to build the message */
15594 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15596 if (unformat (input, "enable"))
15601 else if (unformat (input, "disable"))
15609 errmsg ("Value not set");
15613 /* Construct the API message */
15614 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15616 mp->is_enabled = is_en;
15621 /* Wait for a reply... */
15626 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15629 api_one_enable_disable (vat_main_t * vam)
15631 unformat_input_t *input = vam->input;
15632 vl_api_one_enable_disable_t *mp;
15637 /* Parse args required to build the message */
15638 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15640 if (unformat (input, "enable"))
15645 else if (unformat (input, "disable"))
15655 errmsg ("Value not set");
15659 /* Construct the API message */
15660 M (ONE_ENABLE_DISABLE, mp);
15667 /* Wait for a reply... */
15672 #define api_lisp_enable_disable api_one_enable_disable
15675 api_one_enable_disable_xtr_mode (vat_main_t * vam)
15677 unformat_input_t *input = vam->input;
15678 vl_api_one_enable_disable_xtr_mode_t *mp;
15683 /* Parse args required to build the message */
15684 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15686 if (unformat (input, "enable"))
15691 else if (unformat (input, "disable"))
15701 errmsg ("Value not set");
15705 /* Construct the API message */
15706 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
15713 /* Wait for a reply... */
15719 api_one_show_xtr_mode (vat_main_t * vam)
15721 vl_api_one_show_xtr_mode_t *mp;
15724 /* Construct the API message */
15725 M (ONE_SHOW_XTR_MODE, mp);
15730 /* Wait for a reply... */
15736 api_one_enable_disable_pitr_mode (vat_main_t * vam)
15738 unformat_input_t *input = vam->input;
15739 vl_api_one_enable_disable_pitr_mode_t *mp;
15744 /* Parse args required to build the message */
15745 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15747 if (unformat (input, "enable"))
15752 else if (unformat (input, "disable"))
15762 errmsg ("Value not set");
15766 /* Construct the API message */
15767 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
15774 /* Wait for a reply... */
15780 api_one_show_pitr_mode (vat_main_t * vam)
15782 vl_api_one_show_pitr_mode_t *mp;
15785 /* Construct the API message */
15786 M (ONE_SHOW_PITR_MODE, mp);
15791 /* Wait for a reply... */
15797 api_one_enable_disable_petr_mode (vat_main_t * vam)
15799 unformat_input_t *input = vam->input;
15800 vl_api_one_enable_disable_petr_mode_t *mp;
15805 /* Parse args required to build the message */
15806 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15808 if (unformat (input, "enable"))
15813 else if (unformat (input, "disable"))
15823 errmsg ("Value not set");
15827 /* Construct the API message */
15828 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
15835 /* Wait for a reply... */
15841 api_one_show_petr_mode (vat_main_t * vam)
15843 vl_api_one_show_petr_mode_t *mp;
15846 /* Construct the API message */
15847 M (ONE_SHOW_PETR_MODE, mp);
15852 /* Wait for a reply... */
15858 api_show_one_map_register_state (vat_main_t * vam)
15860 vl_api_show_one_map_register_state_t *mp;
15863 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15868 /* wait for reply */
15873 #define api_show_lisp_map_register_state api_show_one_map_register_state
15876 api_show_one_rloc_probe_state (vat_main_t * vam)
15878 vl_api_show_one_rloc_probe_state_t *mp;
15881 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15886 /* wait for reply */
15891 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15894 api_one_add_del_ndp_entry (vat_main_t * vam)
15896 vl_api_one_add_del_ndp_entry_t *mp;
15897 unformat_input_t *input = vam->input;
15902 u8 mac[6] = { 0, };
15903 u8 ip6[16] = { 0, };
15907 /* Parse args required to build the message */
15908 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15910 if (unformat (input, "del"))
15912 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15914 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15916 else if (unformat (input, "bd %d", &bd))
15920 errmsg ("parse error '%U'", format_unformat_error, input);
15925 if (!bd_set || !ip_set || (!mac_set && is_add))
15927 errmsg ("Missing BD, IP or MAC!");
15931 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15932 mp->is_add = is_add;
15933 clib_memcpy (mp->mac, mac, 6);
15934 mp->bd = clib_host_to_net_u32 (bd);
15935 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
15940 /* wait for reply */
15946 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15948 vl_api_one_add_del_l2_arp_entry_t *mp;
15949 unformat_input_t *input = vam->input;
15954 u8 mac[6] = { 0, };
15955 u32 ip4 = 0, bd = ~0;
15958 /* Parse args required to build the message */
15959 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15961 if (unformat (input, "del"))
15963 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15965 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15967 else if (unformat (input, "bd %d", &bd))
15971 errmsg ("parse error '%U'", format_unformat_error, input);
15976 if (!bd_set || !ip_set || (!mac_set && is_add))
15978 errmsg ("Missing BD, IP or MAC!");
15982 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15983 mp->is_add = is_add;
15984 clib_memcpy (mp->mac, mac, 6);
15985 mp->bd = clib_host_to_net_u32 (bd);
15991 /* wait for reply */
15997 api_one_ndp_bd_get (vat_main_t * vam)
15999 vl_api_one_ndp_bd_get_t *mp;
16002 M (ONE_NDP_BD_GET, mp);
16007 /* wait for reply */
16013 api_one_ndp_entries_get (vat_main_t * vam)
16015 vl_api_one_ndp_entries_get_t *mp;
16016 unformat_input_t *input = vam->input;
16021 /* Parse args required to build the message */
16022 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16024 if (unformat (input, "bd %d", &bd))
16028 errmsg ("parse error '%U'", format_unformat_error, input);
16035 errmsg ("Expected bridge domain!");
16039 M (ONE_NDP_ENTRIES_GET, mp);
16040 mp->bd = clib_host_to_net_u32 (bd);
16045 /* wait for reply */
16051 api_one_l2_arp_bd_get (vat_main_t * vam)
16053 vl_api_one_l2_arp_bd_get_t *mp;
16056 M (ONE_L2_ARP_BD_GET, mp);
16061 /* wait for reply */
16067 api_one_l2_arp_entries_get (vat_main_t * vam)
16069 vl_api_one_l2_arp_entries_get_t *mp;
16070 unformat_input_t *input = vam->input;
16075 /* Parse args required to build the message */
16076 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16078 if (unformat (input, "bd %d", &bd))
16082 errmsg ("parse error '%U'", format_unformat_error, input);
16089 errmsg ("Expected bridge domain!");
16093 M (ONE_L2_ARP_ENTRIES_GET, mp);
16094 mp->bd = clib_host_to_net_u32 (bd);
16099 /* wait for reply */
16105 api_one_stats_enable_disable (vat_main_t * vam)
16107 vl_api_one_stats_enable_disable_t *mp;
16108 unformat_input_t *input = vam->input;
16113 /* Parse args required to build the message */
16114 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16116 if (unformat (input, "enable"))
16121 else if (unformat (input, "disable"))
16131 errmsg ("Value not set");
16135 M (ONE_STATS_ENABLE_DISABLE, mp);
16141 /* wait for reply */
16147 api_show_one_stats_enable_disable (vat_main_t * vam)
16149 vl_api_show_one_stats_enable_disable_t *mp;
16152 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16157 /* wait for reply */
16163 api_show_one_map_request_mode (vat_main_t * vam)
16165 vl_api_show_one_map_request_mode_t *mp;
16168 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16173 /* wait for reply */
16178 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16181 api_one_map_request_mode (vat_main_t * vam)
16183 unformat_input_t *input = vam->input;
16184 vl_api_one_map_request_mode_t *mp;
16188 /* Parse args required to build the message */
16189 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16191 if (unformat (input, "dst-only"))
16193 else if (unformat (input, "src-dst"))
16197 errmsg ("parse error '%U'", format_unformat_error, input);
16202 M (ONE_MAP_REQUEST_MODE, mp);
16209 /* wait for reply */
16214 #define api_lisp_map_request_mode api_one_map_request_mode
16217 * Enable/disable ONE proxy ITR.
16219 * @param vam vpp API test context
16220 * @return return code
16223 api_one_pitr_set_locator_set (vat_main_t * vam)
16225 u8 ls_name_set = 0;
16226 unformat_input_t *input = vam->input;
16227 vl_api_one_pitr_set_locator_set_t *mp;
16232 /* Parse args required to build the message */
16233 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16235 if (unformat (input, "del"))
16237 else if (unformat (input, "locator-set %s", &ls_name))
16241 errmsg ("parse error '%U'", format_unformat_error, input);
16248 errmsg ("locator-set name not set!");
16252 M (ONE_PITR_SET_LOCATOR_SET, mp);
16254 mp->is_add = is_add;
16255 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16256 vec_free (ls_name);
16261 /* wait for reply */
16266 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16269 api_one_nsh_set_locator_set (vat_main_t * vam)
16271 u8 ls_name_set = 0;
16272 unformat_input_t *input = vam->input;
16273 vl_api_one_nsh_set_locator_set_t *mp;
16278 /* Parse args required to build the message */
16279 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16281 if (unformat (input, "del"))
16283 else if (unformat (input, "ls %s", &ls_name))
16287 errmsg ("parse error '%U'", format_unformat_error, input);
16292 if (!ls_name_set && is_add)
16294 errmsg ("locator-set name not set!");
16298 M (ONE_NSH_SET_LOCATOR_SET, mp);
16300 mp->is_add = is_add;
16301 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16302 vec_free (ls_name);
16307 /* wait for reply */
16313 api_show_one_pitr (vat_main_t * vam)
16315 vl_api_show_one_pitr_t *mp;
16318 if (!vam->json_output)
16320 print (vam->ofp, "%=20s", "lisp status:");
16323 M (SHOW_ONE_PITR, mp);
16327 /* Wait for a reply... */
16332 #define api_show_lisp_pitr api_show_one_pitr
16335 api_one_use_petr (vat_main_t * vam)
16337 unformat_input_t *input = vam->input;
16338 vl_api_one_use_petr_t *mp;
16343 clib_memset (&ip, 0, sizeof (ip));
16345 /* Parse args required to build the message */
16346 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16348 if (unformat (input, "disable"))
16351 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16354 ip_addr_version (&ip) = AF_IP4;
16357 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16360 ip_addr_version (&ip) = AF_IP6;
16364 errmsg ("parse error '%U'", format_unformat_error, input);
16369 M (ONE_USE_PETR, mp);
16371 mp->is_add = is_add;
16374 mp->is_ip4 = ip_addr_version (&ip) == AF_IP4 ? 1 : 0;
16376 clib_memcpy (mp->address, &ip, 4);
16378 clib_memcpy (mp->address, &ip, 16);
16384 /* wait for reply */
16389 #define api_lisp_use_petr api_one_use_petr
16392 api_show_one_nsh_mapping (vat_main_t * vam)
16394 vl_api_show_one_use_petr_t *mp;
16397 if (!vam->json_output)
16399 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16402 M (SHOW_ONE_NSH_MAPPING, mp);
16406 /* Wait for a reply... */
16412 api_show_one_use_petr (vat_main_t * vam)
16414 vl_api_show_one_use_petr_t *mp;
16417 if (!vam->json_output)
16419 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16422 M (SHOW_ONE_USE_PETR, mp);
16426 /* Wait for a reply... */
16431 #define api_show_lisp_use_petr api_show_one_use_petr
16434 * Add/delete mapping between vni and vrf
16437 api_one_eid_table_add_del_map (vat_main_t * vam)
16439 unformat_input_t *input = vam->input;
16440 vl_api_one_eid_table_add_del_map_t *mp;
16441 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16442 u32 vni, vrf, bd_index;
16445 /* Parse args required to build the message */
16446 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16448 if (unformat (input, "del"))
16450 else if (unformat (input, "vrf %d", &vrf))
16452 else if (unformat (input, "bd_index %d", &bd_index))
16454 else if (unformat (input, "vni %d", &vni))
16460 if (!vni_set || (!vrf_set && !bd_index_set))
16462 errmsg ("missing arguments!");
16466 if (vrf_set && bd_index_set)
16468 errmsg ("error: both vrf and bd entered!");
16472 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16474 mp->is_add = is_add;
16475 mp->vni = htonl (vni);
16476 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16477 mp->is_l2 = bd_index_set;
16482 /* wait for reply */
16487 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16490 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16492 u32 *action = va_arg (*args, u32 *);
16495 if (unformat (input, "%s", &s))
16497 if (!strcmp ((char *) s, "no-action"))
16499 else if (!strcmp ((char *) s, "natively-forward"))
16501 else if (!strcmp ((char *) s, "send-map-request"))
16503 else if (!strcmp ((char *) s, "drop"))
16507 clib_warning ("invalid action: '%s'", s);
16519 * Add/del remote mapping to/from ONE control plane
16521 * @param vam vpp API test context
16522 * @return return code
16525 api_one_add_del_remote_mapping (vat_main_t * vam)
16527 unformat_input_t *input = vam->input;
16528 vl_api_one_add_del_remote_mapping_t *mp;
16530 lisp_eid_vat_t _eid, *eid = &_eid;
16531 lisp_eid_vat_t _seid, *seid = &_seid;
16532 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16533 u32 action = ~0, p, w, data_len;
16534 ip4_address_t rloc4;
16535 ip6_address_t rloc6;
16536 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16539 clib_memset (&rloc, 0, sizeof (rloc));
16541 /* Parse args required to build the message */
16542 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16544 if (unformat (input, "del-all"))
16548 else if (unformat (input, "del"))
16552 else if (unformat (input, "add"))
16556 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16560 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16564 else if (unformat (input, "vni %d", &vni))
16568 else if (unformat (input, "p %d w %d", &p, &w))
16572 errmsg ("No RLOC configured for setting priority/weight!");
16575 curr_rloc->priority = p;
16576 curr_rloc->weight = w;
16578 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16581 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16582 vec_add1 (rlocs, rloc);
16583 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16585 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16588 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16589 vec_add1 (rlocs, rloc);
16590 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16592 else if (unformat (input, "action %U",
16593 unformat_negative_mapping_action, &action))
16599 clib_warning ("parse error '%U'", format_unformat_error, input);
16606 errmsg ("missing params!");
16610 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16612 errmsg ("no action set for negative map-reply!");
16616 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16618 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16619 mp->is_add = is_add;
16620 mp->vni = htonl (vni);
16621 mp->action = (u8) action;
16622 mp->is_src_dst = seid_set;
16623 mp->eid_len = eid->len;
16624 mp->seid_len = seid->len;
16625 mp->del_all = del_all;
16626 mp->eid_type = eid->type;
16627 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16628 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16630 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16631 clib_memcpy (mp->rlocs, rlocs, data_len);
16637 /* Wait for a reply... */
16642 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16645 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16646 * forwarding entries in data-plane accordingly.
16648 * @param vam vpp API test context
16649 * @return return code
16652 api_one_add_del_adjacency (vat_main_t * vam)
16654 unformat_input_t *input = vam->input;
16655 vl_api_one_add_del_adjacency_t *mp;
16657 ip4_address_t leid4, reid4;
16658 ip6_address_t leid6, reid6;
16659 u8 reid_mac[6] = { 0 };
16660 u8 leid_mac[6] = { 0 };
16661 u8 reid_type, leid_type;
16662 u32 leid_len = 0, reid_len = 0, len;
16666 leid_type = reid_type = (u8) ~ 0;
16668 /* Parse args required to build the message */
16669 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16671 if (unformat (input, "del"))
16675 else if (unformat (input, "add"))
16679 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
16682 reid_type = 0; /* ipv4 */
16685 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
16688 reid_type = 1; /* ipv6 */
16691 else if (unformat (input, "reid %U", unformat_ethernet_address,
16694 reid_type = 2; /* mac */
16696 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
16699 leid_type = 0; /* ipv4 */
16702 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
16705 leid_type = 1; /* ipv6 */
16708 else if (unformat (input, "leid %U", unformat_ethernet_address,
16711 leid_type = 2; /* mac */
16713 else if (unformat (input, "vni %d", &vni))
16719 errmsg ("parse error '%U'", format_unformat_error, input);
16724 if ((u8) ~ 0 == reid_type)
16726 errmsg ("missing params!");
16730 if (leid_type != reid_type)
16732 errmsg ("remote and local EIDs are of different types!");
16736 M (ONE_ADD_DEL_ADJACENCY, mp);
16737 mp->is_add = is_add;
16738 mp->vni = htonl (vni);
16739 mp->leid_len = leid_len;
16740 mp->reid_len = reid_len;
16741 mp->eid_type = reid_type;
16743 switch (mp->eid_type)
16746 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
16747 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
16750 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
16751 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
16754 clib_memcpy (mp->leid, leid_mac, 6);
16755 clib_memcpy (mp->reid, reid_mac, 6);
16758 errmsg ("unknown EID type %d!", mp->eid_type);
16765 /* Wait for a reply... */
16770 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16773 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16775 u32 *mode = va_arg (*args, u32 *);
16777 if (unformat (input, "lisp"))
16779 else if (unformat (input, "vxlan"))
16788 api_gpe_get_encap_mode (vat_main_t * vam)
16790 vl_api_gpe_get_encap_mode_t *mp;
16793 /* Construct the API message */
16794 M (GPE_GET_ENCAP_MODE, mp);
16799 /* Wait for a reply... */
16805 api_gpe_set_encap_mode (vat_main_t * vam)
16807 unformat_input_t *input = vam->input;
16808 vl_api_gpe_set_encap_mode_t *mp;
16812 /* Parse args required to build the message */
16813 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16815 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16821 /* Construct the API message */
16822 M (GPE_SET_ENCAP_MODE, mp);
16829 /* Wait for a reply... */
16835 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16837 unformat_input_t *input = vam->input;
16838 vl_api_gpe_add_del_iface_t *mp;
16839 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16840 u32 dp_table = 0, vni = 0;
16843 /* Parse args required to build the message */
16844 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16846 if (unformat (input, "up"))
16851 else if (unformat (input, "down"))
16856 else if (unformat (input, "table_id %d", &dp_table))
16860 else if (unformat (input, "bd_id %d", &dp_table))
16865 else if (unformat (input, "vni %d", &vni))
16873 if (action_set == 0)
16875 errmsg ("Action not set");
16878 if (dp_table_set == 0 || vni_set == 0)
16880 errmsg ("vni and dp_table must be set");
16884 /* Construct the API message */
16885 M (GPE_ADD_DEL_IFACE, mp);
16887 mp->is_add = is_add;
16888 mp->dp_table = clib_host_to_net_u32 (dp_table);
16890 mp->vni = clib_host_to_net_u32 (vni);
16895 /* Wait for a reply... */
16901 api_one_map_register_fallback_threshold (vat_main_t * vam)
16903 unformat_input_t *input = vam->input;
16904 vl_api_one_map_register_fallback_threshold_t *mp;
16909 /* Parse args required to build the message */
16910 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16912 if (unformat (input, "%u", &value))
16916 clib_warning ("parse error '%U'", format_unformat_error, input);
16923 errmsg ("fallback threshold value is missing!");
16927 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16928 mp->value = clib_host_to_net_u32 (value);
16933 /* Wait for a reply... */
16939 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16941 vl_api_show_one_map_register_fallback_threshold_t *mp;
16944 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16949 /* Wait for a reply... */
16955 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
16957 u32 *proto = va_arg (*args, u32 *);
16959 if (unformat (input, "udp"))
16961 else if (unformat (input, "api"))
16970 api_one_set_transport_protocol (vat_main_t * vam)
16972 unformat_input_t *input = vam->input;
16973 vl_api_one_set_transport_protocol_t *mp;
16978 /* Parse args required to build the message */
16979 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16981 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
16985 clib_warning ("parse error '%U'", format_unformat_error, input);
16992 errmsg ("Transport protocol missing!");
16996 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
16997 mp->protocol = (u8) protocol;
17002 /* Wait for a reply... */
17008 api_one_get_transport_protocol (vat_main_t * vam)
17010 vl_api_one_get_transport_protocol_t *mp;
17013 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17018 /* Wait for a reply... */
17024 api_one_map_register_set_ttl (vat_main_t * vam)
17026 unformat_input_t *input = vam->input;
17027 vl_api_one_map_register_set_ttl_t *mp;
17032 /* Parse args required to build the message */
17033 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17035 if (unformat (input, "%u", &ttl))
17039 clib_warning ("parse error '%U'", format_unformat_error, input);
17046 errmsg ("TTL value missing!");
17050 M (ONE_MAP_REGISTER_SET_TTL, mp);
17051 mp->ttl = clib_host_to_net_u32 (ttl);
17056 /* Wait for a reply... */
17062 api_show_one_map_register_ttl (vat_main_t * vam)
17064 vl_api_show_one_map_register_ttl_t *mp;
17067 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17072 /* Wait for a reply... */
17078 * Add/del map request itr rlocs from ONE control plane and updates
17080 * @param vam vpp API test context
17081 * @return return code
17084 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17086 unformat_input_t *input = vam->input;
17087 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17088 u8 *locator_set_name = 0;
17089 u8 locator_set_name_set = 0;
17093 /* Parse args required to build the message */
17094 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17096 if (unformat (input, "del"))
17100 else if (unformat (input, "%_%v%_", &locator_set_name))
17102 locator_set_name_set = 1;
17106 clib_warning ("parse error '%U'", format_unformat_error, input);
17111 if (is_add && !locator_set_name_set)
17113 errmsg ("itr-rloc is not set!");
17117 if (is_add && vec_len (locator_set_name) > 64)
17119 errmsg ("itr-rloc locator-set name too long");
17120 vec_free (locator_set_name);
17124 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17125 mp->is_add = is_add;
17128 clib_memcpy (mp->locator_set_name, locator_set_name,
17129 vec_len (locator_set_name));
17133 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17135 vec_free (locator_set_name);
17140 /* Wait for a reply... */
17145 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17148 api_one_locator_dump (vat_main_t * vam)
17150 unformat_input_t *input = vam->input;
17151 vl_api_one_locator_dump_t *mp;
17152 vl_api_control_ping_t *mp_ping;
17153 u8 is_index_set = 0, is_name_set = 0;
17158 /* Parse args required to build the message */
17159 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17161 if (unformat (input, "ls_name %_%v%_", &ls_name))
17165 else if (unformat (input, "ls_index %d", &ls_index))
17171 errmsg ("parse error '%U'", format_unformat_error, input);
17176 if (!is_index_set && !is_name_set)
17178 errmsg ("error: expected one of index or name!");
17182 if (is_index_set && is_name_set)
17184 errmsg ("error: only one param expected!");
17188 if (vec_len (ls_name) > 62)
17190 errmsg ("error: locator set name too long!");
17194 if (!vam->json_output)
17196 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17199 M (ONE_LOCATOR_DUMP, mp);
17200 mp->is_index_set = is_index_set;
17203 mp->ls_index = clib_host_to_net_u32 (ls_index);
17206 vec_add1 (ls_name, 0);
17207 strncpy ((char *) mp->ls_name, (char *) ls_name,
17208 sizeof (mp->ls_name) - 1);
17214 /* Use a control ping for synchronization */
17215 MPING (CONTROL_PING, mp_ping);
17218 /* Wait for a reply... */
17223 #define api_lisp_locator_dump api_one_locator_dump
17226 api_one_locator_set_dump (vat_main_t * vam)
17228 vl_api_one_locator_set_dump_t *mp;
17229 vl_api_control_ping_t *mp_ping;
17230 unformat_input_t *input = vam->input;
17234 /* Parse args required to build the message */
17235 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17237 if (unformat (input, "local"))
17241 else if (unformat (input, "remote"))
17247 errmsg ("parse error '%U'", format_unformat_error, input);
17252 if (!vam->json_output)
17254 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17257 M (ONE_LOCATOR_SET_DUMP, mp);
17259 mp->filter = filter;
17264 /* Use a control ping for synchronization */
17265 MPING (CONTROL_PING, mp_ping);
17268 /* Wait for a reply... */
17273 #define api_lisp_locator_set_dump api_one_locator_set_dump
17276 api_one_eid_table_map_dump (vat_main_t * vam)
17280 unformat_input_t *input = vam->input;
17281 vl_api_one_eid_table_map_dump_t *mp;
17282 vl_api_control_ping_t *mp_ping;
17285 /* Parse args required to build the message */
17286 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17288 if (unformat (input, "l2"))
17293 else if (unformat (input, "l3"))
17300 errmsg ("parse error '%U'", format_unformat_error, input);
17307 errmsg ("expected one of 'l2' or 'l3' parameter!");
17311 if (!vam->json_output)
17313 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17316 M (ONE_EID_TABLE_MAP_DUMP, mp);
17322 /* Use a control ping for synchronization */
17323 MPING (CONTROL_PING, mp_ping);
17326 /* Wait for a reply... */
17331 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17334 api_one_eid_table_vni_dump (vat_main_t * vam)
17336 vl_api_one_eid_table_vni_dump_t *mp;
17337 vl_api_control_ping_t *mp_ping;
17340 if (!vam->json_output)
17342 print (vam->ofp, "VNI");
17345 M (ONE_EID_TABLE_VNI_DUMP, mp);
17350 /* Use a control ping for synchronization */
17351 MPING (CONTROL_PING, mp_ping);
17354 /* Wait for a reply... */
17359 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17362 api_one_eid_table_dump (vat_main_t * vam)
17364 unformat_input_t *i = vam->input;
17365 vl_api_one_eid_table_dump_t *mp;
17366 vl_api_control_ping_t *mp_ping;
17367 struct in_addr ip4;
17368 struct in6_addr ip6;
17370 u8 eid_type = ~0, eid_set = 0;
17371 u32 prefix_length = ~0, t, vni = 0;
17374 lisp_nsh_api_t nsh;
17376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17378 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17384 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17390 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17395 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17400 else if (unformat (i, "vni %d", &t))
17404 else if (unformat (i, "local"))
17408 else if (unformat (i, "remote"))
17414 errmsg ("parse error '%U'", format_unformat_error, i);
17419 if (!vam->json_output)
17421 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17422 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17425 M (ONE_EID_TABLE_DUMP, mp);
17427 mp->filter = filter;
17431 mp->vni = htonl (vni);
17432 mp->eid_type = eid_type;
17436 mp->prefix_length = prefix_length;
17437 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17440 mp->prefix_length = prefix_length;
17441 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17444 clib_memcpy (mp->eid, mac, sizeof (mac));
17447 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17450 errmsg ("unknown EID type %d!", eid_type);
17458 /* Use a control ping for synchronization */
17459 MPING (CONTROL_PING, mp_ping);
17462 /* Wait for a reply... */
17467 #define api_lisp_eid_table_dump api_one_eid_table_dump
17470 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17472 unformat_input_t *i = vam->input;
17473 vl_api_gpe_fwd_entries_get_t *mp;
17478 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17480 if (unformat (i, "vni %d", &vni))
17486 errmsg ("parse error '%U'", format_unformat_error, i);
17493 errmsg ("vni not set!");
17497 if (!vam->json_output)
17499 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17503 M (GPE_FWD_ENTRIES_GET, mp);
17504 mp->vni = clib_host_to_net_u32 (vni);
17509 /* Wait for a reply... */
17514 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17515 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17516 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17517 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17518 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17519 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17520 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17521 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17524 api_one_adjacencies_get (vat_main_t * vam)
17526 unformat_input_t *i = vam->input;
17527 vl_api_one_adjacencies_get_t *mp;
17532 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17534 if (unformat (i, "vni %d", &vni))
17540 errmsg ("parse error '%U'", format_unformat_error, i);
17547 errmsg ("vni not set!");
17551 if (!vam->json_output)
17553 print (vam->ofp, "%s %40s", "leid", "reid");
17556 M (ONE_ADJACENCIES_GET, mp);
17557 mp->vni = clib_host_to_net_u32 (vni);
17562 /* Wait for a reply... */
17567 #define api_lisp_adjacencies_get api_one_adjacencies_get
17570 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17572 unformat_input_t *i = vam->input;
17573 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17575 u8 ip_family_set = 0, is_ip4 = 1;
17577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17579 if (unformat (i, "ip4"))
17584 else if (unformat (i, "ip6"))
17591 errmsg ("parse error '%U'", format_unformat_error, i);
17596 if (!ip_family_set)
17598 errmsg ("ip family not set!");
17602 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17603 mp->is_ip4 = is_ip4;
17608 /* Wait for a reply... */
17614 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17616 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17619 if (!vam->json_output)
17621 print (vam->ofp, "VNIs");
17624 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17629 /* Wait for a reply... */
17635 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17637 unformat_input_t *i = vam->input;
17638 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17640 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17641 struct in_addr ip4;
17642 struct in6_addr ip6;
17643 u32 table_id = 0, nh_sw_if_index = ~0;
17645 clib_memset (&ip4, 0, sizeof (ip4));
17646 clib_memset (&ip6, 0, sizeof (ip6));
17648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17650 if (unformat (i, "del"))
17652 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17653 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17658 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17659 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17664 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17668 nh_sw_if_index = ~0;
17670 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
17674 nh_sw_if_index = ~0;
17676 else if (unformat (i, "table %d", &table_id))
17680 errmsg ("parse error '%U'", format_unformat_error, i);
17687 errmsg ("nh addr not set!");
17691 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
17692 mp->is_add = is_add;
17693 mp->table_id = clib_host_to_net_u32 (table_id);
17694 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
17695 mp->is_ip4 = is_ip4;
17697 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
17699 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
17704 /* Wait for a reply... */
17710 api_one_map_server_dump (vat_main_t * vam)
17712 vl_api_one_map_server_dump_t *mp;
17713 vl_api_control_ping_t *mp_ping;
17716 if (!vam->json_output)
17718 print (vam->ofp, "%=20s", "Map server");
17721 M (ONE_MAP_SERVER_DUMP, mp);
17725 /* Use a control ping for synchronization */
17726 MPING (CONTROL_PING, mp_ping);
17729 /* Wait for a reply... */
17734 #define api_lisp_map_server_dump api_one_map_server_dump
17737 api_one_map_resolver_dump (vat_main_t * vam)
17739 vl_api_one_map_resolver_dump_t *mp;
17740 vl_api_control_ping_t *mp_ping;
17743 if (!vam->json_output)
17745 print (vam->ofp, "%=20s", "Map resolver");
17748 M (ONE_MAP_RESOLVER_DUMP, mp);
17752 /* Use a control ping for synchronization */
17753 MPING (CONTROL_PING, mp_ping);
17756 /* Wait for a reply... */
17761 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
17764 api_one_stats_flush (vat_main_t * vam)
17766 vl_api_one_stats_flush_t *mp;
17769 M (ONE_STATS_FLUSH, mp);
17776 api_one_stats_dump (vat_main_t * vam)
17778 vl_api_one_stats_dump_t *mp;
17779 vl_api_control_ping_t *mp_ping;
17782 M (ONE_STATS_DUMP, mp);
17786 /* Use a control ping for synchronization */
17787 MPING (CONTROL_PING, mp_ping);
17790 /* Wait for a reply... */
17796 api_show_one_status (vat_main_t * vam)
17798 vl_api_show_one_status_t *mp;
17801 if (!vam->json_output)
17803 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17806 M (SHOW_ONE_STATUS, mp);
17809 /* Wait for a reply... */
17814 #define api_show_lisp_status api_show_one_status
17817 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17819 vl_api_gpe_fwd_entry_path_dump_t *mp;
17820 vl_api_control_ping_t *mp_ping;
17821 unformat_input_t *i = vam->input;
17822 u32 fwd_entry_index = ~0;
17825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17827 if (unformat (i, "index %d", &fwd_entry_index))
17833 if (~0 == fwd_entry_index)
17835 errmsg ("no index specified!");
17839 if (!vam->json_output)
17841 print (vam->ofp, "first line");
17844 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17848 /* Use a control ping for synchronization */
17849 MPING (CONTROL_PING, mp_ping);
17852 /* Wait for a reply... */
17858 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17860 vl_api_one_get_map_request_itr_rlocs_t *mp;
17863 if (!vam->json_output)
17865 print (vam->ofp, "%=20s", "itr-rlocs:");
17868 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17871 /* Wait for a reply... */
17876 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17879 api_af_packet_create (vat_main_t * vam)
17881 unformat_input_t *i = vam->input;
17882 vl_api_af_packet_create_t *mp;
17883 u8 *host_if_name = 0;
17885 u8 random_hw_addr = 1;
17888 clib_memset (hw_addr, 0, sizeof (hw_addr));
17890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17892 if (unformat (i, "name %s", &host_if_name))
17893 vec_add1 (host_if_name, 0);
17894 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17895 random_hw_addr = 0;
17900 if (!vec_len (host_if_name))
17902 errmsg ("host-interface name must be specified");
17906 if (vec_len (host_if_name) > 64)
17908 errmsg ("host-interface name too long");
17912 M (AF_PACKET_CREATE, mp);
17914 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17915 clib_memcpy (mp->hw_addr, hw_addr, 6);
17916 mp->use_random_hw_addr = random_hw_addr;
17917 vec_free (host_if_name);
17925 fprintf (vam->ofp ? vam->ofp : stderr,
17926 " new sw_if_index = %d\n", vam->sw_if_index);
17933 api_af_packet_delete (vat_main_t * vam)
17935 unformat_input_t *i = vam->input;
17936 vl_api_af_packet_delete_t *mp;
17937 u8 *host_if_name = 0;
17940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17942 if (unformat (i, "name %s", &host_if_name))
17943 vec_add1 (host_if_name, 0);
17948 if (!vec_len (host_if_name))
17950 errmsg ("host-interface name must be specified");
17954 if (vec_len (host_if_name) > 64)
17956 errmsg ("host-interface name too long");
17960 M (AF_PACKET_DELETE, mp);
17962 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17963 vec_free (host_if_name);
17970 static void vl_api_af_packet_details_t_handler
17971 (vl_api_af_packet_details_t * mp)
17973 vat_main_t *vam = &vat_main;
17975 print (vam->ofp, "%-16s %d",
17976 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
17979 static void vl_api_af_packet_details_t_handler_json
17980 (vl_api_af_packet_details_t * mp)
17982 vat_main_t *vam = &vat_main;
17983 vat_json_node_t *node = NULL;
17985 if (VAT_JSON_ARRAY != vam->json_tree.type)
17987 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17988 vat_json_init_array (&vam->json_tree);
17990 node = vat_json_array_add (&vam->json_tree);
17992 vat_json_init_object (node);
17993 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17994 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
17998 api_af_packet_dump (vat_main_t * vam)
18000 vl_api_af_packet_dump_t *mp;
18001 vl_api_control_ping_t *mp_ping;
18004 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
18005 /* Get list of tap interfaces */
18006 M (AF_PACKET_DUMP, mp);
18009 /* Use a control ping for synchronization */
18010 MPING (CONTROL_PING, mp_ping);
18018 api_policer_add_del (vat_main_t * vam)
18020 unformat_input_t *i = vam->input;
18021 vl_api_policer_add_del_t *mp;
18031 u8 color_aware = 0;
18032 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18035 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18036 conform_action.dscp = 0;
18037 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18038 exceed_action.dscp = 0;
18039 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18040 violate_action.dscp = 0;
18042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18044 if (unformat (i, "del"))
18046 else if (unformat (i, "name %s", &name))
18047 vec_add1 (name, 0);
18048 else if (unformat (i, "cir %u", &cir))
18050 else if (unformat (i, "eir %u", &eir))
18052 else if (unformat (i, "cb %u", &cb))
18054 else if (unformat (i, "eb %u", &eb))
18056 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18059 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18062 else if (unformat (i, "type %U", unformat_policer_type, &type))
18064 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18067 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18070 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18073 else if (unformat (i, "color-aware"))
18079 if (!vec_len (name))
18081 errmsg ("policer name must be specified");
18085 if (vec_len (name) > 64)
18087 errmsg ("policer name too long");
18091 M (POLICER_ADD_DEL, mp);
18093 clib_memcpy (mp->name, name, vec_len (name));
18095 mp->is_add = is_add;
18096 mp->cir = ntohl (cir);
18097 mp->eir = ntohl (eir);
18098 mp->cb = clib_net_to_host_u64 (cb);
18099 mp->eb = clib_net_to_host_u64 (eb);
18100 mp->rate_type = rate_type;
18101 mp->round_type = round_type;
18103 mp->conform_action_type = conform_action.action_type;
18104 mp->conform_dscp = conform_action.dscp;
18105 mp->exceed_action_type = exceed_action.action_type;
18106 mp->exceed_dscp = exceed_action.dscp;
18107 mp->violate_action_type = violate_action.action_type;
18108 mp->violate_dscp = violate_action.dscp;
18109 mp->color_aware = color_aware;
18117 api_policer_dump (vat_main_t * vam)
18119 unformat_input_t *i = vam->input;
18120 vl_api_policer_dump_t *mp;
18121 vl_api_control_ping_t *mp_ping;
18122 u8 *match_name = 0;
18123 u8 match_name_valid = 0;
18126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18128 if (unformat (i, "name %s", &match_name))
18130 vec_add1 (match_name, 0);
18131 match_name_valid = 1;
18137 M (POLICER_DUMP, mp);
18138 mp->match_name_valid = match_name_valid;
18139 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18140 vec_free (match_name);
18144 /* Use a control ping for synchronization */
18145 MPING (CONTROL_PING, mp_ping);
18148 /* Wait for a reply... */
18154 api_policer_classify_set_interface (vat_main_t * vam)
18156 unformat_input_t *i = vam->input;
18157 vl_api_policer_classify_set_interface_t *mp;
18159 int sw_if_index_set;
18160 u32 ip4_table_index = ~0;
18161 u32 ip6_table_index = ~0;
18162 u32 l2_table_index = ~0;
18166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18168 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18169 sw_if_index_set = 1;
18170 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18171 sw_if_index_set = 1;
18172 else if (unformat (i, "del"))
18174 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18176 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18178 else if (unformat (i, "l2-table %d", &l2_table_index))
18182 clib_warning ("parse error '%U'", format_unformat_error, i);
18187 if (sw_if_index_set == 0)
18189 errmsg ("missing interface name or sw_if_index");
18193 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18195 mp->sw_if_index = ntohl (sw_if_index);
18196 mp->ip4_table_index = ntohl (ip4_table_index);
18197 mp->ip6_table_index = ntohl (ip6_table_index);
18198 mp->l2_table_index = ntohl (l2_table_index);
18199 mp->is_add = is_add;
18207 api_policer_classify_dump (vat_main_t * vam)
18209 unformat_input_t *i = vam->input;
18210 vl_api_policer_classify_dump_t *mp;
18211 vl_api_control_ping_t *mp_ping;
18212 u8 type = POLICER_CLASSIFY_N_TABLES;
18215 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18219 errmsg ("classify table type must be specified");
18223 if (!vam->json_output)
18225 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18228 M (POLICER_CLASSIFY_DUMP, mp);
18233 /* Use a control ping for synchronization */
18234 MPING (CONTROL_PING, mp_ping);
18237 /* Wait for a reply... */
18243 api_netmap_create (vat_main_t * vam)
18245 unformat_input_t *i = vam->input;
18246 vl_api_netmap_create_t *mp;
18249 u8 random_hw_addr = 1;
18254 clib_memset (hw_addr, 0, sizeof (hw_addr));
18256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18258 if (unformat (i, "name %s", &if_name))
18259 vec_add1 (if_name, 0);
18260 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18261 random_hw_addr = 0;
18262 else if (unformat (i, "pipe"))
18264 else if (unformat (i, "master"))
18266 else if (unformat (i, "slave"))
18272 if (!vec_len (if_name))
18274 errmsg ("interface name must be specified");
18278 if (vec_len (if_name) > 64)
18280 errmsg ("interface name too long");
18284 M (NETMAP_CREATE, mp);
18286 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18287 clib_memcpy (mp->hw_addr, hw_addr, 6);
18288 mp->use_random_hw_addr = random_hw_addr;
18289 mp->is_pipe = is_pipe;
18290 mp->is_master = is_master;
18291 vec_free (if_name);
18299 api_netmap_delete (vat_main_t * vam)
18301 unformat_input_t *i = vam->input;
18302 vl_api_netmap_delete_t *mp;
18306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18308 if (unformat (i, "name %s", &if_name))
18309 vec_add1 (if_name, 0);
18314 if (!vec_len (if_name))
18316 errmsg ("interface name must be specified");
18320 if (vec_len (if_name) > 64)
18322 errmsg ("interface name too long");
18326 M (NETMAP_DELETE, mp);
18328 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18329 vec_free (if_name);
18337 format_fib_api_path_nh_proto (u8 * s, va_list * args)
18339 vl_api_fib_path_nh_proto_t proto =
18340 va_arg (*args, vl_api_fib_path_nh_proto_t);
18344 case FIB_API_PATH_NH_PROTO_IP4:
18345 s = format (s, "ip4");
18347 case FIB_API_PATH_NH_PROTO_IP6:
18348 s = format (s, "ip6");
18350 case FIB_API_PATH_NH_PROTO_MPLS:
18351 s = format (s, "mpls");
18353 case FIB_API_PATH_NH_PROTO_BIER:
18354 s = format (s, "bier");
18356 case FIB_API_PATH_NH_PROTO_ETHERNET:
18357 s = format (s, "ethernet");
18365 format_vl_api_ip_address_union (u8 * s, va_list * args)
18367 vl_api_address_family_t af = va_arg (*args, vl_api_address_family_t);
18368 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
18373 s = format (s, "%U", format_ip4_address, u->ip4);
18376 s = format (s, "%U", format_ip6_address, u->ip6);
18383 format_vl_api_fib_path_type (u8 * s, va_list * args)
18385 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
18389 case FIB_API_PATH_TYPE_NORMAL:
18390 s = format (s, "normal");
18392 case FIB_API_PATH_TYPE_LOCAL:
18393 s = format (s, "local");
18395 case FIB_API_PATH_TYPE_DROP:
18396 s = format (s, "drop");
18398 case FIB_API_PATH_TYPE_UDP_ENCAP:
18399 s = format (s, "udp-encap");
18401 case FIB_API_PATH_TYPE_BIER_IMP:
18402 s = format (s, "bier-imp");
18404 case FIB_API_PATH_TYPE_ICMP_UNREACH:
18405 s = format (s, "unreach");
18407 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
18408 s = format (s, "prohibit");
18410 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
18411 s = format (s, "src-lookup");
18413 case FIB_API_PATH_TYPE_DVR:
18414 s = format (s, "dvr");
18416 case FIB_API_PATH_TYPE_INTERFACE_RX:
18417 s = format (s, "interface-rx");
18419 case FIB_API_PATH_TYPE_CLASSIFY:
18420 s = format (s, "classify");
18428 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
18431 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
18432 ntohl (fp->weight), ntohl (fp->sw_if_index),
18433 format_vl_api_fib_path_type, fp->type,
18434 format_fib_api_path_nh_proto, fp->proto,
18435 format_vl_api_ip_address_union, &fp->nh.address);
18439 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18440 vl_api_fib_path_t * fp)
18442 struct in_addr ip4;
18443 struct in6_addr ip6;
18445 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18446 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18447 vat_json_object_add_uint (node, "type", fp->type);
18448 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
18449 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18451 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
18452 vat_json_object_add_ip4 (node, "next_hop", ip4);
18454 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18456 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
18457 vat_json_object_add_ip6 (node, "next_hop", ip6);
18462 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18464 vat_main_t *vam = &vat_main;
18465 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18466 vl_api_fib_path_t *fp;
18469 print (vam->ofp, "sw_if_index %d via:",
18470 ntohl (mp->mt_tunnel.mt_sw_if_index));
18471 fp = mp->mt_tunnel.mt_paths;
18472 for (i = 0; i < count; i++)
18474 vl_api_fib_path_print (vam, fp);
18478 print (vam->ofp, "");
18481 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18482 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18485 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18487 vat_main_t *vam = &vat_main;
18488 vat_json_node_t *node = NULL;
18489 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18490 vl_api_fib_path_t *fp;
18493 if (VAT_JSON_ARRAY != vam->json_tree.type)
18495 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18496 vat_json_init_array (&vam->json_tree);
18498 node = vat_json_array_add (&vam->json_tree);
18500 vat_json_init_object (node);
18501 vat_json_object_add_uint (node, "sw_if_index",
18502 ntohl (mp->mt_tunnel.mt_sw_if_index));
18504 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
18506 fp = mp->mt_tunnel.mt_paths;
18507 for (i = 0; i < count; i++)
18509 vl_api_mpls_fib_path_json_print (node, fp);
18515 api_mpls_tunnel_dump (vat_main_t * vam)
18517 vl_api_mpls_tunnel_dump_t *mp;
18518 vl_api_control_ping_t *mp_ping;
18521 M (MPLS_TUNNEL_DUMP, mp);
18525 /* Use a control ping for synchronization */
18526 MPING (CONTROL_PING, mp_ping);
18533 #define vl_api_mpls_table_details_t_endian vl_noop_handler
18534 #define vl_api_mpls_table_details_t_print vl_noop_handler
18538 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
18540 vat_main_t *vam = &vat_main;
18542 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
18545 static void vl_api_mpls_table_details_t_handler_json
18546 (vl_api_mpls_table_details_t * mp)
18548 vat_main_t *vam = &vat_main;
18549 vat_json_node_t *node = NULL;
18551 if (VAT_JSON_ARRAY != vam->json_tree.type)
18553 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18554 vat_json_init_array (&vam->json_tree);
18556 node = vat_json_array_add (&vam->json_tree);
18558 vat_json_init_object (node);
18559 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
18563 api_mpls_table_dump (vat_main_t * vam)
18565 vl_api_mpls_table_dump_t *mp;
18566 vl_api_control_ping_t *mp_ping;
18569 M (MPLS_TABLE_DUMP, mp);
18572 /* Use a control ping for synchronization */
18573 MPING (CONTROL_PING, mp_ping);
18580 #define vl_api_mpls_route_details_t_endian vl_noop_handler
18581 #define vl_api_mpls_route_details_t_print vl_noop_handler
18584 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
18586 vat_main_t *vam = &vat_main;
18587 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
18588 vl_api_fib_path_t *fp;
18592 "table-id %d, label %u, ess_bit %u",
18593 ntohl (mp->mr_route.mr_table_id),
18594 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
18595 fp = mp->mr_route.mr_paths;
18596 for (i = 0; i < count; i++)
18598 vl_api_fib_path_print (vam, fp);
18603 static void vl_api_mpls_route_details_t_handler_json
18604 (vl_api_mpls_route_details_t * mp)
18606 vat_main_t *vam = &vat_main;
18607 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
18608 vat_json_node_t *node = NULL;
18609 vl_api_fib_path_t *fp;
18612 if (VAT_JSON_ARRAY != vam->json_tree.type)
18614 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18615 vat_json_init_array (&vam->json_tree);
18617 node = vat_json_array_add (&vam->json_tree);
18619 vat_json_init_object (node);
18620 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
18621 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
18622 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
18623 vat_json_object_add_uint (node, "path_count", count);
18624 fp = mp->mr_route.mr_paths;
18625 for (i = 0; i < count; i++)
18627 vl_api_mpls_fib_path_json_print (node, fp);
18633 api_mpls_route_dump (vat_main_t * vam)
18635 unformat_input_t *input = vam->input;
18636 vl_api_mpls_route_dump_t *mp;
18637 vl_api_control_ping_t *mp_ping;
18641 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18643 if (unformat (input, "table_id %d", &table_id))
18648 if (table_id == ~0)
18650 errmsg ("missing table id");
18654 M (MPLS_ROUTE_DUMP, mp);
18656 mp->table.mt_table_id = ntohl (table_id);
18659 /* Use a control ping for synchronization */
18660 MPING (CONTROL_PING, mp_ping);
18667 #define vl_api_ip_table_details_t_endian vl_noop_handler
18668 #define vl_api_ip_table_details_t_print vl_noop_handler
18671 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
18673 vat_main_t *vam = &vat_main;
18676 "%s; table-id %d, prefix %U/%d",
18677 mp->table.name, ntohl (mp->table.table_id));
18681 static void vl_api_ip_table_details_t_handler_json
18682 (vl_api_ip_table_details_t * mp)
18684 vat_main_t *vam = &vat_main;
18685 vat_json_node_t *node = NULL;
18687 if (VAT_JSON_ARRAY != vam->json_tree.type)
18689 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18690 vat_json_init_array (&vam->json_tree);
18692 node = vat_json_array_add (&vam->json_tree);
18694 vat_json_init_object (node);
18695 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
18699 api_ip_table_dump (vat_main_t * vam)
18701 vl_api_ip_table_dump_t *mp;
18702 vl_api_control_ping_t *mp_ping;
18705 M (IP_TABLE_DUMP, mp);
18708 /* Use a control ping for synchronization */
18709 MPING (CONTROL_PING, mp_ping);
18717 api_ip_mtable_dump (vat_main_t * vam)
18719 vl_api_ip_mtable_dump_t *mp;
18720 vl_api_control_ping_t *mp_ping;
18723 M (IP_MTABLE_DUMP, mp);
18726 /* Use a control ping for synchronization */
18727 MPING (CONTROL_PING, mp_ping);
18735 api_ip_mroute_dump (vat_main_t * vam)
18737 unformat_input_t *input = vam->input;
18738 vl_api_control_ping_t *mp_ping;
18739 vl_api_ip_mroute_dump_t *mp;
18744 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18746 if (unformat (input, "table_id %d", &table_id))
18748 else if (unformat (input, "ip6"))
18750 else if (unformat (input, "ip4"))
18755 if (table_id == ~0)
18757 errmsg ("missing table id");
18761 M (IP_MROUTE_DUMP, mp);
18762 mp->table.table_id = table_id;
18763 mp->table.is_ip6 = is_ip6;
18766 /* Use a control ping for synchronization */
18767 MPING (CONTROL_PING, mp_ping);
18774 static void vl_api_ip_neighbor_details_t_handler
18775 (vl_api_ip_neighbor_details_t * mp)
18777 vat_main_t *vam = &vat_main;
18779 print (vam->ofp, "%c %U %U",
18780 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
18781 format_vl_api_mac_address, &mp->neighbor.mac_address,
18782 format_vl_api_address, &mp->neighbor.ip_address);
18785 static void vl_api_ip_neighbor_details_t_handler_json
18786 (vl_api_ip_neighbor_details_t * mp)
18789 vat_main_t *vam = &vat_main;
18790 vat_json_node_t *node;
18792 if (VAT_JSON_ARRAY != vam->json_tree.type)
18794 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18795 vat_json_init_array (&vam->json_tree);
18797 node = vat_json_array_add (&vam->json_tree);
18799 vat_json_init_object (node);
18800 vat_json_object_add_string_copy
18802 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
18803 (u8 *) "static" : (u8 *) "dynamic"));
18805 vat_json_object_add_string_copy (node, "link_layer",
18806 format (0, "%U", format_vl_api_mac_address,
18807 &mp->neighbor.mac_address));
18808 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
18812 api_ip_neighbor_dump (vat_main_t * vam)
18814 unformat_input_t *i = vam->input;
18815 vl_api_ip_neighbor_dump_t *mp;
18816 vl_api_control_ping_t *mp_ping;
18818 u32 sw_if_index = ~0;
18821 /* Parse args required to build the message */
18822 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18824 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18826 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18828 else if (unformat (i, "ip6"))
18834 if (sw_if_index == ~0)
18836 errmsg ("missing interface name or sw_if_index");
18840 M (IP_NEIGHBOR_DUMP, mp);
18841 mp->is_ipv6 = (u8) is_ipv6;
18842 mp->sw_if_index = ntohl (sw_if_index);
18845 /* Use a control ping for synchronization */
18846 MPING (CONTROL_PING, mp_ping);
18853 #define vl_api_ip_route_details_t_endian vl_noop_handler
18854 #define vl_api_ip_route_details_t_print vl_noop_handler
18857 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
18859 vat_main_t *vam = &vat_main;
18860 u8 count = mp->route.n_paths;
18861 vl_api_fib_path_t *fp;
18865 "table-id %d, prefix %U/%d",
18866 ntohl (mp->route.table_id),
18867 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
18868 for (i = 0; i < count; i++)
18870 fp = &mp->route.paths[i];
18872 vl_api_fib_path_print (vam, fp);
18877 static void vl_api_ip_route_details_t_handler_json
18878 (vl_api_ip_route_details_t * mp)
18880 vat_main_t *vam = &vat_main;
18881 u8 count = mp->route.n_paths;
18882 vat_json_node_t *node = NULL;
18883 struct in_addr ip4;
18884 struct in6_addr ip6;
18885 vl_api_fib_path_t *fp;
18888 if (VAT_JSON_ARRAY != vam->json_tree.type)
18890 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18891 vat_json_init_array (&vam->json_tree);
18893 node = vat_json_array_add (&vam->json_tree);
18895 vat_json_init_object (node);
18896 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
18897 if (ADDRESS_IP6 == mp->route.prefix.address.af)
18899 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
18900 vat_json_object_add_ip6 (node, "prefix", ip6);
18904 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
18905 vat_json_object_add_ip4 (node, "prefix", ip4);
18907 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
18908 vat_json_object_add_uint (node, "path_count", count);
18909 for (i = 0; i < count; i++)
18911 fp = &mp->route.paths[i];
18912 vl_api_mpls_fib_path_json_print (node, fp);
18917 api_ip_route_dump (vat_main_t * vam)
18919 unformat_input_t *input = vam->input;
18920 vl_api_ip_route_dump_t *mp;
18921 vl_api_control_ping_t *mp_ping;
18927 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18929 if (unformat (input, "table_id %d", &table_id))
18931 else if (unformat (input, "ip6"))
18933 else if (unformat (input, "ip4"))
18938 if (table_id == ~0)
18940 errmsg ("missing table id");
18944 M (IP_ROUTE_DUMP, mp);
18946 mp->table.table_id = table_id;
18947 mp->table.is_ip6 = is_ip6;
18951 /* Use a control ping for synchronization */
18952 MPING (CONTROL_PING, mp_ping);
18960 api_classify_table_ids (vat_main_t * vam)
18962 vl_api_classify_table_ids_t *mp;
18965 /* Construct the API message */
18966 M (CLASSIFY_TABLE_IDS, mp);
18975 api_classify_table_by_interface (vat_main_t * vam)
18977 unformat_input_t *input = vam->input;
18978 vl_api_classify_table_by_interface_t *mp;
18980 u32 sw_if_index = ~0;
18982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18984 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18986 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18991 if (sw_if_index == ~0)
18993 errmsg ("missing interface name or sw_if_index");
18997 /* Construct the API message */
18998 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19000 mp->sw_if_index = ntohl (sw_if_index);
19008 api_classify_table_info (vat_main_t * vam)
19010 unformat_input_t *input = vam->input;
19011 vl_api_classify_table_info_t *mp;
19015 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19017 if (unformat (input, "table_id %d", &table_id))
19022 if (table_id == ~0)
19024 errmsg ("missing table id");
19028 /* Construct the API message */
19029 M (CLASSIFY_TABLE_INFO, mp);
19031 mp->table_id = ntohl (table_id);
19039 api_classify_session_dump (vat_main_t * vam)
19041 unformat_input_t *input = vam->input;
19042 vl_api_classify_session_dump_t *mp;
19043 vl_api_control_ping_t *mp_ping;
19047 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19049 if (unformat (input, "table_id %d", &table_id))
19054 if (table_id == ~0)
19056 errmsg ("missing table id");
19060 /* Construct the API message */
19061 M (CLASSIFY_SESSION_DUMP, mp);
19063 mp->table_id = ntohl (table_id);
19066 /* Use a control ping for synchronization */
19067 MPING (CONTROL_PING, mp_ping);
19075 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19077 vat_main_t *vam = &vat_main;
19079 print (vam->ofp, "collector_address %U, collector_port %d, "
19080 "src_address %U, vrf_id %d, path_mtu %u, "
19081 "template_interval %u, udp_checksum %d",
19082 format_ip4_address, mp->collector_address,
19083 ntohs (mp->collector_port),
19084 format_ip4_address, mp->src_address,
19085 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19086 ntohl (mp->template_interval), mp->udp_checksum);
19089 vam->result_ready = 1;
19093 vl_api_ipfix_exporter_details_t_handler_json
19094 (vl_api_ipfix_exporter_details_t * mp)
19096 vat_main_t *vam = &vat_main;
19097 vat_json_node_t node;
19098 struct in_addr collector_address;
19099 struct in_addr src_address;
19101 vat_json_init_object (&node);
19102 clib_memcpy (&collector_address, &mp->collector_address,
19103 sizeof (collector_address));
19104 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19105 vat_json_object_add_uint (&node, "collector_port",
19106 ntohs (mp->collector_port));
19107 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19108 vat_json_object_add_ip4 (&node, "src_address", src_address);
19109 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19110 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19111 vat_json_object_add_uint (&node, "template_interval",
19112 ntohl (mp->template_interval));
19113 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19115 vat_json_print (vam->ofp, &node);
19116 vat_json_free (&node);
19118 vam->result_ready = 1;
19122 api_ipfix_exporter_dump (vat_main_t * vam)
19124 vl_api_ipfix_exporter_dump_t *mp;
19127 /* Construct the API message */
19128 M (IPFIX_EXPORTER_DUMP, mp);
19137 api_ipfix_classify_stream_dump (vat_main_t * vam)
19139 vl_api_ipfix_classify_stream_dump_t *mp;
19142 /* Construct the API message */
19143 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19154 vl_api_ipfix_classify_stream_details_t_handler
19155 (vl_api_ipfix_classify_stream_details_t * mp)
19157 vat_main_t *vam = &vat_main;
19158 print (vam->ofp, "domain_id %d, src_port %d",
19159 ntohl (mp->domain_id), ntohs (mp->src_port));
19161 vam->result_ready = 1;
19165 vl_api_ipfix_classify_stream_details_t_handler_json
19166 (vl_api_ipfix_classify_stream_details_t * mp)
19168 vat_main_t *vam = &vat_main;
19169 vat_json_node_t node;
19171 vat_json_init_object (&node);
19172 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19173 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19175 vat_json_print (vam->ofp, &node);
19176 vat_json_free (&node);
19178 vam->result_ready = 1;
19182 api_ipfix_classify_table_dump (vat_main_t * vam)
19184 vl_api_ipfix_classify_table_dump_t *mp;
19185 vl_api_control_ping_t *mp_ping;
19188 if (!vam->json_output)
19190 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19191 "transport_protocol");
19194 /* Construct the API message */
19195 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19200 /* Use a control ping for synchronization */
19201 MPING (CONTROL_PING, mp_ping);
19209 vl_api_ipfix_classify_table_details_t_handler
19210 (vl_api_ipfix_classify_table_details_t * mp)
19212 vat_main_t *vam = &vat_main;
19213 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19214 mp->transport_protocol);
19218 vl_api_ipfix_classify_table_details_t_handler_json
19219 (vl_api_ipfix_classify_table_details_t * mp)
19221 vat_json_node_t *node = NULL;
19222 vat_main_t *vam = &vat_main;
19224 if (VAT_JSON_ARRAY != vam->json_tree.type)
19226 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19227 vat_json_init_array (&vam->json_tree);
19230 node = vat_json_array_add (&vam->json_tree);
19231 vat_json_init_object (node);
19233 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19234 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19235 vat_json_object_add_uint (node, "transport_protocol",
19236 mp->transport_protocol);
19240 api_sw_interface_span_enable_disable (vat_main_t * vam)
19242 unformat_input_t *i = vam->input;
19243 vl_api_sw_interface_span_enable_disable_t *mp;
19244 u32 src_sw_if_index = ~0;
19245 u32 dst_sw_if_index = ~0;
19250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19253 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19255 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19259 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19261 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19263 else if (unformat (i, "disable"))
19265 else if (unformat (i, "rx"))
19267 else if (unformat (i, "tx"))
19269 else if (unformat (i, "both"))
19271 else if (unformat (i, "l2"))
19277 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19279 mp->sw_if_index_from = htonl (src_sw_if_index);
19280 mp->sw_if_index_to = htonl (dst_sw_if_index);
19290 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19293 vat_main_t *vam = &vat_main;
19294 u8 *sw_if_from_name = 0;
19295 u8 *sw_if_to_name = 0;
19296 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19297 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19298 char *states[] = { "none", "rx", "tx", "both" };
19302 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19304 if ((u32) p->value[0] == sw_if_index_from)
19306 sw_if_from_name = (u8 *)(p->key);
19310 if ((u32) p->value[0] == sw_if_index_to)
19312 sw_if_to_name = (u8 *)(p->key);
19313 if (sw_if_from_name)
19318 print (vam->ofp, "%20s => %20s (%s) %s",
19319 sw_if_from_name, sw_if_to_name, states[mp->state],
19320 mp->is_l2 ? "l2" : "device");
19324 vl_api_sw_interface_span_details_t_handler_json
19325 (vl_api_sw_interface_span_details_t * mp)
19327 vat_main_t *vam = &vat_main;
19328 vat_json_node_t *node = NULL;
19329 u8 *sw_if_from_name = 0;
19330 u8 *sw_if_to_name = 0;
19331 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19332 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19336 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19338 if ((u32) p->value[0] == sw_if_index_from)
19340 sw_if_from_name = (u8 *)(p->key);
19344 if ((u32) p->value[0] == sw_if_index_to)
19346 sw_if_to_name = (u8 *)(p->key);
19347 if (sw_if_from_name)
19353 if (VAT_JSON_ARRAY != vam->json_tree.type)
19355 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19356 vat_json_init_array (&vam->json_tree);
19358 node = vat_json_array_add (&vam->json_tree);
19360 vat_json_init_object (node);
19361 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19362 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19363 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19364 if (0 != sw_if_to_name)
19366 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19368 vat_json_object_add_uint (node, "state", mp->state);
19369 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
19373 api_sw_interface_span_dump (vat_main_t * vam)
19375 unformat_input_t *input = vam->input;
19376 vl_api_sw_interface_span_dump_t *mp;
19377 vl_api_control_ping_t *mp_ping;
19381 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19383 if (unformat (input, "l2"))
19389 M (SW_INTERFACE_SPAN_DUMP, mp);
19393 /* Use a control ping for synchronization */
19394 MPING (CONTROL_PING, mp_ping);
19402 api_pg_create_interface (vat_main_t * vam)
19404 unformat_input_t *input = vam->input;
19405 vl_api_pg_create_interface_t *mp;
19407 u32 if_id = ~0, gso_size = 0;
19408 u8 gso_enabled = 0;
19410 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19412 if (unformat (input, "if_id %d", &if_id))
19414 else if (unformat (input, "gso-enabled"))
19417 if (unformat (input, "gso-size %u", &gso_size))
19421 errmsg ("missing gso-size");
19430 errmsg ("missing pg interface index");
19434 /* Construct the API message */
19435 M (PG_CREATE_INTERFACE, mp);
19437 mp->interface_id = ntohl (if_id);
19438 mp->gso_enabled = gso_enabled;
19446 api_pg_capture (vat_main_t * vam)
19448 unformat_input_t *input = vam->input;
19449 vl_api_pg_capture_t *mp;
19454 u8 pcap_file_set = 0;
19457 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19459 if (unformat (input, "if_id %d", &if_id))
19461 else if (unformat (input, "pcap %s", &pcap_file))
19463 else if (unformat (input, "count %d", &count))
19465 else if (unformat (input, "disable"))
19472 errmsg ("missing pg interface index");
19475 if (pcap_file_set > 0)
19477 if (vec_len (pcap_file) > 255)
19479 errmsg ("pcap file name is too long");
19484 u32 name_len = vec_len (pcap_file);
19485 /* Construct the API message */
19486 M (PG_CAPTURE, mp);
19488 mp->interface_id = ntohl (if_id);
19489 mp->is_enabled = enable;
19490 mp->count = ntohl (count);
19491 mp->pcap_name_length = ntohl (name_len);
19492 if (pcap_file_set != 0)
19494 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19496 vec_free (pcap_file);
19504 api_pg_enable_disable (vat_main_t * vam)
19506 unformat_input_t *input = vam->input;
19507 vl_api_pg_enable_disable_t *mp;
19510 u8 stream_name_set = 0;
19511 u8 *stream_name = 0;
19513 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19515 if (unformat (input, "stream %s", &stream_name))
19516 stream_name_set = 1;
19517 else if (unformat (input, "disable"))
19523 if (stream_name_set > 0)
19525 if (vec_len (stream_name) > 255)
19527 errmsg ("stream name too long");
19532 u32 name_len = vec_len (stream_name);
19533 /* Construct the API message */
19534 M (PG_ENABLE_DISABLE, mp);
19536 mp->is_enabled = enable;
19537 if (stream_name_set != 0)
19539 mp->stream_name_length = ntohl (name_len);
19540 clib_memcpy (mp->stream_name, stream_name, name_len);
19542 vec_free (stream_name);
19550 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19552 unformat_input_t *input = vam->input;
19553 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19555 u16 *low_ports = 0;
19556 u16 *high_ports = 0;
19559 vl_api_prefix_t prefix;
19566 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19568 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
19570 else if (unformat (input, "vrf %d", &vrf_id))
19572 else if (unformat (input, "del"))
19574 else if (unformat (input, "port %d", &tmp))
19576 if (tmp == 0 || tmp > 65535)
19578 errmsg ("port %d out of range", tmp);
19582 this_hi = this_low + 1;
19583 vec_add1 (low_ports, this_low);
19584 vec_add1 (high_ports, this_hi);
19586 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19588 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19590 errmsg ("incorrect range parameters");
19594 /* Note: in debug CLI +1 is added to high before
19595 passing to real fn that does "the work"
19596 (ip_source_and_port_range_check_add_del).
19597 This fn is a wrapper around the binary API fn a
19598 control plane will call, which expects this increment
19599 to have occurred. Hence letting the binary API control
19600 plane fn do the increment for consistency between VAT
19601 and other control planes.
19604 vec_add1 (low_ports, this_low);
19605 vec_add1 (high_ports, this_hi);
19611 if (prefix_set == 0)
19613 errmsg ("<address>/<mask> not specified");
19619 errmsg ("VRF ID required, not specified");
19626 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19630 if (vec_len (low_ports) == 0)
19632 errmsg ("At least one port or port range required");
19636 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19638 mp->is_add = is_add;
19640 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
19642 mp->number_of_ranges = vec_len (low_ports);
19644 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19645 vec_free (low_ports);
19647 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19648 vec_free (high_ports);
19650 mp->vrf_id = ntohl (vrf_id);
19658 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19660 unformat_input_t *input = vam->input;
19661 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19662 u32 sw_if_index = ~0;
19664 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19665 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19669 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19671 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19673 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19675 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19677 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19679 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19681 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19683 else if (unformat (input, "del"))
19689 if (sw_if_index == ~0)
19691 errmsg ("Interface required but not specified");
19697 errmsg ("VRF ID required but not specified");
19701 if (tcp_out_vrf_id == 0
19702 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
19705 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19709 /* Construct the API message */
19710 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
19712 mp->sw_if_index = ntohl (sw_if_index);
19713 mp->is_add = is_add;
19714 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
19715 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
19716 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
19717 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
19722 /* Wait for a reply... */
19728 api_set_punt (vat_main_t * vam)
19730 unformat_input_t *i = vam->input;
19731 vl_api_address_family_t af;
19732 vl_api_set_punt_t *mp;
19738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19740 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
19742 else if (unformat (i, "protocol %d", &protocol))
19744 else if (unformat (i, "port %d", &port))
19746 else if (unformat (i, "del"))
19750 clib_warning ("parse error '%U'", format_unformat_error, i);
19757 mp->is_add = (u8) is_add;
19758 mp->punt.type = PUNT_API_TYPE_L4;
19759 mp->punt.punt.l4.af = af;
19760 mp->punt.punt.l4.protocol = (u8) protocol;
19761 mp->punt.punt.l4.port = htons ((u16) port);
19769 api_delete_subif (vat_main_t * vam)
19771 unformat_input_t *i = vam->input;
19772 vl_api_delete_subif_t *mp;
19773 u32 sw_if_index = ~0;
19776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19778 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19780 if (unformat (i, "sw_if_index %d", &sw_if_index))
19786 if (sw_if_index == ~0)
19788 errmsg ("missing sw_if_index");
19792 /* Construct the API message */
19793 M (DELETE_SUBIF, mp);
19794 mp->sw_if_index = ntohl (sw_if_index);
19801 #define foreach_pbb_vtr_op \
19802 _("disable", L2_VTR_DISABLED) \
19803 _("pop", L2_VTR_POP_2) \
19804 _("push", L2_VTR_PUSH_2)
19807 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
19809 unformat_input_t *i = vam->input;
19810 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
19811 u32 sw_if_index = ~0, vtr_op = ~0;
19812 u16 outer_tag = ~0;
19813 u8 dmac[6], smac[6];
19814 u8 dmac_set = 0, smac_set = 0;
19820 /* Shut up coverity */
19821 clib_memset (dmac, 0, sizeof (dmac));
19822 clib_memset (smac, 0, sizeof (smac));
19824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19826 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19828 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19830 else if (unformat (i, "vtr_op %d", &vtr_op))
19832 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
19835 else if (unformat (i, "translate_pbb_stag"))
19837 if (unformat (i, "%d", &tmp))
19839 vtr_op = L2_VTR_TRANSLATE_2_1;
19845 ("translate_pbb_stag operation requires outer tag definition");
19849 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
19851 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
19853 else if (unformat (i, "sid %d", &sid))
19855 else if (unformat (i, "vlanid %d", &tmp))
19859 clib_warning ("parse error '%U'", format_unformat_error, i);
19864 if ((sw_if_index == ~0) || (vtr_op == ~0))
19866 errmsg ("missing sw_if_index or vtr operation");
19869 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
19870 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
19873 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
19877 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
19878 mp->sw_if_index = ntohl (sw_if_index);
19879 mp->vtr_op = ntohl (vtr_op);
19880 mp->outer_tag = ntohs (outer_tag);
19881 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
19882 clib_memcpy (mp->b_smac, smac, sizeof (smac));
19883 mp->b_vlanid = ntohs (vlanid);
19884 mp->i_sid = ntohl (sid);
19892 api_flow_classify_set_interface (vat_main_t * vam)
19894 unformat_input_t *i = vam->input;
19895 vl_api_flow_classify_set_interface_t *mp;
19897 int sw_if_index_set;
19898 u32 ip4_table_index = ~0;
19899 u32 ip6_table_index = ~0;
19903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19905 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19906 sw_if_index_set = 1;
19907 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19908 sw_if_index_set = 1;
19909 else if (unformat (i, "del"))
19911 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19913 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19917 clib_warning ("parse error '%U'", format_unformat_error, i);
19922 if (sw_if_index_set == 0)
19924 errmsg ("missing interface name or sw_if_index");
19928 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19930 mp->sw_if_index = ntohl (sw_if_index);
19931 mp->ip4_table_index = ntohl (ip4_table_index);
19932 mp->ip6_table_index = ntohl (ip6_table_index);
19933 mp->is_add = is_add;
19941 api_flow_classify_dump (vat_main_t * vam)
19943 unformat_input_t *i = vam->input;
19944 vl_api_flow_classify_dump_t *mp;
19945 vl_api_control_ping_t *mp_ping;
19946 u8 type = FLOW_CLASSIFY_N_TABLES;
19949 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19953 errmsg ("classify table type must be specified");
19957 if (!vam->json_output)
19959 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19962 M (FLOW_CLASSIFY_DUMP, mp);
19967 /* Use a control ping for synchronization */
19968 MPING (CONTROL_PING, mp_ping);
19971 /* Wait for a reply... */
19977 api_feature_enable_disable (vat_main_t * vam)
19979 unformat_input_t *i = vam->input;
19980 vl_api_feature_enable_disable_t *mp;
19982 u8 *feature_name = 0;
19983 u32 sw_if_index = ~0;
19987 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19989 if (unformat (i, "arc_name %s", &arc_name))
19991 else if (unformat (i, "feature_name %s", &feature_name))
19994 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19996 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19998 else if (unformat (i, "disable"))
20006 errmsg ("missing arc name");
20009 if (vec_len (arc_name) > 63)
20011 errmsg ("arc name too long");
20014 if (feature_name == 0)
20016 errmsg ("missing feature name");
20019 if (vec_len (feature_name) > 63)
20021 errmsg ("feature name too long");
20024 if (sw_if_index == ~0)
20026 errmsg ("missing interface name or sw_if_index");
20030 /* Construct the API message */
20031 M (FEATURE_ENABLE_DISABLE, mp);
20032 mp->sw_if_index = ntohl (sw_if_index);
20033 mp->enable = enable;
20034 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20035 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20036 vec_free (arc_name);
20037 vec_free (feature_name);
20045 api_feature_gso_enable_disable (vat_main_t * vam)
20047 unformat_input_t *i = vam->input;
20048 vl_api_feature_gso_enable_disable_t *mp;
20049 u32 sw_if_index = ~0;
20053 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20055 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20057 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20059 else if (unformat (i, "enable"))
20061 else if (unformat (i, "disable"))
20067 if (sw_if_index == ~0)
20069 errmsg ("missing interface name or sw_if_index");
20073 /* Construct the API message */
20074 M (FEATURE_GSO_ENABLE_DISABLE, mp);
20075 mp->sw_if_index = ntohl (sw_if_index);
20076 mp->enable_disable = enable;
20084 api_sw_interface_tag_add_del (vat_main_t * vam)
20086 unformat_input_t *i = vam->input;
20087 vl_api_sw_interface_tag_add_del_t *mp;
20088 u32 sw_if_index = ~0;
20093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20095 if (unformat (i, "tag %s", &tag))
20097 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20099 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20101 else if (unformat (i, "del"))
20107 if (sw_if_index == ~0)
20109 errmsg ("missing interface name or sw_if_index");
20113 if (enable && (tag == 0))
20115 errmsg ("no tag specified");
20119 /* Construct the API message */
20120 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20121 mp->sw_if_index = ntohl (sw_if_index);
20122 mp->is_add = enable;
20124 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20133 api_sw_interface_add_del_mac_address (vat_main_t * vam)
20135 unformat_input_t *i = vam->input;
20136 vl_api_mac_address_t mac = { 0 };
20137 vl_api_sw_interface_add_del_mac_address_t *mp;
20138 u32 sw_if_index = ~0;
20143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20145 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20147 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20149 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
20151 else if (unformat (i, "del"))
20157 if (sw_if_index == ~0)
20159 errmsg ("missing interface name or sw_if_index");
20165 errmsg ("missing MAC address");
20169 /* Construct the API message */
20170 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
20171 mp->sw_if_index = ntohl (sw_if_index);
20172 mp->is_add = is_add;
20173 clib_memcpy (&mp->addr, &mac, sizeof (mac));
20180 static void vl_api_l2_xconnect_details_t_handler
20181 (vl_api_l2_xconnect_details_t * mp)
20183 vat_main_t *vam = &vat_main;
20185 print (vam->ofp, "%15d%15d",
20186 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20189 static void vl_api_l2_xconnect_details_t_handler_json
20190 (vl_api_l2_xconnect_details_t * mp)
20192 vat_main_t *vam = &vat_main;
20193 vat_json_node_t *node = NULL;
20195 if (VAT_JSON_ARRAY != vam->json_tree.type)
20197 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20198 vat_json_init_array (&vam->json_tree);
20200 node = vat_json_array_add (&vam->json_tree);
20202 vat_json_init_object (node);
20203 vat_json_object_add_uint (node, "rx_sw_if_index",
20204 ntohl (mp->rx_sw_if_index));
20205 vat_json_object_add_uint (node, "tx_sw_if_index",
20206 ntohl (mp->tx_sw_if_index));
20210 api_l2_xconnect_dump (vat_main_t * vam)
20212 vl_api_l2_xconnect_dump_t *mp;
20213 vl_api_control_ping_t *mp_ping;
20216 if (!vam->json_output)
20218 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20221 M (L2_XCONNECT_DUMP, mp);
20225 /* Use a control ping for synchronization */
20226 MPING (CONTROL_PING, mp_ping);
20234 api_hw_interface_set_mtu (vat_main_t * vam)
20236 unformat_input_t *i = vam->input;
20237 vl_api_hw_interface_set_mtu_t *mp;
20238 u32 sw_if_index = ~0;
20242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20244 if (unformat (i, "mtu %d", &mtu))
20246 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20248 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20254 if (sw_if_index == ~0)
20256 errmsg ("missing interface name or sw_if_index");
20262 errmsg ("no mtu specified");
20266 /* Construct the API message */
20267 M (HW_INTERFACE_SET_MTU, mp);
20268 mp->sw_if_index = ntohl (sw_if_index);
20269 mp->mtu = ntohs ((u16) mtu);
20277 api_p2p_ethernet_add (vat_main_t * vam)
20279 unformat_input_t *i = vam->input;
20280 vl_api_p2p_ethernet_add_t *mp;
20281 u32 parent_if_index = ~0;
20287 clib_memset (remote_mac, 0, sizeof (remote_mac));
20288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20290 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20292 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20296 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20298 else if (unformat (i, "sub_id %d", &sub_id))
20302 clib_warning ("parse error '%U'", format_unformat_error, i);
20307 if (parent_if_index == ~0)
20309 errmsg ("missing interface name or sw_if_index");
20314 errmsg ("missing remote mac address");
20319 errmsg ("missing sub-interface id");
20323 M (P2P_ETHERNET_ADD, mp);
20324 mp->parent_if_index = ntohl (parent_if_index);
20325 mp->subif_id = ntohl (sub_id);
20326 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20334 api_p2p_ethernet_del (vat_main_t * vam)
20336 unformat_input_t *i = vam->input;
20337 vl_api_p2p_ethernet_del_t *mp;
20338 u32 parent_if_index = ~0;
20343 clib_memset (remote_mac, 0, sizeof (remote_mac));
20344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20346 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20348 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20352 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20356 clib_warning ("parse error '%U'", format_unformat_error, i);
20361 if (parent_if_index == ~0)
20363 errmsg ("missing interface name or sw_if_index");
20368 errmsg ("missing remote mac address");
20372 M (P2P_ETHERNET_DEL, mp);
20373 mp->parent_if_index = ntohl (parent_if_index);
20374 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20382 api_lldp_config (vat_main_t * vam)
20384 unformat_input_t *i = vam->input;
20385 vl_api_lldp_config_t *mp;
20387 int tx_interval = 0;
20388 u8 *sys_name = NULL;
20391 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20393 if (unformat (i, "system-name %s", &sys_name))
20395 else if (unformat (i, "tx-hold %d", &tx_hold))
20397 else if (unformat (i, "tx-interval %d", &tx_interval))
20401 clib_warning ("parse error '%U'", format_unformat_error, i);
20406 vec_add1 (sys_name, 0);
20408 M (LLDP_CONFIG, mp);
20409 mp->tx_hold = htonl (tx_hold);
20410 mp->tx_interval = htonl (tx_interval);
20411 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20412 vec_free (sys_name);
20420 api_sw_interface_set_lldp (vat_main_t * vam)
20422 unformat_input_t *i = vam->input;
20423 vl_api_sw_interface_set_lldp_t *mp;
20424 u32 sw_if_index = ~0;
20426 u8 *port_desc = NULL, *mgmt_oid = NULL;
20427 ip4_address_t ip4_addr;
20428 ip6_address_t ip6_addr;
20431 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
20432 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
20434 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20436 if (unformat (i, "disable"))
20439 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20441 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20443 else if (unformat (i, "port-desc %s", &port_desc))
20445 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20447 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20449 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20455 if (sw_if_index == ~0)
20457 errmsg ("missing interface name or sw_if_index");
20461 /* Construct the API message */
20462 vec_add1 (port_desc, 0);
20463 vec_add1 (mgmt_oid, 0);
20464 M (SW_INTERFACE_SET_LLDP, mp);
20465 mp->sw_if_index = ntohl (sw_if_index);
20466 mp->enable = enable;
20467 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20468 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20469 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20470 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20471 vec_free (port_desc);
20472 vec_free (mgmt_oid);
20480 api_tcp_configure_src_addresses (vat_main_t * vam)
20482 vl_api_tcp_configure_src_addresses_t *mp;
20483 unformat_input_t *i = vam->input;
20484 ip4_address_t v4first, v4last;
20485 ip6_address_t v6first, v6last;
20490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20492 if (unformat (i, "%U - %U",
20493 unformat_ip4_address, &v4first,
20494 unformat_ip4_address, &v4last))
20498 errmsg ("one range per message (range already set)");
20503 else if (unformat (i, "%U - %U",
20504 unformat_ip6_address, &v6first,
20505 unformat_ip6_address, &v6last))
20509 errmsg ("one range per message (range already set)");
20514 else if (unformat (i, "vrf %d", &vrf_id))
20520 if (range_set == 0)
20522 errmsg ("address range not set");
20526 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20527 mp->vrf_id = ntohl (vrf_id);
20529 if (range_set == 2)
20532 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20533 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20538 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20539 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20546 static void vl_api_app_namespace_add_del_reply_t_handler
20547 (vl_api_app_namespace_add_del_reply_t * mp)
20549 vat_main_t *vam = &vat_main;
20550 i32 retval = ntohl (mp->retval);
20551 if (vam->async_mode)
20553 vam->async_errors += (retval < 0);
20557 vam->retval = retval;
20559 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
20560 vam->result_ready = 1;
20564 static void vl_api_app_namespace_add_del_reply_t_handler_json
20565 (vl_api_app_namespace_add_del_reply_t * mp)
20567 vat_main_t *vam = &vat_main;
20568 vat_json_node_t node;
20570 vat_json_init_object (&node);
20571 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
20572 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
20574 vat_json_print (vam->ofp, &node);
20575 vat_json_free (&node);
20577 vam->retval = ntohl (mp->retval);
20578 vam->result_ready = 1;
20582 api_app_namespace_add_del (vat_main_t * vam)
20584 vl_api_app_namespace_add_del_t *mp;
20585 unformat_input_t *i = vam->input;
20586 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20587 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20593 if (unformat (i, "id %_%v%_", &ns_id))
20595 else if (unformat (i, "secret %lu", &secret))
20597 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20598 sw_if_index_set = 1;
20599 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20601 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20606 if (!ns_id || !secret_set || !sw_if_index_set)
20608 errmsg ("namespace id, secret and sw_if_index must be set");
20611 if (vec_len (ns_id) > 64)
20613 errmsg ("namespace id too long");
20616 M (APP_NAMESPACE_ADD_DEL, mp);
20618 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20619 mp->namespace_id_len = vec_len (ns_id);
20620 mp->secret = clib_host_to_net_u64 (secret);
20621 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20622 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20623 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20631 api_sock_init_shm (vat_main_t * vam)
20633 #if VPP_API_TEST_BUILTIN == 0
20634 unformat_input_t *i = vam->input;
20635 vl_api_shm_elem_config_t *config = 0;
20636 u64 size = 64 << 20;
20639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20641 if (unformat (i, "size %U", unformat_memory_size, &size))
20648 * Canned custom ring allocator config.
20649 * Should probably parse all of this
20651 vec_validate (config, 6);
20652 config[0].type = VL_API_VLIB_RING;
20653 config[0].size = 256;
20654 config[0].count = 32;
20656 config[1].type = VL_API_VLIB_RING;
20657 config[1].size = 1024;
20658 config[1].count = 16;
20660 config[2].type = VL_API_VLIB_RING;
20661 config[2].size = 4096;
20662 config[2].count = 2;
20664 config[3].type = VL_API_CLIENT_RING;
20665 config[3].size = 256;
20666 config[3].count = 32;
20668 config[4].type = VL_API_CLIENT_RING;
20669 config[4].size = 1024;
20670 config[4].count = 16;
20672 config[5].type = VL_API_CLIENT_RING;
20673 config[5].size = 4096;
20674 config[5].count = 2;
20676 config[6].type = VL_API_QUEUE;
20677 config[6].count = 128;
20678 config[6].size = sizeof (uword);
20680 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
20682 vam->client_index_invalid = 1;
20690 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
20692 vat_main_t *vam = &vat_main;
20697 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20698 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20699 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
20700 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
20701 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20702 clib_net_to_host_u32 (mp->action_index), mp->tag);
20707 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20708 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20709 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
20710 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
20711 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20712 clib_net_to_host_u32 (mp->action_index), mp->tag);
20717 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
20720 vat_main_t *vam = &vat_main;
20721 vat_json_node_t *node = NULL;
20722 struct in6_addr ip6;
20723 struct in_addr ip4;
20725 if (VAT_JSON_ARRAY != vam->json_tree.type)
20727 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20728 vat_json_init_array (&vam->json_tree);
20730 node = vat_json_array_add (&vam->json_tree);
20731 vat_json_init_object (node);
20733 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
20734 vat_json_object_add_uint (node, "appns_index",
20735 clib_net_to_host_u32 (mp->appns_index));
20736 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
20737 vat_json_object_add_uint (node, "scope", mp->scope);
20738 vat_json_object_add_uint (node, "action_index",
20739 clib_net_to_host_u32 (mp->action_index));
20740 vat_json_object_add_uint (node, "lcl_port",
20741 clib_net_to_host_u16 (mp->lcl_port));
20742 vat_json_object_add_uint (node, "rmt_port",
20743 clib_net_to_host_u16 (mp->rmt_port));
20744 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
20745 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
20746 vat_json_object_add_string_copy (node, "tag", mp->tag);
20749 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
20750 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
20751 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
20752 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
20756 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
20757 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
20758 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
20759 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
20764 api_session_rule_add_del (vat_main_t * vam)
20766 vl_api_session_rule_add_del_t *mp;
20767 unformat_input_t *i = vam->input;
20768 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
20769 u32 appns_index = 0, scope = 0;
20770 ip4_address_t lcl_ip4, rmt_ip4;
20771 ip6_address_t lcl_ip6, rmt_ip6;
20772 u8 is_ip4 = 1, conn_set = 0;
20773 u8 is_add = 1, *tag = 0;
20776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20778 if (unformat (i, "del"))
20780 else if (unformat (i, "add"))
20782 else if (unformat (i, "proto tcp"))
20784 else if (unformat (i, "proto udp"))
20786 else if (unformat (i, "appns %d", &appns_index))
20788 else if (unformat (i, "scope %d", &scope))
20790 else if (unformat (i, "tag %_%v%_", &tag))
20794 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
20795 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
20803 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
20804 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
20810 else if (unformat (i, "action %d", &action))
20815 if (proto == ~0 || !conn_set || action == ~0)
20817 errmsg ("transport proto, connection and action must be set");
20823 errmsg ("scope should be 0-3");
20827 M (SESSION_RULE_ADD_DEL, mp);
20829 mp->is_ip4 = is_ip4;
20830 mp->transport_proto = proto;
20831 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
20832 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
20833 mp->lcl_plen = lcl_plen;
20834 mp->rmt_plen = rmt_plen;
20835 mp->action_index = clib_host_to_net_u32 (action);
20836 mp->appns_index = clib_host_to_net_u32 (appns_index);
20838 mp->is_add = is_add;
20841 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
20842 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
20846 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
20847 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
20851 clib_memcpy (mp->tag, tag, vec_len (tag));
20861 api_session_rules_dump (vat_main_t * vam)
20863 vl_api_session_rules_dump_t *mp;
20864 vl_api_control_ping_t *mp_ping;
20867 if (!vam->json_output)
20869 print (vam->ofp, "%=20s", "Session Rules");
20872 M (SESSION_RULES_DUMP, mp);
20876 /* Use a control ping for synchronization */
20877 MPING (CONTROL_PING, mp_ping);
20880 /* Wait for a reply... */
20886 api_ip_container_proxy_add_del (vat_main_t * vam)
20888 vl_api_ip_container_proxy_add_del_t *mp;
20889 unformat_input_t *i = vam->input;
20890 u32 sw_if_index = ~0;
20891 vl_api_prefix_t pfx = { };
20895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20897 if (unformat (i, "del"))
20899 else if (unformat (i, "add"))
20901 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
20903 else if (unformat (i, "sw_if_index %u", &sw_if_index))
20908 if (sw_if_index == ~0 || pfx.len == 0)
20910 errmsg ("address and sw_if_index must be set");
20914 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
20916 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20917 mp->is_add = is_add;
20918 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
20926 api_qos_record_enable_disable (vat_main_t * vam)
20928 unformat_input_t *i = vam->input;
20929 vl_api_qos_record_enable_disable_t *mp;
20930 u32 sw_if_index, qs = 0xff;
20931 u8 sw_if_index_set = 0;
20935 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20937 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20938 sw_if_index_set = 1;
20939 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20940 sw_if_index_set = 1;
20941 else if (unformat (i, "%U", unformat_qos_source, &qs))
20943 else if (unformat (i, "disable"))
20947 clib_warning ("parse error '%U'", format_unformat_error, i);
20952 if (sw_if_index_set == 0)
20954 errmsg ("missing interface name or sw_if_index");
20959 errmsg ("input location must be specified");
20963 M (QOS_RECORD_ENABLE_DISABLE, mp);
20965 mp->record.sw_if_index = ntohl (sw_if_index);
20966 mp->record.input_source = qs;
20967 mp->enable = enable;
20976 q_or_quit (vat_main_t * vam)
20978 #if VPP_API_TEST_BUILTIN == 0
20979 longjmp (vam->jump_buf, 1);
20981 return 0; /* not so much */
20985 q (vat_main_t * vam)
20987 return q_or_quit (vam);
20991 quit (vat_main_t * vam)
20993 return q_or_quit (vam);
20997 comment (vat_main_t * vam)
21003 elog_save (vat_main_t * vam)
21005 #if VPP_API_TEST_BUILTIN == 0
21006 elog_main_t *em = &vam->elog_main;
21007 unformat_input_t *i = vam->input;
21008 char *file, *chroot_file;
21009 clib_error_t *error;
21011 if (!unformat (i, "%s", &file))
21013 errmsg ("expected file name, got `%U'", format_unformat_error, i);
21017 /* It's fairly hard to get "../oopsie" through unformat; just in case */
21018 if (strstr (file, "..") || index (file, '/'))
21020 errmsg ("illegal characters in filename '%s'", file);
21024 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
21028 errmsg ("Saving %wd of %wd events to %s",
21029 elog_n_events_in_buffer (em),
21030 elog_buffer_capacity (em), chroot_file);
21032 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
21033 vec_free (chroot_file);
21036 clib_error_report (error);
21038 errmsg ("Use the vpp event loger...");
21045 elog_setup (vat_main_t * vam)
21047 #if VPP_API_TEST_BUILTIN == 0
21048 elog_main_t *em = &vam->elog_main;
21049 unformat_input_t *i = vam->input;
21050 u32 nevents = 128 << 10;
21052 (void) unformat (i, "nevents %d", &nevents);
21054 elog_init (em, nevents);
21055 vl_api_set_elog_main (em);
21056 vl_api_set_elog_trace_api_messages (1);
21057 errmsg ("Event logger initialized with %u events", nevents);
21059 errmsg ("Use the vpp event loger...");
21065 elog_enable (vat_main_t * vam)
21067 #if VPP_API_TEST_BUILTIN == 0
21068 elog_main_t *em = &vam->elog_main;
21070 elog_enable_disable (em, 1 /* enable */ );
21071 vl_api_set_elog_trace_api_messages (1);
21072 errmsg ("Event logger enabled...");
21074 errmsg ("Use the vpp event loger...");
21080 elog_disable (vat_main_t * vam)
21082 #if VPP_API_TEST_BUILTIN == 0
21083 elog_main_t *em = &vam->elog_main;
21085 elog_enable_disable (em, 0 /* enable */ );
21086 vl_api_set_elog_trace_api_messages (1);
21087 errmsg ("Event logger disabled...");
21089 errmsg ("Use the vpp event loger...");
21095 statseg (vat_main_t * vam)
21097 ssvm_private_t *ssvmp = &vam->stat_segment;
21098 ssvm_shared_header_t *shared_header = ssvmp->sh;
21099 vlib_counter_t **counters;
21100 u64 thread0_index1_packets;
21101 u64 thread0_index1_bytes;
21102 f64 vector_rate, input_rate;
21105 uword *counter_vector_by_name;
21106 if (vam->stat_segment_lockp == 0)
21108 errmsg ("Stat segment not mapped...");
21112 /* look up "/if/rx for sw_if_index 1 as a test */
21114 clib_spinlock_lock (vam->stat_segment_lockp);
21116 counter_vector_by_name = (uword *) shared_header->opaque[1];
21118 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21121 clib_spinlock_unlock (vam->stat_segment_lockp);
21122 errmsg ("/if/tx not found?");
21126 /* Fish per-thread vector of combined counters from shared memory */
21127 counters = (vlib_counter_t **) p[0];
21129 if (vec_len (counters[0]) < 2)
21131 clib_spinlock_unlock (vam->stat_segment_lockp);
21132 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21136 /* Read thread 0 sw_if_index 1 counter */
21137 thread0_index1_packets = counters[0][1].packets;
21138 thread0_index1_bytes = counters[0][1].bytes;
21140 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21143 clib_spinlock_unlock (vam->stat_segment_lockp);
21144 errmsg ("vector_rate not found?");
21148 vector_rate = *(f64 *) (p[0]);
21149 p = hash_get_mem (counter_vector_by_name, "input_rate");
21152 clib_spinlock_unlock (vam->stat_segment_lockp);
21153 errmsg ("input_rate not found?");
21156 input_rate = *(f64 *) (p[0]);
21158 clib_spinlock_unlock (vam->stat_segment_lockp);
21160 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21161 vector_rate, input_rate);
21162 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21163 thread0_index1_packets, thread0_index1_bytes);
21169 cmd_cmp (void *a1, void *a2)
21174 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21178 help (vat_main_t * vam)
21183 unformat_input_t *i = vam->input;
21186 if (unformat (i, "%s", &name))
21190 vec_add1 (name, 0);
21192 hs = hash_get_mem (vam->help_by_name, name);
21194 print (vam->ofp, "usage: %s %s", name, hs[0]);
21196 print (vam->ofp, "No such msg / command '%s'", name);
21201 print (vam->ofp, "Help is available for the following:");
21204 hash_foreach_pair (p, vam->function_by_name,
21206 vec_add1 (cmds, (u8 *)(p->key));
21210 vec_sort_with_function (cmds, cmd_cmp);
21212 for (j = 0; j < vec_len (cmds); j++)
21213 print (vam->ofp, "%s", cmds[j]);
21220 set (vat_main_t * vam)
21222 u8 *name = 0, *value = 0;
21223 unformat_input_t *i = vam->input;
21225 if (unformat (i, "%s", &name))
21227 /* The input buffer is a vector, not a string. */
21228 value = vec_dup (i->buffer);
21229 vec_delete (value, i->index, 0);
21230 /* Almost certainly has a trailing newline */
21231 if (value[vec_len (value) - 1] == '\n')
21232 value[vec_len (value) - 1] = 0;
21233 /* Make sure it's a proper string, one way or the other */
21234 vec_add1 (value, 0);
21235 (void) clib_macro_set_value (&vam->macro_main,
21236 (char *) name, (char *) value);
21239 errmsg ("usage: set <name> <value>");
21247 unset (vat_main_t * vam)
21251 if (unformat (vam->input, "%s", &name))
21252 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21253 errmsg ("unset: %s wasn't set", name);
21266 macro_sort_cmp (void *a1, void *a2)
21268 macro_sort_t *s1 = a1;
21269 macro_sort_t *s2 = a2;
21271 return strcmp ((char *) (s1->name), (char *) (s2->name));
21275 dump_macro_table (vat_main_t * vam)
21277 macro_sort_t *sort_me = 0, *sm;
21282 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21284 vec_add2 (sort_me, sm, 1);
21285 sm->name = (u8 *)(p->key);
21286 sm->value = (u8 *) (p->value[0]);
21290 vec_sort_with_function (sort_me, macro_sort_cmp);
21292 if (vec_len (sort_me))
21293 print (vam->ofp, "%-15s%s", "Name", "Value");
21295 print (vam->ofp, "The macro table is empty...");
21297 for (i = 0; i < vec_len (sort_me); i++)
21298 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21303 dump_node_table (vat_main_t * vam)
21306 vlib_node_t *node, *next_node;
21308 if (vec_len (vam->graph_nodes) == 0)
21310 print (vam->ofp, "Node table empty, issue get_node_graph...");
21314 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
21316 node = vam->graph_nodes[0][i];
21317 print (vam->ofp, "[%d] %s", i, node->name);
21318 for (j = 0; j < vec_len (node->next_nodes); j++)
21320 if (node->next_nodes[j] != ~0)
21322 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21323 print (vam->ofp, " [%d] %s", j, next_node->name);
21331 value_sort_cmp (void *a1, void *a2)
21333 name_sort_t *n1 = a1;
21334 name_sort_t *n2 = a2;
21336 if (n1->value < n2->value)
21338 if (n1->value > n2->value)
21345 dump_msg_api_table (vat_main_t * vam)
21347 api_main_t *am = vlibapi_get_main ();
21348 name_sort_t *nses = 0, *ns;
21353 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21355 vec_add2 (nses, ns, 1);
21356 ns->name = (u8 *)(hp->key);
21357 ns->value = (u32) hp->value[0];
21361 vec_sort_with_function (nses, value_sort_cmp);
21363 for (i = 0; i < vec_len (nses); i++)
21364 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21370 get_msg_id (vat_main_t * vam)
21375 if (unformat (vam->input, "%s", &name_and_crc))
21377 message_index = vl_msg_api_get_msg_index (name_and_crc);
21378 if (message_index == ~0)
21380 print (vam->ofp, " '%s' not found", name_and_crc);
21383 print (vam->ofp, " '%s' has message index %d",
21384 name_and_crc, message_index);
21387 errmsg ("name_and_crc required...");
21392 search_node_table (vat_main_t * vam)
21394 unformat_input_t *line_input = vam->input;
21397 vlib_node_t *node, *next_node;
21400 if (vam->graph_node_index_by_name == 0)
21402 print (vam->ofp, "Node table empty, issue get_node_graph...");
21406 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21408 if (unformat (line_input, "%s", &node_to_find))
21410 vec_add1 (node_to_find, 0);
21411 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21414 print (vam->ofp, "%s not found...", node_to_find);
21417 node = vam->graph_nodes[0][p[0]];
21418 print (vam->ofp, "[%d] %s", p[0], node->name);
21419 for (j = 0; j < vec_len (node->next_nodes); j++)
21421 if (node->next_nodes[j] != ~0)
21423 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21424 print (vam->ofp, " [%d] %s", j, next_node->name);
21431 clib_warning ("parse error '%U'", format_unformat_error,
21437 vec_free (node_to_find);
21446 script (vat_main_t * vam)
21448 #if (VPP_API_TEST_BUILTIN==0)
21450 char *save_current_file;
21451 unformat_input_t save_input;
21452 jmp_buf save_jump_buf;
21453 u32 save_line_number;
21455 FILE *new_fp, *save_ifp;
21457 if (unformat (vam->input, "%s", &s))
21459 new_fp = fopen ((char *) s, "r");
21462 errmsg ("Couldn't open script file %s", s);
21469 errmsg ("Missing script name");
21473 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21474 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21475 save_ifp = vam->ifp;
21476 save_line_number = vam->input_line_number;
21477 save_current_file = (char *) vam->current_file;
21479 vam->input_line_number = 0;
21481 vam->current_file = s;
21484 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
21485 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21486 vam->ifp = save_ifp;
21487 vam->input_line_number = save_line_number;
21488 vam->current_file = (u8 *) save_current_file;
21493 clib_warning ("use the exec command...");
21499 echo (vat_main_t * vam)
21501 print (vam->ofp, "%v", vam->input->buffer);
21505 /* List of API message constructors, CLI names map to api_xxx */
21506 #define foreach_vpe_api_msg \
21507 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21508 _(sw_interface_dump,"") \
21509 _(sw_interface_set_flags, \
21510 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21511 _(sw_interface_add_del_address, \
21512 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21513 _(sw_interface_set_rx_mode, \
21514 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
21515 _(sw_interface_set_rx_placement, \
21516 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
21517 _(sw_interface_rx_placement_dump, \
21518 "[<intfc> | sw_if_index <id>]") \
21519 _(sw_interface_set_table, \
21520 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21521 _(sw_interface_set_mpls_enable, \
21522 "<intfc> | sw_if_index [disable | dis]") \
21523 _(sw_interface_set_vpath, \
21524 "<intfc> | sw_if_index <id> enable | disable") \
21525 _(sw_interface_set_vxlan_bypass, \
21526 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21527 _(sw_interface_set_geneve_bypass, \
21528 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21529 _(sw_interface_set_l2_xconnect, \
21530 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21531 "enable | disable") \
21532 _(sw_interface_set_l2_bridge, \
21533 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21534 "[shg <split-horizon-group>] [bvi]\n" \
21535 "enable | disable") \
21536 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21537 _(bridge_domain_add_del, \
21538 "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") \
21539 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21541 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21542 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21543 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21545 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21547 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21549 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
21551 "<vpp-if-name> | sw_if_index <id>") \
21552 _(sw_interface_tap_v2_dump, "") \
21553 _(virtio_pci_create, \
21554 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled]") \
21555 _(virtio_pci_delete, \
21556 "<vpp-if-name> | sw_if_index <id>") \
21557 _(sw_interface_virtio_pci_dump, "") \
21559 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
21560 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
21563 "<vpp-if-name> | sw_if_index <id>") \
21565 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
21566 _(bond_detach_slave, \
21567 "sw_if_index <n>") \
21568 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
21569 _(sw_interface_bond_dump, "") \
21570 _(sw_interface_slave_dump, \
21571 "<vpp-if-name> | sw_if_index <id>") \
21572 _(ip_table_add_del, \
21573 "table <n> [ipv6] [add | del]\n") \
21574 _(ip_route_add_del, \
21575 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
21576 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
21577 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
21578 "[multipath] [count <n>] [del]") \
21579 _(ip_mroute_add_del, \
21580 "<src> <grp>/<mask> [table-id <n>]\n" \
21581 "[<intfc> | sw_if_index <id>] [local] [del]") \
21582 _(mpls_table_add_del, \
21583 "table <n> [add | del]\n") \
21584 _(mpls_route_add_del, \
21585 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
21586 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
21587 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
21588 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
21589 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
21590 "[count <n>] [del]") \
21591 _(mpls_ip_bind_unbind, \
21592 "<label> <addr/len>") \
21593 _(mpls_tunnel_add_del, \
21594 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
21595 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
21596 "[l2-only] [out-label <n>]") \
21597 _(sr_mpls_policy_add, \
21598 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
21599 _(sr_mpls_policy_del, \
21601 _(bier_table_add_del, \
21602 "<label> <sub-domain> <set> <bsl> [del]") \
21603 _(bier_route_add_del, \
21604 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
21605 "[<intfc> | sw_if_index <id>]" \
21606 "[weight <n>] [del] [multipath]") \
21607 _(proxy_arp_add_del, \
21608 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21609 _(proxy_arp_intfc_enable_disable, \
21610 "<intfc> | sw_if_index <id> enable | disable") \
21611 _(sw_interface_set_unnumbered, \
21612 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21613 _(ip_neighbor_add_del, \
21614 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21615 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21616 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21617 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21618 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21619 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21620 "[outer_vlan_id_any][inner_vlan_id_any]") \
21621 _(ip_table_replace_begin, "table <n> [ipv6]") \
21622 _(ip_table_flush, "table <n> [ipv6]") \
21623 _(ip_table_replace_end, "table <n> [ipv6]") \
21624 _(set_ip_flow_hash, \
21625 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21626 _(sw_interface_ip6_enable_disable, \
21627 "<intfc> | sw_if_index <id> enable | disable") \
21628 _(ip6nd_proxy_add_del, \
21629 "<intfc> | sw_if_index <id> <ip6-address>") \
21630 _(ip6nd_proxy_dump, "") \
21631 _(sw_interface_ip6nd_ra_prefix, \
21632 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21633 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21634 "[nolink] [isno]") \
21635 _(sw_interface_ip6nd_ra_config, \
21636 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21637 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21638 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21639 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21640 _(l2_patch_add_del, \
21641 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21642 "enable | disable") \
21643 _(sr_localsid_add_del, \
21644 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21645 "fib-table <num> (end.psp) sw_if_index <num>") \
21646 _(classify_add_del_table, \
21647 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21648 " [del] [del-chain] mask <mask-value>\n" \
21649 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21650 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21651 _(classify_add_del_session, \
21652 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21653 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21654 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21655 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21656 _(classify_set_interface_ip_table, \
21657 "<intfc> | sw_if_index <nn> table <nn>") \
21658 _(classify_set_interface_l2_tables, \
21659 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21660 " [other-table <nn>]") \
21661 _(get_node_index, "node <node-name") \
21662 _(add_node_next, "node <node-name> next <next-node-name>") \
21663 _(l2tpv3_create_tunnel, \
21664 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21665 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21666 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21667 _(l2tpv3_set_tunnel_cookies, \
21668 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21669 "[new_remote_cookie <nn>]\n") \
21670 _(l2tpv3_interface_enable_disable, \
21671 "<intfc> | sw_if_index <nn> enable | disable") \
21672 _(l2tpv3_set_lookup_key, \
21673 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21674 _(sw_if_l2tpv3_tunnel_dump, "") \
21675 _(vxlan_offload_rx, \
21676 "hw { <interface name> | hw_if_index <nn>} " \
21677 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
21678 _(vxlan_add_del_tunnel, \
21679 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21680 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
21681 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21682 _(geneve_add_del_tunnel, \
21683 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21684 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21685 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21686 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21687 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21688 _(gre_tunnel_add_del, \
21689 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
21690 "[teb | erspan <session-id>] [del]") \
21691 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21692 _(l2_fib_clear_table, "") \
21693 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21694 _(l2_interface_vlan_tag_rewrite, \
21695 "<intfc> | sw_if_index <nn> \n" \
21696 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21697 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21698 _(create_vhost_user_if, \
21699 "socket <filename> [server] [renumber <dev_instance>] " \
21700 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
21701 "[mac <mac_address>]") \
21702 _(modify_vhost_user_if, \
21703 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21704 "[server] [renumber <dev_instance>] [gso]") \
21705 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21706 _(sw_interface_vhost_user_dump, "") \
21707 _(show_version, "") \
21708 _(show_threads, "") \
21709 _(vxlan_gpe_add_del_tunnel, \
21710 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21711 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21712 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21713 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21714 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21715 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21716 _(interface_name_renumber, \
21717 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21718 _(input_acl_set_interface, \
21719 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21720 " [l2-table <nn>] [del]") \
21721 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
21722 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
21723 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
21724 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21725 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21726 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21727 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21728 _(ip_dump, "ipv4 | ipv6") \
21729 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21730 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21732 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21733 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21734 " integ_alg <alg> integ_key <hex>") \
21735 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
21736 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21737 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21738 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21739 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21740 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21741 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21742 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
21743 " [instance <n>]") \
21744 _(ipsec_sa_dump, "[sa_id <n>]") \
21745 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
21746 _(delete_loopback,"sw_if_index <nn>") \
21747 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21748 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
21749 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
21750 _(want_interface_events, "enable|disable") \
21751 _(get_first_msg_id, "client <name>") \
21752 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21753 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21754 "fib-id <nn> [ip4][ip6][default]") \
21755 _(get_node_graph, " ") \
21756 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21757 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21758 _(ioam_disable, "") \
21759 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21760 " sw_if_index <sw_if_index> p <priority> " \
21761 "w <weight>] [del]") \
21762 _(one_add_del_locator, "locator-set <locator_name> " \
21763 "iface <intf> | sw_if_index <sw_if_index> " \
21764 "p <priority> w <weight> [del]") \
21765 _(one_add_del_local_eid,"vni <vni> eid " \
21766 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21767 "locator-set <locator_name> [del]" \
21768 "[key-id sha1|sha256 secret-key <secret-key>]")\
21769 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21770 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21771 _(one_enable_disable, "enable|disable") \
21772 _(one_map_register_enable_disable, "enable|disable") \
21773 _(one_map_register_fallback_threshold, "<value>") \
21774 _(one_rloc_probe_enable_disable, "enable|disable") \
21775 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21777 "rloc <locator> p <prio> " \
21778 "w <weight> [rloc <loc> ... ] " \
21779 "action <action> [del-all]") \
21780 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21782 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21783 _(one_use_petr, "ip-address> | disable") \
21784 _(one_map_request_mode, "src-dst|dst-only") \
21785 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21786 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21787 _(one_locator_set_dump, "[local | remote]") \
21788 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21789 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21790 "[local] | [remote]") \
21791 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21792 _(one_ndp_bd_get, "") \
21793 _(one_ndp_entries_get, "bd <bridge-domain>") \
21794 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21795 _(one_l2_arp_bd_get, "") \
21796 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21797 _(one_stats_enable_disable, "enable|disable") \
21798 _(show_one_stats_enable_disable, "") \
21799 _(one_eid_table_vni_dump, "") \
21800 _(one_eid_table_map_dump, "l2|l3") \
21801 _(one_map_resolver_dump, "") \
21802 _(one_map_server_dump, "") \
21803 _(one_adjacencies_get, "vni <vni>") \
21804 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21805 _(show_one_rloc_probe_state, "") \
21806 _(show_one_map_register_state, "") \
21807 _(show_one_status, "") \
21808 _(one_stats_dump, "") \
21809 _(one_stats_flush, "") \
21810 _(one_get_map_request_itr_rlocs, "") \
21811 _(one_map_register_set_ttl, "<ttl>") \
21812 _(one_set_transport_protocol, "udp|api") \
21813 _(one_get_transport_protocol, "") \
21814 _(one_enable_disable_xtr_mode, "enable|disable") \
21815 _(one_show_xtr_mode, "") \
21816 _(one_enable_disable_pitr_mode, "enable|disable") \
21817 _(one_show_pitr_mode, "") \
21818 _(one_enable_disable_petr_mode, "enable|disable") \
21819 _(one_show_petr_mode, "") \
21820 _(show_one_nsh_mapping, "") \
21821 _(show_one_pitr, "") \
21822 _(show_one_use_petr, "") \
21823 _(show_one_map_request_mode, "") \
21824 _(show_one_map_register_ttl, "") \
21825 _(show_one_map_register_fallback_threshold, "") \
21826 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21827 " sw_if_index <sw_if_index> p <priority> " \
21828 "w <weight>] [del]") \
21829 _(lisp_add_del_locator, "locator-set <locator_name> " \
21830 "iface <intf> | sw_if_index <sw_if_index> " \
21831 "p <priority> w <weight> [del]") \
21832 _(lisp_add_del_local_eid,"vni <vni> eid " \
21833 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21834 "locator-set <locator_name> [del]" \
21835 "[key-id sha1|sha256 secret-key <secret-key>]") \
21836 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21837 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21838 _(lisp_enable_disable, "enable|disable") \
21839 _(lisp_map_register_enable_disable, "enable|disable") \
21840 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21841 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21843 "rloc <locator> p <prio> " \
21844 "w <weight> [rloc <loc> ... ] " \
21845 "action <action> [del-all]") \
21846 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21848 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21849 _(lisp_use_petr, "<ip-address> | disable") \
21850 _(lisp_map_request_mode, "src-dst|dst-only") \
21851 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21852 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21853 _(lisp_locator_set_dump, "[local | remote]") \
21854 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21855 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21856 "[local] | [remote]") \
21857 _(lisp_eid_table_vni_dump, "") \
21858 _(lisp_eid_table_map_dump, "l2|l3") \
21859 _(lisp_map_resolver_dump, "") \
21860 _(lisp_map_server_dump, "") \
21861 _(lisp_adjacencies_get, "vni <vni>") \
21862 _(gpe_fwd_entry_vnis_get, "") \
21863 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21864 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21865 "[table <table-id>]") \
21866 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21867 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21868 _(gpe_set_encap_mode, "lisp|vxlan") \
21869 _(gpe_get_encap_mode, "") \
21870 _(lisp_gpe_add_del_iface, "up|down") \
21871 _(lisp_gpe_enable_disable, "enable|disable") \
21872 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21873 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21874 _(show_lisp_rloc_probe_state, "") \
21875 _(show_lisp_map_register_state, "") \
21876 _(show_lisp_status, "") \
21877 _(lisp_get_map_request_itr_rlocs, "") \
21878 _(show_lisp_pitr, "") \
21879 _(show_lisp_use_petr, "") \
21880 _(show_lisp_map_request_mode, "") \
21881 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21882 _(af_packet_delete, "name <host interface name>") \
21883 _(af_packet_dump, "") \
21884 _(policer_add_del, "name <policer name> <params> [del]") \
21885 _(policer_dump, "[name <policer name>]") \
21886 _(policer_classify_set_interface, \
21887 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21888 " [l2-table <nn>] [del]") \
21889 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21890 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21891 "[master|slave]") \
21892 _(netmap_delete, "name <interface name>") \
21893 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21894 _(mpls_table_dump, "") \
21895 _(mpls_route_dump, "table-id <ID>") \
21896 _(classify_table_ids, "") \
21897 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21898 _(classify_table_info, "table_id <nn>") \
21899 _(classify_session_dump, "table_id <nn>") \
21900 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21901 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21902 "[template_interval <nn>] [udp_checksum]") \
21903 _(ipfix_exporter_dump, "") \
21904 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21905 _(ipfix_classify_stream_dump, "") \
21906 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21907 _(ipfix_classify_table_dump, "") \
21908 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21909 _(sw_interface_span_dump, "[l2]") \
21910 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21911 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
21912 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21913 _(pg_enable_disable, "[stream <id>] disable") \
21914 _(ip_source_and_port_range_check_add_del, \
21915 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21916 _(ip_source_and_port_range_check_interface_add_del, \
21917 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21918 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21919 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21920 _(l2_interface_pbb_tag_rewrite, \
21921 "<intfc> | sw_if_index <nn> \n" \
21922 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21923 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21924 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21925 _(flow_classify_set_interface, \
21926 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21927 _(flow_classify_dump, "type [ip4|ip6]") \
21928 _(ip_table_dump, "") \
21929 _(ip_route_dump, "table-id [ip4|ip6]") \
21930 _(ip_mtable_dump, "") \
21931 _(ip_mroute_dump, "table-id [ip4|ip6]") \
21932 _(feature_enable_disable, "arc_name <arc_name> " \
21933 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21934 _(feature_gso_enable_disable, "<intfc> | sw_if_index <nn> " \
21935 "[enable | disable] ") \
21936 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21938 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
21939 "mac <mac-address> [del]") \
21940 _(l2_xconnect_dump, "") \
21941 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
21942 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21943 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21944 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21945 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21946 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21947 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21948 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21949 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21950 _(sock_init_shm, "size <nnn>") \
21951 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21952 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
21953 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
21954 _(session_rules_dump, "") \
21955 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
21956 _(output_acl_set_interface, \
21957 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21958 " [l2-table <nn>] [del]") \
21959 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
21961 /* List of command functions, CLI names map directly to functions */
21962 #define foreach_cli_function \
21963 _(comment, "usage: comment <ignore-rest-of-line>") \
21964 _(dump_interface_table, "usage: dump_interface_table") \
21965 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21966 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21967 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21968 _(dump_macro_table, "usage: dump_macro_table ") \
21969 _(dump_node_table, "usage: dump_node_table") \
21970 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21971 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
21972 _(elog_disable, "usage: elog_disable") \
21973 _(elog_enable, "usage: elog_enable") \
21974 _(elog_save, "usage: elog_save <filename>") \
21975 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21976 _(echo, "usage: echo <message>") \
21977 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21978 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21979 _(help, "usage: help") \
21980 _(q, "usage: quit") \
21981 _(quit, "usage: quit") \
21982 _(search_node_table, "usage: search_node_table <name>...") \
21983 _(set, "usage: set <variable-name> <value>") \
21984 _(script, "usage: script <file-name>") \
21985 _(statseg, "usage: statseg") \
21986 _(unset, "usage: unset <variable-name>")
21989 static void vl_api_##n##_t_handler_uni \
21990 (vl_api_##n##_t * mp) \
21992 vat_main_t * vam = &vat_main; \
21993 if (vam->json_output) { \
21994 vl_api_##n##_t_handler_json(mp); \
21996 vl_api_##n##_t_handler(mp); \
21999 foreach_vpe_api_reply_msg;
22000 #if VPP_API_TEST_BUILTIN == 0
22001 foreach_standalone_reply_msg;
22006 vat_api_hookup (vat_main_t * vam)
22009 vl_msg_api_set_handlers(VL_API_##N, #n, \
22010 vl_api_##n##_t_handler_uni, \
22012 vl_api_##n##_t_endian, \
22013 vl_api_##n##_t_print, \
22014 sizeof(vl_api_##n##_t), 1);
22015 foreach_vpe_api_reply_msg;
22016 #if VPP_API_TEST_BUILTIN == 0
22017 foreach_standalone_reply_msg;
22021 #if (VPP_API_TEST_BUILTIN==0)
22022 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22024 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22026 vam->function_by_name = hash_create_string (0, sizeof (uword));
22028 vam->help_by_name = hash_create_string (0, sizeof (uword));
22031 /* API messages we can send */
22032 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22033 foreach_vpe_api_msg;
22037 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22038 foreach_vpe_api_msg;
22041 /* CLI functions */
22042 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22043 foreach_cli_function;
22047 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22048 foreach_cli_function;
22052 #if VPP_API_TEST_BUILTIN
22053 static clib_error_t *
22054 vat_api_hookup_shim (vlib_main_t * vm)
22056 vat_api_hookup (&vat_main);
22060 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22064 * fd.io coding-style-patch-verification: ON
22067 * eval: (c-set-style "gnu")