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 = &api_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 = &api_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 = &api_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_mroute_add_del_reply) \
5075 _(mpls_route_add_del_reply) \
5076 _(mpls_table_add_del_reply) \
5077 _(mpls_ip_bind_unbind_reply) \
5078 _(bier_route_add_del_reply) \
5079 _(bier_table_add_del_reply) \
5080 _(proxy_arp_add_del_reply) \
5081 _(proxy_arp_intfc_enable_disable_reply) \
5082 _(sw_interface_set_unnumbered_reply) \
5083 _(ip_neighbor_add_del_reply) \
5084 _(reset_fib_reply) \
5085 _(set_ip_flow_hash_reply) \
5086 _(sw_interface_ip6_enable_disable_reply) \
5087 _(ip6nd_proxy_add_del_reply) \
5088 _(sw_interface_ip6nd_ra_prefix_reply) \
5089 _(sw_interface_ip6nd_ra_config_reply) \
5090 _(set_arp_neighbor_limit_reply) \
5091 _(l2_patch_add_del_reply) \
5092 _(sr_mpls_policy_add_reply) \
5093 _(sr_mpls_policy_mod_reply) \
5094 _(sr_mpls_policy_del_reply) \
5095 _(sr_policy_add_reply) \
5096 _(sr_policy_mod_reply) \
5097 _(sr_policy_del_reply) \
5098 _(sr_localsid_add_del_reply) \
5099 _(sr_steering_add_del_reply) \
5100 _(classify_add_del_session_reply) \
5101 _(classify_set_interface_ip_table_reply) \
5102 _(classify_set_interface_l2_tables_reply) \
5103 _(l2tpv3_set_tunnel_cookies_reply) \
5104 _(l2tpv3_interface_enable_disable_reply) \
5105 _(l2tpv3_set_lookup_key_reply) \
5106 _(l2_fib_clear_table_reply) \
5107 _(l2_interface_efp_filter_reply) \
5108 _(l2_interface_vlan_tag_rewrite_reply) \
5109 _(modify_vhost_user_if_reply) \
5110 _(delete_vhost_user_if_reply) \
5111 _(ip_probe_neighbor_reply) \
5112 _(ip_scan_neighbor_enable_disable_reply) \
5113 _(want_ip4_arp_events_reply) \
5114 _(want_ip6_nd_events_reply) \
5115 _(want_l2_macs_events_reply) \
5116 _(input_acl_set_interface_reply) \
5117 _(ipsec_spd_add_del_reply) \
5118 _(ipsec_interface_add_del_spd_reply) \
5119 _(ipsec_spd_entry_add_del_reply) \
5120 _(ipsec_sad_entry_add_del_reply) \
5121 _(ipsec_tunnel_if_add_del_reply) \
5122 _(ipsec_tunnel_if_set_sa_reply) \
5123 _(delete_loopback_reply) \
5124 _(bd_ip_mac_add_del_reply) \
5125 _(bd_ip_mac_flush_reply) \
5126 _(want_interface_events_reply) \
5127 _(cop_interface_enable_disable_reply) \
5128 _(cop_whitelist_enable_disable_reply) \
5129 _(sw_interface_clear_stats_reply) \
5130 _(ioam_enable_reply) \
5131 _(ioam_disable_reply) \
5132 _(one_add_del_locator_reply) \
5133 _(one_add_del_local_eid_reply) \
5134 _(one_add_del_remote_mapping_reply) \
5135 _(one_add_del_adjacency_reply) \
5136 _(one_add_del_map_resolver_reply) \
5137 _(one_add_del_map_server_reply) \
5138 _(one_enable_disable_reply) \
5139 _(one_rloc_probe_enable_disable_reply) \
5140 _(one_map_register_enable_disable_reply) \
5141 _(one_map_register_set_ttl_reply) \
5142 _(one_set_transport_protocol_reply) \
5143 _(one_map_register_fallback_threshold_reply) \
5144 _(one_pitr_set_locator_set_reply) \
5145 _(one_map_request_mode_reply) \
5146 _(one_add_del_map_request_itr_rlocs_reply) \
5147 _(one_eid_table_add_del_map_reply) \
5148 _(one_use_petr_reply) \
5149 _(one_stats_enable_disable_reply) \
5150 _(one_add_del_l2_arp_entry_reply) \
5151 _(one_add_del_ndp_entry_reply) \
5152 _(one_stats_flush_reply) \
5153 _(one_enable_disable_xtr_mode_reply) \
5154 _(one_enable_disable_pitr_mode_reply) \
5155 _(one_enable_disable_petr_mode_reply) \
5156 _(gpe_enable_disable_reply) \
5157 _(gpe_set_encap_mode_reply) \
5158 _(gpe_add_del_iface_reply) \
5159 _(gpe_add_del_native_fwd_rpath_reply) \
5160 _(af_packet_delete_reply) \
5161 _(policer_classify_set_interface_reply) \
5162 _(netmap_create_reply) \
5163 _(netmap_delete_reply) \
5164 _(set_ipfix_exporter_reply) \
5165 _(set_ipfix_classify_stream_reply) \
5166 _(ipfix_classify_table_add_del_reply) \
5167 _(flow_classify_set_interface_reply) \
5168 _(sw_interface_span_enable_disable_reply) \
5169 _(pg_capture_reply) \
5170 _(pg_enable_disable_reply) \
5171 _(ip_source_and_port_range_check_add_del_reply) \
5172 _(ip_source_and_port_range_check_interface_add_del_reply)\
5173 _(delete_subif_reply) \
5174 _(l2_interface_pbb_tag_rewrite_reply) \
5176 _(feature_enable_disable_reply) \
5177 _(sw_interface_tag_add_del_reply) \
5178 _(sw_interface_add_del_mac_address_reply) \
5179 _(hw_interface_set_mtu_reply) \
5180 _(p2p_ethernet_add_reply) \
5181 _(p2p_ethernet_del_reply) \
5182 _(lldp_config_reply) \
5183 _(sw_interface_set_lldp_reply) \
5184 _(tcp_configure_src_addresses_reply) \
5185 _(session_rule_add_del_reply) \
5186 _(ip_container_proxy_add_del_reply) \
5187 _(output_acl_set_interface_reply) \
5188 _(qos_record_enable_disable_reply)
5191 static void vl_api_##n##_t_handler \
5192 (vl_api_##n##_t * mp) \
5194 vat_main_t * vam = &vat_main; \
5195 i32 retval = ntohl(mp->retval); \
5196 if (vam->async_mode) { \
5197 vam->async_errors += (retval < 0); \
5199 vam->retval = retval; \
5200 vam->result_ready = 1; \
5203 foreach_standard_reply_retval_handler;
5207 static void vl_api_##n##_t_handler_json \
5208 (vl_api_##n##_t * mp) \
5210 vat_main_t * vam = &vat_main; \
5211 vat_json_node_t node; \
5212 vat_json_init_object(&node); \
5213 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5214 vat_json_print(vam->ofp, &node); \
5215 vam->retval = ntohl(mp->retval); \
5216 vam->result_ready = 1; \
5218 foreach_standard_reply_retval_handler;
5222 * Table of message reply handlers, must include boilerplate handlers
5226 #define foreach_vpe_api_reply_msg \
5227 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5228 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5229 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5230 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5231 _(CONTROL_PING_REPLY, control_ping_reply) \
5232 _(CLI_REPLY, cli_reply) \
5233 _(CLI_INBAND_REPLY, cli_inband_reply) \
5234 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5235 sw_interface_add_del_address_reply) \
5236 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5237 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5238 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5239 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5240 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5241 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5242 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5243 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5244 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5245 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5246 sw_interface_set_l2_xconnect_reply) \
5247 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5248 sw_interface_set_l2_bridge_reply) \
5249 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5250 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5251 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5252 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5253 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5254 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5255 _(L2_FLAGS_REPLY, l2_flags_reply) \
5256 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5257 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5258 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5259 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5260 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5261 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5262 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5263 _(BOND_CREATE_REPLY, bond_create_reply) \
5264 _(BOND_DELETE_REPLY, bond_delete_reply) \
5265 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5266 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5267 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5268 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5269 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5270 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5271 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5272 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5273 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5274 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5275 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5276 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5277 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5278 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5279 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5280 proxy_arp_intfc_enable_disable_reply) \
5281 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5282 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5283 sw_interface_set_unnumbered_reply) \
5284 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5285 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5286 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5287 _(RESET_FIB_REPLY, reset_fib_reply) \
5288 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5289 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5290 sw_interface_ip6_enable_disable_reply) \
5291 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5292 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5293 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5294 sw_interface_ip6nd_ra_prefix_reply) \
5295 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5296 sw_interface_ip6nd_ra_config_reply) \
5297 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5298 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5299 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5300 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5301 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5302 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5303 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5304 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5305 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5306 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5307 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5308 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5309 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5310 classify_set_interface_ip_table_reply) \
5311 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5312 classify_set_interface_l2_tables_reply) \
5313 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5314 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5315 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5316 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5317 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5318 l2tpv3_interface_enable_disable_reply) \
5319 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5320 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5321 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5322 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5323 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5324 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5325 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5326 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5327 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5328 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5329 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5330 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5331 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5332 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5333 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5334 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5335 _(SHOW_VERSION_REPLY, show_version_reply) \
5336 _(SHOW_THREADS_REPLY, show_threads_reply) \
5337 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5338 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5339 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5340 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5341 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5342 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5343 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5344 _(IP4_ARP_EVENT, ip4_arp_event) \
5345 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5346 _(IP6_ND_EVENT, ip6_nd_event) \
5347 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5348 _(L2_MACS_EVENT, l2_macs_event) \
5349 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5350 _(IP_ADDRESS_DETAILS, ip_address_details) \
5351 _(IP_DETAILS, ip_details) \
5352 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5353 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5354 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5355 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5356 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5357 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5358 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5359 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5360 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5361 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5362 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5363 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5364 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5365 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5366 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5367 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5368 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5369 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5370 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5371 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5372 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5373 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5374 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5375 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5376 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5377 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5378 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5379 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5380 one_map_register_enable_disable_reply) \
5381 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5382 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5383 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5384 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5385 one_map_register_fallback_threshold_reply) \
5386 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5387 one_rloc_probe_enable_disable_reply) \
5388 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5389 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5390 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5391 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5392 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5393 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5394 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5395 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5396 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5397 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5398 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5399 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5400 _(ONE_STATS_DETAILS, one_stats_details) \
5401 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5402 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5403 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5404 show_one_stats_enable_disable_reply) \
5405 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5406 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5407 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5408 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5409 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5410 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5411 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5412 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5413 one_enable_disable_pitr_mode_reply) \
5414 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5415 one_enable_disable_petr_mode_reply) \
5416 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5417 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5418 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5419 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5420 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5421 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5422 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5423 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5424 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5425 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5426 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5427 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5428 gpe_add_del_native_fwd_rpath_reply) \
5429 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5430 gpe_fwd_entry_path_details) \
5431 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5432 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5433 one_add_del_map_request_itr_rlocs_reply) \
5434 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5435 one_get_map_request_itr_rlocs_reply) \
5436 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5437 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5438 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5439 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5440 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5441 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5442 show_one_map_register_state_reply) \
5443 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5444 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5445 show_one_map_register_fallback_threshold_reply) \
5446 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5447 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5448 _(AF_PACKET_DETAILS, af_packet_details) \
5449 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5450 _(POLICER_DETAILS, policer_details) \
5451 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5452 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5453 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5454 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5455 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5456 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5457 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5458 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5459 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5460 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5461 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5462 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5463 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5464 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5465 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5466 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5467 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5468 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5469 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5470 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5471 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5472 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5473 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5474 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5475 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5476 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5477 ip_source_and_port_range_check_add_del_reply) \
5478 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5479 ip_source_and_port_range_check_interface_add_del_reply) \
5480 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5481 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5482 _(SET_PUNT_REPLY, set_punt_reply) \
5483 _(IP_TABLE_DETAILS, ip_table_details) \
5484 _(IP_ROUTE_DETAILS, ip_route_details) \
5485 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5486 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5487 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
5488 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5489 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5490 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5491 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5492 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5493 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5494 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5495 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5496 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5497 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5498 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5499 _(SESSION_RULES_DETAILS, session_rules_details) \
5500 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5501 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5502 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5504 #define foreach_standalone_reply_msg \
5505 _(SW_INTERFACE_EVENT, sw_interface_event)
5513 #define STR_VTR_OP_CASE(op) \
5514 case L2_VTR_ ## op: \
5518 str_vtr_op (u32 vtr_op)
5522 STR_VTR_OP_CASE (DISABLED);
5523 STR_VTR_OP_CASE (PUSH_1);
5524 STR_VTR_OP_CASE (PUSH_2);
5525 STR_VTR_OP_CASE (POP_1);
5526 STR_VTR_OP_CASE (POP_2);
5527 STR_VTR_OP_CASE (TRANSLATE_1_1);
5528 STR_VTR_OP_CASE (TRANSLATE_1_2);
5529 STR_VTR_OP_CASE (TRANSLATE_2_1);
5530 STR_VTR_OP_CASE (TRANSLATE_2_2);
5537 dump_sub_interface_table (vat_main_t * vam)
5539 const sw_interface_subif_t *sub = NULL;
5541 if (vam->json_output)
5544 ("JSON output supported only for VPE API calls and dump_stats_table");
5549 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5550 "Interface", "sw_if_index",
5551 "sub id", "dot1ad", "tags", "outer id",
5552 "inner id", "exact", "default", "outer any", "inner any");
5554 vec_foreach (sub, vam->sw_if_subif_table)
5557 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5558 sub->interface_name,
5560 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5561 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5562 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5563 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5564 if (sub->vtr_op != L2_VTR_DISABLED)
5567 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5568 "tag1: %d tag2: %d ]",
5569 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5570 sub->vtr_tag1, sub->vtr_tag2);
5578 name_sort_cmp (void *a1, void *a2)
5580 name_sort_t *n1 = a1;
5581 name_sort_t *n2 = a2;
5583 return strcmp ((char *) n1->name, (char *) n2->name);
5587 dump_interface_table (vat_main_t * vam)
5590 name_sort_t *nses = 0, *ns;
5592 if (vam->json_output)
5595 ("JSON output supported only for VPE API calls and dump_stats_table");
5600 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5602 vec_add2 (nses, ns, 1);
5603 ns->name = (u8 *)(p->key);
5604 ns->value = (u32) p->value[0];
5608 vec_sort_with_function (nses, name_sort_cmp);
5610 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5611 vec_foreach (ns, nses)
5613 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5620 dump_ip_table (vat_main_t * vam, int is_ipv6)
5622 const ip_details_t *det = NULL;
5623 const ip_address_details_t *address = NULL;
5626 print (vam->ofp, "%-12s", "sw_if_index");
5628 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5635 print (vam->ofp, "%-12d", i);
5636 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5641 vec_foreach (address, det->addr)
5645 is_ipv6 ? format_ip6_address : format_ip4_address,
5646 address->ip, address->prefix_length);
5654 dump_ipv4_table (vat_main_t * vam)
5656 if (vam->json_output)
5659 ("JSON output supported only for VPE API calls and dump_stats_table");
5663 return dump_ip_table (vam, 0);
5667 dump_ipv6_table (vat_main_t * vam)
5669 if (vam->json_output)
5672 ("JSON output supported only for VPE API calls and dump_stats_table");
5676 return dump_ip_table (vam, 1);
5680 * Pass CLI buffers directly in the CLI_INBAND API message,
5681 * instead of an additional shared memory area.
5684 exec_inband (vat_main_t * vam)
5686 vl_api_cli_inband_t *mp;
5687 unformat_input_t *i = vam->input;
5690 if (vec_len (i->buffer) == 0)
5693 if (vam->exec_mode == 0 && unformat (i, "mode"))
5698 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5705 * In order for the CLI command to work, it
5706 * must be a vector ending in \n, not a C-string ending
5709 u32 len = vec_len (vam->input->buffer);
5710 M2 (CLI_INBAND, mp, len);
5711 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5715 /* json responses may or may not include a useful reply... */
5716 if (vec_len (vam->cmd_reply))
5717 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5722 exec (vat_main_t * vam)
5724 return exec_inband (vam);
5728 api_create_loopback (vat_main_t * vam)
5730 unformat_input_t *i = vam->input;
5731 vl_api_create_loopback_t *mp;
5732 vl_api_create_loopback_instance_t *mp_lbi;
5735 u8 is_specified = 0;
5736 u32 user_instance = 0;
5739 clib_memset (mac_address, 0, sizeof (mac_address));
5741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5743 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5745 if (unformat (i, "instance %d", &user_instance))
5753 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5754 mp_lbi->is_specified = is_specified;
5756 mp_lbi->user_instance = htonl (user_instance);
5758 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5763 /* Construct the API message */
5764 M (CREATE_LOOPBACK, mp);
5766 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5775 api_delete_loopback (vat_main_t * vam)
5777 unformat_input_t *i = vam->input;
5778 vl_api_delete_loopback_t *mp;
5779 u32 sw_if_index = ~0;
5782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5784 if (unformat (i, "sw_if_index %d", &sw_if_index))
5790 if (sw_if_index == ~0)
5792 errmsg ("missing sw_if_index");
5796 /* Construct the API message */
5797 M (DELETE_LOOPBACK, mp);
5798 mp->sw_if_index = ntohl (sw_if_index);
5806 api_want_interface_events (vat_main_t * vam)
5808 unformat_input_t *i = vam->input;
5809 vl_api_want_interface_events_t *mp;
5813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5815 if (unformat (i, "enable"))
5817 else if (unformat (i, "disable"))
5825 errmsg ("missing enable|disable");
5829 M (WANT_INTERFACE_EVENTS, mp);
5830 mp->enable_disable = enable;
5832 vam->interface_event_display = enable;
5840 /* Note: non-static, called once to set up the initial intfc table */
5842 api_sw_interface_dump (vat_main_t * vam)
5844 vl_api_sw_interface_dump_t *mp;
5845 vl_api_control_ping_t *mp_ping;
5847 name_sort_t *nses = 0, *ns;
5848 sw_interface_subif_t *sub = NULL;
5851 /* Toss the old name table */
5853 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5855 vec_add2 (nses, ns, 1);
5856 ns->name = (u8 *)(p->key);
5857 ns->value = (u32) p->value[0];
5861 hash_free (vam->sw_if_index_by_interface_name);
5863 vec_foreach (ns, nses) vec_free (ns->name);
5867 vec_foreach (sub, vam->sw_if_subif_table)
5869 vec_free (sub->interface_name);
5871 vec_free (vam->sw_if_subif_table);
5873 /* recreate the interface name hash table */
5874 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5877 * Ask for all interface names. Otherwise, the epic catalog of
5878 * name filters becomes ridiculously long, and vat ends up needing
5879 * to be taught about new interface types.
5881 M (SW_INTERFACE_DUMP, mp);
5884 /* Use a control ping for synchronization */
5885 MPING (CONTROL_PING, mp_ping);
5893 api_sw_interface_set_flags (vat_main_t * vam)
5895 unformat_input_t *i = vam->input;
5896 vl_api_sw_interface_set_flags_t *mp;
5898 u8 sw_if_index_set = 0;
5902 /* Parse args required to build the message */
5903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5905 if (unformat (i, "admin-up"))
5907 else if (unformat (i, "admin-down"))
5910 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5911 sw_if_index_set = 1;
5912 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5913 sw_if_index_set = 1;
5918 if (sw_if_index_set == 0)
5920 errmsg ("missing interface name or sw_if_index");
5924 /* Construct the API message */
5925 M (SW_INTERFACE_SET_FLAGS, mp);
5926 mp->sw_if_index = ntohl (sw_if_index);
5927 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5932 /* Wait for a reply, return the good/bad news... */
5938 api_sw_interface_set_rx_mode (vat_main_t * vam)
5940 unformat_input_t *i = vam->input;
5941 vl_api_sw_interface_set_rx_mode_t *mp;
5943 u8 sw_if_index_set = 0;
5945 u8 queue_id_valid = 0;
5947 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5949 /* Parse args required to build the message */
5950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5952 if (unformat (i, "queue %d", &queue_id))
5954 else if (unformat (i, "polling"))
5955 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5956 else if (unformat (i, "interrupt"))
5957 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5958 else if (unformat (i, "adaptive"))
5959 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5961 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5962 sw_if_index_set = 1;
5963 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5964 sw_if_index_set = 1;
5969 if (sw_if_index_set == 0)
5971 errmsg ("missing interface name or sw_if_index");
5974 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
5976 errmsg ("missing rx-mode");
5980 /* Construct the API message */
5981 M (SW_INTERFACE_SET_RX_MODE, mp);
5982 mp->sw_if_index = ntohl (sw_if_index);
5983 mp->mode = (vl_api_rx_mode_t) mode;
5984 mp->queue_id_valid = queue_id_valid;
5985 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
5990 /* Wait for a reply, return the good/bad news... */
5996 api_sw_interface_set_rx_placement (vat_main_t * vam)
5998 unformat_input_t *i = vam->input;
5999 vl_api_sw_interface_set_rx_placement_t *mp;
6001 u8 sw_if_index_set = 0;
6004 u32 queue_id, thread_index;
6006 /* Parse args required to build the message */
6007 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6009 if (unformat (i, "queue %d", &queue_id))
6011 else if (unformat (i, "main"))
6013 else if (unformat (i, "worker %d", &thread_index))
6016 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6017 sw_if_index_set = 1;
6018 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6019 sw_if_index_set = 1;
6024 if (sw_if_index_set == 0)
6026 errmsg ("missing interface name or sw_if_index");
6032 /* Construct the API message */
6033 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6034 mp->sw_if_index = ntohl (sw_if_index);
6035 mp->worker_id = ntohl (thread_index);
6036 mp->queue_id = ntohl (queue_id);
6037 mp->is_main = is_main;
6041 /* Wait for a reply, return the good/bad news... */
6046 static void vl_api_sw_interface_rx_placement_details_t_handler
6047 (vl_api_sw_interface_rx_placement_details_t * mp)
6049 vat_main_t *vam = &vat_main;
6050 u32 worker_id = ntohl (mp->worker_id);
6053 "\n%-11d %-11s %-6d %-5d %-9s",
6054 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6055 worker_id, ntohl (mp->queue_id),
6057 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6060 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6061 (vl_api_sw_interface_rx_placement_details_t * mp)
6063 vat_main_t *vam = &vat_main;
6064 vat_json_node_t *node = NULL;
6066 if (VAT_JSON_ARRAY != vam->json_tree.type)
6068 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6069 vat_json_init_array (&vam->json_tree);
6071 node = vat_json_array_add (&vam->json_tree);
6073 vat_json_init_object (node);
6074 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6075 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6076 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6077 vat_json_object_add_uint (node, "mode", mp->mode);
6081 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6083 unformat_input_t *i = vam->input;
6084 vl_api_sw_interface_rx_placement_dump_t *mp;
6085 vl_api_control_ping_t *mp_ping;
6088 u8 sw_if_index_set = 0;
6090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6092 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6094 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6101 "\n%-11s %-11s %-6s %-5s %-4s",
6102 "sw_if_index", "main/worker", "thread", "queue", "mode");
6104 /* Dump Interface rx placement */
6105 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6107 if (sw_if_index_set)
6108 mp->sw_if_index = htonl (sw_if_index);
6110 mp->sw_if_index = ~0;
6114 /* Use a control ping for synchronization */
6115 MPING (CONTROL_PING, mp_ping);
6123 api_sw_interface_clear_stats (vat_main_t * vam)
6125 unformat_input_t *i = vam->input;
6126 vl_api_sw_interface_clear_stats_t *mp;
6128 u8 sw_if_index_set = 0;
6131 /* Parse args required to build the message */
6132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6134 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6135 sw_if_index_set = 1;
6136 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6137 sw_if_index_set = 1;
6142 /* Construct the API message */
6143 M (SW_INTERFACE_CLEAR_STATS, mp);
6145 if (sw_if_index_set == 1)
6146 mp->sw_if_index = ntohl (sw_if_index);
6148 mp->sw_if_index = ~0;
6153 /* Wait for a reply, return the good/bad news... */
6159 api_sw_interface_add_del_address (vat_main_t * vam)
6161 unformat_input_t *i = vam->input;
6162 vl_api_sw_interface_add_del_address_t *mp;
6164 u8 sw_if_index_set = 0;
6165 u8 is_add = 1, del_all = 0;
6166 u32 address_length = 0;
6167 u8 v4_address_set = 0;
6168 u8 v6_address_set = 0;
6169 ip4_address_t v4address;
6170 ip6_address_t v6address;
6173 /* Parse args required to build the message */
6174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6176 if (unformat (i, "del-all"))
6178 else if (unformat (i, "del"))
6181 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6182 sw_if_index_set = 1;
6183 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6184 sw_if_index_set = 1;
6185 else if (unformat (i, "%U/%d",
6186 unformat_ip4_address, &v4address, &address_length))
6188 else if (unformat (i, "%U/%d",
6189 unformat_ip6_address, &v6address, &address_length))
6195 if (sw_if_index_set == 0)
6197 errmsg ("missing interface name or sw_if_index");
6200 if (v4_address_set && v6_address_set)
6202 errmsg ("both v4 and v6 addresses set");
6205 if (!v4_address_set && !v6_address_set && !del_all)
6207 errmsg ("no addresses set");
6211 /* Construct the API message */
6212 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6214 mp->sw_if_index = ntohl (sw_if_index);
6215 mp->is_add = is_add;
6216 mp->del_all = del_all;
6219 mp->prefix.address.af = ADDRESS_IP6;
6220 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6224 mp->prefix.address.af = ADDRESS_IP4;
6225 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6227 mp->prefix.len = address_length;
6232 /* Wait for a reply, return good/bad news */
6238 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6240 unformat_input_t *i = vam->input;
6241 vl_api_sw_interface_set_mpls_enable_t *mp;
6243 u8 sw_if_index_set = 0;
6247 /* Parse args required to build the message */
6248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6250 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6251 sw_if_index_set = 1;
6252 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6253 sw_if_index_set = 1;
6254 else if (unformat (i, "disable"))
6256 else if (unformat (i, "dis"))
6262 if (sw_if_index_set == 0)
6264 errmsg ("missing interface name or sw_if_index");
6268 /* Construct the API message */
6269 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6271 mp->sw_if_index = ntohl (sw_if_index);
6272 mp->enable = enable;
6277 /* Wait for a reply... */
6283 api_sw_interface_set_table (vat_main_t * vam)
6285 unformat_input_t *i = vam->input;
6286 vl_api_sw_interface_set_table_t *mp;
6287 u32 sw_if_index, vrf_id = 0;
6288 u8 sw_if_index_set = 0;
6292 /* Parse args required to build the message */
6293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6295 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6296 sw_if_index_set = 1;
6297 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6298 sw_if_index_set = 1;
6299 else if (unformat (i, "vrf %d", &vrf_id))
6301 else if (unformat (i, "ipv6"))
6307 if (sw_if_index_set == 0)
6309 errmsg ("missing interface name or sw_if_index");
6313 /* Construct the API message */
6314 M (SW_INTERFACE_SET_TABLE, mp);
6316 mp->sw_if_index = ntohl (sw_if_index);
6317 mp->is_ipv6 = is_ipv6;
6318 mp->vrf_id = ntohl (vrf_id);
6323 /* Wait for a reply... */
6328 static void vl_api_sw_interface_get_table_reply_t_handler
6329 (vl_api_sw_interface_get_table_reply_t * mp)
6331 vat_main_t *vam = &vat_main;
6333 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6335 vam->retval = ntohl (mp->retval);
6336 vam->result_ready = 1;
6340 static void vl_api_sw_interface_get_table_reply_t_handler_json
6341 (vl_api_sw_interface_get_table_reply_t * mp)
6343 vat_main_t *vam = &vat_main;
6344 vat_json_node_t node;
6346 vat_json_init_object (&node);
6347 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6348 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6350 vat_json_print (vam->ofp, &node);
6351 vat_json_free (&node);
6353 vam->retval = ntohl (mp->retval);
6354 vam->result_ready = 1;
6358 api_sw_interface_get_table (vat_main_t * vam)
6360 unformat_input_t *i = vam->input;
6361 vl_api_sw_interface_get_table_t *mp;
6363 u8 sw_if_index_set = 0;
6367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6369 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6370 sw_if_index_set = 1;
6371 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6372 sw_if_index_set = 1;
6373 else if (unformat (i, "ipv6"))
6379 if (sw_if_index_set == 0)
6381 errmsg ("missing interface name or sw_if_index");
6385 M (SW_INTERFACE_GET_TABLE, mp);
6386 mp->sw_if_index = htonl (sw_if_index);
6387 mp->is_ipv6 = is_ipv6;
6395 api_sw_interface_set_vpath (vat_main_t * vam)
6397 unformat_input_t *i = vam->input;
6398 vl_api_sw_interface_set_vpath_t *mp;
6399 u32 sw_if_index = 0;
6400 u8 sw_if_index_set = 0;
6404 /* Parse args required to build the message */
6405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6407 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6408 sw_if_index_set = 1;
6409 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6410 sw_if_index_set = 1;
6411 else if (unformat (i, "enable"))
6413 else if (unformat (i, "disable"))
6419 if (sw_if_index_set == 0)
6421 errmsg ("missing interface name or sw_if_index");
6425 /* Construct the API message */
6426 M (SW_INTERFACE_SET_VPATH, mp);
6428 mp->sw_if_index = ntohl (sw_if_index);
6429 mp->enable = is_enable;
6434 /* Wait for a reply... */
6440 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6442 unformat_input_t *i = vam->input;
6443 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6444 u32 sw_if_index = 0;
6445 u8 sw_if_index_set = 0;
6450 /* Parse args required to build the message */
6451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6453 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6454 sw_if_index_set = 1;
6455 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6456 sw_if_index_set = 1;
6457 else if (unformat (i, "enable"))
6459 else if (unformat (i, "disable"))
6461 else if (unformat (i, "ip4"))
6463 else if (unformat (i, "ip6"))
6469 if (sw_if_index_set == 0)
6471 errmsg ("missing interface name or sw_if_index");
6475 /* Construct the API message */
6476 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6478 mp->sw_if_index = ntohl (sw_if_index);
6479 mp->enable = is_enable;
6480 mp->is_ipv6 = is_ipv6;
6485 /* Wait for a reply... */
6491 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6493 unformat_input_t *i = vam->input;
6494 vl_api_sw_interface_set_geneve_bypass_t *mp;
6495 u32 sw_if_index = 0;
6496 u8 sw_if_index_set = 0;
6501 /* Parse args required to build the message */
6502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6504 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6505 sw_if_index_set = 1;
6506 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6507 sw_if_index_set = 1;
6508 else if (unformat (i, "enable"))
6510 else if (unformat (i, "disable"))
6512 else if (unformat (i, "ip4"))
6514 else if (unformat (i, "ip6"))
6520 if (sw_if_index_set == 0)
6522 errmsg ("missing interface name or sw_if_index");
6526 /* Construct the API message */
6527 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6529 mp->sw_if_index = ntohl (sw_if_index);
6530 mp->enable = is_enable;
6531 mp->is_ipv6 = is_ipv6;
6536 /* Wait for a reply... */
6542 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6544 unformat_input_t *i = vam->input;
6545 vl_api_sw_interface_set_l2_xconnect_t *mp;
6547 u8 rx_sw_if_index_set = 0;
6549 u8 tx_sw_if_index_set = 0;
6553 /* Parse args required to build the message */
6554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6556 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6557 rx_sw_if_index_set = 1;
6558 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6559 tx_sw_if_index_set = 1;
6560 else if (unformat (i, "rx"))
6562 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6564 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6566 rx_sw_if_index_set = 1;
6571 else if (unformat (i, "tx"))
6573 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6575 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6577 tx_sw_if_index_set = 1;
6582 else if (unformat (i, "enable"))
6584 else if (unformat (i, "disable"))
6590 if (rx_sw_if_index_set == 0)
6592 errmsg ("missing rx interface name or rx_sw_if_index");
6596 if (enable && (tx_sw_if_index_set == 0))
6598 errmsg ("missing tx interface name or tx_sw_if_index");
6602 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6604 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6605 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6606 mp->enable = enable;
6614 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6616 unformat_input_t *i = vam->input;
6617 vl_api_sw_interface_set_l2_bridge_t *mp;
6618 vl_api_l2_port_type_t port_type;
6620 u8 rx_sw_if_index_set = 0;
6627 port_type = L2_API_PORT_TYPE_NORMAL;
6629 /* Parse args required to build the message */
6630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6632 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6633 rx_sw_if_index_set = 1;
6634 else if (unformat (i, "bd_id %d", &bd_id))
6638 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6639 rx_sw_if_index_set = 1;
6640 else if (unformat (i, "shg %d", &shg))
6642 else if (unformat (i, "bvi"))
6643 port_type = L2_API_PORT_TYPE_BVI;
6644 else if (unformat (i, "uu-fwd"))
6645 port_type = L2_API_PORT_TYPE_UU_FWD;
6646 else if (unformat (i, "enable"))
6648 else if (unformat (i, "disable"))
6654 if (rx_sw_if_index_set == 0)
6656 errmsg ("missing rx interface name or sw_if_index");
6660 if (enable && (bd_id_set == 0))
6662 errmsg ("missing bridge domain");
6666 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6668 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6669 mp->bd_id = ntohl (bd_id);
6671 mp->port_type = ntohl (port_type);
6672 mp->enable = enable;
6680 api_bridge_domain_dump (vat_main_t * vam)
6682 unformat_input_t *i = vam->input;
6683 vl_api_bridge_domain_dump_t *mp;
6684 vl_api_control_ping_t *mp_ping;
6688 /* Parse args required to build the message */
6689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6691 if (unformat (i, "bd_id %d", &bd_id))
6697 M (BRIDGE_DOMAIN_DUMP, mp);
6698 mp->bd_id = ntohl (bd_id);
6701 /* Use a control ping for synchronization */
6702 MPING (CONTROL_PING, mp_ping);
6710 api_bridge_domain_add_del (vat_main_t * vam)
6712 unformat_input_t *i = vam->input;
6713 vl_api_bridge_domain_add_del_t *mp;
6716 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6721 /* Parse args required to build the message */
6722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6724 if (unformat (i, "bd_id %d", &bd_id))
6726 else if (unformat (i, "flood %d", &flood))
6728 else if (unformat (i, "uu-flood %d", &uu_flood))
6730 else if (unformat (i, "forward %d", &forward))
6732 else if (unformat (i, "learn %d", &learn))
6734 else if (unformat (i, "arp-term %d", &arp_term))
6736 else if (unformat (i, "mac-age %d", &mac_age))
6738 else if (unformat (i, "bd-tag %s", &bd_tag))
6740 else if (unformat (i, "del"))
6743 flood = uu_flood = forward = learn = 0;
6751 errmsg ("missing bridge domain");
6758 errmsg ("mac age must be less than 256 ");
6763 if ((bd_tag) && (vec_len (bd_tag) > 63))
6765 errmsg ("bd-tag cannot be longer than 63");
6770 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6772 mp->bd_id = ntohl (bd_id);
6774 mp->uu_flood = uu_flood;
6775 mp->forward = forward;
6777 mp->arp_term = arp_term;
6778 mp->is_add = is_add;
6779 mp->mac_age = (u8) mac_age;
6782 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6783 mp->bd_tag[vec_len (bd_tag)] = 0;
6794 api_l2fib_flush_bd (vat_main_t * vam)
6796 unformat_input_t *i = vam->input;
6797 vl_api_l2fib_flush_bd_t *mp;
6801 /* Parse args required to build the message */
6802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6804 if (unformat (i, "bd_id %d", &bd_id));
6811 errmsg ("missing bridge domain");
6815 M (L2FIB_FLUSH_BD, mp);
6817 mp->bd_id = htonl (bd_id);
6825 api_l2fib_flush_int (vat_main_t * vam)
6827 unformat_input_t *i = vam->input;
6828 vl_api_l2fib_flush_int_t *mp;
6829 u32 sw_if_index = ~0;
6832 /* Parse args required to build the message */
6833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6835 if (unformat (i, "sw_if_index %d", &sw_if_index));
6837 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6842 if (sw_if_index == ~0)
6844 errmsg ("missing interface name or sw_if_index");
6848 M (L2FIB_FLUSH_INT, mp);
6850 mp->sw_if_index = ntohl (sw_if_index);
6858 api_l2fib_add_del (vat_main_t * vam)
6860 unformat_input_t *i = vam->input;
6861 vl_api_l2fib_add_del_t *mp;
6867 u32 sw_if_index = 0;
6868 u8 sw_if_index_set = 0;
6877 /* Parse args required to build the message */
6878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6880 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6882 else if (unformat (i, "bd_id %d", &bd_id))
6884 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6885 sw_if_index_set = 1;
6886 else if (unformat (i, "sw_if"))
6888 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6891 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6892 sw_if_index_set = 1;
6897 else if (unformat (i, "static"))
6899 else if (unformat (i, "filter"))
6904 else if (unformat (i, "bvi"))
6909 else if (unformat (i, "del"))
6911 else if (unformat (i, "count %d", &count))
6919 errmsg ("missing mac address");
6925 errmsg ("missing bridge domain");
6929 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6931 errmsg ("missing interface name or sw_if_index");
6937 /* Turn on async mode */
6938 vam->async_mode = 1;
6939 vam->async_errors = 0;
6940 before = vat_time_now (vam);
6943 for (j = 0; j < count; j++)
6945 M (L2FIB_ADD_DEL, mp);
6947 clib_memcpy (mp->mac, mac, 6);
6948 mp->bd_id = ntohl (bd_id);
6949 mp->is_add = is_add;
6950 mp->sw_if_index = ntohl (sw_if_index);
6954 mp->static_mac = static_mac;
6955 mp->filter_mac = filter_mac;
6956 mp->bvi_mac = bvi_mac;
6958 increment_mac_address (mac);
6965 vl_api_control_ping_t *mp_ping;
6968 /* Shut off async mode */
6969 vam->async_mode = 0;
6971 MPING (CONTROL_PING, mp_ping);
6974 timeout = vat_time_now (vam) + 1.0;
6975 while (vat_time_now (vam) < timeout)
6976 if (vam->result_ready == 1)
6981 if (vam->retval == -99)
6984 if (vam->async_errors > 0)
6986 errmsg ("%d asynchronous errors", vam->async_errors);
6989 vam->async_errors = 0;
6990 after = vat_time_now (vam);
6992 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6993 count, after - before, count / (after - before));
6999 /* Wait for a reply... */
7003 /* Return the good/bad news */
7004 return (vam->retval);
7008 api_bridge_domain_set_mac_age (vat_main_t * vam)
7010 unformat_input_t *i = vam->input;
7011 vl_api_bridge_domain_set_mac_age_t *mp;
7016 /* Parse args required to build the message */
7017 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7019 if (unformat (i, "bd_id %d", &bd_id));
7020 else if (unformat (i, "mac-age %d", &mac_age));
7027 errmsg ("missing bridge domain");
7033 errmsg ("mac age must be less than 256 ");
7037 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7039 mp->bd_id = htonl (bd_id);
7040 mp->mac_age = (u8) mac_age;
7048 api_l2_flags (vat_main_t * vam)
7050 unformat_input_t *i = vam->input;
7051 vl_api_l2_flags_t *mp;
7054 u8 sw_if_index_set = 0;
7058 /* Parse args required to build the message */
7059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7061 if (unformat (i, "sw_if_index %d", &sw_if_index))
7062 sw_if_index_set = 1;
7063 else if (unformat (i, "sw_if"))
7065 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7068 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7069 sw_if_index_set = 1;
7074 else if (unformat (i, "learn"))
7076 else if (unformat (i, "forward"))
7078 else if (unformat (i, "flood"))
7080 else if (unformat (i, "uu-flood"))
7081 flags |= L2_UU_FLOOD;
7082 else if (unformat (i, "arp-term"))
7083 flags |= L2_ARP_TERM;
7084 else if (unformat (i, "off"))
7086 else if (unformat (i, "disable"))
7092 if (sw_if_index_set == 0)
7094 errmsg ("missing interface name or sw_if_index");
7100 mp->sw_if_index = ntohl (sw_if_index);
7101 mp->feature_bitmap = ntohl (flags);
7102 mp->is_set = is_set;
7110 api_bridge_flags (vat_main_t * vam)
7112 unformat_input_t *i = vam->input;
7113 vl_api_bridge_flags_t *mp;
7117 bd_flags_t flags = 0;
7120 /* Parse args required to build the message */
7121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7123 if (unformat (i, "bd_id %d", &bd_id))
7125 else if (unformat (i, "learn"))
7126 flags |= BRIDGE_API_FLAG_LEARN;
7127 else if (unformat (i, "forward"))
7128 flags |= BRIDGE_API_FLAG_FWD;
7129 else if (unformat (i, "flood"))
7130 flags |= BRIDGE_API_FLAG_FLOOD;
7131 else if (unformat (i, "uu-flood"))
7132 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7133 else if (unformat (i, "arp-term"))
7134 flags |= BRIDGE_API_FLAG_ARP_TERM;
7135 else if (unformat (i, "off"))
7137 else if (unformat (i, "disable"))
7145 errmsg ("missing bridge domain");
7149 M (BRIDGE_FLAGS, mp);
7151 mp->bd_id = ntohl (bd_id);
7152 mp->flags = ntohl (flags);
7153 mp->is_set = is_set;
7161 api_bd_ip_mac_add_del (vat_main_t * vam)
7163 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7164 vl_api_mac_address_t mac = { 0 };
7165 unformat_input_t *i = vam->input;
7166 vl_api_bd_ip_mac_add_del_t *mp;
7175 /* Parse args required to build the message */
7176 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7178 if (unformat (i, "bd_id %d", &bd_id))
7182 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7186 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7190 else if (unformat (i, "del"))
7198 errmsg ("missing bridge domain");
7201 else if (ip_set == 0)
7203 errmsg ("missing IP address");
7206 else if (mac_set == 0)
7208 errmsg ("missing MAC address");
7212 M (BD_IP_MAC_ADD_DEL, mp);
7214 mp->entry.bd_id = ntohl (bd_id);
7215 mp->is_add = is_add;
7217 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7218 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7226 api_bd_ip_mac_flush (vat_main_t * vam)
7228 unformat_input_t *i = vam->input;
7229 vl_api_bd_ip_mac_flush_t *mp;
7234 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7236 if (unformat (i, "bd_id %d", &bd_id))
7246 errmsg ("missing bridge domain");
7250 M (BD_IP_MAC_FLUSH, mp);
7252 mp->bd_id = ntohl (bd_id);
7259 static void vl_api_bd_ip_mac_details_t_handler
7260 (vl_api_bd_ip_mac_details_t * mp)
7262 vat_main_t *vam = &vat_main;
7266 ntohl (mp->entry.bd_id),
7267 format_vl_api_mac_address, mp->entry.mac,
7268 format_vl_api_address, &mp->entry.ip);
7271 static void vl_api_bd_ip_mac_details_t_handler_json
7272 (vl_api_bd_ip_mac_details_t * mp)
7274 vat_main_t *vam = &vat_main;
7275 vat_json_node_t *node = NULL;
7277 if (VAT_JSON_ARRAY != vam->json_tree.type)
7279 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7280 vat_json_init_array (&vam->json_tree);
7282 node = vat_json_array_add (&vam->json_tree);
7284 vat_json_init_object (node);
7285 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7286 vat_json_object_add_string_copy (node, "mac_address",
7287 format (0, "%U", format_vl_api_mac_address,
7291 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7292 vat_json_object_add_string_copy (node, "ip_address", ip);
7297 api_bd_ip_mac_dump (vat_main_t * vam)
7299 unformat_input_t *i = vam->input;
7300 vl_api_bd_ip_mac_dump_t *mp;
7301 vl_api_control_ping_t *mp_ping;
7306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7308 if (unformat (i, "bd_id %d", &bd_id))
7317 "\n%-5s %-7s %-20s %-30s",
7318 "bd_id", "is_ipv6", "mac_address", "ip_address");
7320 /* Dump Bridge Domain Ip to Mac entries */
7321 M (BD_IP_MAC_DUMP, mp);
7324 mp->bd_id = htonl (bd_id);
7330 /* Use a control ping for synchronization */
7331 MPING (CONTROL_PING, mp_ping);
7339 api_tap_create_v2 (vat_main_t * vam)
7341 unformat_input_t *i = vam->input;
7342 vl_api_tap_create_v2_t *mp;
7343 #define TAP_FLAG_GSO (1 << 0)
7347 u8 *host_if_name = 0;
7349 u8 host_mac_addr[6];
7350 u8 host_mac_addr_set = 0;
7351 u8 *host_bridge = 0;
7352 ip4_address_t host_ip4_addr;
7353 ip4_address_t host_ip4_gw;
7354 u8 host_ip4_gw_set = 0;
7355 u32 host_ip4_prefix_len = 0;
7356 ip6_address_t host_ip6_addr;
7357 ip6_address_t host_ip6_gw;
7358 u8 host_ip6_gw_set = 0;
7359 u32 host_ip6_prefix_len = 0;
7360 u8 host_mtu_set = 0;
7361 u32 host_mtu_size = 0;
7364 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7366 clib_memset (mac_address, 0, sizeof (mac_address));
7368 /* Parse args required to build the message */
7369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7371 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7375 else if (unformat (i, "id %u", &id))
7377 else if (unformat (i, "host-if-name %s", &host_if_name))
7379 else if (unformat (i, "host-ns %s", &host_ns))
7381 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7383 host_mac_addr_set = 1;
7384 else if (unformat (i, "host-bridge %s", &host_bridge))
7386 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7387 &host_ip4_addr, &host_ip4_prefix_len))
7389 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7390 &host_ip6_addr, &host_ip6_prefix_len))
7392 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7394 host_ip4_gw_set = 1;
7395 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7397 host_ip6_gw_set = 1;
7398 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7400 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7402 else if (unformat (i, "host-mtu-size %d", &host_mtu_size))
7404 else if (unformat (i, "no-gso"))
7405 tap_flags &= ~TAP_FLAG_GSO;
7406 else if (unformat (i, "gso"))
7407 tap_flags |= TAP_FLAG_GSO;
7412 if (vec_len (host_if_name) > 63)
7414 errmsg ("tap name too long. ");
7417 if (vec_len (host_ns) > 63)
7419 errmsg ("host name space too long. ");
7422 if (vec_len (host_bridge) > 63)
7424 errmsg ("host bridge name too long. ");
7427 if (host_ip4_prefix_len > 32)
7429 errmsg ("host ip4 prefix length not valid. ");
7432 if (host_ip6_prefix_len > 128)
7434 errmsg ("host ip6 prefix length not valid. ");
7437 if (!is_pow2 (rx_ring_sz))
7439 errmsg ("rx ring size must be power of 2. ");
7442 if (rx_ring_sz > 32768)
7444 errmsg ("rx ring size must be 32768 or lower. ");
7447 if (!is_pow2 (tx_ring_sz))
7449 errmsg ("tx ring size must be power of 2. ");
7452 if (tx_ring_sz > 32768)
7454 errmsg ("tx ring size must be 32768 or lower. ");
7457 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7459 errmsg ("host MTU size must be in between 64 and 65355. ");
7463 /* Construct the API message */
7464 M (TAP_CREATE_V2, mp);
7466 mp->use_random_mac = random_mac;
7468 mp->id = ntohl (id);
7469 mp->host_namespace_set = host_ns != 0;
7470 mp->host_bridge_set = host_bridge != 0;
7471 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7472 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7473 mp->rx_ring_sz = ntohs (rx_ring_sz);
7474 mp->tx_ring_sz = ntohs (tx_ring_sz);
7475 mp->host_mtu_set = host_mtu_set;
7476 mp->host_mtu_size = ntohl (host_mtu_size);
7477 mp->tap_flags = ntohl (tap_flags);
7479 if (random_mac == 0)
7480 clib_memcpy (mp->mac_address, mac_address, 6);
7481 if (host_mac_addr_set)
7482 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7484 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7486 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7488 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7489 if (host_ip4_prefix_len)
7490 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7491 if (host_ip6_prefix_len)
7492 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7493 if (host_ip4_gw_set)
7494 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7495 if (host_ip6_gw_set)
7496 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7499 vec_free (host_if_name);
7500 vec_free (host_bridge);
7505 /* Wait for a reply... */
7511 api_tap_delete_v2 (vat_main_t * vam)
7513 unformat_input_t *i = vam->input;
7514 vl_api_tap_delete_v2_t *mp;
7515 u32 sw_if_index = ~0;
7516 u8 sw_if_index_set = 0;
7519 /* Parse args required to build the message */
7520 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7522 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7523 sw_if_index_set = 1;
7524 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7525 sw_if_index_set = 1;
7530 if (sw_if_index_set == 0)
7532 errmsg ("missing vpp interface name. ");
7536 /* Construct the API message */
7537 M (TAP_DELETE_V2, mp);
7539 mp->sw_if_index = ntohl (sw_if_index);
7544 /* Wait for a reply... */
7550 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7552 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7555 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7558 addr->domain = x[0];
7561 addr->function = x[3];
7567 api_virtio_pci_create (vat_main_t * vam)
7569 unformat_input_t *i = vam->input;
7570 vl_api_virtio_pci_create_t *mp;
7575 u64 features = (u64) ~ (0ULL);
7578 clib_memset (mac_address, 0, sizeof (mac_address));
7580 /* Parse args required to build the message */
7581 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7583 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7587 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7589 else if (unformat (i, "features 0x%llx", &features))
7591 else if (unformat (i, "gso-enabled"))
7599 errmsg ("pci address must be non zero. ");
7603 /* Construct the API message */
7604 M (VIRTIO_PCI_CREATE, mp);
7606 mp->use_random_mac = random_mac;
7608 mp->pci_addr = htonl (pci_addr);
7609 mp->features = clib_host_to_net_u64 (features);
7610 mp->gso_enabled = gso_enabled;
7612 if (random_mac == 0)
7613 clib_memcpy (mp->mac_address, mac_address, 6);
7618 /* Wait for a reply... */
7624 api_virtio_pci_delete (vat_main_t * vam)
7626 unformat_input_t *i = vam->input;
7627 vl_api_virtio_pci_delete_t *mp;
7628 u32 sw_if_index = ~0;
7629 u8 sw_if_index_set = 0;
7632 /* Parse args required to build the message */
7633 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7635 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7636 sw_if_index_set = 1;
7637 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7638 sw_if_index_set = 1;
7643 if (sw_if_index_set == 0)
7645 errmsg ("missing vpp interface name. ");
7649 /* Construct the API message */
7650 M (VIRTIO_PCI_DELETE, mp);
7652 mp->sw_if_index = htonl (sw_if_index);
7657 /* Wait for a reply... */
7663 api_bond_create (vat_main_t * vam)
7665 unformat_input_t *i = vam->input;
7666 vl_api_bond_create_t *mp;
7676 clib_memset (mac_address, 0, sizeof (mac_address));
7679 /* Parse args required to build the message */
7680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7682 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7684 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7685 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7687 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7690 else if (unformat (i, "numa-only"))
7692 else if (unformat (i, "id %u", &id))
7698 if (mode_is_set == 0)
7700 errmsg ("Missing bond mode. ");
7704 /* Construct the API message */
7705 M (BOND_CREATE, mp);
7707 mp->use_custom_mac = custom_mac;
7709 mp->mode = htonl (mode);
7710 mp->lb = htonl (lb);
7711 mp->id = htonl (id);
7712 mp->numa_only = numa_only;
7715 clib_memcpy (mp->mac_address, mac_address, 6);
7720 /* Wait for a reply... */
7726 api_bond_delete (vat_main_t * vam)
7728 unformat_input_t *i = vam->input;
7729 vl_api_bond_delete_t *mp;
7730 u32 sw_if_index = ~0;
7731 u8 sw_if_index_set = 0;
7734 /* Parse args required to build the message */
7735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7737 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7738 sw_if_index_set = 1;
7739 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7740 sw_if_index_set = 1;
7745 if (sw_if_index_set == 0)
7747 errmsg ("missing vpp interface name. ");
7751 /* Construct the API message */
7752 M (BOND_DELETE, mp);
7754 mp->sw_if_index = ntohl (sw_if_index);
7759 /* Wait for a reply... */
7765 api_bond_enslave (vat_main_t * vam)
7767 unformat_input_t *i = vam->input;
7768 vl_api_bond_enslave_t *mp;
7769 u32 bond_sw_if_index;
7773 u32 bond_sw_if_index_is_set = 0;
7775 u8 sw_if_index_is_set = 0;
7777 /* Parse args required to build the message */
7778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7780 if (unformat (i, "sw_if_index %d", &sw_if_index))
7781 sw_if_index_is_set = 1;
7782 else if (unformat (i, "bond %u", &bond_sw_if_index))
7783 bond_sw_if_index_is_set = 1;
7784 else if (unformat (i, "passive %d", &is_passive))
7786 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7792 if (bond_sw_if_index_is_set == 0)
7794 errmsg ("Missing bond sw_if_index. ");
7797 if (sw_if_index_is_set == 0)
7799 errmsg ("Missing slave sw_if_index. ");
7803 /* Construct the API message */
7804 M (BOND_ENSLAVE, mp);
7806 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7807 mp->sw_if_index = ntohl (sw_if_index);
7808 mp->is_long_timeout = is_long_timeout;
7809 mp->is_passive = is_passive;
7814 /* Wait for a reply... */
7820 api_bond_detach_slave (vat_main_t * vam)
7822 unformat_input_t *i = vam->input;
7823 vl_api_bond_detach_slave_t *mp;
7824 u32 sw_if_index = ~0;
7825 u8 sw_if_index_set = 0;
7828 /* Parse args required to build the message */
7829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7831 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7832 sw_if_index_set = 1;
7833 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7834 sw_if_index_set = 1;
7839 if (sw_if_index_set == 0)
7841 errmsg ("missing vpp interface name. ");
7845 /* Construct the API message */
7846 M (BOND_DETACH_SLAVE, mp);
7848 mp->sw_if_index = ntohl (sw_if_index);
7853 /* Wait for a reply... */
7859 api_ip_table_add_del (vat_main_t * vam)
7861 unformat_input_t *i = vam->input;
7862 vl_api_ip_table_add_del_t *mp;
7868 /* Parse args required to build the message */
7869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7871 if (unformat (i, "ipv6"))
7873 else if (unformat (i, "del"))
7875 else if (unformat (i, "add"))
7877 else if (unformat (i, "table %d", &table_id))
7881 clib_warning ("parse error '%U'", format_unformat_error, i);
7888 errmsg ("missing table-ID");
7892 /* Construct the API message */
7893 M (IP_TABLE_ADD_DEL, mp);
7895 mp->table.table_id = ntohl (table_id);
7896 mp->table.is_ip6 = is_ipv6;
7897 mp->is_add = is_add;
7902 /* Wait for a reply... */
7909 unformat_fib_path (unformat_input_t * input, va_list * args)
7911 vat_main_t *vam = va_arg (*args, vat_main_t *);
7912 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7913 u32 weight, preference;
7914 mpls_label_t out_label;
7916 clib_memset (path, 0, sizeof (*path));
7918 path->sw_if_index = ~0;
7922 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7924 if (unformat (input, "%U %U",
7925 unformat_vl_api_ip4_address,
7926 &path->nh.address.ip4,
7927 api_unformat_sw_if_index, vam, &path->sw_if_index))
7929 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7931 else if (unformat (input, "%U %U",
7932 unformat_vl_api_ip6_address,
7933 &path->nh.address.ip6,
7934 api_unformat_sw_if_index, vam, &path->sw_if_index))
7936 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7938 else if (unformat (input, "weight %u", &weight))
7940 path->weight = weight;
7942 else if (unformat (input, "preference %u", &preference))
7944 path->preference = preference;
7946 else if (unformat (input, "%U next-hop-table %d",
7947 unformat_vl_api_ip4_address,
7948 &path->nh.address.ip4, &path->table_id))
7950 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7952 else if (unformat (input, "%U next-hop-table %d",
7953 unformat_vl_api_ip6_address,
7954 &path->nh.address.ip6, &path->table_id))
7956 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7958 else if (unformat (input, "%U",
7959 unformat_vl_api_ip4_address, &path->nh.address.ip4))
7962 * the recursive next-hops are by default in the default table
7965 path->sw_if_index = ~0;
7966 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7968 else if (unformat (input, "%U",
7969 unformat_vl_api_ip6_address, &path->nh.address.ip6))
7972 * the recursive next-hops are by default in the default table
7975 path->sw_if_index = ~0;
7976 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7978 else if (unformat (input, "resolve-via-host"))
7980 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
7982 else if (unformat (input, "resolve-via-attached"))
7984 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
7986 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
7988 path->type = FIB_API_PATH_TYPE_LOCAL;
7989 path->sw_if_index = ~0;
7990 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7992 else if (unformat (input, "ip6-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_IP6;
7998 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8000 else if (unformat (input, "via-label %d", &path->nh.via_label))
8002 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8003 path->sw_if_index = ~0;
8005 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8007 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8008 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8010 else if (unformat (input, "local"))
8012 path->type = FIB_API_PATH_TYPE_LOCAL;
8014 else if (unformat (input, "out-labels"))
8016 while (unformat (input, "%d", &out_label))
8018 path->label_stack[path->n_labels].label = out_label;
8019 path->label_stack[path->n_labels].is_uniform = 0;
8020 path->label_stack[path->n_labels].ttl = 64;
8024 else if (unformat (input, "via"))
8026 /* new path, back up and return */
8027 unformat_put_input (input);
8028 unformat_put_input (input);
8029 unformat_put_input (input);
8030 unformat_put_input (input);
8039 path->proto = ntohl (path->proto);
8040 path->type = ntohl (path->type);
8041 path->flags = ntohl (path->flags);
8042 path->table_id = ntohl (path->table_id);
8043 path->sw_if_index = ntohl (path->sw_if_index);
8049 api_ip_route_add_del (vat_main_t * vam)
8051 unformat_input_t *i = vam->input;
8052 vl_api_ip_route_add_del_t *mp;
8055 u8 is_multipath = 0;
8058 vl_api_prefix_t pfx = { };
8059 vl_api_fib_path_t paths[8];
8063 u32 random_add_del = 0;
8064 u32 *random_vector = 0;
8065 u32 random_seed = 0xdeaddabe;
8067 /* Parse args required to build the message */
8068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8070 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8072 else if (unformat (i, "del"))
8074 else if (unformat (i, "add"))
8076 else if (unformat (i, "vrf %d", &vrf_id))
8078 else if (unformat (i, "count %d", &count))
8080 else if (unformat (i, "random"))
8082 else if (unformat (i, "multipath"))
8084 else if (unformat (i, "seed %d", &random_seed))
8088 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8091 if (8 == path_count)
8093 errmsg ("max 8 paths");
8099 clib_warning ("parse error '%U'", format_unformat_error, i);
8106 errmsg ("specify a path; via ...");
8109 if (prefix_set == 0)
8111 errmsg ("missing prefix");
8115 /* Generate a pile of unique, random routes */
8118 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8119 u32 this_random_address;
8122 random_hash = hash_create (count, sizeof (uword));
8124 hash_set (random_hash, i->as_u32, 1);
8125 for (j = 0; j <= count; j++)
8129 this_random_address = random_u32 (&random_seed);
8130 this_random_address =
8131 clib_host_to_net_u32 (this_random_address);
8133 while (hash_get (random_hash, this_random_address));
8134 vec_add1 (random_vector, this_random_address);
8135 hash_set (random_hash, this_random_address, 1);
8137 hash_free (random_hash);
8138 set_ip4_address (&pfx.address, random_vector[0]);
8143 /* Turn on async mode */
8144 vam->async_mode = 1;
8145 vam->async_errors = 0;
8146 before = vat_time_now (vam);
8149 for (j = 0; j < count; j++)
8151 /* Construct the API message */
8152 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8154 mp->is_add = is_add;
8155 mp->is_multipath = is_multipath;
8157 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8158 mp->route.table_id = ntohl (vrf_id);
8159 mp->route.n_paths = path_count;
8161 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8164 set_ip4_address (&pfx.address, random_vector[j + 1]);
8166 increment_address (&pfx.address);
8169 /* If we receive SIGTERM, stop now... */
8174 /* When testing multiple add/del ops, use a control-ping to sync */
8177 vl_api_control_ping_t *mp_ping;
8181 /* Shut off async mode */
8182 vam->async_mode = 0;
8184 MPING (CONTROL_PING, mp_ping);
8187 timeout = vat_time_now (vam) + 1.0;
8188 while (vat_time_now (vam) < timeout)
8189 if (vam->result_ready == 1)
8194 if (vam->retval == -99)
8197 if (vam->async_errors > 0)
8199 errmsg ("%d asynchronous errors", vam->async_errors);
8202 vam->async_errors = 0;
8203 after = vat_time_now (vam);
8205 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8209 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8210 count, after - before, count / (after - before));
8216 /* Wait for a reply... */
8221 /* Return the good/bad news */
8222 return (vam->retval);
8226 api_ip_mroute_add_del (vat_main_t * vam)
8228 unformat_input_t *i = vam->input;
8229 u8 path_set = 0, prefix_set = 0, is_add = 1;
8230 vl_api_ip_mroute_add_del_t *mp;
8231 mfib_entry_flags_t eflags = 0;
8232 vl_api_mfib_path_t path;
8233 vl_api_mprefix_t pfx = { };
8237 /* Parse args required to build the message */
8238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8240 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8243 pfx.grp_address_length = htons (pfx.grp_address_length);
8245 else if (unformat (i, "del"))
8247 else if (unformat (i, "add"))
8249 else if (unformat (i, "vrf %d", &vrf_id))
8251 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8252 path.itf_flags = htonl (path.itf_flags);
8253 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8255 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8259 clib_warning ("parse error '%U'", format_unformat_error, i);
8264 if (prefix_set == 0)
8266 errmsg ("missing addresses\n");
8271 errmsg ("missing path\n");
8275 /* Construct the API message */
8276 M (IP_MROUTE_ADD_DEL, mp);
8278 mp->is_add = is_add;
8279 mp->is_multipath = 1;
8281 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8282 mp->route.table_id = htonl (vrf_id);
8283 mp->route.n_paths = 1;
8284 mp->route.entry_flags = htonl (eflags);
8286 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8290 /* Wait for a reply... */
8296 api_mpls_table_add_del (vat_main_t * vam)
8298 unformat_input_t *i = vam->input;
8299 vl_api_mpls_table_add_del_t *mp;
8304 /* Parse args required to build the message */
8305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8307 if (unformat (i, "table %d", &table_id))
8309 else if (unformat (i, "del"))
8311 else if (unformat (i, "add"))
8315 clib_warning ("parse error '%U'", format_unformat_error, i);
8322 errmsg ("missing table-ID");
8326 /* Construct the API message */
8327 M (MPLS_TABLE_ADD_DEL, mp);
8329 mp->mt_table.mt_table_id = ntohl (table_id);
8330 mp->mt_is_add = is_add;
8335 /* Wait for a reply... */
8342 api_mpls_route_add_del (vat_main_t * vam)
8344 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8345 mpls_label_t local_label = MPLS_LABEL_INVALID;
8346 unformat_input_t *i = vam->input;
8347 vl_api_mpls_route_add_del_t *mp;
8348 vl_api_fib_path_t paths[8];
8352 /* Parse args required to build the message */
8353 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8355 if (unformat (i, "%d", &local_label))
8357 else if (unformat (i, "eos"))
8359 else if (unformat (i, "non-eos"))
8361 else if (unformat (i, "del"))
8363 else if (unformat (i, "add"))
8365 else if (unformat (i, "multipath"))
8367 else if (unformat (i, "count %d", &count))
8371 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8374 if (8 == path_count)
8376 errmsg ("max 8 paths");
8382 clib_warning ("parse error '%U'", format_unformat_error, i);
8389 errmsg ("specify a path; via ...");
8393 if (MPLS_LABEL_INVALID == local_label)
8395 errmsg ("missing label");
8401 /* Turn on async mode */
8402 vam->async_mode = 1;
8403 vam->async_errors = 0;
8404 before = vat_time_now (vam);
8407 for (j = 0; j < count; j++)
8409 /* Construct the API message */
8410 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8412 mp->mr_is_add = is_add;
8413 mp->mr_is_multipath = is_multipath;
8415 mp->mr_route.mr_label = local_label;
8416 mp->mr_route.mr_eos = is_eos;
8417 mp->mr_route.mr_table_id = 0;
8418 mp->mr_route.mr_n_paths = path_count;
8420 clib_memcpy (&mp->mr_route.mr_paths, paths,
8421 sizeof (paths[0]) * path_count);
8427 /* If we receive SIGTERM, stop now... */
8432 /* When testing multiple add/del ops, use a control-ping to sync */
8435 vl_api_control_ping_t *mp_ping;
8439 /* Shut off async mode */
8440 vam->async_mode = 0;
8442 MPING (CONTROL_PING, mp_ping);
8445 timeout = vat_time_now (vam) + 1.0;
8446 while (vat_time_now (vam) < timeout)
8447 if (vam->result_ready == 1)
8452 if (vam->retval == -99)
8455 if (vam->async_errors > 0)
8457 errmsg ("%d asynchronous errors", vam->async_errors);
8460 vam->async_errors = 0;
8461 after = vat_time_now (vam);
8463 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8467 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8468 count, after - before, count / (after - before));
8474 /* Wait for a reply... */
8479 /* Return the good/bad news */
8480 return (vam->retval);
8485 api_mpls_ip_bind_unbind (vat_main_t * vam)
8487 unformat_input_t *i = vam->input;
8488 vl_api_mpls_ip_bind_unbind_t *mp;
8489 u32 ip_table_id = 0;
8491 vl_api_prefix_t pfx;
8493 mpls_label_t local_label = MPLS_LABEL_INVALID;
8496 /* Parse args required to build the message */
8497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8499 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8501 else if (unformat (i, "%d", &local_label))
8503 else if (unformat (i, "table-id %d", &ip_table_id))
8505 else if (unformat (i, "unbind"))
8507 else if (unformat (i, "bind"))
8511 clib_warning ("parse error '%U'", format_unformat_error, i);
8518 errmsg ("IP prefix not set");
8522 if (MPLS_LABEL_INVALID == local_label)
8524 errmsg ("missing label");
8528 /* Construct the API message */
8529 M (MPLS_IP_BIND_UNBIND, mp);
8531 mp->mb_is_bind = is_bind;
8532 mp->mb_ip_table_id = ntohl (ip_table_id);
8533 mp->mb_mpls_table_id = 0;
8534 mp->mb_label = ntohl (local_label);
8535 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8540 /* Wait for a reply... */
8547 api_sr_mpls_policy_add (vat_main_t * vam)
8549 unformat_input_t *i = vam->input;
8550 vl_api_sr_mpls_policy_add_t *mp;
8556 u32 *segments = NULL;
8559 /* Parse args required to build the message */
8560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8562 if (unformat (i, "bsid %d", &bsid))
8564 else if (unformat (i, "weight %d", &weight))
8566 else if (unformat (i, "spray"))
8568 else if (unformat (i, "next %d", &sid))
8571 vec_add1 (segments, htonl (sid));
8575 clib_warning ("parse error '%U'", format_unformat_error, i);
8582 errmsg ("bsid not set");
8586 if (n_segments == 0)
8588 errmsg ("no sid in segment stack");
8592 /* Construct the API message */
8593 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8595 mp->bsid = htonl (bsid);
8596 mp->weight = htonl (weight);
8598 mp->n_segments = n_segments;
8599 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8600 vec_free (segments);
8605 /* Wait for a reply... */
8611 api_sr_mpls_policy_del (vat_main_t * vam)
8613 unformat_input_t *i = vam->input;
8614 vl_api_sr_mpls_policy_del_t *mp;
8618 /* Parse args required to build the message */
8619 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8621 if (unformat (i, "bsid %d", &bsid))
8625 clib_warning ("parse error '%U'", format_unformat_error, i);
8632 errmsg ("bsid not set");
8636 /* Construct the API message */
8637 M (SR_MPLS_POLICY_DEL, mp);
8639 mp->bsid = htonl (bsid);
8644 /* Wait for a reply... */
8650 api_bier_table_add_del (vat_main_t * vam)
8652 unformat_input_t *i = vam->input;
8653 vl_api_bier_table_add_del_t *mp;
8655 u32 set = 0, sub_domain = 0, hdr_len = 3;
8656 mpls_label_t local_label = MPLS_LABEL_INVALID;
8659 /* Parse args required to build the message */
8660 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8662 if (unformat (i, "sub-domain %d", &sub_domain))
8664 else if (unformat (i, "set %d", &set))
8666 else if (unformat (i, "label %d", &local_label))
8668 else if (unformat (i, "hdr-len %d", &hdr_len))
8670 else if (unformat (i, "add"))
8672 else if (unformat (i, "del"))
8676 clib_warning ("parse error '%U'", format_unformat_error, i);
8681 if (MPLS_LABEL_INVALID == local_label)
8683 errmsg ("missing label\n");
8687 /* Construct the API message */
8688 M (BIER_TABLE_ADD_DEL, mp);
8690 mp->bt_is_add = is_add;
8691 mp->bt_label = ntohl (local_label);
8692 mp->bt_tbl_id.bt_set = set;
8693 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8694 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8699 /* Wait for a reply... */
8706 api_bier_route_add_del (vat_main_t * vam)
8708 unformat_input_t *i = vam->input;
8709 vl_api_bier_route_add_del_t *mp;
8711 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8712 ip4_address_t v4_next_hop_address;
8713 ip6_address_t v6_next_hop_address;
8714 u8 next_hop_set = 0;
8715 u8 next_hop_proto_is_ip4 = 1;
8716 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8719 /* Parse args required to build the message */
8720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8722 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8724 next_hop_proto_is_ip4 = 1;
8727 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8729 next_hop_proto_is_ip4 = 0;
8732 if (unformat (i, "sub-domain %d", &sub_domain))
8734 else if (unformat (i, "set %d", &set))
8736 else if (unformat (i, "hdr-len %d", &hdr_len))
8738 else if (unformat (i, "bp %d", &bp))
8740 else if (unformat (i, "add"))
8742 else if (unformat (i, "del"))
8744 else if (unformat (i, "out-label %d", &next_hop_out_label))
8748 clib_warning ("parse error '%U'", format_unformat_error, i);
8753 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8755 errmsg ("next hop / label set\n");
8760 errmsg ("bit=position not set\n");
8764 /* Construct the API message */
8765 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8767 mp->br_is_add = is_add;
8768 mp->br_route.br_tbl_id.bt_set = set;
8769 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8770 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8771 mp->br_route.br_bp = ntohs (bp);
8772 mp->br_route.br_n_paths = 1;
8773 mp->br_route.br_paths[0].n_labels = 1;
8774 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8775 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8776 FIB_API_PATH_NH_PROTO_IP4 :
8777 FIB_API_PATH_NH_PROTO_IP6);
8779 if (next_hop_proto_is_ip4)
8781 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8782 &v4_next_hop_address, sizeof (v4_next_hop_address));
8786 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8787 &v6_next_hop_address, sizeof (v6_next_hop_address));
8793 /* Wait for a reply... */
8800 api_proxy_arp_add_del (vat_main_t * vam)
8802 unformat_input_t *i = vam->input;
8803 vl_api_proxy_arp_add_del_t *mp;
8806 vl_api_ip4_address_t lo, hi;
8810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8812 if (unformat (i, "vrf %d", &vrf_id))
8814 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
8815 unformat_vl_api_ip4_address, &hi))
8817 else if (unformat (i, "del"))
8821 clib_warning ("parse error '%U'", format_unformat_error, i);
8828 errmsg ("address range not set");
8832 M (PROXY_ARP_ADD_DEL, mp);
8834 mp->proxy.table_id = ntohl (vrf_id);
8835 mp->is_add = is_add;
8836 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
8837 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
8845 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8847 unformat_input_t *i = vam->input;
8848 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8851 u8 sw_if_index_set = 0;
8854 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8856 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8857 sw_if_index_set = 1;
8858 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8859 sw_if_index_set = 1;
8860 else if (unformat (i, "enable"))
8862 else if (unformat (i, "disable"))
8866 clib_warning ("parse error '%U'", format_unformat_error, i);
8871 if (sw_if_index_set == 0)
8873 errmsg ("missing interface name or sw_if_index");
8877 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8879 mp->sw_if_index = ntohl (sw_if_index);
8880 mp->enable_disable = enable;
8888 api_mpls_tunnel_add_del (vat_main_t * vam)
8890 unformat_input_t *i = vam->input;
8891 vl_api_mpls_tunnel_add_del_t *mp;
8893 vl_api_fib_path_t paths[8];
8894 u32 sw_if_index = ~0;
8900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8902 if (unformat (i, "add"))
8906 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8908 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8910 else if (unformat (i, "l2-only"))
8914 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8917 if (8 == path_count)
8919 errmsg ("max 8 paths");
8925 clib_warning ("parse error '%U'", format_unformat_error, i);
8930 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8932 mp->mt_is_add = is_add;
8933 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8934 mp->mt_tunnel.mt_l2_only = l2_only;
8935 mp->mt_tunnel.mt_is_multicast = 0;
8936 mp->mt_tunnel.mt_n_paths = path_count;
8938 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8939 sizeof (paths[0]) * path_count);
8947 api_sw_interface_set_unnumbered (vat_main_t * vam)
8949 unformat_input_t *i = vam->input;
8950 vl_api_sw_interface_set_unnumbered_t *mp;
8952 u32 unnum_sw_index = ~0;
8954 u8 sw_if_index_set = 0;
8957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8959 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8960 sw_if_index_set = 1;
8961 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8962 sw_if_index_set = 1;
8963 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8965 else if (unformat (i, "del"))
8969 clib_warning ("parse error '%U'", format_unformat_error, i);
8974 if (sw_if_index_set == 0)
8976 errmsg ("missing interface name or sw_if_index");
8980 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8982 mp->sw_if_index = ntohl (sw_if_index);
8983 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8984 mp->is_add = is_add;
8992 api_ip_neighbor_add_del (vat_main_t * vam)
8994 vl_api_mac_address_t mac_address;
8995 unformat_input_t *i = vam->input;
8996 vl_api_ip_neighbor_add_del_t *mp;
8997 vl_api_address_t ip_address;
8999 u8 sw_if_index_set = 0;
9004 ip_neighbor_flags_t flags;
9006 flags = IP_NEIGHBOR_FLAG_NONE;
9007 clib_memset (&ip_address, 0, sizeof (ip_address));
9008 clib_memset (&mac_address, 0, sizeof (mac_address));
9010 /* Parse args required to build the message */
9011 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9013 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9017 else if (unformat (i, "del"))
9020 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9021 sw_if_index_set = 1;
9022 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9023 sw_if_index_set = 1;
9024 else if (unformat (i, "static"))
9025 flags |= IP_NEIGHBOR_FLAG_STATIC;
9026 else if (unformat (i, "no-fib-entry"))
9027 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9028 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9032 clib_warning ("parse error '%U'", format_unformat_error, i);
9037 if (sw_if_index_set == 0)
9039 errmsg ("missing interface name or sw_if_index");
9044 errmsg ("no address set");
9048 /* Construct the API message */
9049 M (IP_NEIGHBOR_ADD_DEL, mp);
9051 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9052 mp->is_add = is_add;
9053 mp->neighbor.flags = htonl (flags);
9055 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9056 sizeof (mac_address));
9058 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9063 /* Wait for a reply, return good/bad news */
9069 api_create_vlan_subif (vat_main_t * vam)
9071 unformat_input_t *i = vam->input;
9072 vl_api_create_vlan_subif_t *mp;
9074 u8 sw_if_index_set = 0;
9079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9081 if (unformat (i, "sw_if_index %d", &sw_if_index))
9082 sw_if_index_set = 1;
9084 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9085 sw_if_index_set = 1;
9086 else if (unformat (i, "vlan %d", &vlan_id))
9090 clib_warning ("parse error '%U'", format_unformat_error, i);
9095 if (sw_if_index_set == 0)
9097 errmsg ("missing interface name or sw_if_index");
9101 if (vlan_id_set == 0)
9103 errmsg ("missing vlan_id");
9106 M (CREATE_VLAN_SUBIF, mp);
9108 mp->sw_if_index = ntohl (sw_if_index);
9109 mp->vlan_id = ntohl (vlan_id);
9116 #define foreach_create_subif_bit \
9123 _(outer_vlan_id_any) \
9124 _(inner_vlan_id_any)
9126 #define foreach_create_subif_flag \
9131 _(4, "exact_match") \
9132 _(5, "default_sub") \
9133 _(6, "outer_vlan_id_any") \
9134 _(7, "inner_vlan_id_any")
9137 api_create_subif (vat_main_t * vam)
9139 unformat_input_t *i = vam->input;
9140 vl_api_create_subif_t *mp;
9142 u8 sw_if_index_set = 0;
9145 u32 __attribute__ ((unused)) no_tags = 0;
9146 u32 __attribute__ ((unused)) one_tag = 0;
9147 u32 __attribute__ ((unused)) two_tags = 0;
9148 u32 __attribute__ ((unused)) dot1ad = 0;
9149 u32 __attribute__ ((unused)) exact_match = 0;
9150 u32 __attribute__ ((unused)) default_sub = 0;
9151 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
9152 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
9154 u16 outer_vlan_id = 0;
9155 u16 inner_vlan_id = 0;
9158 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9160 if (unformat (i, "sw_if_index %d", &sw_if_index))
9161 sw_if_index_set = 1;
9163 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9164 sw_if_index_set = 1;
9165 else if (unformat (i, "sub_id %d", &sub_id))
9167 else if (unformat (i, "outer_vlan_id %d", &tmp))
9168 outer_vlan_id = tmp;
9169 else if (unformat (i, "inner_vlan_id %d", &tmp))
9170 inner_vlan_id = tmp;
9172 #define _(a) else if (unformat (i, #a)) a = 1 ;
9173 foreach_create_subif_bit
9177 clib_warning ("parse error '%U'", format_unformat_error, i);
9182 if (sw_if_index_set == 0)
9184 errmsg ("missing interface name or sw_if_index");
9188 if (sub_id_set == 0)
9190 errmsg ("missing sub_id");
9193 M (CREATE_SUBIF, mp);
9195 mp->sw_if_index = ntohl (sw_if_index);
9196 mp->sub_id = ntohl (sub_id);
9198 #define _(a,b) mp->sub_if_flags |= (1 << a);
9199 foreach_create_subif_flag;
9202 mp->outer_vlan_id = ntohs (outer_vlan_id);
9203 mp->inner_vlan_id = ntohs (inner_vlan_id);
9211 api_reset_fib (vat_main_t * vam)
9213 unformat_input_t *i = vam->input;
9214 vl_api_reset_fib_t *mp;
9220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9222 if (unformat (i, "vrf %d", &vrf_id))
9224 else if (unformat (i, "ipv6"))
9228 clib_warning ("parse error '%U'", format_unformat_error, i);
9233 if (vrf_id_set == 0)
9235 errmsg ("missing vrf id");
9241 mp->vrf_id = ntohl (vrf_id);
9242 mp->is_ipv6 = is_ipv6;
9250 api_set_ip_flow_hash (vat_main_t * vam)
9252 unformat_input_t *i = vam->input;
9253 vl_api_set_ip_flow_hash_t *mp;
9265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9267 if (unformat (i, "vrf %d", &vrf_id))
9269 else if (unformat (i, "ipv6"))
9271 else if (unformat (i, "src"))
9273 else if (unformat (i, "dst"))
9275 else if (unformat (i, "sport"))
9277 else if (unformat (i, "dport"))
9279 else if (unformat (i, "proto"))
9281 else if (unformat (i, "reverse"))
9286 clib_warning ("parse error '%U'", format_unformat_error, i);
9291 if (vrf_id_set == 0)
9293 errmsg ("missing vrf id");
9297 M (SET_IP_FLOW_HASH, mp);
9303 mp->reverse = reverse;
9304 mp->vrf_id = ntohl (vrf_id);
9305 mp->is_ipv6 = is_ipv6;
9313 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9315 unformat_input_t *i = vam->input;
9316 vl_api_sw_interface_ip6_enable_disable_t *mp;
9318 u8 sw_if_index_set = 0;
9322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9324 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9325 sw_if_index_set = 1;
9326 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9327 sw_if_index_set = 1;
9328 else if (unformat (i, "enable"))
9330 else if (unformat (i, "disable"))
9334 clib_warning ("parse error '%U'", format_unformat_error, i);
9339 if (sw_if_index_set == 0)
9341 errmsg ("missing interface name or sw_if_index");
9345 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9347 mp->sw_if_index = ntohl (sw_if_index);
9348 mp->enable = enable;
9356 api_ip6nd_proxy_add_del (vat_main_t * vam)
9358 unformat_input_t *i = vam->input;
9359 vl_api_ip6nd_proxy_add_del_t *mp;
9360 u32 sw_if_index = ~0;
9361 u8 v6_address_set = 0;
9362 vl_api_ip6_address_t v6address;
9366 /* Parse args required to build the message */
9367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9369 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9371 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9373 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
9375 if (unformat (i, "del"))
9379 clib_warning ("parse error '%U'", format_unformat_error, i);
9384 if (sw_if_index == ~0)
9386 errmsg ("missing interface name or sw_if_index");
9389 if (!v6_address_set)
9391 errmsg ("no address set");
9395 /* Construct the API message */
9396 M (IP6ND_PROXY_ADD_DEL, mp);
9398 mp->is_del = is_del;
9399 mp->sw_if_index = ntohl (sw_if_index);
9400 clib_memcpy (mp->ip, v6address, sizeof (v6address));
9405 /* Wait for a reply, return good/bad news */
9411 api_ip6nd_proxy_dump (vat_main_t * vam)
9413 vl_api_ip6nd_proxy_dump_t *mp;
9414 vl_api_control_ping_t *mp_ping;
9417 M (IP6ND_PROXY_DUMP, mp);
9421 /* Use a control ping for synchronization */
9422 MPING (CONTROL_PING, mp_ping);
9429 static void vl_api_ip6nd_proxy_details_t_handler
9430 (vl_api_ip6nd_proxy_details_t * mp)
9432 vat_main_t *vam = &vat_main;
9434 print (vam->ofp, "host %U sw_if_index %d",
9435 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
9438 static void vl_api_ip6nd_proxy_details_t_handler_json
9439 (vl_api_ip6nd_proxy_details_t * mp)
9441 vat_main_t *vam = &vat_main;
9442 struct in6_addr ip6;
9443 vat_json_node_t *node = NULL;
9445 if (VAT_JSON_ARRAY != vam->json_tree.type)
9447 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9448 vat_json_init_array (&vam->json_tree);
9450 node = vat_json_array_add (&vam->json_tree);
9452 vat_json_init_object (node);
9453 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9455 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
9456 vat_json_object_add_ip6 (node, "host", ip6);
9460 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9462 unformat_input_t *i = vam->input;
9463 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9465 u8 sw_if_index_set = 0;
9466 u8 v6_address_set = 0;
9467 vl_api_prefix_t pfx;
9469 u8 no_advertise = 0;
9471 u8 no_autoconfig = 0;
9474 u32 val_lifetime = 0;
9475 u32 pref_lifetime = 0;
9478 /* Parse args required to build the message */
9479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9481 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9482 sw_if_index_set = 1;
9483 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9484 sw_if_index_set = 1;
9485 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
9487 else if (unformat (i, "val_life %d", &val_lifetime))
9489 else if (unformat (i, "pref_life %d", &pref_lifetime))
9491 else if (unformat (i, "def"))
9493 else if (unformat (i, "noadv"))
9495 else if (unformat (i, "offl"))
9497 else if (unformat (i, "noauto"))
9499 else if (unformat (i, "nolink"))
9501 else if (unformat (i, "isno"))
9505 clib_warning ("parse error '%U'", format_unformat_error, i);
9510 if (sw_if_index_set == 0)
9512 errmsg ("missing interface name or sw_if_index");
9515 if (!v6_address_set)
9517 errmsg ("no address set");
9521 /* Construct the API message */
9522 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9524 mp->sw_if_index = ntohl (sw_if_index);
9525 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
9526 mp->use_default = use_default;
9527 mp->no_advertise = no_advertise;
9528 mp->off_link = off_link;
9529 mp->no_autoconfig = no_autoconfig;
9530 mp->no_onlink = no_onlink;
9532 mp->val_lifetime = ntohl (val_lifetime);
9533 mp->pref_lifetime = ntohl (pref_lifetime);
9538 /* Wait for a reply, return good/bad news */
9544 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9546 unformat_input_t *i = vam->input;
9547 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9549 u8 sw_if_index_set = 0;
9554 u8 send_unicast = 0;
9557 u8 default_router = 0;
9558 u32 max_interval = 0;
9559 u32 min_interval = 0;
9561 u32 initial_count = 0;
9562 u32 initial_interval = 0;
9566 /* Parse args required to build the message */
9567 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9569 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9570 sw_if_index_set = 1;
9571 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9572 sw_if_index_set = 1;
9573 else if (unformat (i, "maxint %d", &max_interval))
9575 else if (unformat (i, "minint %d", &min_interval))
9577 else if (unformat (i, "life %d", &lifetime))
9579 else if (unformat (i, "count %d", &initial_count))
9581 else if (unformat (i, "interval %d", &initial_interval))
9583 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9585 else if (unformat (i, "managed"))
9587 else if (unformat (i, "other"))
9589 else if (unformat (i, "ll"))
9591 else if (unformat (i, "send"))
9593 else if (unformat (i, "cease"))
9595 else if (unformat (i, "isno"))
9597 else if (unformat (i, "def"))
9601 clib_warning ("parse error '%U'", format_unformat_error, i);
9606 if (sw_if_index_set == 0)
9608 errmsg ("missing interface name or sw_if_index");
9612 /* Construct the API message */
9613 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9615 mp->sw_if_index = ntohl (sw_if_index);
9616 mp->max_interval = ntohl (max_interval);
9617 mp->min_interval = ntohl (min_interval);
9618 mp->lifetime = ntohl (lifetime);
9619 mp->initial_count = ntohl (initial_count);
9620 mp->initial_interval = ntohl (initial_interval);
9621 mp->suppress = suppress;
9622 mp->managed = managed;
9624 mp->ll_option = ll_option;
9625 mp->send_unicast = send_unicast;
9628 mp->default_router = default_router;
9633 /* Wait for a reply, return good/bad news */
9639 api_set_arp_neighbor_limit (vat_main_t * vam)
9641 unformat_input_t *i = vam->input;
9642 vl_api_set_arp_neighbor_limit_t *mp;
9648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9650 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9652 else if (unformat (i, "ipv6"))
9656 clib_warning ("parse error '%U'", format_unformat_error, i);
9663 errmsg ("missing limit value");
9667 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9669 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9670 mp->is_ipv6 = is_ipv6;
9678 api_l2_patch_add_del (vat_main_t * vam)
9680 unformat_input_t *i = vam->input;
9681 vl_api_l2_patch_add_del_t *mp;
9683 u8 rx_sw_if_index_set = 0;
9685 u8 tx_sw_if_index_set = 0;
9689 /* Parse args required to build the message */
9690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9692 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9693 rx_sw_if_index_set = 1;
9694 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9695 tx_sw_if_index_set = 1;
9696 else if (unformat (i, "rx"))
9698 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9700 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9702 rx_sw_if_index_set = 1;
9707 else if (unformat (i, "tx"))
9709 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9711 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9713 tx_sw_if_index_set = 1;
9718 else if (unformat (i, "del"))
9724 if (rx_sw_if_index_set == 0)
9726 errmsg ("missing rx interface name or rx_sw_if_index");
9730 if (tx_sw_if_index_set == 0)
9732 errmsg ("missing tx interface name or tx_sw_if_index");
9736 M (L2_PATCH_ADD_DEL, mp);
9738 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9739 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9740 mp->is_add = is_add;
9748 u8 localsid_addr[16];
9757 api_sr_localsid_add_del (vat_main_t * vam)
9759 unformat_input_t *i = vam->input;
9760 vl_api_sr_localsid_add_del_t *mp;
9763 ip6_address_t localsid;
9767 u32 fib_table = ~(u32) 0;
9768 ip6_address_t nh_addr6;
9769 ip4_address_t nh_addr4;
9770 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
9771 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
9773 bool nexthop_set = 0;
9777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9779 if (unformat (i, "del"))
9781 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9782 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
9784 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
9786 else if (unformat (i, "behavior %u", &behavior));
9787 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9788 else if (unformat (i, "fib-table %u", &fib_table));
9789 else if (unformat (i, "end.psp %u", &behavior));
9794 M (SR_LOCALSID_ADD_DEL, mp);
9796 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
9799 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
9800 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
9802 mp->behavior = behavior;
9803 mp->sw_if_index = ntohl (sw_if_index);
9804 mp->fib_table = ntohl (fib_table);
9805 mp->end_psp = end_psp;
9806 mp->is_del = is_del;
9814 api_ioam_enable (vat_main_t * vam)
9816 unformat_input_t *input = vam->input;
9817 vl_api_ioam_enable_t *mp;
9819 int has_trace_option = 0;
9820 int has_pot_option = 0;
9821 int has_seqno_option = 0;
9822 int has_analyse_option = 0;
9825 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9827 if (unformat (input, "trace"))
9828 has_trace_option = 1;
9829 else if (unformat (input, "pot"))
9831 else if (unformat (input, "seqno"))
9832 has_seqno_option = 1;
9833 else if (unformat (input, "analyse"))
9834 has_analyse_option = 1;
9838 M (IOAM_ENABLE, mp);
9839 mp->id = htons (id);
9840 mp->seqno = has_seqno_option;
9841 mp->analyse = has_analyse_option;
9842 mp->pot_enable = has_pot_option;
9843 mp->trace_enable = has_trace_option;
9852 api_ioam_disable (vat_main_t * vam)
9854 vl_api_ioam_disable_t *mp;
9857 M (IOAM_DISABLE, mp);
9863 #define foreach_tcp_proto_field \
9867 #define foreach_udp_proto_field \
9871 #define foreach_ip4_proto_field \
9883 u16 src_port, dst_port;
9886 #if VPP_API_TEST_BUILTIN == 0
9888 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9890 u8 **maskp = va_arg (*args, u8 **);
9892 u8 found_something = 0;
9895 #define _(a) u8 a=0;
9896 foreach_tcp_proto_field;
9899 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9902 #define _(a) else if (unformat (input, #a)) a=1;
9903 foreach_tcp_proto_field
9909 #define _(a) found_something += a;
9910 foreach_tcp_proto_field;
9913 if (found_something == 0)
9916 vec_validate (mask, sizeof (*tcp) - 1);
9918 tcp = (tcp_header_t *) mask;
9920 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
9921 foreach_tcp_proto_field;
9929 unformat_udp_mask (unformat_input_t * input, va_list * args)
9931 u8 **maskp = va_arg (*args, u8 **);
9933 u8 found_something = 0;
9936 #define _(a) u8 a=0;
9937 foreach_udp_proto_field;
9940 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9943 #define _(a) else if (unformat (input, #a)) a=1;
9944 foreach_udp_proto_field
9950 #define _(a) found_something += a;
9951 foreach_udp_proto_field;
9954 if (found_something == 0)
9957 vec_validate (mask, sizeof (*udp) - 1);
9959 udp = (udp_header_t *) mask;
9961 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
9962 foreach_udp_proto_field;
9970 unformat_l4_mask (unformat_input_t * input, va_list * args)
9972 u8 **maskp = va_arg (*args, u8 **);
9973 u16 src_port = 0, dst_port = 0;
9974 tcpudp_header_t *tcpudp;
9976 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9978 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9980 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9982 else if (unformat (input, "src_port"))
9984 else if (unformat (input, "dst_port"))
9990 if (!src_port && !dst_port)
9994 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9996 tcpudp = (tcpudp_header_t *) mask;
9997 tcpudp->src_port = src_port;
9998 tcpudp->dst_port = dst_port;
10006 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10008 u8 **maskp = va_arg (*args, u8 **);
10010 u8 found_something = 0;
10013 #define _(a) u8 a=0;
10014 foreach_ip4_proto_field;
10020 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10022 if (unformat (input, "version"))
10024 else if (unformat (input, "hdr_length"))
10026 else if (unformat (input, "src"))
10028 else if (unformat (input, "dst"))
10030 else if (unformat (input, "proto"))
10033 #define _(a) else if (unformat (input, #a)) a=1;
10034 foreach_ip4_proto_field
10040 #define _(a) found_something += a;
10041 foreach_ip4_proto_field;
10044 if (found_something == 0)
10047 vec_validate (mask, sizeof (*ip) - 1);
10049 ip = (ip4_header_t *) mask;
10051 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10052 foreach_ip4_proto_field;
10055 ip->ip_version_and_header_length = 0;
10058 ip->ip_version_and_header_length |= 0xF0;
10061 ip->ip_version_and_header_length |= 0x0F;
10067 #define foreach_ip6_proto_field \
10070 _(payload_length) \
10075 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10077 u8 **maskp = va_arg (*args, u8 **);
10079 u8 found_something = 0;
10081 u32 ip_version_traffic_class_and_flow_label;
10083 #define _(a) u8 a=0;
10084 foreach_ip6_proto_field;
10087 u8 traffic_class = 0;
10090 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10092 if (unformat (input, "version"))
10094 else if (unformat (input, "traffic-class"))
10096 else if (unformat (input, "flow-label"))
10098 else if (unformat (input, "src"))
10100 else if (unformat (input, "dst"))
10102 else if (unformat (input, "proto"))
10105 #define _(a) else if (unformat (input, #a)) a=1;
10106 foreach_ip6_proto_field
10112 #define _(a) found_something += a;
10113 foreach_ip6_proto_field;
10116 if (found_something == 0)
10119 vec_validate (mask, sizeof (*ip) - 1);
10121 ip = (ip6_header_t *) mask;
10123 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10124 foreach_ip6_proto_field;
10127 ip_version_traffic_class_and_flow_label = 0;
10130 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10133 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10136 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10138 ip->ip_version_traffic_class_and_flow_label =
10139 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10146 unformat_l3_mask (unformat_input_t * input, va_list * args)
10148 u8 **maskp = va_arg (*args, u8 **);
10150 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10152 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10154 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10163 unformat_l2_mask (unformat_input_t * input, va_list * args)
10165 u8 **maskp = va_arg (*args, u8 **);
10172 u8 ignore_tag1 = 0;
10173 u8 ignore_tag2 = 0;
10180 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10182 if (unformat (input, "src"))
10184 else if (unformat (input, "dst"))
10186 else if (unformat (input, "proto"))
10188 else if (unformat (input, "tag1"))
10190 else if (unformat (input, "tag2"))
10192 else if (unformat (input, "ignore-tag1"))
10194 else if (unformat (input, "ignore-tag2"))
10196 else if (unformat (input, "cos1"))
10198 else if (unformat (input, "cos2"))
10200 else if (unformat (input, "dot1q"))
10202 else if (unformat (input, "dot1ad"))
10207 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10208 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10211 if (tag1 || ignore_tag1 || cos1 || dot1q)
10213 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10216 vec_validate (mask, len - 1);
10219 clib_memset (mask, 0xff, 6);
10222 clib_memset (mask + 6, 0xff, 6);
10224 if (tag2 || dot1ad)
10226 /* inner vlan tag */
10235 mask[21] = mask[20] = 0xff;
10256 mask[16] = mask[17] = 0xff;
10266 mask[12] = mask[13] = 0xff;
10273 unformat_classify_mask (unformat_input_t * input, va_list * args)
10275 u8 **maskp = va_arg (*args, u8 **);
10276 u32 *skipp = va_arg (*args, u32 *);
10277 u32 *matchp = va_arg (*args, u32 *);
10285 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10287 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10289 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10291 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10293 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10307 if (mask || l2 || l3 || l4)
10309 if (l2 || l3 || l4)
10311 /* "With a free Ethernet header in every package" */
10313 vec_validate (l2, 13);
10317 vec_append (mask, l3);
10322 vec_append (mask, l4);
10327 /* Scan forward looking for the first significant mask octet */
10328 for (i = 0; i < vec_len (mask); i++)
10332 /* compute (skip, match) params */
10333 *skipp = i / sizeof (u32x4);
10334 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10336 /* Pad mask to an even multiple of the vector size */
10337 while (vec_len (mask) % sizeof (u32x4))
10338 vec_add1 (mask, 0);
10340 match = vec_len (mask) / sizeof (u32x4);
10342 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10344 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10345 if (*tmp || *(tmp + 1))
10350 clib_warning ("BUG: match 0");
10352 _vec_len (mask) = match * sizeof (u32x4);
10362 #endif /* VPP_API_TEST_BUILTIN */
10364 #define foreach_l2_next \
10366 _(ethernet, ETHERNET_INPUT) \
10367 _(ip4, IP4_INPUT) \
10371 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10373 u32 *miss_next_indexp = va_arg (*args, u32 *);
10374 u32 next_index = 0;
10378 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10382 if (unformat (input, "%d", &tmp))
10391 *miss_next_indexp = next_index;
10395 #define foreach_ip_next \
10398 _(rewrite, REWRITE)
10401 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10403 u32 *miss_next_indexp = va_arg (*args, u32 *);
10404 u32 next_index = 0;
10408 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10412 if (unformat (input, "%d", &tmp))
10421 *miss_next_indexp = next_index;
10425 #define foreach_acl_next \
10429 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10431 u32 *miss_next_indexp = va_arg (*args, u32 *);
10432 u32 next_index = 0;
10436 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10440 if (unformat (input, "permit"))
10445 else if (unformat (input, "%d", &tmp))
10454 *miss_next_indexp = next_index;
10459 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10461 u32 *r = va_arg (*args, u32 *);
10463 if (unformat (input, "conform-color"))
10464 *r = POLICE_CONFORM;
10465 else if (unformat (input, "exceed-color"))
10466 *r = POLICE_EXCEED;
10474 api_classify_add_del_table (vat_main_t * vam)
10476 unformat_input_t *i = vam->input;
10477 vl_api_classify_add_del_table_t *mp;
10484 u32 table_index = ~0;
10485 u32 next_table_index = ~0;
10486 u32 miss_next_index = ~0;
10487 u32 memory_size = 32 << 20;
10489 u32 current_data_flag = 0;
10490 int current_data_offset = 0;
10493 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10495 if (unformat (i, "del"))
10497 else if (unformat (i, "del-chain"))
10502 else if (unformat (i, "buckets %d", &nbuckets))
10504 else if (unformat (i, "memory_size %d", &memory_size))
10506 else if (unformat (i, "skip %d", &skip))
10508 else if (unformat (i, "match %d", &match))
10510 else if (unformat (i, "table %d", &table_index))
10512 else if (unformat (i, "mask %U", unformat_classify_mask,
10513 &mask, &skip, &match))
10515 else if (unformat (i, "next-table %d", &next_table_index))
10517 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10520 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10523 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10526 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10528 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10534 if (is_add && mask == 0)
10536 errmsg ("Mask required");
10540 if (is_add && skip == ~0)
10542 errmsg ("skip count required");
10546 if (is_add && match == ~0)
10548 errmsg ("match count required");
10552 if (!is_add && table_index == ~0)
10554 errmsg ("table index required for delete");
10558 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10560 mp->is_add = is_add;
10561 mp->del_chain = del_chain;
10562 mp->table_index = ntohl (table_index);
10563 mp->nbuckets = ntohl (nbuckets);
10564 mp->memory_size = ntohl (memory_size);
10565 mp->skip_n_vectors = ntohl (skip);
10566 mp->match_n_vectors = ntohl (match);
10567 mp->next_table_index = ntohl (next_table_index);
10568 mp->miss_next_index = ntohl (miss_next_index);
10569 mp->current_data_flag = ntohl (current_data_flag);
10570 mp->current_data_offset = ntohl (current_data_offset);
10571 mp->mask_len = ntohl (vec_len (mask));
10572 clib_memcpy (mp->mask, mask, vec_len (mask));
10581 #if VPP_API_TEST_BUILTIN == 0
10583 unformat_l4_match (unformat_input_t * input, va_list * args)
10585 u8 **matchp = va_arg (*args, u8 **);
10587 u8 *proto_header = 0;
10593 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10595 if (unformat (input, "src_port %d", &src_port))
10597 else if (unformat (input, "dst_port %d", &dst_port))
10603 h.src_port = clib_host_to_net_u16 (src_port);
10604 h.dst_port = clib_host_to_net_u16 (dst_port);
10605 vec_validate (proto_header, sizeof (h) - 1);
10606 memcpy (proto_header, &h, sizeof (h));
10608 *matchp = proto_header;
10614 unformat_ip4_match (unformat_input_t * input, va_list * args)
10616 u8 **matchp = va_arg (*args, u8 **);
10621 int hdr_length = 0;
10622 u32 hdr_length_val;
10623 int src = 0, dst = 0;
10624 ip4_address_t src_val, dst_val;
10631 int fragment_id = 0;
10632 u32 fragment_id_val;
10638 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10640 if (unformat (input, "version %d", &version_val))
10642 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10644 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10646 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10648 else if (unformat (input, "proto %d", &proto_val))
10650 else if (unformat (input, "tos %d", &tos_val))
10652 else if (unformat (input, "length %d", &length_val))
10654 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10656 else if (unformat (input, "ttl %d", &ttl_val))
10658 else if (unformat (input, "checksum %d", &checksum_val))
10664 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10665 + ttl + checksum == 0)
10669 * Aligned because we use the real comparison functions
10671 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10673 ip = (ip4_header_t *) match;
10675 /* These are realistically matched in practice */
10677 ip->src_address.as_u32 = src_val.as_u32;
10680 ip->dst_address.as_u32 = dst_val.as_u32;
10683 ip->protocol = proto_val;
10686 /* These are not, but they're included for completeness */
10688 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10691 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10697 ip->length = clib_host_to_net_u16 (length_val);
10703 ip->checksum = clib_host_to_net_u16 (checksum_val);
10710 unformat_ip6_match (unformat_input_t * input, va_list * args)
10712 u8 **matchp = va_arg (*args, u8 **);
10717 u8 traffic_class = 0;
10718 u32 traffic_class_val = 0;
10721 int src = 0, dst = 0;
10722 ip6_address_t src_val, dst_val;
10725 int payload_length = 0;
10726 u32 payload_length_val;
10729 u32 ip_version_traffic_class_and_flow_label;
10731 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10733 if (unformat (input, "version %d", &version_val))
10735 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10737 else if (unformat (input, "flow_label %d", &flow_label_val))
10739 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10741 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10743 else if (unformat (input, "proto %d", &proto_val))
10745 else if (unformat (input, "payload_length %d", &payload_length_val))
10746 payload_length = 1;
10747 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10753 if (version + traffic_class + flow_label + src + dst + proto +
10754 payload_length + hop_limit == 0)
10758 * Aligned because we use the real comparison functions
10760 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10762 ip = (ip6_header_t *) match;
10765 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10768 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10771 ip->protocol = proto_val;
10773 ip_version_traffic_class_and_flow_label = 0;
10776 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10779 ip_version_traffic_class_and_flow_label |=
10780 (traffic_class_val & 0xFF) << 20;
10783 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10785 ip->ip_version_traffic_class_and_flow_label =
10786 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10788 if (payload_length)
10789 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10792 ip->hop_limit = hop_limit_val;
10799 unformat_l3_match (unformat_input_t * input, va_list * args)
10801 u8 **matchp = va_arg (*args, u8 **);
10803 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10805 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10807 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10816 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10818 u8 *tagp = va_arg (*args, u8 *);
10821 if (unformat (input, "%d", &tag))
10823 tagp[0] = (tag >> 8) & 0x0F;
10824 tagp[1] = tag & 0xFF;
10832 unformat_l2_match (unformat_input_t * input, va_list * args)
10834 u8 **matchp = va_arg (*args, u8 **);
10847 u8 ignore_tag1 = 0;
10848 u8 ignore_tag2 = 0;
10854 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10856 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10859 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10861 else if (unformat (input, "proto %U",
10862 unformat_ethernet_type_host_byte_order, &proto_val))
10864 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10866 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10868 else if (unformat (input, "ignore-tag1"))
10870 else if (unformat (input, "ignore-tag2"))
10872 else if (unformat (input, "cos1 %d", &cos1_val))
10874 else if (unformat (input, "cos2 %d", &cos2_val))
10879 if ((src + dst + proto + tag1 + tag2 +
10880 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10883 if (tag1 || ignore_tag1 || cos1)
10885 if (tag2 || ignore_tag2 || cos2)
10888 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10891 clib_memcpy (match, dst_val, 6);
10894 clib_memcpy (match + 6, src_val, 6);
10898 /* inner vlan tag */
10899 match[19] = tag2_val[1];
10900 match[18] = tag2_val[0];
10902 match[18] |= (cos2_val & 0x7) << 5;
10905 match[21] = proto_val & 0xff;
10906 match[20] = proto_val >> 8;
10910 match[15] = tag1_val[1];
10911 match[14] = tag1_val[0];
10914 match[14] |= (cos1_val & 0x7) << 5;
10920 match[15] = tag1_val[1];
10921 match[14] = tag1_val[0];
10924 match[17] = proto_val & 0xff;
10925 match[16] = proto_val >> 8;
10928 match[14] |= (cos1_val & 0x7) << 5;
10934 match[18] |= (cos2_val & 0x7) << 5;
10936 match[14] |= (cos1_val & 0x7) << 5;
10939 match[13] = proto_val & 0xff;
10940 match[12] = proto_val >> 8;
10948 unformat_qos_source (unformat_input_t * input, va_list * args)
10950 int *qs = va_arg (*args, int *);
10952 if (unformat (input, "ip"))
10953 *qs = QOS_SOURCE_IP;
10954 else if (unformat (input, "mpls"))
10955 *qs = QOS_SOURCE_MPLS;
10956 else if (unformat (input, "ext"))
10957 *qs = QOS_SOURCE_EXT;
10958 else if (unformat (input, "vlan"))
10959 *qs = QOS_SOURCE_VLAN;
10968 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10970 u8 **matchp = va_arg (*args, u8 **);
10971 u32 skip_n_vectors = va_arg (*args, u32);
10972 u32 match_n_vectors = va_arg (*args, u32);
10979 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10981 if (unformat (input, "hex %U", unformat_hex_string, &match))
10983 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10985 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10987 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11001 if (match || l2 || l3 || l4)
11003 if (l2 || l3 || l4)
11005 /* "Win a free Ethernet header in every packet" */
11007 vec_validate_aligned (l2, 13, sizeof (u32x4));
11011 vec_append_aligned (match, l3, sizeof (u32x4));
11016 vec_append_aligned (match, l4, sizeof (u32x4));
11021 /* Make sure the vector is big enough even if key is all 0's */
11022 vec_validate_aligned
11023 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11026 /* Set size, include skipped vectors */
11027 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11038 api_classify_add_del_session (vat_main_t * vam)
11040 unformat_input_t *i = vam->input;
11041 vl_api_classify_add_del_session_t *mp;
11043 u32 table_index = ~0;
11044 u32 hit_next_index = ~0;
11045 u32 opaque_index = ~0;
11048 u32 skip_n_vectors = 0;
11049 u32 match_n_vectors = 0;
11055 * Warning: you have to supply skip_n and match_n
11056 * because the API client cant simply look at the classify
11060 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11062 if (unformat (i, "del"))
11064 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11067 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11070 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11073 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11075 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11077 else if (unformat (i, "opaque-index %d", &opaque_index))
11079 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11081 else if (unformat (i, "match_n %d", &match_n_vectors))
11083 else if (unformat (i, "match %U", api_unformat_classify_match,
11084 &match, skip_n_vectors, match_n_vectors))
11086 else if (unformat (i, "advance %d", &advance))
11088 else if (unformat (i, "table-index %d", &table_index))
11090 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11092 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11094 else if (unformat (i, "action %d", &action))
11096 else if (unformat (i, "metadata %d", &metadata))
11102 if (table_index == ~0)
11104 errmsg ("Table index required");
11108 if (is_add && match == 0)
11110 errmsg ("Match value required");
11114 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11116 mp->is_add = is_add;
11117 mp->table_index = ntohl (table_index);
11118 mp->hit_next_index = ntohl (hit_next_index);
11119 mp->opaque_index = ntohl (opaque_index);
11120 mp->advance = ntohl (advance);
11121 mp->action = action;
11122 mp->metadata = ntohl (metadata);
11123 mp->match_len = ntohl (vec_len (match));
11124 clib_memcpy (mp->match, match, vec_len (match));
11133 api_classify_set_interface_ip_table (vat_main_t * vam)
11135 unformat_input_t *i = vam->input;
11136 vl_api_classify_set_interface_ip_table_t *mp;
11138 int sw_if_index_set;
11139 u32 table_index = ~0;
11143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11145 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11146 sw_if_index_set = 1;
11147 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11148 sw_if_index_set = 1;
11149 else if (unformat (i, "table %d", &table_index))
11153 clib_warning ("parse error '%U'", format_unformat_error, i);
11158 if (sw_if_index_set == 0)
11160 errmsg ("missing interface name or sw_if_index");
11165 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11167 mp->sw_if_index = ntohl (sw_if_index);
11168 mp->table_index = ntohl (table_index);
11169 mp->is_ipv6 = is_ipv6;
11177 api_classify_set_interface_l2_tables (vat_main_t * vam)
11179 unformat_input_t *i = vam->input;
11180 vl_api_classify_set_interface_l2_tables_t *mp;
11182 int sw_if_index_set;
11183 u32 ip4_table_index = ~0;
11184 u32 ip6_table_index = ~0;
11185 u32 other_table_index = ~0;
11189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11191 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11192 sw_if_index_set = 1;
11193 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11194 sw_if_index_set = 1;
11195 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11197 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11199 else if (unformat (i, "other-table %d", &other_table_index))
11201 else if (unformat (i, "is-input %d", &is_input))
11205 clib_warning ("parse error '%U'", format_unformat_error, i);
11210 if (sw_if_index_set == 0)
11212 errmsg ("missing interface name or sw_if_index");
11217 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11219 mp->sw_if_index = ntohl (sw_if_index);
11220 mp->ip4_table_index = ntohl (ip4_table_index);
11221 mp->ip6_table_index = ntohl (ip6_table_index);
11222 mp->other_table_index = ntohl (other_table_index);
11223 mp->is_input = (u8) is_input;
11231 api_set_ipfix_exporter (vat_main_t * vam)
11233 unformat_input_t *i = vam->input;
11234 vl_api_set_ipfix_exporter_t *mp;
11235 ip4_address_t collector_address;
11236 u8 collector_address_set = 0;
11237 u32 collector_port = ~0;
11238 ip4_address_t src_address;
11239 u8 src_address_set = 0;
11242 u32 template_interval = ~0;
11243 u8 udp_checksum = 0;
11246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11248 if (unformat (i, "collector_address %U", unformat_ip4_address,
11249 &collector_address))
11250 collector_address_set = 1;
11251 else if (unformat (i, "collector_port %d", &collector_port))
11253 else if (unformat (i, "src_address %U", unformat_ip4_address,
11255 src_address_set = 1;
11256 else if (unformat (i, "vrf_id %d", &vrf_id))
11258 else if (unformat (i, "path_mtu %d", &path_mtu))
11260 else if (unformat (i, "template_interval %d", &template_interval))
11262 else if (unformat (i, "udp_checksum"))
11268 if (collector_address_set == 0)
11270 errmsg ("collector_address required");
11274 if (src_address_set == 0)
11276 errmsg ("src_address required");
11280 M (SET_IPFIX_EXPORTER, mp);
11282 memcpy (mp->collector_address, collector_address.data,
11283 sizeof (collector_address.data));
11284 mp->collector_port = htons ((u16) collector_port);
11285 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11286 mp->vrf_id = htonl (vrf_id);
11287 mp->path_mtu = htonl (path_mtu);
11288 mp->template_interval = htonl (template_interval);
11289 mp->udp_checksum = udp_checksum;
11297 api_set_ipfix_classify_stream (vat_main_t * vam)
11299 unformat_input_t *i = vam->input;
11300 vl_api_set_ipfix_classify_stream_t *mp;
11302 u32 src_port = UDP_DST_PORT_ipfix;
11305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11307 if (unformat (i, "domain %d", &domain_id))
11309 else if (unformat (i, "src_port %d", &src_port))
11313 errmsg ("unknown input `%U'", format_unformat_error, i);
11318 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11320 mp->domain_id = htonl (domain_id);
11321 mp->src_port = htons ((u16) src_port);
11329 api_ipfix_classify_table_add_del (vat_main_t * vam)
11331 unformat_input_t *i = vam->input;
11332 vl_api_ipfix_classify_table_add_del_t *mp;
11334 u32 classify_table_index = ~0;
11336 u8 transport_protocol = 255;
11339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11341 if (unformat (i, "add"))
11343 else if (unformat (i, "del"))
11345 else if (unformat (i, "table %d", &classify_table_index))
11347 else if (unformat (i, "ip4"))
11349 else if (unformat (i, "ip6"))
11351 else if (unformat (i, "tcp"))
11352 transport_protocol = 6;
11353 else if (unformat (i, "udp"))
11354 transport_protocol = 17;
11357 errmsg ("unknown input `%U'", format_unformat_error, i);
11364 errmsg ("expecting: add|del");
11367 if (classify_table_index == ~0)
11369 errmsg ("classifier table not specified");
11372 if (ip_version == 0)
11374 errmsg ("IP version not specified");
11378 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11380 mp->is_add = is_add;
11381 mp->table_id = htonl (classify_table_index);
11382 mp->ip_version = ip_version;
11383 mp->transport_protocol = transport_protocol;
11391 api_get_node_index (vat_main_t * vam)
11393 unformat_input_t *i = vam->input;
11394 vl_api_get_node_index_t *mp;
11398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11400 if (unformat (i, "node %s", &name))
11407 errmsg ("node name required");
11410 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11412 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11416 M (GET_NODE_INDEX, mp);
11417 clib_memcpy (mp->node_name, name, vec_len (name));
11426 api_get_next_index (vat_main_t * vam)
11428 unformat_input_t *i = vam->input;
11429 vl_api_get_next_index_t *mp;
11430 u8 *node_name = 0, *next_node_name = 0;
11433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11435 if (unformat (i, "node-name %s", &node_name))
11437 else if (unformat (i, "next-node-name %s", &next_node_name))
11441 if (node_name == 0)
11443 errmsg ("node name required");
11446 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11448 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11452 if (next_node_name == 0)
11454 errmsg ("next node name required");
11457 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11459 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11463 M (GET_NEXT_INDEX, mp);
11464 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11465 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11466 vec_free (node_name);
11467 vec_free (next_node_name);
11475 api_add_node_next (vat_main_t * vam)
11477 unformat_input_t *i = vam->input;
11478 vl_api_add_node_next_t *mp;
11483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11485 if (unformat (i, "node %s", &name))
11487 else if (unformat (i, "next %s", &next))
11494 errmsg ("node name required");
11497 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11499 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11504 errmsg ("next node required");
11507 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11509 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11513 M (ADD_NODE_NEXT, mp);
11514 clib_memcpy (mp->node_name, name, vec_len (name));
11515 clib_memcpy (mp->next_name, next, vec_len (next));
11525 api_l2tpv3_create_tunnel (vat_main_t * vam)
11527 unformat_input_t *i = vam->input;
11528 ip6_address_t client_address, our_address;
11529 int client_address_set = 0;
11530 int our_address_set = 0;
11531 u32 local_session_id = 0;
11532 u32 remote_session_id = 0;
11533 u64 local_cookie = 0;
11534 u64 remote_cookie = 0;
11535 u8 l2_sublayer_present = 0;
11536 vl_api_l2tpv3_create_tunnel_t *mp;
11539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11541 if (unformat (i, "client_address %U", unformat_ip6_address,
11543 client_address_set = 1;
11544 else if (unformat (i, "our_address %U", unformat_ip6_address,
11546 our_address_set = 1;
11547 else if (unformat (i, "local_session_id %d", &local_session_id))
11549 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11551 else if (unformat (i, "local_cookie %lld", &local_cookie))
11553 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11555 else if (unformat (i, "l2-sublayer-present"))
11556 l2_sublayer_present = 1;
11561 if (client_address_set == 0)
11563 errmsg ("client_address required");
11567 if (our_address_set == 0)
11569 errmsg ("our_address required");
11573 M (L2TPV3_CREATE_TUNNEL, mp);
11575 clib_memcpy (mp->client_address, client_address.as_u8,
11576 sizeof (mp->client_address));
11578 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11580 mp->local_session_id = ntohl (local_session_id);
11581 mp->remote_session_id = ntohl (remote_session_id);
11582 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11583 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11584 mp->l2_sublayer_present = l2_sublayer_present;
11593 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11595 unformat_input_t *i = vam->input;
11597 u8 sw_if_index_set = 0;
11598 u64 new_local_cookie = 0;
11599 u64 new_remote_cookie = 0;
11600 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11605 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11606 sw_if_index_set = 1;
11607 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11608 sw_if_index_set = 1;
11609 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11611 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11617 if (sw_if_index_set == 0)
11619 errmsg ("missing interface name or sw_if_index");
11623 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11625 mp->sw_if_index = ntohl (sw_if_index);
11626 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11627 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11635 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11637 unformat_input_t *i = vam->input;
11638 vl_api_l2tpv3_interface_enable_disable_t *mp;
11640 u8 sw_if_index_set = 0;
11641 u8 enable_disable = 1;
11644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11646 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11647 sw_if_index_set = 1;
11648 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11649 sw_if_index_set = 1;
11650 else if (unformat (i, "enable"))
11651 enable_disable = 1;
11652 else if (unformat (i, "disable"))
11653 enable_disable = 0;
11658 if (sw_if_index_set == 0)
11660 errmsg ("missing interface name or sw_if_index");
11664 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11666 mp->sw_if_index = ntohl (sw_if_index);
11667 mp->enable_disable = enable_disable;
11675 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11677 unformat_input_t *i = vam->input;
11678 vl_api_l2tpv3_set_lookup_key_t *mp;
11682 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11684 if (unformat (i, "lookup_v6_src"))
11685 key = L2T_LOOKUP_SRC_ADDRESS;
11686 else if (unformat (i, "lookup_v6_dst"))
11687 key = L2T_LOOKUP_DST_ADDRESS;
11688 else if (unformat (i, "lookup_session_id"))
11689 key = L2T_LOOKUP_SESSION_ID;
11694 if (key == (u8) ~ 0)
11696 errmsg ("l2tp session lookup key unset");
11700 M (L2TPV3_SET_LOOKUP_KEY, mp);
11709 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11710 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11712 vat_main_t *vam = &vat_main;
11714 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11715 format_ip6_address, mp->our_address,
11716 format_ip6_address, mp->client_address,
11717 clib_net_to_host_u32 (mp->sw_if_index));
11720 " local cookies %016llx %016llx remote cookie %016llx",
11721 clib_net_to_host_u64 (mp->local_cookie[0]),
11722 clib_net_to_host_u64 (mp->local_cookie[1]),
11723 clib_net_to_host_u64 (mp->remote_cookie));
11725 print (vam->ofp, " local session-id %d remote session-id %d",
11726 clib_net_to_host_u32 (mp->local_session_id),
11727 clib_net_to_host_u32 (mp->remote_session_id));
11729 print (vam->ofp, " l2 specific sublayer %s\n",
11730 mp->l2_sublayer_present ? "preset" : "absent");
11734 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11735 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11737 vat_main_t *vam = &vat_main;
11738 vat_json_node_t *node = NULL;
11739 struct in6_addr addr;
11741 if (VAT_JSON_ARRAY != vam->json_tree.type)
11743 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11744 vat_json_init_array (&vam->json_tree);
11746 node = vat_json_array_add (&vam->json_tree);
11748 vat_json_init_object (node);
11750 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11751 vat_json_object_add_ip6 (node, "our_address", addr);
11752 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11753 vat_json_object_add_ip6 (node, "client_address", addr);
11755 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11756 vat_json_init_array (lc);
11757 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11758 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11759 vat_json_object_add_uint (node, "remote_cookie",
11760 clib_net_to_host_u64 (mp->remote_cookie));
11762 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11763 vat_json_object_add_uint (node, "local_session_id",
11764 clib_net_to_host_u32 (mp->local_session_id));
11765 vat_json_object_add_uint (node, "remote_session_id",
11766 clib_net_to_host_u32 (mp->remote_session_id));
11767 vat_json_object_add_string_copy (node, "l2_sublayer",
11768 mp->l2_sublayer_present ? (u8 *) "present"
11769 : (u8 *) "absent");
11773 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11775 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11776 vl_api_control_ping_t *mp_ping;
11779 /* Get list of l2tpv3-tunnel interfaces */
11780 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11783 /* Use a control ping for synchronization */
11784 MPING (CONTROL_PING, mp_ping);
11792 static void vl_api_sw_interface_tap_v2_details_t_handler
11793 (vl_api_sw_interface_tap_v2_details_t * mp)
11795 vat_main_t *vam = &vat_main;
11797 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
11798 mp->host_ip4_prefix_len);
11799 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
11800 mp->host_ip6_prefix_len);
11803 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
11804 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
11805 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11806 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
11807 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
11813 static void vl_api_sw_interface_tap_v2_details_t_handler_json
11814 (vl_api_sw_interface_tap_v2_details_t * mp)
11816 vat_main_t *vam = &vat_main;
11817 vat_json_node_t *node = NULL;
11819 if (VAT_JSON_ARRAY != vam->json_tree.type)
11821 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11822 vat_json_init_array (&vam->json_tree);
11824 node = vat_json_array_add (&vam->json_tree);
11826 vat_json_init_object (node);
11827 vat_json_object_add_uint (node, "id", ntohl (mp->id));
11828 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11829 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
11830 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11831 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11832 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11833 vat_json_object_add_string_copy (node, "host_mac_addr",
11834 format (0, "%U", format_ethernet_address,
11835 &mp->host_mac_addr));
11836 vat_json_object_add_string_copy (node, "host_namespace",
11837 mp->host_namespace);
11838 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
11839 vat_json_object_add_string_copy (node, "host_ip4_addr",
11840 format (0, "%U/%d", format_ip4_address,
11842 mp->host_ip4_prefix_len));
11843 vat_json_object_add_string_copy (node, "host_ip6_addr",
11844 format (0, "%U/%d", format_ip6_address,
11846 mp->host_ip6_prefix_len));
11851 api_sw_interface_tap_v2_dump (vat_main_t * vam)
11853 vl_api_sw_interface_tap_v2_dump_t *mp;
11854 vl_api_control_ping_t *mp_ping;
11858 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
11859 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
11860 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
11863 /* Get list of tap interfaces */
11864 M (SW_INTERFACE_TAP_V2_DUMP, mp);
11867 /* Use a control ping for synchronization */
11868 MPING (CONTROL_PING, mp_ping);
11875 static void vl_api_sw_interface_virtio_pci_details_t_handler
11876 (vl_api_sw_interface_virtio_pci_details_t * mp)
11878 vat_main_t *vam = &vat_main;
11892 addr.as_u32 = ntohl (mp->pci_addr);
11893 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
11894 addr.slot, addr.function);
11897 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
11898 pci_addr, ntohl (mp->sw_if_index),
11899 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11900 format_ethernet_address, mp->mac_addr,
11901 clib_net_to_host_u64 (mp->features));
11902 vec_free (pci_addr);
11905 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
11906 (vl_api_sw_interface_virtio_pci_details_t * mp)
11908 vat_main_t *vam = &vat_main;
11909 vat_json_node_t *node = NULL;
11911 if (VAT_JSON_ARRAY != vam->json_tree.type)
11913 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11914 vat_json_init_array (&vam->json_tree);
11916 node = vat_json_array_add (&vam->json_tree);
11918 vat_json_init_object (node);
11919 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
11920 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11921 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11922 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11923 vat_json_object_add_uint (node, "features",
11924 clib_net_to_host_u64 (mp->features));
11925 vat_json_object_add_string_copy (node, "mac_addr",
11926 format (0, "%U", format_ethernet_address,
11931 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
11933 vl_api_sw_interface_virtio_pci_dump_t *mp;
11934 vl_api_control_ping_t *mp_ping;
11938 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
11939 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
11940 "mac_addr", "features");
11942 /* Get list of tap interfaces */
11943 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
11946 /* Use a control ping for synchronization */
11947 MPING (CONTROL_PING, mp_ping);
11955 api_vxlan_offload_rx (vat_main_t * vam)
11957 unformat_input_t *line_input = vam->input;
11958 vl_api_vxlan_offload_rx_t *mp;
11959 u32 hw_if_index = ~0, rx_if_index = ~0;
11963 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11965 if (unformat (line_input, "del"))
11967 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
11970 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
11972 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
11975 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
11979 errmsg ("parse error '%U'", format_unformat_error, line_input);
11984 if (hw_if_index == ~0)
11986 errmsg ("no hw interface");
11990 if (rx_if_index == ~0)
11992 errmsg ("no rx tunnel");
11996 M (VXLAN_OFFLOAD_RX, mp);
11998 mp->hw_if_index = ntohl (hw_if_index);
11999 mp->sw_if_index = ntohl (rx_if_index);
12000 mp->enable = is_add;
12007 static uword unformat_vxlan_decap_next
12008 (unformat_input_t * input, va_list * args)
12010 u32 *result = va_arg (*args, u32 *);
12013 if (unformat (input, "l2"))
12014 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12015 else if (unformat (input, "%d", &tmp))
12023 api_vxlan_add_del_tunnel (vat_main_t * vam)
12025 unformat_input_t *line_input = vam->input;
12026 vl_api_vxlan_add_del_tunnel_t *mp;
12027 ip46_address_t src, dst;
12029 u8 ipv4_set = 0, ipv6_set = 0;
12034 u32 mcast_sw_if_index = ~0;
12035 u32 encap_vrf_id = 0;
12036 u32 decap_next_index = ~0;
12040 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12041 clib_memset (&src, 0, sizeof src);
12042 clib_memset (&dst, 0, sizeof dst);
12044 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12046 if (unformat (line_input, "del"))
12048 else if (unformat (line_input, "instance %d", &instance))
12051 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12057 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12063 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12069 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12074 else if (unformat (line_input, "group %U %U",
12075 unformat_ip4_address, &dst.ip4,
12076 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12078 grp_set = dst_set = 1;
12081 else if (unformat (line_input, "group %U",
12082 unformat_ip4_address, &dst.ip4))
12084 grp_set = dst_set = 1;
12087 else if (unformat (line_input, "group %U %U",
12088 unformat_ip6_address, &dst.ip6,
12089 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12091 grp_set = dst_set = 1;
12094 else if (unformat (line_input, "group %U",
12095 unformat_ip6_address, &dst.ip6))
12097 grp_set = dst_set = 1;
12101 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12103 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12105 else if (unformat (line_input, "decap-next %U",
12106 unformat_vxlan_decap_next, &decap_next_index))
12108 else if (unformat (line_input, "vni %d", &vni))
12112 errmsg ("parse error '%U'", format_unformat_error, line_input);
12119 errmsg ("tunnel src address not specified");
12124 errmsg ("tunnel dst address not specified");
12128 if (grp_set && !ip46_address_is_multicast (&dst))
12130 errmsg ("tunnel group address not multicast");
12133 if (grp_set && mcast_sw_if_index == ~0)
12135 errmsg ("tunnel nonexistent multicast device");
12138 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12140 errmsg ("tunnel dst address must be unicast");
12145 if (ipv4_set && ipv6_set)
12147 errmsg ("both IPv4 and IPv6 addresses specified");
12151 if ((vni == 0) || (vni >> 24))
12153 errmsg ("vni not specified or out of range");
12157 M (VXLAN_ADD_DEL_TUNNEL, mp);
12161 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12162 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12166 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12167 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12170 mp->instance = htonl (instance);
12171 mp->encap_vrf_id = ntohl (encap_vrf_id);
12172 mp->decap_next_index = ntohl (decap_next_index);
12173 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12174 mp->vni = ntohl (vni);
12175 mp->is_add = is_add;
12176 mp->is_ipv6 = ipv6_set;
12183 static void vl_api_vxlan_tunnel_details_t_handler
12184 (vl_api_vxlan_tunnel_details_t * mp)
12186 vat_main_t *vam = &vat_main;
12187 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12188 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12190 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12191 ntohl (mp->sw_if_index),
12192 ntohl (mp->instance),
12193 format_ip46_address, &src, IP46_TYPE_ANY,
12194 format_ip46_address, &dst, IP46_TYPE_ANY,
12195 ntohl (mp->encap_vrf_id),
12196 ntohl (mp->decap_next_index), ntohl (mp->vni),
12197 ntohl (mp->mcast_sw_if_index));
12200 static void vl_api_vxlan_tunnel_details_t_handler_json
12201 (vl_api_vxlan_tunnel_details_t * mp)
12203 vat_main_t *vam = &vat_main;
12204 vat_json_node_t *node = NULL;
12206 if (VAT_JSON_ARRAY != vam->json_tree.type)
12208 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12209 vat_json_init_array (&vam->json_tree);
12211 node = vat_json_array_add (&vam->json_tree);
12213 vat_json_init_object (node);
12214 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12216 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12220 struct in6_addr ip6;
12222 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12223 vat_json_object_add_ip6 (node, "src_address", ip6);
12224 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12225 vat_json_object_add_ip6 (node, "dst_address", ip6);
12229 struct in_addr ip4;
12231 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12232 vat_json_object_add_ip4 (node, "src_address", ip4);
12233 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12234 vat_json_object_add_ip4 (node, "dst_address", ip4);
12236 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12237 vat_json_object_add_uint (node, "decap_next_index",
12238 ntohl (mp->decap_next_index));
12239 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12240 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12241 vat_json_object_add_uint (node, "mcast_sw_if_index",
12242 ntohl (mp->mcast_sw_if_index));
12246 api_vxlan_tunnel_dump (vat_main_t * vam)
12248 unformat_input_t *i = vam->input;
12249 vl_api_vxlan_tunnel_dump_t *mp;
12250 vl_api_control_ping_t *mp_ping;
12252 u8 sw_if_index_set = 0;
12255 /* Parse args required to build the message */
12256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12258 if (unformat (i, "sw_if_index %d", &sw_if_index))
12259 sw_if_index_set = 1;
12264 if (sw_if_index_set == 0)
12269 if (!vam->json_output)
12271 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12272 "sw_if_index", "instance", "src_address", "dst_address",
12273 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12276 /* Get list of vxlan-tunnel interfaces */
12277 M (VXLAN_TUNNEL_DUMP, mp);
12279 mp->sw_if_index = htonl (sw_if_index);
12283 /* Use a control ping for synchronization */
12284 MPING (CONTROL_PING, mp_ping);
12291 static uword unformat_geneve_decap_next
12292 (unformat_input_t * input, va_list * args)
12294 u32 *result = va_arg (*args, u32 *);
12297 if (unformat (input, "l2"))
12298 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12299 else if (unformat (input, "%d", &tmp))
12307 api_geneve_add_del_tunnel (vat_main_t * vam)
12309 unformat_input_t *line_input = vam->input;
12310 vl_api_geneve_add_del_tunnel_t *mp;
12311 ip46_address_t src, dst;
12313 u8 ipv4_set = 0, ipv6_set = 0;
12317 u32 mcast_sw_if_index = ~0;
12318 u32 encap_vrf_id = 0;
12319 u32 decap_next_index = ~0;
12323 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12324 clib_memset (&src, 0, sizeof src);
12325 clib_memset (&dst, 0, sizeof dst);
12327 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12329 if (unformat (line_input, "del"))
12332 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12338 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12344 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12350 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12355 else if (unformat (line_input, "group %U %U",
12356 unformat_ip4_address, &dst.ip4,
12357 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12359 grp_set = dst_set = 1;
12362 else if (unformat (line_input, "group %U",
12363 unformat_ip4_address, &dst.ip4))
12365 grp_set = dst_set = 1;
12368 else if (unformat (line_input, "group %U %U",
12369 unformat_ip6_address, &dst.ip6,
12370 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12372 grp_set = dst_set = 1;
12375 else if (unformat (line_input, "group %U",
12376 unformat_ip6_address, &dst.ip6))
12378 grp_set = dst_set = 1;
12382 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12384 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12386 else if (unformat (line_input, "decap-next %U",
12387 unformat_geneve_decap_next, &decap_next_index))
12389 else if (unformat (line_input, "vni %d", &vni))
12393 errmsg ("parse error '%U'", format_unformat_error, line_input);
12400 errmsg ("tunnel src address not specified");
12405 errmsg ("tunnel dst address not specified");
12409 if (grp_set && !ip46_address_is_multicast (&dst))
12411 errmsg ("tunnel group address not multicast");
12414 if (grp_set && mcast_sw_if_index == ~0)
12416 errmsg ("tunnel nonexistent multicast device");
12419 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12421 errmsg ("tunnel dst address must be unicast");
12426 if (ipv4_set && ipv6_set)
12428 errmsg ("both IPv4 and IPv6 addresses specified");
12432 if ((vni == 0) || (vni >> 24))
12434 errmsg ("vni not specified or out of range");
12438 M (GENEVE_ADD_DEL_TUNNEL, mp);
12442 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12443 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12447 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12448 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12450 mp->encap_vrf_id = ntohl (encap_vrf_id);
12451 mp->decap_next_index = ntohl (decap_next_index);
12452 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12453 mp->vni = ntohl (vni);
12454 mp->is_add = is_add;
12455 mp->is_ipv6 = ipv6_set;
12462 static void vl_api_geneve_tunnel_details_t_handler
12463 (vl_api_geneve_tunnel_details_t * mp)
12465 vat_main_t *vam = &vat_main;
12466 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12467 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12469 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12470 ntohl (mp->sw_if_index),
12471 format_ip46_address, &src, IP46_TYPE_ANY,
12472 format_ip46_address, &dst, IP46_TYPE_ANY,
12473 ntohl (mp->encap_vrf_id),
12474 ntohl (mp->decap_next_index), ntohl (mp->vni),
12475 ntohl (mp->mcast_sw_if_index));
12478 static void vl_api_geneve_tunnel_details_t_handler_json
12479 (vl_api_geneve_tunnel_details_t * mp)
12481 vat_main_t *vam = &vat_main;
12482 vat_json_node_t *node = NULL;
12484 if (VAT_JSON_ARRAY != vam->json_tree.type)
12486 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12487 vat_json_init_array (&vam->json_tree);
12489 node = vat_json_array_add (&vam->json_tree);
12491 vat_json_init_object (node);
12492 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12495 struct in6_addr ip6;
12497 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12498 vat_json_object_add_ip6 (node, "src_address", ip6);
12499 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12500 vat_json_object_add_ip6 (node, "dst_address", ip6);
12504 struct in_addr ip4;
12506 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12507 vat_json_object_add_ip4 (node, "src_address", ip4);
12508 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12509 vat_json_object_add_ip4 (node, "dst_address", ip4);
12511 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12512 vat_json_object_add_uint (node, "decap_next_index",
12513 ntohl (mp->decap_next_index));
12514 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12515 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12516 vat_json_object_add_uint (node, "mcast_sw_if_index",
12517 ntohl (mp->mcast_sw_if_index));
12521 api_geneve_tunnel_dump (vat_main_t * vam)
12523 unformat_input_t *i = vam->input;
12524 vl_api_geneve_tunnel_dump_t *mp;
12525 vl_api_control_ping_t *mp_ping;
12527 u8 sw_if_index_set = 0;
12530 /* Parse args required to build the message */
12531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12533 if (unformat (i, "sw_if_index %d", &sw_if_index))
12534 sw_if_index_set = 1;
12539 if (sw_if_index_set == 0)
12544 if (!vam->json_output)
12546 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12547 "sw_if_index", "local_address", "remote_address",
12548 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12551 /* Get list of geneve-tunnel interfaces */
12552 M (GENEVE_TUNNEL_DUMP, mp);
12554 mp->sw_if_index = htonl (sw_if_index);
12558 /* Use a control ping for synchronization */
12559 M (CONTROL_PING, mp_ping);
12567 api_gre_tunnel_add_del (vat_main_t * vam)
12569 unformat_input_t *line_input = vam->input;
12570 vl_api_address_t src = { }, dst =
12573 vl_api_gre_tunnel_add_del_t *mp;
12574 vl_api_gre_tunnel_type_t t_type;
12578 u32 outer_fib_id = 0;
12579 u32 session_id = 0;
12583 t_type = GRE_API_TUNNEL_TYPE_L3;
12585 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12587 if (unformat (line_input, "del"))
12589 else if (unformat (line_input, "instance %d", &instance))
12591 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
12595 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
12599 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12601 else if (unformat (line_input, "teb"))
12602 t_type = GRE_API_TUNNEL_TYPE_TEB;
12603 else if (unformat (line_input, "erspan %d", &session_id))
12604 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
12607 errmsg ("parse error '%U'", format_unformat_error, line_input);
12614 errmsg ("tunnel src address not specified");
12619 errmsg ("tunnel dst address not specified");
12623 M (GRE_TUNNEL_ADD_DEL, mp);
12625 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
12626 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
12628 mp->tunnel.instance = htonl (instance);
12629 mp->tunnel.outer_fib_id = htonl (outer_fib_id);
12630 mp->is_add = is_add;
12631 mp->tunnel.session_id = htons ((u16) session_id);
12632 mp->tunnel.type = htonl (t_type);
12639 static void vl_api_gre_tunnel_details_t_handler
12640 (vl_api_gre_tunnel_details_t * mp)
12642 vat_main_t *vam = &vat_main;
12644 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
12645 ntohl (mp->tunnel.sw_if_index),
12646 ntohl (mp->tunnel.instance),
12647 format_vl_api_address, &mp->tunnel.src,
12648 format_vl_api_address, &mp->tunnel.dst,
12649 mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
12650 ntohl (mp->tunnel.session_id));
12653 static void vl_api_gre_tunnel_details_t_handler_json
12654 (vl_api_gre_tunnel_details_t * mp)
12656 vat_main_t *vam = &vat_main;
12657 vat_json_node_t *node = NULL;
12659 if (VAT_JSON_ARRAY != vam->json_tree.type)
12661 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12662 vat_json_init_array (&vam->json_tree);
12664 node = vat_json_array_add (&vam->json_tree);
12666 vat_json_init_object (node);
12667 vat_json_object_add_uint (node, "sw_if_index",
12668 ntohl (mp->tunnel.sw_if_index));
12669 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
12671 vat_json_object_add_address (node, "src", &mp->tunnel.src);
12672 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
12673 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
12674 vat_json_object_add_uint (node, "outer_fib_id",
12675 ntohl (mp->tunnel.outer_fib_id));
12676 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
12680 api_gre_tunnel_dump (vat_main_t * vam)
12682 unformat_input_t *i = vam->input;
12683 vl_api_gre_tunnel_dump_t *mp;
12684 vl_api_control_ping_t *mp_ping;
12686 u8 sw_if_index_set = 0;
12689 /* Parse args required to build the message */
12690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12692 if (unformat (i, "sw_if_index %d", &sw_if_index))
12693 sw_if_index_set = 1;
12698 if (sw_if_index_set == 0)
12703 if (!vam->json_output)
12705 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
12706 "sw_if_index", "instance", "src_address", "dst_address",
12707 "tunnel_type", "outer_fib_id", "session_id");
12710 /* Get list of gre-tunnel interfaces */
12711 M (GRE_TUNNEL_DUMP, mp);
12713 mp->sw_if_index = htonl (sw_if_index);
12717 /* Use a control ping for synchronization */
12718 MPING (CONTROL_PING, mp_ping);
12726 api_l2_fib_clear_table (vat_main_t * vam)
12728 // unformat_input_t * i = vam->input;
12729 vl_api_l2_fib_clear_table_t *mp;
12732 M (L2_FIB_CLEAR_TABLE, mp);
12740 api_l2_interface_efp_filter (vat_main_t * vam)
12742 unformat_input_t *i = vam->input;
12743 vl_api_l2_interface_efp_filter_t *mp;
12746 u8 sw_if_index_set = 0;
12749 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12751 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12752 sw_if_index_set = 1;
12753 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12754 sw_if_index_set = 1;
12755 else if (unformat (i, "enable"))
12757 else if (unformat (i, "disable"))
12761 clib_warning ("parse error '%U'", format_unformat_error, i);
12766 if (sw_if_index_set == 0)
12768 errmsg ("missing sw_if_index");
12772 M (L2_INTERFACE_EFP_FILTER, mp);
12774 mp->sw_if_index = ntohl (sw_if_index);
12775 mp->enable_disable = enable;
12782 #define foreach_vtr_op \
12783 _("disable", L2_VTR_DISABLED) \
12784 _("push-1", L2_VTR_PUSH_1) \
12785 _("push-2", L2_VTR_PUSH_2) \
12786 _("pop-1", L2_VTR_POP_1) \
12787 _("pop-2", L2_VTR_POP_2) \
12788 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12789 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12790 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12791 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12794 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12796 unformat_input_t *i = vam->input;
12797 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12799 u8 sw_if_index_set = 0;
12802 u32 push_dot1q = 1;
12807 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12809 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12810 sw_if_index_set = 1;
12811 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12812 sw_if_index_set = 1;
12813 else if (unformat (i, "vtr_op %d", &vtr_op))
12815 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12818 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12820 else if (unformat (i, "tag1 %d", &tag1))
12822 else if (unformat (i, "tag2 %d", &tag2))
12826 clib_warning ("parse error '%U'", format_unformat_error, i);
12831 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12833 errmsg ("missing vtr operation or sw_if_index");
12837 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12838 mp->sw_if_index = ntohl (sw_if_index);
12839 mp->vtr_op = ntohl (vtr_op);
12840 mp->push_dot1q = ntohl (push_dot1q);
12841 mp->tag1 = ntohl (tag1);
12842 mp->tag2 = ntohl (tag2);
12850 api_create_vhost_user_if (vat_main_t * vam)
12852 unformat_input_t *i = vam->input;
12853 vl_api_create_vhost_user_if_t *mp;
12856 u8 file_name_set = 0;
12857 u32 custom_dev_instance = ~0;
12859 u8 use_custom_mac = 0;
12860 u8 disable_mrg_rxbuf = 0;
12861 u8 disable_indirect_desc = 0;
12866 /* Shut up coverity */
12867 clib_memset (hwaddr, 0, sizeof (hwaddr));
12869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12871 if (unformat (i, "socket %s", &file_name))
12875 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12877 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12878 use_custom_mac = 1;
12879 else if (unformat (i, "server"))
12881 else if (unformat (i, "disable_mrg_rxbuf"))
12882 disable_mrg_rxbuf = 1;
12883 else if (unformat (i, "disable_indirect_desc"))
12884 disable_indirect_desc = 1;
12885 else if (unformat (i, "gso"))
12887 else if (unformat (i, "tag %s", &tag))
12893 if (file_name_set == 0)
12895 errmsg ("missing socket file name");
12899 if (vec_len (file_name) > 255)
12901 errmsg ("socket file name too long");
12904 vec_add1 (file_name, 0);
12906 M (CREATE_VHOST_USER_IF, mp);
12908 mp->is_server = is_server;
12909 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
12910 mp->disable_indirect_desc = disable_indirect_desc;
12911 mp->enable_gso = enable_gso;
12912 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12913 vec_free (file_name);
12914 if (custom_dev_instance != ~0)
12917 mp->custom_dev_instance = ntohl (custom_dev_instance);
12920 mp->use_custom_mac = use_custom_mac;
12921 clib_memcpy (mp->mac_address, hwaddr, 6);
12923 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12932 api_modify_vhost_user_if (vat_main_t * vam)
12934 unformat_input_t *i = vam->input;
12935 vl_api_modify_vhost_user_if_t *mp;
12938 u8 file_name_set = 0;
12939 u32 custom_dev_instance = ~0;
12940 u8 sw_if_index_set = 0;
12941 u32 sw_if_index = (u32) ~ 0;
12945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12947 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12948 sw_if_index_set = 1;
12949 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12950 sw_if_index_set = 1;
12951 else if (unformat (i, "socket %s", &file_name))
12955 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12957 else if (unformat (i, "server"))
12959 else if (unformat (i, "gso"))
12965 if (sw_if_index_set == 0)
12967 errmsg ("missing sw_if_index or interface name");
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 (MODIFY_VHOST_USER_IF, mp);
12986 mp->sw_if_index = ntohl (sw_if_index);
12987 mp->is_server = is_server;
12988 mp->enable_gso = enable_gso;
12989 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12990 vec_free (file_name);
12991 if (custom_dev_instance != ~0)
12994 mp->custom_dev_instance = ntohl (custom_dev_instance);
13003 api_delete_vhost_user_if (vat_main_t * vam)
13005 unformat_input_t *i = vam->input;
13006 vl_api_delete_vhost_user_if_t *mp;
13007 u32 sw_if_index = ~0;
13008 u8 sw_if_index_set = 0;
13011 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13013 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13014 sw_if_index_set = 1;
13015 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13016 sw_if_index_set = 1;
13021 if (sw_if_index_set == 0)
13023 errmsg ("missing sw_if_index or interface name");
13028 M (DELETE_VHOST_USER_IF, mp);
13030 mp->sw_if_index = ntohl (sw_if_index);
13037 static void vl_api_sw_interface_vhost_user_details_t_handler
13038 (vl_api_sw_interface_vhost_user_details_t * mp)
13040 vat_main_t *vam = &vat_main;
13042 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13043 (char *) mp->interface_name,
13044 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13045 clib_net_to_host_u64 (mp->features), mp->is_server,
13046 ntohl (mp->num_regions), (char *) mp->sock_filename);
13047 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13050 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13051 (vl_api_sw_interface_vhost_user_details_t * mp)
13053 vat_main_t *vam = &vat_main;
13054 vat_json_node_t *node = NULL;
13056 if (VAT_JSON_ARRAY != vam->json_tree.type)
13058 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13059 vat_json_init_array (&vam->json_tree);
13061 node = vat_json_array_add (&vam->json_tree);
13063 vat_json_init_object (node);
13064 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13065 vat_json_object_add_string_copy (node, "interface_name",
13066 mp->interface_name);
13067 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13068 ntohl (mp->virtio_net_hdr_sz));
13069 vat_json_object_add_uint (node, "features",
13070 clib_net_to_host_u64 (mp->features));
13071 vat_json_object_add_uint (node, "is_server", mp->is_server);
13072 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13073 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13074 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13078 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13080 vl_api_sw_interface_vhost_user_dump_t *mp;
13081 vl_api_control_ping_t *mp_ping;
13084 "Interface name idx hdr_sz features server regions filename");
13086 /* Get list of vhost-user interfaces */
13087 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13090 /* Use a control ping for synchronization */
13091 MPING (CONTROL_PING, mp_ping);
13099 api_show_version (vat_main_t * vam)
13101 vl_api_show_version_t *mp;
13104 M (SHOW_VERSION, mp);
13113 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13115 unformat_input_t *line_input = vam->input;
13116 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13117 ip4_address_t local4, remote4;
13118 ip6_address_t local6, remote6;
13120 u8 ipv4_set = 0, ipv6_set = 0;
13124 u32 mcast_sw_if_index = ~0;
13125 u32 encap_vrf_id = 0;
13126 u32 decap_vrf_id = 0;
13132 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13133 clib_memset (&local4, 0, sizeof local4);
13134 clib_memset (&remote4, 0, sizeof remote4);
13135 clib_memset (&local6, 0, sizeof local6);
13136 clib_memset (&remote6, 0, sizeof remote6);
13138 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13140 if (unformat (line_input, "del"))
13142 else if (unformat (line_input, "local %U",
13143 unformat_ip4_address, &local4))
13148 else if (unformat (line_input, "remote %U",
13149 unformat_ip4_address, &remote4))
13154 else if (unformat (line_input, "local %U",
13155 unformat_ip6_address, &local6))
13160 else if (unformat (line_input, "remote %U",
13161 unformat_ip6_address, &remote6))
13166 else if (unformat (line_input, "group %U %U",
13167 unformat_ip4_address, &remote4,
13168 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13170 grp_set = remote_set = 1;
13173 else if (unformat (line_input, "group %U",
13174 unformat_ip4_address, &remote4))
13176 grp_set = remote_set = 1;
13179 else if (unformat (line_input, "group %U %U",
13180 unformat_ip6_address, &remote6,
13181 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13183 grp_set = remote_set = 1;
13186 else if (unformat (line_input, "group %U",
13187 unformat_ip6_address, &remote6))
13189 grp_set = remote_set = 1;
13193 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13195 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13197 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13199 else if (unformat (line_input, "vni %d", &vni))
13201 else if (unformat (line_input, "next-ip4"))
13203 else if (unformat (line_input, "next-ip6"))
13205 else if (unformat (line_input, "next-ethernet"))
13207 else if (unformat (line_input, "next-nsh"))
13211 errmsg ("parse error '%U'", format_unformat_error, line_input);
13216 if (local_set == 0)
13218 errmsg ("tunnel local address not specified");
13221 if (remote_set == 0)
13223 errmsg ("tunnel remote address not specified");
13226 if (grp_set && mcast_sw_if_index == ~0)
13228 errmsg ("tunnel nonexistent multicast device");
13231 if (ipv4_set && ipv6_set)
13233 errmsg ("both IPv4 and IPv6 addresses specified");
13239 errmsg ("vni not specified");
13243 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13248 clib_memcpy (&mp->local, &local6, sizeof (local6));
13249 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13253 clib_memcpy (&mp->local, &local4, sizeof (local4));
13254 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13257 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13258 mp->encap_vrf_id = ntohl (encap_vrf_id);
13259 mp->decap_vrf_id = ntohl (decap_vrf_id);
13260 mp->protocol = protocol;
13261 mp->vni = ntohl (vni);
13262 mp->is_add = is_add;
13263 mp->is_ipv6 = ipv6_set;
13270 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13271 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13273 vat_main_t *vam = &vat_main;
13274 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13275 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13277 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13278 ntohl (mp->sw_if_index),
13279 format_ip46_address, &local, IP46_TYPE_ANY,
13280 format_ip46_address, &remote, IP46_TYPE_ANY,
13281 ntohl (mp->vni), mp->protocol,
13282 ntohl (mp->mcast_sw_if_index),
13283 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13287 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13288 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13290 vat_main_t *vam = &vat_main;
13291 vat_json_node_t *node = NULL;
13292 struct in_addr ip4;
13293 struct in6_addr ip6;
13295 if (VAT_JSON_ARRAY != vam->json_tree.type)
13297 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13298 vat_json_init_array (&vam->json_tree);
13300 node = vat_json_array_add (&vam->json_tree);
13302 vat_json_init_object (node);
13303 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13306 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13307 vat_json_object_add_ip6 (node, "local", ip6);
13308 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13309 vat_json_object_add_ip6 (node, "remote", ip6);
13313 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13314 vat_json_object_add_ip4 (node, "local", ip4);
13315 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13316 vat_json_object_add_ip4 (node, "remote", ip4);
13318 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13319 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13320 vat_json_object_add_uint (node, "mcast_sw_if_index",
13321 ntohl (mp->mcast_sw_if_index));
13322 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13323 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13324 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13328 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13330 unformat_input_t *i = vam->input;
13331 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13332 vl_api_control_ping_t *mp_ping;
13334 u8 sw_if_index_set = 0;
13337 /* Parse args required to build the message */
13338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13340 if (unformat (i, "sw_if_index %d", &sw_if_index))
13341 sw_if_index_set = 1;
13346 if (sw_if_index_set == 0)
13351 if (!vam->json_output)
13353 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13354 "sw_if_index", "local", "remote", "vni",
13355 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13358 /* Get list of vxlan-tunnel interfaces */
13359 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13361 mp->sw_if_index = htonl (sw_if_index);
13365 /* Use a control ping for synchronization */
13366 MPING (CONTROL_PING, mp_ping);
13373 static void vl_api_l2_fib_table_details_t_handler
13374 (vl_api_l2_fib_table_details_t * mp)
13376 vat_main_t *vam = &vat_main;
13378 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13380 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13381 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13385 static void vl_api_l2_fib_table_details_t_handler_json
13386 (vl_api_l2_fib_table_details_t * mp)
13388 vat_main_t *vam = &vat_main;
13389 vat_json_node_t *node = NULL;
13391 if (VAT_JSON_ARRAY != vam->json_tree.type)
13393 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13394 vat_json_init_array (&vam->json_tree);
13396 node = vat_json_array_add (&vam->json_tree);
13398 vat_json_init_object (node);
13399 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13400 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13401 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13402 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13403 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13404 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13408 api_l2_fib_table_dump (vat_main_t * vam)
13410 unformat_input_t *i = vam->input;
13411 vl_api_l2_fib_table_dump_t *mp;
13412 vl_api_control_ping_t *mp_ping;
13417 /* Parse args required to build the message */
13418 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13420 if (unformat (i, "bd_id %d", &bd_id))
13426 if (bd_id_set == 0)
13428 errmsg ("missing bridge domain");
13432 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13434 /* Get list of l2 fib entries */
13435 M (L2_FIB_TABLE_DUMP, mp);
13437 mp->bd_id = ntohl (bd_id);
13440 /* Use a control ping for synchronization */
13441 MPING (CONTROL_PING, mp_ping);
13450 api_interface_name_renumber (vat_main_t * vam)
13452 unformat_input_t *line_input = vam->input;
13453 vl_api_interface_name_renumber_t *mp;
13454 u32 sw_if_index = ~0;
13455 u32 new_show_dev_instance = ~0;
13458 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13460 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13463 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13465 else if (unformat (line_input, "new_show_dev_instance %d",
13466 &new_show_dev_instance))
13472 if (sw_if_index == ~0)
13474 errmsg ("missing interface name or sw_if_index");
13478 if (new_show_dev_instance == ~0)
13480 errmsg ("missing new_show_dev_instance");
13484 M (INTERFACE_NAME_RENUMBER, mp);
13486 mp->sw_if_index = ntohl (sw_if_index);
13487 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13495 api_ip_probe_neighbor (vat_main_t * vam)
13497 unformat_input_t *i = vam->input;
13498 vl_api_ip_probe_neighbor_t *mp;
13499 vl_api_address_t dst_adr = { };
13505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13507 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13509 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13511 else if (unformat (i, "address %U", unformat_vl_api_address, &dst_adr))
13519 errmsg ("missing interface");
13525 errmsg ("missing addresses");
13529 M (IP_PROBE_NEIGHBOR, mp);
13531 mp->sw_if_index = ntohl (sw_if_index);
13532 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
13540 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
13542 unformat_input_t *i = vam->input;
13543 vl_api_ip_scan_neighbor_enable_disable_t *mp;
13544 u8 mode = IP_SCAN_V46_NEIGHBORS;
13545 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
13548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13550 if (unformat (i, "ip4"))
13551 mode = IP_SCAN_V4_NEIGHBORS;
13552 else if (unformat (i, "ip6"))
13553 mode = IP_SCAN_V6_NEIGHBORS;
13554 if (unformat (i, "both"))
13555 mode = IP_SCAN_V46_NEIGHBORS;
13556 else if (unformat (i, "disable"))
13557 mode = IP_SCAN_DISABLED;
13558 else if (unformat (i, "interval %d", &interval))
13560 else if (unformat (i, "max-time %d", &time))
13562 else if (unformat (i, "max-update %d", &update))
13564 else if (unformat (i, "delay %d", &delay))
13566 else if (unformat (i, "stale %d", &stale))
13572 if (interval > 255)
13574 errmsg ("interval cannot exceed 255 minutes.");
13579 errmsg ("max-time cannot exceed 255 usec.");
13584 errmsg ("max-update cannot exceed 255.");
13589 errmsg ("delay cannot exceed 255 msec.");
13594 errmsg ("stale cannot exceed 255 minutes.");
13598 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
13600 mp->scan_interval = interval;
13601 mp->max_proc_time = time;
13602 mp->max_update = update;
13603 mp->scan_int_delay = delay;
13604 mp->stale_threshold = stale;
13612 api_want_ip4_arp_events (vat_main_t * vam)
13614 unformat_input_t *line_input = vam->input;
13615 vl_api_want_ip4_arp_events_t *mp;
13616 ip4_address_t address;
13617 int address_set = 0;
13618 u32 enable_disable = 1;
13621 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13623 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13625 else if (unformat (line_input, "del"))
13626 enable_disable = 0;
13631 if (address_set == 0)
13633 errmsg ("missing addresses");
13637 M (WANT_IP4_ARP_EVENTS, mp);
13638 mp->enable_disable = enable_disable;
13639 mp->pid = htonl (getpid ());
13640 clib_memcpy (mp->ip, &address, sizeof (address));
13648 api_want_ip6_nd_events (vat_main_t * vam)
13650 unformat_input_t *line_input = vam->input;
13651 vl_api_want_ip6_nd_events_t *mp;
13652 vl_api_ip6_address_t address;
13653 int address_set = 0;
13654 u32 enable_disable = 1;
13657 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13660 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
13662 else if (unformat (line_input, "del"))
13663 enable_disable = 0;
13668 if (address_set == 0)
13670 errmsg ("missing addresses");
13674 M (WANT_IP6_ND_EVENTS, mp);
13675 mp->enable_disable = enable_disable;
13676 mp->pid = htonl (getpid ());
13677 clib_memcpy (&mp->ip, &address, sizeof (address));
13685 api_want_l2_macs_events (vat_main_t * vam)
13687 unformat_input_t *line_input = vam->input;
13688 vl_api_want_l2_macs_events_t *mp;
13689 u8 enable_disable = 1;
13690 u32 scan_delay = 0;
13691 u32 max_macs_in_event = 0;
13692 u32 learn_limit = 0;
13695 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13697 if (unformat (line_input, "learn-limit %d", &learn_limit))
13699 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13701 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13703 else if (unformat (line_input, "disable"))
13704 enable_disable = 0;
13709 M (WANT_L2_MACS_EVENTS, mp);
13710 mp->enable_disable = enable_disable;
13711 mp->pid = htonl (getpid ());
13712 mp->learn_limit = htonl (learn_limit);
13713 mp->scan_delay = (u8) scan_delay;
13714 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13721 api_input_acl_set_interface (vat_main_t * vam)
13723 unformat_input_t *i = vam->input;
13724 vl_api_input_acl_set_interface_t *mp;
13726 int sw_if_index_set;
13727 u32 ip4_table_index = ~0;
13728 u32 ip6_table_index = ~0;
13729 u32 l2_table_index = ~0;
13733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13735 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13736 sw_if_index_set = 1;
13737 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13738 sw_if_index_set = 1;
13739 else if (unformat (i, "del"))
13741 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13743 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13745 else if (unformat (i, "l2-table %d", &l2_table_index))
13749 clib_warning ("parse error '%U'", format_unformat_error, i);
13754 if (sw_if_index_set == 0)
13756 errmsg ("missing interface name or sw_if_index");
13760 M (INPUT_ACL_SET_INTERFACE, mp);
13762 mp->sw_if_index = ntohl (sw_if_index);
13763 mp->ip4_table_index = ntohl (ip4_table_index);
13764 mp->ip6_table_index = ntohl (ip6_table_index);
13765 mp->l2_table_index = ntohl (l2_table_index);
13766 mp->is_add = is_add;
13774 api_output_acl_set_interface (vat_main_t * vam)
13776 unformat_input_t *i = vam->input;
13777 vl_api_output_acl_set_interface_t *mp;
13779 int sw_if_index_set;
13780 u32 ip4_table_index = ~0;
13781 u32 ip6_table_index = ~0;
13782 u32 l2_table_index = ~0;
13786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13788 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13789 sw_if_index_set = 1;
13790 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13791 sw_if_index_set = 1;
13792 else if (unformat (i, "del"))
13794 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13796 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13798 else if (unformat (i, "l2-table %d", &l2_table_index))
13802 clib_warning ("parse error '%U'", format_unformat_error, i);
13807 if (sw_if_index_set == 0)
13809 errmsg ("missing interface name or sw_if_index");
13813 M (OUTPUT_ACL_SET_INTERFACE, mp);
13815 mp->sw_if_index = ntohl (sw_if_index);
13816 mp->ip4_table_index = ntohl (ip4_table_index);
13817 mp->ip6_table_index = ntohl (ip6_table_index);
13818 mp->l2_table_index = ntohl (l2_table_index);
13819 mp->is_add = is_add;
13827 api_ip_address_dump (vat_main_t * vam)
13829 unformat_input_t *i = vam->input;
13830 vl_api_ip_address_dump_t *mp;
13831 vl_api_control_ping_t *mp_ping;
13832 u32 sw_if_index = ~0;
13833 u8 sw_if_index_set = 0;
13838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13840 if (unformat (i, "sw_if_index %d", &sw_if_index))
13841 sw_if_index_set = 1;
13843 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13844 sw_if_index_set = 1;
13845 else if (unformat (i, "ipv4"))
13847 else if (unformat (i, "ipv6"))
13853 if (ipv4_set && ipv6_set)
13855 errmsg ("ipv4 and ipv6 flags cannot be both set");
13859 if ((!ipv4_set) && (!ipv6_set))
13861 errmsg ("no ipv4 nor ipv6 flag set");
13865 if (sw_if_index_set == 0)
13867 errmsg ("missing interface name or sw_if_index");
13871 vam->current_sw_if_index = sw_if_index;
13872 vam->is_ipv6 = ipv6_set;
13874 M (IP_ADDRESS_DUMP, mp);
13875 mp->sw_if_index = ntohl (sw_if_index);
13876 mp->is_ipv6 = ipv6_set;
13879 /* Use a control ping for synchronization */
13880 MPING (CONTROL_PING, mp_ping);
13888 api_ip_dump (vat_main_t * vam)
13890 vl_api_ip_dump_t *mp;
13891 vl_api_control_ping_t *mp_ping;
13892 unformat_input_t *in = vam->input;
13899 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13901 if (unformat (in, "ipv4"))
13903 else if (unformat (in, "ipv6"))
13909 if (ipv4_set && ipv6_set)
13911 errmsg ("ipv4 and ipv6 flags cannot be both set");
13915 if ((!ipv4_set) && (!ipv6_set))
13917 errmsg ("no ipv4 nor ipv6 flag set");
13921 is_ipv6 = ipv6_set;
13922 vam->is_ipv6 = is_ipv6;
13924 /* free old data */
13925 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13927 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13929 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13932 mp->is_ipv6 = ipv6_set;
13935 /* Use a control ping for synchronization */
13936 MPING (CONTROL_PING, mp_ping);
13944 api_ipsec_spd_add_del (vat_main_t * vam)
13946 unformat_input_t *i = vam->input;
13947 vl_api_ipsec_spd_add_del_t *mp;
13952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13954 if (unformat (i, "spd_id %d", &spd_id))
13956 else if (unformat (i, "del"))
13960 clib_warning ("parse error '%U'", format_unformat_error, i);
13966 errmsg ("spd_id must be set");
13970 M (IPSEC_SPD_ADD_DEL, mp);
13972 mp->spd_id = ntohl (spd_id);
13973 mp->is_add = is_add;
13981 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13983 unformat_input_t *i = vam->input;
13984 vl_api_ipsec_interface_add_del_spd_t *mp;
13986 u8 sw_if_index_set = 0;
13987 u32 spd_id = (u32) ~ 0;
13991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13993 if (unformat (i, "del"))
13995 else if (unformat (i, "spd_id %d", &spd_id))
13998 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13999 sw_if_index_set = 1;
14000 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14001 sw_if_index_set = 1;
14004 clib_warning ("parse error '%U'", format_unformat_error, i);
14010 if (spd_id == (u32) ~ 0)
14012 errmsg ("spd_id must be set");
14016 if (sw_if_index_set == 0)
14018 errmsg ("missing interface name or sw_if_index");
14022 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14024 mp->spd_id = ntohl (spd_id);
14025 mp->sw_if_index = ntohl (sw_if_index);
14026 mp->is_add = is_add;
14034 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14036 unformat_input_t *i = vam->input;
14037 vl_api_ipsec_spd_entry_add_del_t *mp;
14038 u8 is_add = 1, is_outbound = 0;
14039 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14041 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14042 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14043 vl_api_address_t laddr_start = { }, laddr_stop =
14052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14054 if (unformat (i, "del"))
14056 if (unformat (i, "outbound"))
14058 if (unformat (i, "inbound"))
14060 else if (unformat (i, "spd_id %d", &spd_id))
14062 else if (unformat (i, "sa_id %d", &sa_id))
14064 else if (unformat (i, "priority %d", &priority))
14066 else if (unformat (i, "protocol %d", &protocol))
14068 else if (unformat (i, "lport_start %d", &lport_start))
14070 else if (unformat (i, "lport_stop %d", &lport_stop))
14072 else if (unformat (i, "rport_start %d", &rport_start))
14074 else if (unformat (i, "rport_stop %d", &rport_stop))
14076 else if (unformat (i, "laddr_start %U",
14077 unformat_vl_api_address, &laddr_start))
14079 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14082 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14085 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14089 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14091 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14093 clib_warning ("unsupported action: 'resolve'");
14099 clib_warning ("parse error '%U'", format_unformat_error, i);
14105 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14107 mp->is_add = is_add;
14109 mp->entry.spd_id = ntohl (spd_id);
14110 mp->entry.priority = ntohl (priority);
14111 mp->entry.is_outbound = is_outbound;
14113 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14114 sizeof (vl_api_address_t));
14115 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14116 sizeof (vl_api_address_t));
14117 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14118 sizeof (vl_api_address_t));
14119 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14120 sizeof (vl_api_address_t));
14122 mp->entry.protocol = (u8) protocol;
14123 mp->entry.local_port_start = ntohs ((u16) lport_start);
14124 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14125 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14126 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14127 mp->entry.policy = (u8) policy;
14128 mp->entry.sa_id = ntohl (sa_id);
14136 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14138 unformat_input_t *i = vam->input;
14139 vl_api_ipsec_sad_entry_add_del_t *mp;
14140 u32 sad_id = 0, spi = 0;
14141 u8 *ck = 0, *ik = 0;
14144 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14145 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14146 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14147 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14148 vl_api_address_t tun_src, tun_dst;
14151 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14153 if (unformat (i, "del"))
14155 else if (unformat (i, "sad_id %d", &sad_id))
14157 else if (unformat (i, "spi %d", &spi))
14159 else if (unformat (i, "esp"))
14160 protocol = IPSEC_API_PROTO_ESP;
14162 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14164 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14165 if (ADDRESS_IP6 == tun_src.af)
14166 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14169 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14171 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14172 if (ADDRESS_IP6 == tun_src.af)
14173 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14176 if (unformat (i, "crypto_alg %U",
14177 unformat_ipsec_api_crypto_alg, &crypto_alg))
14179 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14181 else if (unformat (i, "integ_alg %U",
14182 unformat_ipsec_api_integ_alg, &integ_alg))
14184 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14188 clib_warning ("parse error '%U'", format_unformat_error, i);
14194 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14196 mp->is_add = is_add;
14197 mp->entry.sad_id = ntohl (sad_id);
14198 mp->entry.protocol = protocol;
14199 mp->entry.spi = ntohl (spi);
14200 mp->entry.flags = flags;
14202 mp->entry.crypto_algorithm = crypto_alg;
14203 mp->entry.integrity_algorithm = integ_alg;
14204 mp->entry.crypto_key.length = vec_len (ck);
14205 mp->entry.integrity_key.length = vec_len (ik);
14207 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14208 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14210 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14211 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14214 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14216 clib_memcpy (mp->entry.integrity_key.data, ik,
14217 mp->entry.integrity_key.length);
14219 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14221 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14222 sizeof (mp->entry.tunnel_src));
14223 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14224 sizeof (mp->entry.tunnel_dst));
14233 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14235 unformat_input_t *i = vam->input;
14236 vl_api_ipsec_tunnel_if_add_del_t *mp;
14237 u32 local_spi = 0, remote_spi = 0;
14238 u32 crypto_alg = 0, integ_alg = 0;
14239 u8 *lck = NULL, *rck = NULL;
14240 u8 *lik = NULL, *rik = NULL;
14241 vl_api_address_t local_ip = { 0 };
14242 vl_api_address_t remote_ip = { 0 };
14246 u8 anti_replay = 0;
14252 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14254 if (unformat (i, "del"))
14256 else if (unformat (i, "esn"))
14258 else if (unformat (i, "anti-replay"))
14260 else if (unformat (i, "count %d", &count))
14262 else if (unformat (i, "local_spi %d", &local_spi))
14264 else if (unformat (i, "remote_spi %d", &remote_spi))
14267 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
14270 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
14272 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14275 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14277 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14279 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14283 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
14285 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
14287 errmsg ("unsupported crypto-alg: '%U'\n",
14288 format_ipsec_crypto_alg, crypto_alg);
14294 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
14296 if (integ_alg >= IPSEC_INTEG_N_ALG)
14298 errmsg ("unsupported integ-alg: '%U'\n",
14299 format_ipsec_integ_alg, integ_alg);
14303 else if (unformat (i, "instance %u", &instance))
14307 errmsg ("parse error '%U'\n", format_unformat_error, i);
14314 /* Turn on async mode */
14315 vam->async_mode = 1;
14316 vam->async_errors = 0;
14317 before = vat_time_now (vam);
14320 for (jj = 0; jj < count; jj++)
14322 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14324 mp->is_add = is_add;
14326 mp->anti_replay = anti_replay;
14329 increment_address (&remote_ip);
14331 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
14332 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
14334 mp->local_spi = htonl (local_spi + jj);
14335 mp->remote_spi = htonl (remote_spi + jj);
14336 mp->crypto_alg = (u8) crypto_alg;
14338 mp->local_crypto_key_len = 0;
14341 mp->local_crypto_key_len = vec_len (lck);
14342 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14343 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14344 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14347 mp->remote_crypto_key_len = 0;
14350 mp->remote_crypto_key_len = vec_len (rck);
14351 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14352 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14353 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14356 mp->integ_alg = (u8) integ_alg;
14358 mp->local_integ_key_len = 0;
14361 mp->local_integ_key_len = vec_len (lik);
14362 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14363 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14364 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14367 mp->remote_integ_key_len = 0;
14370 mp->remote_integ_key_len = vec_len (rik);
14371 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14372 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14373 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14378 mp->renumber = renumber;
14379 mp->show_instance = ntohl (instance);
14384 /* When testing multiple add/del ops, use a control-ping to sync */
14387 vl_api_control_ping_t *mp_ping;
14391 /* Shut off async mode */
14392 vam->async_mode = 0;
14394 MPING (CONTROL_PING, mp_ping);
14397 timeout = vat_time_now (vam) + 1.0;
14398 while (vat_time_now (vam) < timeout)
14399 if (vam->result_ready == 1)
14404 if (vam->retval == -99)
14405 errmsg ("timeout");
14407 if (vam->async_errors > 0)
14409 errmsg ("%d asynchronous errors", vam->async_errors);
14412 vam->async_errors = 0;
14413 after = vat_time_now (vam);
14415 /* slim chance, but we might have eaten SIGTERM on the first iteration */
14419 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
14420 count, after - before, count / (after - before));
14424 /* Wait for a reply... */
14433 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14435 vat_main_t *vam = &vat_main;
14437 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14438 "crypto_key %U integ_alg %u integ_key %U flags %x "
14439 "tunnel_src_addr %U tunnel_dst_addr %U "
14440 "salt %u seq_outbound %lu last_seq_inbound %lu "
14441 "replay_window %lu\n",
14442 ntohl (mp->entry.sad_id),
14443 ntohl (mp->sw_if_index),
14444 ntohl (mp->entry.spi),
14445 ntohl (mp->entry.protocol),
14446 ntohl (mp->entry.crypto_algorithm),
14447 format_hex_bytes, mp->entry.crypto_key.data,
14448 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
14449 format_hex_bytes, mp->entry.integrity_key.data,
14450 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
14451 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
14452 &mp->entry.tunnel_dst, ntohl (mp->salt),
14453 clib_net_to_host_u64 (mp->seq_outbound),
14454 clib_net_to_host_u64 (mp->last_seq_inbound),
14455 clib_net_to_host_u64 (mp->replay_window));
14458 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14459 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14461 static void vl_api_ipsec_sa_details_t_handler_json
14462 (vl_api_ipsec_sa_details_t * mp)
14464 vat_main_t *vam = &vat_main;
14465 vat_json_node_t *node = NULL;
14466 vl_api_ipsec_sad_flags_t flags;
14468 if (VAT_JSON_ARRAY != vam->json_tree.type)
14470 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14471 vat_json_init_array (&vam->json_tree);
14473 node = vat_json_array_add (&vam->json_tree);
14475 vat_json_init_object (node);
14476 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
14477 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14478 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
14479 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
14480 vat_json_object_add_uint (node, "crypto_alg",
14481 ntohl (mp->entry.crypto_algorithm));
14482 vat_json_object_add_uint (node, "integ_alg",
14483 ntohl (mp->entry.integrity_algorithm));
14484 flags = ntohl (mp->entry.flags);
14485 vat_json_object_add_uint (node, "use_esn",
14486 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
14487 vat_json_object_add_uint (node, "use_anti_replay",
14488 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
14489 vat_json_object_add_uint (node, "is_tunnel",
14490 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
14491 vat_json_object_add_uint (node, "is_tunnel_ip6",
14492 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
14493 vat_json_object_add_uint (node, "udp_encap",
14494 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
14495 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
14496 mp->entry.crypto_key.length);
14497 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
14498 mp->entry.integrity_key.length);
14499 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
14500 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
14501 vat_json_object_add_uint (node, "replay_window",
14502 clib_net_to_host_u64 (mp->replay_window));
14506 api_ipsec_sa_dump (vat_main_t * vam)
14508 unformat_input_t *i = vam->input;
14509 vl_api_ipsec_sa_dump_t *mp;
14510 vl_api_control_ping_t *mp_ping;
14514 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14516 if (unformat (i, "sa_id %d", &sa_id))
14520 clib_warning ("parse error '%U'", format_unformat_error, i);
14525 M (IPSEC_SA_DUMP, mp);
14527 mp->sa_id = ntohl (sa_id);
14531 /* Use a control ping for synchronization */
14532 M (CONTROL_PING, mp_ping);
14540 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14542 unformat_input_t *i = vam->input;
14543 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14544 u32 sw_if_index = ~0;
14546 u8 is_outbound = (u8) ~ 0;
14549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14551 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14553 else if (unformat (i, "sa_id %d", &sa_id))
14555 else if (unformat (i, "outbound"))
14557 else if (unformat (i, "inbound"))
14561 clib_warning ("parse error '%U'", format_unformat_error, i);
14566 if (sw_if_index == ~0)
14568 errmsg ("interface must be specified");
14574 errmsg ("SA ID must be specified");
14578 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14580 mp->sw_if_index = htonl (sw_if_index);
14581 mp->sa_id = htonl (sa_id);
14582 mp->is_outbound = is_outbound;
14591 api_get_first_msg_id (vat_main_t * vam)
14593 vl_api_get_first_msg_id_t *mp;
14594 unformat_input_t *i = vam->input;
14599 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14601 if (unformat (i, "client %s", &name))
14609 errmsg ("missing client name");
14612 vec_add1 (name, 0);
14614 if (vec_len (name) > 63)
14616 errmsg ("client name too long");
14620 M (GET_FIRST_MSG_ID, mp);
14621 clib_memcpy (mp->name, name, vec_len (name));
14628 api_cop_interface_enable_disable (vat_main_t * vam)
14630 unformat_input_t *line_input = vam->input;
14631 vl_api_cop_interface_enable_disable_t *mp;
14632 u32 sw_if_index = ~0;
14633 u8 enable_disable = 1;
14636 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14638 if (unformat (line_input, "disable"))
14639 enable_disable = 0;
14640 if (unformat (line_input, "enable"))
14641 enable_disable = 1;
14642 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14643 vam, &sw_if_index))
14645 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14651 if (sw_if_index == ~0)
14653 errmsg ("missing interface name or sw_if_index");
14657 /* Construct the API message */
14658 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14659 mp->sw_if_index = ntohl (sw_if_index);
14660 mp->enable_disable = enable_disable;
14664 /* Wait for the reply */
14670 api_cop_whitelist_enable_disable (vat_main_t * vam)
14672 unformat_input_t *line_input = vam->input;
14673 vl_api_cop_whitelist_enable_disable_t *mp;
14674 u32 sw_if_index = ~0;
14675 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14679 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14681 if (unformat (line_input, "ip4"))
14683 else if (unformat (line_input, "ip6"))
14685 else if (unformat (line_input, "default"))
14687 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14688 vam, &sw_if_index))
14690 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14692 else if (unformat (line_input, "fib-id %d", &fib_id))
14698 if (sw_if_index == ~0)
14700 errmsg ("missing interface name or sw_if_index");
14704 /* Construct the API message */
14705 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14706 mp->sw_if_index = ntohl (sw_if_index);
14707 mp->fib_id = ntohl (fib_id);
14710 mp->default_cop = default_cop;
14714 /* Wait for the reply */
14720 api_get_node_graph (vat_main_t * vam)
14722 vl_api_get_node_graph_t *mp;
14725 M (GET_NODE_GRAPH, mp);
14729 /* Wait for the reply */
14735 /** Used for parsing LISP eids */
14736 typedef CLIB_PACKED(struct{
14737 u8 addr[16]; /**< eid address */
14738 u32 len; /**< prefix length if IP */
14739 u8 type; /**< type of eid */
14744 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14746 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14748 clib_memset (a, 0, sizeof (a[0]));
14750 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14752 a->type = 0; /* ipv4 type */
14754 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14756 a->type = 1; /* ipv6 type */
14758 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14760 a->type = 2; /* mac type */
14762 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14764 a->type = 3; /* NSH type */
14765 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14766 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14773 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14782 lisp_eid_size_vat (u8 type)
14799 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14801 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14805 api_one_add_del_locator_set (vat_main_t * vam)
14807 unformat_input_t *input = vam->input;
14808 vl_api_one_add_del_locator_set_t *mp;
14810 u8 *locator_set_name = NULL;
14811 u8 locator_set_name_set = 0;
14812 vl_api_local_locator_t locator, *locators = 0;
14813 u32 sw_if_index, priority, weight;
14817 /* Parse args required to build the message */
14818 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14820 if (unformat (input, "del"))
14824 else if (unformat (input, "locator-set %s", &locator_set_name))
14826 locator_set_name_set = 1;
14828 else if (unformat (input, "sw_if_index %u p %u w %u",
14829 &sw_if_index, &priority, &weight))
14831 locator.sw_if_index = htonl (sw_if_index);
14832 locator.priority = priority;
14833 locator.weight = weight;
14834 vec_add1 (locators, locator);
14838 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14839 &sw_if_index, &priority, &weight))
14841 locator.sw_if_index = htonl (sw_if_index);
14842 locator.priority = priority;
14843 locator.weight = weight;
14844 vec_add1 (locators, locator);
14850 if (locator_set_name_set == 0)
14852 errmsg ("missing locator-set name");
14853 vec_free (locators);
14857 if (vec_len (locator_set_name) > 64)
14859 errmsg ("locator-set name too long");
14860 vec_free (locator_set_name);
14861 vec_free (locators);
14864 vec_add1 (locator_set_name, 0);
14866 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14868 /* Construct the API message */
14869 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14871 mp->is_add = is_add;
14872 clib_memcpy (mp->locator_set_name, locator_set_name,
14873 vec_len (locator_set_name));
14874 vec_free (locator_set_name);
14876 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14878 clib_memcpy (mp->locators, locators, data_len);
14879 vec_free (locators);
14884 /* Wait for a reply... */
14889 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14892 api_one_add_del_locator (vat_main_t * vam)
14894 unformat_input_t *input = vam->input;
14895 vl_api_one_add_del_locator_t *mp;
14896 u32 tmp_if_index = ~0;
14897 u32 sw_if_index = ~0;
14898 u8 sw_if_index_set = 0;
14899 u8 sw_if_index_if_name_set = 0;
14901 u8 priority_set = 0;
14905 u8 *locator_set_name = NULL;
14906 u8 locator_set_name_set = 0;
14909 /* Parse args required to build the message */
14910 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14912 if (unformat (input, "del"))
14916 else if (unformat (input, "locator-set %s", &locator_set_name))
14918 locator_set_name_set = 1;
14920 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14923 sw_if_index_if_name_set = 1;
14924 sw_if_index = tmp_if_index;
14926 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14928 sw_if_index_set = 1;
14929 sw_if_index = tmp_if_index;
14931 else if (unformat (input, "p %d", &priority))
14935 else if (unformat (input, "w %d", &weight))
14943 if (locator_set_name_set == 0)
14945 errmsg ("missing locator-set name");
14949 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14951 errmsg ("missing sw_if_index");
14952 vec_free (locator_set_name);
14956 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14958 errmsg ("cannot use both params interface name and sw_if_index");
14959 vec_free (locator_set_name);
14963 if (priority_set == 0)
14965 errmsg ("missing locator-set priority");
14966 vec_free (locator_set_name);
14970 if (weight_set == 0)
14972 errmsg ("missing locator-set weight");
14973 vec_free (locator_set_name);
14977 if (vec_len (locator_set_name) > 64)
14979 errmsg ("locator-set name too long");
14980 vec_free (locator_set_name);
14983 vec_add1 (locator_set_name, 0);
14985 /* Construct the API message */
14986 M (ONE_ADD_DEL_LOCATOR, mp);
14988 mp->is_add = is_add;
14989 mp->sw_if_index = ntohl (sw_if_index);
14990 mp->priority = priority;
14991 mp->weight = weight;
14992 clib_memcpy (mp->locator_set_name, locator_set_name,
14993 vec_len (locator_set_name));
14994 vec_free (locator_set_name);
14999 /* Wait for a reply... */
15004 #define api_lisp_add_del_locator api_one_add_del_locator
15007 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15009 u32 *key_id = va_arg (*args, u32 *);
15012 if (unformat (input, "%s", &s))
15014 if (!strcmp ((char *) s, "sha1"))
15015 key_id[0] = HMAC_SHA_1_96;
15016 else if (!strcmp ((char *) s, "sha256"))
15017 key_id[0] = HMAC_SHA_256_128;
15020 clib_warning ("invalid key_id: '%s'", s);
15021 key_id[0] = HMAC_NO_KEY;
15032 api_one_add_del_local_eid (vat_main_t * vam)
15034 unformat_input_t *input = vam->input;
15035 vl_api_one_add_del_local_eid_t *mp;
15038 lisp_eid_vat_t _eid, *eid = &_eid;
15039 u8 *locator_set_name = 0;
15040 u8 locator_set_name_set = 0;
15046 /* Parse args required to build the message */
15047 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15049 if (unformat (input, "del"))
15053 else if (unformat (input, "vni %d", &vni))
15057 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15061 else if (unformat (input, "locator-set %s", &locator_set_name))
15063 locator_set_name_set = 1;
15065 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15067 else if (unformat (input, "secret-key %_%v%_", &key))
15073 if (locator_set_name_set == 0)
15075 errmsg ("missing locator-set name");
15081 errmsg ("EID address not set!");
15082 vec_free (locator_set_name);
15086 if (key && (0 == key_id))
15088 errmsg ("invalid key_id!");
15092 if (vec_len (key) > 64)
15094 errmsg ("key too long");
15099 if (vec_len (locator_set_name) > 64)
15101 errmsg ("locator-set name too long");
15102 vec_free (locator_set_name);
15105 vec_add1 (locator_set_name, 0);
15107 /* Construct the API message */
15108 M (ONE_ADD_DEL_LOCAL_EID, mp);
15110 mp->is_add = is_add;
15111 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15112 mp->eid_type = eid->type;
15113 mp->prefix_len = eid->len;
15114 mp->vni = clib_host_to_net_u32 (vni);
15115 mp->key_id = clib_host_to_net_u16 (key_id);
15116 clib_memcpy (mp->locator_set_name, locator_set_name,
15117 vec_len (locator_set_name));
15118 clib_memcpy (mp->key, key, vec_len (key));
15120 vec_free (locator_set_name);
15126 /* Wait for a reply... */
15131 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15134 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15136 u32 dp_table = 0, vni = 0;;
15137 unformat_input_t *input = vam->input;
15138 vl_api_gpe_add_del_fwd_entry_t *mp;
15140 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15141 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15142 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15143 u32 action = ~0, w;
15144 ip4_address_t rmt_rloc4, lcl_rloc4;
15145 ip6_address_t rmt_rloc6, lcl_rloc6;
15146 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15149 clib_memset (&rloc, 0, sizeof (rloc));
15151 /* Parse args required to build the message */
15152 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15154 if (unformat (input, "del"))
15156 else if (unformat (input, "add"))
15158 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15162 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15166 else if (unformat (input, "vrf %d", &dp_table))
15168 else if (unformat (input, "bd %d", &dp_table))
15170 else if (unformat (input, "vni %d", &vni))
15172 else if (unformat (input, "w %d", &w))
15176 errmsg ("No RLOC configured for setting priority/weight!");
15179 curr_rloc->weight = w;
15181 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15182 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15186 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15188 vec_add1 (lcl_locs, rloc);
15190 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15191 vec_add1 (rmt_locs, rloc);
15192 /* weight saved in rmt loc */
15193 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15195 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15196 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15199 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15201 vec_add1 (lcl_locs, rloc);
15203 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15204 vec_add1 (rmt_locs, rloc);
15205 /* weight saved in rmt loc */
15206 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15208 else if (unformat (input, "action %d", &action))
15214 clib_warning ("parse error '%U'", format_unformat_error, input);
15221 errmsg ("remote eid addresses not set");
15225 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15227 errmsg ("eid types don't match");
15231 if (0 == rmt_locs && (u32) ~ 0 == action)
15233 errmsg ("action not set for negative mapping");
15237 /* Construct the API message */
15238 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15239 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15241 mp->is_add = is_add;
15242 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15243 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15244 mp->eid_type = rmt_eid->type;
15245 mp->dp_table = clib_host_to_net_u32 (dp_table);
15246 mp->vni = clib_host_to_net_u32 (vni);
15247 mp->rmt_len = rmt_eid->len;
15248 mp->lcl_len = lcl_eid->len;
15249 mp->action = action;
15251 if (0 != rmt_locs && 0 != lcl_locs)
15253 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15254 clib_memcpy (mp->locs, lcl_locs,
15255 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15257 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15258 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15259 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15261 vec_free (lcl_locs);
15262 vec_free (rmt_locs);
15267 /* Wait for a reply... */
15273 api_one_add_del_map_server (vat_main_t * vam)
15275 unformat_input_t *input = vam->input;
15276 vl_api_one_add_del_map_server_t *mp;
15280 ip4_address_t ipv4;
15281 ip6_address_t ipv6;
15284 /* Parse args required to build the message */
15285 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15287 if (unformat (input, "del"))
15291 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15295 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15303 if (ipv4_set && ipv6_set)
15305 errmsg ("both eid v4 and v6 addresses set");
15309 if (!ipv4_set && !ipv6_set)
15311 errmsg ("eid addresses not set");
15315 /* Construct the API message */
15316 M (ONE_ADD_DEL_MAP_SERVER, mp);
15318 mp->is_add = is_add;
15322 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15327 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15333 /* Wait for a reply... */
15338 #define api_lisp_add_del_map_server api_one_add_del_map_server
15341 api_one_add_del_map_resolver (vat_main_t * vam)
15343 unformat_input_t *input = vam->input;
15344 vl_api_one_add_del_map_resolver_t *mp;
15348 ip4_address_t ipv4;
15349 ip6_address_t ipv6;
15352 /* Parse args required to build the message */
15353 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15355 if (unformat (input, "del"))
15359 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15363 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15371 if (ipv4_set && ipv6_set)
15373 errmsg ("both eid v4 and v6 addresses set");
15377 if (!ipv4_set && !ipv6_set)
15379 errmsg ("eid addresses not set");
15383 /* Construct the API message */
15384 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15386 mp->is_add = is_add;
15390 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15395 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15401 /* Wait for a reply... */
15406 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15409 api_lisp_gpe_enable_disable (vat_main_t * vam)
15411 unformat_input_t *input = vam->input;
15412 vl_api_gpe_enable_disable_t *mp;
15417 /* Parse args required to build the message */
15418 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15420 if (unformat (input, "enable"))
15425 else if (unformat (input, "disable"))
15436 errmsg ("Value not set");
15440 /* Construct the API message */
15441 M (GPE_ENABLE_DISABLE, mp);
15448 /* Wait for a reply... */
15454 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15456 unformat_input_t *input = vam->input;
15457 vl_api_one_rloc_probe_enable_disable_t *mp;
15462 /* Parse args required to build the message */
15463 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15465 if (unformat (input, "enable"))
15470 else if (unformat (input, "disable"))
15478 errmsg ("Value not set");
15482 /* Construct the API message */
15483 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15485 mp->is_enabled = is_en;
15490 /* Wait for a reply... */
15495 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15498 api_one_map_register_enable_disable (vat_main_t * vam)
15500 unformat_input_t *input = vam->input;
15501 vl_api_one_map_register_enable_disable_t *mp;
15506 /* Parse args required to build the message */
15507 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15509 if (unformat (input, "enable"))
15514 else if (unformat (input, "disable"))
15522 errmsg ("Value not set");
15526 /* Construct the API message */
15527 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15529 mp->is_enabled = is_en;
15534 /* Wait for a reply... */
15539 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15542 api_one_enable_disable (vat_main_t * vam)
15544 unformat_input_t *input = vam->input;
15545 vl_api_one_enable_disable_t *mp;
15550 /* Parse args required to build the message */
15551 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15553 if (unformat (input, "enable"))
15558 else if (unformat (input, "disable"))
15568 errmsg ("Value not set");
15572 /* Construct the API message */
15573 M (ONE_ENABLE_DISABLE, mp);
15580 /* Wait for a reply... */
15585 #define api_lisp_enable_disable api_one_enable_disable
15588 api_one_enable_disable_xtr_mode (vat_main_t * vam)
15590 unformat_input_t *input = vam->input;
15591 vl_api_one_enable_disable_xtr_mode_t *mp;
15596 /* Parse args required to build the message */
15597 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15599 if (unformat (input, "enable"))
15604 else if (unformat (input, "disable"))
15614 errmsg ("Value not set");
15618 /* Construct the API message */
15619 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
15626 /* Wait for a reply... */
15632 api_one_show_xtr_mode (vat_main_t * vam)
15634 vl_api_one_show_xtr_mode_t *mp;
15637 /* Construct the API message */
15638 M (ONE_SHOW_XTR_MODE, mp);
15643 /* Wait for a reply... */
15649 api_one_enable_disable_pitr_mode (vat_main_t * vam)
15651 unformat_input_t *input = vam->input;
15652 vl_api_one_enable_disable_pitr_mode_t *mp;
15657 /* Parse args required to build the message */
15658 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15660 if (unformat (input, "enable"))
15665 else if (unformat (input, "disable"))
15675 errmsg ("Value not set");
15679 /* Construct the API message */
15680 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
15687 /* Wait for a reply... */
15693 api_one_show_pitr_mode (vat_main_t * vam)
15695 vl_api_one_show_pitr_mode_t *mp;
15698 /* Construct the API message */
15699 M (ONE_SHOW_PITR_MODE, mp);
15704 /* Wait for a reply... */
15710 api_one_enable_disable_petr_mode (vat_main_t * vam)
15712 unformat_input_t *input = vam->input;
15713 vl_api_one_enable_disable_petr_mode_t *mp;
15718 /* Parse args required to build the message */
15719 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15721 if (unformat (input, "enable"))
15726 else if (unformat (input, "disable"))
15736 errmsg ("Value not set");
15740 /* Construct the API message */
15741 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
15748 /* Wait for a reply... */
15754 api_one_show_petr_mode (vat_main_t * vam)
15756 vl_api_one_show_petr_mode_t *mp;
15759 /* Construct the API message */
15760 M (ONE_SHOW_PETR_MODE, mp);
15765 /* Wait for a reply... */
15771 api_show_one_map_register_state (vat_main_t * vam)
15773 vl_api_show_one_map_register_state_t *mp;
15776 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15781 /* wait for reply */
15786 #define api_show_lisp_map_register_state api_show_one_map_register_state
15789 api_show_one_rloc_probe_state (vat_main_t * vam)
15791 vl_api_show_one_rloc_probe_state_t *mp;
15794 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15799 /* wait for reply */
15804 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15807 api_one_add_del_ndp_entry (vat_main_t * vam)
15809 vl_api_one_add_del_ndp_entry_t *mp;
15810 unformat_input_t *input = vam->input;
15815 u8 mac[6] = { 0, };
15816 u8 ip6[16] = { 0, };
15820 /* Parse args required to build the message */
15821 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15823 if (unformat (input, "del"))
15825 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15827 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15829 else if (unformat (input, "bd %d", &bd))
15833 errmsg ("parse error '%U'", format_unformat_error, input);
15838 if (!bd_set || !ip_set || (!mac_set && is_add))
15840 errmsg ("Missing BD, IP or MAC!");
15844 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15845 mp->is_add = is_add;
15846 clib_memcpy (mp->mac, mac, 6);
15847 mp->bd = clib_host_to_net_u32 (bd);
15848 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
15853 /* wait for reply */
15859 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15861 vl_api_one_add_del_l2_arp_entry_t *mp;
15862 unformat_input_t *input = vam->input;
15867 u8 mac[6] = { 0, };
15868 u32 ip4 = 0, bd = ~0;
15871 /* Parse args required to build the message */
15872 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15874 if (unformat (input, "del"))
15876 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15878 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15880 else if (unformat (input, "bd %d", &bd))
15884 errmsg ("parse error '%U'", format_unformat_error, input);
15889 if (!bd_set || !ip_set || (!mac_set && is_add))
15891 errmsg ("Missing BD, IP or MAC!");
15895 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15896 mp->is_add = is_add;
15897 clib_memcpy (mp->mac, mac, 6);
15898 mp->bd = clib_host_to_net_u32 (bd);
15904 /* wait for reply */
15910 api_one_ndp_bd_get (vat_main_t * vam)
15912 vl_api_one_ndp_bd_get_t *mp;
15915 M (ONE_NDP_BD_GET, mp);
15920 /* wait for reply */
15926 api_one_ndp_entries_get (vat_main_t * vam)
15928 vl_api_one_ndp_entries_get_t *mp;
15929 unformat_input_t *input = vam->input;
15934 /* Parse args required to build the message */
15935 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15937 if (unformat (input, "bd %d", &bd))
15941 errmsg ("parse error '%U'", format_unformat_error, input);
15948 errmsg ("Expected bridge domain!");
15952 M (ONE_NDP_ENTRIES_GET, mp);
15953 mp->bd = clib_host_to_net_u32 (bd);
15958 /* wait for reply */
15964 api_one_l2_arp_bd_get (vat_main_t * vam)
15966 vl_api_one_l2_arp_bd_get_t *mp;
15969 M (ONE_L2_ARP_BD_GET, mp);
15974 /* wait for reply */
15980 api_one_l2_arp_entries_get (vat_main_t * vam)
15982 vl_api_one_l2_arp_entries_get_t *mp;
15983 unformat_input_t *input = vam->input;
15988 /* Parse args required to build the message */
15989 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15991 if (unformat (input, "bd %d", &bd))
15995 errmsg ("parse error '%U'", format_unformat_error, input);
16002 errmsg ("Expected bridge domain!");
16006 M (ONE_L2_ARP_ENTRIES_GET, mp);
16007 mp->bd = clib_host_to_net_u32 (bd);
16012 /* wait for reply */
16018 api_one_stats_enable_disable (vat_main_t * vam)
16020 vl_api_one_stats_enable_disable_t *mp;
16021 unformat_input_t *input = vam->input;
16026 /* Parse args required to build the message */
16027 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16029 if (unformat (input, "enable"))
16034 else if (unformat (input, "disable"))
16044 errmsg ("Value not set");
16048 M (ONE_STATS_ENABLE_DISABLE, mp);
16054 /* wait for reply */
16060 api_show_one_stats_enable_disable (vat_main_t * vam)
16062 vl_api_show_one_stats_enable_disable_t *mp;
16065 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16070 /* wait for reply */
16076 api_show_one_map_request_mode (vat_main_t * vam)
16078 vl_api_show_one_map_request_mode_t *mp;
16081 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16086 /* wait for reply */
16091 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16094 api_one_map_request_mode (vat_main_t * vam)
16096 unformat_input_t *input = vam->input;
16097 vl_api_one_map_request_mode_t *mp;
16101 /* Parse args required to build the message */
16102 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16104 if (unformat (input, "dst-only"))
16106 else if (unformat (input, "src-dst"))
16110 errmsg ("parse error '%U'", format_unformat_error, input);
16115 M (ONE_MAP_REQUEST_MODE, mp);
16122 /* wait for reply */
16127 #define api_lisp_map_request_mode api_one_map_request_mode
16130 * Enable/disable ONE proxy ITR.
16132 * @param vam vpp API test context
16133 * @return return code
16136 api_one_pitr_set_locator_set (vat_main_t * vam)
16138 u8 ls_name_set = 0;
16139 unformat_input_t *input = vam->input;
16140 vl_api_one_pitr_set_locator_set_t *mp;
16145 /* Parse args required to build the message */
16146 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16148 if (unformat (input, "del"))
16150 else if (unformat (input, "locator-set %s", &ls_name))
16154 errmsg ("parse error '%U'", format_unformat_error, input);
16161 errmsg ("locator-set name not set!");
16165 M (ONE_PITR_SET_LOCATOR_SET, mp);
16167 mp->is_add = is_add;
16168 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16169 vec_free (ls_name);
16174 /* wait for reply */
16179 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16182 api_one_nsh_set_locator_set (vat_main_t * vam)
16184 u8 ls_name_set = 0;
16185 unformat_input_t *input = vam->input;
16186 vl_api_one_nsh_set_locator_set_t *mp;
16191 /* Parse args required to build the message */
16192 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16194 if (unformat (input, "del"))
16196 else if (unformat (input, "ls %s", &ls_name))
16200 errmsg ("parse error '%U'", format_unformat_error, input);
16205 if (!ls_name_set && is_add)
16207 errmsg ("locator-set name not set!");
16211 M (ONE_NSH_SET_LOCATOR_SET, mp);
16213 mp->is_add = is_add;
16214 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16215 vec_free (ls_name);
16220 /* wait for reply */
16226 api_show_one_pitr (vat_main_t * vam)
16228 vl_api_show_one_pitr_t *mp;
16231 if (!vam->json_output)
16233 print (vam->ofp, "%=20s", "lisp status:");
16236 M (SHOW_ONE_PITR, mp);
16240 /* Wait for a reply... */
16245 #define api_show_lisp_pitr api_show_one_pitr
16248 api_one_use_petr (vat_main_t * vam)
16250 unformat_input_t *input = vam->input;
16251 vl_api_one_use_petr_t *mp;
16256 clib_memset (&ip, 0, sizeof (ip));
16258 /* Parse args required to build the message */
16259 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16261 if (unformat (input, "disable"))
16264 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16267 ip_addr_version (&ip) = IP4;
16270 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16273 ip_addr_version (&ip) = IP6;
16277 errmsg ("parse error '%U'", format_unformat_error, input);
16282 M (ONE_USE_PETR, mp);
16284 mp->is_add = is_add;
16287 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16289 clib_memcpy (mp->address, &ip, 4);
16291 clib_memcpy (mp->address, &ip, 16);
16297 /* wait for reply */
16302 #define api_lisp_use_petr api_one_use_petr
16305 api_show_one_nsh_mapping (vat_main_t * vam)
16307 vl_api_show_one_use_petr_t *mp;
16310 if (!vam->json_output)
16312 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16315 M (SHOW_ONE_NSH_MAPPING, mp);
16319 /* Wait for a reply... */
16325 api_show_one_use_petr (vat_main_t * vam)
16327 vl_api_show_one_use_petr_t *mp;
16330 if (!vam->json_output)
16332 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16335 M (SHOW_ONE_USE_PETR, mp);
16339 /* Wait for a reply... */
16344 #define api_show_lisp_use_petr api_show_one_use_petr
16347 * Add/delete mapping between vni and vrf
16350 api_one_eid_table_add_del_map (vat_main_t * vam)
16352 unformat_input_t *input = vam->input;
16353 vl_api_one_eid_table_add_del_map_t *mp;
16354 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16355 u32 vni, vrf, bd_index;
16358 /* Parse args required to build the message */
16359 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16361 if (unformat (input, "del"))
16363 else if (unformat (input, "vrf %d", &vrf))
16365 else if (unformat (input, "bd_index %d", &bd_index))
16367 else if (unformat (input, "vni %d", &vni))
16373 if (!vni_set || (!vrf_set && !bd_index_set))
16375 errmsg ("missing arguments!");
16379 if (vrf_set && bd_index_set)
16381 errmsg ("error: both vrf and bd entered!");
16385 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16387 mp->is_add = is_add;
16388 mp->vni = htonl (vni);
16389 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16390 mp->is_l2 = bd_index_set;
16395 /* wait for reply */
16400 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16403 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16405 u32 *action = va_arg (*args, u32 *);
16408 if (unformat (input, "%s", &s))
16410 if (!strcmp ((char *) s, "no-action"))
16412 else if (!strcmp ((char *) s, "natively-forward"))
16414 else if (!strcmp ((char *) s, "send-map-request"))
16416 else if (!strcmp ((char *) s, "drop"))
16420 clib_warning ("invalid action: '%s'", s);
16432 * Add/del remote mapping to/from ONE control plane
16434 * @param vam vpp API test context
16435 * @return return code
16438 api_one_add_del_remote_mapping (vat_main_t * vam)
16440 unformat_input_t *input = vam->input;
16441 vl_api_one_add_del_remote_mapping_t *mp;
16443 lisp_eid_vat_t _eid, *eid = &_eid;
16444 lisp_eid_vat_t _seid, *seid = &_seid;
16445 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16446 u32 action = ~0, p, w, data_len;
16447 ip4_address_t rloc4;
16448 ip6_address_t rloc6;
16449 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16452 clib_memset (&rloc, 0, sizeof (rloc));
16454 /* Parse args required to build the message */
16455 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16457 if (unformat (input, "del-all"))
16461 else if (unformat (input, "del"))
16465 else if (unformat (input, "add"))
16469 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16473 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16477 else if (unformat (input, "vni %d", &vni))
16481 else if (unformat (input, "p %d w %d", &p, &w))
16485 errmsg ("No RLOC configured for setting priority/weight!");
16488 curr_rloc->priority = p;
16489 curr_rloc->weight = w;
16491 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16494 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16495 vec_add1 (rlocs, rloc);
16496 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16498 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16501 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16502 vec_add1 (rlocs, rloc);
16503 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16505 else if (unformat (input, "action %U",
16506 unformat_negative_mapping_action, &action))
16512 clib_warning ("parse error '%U'", format_unformat_error, input);
16519 errmsg ("missing params!");
16523 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16525 errmsg ("no action set for negative map-reply!");
16529 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16531 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16532 mp->is_add = is_add;
16533 mp->vni = htonl (vni);
16534 mp->action = (u8) action;
16535 mp->is_src_dst = seid_set;
16536 mp->eid_len = eid->len;
16537 mp->seid_len = seid->len;
16538 mp->del_all = del_all;
16539 mp->eid_type = eid->type;
16540 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16541 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16543 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16544 clib_memcpy (mp->rlocs, rlocs, data_len);
16550 /* Wait for a reply... */
16555 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16558 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16559 * forwarding entries in data-plane accordingly.
16561 * @param vam vpp API test context
16562 * @return return code
16565 api_one_add_del_adjacency (vat_main_t * vam)
16567 unformat_input_t *input = vam->input;
16568 vl_api_one_add_del_adjacency_t *mp;
16570 ip4_address_t leid4, reid4;
16571 ip6_address_t leid6, reid6;
16572 u8 reid_mac[6] = { 0 };
16573 u8 leid_mac[6] = { 0 };
16574 u8 reid_type, leid_type;
16575 u32 leid_len = 0, reid_len = 0, len;
16579 leid_type = reid_type = (u8) ~ 0;
16581 /* Parse args required to build the message */
16582 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16584 if (unformat (input, "del"))
16588 else if (unformat (input, "add"))
16592 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
16595 reid_type = 0; /* ipv4 */
16598 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
16601 reid_type = 1; /* ipv6 */
16604 else if (unformat (input, "reid %U", unformat_ethernet_address,
16607 reid_type = 2; /* mac */
16609 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
16612 leid_type = 0; /* ipv4 */
16615 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
16618 leid_type = 1; /* ipv6 */
16621 else if (unformat (input, "leid %U", unformat_ethernet_address,
16624 leid_type = 2; /* mac */
16626 else if (unformat (input, "vni %d", &vni))
16632 errmsg ("parse error '%U'", format_unformat_error, input);
16637 if ((u8) ~ 0 == reid_type)
16639 errmsg ("missing params!");
16643 if (leid_type != reid_type)
16645 errmsg ("remote and local EIDs are of different types!");
16649 M (ONE_ADD_DEL_ADJACENCY, mp);
16650 mp->is_add = is_add;
16651 mp->vni = htonl (vni);
16652 mp->leid_len = leid_len;
16653 mp->reid_len = reid_len;
16654 mp->eid_type = reid_type;
16656 switch (mp->eid_type)
16659 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
16660 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
16663 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
16664 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
16667 clib_memcpy (mp->leid, leid_mac, 6);
16668 clib_memcpy (mp->reid, reid_mac, 6);
16671 errmsg ("unknown EID type %d!", mp->eid_type);
16678 /* Wait for a reply... */
16683 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16686 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16688 u32 *mode = va_arg (*args, u32 *);
16690 if (unformat (input, "lisp"))
16692 else if (unformat (input, "vxlan"))
16701 api_gpe_get_encap_mode (vat_main_t * vam)
16703 vl_api_gpe_get_encap_mode_t *mp;
16706 /* Construct the API message */
16707 M (GPE_GET_ENCAP_MODE, mp);
16712 /* Wait for a reply... */
16718 api_gpe_set_encap_mode (vat_main_t * vam)
16720 unformat_input_t *input = vam->input;
16721 vl_api_gpe_set_encap_mode_t *mp;
16725 /* Parse args required to build the message */
16726 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16728 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16734 /* Construct the API message */
16735 M (GPE_SET_ENCAP_MODE, mp);
16742 /* Wait for a reply... */
16748 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16750 unformat_input_t *input = vam->input;
16751 vl_api_gpe_add_del_iface_t *mp;
16752 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16753 u32 dp_table = 0, vni = 0;
16756 /* Parse args required to build the message */
16757 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16759 if (unformat (input, "up"))
16764 else if (unformat (input, "down"))
16769 else if (unformat (input, "table_id %d", &dp_table))
16773 else if (unformat (input, "bd_id %d", &dp_table))
16778 else if (unformat (input, "vni %d", &vni))
16786 if (action_set == 0)
16788 errmsg ("Action not set");
16791 if (dp_table_set == 0 || vni_set == 0)
16793 errmsg ("vni and dp_table must be set");
16797 /* Construct the API message */
16798 M (GPE_ADD_DEL_IFACE, mp);
16800 mp->is_add = is_add;
16801 mp->dp_table = clib_host_to_net_u32 (dp_table);
16803 mp->vni = clib_host_to_net_u32 (vni);
16808 /* Wait for a reply... */
16814 api_one_map_register_fallback_threshold (vat_main_t * vam)
16816 unformat_input_t *input = vam->input;
16817 vl_api_one_map_register_fallback_threshold_t *mp;
16822 /* Parse args required to build the message */
16823 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16825 if (unformat (input, "%u", &value))
16829 clib_warning ("parse error '%U'", format_unformat_error, input);
16836 errmsg ("fallback threshold value is missing!");
16840 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16841 mp->value = clib_host_to_net_u32 (value);
16846 /* Wait for a reply... */
16852 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16854 vl_api_show_one_map_register_fallback_threshold_t *mp;
16857 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16862 /* Wait for a reply... */
16868 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
16870 u32 *proto = va_arg (*args, u32 *);
16872 if (unformat (input, "udp"))
16874 else if (unformat (input, "api"))
16883 api_one_set_transport_protocol (vat_main_t * vam)
16885 unformat_input_t *input = vam->input;
16886 vl_api_one_set_transport_protocol_t *mp;
16891 /* Parse args required to build the message */
16892 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16894 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
16898 clib_warning ("parse error '%U'", format_unformat_error, input);
16905 errmsg ("Transport protocol missing!");
16909 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
16910 mp->protocol = (u8) protocol;
16915 /* Wait for a reply... */
16921 api_one_get_transport_protocol (vat_main_t * vam)
16923 vl_api_one_get_transport_protocol_t *mp;
16926 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
16931 /* Wait for a reply... */
16937 api_one_map_register_set_ttl (vat_main_t * vam)
16939 unformat_input_t *input = vam->input;
16940 vl_api_one_map_register_set_ttl_t *mp;
16945 /* Parse args required to build the message */
16946 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16948 if (unformat (input, "%u", &ttl))
16952 clib_warning ("parse error '%U'", format_unformat_error, input);
16959 errmsg ("TTL value missing!");
16963 M (ONE_MAP_REGISTER_SET_TTL, mp);
16964 mp->ttl = clib_host_to_net_u32 (ttl);
16969 /* Wait for a reply... */
16975 api_show_one_map_register_ttl (vat_main_t * vam)
16977 vl_api_show_one_map_register_ttl_t *mp;
16980 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16985 /* Wait for a reply... */
16991 * Add/del map request itr rlocs from ONE control plane and updates
16993 * @param vam vpp API test context
16994 * @return return code
16997 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16999 unformat_input_t *input = vam->input;
17000 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17001 u8 *locator_set_name = 0;
17002 u8 locator_set_name_set = 0;
17006 /* Parse args required to build the message */
17007 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17009 if (unformat (input, "del"))
17013 else if (unformat (input, "%_%v%_", &locator_set_name))
17015 locator_set_name_set = 1;
17019 clib_warning ("parse error '%U'", format_unformat_error, input);
17024 if (is_add && !locator_set_name_set)
17026 errmsg ("itr-rloc is not set!");
17030 if (is_add && vec_len (locator_set_name) > 64)
17032 errmsg ("itr-rloc locator-set name too long");
17033 vec_free (locator_set_name);
17037 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17038 mp->is_add = is_add;
17041 clib_memcpy (mp->locator_set_name, locator_set_name,
17042 vec_len (locator_set_name));
17046 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17048 vec_free (locator_set_name);
17053 /* Wait for a reply... */
17058 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17061 api_one_locator_dump (vat_main_t * vam)
17063 unformat_input_t *input = vam->input;
17064 vl_api_one_locator_dump_t *mp;
17065 vl_api_control_ping_t *mp_ping;
17066 u8 is_index_set = 0, is_name_set = 0;
17071 /* Parse args required to build the message */
17072 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17074 if (unformat (input, "ls_name %_%v%_", &ls_name))
17078 else if (unformat (input, "ls_index %d", &ls_index))
17084 errmsg ("parse error '%U'", format_unformat_error, input);
17089 if (!is_index_set && !is_name_set)
17091 errmsg ("error: expected one of index or name!");
17095 if (is_index_set && is_name_set)
17097 errmsg ("error: only one param expected!");
17101 if (vec_len (ls_name) > 62)
17103 errmsg ("error: locator set name too long!");
17107 if (!vam->json_output)
17109 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17112 M (ONE_LOCATOR_DUMP, mp);
17113 mp->is_index_set = is_index_set;
17116 mp->ls_index = clib_host_to_net_u32 (ls_index);
17119 vec_add1 (ls_name, 0);
17120 strncpy ((char *) mp->ls_name, (char *) ls_name,
17121 sizeof (mp->ls_name) - 1);
17127 /* Use a control ping for synchronization */
17128 MPING (CONTROL_PING, mp_ping);
17131 /* Wait for a reply... */
17136 #define api_lisp_locator_dump api_one_locator_dump
17139 api_one_locator_set_dump (vat_main_t * vam)
17141 vl_api_one_locator_set_dump_t *mp;
17142 vl_api_control_ping_t *mp_ping;
17143 unformat_input_t *input = vam->input;
17147 /* Parse args required to build the message */
17148 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17150 if (unformat (input, "local"))
17154 else if (unformat (input, "remote"))
17160 errmsg ("parse error '%U'", format_unformat_error, input);
17165 if (!vam->json_output)
17167 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17170 M (ONE_LOCATOR_SET_DUMP, mp);
17172 mp->filter = filter;
17177 /* Use a control ping for synchronization */
17178 MPING (CONTROL_PING, mp_ping);
17181 /* Wait for a reply... */
17186 #define api_lisp_locator_set_dump api_one_locator_set_dump
17189 api_one_eid_table_map_dump (vat_main_t * vam)
17193 unformat_input_t *input = vam->input;
17194 vl_api_one_eid_table_map_dump_t *mp;
17195 vl_api_control_ping_t *mp_ping;
17198 /* Parse args required to build the message */
17199 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17201 if (unformat (input, "l2"))
17206 else if (unformat (input, "l3"))
17213 errmsg ("parse error '%U'", format_unformat_error, input);
17220 errmsg ("expected one of 'l2' or 'l3' parameter!");
17224 if (!vam->json_output)
17226 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17229 M (ONE_EID_TABLE_MAP_DUMP, mp);
17235 /* Use a control ping for synchronization */
17236 MPING (CONTROL_PING, mp_ping);
17239 /* Wait for a reply... */
17244 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17247 api_one_eid_table_vni_dump (vat_main_t * vam)
17249 vl_api_one_eid_table_vni_dump_t *mp;
17250 vl_api_control_ping_t *mp_ping;
17253 if (!vam->json_output)
17255 print (vam->ofp, "VNI");
17258 M (ONE_EID_TABLE_VNI_DUMP, mp);
17263 /* Use a control ping for synchronization */
17264 MPING (CONTROL_PING, mp_ping);
17267 /* Wait for a reply... */
17272 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17275 api_one_eid_table_dump (vat_main_t * vam)
17277 unformat_input_t *i = vam->input;
17278 vl_api_one_eid_table_dump_t *mp;
17279 vl_api_control_ping_t *mp_ping;
17280 struct in_addr ip4;
17281 struct in6_addr ip6;
17283 u8 eid_type = ~0, eid_set = 0;
17284 u32 prefix_length = ~0, t, vni = 0;
17287 lisp_nsh_api_t nsh;
17289 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17291 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17297 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17303 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17308 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17313 else if (unformat (i, "vni %d", &t))
17317 else if (unformat (i, "local"))
17321 else if (unformat (i, "remote"))
17327 errmsg ("parse error '%U'", format_unformat_error, i);
17332 if (!vam->json_output)
17334 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17335 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17338 M (ONE_EID_TABLE_DUMP, mp);
17340 mp->filter = filter;
17344 mp->vni = htonl (vni);
17345 mp->eid_type = eid_type;
17349 mp->prefix_length = prefix_length;
17350 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17353 mp->prefix_length = prefix_length;
17354 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17357 clib_memcpy (mp->eid, mac, sizeof (mac));
17360 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17363 errmsg ("unknown EID type %d!", eid_type);
17371 /* Use a control ping for synchronization */
17372 MPING (CONTROL_PING, mp_ping);
17375 /* Wait for a reply... */
17380 #define api_lisp_eid_table_dump api_one_eid_table_dump
17383 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17385 unformat_input_t *i = vam->input;
17386 vl_api_gpe_fwd_entries_get_t *mp;
17391 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17393 if (unformat (i, "vni %d", &vni))
17399 errmsg ("parse error '%U'", format_unformat_error, i);
17406 errmsg ("vni not set!");
17410 if (!vam->json_output)
17412 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17416 M (GPE_FWD_ENTRIES_GET, mp);
17417 mp->vni = clib_host_to_net_u32 (vni);
17422 /* Wait for a reply... */
17427 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17428 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17429 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17430 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17431 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17432 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17433 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17434 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17437 api_one_adjacencies_get (vat_main_t * vam)
17439 unformat_input_t *i = vam->input;
17440 vl_api_one_adjacencies_get_t *mp;
17445 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17447 if (unformat (i, "vni %d", &vni))
17453 errmsg ("parse error '%U'", format_unformat_error, i);
17460 errmsg ("vni not set!");
17464 if (!vam->json_output)
17466 print (vam->ofp, "%s %40s", "leid", "reid");
17469 M (ONE_ADJACENCIES_GET, mp);
17470 mp->vni = clib_host_to_net_u32 (vni);
17475 /* Wait for a reply... */
17480 #define api_lisp_adjacencies_get api_one_adjacencies_get
17483 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17485 unformat_input_t *i = vam->input;
17486 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17488 u8 ip_family_set = 0, is_ip4 = 1;
17490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17492 if (unformat (i, "ip4"))
17497 else if (unformat (i, "ip6"))
17504 errmsg ("parse error '%U'", format_unformat_error, i);
17509 if (!ip_family_set)
17511 errmsg ("ip family not set!");
17515 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17516 mp->is_ip4 = is_ip4;
17521 /* Wait for a reply... */
17527 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17529 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17532 if (!vam->json_output)
17534 print (vam->ofp, "VNIs");
17537 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17542 /* Wait for a reply... */
17548 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17550 unformat_input_t *i = vam->input;
17551 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17553 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17554 struct in_addr ip4;
17555 struct in6_addr ip6;
17556 u32 table_id = 0, nh_sw_if_index = ~0;
17558 clib_memset (&ip4, 0, sizeof (ip4));
17559 clib_memset (&ip6, 0, sizeof (ip6));
17561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17563 if (unformat (i, "del"))
17565 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17566 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17571 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17572 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17577 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17581 nh_sw_if_index = ~0;
17583 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
17587 nh_sw_if_index = ~0;
17589 else if (unformat (i, "table %d", &table_id))
17593 errmsg ("parse error '%U'", format_unformat_error, i);
17600 errmsg ("nh addr not set!");
17604 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
17605 mp->is_add = is_add;
17606 mp->table_id = clib_host_to_net_u32 (table_id);
17607 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
17608 mp->is_ip4 = is_ip4;
17610 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
17612 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
17617 /* Wait for a reply... */
17623 api_one_map_server_dump (vat_main_t * vam)
17625 vl_api_one_map_server_dump_t *mp;
17626 vl_api_control_ping_t *mp_ping;
17629 if (!vam->json_output)
17631 print (vam->ofp, "%=20s", "Map server");
17634 M (ONE_MAP_SERVER_DUMP, mp);
17638 /* Use a control ping for synchronization */
17639 MPING (CONTROL_PING, mp_ping);
17642 /* Wait for a reply... */
17647 #define api_lisp_map_server_dump api_one_map_server_dump
17650 api_one_map_resolver_dump (vat_main_t * vam)
17652 vl_api_one_map_resolver_dump_t *mp;
17653 vl_api_control_ping_t *mp_ping;
17656 if (!vam->json_output)
17658 print (vam->ofp, "%=20s", "Map resolver");
17661 M (ONE_MAP_RESOLVER_DUMP, mp);
17665 /* Use a control ping for synchronization */
17666 MPING (CONTROL_PING, mp_ping);
17669 /* Wait for a reply... */
17674 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
17677 api_one_stats_flush (vat_main_t * vam)
17679 vl_api_one_stats_flush_t *mp;
17682 M (ONE_STATS_FLUSH, mp);
17689 api_one_stats_dump (vat_main_t * vam)
17691 vl_api_one_stats_dump_t *mp;
17692 vl_api_control_ping_t *mp_ping;
17695 M (ONE_STATS_DUMP, mp);
17699 /* Use a control ping for synchronization */
17700 MPING (CONTROL_PING, mp_ping);
17703 /* Wait for a reply... */
17709 api_show_one_status (vat_main_t * vam)
17711 vl_api_show_one_status_t *mp;
17714 if (!vam->json_output)
17716 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17719 M (SHOW_ONE_STATUS, mp);
17722 /* Wait for a reply... */
17727 #define api_show_lisp_status api_show_one_status
17730 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17732 vl_api_gpe_fwd_entry_path_dump_t *mp;
17733 vl_api_control_ping_t *mp_ping;
17734 unformat_input_t *i = vam->input;
17735 u32 fwd_entry_index = ~0;
17738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17740 if (unformat (i, "index %d", &fwd_entry_index))
17746 if (~0 == fwd_entry_index)
17748 errmsg ("no index specified!");
17752 if (!vam->json_output)
17754 print (vam->ofp, "first line");
17757 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17761 /* Use a control ping for synchronization */
17762 MPING (CONTROL_PING, mp_ping);
17765 /* Wait for a reply... */
17771 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17773 vl_api_one_get_map_request_itr_rlocs_t *mp;
17776 if (!vam->json_output)
17778 print (vam->ofp, "%=20s", "itr-rlocs:");
17781 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17784 /* Wait for a reply... */
17789 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17792 api_af_packet_create (vat_main_t * vam)
17794 unformat_input_t *i = vam->input;
17795 vl_api_af_packet_create_t *mp;
17796 u8 *host_if_name = 0;
17798 u8 random_hw_addr = 1;
17801 clib_memset (hw_addr, 0, sizeof (hw_addr));
17803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17805 if (unformat (i, "name %s", &host_if_name))
17806 vec_add1 (host_if_name, 0);
17807 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17808 random_hw_addr = 0;
17813 if (!vec_len (host_if_name))
17815 errmsg ("host-interface name must be specified");
17819 if (vec_len (host_if_name) > 64)
17821 errmsg ("host-interface name too long");
17825 M (AF_PACKET_CREATE, mp);
17827 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17828 clib_memcpy (mp->hw_addr, hw_addr, 6);
17829 mp->use_random_hw_addr = random_hw_addr;
17830 vec_free (host_if_name);
17838 fprintf (vam->ofp ? vam->ofp : stderr,
17839 " new sw_if_index = %d\n", vam->sw_if_index);
17846 api_af_packet_delete (vat_main_t * vam)
17848 unformat_input_t *i = vam->input;
17849 vl_api_af_packet_delete_t *mp;
17850 u8 *host_if_name = 0;
17853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17855 if (unformat (i, "name %s", &host_if_name))
17856 vec_add1 (host_if_name, 0);
17861 if (!vec_len (host_if_name))
17863 errmsg ("host-interface name must be specified");
17867 if (vec_len (host_if_name) > 64)
17869 errmsg ("host-interface name too long");
17873 M (AF_PACKET_DELETE, mp);
17875 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17876 vec_free (host_if_name);
17883 static void vl_api_af_packet_details_t_handler
17884 (vl_api_af_packet_details_t * mp)
17886 vat_main_t *vam = &vat_main;
17888 print (vam->ofp, "%-16s %d",
17889 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
17892 static void vl_api_af_packet_details_t_handler_json
17893 (vl_api_af_packet_details_t * mp)
17895 vat_main_t *vam = &vat_main;
17896 vat_json_node_t *node = NULL;
17898 if (VAT_JSON_ARRAY != vam->json_tree.type)
17900 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17901 vat_json_init_array (&vam->json_tree);
17903 node = vat_json_array_add (&vam->json_tree);
17905 vat_json_init_object (node);
17906 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17907 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
17911 api_af_packet_dump (vat_main_t * vam)
17913 vl_api_af_packet_dump_t *mp;
17914 vl_api_control_ping_t *mp_ping;
17917 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
17918 /* Get list of tap interfaces */
17919 M (AF_PACKET_DUMP, mp);
17922 /* Use a control ping for synchronization */
17923 MPING (CONTROL_PING, mp_ping);
17931 api_policer_add_del (vat_main_t * vam)
17933 unformat_input_t *i = vam->input;
17934 vl_api_policer_add_del_t *mp;
17944 u8 color_aware = 0;
17945 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17948 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17949 conform_action.dscp = 0;
17950 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17951 exceed_action.dscp = 0;
17952 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17953 violate_action.dscp = 0;
17955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17957 if (unformat (i, "del"))
17959 else if (unformat (i, "name %s", &name))
17960 vec_add1 (name, 0);
17961 else if (unformat (i, "cir %u", &cir))
17963 else if (unformat (i, "eir %u", &eir))
17965 else if (unformat (i, "cb %u", &cb))
17967 else if (unformat (i, "eb %u", &eb))
17969 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17972 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17975 else if (unformat (i, "type %U", unformat_policer_type, &type))
17977 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17980 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17983 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17986 else if (unformat (i, "color-aware"))
17992 if (!vec_len (name))
17994 errmsg ("policer name must be specified");
17998 if (vec_len (name) > 64)
18000 errmsg ("policer name too long");
18004 M (POLICER_ADD_DEL, mp);
18006 clib_memcpy (mp->name, name, vec_len (name));
18008 mp->is_add = is_add;
18009 mp->cir = ntohl (cir);
18010 mp->eir = ntohl (eir);
18011 mp->cb = clib_net_to_host_u64 (cb);
18012 mp->eb = clib_net_to_host_u64 (eb);
18013 mp->rate_type = rate_type;
18014 mp->round_type = round_type;
18016 mp->conform_action_type = conform_action.action_type;
18017 mp->conform_dscp = conform_action.dscp;
18018 mp->exceed_action_type = exceed_action.action_type;
18019 mp->exceed_dscp = exceed_action.dscp;
18020 mp->violate_action_type = violate_action.action_type;
18021 mp->violate_dscp = violate_action.dscp;
18022 mp->color_aware = color_aware;
18030 api_policer_dump (vat_main_t * vam)
18032 unformat_input_t *i = vam->input;
18033 vl_api_policer_dump_t *mp;
18034 vl_api_control_ping_t *mp_ping;
18035 u8 *match_name = 0;
18036 u8 match_name_valid = 0;
18039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18041 if (unformat (i, "name %s", &match_name))
18043 vec_add1 (match_name, 0);
18044 match_name_valid = 1;
18050 M (POLICER_DUMP, mp);
18051 mp->match_name_valid = match_name_valid;
18052 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18053 vec_free (match_name);
18057 /* Use a control ping for synchronization */
18058 MPING (CONTROL_PING, mp_ping);
18061 /* Wait for a reply... */
18067 api_policer_classify_set_interface (vat_main_t * vam)
18069 unformat_input_t *i = vam->input;
18070 vl_api_policer_classify_set_interface_t *mp;
18072 int sw_if_index_set;
18073 u32 ip4_table_index = ~0;
18074 u32 ip6_table_index = ~0;
18075 u32 l2_table_index = ~0;
18079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18081 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18082 sw_if_index_set = 1;
18083 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18084 sw_if_index_set = 1;
18085 else if (unformat (i, "del"))
18087 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18089 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18091 else if (unformat (i, "l2-table %d", &l2_table_index))
18095 clib_warning ("parse error '%U'", format_unformat_error, i);
18100 if (sw_if_index_set == 0)
18102 errmsg ("missing interface name or sw_if_index");
18106 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18108 mp->sw_if_index = ntohl (sw_if_index);
18109 mp->ip4_table_index = ntohl (ip4_table_index);
18110 mp->ip6_table_index = ntohl (ip6_table_index);
18111 mp->l2_table_index = ntohl (l2_table_index);
18112 mp->is_add = is_add;
18120 api_policer_classify_dump (vat_main_t * vam)
18122 unformat_input_t *i = vam->input;
18123 vl_api_policer_classify_dump_t *mp;
18124 vl_api_control_ping_t *mp_ping;
18125 u8 type = POLICER_CLASSIFY_N_TABLES;
18128 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18132 errmsg ("classify table type must be specified");
18136 if (!vam->json_output)
18138 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18141 M (POLICER_CLASSIFY_DUMP, mp);
18146 /* Use a control ping for synchronization */
18147 MPING (CONTROL_PING, mp_ping);
18150 /* Wait for a reply... */
18156 api_netmap_create (vat_main_t * vam)
18158 unformat_input_t *i = vam->input;
18159 vl_api_netmap_create_t *mp;
18162 u8 random_hw_addr = 1;
18167 clib_memset (hw_addr, 0, sizeof (hw_addr));
18169 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18171 if (unformat (i, "name %s", &if_name))
18172 vec_add1 (if_name, 0);
18173 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18174 random_hw_addr = 0;
18175 else if (unformat (i, "pipe"))
18177 else if (unformat (i, "master"))
18179 else if (unformat (i, "slave"))
18185 if (!vec_len (if_name))
18187 errmsg ("interface name must be specified");
18191 if (vec_len (if_name) > 64)
18193 errmsg ("interface name too long");
18197 M (NETMAP_CREATE, mp);
18199 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18200 clib_memcpy (mp->hw_addr, hw_addr, 6);
18201 mp->use_random_hw_addr = random_hw_addr;
18202 mp->is_pipe = is_pipe;
18203 mp->is_master = is_master;
18204 vec_free (if_name);
18212 api_netmap_delete (vat_main_t * vam)
18214 unformat_input_t *i = vam->input;
18215 vl_api_netmap_delete_t *mp;
18219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18221 if (unformat (i, "name %s", &if_name))
18222 vec_add1 (if_name, 0);
18227 if (!vec_len (if_name))
18229 errmsg ("interface name must be specified");
18233 if (vec_len (if_name) > 64)
18235 errmsg ("interface name too long");
18239 M (NETMAP_DELETE, mp);
18241 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18242 vec_free (if_name);
18250 format_fib_api_path_nh_proto (u8 * s, va_list * args)
18252 vl_api_fib_path_nh_proto_t proto =
18253 va_arg (*args, vl_api_fib_path_nh_proto_t);
18257 case FIB_API_PATH_NH_PROTO_IP4:
18258 s = format (s, "ip4");
18260 case FIB_API_PATH_NH_PROTO_IP6:
18261 s = format (s, "ip6");
18263 case FIB_API_PATH_NH_PROTO_MPLS:
18264 s = format (s, "mpls");
18266 case FIB_API_PATH_NH_PROTO_BIER:
18267 s = format (s, "bier");
18269 case FIB_API_PATH_NH_PROTO_ETHERNET:
18270 s = format (s, "ethernet");
18278 format_vl_api_ip_address_union (u8 * s, va_list * args)
18280 vl_api_address_family_t af = va_arg (*args, vl_api_address_family_t);
18281 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
18286 s = format (s, "%U", format_ip4_address, u->ip4);
18289 s = format (s, "%U", format_ip6_address, u->ip6);
18296 format_vl_api_fib_path_type (u8 * s, va_list * args)
18298 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
18302 case FIB_API_PATH_TYPE_NORMAL:
18303 s = format (s, "normal");
18305 case FIB_API_PATH_TYPE_LOCAL:
18306 s = format (s, "local");
18308 case FIB_API_PATH_TYPE_DROP:
18309 s = format (s, "drop");
18311 case FIB_API_PATH_TYPE_UDP_ENCAP:
18312 s = format (s, "udp-encap");
18314 case FIB_API_PATH_TYPE_BIER_IMP:
18315 s = format (s, "bier-imp");
18317 case FIB_API_PATH_TYPE_ICMP_UNREACH:
18318 s = format (s, "unreach");
18320 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
18321 s = format (s, "prohibit");
18323 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
18324 s = format (s, "src-lookup");
18326 case FIB_API_PATH_TYPE_DVR:
18327 s = format (s, "dvr");
18329 case FIB_API_PATH_TYPE_INTERFACE_RX:
18330 s = format (s, "interface-rx");
18332 case FIB_API_PATH_TYPE_CLASSIFY:
18333 s = format (s, "classify");
18341 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
18344 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
18345 ntohl (fp->weight), ntohl (fp->sw_if_index),
18346 format_vl_api_fib_path_type, fp->type,
18347 format_fib_api_path_nh_proto, fp->proto,
18348 format_vl_api_ip_address_union, &fp->nh.address);
18352 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18353 vl_api_fib_path_t * fp)
18355 struct in_addr ip4;
18356 struct in6_addr ip6;
18358 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18359 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18360 vat_json_object_add_uint (node, "type", fp->type);
18361 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
18362 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18364 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
18365 vat_json_object_add_ip4 (node, "next_hop", ip4);
18367 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18369 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
18370 vat_json_object_add_ip6 (node, "next_hop", ip6);
18375 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18377 vat_main_t *vam = &vat_main;
18378 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18379 vl_api_fib_path_t *fp;
18382 print (vam->ofp, "sw_if_index %d via:",
18383 ntohl (mp->mt_tunnel.mt_sw_if_index));
18384 fp = mp->mt_tunnel.mt_paths;
18385 for (i = 0; i < count; i++)
18387 vl_api_fib_path_print (vam, fp);
18391 print (vam->ofp, "");
18394 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18395 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18398 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18400 vat_main_t *vam = &vat_main;
18401 vat_json_node_t *node = NULL;
18402 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18403 vl_api_fib_path_t *fp;
18406 if (VAT_JSON_ARRAY != vam->json_tree.type)
18408 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18409 vat_json_init_array (&vam->json_tree);
18411 node = vat_json_array_add (&vam->json_tree);
18413 vat_json_init_object (node);
18414 vat_json_object_add_uint (node, "sw_if_index",
18415 ntohl (mp->mt_tunnel.mt_sw_if_index));
18417 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
18419 fp = mp->mt_tunnel.mt_paths;
18420 for (i = 0; i < count; i++)
18422 vl_api_mpls_fib_path_json_print (node, fp);
18428 api_mpls_tunnel_dump (vat_main_t * vam)
18430 vl_api_mpls_tunnel_dump_t *mp;
18431 vl_api_control_ping_t *mp_ping;
18434 M (MPLS_TUNNEL_DUMP, mp);
18438 /* Use a control ping for synchronization */
18439 MPING (CONTROL_PING, mp_ping);
18446 #define vl_api_mpls_table_details_t_endian vl_noop_handler
18447 #define vl_api_mpls_table_details_t_print vl_noop_handler
18451 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
18453 vat_main_t *vam = &vat_main;
18455 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
18458 static void vl_api_mpls_table_details_t_handler_json
18459 (vl_api_mpls_table_details_t * mp)
18461 vat_main_t *vam = &vat_main;
18462 vat_json_node_t *node = NULL;
18464 if (VAT_JSON_ARRAY != vam->json_tree.type)
18466 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18467 vat_json_init_array (&vam->json_tree);
18469 node = vat_json_array_add (&vam->json_tree);
18471 vat_json_init_object (node);
18472 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
18476 api_mpls_table_dump (vat_main_t * vam)
18478 vl_api_mpls_table_dump_t *mp;
18479 vl_api_control_ping_t *mp_ping;
18482 M (MPLS_TABLE_DUMP, mp);
18485 /* Use a control ping for synchronization */
18486 MPING (CONTROL_PING, mp_ping);
18493 #define vl_api_mpls_route_details_t_endian vl_noop_handler
18494 #define vl_api_mpls_route_details_t_print vl_noop_handler
18497 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
18499 vat_main_t *vam = &vat_main;
18500 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
18501 vl_api_fib_path_t *fp;
18505 "table-id %d, label %u, ess_bit %u",
18506 ntohl (mp->mr_route.mr_table_id),
18507 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
18508 fp = mp->mr_route.mr_paths;
18509 for (i = 0; i < count; i++)
18511 vl_api_fib_path_print (vam, fp);
18516 static void vl_api_mpls_route_details_t_handler_json
18517 (vl_api_mpls_route_details_t * mp)
18519 vat_main_t *vam = &vat_main;
18520 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
18521 vat_json_node_t *node = NULL;
18522 vl_api_fib_path_t *fp;
18525 if (VAT_JSON_ARRAY != vam->json_tree.type)
18527 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18528 vat_json_init_array (&vam->json_tree);
18530 node = vat_json_array_add (&vam->json_tree);
18532 vat_json_init_object (node);
18533 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
18534 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
18535 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
18536 vat_json_object_add_uint (node, "path_count", count);
18537 fp = mp->mr_route.mr_paths;
18538 for (i = 0; i < count; i++)
18540 vl_api_mpls_fib_path_json_print (node, fp);
18546 api_mpls_route_dump (vat_main_t * vam)
18548 unformat_input_t *input = vam->input;
18549 vl_api_mpls_route_dump_t *mp;
18550 vl_api_control_ping_t *mp_ping;
18554 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18556 if (unformat (input, "table_id %d", &table_id))
18561 if (table_id == ~0)
18563 errmsg ("missing table id");
18567 M (MPLS_ROUTE_DUMP, mp);
18569 mp->table.mt_table_id = ntohl (table_id);
18572 /* Use a control ping for synchronization */
18573 MPING (CONTROL_PING, mp_ping);
18580 #define vl_api_ip_table_details_t_endian vl_noop_handler
18581 #define vl_api_ip_table_details_t_print vl_noop_handler
18584 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
18586 vat_main_t *vam = &vat_main;
18589 "%s; table-id %d, prefix %U/%d",
18590 mp->table.name, ntohl (mp->table.table_id));
18594 static void vl_api_ip_table_details_t_handler_json
18595 (vl_api_ip_table_details_t * mp)
18597 vat_main_t *vam = &vat_main;
18598 vat_json_node_t *node = NULL;
18600 if (VAT_JSON_ARRAY != vam->json_tree.type)
18602 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18603 vat_json_init_array (&vam->json_tree);
18605 node = vat_json_array_add (&vam->json_tree);
18607 vat_json_init_object (node);
18608 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
18612 api_ip_table_dump (vat_main_t * vam)
18614 vl_api_ip_table_dump_t *mp;
18615 vl_api_control_ping_t *mp_ping;
18618 M (IP_TABLE_DUMP, mp);
18621 /* Use a control ping for synchronization */
18622 MPING (CONTROL_PING, mp_ping);
18630 api_ip_mtable_dump (vat_main_t * vam)
18632 vl_api_ip_mtable_dump_t *mp;
18633 vl_api_control_ping_t *mp_ping;
18636 M (IP_MTABLE_DUMP, mp);
18639 /* Use a control ping for synchronization */
18640 MPING (CONTROL_PING, mp_ping);
18648 api_ip_mroute_dump (vat_main_t * vam)
18650 unformat_input_t *input = vam->input;
18651 vl_api_control_ping_t *mp_ping;
18652 vl_api_ip_mroute_dump_t *mp;
18657 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18659 if (unformat (input, "table_id %d", &table_id))
18661 else if (unformat (input, "ip6"))
18663 else if (unformat (input, "ip4"))
18668 if (table_id == ~0)
18670 errmsg ("missing table id");
18674 M (IP_MROUTE_DUMP, mp);
18675 mp->table.table_id = table_id;
18676 mp->table.is_ip6 = is_ip6;
18679 /* Use a control ping for synchronization */
18680 MPING (CONTROL_PING, mp_ping);
18687 static void vl_api_ip_neighbor_details_t_handler
18688 (vl_api_ip_neighbor_details_t * mp)
18690 vat_main_t *vam = &vat_main;
18692 print (vam->ofp, "%c %U %U",
18693 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
18694 format_vl_api_mac_address, &mp->neighbor.mac_address,
18695 format_vl_api_address, &mp->neighbor.ip_address);
18698 static void vl_api_ip_neighbor_details_t_handler_json
18699 (vl_api_ip_neighbor_details_t * mp)
18702 vat_main_t *vam = &vat_main;
18703 vat_json_node_t *node;
18705 if (VAT_JSON_ARRAY != vam->json_tree.type)
18707 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18708 vat_json_init_array (&vam->json_tree);
18710 node = vat_json_array_add (&vam->json_tree);
18712 vat_json_init_object (node);
18713 vat_json_object_add_string_copy
18715 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
18716 (u8 *) "static" : (u8 *) "dynamic"));
18718 vat_json_object_add_string_copy (node, "link_layer",
18719 format (0, "%U", format_vl_api_mac_address,
18720 &mp->neighbor.mac_address));
18721 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
18725 api_ip_neighbor_dump (vat_main_t * vam)
18727 unformat_input_t *i = vam->input;
18728 vl_api_ip_neighbor_dump_t *mp;
18729 vl_api_control_ping_t *mp_ping;
18731 u32 sw_if_index = ~0;
18734 /* Parse args required to build the message */
18735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18737 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18739 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18741 else if (unformat (i, "ip6"))
18747 if (sw_if_index == ~0)
18749 errmsg ("missing interface name or sw_if_index");
18753 M (IP_NEIGHBOR_DUMP, mp);
18754 mp->is_ipv6 = (u8) is_ipv6;
18755 mp->sw_if_index = ntohl (sw_if_index);
18758 /* Use a control ping for synchronization */
18759 MPING (CONTROL_PING, mp_ping);
18766 #define vl_api_ip_route_details_t_endian vl_noop_handler
18767 #define vl_api_ip_route_details_t_print vl_noop_handler
18770 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
18772 vat_main_t *vam = &vat_main;
18773 u8 count = mp->route.n_paths;
18774 vl_api_fib_path_t *fp;
18778 "table-id %d, prefix %U/%d",
18779 ntohl (mp->route.table_id),
18780 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
18781 for (i = 0; i < count; i++)
18783 fp = &mp->route.paths[i];
18785 vl_api_fib_path_print (vam, fp);
18790 static void vl_api_ip_route_details_t_handler_json
18791 (vl_api_ip_route_details_t * mp)
18793 vat_main_t *vam = &vat_main;
18794 u8 count = mp->route.n_paths;
18795 vat_json_node_t *node = NULL;
18796 struct in_addr ip4;
18797 struct in6_addr ip6;
18798 vl_api_fib_path_t *fp;
18801 if (VAT_JSON_ARRAY != vam->json_tree.type)
18803 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18804 vat_json_init_array (&vam->json_tree);
18806 node = vat_json_array_add (&vam->json_tree);
18808 vat_json_init_object (node);
18809 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
18810 if (ADDRESS_IP6 == mp->route.prefix.address.af)
18812 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
18813 vat_json_object_add_ip6 (node, "prefix", ip6);
18817 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
18818 vat_json_object_add_ip4 (node, "prefix", ip4);
18820 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
18821 vat_json_object_add_uint (node, "path_count", count);
18822 for (i = 0; i < count; i++)
18824 fp = &mp->route.paths[i];
18825 vl_api_mpls_fib_path_json_print (node, fp);
18830 api_ip_route_dump (vat_main_t * vam)
18832 unformat_input_t *input = vam->input;
18833 vl_api_ip_route_dump_t *mp;
18834 vl_api_control_ping_t *mp_ping;
18840 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18842 if (unformat (input, "table_id %d", &table_id))
18844 else if (unformat (input, "ip6"))
18846 else if (unformat (input, "ip4"))
18851 if (table_id == ~0)
18853 errmsg ("missing table id");
18857 M (IP_ROUTE_DUMP, mp);
18859 mp->table.table_id = table_id;
18860 mp->table.is_ip6 = is_ip6;
18864 /* Use a control ping for synchronization */
18865 MPING (CONTROL_PING, mp_ping);
18873 api_classify_table_ids (vat_main_t * vam)
18875 vl_api_classify_table_ids_t *mp;
18878 /* Construct the API message */
18879 M (CLASSIFY_TABLE_IDS, mp);
18888 api_classify_table_by_interface (vat_main_t * vam)
18890 unformat_input_t *input = vam->input;
18891 vl_api_classify_table_by_interface_t *mp;
18893 u32 sw_if_index = ~0;
18895 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18897 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18899 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18904 if (sw_if_index == ~0)
18906 errmsg ("missing interface name or sw_if_index");
18910 /* Construct the API message */
18911 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18913 mp->sw_if_index = ntohl (sw_if_index);
18921 api_classify_table_info (vat_main_t * vam)
18923 unformat_input_t *input = vam->input;
18924 vl_api_classify_table_info_t *mp;
18928 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18930 if (unformat (input, "table_id %d", &table_id))
18935 if (table_id == ~0)
18937 errmsg ("missing table id");
18941 /* Construct the API message */
18942 M (CLASSIFY_TABLE_INFO, mp);
18944 mp->table_id = ntohl (table_id);
18952 api_classify_session_dump (vat_main_t * vam)
18954 unformat_input_t *input = vam->input;
18955 vl_api_classify_session_dump_t *mp;
18956 vl_api_control_ping_t *mp_ping;
18960 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18962 if (unformat (input, "table_id %d", &table_id))
18967 if (table_id == ~0)
18969 errmsg ("missing table id");
18973 /* Construct the API message */
18974 M (CLASSIFY_SESSION_DUMP, mp);
18976 mp->table_id = ntohl (table_id);
18979 /* Use a control ping for synchronization */
18980 MPING (CONTROL_PING, mp_ping);
18988 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
18990 vat_main_t *vam = &vat_main;
18992 print (vam->ofp, "collector_address %U, collector_port %d, "
18993 "src_address %U, vrf_id %d, path_mtu %u, "
18994 "template_interval %u, udp_checksum %d",
18995 format_ip4_address, mp->collector_address,
18996 ntohs (mp->collector_port),
18997 format_ip4_address, mp->src_address,
18998 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
18999 ntohl (mp->template_interval), mp->udp_checksum);
19002 vam->result_ready = 1;
19006 vl_api_ipfix_exporter_details_t_handler_json
19007 (vl_api_ipfix_exporter_details_t * mp)
19009 vat_main_t *vam = &vat_main;
19010 vat_json_node_t node;
19011 struct in_addr collector_address;
19012 struct in_addr src_address;
19014 vat_json_init_object (&node);
19015 clib_memcpy (&collector_address, &mp->collector_address,
19016 sizeof (collector_address));
19017 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19018 vat_json_object_add_uint (&node, "collector_port",
19019 ntohs (mp->collector_port));
19020 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19021 vat_json_object_add_ip4 (&node, "src_address", src_address);
19022 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19023 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19024 vat_json_object_add_uint (&node, "template_interval",
19025 ntohl (mp->template_interval));
19026 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19028 vat_json_print (vam->ofp, &node);
19029 vat_json_free (&node);
19031 vam->result_ready = 1;
19035 api_ipfix_exporter_dump (vat_main_t * vam)
19037 vl_api_ipfix_exporter_dump_t *mp;
19040 /* Construct the API message */
19041 M (IPFIX_EXPORTER_DUMP, mp);
19050 api_ipfix_classify_stream_dump (vat_main_t * vam)
19052 vl_api_ipfix_classify_stream_dump_t *mp;
19055 /* Construct the API message */
19056 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19067 vl_api_ipfix_classify_stream_details_t_handler
19068 (vl_api_ipfix_classify_stream_details_t * mp)
19070 vat_main_t *vam = &vat_main;
19071 print (vam->ofp, "domain_id %d, src_port %d",
19072 ntohl (mp->domain_id), ntohs (mp->src_port));
19074 vam->result_ready = 1;
19078 vl_api_ipfix_classify_stream_details_t_handler_json
19079 (vl_api_ipfix_classify_stream_details_t * mp)
19081 vat_main_t *vam = &vat_main;
19082 vat_json_node_t node;
19084 vat_json_init_object (&node);
19085 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19086 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19088 vat_json_print (vam->ofp, &node);
19089 vat_json_free (&node);
19091 vam->result_ready = 1;
19095 api_ipfix_classify_table_dump (vat_main_t * vam)
19097 vl_api_ipfix_classify_table_dump_t *mp;
19098 vl_api_control_ping_t *mp_ping;
19101 if (!vam->json_output)
19103 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19104 "transport_protocol");
19107 /* Construct the API message */
19108 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19113 /* Use a control ping for synchronization */
19114 MPING (CONTROL_PING, mp_ping);
19122 vl_api_ipfix_classify_table_details_t_handler
19123 (vl_api_ipfix_classify_table_details_t * mp)
19125 vat_main_t *vam = &vat_main;
19126 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19127 mp->transport_protocol);
19131 vl_api_ipfix_classify_table_details_t_handler_json
19132 (vl_api_ipfix_classify_table_details_t * mp)
19134 vat_json_node_t *node = NULL;
19135 vat_main_t *vam = &vat_main;
19137 if (VAT_JSON_ARRAY != vam->json_tree.type)
19139 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19140 vat_json_init_array (&vam->json_tree);
19143 node = vat_json_array_add (&vam->json_tree);
19144 vat_json_init_object (node);
19146 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19147 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19148 vat_json_object_add_uint (node, "transport_protocol",
19149 mp->transport_protocol);
19153 api_sw_interface_span_enable_disable (vat_main_t * vam)
19155 unformat_input_t *i = vam->input;
19156 vl_api_sw_interface_span_enable_disable_t *mp;
19157 u32 src_sw_if_index = ~0;
19158 u32 dst_sw_if_index = ~0;
19163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19166 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19168 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19172 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19174 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19176 else if (unformat (i, "disable"))
19178 else if (unformat (i, "rx"))
19180 else if (unformat (i, "tx"))
19182 else if (unformat (i, "both"))
19184 else if (unformat (i, "l2"))
19190 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19192 mp->sw_if_index_from = htonl (src_sw_if_index);
19193 mp->sw_if_index_to = htonl (dst_sw_if_index);
19203 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19206 vat_main_t *vam = &vat_main;
19207 u8 *sw_if_from_name = 0;
19208 u8 *sw_if_to_name = 0;
19209 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19210 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19211 char *states[] = { "none", "rx", "tx", "both" };
19215 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19217 if ((u32) p->value[0] == sw_if_index_from)
19219 sw_if_from_name = (u8 *)(p->key);
19223 if ((u32) p->value[0] == sw_if_index_to)
19225 sw_if_to_name = (u8 *)(p->key);
19226 if (sw_if_from_name)
19231 print (vam->ofp, "%20s => %20s (%s) %s",
19232 sw_if_from_name, sw_if_to_name, states[mp->state],
19233 mp->is_l2 ? "l2" : "device");
19237 vl_api_sw_interface_span_details_t_handler_json
19238 (vl_api_sw_interface_span_details_t * mp)
19240 vat_main_t *vam = &vat_main;
19241 vat_json_node_t *node = NULL;
19242 u8 *sw_if_from_name = 0;
19243 u8 *sw_if_to_name = 0;
19244 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19245 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19249 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19251 if ((u32) p->value[0] == sw_if_index_from)
19253 sw_if_from_name = (u8 *)(p->key);
19257 if ((u32) p->value[0] == sw_if_index_to)
19259 sw_if_to_name = (u8 *)(p->key);
19260 if (sw_if_from_name)
19266 if (VAT_JSON_ARRAY != vam->json_tree.type)
19268 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19269 vat_json_init_array (&vam->json_tree);
19271 node = vat_json_array_add (&vam->json_tree);
19273 vat_json_init_object (node);
19274 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19275 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19276 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19277 if (0 != sw_if_to_name)
19279 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19281 vat_json_object_add_uint (node, "state", mp->state);
19282 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
19286 api_sw_interface_span_dump (vat_main_t * vam)
19288 unformat_input_t *input = vam->input;
19289 vl_api_sw_interface_span_dump_t *mp;
19290 vl_api_control_ping_t *mp_ping;
19294 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19296 if (unformat (input, "l2"))
19302 M (SW_INTERFACE_SPAN_DUMP, mp);
19306 /* Use a control ping for synchronization */
19307 MPING (CONTROL_PING, mp_ping);
19315 api_pg_create_interface (vat_main_t * vam)
19317 unformat_input_t *input = vam->input;
19318 vl_api_pg_create_interface_t *mp;
19320 u32 if_id = ~0, gso_size = 0;
19321 u8 gso_enabled = 0;
19323 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19325 if (unformat (input, "if_id %d", &if_id))
19327 else if (unformat (input, "gso-enabled"))
19330 if (unformat (input, "gso-size %u", &gso_size))
19334 errmsg ("missing gso-size");
19343 errmsg ("missing pg interface index");
19347 /* Construct the API message */
19348 M (PG_CREATE_INTERFACE, mp);
19350 mp->interface_id = ntohl (if_id);
19351 mp->gso_enabled = gso_enabled;
19359 api_pg_capture (vat_main_t * vam)
19361 unformat_input_t *input = vam->input;
19362 vl_api_pg_capture_t *mp;
19367 u8 pcap_file_set = 0;
19370 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19372 if (unformat (input, "if_id %d", &if_id))
19374 else if (unformat (input, "pcap %s", &pcap_file))
19376 else if (unformat (input, "count %d", &count))
19378 else if (unformat (input, "disable"))
19385 errmsg ("missing pg interface index");
19388 if (pcap_file_set > 0)
19390 if (vec_len (pcap_file) > 255)
19392 errmsg ("pcap file name is too long");
19397 u32 name_len = vec_len (pcap_file);
19398 /* Construct the API message */
19399 M (PG_CAPTURE, mp);
19401 mp->interface_id = ntohl (if_id);
19402 mp->is_enabled = enable;
19403 mp->count = ntohl (count);
19404 mp->pcap_name_length = ntohl (name_len);
19405 if (pcap_file_set != 0)
19407 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19409 vec_free (pcap_file);
19417 api_pg_enable_disable (vat_main_t * vam)
19419 unformat_input_t *input = vam->input;
19420 vl_api_pg_enable_disable_t *mp;
19423 u8 stream_name_set = 0;
19424 u8 *stream_name = 0;
19426 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19428 if (unformat (input, "stream %s", &stream_name))
19429 stream_name_set = 1;
19430 else if (unformat (input, "disable"))
19436 if (stream_name_set > 0)
19438 if (vec_len (stream_name) > 255)
19440 errmsg ("stream name too long");
19445 u32 name_len = vec_len (stream_name);
19446 /* Construct the API message */
19447 M (PG_ENABLE_DISABLE, mp);
19449 mp->is_enabled = enable;
19450 if (stream_name_set != 0)
19452 mp->stream_name_length = ntohl (name_len);
19453 clib_memcpy (mp->stream_name, stream_name, name_len);
19455 vec_free (stream_name);
19463 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19465 unformat_input_t *input = vam->input;
19466 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19468 u16 *low_ports = 0;
19469 u16 *high_ports = 0;
19472 vl_api_prefix_t prefix;
19479 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19481 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
19483 else if (unformat (input, "vrf %d", &vrf_id))
19485 else if (unformat (input, "del"))
19487 else if (unformat (input, "port %d", &tmp))
19489 if (tmp == 0 || tmp > 65535)
19491 errmsg ("port %d out of range", tmp);
19495 this_hi = this_low + 1;
19496 vec_add1 (low_ports, this_low);
19497 vec_add1 (high_ports, this_hi);
19499 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19501 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19503 errmsg ("incorrect range parameters");
19507 /* Note: in debug CLI +1 is added to high before
19508 passing to real fn that does "the work"
19509 (ip_source_and_port_range_check_add_del).
19510 This fn is a wrapper around the binary API fn a
19511 control plane will call, which expects this increment
19512 to have occurred. Hence letting the binary API control
19513 plane fn do the increment for consistency between VAT
19514 and other control planes.
19517 vec_add1 (low_ports, this_low);
19518 vec_add1 (high_ports, this_hi);
19524 if (prefix_set == 0)
19526 errmsg ("<address>/<mask> not specified");
19532 errmsg ("VRF ID required, not specified");
19539 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19543 if (vec_len (low_ports) == 0)
19545 errmsg ("At least one port or port range required");
19549 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19551 mp->is_add = is_add;
19553 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
19555 mp->number_of_ranges = vec_len (low_ports);
19557 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19558 vec_free (low_ports);
19560 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19561 vec_free (high_ports);
19563 mp->vrf_id = ntohl (vrf_id);
19571 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19573 unformat_input_t *input = vam->input;
19574 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19575 u32 sw_if_index = ~0;
19577 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19578 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19582 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19584 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19586 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19588 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19590 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19592 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19594 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19596 else if (unformat (input, "del"))
19602 if (sw_if_index == ~0)
19604 errmsg ("Interface required but not specified");
19610 errmsg ("VRF ID required but not specified");
19614 if (tcp_out_vrf_id == 0
19615 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
19618 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19622 /* Construct the API message */
19623 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
19625 mp->sw_if_index = ntohl (sw_if_index);
19626 mp->is_add = is_add;
19627 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
19628 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
19629 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
19630 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
19635 /* Wait for a reply... */
19641 api_set_punt (vat_main_t * vam)
19643 unformat_input_t *i = vam->input;
19644 vl_api_address_family_t af;
19645 vl_api_set_punt_t *mp;
19651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19653 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
19655 else if (unformat (i, "protocol %d", &protocol))
19657 else if (unformat (i, "port %d", &port))
19659 else if (unformat (i, "del"))
19663 clib_warning ("parse error '%U'", format_unformat_error, i);
19670 mp->is_add = (u8) is_add;
19671 mp->punt.type = PUNT_API_TYPE_L4;
19672 mp->punt.punt.l4.af = af;
19673 mp->punt.punt.l4.protocol = (u8) protocol;
19674 mp->punt.punt.l4.port = htons ((u16) port);
19682 api_delete_subif (vat_main_t * vam)
19684 unformat_input_t *i = vam->input;
19685 vl_api_delete_subif_t *mp;
19686 u32 sw_if_index = ~0;
19689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19691 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19693 if (unformat (i, "sw_if_index %d", &sw_if_index))
19699 if (sw_if_index == ~0)
19701 errmsg ("missing sw_if_index");
19705 /* Construct the API message */
19706 M (DELETE_SUBIF, mp);
19707 mp->sw_if_index = ntohl (sw_if_index);
19714 #define foreach_pbb_vtr_op \
19715 _("disable", L2_VTR_DISABLED) \
19716 _("pop", L2_VTR_POP_2) \
19717 _("push", L2_VTR_PUSH_2)
19720 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
19722 unformat_input_t *i = vam->input;
19723 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
19724 u32 sw_if_index = ~0, vtr_op = ~0;
19725 u16 outer_tag = ~0;
19726 u8 dmac[6], smac[6];
19727 u8 dmac_set = 0, smac_set = 0;
19733 /* Shut up coverity */
19734 clib_memset (dmac, 0, sizeof (dmac));
19735 clib_memset (smac, 0, sizeof (smac));
19737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19739 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19741 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19743 else if (unformat (i, "vtr_op %d", &vtr_op))
19745 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
19748 else if (unformat (i, "translate_pbb_stag"))
19750 if (unformat (i, "%d", &tmp))
19752 vtr_op = L2_VTR_TRANSLATE_2_1;
19758 ("translate_pbb_stag operation requires outer tag definition");
19762 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
19764 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
19766 else if (unformat (i, "sid %d", &sid))
19768 else if (unformat (i, "vlanid %d", &tmp))
19772 clib_warning ("parse error '%U'", format_unformat_error, i);
19777 if ((sw_if_index == ~0) || (vtr_op == ~0))
19779 errmsg ("missing sw_if_index or vtr operation");
19782 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
19783 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
19786 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
19790 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
19791 mp->sw_if_index = ntohl (sw_if_index);
19792 mp->vtr_op = ntohl (vtr_op);
19793 mp->outer_tag = ntohs (outer_tag);
19794 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
19795 clib_memcpy (mp->b_smac, smac, sizeof (smac));
19796 mp->b_vlanid = ntohs (vlanid);
19797 mp->i_sid = ntohl (sid);
19805 api_flow_classify_set_interface (vat_main_t * vam)
19807 unformat_input_t *i = vam->input;
19808 vl_api_flow_classify_set_interface_t *mp;
19810 int sw_if_index_set;
19811 u32 ip4_table_index = ~0;
19812 u32 ip6_table_index = ~0;
19816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19818 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19819 sw_if_index_set = 1;
19820 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19821 sw_if_index_set = 1;
19822 else if (unformat (i, "del"))
19824 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19826 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19830 clib_warning ("parse error '%U'", format_unformat_error, i);
19835 if (sw_if_index_set == 0)
19837 errmsg ("missing interface name or sw_if_index");
19841 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19843 mp->sw_if_index = ntohl (sw_if_index);
19844 mp->ip4_table_index = ntohl (ip4_table_index);
19845 mp->ip6_table_index = ntohl (ip6_table_index);
19846 mp->is_add = is_add;
19854 api_flow_classify_dump (vat_main_t * vam)
19856 unformat_input_t *i = vam->input;
19857 vl_api_flow_classify_dump_t *mp;
19858 vl_api_control_ping_t *mp_ping;
19859 u8 type = FLOW_CLASSIFY_N_TABLES;
19862 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19866 errmsg ("classify table type must be specified");
19870 if (!vam->json_output)
19872 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19875 M (FLOW_CLASSIFY_DUMP, mp);
19880 /* Use a control ping for synchronization */
19881 MPING (CONTROL_PING, mp_ping);
19884 /* Wait for a reply... */
19890 api_feature_enable_disable (vat_main_t * vam)
19892 unformat_input_t *i = vam->input;
19893 vl_api_feature_enable_disable_t *mp;
19895 u8 *feature_name = 0;
19896 u32 sw_if_index = ~0;
19900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19902 if (unformat (i, "arc_name %s", &arc_name))
19904 else if (unformat (i, "feature_name %s", &feature_name))
19907 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19909 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19911 else if (unformat (i, "disable"))
19919 errmsg ("missing arc name");
19922 if (vec_len (arc_name) > 63)
19924 errmsg ("arc name too long");
19927 if (feature_name == 0)
19929 errmsg ("missing feature name");
19932 if (vec_len (feature_name) > 63)
19934 errmsg ("feature name too long");
19937 if (sw_if_index == ~0)
19939 errmsg ("missing interface name or sw_if_index");
19943 /* Construct the API message */
19944 M (FEATURE_ENABLE_DISABLE, mp);
19945 mp->sw_if_index = ntohl (sw_if_index);
19946 mp->enable = enable;
19947 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19948 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19949 vec_free (arc_name);
19950 vec_free (feature_name);
19958 api_sw_interface_tag_add_del (vat_main_t * vam)
19960 unformat_input_t *i = vam->input;
19961 vl_api_sw_interface_tag_add_del_t *mp;
19962 u32 sw_if_index = ~0;
19967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19969 if (unformat (i, "tag %s", &tag))
19971 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19973 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19975 else if (unformat (i, "del"))
19981 if (sw_if_index == ~0)
19983 errmsg ("missing interface name or sw_if_index");
19987 if (enable && (tag == 0))
19989 errmsg ("no tag specified");
19993 /* Construct the API message */
19994 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19995 mp->sw_if_index = ntohl (sw_if_index);
19996 mp->is_add = enable;
19998 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20007 api_sw_interface_add_del_mac_address (vat_main_t * vam)
20009 unformat_input_t *i = vam->input;
20010 vl_api_mac_address_t mac = { 0 };
20011 vl_api_sw_interface_add_del_mac_address_t *mp;
20012 u32 sw_if_index = ~0;
20017 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20019 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20021 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20023 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
20025 else if (unformat (i, "del"))
20031 if (sw_if_index == ~0)
20033 errmsg ("missing interface name or sw_if_index");
20039 errmsg ("missing MAC address");
20043 /* Construct the API message */
20044 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
20045 mp->sw_if_index = ntohl (sw_if_index);
20046 mp->is_add = is_add;
20047 clib_memcpy (&mp->addr, &mac, sizeof (mac));
20054 static void vl_api_l2_xconnect_details_t_handler
20055 (vl_api_l2_xconnect_details_t * mp)
20057 vat_main_t *vam = &vat_main;
20059 print (vam->ofp, "%15d%15d",
20060 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20063 static void vl_api_l2_xconnect_details_t_handler_json
20064 (vl_api_l2_xconnect_details_t * mp)
20066 vat_main_t *vam = &vat_main;
20067 vat_json_node_t *node = NULL;
20069 if (VAT_JSON_ARRAY != vam->json_tree.type)
20071 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20072 vat_json_init_array (&vam->json_tree);
20074 node = vat_json_array_add (&vam->json_tree);
20076 vat_json_init_object (node);
20077 vat_json_object_add_uint (node, "rx_sw_if_index",
20078 ntohl (mp->rx_sw_if_index));
20079 vat_json_object_add_uint (node, "tx_sw_if_index",
20080 ntohl (mp->tx_sw_if_index));
20084 api_l2_xconnect_dump (vat_main_t * vam)
20086 vl_api_l2_xconnect_dump_t *mp;
20087 vl_api_control_ping_t *mp_ping;
20090 if (!vam->json_output)
20092 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20095 M (L2_XCONNECT_DUMP, mp);
20099 /* Use a control ping for synchronization */
20100 MPING (CONTROL_PING, mp_ping);
20108 api_hw_interface_set_mtu (vat_main_t * vam)
20110 unformat_input_t *i = vam->input;
20111 vl_api_hw_interface_set_mtu_t *mp;
20112 u32 sw_if_index = ~0;
20116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20118 if (unformat (i, "mtu %d", &mtu))
20120 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20122 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20128 if (sw_if_index == ~0)
20130 errmsg ("missing interface name or sw_if_index");
20136 errmsg ("no mtu specified");
20140 /* Construct the API message */
20141 M (HW_INTERFACE_SET_MTU, mp);
20142 mp->sw_if_index = ntohl (sw_if_index);
20143 mp->mtu = ntohs ((u16) mtu);
20151 api_p2p_ethernet_add (vat_main_t * vam)
20153 unformat_input_t *i = vam->input;
20154 vl_api_p2p_ethernet_add_t *mp;
20155 u32 parent_if_index = ~0;
20161 clib_memset (remote_mac, 0, sizeof (remote_mac));
20162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20164 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20166 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20170 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20172 else if (unformat (i, "sub_id %d", &sub_id))
20176 clib_warning ("parse error '%U'", format_unformat_error, i);
20181 if (parent_if_index == ~0)
20183 errmsg ("missing interface name or sw_if_index");
20188 errmsg ("missing remote mac address");
20193 errmsg ("missing sub-interface id");
20197 M (P2P_ETHERNET_ADD, mp);
20198 mp->parent_if_index = ntohl (parent_if_index);
20199 mp->subif_id = ntohl (sub_id);
20200 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20208 api_p2p_ethernet_del (vat_main_t * vam)
20210 unformat_input_t *i = vam->input;
20211 vl_api_p2p_ethernet_del_t *mp;
20212 u32 parent_if_index = ~0;
20217 clib_memset (remote_mac, 0, sizeof (remote_mac));
20218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20220 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20222 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20226 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20230 clib_warning ("parse error '%U'", format_unformat_error, i);
20235 if (parent_if_index == ~0)
20237 errmsg ("missing interface name or sw_if_index");
20242 errmsg ("missing remote mac address");
20246 M (P2P_ETHERNET_DEL, mp);
20247 mp->parent_if_index = ntohl (parent_if_index);
20248 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20256 api_lldp_config (vat_main_t * vam)
20258 unformat_input_t *i = vam->input;
20259 vl_api_lldp_config_t *mp;
20261 int tx_interval = 0;
20262 u8 *sys_name = NULL;
20265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20267 if (unformat (i, "system-name %s", &sys_name))
20269 else if (unformat (i, "tx-hold %d", &tx_hold))
20271 else if (unformat (i, "tx-interval %d", &tx_interval))
20275 clib_warning ("parse error '%U'", format_unformat_error, i);
20280 vec_add1 (sys_name, 0);
20282 M (LLDP_CONFIG, mp);
20283 mp->tx_hold = htonl (tx_hold);
20284 mp->tx_interval = htonl (tx_interval);
20285 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20286 vec_free (sys_name);
20294 api_sw_interface_set_lldp (vat_main_t * vam)
20296 unformat_input_t *i = vam->input;
20297 vl_api_sw_interface_set_lldp_t *mp;
20298 u32 sw_if_index = ~0;
20300 u8 *port_desc = NULL, *mgmt_oid = NULL;
20301 ip4_address_t ip4_addr;
20302 ip6_address_t ip6_addr;
20305 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
20306 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
20308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20310 if (unformat (i, "disable"))
20313 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20315 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20317 else if (unformat (i, "port-desc %s", &port_desc))
20319 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20321 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20323 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20329 if (sw_if_index == ~0)
20331 errmsg ("missing interface name or sw_if_index");
20335 /* Construct the API message */
20336 vec_add1 (port_desc, 0);
20337 vec_add1 (mgmt_oid, 0);
20338 M (SW_INTERFACE_SET_LLDP, mp);
20339 mp->sw_if_index = ntohl (sw_if_index);
20340 mp->enable = enable;
20341 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20342 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20343 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20344 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20345 vec_free (port_desc);
20346 vec_free (mgmt_oid);
20354 api_tcp_configure_src_addresses (vat_main_t * vam)
20356 vl_api_tcp_configure_src_addresses_t *mp;
20357 unformat_input_t *i = vam->input;
20358 ip4_address_t v4first, v4last;
20359 ip6_address_t v6first, v6last;
20364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20366 if (unformat (i, "%U - %U",
20367 unformat_ip4_address, &v4first,
20368 unformat_ip4_address, &v4last))
20372 errmsg ("one range per message (range already set)");
20377 else if (unformat (i, "%U - %U",
20378 unformat_ip6_address, &v6first,
20379 unformat_ip6_address, &v6last))
20383 errmsg ("one range per message (range already set)");
20388 else if (unformat (i, "vrf %d", &vrf_id))
20394 if (range_set == 0)
20396 errmsg ("address range not set");
20400 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20401 mp->vrf_id = ntohl (vrf_id);
20403 if (range_set == 2)
20406 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20407 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20412 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20413 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20420 static void vl_api_app_namespace_add_del_reply_t_handler
20421 (vl_api_app_namespace_add_del_reply_t * mp)
20423 vat_main_t *vam = &vat_main;
20424 i32 retval = ntohl (mp->retval);
20425 if (vam->async_mode)
20427 vam->async_errors += (retval < 0);
20431 vam->retval = retval;
20433 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
20434 vam->result_ready = 1;
20438 static void vl_api_app_namespace_add_del_reply_t_handler_json
20439 (vl_api_app_namespace_add_del_reply_t * mp)
20441 vat_main_t *vam = &vat_main;
20442 vat_json_node_t node;
20444 vat_json_init_object (&node);
20445 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
20446 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
20448 vat_json_print (vam->ofp, &node);
20449 vat_json_free (&node);
20451 vam->retval = ntohl (mp->retval);
20452 vam->result_ready = 1;
20456 api_app_namespace_add_del (vat_main_t * vam)
20458 vl_api_app_namespace_add_del_t *mp;
20459 unformat_input_t *i = vam->input;
20460 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20461 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20467 if (unformat (i, "id %_%v%_", &ns_id))
20469 else if (unformat (i, "secret %lu", &secret))
20471 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20472 sw_if_index_set = 1;
20473 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20475 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20480 if (!ns_id || !secret_set || !sw_if_index_set)
20482 errmsg ("namespace id, secret and sw_if_index must be set");
20485 if (vec_len (ns_id) > 64)
20487 errmsg ("namespace id too long");
20490 M (APP_NAMESPACE_ADD_DEL, mp);
20492 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20493 mp->namespace_id_len = vec_len (ns_id);
20494 mp->secret = clib_host_to_net_u64 (secret);
20495 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20496 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20497 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20505 api_sock_init_shm (vat_main_t * vam)
20507 #if VPP_API_TEST_BUILTIN == 0
20508 unformat_input_t *i = vam->input;
20509 vl_api_shm_elem_config_t *config = 0;
20510 u64 size = 64 << 20;
20513 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20515 if (unformat (i, "size %U", unformat_memory_size, &size))
20522 * Canned custom ring allocator config.
20523 * Should probably parse all of this
20525 vec_validate (config, 6);
20526 config[0].type = VL_API_VLIB_RING;
20527 config[0].size = 256;
20528 config[0].count = 32;
20530 config[1].type = VL_API_VLIB_RING;
20531 config[1].size = 1024;
20532 config[1].count = 16;
20534 config[2].type = VL_API_VLIB_RING;
20535 config[2].size = 4096;
20536 config[2].count = 2;
20538 config[3].type = VL_API_CLIENT_RING;
20539 config[3].size = 256;
20540 config[3].count = 32;
20542 config[4].type = VL_API_CLIENT_RING;
20543 config[4].size = 1024;
20544 config[4].count = 16;
20546 config[5].type = VL_API_CLIENT_RING;
20547 config[5].size = 4096;
20548 config[5].count = 2;
20550 config[6].type = VL_API_QUEUE;
20551 config[6].count = 128;
20552 config[6].size = sizeof (uword);
20554 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
20556 vam->client_index_invalid = 1;
20564 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
20566 vat_main_t *vam = &vat_main;
20571 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20572 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20573 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
20574 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
20575 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20576 clib_net_to_host_u32 (mp->action_index), mp->tag);
20581 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20582 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20583 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
20584 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
20585 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20586 clib_net_to_host_u32 (mp->action_index), mp->tag);
20591 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
20594 vat_main_t *vam = &vat_main;
20595 vat_json_node_t *node = NULL;
20596 struct in6_addr ip6;
20597 struct in_addr ip4;
20599 if (VAT_JSON_ARRAY != vam->json_tree.type)
20601 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20602 vat_json_init_array (&vam->json_tree);
20604 node = vat_json_array_add (&vam->json_tree);
20605 vat_json_init_object (node);
20607 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
20608 vat_json_object_add_uint (node, "appns_index",
20609 clib_net_to_host_u32 (mp->appns_index));
20610 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
20611 vat_json_object_add_uint (node, "scope", mp->scope);
20612 vat_json_object_add_uint (node, "action_index",
20613 clib_net_to_host_u32 (mp->action_index));
20614 vat_json_object_add_uint (node, "lcl_port",
20615 clib_net_to_host_u16 (mp->lcl_port));
20616 vat_json_object_add_uint (node, "rmt_port",
20617 clib_net_to_host_u16 (mp->rmt_port));
20618 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
20619 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
20620 vat_json_object_add_string_copy (node, "tag", mp->tag);
20623 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
20624 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
20625 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
20626 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
20630 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
20631 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
20632 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
20633 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
20638 api_session_rule_add_del (vat_main_t * vam)
20640 vl_api_session_rule_add_del_t *mp;
20641 unformat_input_t *i = vam->input;
20642 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
20643 u32 appns_index = 0, scope = 0;
20644 ip4_address_t lcl_ip4, rmt_ip4;
20645 ip6_address_t lcl_ip6, rmt_ip6;
20646 u8 is_ip4 = 1, conn_set = 0;
20647 u8 is_add = 1, *tag = 0;
20650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20652 if (unformat (i, "del"))
20654 else if (unformat (i, "add"))
20656 else if (unformat (i, "proto tcp"))
20658 else if (unformat (i, "proto udp"))
20660 else if (unformat (i, "appns %d", &appns_index))
20662 else if (unformat (i, "scope %d", &scope))
20664 else if (unformat (i, "tag %_%v%_", &tag))
20668 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
20669 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
20677 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
20678 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
20684 else if (unformat (i, "action %d", &action))
20689 if (proto == ~0 || !conn_set || action == ~0)
20691 errmsg ("transport proto, connection and action must be set");
20697 errmsg ("scope should be 0-3");
20701 M (SESSION_RULE_ADD_DEL, mp);
20703 mp->is_ip4 = is_ip4;
20704 mp->transport_proto = proto;
20705 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
20706 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
20707 mp->lcl_plen = lcl_plen;
20708 mp->rmt_plen = rmt_plen;
20709 mp->action_index = clib_host_to_net_u32 (action);
20710 mp->appns_index = clib_host_to_net_u32 (appns_index);
20712 mp->is_add = is_add;
20715 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
20716 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
20720 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
20721 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
20725 clib_memcpy (mp->tag, tag, vec_len (tag));
20735 api_session_rules_dump (vat_main_t * vam)
20737 vl_api_session_rules_dump_t *mp;
20738 vl_api_control_ping_t *mp_ping;
20741 if (!vam->json_output)
20743 print (vam->ofp, "%=20s", "Session Rules");
20746 M (SESSION_RULES_DUMP, mp);
20750 /* Use a control ping for synchronization */
20751 MPING (CONTROL_PING, mp_ping);
20754 /* Wait for a reply... */
20760 api_ip_container_proxy_add_del (vat_main_t * vam)
20762 vl_api_ip_container_proxy_add_del_t *mp;
20763 unformat_input_t *i = vam->input;
20764 u32 sw_if_index = ~0;
20765 vl_api_prefix_t pfx = { };
20769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20771 if (unformat (i, "del"))
20773 else if (unformat (i, "add"))
20775 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
20777 else if (unformat (i, "sw_if_index %u", &sw_if_index))
20782 if (sw_if_index == ~0 || pfx.len == 0)
20784 errmsg ("address and sw_if_index must be set");
20788 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
20790 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20791 mp->is_add = is_add;
20792 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
20800 api_qos_record_enable_disable (vat_main_t * vam)
20802 unformat_input_t *i = vam->input;
20803 vl_api_qos_record_enable_disable_t *mp;
20804 u32 sw_if_index, qs = 0xff;
20805 u8 sw_if_index_set = 0;
20809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20811 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20812 sw_if_index_set = 1;
20813 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20814 sw_if_index_set = 1;
20815 else if (unformat (i, "%U", unformat_qos_source, &qs))
20817 else if (unformat (i, "disable"))
20821 clib_warning ("parse error '%U'", format_unformat_error, i);
20826 if (sw_if_index_set == 0)
20828 errmsg ("missing interface name or sw_if_index");
20833 errmsg ("input location must be specified");
20837 M (QOS_RECORD_ENABLE_DISABLE, mp);
20839 mp->record.sw_if_index = ntohl (sw_if_index);
20840 mp->record.input_source = qs;
20841 mp->enable = enable;
20850 q_or_quit (vat_main_t * vam)
20852 #if VPP_API_TEST_BUILTIN == 0
20853 longjmp (vam->jump_buf, 1);
20855 return 0; /* not so much */
20859 q (vat_main_t * vam)
20861 return q_or_quit (vam);
20865 quit (vat_main_t * vam)
20867 return q_or_quit (vam);
20871 comment (vat_main_t * vam)
20877 elog_save (vat_main_t * vam)
20879 #if VPP_API_TEST_BUILTIN == 0
20880 elog_main_t *em = &vam->elog_main;
20881 unformat_input_t *i = vam->input;
20882 char *file, *chroot_file;
20883 clib_error_t *error;
20885 if (!unformat (i, "%s", &file))
20887 errmsg ("expected file name, got `%U'", format_unformat_error, i);
20891 /* It's fairly hard to get "../oopsie" through unformat; just in case */
20892 if (strstr (file, "..") || index (file, '/'))
20894 errmsg ("illegal characters in filename '%s'", file);
20898 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
20902 errmsg ("Saving %wd of %wd events to %s",
20903 elog_n_events_in_buffer (em),
20904 elog_buffer_capacity (em), chroot_file);
20906 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
20907 vec_free (chroot_file);
20910 clib_error_report (error);
20912 errmsg ("Use the vpp event loger...");
20919 elog_setup (vat_main_t * vam)
20921 #if VPP_API_TEST_BUILTIN == 0
20922 elog_main_t *em = &vam->elog_main;
20923 unformat_input_t *i = vam->input;
20924 u32 nevents = 128 << 10;
20926 (void) unformat (i, "nevents %d", &nevents);
20928 elog_init (em, nevents);
20929 vl_api_set_elog_main (em);
20930 vl_api_set_elog_trace_api_messages (1);
20931 errmsg ("Event logger initialized with %u events", nevents);
20933 errmsg ("Use the vpp event loger...");
20939 elog_enable (vat_main_t * vam)
20941 #if VPP_API_TEST_BUILTIN == 0
20942 elog_main_t *em = &vam->elog_main;
20944 elog_enable_disable (em, 1 /* enable */ );
20945 vl_api_set_elog_trace_api_messages (1);
20946 errmsg ("Event logger enabled...");
20948 errmsg ("Use the vpp event loger...");
20954 elog_disable (vat_main_t * vam)
20956 #if VPP_API_TEST_BUILTIN == 0
20957 elog_main_t *em = &vam->elog_main;
20959 elog_enable_disable (em, 0 /* enable */ );
20960 vl_api_set_elog_trace_api_messages (1);
20961 errmsg ("Event logger disabled...");
20963 errmsg ("Use the vpp event loger...");
20969 statseg (vat_main_t * vam)
20971 ssvm_private_t *ssvmp = &vam->stat_segment;
20972 ssvm_shared_header_t *shared_header = ssvmp->sh;
20973 vlib_counter_t **counters;
20974 u64 thread0_index1_packets;
20975 u64 thread0_index1_bytes;
20976 f64 vector_rate, input_rate;
20979 uword *counter_vector_by_name;
20980 if (vam->stat_segment_lockp == 0)
20982 errmsg ("Stat segment not mapped...");
20986 /* look up "/if/rx for sw_if_index 1 as a test */
20988 clib_spinlock_lock (vam->stat_segment_lockp);
20990 counter_vector_by_name = (uword *) shared_header->opaque[1];
20992 p = hash_get_mem (counter_vector_by_name, "/if/rx");
20995 clib_spinlock_unlock (vam->stat_segment_lockp);
20996 errmsg ("/if/tx not found?");
21000 /* Fish per-thread vector of combined counters from shared memory */
21001 counters = (vlib_counter_t **) p[0];
21003 if (vec_len (counters[0]) < 2)
21005 clib_spinlock_unlock (vam->stat_segment_lockp);
21006 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21010 /* Read thread 0 sw_if_index 1 counter */
21011 thread0_index1_packets = counters[0][1].packets;
21012 thread0_index1_bytes = counters[0][1].bytes;
21014 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21017 clib_spinlock_unlock (vam->stat_segment_lockp);
21018 errmsg ("vector_rate not found?");
21022 vector_rate = *(f64 *) (p[0]);
21023 p = hash_get_mem (counter_vector_by_name, "input_rate");
21026 clib_spinlock_unlock (vam->stat_segment_lockp);
21027 errmsg ("input_rate not found?");
21030 input_rate = *(f64 *) (p[0]);
21032 clib_spinlock_unlock (vam->stat_segment_lockp);
21034 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21035 vector_rate, input_rate);
21036 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21037 thread0_index1_packets, thread0_index1_bytes);
21043 cmd_cmp (void *a1, void *a2)
21048 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21052 help (vat_main_t * vam)
21057 unformat_input_t *i = vam->input;
21060 if (unformat (i, "%s", &name))
21064 vec_add1 (name, 0);
21066 hs = hash_get_mem (vam->help_by_name, name);
21068 print (vam->ofp, "usage: %s %s", name, hs[0]);
21070 print (vam->ofp, "No such msg / command '%s'", name);
21075 print (vam->ofp, "Help is available for the following:");
21078 hash_foreach_pair (p, vam->function_by_name,
21080 vec_add1 (cmds, (u8 *)(p->key));
21084 vec_sort_with_function (cmds, cmd_cmp);
21086 for (j = 0; j < vec_len (cmds); j++)
21087 print (vam->ofp, "%s", cmds[j]);
21094 set (vat_main_t * vam)
21096 u8 *name = 0, *value = 0;
21097 unformat_input_t *i = vam->input;
21099 if (unformat (i, "%s", &name))
21101 /* The input buffer is a vector, not a string. */
21102 value = vec_dup (i->buffer);
21103 vec_delete (value, i->index, 0);
21104 /* Almost certainly has a trailing newline */
21105 if (value[vec_len (value) - 1] == '\n')
21106 value[vec_len (value) - 1] = 0;
21107 /* Make sure it's a proper string, one way or the other */
21108 vec_add1 (value, 0);
21109 (void) clib_macro_set_value (&vam->macro_main,
21110 (char *) name, (char *) value);
21113 errmsg ("usage: set <name> <value>");
21121 unset (vat_main_t * vam)
21125 if (unformat (vam->input, "%s", &name))
21126 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21127 errmsg ("unset: %s wasn't set", name);
21140 macro_sort_cmp (void *a1, void *a2)
21142 macro_sort_t *s1 = a1;
21143 macro_sort_t *s2 = a2;
21145 return strcmp ((char *) (s1->name), (char *) (s2->name));
21149 dump_macro_table (vat_main_t * vam)
21151 macro_sort_t *sort_me = 0, *sm;
21156 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21158 vec_add2 (sort_me, sm, 1);
21159 sm->name = (u8 *)(p->key);
21160 sm->value = (u8 *) (p->value[0]);
21164 vec_sort_with_function (sort_me, macro_sort_cmp);
21166 if (vec_len (sort_me))
21167 print (vam->ofp, "%-15s%s", "Name", "Value");
21169 print (vam->ofp, "The macro table is empty...");
21171 for (i = 0; i < vec_len (sort_me); i++)
21172 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21177 dump_node_table (vat_main_t * vam)
21180 vlib_node_t *node, *next_node;
21182 if (vec_len (vam->graph_nodes) == 0)
21184 print (vam->ofp, "Node table empty, issue get_node_graph...");
21188 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
21190 node = vam->graph_nodes[0][i];
21191 print (vam->ofp, "[%d] %s", i, node->name);
21192 for (j = 0; j < vec_len (node->next_nodes); j++)
21194 if (node->next_nodes[j] != ~0)
21196 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21197 print (vam->ofp, " [%d] %s", j, next_node->name);
21205 value_sort_cmp (void *a1, void *a2)
21207 name_sort_t *n1 = a1;
21208 name_sort_t *n2 = a2;
21210 if (n1->value < n2->value)
21212 if (n1->value > n2->value)
21219 dump_msg_api_table (vat_main_t * vam)
21221 api_main_t *am = &api_main;
21222 name_sort_t *nses = 0, *ns;
21227 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21229 vec_add2 (nses, ns, 1);
21230 ns->name = (u8 *)(hp->key);
21231 ns->value = (u32) hp->value[0];
21235 vec_sort_with_function (nses, value_sort_cmp);
21237 for (i = 0; i < vec_len (nses); i++)
21238 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21244 get_msg_id (vat_main_t * vam)
21249 if (unformat (vam->input, "%s", &name_and_crc))
21251 message_index = vl_msg_api_get_msg_index (name_and_crc);
21252 if (message_index == ~0)
21254 print (vam->ofp, " '%s' not found", name_and_crc);
21257 print (vam->ofp, " '%s' has message index %d",
21258 name_and_crc, message_index);
21261 errmsg ("name_and_crc required...");
21266 search_node_table (vat_main_t * vam)
21268 unformat_input_t *line_input = vam->input;
21271 vlib_node_t *node, *next_node;
21274 if (vam->graph_node_index_by_name == 0)
21276 print (vam->ofp, "Node table empty, issue get_node_graph...");
21280 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21282 if (unformat (line_input, "%s", &node_to_find))
21284 vec_add1 (node_to_find, 0);
21285 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21288 print (vam->ofp, "%s not found...", node_to_find);
21291 node = vam->graph_nodes[0][p[0]];
21292 print (vam->ofp, "[%d] %s", p[0], node->name);
21293 for (j = 0; j < vec_len (node->next_nodes); j++)
21295 if (node->next_nodes[j] != ~0)
21297 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21298 print (vam->ofp, " [%d] %s", j, next_node->name);
21305 clib_warning ("parse error '%U'", format_unformat_error,
21311 vec_free (node_to_find);
21320 script (vat_main_t * vam)
21322 #if (VPP_API_TEST_BUILTIN==0)
21324 char *save_current_file;
21325 unformat_input_t save_input;
21326 jmp_buf save_jump_buf;
21327 u32 save_line_number;
21329 FILE *new_fp, *save_ifp;
21331 if (unformat (vam->input, "%s", &s))
21333 new_fp = fopen ((char *) s, "r");
21336 errmsg ("Couldn't open script file %s", s);
21343 errmsg ("Missing script name");
21347 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21348 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21349 save_ifp = vam->ifp;
21350 save_line_number = vam->input_line_number;
21351 save_current_file = (char *) vam->current_file;
21353 vam->input_line_number = 0;
21355 vam->current_file = s;
21358 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
21359 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21360 vam->ifp = save_ifp;
21361 vam->input_line_number = save_line_number;
21362 vam->current_file = (u8 *) save_current_file;
21367 clib_warning ("use the exec command...");
21373 echo (vat_main_t * vam)
21375 print (vam->ofp, "%v", vam->input->buffer);
21379 /* List of API message constructors, CLI names map to api_xxx */
21380 #define foreach_vpe_api_msg \
21381 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21382 _(sw_interface_dump,"") \
21383 _(sw_interface_set_flags, \
21384 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21385 _(sw_interface_add_del_address, \
21386 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21387 _(sw_interface_set_rx_mode, \
21388 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
21389 _(sw_interface_set_rx_placement, \
21390 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
21391 _(sw_interface_rx_placement_dump, \
21392 "[<intfc> | sw_if_index <id>]") \
21393 _(sw_interface_set_table, \
21394 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21395 _(sw_interface_set_mpls_enable, \
21396 "<intfc> | sw_if_index [disable | dis]") \
21397 _(sw_interface_set_vpath, \
21398 "<intfc> | sw_if_index <id> enable | disable") \
21399 _(sw_interface_set_vxlan_bypass, \
21400 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21401 _(sw_interface_set_geneve_bypass, \
21402 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21403 _(sw_interface_set_l2_xconnect, \
21404 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21405 "enable | disable") \
21406 _(sw_interface_set_l2_bridge, \
21407 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21408 "[shg <split-horizon-group>] [bvi]\n" \
21409 "enable | disable") \
21410 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21411 _(bridge_domain_add_del, \
21412 "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") \
21413 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21415 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21416 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21417 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21419 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21421 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21423 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
21425 "<vpp-if-name> | sw_if_index <id>") \
21426 _(sw_interface_tap_v2_dump, "") \
21427 _(virtio_pci_create, \
21428 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled]") \
21429 _(virtio_pci_delete, \
21430 "<vpp-if-name> | sw_if_index <id>") \
21431 _(sw_interface_virtio_pci_dump, "") \
21433 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
21434 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
21437 "<vpp-if-name> | sw_if_index <id>") \
21439 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
21440 _(bond_detach_slave, \
21441 "sw_if_index <n>") \
21442 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
21443 _(sw_interface_bond_dump, "") \
21444 _(sw_interface_slave_dump, \
21445 "<vpp-if-name> | sw_if_index <id>") \
21446 _(ip_table_add_del, \
21447 "table <n> [ipv6] [add | del]\n") \
21448 _(ip_route_add_del, \
21449 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
21450 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
21451 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
21452 "[multipath] [count <n>] [del]") \
21453 _(ip_mroute_add_del, \
21454 "<src> <grp>/<mask> [table-id <n>]\n" \
21455 "[<intfc> | sw_if_index <id>] [local] [del]") \
21456 _(mpls_table_add_del, \
21457 "table <n> [add | del]\n") \
21458 _(mpls_route_add_del, \
21459 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
21460 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
21461 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
21462 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
21463 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
21464 "[count <n>] [del]") \
21465 _(mpls_ip_bind_unbind, \
21466 "<label> <addr/len>") \
21467 _(mpls_tunnel_add_del, \
21468 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
21469 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
21470 "[l2-only] [out-label <n>]") \
21471 _(sr_mpls_policy_add, \
21472 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
21473 _(sr_mpls_policy_del, \
21475 _(bier_table_add_del, \
21476 "<label> <sub-domain> <set> <bsl> [del]") \
21477 _(bier_route_add_del, \
21478 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
21479 "[<intfc> | sw_if_index <id>]" \
21480 "[weight <n>] [del] [multipath]") \
21481 _(proxy_arp_add_del, \
21482 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21483 _(proxy_arp_intfc_enable_disable, \
21484 "<intfc> | sw_if_index <id> enable | disable") \
21485 _(sw_interface_set_unnumbered, \
21486 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21487 _(ip_neighbor_add_del, \
21488 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21489 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21490 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21491 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21492 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21493 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21494 "[outer_vlan_id_any][inner_vlan_id_any]") \
21495 _(reset_fib, "vrf <n> [ipv6]") \
21496 _(set_ip_flow_hash, \
21497 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21498 _(sw_interface_ip6_enable_disable, \
21499 "<intfc> | sw_if_index <id> enable | disable") \
21500 _(ip6nd_proxy_add_del, \
21501 "<intfc> | sw_if_index <id> <ip6-address>") \
21502 _(ip6nd_proxy_dump, "") \
21503 _(sw_interface_ip6nd_ra_prefix, \
21504 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21505 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21506 "[nolink] [isno]") \
21507 _(sw_interface_ip6nd_ra_config, \
21508 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21509 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21510 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21511 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21512 _(l2_patch_add_del, \
21513 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21514 "enable | disable") \
21515 _(sr_localsid_add_del, \
21516 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21517 "fib-table <num> (end.psp) sw_if_index <num>") \
21518 _(classify_add_del_table, \
21519 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21520 " [del] [del-chain] mask <mask-value>\n" \
21521 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21522 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21523 _(classify_add_del_session, \
21524 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21525 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21526 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21527 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21528 _(classify_set_interface_ip_table, \
21529 "<intfc> | sw_if_index <nn> table <nn>") \
21530 _(classify_set_interface_l2_tables, \
21531 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21532 " [other-table <nn>]") \
21533 _(get_node_index, "node <node-name") \
21534 _(add_node_next, "node <node-name> next <next-node-name>") \
21535 _(l2tpv3_create_tunnel, \
21536 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21537 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21538 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21539 _(l2tpv3_set_tunnel_cookies, \
21540 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21541 "[new_remote_cookie <nn>]\n") \
21542 _(l2tpv3_interface_enable_disable, \
21543 "<intfc> | sw_if_index <nn> enable | disable") \
21544 _(l2tpv3_set_lookup_key, \
21545 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21546 _(sw_if_l2tpv3_tunnel_dump, "") \
21547 _(vxlan_offload_rx, \
21548 "hw { <interface name> | hw_if_index <nn>} " \
21549 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
21550 _(vxlan_add_del_tunnel, \
21551 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21552 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
21553 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21554 _(geneve_add_del_tunnel, \
21555 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21556 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21557 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21558 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21559 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21560 _(gre_tunnel_add_del, \
21561 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
21562 "[teb | erspan <session-id>] [del]") \
21563 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21564 _(l2_fib_clear_table, "") \
21565 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21566 _(l2_interface_vlan_tag_rewrite, \
21567 "<intfc> | sw_if_index <nn> \n" \
21568 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21569 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21570 _(create_vhost_user_if, \
21571 "socket <filename> [server] [renumber <dev_instance>] " \
21572 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
21573 "[mac <mac_address>]") \
21574 _(modify_vhost_user_if, \
21575 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21576 "[server] [renumber <dev_instance>] [gso]") \
21577 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21578 _(sw_interface_vhost_user_dump, "") \
21579 _(show_version, "") \
21580 _(show_threads, "") \
21581 _(vxlan_gpe_add_del_tunnel, \
21582 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21583 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21584 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21585 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21586 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21587 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21588 _(interface_name_renumber, \
21589 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21590 _(input_acl_set_interface, \
21591 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21592 " [l2-table <nn>] [del]") \
21593 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
21594 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
21595 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
21596 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21597 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21598 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21599 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21600 _(ip_dump, "ipv4 | ipv6") \
21601 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21602 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21604 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21605 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21606 " integ_alg <alg> integ_key <hex>") \
21607 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
21608 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21609 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21610 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21611 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21612 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21613 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21614 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
21615 " [instance <n>]") \
21616 _(ipsec_sa_dump, "[sa_id <n>]") \
21617 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
21618 _(delete_loopback,"sw_if_index <nn>") \
21619 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21620 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
21621 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
21622 _(want_interface_events, "enable|disable") \
21623 _(get_first_msg_id, "client <name>") \
21624 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21625 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21626 "fib-id <nn> [ip4][ip6][default]") \
21627 _(get_node_graph, " ") \
21628 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21629 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21630 _(ioam_disable, "") \
21631 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21632 " sw_if_index <sw_if_index> p <priority> " \
21633 "w <weight>] [del]") \
21634 _(one_add_del_locator, "locator-set <locator_name> " \
21635 "iface <intf> | sw_if_index <sw_if_index> " \
21636 "p <priority> w <weight> [del]") \
21637 _(one_add_del_local_eid,"vni <vni> eid " \
21638 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21639 "locator-set <locator_name> [del]" \
21640 "[key-id sha1|sha256 secret-key <secret-key>]")\
21641 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21642 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21643 _(one_enable_disable, "enable|disable") \
21644 _(one_map_register_enable_disable, "enable|disable") \
21645 _(one_map_register_fallback_threshold, "<value>") \
21646 _(one_rloc_probe_enable_disable, "enable|disable") \
21647 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21649 "rloc <locator> p <prio> " \
21650 "w <weight> [rloc <loc> ... ] " \
21651 "action <action> [del-all]") \
21652 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21654 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21655 _(one_use_petr, "ip-address> | disable") \
21656 _(one_map_request_mode, "src-dst|dst-only") \
21657 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21658 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21659 _(one_locator_set_dump, "[local | remote]") \
21660 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21661 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21662 "[local] | [remote]") \
21663 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21664 _(one_ndp_bd_get, "") \
21665 _(one_ndp_entries_get, "bd <bridge-domain>") \
21666 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21667 _(one_l2_arp_bd_get, "") \
21668 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21669 _(one_stats_enable_disable, "enable|disable") \
21670 _(show_one_stats_enable_disable, "") \
21671 _(one_eid_table_vni_dump, "") \
21672 _(one_eid_table_map_dump, "l2|l3") \
21673 _(one_map_resolver_dump, "") \
21674 _(one_map_server_dump, "") \
21675 _(one_adjacencies_get, "vni <vni>") \
21676 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21677 _(show_one_rloc_probe_state, "") \
21678 _(show_one_map_register_state, "") \
21679 _(show_one_status, "") \
21680 _(one_stats_dump, "") \
21681 _(one_stats_flush, "") \
21682 _(one_get_map_request_itr_rlocs, "") \
21683 _(one_map_register_set_ttl, "<ttl>") \
21684 _(one_set_transport_protocol, "udp|api") \
21685 _(one_get_transport_protocol, "") \
21686 _(one_enable_disable_xtr_mode, "enable|disable") \
21687 _(one_show_xtr_mode, "") \
21688 _(one_enable_disable_pitr_mode, "enable|disable") \
21689 _(one_show_pitr_mode, "") \
21690 _(one_enable_disable_petr_mode, "enable|disable") \
21691 _(one_show_petr_mode, "") \
21692 _(show_one_nsh_mapping, "") \
21693 _(show_one_pitr, "") \
21694 _(show_one_use_petr, "") \
21695 _(show_one_map_request_mode, "") \
21696 _(show_one_map_register_ttl, "") \
21697 _(show_one_map_register_fallback_threshold, "") \
21698 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21699 " sw_if_index <sw_if_index> p <priority> " \
21700 "w <weight>] [del]") \
21701 _(lisp_add_del_locator, "locator-set <locator_name> " \
21702 "iface <intf> | sw_if_index <sw_if_index> " \
21703 "p <priority> w <weight> [del]") \
21704 _(lisp_add_del_local_eid,"vni <vni> eid " \
21705 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21706 "locator-set <locator_name> [del]" \
21707 "[key-id sha1|sha256 secret-key <secret-key>]") \
21708 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21709 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21710 _(lisp_enable_disable, "enable|disable") \
21711 _(lisp_map_register_enable_disable, "enable|disable") \
21712 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21713 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21715 "rloc <locator> p <prio> " \
21716 "w <weight> [rloc <loc> ... ] " \
21717 "action <action> [del-all]") \
21718 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21720 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21721 _(lisp_use_petr, "<ip-address> | disable") \
21722 _(lisp_map_request_mode, "src-dst|dst-only") \
21723 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21724 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21725 _(lisp_locator_set_dump, "[local | remote]") \
21726 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21727 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21728 "[local] | [remote]") \
21729 _(lisp_eid_table_vni_dump, "") \
21730 _(lisp_eid_table_map_dump, "l2|l3") \
21731 _(lisp_map_resolver_dump, "") \
21732 _(lisp_map_server_dump, "") \
21733 _(lisp_adjacencies_get, "vni <vni>") \
21734 _(gpe_fwd_entry_vnis_get, "") \
21735 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21736 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21737 "[table <table-id>]") \
21738 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21739 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21740 _(gpe_set_encap_mode, "lisp|vxlan") \
21741 _(gpe_get_encap_mode, "") \
21742 _(lisp_gpe_add_del_iface, "up|down") \
21743 _(lisp_gpe_enable_disable, "enable|disable") \
21744 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21745 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21746 _(show_lisp_rloc_probe_state, "") \
21747 _(show_lisp_map_register_state, "") \
21748 _(show_lisp_status, "") \
21749 _(lisp_get_map_request_itr_rlocs, "") \
21750 _(show_lisp_pitr, "") \
21751 _(show_lisp_use_petr, "") \
21752 _(show_lisp_map_request_mode, "") \
21753 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21754 _(af_packet_delete, "name <host interface name>") \
21755 _(af_packet_dump, "") \
21756 _(policer_add_del, "name <policer name> <params> [del]") \
21757 _(policer_dump, "[name <policer name>]") \
21758 _(policer_classify_set_interface, \
21759 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21760 " [l2-table <nn>] [del]") \
21761 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21762 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21763 "[master|slave]") \
21764 _(netmap_delete, "name <interface name>") \
21765 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21766 _(mpls_table_dump, "") \
21767 _(mpls_route_dump, "table-id <ID>") \
21768 _(classify_table_ids, "") \
21769 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21770 _(classify_table_info, "table_id <nn>") \
21771 _(classify_session_dump, "table_id <nn>") \
21772 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21773 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21774 "[template_interval <nn>] [udp_checksum]") \
21775 _(ipfix_exporter_dump, "") \
21776 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21777 _(ipfix_classify_stream_dump, "") \
21778 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21779 _(ipfix_classify_table_dump, "") \
21780 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21781 _(sw_interface_span_dump, "[l2]") \
21782 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21783 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
21784 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21785 _(pg_enable_disable, "[stream <id>] disable") \
21786 _(ip_source_and_port_range_check_add_del, \
21787 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21788 _(ip_source_and_port_range_check_interface_add_del, \
21789 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21790 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21791 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21792 _(l2_interface_pbb_tag_rewrite, \
21793 "<intfc> | sw_if_index <nn> \n" \
21794 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21795 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21796 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21797 _(flow_classify_set_interface, \
21798 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21799 _(flow_classify_dump, "type [ip4|ip6]") \
21800 _(ip_table_dump, "") \
21801 _(ip_route_dump, "table-id [ip4|ip6]") \
21802 _(ip_mtable_dump, "") \
21803 _(ip_mroute_dump, "table-id [ip4|ip6]") \
21804 _(feature_enable_disable, "arc_name <arc_name> " \
21805 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21806 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21808 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
21809 "mac <mac-address> [del]") \
21810 _(l2_xconnect_dump, "") \
21811 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
21812 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21813 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21814 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21815 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21816 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21817 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21818 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21819 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21820 _(sock_init_shm, "size <nnn>") \
21821 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21822 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
21823 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
21824 _(session_rules_dump, "") \
21825 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
21826 _(output_acl_set_interface, \
21827 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21828 " [l2-table <nn>] [del]") \
21829 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
21831 /* List of command functions, CLI names map directly to functions */
21832 #define foreach_cli_function \
21833 _(comment, "usage: comment <ignore-rest-of-line>") \
21834 _(dump_interface_table, "usage: dump_interface_table") \
21835 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21836 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21837 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21838 _(dump_macro_table, "usage: dump_macro_table ") \
21839 _(dump_node_table, "usage: dump_node_table") \
21840 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21841 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
21842 _(elog_disable, "usage: elog_disable") \
21843 _(elog_enable, "usage: elog_enable") \
21844 _(elog_save, "usage: elog_save <filename>") \
21845 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21846 _(echo, "usage: echo <message>") \
21847 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21848 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21849 _(help, "usage: help") \
21850 _(q, "usage: quit") \
21851 _(quit, "usage: quit") \
21852 _(search_node_table, "usage: search_node_table <name>...") \
21853 _(set, "usage: set <variable-name> <value>") \
21854 _(script, "usage: script <file-name>") \
21855 _(statseg, "usage: statseg") \
21856 _(unset, "usage: unset <variable-name>")
21859 static void vl_api_##n##_t_handler_uni \
21860 (vl_api_##n##_t * mp) \
21862 vat_main_t * vam = &vat_main; \
21863 if (vam->json_output) { \
21864 vl_api_##n##_t_handler_json(mp); \
21866 vl_api_##n##_t_handler(mp); \
21869 foreach_vpe_api_reply_msg;
21870 #if VPP_API_TEST_BUILTIN == 0
21871 foreach_standalone_reply_msg;
21876 vat_api_hookup (vat_main_t * vam)
21879 vl_msg_api_set_handlers(VL_API_##N, #n, \
21880 vl_api_##n##_t_handler_uni, \
21882 vl_api_##n##_t_endian, \
21883 vl_api_##n##_t_print, \
21884 sizeof(vl_api_##n##_t), 1);
21885 foreach_vpe_api_reply_msg;
21886 #if VPP_API_TEST_BUILTIN == 0
21887 foreach_standalone_reply_msg;
21891 #if (VPP_API_TEST_BUILTIN==0)
21892 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21894 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21896 vam->function_by_name = hash_create_string (0, sizeof (uword));
21898 vam->help_by_name = hash_create_string (0, sizeof (uword));
21901 /* API messages we can send */
21902 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21903 foreach_vpe_api_msg;
21907 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21908 foreach_vpe_api_msg;
21911 /* CLI functions */
21912 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21913 foreach_cli_function;
21917 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21918 foreach_cli_function;
21922 #if VPP_API_TEST_BUILTIN
21923 static clib_error_t *
21924 vat_api_hookup_shim (vlib_main_t * vm)
21926 vat_api_hookup (&vat_main);
21930 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21934 * fd.io coding-style-patch-verification: ON
21937 * eval: (c-set-style "gnu")