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 _(feature_gso_enable_disable_reply) \
5178 _(sw_interface_tag_add_del_reply) \
5179 _(sw_interface_add_del_mac_address_reply) \
5180 _(hw_interface_set_mtu_reply) \
5181 _(p2p_ethernet_add_reply) \
5182 _(p2p_ethernet_del_reply) \
5183 _(lldp_config_reply) \
5184 _(sw_interface_set_lldp_reply) \
5185 _(tcp_configure_src_addresses_reply) \
5186 _(session_rule_add_del_reply) \
5187 _(ip_container_proxy_add_del_reply) \
5188 _(output_acl_set_interface_reply) \
5189 _(qos_record_enable_disable_reply)
5192 static void vl_api_##n##_t_handler \
5193 (vl_api_##n##_t * mp) \
5195 vat_main_t * vam = &vat_main; \
5196 i32 retval = ntohl(mp->retval); \
5197 if (vam->async_mode) { \
5198 vam->async_errors += (retval < 0); \
5200 vam->retval = retval; \
5201 vam->result_ready = 1; \
5204 foreach_standard_reply_retval_handler;
5208 static void vl_api_##n##_t_handler_json \
5209 (vl_api_##n##_t * mp) \
5211 vat_main_t * vam = &vat_main; \
5212 vat_json_node_t node; \
5213 vat_json_init_object(&node); \
5214 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5215 vat_json_print(vam->ofp, &node); \
5216 vam->retval = ntohl(mp->retval); \
5217 vam->result_ready = 1; \
5219 foreach_standard_reply_retval_handler;
5223 * Table of message reply handlers, must include boilerplate handlers
5227 #define foreach_vpe_api_reply_msg \
5228 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5229 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5230 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5231 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5232 _(CONTROL_PING_REPLY, control_ping_reply) \
5233 _(CLI_REPLY, cli_reply) \
5234 _(CLI_INBAND_REPLY, cli_inband_reply) \
5235 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5236 sw_interface_add_del_address_reply) \
5237 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5238 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5239 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5240 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5241 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5242 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5243 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5244 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5245 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5246 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5247 sw_interface_set_l2_xconnect_reply) \
5248 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5249 sw_interface_set_l2_bridge_reply) \
5250 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5251 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5252 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5253 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5254 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5255 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5256 _(L2_FLAGS_REPLY, l2_flags_reply) \
5257 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5258 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5259 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5260 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5261 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5262 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5263 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5264 _(BOND_CREATE_REPLY, bond_create_reply) \
5265 _(BOND_DELETE_REPLY, bond_delete_reply) \
5266 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5267 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5268 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5269 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5270 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5271 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5272 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5273 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5274 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5275 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5276 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5277 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5278 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5279 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5280 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5281 proxy_arp_intfc_enable_disable_reply) \
5282 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5283 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5284 sw_interface_set_unnumbered_reply) \
5285 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5286 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5287 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5288 _(RESET_FIB_REPLY, reset_fib_reply) \
5289 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5290 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5291 sw_interface_ip6_enable_disable_reply) \
5292 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5293 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5294 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5295 sw_interface_ip6nd_ra_prefix_reply) \
5296 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5297 sw_interface_ip6nd_ra_config_reply) \
5298 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5299 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5300 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5301 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5302 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5303 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5304 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5305 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5306 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5307 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5308 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5309 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5310 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5311 classify_set_interface_ip_table_reply) \
5312 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5313 classify_set_interface_l2_tables_reply) \
5314 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5315 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5316 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5317 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5318 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5319 l2tpv3_interface_enable_disable_reply) \
5320 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5321 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5322 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5323 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5324 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5325 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5326 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5327 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5328 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5329 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5330 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5331 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5332 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5333 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5334 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5335 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5336 _(SHOW_VERSION_REPLY, show_version_reply) \
5337 _(SHOW_THREADS_REPLY, show_threads_reply) \
5338 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5339 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5340 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5341 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5342 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5343 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5344 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5345 _(IP4_ARP_EVENT, ip4_arp_event) \
5346 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5347 _(IP6_ND_EVENT, ip6_nd_event) \
5348 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5349 _(L2_MACS_EVENT, l2_macs_event) \
5350 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5351 _(IP_ADDRESS_DETAILS, ip_address_details) \
5352 _(IP_DETAILS, ip_details) \
5353 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5354 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5355 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5356 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5357 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5358 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5359 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5360 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5361 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5362 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5363 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5364 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5365 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5366 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5367 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5368 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5369 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5370 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5371 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5372 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5373 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5374 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5375 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5376 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5377 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5378 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5379 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5380 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5381 one_map_register_enable_disable_reply) \
5382 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5383 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5384 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5385 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5386 one_map_register_fallback_threshold_reply) \
5387 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5388 one_rloc_probe_enable_disable_reply) \
5389 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5390 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5391 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5392 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5393 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5394 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5395 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5396 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5397 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5398 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5399 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5400 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5401 _(ONE_STATS_DETAILS, one_stats_details) \
5402 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5403 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5404 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5405 show_one_stats_enable_disable_reply) \
5406 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5407 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5408 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5409 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5410 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5411 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5412 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5413 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5414 one_enable_disable_pitr_mode_reply) \
5415 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5416 one_enable_disable_petr_mode_reply) \
5417 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5418 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5419 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5420 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5421 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5422 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5423 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5424 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5425 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5426 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5427 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5428 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5429 gpe_add_del_native_fwd_rpath_reply) \
5430 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5431 gpe_fwd_entry_path_details) \
5432 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5433 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5434 one_add_del_map_request_itr_rlocs_reply) \
5435 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5436 one_get_map_request_itr_rlocs_reply) \
5437 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5438 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5439 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5440 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5441 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5442 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5443 show_one_map_register_state_reply) \
5444 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5445 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5446 show_one_map_register_fallback_threshold_reply) \
5447 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5448 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5449 _(AF_PACKET_DETAILS, af_packet_details) \
5450 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5451 _(POLICER_DETAILS, policer_details) \
5452 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5453 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5454 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5455 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5456 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5457 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5458 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5459 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5460 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5461 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5462 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5463 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5464 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5465 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5466 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5467 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5468 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5469 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5470 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5471 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5472 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5473 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5474 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5475 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5476 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5477 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5478 ip_source_and_port_range_check_add_del_reply) \
5479 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5480 ip_source_and_port_range_check_interface_add_del_reply) \
5481 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5482 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5483 _(SET_PUNT_REPLY, set_punt_reply) \
5484 _(IP_TABLE_DETAILS, ip_table_details) \
5485 _(IP_ROUTE_DETAILS, ip_route_details) \
5486 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5487 _(FEATURE_GSO_ENABLE_DISABLE_REPLY, feature_gso_enable_disable_reply) \
5488 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5489 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
5490 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5491 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5492 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5493 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5494 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5495 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5496 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5497 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5498 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5499 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5500 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5501 _(SESSION_RULES_DETAILS, session_rules_details) \
5502 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5503 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5504 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5506 #define foreach_standalone_reply_msg \
5507 _(SW_INTERFACE_EVENT, sw_interface_event)
5515 #define STR_VTR_OP_CASE(op) \
5516 case L2_VTR_ ## op: \
5520 str_vtr_op (u32 vtr_op)
5524 STR_VTR_OP_CASE (DISABLED);
5525 STR_VTR_OP_CASE (PUSH_1);
5526 STR_VTR_OP_CASE (PUSH_2);
5527 STR_VTR_OP_CASE (POP_1);
5528 STR_VTR_OP_CASE (POP_2);
5529 STR_VTR_OP_CASE (TRANSLATE_1_1);
5530 STR_VTR_OP_CASE (TRANSLATE_1_2);
5531 STR_VTR_OP_CASE (TRANSLATE_2_1);
5532 STR_VTR_OP_CASE (TRANSLATE_2_2);
5539 dump_sub_interface_table (vat_main_t * vam)
5541 const sw_interface_subif_t *sub = NULL;
5543 if (vam->json_output)
5546 ("JSON output supported only for VPE API calls and dump_stats_table");
5551 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5552 "Interface", "sw_if_index",
5553 "sub id", "dot1ad", "tags", "outer id",
5554 "inner id", "exact", "default", "outer any", "inner any");
5556 vec_foreach (sub, vam->sw_if_subif_table)
5559 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5560 sub->interface_name,
5562 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5563 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5564 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5565 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5566 if (sub->vtr_op != L2_VTR_DISABLED)
5569 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5570 "tag1: %d tag2: %d ]",
5571 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5572 sub->vtr_tag1, sub->vtr_tag2);
5580 name_sort_cmp (void *a1, void *a2)
5582 name_sort_t *n1 = a1;
5583 name_sort_t *n2 = a2;
5585 return strcmp ((char *) n1->name, (char *) n2->name);
5589 dump_interface_table (vat_main_t * vam)
5592 name_sort_t *nses = 0, *ns;
5594 if (vam->json_output)
5597 ("JSON output supported only for VPE API calls and dump_stats_table");
5602 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5604 vec_add2 (nses, ns, 1);
5605 ns->name = (u8 *)(p->key);
5606 ns->value = (u32) p->value[0];
5610 vec_sort_with_function (nses, name_sort_cmp);
5612 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5613 vec_foreach (ns, nses)
5615 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5622 dump_ip_table (vat_main_t * vam, int is_ipv6)
5624 const ip_details_t *det = NULL;
5625 const ip_address_details_t *address = NULL;
5628 print (vam->ofp, "%-12s", "sw_if_index");
5630 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5637 print (vam->ofp, "%-12d", i);
5638 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5643 vec_foreach (address, det->addr)
5647 is_ipv6 ? format_ip6_address : format_ip4_address,
5648 address->ip, address->prefix_length);
5656 dump_ipv4_table (vat_main_t * vam)
5658 if (vam->json_output)
5661 ("JSON output supported only for VPE API calls and dump_stats_table");
5665 return dump_ip_table (vam, 0);
5669 dump_ipv6_table (vat_main_t * vam)
5671 if (vam->json_output)
5674 ("JSON output supported only for VPE API calls and dump_stats_table");
5678 return dump_ip_table (vam, 1);
5682 * Pass CLI buffers directly in the CLI_INBAND API message,
5683 * instead of an additional shared memory area.
5686 exec_inband (vat_main_t * vam)
5688 vl_api_cli_inband_t *mp;
5689 unformat_input_t *i = vam->input;
5692 if (vec_len (i->buffer) == 0)
5695 if (vam->exec_mode == 0 && unformat (i, "mode"))
5700 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5707 * In order for the CLI command to work, it
5708 * must be a vector ending in \n, not a C-string ending
5711 u32 len = vec_len (vam->input->buffer);
5712 M2 (CLI_INBAND, mp, len);
5713 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5717 /* json responses may or may not include a useful reply... */
5718 if (vec_len (vam->cmd_reply))
5719 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5724 exec (vat_main_t * vam)
5726 return exec_inband (vam);
5730 api_create_loopback (vat_main_t * vam)
5732 unformat_input_t *i = vam->input;
5733 vl_api_create_loopback_t *mp;
5734 vl_api_create_loopback_instance_t *mp_lbi;
5737 u8 is_specified = 0;
5738 u32 user_instance = 0;
5741 clib_memset (mac_address, 0, sizeof (mac_address));
5743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5745 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5747 if (unformat (i, "instance %d", &user_instance))
5755 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5756 mp_lbi->is_specified = is_specified;
5758 mp_lbi->user_instance = htonl (user_instance);
5760 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5765 /* Construct the API message */
5766 M (CREATE_LOOPBACK, mp);
5768 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5777 api_delete_loopback (vat_main_t * vam)
5779 unformat_input_t *i = vam->input;
5780 vl_api_delete_loopback_t *mp;
5781 u32 sw_if_index = ~0;
5784 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5786 if (unformat (i, "sw_if_index %d", &sw_if_index))
5792 if (sw_if_index == ~0)
5794 errmsg ("missing sw_if_index");
5798 /* Construct the API message */
5799 M (DELETE_LOOPBACK, mp);
5800 mp->sw_if_index = ntohl (sw_if_index);
5808 api_want_interface_events (vat_main_t * vam)
5810 unformat_input_t *i = vam->input;
5811 vl_api_want_interface_events_t *mp;
5815 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5817 if (unformat (i, "enable"))
5819 else if (unformat (i, "disable"))
5827 errmsg ("missing enable|disable");
5831 M (WANT_INTERFACE_EVENTS, mp);
5832 mp->enable_disable = enable;
5834 vam->interface_event_display = enable;
5842 /* Note: non-static, called once to set up the initial intfc table */
5844 api_sw_interface_dump (vat_main_t * vam)
5846 vl_api_sw_interface_dump_t *mp;
5847 vl_api_control_ping_t *mp_ping;
5849 name_sort_t *nses = 0, *ns;
5850 sw_interface_subif_t *sub = NULL;
5853 /* Toss the old name table */
5855 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5857 vec_add2 (nses, ns, 1);
5858 ns->name = (u8 *)(p->key);
5859 ns->value = (u32) p->value[0];
5863 hash_free (vam->sw_if_index_by_interface_name);
5865 vec_foreach (ns, nses) vec_free (ns->name);
5869 vec_foreach (sub, vam->sw_if_subif_table)
5871 vec_free (sub->interface_name);
5873 vec_free (vam->sw_if_subif_table);
5875 /* recreate the interface name hash table */
5876 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5879 * Ask for all interface names. Otherwise, the epic catalog of
5880 * name filters becomes ridiculously long, and vat ends up needing
5881 * to be taught about new interface types.
5883 M (SW_INTERFACE_DUMP, mp);
5886 /* Use a control ping for synchronization */
5887 MPING (CONTROL_PING, mp_ping);
5895 api_sw_interface_set_flags (vat_main_t * vam)
5897 unformat_input_t *i = vam->input;
5898 vl_api_sw_interface_set_flags_t *mp;
5900 u8 sw_if_index_set = 0;
5904 /* Parse args required to build the message */
5905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5907 if (unformat (i, "admin-up"))
5909 else if (unformat (i, "admin-down"))
5912 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5913 sw_if_index_set = 1;
5914 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5915 sw_if_index_set = 1;
5920 if (sw_if_index_set == 0)
5922 errmsg ("missing interface name or sw_if_index");
5926 /* Construct the API message */
5927 M (SW_INTERFACE_SET_FLAGS, mp);
5928 mp->sw_if_index = ntohl (sw_if_index);
5929 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5934 /* Wait for a reply, return the good/bad news... */
5940 api_sw_interface_set_rx_mode (vat_main_t * vam)
5942 unformat_input_t *i = vam->input;
5943 vl_api_sw_interface_set_rx_mode_t *mp;
5945 u8 sw_if_index_set = 0;
5947 u8 queue_id_valid = 0;
5949 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5951 /* Parse args required to build the message */
5952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5954 if (unformat (i, "queue %d", &queue_id))
5956 else if (unformat (i, "polling"))
5957 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5958 else if (unformat (i, "interrupt"))
5959 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5960 else if (unformat (i, "adaptive"))
5961 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5963 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5964 sw_if_index_set = 1;
5965 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5966 sw_if_index_set = 1;
5971 if (sw_if_index_set == 0)
5973 errmsg ("missing interface name or sw_if_index");
5976 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
5978 errmsg ("missing rx-mode");
5982 /* Construct the API message */
5983 M (SW_INTERFACE_SET_RX_MODE, mp);
5984 mp->sw_if_index = ntohl (sw_if_index);
5985 mp->mode = (vl_api_rx_mode_t) mode;
5986 mp->queue_id_valid = queue_id_valid;
5987 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
5992 /* Wait for a reply, return the good/bad news... */
5998 api_sw_interface_set_rx_placement (vat_main_t * vam)
6000 unformat_input_t *i = vam->input;
6001 vl_api_sw_interface_set_rx_placement_t *mp;
6003 u8 sw_if_index_set = 0;
6006 u32 queue_id, thread_index;
6008 /* Parse args required to build the message */
6009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6011 if (unformat (i, "queue %d", &queue_id))
6013 else if (unformat (i, "main"))
6015 else if (unformat (i, "worker %d", &thread_index))
6018 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6019 sw_if_index_set = 1;
6020 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6021 sw_if_index_set = 1;
6026 if (sw_if_index_set == 0)
6028 errmsg ("missing interface name or sw_if_index");
6034 /* Construct the API message */
6035 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6036 mp->sw_if_index = ntohl (sw_if_index);
6037 mp->worker_id = ntohl (thread_index);
6038 mp->queue_id = ntohl (queue_id);
6039 mp->is_main = is_main;
6043 /* Wait for a reply, return the good/bad news... */
6048 static void vl_api_sw_interface_rx_placement_details_t_handler
6049 (vl_api_sw_interface_rx_placement_details_t * mp)
6051 vat_main_t *vam = &vat_main;
6052 u32 worker_id = ntohl (mp->worker_id);
6055 "\n%-11d %-11s %-6d %-5d %-9s",
6056 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6057 worker_id, ntohl (mp->queue_id),
6059 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6062 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6063 (vl_api_sw_interface_rx_placement_details_t * mp)
6065 vat_main_t *vam = &vat_main;
6066 vat_json_node_t *node = NULL;
6068 if (VAT_JSON_ARRAY != vam->json_tree.type)
6070 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6071 vat_json_init_array (&vam->json_tree);
6073 node = vat_json_array_add (&vam->json_tree);
6075 vat_json_init_object (node);
6076 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6077 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6078 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6079 vat_json_object_add_uint (node, "mode", mp->mode);
6083 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6085 unformat_input_t *i = vam->input;
6086 vl_api_sw_interface_rx_placement_dump_t *mp;
6087 vl_api_control_ping_t *mp_ping;
6090 u8 sw_if_index_set = 0;
6092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6094 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6096 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6103 "\n%-11s %-11s %-6s %-5s %-4s",
6104 "sw_if_index", "main/worker", "thread", "queue", "mode");
6106 /* Dump Interface rx placement */
6107 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6109 if (sw_if_index_set)
6110 mp->sw_if_index = htonl (sw_if_index);
6112 mp->sw_if_index = ~0;
6116 /* Use a control ping for synchronization */
6117 MPING (CONTROL_PING, mp_ping);
6125 api_sw_interface_clear_stats (vat_main_t * vam)
6127 unformat_input_t *i = vam->input;
6128 vl_api_sw_interface_clear_stats_t *mp;
6130 u8 sw_if_index_set = 0;
6133 /* Parse args required to build the message */
6134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6136 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6137 sw_if_index_set = 1;
6138 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6139 sw_if_index_set = 1;
6144 /* Construct the API message */
6145 M (SW_INTERFACE_CLEAR_STATS, mp);
6147 if (sw_if_index_set == 1)
6148 mp->sw_if_index = ntohl (sw_if_index);
6150 mp->sw_if_index = ~0;
6155 /* Wait for a reply, return the good/bad news... */
6161 api_sw_interface_add_del_address (vat_main_t * vam)
6163 unformat_input_t *i = vam->input;
6164 vl_api_sw_interface_add_del_address_t *mp;
6166 u8 sw_if_index_set = 0;
6167 u8 is_add = 1, del_all = 0;
6168 u32 address_length = 0;
6169 u8 v4_address_set = 0;
6170 u8 v6_address_set = 0;
6171 ip4_address_t v4address;
6172 ip6_address_t v6address;
6175 /* Parse args required to build the message */
6176 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6178 if (unformat (i, "del-all"))
6180 else if (unformat (i, "del"))
6183 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6184 sw_if_index_set = 1;
6185 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6186 sw_if_index_set = 1;
6187 else if (unformat (i, "%U/%d",
6188 unformat_ip4_address, &v4address, &address_length))
6190 else if (unformat (i, "%U/%d",
6191 unformat_ip6_address, &v6address, &address_length))
6197 if (sw_if_index_set == 0)
6199 errmsg ("missing interface name or sw_if_index");
6202 if (v4_address_set && v6_address_set)
6204 errmsg ("both v4 and v6 addresses set");
6207 if (!v4_address_set && !v6_address_set && !del_all)
6209 errmsg ("no addresses set");
6213 /* Construct the API message */
6214 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6216 mp->sw_if_index = ntohl (sw_if_index);
6217 mp->is_add = is_add;
6218 mp->del_all = del_all;
6221 mp->prefix.address.af = ADDRESS_IP6;
6222 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6226 mp->prefix.address.af = ADDRESS_IP4;
6227 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6229 mp->prefix.len = address_length;
6234 /* Wait for a reply, return good/bad news */
6240 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6242 unformat_input_t *i = vam->input;
6243 vl_api_sw_interface_set_mpls_enable_t *mp;
6245 u8 sw_if_index_set = 0;
6249 /* Parse args required to build the message */
6250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6252 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6253 sw_if_index_set = 1;
6254 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6255 sw_if_index_set = 1;
6256 else if (unformat (i, "disable"))
6258 else if (unformat (i, "dis"))
6264 if (sw_if_index_set == 0)
6266 errmsg ("missing interface name or sw_if_index");
6270 /* Construct the API message */
6271 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6273 mp->sw_if_index = ntohl (sw_if_index);
6274 mp->enable = enable;
6279 /* Wait for a reply... */
6285 api_sw_interface_set_table (vat_main_t * vam)
6287 unformat_input_t *i = vam->input;
6288 vl_api_sw_interface_set_table_t *mp;
6289 u32 sw_if_index, vrf_id = 0;
6290 u8 sw_if_index_set = 0;
6294 /* Parse args required to build the message */
6295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6297 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6298 sw_if_index_set = 1;
6299 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6300 sw_if_index_set = 1;
6301 else if (unformat (i, "vrf %d", &vrf_id))
6303 else if (unformat (i, "ipv6"))
6309 if (sw_if_index_set == 0)
6311 errmsg ("missing interface name or sw_if_index");
6315 /* Construct the API message */
6316 M (SW_INTERFACE_SET_TABLE, mp);
6318 mp->sw_if_index = ntohl (sw_if_index);
6319 mp->is_ipv6 = is_ipv6;
6320 mp->vrf_id = ntohl (vrf_id);
6325 /* Wait for a reply... */
6330 static void vl_api_sw_interface_get_table_reply_t_handler
6331 (vl_api_sw_interface_get_table_reply_t * mp)
6333 vat_main_t *vam = &vat_main;
6335 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6337 vam->retval = ntohl (mp->retval);
6338 vam->result_ready = 1;
6342 static void vl_api_sw_interface_get_table_reply_t_handler_json
6343 (vl_api_sw_interface_get_table_reply_t * mp)
6345 vat_main_t *vam = &vat_main;
6346 vat_json_node_t node;
6348 vat_json_init_object (&node);
6349 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6350 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6352 vat_json_print (vam->ofp, &node);
6353 vat_json_free (&node);
6355 vam->retval = ntohl (mp->retval);
6356 vam->result_ready = 1;
6360 api_sw_interface_get_table (vat_main_t * vam)
6362 unformat_input_t *i = vam->input;
6363 vl_api_sw_interface_get_table_t *mp;
6365 u8 sw_if_index_set = 0;
6369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6371 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6372 sw_if_index_set = 1;
6373 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6374 sw_if_index_set = 1;
6375 else if (unformat (i, "ipv6"))
6381 if (sw_if_index_set == 0)
6383 errmsg ("missing interface name or sw_if_index");
6387 M (SW_INTERFACE_GET_TABLE, mp);
6388 mp->sw_if_index = htonl (sw_if_index);
6389 mp->is_ipv6 = is_ipv6;
6397 api_sw_interface_set_vpath (vat_main_t * vam)
6399 unformat_input_t *i = vam->input;
6400 vl_api_sw_interface_set_vpath_t *mp;
6401 u32 sw_if_index = 0;
6402 u8 sw_if_index_set = 0;
6406 /* Parse args required to build the message */
6407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6409 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6410 sw_if_index_set = 1;
6411 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6412 sw_if_index_set = 1;
6413 else if (unformat (i, "enable"))
6415 else if (unformat (i, "disable"))
6421 if (sw_if_index_set == 0)
6423 errmsg ("missing interface name or sw_if_index");
6427 /* Construct the API message */
6428 M (SW_INTERFACE_SET_VPATH, mp);
6430 mp->sw_if_index = ntohl (sw_if_index);
6431 mp->enable = is_enable;
6436 /* Wait for a reply... */
6442 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6444 unformat_input_t *i = vam->input;
6445 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6446 u32 sw_if_index = 0;
6447 u8 sw_if_index_set = 0;
6452 /* Parse args required to build the message */
6453 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6455 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6456 sw_if_index_set = 1;
6457 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6458 sw_if_index_set = 1;
6459 else if (unformat (i, "enable"))
6461 else if (unformat (i, "disable"))
6463 else if (unformat (i, "ip4"))
6465 else if (unformat (i, "ip6"))
6471 if (sw_if_index_set == 0)
6473 errmsg ("missing interface name or sw_if_index");
6477 /* Construct the API message */
6478 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6480 mp->sw_if_index = ntohl (sw_if_index);
6481 mp->enable = is_enable;
6482 mp->is_ipv6 = is_ipv6;
6487 /* Wait for a reply... */
6493 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6495 unformat_input_t *i = vam->input;
6496 vl_api_sw_interface_set_geneve_bypass_t *mp;
6497 u32 sw_if_index = 0;
6498 u8 sw_if_index_set = 0;
6503 /* Parse args required to build the message */
6504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6506 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6507 sw_if_index_set = 1;
6508 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6509 sw_if_index_set = 1;
6510 else if (unformat (i, "enable"))
6512 else if (unformat (i, "disable"))
6514 else if (unformat (i, "ip4"))
6516 else if (unformat (i, "ip6"))
6522 if (sw_if_index_set == 0)
6524 errmsg ("missing interface name or sw_if_index");
6528 /* Construct the API message */
6529 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6531 mp->sw_if_index = ntohl (sw_if_index);
6532 mp->enable = is_enable;
6533 mp->is_ipv6 = is_ipv6;
6538 /* Wait for a reply... */
6544 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6546 unformat_input_t *i = vam->input;
6547 vl_api_sw_interface_set_l2_xconnect_t *mp;
6549 u8 rx_sw_if_index_set = 0;
6551 u8 tx_sw_if_index_set = 0;
6555 /* Parse args required to build the message */
6556 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6558 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6559 rx_sw_if_index_set = 1;
6560 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6561 tx_sw_if_index_set = 1;
6562 else if (unformat (i, "rx"))
6564 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6566 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6568 rx_sw_if_index_set = 1;
6573 else if (unformat (i, "tx"))
6575 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6577 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6579 tx_sw_if_index_set = 1;
6584 else if (unformat (i, "enable"))
6586 else if (unformat (i, "disable"))
6592 if (rx_sw_if_index_set == 0)
6594 errmsg ("missing rx interface name or rx_sw_if_index");
6598 if (enable && (tx_sw_if_index_set == 0))
6600 errmsg ("missing tx interface name or tx_sw_if_index");
6604 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6606 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6607 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6608 mp->enable = enable;
6616 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6618 unformat_input_t *i = vam->input;
6619 vl_api_sw_interface_set_l2_bridge_t *mp;
6620 vl_api_l2_port_type_t port_type;
6622 u8 rx_sw_if_index_set = 0;
6629 port_type = L2_API_PORT_TYPE_NORMAL;
6631 /* Parse args required to build the message */
6632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6634 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6635 rx_sw_if_index_set = 1;
6636 else if (unformat (i, "bd_id %d", &bd_id))
6640 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6641 rx_sw_if_index_set = 1;
6642 else if (unformat (i, "shg %d", &shg))
6644 else if (unformat (i, "bvi"))
6645 port_type = L2_API_PORT_TYPE_BVI;
6646 else if (unformat (i, "uu-fwd"))
6647 port_type = L2_API_PORT_TYPE_UU_FWD;
6648 else if (unformat (i, "enable"))
6650 else if (unformat (i, "disable"))
6656 if (rx_sw_if_index_set == 0)
6658 errmsg ("missing rx interface name or sw_if_index");
6662 if (enable && (bd_id_set == 0))
6664 errmsg ("missing bridge domain");
6668 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6670 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6671 mp->bd_id = ntohl (bd_id);
6673 mp->port_type = ntohl (port_type);
6674 mp->enable = enable;
6682 api_bridge_domain_dump (vat_main_t * vam)
6684 unformat_input_t *i = vam->input;
6685 vl_api_bridge_domain_dump_t *mp;
6686 vl_api_control_ping_t *mp_ping;
6690 /* Parse args required to build the message */
6691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6693 if (unformat (i, "bd_id %d", &bd_id))
6699 M (BRIDGE_DOMAIN_DUMP, mp);
6700 mp->bd_id = ntohl (bd_id);
6703 /* Use a control ping for synchronization */
6704 MPING (CONTROL_PING, mp_ping);
6712 api_bridge_domain_add_del (vat_main_t * vam)
6714 unformat_input_t *i = vam->input;
6715 vl_api_bridge_domain_add_del_t *mp;
6718 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6723 /* Parse args required to build the message */
6724 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6726 if (unformat (i, "bd_id %d", &bd_id))
6728 else if (unformat (i, "flood %d", &flood))
6730 else if (unformat (i, "uu-flood %d", &uu_flood))
6732 else if (unformat (i, "forward %d", &forward))
6734 else if (unformat (i, "learn %d", &learn))
6736 else if (unformat (i, "arp-term %d", &arp_term))
6738 else if (unformat (i, "mac-age %d", &mac_age))
6740 else if (unformat (i, "bd-tag %s", &bd_tag))
6742 else if (unformat (i, "del"))
6745 flood = uu_flood = forward = learn = 0;
6753 errmsg ("missing bridge domain");
6760 errmsg ("mac age must be less than 256 ");
6765 if ((bd_tag) && (vec_len (bd_tag) > 63))
6767 errmsg ("bd-tag cannot be longer than 63");
6772 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6774 mp->bd_id = ntohl (bd_id);
6776 mp->uu_flood = uu_flood;
6777 mp->forward = forward;
6779 mp->arp_term = arp_term;
6780 mp->is_add = is_add;
6781 mp->mac_age = (u8) mac_age;
6784 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6785 mp->bd_tag[vec_len (bd_tag)] = 0;
6796 api_l2fib_flush_bd (vat_main_t * vam)
6798 unformat_input_t *i = vam->input;
6799 vl_api_l2fib_flush_bd_t *mp;
6803 /* Parse args required to build the message */
6804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6806 if (unformat (i, "bd_id %d", &bd_id));
6813 errmsg ("missing bridge domain");
6817 M (L2FIB_FLUSH_BD, mp);
6819 mp->bd_id = htonl (bd_id);
6827 api_l2fib_flush_int (vat_main_t * vam)
6829 unformat_input_t *i = vam->input;
6830 vl_api_l2fib_flush_int_t *mp;
6831 u32 sw_if_index = ~0;
6834 /* Parse args required to build the message */
6835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6837 if (unformat (i, "sw_if_index %d", &sw_if_index));
6839 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6844 if (sw_if_index == ~0)
6846 errmsg ("missing interface name or sw_if_index");
6850 M (L2FIB_FLUSH_INT, mp);
6852 mp->sw_if_index = ntohl (sw_if_index);
6860 api_l2fib_add_del (vat_main_t * vam)
6862 unformat_input_t *i = vam->input;
6863 vl_api_l2fib_add_del_t *mp;
6869 u32 sw_if_index = 0;
6870 u8 sw_if_index_set = 0;
6879 /* Parse args required to build the message */
6880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6882 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6884 else if (unformat (i, "bd_id %d", &bd_id))
6886 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6887 sw_if_index_set = 1;
6888 else if (unformat (i, "sw_if"))
6890 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6893 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6894 sw_if_index_set = 1;
6899 else if (unformat (i, "static"))
6901 else if (unformat (i, "filter"))
6906 else if (unformat (i, "bvi"))
6911 else if (unformat (i, "del"))
6913 else if (unformat (i, "count %d", &count))
6921 errmsg ("missing mac address");
6927 errmsg ("missing bridge domain");
6931 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6933 errmsg ("missing interface name or sw_if_index");
6939 /* Turn on async mode */
6940 vam->async_mode = 1;
6941 vam->async_errors = 0;
6942 before = vat_time_now (vam);
6945 for (j = 0; j < count; j++)
6947 M (L2FIB_ADD_DEL, mp);
6949 clib_memcpy (mp->mac, mac, 6);
6950 mp->bd_id = ntohl (bd_id);
6951 mp->is_add = is_add;
6952 mp->sw_if_index = ntohl (sw_if_index);
6956 mp->static_mac = static_mac;
6957 mp->filter_mac = filter_mac;
6958 mp->bvi_mac = bvi_mac;
6960 increment_mac_address (mac);
6967 vl_api_control_ping_t *mp_ping;
6970 /* Shut off async mode */
6971 vam->async_mode = 0;
6973 MPING (CONTROL_PING, mp_ping);
6976 timeout = vat_time_now (vam) + 1.0;
6977 while (vat_time_now (vam) < timeout)
6978 if (vam->result_ready == 1)
6983 if (vam->retval == -99)
6986 if (vam->async_errors > 0)
6988 errmsg ("%d asynchronous errors", vam->async_errors);
6991 vam->async_errors = 0;
6992 after = vat_time_now (vam);
6994 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6995 count, after - before, count / (after - before));
7001 /* Wait for a reply... */
7005 /* Return the good/bad news */
7006 return (vam->retval);
7010 api_bridge_domain_set_mac_age (vat_main_t * vam)
7012 unformat_input_t *i = vam->input;
7013 vl_api_bridge_domain_set_mac_age_t *mp;
7018 /* Parse args required to build the message */
7019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7021 if (unformat (i, "bd_id %d", &bd_id));
7022 else if (unformat (i, "mac-age %d", &mac_age));
7029 errmsg ("missing bridge domain");
7035 errmsg ("mac age must be less than 256 ");
7039 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7041 mp->bd_id = htonl (bd_id);
7042 mp->mac_age = (u8) mac_age;
7050 api_l2_flags (vat_main_t * vam)
7052 unformat_input_t *i = vam->input;
7053 vl_api_l2_flags_t *mp;
7056 u8 sw_if_index_set = 0;
7060 /* Parse args required to build the message */
7061 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7063 if (unformat (i, "sw_if_index %d", &sw_if_index))
7064 sw_if_index_set = 1;
7065 else if (unformat (i, "sw_if"))
7067 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7070 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7071 sw_if_index_set = 1;
7076 else if (unformat (i, "learn"))
7078 else if (unformat (i, "forward"))
7080 else if (unformat (i, "flood"))
7082 else if (unformat (i, "uu-flood"))
7083 flags |= L2_UU_FLOOD;
7084 else if (unformat (i, "arp-term"))
7085 flags |= L2_ARP_TERM;
7086 else if (unformat (i, "off"))
7088 else if (unformat (i, "disable"))
7094 if (sw_if_index_set == 0)
7096 errmsg ("missing interface name or sw_if_index");
7102 mp->sw_if_index = ntohl (sw_if_index);
7103 mp->feature_bitmap = ntohl (flags);
7104 mp->is_set = is_set;
7112 api_bridge_flags (vat_main_t * vam)
7114 unformat_input_t *i = vam->input;
7115 vl_api_bridge_flags_t *mp;
7119 bd_flags_t flags = 0;
7122 /* Parse args required to build the message */
7123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7125 if (unformat (i, "bd_id %d", &bd_id))
7127 else if (unformat (i, "learn"))
7128 flags |= BRIDGE_API_FLAG_LEARN;
7129 else if (unformat (i, "forward"))
7130 flags |= BRIDGE_API_FLAG_FWD;
7131 else if (unformat (i, "flood"))
7132 flags |= BRIDGE_API_FLAG_FLOOD;
7133 else if (unformat (i, "uu-flood"))
7134 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7135 else if (unformat (i, "arp-term"))
7136 flags |= BRIDGE_API_FLAG_ARP_TERM;
7137 else if (unformat (i, "off"))
7139 else if (unformat (i, "disable"))
7147 errmsg ("missing bridge domain");
7151 M (BRIDGE_FLAGS, mp);
7153 mp->bd_id = ntohl (bd_id);
7154 mp->flags = ntohl (flags);
7155 mp->is_set = is_set;
7163 api_bd_ip_mac_add_del (vat_main_t * vam)
7165 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7166 vl_api_mac_address_t mac = { 0 };
7167 unformat_input_t *i = vam->input;
7168 vl_api_bd_ip_mac_add_del_t *mp;
7177 /* Parse args required to build the message */
7178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7180 if (unformat (i, "bd_id %d", &bd_id))
7184 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7188 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7192 else if (unformat (i, "del"))
7200 errmsg ("missing bridge domain");
7203 else if (ip_set == 0)
7205 errmsg ("missing IP address");
7208 else if (mac_set == 0)
7210 errmsg ("missing MAC address");
7214 M (BD_IP_MAC_ADD_DEL, mp);
7216 mp->entry.bd_id = ntohl (bd_id);
7217 mp->is_add = is_add;
7219 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7220 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7228 api_bd_ip_mac_flush (vat_main_t * vam)
7230 unformat_input_t *i = vam->input;
7231 vl_api_bd_ip_mac_flush_t *mp;
7236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7238 if (unformat (i, "bd_id %d", &bd_id))
7248 errmsg ("missing bridge domain");
7252 M (BD_IP_MAC_FLUSH, mp);
7254 mp->bd_id = ntohl (bd_id);
7261 static void vl_api_bd_ip_mac_details_t_handler
7262 (vl_api_bd_ip_mac_details_t * mp)
7264 vat_main_t *vam = &vat_main;
7268 ntohl (mp->entry.bd_id),
7269 format_vl_api_mac_address, mp->entry.mac,
7270 format_vl_api_address, &mp->entry.ip);
7273 static void vl_api_bd_ip_mac_details_t_handler_json
7274 (vl_api_bd_ip_mac_details_t * mp)
7276 vat_main_t *vam = &vat_main;
7277 vat_json_node_t *node = NULL;
7279 if (VAT_JSON_ARRAY != vam->json_tree.type)
7281 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7282 vat_json_init_array (&vam->json_tree);
7284 node = vat_json_array_add (&vam->json_tree);
7286 vat_json_init_object (node);
7287 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7288 vat_json_object_add_string_copy (node, "mac_address",
7289 format (0, "%U", format_vl_api_mac_address,
7293 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7294 vat_json_object_add_string_copy (node, "ip_address", ip);
7299 api_bd_ip_mac_dump (vat_main_t * vam)
7301 unformat_input_t *i = vam->input;
7302 vl_api_bd_ip_mac_dump_t *mp;
7303 vl_api_control_ping_t *mp_ping;
7308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7310 if (unformat (i, "bd_id %d", &bd_id))
7319 "\n%-5s %-7s %-20s %-30s",
7320 "bd_id", "is_ipv6", "mac_address", "ip_address");
7322 /* Dump Bridge Domain Ip to Mac entries */
7323 M (BD_IP_MAC_DUMP, mp);
7326 mp->bd_id = htonl (bd_id);
7332 /* Use a control ping for synchronization */
7333 MPING (CONTROL_PING, mp_ping);
7341 api_tap_create_v2 (vat_main_t * vam)
7343 unformat_input_t *i = vam->input;
7344 vl_api_tap_create_v2_t *mp;
7345 #define TAP_FLAG_GSO (1 << 0)
7349 u8 *host_if_name = 0;
7351 u8 host_mac_addr[6];
7352 u8 host_mac_addr_set = 0;
7353 u8 *host_bridge = 0;
7354 ip4_address_t host_ip4_addr;
7355 ip4_address_t host_ip4_gw;
7356 u8 host_ip4_gw_set = 0;
7357 u32 host_ip4_prefix_len = 0;
7358 ip6_address_t host_ip6_addr;
7359 ip6_address_t host_ip6_gw;
7360 u8 host_ip6_gw_set = 0;
7361 u32 host_ip6_prefix_len = 0;
7362 u8 host_mtu_set = 0;
7363 u32 host_mtu_size = 0;
7366 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7368 clib_memset (mac_address, 0, sizeof (mac_address));
7370 /* Parse args required to build the message */
7371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7373 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7377 else if (unformat (i, "id %u", &id))
7379 else if (unformat (i, "host-if-name %s", &host_if_name))
7381 else if (unformat (i, "host-ns %s", &host_ns))
7383 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7385 host_mac_addr_set = 1;
7386 else if (unformat (i, "host-bridge %s", &host_bridge))
7388 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7389 &host_ip4_addr, &host_ip4_prefix_len))
7391 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7392 &host_ip6_addr, &host_ip6_prefix_len))
7394 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7396 host_ip4_gw_set = 1;
7397 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7399 host_ip6_gw_set = 1;
7400 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7402 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7404 else if (unformat (i, "host-mtu-size %d", &host_mtu_size))
7406 else if (unformat (i, "no-gso"))
7407 tap_flags &= ~TAP_FLAG_GSO;
7408 else if (unformat (i, "gso"))
7409 tap_flags |= TAP_FLAG_GSO;
7414 if (vec_len (host_if_name) > 63)
7416 errmsg ("tap name too long. ");
7419 if (vec_len (host_ns) > 63)
7421 errmsg ("host name space too long. ");
7424 if (vec_len (host_bridge) > 63)
7426 errmsg ("host bridge name too long. ");
7429 if (host_ip4_prefix_len > 32)
7431 errmsg ("host ip4 prefix length not valid. ");
7434 if (host_ip6_prefix_len > 128)
7436 errmsg ("host ip6 prefix length not valid. ");
7439 if (!is_pow2 (rx_ring_sz))
7441 errmsg ("rx ring size must be power of 2. ");
7444 if (rx_ring_sz > 32768)
7446 errmsg ("rx ring size must be 32768 or lower. ");
7449 if (!is_pow2 (tx_ring_sz))
7451 errmsg ("tx ring size must be power of 2. ");
7454 if (tx_ring_sz > 32768)
7456 errmsg ("tx ring size must be 32768 or lower. ");
7459 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7461 errmsg ("host MTU size must be in between 64 and 65355. ");
7465 /* Construct the API message */
7466 M (TAP_CREATE_V2, mp);
7468 mp->use_random_mac = random_mac;
7470 mp->id = ntohl (id);
7471 mp->host_namespace_set = host_ns != 0;
7472 mp->host_bridge_set = host_bridge != 0;
7473 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7474 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7475 mp->rx_ring_sz = ntohs (rx_ring_sz);
7476 mp->tx_ring_sz = ntohs (tx_ring_sz);
7477 mp->host_mtu_set = host_mtu_set;
7478 mp->host_mtu_size = ntohl (host_mtu_size);
7479 mp->tap_flags = ntohl (tap_flags);
7481 if (random_mac == 0)
7482 clib_memcpy (mp->mac_address, mac_address, 6);
7483 if (host_mac_addr_set)
7484 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7486 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7488 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7490 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7491 if (host_ip4_prefix_len)
7492 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7493 if (host_ip6_prefix_len)
7494 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7495 if (host_ip4_gw_set)
7496 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7497 if (host_ip6_gw_set)
7498 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7501 vec_free (host_if_name);
7502 vec_free (host_bridge);
7507 /* Wait for a reply... */
7513 api_tap_delete_v2 (vat_main_t * vam)
7515 unformat_input_t *i = vam->input;
7516 vl_api_tap_delete_v2_t *mp;
7517 u32 sw_if_index = ~0;
7518 u8 sw_if_index_set = 0;
7521 /* Parse args required to build the message */
7522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7524 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7525 sw_if_index_set = 1;
7526 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7527 sw_if_index_set = 1;
7532 if (sw_if_index_set == 0)
7534 errmsg ("missing vpp interface name. ");
7538 /* Construct the API message */
7539 M (TAP_DELETE_V2, mp);
7541 mp->sw_if_index = ntohl (sw_if_index);
7546 /* Wait for a reply... */
7552 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7554 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7557 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7560 addr->domain = x[0];
7563 addr->function = x[3];
7569 api_virtio_pci_create (vat_main_t * vam)
7571 unformat_input_t *i = vam->input;
7572 vl_api_virtio_pci_create_t *mp;
7577 u64 features = (u64) ~ (0ULL);
7580 clib_memset (mac_address, 0, sizeof (mac_address));
7582 /* Parse args required to build the message */
7583 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7585 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7589 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7591 else if (unformat (i, "features 0x%llx", &features))
7593 else if (unformat (i, "gso-enabled"))
7601 errmsg ("pci address must be non zero. ");
7605 /* Construct the API message */
7606 M (VIRTIO_PCI_CREATE, mp);
7608 mp->use_random_mac = random_mac;
7610 mp->pci_addr = htonl (pci_addr);
7611 mp->features = clib_host_to_net_u64 (features);
7612 mp->gso_enabled = gso_enabled;
7614 if (random_mac == 0)
7615 clib_memcpy (mp->mac_address, mac_address, 6);
7620 /* Wait for a reply... */
7626 api_virtio_pci_delete (vat_main_t * vam)
7628 unformat_input_t *i = vam->input;
7629 vl_api_virtio_pci_delete_t *mp;
7630 u32 sw_if_index = ~0;
7631 u8 sw_if_index_set = 0;
7634 /* Parse args required to build the message */
7635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7637 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7638 sw_if_index_set = 1;
7639 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7640 sw_if_index_set = 1;
7645 if (sw_if_index_set == 0)
7647 errmsg ("missing vpp interface name. ");
7651 /* Construct the API message */
7652 M (VIRTIO_PCI_DELETE, mp);
7654 mp->sw_if_index = htonl (sw_if_index);
7659 /* Wait for a reply... */
7665 api_bond_create (vat_main_t * vam)
7667 unformat_input_t *i = vam->input;
7668 vl_api_bond_create_t *mp;
7678 clib_memset (mac_address, 0, sizeof (mac_address));
7681 /* Parse args required to build the message */
7682 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7684 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7686 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7687 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7689 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7692 else if (unformat (i, "numa-only"))
7694 else if (unformat (i, "id %u", &id))
7700 if (mode_is_set == 0)
7702 errmsg ("Missing bond mode. ");
7706 /* Construct the API message */
7707 M (BOND_CREATE, mp);
7709 mp->use_custom_mac = custom_mac;
7711 mp->mode = htonl (mode);
7712 mp->lb = htonl (lb);
7713 mp->id = htonl (id);
7714 mp->numa_only = numa_only;
7717 clib_memcpy (mp->mac_address, mac_address, 6);
7722 /* Wait for a reply... */
7728 api_bond_delete (vat_main_t * vam)
7730 unformat_input_t *i = vam->input;
7731 vl_api_bond_delete_t *mp;
7732 u32 sw_if_index = ~0;
7733 u8 sw_if_index_set = 0;
7736 /* Parse args required to build the message */
7737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7739 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7740 sw_if_index_set = 1;
7741 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7742 sw_if_index_set = 1;
7747 if (sw_if_index_set == 0)
7749 errmsg ("missing vpp interface name. ");
7753 /* Construct the API message */
7754 M (BOND_DELETE, mp);
7756 mp->sw_if_index = ntohl (sw_if_index);
7761 /* Wait for a reply... */
7767 api_bond_enslave (vat_main_t * vam)
7769 unformat_input_t *i = vam->input;
7770 vl_api_bond_enslave_t *mp;
7771 u32 bond_sw_if_index;
7775 u32 bond_sw_if_index_is_set = 0;
7777 u8 sw_if_index_is_set = 0;
7779 /* Parse args required to build the message */
7780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7782 if (unformat (i, "sw_if_index %d", &sw_if_index))
7783 sw_if_index_is_set = 1;
7784 else if (unformat (i, "bond %u", &bond_sw_if_index))
7785 bond_sw_if_index_is_set = 1;
7786 else if (unformat (i, "passive %d", &is_passive))
7788 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7794 if (bond_sw_if_index_is_set == 0)
7796 errmsg ("Missing bond sw_if_index. ");
7799 if (sw_if_index_is_set == 0)
7801 errmsg ("Missing slave sw_if_index. ");
7805 /* Construct the API message */
7806 M (BOND_ENSLAVE, mp);
7808 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7809 mp->sw_if_index = ntohl (sw_if_index);
7810 mp->is_long_timeout = is_long_timeout;
7811 mp->is_passive = is_passive;
7816 /* Wait for a reply... */
7822 api_bond_detach_slave (vat_main_t * vam)
7824 unformat_input_t *i = vam->input;
7825 vl_api_bond_detach_slave_t *mp;
7826 u32 sw_if_index = ~0;
7827 u8 sw_if_index_set = 0;
7830 /* Parse args required to build the message */
7831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7833 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7834 sw_if_index_set = 1;
7835 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7836 sw_if_index_set = 1;
7841 if (sw_if_index_set == 0)
7843 errmsg ("missing vpp interface name. ");
7847 /* Construct the API message */
7848 M (BOND_DETACH_SLAVE, mp);
7850 mp->sw_if_index = ntohl (sw_if_index);
7855 /* Wait for a reply... */
7861 api_ip_table_add_del (vat_main_t * vam)
7863 unformat_input_t *i = vam->input;
7864 vl_api_ip_table_add_del_t *mp;
7870 /* Parse args required to build the message */
7871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7873 if (unformat (i, "ipv6"))
7875 else if (unformat (i, "del"))
7877 else if (unformat (i, "add"))
7879 else if (unformat (i, "table %d", &table_id))
7883 clib_warning ("parse error '%U'", format_unformat_error, i);
7890 errmsg ("missing table-ID");
7894 /* Construct the API message */
7895 M (IP_TABLE_ADD_DEL, mp);
7897 mp->table.table_id = ntohl (table_id);
7898 mp->table.is_ip6 = is_ipv6;
7899 mp->is_add = is_add;
7904 /* Wait for a reply... */
7911 unformat_fib_path (unformat_input_t * input, va_list * args)
7913 vat_main_t *vam = va_arg (*args, vat_main_t *);
7914 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7915 u32 weight, preference;
7916 mpls_label_t out_label;
7918 clib_memset (path, 0, sizeof (*path));
7920 path->sw_if_index = ~0;
7924 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7926 if (unformat (input, "%U %U",
7927 unformat_vl_api_ip4_address,
7928 &path->nh.address.ip4,
7929 api_unformat_sw_if_index, vam, &path->sw_if_index))
7931 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7933 else if (unformat (input, "%U %U",
7934 unformat_vl_api_ip6_address,
7935 &path->nh.address.ip6,
7936 api_unformat_sw_if_index, vam, &path->sw_if_index))
7938 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7940 else if (unformat (input, "weight %u", &weight))
7942 path->weight = weight;
7944 else if (unformat (input, "preference %u", &preference))
7946 path->preference = preference;
7948 else if (unformat (input, "%U next-hop-table %d",
7949 unformat_vl_api_ip4_address,
7950 &path->nh.address.ip4, &path->table_id))
7952 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7954 else if (unformat (input, "%U next-hop-table %d",
7955 unformat_vl_api_ip6_address,
7956 &path->nh.address.ip6, &path->table_id))
7958 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7960 else if (unformat (input, "%U",
7961 unformat_vl_api_ip4_address, &path->nh.address.ip4))
7964 * the recursive next-hops are by default in the default table
7967 path->sw_if_index = ~0;
7968 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7970 else if (unformat (input, "%U",
7971 unformat_vl_api_ip6_address, &path->nh.address.ip6))
7974 * the recursive next-hops are by default in the default table
7977 path->sw_if_index = ~0;
7978 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7980 else if (unformat (input, "resolve-via-host"))
7982 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
7984 else if (unformat (input, "resolve-via-attached"))
7986 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
7988 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
7990 path->type = FIB_API_PATH_TYPE_LOCAL;
7991 path->sw_if_index = ~0;
7992 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7994 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
7996 path->type = FIB_API_PATH_TYPE_LOCAL;
7997 path->sw_if_index = ~0;
7998 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8000 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8002 else if (unformat (input, "via-label %d", &path->nh.via_label))
8004 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8005 path->sw_if_index = ~0;
8007 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8009 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8010 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8012 else if (unformat (input, "local"))
8014 path->type = FIB_API_PATH_TYPE_LOCAL;
8016 else if (unformat (input, "out-labels"))
8018 while (unformat (input, "%d", &out_label))
8020 path->label_stack[path->n_labels].label = out_label;
8021 path->label_stack[path->n_labels].is_uniform = 0;
8022 path->label_stack[path->n_labels].ttl = 64;
8026 else if (unformat (input, "via"))
8028 /* new path, back up and return */
8029 unformat_put_input (input);
8030 unformat_put_input (input);
8031 unformat_put_input (input);
8032 unformat_put_input (input);
8041 path->proto = ntohl (path->proto);
8042 path->type = ntohl (path->type);
8043 path->flags = ntohl (path->flags);
8044 path->table_id = ntohl (path->table_id);
8045 path->sw_if_index = ntohl (path->sw_if_index);
8051 api_ip_route_add_del (vat_main_t * vam)
8053 unformat_input_t *i = vam->input;
8054 vl_api_ip_route_add_del_t *mp;
8057 u8 is_multipath = 0;
8060 vl_api_prefix_t pfx = { };
8061 vl_api_fib_path_t paths[8];
8065 u32 random_add_del = 0;
8066 u32 *random_vector = 0;
8067 u32 random_seed = 0xdeaddabe;
8069 /* Parse args required to build the message */
8070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8072 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8074 else if (unformat (i, "del"))
8076 else if (unformat (i, "add"))
8078 else if (unformat (i, "vrf %d", &vrf_id))
8080 else if (unformat (i, "count %d", &count))
8082 else if (unformat (i, "random"))
8084 else if (unformat (i, "multipath"))
8086 else if (unformat (i, "seed %d", &random_seed))
8090 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8093 if (8 == path_count)
8095 errmsg ("max 8 paths");
8101 clib_warning ("parse error '%U'", format_unformat_error, i);
8108 errmsg ("specify a path; via ...");
8111 if (prefix_set == 0)
8113 errmsg ("missing prefix");
8117 /* Generate a pile of unique, random routes */
8120 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8121 u32 this_random_address;
8124 random_hash = hash_create (count, sizeof (uword));
8126 hash_set (random_hash, i->as_u32, 1);
8127 for (j = 0; j <= count; j++)
8131 this_random_address = random_u32 (&random_seed);
8132 this_random_address =
8133 clib_host_to_net_u32 (this_random_address);
8135 while (hash_get (random_hash, this_random_address));
8136 vec_add1 (random_vector, this_random_address);
8137 hash_set (random_hash, this_random_address, 1);
8139 hash_free (random_hash);
8140 set_ip4_address (&pfx.address, random_vector[0]);
8145 /* Turn on async mode */
8146 vam->async_mode = 1;
8147 vam->async_errors = 0;
8148 before = vat_time_now (vam);
8151 for (j = 0; j < count; j++)
8153 /* Construct the API message */
8154 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8156 mp->is_add = is_add;
8157 mp->is_multipath = is_multipath;
8159 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8160 mp->route.table_id = ntohl (vrf_id);
8161 mp->route.n_paths = path_count;
8163 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8166 set_ip4_address (&pfx.address, random_vector[j + 1]);
8168 increment_address (&pfx.address);
8171 /* If we receive SIGTERM, stop now... */
8176 /* When testing multiple add/del ops, use a control-ping to sync */
8179 vl_api_control_ping_t *mp_ping;
8183 /* Shut off async mode */
8184 vam->async_mode = 0;
8186 MPING (CONTROL_PING, mp_ping);
8189 timeout = vat_time_now (vam) + 1.0;
8190 while (vat_time_now (vam) < timeout)
8191 if (vam->result_ready == 1)
8196 if (vam->retval == -99)
8199 if (vam->async_errors > 0)
8201 errmsg ("%d asynchronous errors", vam->async_errors);
8204 vam->async_errors = 0;
8205 after = vat_time_now (vam);
8207 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8211 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8212 count, after - before, count / (after - before));
8218 /* Wait for a reply... */
8223 /* Return the good/bad news */
8224 return (vam->retval);
8228 api_ip_mroute_add_del (vat_main_t * vam)
8230 unformat_input_t *i = vam->input;
8231 u8 path_set = 0, prefix_set = 0, is_add = 1;
8232 vl_api_ip_mroute_add_del_t *mp;
8233 mfib_entry_flags_t eflags = 0;
8234 vl_api_mfib_path_t path;
8235 vl_api_mprefix_t pfx = { };
8239 /* Parse args required to build the message */
8240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8242 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8245 pfx.grp_address_length = htons (pfx.grp_address_length);
8247 else if (unformat (i, "del"))
8249 else if (unformat (i, "add"))
8251 else if (unformat (i, "vrf %d", &vrf_id))
8253 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8254 path.itf_flags = htonl (path.itf_flags);
8255 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8257 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8261 clib_warning ("parse error '%U'", format_unformat_error, i);
8266 if (prefix_set == 0)
8268 errmsg ("missing addresses\n");
8273 errmsg ("missing path\n");
8277 /* Construct the API message */
8278 M (IP_MROUTE_ADD_DEL, mp);
8280 mp->is_add = is_add;
8281 mp->is_multipath = 1;
8283 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8284 mp->route.table_id = htonl (vrf_id);
8285 mp->route.n_paths = 1;
8286 mp->route.entry_flags = htonl (eflags);
8288 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8292 /* Wait for a reply... */
8298 api_mpls_table_add_del (vat_main_t * vam)
8300 unformat_input_t *i = vam->input;
8301 vl_api_mpls_table_add_del_t *mp;
8306 /* Parse args required to build the message */
8307 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8309 if (unformat (i, "table %d", &table_id))
8311 else if (unformat (i, "del"))
8313 else if (unformat (i, "add"))
8317 clib_warning ("parse error '%U'", format_unformat_error, i);
8324 errmsg ("missing table-ID");
8328 /* Construct the API message */
8329 M (MPLS_TABLE_ADD_DEL, mp);
8331 mp->mt_table.mt_table_id = ntohl (table_id);
8332 mp->mt_is_add = is_add;
8337 /* Wait for a reply... */
8344 api_mpls_route_add_del (vat_main_t * vam)
8346 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8347 mpls_label_t local_label = MPLS_LABEL_INVALID;
8348 unformat_input_t *i = vam->input;
8349 vl_api_mpls_route_add_del_t *mp;
8350 vl_api_fib_path_t paths[8];
8354 /* Parse args required to build the message */
8355 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8357 if (unformat (i, "%d", &local_label))
8359 else if (unformat (i, "eos"))
8361 else if (unformat (i, "non-eos"))
8363 else if (unformat (i, "del"))
8365 else if (unformat (i, "add"))
8367 else if (unformat (i, "multipath"))
8369 else if (unformat (i, "count %d", &count))
8373 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8376 if (8 == path_count)
8378 errmsg ("max 8 paths");
8384 clib_warning ("parse error '%U'", format_unformat_error, i);
8391 errmsg ("specify a path; via ...");
8395 if (MPLS_LABEL_INVALID == local_label)
8397 errmsg ("missing label");
8403 /* Turn on async mode */
8404 vam->async_mode = 1;
8405 vam->async_errors = 0;
8406 before = vat_time_now (vam);
8409 for (j = 0; j < count; j++)
8411 /* Construct the API message */
8412 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8414 mp->mr_is_add = is_add;
8415 mp->mr_is_multipath = is_multipath;
8417 mp->mr_route.mr_label = local_label;
8418 mp->mr_route.mr_eos = is_eos;
8419 mp->mr_route.mr_table_id = 0;
8420 mp->mr_route.mr_n_paths = path_count;
8422 clib_memcpy (&mp->mr_route.mr_paths, paths,
8423 sizeof (paths[0]) * path_count);
8429 /* If we receive SIGTERM, stop now... */
8434 /* When testing multiple add/del ops, use a control-ping to sync */
8437 vl_api_control_ping_t *mp_ping;
8441 /* Shut off async mode */
8442 vam->async_mode = 0;
8444 MPING (CONTROL_PING, mp_ping);
8447 timeout = vat_time_now (vam) + 1.0;
8448 while (vat_time_now (vam) < timeout)
8449 if (vam->result_ready == 1)
8454 if (vam->retval == -99)
8457 if (vam->async_errors > 0)
8459 errmsg ("%d asynchronous errors", vam->async_errors);
8462 vam->async_errors = 0;
8463 after = vat_time_now (vam);
8465 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8469 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8470 count, after - before, count / (after - before));
8476 /* Wait for a reply... */
8481 /* Return the good/bad news */
8482 return (vam->retval);
8487 api_mpls_ip_bind_unbind (vat_main_t * vam)
8489 unformat_input_t *i = vam->input;
8490 vl_api_mpls_ip_bind_unbind_t *mp;
8491 u32 ip_table_id = 0;
8493 vl_api_prefix_t pfx;
8495 mpls_label_t local_label = MPLS_LABEL_INVALID;
8498 /* Parse args required to build the message */
8499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8501 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8503 else if (unformat (i, "%d", &local_label))
8505 else if (unformat (i, "table-id %d", &ip_table_id))
8507 else if (unformat (i, "unbind"))
8509 else if (unformat (i, "bind"))
8513 clib_warning ("parse error '%U'", format_unformat_error, i);
8520 errmsg ("IP prefix not set");
8524 if (MPLS_LABEL_INVALID == local_label)
8526 errmsg ("missing label");
8530 /* Construct the API message */
8531 M (MPLS_IP_BIND_UNBIND, mp);
8533 mp->mb_is_bind = is_bind;
8534 mp->mb_ip_table_id = ntohl (ip_table_id);
8535 mp->mb_mpls_table_id = 0;
8536 mp->mb_label = ntohl (local_label);
8537 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8542 /* Wait for a reply... */
8549 api_sr_mpls_policy_add (vat_main_t * vam)
8551 unformat_input_t *i = vam->input;
8552 vl_api_sr_mpls_policy_add_t *mp;
8558 u32 *segments = NULL;
8561 /* Parse args required to build the message */
8562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8564 if (unformat (i, "bsid %d", &bsid))
8566 else if (unformat (i, "weight %d", &weight))
8568 else if (unformat (i, "spray"))
8570 else if (unformat (i, "next %d", &sid))
8573 vec_add1 (segments, htonl (sid));
8577 clib_warning ("parse error '%U'", format_unformat_error, i);
8584 errmsg ("bsid not set");
8588 if (n_segments == 0)
8590 errmsg ("no sid in segment stack");
8594 /* Construct the API message */
8595 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8597 mp->bsid = htonl (bsid);
8598 mp->weight = htonl (weight);
8600 mp->n_segments = n_segments;
8601 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8602 vec_free (segments);
8607 /* Wait for a reply... */
8613 api_sr_mpls_policy_del (vat_main_t * vam)
8615 unformat_input_t *i = vam->input;
8616 vl_api_sr_mpls_policy_del_t *mp;
8620 /* Parse args required to build the message */
8621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8623 if (unformat (i, "bsid %d", &bsid))
8627 clib_warning ("parse error '%U'", format_unformat_error, i);
8634 errmsg ("bsid not set");
8638 /* Construct the API message */
8639 M (SR_MPLS_POLICY_DEL, mp);
8641 mp->bsid = htonl (bsid);
8646 /* Wait for a reply... */
8652 api_bier_table_add_del (vat_main_t * vam)
8654 unformat_input_t *i = vam->input;
8655 vl_api_bier_table_add_del_t *mp;
8657 u32 set = 0, sub_domain = 0, hdr_len = 3;
8658 mpls_label_t local_label = MPLS_LABEL_INVALID;
8661 /* Parse args required to build the message */
8662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8664 if (unformat (i, "sub-domain %d", &sub_domain))
8666 else if (unformat (i, "set %d", &set))
8668 else if (unformat (i, "label %d", &local_label))
8670 else if (unformat (i, "hdr-len %d", &hdr_len))
8672 else if (unformat (i, "add"))
8674 else if (unformat (i, "del"))
8678 clib_warning ("parse error '%U'", format_unformat_error, i);
8683 if (MPLS_LABEL_INVALID == local_label)
8685 errmsg ("missing label\n");
8689 /* Construct the API message */
8690 M (BIER_TABLE_ADD_DEL, mp);
8692 mp->bt_is_add = is_add;
8693 mp->bt_label = ntohl (local_label);
8694 mp->bt_tbl_id.bt_set = set;
8695 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8696 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8701 /* Wait for a reply... */
8708 api_bier_route_add_del (vat_main_t * vam)
8710 unformat_input_t *i = vam->input;
8711 vl_api_bier_route_add_del_t *mp;
8713 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8714 ip4_address_t v4_next_hop_address;
8715 ip6_address_t v6_next_hop_address;
8716 u8 next_hop_set = 0;
8717 u8 next_hop_proto_is_ip4 = 1;
8718 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8721 /* Parse args required to build the message */
8722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8724 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8726 next_hop_proto_is_ip4 = 1;
8729 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8731 next_hop_proto_is_ip4 = 0;
8734 if (unformat (i, "sub-domain %d", &sub_domain))
8736 else if (unformat (i, "set %d", &set))
8738 else if (unformat (i, "hdr-len %d", &hdr_len))
8740 else if (unformat (i, "bp %d", &bp))
8742 else if (unformat (i, "add"))
8744 else if (unformat (i, "del"))
8746 else if (unformat (i, "out-label %d", &next_hop_out_label))
8750 clib_warning ("parse error '%U'", format_unformat_error, i);
8755 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8757 errmsg ("next hop / label set\n");
8762 errmsg ("bit=position not set\n");
8766 /* Construct the API message */
8767 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8769 mp->br_is_add = is_add;
8770 mp->br_route.br_tbl_id.bt_set = set;
8771 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8772 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8773 mp->br_route.br_bp = ntohs (bp);
8774 mp->br_route.br_n_paths = 1;
8775 mp->br_route.br_paths[0].n_labels = 1;
8776 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8777 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8778 FIB_API_PATH_NH_PROTO_IP4 :
8779 FIB_API_PATH_NH_PROTO_IP6);
8781 if (next_hop_proto_is_ip4)
8783 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8784 &v4_next_hop_address, sizeof (v4_next_hop_address));
8788 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8789 &v6_next_hop_address, sizeof (v6_next_hop_address));
8795 /* Wait for a reply... */
8802 api_proxy_arp_add_del (vat_main_t * vam)
8804 unformat_input_t *i = vam->input;
8805 vl_api_proxy_arp_add_del_t *mp;
8808 vl_api_ip4_address_t lo, hi;
8812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8814 if (unformat (i, "vrf %d", &vrf_id))
8816 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
8817 unformat_vl_api_ip4_address, &hi))
8819 else if (unformat (i, "del"))
8823 clib_warning ("parse error '%U'", format_unformat_error, i);
8830 errmsg ("address range not set");
8834 M (PROXY_ARP_ADD_DEL, mp);
8836 mp->proxy.table_id = ntohl (vrf_id);
8837 mp->is_add = is_add;
8838 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
8839 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
8847 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8849 unformat_input_t *i = vam->input;
8850 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8853 u8 sw_if_index_set = 0;
8856 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8858 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8859 sw_if_index_set = 1;
8860 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8861 sw_if_index_set = 1;
8862 else if (unformat (i, "enable"))
8864 else if (unformat (i, "disable"))
8868 clib_warning ("parse error '%U'", format_unformat_error, i);
8873 if (sw_if_index_set == 0)
8875 errmsg ("missing interface name or sw_if_index");
8879 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8881 mp->sw_if_index = ntohl (sw_if_index);
8882 mp->enable_disable = enable;
8890 api_mpls_tunnel_add_del (vat_main_t * vam)
8892 unformat_input_t *i = vam->input;
8893 vl_api_mpls_tunnel_add_del_t *mp;
8895 vl_api_fib_path_t paths[8];
8896 u32 sw_if_index = ~0;
8902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8904 if (unformat (i, "add"))
8908 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8910 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8912 else if (unformat (i, "l2-only"))
8916 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8919 if (8 == path_count)
8921 errmsg ("max 8 paths");
8927 clib_warning ("parse error '%U'", format_unformat_error, i);
8932 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8934 mp->mt_is_add = is_add;
8935 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8936 mp->mt_tunnel.mt_l2_only = l2_only;
8937 mp->mt_tunnel.mt_is_multicast = 0;
8938 mp->mt_tunnel.mt_n_paths = path_count;
8940 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8941 sizeof (paths[0]) * path_count);
8949 api_sw_interface_set_unnumbered (vat_main_t * vam)
8951 unformat_input_t *i = vam->input;
8952 vl_api_sw_interface_set_unnumbered_t *mp;
8954 u32 unnum_sw_index = ~0;
8956 u8 sw_if_index_set = 0;
8959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8961 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8962 sw_if_index_set = 1;
8963 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8964 sw_if_index_set = 1;
8965 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8967 else if (unformat (i, "del"))
8971 clib_warning ("parse error '%U'", format_unformat_error, i);
8976 if (sw_if_index_set == 0)
8978 errmsg ("missing interface name or sw_if_index");
8982 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8984 mp->sw_if_index = ntohl (sw_if_index);
8985 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8986 mp->is_add = is_add;
8994 api_ip_neighbor_add_del (vat_main_t * vam)
8996 vl_api_mac_address_t mac_address;
8997 unformat_input_t *i = vam->input;
8998 vl_api_ip_neighbor_add_del_t *mp;
8999 vl_api_address_t ip_address;
9001 u8 sw_if_index_set = 0;
9006 ip_neighbor_flags_t flags;
9008 flags = IP_NEIGHBOR_FLAG_NONE;
9009 clib_memset (&ip_address, 0, sizeof (ip_address));
9010 clib_memset (&mac_address, 0, sizeof (mac_address));
9012 /* Parse args required to build the message */
9013 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9015 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9019 else if (unformat (i, "del"))
9022 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9023 sw_if_index_set = 1;
9024 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9025 sw_if_index_set = 1;
9026 else if (unformat (i, "static"))
9027 flags |= IP_NEIGHBOR_FLAG_STATIC;
9028 else if (unformat (i, "no-fib-entry"))
9029 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9030 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9034 clib_warning ("parse error '%U'", format_unformat_error, i);
9039 if (sw_if_index_set == 0)
9041 errmsg ("missing interface name or sw_if_index");
9046 errmsg ("no address set");
9050 /* Construct the API message */
9051 M (IP_NEIGHBOR_ADD_DEL, mp);
9053 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9054 mp->is_add = is_add;
9055 mp->neighbor.flags = htonl (flags);
9057 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9058 sizeof (mac_address));
9060 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9065 /* Wait for a reply, return good/bad news */
9071 api_create_vlan_subif (vat_main_t * vam)
9073 unformat_input_t *i = vam->input;
9074 vl_api_create_vlan_subif_t *mp;
9076 u8 sw_if_index_set = 0;
9081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9083 if (unformat (i, "sw_if_index %d", &sw_if_index))
9084 sw_if_index_set = 1;
9086 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9087 sw_if_index_set = 1;
9088 else if (unformat (i, "vlan %d", &vlan_id))
9092 clib_warning ("parse error '%U'", format_unformat_error, i);
9097 if (sw_if_index_set == 0)
9099 errmsg ("missing interface name or sw_if_index");
9103 if (vlan_id_set == 0)
9105 errmsg ("missing vlan_id");
9108 M (CREATE_VLAN_SUBIF, mp);
9110 mp->sw_if_index = ntohl (sw_if_index);
9111 mp->vlan_id = ntohl (vlan_id);
9118 #define foreach_create_subif_bit \
9125 _(outer_vlan_id_any) \
9126 _(inner_vlan_id_any)
9128 #define foreach_create_subif_flag \
9133 _(4, "exact_match") \
9134 _(5, "default_sub") \
9135 _(6, "outer_vlan_id_any") \
9136 _(7, "inner_vlan_id_any")
9139 api_create_subif (vat_main_t * vam)
9141 unformat_input_t *i = vam->input;
9142 vl_api_create_subif_t *mp;
9144 u8 sw_if_index_set = 0;
9147 u32 __attribute__ ((unused)) no_tags = 0;
9148 u32 __attribute__ ((unused)) one_tag = 0;
9149 u32 __attribute__ ((unused)) two_tags = 0;
9150 u32 __attribute__ ((unused)) dot1ad = 0;
9151 u32 __attribute__ ((unused)) exact_match = 0;
9152 u32 __attribute__ ((unused)) default_sub = 0;
9153 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
9154 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
9156 u16 outer_vlan_id = 0;
9157 u16 inner_vlan_id = 0;
9160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9162 if (unformat (i, "sw_if_index %d", &sw_if_index))
9163 sw_if_index_set = 1;
9165 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9166 sw_if_index_set = 1;
9167 else if (unformat (i, "sub_id %d", &sub_id))
9169 else if (unformat (i, "outer_vlan_id %d", &tmp))
9170 outer_vlan_id = tmp;
9171 else if (unformat (i, "inner_vlan_id %d", &tmp))
9172 inner_vlan_id = tmp;
9174 #define _(a) else if (unformat (i, #a)) a = 1 ;
9175 foreach_create_subif_bit
9179 clib_warning ("parse error '%U'", format_unformat_error, i);
9184 if (sw_if_index_set == 0)
9186 errmsg ("missing interface name or sw_if_index");
9190 if (sub_id_set == 0)
9192 errmsg ("missing sub_id");
9195 M (CREATE_SUBIF, mp);
9197 mp->sw_if_index = ntohl (sw_if_index);
9198 mp->sub_id = ntohl (sub_id);
9200 #define _(a,b) mp->sub_if_flags |= (1 << a);
9201 foreach_create_subif_flag;
9204 mp->outer_vlan_id = ntohs (outer_vlan_id);
9205 mp->inner_vlan_id = ntohs (inner_vlan_id);
9213 api_reset_fib (vat_main_t * vam)
9215 unformat_input_t *i = vam->input;
9216 vl_api_reset_fib_t *mp;
9222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9224 if (unformat (i, "vrf %d", &vrf_id))
9226 else if (unformat (i, "ipv6"))
9230 clib_warning ("parse error '%U'", format_unformat_error, i);
9235 if (vrf_id_set == 0)
9237 errmsg ("missing vrf id");
9243 mp->vrf_id = ntohl (vrf_id);
9244 mp->is_ipv6 = is_ipv6;
9252 api_set_ip_flow_hash (vat_main_t * vam)
9254 unformat_input_t *i = vam->input;
9255 vl_api_set_ip_flow_hash_t *mp;
9267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9269 if (unformat (i, "vrf %d", &vrf_id))
9271 else if (unformat (i, "ipv6"))
9273 else if (unformat (i, "src"))
9275 else if (unformat (i, "dst"))
9277 else if (unformat (i, "sport"))
9279 else if (unformat (i, "dport"))
9281 else if (unformat (i, "proto"))
9283 else if (unformat (i, "reverse"))
9288 clib_warning ("parse error '%U'", format_unformat_error, i);
9293 if (vrf_id_set == 0)
9295 errmsg ("missing vrf id");
9299 M (SET_IP_FLOW_HASH, mp);
9305 mp->reverse = reverse;
9306 mp->vrf_id = ntohl (vrf_id);
9307 mp->is_ipv6 = is_ipv6;
9315 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9317 unformat_input_t *i = vam->input;
9318 vl_api_sw_interface_ip6_enable_disable_t *mp;
9320 u8 sw_if_index_set = 0;
9324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9326 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9327 sw_if_index_set = 1;
9328 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9329 sw_if_index_set = 1;
9330 else if (unformat (i, "enable"))
9332 else if (unformat (i, "disable"))
9336 clib_warning ("parse error '%U'", format_unformat_error, i);
9341 if (sw_if_index_set == 0)
9343 errmsg ("missing interface name or sw_if_index");
9347 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9349 mp->sw_if_index = ntohl (sw_if_index);
9350 mp->enable = enable;
9358 api_ip6nd_proxy_add_del (vat_main_t * vam)
9360 unformat_input_t *i = vam->input;
9361 vl_api_ip6nd_proxy_add_del_t *mp;
9362 u32 sw_if_index = ~0;
9363 u8 v6_address_set = 0;
9364 vl_api_ip6_address_t v6address;
9368 /* Parse args required to build the message */
9369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9371 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9373 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9375 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
9377 if (unformat (i, "del"))
9381 clib_warning ("parse error '%U'", format_unformat_error, i);
9386 if (sw_if_index == ~0)
9388 errmsg ("missing interface name or sw_if_index");
9391 if (!v6_address_set)
9393 errmsg ("no address set");
9397 /* Construct the API message */
9398 M (IP6ND_PROXY_ADD_DEL, mp);
9400 mp->is_del = is_del;
9401 mp->sw_if_index = ntohl (sw_if_index);
9402 clib_memcpy (mp->ip, v6address, sizeof (v6address));
9407 /* Wait for a reply, return good/bad news */
9413 api_ip6nd_proxy_dump (vat_main_t * vam)
9415 vl_api_ip6nd_proxy_dump_t *mp;
9416 vl_api_control_ping_t *mp_ping;
9419 M (IP6ND_PROXY_DUMP, mp);
9423 /* Use a control ping for synchronization */
9424 MPING (CONTROL_PING, mp_ping);
9431 static void vl_api_ip6nd_proxy_details_t_handler
9432 (vl_api_ip6nd_proxy_details_t * mp)
9434 vat_main_t *vam = &vat_main;
9436 print (vam->ofp, "host %U sw_if_index %d",
9437 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
9440 static void vl_api_ip6nd_proxy_details_t_handler_json
9441 (vl_api_ip6nd_proxy_details_t * mp)
9443 vat_main_t *vam = &vat_main;
9444 struct in6_addr ip6;
9445 vat_json_node_t *node = NULL;
9447 if (VAT_JSON_ARRAY != vam->json_tree.type)
9449 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9450 vat_json_init_array (&vam->json_tree);
9452 node = vat_json_array_add (&vam->json_tree);
9454 vat_json_init_object (node);
9455 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9457 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
9458 vat_json_object_add_ip6 (node, "host", ip6);
9462 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9464 unformat_input_t *i = vam->input;
9465 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9467 u8 sw_if_index_set = 0;
9468 u8 v6_address_set = 0;
9469 vl_api_prefix_t pfx;
9471 u8 no_advertise = 0;
9473 u8 no_autoconfig = 0;
9476 u32 val_lifetime = 0;
9477 u32 pref_lifetime = 0;
9480 /* Parse args required to build the message */
9481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9483 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9484 sw_if_index_set = 1;
9485 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9486 sw_if_index_set = 1;
9487 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
9489 else if (unformat (i, "val_life %d", &val_lifetime))
9491 else if (unformat (i, "pref_life %d", &pref_lifetime))
9493 else if (unformat (i, "def"))
9495 else if (unformat (i, "noadv"))
9497 else if (unformat (i, "offl"))
9499 else if (unformat (i, "noauto"))
9501 else if (unformat (i, "nolink"))
9503 else if (unformat (i, "isno"))
9507 clib_warning ("parse error '%U'", format_unformat_error, i);
9512 if (sw_if_index_set == 0)
9514 errmsg ("missing interface name or sw_if_index");
9517 if (!v6_address_set)
9519 errmsg ("no address set");
9523 /* Construct the API message */
9524 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9526 mp->sw_if_index = ntohl (sw_if_index);
9527 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
9528 mp->use_default = use_default;
9529 mp->no_advertise = no_advertise;
9530 mp->off_link = off_link;
9531 mp->no_autoconfig = no_autoconfig;
9532 mp->no_onlink = no_onlink;
9534 mp->val_lifetime = ntohl (val_lifetime);
9535 mp->pref_lifetime = ntohl (pref_lifetime);
9540 /* Wait for a reply, return good/bad news */
9546 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9548 unformat_input_t *i = vam->input;
9549 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9551 u8 sw_if_index_set = 0;
9556 u8 send_unicast = 0;
9559 u8 default_router = 0;
9560 u32 max_interval = 0;
9561 u32 min_interval = 0;
9563 u32 initial_count = 0;
9564 u32 initial_interval = 0;
9568 /* Parse args required to build the message */
9569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9571 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9572 sw_if_index_set = 1;
9573 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9574 sw_if_index_set = 1;
9575 else if (unformat (i, "maxint %d", &max_interval))
9577 else if (unformat (i, "minint %d", &min_interval))
9579 else if (unformat (i, "life %d", &lifetime))
9581 else if (unformat (i, "count %d", &initial_count))
9583 else if (unformat (i, "interval %d", &initial_interval))
9585 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9587 else if (unformat (i, "managed"))
9589 else if (unformat (i, "other"))
9591 else if (unformat (i, "ll"))
9593 else if (unformat (i, "send"))
9595 else if (unformat (i, "cease"))
9597 else if (unformat (i, "isno"))
9599 else if (unformat (i, "def"))
9603 clib_warning ("parse error '%U'", format_unformat_error, i);
9608 if (sw_if_index_set == 0)
9610 errmsg ("missing interface name or sw_if_index");
9614 /* Construct the API message */
9615 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9617 mp->sw_if_index = ntohl (sw_if_index);
9618 mp->max_interval = ntohl (max_interval);
9619 mp->min_interval = ntohl (min_interval);
9620 mp->lifetime = ntohl (lifetime);
9621 mp->initial_count = ntohl (initial_count);
9622 mp->initial_interval = ntohl (initial_interval);
9623 mp->suppress = suppress;
9624 mp->managed = managed;
9626 mp->ll_option = ll_option;
9627 mp->send_unicast = send_unicast;
9630 mp->default_router = default_router;
9635 /* Wait for a reply, return good/bad news */
9641 api_set_arp_neighbor_limit (vat_main_t * vam)
9643 unformat_input_t *i = vam->input;
9644 vl_api_set_arp_neighbor_limit_t *mp;
9650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9652 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9654 else if (unformat (i, "ipv6"))
9658 clib_warning ("parse error '%U'", format_unformat_error, i);
9665 errmsg ("missing limit value");
9669 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9671 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9672 mp->is_ipv6 = is_ipv6;
9680 api_l2_patch_add_del (vat_main_t * vam)
9682 unformat_input_t *i = vam->input;
9683 vl_api_l2_patch_add_del_t *mp;
9685 u8 rx_sw_if_index_set = 0;
9687 u8 tx_sw_if_index_set = 0;
9691 /* Parse args required to build the message */
9692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9694 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9695 rx_sw_if_index_set = 1;
9696 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9697 tx_sw_if_index_set = 1;
9698 else if (unformat (i, "rx"))
9700 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9702 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9704 rx_sw_if_index_set = 1;
9709 else if (unformat (i, "tx"))
9711 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9713 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9715 tx_sw_if_index_set = 1;
9720 else if (unformat (i, "del"))
9726 if (rx_sw_if_index_set == 0)
9728 errmsg ("missing rx interface name or rx_sw_if_index");
9732 if (tx_sw_if_index_set == 0)
9734 errmsg ("missing tx interface name or tx_sw_if_index");
9738 M (L2_PATCH_ADD_DEL, mp);
9740 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9741 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9742 mp->is_add = is_add;
9750 u8 localsid_addr[16];
9759 api_sr_localsid_add_del (vat_main_t * vam)
9761 unformat_input_t *i = vam->input;
9762 vl_api_sr_localsid_add_del_t *mp;
9765 ip6_address_t localsid;
9769 u32 fib_table = ~(u32) 0;
9770 ip6_address_t nh_addr6;
9771 ip4_address_t nh_addr4;
9772 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
9773 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
9775 bool nexthop_set = 0;
9779 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9781 if (unformat (i, "del"))
9783 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9784 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
9786 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
9788 else if (unformat (i, "behavior %u", &behavior));
9789 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9790 else if (unformat (i, "fib-table %u", &fib_table));
9791 else if (unformat (i, "end.psp %u", &behavior));
9796 M (SR_LOCALSID_ADD_DEL, mp);
9798 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
9802 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
9803 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
9805 mp->behavior = behavior;
9806 mp->sw_if_index = ntohl (sw_if_index);
9807 mp->fib_table = ntohl (fib_table);
9808 mp->end_psp = end_psp;
9809 mp->is_del = is_del;
9817 api_ioam_enable (vat_main_t * vam)
9819 unformat_input_t *input = vam->input;
9820 vl_api_ioam_enable_t *mp;
9822 int has_trace_option = 0;
9823 int has_pot_option = 0;
9824 int has_seqno_option = 0;
9825 int has_analyse_option = 0;
9828 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9830 if (unformat (input, "trace"))
9831 has_trace_option = 1;
9832 else if (unformat (input, "pot"))
9834 else if (unformat (input, "seqno"))
9835 has_seqno_option = 1;
9836 else if (unformat (input, "analyse"))
9837 has_analyse_option = 1;
9841 M (IOAM_ENABLE, mp);
9842 mp->id = htons (id);
9843 mp->seqno = has_seqno_option;
9844 mp->analyse = has_analyse_option;
9845 mp->pot_enable = has_pot_option;
9846 mp->trace_enable = has_trace_option;
9855 api_ioam_disable (vat_main_t * vam)
9857 vl_api_ioam_disable_t *mp;
9860 M (IOAM_DISABLE, mp);
9866 #define foreach_tcp_proto_field \
9870 #define foreach_udp_proto_field \
9874 #define foreach_ip4_proto_field \
9886 u16 src_port, dst_port;
9889 #if VPP_API_TEST_BUILTIN == 0
9891 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9893 u8 **maskp = va_arg (*args, u8 **);
9895 u8 found_something = 0;
9898 #define _(a) u8 a=0;
9899 foreach_tcp_proto_field;
9902 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9905 #define _(a) else if (unformat (input, #a)) a=1;
9906 foreach_tcp_proto_field
9912 #define _(a) found_something += a;
9913 foreach_tcp_proto_field;
9916 if (found_something == 0)
9919 vec_validate (mask, sizeof (*tcp) - 1);
9921 tcp = (tcp_header_t *) mask;
9923 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
9924 foreach_tcp_proto_field;
9932 unformat_udp_mask (unformat_input_t * input, va_list * args)
9934 u8 **maskp = va_arg (*args, u8 **);
9936 u8 found_something = 0;
9939 #define _(a) u8 a=0;
9940 foreach_udp_proto_field;
9943 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9946 #define _(a) else if (unformat (input, #a)) a=1;
9947 foreach_udp_proto_field
9953 #define _(a) found_something += a;
9954 foreach_udp_proto_field;
9957 if (found_something == 0)
9960 vec_validate (mask, sizeof (*udp) - 1);
9962 udp = (udp_header_t *) mask;
9964 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
9965 foreach_udp_proto_field;
9973 unformat_l4_mask (unformat_input_t * input, va_list * args)
9975 u8 **maskp = va_arg (*args, u8 **);
9976 u16 src_port = 0, dst_port = 0;
9977 tcpudp_header_t *tcpudp;
9979 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9981 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9983 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9985 else if (unformat (input, "src_port"))
9987 else if (unformat (input, "dst_port"))
9993 if (!src_port && !dst_port)
9997 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9999 tcpudp = (tcpudp_header_t *) mask;
10000 tcpudp->src_port = src_port;
10001 tcpudp->dst_port = dst_port;
10009 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10011 u8 **maskp = va_arg (*args, u8 **);
10013 u8 found_something = 0;
10016 #define _(a) u8 a=0;
10017 foreach_ip4_proto_field;
10023 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10025 if (unformat (input, "version"))
10027 else if (unformat (input, "hdr_length"))
10029 else if (unformat (input, "src"))
10031 else if (unformat (input, "dst"))
10033 else if (unformat (input, "proto"))
10036 #define _(a) else if (unformat (input, #a)) a=1;
10037 foreach_ip4_proto_field
10043 #define _(a) found_something += a;
10044 foreach_ip4_proto_field;
10047 if (found_something == 0)
10050 vec_validate (mask, sizeof (*ip) - 1);
10052 ip = (ip4_header_t *) mask;
10054 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10055 foreach_ip4_proto_field;
10058 ip->ip_version_and_header_length = 0;
10061 ip->ip_version_and_header_length |= 0xF0;
10064 ip->ip_version_and_header_length |= 0x0F;
10070 #define foreach_ip6_proto_field \
10073 _(payload_length) \
10078 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10080 u8 **maskp = va_arg (*args, u8 **);
10082 u8 found_something = 0;
10084 u32 ip_version_traffic_class_and_flow_label;
10086 #define _(a) u8 a=0;
10087 foreach_ip6_proto_field;
10090 u8 traffic_class = 0;
10093 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10095 if (unformat (input, "version"))
10097 else if (unformat (input, "traffic-class"))
10099 else if (unformat (input, "flow-label"))
10101 else if (unformat (input, "src"))
10103 else if (unformat (input, "dst"))
10105 else if (unformat (input, "proto"))
10108 #define _(a) else if (unformat (input, #a)) a=1;
10109 foreach_ip6_proto_field
10115 #define _(a) found_something += a;
10116 foreach_ip6_proto_field;
10119 if (found_something == 0)
10122 vec_validate (mask, sizeof (*ip) - 1);
10124 ip = (ip6_header_t *) mask;
10126 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10127 foreach_ip6_proto_field;
10130 ip_version_traffic_class_and_flow_label = 0;
10133 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10136 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10139 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10141 ip->ip_version_traffic_class_and_flow_label =
10142 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10149 unformat_l3_mask (unformat_input_t * input, va_list * args)
10151 u8 **maskp = va_arg (*args, u8 **);
10153 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10155 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10157 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10166 unformat_l2_mask (unformat_input_t * input, va_list * args)
10168 u8 **maskp = va_arg (*args, u8 **);
10175 u8 ignore_tag1 = 0;
10176 u8 ignore_tag2 = 0;
10183 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10185 if (unformat (input, "src"))
10187 else if (unformat (input, "dst"))
10189 else if (unformat (input, "proto"))
10191 else if (unformat (input, "tag1"))
10193 else if (unformat (input, "tag2"))
10195 else if (unformat (input, "ignore-tag1"))
10197 else if (unformat (input, "ignore-tag2"))
10199 else if (unformat (input, "cos1"))
10201 else if (unformat (input, "cos2"))
10203 else if (unformat (input, "dot1q"))
10205 else if (unformat (input, "dot1ad"))
10210 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10211 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10214 if (tag1 || ignore_tag1 || cos1 || dot1q)
10216 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10219 vec_validate (mask, len - 1);
10222 clib_memset (mask, 0xff, 6);
10225 clib_memset (mask + 6, 0xff, 6);
10227 if (tag2 || dot1ad)
10229 /* inner vlan tag */
10238 mask[21] = mask[20] = 0xff;
10259 mask[16] = mask[17] = 0xff;
10269 mask[12] = mask[13] = 0xff;
10276 unformat_classify_mask (unformat_input_t * input, va_list * args)
10278 u8 **maskp = va_arg (*args, u8 **);
10279 u32 *skipp = va_arg (*args, u32 *);
10280 u32 *matchp = va_arg (*args, u32 *);
10288 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10290 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10292 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10294 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10296 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10310 if (mask || l2 || l3 || l4)
10312 if (l2 || l3 || l4)
10314 /* "With a free Ethernet header in every package" */
10316 vec_validate (l2, 13);
10320 vec_append (mask, l3);
10325 vec_append (mask, l4);
10330 /* Scan forward looking for the first significant mask octet */
10331 for (i = 0; i < vec_len (mask); i++)
10335 /* compute (skip, match) params */
10336 *skipp = i / sizeof (u32x4);
10337 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10339 /* Pad mask to an even multiple of the vector size */
10340 while (vec_len (mask) % sizeof (u32x4))
10341 vec_add1 (mask, 0);
10343 match = vec_len (mask) / sizeof (u32x4);
10345 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10347 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10348 if (*tmp || *(tmp + 1))
10353 clib_warning ("BUG: match 0");
10355 _vec_len (mask) = match * sizeof (u32x4);
10365 #endif /* VPP_API_TEST_BUILTIN */
10367 #define foreach_l2_next \
10369 _(ethernet, ETHERNET_INPUT) \
10370 _(ip4, IP4_INPUT) \
10374 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10376 u32 *miss_next_indexp = va_arg (*args, u32 *);
10377 u32 next_index = 0;
10381 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10385 if (unformat (input, "%d", &tmp))
10394 *miss_next_indexp = next_index;
10398 #define foreach_ip_next \
10401 _(rewrite, REWRITE)
10404 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10406 u32 *miss_next_indexp = va_arg (*args, u32 *);
10407 u32 next_index = 0;
10411 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10415 if (unformat (input, "%d", &tmp))
10424 *miss_next_indexp = next_index;
10428 #define foreach_acl_next \
10432 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10434 u32 *miss_next_indexp = va_arg (*args, u32 *);
10435 u32 next_index = 0;
10439 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10443 if (unformat (input, "permit"))
10448 else if (unformat (input, "%d", &tmp))
10457 *miss_next_indexp = next_index;
10462 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10464 u32 *r = va_arg (*args, u32 *);
10466 if (unformat (input, "conform-color"))
10467 *r = POLICE_CONFORM;
10468 else if (unformat (input, "exceed-color"))
10469 *r = POLICE_EXCEED;
10477 api_classify_add_del_table (vat_main_t * vam)
10479 unformat_input_t *i = vam->input;
10480 vl_api_classify_add_del_table_t *mp;
10487 u32 table_index = ~0;
10488 u32 next_table_index = ~0;
10489 u32 miss_next_index = ~0;
10490 u32 memory_size = 32 << 20;
10492 u32 current_data_flag = 0;
10493 int current_data_offset = 0;
10496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10498 if (unformat (i, "del"))
10500 else if (unformat (i, "del-chain"))
10505 else if (unformat (i, "buckets %d", &nbuckets))
10507 else if (unformat (i, "memory_size %d", &memory_size))
10509 else if (unformat (i, "skip %d", &skip))
10511 else if (unformat (i, "match %d", &match))
10513 else if (unformat (i, "table %d", &table_index))
10515 else if (unformat (i, "mask %U", unformat_classify_mask,
10516 &mask, &skip, &match))
10518 else if (unformat (i, "next-table %d", &next_table_index))
10520 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10523 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10526 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10529 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10531 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10537 if (is_add && mask == 0)
10539 errmsg ("Mask required");
10543 if (is_add && skip == ~0)
10545 errmsg ("skip count required");
10549 if (is_add && match == ~0)
10551 errmsg ("match count required");
10555 if (!is_add && table_index == ~0)
10557 errmsg ("table index required for delete");
10561 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10563 mp->is_add = is_add;
10564 mp->del_chain = del_chain;
10565 mp->table_index = ntohl (table_index);
10566 mp->nbuckets = ntohl (nbuckets);
10567 mp->memory_size = ntohl (memory_size);
10568 mp->skip_n_vectors = ntohl (skip);
10569 mp->match_n_vectors = ntohl (match);
10570 mp->next_table_index = ntohl (next_table_index);
10571 mp->miss_next_index = ntohl (miss_next_index);
10572 mp->current_data_flag = ntohl (current_data_flag);
10573 mp->current_data_offset = ntohl (current_data_offset);
10574 mp->mask_len = ntohl (vec_len (mask));
10575 clib_memcpy (mp->mask, mask, vec_len (mask));
10584 #if VPP_API_TEST_BUILTIN == 0
10586 unformat_l4_match (unformat_input_t * input, va_list * args)
10588 u8 **matchp = va_arg (*args, u8 **);
10590 u8 *proto_header = 0;
10596 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10598 if (unformat (input, "src_port %d", &src_port))
10600 else if (unformat (input, "dst_port %d", &dst_port))
10606 h.src_port = clib_host_to_net_u16 (src_port);
10607 h.dst_port = clib_host_to_net_u16 (dst_port);
10608 vec_validate (proto_header, sizeof (h) - 1);
10609 memcpy (proto_header, &h, sizeof (h));
10611 *matchp = proto_header;
10617 unformat_ip4_match (unformat_input_t * input, va_list * args)
10619 u8 **matchp = va_arg (*args, u8 **);
10624 int hdr_length = 0;
10625 u32 hdr_length_val;
10626 int src = 0, dst = 0;
10627 ip4_address_t src_val, dst_val;
10634 int fragment_id = 0;
10635 u32 fragment_id_val;
10641 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10643 if (unformat (input, "version %d", &version_val))
10645 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10647 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10649 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10651 else if (unformat (input, "proto %d", &proto_val))
10653 else if (unformat (input, "tos %d", &tos_val))
10655 else if (unformat (input, "length %d", &length_val))
10657 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10659 else if (unformat (input, "ttl %d", &ttl_val))
10661 else if (unformat (input, "checksum %d", &checksum_val))
10667 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10668 + ttl + checksum == 0)
10672 * Aligned because we use the real comparison functions
10674 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10676 ip = (ip4_header_t *) match;
10678 /* These are realistically matched in practice */
10680 ip->src_address.as_u32 = src_val.as_u32;
10683 ip->dst_address.as_u32 = dst_val.as_u32;
10686 ip->protocol = proto_val;
10689 /* These are not, but they're included for completeness */
10691 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10694 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10700 ip->length = clib_host_to_net_u16 (length_val);
10706 ip->checksum = clib_host_to_net_u16 (checksum_val);
10713 unformat_ip6_match (unformat_input_t * input, va_list * args)
10715 u8 **matchp = va_arg (*args, u8 **);
10720 u8 traffic_class = 0;
10721 u32 traffic_class_val = 0;
10724 int src = 0, dst = 0;
10725 ip6_address_t src_val, dst_val;
10728 int payload_length = 0;
10729 u32 payload_length_val;
10732 u32 ip_version_traffic_class_and_flow_label;
10734 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10736 if (unformat (input, "version %d", &version_val))
10738 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10740 else if (unformat (input, "flow_label %d", &flow_label_val))
10742 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10744 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10746 else if (unformat (input, "proto %d", &proto_val))
10748 else if (unformat (input, "payload_length %d", &payload_length_val))
10749 payload_length = 1;
10750 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10756 if (version + traffic_class + flow_label + src + dst + proto +
10757 payload_length + hop_limit == 0)
10761 * Aligned because we use the real comparison functions
10763 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10765 ip = (ip6_header_t *) match;
10768 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10771 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10774 ip->protocol = proto_val;
10776 ip_version_traffic_class_and_flow_label = 0;
10779 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10782 ip_version_traffic_class_and_flow_label |=
10783 (traffic_class_val & 0xFF) << 20;
10786 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10788 ip->ip_version_traffic_class_and_flow_label =
10789 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10791 if (payload_length)
10792 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10795 ip->hop_limit = hop_limit_val;
10802 unformat_l3_match (unformat_input_t * input, va_list * args)
10804 u8 **matchp = va_arg (*args, u8 **);
10806 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10808 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10810 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10819 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10821 u8 *tagp = va_arg (*args, u8 *);
10824 if (unformat (input, "%d", &tag))
10826 tagp[0] = (tag >> 8) & 0x0F;
10827 tagp[1] = tag & 0xFF;
10835 unformat_l2_match (unformat_input_t * input, va_list * args)
10837 u8 **matchp = va_arg (*args, u8 **);
10850 u8 ignore_tag1 = 0;
10851 u8 ignore_tag2 = 0;
10857 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10859 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10862 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10864 else if (unformat (input, "proto %U",
10865 unformat_ethernet_type_host_byte_order, &proto_val))
10867 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10869 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10871 else if (unformat (input, "ignore-tag1"))
10873 else if (unformat (input, "ignore-tag2"))
10875 else if (unformat (input, "cos1 %d", &cos1_val))
10877 else if (unformat (input, "cos2 %d", &cos2_val))
10882 if ((src + dst + proto + tag1 + tag2 +
10883 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10886 if (tag1 || ignore_tag1 || cos1)
10888 if (tag2 || ignore_tag2 || cos2)
10891 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10894 clib_memcpy (match, dst_val, 6);
10897 clib_memcpy (match + 6, src_val, 6);
10901 /* inner vlan tag */
10902 match[19] = tag2_val[1];
10903 match[18] = tag2_val[0];
10905 match[18] |= (cos2_val & 0x7) << 5;
10908 match[21] = proto_val & 0xff;
10909 match[20] = proto_val >> 8;
10913 match[15] = tag1_val[1];
10914 match[14] = tag1_val[0];
10917 match[14] |= (cos1_val & 0x7) << 5;
10923 match[15] = tag1_val[1];
10924 match[14] = tag1_val[0];
10927 match[17] = proto_val & 0xff;
10928 match[16] = proto_val >> 8;
10931 match[14] |= (cos1_val & 0x7) << 5;
10937 match[18] |= (cos2_val & 0x7) << 5;
10939 match[14] |= (cos1_val & 0x7) << 5;
10942 match[13] = proto_val & 0xff;
10943 match[12] = proto_val >> 8;
10951 unformat_qos_source (unformat_input_t * input, va_list * args)
10953 int *qs = va_arg (*args, int *);
10955 if (unformat (input, "ip"))
10956 *qs = QOS_SOURCE_IP;
10957 else if (unformat (input, "mpls"))
10958 *qs = QOS_SOURCE_MPLS;
10959 else if (unformat (input, "ext"))
10960 *qs = QOS_SOURCE_EXT;
10961 else if (unformat (input, "vlan"))
10962 *qs = QOS_SOURCE_VLAN;
10971 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10973 u8 **matchp = va_arg (*args, u8 **);
10974 u32 skip_n_vectors = va_arg (*args, u32);
10975 u32 match_n_vectors = va_arg (*args, u32);
10982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10984 if (unformat (input, "hex %U", unformat_hex_string, &match))
10986 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10988 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10990 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11004 if (match || l2 || l3 || l4)
11006 if (l2 || l3 || l4)
11008 /* "Win a free Ethernet header in every packet" */
11010 vec_validate_aligned (l2, 13, sizeof (u32x4));
11014 vec_append_aligned (match, l3, sizeof (u32x4));
11019 vec_append_aligned (match, l4, sizeof (u32x4));
11024 /* Make sure the vector is big enough even if key is all 0's */
11025 vec_validate_aligned
11026 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11029 /* Set size, include skipped vectors */
11030 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11041 api_classify_add_del_session (vat_main_t * vam)
11043 unformat_input_t *i = vam->input;
11044 vl_api_classify_add_del_session_t *mp;
11046 u32 table_index = ~0;
11047 u32 hit_next_index = ~0;
11048 u32 opaque_index = ~0;
11051 u32 skip_n_vectors = 0;
11052 u32 match_n_vectors = 0;
11058 * Warning: you have to supply skip_n and match_n
11059 * because the API client cant simply look at the classify
11063 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11065 if (unformat (i, "del"))
11067 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11070 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11073 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11076 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11078 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11080 else if (unformat (i, "opaque-index %d", &opaque_index))
11082 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11084 else if (unformat (i, "match_n %d", &match_n_vectors))
11086 else if (unformat (i, "match %U", api_unformat_classify_match,
11087 &match, skip_n_vectors, match_n_vectors))
11089 else if (unformat (i, "advance %d", &advance))
11091 else if (unformat (i, "table-index %d", &table_index))
11093 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11095 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11097 else if (unformat (i, "action %d", &action))
11099 else if (unformat (i, "metadata %d", &metadata))
11105 if (table_index == ~0)
11107 errmsg ("Table index required");
11111 if (is_add && match == 0)
11113 errmsg ("Match value required");
11117 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11119 mp->is_add = is_add;
11120 mp->table_index = ntohl (table_index);
11121 mp->hit_next_index = ntohl (hit_next_index);
11122 mp->opaque_index = ntohl (opaque_index);
11123 mp->advance = ntohl (advance);
11124 mp->action = action;
11125 mp->metadata = ntohl (metadata);
11126 mp->match_len = ntohl (vec_len (match));
11127 clib_memcpy (mp->match, match, vec_len (match));
11136 api_classify_set_interface_ip_table (vat_main_t * vam)
11138 unformat_input_t *i = vam->input;
11139 vl_api_classify_set_interface_ip_table_t *mp;
11141 int sw_if_index_set;
11142 u32 table_index = ~0;
11146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11148 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11149 sw_if_index_set = 1;
11150 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11151 sw_if_index_set = 1;
11152 else if (unformat (i, "table %d", &table_index))
11156 clib_warning ("parse error '%U'", format_unformat_error, i);
11161 if (sw_if_index_set == 0)
11163 errmsg ("missing interface name or sw_if_index");
11168 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11170 mp->sw_if_index = ntohl (sw_if_index);
11171 mp->table_index = ntohl (table_index);
11172 mp->is_ipv6 = is_ipv6;
11180 api_classify_set_interface_l2_tables (vat_main_t * vam)
11182 unformat_input_t *i = vam->input;
11183 vl_api_classify_set_interface_l2_tables_t *mp;
11185 int sw_if_index_set;
11186 u32 ip4_table_index = ~0;
11187 u32 ip6_table_index = ~0;
11188 u32 other_table_index = ~0;
11192 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11194 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11195 sw_if_index_set = 1;
11196 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11197 sw_if_index_set = 1;
11198 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11200 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11202 else if (unformat (i, "other-table %d", &other_table_index))
11204 else if (unformat (i, "is-input %d", &is_input))
11208 clib_warning ("parse error '%U'", format_unformat_error, i);
11213 if (sw_if_index_set == 0)
11215 errmsg ("missing interface name or sw_if_index");
11220 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11222 mp->sw_if_index = ntohl (sw_if_index);
11223 mp->ip4_table_index = ntohl (ip4_table_index);
11224 mp->ip6_table_index = ntohl (ip6_table_index);
11225 mp->other_table_index = ntohl (other_table_index);
11226 mp->is_input = (u8) is_input;
11234 api_set_ipfix_exporter (vat_main_t * vam)
11236 unformat_input_t *i = vam->input;
11237 vl_api_set_ipfix_exporter_t *mp;
11238 ip4_address_t collector_address;
11239 u8 collector_address_set = 0;
11240 u32 collector_port = ~0;
11241 ip4_address_t src_address;
11242 u8 src_address_set = 0;
11245 u32 template_interval = ~0;
11246 u8 udp_checksum = 0;
11249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11251 if (unformat (i, "collector_address %U", unformat_ip4_address,
11252 &collector_address))
11253 collector_address_set = 1;
11254 else if (unformat (i, "collector_port %d", &collector_port))
11256 else if (unformat (i, "src_address %U", unformat_ip4_address,
11258 src_address_set = 1;
11259 else if (unformat (i, "vrf_id %d", &vrf_id))
11261 else if (unformat (i, "path_mtu %d", &path_mtu))
11263 else if (unformat (i, "template_interval %d", &template_interval))
11265 else if (unformat (i, "udp_checksum"))
11271 if (collector_address_set == 0)
11273 errmsg ("collector_address required");
11277 if (src_address_set == 0)
11279 errmsg ("src_address required");
11283 M (SET_IPFIX_EXPORTER, mp);
11285 memcpy (mp->collector_address.un.ip4, collector_address.data,
11286 sizeof (collector_address.data));
11287 mp->collector_port = htons ((u16) collector_port);
11288 memcpy (mp->src_address.un.ip4, src_address.data,
11289 sizeof (src_address.data));
11290 mp->vrf_id = htonl (vrf_id);
11291 mp->path_mtu = htonl (path_mtu);
11292 mp->template_interval = htonl (template_interval);
11293 mp->udp_checksum = udp_checksum;
11301 api_set_ipfix_classify_stream (vat_main_t * vam)
11303 unformat_input_t *i = vam->input;
11304 vl_api_set_ipfix_classify_stream_t *mp;
11306 u32 src_port = UDP_DST_PORT_ipfix;
11309 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11311 if (unformat (i, "domain %d", &domain_id))
11313 else if (unformat (i, "src_port %d", &src_port))
11317 errmsg ("unknown input `%U'", format_unformat_error, i);
11322 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11324 mp->domain_id = htonl (domain_id);
11325 mp->src_port = htons ((u16) src_port);
11333 api_ipfix_classify_table_add_del (vat_main_t * vam)
11335 unformat_input_t *i = vam->input;
11336 vl_api_ipfix_classify_table_add_del_t *mp;
11338 u32 classify_table_index = ~0;
11340 u8 transport_protocol = 255;
11343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11345 if (unformat (i, "add"))
11347 else if (unformat (i, "del"))
11349 else if (unformat (i, "table %d", &classify_table_index))
11351 else if (unformat (i, "ip4"))
11353 else if (unformat (i, "ip6"))
11355 else if (unformat (i, "tcp"))
11356 transport_protocol = 6;
11357 else if (unformat (i, "udp"))
11358 transport_protocol = 17;
11361 errmsg ("unknown input `%U'", format_unformat_error, i);
11368 errmsg ("expecting: add|del");
11371 if (classify_table_index == ~0)
11373 errmsg ("classifier table not specified");
11376 if (ip_version == 0)
11378 errmsg ("IP version not specified");
11382 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11384 mp->is_add = is_add;
11385 mp->table_id = htonl (classify_table_index);
11386 mp->ip_version = ip_version;
11387 mp->transport_protocol = transport_protocol;
11395 api_get_node_index (vat_main_t * vam)
11397 unformat_input_t *i = vam->input;
11398 vl_api_get_node_index_t *mp;
11402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11404 if (unformat (i, "node %s", &name))
11411 errmsg ("node name required");
11414 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11416 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11420 M (GET_NODE_INDEX, mp);
11421 clib_memcpy (mp->node_name, name, vec_len (name));
11430 api_get_next_index (vat_main_t * vam)
11432 unformat_input_t *i = vam->input;
11433 vl_api_get_next_index_t *mp;
11434 u8 *node_name = 0, *next_node_name = 0;
11437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11439 if (unformat (i, "node-name %s", &node_name))
11441 else if (unformat (i, "next-node-name %s", &next_node_name))
11445 if (node_name == 0)
11447 errmsg ("node name required");
11450 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11452 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11456 if (next_node_name == 0)
11458 errmsg ("next node name required");
11461 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11463 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11467 M (GET_NEXT_INDEX, mp);
11468 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11469 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11470 vec_free (node_name);
11471 vec_free (next_node_name);
11479 api_add_node_next (vat_main_t * vam)
11481 unformat_input_t *i = vam->input;
11482 vl_api_add_node_next_t *mp;
11487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11489 if (unformat (i, "node %s", &name))
11491 else if (unformat (i, "next %s", &next))
11498 errmsg ("node name required");
11501 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11503 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11508 errmsg ("next node required");
11511 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11513 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11517 M (ADD_NODE_NEXT, mp);
11518 clib_memcpy (mp->node_name, name, vec_len (name));
11519 clib_memcpy (mp->next_name, next, vec_len (next));
11529 api_l2tpv3_create_tunnel (vat_main_t * vam)
11531 unformat_input_t *i = vam->input;
11532 ip6_address_t client_address, our_address;
11533 int client_address_set = 0;
11534 int our_address_set = 0;
11535 u32 local_session_id = 0;
11536 u32 remote_session_id = 0;
11537 u64 local_cookie = 0;
11538 u64 remote_cookie = 0;
11539 u8 l2_sublayer_present = 0;
11540 vl_api_l2tpv3_create_tunnel_t *mp;
11543 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11545 if (unformat (i, "client_address %U", unformat_ip6_address,
11547 client_address_set = 1;
11548 else if (unformat (i, "our_address %U", unformat_ip6_address,
11550 our_address_set = 1;
11551 else if (unformat (i, "local_session_id %d", &local_session_id))
11553 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11555 else if (unformat (i, "local_cookie %lld", &local_cookie))
11557 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11559 else if (unformat (i, "l2-sublayer-present"))
11560 l2_sublayer_present = 1;
11565 if (client_address_set == 0)
11567 errmsg ("client_address required");
11571 if (our_address_set == 0)
11573 errmsg ("our_address required");
11577 M (L2TPV3_CREATE_TUNNEL, mp);
11579 clib_memcpy (mp->client_address.un.ip6, client_address.as_u8,
11580 sizeof (ip6_address_t));
11582 clib_memcpy (mp->our_address.un.ip6, our_address.as_u8,
11583 sizeof (ip6_address_t));
11585 mp->local_session_id = ntohl (local_session_id);
11586 mp->remote_session_id = ntohl (remote_session_id);
11587 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11588 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11589 mp->l2_sublayer_present = l2_sublayer_present;
11597 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11599 unformat_input_t *i = vam->input;
11601 u8 sw_if_index_set = 0;
11602 u64 new_local_cookie = 0;
11603 u64 new_remote_cookie = 0;
11604 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11607 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11609 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11610 sw_if_index_set = 1;
11611 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11612 sw_if_index_set = 1;
11613 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11615 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11621 if (sw_if_index_set == 0)
11623 errmsg ("missing interface name or sw_if_index");
11627 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11629 mp->sw_if_index = ntohl (sw_if_index);
11630 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11631 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11639 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11641 unformat_input_t *i = vam->input;
11642 vl_api_l2tpv3_interface_enable_disable_t *mp;
11644 u8 sw_if_index_set = 0;
11645 u8 enable_disable = 1;
11648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11650 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11651 sw_if_index_set = 1;
11652 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11653 sw_if_index_set = 1;
11654 else if (unformat (i, "enable"))
11655 enable_disable = 1;
11656 else if (unformat (i, "disable"))
11657 enable_disable = 0;
11662 if (sw_if_index_set == 0)
11664 errmsg ("missing interface name or sw_if_index");
11668 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11670 mp->sw_if_index = ntohl (sw_if_index);
11671 mp->enable_disable = enable_disable;
11679 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11681 unformat_input_t *i = vam->input;
11682 vl_api_l2tpv3_set_lookup_key_t *mp;
11686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11688 if (unformat (i, "lookup_v6_src"))
11689 key = L2T_LOOKUP_SRC_ADDRESS;
11690 else if (unformat (i, "lookup_v6_dst"))
11691 key = L2T_LOOKUP_DST_ADDRESS;
11692 else if (unformat (i, "lookup_session_id"))
11693 key = L2T_LOOKUP_SESSION_ID;
11698 if (key == (u8) ~ 0)
11700 errmsg ("l2tp session lookup key unset");
11704 M (L2TPV3_SET_LOOKUP_KEY, mp);
11713 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11714 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11716 vat_main_t *vam = &vat_main;
11718 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11719 format_ip6_address, mp->our_address,
11720 format_ip6_address, mp->client_address,
11721 clib_net_to_host_u32 (mp->sw_if_index));
11724 " local cookies %016llx %016llx remote cookie %016llx",
11725 clib_net_to_host_u64 (mp->local_cookie[0]),
11726 clib_net_to_host_u64 (mp->local_cookie[1]),
11727 clib_net_to_host_u64 (mp->remote_cookie));
11729 print (vam->ofp, " local session-id %d remote session-id %d",
11730 clib_net_to_host_u32 (mp->local_session_id),
11731 clib_net_to_host_u32 (mp->remote_session_id));
11733 print (vam->ofp, " l2 specific sublayer %s\n",
11734 mp->l2_sublayer_present ? "preset" : "absent");
11738 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11739 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11741 vat_main_t *vam = &vat_main;
11742 vat_json_node_t *node = NULL;
11743 struct in6_addr addr;
11745 if (VAT_JSON_ARRAY != vam->json_tree.type)
11747 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11748 vat_json_init_array (&vam->json_tree);
11750 node = vat_json_array_add (&vam->json_tree);
11752 vat_json_init_object (node);
11754 clib_memcpy (&addr, mp->our_address.un.ip6, sizeof (addr));
11755 vat_json_object_add_ip6 (node, "our_address", addr);
11756 clib_memcpy (&addr, mp->client_address.un.ip6, sizeof (addr));
11757 vat_json_object_add_ip6 (node, "client_address", addr);
11759 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11760 vat_json_init_array (lc);
11761 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11762 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11763 vat_json_object_add_uint (node, "remote_cookie",
11764 clib_net_to_host_u64 (mp->remote_cookie));
11766 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11767 vat_json_object_add_uint (node, "local_session_id",
11768 clib_net_to_host_u32 (mp->local_session_id));
11769 vat_json_object_add_uint (node, "remote_session_id",
11770 clib_net_to_host_u32 (mp->remote_session_id));
11771 vat_json_object_add_string_copy (node, "l2_sublayer",
11772 mp->l2_sublayer_present ? (u8 *) "present"
11773 : (u8 *) "absent");
11777 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11779 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11780 vl_api_control_ping_t *mp_ping;
11783 /* Get list of l2tpv3-tunnel interfaces */
11784 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11787 /* Use a control ping for synchronization */
11788 MPING (CONTROL_PING, mp_ping);
11796 static void vl_api_sw_interface_tap_v2_details_t_handler
11797 (vl_api_sw_interface_tap_v2_details_t * mp)
11799 vat_main_t *vam = &vat_main;
11801 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
11802 mp->host_ip4_prefix_len);
11803 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
11804 mp->host_ip6_prefix_len);
11807 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
11808 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
11809 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11810 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
11811 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
11817 static void vl_api_sw_interface_tap_v2_details_t_handler_json
11818 (vl_api_sw_interface_tap_v2_details_t * mp)
11820 vat_main_t *vam = &vat_main;
11821 vat_json_node_t *node = NULL;
11823 if (VAT_JSON_ARRAY != vam->json_tree.type)
11825 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11826 vat_json_init_array (&vam->json_tree);
11828 node = vat_json_array_add (&vam->json_tree);
11830 vat_json_init_object (node);
11831 vat_json_object_add_uint (node, "id", ntohl (mp->id));
11832 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11833 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
11834 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11835 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11836 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11837 vat_json_object_add_string_copy (node, "host_mac_addr",
11838 format (0, "%U", format_ethernet_address,
11839 &mp->host_mac_addr));
11840 vat_json_object_add_string_copy (node, "host_namespace",
11841 mp->host_namespace);
11842 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
11843 vat_json_object_add_string_copy (node, "host_ip4_addr",
11844 format (0, "%U/%d", format_ip4_address,
11846 mp->host_ip4_prefix_len));
11847 vat_json_object_add_string_copy (node, "host_ip6_addr",
11848 format (0, "%U/%d", format_ip6_address,
11850 mp->host_ip6_prefix_len));
11855 api_sw_interface_tap_v2_dump (vat_main_t * vam)
11857 vl_api_sw_interface_tap_v2_dump_t *mp;
11858 vl_api_control_ping_t *mp_ping;
11862 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
11863 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
11864 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
11867 /* Get list of tap interfaces */
11868 M (SW_INTERFACE_TAP_V2_DUMP, mp);
11871 /* Use a control ping for synchronization */
11872 MPING (CONTROL_PING, mp_ping);
11879 static void vl_api_sw_interface_virtio_pci_details_t_handler
11880 (vl_api_sw_interface_virtio_pci_details_t * mp)
11882 vat_main_t *vam = &vat_main;
11896 addr.as_u32 = ntohl (mp->pci_addr);
11897 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
11898 addr.slot, addr.function);
11901 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
11902 pci_addr, ntohl (mp->sw_if_index),
11903 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11904 format_ethernet_address, mp->mac_addr,
11905 clib_net_to_host_u64 (mp->features));
11906 vec_free (pci_addr);
11909 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
11910 (vl_api_sw_interface_virtio_pci_details_t * mp)
11912 vat_main_t *vam = &vat_main;
11913 vat_json_node_t *node = NULL;
11915 if (VAT_JSON_ARRAY != vam->json_tree.type)
11917 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11918 vat_json_init_array (&vam->json_tree);
11920 node = vat_json_array_add (&vam->json_tree);
11922 vat_json_init_object (node);
11923 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
11924 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11925 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11926 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11927 vat_json_object_add_uint (node, "features",
11928 clib_net_to_host_u64 (mp->features));
11929 vat_json_object_add_string_copy (node, "mac_addr",
11930 format (0, "%U", format_ethernet_address,
11935 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
11937 vl_api_sw_interface_virtio_pci_dump_t *mp;
11938 vl_api_control_ping_t *mp_ping;
11942 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
11943 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
11944 "mac_addr", "features");
11946 /* Get list of tap interfaces */
11947 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
11950 /* Use a control ping for synchronization */
11951 MPING (CONTROL_PING, mp_ping);
11959 api_vxlan_offload_rx (vat_main_t * vam)
11961 unformat_input_t *line_input = vam->input;
11962 vl_api_vxlan_offload_rx_t *mp;
11963 u32 hw_if_index = ~0, rx_if_index = ~0;
11967 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11969 if (unformat (line_input, "del"))
11971 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
11974 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
11976 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
11979 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
11983 errmsg ("parse error '%U'", format_unformat_error, line_input);
11988 if (hw_if_index == ~0)
11990 errmsg ("no hw interface");
11994 if (rx_if_index == ~0)
11996 errmsg ("no rx tunnel");
12000 M (VXLAN_OFFLOAD_RX, mp);
12002 mp->hw_if_index = ntohl (hw_if_index);
12003 mp->sw_if_index = ntohl (rx_if_index);
12004 mp->enable = is_add;
12011 static uword unformat_vxlan_decap_next
12012 (unformat_input_t * input, va_list * args)
12014 u32 *result = va_arg (*args, u32 *);
12017 if (unformat (input, "l2"))
12018 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12019 else if (unformat (input, "%d", &tmp))
12027 api_vxlan_add_del_tunnel (vat_main_t * vam)
12029 unformat_input_t *line_input = vam->input;
12030 vl_api_vxlan_add_del_tunnel_t *mp;
12031 ip46_address_t src, dst;
12033 u8 ipv4_set = 0, ipv6_set = 0;
12038 u32 mcast_sw_if_index = ~0;
12039 u32 encap_vrf_id = 0;
12040 u32 decap_next_index = ~0;
12044 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12045 clib_memset (&src, 0, sizeof src);
12046 clib_memset (&dst, 0, sizeof dst);
12048 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12050 if (unformat (line_input, "del"))
12052 else if (unformat (line_input, "instance %d", &instance))
12055 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12061 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12067 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12073 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12078 else if (unformat (line_input, "group %U %U",
12079 unformat_ip4_address, &dst.ip4,
12080 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12082 grp_set = dst_set = 1;
12085 else if (unformat (line_input, "group %U",
12086 unformat_ip4_address, &dst.ip4))
12088 grp_set = dst_set = 1;
12091 else if (unformat (line_input, "group %U %U",
12092 unformat_ip6_address, &dst.ip6,
12093 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12095 grp_set = dst_set = 1;
12098 else if (unformat (line_input, "group %U",
12099 unformat_ip6_address, &dst.ip6))
12101 grp_set = dst_set = 1;
12105 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12107 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12109 else if (unformat (line_input, "decap-next %U",
12110 unformat_vxlan_decap_next, &decap_next_index))
12112 else if (unformat (line_input, "vni %d", &vni))
12116 errmsg ("parse error '%U'", format_unformat_error, line_input);
12123 errmsg ("tunnel src address not specified");
12128 errmsg ("tunnel dst address not specified");
12132 if (grp_set && !ip46_address_is_multicast (&dst))
12134 errmsg ("tunnel group address not multicast");
12137 if (grp_set && mcast_sw_if_index == ~0)
12139 errmsg ("tunnel nonexistent multicast device");
12142 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12144 errmsg ("tunnel dst address must be unicast");
12149 if (ipv4_set && ipv6_set)
12151 errmsg ("both IPv4 and IPv6 addresses specified");
12155 if ((vni == 0) || (vni >> 24))
12157 errmsg ("vni not specified or out of range");
12161 M (VXLAN_ADD_DEL_TUNNEL, mp);
12165 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12166 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12170 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12171 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12174 mp->instance = htonl (instance);
12175 mp->encap_vrf_id = ntohl (encap_vrf_id);
12176 mp->decap_next_index = ntohl (decap_next_index);
12177 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12178 mp->vni = ntohl (vni);
12179 mp->is_add = is_add;
12180 mp->is_ipv6 = ipv6_set;
12187 static void vl_api_vxlan_tunnel_details_t_handler
12188 (vl_api_vxlan_tunnel_details_t * mp)
12190 vat_main_t *vam = &vat_main;
12191 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12192 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12194 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12195 ntohl (mp->sw_if_index),
12196 ntohl (mp->instance),
12197 format_ip46_address, &src, IP46_TYPE_ANY,
12198 format_ip46_address, &dst, IP46_TYPE_ANY,
12199 ntohl (mp->encap_vrf_id),
12200 ntohl (mp->decap_next_index), ntohl (mp->vni),
12201 ntohl (mp->mcast_sw_if_index));
12204 static void vl_api_vxlan_tunnel_details_t_handler_json
12205 (vl_api_vxlan_tunnel_details_t * mp)
12207 vat_main_t *vam = &vat_main;
12208 vat_json_node_t *node = NULL;
12210 if (VAT_JSON_ARRAY != vam->json_tree.type)
12212 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12213 vat_json_init_array (&vam->json_tree);
12215 node = vat_json_array_add (&vam->json_tree);
12217 vat_json_init_object (node);
12218 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12220 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12224 struct in6_addr ip6;
12226 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12227 vat_json_object_add_ip6 (node, "src_address", ip6);
12228 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12229 vat_json_object_add_ip6 (node, "dst_address", ip6);
12233 struct in_addr ip4;
12235 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12236 vat_json_object_add_ip4 (node, "src_address", ip4);
12237 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12238 vat_json_object_add_ip4 (node, "dst_address", ip4);
12240 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12241 vat_json_object_add_uint (node, "decap_next_index",
12242 ntohl (mp->decap_next_index));
12243 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12244 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12245 vat_json_object_add_uint (node, "mcast_sw_if_index",
12246 ntohl (mp->mcast_sw_if_index));
12250 api_vxlan_tunnel_dump (vat_main_t * vam)
12252 unformat_input_t *i = vam->input;
12253 vl_api_vxlan_tunnel_dump_t *mp;
12254 vl_api_control_ping_t *mp_ping;
12256 u8 sw_if_index_set = 0;
12259 /* Parse args required to build the message */
12260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12262 if (unformat (i, "sw_if_index %d", &sw_if_index))
12263 sw_if_index_set = 1;
12268 if (sw_if_index_set == 0)
12273 if (!vam->json_output)
12275 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12276 "sw_if_index", "instance", "src_address", "dst_address",
12277 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12280 /* Get list of vxlan-tunnel interfaces */
12281 M (VXLAN_TUNNEL_DUMP, mp);
12283 mp->sw_if_index = htonl (sw_if_index);
12287 /* Use a control ping for synchronization */
12288 MPING (CONTROL_PING, mp_ping);
12295 static uword unformat_geneve_decap_next
12296 (unformat_input_t * input, va_list * args)
12298 u32 *result = va_arg (*args, u32 *);
12301 if (unformat (input, "l2"))
12302 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12303 else if (unformat (input, "%d", &tmp))
12311 api_geneve_add_del_tunnel (vat_main_t * vam)
12313 unformat_input_t *line_input = vam->input;
12314 vl_api_geneve_add_del_tunnel_t *mp;
12315 ip46_address_t src, dst;
12317 u8 ipv4_set = 0, ipv6_set = 0;
12321 u32 mcast_sw_if_index = ~0;
12322 u32 encap_vrf_id = 0;
12323 u32 decap_next_index = ~0;
12327 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12328 clib_memset (&src, 0, sizeof src);
12329 clib_memset (&dst, 0, sizeof dst);
12331 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12333 if (unformat (line_input, "del"))
12336 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12342 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12348 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12354 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12359 else if (unformat (line_input, "group %U %U",
12360 unformat_ip4_address, &dst.ip4,
12361 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12363 grp_set = dst_set = 1;
12366 else if (unformat (line_input, "group %U",
12367 unformat_ip4_address, &dst.ip4))
12369 grp_set = dst_set = 1;
12372 else if (unformat (line_input, "group %U %U",
12373 unformat_ip6_address, &dst.ip6,
12374 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12376 grp_set = dst_set = 1;
12379 else if (unformat (line_input, "group %U",
12380 unformat_ip6_address, &dst.ip6))
12382 grp_set = dst_set = 1;
12386 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12388 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12390 else if (unformat (line_input, "decap-next %U",
12391 unformat_geneve_decap_next, &decap_next_index))
12393 else if (unformat (line_input, "vni %d", &vni))
12397 errmsg ("parse error '%U'", format_unformat_error, line_input);
12404 errmsg ("tunnel src address not specified");
12409 errmsg ("tunnel dst address not specified");
12413 if (grp_set && !ip46_address_is_multicast (&dst))
12415 errmsg ("tunnel group address not multicast");
12418 if (grp_set && mcast_sw_if_index == ~0)
12420 errmsg ("tunnel nonexistent multicast device");
12423 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12425 errmsg ("tunnel dst address must be unicast");
12430 if (ipv4_set && ipv6_set)
12432 errmsg ("both IPv4 and IPv6 addresses specified");
12436 if ((vni == 0) || (vni >> 24))
12438 errmsg ("vni not specified or out of range");
12442 M (GENEVE_ADD_DEL_TUNNEL, mp);
12446 clib_memcpy (&mp->local_address.un.ip6, &src.ip6, sizeof (src.ip6));
12447 clib_memcpy (&mp->remote_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
12451 clib_memcpy (&mp->local_address.un.ip4, &src.ip4, sizeof (src.ip4));
12452 clib_memcpy (&mp->remote_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
12454 mp->encap_vrf_id = ntohl (encap_vrf_id);
12455 mp->decap_next_index = ntohl (decap_next_index);
12456 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12457 mp->vni = ntohl (vni);
12458 mp->is_add = is_add;
12465 static void vl_api_geneve_tunnel_details_t_handler
12466 (vl_api_geneve_tunnel_details_t * mp)
12468 vat_main_t *vam = &vat_main;
12469 ip46_address_t src = {.as_u64[0] = 0,.as_u64[1] = 0 };
12470 ip46_address_t dst = {.as_u64[0] = 0,.as_u64[1] = 0 };
12472 if (mp->src_address.af == ADDRESS_IP6)
12474 clib_memcpy (&src.ip6, &mp->src_address.un.ip6, sizeof (ip6_address_t));
12475 clib_memcpy (&dst.ip6, &mp->dst_address.un.ip6, sizeof (ip6_address_t));
12479 clib_memcpy (&src.ip4, &mp->src_address.un.ip4, sizeof (ip4_address_t));
12480 clib_memcpy (&dst.ip4, &mp->dst_address.un.ip4, sizeof (ip4_address_t));
12483 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12484 ntohl (mp->sw_if_index),
12485 format_ip46_address, &src, IP46_TYPE_ANY,
12486 format_ip46_address, &dst, IP46_TYPE_ANY,
12487 ntohl (mp->encap_vrf_id),
12488 ntohl (mp->decap_next_index), ntohl (mp->vni),
12489 ntohl (mp->mcast_sw_if_index));
12492 static void vl_api_geneve_tunnel_details_t_handler_json
12493 (vl_api_geneve_tunnel_details_t * mp)
12495 vat_main_t *vam = &vat_main;
12496 vat_json_node_t *node = NULL;
12499 if (VAT_JSON_ARRAY != vam->json_tree.type)
12501 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12502 vat_json_init_array (&vam->json_tree);
12504 node = vat_json_array_add (&vam->json_tree);
12506 vat_json_init_object (node);
12507 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12508 is_ipv6 = mp->src_address.af == ADDRESS_IP6;
12511 struct in6_addr ip6;
12513 clib_memcpy (&ip6, &mp->src_address.un.ip6, sizeof (ip6));
12514 vat_json_object_add_ip6 (node, "src_address", ip6);
12515 clib_memcpy (&ip6, &mp->dst_address.un.ip6, sizeof (ip6));
12516 vat_json_object_add_ip6 (node, "dst_address", ip6);
12520 struct in_addr ip4;
12522 clib_memcpy (&ip4, &mp->src_address.un.ip4, sizeof (ip4));
12523 vat_json_object_add_ip4 (node, "src_address", ip4);
12524 clib_memcpy (&ip4, &mp->dst_address.un.ip4, sizeof (ip4));
12525 vat_json_object_add_ip4 (node, "dst_address", ip4);
12527 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12528 vat_json_object_add_uint (node, "decap_next_index",
12529 ntohl (mp->decap_next_index));
12530 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12531 vat_json_object_add_uint (node, "mcast_sw_if_index",
12532 ntohl (mp->mcast_sw_if_index));
12536 api_geneve_tunnel_dump (vat_main_t * vam)
12538 unformat_input_t *i = vam->input;
12539 vl_api_geneve_tunnel_dump_t *mp;
12540 vl_api_control_ping_t *mp_ping;
12542 u8 sw_if_index_set = 0;
12545 /* Parse args required to build the message */
12546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12548 if (unformat (i, "sw_if_index %d", &sw_if_index))
12549 sw_if_index_set = 1;
12554 if (sw_if_index_set == 0)
12559 if (!vam->json_output)
12561 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12562 "sw_if_index", "local_address", "remote_address",
12563 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12566 /* Get list of geneve-tunnel interfaces */
12567 M (GENEVE_TUNNEL_DUMP, mp);
12569 mp->sw_if_index = htonl (sw_if_index);
12573 /* Use a control ping for synchronization */
12574 M (CONTROL_PING, mp_ping);
12582 api_gre_tunnel_add_del (vat_main_t * vam)
12584 unformat_input_t *line_input = vam->input;
12585 vl_api_address_t src = { }, dst =
12588 vl_api_gre_tunnel_add_del_t *mp;
12589 vl_api_gre_tunnel_type_t t_type;
12593 u32 outer_fib_id = 0;
12594 u32 session_id = 0;
12598 t_type = GRE_API_TUNNEL_TYPE_L3;
12600 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12602 if (unformat (line_input, "del"))
12604 else if (unformat (line_input, "instance %d", &instance))
12606 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
12610 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
12614 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12616 else if (unformat (line_input, "teb"))
12617 t_type = GRE_API_TUNNEL_TYPE_TEB;
12618 else if (unformat (line_input, "erspan %d", &session_id))
12619 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
12622 errmsg ("parse error '%U'", format_unformat_error, line_input);
12629 errmsg ("tunnel src address not specified");
12634 errmsg ("tunnel dst address not specified");
12638 M (GRE_TUNNEL_ADD_DEL, mp);
12640 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
12641 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
12643 mp->tunnel.instance = htonl (instance);
12644 mp->tunnel.outer_fib_id = htonl (outer_fib_id);
12645 mp->is_add = is_add;
12646 mp->tunnel.session_id = htons ((u16) session_id);
12647 mp->tunnel.type = htonl (t_type);
12654 static void vl_api_gre_tunnel_details_t_handler
12655 (vl_api_gre_tunnel_details_t * mp)
12657 vat_main_t *vam = &vat_main;
12659 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
12660 ntohl (mp->tunnel.sw_if_index),
12661 ntohl (mp->tunnel.instance),
12662 format_vl_api_address, &mp->tunnel.src,
12663 format_vl_api_address, &mp->tunnel.dst,
12664 mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
12665 ntohl (mp->tunnel.session_id));
12668 static void vl_api_gre_tunnel_details_t_handler_json
12669 (vl_api_gre_tunnel_details_t * mp)
12671 vat_main_t *vam = &vat_main;
12672 vat_json_node_t *node = NULL;
12674 if (VAT_JSON_ARRAY != vam->json_tree.type)
12676 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12677 vat_json_init_array (&vam->json_tree);
12679 node = vat_json_array_add (&vam->json_tree);
12681 vat_json_init_object (node);
12682 vat_json_object_add_uint (node, "sw_if_index",
12683 ntohl (mp->tunnel.sw_if_index));
12684 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
12686 vat_json_object_add_address (node, "src", &mp->tunnel.src);
12687 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
12688 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
12689 vat_json_object_add_uint (node, "outer_fib_id",
12690 ntohl (mp->tunnel.outer_fib_id));
12691 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
12695 api_gre_tunnel_dump (vat_main_t * vam)
12697 unformat_input_t *i = vam->input;
12698 vl_api_gre_tunnel_dump_t *mp;
12699 vl_api_control_ping_t *mp_ping;
12701 u8 sw_if_index_set = 0;
12704 /* Parse args required to build the message */
12705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12707 if (unformat (i, "sw_if_index %d", &sw_if_index))
12708 sw_if_index_set = 1;
12713 if (sw_if_index_set == 0)
12718 if (!vam->json_output)
12720 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
12721 "sw_if_index", "instance", "src_address", "dst_address",
12722 "tunnel_type", "outer_fib_id", "session_id");
12725 /* Get list of gre-tunnel interfaces */
12726 M (GRE_TUNNEL_DUMP, mp);
12728 mp->sw_if_index = htonl (sw_if_index);
12732 /* Use a control ping for synchronization */
12733 MPING (CONTROL_PING, mp_ping);
12741 api_l2_fib_clear_table (vat_main_t * vam)
12743 // unformat_input_t * i = vam->input;
12744 vl_api_l2_fib_clear_table_t *mp;
12747 M (L2_FIB_CLEAR_TABLE, mp);
12755 api_l2_interface_efp_filter (vat_main_t * vam)
12757 unformat_input_t *i = vam->input;
12758 vl_api_l2_interface_efp_filter_t *mp;
12761 u8 sw_if_index_set = 0;
12764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12766 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12767 sw_if_index_set = 1;
12768 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12769 sw_if_index_set = 1;
12770 else if (unformat (i, "enable"))
12772 else if (unformat (i, "disable"))
12776 clib_warning ("parse error '%U'", format_unformat_error, i);
12781 if (sw_if_index_set == 0)
12783 errmsg ("missing sw_if_index");
12787 M (L2_INTERFACE_EFP_FILTER, mp);
12789 mp->sw_if_index = ntohl (sw_if_index);
12790 mp->enable_disable = enable;
12797 #define foreach_vtr_op \
12798 _("disable", L2_VTR_DISABLED) \
12799 _("push-1", L2_VTR_PUSH_1) \
12800 _("push-2", L2_VTR_PUSH_2) \
12801 _("pop-1", L2_VTR_POP_1) \
12802 _("pop-2", L2_VTR_POP_2) \
12803 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12804 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12805 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12806 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12809 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12811 unformat_input_t *i = vam->input;
12812 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12814 u8 sw_if_index_set = 0;
12817 u32 push_dot1q = 1;
12822 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12824 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12825 sw_if_index_set = 1;
12826 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12827 sw_if_index_set = 1;
12828 else if (unformat (i, "vtr_op %d", &vtr_op))
12830 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12833 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12835 else if (unformat (i, "tag1 %d", &tag1))
12837 else if (unformat (i, "tag2 %d", &tag2))
12841 clib_warning ("parse error '%U'", format_unformat_error, i);
12846 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12848 errmsg ("missing vtr operation or sw_if_index");
12852 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12853 mp->sw_if_index = ntohl (sw_if_index);
12854 mp->vtr_op = ntohl (vtr_op);
12855 mp->push_dot1q = ntohl (push_dot1q);
12856 mp->tag1 = ntohl (tag1);
12857 mp->tag2 = ntohl (tag2);
12865 api_create_vhost_user_if (vat_main_t * vam)
12867 unformat_input_t *i = vam->input;
12868 vl_api_create_vhost_user_if_t *mp;
12871 u8 file_name_set = 0;
12872 u32 custom_dev_instance = ~0;
12874 u8 use_custom_mac = 0;
12875 u8 disable_mrg_rxbuf = 0;
12876 u8 disable_indirect_desc = 0;
12881 /* Shut up coverity */
12882 clib_memset (hwaddr, 0, sizeof (hwaddr));
12884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12886 if (unformat (i, "socket %s", &file_name))
12890 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12892 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12893 use_custom_mac = 1;
12894 else if (unformat (i, "server"))
12896 else if (unformat (i, "disable_mrg_rxbuf"))
12897 disable_mrg_rxbuf = 1;
12898 else if (unformat (i, "disable_indirect_desc"))
12899 disable_indirect_desc = 1;
12900 else if (unformat (i, "gso"))
12902 else if (unformat (i, "tag %s", &tag))
12908 if (file_name_set == 0)
12910 errmsg ("missing socket file name");
12914 if (vec_len (file_name) > 255)
12916 errmsg ("socket file name too long");
12919 vec_add1 (file_name, 0);
12921 M (CREATE_VHOST_USER_IF, mp);
12923 mp->is_server = is_server;
12924 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
12925 mp->disable_indirect_desc = disable_indirect_desc;
12926 mp->enable_gso = enable_gso;
12927 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12928 vec_free (file_name);
12929 if (custom_dev_instance != ~0)
12932 mp->custom_dev_instance = ntohl (custom_dev_instance);
12935 mp->use_custom_mac = use_custom_mac;
12936 clib_memcpy (mp->mac_address, hwaddr, 6);
12938 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12947 api_modify_vhost_user_if (vat_main_t * vam)
12949 unformat_input_t *i = vam->input;
12950 vl_api_modify_vhost_user_if_t *mp;
12953 u8 file_name_set = 0;
12954 u32 custom_dev_instance = ~0;
12955 u8 sw_if_index_set = 0;
12956 u32 sw_if_index = (u32) ~ 0;
12960 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12962 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12963 sw_if_index_set = 1;
12964 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12965 sw_if_index_set = 1;
12966 else if (unformat (i, "socket %s", &file_name))
12970 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12972 else if (unformat (i, "server"))
12974 else if (unformat (i, "gso"))
12980 if (sw_if_index_set == 0)
12982 errmsg ("missing sw_if_index or interface name");
12986 if (file_name_set == 0)
12988 errmsg ("missing socket file name");
12992 if (vec_len (file_name) > 255)
12994 errmsg ("socket file name too long");
12997 vec_add1 (file_name, 0);
12999 M (MODIFY_VHOST_USER_IF, mp);
13001 mp->sw_if_index = ntohl (sw_if_index);
13002 mp->is_server = is_server;
13003 mp->enable_gso = enable_gso;
13004 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13005 vec_free (file_name);
13006 if (custom_dev_instance != ~0)
13009 mp->custom_dev_instance = ntohl (custom_dev_instance);
13018 api_delete_vhost_user_if (vat_main_t * vam)
13020 unformat_input_t *i = vam->input;
13021 vl_api_delete_vhost_user_if_t *mp;
13022 u32 sw_if_index = ~0;
13023 u8 sw_if_index_set = 0;
13026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13028 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13029 sw_if_index_set = 1;
13030 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13031 sw_if_index_set = 1;
13036 if (sw_if_index_set == 0)
13038 errmsg ("missing sw_if_index or interface name");
13043 M (DELETE_VHOST_USER_IF, mp);
13045 mp->sw_if_index = ntohl (sw_if_index);
13052 static void vl_api_sw_interface_vhost_user_details_t_handler
13053 (vl_api_sw_interface_vhost_user_details_t * mp)
13055 vat_main_t *vam = &vat_main;
13057 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13058 (char *) mp->interface_name,
13059 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13060 clib_net_to_host_u64 (mp->features), mp->is_server,
13061 ntohl (mp->num_regions), (char *) mp->sock_filename);
13062 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13065 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13066 (vl_api_sw_interface_vhost_user_details_t * mp)
13068 vat_main_t *vam = &vat_main;
13069 vat_json_node_t *node = NULL;
13071 if (VAT_JSON_ARRAY != vam->json_tree.type)
13073 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13074 vat_json_init_array (&vam->json_tree);
13076 node = vat_json_array_add (&vam->json_tree);
13078 vat_json_init_object (node);
13079 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13080 vat_json_object_add_string_copy (node, "interface_name",
13081 mp->interface_name);
13082 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13083 ntohl (mp->virtio_net_hdr_sz));
13084 vat_json_object_add_uint (node, "features",
13085 clib_net_to_host_u64 (mp->features));
13086 vat_json_object_add_uint (node, "is_server", mp->is_server);
13087 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13088 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13089 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13093 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13095 vl_api_sw_interface_vhost_user_dump_t *mp;
13096 vl_api_control_ping_t *mp_ping;
13099 "Interface name idx hdr_sz features server regions filename");
13101 /* Get list of vhost-user interfaces */
13102 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13105 /* Use a control ping for synchronization */
13106 MPING (CONTROL_PING, mp_ping);
13114 api_show_version (vat_main_t * vam)
13116 vl_api_show_version_t *mp;
13119 M (SHOW_VERSION, mp);
13128 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13130 unformat_input_t *line_input = vam->input;
13131 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13132 ip4_address_t local4, remote4;
13133 ip6_address_t local6, remote6;
13135 u8 ipv4_set = 0, ipv6_set = 0;
13139 u32 mcast_sw_if_index = ~0;
13140 u32 encap_vrf_id = 0;
13141 u32 decap_vrf_id = 0;
13147 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13148 clib_memset (&local4, 0, sizeof local4);
13149 clib_memset (&remote4, 0, sizeof remote4);
13150 clib_memset (&local6, 0, sizeof local6);
13151 clib_memset (&remote6, 0, sizeof remote6);
13153 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13155 if (unformat (line_input, "del"))
13157 else if (unformat (line_input, "local %U",
13158 unformat_ip4_address, &local4))
13163 else if (unformat (line_input, "remote %U",
13164 unformat_ip4_address, &remote4))
13169 else if (unformat (line_input, "local %U",
13170 unformat_ip6_address, &local6))
13175 else if (unformat (line_input, "remote %U",
13176 unformat_ip6_address, &remote6))
13181 else if (unformat (line_input, "group %U %U",
13182 unformat_ip4_address, &remote4,
13183 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13185 grp_set = remote_set = 1;
13188 else if (unformat (line_input, "group %U",
13189 unformat_ip4_address, &remote4))
13191 grp_set = remote_set = 1;
13194 else if (unformat (line_input, "group %U %U",
13195 unformat_ip6_address, &remote6,
13196 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13198 grp_set = remote_set = 1;
13201 else if (unformat (line_input, "group %U",
13202 unformat_ip6_address, &remote6))
13204 grp_set = remote_set = 1;
13208 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13210 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13212 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13214 else if (unformat (line_input, "vni %d", &vni))
13216 else if (unformat (line_input, "next-ip4"))
13218 else if (unformat (line_input, "next-ip6"))
13220 else if (unformat (line_input, "next-ethernet"))
13222 else if (unformat (line_input, "next-nsh"))
13226 errmsg ("parse error '%U'", format_unformat_error, line_input);
13231 if (local_set == 0)
13233 errmsg ("tunnel local address not specified");
13236 if (remote_set == 0)
13238 errmsg ("tunnel remote address not specified");
13241 if (grp_set && mcast_sw_if_index == ~0)
13243 errmsg ("tunnel nonexistent multicast device");
13246 if (ipv4_set && ipv6_set)
13248 errmsg ("both IPv4 and IPv6 addresses specified");
13254 errmsg ("vni not specified");
13258 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13263 clib_memcpy (&mp->local, &local6, sizeof (local6));
13264 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13268 clib_memcpy (&mp->local, &local4, sizeof (local4));
13269 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13272 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13273 mp->encap_vrf_id = ntohl (encap_vrf_id);
13274 mp->decap_vrf_id = ntohl (decap_vrf_id);
13275 mp->protocol = protocol;
13276 mp->vni = ntohl (vni);
13277 mp->is_add = is_add;
13278 mp->is_ipv6 = ipv6_set;
13285 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13286 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13288 vat_main_t *vam = &vat_main;
13289 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13290 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13292 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13293 ntohl (mp->sw_if_index),
13294 format_ip46_address, &local, IP46_TYPE_ANY,
13295 format_ip46_address, &remote, IP46_TYPE_ANY,
13296 ntohl (mp->vni), mp->protocol,
13297 ntohl (mp->mcast_sw_if_index),
13298 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13302 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13303 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13305 vat_main_t *vam = &vat_main;
13306 vat_json_node_t *node = NULL;
13307 struct in_addr ip4;
13308 struct in6_addr ip6;
13310 if (VAT_JSON_ARRAY != vam->json_tree.type)
13312 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13313 vat_json_init_array (&vam->json_tree);
13315 node = vat_json_array_add (&vam->json_tree);
13317 vat_json_init_object (node);
13318 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13321 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13322 vat_json_object_add_ip6 (node, "local", ip6);
13323 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13324 vat_json_object_add_ip6 (node, "remote", ip6);
13328 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13329 vat_json_object_add_ip4 (node, "local", ip4);
13330 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13331 vat_json_object_add_ip4 (node, "remote", ip4);
13333 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13334 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13335 vat_json_object_add_uint (node, "mcast_sw_if_index",
13336 ntohl (mp->mcast_sw_if_index));
13337 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13338 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13339 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13343 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13345 unformat_input_t *i = vam->input;
13346 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13347 vl_api_control_ping_t *mp_ping;
13349 u8 sw_if_index_set = 0;
13352 /* Parse args required to build the message */
13353 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13355 if (unformat (i, "sw_if_index %d", &sw_if_index))
13356 sw_if_index_set = 1;
13361 if (sw_if_index_set == 0)
13366 if (!vam->json_output)
13368 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13369 "sw_if_index", "local", "remote", "vni",
13370 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13373 /* Get list of vxlan-tunnel interfaces */
13374 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13376 mp->sw_if_index = htonl (sw_if_index);
13380 /* Use a control ping for synchronization */
13381 MPING (CONTROL_PING, mp_ping);
13388 static void vl_api_l2_fib_table_details_t_handler
13389 (vl_api_l2_fib_table_details_t * mp)
13391 vat_main_t *vam = &vat_main;
13393 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13395 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13396 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13400 static void vl_api_l2_fib_table_details_t_handler_json
13401 (vl_api_l2_fib_table_details_t * mp)
13403 vat_main_t *vam = &vat_main;
13404 vat_json_node_t *node = NULL;
13406 if (VAT_JSON_ARRAY != vam->json_tree.type)
13408 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13409 vat_json_init_array (&vam->json_tree);
13411 node = vat_json_array_add (&vam->json_tree);
13413 vat_json_init_object (node);
13414 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13415 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13416 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13417 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13418 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13419 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13423 api_l2_fib_table_dump (vat_main_t * vam)
13425 unformat_input_t *i = vam->input;
13426 vl_api_l2_fib_table_dump_t *mp;
13427 vl_api_control_ping_t *mp_ping;
13432 /* Parse args required to build the message */
13433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13435 if (unformat (i, "bd_id %d", &bd_id))
13441 if (bd_id_set == 0)
13443 errmsg ("missing bridge domain");
13447 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13449 /* Get list of l2 fib entries */
13450 M (L2_FIB_TABLE_DUMP, mp);
13452 mp->bd_id = ntohl (bd_id);
13455 /* Use a control ping for synchronization */
13456 MPING (CONTROL_PING, mp_ping);
13465 api_interface_name_renumber (vat_main_t * vam)
13467 unformat_input_t *line_input = vam->input;
13468 vl_api_interface_name_renumber_t *mp;
13469 u32 sw_if_index = ~0;
13470 u32 new_show_dev_instance = ~0;
13473 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13475 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13478 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13480 else if (unformat (line_input, "new_show_dev_instance %d",
13481 &new_show_dev_instance))
13487 if (sw_if_index == ~0)
13489 errmsg ("missing interface name or sw_if_index");
13493 if (new_show_dev_instance == ~0)
13495 errmsg ("missing new_show_dev_instance");
13499 M (INTERFACE_NAME_RENUMBER, mp);
13501 mp->sw_if_index = ntohl (sw_if_index);
13502 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13510 api_ip_probe_neighbor (vat_main_t * vam)
13512 unformat_input_t *i = vam->input;
13513 vl_api_ip_probe_neighbor_t *mp;
13514 vl_api_address_t dst_adr = { };
13520 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13522 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13524 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13526 else if (unformat (i, "address %U", unformat_vl_api_address, &dst_adr))
13534 errmsg ("missing interface");
13540 errmsg ("missing addresses");
13544 M (IP_PROBE_NEIGHBOR, mp);
13546 mp->sw_if_index = ntohl (sw_if_index);
13547 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
13555 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
13557 unformat_input_t *i = vam->input;
13558 vl_api_ip_scan_neighbor_enable_disable_t *mp;
13559 u8 mode = IP_SCAN_V46_NEIGHBORS;
13560 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
13563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13565 if (unformat (i, "ip4"))
13566 mode = IP_SCAN_V4_NEIGHBORS;
13567 else if (unformat (i, "ip6"))
13568 mode = IP_SCAN_V6_NEIGHBORS;
13569 if (unformat (i, "both"))
13570 mode = IP_SCAN_V46_NEIGHBORS;
13571 else if (unformat (i, "disable"))
13572 mode = IP_SCAN_DISABLED;
13573 else if (unformat (i, "interval %d", &interval))
13575 else if (unformat (i, "max-time %d", &time))
13577 else if (unformat (i, "max-update %d", &update))
13579 else if (unformat (i, "delay %d", &delay))
13581 else if (unformat (i, "stale %d", &stale))
13587 if (interval > 255)
13589 errmsg ("interval cannot exceed 255 minutes.");
13594 errmsg ("max-time cannot exceed 255 usec.");
13599 errmsg ("max-update cannot exceed 255.");
13604 errmsg ("delay cannot exceed 255 msec.");
13609 errmsg ("stale cannot exceed 255 minutes.");
13613 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
13615 mp->scan_interval = interval;
13616 mp->max_proc_time = time;
13617 mp->max_update = update;
13618 mp->scan_int_delay = delay;
13619 mp->stale_threshold = stale;
13627 api_want_ip4_arp_events (vat_main_t * vam)
13629 unformat_input_t *line_input = vam->input;
13630 vl_api_want_ip4_arp_events_t *mp;
13631 ip4_address_t address;
13632 int address_set = 0;
13633 u32 enable_disable = 1;
13636 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13638 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13640 else if (unformat (line_input, "del"))
13641 enable_disable = 0;
13646 if (address_set == 0)
13648 errmsg ("missing addresses");
13652 M (WANT_IP4_ARP_EVENTS, mp);
13653 mp->enable_disable = enable_disable;
13654 mp->pid = htonl (getpid ());
13655 clib_memcpy (mp->ip, &address, sizeof (address));
13663 api_want_ip6_nd_events (vat_main_t * vam)
13665 unformat_input_t *line_input = vam->input;
13666 vl_api_want_ip6_nd_events_t *mp;
13667 vl_api_ip6_address_t address;
13668 int address_set = 0;
13669 u32 enable_disable = 1;
13672 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13675 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
13677 else if (unformat (line_input, "del"))
13678 enable_disable = 0;
13683 if (address_set == 0)
13685 errmsg ("missing addresses");
13689 M (WANT_IP6_ND_EVENTS, mp);
13690 mp->enable_disable = enable_disable;
13691 mp->pid = htonl (getpid ());
13692 clib_memcpy (&mp->ip, &address, sizeof (address));
13700 api_want_l2_macs_events (vat_main_t * vam)
13702 unformat_input_t *line_input = vam->input;
13703 vl_api_want_l2_macs_events_t *mp;
13704 u8 enable_disable = 1;
13705 u32 scan_delay = 0;
13706 u32 max_macs_in_event = 0;
13707 u32 learn_limit = 0;
13710 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13712 if (unformat (line_input, "learn-limit %d", &learn_limit))
13714 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13716 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13718 else if (unformat (line_input, "disable"))
13719 enable_disable = 0;
13724 M (WANT_L2_MACS_EVENTS, mp);
13725 mp->enable_disable = enable_disable;
13726 mp->pid = htonl (getpid ());
13727 mp->learn_limit = htonl (learn_limit);
13728 mp->scan_delay = (u8) scan_delay;
13729 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13736 api_input_acl_set_interface (vat_main_t * vam)
13738 unformat_input_t *i = vam->input;
13739 vl_api_input_acl_set_interface_t *mp;
13741 int sw_if_index_set;
13742 u32 ip4_table_index = ~0;
13743 u32 ip6_table_index = ~0;
13744 u32 l2_table_index = ~0;
13748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13750 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13751 sw_if_index_set = 1;
13752 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13753 sw_if_index_set = 1;
13754 else if (unformat (i, "del"))
13756 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13758 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13760 else if (unformat (i, "l2-table %d", &l2_table_index))
13764 clib_warning ("parse error '%U'", format_unformat_error, i);
13769 if (sw_if_index_set == 0)
13771 errmsg ("missing interface name or sw_if_index");
13775 M (INPUT_ACL_SET_INTERFACE, mp);
13777 mp->sw_if_index = ntohl (sw_if_index);
13778 mp->ip4_table_index = ntohl (ip4_table_index);
13779 mp->ip6_table_index = ntohl (ip6_table_index);
13780 mp->l2_table_index = ntohl (l2_table_index);
13781 mp->is_add = is_add;
13789 api_output_acl_set_interface (vat_main_t * vam)
13791 unformat_input_t *i = vam->input;
13792 vl_api_output_acl_set_interface_t *mp;
13794 int sw_if_index_set;
13795 u32 ip4_table_index = ~0;
13796 u32 ip6_table_index = ~0;
13797 u32 l2_table_index = ~0;
13801 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13803 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13804 sw_if_index_set = 1;
13805 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13806 sw_if_index_set = 1;
13807 else if (unformat (i, "del"))
13809 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13811 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13813 else if (unformat (i, "l2-table %d", &l2_table_index))
13817 clib_warning ("parse error '%U'", format_unformat_error, i);
13822 if (sw_if_index_set == 0)
13824 errmsg ("missing interface name or sw_if_index");
13828 M (OUTPUT_ACL_SET_INTERFACE, mp);
13830 mp->sw_if_index = ntohl (sw_if_index);
13831 mp->ip4_table_index = ntohl (ip4_table_index);
13832 mp->ip6_table_index = ntohl (ip6_table_index);
13833 mp->l2_table_index = ntohl (l2_table_index);
13834 mp->is_add = is_add;
13842 api_ip_address_dump (vat_main_t * vam)
13844 unformat_input_t *i = vam->input;
13845 vl_api_ip_address_dump_t *mp;
13846 vl_api_control_ping_t *mp_ping;
13847 u32 sw_if_index = ~0;
13848 u8 sw_if_index_set = 0;
13853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13855 if (unformat (i, "sw_if_index %d", &sw_if_index))
13856 sw_if_index_set = 1;
13858 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13859 sw_if_index_set = 1;
13860 else if (unformat (i, "ipv4"))
13862 else if (unformat (i, "ipv6"))
13868 if (ipv4_set && ipv6_set)
13870 errmsg ("ipv4 and ipv6 flags cannot be both set");
13874 if ((!ipv4_set) && (!ipv6_set))
13876 errmsg ("no ipv4 nor ipv6 flag set");
13880 if (sw_if_index_set == 0)
13882 errmsg ("missing interface name or sw_if_index");
13886 vam->current_sw_if_index = sw_if_index;
13887 vam->is_ipv6 = ipv6_set;
13889 M (IP_ADDRESS_DUMP, mp);
13890 mp->sw_if_index = ntohl (sw_if_index);
13891 mp->is_ipv6 = ipv6_set;
13894 /* Use a control ping for synchronization */
13895 MPING (CONTROL_PING, mp_ping);
13903 api_ip_dump (vat_main_t * vam)
13905 vl_api_ip_dump_t *mp;
13906 vl_api_control_ping_t *mp_ping;
13907 unformat_input_t *in = vam->input;
13914 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13916 if (unformat (in, "ipv4"))
13918 else if (unformat (in, "ipv6"))
13924 if (ipv4_set && ipv6_set)
13926 errmsg ("ipv4 and ipv6 flags cannot be both set");
13930 if ((!ipv4_set) && (!ipv6_set))
13932 errmsg ("no ipv4 nor ipv6 flag set");
13936 is_ipv6 = ipv6_set;
13937 vam->is_ipv6 = is_ipv6;
13939 /* free old data */
13940 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13942 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13944 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13947 mp->is_ipv6 = ipv6_set;
13950 /* Use a control ping for synchronization */
13951 MPING (CONTROL_PING, mp_ping);
13959 api_ipsec_spd_add_del (vat_main_t * vam)
13961 unformat_input_t *i = vam->input;
13962 vl_api_ipsec_spd_add_del_t *mp;
13967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13969 if (unformat (i, "spd_id %d", &spd_id))
13971 else if (unformat (i, "del"))
13975 clib_warning ("parse error '%U'", format_unformat_error, i);
13981 errmsg ("spd_id must be set");
13985 M (IPSEC_SPD_ADD_DEL, mp);
13987 mp->spd_id = ntohl (spd_id);
13988 mp->is_add = is_add;
13996 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13998 unformat_input_t *i = vam->input;
13999 vl_api_ipsec_interface_add_del_spd_t *mp;
14001 u8 sw_if_index_set = 0;
14002 u32 spd_id = (u32) ~ 0;
14006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14008 if (unformat (i, "del"))
14010 else if (unformat (i, "spd_id %d", &spd_id))
14013 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14014 sw_if_index_set = 1;
14015 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14016 sw_if_index_set = 1;
14019 clib_warning ("parse error '%U'", format_unformat_error, i);
14025 if (spd_id == (u32) ~ 0)
14027 errmsg ("spd_id must be set");
14031 if (sw_if_index_set == 0)
14033 errmsg ("missing interface name or sw_if_index");
14037 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14039 mp->spd_id = ntohl (spd_id);
14040 mp->sw_if_index = ntohl (sw_if_index);
14041 mp->is_add = is_add;
14049 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14051 unformat_input_t *i = vam->input;
14052 vl_api_ipsec_spd_entry_add_del_t *mp;
14053 u8 is_add = 1, is_outbound = 0;
14054 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14056 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14057 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14058 vl_api_address_t laddr_start = { }, laddr_stop =
14067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14069 if (unformat (i, "del"))
14071 if (unformat (i, "outbound"))
14073 if (unformat (i, "inbound"))
14075 else if (unformat (i, "spd_id %d", &spd_id))
14077 else if (unformat (i, "sa_id %d", &sa_id))
14079 else if (unformat (i, "priority %d", &priority))
14081 else if (unformat (i, "protocol %d", &protocol))
14083 else if (unformat (i, "lport_start %d", &lport_start))
14085 else if (unformat (i, "lport_stop %d", &lport_stop))
14087 else if (unformat (i, "rport_start %d", &rport_start))
14089 else if (unformat (i, "rport_stop %d", &rport_stop))
14091 else if (unformat (i, "laddr_start %U",
14092 unformat_vl_api_address, &laddr_start))
14094 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14097 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14100 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14104 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14106 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14108 clib_warning ("unsupported action: 'resolve'");
14114 clib_warning ("parse error '%U'", format_unformat_error, i);
14120 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14122 mp->is_add = is_add;
14124 mp->entry.spd_id = ntohl (spd_id);
14125 mp->entry.priority = ntohl (priority);
14126 mp->entry.is_outbound = is_outbound;
14128 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14129 sizeof (vl_api_address_t));
14130 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14131 sizeof (vl_api_address_t));
14132 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14133 sizeof (vl_api_address_t));
14134 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14135 sizeof (vl_api_address_t));
14137 mp->entry.protocol = (u8) protocol;
14138 mp->entry.local_port_start = ntohs ((u16) lport_start);
14139 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14140 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14141 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14142 mp->entry.policy = (u8) policy;
14143 mp->entry.sa_id = ntohl (sa_id);
14151 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14153 unformat_input_t *i = vam->input;
14154 vl_api_ipsec_sad_entry_add_del_t *mp;
14155 u32 sad_id = 0, spi = 0;
14156 u8 *ck = 0, *ik = 0;
14159 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14160 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14161 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14162 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14163 vl_api_address_t tun_src, tun_dst;
14166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14168 if (unformat (i, "del"))
14170 else if (unformat (i, "sad_id %d", &sad_id))
14172 else if (unformat (i, "spi %d", &spi))
14174 else if (unformat (i, "esp"))
14175 protocol = IPSEC_API_PROTO_ESP;
14177 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14179 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14180 if (ADDRESS_IP6 == tun_src.af)
14181 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14184 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14186 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14187 if (ADDRESS_IP6 == tun_src.af)
14188 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14191 if (unformat (i, "crypto_alg %U",
14192 unformat_ipsec_api_crypto_alg, &crypto_alg))
14194 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14196 else if (unformat (i, "integ_alg %U",
14197 unformat_ipsec_api_integ_alg, &integ_alg))
14199 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14203 clib_warning ("parse error '%U'", format_unformat_error, i);
14209 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14211 mp->is_add = is_add;
14212 mp->entry.sad_id = ntohl (sad_id);
14213 mp->entry.protocol = protocol;
14214 mp->entry.spi = ntohl (spi);
14215 mp->entry.flags = flags;
14217 mp->entry.crypto_algorithm = crypto_alg;
14218 mp->entry.integrity_algorithm = integ_alg;
14219 mp->entry.crypto_key.length = vec_len (ck);
14220 mp->entry.integrity_key.length = vec_len (ik);
14222 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14223 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14225 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14226 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14229 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14231 clib_memcpy (mp->entry.integrity_key.data, ik,
14232 mp->entry.integrity_key.length);
14234 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14236 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14237 sizeof (mp->entry.tunnel_src));
14238 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14239 sizeof (mp->entry.tunnel_dst));
14248 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14250 unformat_input_t *i = vam->input;
14251 vl_api_ipsec_tunnel_if_add_del_t *mp;
14252 u32 local_spi = 0, remote_spi = 0;
14253 u32 crypto_alg = 0, integ_alg = 0;
14254 u8 *lck = NULL, *rck = NULL;
14255 u8 *lik = NULL, *rik = NULL;
14256 vl_api_address_t local_ip = { 0 };
14257 vl_api_address_t remote_ip = { 0 };
14261 u8 anti_replay = 0;
14267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14269 if (unformat (i, "del"))
14271 else if (unformat (i, "esn"))
14273 else if (unformat (i, "anti-replay"))
14275 else if (unformat (i, "count %d", &count))
14277 else if (unformat (i, "local_spi %d", &local_spi))
14279 else if (unformat (i, "remote_spi %d", &remote_spi))
14282 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
14285 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
14287 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14290 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14292 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14294 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14298 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
14300 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
14302 errmsg ("unsupported crypto-alg: '%U'\n",
14303 format_ipsec_crypto_alg, crypto_alg);
14309 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
14311 if (integ_alg >= IPSEC_INTEG_N_ALG)
14313 errmsg ("unsupported integ-alg: '%U'\n",
14314 format_ipsec_integ_alg, integ_alg);
14318 else if (unformat (i, "instance %u", &instance))
14322 errmsg ("parse error '%U'\n", format_unformat_error, i);
14329 /* Turn on async mode */
14330 vam->async_mode = 1;
14331 vam->async_errors = 0;
14332 before = vat_time_now (vam);
14335 for (jj = 0; jj < count; jj++)
14337 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14339 mp->is_add = is_add;
14341 mp->anti_replay = anti_replay;
14344 increment_address (&remote_ip);
14346 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
14347 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
14349 mp->local_spi = htonl (local_spi + jj);
14350 mp->remote_spi = htonl (remote_spi + jj);
14351 mp->crypto_alg = (u8) crypto_alg;
14353 mp->local_crypto_key_len = 0;
14356 mp->local_crypto_key_len = vec_len (lck);
14357 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14358 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14359 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14362 mp->remote_crypto_key_len = 0;
14365 mp->remote_crypto_key_len = vec_len (rck);
14366 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14367 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14368 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14371 mp->integ_alg = (u8) integ_alg;
14373 mp->local_integ_key_len = 0;
14376 mp->local_integ_key_len = vec_len (lik);
14377 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14378 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14379 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14382 mp->remote_integ_key_len = 0;
14385 mp->remote_integ_key_len = vec_len (rik);
14386 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14387 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14388 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14393 mp->renumber = renumber;
14394 mp->show_instance = ntohl (instance);
14399 /* When testing multiple add/del ops, use a control-ping to sync */
14402 vl_api_control_ping_t *mp_ping;
14406 /* Shut off async mode */
14407 vam->async_mode = 0;
14409 MPING (CONTROL_PING, mp_ping);
14412 timeout = vat_time_now (vam) + 1.0;
14413 while (vat_time_now (vam) < timeout)
14414 if (vam->result_ready == 1)
14419 if (vam->retval == -99)
14420 errmsg ("timeout");
14422 if (vam->async_errors > 0)
14424 errmsg ("%d asynchronous errors", vam->async_errors);
14427 vam->async_errors = 0;
14428 after = vat_time_now (vam);
14430 /* slim chance, but we might have eaten SIGTERM on the first iteration */
14434 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
14435 count, after - before, count / (after - before));
14439 /* Wait for a reply... */
14448 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14450 vat_main_t *vam = &vat_main;
14452 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14453 "crypto_key %U integ_alg %u integ_key %U flags %x "
14454 "tunnel_src_addr %U tunnel_dst_addr %U "
14455 "salt %u seq_outbound %lu last_seq_inbound %lu "
14456 "replay_window %lu\n",
14457 ntohl (mp->entry.sad_id),
14458 ntohl (mp->sw_if_index),
14459 ntohl (mp->entry.spi),
14460 ntohl (mp->entry.protocol),
14461 ntohl (mp->entry.crypto_algorithm),
14462 format_hex_bytes, mp->entry.crypto_key.data,
14463 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
14464 format_hex_bytes, mp->entry.integrity_key.data,
14465 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
14466 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
14467 &mp->entry.tunnel_dst, ntohl (mp->salt),
14468 clib_net_to_host_u64 (mp->seq_outbound),
14469 clib_net_to_host_u64 (mp->last_seq_inbound),
14470 clib_net_to_host_u64 (mp->replay_window));
14473 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14474 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14476 static void vl_api_ipsec_sa_details_t_handler_json
14477 (vl_api_ipsec_sa_details_t * mp)
14479 vat_main_t *vam = &vat_main;
14480 vat_json_node_t *node = NULL;
14481 vl_api_ipsec_sad_flags_t flags;
14483 if (VAT_JSON_ARRAY != vam->json_tree.type)
14485 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14486 vat_json_init_array (&vam->json_tree);
14488 node = vat_json_array_add (&vam->json_tree);
14490 vat_json_init_object (node);
14491 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
14492 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14493 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
14494 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
14495 vat_json_object_add_uint (node, "crypto_alg",
14496 ntohl (mp->entry.crypto_algorithm));
14497 vat_json_object_add_uint (node, "integ_alg",
14498 ntohl (mp->entry.integrity_algorithm));
14499 flags = ntohl (mp->entry.flags);
14500 vat_json_object_add_uint (node, "use_esn",
14501 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
14502 vat_json_object_add_uint (node, "use_anti_replay",
14503 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
14504 vat_json_object_add_uint (node, "is_tunnel",
14505 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
14506 vat_json_object_add_uint (node, "is_tunnel_ip6",
14507 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
14508 vat_json_object_add_uint (node, "udp_encap",
14509 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
14510 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
14511 mp->entry.crypto_key.length);
14512 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
14513 mp->entry.integrity_key.length);
14514 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
14515 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
14516 vat_json_object_add_uint (node, "replay_window",
14517 clib_net_to_host_u64 (mp->replay_window));
14521 api_ipsec_sa_dump (vat_main_t * vam)
14523 unformat_input_t *i = vam->input;
14524 vl_api_ipsec_sa_dump_t *mp;
14525 vl_api_control_ping_t *mp_ping;
14529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14531 if (unformat (i, "sa_id %d", &sa_id))
14535 clib_warning ("parse error '%U'", format_unformat_error, i);
14540 M (IPSEC_SA_DUMP, mp);
14542 mp->sa_id = ntohl (sa_id);
14546 /* Use a control ping for synchronization */
14547 M (CONTROL_PING, mp_ping);
14555 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14557 unformat_input_t *i = vam->input;
14558 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14559 u32 sw_if_index = ~0;
14561 u8 is_outbound = (u8) ~ 0;
14564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14566 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14568 else if (unformat (i, "sa_id %d", &sa_id))
14570 else if (unformat (i, "outbound"))
14572 else if (unformat (i, "inbound"))
14576 clib_warning ("parse error '%U'", format_unformat_error, i);
14581 if (sw_if_index == ~0)
14583 errmsg ("interface must be specified");
14589 errmsg ("SA ID must be specified");
14593 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14595 mp->sw_if_index = htonl (sw_if_index);
14596 mp->sa_id = htonl (sa_id);
14597 mp->is_outbound = is_outbound;
14606 api_get_first_msg_id (vat_main_t * vam)
14608 vl_api_get_first_msg_id_t *mp;
14609 unformat_input_t *i = vam->input;
14614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14616 if (unformat (i, "client %s", &name))
14624 errmsg ("missing client name");
14627 vec_add1 (name, 0);
14629 if (vec_len (name) > 63)
14631 errmsg ("client name too long");
14635 M (GET_FIRST_MSG_ID, mp);
14636 clib_memcpy (mp->name, name, vec_len (name));
14643 api_cop_interface_enable_disable (vat_main_t * vam)
14645 unformat_input_t *line_input = vam->input;
14646 vl_api_cop_interface_enable_disable_t *mp;
14647 u32 sw_if_index = ~0;
14648 u8 enable_disable = 1;
14651 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14653 if (unformat (line_input, "disable"))
14654 enable_disable = 0;
14655 if (unformat (line_input, "enable"))
14656 enable_disable = 1;
14657 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14658 vam, &sw_if_index))
14660 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14666 if (sw_if_index == ~0)
14668 errmsg ("missing interface name or sw_if_index");
14672 /* Construct the API message */
14673 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14674 mp->sw_if_index = ntohl (sw_if_index);
14675 mp->enable_disable = enable_disable;
14679 /* Wait for the reply */
14685 api_cop_whitelist_enable_disable (vat_main_t * vam)
14687 unformat_input_t *line_input = vam->input;
14688 vl_api_cop_whitelist_enable_disable_t *mp;
14689 u32 sw_if_index = ~0;
14690 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14694 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14696 if (unformat (line_input, "ip4"))
14698 else if (unformat (line_input, "ip6"))
14700 else if (unformat (line_input, "default"))
14702 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14703 vam, &sw_if_index))
14705 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14707 else if (unformat (line_input, "fib-id %d", &fib_id))
14713 if (sw_if_index == ~0)
14715 errmsg ("missing interface name or sw_if_index");
14719 /* Construct the API message */
14720 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14721 mp->sw_if_index = ntohl (sw_if_index);
14722 mp->fib_id = ntohl (fib_id);
14725 mp->default_cop = default_cop;
14729 /* Wait for the reply */
14735 api_get_node_graph (vat_main_t * vam)
14737 vl_api_get_node_graph_t *mp;
14740 M (GET_NODE_GRAPH, mp);
14744 /* Wait for the reply */
14750 /** Used for parsing LISP eids */
14751 typedef CLIB_PACKED(struct{
14752 u8 addr[16]; /**< eid address */
14753 u32 len; /**< prefix length if IP */
14754 u8 type; /**< type of eid */
14759 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14761 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14763 clib_memset (a, 0, sizeof (a[0]));
14765 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14767 a->type = 0; /* ipv4 type */
14769 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14771 a->type = 1; /* ipv6 type */
14773 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14775 a->type = 2; /* mac type */
14777 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14779 a->type = 3; /* NSH type */
14780 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14781 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14788 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14797 lisp_eid_size_vat (u8 type)
14814 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14816 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14820 api_one_add_del_locator_set (vat_main_t * vam)
14822 unformat_input_t *input = vam->input;
14823 vl_api_one_add_del_locator_set_t *mp;
14825 u8 *locator_set_name = NULL;
14826 u8 locator_set_name_set = 0;
14827 vl_api_local_locator_t locator, *locators = 0;
14828 u32 sw_if_index, priority, weight;
14832 /* Parse args required to build the message */
14833 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14835 if (unformat (input, "del"))
14839 else if (unformat (input, "locator-set %s", &locator_set_name))
14841 locator_set_name_set = 1;
14843 else if (unformat (input, "sw_if_index %u p %u w %u",
14844 &sw_if_index, &priority, &weight))
14846 locator.sw_if_index = htonl (sw_if_index);
14847 locator.priority = priority;
14848 locator.weight = weight;
14849 vec_add1 (locators, locator);
14853 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14854 &sw_if_index, &priority, &weight))
14856 locator.sw_if_index = htonl (sw_if_index);
14857 locator.priority = priority;
14858 locator.weight = weight;
14859 vec_add1 (locators, locator);
14865 if (locator_set_name_set == 0)
14867 errmsg ("missing locator-set name");
14868 vec_free (locators);
14872 if (vec_len (locator_set_name) > 64)
14874 errmsg ("locator-set name too long");
14875 vec_free (locator_set_name);
14876 vec_free (locators);
14879 vec_add1 (locator_set_name, 0);
14881 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14883 /* Construct the API message */
14884 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14886 mp->is_add = is_add;
14887 clib_memcpy (mp->locator_set_name, locator_set_name,
14888 vec_len (locator_set_name));
14889 vec_free (locator_set_name);
14891 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14893 clib_memcpy (mp->locators, locators, data_len);
14894 vec_free (locators);
14899 /* Wait for a reply... */
14904 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14907 api_one_add_del_locator (vat_main_t * vam)
14909 unformat_input_t *input = vam->input;
14910 vl_api_one_add_del_locator_t *mp;
14911 u32 tmp_if_index = ~0;
14912 u32 sw_if_index = ~0;
14913 u8 sw_if_index_set = 0;
14914 u8 sw_if_index_if_name_set = 0;
14916 u8 priority_set = 0;
14920 u8 *locator_set_name = NULL;
14921 u8 locator_set_name_set = 0;
14924 /* Parse args required to build the message */
14925 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14927 if (unformat (input, "del"))
14931 else if (unformat (input, "locator-set %s", &locator_set_name))
14933 locator_set_name_set = 1;
14935 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14938 sw_if_index_if_name_set = 1;
14939 sw_if_index = tmp_if_index;
14941 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14943 sw_if_index_set = 1;
14944 sw_if_index = tmp_if_index;
14946 else if (unformat (input, "p %d", &priority))
14950 else if (unformat (input, "w %d", &weight))
14958 if (locator_set_name_set == 0)
14960 errmsg ("missing locator-set name");
14964 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14966 errmsg ("missing sw_if_index");
14967 vec_free (locator_set_name);
14971 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14973 errmsg ("cannot use both params interface name and sw_if_index");
14974 vec_free (locator_set_name);
14978 if (priority_set == 0)
14980 errmsg ("missing locator-set priority");
14981 vec_free (locator_set_name);
14985 if (weight_set == 0)
14987 errmsg ("missing locator-set weight");
14988 vec_free (locator_set_name);
14992 if (vec_len (locator_set_name) > 64)
14994 errmsg ("locator-set name too long");
14995 vec_free (locator_set_name);
14998 vec_add1 (locator_set_name, 0);
15000 /* Construct the API message */
15001 M (ONE_ADD_DEL_LOCATOR, mp);
15003 mp->is_add = is_add;
15004 mp->sw_if_index = ntohl (sw_if_index);
15005 mp->priority = priority;
15006 mp->weight = weight;
15007 clib_memcpy (mp->locator_set_name, locator_set_name,
15008 vec_len (locator_set_name));
15009 vec_free (locator_set_name);
15014 /* Wait for a reply... */
15019 #define api_lisp_add_del_locator api_one_add_del_locator
15022 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15024 u32 *key_id = va_arg (*args, u32 *);
15027 if (unformat (input, "%s", &s))
15029 if (!strcmp ((char *) s, "sha1"))
15030 key_id[0] = HMAC_SHA_1_96;
15031 else if (!strcmp ((char *) s, "sha256"))
15032 key_id[0] = HMAC_SHA_256_128;
15035 clib_warning ("invalid key_id: '%s'", s);
15036 key_id[0] = HMAC_NO_KEY;
15047 api_one_add_del_local_eid (vat_main_t * vam)
15049 unformat_input_t *input = vam->input;
15050 vl_api_one_add_del_local_eid_t *mp;
15053 lisp_eid_vat_t _eid, *eid = &_eid;
15054 u8 *locator_set_name = 0;
15055 u8 locator_set_name_set = 0;
15061 /* Parse args required to build the message */
15062 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15064 if (unformat (input, "del"))
15068 else if (unformat (input, "vni %d", &vni))
15072 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15076 else if (unformat (input, "locator-set %s", &locator_set_name))
15078 locator_set_name_set = 1;
15080 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15082 else if (unformat (input, "secret-key %_%v%_", &key))
15088 if (locator_set_name_set == 0)
15090 errmsg ("missing locator-set name");
15096 errmsg ("EID address not set!");
15097 vec_free (locator_set_name);
15101 if (key && (0 == key_id))
15103 errmsg ("invalid key_id!");
15107 if (vec_len (key) > 64)
15109 errmsg ("key too long");
15114 if (vec_len (locator_set_name) > 64)
15116 errmsg ("locator-set name too long");
15117 vec_free (locator_set_name);
15120 vec_add1 (locator_set_name, 0);
15122 /* Construct the API message */
15123 M (ONE_ADD_DEL_LOCAL_EID, mp);
15125 mp->is_add = is_add;
15126 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15127 mp->eid_type = eid->type;
15128 mp->prefix_len = eid->len;
15129 mp->vni = clib_host_to_net_u32 (vni);
15130 mp->key_id = clib_host_to_net_u16 (key_id);
15131 clib_memcpy (mp->locator_set_name, locator_set_name,
15132 vec_len (locator_set_name));
15133 clib_memcpy (mp->key, key, vec_len (key));
15135 vec_free (locator_set_name);
15141 /* Wait for a reply... */
15146 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15149 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15151 u32 dp_table = 0, vni = 0;;
15152 unformat_input_t *input = vam->input;
15153 vl_api_gpe_add_del_fwd_entry_t *mp;
15155 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15156 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15157 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15158 u32 action = ~0, w;
15159 ip4_address_t rmt_rloc4, lcl_rloc4;
15160 ip6_address_t rmt_rloc6, lcl_rloc6;
15161 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15164 clib_memset (&rloc, 0, sizeof (rloc));
15166 /* Parse args required to build the message */
15167 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15169 if (unformat (input, "del"))
15171 else if (unformat (input, "add"))
15173 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15177 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15181 else if (unformat (input, "vrf %d", &dp_table))
15183 else if (unformat (input, "bd %d", &dp_table))
15185 else if (unformat (input, "vni %d", &vni))
15187 else if (unformat (input, "w %d", &w))
15191 errmsg ("No RLOC configured for setting priority/weight!");
15194 curr_rloc->weight = w;
15196 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15197 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15201 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15203 vec_add1 (lcl_locs, rloc);
15205 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15206 vec_add1 (rmt_locs, rloc);
15207 /* weight saved in rmt loc */
15208 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15210 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15211 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15214 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15216 vec_add1 (lcl_locs, rloc);
15218 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15219 vec_add1 (rmt_locs, rloc);
15220 /* weight saved in rmt loc */
15221 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15223 else if (unformat (input, "action %d", &action))
15229 clib_warning ("parse error '%U'", format_unformat_error, input);
15236 errmsg ("remote eid addresses not set");
15240 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15242 errmsg ("eid types don't match");
15246 if (0 == rmt_locs && (u32) ~ 0 == action)
15248 errmsg ("action not set for negative mapping");
15252 /* Construct the API message */
15253 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15254 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15256 mp->is_add = is_add;
15257 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15258 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15259 mp->eid_type = rmt_eid->type;
15260 mp->dp_table = clib_host_to_net_u32 (dp_table);
15261 mp->vni = clib_host_to_net_u32 (vni);
15262 mp->rmt_len = rmt_eid->len;
15263 mp->lcl_len = lcl_eid->len;
15264 mp->action = action;
15266 if (0 != rmt_locs && 0 != lcl_locs)
15268 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15269 clib_memcpy (mp->locs, lcl_locs,
15270 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15272 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15273 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15274 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15276 vec_free (lcl_locs);
15277 vec_free (rmt_locs);
15282 /* Wait for a reply... */
15288 api_one_add_del_map_server (vat_main_t * vam)
15290 unformat_input_t *input = vam->input;
15291 vl_api_one_add_del_map_server_t *mp;
15295 ip4_address_t ipv4;
15296 ip6_address_t ipv6;
15299 /* Parse args required to build the message */
15300 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15302 if (unformat (input, "del"))
15306 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15310 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15318 if (ipv4_set && ipv6_set)
15320 errmsg ("both eid v4 and v6 addresses set");
15324 if (!ipv4_set && !ipv6_set)
15326 errmsg ("eid addresses not set");
15330 /* Construct the API message */
15331 M (ONE_ADD_DEL_MAP_SERVER, mp);
15333 mp->is_add = is_add;
15337 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15342 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15348 /* Wait for a reply... */
15353 #define api_lisp_add_del_map_server api_one_add_del_map_server
15356 api_one_add_del_map_resolver (vat_main_t * vam)
15358 unformat_input_t *input = vam->input;
15359 vl_api_one_add_del_map_resolver_t *mp;
15363 ip4_address_t ipv4;
15364 ip6_address_t ipv6;
15367 /* Parse args required to build the message */
15368 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15370 if (unformat (input, "del"))
15374 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15378 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15386 if (ipv4_set && ipv6_set)
15388 errmsg ("both eid v4 and v6 addresses set");
15392 if (!ipv4_set && !ipv6_set)
15394 errmsg ("eid addresses not set");
15398 /* Construct the API message */
15399 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15401 mp->is_add = is_add;
15405 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15410 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15416 /* Wait for a reply... */
15421 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15424 api_lisp_gpe_enable_disable (vat_main_t * vam)
15426 unformat_input_t *input = vam->input;
15427 vl_api_gpe_enable_disable_t *mp;
15432 /* Parse args required to build the message */
15433 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15435 if (unformat (input, "enable"))
15440 else if (unformat (input, "disable"))
15451 errmsg ("Value not set");
15455 /* Construct the API message */
15456 M (GPE_ENABLE_DISABLE, mp);
15463 /* Wait for a reply... */
15469 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15471 unformat_input_t *input = vam->input;
15472 vl_api_one_rloc_probe_enable_disable_t *mp;
15477 /* Parse args required to build the message */
15478 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15480 if (unformat (input, "enable"))
15485 else if (unformat (input, "disable"))
15493 errmsg ("Value not set");
15497 /* Construct the API message */
15498 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15500 mp->is_enabled = is_en;
15505 /* Wait for a reply... */
15510 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15513 api_one_map_register_enable_disable (vat_main_t * vam)
15515 unformat_input_t *input = vam->input;
15516 vl_api_one_map_register_enable_disable_t *mp;
15521 /* Parse args required to build the message */
15522 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15524 if (unformat (input, "enable"))
15529 else if (unformat (input, "disable"))
15537 errmsg ("Value not set");
15541 /* Construct the API message */
15542 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15544 mp->is_enabled = is_en;
15549 /* Wait for a reply... */
15554 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15557 api_one_enable_disable (vat_main_t * vam)
15559 unformat_input_t *input = vam->input;
15560 vl_api_one_enable_disable_t *mp;
15565 /* Parse args required to build the message */
15566 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15568 if (unformat (input, "enable"))
15573 else if (unformat (input, "disable"))
15583 errmsg ("Value not set");
15587 /* Construct the API message */
15588 M (ONE_ENABLE_DISABLE, mp);
15595 /* Wait for a reply... */
15600 #define api_lisp_enable_disable api_one_enable_disable
15603 api_one_enable_disable_xtr_mode (vat_main_t * vam)
15605 unformat_input_t *input = vam->input;
15606 vl_api_one_enable_disable_xtr_mode_t *mp;
15611 /* Parse args required to build the message */
15612 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15614 if (unformat (input, "enable"))
15619 else if (unformat (input, "disable"))
15629 errmsg ("Value not set");
15633 /* Construct the API message */
15634 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
15641 /* Wait for a reply... */
15647 api_one_show_xtr_mode (vat_main_t * vam)
15649 vl_api_one_show_xtr_mode_t *mp;
15652 /* Construct the API message */
15653 M (ONE_SHOW_XTR_MODE, mp);
15658 /* Wait for a reply... */
15664 api_one_enable_disable_pitr_mode (vat_main_t * vam)
15666 unformat_input_t *input = vam->input;
15667 vl_api_one_enable_disable_pitr_mode_t *mp;
15672 /* Parse args required to build the message */
15673 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15675 if (unformat (input, "enable"))
15680 else if (unformat (input, "disable"))
15690 errmsg ("Value not set");
15694 /* Construct the API message */
15695 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
15702 /* Wait for a reply... */
15708 api_one_show_pitr_mode (vat_main_t * vam)
15710 vl_api_one_show_pitr_mode_t *mp;
15713 /* Construct the API message */
15714 M (ONE_SHOW_PITR_MODE, mp);
15719 /* Wait for a reply... */
15725 api_one_enable_disable_petr_mode (vat_main_t * vam)
15727 unformat_input_t *input = vam->input;
15728 vl_api_one_enable_disable_petr_mode_t *mp;
15733 /* Parse args required to build the message */
15734 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15736 if (unformat (input, "enable"))
15741 else if (unformat (input, "disable"))
15751 errmsg ("Value not set");
15755 /* Construct the API message */
15756 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
15763 /* Wait for a reply... */
15769 api_one_show_petr_mode (vat_main_t * vam)
15771 vl_api_one_show_petr_mode_t *mp;
15774 /* Construct the API message */
15775 M (ONE_SHOW_PETR_MODE, mp);
15780 /* Wait for a reply... */
15786 api_show_one_map_register_state (vat_main_t * vam)
15788 vl_api_show_one_map_register_state_t *mp;
15791 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15796 /* wait for reply */
15801 #define api_show_lisp_map_register_state api_show_one_map_register_state
15804 api_show_one_rloc_probe_state (vat_main_t * vam)
15806 vl_api_show_one_rloc_probe_state_t *mp;
15809 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15814 /* wait for reply */
15819 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15822 api_one_add_del_ndp_entry (vat_main_t * vam)
15824 vl_api_one_add_del_ndp_entry_t *mp;
15825 unformat_input_t *input = vam->input;
15830 u8 mac[6] = { 0, };
15831 u8 ip6[16] = { 0, };
15835 /* Parse args required to build the message */
15836 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15838 if (unformat (input, "del"))
15840 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15842 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15844 else if (unformat (input, "bd %d", &bd))
15848 errmsg ("parse error '%U'", format_unformat_error, input);
15853 if (!bd_set || !ip_set || (!mac_set && is_add))
15855 errmsg ("Missing BD, IP or MAC!");
15859 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15860 mp->is_add = is_add;
15861 clib_memcpy (mp->mac, mac, 6);
15862 mp->bd = clib_host_to_net_u32 (bd);
15863 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
15868 /* wait for reply */
15874 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15876 vl_api_one_add_del_l2_arp_entry_t *mp;
15877 unformat_input_t *input = vam->input;
15882 u8 mac[6] = { 0, };
15883 u32 ip4 = 0, bd = ~0;
15886 /* Parse args required to build the message */
15887 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15889 if (unformat (input, "del"))
15891 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15893 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15895 else if (unformat (input, "bd %d", &bd))
15899 errmsg ("parse error '%U'", format_unformat_error, input);
15904 if (!bd_set || !ip_set || (!mac_set && is_add))
15906 errmsg ("Missing BD, IP or MAC!");
15910 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15911 mp->is_add = is_add;
15912 clib_memcpy (mp->mac, mac, 6);
15913 mp->bd = clib_host_to_net_u32 (bd);
15919 /* wait for reply */
15925 api_one_ndp_bd_get (vat_main_t * vam)
15927 vl_api_one_ndp_bd_get_t *mp;
15930 M (ONE_NDP_BD_GET, mp);
15935 /* wait for reply */
15941 api_one_ndp_entries_get (vat_main_t * vam)
15943 vl_api_one_ndp_entries_get_t *mp;
15944 unformat_input_t *input = vam->input;
15949 /* Parse args required to build the message */
15950 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15952 if (unformat (input, "bd %d", &bd))
15956 errmsg ("parse error '%U'", format_unformat_error, input);
15963 errmsg ("Expected bridge domain!");
15967 M (ONE_NDP_ENTRIES_GET, mp);
15968 mp->bd = clib_host_to_net_u32 (bd);
15973 /* wait for reply */
15979 api_one_l2_arp_bd_get (vat_main_t * vam)
15981 vl_api_one_l2_arp_bd_get_t *mp;
15984 M (ONE_L2_ARP_BD_GET, mp);
15989 /* wait for reply */
15995 api_one_l2_arp_entries_get (vat_main_t * vam)
15997 vl_api_one_l2_arp_entries_get_t *mp;
15998 unformat_input_t *input = vam->input;
16003 /* Parse args required to build the message */
16004 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16006 if (unformat (input, "bd %d", &bd))
16010 errmsg ("parse error '%U'", format_unformat_error, input);
16017 errmsg ("Expected bridge domain!");
16021 M (ONE_L2_ARP_ENTRIES_GET, mp);
16022 mp->bd = clib_host_to_net_u32 (bd);
16027 /* wait for reply */
16033 api_one_stats_enable_disable (vat_main_t * vam)
16035 vl_api_one_stats_enable_disable_t *mp;
16036 unformat_input_t *input = vam->input;
16041 /* Parse args required to build the message */
16042 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16044 if (unformat (input, "enable"))
16049 else if (unformat (input, "disable"))
16059 errmsg ("Value not set");
16063 M (ONE_STATS_ENABLE_DISABLE, mp);
16069 /* wait for reply */
16075 api_show_one_stats_enable_disable (vat_main_t * vam)
16077 vl_api_show_one_stats_enable_disable_t *mp;
16080 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16085 /* wait for reply */
16091 api_show_one_map_request_mode (vat_main_t * vam)
16093 vl_api_show_one_map_request_mode_t *mp;
16096 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16101 /* wait for reply */
16106 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16109 api_one_map_request_mode (vat_main_t * vam)
16111 unformat_input_t *input = vam->input;
16112 vl_api_one_map_request_mode_t *mp;
16116 /* Parse args required to build the message */
16117 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16119 if (unformat (input, "dst-only"))
16121 else if (unformat (input, "src-dst"))
16125 errmsg ("parse error '%U'", format_unformat_error, input);
16130 M (ONE_MAP_REQUEST_MODE, mp);
16137 /* wait for reply */
16142 #define api_lisp_map_request_mode api_one_map_request_mode
16145 * Enable/disable ONE proxy ITR.
16147 * @param vam vpp API test context
16148 * @return return code
16151 api_one_pitr_set_locator_set (vat_main_t * vam)
16153 u8 ls_name_set = 0;
16154 unformat_input_t *input = vam->input;
16155 vl_api_one_pitr_set_locator_set_t *mp;
16160 /* Parse args required to build the message */
16161 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16163 if (unformat (input, "del"))
16165 else if (unformat (input, "locator-set %s", &ls_name))
16169 errmsg ("parse error '%U'", format_unformat_error, input);
16176 errmsg ("locator-set name not set!");
16180 M (ONE_PITR_SET_LOCATOR_SET, mp);
16182 mp->is_add = is_add;
16183 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16184 vec_free (ls_name);
16189 /* wait for reply */
16194 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16197 api_one_nsh_set_locator_set (vat_main_t * vam)
16199 u8 ls_name_set = 0;
16200 unformat_input_t *input = vam->input;
16201 vl_api_one_nsh_set_locator_set_t *mp;
16206 /* Parse args required to build the message */
16207 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16209 if (unformat (input, "del"))
16211 else if (unformat (input, "ls %s", &ls_name))
16215 errmsg ("parse error '%U'", format_unformat_error, input);
16220 if (!ls_name_set && is_add)
16222 errmsg ("locator-set name not set!");
16226 M (ONE_NSH_SET_LOCATOR_SET, mp);
16228 mp->is_add = is_add;
16229 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16230 vec_free (ls_name);
16235 /* wait for reply */
16241 api_show_one_pitr (vat_main_t * vam)
16243 vl_api_show_one_pitr_t *mp;
16246 if (!vam->json_output)
16248 print (vam->ofp, "%=20s", "lisp status:");
16251 M (SHOW_ONE_PITR, mp);
16255 /* Wait for a reply... */
16260 #define api_show_lisp_pitr api_show_one_pitr
16263 api_one_use_petr (vat_main_t * vam)
16265 unformat_input_t *input = vam->input;
16266 vl_api_one_use_petr_t *mp;
16271 clib_memset (&ip, 0, sizeof (ip));
16273 /* Parse args required to build the message */
16274 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16276 if (unformat (input, "disable"))
16279 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16282 ip_addr_version (&ip) = AF_IP4;
16285 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16288 ip_addr_version (&ip) = AF_IP6;
16292 errmsg ("parse error '%U'", format_unformat_error, input);
16297 M (ONE_USE_PETR, mp);
16299 mp->is_add = is_add;
16302 mp->is_ip4 = ip_addr_version (&ip) == AF_IP4 ? 1 : 0;
16304 clib_memcpy (mp->address, &ip, 4);
16306 clib_memcpy (mp->address, &ip, 16);
16312 /* wait for reply */
16317 #define api_lisp_use_petr api_one_use_petr
16320 api_show_one_nsh_mapping (vat_main_t * vam)
16322 vl_api_show_one_use_petr_t *mp;
16325 if (!vam->json_output)
16327 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16330 M (SHOW_ONE_NSH_MAPPING, mp);
16334 /* Wait for a reply... */
16340 api_show_one_use_petr (vat_main_t * vam)
16342 vl_api_show_one_use_petr_t *mp;
16345 if (!vam->json_output)
16347 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16350 M (SHOW_ONE_USE_PETR, mp);
16354 /* Wait for a reply... */
16359 #define api_show_lisp_use_petr api_show_one_use_petr
16362 * Add/delete mapping between vni and vrf
16365 api_one_eid_table_add_del_map (vat_main_t * vam)
16367 unformat_input_t *input = vam->input;
16368 vl_api_one_eid_table_add_del_map_t *mp;
16369 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16370 u32 vni, vrf, bd_index;
16373 /* Parse args required to build the message */
16374 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16376 if (unformat (input, "del"))
16378 else if (unformat (input, "vrf %d", &vrf))
16380 else if (unformat (input, "bd_index %d", &bd_index))
16382 else if (unformat (input, "vni %d", &vni))
16388 if (!vni_set || (!vrf_set && !bd_index_set))
16390 errmsg ("missing arguments!");
16394 if (vrf_set && bd_index_set)
16396 errmsg ("error: both vrf and bd entered!");
16400 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16402 mp->is_add = is_add;
16403 mp->vni = htonl (vni);
16404 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16405 mp->is_l2 = bd_index_set;
16410 /* wait for reply */
16415 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16418 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16420 u32 *action = va_arg (*args, u32 *);
16423 if (unformat (input, "%s", &s))
16425 if (!strcmp ((char *) s, "no-action"))
16427 else if (!strcmp ((char *) s, "natively-forward"))
16429 else if (!strcmp ((char *) s, "send-map-request"))
16431 else if (!strcmp ((char *) s, "drop"))
16435 clib_warning ("invalid action: '%s'", s);
16447 * Add/del remote mapping to/from ONE control plane
16449 * @param vam vpp API test context
16450 * @return return code
16453 api_one_add_del_remote_mapping (vat_main_t * vam)
16455 unformat_input_t *input = vam->input;
16456 vl_api_one_add_del_remote_mapping_t *mp;
16458 lisp_eid_vat_t _eid, *eid = &_eid;
16459 lisp_eid_vat_t _seid, *seid = &_seid;
16460 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16461 u32 action = ~0, p, w, data_len;
16462 ip4_address_t rloc4;
16463 ip6_address_t rloc6;
16464 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16467 clib_memset (&rloc, 0, sizeof (rloc));
16469 /* Parse args required to build the message */
16470 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16472 if (unformat (input, "del-all"))
16476 else if (unformat (input, "del"))
16480 else if (unformat (input, "add"))
16484 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16488 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16492 else if (unformat (input, "vni %d", &vni))
16496 else if (unformat (input, "p %d w %d", &p, &w))
16500 errmsg ("No RLOC configured for setting priority/weight!");
16503 curr_rloc->priority = p;
16504 curr_rloc->weight = w;
16506 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16509 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16510 vec_add1 (rlocs, rloc);
16511 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16513 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16516 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16517 vec_add1 (rlocs, rloc);
16518 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16520 else if (unformat (input, "action %U",
16521 unformat_negative_mapping_action, &action))
16527 clib_warning ("parse error '%U'", format_unformat_error, input);
16534 errmsg ("missing params!");
16538 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16540 errmsg ("no action set for negative map-reply!");
16544 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16546 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16547 mp->is_add = is_add;
16548 mp->vni = htonl (vni);
16549 mp->action = (u8) action;
16550 mp->is_src_dst = seid_set;
16551 mp->eid_len = eid->len;
16552 mp->seid_len = seid->len;
16553 mp->del_all = del_all;
16554 mp->eid_type = eid->type;
16555 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16556 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16558 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16559 clib_memcpy (mp->rlocs, rlocs, data_len);
16565 /* Wait for a reply... */
16570 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16573 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16574 * forwarding entries in data-plane accordingly.
16576 * @param vam vpp API test context
16577 * @return return code
16580 api_one_add_del_adjacency (vat_main_t * vam)
16582 unformat_input_t *input = vam->input;
16583 vl_api_one_add_del_adjacency_t *mp;
16585 ip4_address_t leid4, reid4;
16586 ip6_address_t leid6, reid6;
16587 u8 reid_mac[6] = { 0 };
16588 u8 leid_mac[6] = { 0 };
16589 u8 reid_type, leid_type;
16590 u32 leid_len = 0, reid_len = 0, len;
16594 leid_type = reid_type = (u8) ~ 0;
16596 /* Parse args required to build the message */
16597 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16599 if (unformat (input, "del"))
16603 else if (unformat (input, "add"))
16607 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
16610 reid_type = 0; /* ipv4 */
16613 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
16616 reid_type = 1; /* ipv6 */
16619 else if (unformat (input, "reid %U", unformat_ethernet_address,
16622 reid_type = 2; /* mac */
16624 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
16627 leid_type = 0; /* ipv4 */
16630 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
16633 leid_type = 1; /* ipv6 */
16636 else if (unformat (input, "leid %U", unformat_ethernet_address,
16639 leid_type = 2; /* mac */
16641 else if (unformat (input, "vni %d", &vni))
16647 errmsg ("parse error '%U'", format_unformat_error, input);
16652 if ((u8) ~ 0 == reid_type)
16654 errmsg ("missing params!");
16658 if (leid_type != reid_type)
16660 errmsg ("remote and local EIDs are of different types!");
16664 M (ONE_ADD_DEL_ADJACENCY, mp);
16665 mp->is_add = is_add;
16666 mp->vni = htonl (vni);
16667 mp->leid_len = leid_len;
16668 mp->reid_len = reid_len;
16669 mp->eid_type = reid_type;
16671 switch (mp->eid_type)
16674 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
16675 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
16678 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
16679 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
16682 clib_memcpy (mp->leid, leid_mac, 6);
16683 clib_memcpy (mp->reid, reid_mac, 6);
16686 errmsg ("unknown EID type %d!", mp->eid_type);
16693 /* Wait for a reply... */
16698 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16701 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16703 u32 *mode = va_arg (*args, u32 *);
16705 if (unformat (input, "lisp"))
16707 else if (unformat (input, "vxlan"))
16716 api_gpe_get_encap_mode (vat_main_t * vam)
16718 vl_api_gpe_get_encap_mode_t *mp;
16721 /* Construct the API message */
16722 M (GPE_GET_ENCAP_MODE, mp);
16727 /* Wait for a reply... */
16733 api_gpe_set_encap_mode (vat_main_t * vam)
16735 unformat_input_t *input = vam->input;
16736 vl_api_gpe_set_encap_mode_t *mp;
16740 /* Parse args required to build the message */
16741 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16743 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16749 /* Construct the API message */
16750 M (GPE_SET_ENCAP_MODE, mp);
16757 /* Wait for a reply... */
16763 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16765 unformat_input_t *input = vam->input;
16766 vl_api_gpe_add_del_iface_t *mp;
16767 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16768 u32 dp_table = 0, vni = 0;
16771 /* Parse args required to build the message */
16772 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16774 if (unformat (input, "up"))
16779 else if (unformat (input, "down"))
16784 else if (unformat (input, "table_id %d", &dp_table))
16788 else if (unformat (input, "bd_id %d", &dp_table))
16793 else if (unformat (input, "vni %d", &vni))
16801 if (action_set == 0)
16803 errmsg ("Action not set");
16806 if (dp_table_set == 0 || vni_set == 0)
16808 errmsg ("vni and dp_table must be set");
16812 /* Construct the API message */
16813 M (GPE_ADD_DEL_IFACE, mp);
16815 mp->is_add = is_add;
16816 mp->dp_table = clib_host_to_net_u32 (dp_table);
16818 mp->vni = clib_host_to_net_u32 (vni);
16823 /* Wait for a reply... */
16829 api_one_map_register_fallback_threshold (vat_main_t * vam)
16831 unformat_input_t *input = vam->input;
16832 vl_api_one_map_register_fallback_threshold_t *mp;
16837 /* Parse args required to build the message */
16838 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16840 if (unformat (input, "%u", &value))
16844 clib_warning ("parse error '%U'", format_unformat_error, input);
16851 errmsg ("fallback threshold value is missing!");
16855 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16856 mp->value = clib_host_to_net_u32 (value);
16861 /* Wait for a reply... */
16867 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16869 vl_api_show_one_map_register_fallback_threshold_t *mp;
16872 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16877 /* Wait for a reply... */
16883 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
16885 u32 *proto = va_arg (*args, u32 *);
16887 if (unformat (input, "udp"))
16889 else if (unformat (input, "api"))
16898 api_one_set_transport_protocol (vat_main_t * vam)
16900 unformat_input_t *input = vam->input;
16901 vl_api_one_set_transport_protocol_t *mp;
16906 /* Parse args required to build the message */
16907 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16909 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
16913 clib_warning ("parse error '%U'", format_unformat_error, input);
16920 errmsg ("Transport protocol missing!");
16924 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
16925 mp->protocol = (u8) protocol;
16930 /* Wait for a reply... */
16936 api_one_get_transport_protocol (vat_main_t * vam)
16938 vl_api_one_get_transport_protocol_t *mp;
16941 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
16946 /* Wait for a reply... */
16952 api_one_map_register_set_ttl (vat_main_t * vam)
16954 unformat_input_t *input = vam->input;
16955 vl_api_one_map_register_set_ttl_t *mp;
16960 /* Parse args required to build the message */
16961 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16963 if (unformat (input, "%u", &ttl))
16967 clib_warning ("parse error '%U'", format_unformat_error, input);
16974 errmsg ("TTL value missing!");
16978 M (ONE_MAP_REGISTER_SET_TTL, mp);
16979 mp->ttl = clib_host_to_net_u32 (ttl);
16984 /* Wait for a reply... */
16990 api_show_one_map_register_ttl (vat_main_t * vam)
16992 vl_api_show_one_map_register_ttl_t *mp;
16995 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17000 /* Wait for a reply... */
17006 * Add/del map request itr rlocs from ONE control plane and updates
17008 * @param vam vpp API test context
17009 * @return return code
17012 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17014 unformat_input_t *input = vam->input;
17015 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17016 u8 *locator_set_name = 0;
17017 u8 locator_set_name_set = 0;
17021 /* Parse args required to build the message */
17022 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17024 if (unformat (input, "del"))
17028 else if (unformat (input, "%_%v%_", &locator_set_name))
17030 locator_set_name_set = 1;
17034 clib_warning ("parse error '%U'", format_unformat_error, input);
17039 if (is_add && !locator_set_name_set)
17041 errmsg ("itr-rloc is not set!");
17045 if (is_add && vec_len (locator_set_name) > 64)
17047 errmsg ("itr-rloc locator-set name too long");
17048 vec_free (locator_set_name);
17052 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17053 mp->is_add = is_add;
17056 clib_memcpy (mp->locator_set_name, locator_set_name,
17057 vec_len (locator_set_name));
17061 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17063 vec_free (locator_set_name);
17068 /* Wait for a reply... */
17073 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17076 api_one_locator_dump (vat_main_t * vam)
17078 unformat_input_t *input = vam->input;
17079 vl_api_one_locator_dump_t *mp;
17080 vl_api_control_ping_t *mp_ping;
17081 u8 is_index_set = 0, is_name_set = 0;
17086 /* Parse args required to build the message */
17087 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17089 if (unformat (input, "ls_name %_%v%_", &ls_name))
17093 else if (unformat (input, "ls_index %d", &ls_index))
17099 errmsg ("parse error '%U'", format_unformat_error, input);
17104 if (!is_index_set && !is_name_set)
17106 errmsg ("error: expected one of index or name!");
17110 if (is_index_set && is_name_set)
17112 errmsg ("error: only one param expected!");
17116 if (vec_len (ls_name) > 62)
17118 errmsg ("error: locator set name too long!");
17122 if (!vam->json_output)
17124 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17127 M (ONE_LOCATOR_DUMP, mp);
17128 mp->is_index_set = is_index_set;
17131 mp->ls_index = clib_host_to_net_u32 (ls_index);
17134 vec_add1 (ls_name, 0);
17135 strncpy ((char *) mp->ls_name, (char *) ls_name,
17136 sizeof (mp->ls_name) - 1);
17142 /* Use a control ping for synchronization */
17143 MPING (CONTROL_PING, mp_ping);
17146 /* Wait for a reply... */
17151 #define api_lisp_locator_dump api_one_locator_dump
17154 api_one_locator_set_dump (vat_main_t * vam)
17156 vl_api_one_locator_set_dump_t *mp;
17157 vl_api_control_ping_t *mp_ping;
17158 unformat_input_t *input = vam->input;
17162 /* Parse args required to build the message */
17163 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17165 if (unformat (input, "local"))
17169 else if (unformat (input, "remote"))
17175 errmsg ("parse error '%U'", format_unformat_error, input);
17180 if (!vam->json_output)
17182 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17185 M (ONE_LOCATOR_SET_DUMP, mp);
17187 mp->filter = filter;
17192 /* Use a control ping for synchronization */
17193 MPING (CONTROL_PING, mp_ping);
17196 /* Wait for a reply... */
17201 #define api_lisp_locator_set_dump api_one_locator_set_dump
17204 api_one_eid_table_map_dump (vat_main_t * vam)
17208 unformat_input_t *input = vam->input;
17209 vl_api_one_eid_table_map_dump_t *mp;
17210 vl_api_control_ping_t *mp_ping;
17213 /* Parse args required to build the message */
17214 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17216 if (unformat (input, "l2"))
17221 else if (unformat (input, "l3"))
17228 errmsg ("parse error '%U'", format_unformat_error, input);
17235 errmsg ("expected one of 'l2' or 'l3' parameter!");
17239 if (!vam->json_output)
17241 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17244 M (ONE_EID_TABLE_MAP_DUMP, mp);
17250 /* Use a control ping for synchronization */
17251 MPING (CONTROL_PING, mp_ping);
17254 /* Wait for a reply... */
17259 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17262 api_one_eid_table_vni_dump (vat_main_t * vam)
17264 vl_api_one_eid_table_vni_dump_t *mp;
17265 vl_api_control_ping_t *mp_ping;
17268 if (!vam->json_output)
17270 print (vam->ofp, "VNI");
17273 M (ONE_EID_TABLE_VNI_DUMP, mp);
17278 /* Use a control ping for synchronization */
17279 MPING (CONTROL_PING, mp_ping);
17282 /* Wait for a reply... */
17287 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17290 api_one_eid_table_dump (vat_main_t * vam)
17292 unformat_input_t *i = vam->input;
17293 vl_api_one_eid_table_dump_t *mp;
17294 vl_api_control_ping_t *mp_ping;
17295 struct in_addr ip4;
17296 struct in6_addr ip6;
17298 u8 eid_type = ~0, eid_set = 0;
17299 u32 prefix_length = ~0, t, vni = 0;
17302 lisp_nsh_api_t nsh;
17304 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17306 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17312 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17318 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17323 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17328 else if (unformat (i, "vni %d", &t))
17332 else if (unformat (i, "local"))
17336 else if (unformat (i, "remote"))
17342 errmsg ("parse error '%U'", format_unformat_error, i);
17347 if (!vam->json_output)
17349 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17350 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17353 M (ONE_EID_TABLE_DUMP, mp);
17355 mp->filter = filter;
17359 mp->vni = htonl (vni);
17360 mp->eid_type = eid_type;
17364 mp->prefix_length = prefix_length;
17365 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17368 mp->prefix_length = prefix_length;
17369 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17372 clib_memcpy (mp->eid, mac, sizeof (mac));
17375 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17378 errmsg ("unknown EID type %d!", eid_type);
17386 /* Use a control ping for synchronization */
17387 MPING (CONTROL_PING, mp_ping);
17390 /* Wait for a reply... */
17395 #define api_lisp_eid_table_dump api_one_eid_table_dump
17398 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17400 unformat_input_t *i = vam->input;
17401 vl_api_gpe_fwd_entries_get_t *mp;
17406 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17408 if (unformat (i, "vni %d", &vni))
17414 errmsg ("parse error '%U'", format_unformat_error, i);
17421 errmsg ("vni not set!");
17425 if (!vam->json_output)
17427 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17431 M (GPE_FWD_ENTRIES_GET, mp);
17432 mp->vni = clib_host_to_net_u32 (vni);
17437 /* Wait for a reply... */
17442 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17443 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17444 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17445 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17446 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17447 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17448 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17449 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17452 api_one_adjacencies_get (vat_main_t * vam)
17454 unformat_input_t *i = vam->input;
17455 vl_api_one_adjacencies_get_t *mp;
17460 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17462 if (unformat (i, "vni %d", &vni))
17468 errmsg ("parse error '%U'", format_unformat_error, i);
17475 errmsg ("vni not set!");
17479 if (!vam->json_output)
17481 print (vam->ofp, "%s %40s", "leid", "reid");
17484 M (ONE_ADJACENCIES_GET, mp);
17485 mp->vni = clib_host_to_net_u32 (vni);
17490 /* Wait for a reply... */
17495 #define api_lisp_adjacencies_get api_one_adjacencies_get
17498 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17500 unformat_input_t *i = vam->input;
17501 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17503 u8 ip_family_set = 0, is_ip4 = 1;
17505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17507 if (unformat (i, "ip4"))
17512 else if (unformat (i, "ip6"))
17519 errmsg ("parse error '%U'", format_unformat_error, i);
17524 if (!ip_family_set)
17526 errmsg ("ip family not set!");
17530 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17531 mp->is_ip4 = is_ip4;
17536 /* Wait for a reply... */
17542 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17544 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17547 if (!vam->json_output)
17549 print (vam->ofp, "VNIs");
17552 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17557 /* Wait for a reply... */
17563 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17565 unformat_input_t *i = vam->input;
17566 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17568 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17569 struct in_addr ip4;
17570 struct in6_addr ip6;
17571 u32 table_id = 0, nh_sw_if_index = ~0;
17573 clib_memset (&ip4, 0, sizeof (ip4));
17574 clib_memset (&ip6, 0, sizeof (ip6));
17576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17578 if (unformat (i, "del"))
17580 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17581 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17586 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17587 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17592 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17596 nh_sw_if_index = ~0;
17598 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
17602 nh_sw_if_index = ~0;
17604 else if (unformat (i, "table %d", &table_id))
17608 errmsg ("parse error '%U'", format_unformat_error, i);
17615 errmsg ("nh addr not set!");
17619 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
17620 mp->is_add = is_add;
17621 mp->table_id = clib_host_to_net_u32 (table_id);
17622 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
17623 mp->is_ip4 = is_ip4;
17625 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
17627 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
17632 /* Wait for a reply... */
17638 api_one_map_server_dump (vat_main_t * vam)
17640 vl_api_one_map_server_dump_t *mp;
17641 vl_api_control_ping_t *mp_ping;
17644 if (!vam->json_output)
17646 print (vam->ofp, "%=20s", "Map server");
17649 M (ONE_MAP_SERVER_DUMP, mp);
17653 /* Use a control ping for synchronization */
17654 MPING (CONTROL_PING, mp_ping);
17657 /* Wait for a reply... */
17662 #define api_lisp_map_server_dump api_one_map_server_dump
17665 api_one_map_resolver_dump (vat_main_t * vam)
17667 vl_api_one_map_resolver_dump_t *mp;
17668 vl_api_control_ping_t *mp_ping;
17671 if (!vam->json_output)
17673 print (vam->ofp, "%=20s", "Map resolver");
17676 M (ONE_MAP_RESOLVER_DUMP, mp);
17680 /* Use a control ping for synchronization */
17681 MPING (CONTROL_PING, mp_ping);
17684 /* Wait for a reply... */
17689 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
17692 api_one_stats_flush (vat_main_t * vam)
17694 vl_api_one_stats_flush_t *mp;
17697 M (ONE_STATS_FLUSH, mp);
17704 api_one_stats_dump (vat_main_t * vam)
17706 vl_api_one_stats_dump_t *mp;
17707 vl_api_control_ping_t *mp_ping;
17710 M (ONE_STATS_DUMP, mp);
17714 /* Use a control ping for synchronization */
17715 MPING (CONTROL_PING, mp_ping);
17718 /* Wait for a reply... */
17724 api_show_one_status (vat_main_t * vam)
17726 vl_api_show_one_status_t *mp;
17729 if (!vam->json_output)
17731 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17734 M (SHOW_ONE_STATUS, mp);
17737 /* Wait for a reply... */
17742 #define api_show_lisp_status api_show_one_status
17745 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17747 vl_api_gpe_fwd_entry_path_dump_t *mp;
17748 vl_api_control_ping_t *mp_ping;
17749 unformat_input_t *i = vam->input;
17750 u32 fwd_entry_index = ~0;
17753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17755 if (unformat (i, "index %d", &fwd_entry_index))
17761 if (~0 == fwd_entry_index)
17763 errmsg ("no index specified!");
17767 if (!vam->json_output)
17769 print (vam->ofp, "first line");
17772 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17776 /* Use a control ping for synchronization */
17777 MPING (CONTROL_PING, mp_ping);
17780 /* Wait for a reply... */
17786 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17788 vl_api_one_get_map_request_itr_rlocs_t *mp;
17791 if (!vam->json_output)
17793 print (vam->ofp, "%=20s", "itr-rlocs:");
17796 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17799 /* Wait for a reply... */
17804 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17807 api_af_packet_create (vat_main_t * vam)
17809 unformat_input_t *i = vam->input;
17810 vl_api_af_packet_create_t *mp;
17811 u8 *host_if_name = 0;
17813 u8 random_hw_addr = 1;
17816 clib_memset (hw_addr, 0, sizeof (hw_addr));
17818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17820 if (unformat (i, "name %s", &host_if_name))
17821 vec_add1 (host_if_name, 0);
17822 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17823 random_hw_addr = 0;
17828 if (!vec_len (host_if_name))
17830 errmsg ("host-interface name must be specified");
17834 if (vec_len (host_if_name) > 64)
17836 errmsg ("host-interface name too long");
17840 M (AF_PACKET_CREATE, mp);
17842 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17843 clib_memcpy (mp->hw_addr, hw_addr, 6);
17844 mp->use_random_hw_addr = random_hw_addr;
17845 vec_free (host_if_name);
17853 fprintf (vam->ofp ? vam->ofp : stderr,
17854 " new sw_if_index = %d\n", vam->sw_if_index);
17861 api_af_packet_delete (vat_main_t * vam)
17863 unformat_input_t *i = vam->input;
17864 vl_api_af_packet_delete_t *mp;
17865 u8 *host_if_name = 0;
17868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17870 if (unformat (i, "name %s", &host_if_name))
17871 vec_add1 (host_if_name, 0);
17876 if (!vec_len (host_if_name))
17878 errmsg ("host-interface name must be specified");
17882 if (vec_len (host_if_name) > 64)
17884 errmsg ("host-interface name too long");
17888 M (AF_PACKET_DELETE, mp);
17890 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17891 vec_free (host_if_name);
17898 static void vl_api_af_packet_details_t_handler
17899 (vl_api_af_packet_details_t * mp)
17901 vat_main_t *vam = &vat_main;
17903 print (vam->ofp, "%-16s %d",
17904 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
17907 static void vl_api_af_packet_details_t_handler_json
17908 (vl_api_af_packet_details_t * mp)
17910 vat_main_t *vam = &vat_main;
17911 vat_json_node_t *node = NULL;
17913 if (VAT_JSON_ARRAY != vam->json_tree.type)
17915 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17916 vat_json_init_array (&vam->json_tree);
17918 node = vat_json_array_add (&vam->json_tree);
17920 vat_json_init_object (node);
17921 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17922 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
17926 api_af_packet_dump (vat_main_t * vam)
17928 vl_api_af_packet_dump_t *mp;
17929 vl_api_control_ping_t *mp_ping;
17932 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
17933 /* Get list of tap interfaces */
17934 M (AF_PACKET_DUMP, mp);
17937 /* Use a control ping for synchronization */
17938 MPING (CONTROL_PING, mp_ping);
17946 api_policer_add_del (vat_main_t * vam)
17948 unformat_input_t *i = vam->input;
17949 vl_api_policer_add_del_t *mp;
17959 u8 color_aware = 0;
17960 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17963 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17964 conform_action.dscp = 0;
17965 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17966 exceed_action.dscp = 0;
17967 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17968 violate_action.dscp = 0;
17970 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17972 if (unformat (i, "del"))
17974 else if (unformat (i, "name %s", &name))
17975 vec_add1 (name, 0);
17976 else if (unformat (i, "cir %u", &cir))
17978 else if (unformat (i, "eir %u", &eir))
17980 else if (unformat (i, "cb %u", &cb))
17982 else if (unformat (i, "eb %u", &eb))
17984 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17987 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17990 else if (unformat (i, "type %U", unformat_policer_type, &type))
17992 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17995 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17998 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18001 else if (unformat (i, "color-aware"))
18007 if (!vec_len (name))
18009 errmsg ("policer name must be specified");
18013 if (vec_len (name) > 64)
18015 errmsg ("policer name too long");
18019 M (POLICER_ADD_DEL, mp);
18021 clib_memcpy (mp->name, name, vec_len (name));
18023 mp->is_add = is_add;
18024 mp->cir = ntohl (cir);
18025 mp->eir = ntohl (eir);
18026 mp->cb = clib_net_to_host_u64 (cb);
18027 mp->eb = clib_net_to_host_u64 (eb);
18028 mp->rate_type = rate_type;
18029 mp->round_type = round_type;
18031 mp->conform_action_type = conform_action.action_type;
18032 mp->conform_dscp = conform_action.dscp;
18033 mp->exceed_action_type = exceed_action.action_type;
18034 mp->exceed_dscp = exceed_action.dscp;
18035 mp->violate_action_type = violate_action.action_type;
18036 mp->violate_dscp = violate_action.dscp;
18037 mp->color_aware = color_aware;
18045 api_policer_dump (vat_main_t * vam)
18047 unformat_input_t *i = vam->input;
18048 vl_api_policer_dump_t *mp;
18049 vl_api_control_ping_t *mp_ping;
18050 u8 *match_name = 0;
18051 u8 match_name_valid = 0;
18054 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18056 if (unformat (i, "name %s", &match_name))
18058 vec_add1 (match_name, 0);
18059 match_name_valid = 1;
18065 M (POLICER_DUMP, mp);
18066 mp->match_name_valid = match_name_valid;
18067 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18068 vec_free (match_name);
18072 /* Use a control ping for synchronization */
18073 MPING (CONTROL_PING, mp_ping);
18076 /* Wait for a reply... */
18082 api_policer_classify_set_interface (vat_main_t * vam)
18084 unformat_input_t *i = vam->input;
18085 vl_api_policer_classify_set_interface_t *mp;
18087 int sw_if_index_set;
18088 u32 ip4_table_index = ~0;
18089 u32 ip6_table_index = ~0;
18090 u32 l2_table_index = ~0;
18094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18096 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18097 sw_if_index_set = 1;
18098 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18099 sw_if_index_set = 1;
18100 else if (unformat (i, "del"))
18102 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18104 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18106 else if (unformat (i, "l2-table %d", &l2_table_index))
18110 clib_warning ("parse error '%U'", format_unformat_error, i);
18115 if (sw_if_index_set == 0)
18117 errmsg ("missing interface name or sw_if_index");
18121 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18123 mp->sw_if_index = ntohl (sw_if_index);
18124 mp->ip4_table_index = ntohl (ip4_table_index);
18125 mp->ip6_table_index = ntohl (ip6_table_index);
18126 mp->l2_table_index = ntohl (l2_table_index);
18127 mp->is_add = is_add;
18135 api_policer_classify_dump (vat_main_t * vam)
18137 unformat_input_t *i = vam->input;
18138 vl_api_policer_classify_dump_t *mp;
18139 vl_api_control_ping_t *mp_ping;
18140 u8 type = POLICER_CLASSIFY_N_TABLES;
18143 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18147 errmsg ("classify table type must be specified");
18151 if (!vam->json_output)
18153 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18156 M (POLICER_CLASSIFY_DUMP, mp);
18161 /* Use a control ping for synchronization */
18162 MPING (CONTROL_PING, mp_ping);
18165 /* Wait for a reply... */
18171 api_netmap_create (vat_main_t * vam)
18173 unformat_input_t *i = vam->input;
18174 vl_api_netmap_create_t *mp;
18177 u8 random_hw_addr = 1;
18182 clib_memset (hw_addr, 0, sizeof (hw_addr));
18184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18186 if (unformat (i, "name %s", &if_name))
18187 vec_add1 (if_name, 0);
18188 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18189 random_hw_addr = 0;
18190 else if (unformat (i, "pipe"))
18192 else if (unformat (i, "master"))
18194 else if (unformat (i, "slave"))
18200 if (!vec_len (if_name))
18202 errmsg ("interface name must be specified");
18206 if (vec_len (if_name) > 64)
18208 errmsg ("interface name too long");
18212 M (NETMAP_CREATE, mp);
18214 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18215 clib_memcpy (mp->hw_addr, hw_addr, 6);
18216 mp->use_random_hw_addr = random_hw_addr;
18217 mp->is_pipe = is_pipe;
18218 mp->is_master = is_master;
18219 vec_free (if_name);
18227 api_netmap_delete (vat_main_t * vam)
18229 unformat_input_t *i = vam->input;
18230 vl_api_netmap_delete_t *mp;
18234 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18236 if (unformat (i, "name %s", &if_name))
18237 vec_add1 (if_name, 0);
18242 if (!vec_len (if_name))
18244 errmsg ("interface name must be specified");
18248 if (vec_len (if_name) > 64)
18250 errmsg ("interface name too long");
18254 M (NETMAP_DELETE, mp);
18256 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18257 vec_free (if_name);
18265 format_fib_api_path_nh_proto (u8 * s, va_list * args)
18267 vl_api_fib_path_nh_proto_t proto =
18268 va_arg (*args, vl_api_fib_path_nh_proto_t);
18272 case FIB_API_PATH_NH_PROTO_IP4:
18273 s = format (s, "ip4");
18275 case FIB_API_PATH_NH_PROTO_IP6:
18276 s = format (s, "ip6");
18278 case FIB_API_PATH_NH_PROTO_MPLS:
18279 s = format (s, "mpls");
18281 case FIB_API_PATH_NH_PROTO_BIER:
18282 s = format (s, "bier");
18284 case FIB_API_PATH_NH_PROTO_ETHERNET:
18285 s = format (s, "ethernet");
18293 format_vl_api_ip_address_union (u8 * s, va_list * args)
18295 vl_api_address_family_t af = va_arg (*args, vl_api_address_family_t);
18296 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
18301 s = format (s, "%U", format_ip4_address, u->ip4);
18304 s = format (s, "%U", format_ip6_address, u->ip6);
18311 format_vl_api_fib_path_type (u8 * s, va_list * args)
18313 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
18317 case FIB_API_PATH_TYPE_NORMAL:
18318 s = format (s, "normal");
18320 case FIB_API_PATH_TYPE_LOCAL:
18321 s = format (s, "local");
18323 case FIB_API_PATH_TYPE_DROP:
18324 s = format (s, "drop");
18326 case FIB_API_PATH_TYPE_UDP_ENCAP:
18327 s = format (s, "udp-encap");
18329 case FIB_API_PATH_TYPE_BIER_IMP:
18330 s = format (s, "bier-imp");
18332 case FIB_API_PATH_TYPE_ICMP_UNREACH:
18333 s = format (s, "unreach");
18335 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
18336 s = format (s, "prohibit");
18338 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
18339 s = format (s, "src-lookup");
18341 case FIB_API_PATH_TYPE_DVR:
18342 s = format (s, "dvr");
18344 case FIB_API_PATH_TYPE_INTERFACE_RX:
18345 s = format (s, "interface-rx");
18347 case FIB_API_PATH_TYPE_CLASSIFY:
18348 s = format (s, "classify");
18356 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
18359 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
18360 ntohl (fp->weight), ntohl (fp->sw_if_index),
18361 format_vl_api_fib_path_type, fp->type,
18362 format_fib_api_path_nh_proto, fp->proto,
18363 format_vl_api_ip_address_union, &fp->nh.address);
18367 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18368 vl_api_fib_path_t * fp)
18370 struct in_addr ip4;
18371 struct in6_addr ip6;
18373 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18374 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18375 vat_json_object_add_uint (node, "type", fp->type);
18376 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
18377 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18379 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
18380 vat_json_object_add_ip4 (node, "next_hop", ip4);
18382 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18384 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
18385 vat_json_object_add_ip6 (node, "next_hop", ip6);
18390 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18392 vat_main_t *vam = &vat_main;
18393 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18394 vl_api_fib_path_t *fp;
18397 print (vam->ofp, "sw_if_index %d via:",
18398 ntohl (mp->mt_tunnel.mt_sw_if_index));
18399 fp = mp->mt_tunnel.mt_paths;
18400 for (i = 0; i < count; i++)
18402 vl_api_fib_path_print (vam, fp);
18406 print (vam->ofp, "");
18409 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18410 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18413 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18415 vat_main_t *vam = &vat_main;
18416 vat_json_node_t *node = NULL;
18417 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18418 vl_api_fib_path_t *fp;
18421 if (VAT_JSON_ARRAY != vam->json_tree.type)
18423 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18424 vat_json_init_array (&vam->json_tree);
18426 node = vat_json_array_add (&vam->json_tree);
18428 vat_json_init_object (node);
18429 vat_json_object_add_uint (node, "sw_if_index",
18430 ntohl (mp->mt_tunnel.mt_sw_if_index));
18432 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
18434 fp = mp->mt_tunnel.mt_paths;
18435 for (i = 0; i < count; i++)
18437 vl_api_mpls_fib_path_json_print (node, fp);
18443 api_mpls_tunnel_dump (vat_main_t * vam)
18445 vl_api_mpls_tunnel_dump_t *mp;
18446 vl_api_control_ping_t *mp_ping;
18449 M (MPLS_TUNNEL_DUMP, mp);
18453 /* Use a control ping for synchronization */
18454 MPING (CONTROL_PING, mp_ping);
18461 #define vl_api_mpls_table_details_t_endian vl_noop_handler
18462 #define vl_api_mpls_table_details_t_print vl_noop_handler
18466 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
18468 vat_main_t *vam = &vat_main;
18470 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
18473 static void vl_api_mpls_table_details_t_handler_json
18474 (vl_api_mpls_table_details_t * mp)
18476 vat_main_t *vam = &vat_main;
18477 vat_json_node_t *node = NULL;
18479 if (VAT_JSON_ARRAY != vam->json_tree.type)
18481 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18482 vat_json_init_array (&vam->json_tree);
18484 node = vat_json_array_add (&vam->json_tree);
18486 vat_json_init_object (node);
18487 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
18491 api_mpls_table_dump (vat_main_t * vam)
18493 vl_api_mpls_table_dump_t *mp;
18494 vl_api_control_ping_t *mp_ping;
18497 M (MPLS_TABLE_DUMP, mp);
18500 /* Use a control ping for synchronization */
18501 MPING (CONTROL_PING, mp_ping);
18508 #define vl_api_mpls_route_details_t_endian vl_noop_handler
18509 #define vl_api_mpls_route_details_t_print vl_noop_handler
18512 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
18514 vat_main_t *vam = &vat_main;
18515 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
18516 vl_api_fib_path_t *fp;
18520 "table-id %d, label %u, ess_bit %u",
18521 ntohl (mp->mr_route.mr_table_id),
18522 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
18523 fp = mp->mr_route.mr_paths;
18524 for (i = 0; i < count; i++)
18526 vl_api_fib_path_print (vam, fp);
18531 static void vl_api_mpls_route_details_t_handler_json
18532 (vl_api_mpls_route_details_t * mp)
18534 vat_main_t *vam = &vat_main;
18535 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
18536 vat_json_node_t *node = NULL;
18537 vl_api_fib_path_t *fp;
18540 if (VAT_JSON_ARRAY != vam->json_tree.type)
18542 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18543 vat_json_init_array (&vam->json_tree);
18545 node = vat_json_array_add (&vam->json_tree);
18547 vat_json_init_object (node);
18548 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
18549 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
18550 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
18551 vat_json_object_add_uint (node, "path_count", count);
18552 fp = mp->mr_route.mr_paths;
18553 for (i = 0; i < count; i++)
18555 vl_api_mpls_fib_path_json_print (node, fp);
18561 api_mpls_route_dump (vat_main_t * vam)
18563 unformat_input_t *input = vam->input;
18564 vl_api_mpls_route_dump_t *mp;
18565 vl_api_control_ping_t *mp_ping;
18569 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18571 if (unformat (input, "table_id %d", &table_id))
18576 if (table_id == ~0)
18578 errmsg ("missing table id");
18582 M (MPLS_ROUTE_DUMP, mp);
18584 mp->table.mt_table_id = ntohl (table_id);
18587 /* Use a control ping for synchronization */
18588 MPING (CONTROL_PING, mp_ping);
18595 #define vl_api_ip_table_details_t_endian vl_noop_handler
18596 #define vl_api_ip_table_details_t_print vl_noop_handler
18599 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
18601 vat_main_t *vam = &vat_main;
18604 "%s; table-id %d, prefix %U/%d",
18605 mp->table.name, ntohl (mp->table.table_id));
18609 static void vl_api_ip_table_details_t_handler_json
18610 (vl_api_ip_table_details_t * mp)
18612 vat_main_t *vam = &vat_main;
18613 vat_json_node_t *node = NULL;
18615 if (VAT_JSON_ARRAY != vam->json_tree.type)
18617 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18618 vat_json_init_array (&vam->json_tree);
18620 node = vat_json_array_add (&vam->json_tree);
18622 vat_json_init_object (node);
18623 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
18627 api_ip_table_dump (vat_main_t * vam)
18629 vl_api_ip_table_dump_t *mp;
18630 vl_api_control_ping_t *mp_ping;
18633 M (IP_TABLE_DUMP, mp);
18636 /* Use a control ping for synchronization */
18637 MPING (CONTROL_PING, mp_ping);
18645 api_ip_mtable_dump (vat_main_t * vam)
18647 vl_api_ip_mtable_dump_t *mp;
18648 vl_api_control_ping_t *mp_ping;
18651 M (IP_MTABLE_DUMP, mp);
18654 /* Use a control ping for synchronization */
18655 MPING (CONTROL_PING, mp_ping);
18663 api_ip_mroute_dump (vat_main_t * vam)
18665 unformat_input_t *input = vam->input;
18666 vl_api_control_ping_t *mp_ping;
18667 vl_api_ip_mroute_dump_t *mp;
18672 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18674 if (unformat (input, "table_id %d", &table_id))
18676 else if (unformat (input, "ip6"))
18678 else if (unformat (input, "ip4"))
18683 if (table_id == ~0)
18685 errmsg ("missing table id");
18689 M (IP_MROUTE_DUMP, mp);
18690 mp->table.table_id = table_id;
18691 mp->table.is_ip6 = is_ip6;
18694 /* Use a control ping for synchronization */
18695 MPING (CONTROL_PING, mp_ping);
18702 static void vl_api_ip_neighbor_details_t_handler
18703 (vl_api_ip_neighbor_details_t * mp)
18705 vat_main_t *vam = &vat_main;
18707 print (vam->ofp, "%c %U %U",
18708 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
18709 format_vl_api_mac_address, &mp->neighbor.mac_address,
18710 format_vl_api_address, &mp->neighbor.ip_address);
18713 static void vl_api_ip_neighbor_details_t_handler_json
18714 (vl_api_ip_neighbor_details_t * mp)
18717 vat_main_t *vam = &vat_main;
18718 vat_json_node_t *node;
18720 if (VAT_JSON_ARRAY != vam->json_tree.type)
18722 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18723 vat_json_init_array (&vam->json_tree);
18725 node = vat_json_array_add (&vam->json_tree);
18727 vat_json_init_object (node);
18728 vat_json_object_add_string_copy
18730 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
18731 (u8 *) "static" : (u8 *) "dynamic"));
18733 vat_json_object_add_string_copy (node, "link_layer",
18734 format (0, "%U", format_vl_api_mac_address,
18735 &mp->neighbor.mac_address));
18736 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
18740 api_ip_neighbor_dump (vat_main_t * vam)
18742 unformat_input_t *i = vam->input;
18743 vl_api_ip_neighbor_dump_t *mp;
18744 vl_api_control_ping_t *mp_ping;
18746 u32 sw_if_index = ~0;
18749 /* Parse args required to build the message */
18750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18752 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18754 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18756 else if (unformat (i, "ip6"))
18762 if (sw_if_index == ~0)
18764 errmsg ("missing interface name or sw_if_index");
18768 M (IP_NEIGHBOR_DUMP, mp);
18769 mp->is_ipv6 = (u8) is_ipv6;
18770 mp->sw_if_index = ntohl (sw_if_index);
18773 /* Use a control ping for synchronization */
18774 MPING (CONTROL_PING, mp_ping);
18781 #define vl_api_ip_route_details_t_endian vl_noop_handler
18782 #define vl_api_ip_route_details_t_print vl_noop_handler
18785 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
18787 vat_main_t *vam = &vat_main;
18788 u8 count = mp->route.n_paths;
18789 vl_api_fib_path_t *fp;
18793 "table-id %d, prefix %U/%d",
18794 ntohl (mp->route.table_id),
18795 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
18796 for (i = 0; i < count; i++)
18798 fp = &mp->route.paths[i];
18800 vl_api_fib_path_print (vam, fp);
18805 static void vl_api_ip_route_details_t_handler_json
18806 (vl_api_ip_route_details_t * mp)
18808 vat_main_t *vam = &vat_main;
18809 u8 count = mp->route.n_paths;
18810 vat_json_node_t *node = NULL;
18811 struct in_addr ip4;
18812 struct in6_addr ip6;
18813 vl_api_fib_path_t *fp;
18816 if (VAT_JSON_ARRAY != vam->json_tree.type)
18818 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18819 vat_json_init_array (&vam->json_tree);
18821 node = vat_json_array_add (&vam->json_tree);
18823 vat_json_init_object (node);
18824 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
18825 if (ADDRESS_IP6 == mp->route.prefix.address.af)
18827 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
18828 vat_json_object_add_ip6 (node, "prefix", ip6);
18832 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
18833 vat_json_object_add_ip4 (node, "prefix", ip4);
18835 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
18836 vat_json_object_add_uint (node, "path_count", count);
18837 for (i = 0; i < count; i++)
18839 fp = &mp->route.paths[i];
18840 vl_api_mpls_fib_path_json_print (node, fp);
18845 api_ip_route_dump (vat_main_t * vam)
18847 unformat_input_t *input = vam->input;
18848 vl_api_ip_route_dump_t *mp;
18849 vl_api_control_ping_t *mp_ping;
18855 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18857 if (unformat (input, "table_id %d", &table_id))
18859 else if (unformat (input, "ip6"))
18861 else if (unformat (input, "ip4"))
18866 if (table_id == ~0)
18868 errmsg ("missing table id");
18872 M (IP_ROUTE_DUMP, mp);
18874 mp->table.table_id = table_id;
18875 mp->table.is_ip6 = is_ip6;
18879 /* Use a control ping for synchronization */
18880 MPING (CONTROL_PING, mp_ping);
18888 api_classify_table_ids (vat_main_t * vam)
18890 vl_api_classify_table_ids_t *mp;
18893 /* Construct the API message */
18894 M (CLASSIFY_TABLE_IDS, mp);
18903 api_classify_table_by_interface (vat_main_t * vam)
18905 unformat_input_t *input = vam->input;
18906 vl_api_classify_table_by_interface_t *mp;
18908 u32 sw_if_index = ~0;
18910 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18912 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18914 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18919 if (sw_if_index == ~0)
18921 errmsg ("missing interface name or sw_if_index");
18925 /* Construct the API message */
18926 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18928 mp->sw_if_index = ntohl (sw_if_index);
18936 api_classify_table_info (vat_main_t * vam)
18938 unformat_input_t *input = vam->input;
18939 vl_api_classify_table_info_t *mp;
18943 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18945 if (unformat (input, "table_id %d", &table_id))
18950 if (table_id == ~0)
18952 errmsg ("missing table id");
18956 /* Construct the API message */
18957 M (CLASSIFY_TABLE_INFO, mp);
18959 mp->table_id = ntohl (table_id);
18967 api_classify_session_dump (vat_main_t * vam)
18969 unformat_input_t *input = vam->input;
18970 vl_api_classify_session_dump_t *mp;
18971 vl_api_control_ping_t *mp_ping;
18975 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18977 if (unformat (input, "table_id %d", &table_id))
18982 if (table_id == ~0)
18984 errmsg ("missing table id");
18988 /* Construct the API message */
18989 M (CLASSIFY_SESSION_DUMP, mp);
18991 mp->table_id = ntohl (table_id);
18994 /* Use a control ping for synchronization */
18995 MPING (CONTROL_PING, mp_ping);
19003 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19005 vat_main_t *vam = &vat_main;
19007 print (vam->ofp, "collector_address %U, collector_port %d, "
19008 "src_address %U, vrf_id %d, path_mtu %u, "
19009 "template_interval %u, udp_checksum %d",
19010 format_ip4_address, mp->collector_address,
19011 ntohs (mp->collector_port),
19012 format_ip4_address, mp->src_address,
19013 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19014 ntohl (mp->template_interval), mp->udp_checksum);
19017 vam->result_ready = 1;
19021 vl_api_ipfix_exporter_details_t_handler_json
19022 (vl_api_ipfix_exporter_details_t * mp)
19024 vat_main_t *vam = &vat_main;
19025 vat_json_node_t node;
19026 struct in_addr collector_address;
19027 struct in_addr src_address;
19029 vat_json_init_object (&node);
19030 clib_memcpy (&collector_address, &mp->collector_address,
19031 sizeof (collector_address));
19032 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19033 vat_json_object_add_uint (&node, "collector_port",
19034 ntohs (mp->collector_port));
19035 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19036 vat_json_object_add_ip4 (&node, "src_address", src_address);
19037 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19038 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19039 vat_json_object_add_uint (&node, "template_interval",
19040 ntohl (mp->template_interval));
19041 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19043 vat_json_print (vam->ofp, &node);
19044 vat_json_free (&node);
19046 vam->result_ready = 1;
19050 api_ipfix_exporter_dump (vat_main_t * vam)
19052 vl_api_ipfix_exporter_dump_t *mp;
19055 /* Construct the API message */
19056 M (IPFIX_EXPORTER_DUMP, mp);
19065 api_ipfix_classify_stream_dump (vat_main_t * vam)
19067 vl_api_ipfix_classify_stream_dump_t *mp;
19070 /* Construct the API message */
19071 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19082 vl_api_ipfix_classify_stream_details_t_handler
19083 (vl_api_ipfix_classify_stream_details_t * mp)
19085 vat_main_t *vam = &vat_main;
19086 print (vam->ofp, "domain_id %d, src_port %d",
19087 ntohl (mp->domain_id), ntohs (mp->src_port));
19089 vam->result_ready = 1;
19093 vl_api_ipfix_classify_stream_details_t_handler_json
19094 (vl_api_ipfix_classify_stream_details_t * mp)
19096 vat_main_t *vam = &vat_main;
19097 vat_json_node_t node;
19099 vat_json_init_object (&node);
19100 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19101 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19103 vat_json_print (vam->ofp, &node);
19104 vat_json_free (&node);
19106 vam->result_ready = 1;
19110 api_ipfix_classify_table_dump (vat_main_t * vam)
19112 vl_api_ipfix_classify_table_dump_t *mp;
19113 vl_api_control_ping_t *mp_ping;
19116 if (!vam->json_output)
19118 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19119 "transport_protocol");
19122 /* Construct the API message */
19123 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19128 /* Use a control ping for synchronization */
19129 MPING (CONTROL_PING, mp_ping);
19137 vl_api_ipfix_classify_table_details_t_handler
19138 (vl_api_ipfix_classify_table_details_t * mp)
19140 vat_main_t *vam = &vat_main;
19141 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19142 mp->transport_protocol);
19146 vl_api_ipfix_classify_table_details_t_handler_json
19147 (vl_api_ipfix_classify_table_details_t * mp)
19149 vat_json_node_t *node = NULL;
19150 vat_main_t *vam = &vat_main;
19152 if (VAT_JSON_ARRAY != vam->json_tree.type)
19154 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19155 vat_json_init_array (&vam->json_tree);
19158 node = vat_json_array_add (&vam->json_tree);
19159 vat_json_init_object (node);
19161 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19162 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19163 vat_json_object_add_uint (node, "transport_protocol",
19164 mp->transport_protocol);
19168 api_sw_interface_span_enable_disable (vat_main_t * vam)
19170 unformat_input_t *i = vam->input;
19171 vl_api_sw_interface_span_enable_disable_t *mp;
19172 u32 src_sw_if_index = ~0;
19173 u32 dst_sw_if_index = ~0;
19178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19181 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19183 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19187 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19189 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19191 else if (unformat (i, "disable"))
19193 else if (unformat (i, "rx"))
19195 else if (unformat (i, "tx"))
19197 else if (unformat (i, "both"))
19199 else if (unformat (i, "l2"))
19205 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19207 mp->sw_if_index_from = htonl (src_sw_if_index);
19208 mp->sw_if_index_to = htonl (dst_sw_if_index);
19218 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19221 vat_main_t *vam = &vat_main;
19222 u8 *sw_if_from_name = 0;
19223 u8 *sw_if_to_name = 0;
19224 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19225 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19226 char *states[] = { "none", "rx", "tx", "both" };
19230 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19232 if ((u32) p->value[0] == sw_if_index_from)
19234 sw_if_from_name = (u8 *)(p->key);
19238 if ((u32) p->value[0] == sw_if_index_to)
19240 sw_if_to_name = (u8 *)(p->key);
19241 if (sw_if_from_name)
19246 print (vam->ofp, "%20s => %20s (%s) %s",
19247 sw_if_from_name, sw_if_to_name, states[mp->state],
19248 mp->is_l2 ? "l2" : "device");
19252 vl_api_sw_interface_span_details_t_handler_json
19253 (vl_api_sw_interface_span_details_t * mp)
19255 vat_main_t *vam = &vat_main;
19256 vat_json_node_t *node = NULL;
19257 u8 *sw_if_from_name = 0;
19258 u8 *sw_if_to_name = 0;
19259 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19260 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19264 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19266 if ((u32) p->value[0] == sw_if_index_from)
19268 sw_if_from_name = (u8 *)(p->key);
19272 if ((u32) p->value[0] == sw_if_index_to)
19274 sw_if_to_name = (u8 *)(p->key);
19275 if (sw_if_from_name)
19281 if (VAT_JSON_ARRAY != vam->json_tree.type)
19283 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19284 vat_json_init_array (&vam->json_tree);
19286 node = vat_json_array_add (&vam->json_tree);
19288 vat_json_init_object (node);
19289 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19290 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19291 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19292 if (0 != sw_if_to_name)
19294 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19296 vat_json_object_add_uint (node, "state", mp->state);
19297 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
19301 api_sw_interface_span_dump (vat_main_t * vam)
19303 unformat_input_t *input = vam->input;
19304 vl_api_sw_interface_span_dump_t *mp;
19305 vl_api_control_ping_t *mp_ping;
19309 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19311 if (unformat (input, "l2"))
19317 M (SW_INTERFACE_SPAN_DUMP, mp);
19321 /* Use a control ping for synchronization */
19322 MPING (CONTROL_PING, mp_ping);
19330 api_pg_create_interface (vat_main_t * vam)
19332 unformat_input_t *input = vam->input;
19333 vl_api_pg_create_interface_t *mp;
19335 u32 if_id = ~0, gso_size = 0;
19336 u8 gso_enabled = 0;
19338 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19340 if (unformat (input, "if_id %d", &if_id))
19342 else if (unformat (input, "gso-enabled"))
19345 if (unformat (input, "gso-size %u", &gso_size))
19349 errmsg ("missing gso-size");
19358 errmsg ("missing pg interface index");
19362 /* Construct the API message */
19363 M (PG_CREATE_INTERFACE, mp);
19365 mp->interface_id = ntohl (if_id);
19366 mp->gso_enabled = gso_enabled;
19374 api_pg_capture (vat_main_t * vam)
19376 unformat_input_t *input = vam->input;
19377 vl_api_pg_capture_t *mp;
19382 u8 pcap_file_set = 0;
19385 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19387 if (unformat (input, "if_id %d", &if_id))
19389 else if (unformat (input, "pcap %s", &pcap_file))
19391 else if (unformat (input, "count %d", &count))
19393 else if (unformat (input, "disable"))
19400 errmsg ("missing pg interface index");
19403 if (pcap_file_set > 0)
19405 if (vec_len (pcap_file) > 255)
19407 errmsg ("pcap file name is too long");
19412 u32 name_len = vec_len (pcap_file);
19413 /* Construct the API message */
19414 M (PG_CAPTURE, mp);
19416 mp->interface_id = ntohl (if_id);
19417 mp->is_enabled = enable;
19418 mp->count = ntohl (count);
19419 mp->pcap_name_length = ntohl (name_len);
19420 if (pcap_file_set != 0)
19422 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19424 vec_free (pcap_file);
19432 api_pg_enable_disable (vat_main_t * vam)
19434 unformat_input_t *input = vam->input;
19435 vl_api_pg_enable_disable_t *mp;
19438 u8 stream_name_set = 0;
19439 u8 *stream_name = 0;
19441 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19443 if (unformat (input, "stream %s", &stream_name))
19444 stream_name_set = 1;
19445 else if (unformat (input, "disable"))
19451 if (stream_name_set > 0)
19453 if (vec_len (stream_name) > 255)
19455 errmsg ("stream name too long");
19460 u32 name_len = vec_len (stream_name);
19461 /* Construct the API message */
19462 M (PG_ENABLE_DISABLE, mp);
19464 mp->is_enabled = enable;
19465 if (stream_name_set != 0)
19467 mp->stream_name_length = ntohl (name_len);
19468 clib_memcpy (mp->stream_name, stream_name, name_len);
19470 vec_free (stream_name);
19478 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19480 unformat_input_t *input = vam->input;
19481 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19483 u16 *low_ports = 0;
19484 u16 *high_ports = 0;
19487 vl_api_prefix_t prefix;
19494 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19496 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
19498 else if (unformat (input, "vrf %d", &vrf_id))
19500 else if (unformat (input, "del"))
19502 else if (unformat (input, "port %d", &tmp))
19504 if (tmp == 0 || tmp > 65535)
19506 errmsg ("port %d out of range", tmp);
19510 this_hi = this_low + 1;
19511 vec_add1 (low_ports, this_low);
19512 vec_add1 (high_ports, this_hi);
19514 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19516 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19518 errmsg ("incorrect range parameters");
19522 /* Note: in debug CLI +1 is added to high before
19523 passing to real fn that does "the work"
19524 (ip_source_and_port_range_check_add_del).
19525 This fn is a wrapper around the binary API fn a
19526 control plane will call, which expects this increment
19527 to have occurred. Hence letting the binary API control
19528 plane fn do the increment for consistency between VAT
19529 and other control planes.
19532 vec_add1 (low_ports, this_low);
19533 vec_add1 (high_ports, this_hi);
19539 if (prefix_set == 0)
19541 errmsg ("<address>/<mask> not specified");
19547 errmsg ("VRF ID required, not specified");
19554 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19558 if (vec_len (low_ports) == 0)
19560 errmsg ("At least one port or port range required");
19564 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19566 mp->is_add = is_add;
19568 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
19570 mp->number_of_ranges = vec_len (low_ports);
19572 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19573 vec_free (low_ports);
19575 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19576 vec_free (high_ports);
19578 mp->vrf_id = ntohl (vrf_id);
19586 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19588 unformat_input_t *input = vam->input;
19589 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19590 u32 sw_if_index = ~0;
19592 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19593 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19597 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19599 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19601 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19603 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19605 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19607 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19609 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19611 else if (unformat (input, "del"))
19617 if (sw_if_index == ~0)
19619 errmsg ("Interface required but not specified");
19625 errmsg ("VRF ID required but not specified");
19629 if (tcp_out_vrf_id == 0
19630 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
19633 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19637 /* Construct the API message */
19638 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
19640 mp->sw_if_index = ntohl (sw_if_index);
19641 mp->is_add = is_add;
19642 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
19643 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
19644 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
19645 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
19650 /* Wait for a reply... */
19656 api_set_punt (vat_main_t * vam)
19658 unformat_input_t *i = vam->input;
19659 vl_api_address_family_t af;
19660 vl_api_set_punt_t *mp;
19666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19668 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
19670 else if (unformat (i, "protocol %d", &protocol))
19672 else if (unformat (i, "port %d", &port))
19674 else if (unformat (i, "del"))
19678 clib_warning ("parse error '%U'", format_unformat_error, i);
19685 mp->is_add = (u8) is_add;
19686 mp->punt.type = PUNT_API_TYPE_L4;
19687 mp->punt.punt.l4.af = af;
19688 mp->punt.punt.l4.protocol = (u8) protocol;
19689 mp->punt.punt.l4.port = htons ((u16) port);
19697 api_delete_subif (vat_main_t * vam)
19699 unformat_input_t *i = vam->input;
19700 vl_api_delete_subif_t *mp;
19701 u32 sw_if_index = ~0;
19704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19706 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19708 if (unformat (i, "sw_if_index %d", &sw_if_index))
19714 if (sw_if_index == ~0)
19716 errmsg ("missing sw_if_index");
19720 /* Construct the API message */
19721 M (DELETE_SUBIF, mp);
19722 mp->sw_if_index = ntohl (sw_if_index);
19729 #define foreach_pbb_vtr_op \
19730 _("disable", L2_VTR_DISABLED) \
19731 _("pop", L2_VTR_POP_2) \
19732 _("push", L2_VTR_PUSH_2)
19735 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
19737 unformat_input_t *i = vam->input;
19738 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
19739 u32 sw_if_index = ~0, vtr_op = ~0;
19740 u16 outer_tag = ~0;
19741 u8 dmac[6], smac[6];
19742 u8 dmac_set = 0, smac_set = 0;
19748 /* Shut up coverity */
19749 clib_memset (dmac, 0, sizeof (dmac));
19750 clib_memset (smac, 0, sizeof (smac));
19752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19754 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19756 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19758 else if (unformat (i, "vtr_op %d", &vtr_op))
19760 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
19763 else if (unformat (i, "translate_pbb_stag"))
19765 if (unformat (i, "%d", &tmp))
19767 vtr_op = L2_VTR_TRANSLATE_2_1;
19773 ("translate_pbb_stag operation requires outer tag definition");
19777 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
19779 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
19781 else if (unformat (i, "sid %d", &sid))
19783 else if (unformat (i, "vlanid %d", &tmp))
19787 clib_warning ("parse error '%U'", format_unformat_error, i);
19792 if ((sw_if_index == ~0) || (vtr_op == ~0))
19794 errmsg ("missing sw_if_index or vtr operation");
19797 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
19798 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
19801 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
19805 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
19806 mp->sw_if_index = ntohl (sw_if_index);
19807 mp->vtr_op = ntohl (vtr_op);
19808 mp->outer_tag = ntohs (outer_tag);
19809 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
19810 clib_memcpy (mp->b_smac, smac, sizeof (smac));
19811 mp->b_vlanid = ntohs (vlanid);
19812 mp->i_sid = ntohl (sid);
19820 api_flow_classify_set_interface (vat_main_t * vam)
19822 unformat_input_t *i = vam->input;
19823 vl_api_flow_classify_set_interface_t *mp;
19825 int sw_if_index_set;
19826 u32 ip4_table_index = ~0;
19827 u32 ip6_table_index = ~0;
19831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19833 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19834 sw_if_index_set = 1;
19835 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19836 sw_if_index_set = 1;
19837 else if (unformat (i, "del"))
19839 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19841 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19845 clib_warning ("parse error '%U'", format_unformat_error, i);
19850 if (sw_if_index_set == 0)
19852 errmsg ("missing interface name or sw_if_index");
19856 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19858 mp->sw_if_index = ntohl (sw_if_index);
19859 mp->ip4_table_index = ntohl (ip4_table_index);
19860 mp->ip6_table_index = ntohl (ip6_table_index);
19861 mp->is_add = is_add;
19869 api_flow_classify_dump (vat_main_t * vam)
19871 unformat_input_t *i = vam->input;
19872 vl_api_flow_classify_dump_t *mp;
19873 vl_api_control_ping_t *mp_ping;
19874 u8 type = FLOW_CLASSIFY_N_TABLES;
19877 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19881 errmsg ("classify table type must be specified");
19885 if (!vam->json_output)
19887 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19890 M (FLOW_CLASSIFY_DUMP, mp);
19895 /* Use a control ping for synchronization */
19896 MPING (CONTROL_PING, mp_ping);
19899 /* Wait for a reply... */
19905 api_feature_enable_disable (vat_main_t * vam)
19907 unformat_input_t *i = vam->input;
19908 vl_api_feature_enable_disable_t *mp;
19910 u8 *feature_name = 0;
19911 u32 sw_if_index = ~0;
19915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19917 if (unformat (i, "arc_name %s", &arc_name))
19919 else if (unformat (i, "feature_name %s", &feature_name))
19922 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19924 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19926 else if (unformat (i, "disable"))
19934 errmsg ("missing arc name");
19937 if (vec_len (arc_name) > 63)
19939 errmsg ("arc name too long");
19942 if (feature_name == 0)
19944 errmsg ("missing feature name");
19947 if (vec_len (feature_name) > 63)
19949 errmsg ("feature name too long");
19952 if (sw_if_index == ~0)
19954 errmsg ("missing interface name or sw_if_index");
19958 /* Construct the API message */
19959 M (FEATURE_ENABLE_DISABLE, mp);
19960 mp->sw_if_index = ntohl (sw_if_index);
19961 mp->enable = enable;
19962 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19963 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19964 vec_free (arc_name);
19965 vec_free (feature_name);
19973 api_feature_gso_enable_disable (vat_main_t * vam)
19975 unformat_input_t *i = vam->input;
19976 vl_api_feature_gso_enable_disable_t *mp;
19977 u32 sw_if_index = ~0;
19981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19983 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19985 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19987 else if (unformat (i, "enable"))
19989 else if (unformat (i, "disable"))
19995 if (sw_if_index == ~0)
19997 errmsg ("missing interface name or sw_if_index");
20001 /* Construct the API message */
20002 M (FEATURE_GSO_ENABLE_DISABLE, mp);
20003 mp->sw_if_index = ntohl (sw_if_index);
20004 mp->enable_disable = enable;
20012 api_sw_interface_tag_add_del (vat_main_t * vam)
20014 unformat_input_t *i = vam->input;
20015 vl_api_sw_interface_tag_add_del_t *mp;
20016 u32 sw_if_index = ~0;
20021 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20023 if (unformat (i, "tag %s", &tag))
20025 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20027 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20029 else if (unformat (i, "del"))
20035 if (sw_if_index == ~0)
20037 errmsg ("missing interface name or sw_if_index");
20041 if (enable && (tag == 0))
20043 errmsg ("no tag specified");
20047 /* Construct the API message */
20048 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20049 mp->sw_if_index = ntohl (sw_if_index);
20050 mp->is_add = enable;
20052 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20061 api_sw_interface_add_del_mac_address (vat_main_t * vam)
20063 unformat_input_t *i = vam->input;
20064 vl_api_mac_address_t mac = { 0 };
20065 vl_api_sw_interface_add_del_mac_address_t *mp;
20066 u32 sw_if_index = ~0;
20071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20073 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20075 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20077 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
20079 else if (unformat (i, "del"))
20085 if (sw_if_index == ~0)
20087 errmsg ("missing interface name or sw_if_index");
20093 errmsg ("missing MAC address");
20097 /* Construct the API message */
20098 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
20099 mp->sw_if_index = ntohl (sw_if_index);
20100 mp->is_add = is_add;
20101 clib_memcpy (&mp->addr, &mac, sizeof (mac));
20108 static void vl_api_l2_xconnect_details_t_handler
20109 (vl_api_l2_xconnect_details_t * mp)
20111 vat_main_t *vam = &vat_main;
20113 print (vam->ofp, "%15d%15d",
20114 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20117 static void vl_api_l2_xconnect_details_t_handler_json
20118 (vl_api_l2_xconnect_details_t * mp)
20120 vat_main_t *vam = &vat_main;
20121 vat_json_node_t *node = NULL;
20123 if (VAT_JSON_ARRAY != vam->json_tree.type)
20125 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20126 vat_json_init_array (&vam->json_tree);
20128 node = vat_json_array_add (&vam->json_tree);
20130 vat_json_init_object (node);
20131 vat_json_object_add_uint (node, "rx_sw_if_index",
20132 ntohl (mp->rx_sw_if_index));
20133 vat_json_object_add_uint (node, "tx_sw_if_index",
20134 ntohl (mp->tx_sw_if_index));
20138 api_l2_xconnect_dump (vat_main_t * vam)
20140 vl_api_l2_xconnect_dump_t *mp;
20141 vl_api_control_ping_t *mp_ping;
20144 if (!vam->json_output)
20146 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20149 M (L2_XCONNECT_DUMP, mp);
20153 /* Use a control ping for synchronization */
20154 MPING (CONTROL_PING, mp_ping);
20162 api_hw_interface_set_mtu (vat_main_t * vam)
20164 unformat_input_t *i = vam->input;
20165 vl_api_hw_interface_set_mtu_t *mp;
20166 u32 sw_if_index = ~0;
20170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20172 if (unformat (i, "mtu %d", &mtu))
20174 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20176 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20182 if (sw_if_index == ~0)
20184 errmsg ("missing interface name or sw_if_index");
20190 errmsg ("no mtu specified");
20194 /* Construct the API message */
20195 M (HW_INTERFACE_SET_MTU, mp);
20196 mp->sw_if_index = ntohl (sw_if_index);
20197 mp->mtu = ntohs ((u16) mtu);
20205 api_p2p_ethernet_add (vat_main_t * vam)
20207 unformat_input_t *i = vam->input;
20208 vl_api_p2p_ethernet_add_t *mp;
20209 u32 parent_if_index = ~0;
20215 clib_memset (remote_mac, 0, sizeof (remote_mac));
20216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20218 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20220 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20224 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20226 else if (unformat (i, "sub_id %d", &sub_id))
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");
20247 errmsg ("missing sub-interface id");
20251 M (P2P_ETHERNET_ADD, mp);
20252 mp->parent_if_index = ntohl (parent_if_index);
20253 mp->subif_id = ntohl (sub_id);
20254 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20262 api_p2p_ethernet_del (vat_main_t * vam)
20264 unformat_input_t *i = vam->input;
20265 vl_api_p2p_ethernet_del_t *mp;
20266 u32 parent_if_index = ~0;
20271 clib_memset (remote_mac, 0, sizeof (remote_mac));
20272 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20274 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20276 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20280 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20284 clib_warning ("parse error '%U'", format_unformat_error, i);
20289 if (parent_if_index == ~0)
20291 errmsg ("missing interface name or sw_if_index");
20296 errmsg ("missing remote mac address");
20300 M (P2P_ETHERNET_DEL, mp);
20301 mp->parent_if_index = ntohl (parent_if_index);
20302 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20310 api_lldp_config (vat_main_t * vam)
20312 unformat_input_t *i = vam->input;
20313 vl_api_lldp_config_t *mp;
20315 int tx_interval = 0;
20316 u8 *sys_name = NULL;
20319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20321 if (unformat (i, "system-name %s", &sys_name))
20323 else if (unformat (i, "tx-hold %d", &tx_hold))
20325 else if (unformat (i, "tx-interval %d", &tx_interval))
20329 clib_warning ("parse error '%U'", format_unformat_error, i);
20334 vec_add1 (sys_name, 0);
20336 M (LLDP_CONFIG, mp);
20337 mp->tx_hold = htonl (tx_hold);
20338 mp->tx_interval = htonl (tx_interval);
20339 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20340 vec_free (sys_name);
20348 api_sw_interface_set_lldp (vat_main_t * vam)
20350 unformat_input_t *i = vam->input;
20351 vl_api_sw_interface_set_lldp_t *mp;
20352 u32 sw_if_index = ~0;
20354 u8 *port_desc = NULL, *mgmt_oid = NULL;
20355 ip4_address_t ip4_addr;
20356 ip6_address_t ip6_addr;
20359 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
20360 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
20362 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20364 if (unformat (i, "disable"))
20367 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20369 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20371 else if (unformat (i, "port-desc %s", &port_desc))
20373 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20375 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20377 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20383 if (sw_if_index == ~0)
20385 errmsg ("missing interface name or sw_if_index");
20389 /* Construct the API message */
20390 vec_add1 (port_desc, 0);
20391 vec_add1 (mgmt_oid, 0);
20392 M (SW_INTERFACE_SET_LLDP, mp);
20393 mp->sw_if_index = ntohl (sw_if_index);
20394 mp->enable = enable;
20395 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20396 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20397 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20398 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20399 vec_free (port_desc);
20400 vec_free (mgmt_oid);
20408 api_tcp_configure_src_addresses (vat_main_t * vam)
20410 vl_api_tcp_configure_src_addresses_t *mp;
20411 unformat_input_t *i = vam->input;
20412 ip4_address_t v4first, v4last;
20413 ip6_address_t v6first, v6last;
20418 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20420 if (unformat (i, "%U - %U",
20421 unformat_ip4_address, &v4first,
20422 unformat_ip4_address, &v4last))
20426 errmsg ("one range per message (range already set)");
20431 else if (unformat (i, "%U - %U",
20432 unformat_ip6_address, &v6first,
20433 unformat_ip6_address, &v6last))
20437 errmsg ("one range per message (range already set)");
20442 else if (unformat (i, "vrf %d", &vrf_id))
20448 if (range_set == 0)
20450 errmsg ("address range not set");
20454 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20455 mp->vrf_id = ntohl (vrf_id);
20457 if (range_set == 2)
20460 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20461 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20466 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20467 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20474 static void vl_api_app_namespace_add_del_reply_t_handler
20475 (vl_api_app_namespace_add_del_reply_t * mp)
20477 vat_main_t *vam = &vat_main;
20478 i32 retval = ntohl (mp->retval);
20479 if (vam->async_mode)
20481 vam->async_errors += (retval < 0);
20485 vam->retval = retval;
20487 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
20488 vam->result_ready = 1;
20492 static void vl_api_app_namespace_add_del_reply_t_handler_json
20493 (vl_api_app_namespace_add_del_reply_t * mp)
20495 vat_main_t *vam = &vat_main;
20496 vat_json_node_t node;
20498 vat_json_init_object (&node);
20499 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
20500 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
20502 vat_json_print (vam->ofp, &node);
20503 vat_json_free (&node);
20505 vam->retval = ntohl (mp->retval);
20506 vam->result_ready = 1;
20510 api_app_namespace_add_del (vat_main_t * vam)
20512 vl_api_app_namespace_add_del_t *mp;
20513 unformat_input_t *i = vam->input;
20514 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20515 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20519 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20521 if (unformat (i, "id %_%v%_", &ns_id))
20523 else if (unformat (i, "secret %lu", &secret))
20525 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20526 sw_if_index_set = 1;
20527 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20529 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20534 if (!ns_id || !secret_set || !sw_if_index_set)
20536 errmsg ("namespace id, secret and sw_if_index must be set");
20539 if (vec_len (ns_id) > 64)
20541 errmsg ("namespace id too long");
20544 M (APP_NAMESPACE_ADD_DEL, mp);
20546 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20547 mp->namespace_id_len = vec_len (ns_id);
20548 mp->secret = clib_host_to_net_u64 (secret);
20549 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20550 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20551 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20559 api_sock_init_shm (vat_main_t * vam)
20561 #if VPP_API_TEST_BUILTIN == 0
20562 unformat_input_t *i = vam->input;
20563 vl_api_shm_elem_config_t *config = 0;
20564 u64 size = 64 << 20;
20567 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20569 if (unformat (i, "size %U", unformat_memory_size, &size))
20576 * Canned custom ring allocator config.
20577 * Should probably parse all of this
20579 vec_validate (config, 6);
20580 config[0].type = VL_API_VLIB_RING;
20581 config[0].size = 256;
20582 config[0].count = 32;
20584 config[1].type = VL_API_VLIB_RING;
20585 config[1].size = 1024;
20586 config[1].count = 16;
20588 config[2].type = VL_API_VLIB_RING;
20589 config[2].size = 4096;
20590 config[2].count = 2;
20592 config[3].type = VL_API_CLIENT_RING;
20593 config[3].size = 256;
20594 config[3].count = 32;
20596 config[4].type = VL_API_CLIENT_RING;
20597 config[4].size = 1024;
20598 config[4].count = 16;
20600 config[5].type = VL_API_CLIENT_RING;
20601 config[5].size = 4096;
20602 config[5].count = 2;
20604 config[6].type = VL_API_QUEUE;
20605 config[6].count = 128;
20606 config[6].size = sizeof (uword);
20608 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
20610 vam->client_index_invalid = 1;
20618 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
20620 vat_main_t *vam = &vat_main;
20625 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20626 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20627 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
20628 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
20629 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20630 clib_net_to_host_u32 (mp->action_index), mp->tag);
20635 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20636 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20637 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
20638 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
20639 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20640 clib_net_to_host_u32 (mp->action_index), mp->tag);
20645 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
20648 vat_main_t *vam = &vat_main;
20649 vat_json_node_t *node = NULL;
20650 struct in6_addr ip6;
20651 struct in_addr ip4;
20653 if (VAT_JSON_ARRAY != vam->json_tree.type)
20655 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20656 vat_json_init_array (&vam->json_tree);
20658 node = vat_json_array_add (&vam->json_tree);
20659 vat_json_init_object (node);
20661 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
20662 vat_json_object_add_uint (node, "appns_index",
20663 clib_net_to_host_u32 (mp->appns_index));
20664 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
20665 vat_json_object_add_uint (node, "scope", mp->scope);
20666 vat_json_object_add_uint (node, "action_index",
20667 clib_net_to_host_u32 (mp->action_index));
20668 vat_json_object_add_uint (node, "lcl_port",
20669 clib_net_to_host_u16 (mp->lcl_port));
20670 vat_json_object_add_uint (node, "rmt_port",
20671 clib_net_to_host_u16 (mp->rmt_port));
20672 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
20673 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
20674 vat_json_object_add_string_copy (node, "tag", mp->tag);
20677 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
20678 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
20679 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
20680 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
20684 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
20685 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
20686 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
20687 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
20692 api_session_rule_add_del (vat_main_t * vam)
20694 vl_api_session_rule_add_del_t *mp;
20695 unformat_input_t *i = vam->input;
20696 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
20697 u32 appns_index = 0, scope = 0;
20698 ip4_address_t lcl_ip4, rmt_ip4;
20699 ip6_address_t lcl_ip6, rmt_ip6;
20700 u8 is_ip4 = 1, conn_set = 0;
20701 u8 is_add = 1, *tag = 0;
20704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20706 if (unformat (i, "del"))
20708 else if (unformat (i, "add"))
20710 else if (unformat (i, "proto tcp"))
20712 else if (unformat (i, "proto udp"))
20714 else if (unformat (i, "appns %d", &appns_index))
20716 else if (unformat (i, "scope %d", &scope))
20718 else if (unformat (i, "tag %_%v%_", &tag))
20722 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
20723 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
20731 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
20732 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
20738 else if (unformat (i, "action %d", &action))
20743 if (proto == ~0 || !conn_set || action == ~0)
20745 errmsg ("transport proto, connection and action must be set");
20751 errmsg ("scope should be 0-3");
20755 M (SESSION_RULE_ADD_DEL, mp);
20757 mp->is_ip4 = is_ip4;
20758 mp->transport_proto = proto;
20759 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
20760 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
20761 mp->lcl_plen = lcl_plen;
20762 mp->rmt_plen = rmt_plen;
20763 mp->action_index = clib_host_to_net_u32 (action);
20764 mp->appns_index = clib_host_to_net_u32 (appns_index);
20766 mp->is_add = is_add;
20769 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
20770 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
20774 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
20775 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
20779 clib_memcpy (mp->tag, tag, vec_len (tag));
20789 api_session_rules_dump (vat_main_t * vam)
20791 vl_api_session_rules_dump_t *mp;
20792 vl_api_control_ping_t *mp_ping;
20795 if (!vam->json_output)
20797 print (vam->ofp, "%=20s", "Session Rules");
20800 M (SESSION_RULES_DUMP, mp);
20804 /* Use a control ping for synchronization */
20805 MPING (CONTROL_PING, mp_ping);
20808 /* Wait for a reply... */
20814 api_ip_container_proxy_add_del (vat_main_t * vam)
20816 vl_api_ip_container_proxy_add_del_t *mp;
20817 unformat_input_t *i = vam->input;
20818 u32 sw_if_index = ~0;
20819 vl_api_prefix_t pfx = { };
20823 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20825 if (unformat (i, "del"))
20827 else if (unformat (i, "add"))
20829 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
20831 else if (unformat (i, "sw_if_index %u", &sw_if_index))
20836 if (sw_if_index == ~0 || pfx.len == 0)
20838 errmsg ("address and sw_if_index must be set");
20842 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
20844 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20845 mp->is_add = is_add;
20846 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
20854 api_qos_record_enable_disable (vat_main_t * vam)
20856 unformat_input_t *i = vam->input;
20857 vl_api_qos_record_enable_disable_t *mp;
20858 u32 sw_if_index, qs = 0xff;
20859 u8 sw_if_index_set = 0;
20863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20865 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20866 sw_if_index_set = 1;
20867 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20868 sw_if_index_set = 1;
20869 else if (unformat (i, "%U", unformat_qos_source, &qs))
20871 else if (unformat (i, "disable"))
20875 clib_warning ("parse error '%U'", format_unformat_error, i);
20880 if (sw_if_index_set == 0)
20882 errmsg ("missing interface name or sw_if_index");
20887 errmsg ("input location must be specified");
20891 M (QOS_RECORD_ENABLE_DISABLE, mp);
20893 mp->record.sw_if_index = ntohl (sw_if_index);
20894 mp->record.input_source = qs;
20895 mp->enable = enable;
20904 q_or_quit (vat_main_t * vam)
20906 #if VPP_API_TEST_BUILTIN == 0
20907 longjmp (vam->jump_buf, 1);
20909 return 0; /* not so much */
20913 q (vat_main_t * vam)
20915 return q_or_quit (vam);
20919 quit (vat_main_t * vam)
20921 return q_or_quit (vam);
20925 comment (vat_main_t * vam)
20931 elog_save (vat_main_t * vam)
20933 #if VPP_API_TEST_BUILTIN == 0
20934 elog_main_t *em = &vam->elog_main;
20935 unformat_input_t *i = vam->input;
20936 char *file, *chroot_file;
20937 clib_error_t *error;
20939 if (!unformat (i, "%s", &file))
20941 errmsg ("expected file name, got `%U'", format_unformat_error, i);
20945 /* It's fairly hard to get "../oopsie" through unformat; just in case */
20946 if (strstr (file, "..") || index (file, '/'))
20948 errmsg ("illegal characters in filename '%s'", file);
20952 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
20956 errmsg ("Saving %wd of %wd events to %s",
20957 elog_n_events_in_buffer (em),
20958 elog_buffer_capacity (em), chroot_file);
20960 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
20961 vec_free (chroot_file);
20964 clib_error_report (error);
20966 errmsg ("Use the vpp event loger...");
20973 elog_setup (vat_main_t * vam)
20975 #if VPP_API_TEST_BUILTIN == 0
20976 elog_main_t *em = &vam->elog_main;
20977 unformat_input_t *i = vam->input;
20978 u32 nevents = 128 << 10;
20980 (void) unformat (i, "nevents %d", &nevents);
20982 elog_init (em, nevents);
20983 vl_api_set_elog_main (em);
20984 vl_api_set_elog_trace_api_messages (1);
20985 errmsg ("Event logger initialized with %u events", nevents);
20987 errmsg ("Use the vpp event loger...");
20993 elog_enable (vat_main_t * vam)
20995 #if VPP_API_TEST_BUILTIN == 0
20996 elog_main_t *em = &vam->elog_main;
20998 elog_enable_disable (em, 1 /* enable */ );
20999 vl_api_set_elog_trace_api_messages (1);
21000 errmsg ("Event logger enabled...");
21002 errmsg ("Use the vpp event loger...");
21008 elog_disable (vat_main_t * vam)
21010 #if VPP_API_TEST_BUILTIN == 0
21011 elog_main_t *em = &vam->elog_main;
21013 elog_enable_disable (em, 0 /* enable */ );
21014 vl_api_set_elog_trace_api_messages (1);
21015 errmsg ("Event logger disabled...");
21017 errmsg ("Use the vpp event loger...");
21023 statseg (vat_main_t * vam)
21025 ssvm_private_t *ssvmp = &vam->stat_segment;
21026 ssvm_shared_header_t *shared_header = ssvmp->sh;
21027 vlib_counter_t **counters;
21028 u64 thread0_index1_packets;
21029 u64 thread0_index1_bytes;
21030 f64 vector_rate, input_rate;
21033 uword *counter_vector_by_name;
21034 if (vam->stat_segment_lockp == 0)
21036 errmsg ("Stat segment not mapped...");
21040 /* look up "/if/rx for sw_if_index 1 as a test */
21042 clib_spinlock_lock (vam->stat_segment_lockp);
21044 counter_vector_by_name = (uword *) shared_header->opaque[1];
21046 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21049 clib_spinlock_unlock (vam->stat_segment_lockp);
21050 errmsg ("/if/tx not found?");
21054 /* Fish per-thread vector of combined counters from shared memory */
21055 counters = (vlib_counter_t **) p[0];
21057 if (vec_len (counters[0]) < 2)
21059 clib_spinlock_unlock (vam->stat_segment_lockp);
21060 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21064 /* Read thread 0 sw_if_index 1 counter */
21065 thread0_index1_packets = counters[0][1].packets;
21066 thread0_index1_bytes = counters[0][1].bytes;
21068 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21071 clib_spinlock_unlock (vam->stat_segment_lockp);
21072 errmsg ("vector_rate not found?");
21076 vector_rate = *(f64 *) (p[0]);
21077 p = hash_get_mem (counter_vector_by_name, "input_rate");
21080 clib_spinlock_unlock (vam->stat_segment_lockp);
21081 errmsg ("input_rate not found?");
21084 input_rate = *(f64 *) (p[0]);
21086 clib_spinlock_unlock (vam->stat_segment_lockp);
21088 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21089 vector_rate, input_rate);
21090 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21091 thread0_index1_packets, thread0_index1_bytes);
21097 cmd_cmp (void *a1, void *a2)
21102 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21106 help (vat_main_t * vam)
21111 unformat_input_t *i = vam->input;
21114 if (unformat (i, "%s", &name))
21118 vec_add1 (name, 0);
21120 hs = hash_get_mem (vam->help_by_name, name);
21122 print (vam->ofp, "usage: %s %s", name, hs[0]);
21124 print (vam->ofp, "No such msg / command '%s'", name);
21129 print (vam->ofp, "Help is available for the following:");
21132 hash_foreach_pair (p, vam->function_by_name,
21134 vec_add1 (cmds, (u8 *)(p->key));
21138 vec_sort_with_function (cmds, cmd_cmp);
21140 for (j = 0; j < vec_len (cmds); j++)
21141 print (vam->ofp, "%s", cmds[j]);
21148 set (vat_main_t * vam)
21150 u8 *name = 0, *value = 0;
21151 unformat_input_t *i = vam->input;
21153 if (unformat (i, "%s", &name))
21155 /* The input buffer is a vector, not a string. */
21156 value = vec_dup (i->buffer);
21157 vec_delete (value, i->index, 0);
21158 /* Almost certainly has a trailing newline */
21159 if (value[vec_len (value) - 1] == '\n')
21160 value[vec_len (value) - 1] = 0;
21161 /* Make sure it's a proper string, one way or the other */
21162 vec_add1 (value, 0);
21163 (void) clib_macro_set_value (&vam->macro_main,
21164 (char *) name, (char *) value);
21167 errmsg ("usage: set <name> <value>");
21175 unset (vat_main_t * vam)
21179 if (unformat (vam->input, "%s", &name))
21180 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21181 errmsg ("unset: %s wasn't set", name);
21194 macro_sort_cmp (void *a1, void *a2)
21196 macro_sort_t *s1 = a1;
21197 macro_sort_t *s2 = a2;
21199 return strcmp ((char *) (s1->name), (char *) (s2->name));
21203 dump_macro_table (vat_main_t * vam)
21205 macro_sort_t *sort_me = 0, *sm;
21210 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21212 vec_add2 (sort_me, sm, 1);
21213 sm->name = (u8 *)(p->key);
21214 sm->value = (u8 *) (p->value[0]);
21218 vec_sort_with_function (sort_me, macro_sort_cmp);
21220 if (vec_len (sort_me))
21221 print (vam->ofp, "%-15s%s", "Name", "Value");
21223 print (vam->ofp, "The macro table is empty...");
21225 for (i = 0; i < vec_len (sort_me); i++)
21226 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21231 dump_node_table (vat_main_t * vam)
21234 vlib_node_t *node, *next_node;
21236 if (vec_len (vam->graph_nodes) == 0)
21238 print (vam->ofp, "Node table empty, issue get_node_graph...");
21242 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
21244 node = vam->graph_nodes[0][i];
21245 print (vam->ofp, "[%d] %s", i, node->name);
21246 for (j = 0; j < vec_len (node->next_nodes); j++)
21248 if (node->next_nodes[j] != ~0)
21250 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21251 print (vam->ofp, " [%d] %s", j, next_node->name);
21259 value_sort_cmp (void *a1, void *a2)
21261 name_sort_t *n1 = a1;
21262 name_sort_t *n2 = a2;
21264 if (n1->value < n2->value)
21266 if (n1->value > n2->value)
21273 dump_msg_api_table (vat_main_t * vam)
21275 api_main_t *am = &api_main;
21276 name_sort_t *nses = 0, *ns;
21281 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21283 vec_add2 (nses, ns, 1);
21284 ns->name = (u8 *)(hp->key);
21285 ns->value = (u32) hp->value[0];
21289 vec_sort_with_function (nses, value_sort_cmp);
21291 for (i = 0; i < vec_len (nses); i++)
21292 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21298 get_msg_id (vat_main_t * vam)
21303 if (unformat (vam->input, "%s", &name_and_crc))
21305 message_index = vl_msg_api_get_msg_index (name_and_crc);
21306 if (message_index == ~0)
21308 print (vam->ofp, " '%s' not found", name_and_crc);
21311 print (vam->ofp, " '%s' has message index %d",
21312 name_and_crc, message_index);
21315 errmsg ("name_and_crc required...");
21320 search_node_table (vat_main_t * vam)
21322 unformat_input_t *line_input = vam->input;
21325 vlib_node_t *node, *next_node;
21328 if (vam->graph_node_index_by_name == 0)
21330 print (vam->ofp, "Node table empty, issue get_node_graph...");
21334 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21336 if (unformat (line_input, "%s", &node_to_find))
21338 vec_add1 (node_to_find, 0);
21339 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21342 print (vam->ofp, "%s not found...", node_to_find);
21345 node = vam->graph_nodes[0][p[0]];
21346 print (vam->ofp, "[%d] %s", p[0], node->name);
21347 for (j = 0; j < vec_len (node->next_nodes); j++)
21349 if (node->next_nodes[j] != ~0)
21351 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21352 print (vam->ofp, " [%d] %s", j, next_node->name);
21359 clib_warning ("parse error '%U'", format_unformat_error,
21365 vec_free (node_to_find);
21374 script (vat_main_t * vam)
21376 #if (VPP_API_TEST_BUILTIN==0)
21378 char *save_current_file;
21379 unformat_input_t save_input;
21380 jmp_buf save_jump_buf;
21381 u32 save_line_number;
21383 FILE *new_fp, *save_ifp;
21385 if (unformat (vam->input, "%s", &s))
21387 new_fp = fopen ((char *) s, "r");
21390 errmsg ("Couldn't open script file %s", s);
21397 errmsg ("Missing script name");
21401 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21402 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21403 save_ifp = vam->ifp;
21404 save_line_number = vam->input_line_number;
21405 save_current_file = (char *) vam->current_file;
21407 vam->input_line_number = 0;
21409 vam->current_file = s;
21412 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
21413 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21414 vam->ifp = save_ifp;
21415 vam->input_line_number = save_line_number;
21416 vam->current_file = (u8 *) save_current_file;
21421 clib_warning ("use the exec command...");
21427 echo (vat_main_t * vam)
21429 print (vam->ofp, "%v", vam->input->buffer);
21433 /* List of API message constructors, CLI names map to api_xxx */
21434 #define foreach_vpe_api_msg \
21435 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21436 _(sw_interface_dump,"") \
21437 _(sw_interface_set_flags, \
21438 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21439 _(sw_interface_add_del_address, \
21440 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21441 _(sw_interface_set_rx_mode, \
21442 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
21443 _(sw_interface_set_rx_placement, \
21444 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
21445 _(sw_interface_rx_placement_dump, \
21446 "[<intfc> | sw_if_index <id>]") \
21447 _(sw_interface_set_table, \
21448 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21449 _(sw_interface_set_mpls_enable, \
21450 "<intfc> | sw_if_index [disable | dis]") \
21451 _(sw_interface_set_vpath, \
21452 "<intfc> | sw_if_index <id> enable | disable") \
21453 _(sw_interface_set_vxlan_bypass, \
21454 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21455 _(sw_interface_set_geneve_bypass, \
21456 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21457 _(sw_interface_set_l2_xconnect, \
21458 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21459 "enable | disable") \
21460 _(sw_interface_set_l2_bridge, \
21461 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21462 "[shg <split-horizon-group>] [bvi]\n" \
21463 "enable | disable") \
21464 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21465 _(bridge_domain_add_del, \
21466 "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") \
21467 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21469 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21470 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21471 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21473 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21475 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21477 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
21479 "<vpp-if-name> | sw_if_index <id>") \
21480 _(sw_interface_tap_v2_dump, "") \
21481 _(virtio_pci_create, \
21482 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled]") \
21483 _(virtio_pci_delete, \
21484 "<vpp-if-name> | sw_if_index <id>") \
21485 _(sw_interface_virtio_pci_dump, "") \
21487 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
21488 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
21491 "<vpp-if-name> | sw_if_index <id>") \
21493 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
21494 _(bond_detach_slave, \
21495 "sw_if_index <n>") \
21496 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
21497 _(sw_interface_bond_dump, "") \
21498 _(sw_interface_slave_dump, \
21499 "<vpp-if-name> | sw_if_index <id>") \
21500 _(ip_table_add_del, \
21501 "table <n> [ipv6] [add | del]\n") \
21502 _(ip_route_add_del, \
21503 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
21504 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
21505 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
21506 "[multipath] [count <n>] [del]") \
21507 _(ip_mroute_add_del, \
21508 "<src> <grp>/<mask> [table-id <n>]\n" \
21509 "[<intfc> | sw_if_index <id>] [local] [del]") \
21510 _(mpls_table_add_del, \
21511 "table <n> [add | del]\n") \
21512 _(mpls_route_add_del, \
21513 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
21514 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
21515 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
21516 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
21517 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
21518 "[count <n>] [del]") \
21519 _(mpls_ip_bind_unbind, \
21520 "<label> <addr/len>") \
21521 _(mpls_tunnel_add_del, \
21522 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
21523 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
21524 "[l2-only] [out-label <n>]") \
21525 _(sr_mpls_policy_add, \
21526 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
21527 _(sr_mpls_policy_del, \
21529 _(bier_table_add_del, \
21530 "<label> <sub-domain> <set> <bsl> [del]") \
21531 _(bier_route_add_del, \
21532 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
21533 "[<intfc> | sw_if_index <id>]" \
21534 "[weight <n>] [del] [multipath]") \
21535 _(proxy_arp_add_del, \
21536 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21537 _(proxy_arp_intfc_enable_disable, \
21538 "<intfc> | sw_if_index <id> enable | disable") \
21539 _(sw_interface_set_unnumbered, \
21540 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21541 _(ip_neighbor_add_del, \
21542 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21543 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21544 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21545 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21546 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21547 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21548 "[outer_vlan_id_any][inner_vlan_id_any]") \
21549 _(reset_fib, "vrf <n> [ipv6]") \
21550 _(set_ip_flow_hash, \
21551 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21552 _(sw_interface_ip6_enable_disable, \
21553 "<intfc> | sw_if_index <id> enable | disable") \
21554 _(ip6nd_proxy_add_del, \
21555 "<intfc> | sw_if_index <id> <ip6-address>") \
21556 _(ip6nd_proxy_dump, "") \
21557 _(sw_interface_ip6nd_ra_prefix, \
21558 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21559 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21560 "[nolink] [isno]") \
21561 _(sw_interface_ip6nd_ra_config, \
21562 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21563 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21564 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21565 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21566 _(l2_patch_add_del, \
21567 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21568 "enable | disable") \
21569 _(sr_localsid_add_del, \
21570 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21571 "fib-table <num> (end.psp) sw_if_index <num>") \
21572 _(classify_add_del_table, \
21573 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21574 " [del] [del-chain] mask <mask-value>\n" \
21575 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21576 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21577 _(classify_add_del_session, \
21578 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21579 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21580 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21581 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21582 _(classify_set_interface_ip_table, \
21583 "<intfc> | sw_if_index <nn> table <nn>") \
21584 _(classify_set_interface_l2_tables, \
21585 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21586 " [other-table <nn>]") \
21587 _(get_node_index, "node <node-name") \
21588 _(add_node_next, "node <node-name> next <next-node-name>") \
21589 _(l2tpv3_create_tunnel, \
21590 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21591 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21592 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21593 _(l2tpv3_set_tunnel_cookies, \
21594 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21595 "[new_remote_cookie <nn>]\n") \
21596 _(l2tpv3_interface_enable_disable, \
21597 "<intfc> | sw_if_index <nn> enable | disable") \
21598 _(l2tpv3_set_lookup_key, \
21599 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21600 _(sw_if_l2tpv3_tunnel_dump, "") \
21601 _(vxlan_offload_rx, \
21602 "hw { <interface name> | hw_if_index <nn>} " \
21603 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
21604 _(vxlan_add_del_tunnel, \
21605 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21606 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
21607 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21608 _(geneve_add_del_tunnel, \
21609 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21610 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21611 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21612 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21613 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21614 _(gre_tunnel_add_del, \
21615 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
21616 "[teb | erspan <session-id>] [del]") \
21617 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21618 _(l2_fib_clear_table, "") \
21619 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21620 _(l2_interface_vlan_tag_rewrite, \
21621 "<intfc> | sw_if_index <nn> \n" \
21622 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21623 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21624 _(create_vhost_user_if, \
21625 "socket <filename> [server] [renumber <dev_instance>] " \
21626 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
21627 "[mac <mac_address>]") \
21628 _(modify_vhost_user_if, \
21629 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21630 "[server] [renumber <dev_instance>] [gso]") \
21631 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21632 _(sw_interface_vhost_user_dump, "") \
21633 _(show_version, "") \
21634 _(show_threads, "") \
21635 _(vxlan_gpe_add_del_tunnel, \
21636 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21637 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21638 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21639 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21640 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21641 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21642 _(interface_name_renumber, \
21643 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21644 _(input_acl_set_interface, \
21645 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21646 " [l2-table <nn>] [del]") \
21647 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
21648 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
21649 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
21650 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21651 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21652 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21653 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21654 _(ip_dump, "ipv4 | ipv6") \
21655 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21656 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21658 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21659 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21660 " integ_alg <alg> integ_key <hex>") \
21661 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
21662 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21663 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21664 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21665 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21666 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21667 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21668 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
21669 " [instance <n>]") \
21670 _(ipsec_sa_dump, "[sa_id <n>]") \
21671 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
21672 _(delete_loopback,"sw_if_index <nn>") \
21673 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21674 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
21675 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
21676 _(want_interface_events, "enable|disable") \
21677 _(get_first_msg_id, "client <name>") \
21678 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21679 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21680 "fib-id <nn> [ip4][ip6][default]") \
21681 _(get_node_graph, " ") \
21682 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21683 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21684 _(ioam_disable, "") \
21685 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21686 " sw_if_index <sw_if_index> p <priority> " \
21687 "w <weight>] [del]") \
21688 _(one_add_del_locator, "locator-set <locator_name> " \
21689 "iface <intf> | sw_if_index <sw_if_index> " \
21690 "p <priority> w <weight> [del]") \
21691 _(one_add_del_local_eid,"vni <vni> eid " \
21692 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21693 "locator-set <locator_name> [del]" \
21694 "[key-id sha1|sha256 secret-key <secret-key>]")\
21695 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21696 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21697 _(one_enable_disable, "enable|disable") \
21698 _(one_map_register_enable_disable, "enable|disable") \
21699 _(one_map_register_fallback_threshold, "<value>") \
21700 _(one_rloc_probe_enable_disable, "enable|disable") \
21701 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21703 "rloc <locator> p <prio> " \
21704 "w <weight> [rloc <loc> ... ] " \
21705 "action <action> [del-all]") \
21706 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21708 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21709 _(one_use_petr, "ip-address> | disable") \
21710 _(one_map_request_mode, "src-dst|dst-only") \
21711 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21712 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21713 _(one_locator_set_dump, "[local | remote]") \
21714 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21715 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21716 "[local] | [remote]") \
21717 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21718 _(one_ndp_bd_get, "") \
21719 _(one_ndp_entries_get, "bd <bridge-domain>") \
21720 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21721 _(one_l2_arp_bd_get, "") \
21722 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21723 _(one_stats_enable_disable, "enable|disable") \
21724 _(show_one_stats_enable_disable, "") \
21725 _(one_eid_table_vni_dump, "") \
21726 _(one_eid_table_map_dump, "l2|l3") \
21727 _(one_map_resolver_dump, "") \
21728 _(one_map_server_dump, "") \
21729 _(one_adjacencies_get, "vni <vni>") \
21730 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21731 _(show_one_rloc_probe_state, "") \
21732 _(show_one_map_register_state, "") \
21733 _(show_one_status, "") \
21734 _(one_stats_dump, "") \
21735 _(one_stats_flush, "") \
21736 _(one_get_map_request_itr_rlocs, "") \
21737 _(one_map_register_set_ttl, "<ttl>") \
21738 _(one_set_transport_protocol, "udp|api") \
21739 _(one_get_transport_protocol, "") \
21740 _(one_enable_disable_xtr_mode, "enable|disable") \
21741 _(one_show_xtr_mode, "") \
21742 _(one_enable_disable_pitr_mode, "enable|disable") \
21743 _(one_show_pitr_mode, "") \
21744 _(one_enable_disable_petr_mode, "enable|disable") \
21745 _(one_show_petr_mode, "") \
21746 _(show_one_nsh_mapping, "") \
21747 _(show_one_pitr, "") \
21748 _(show_one_use_petr, "") \
21749 _(show_one_map_request_mode, "") \
21750 _(show_one_map_register_ttl, "") \
21751 _(show_one_map_register_fallback_threshold, "") \
21752 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21753 " sw_if_index <sw_if_index> p <priority> " \
21754 "w <weight>] [del]") \
21755 _(lisp_add_del_locator, "locator-set <locator_name> " \
21756 "iface <intf> | sw_if_index <sw_if_index> " \
21757 "p <priority> w <weight> [del]") \
21758 _(lisp_add_del_local_eid,"vni <vni> eid " \
21759 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21760 "locator-set <locator_name> [del]" \
21761 "[key-id sha1|sha256 secret-key <secret-key>]") \
21762 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21763 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21764 _(lisp_enable_disable, "enable|disable") \
21765 _(lisp_map_register_enable_disable, "enable|disable") \
21766 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21767 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21769 "rloc <locator> p <prio> " \
21770 "w <weight> [rloc <loc> ... ] " \
21771 "action <action> [del-all]") \
21772 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21774 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21775 _(lisp_use_petr, "<ip-address> | disable") \
21776 _(lisp_map_request_mode, "src-dst|dst-only") \
21777 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21778 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21779 _(lisp_locator_set_dump, "[local | remote]") \
21780 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21781 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21782 "[local] | [remote]") \
21783 _(lisp_eid_table_vni_dump, "") \
21784 _(lisp_eid_table_map_dump, "l2|l3") \
21785 _(lisp_map_resolver_dump, "") \
21786 _(lisp_map_server_dump, "") \
21787 _(lisp_adjacencies_get, "vni <vni>") \
21788 _(gpe_fwd_entry_vnis_get, "") \
21789 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21790 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21791 "[table <table-id>]") \
21792 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21793 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21794 _(gpe_set_encap_mode, "lisp|vxlan") \
21795 _(gpe_get_encap_mode, "") \
21796 _(lisp_gpe_add_del_iface, "up|down") \
21797 _(lisp_gpe_enable_disable, "enable|disable") \
21798 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21799 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21800 _(show_lisp_rloc_probe_state, "") \
21801 _(show_lisp_map_register_state, "") \
21802 _(show_lisp_status, "") \
21803 _(lisp_get_map_request_itr_rlocs, "") \
21804 _(show_lisp_pitr, "") \
21805 _(show_lisp_use_petr, "") \
21806 _(show_lisp_map_request_mode, "") \
21807 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21808 _(af_packet_delete, "name <host interface name>") \
21809 _(af_packet_dump, "") \
21810 _(policer_add_del, "name <policer name> <params> [del]") \
21811 _(policer_dump, "[name <policer name>]") \
21812 _(policer_classify_set_interface, \
21813 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21814 " [l2-table <nn>] [del]") \
21815 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21816 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21817 "[master|slave]") \
21818 _(netmap_delete, "name <interface name>") \
21819 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21820 _(mpls_table_dump, "") \
21821 _(mpls_route_dump, "table-id <ID>") \
21822 _(classify_table_ids, "") \
21823 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21824 _(classify_table_info, "table_id <nn>") \
21825 _(classify_session_dump, "table_id <nn>") \
21826 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21827 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21828 "[template_interval <nn>] [udp_checksum]") \
21829 _(ipfix_exporter_dump, "") \
21830 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21831 _(ipfix_classify_stream_dump, "") \
21832 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21833 _(ipfix_classify_table_dump, "") \
21834 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21835 _(sw_interface_span_dump, "[l2]") \
21836 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21837 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
21838 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21839 _(pg_enable_disable, "[stream <id>] disable") \
21840 _(ip_source_and_port_range_check_add_del, \
21841 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21842 _(ip_source_and_port_range_check_interface_add_del, \
21843 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21844 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21845 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21846 _(l2_interface_pbb_tag_rewrite, \
21847 "<intfc> | sw_if_index <nn> \n" \
21848 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21849 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21850 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21851 _(flow_classify_set_interface, \
21852 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21853 _(flow_classify_dump, "type [ip4|ip6]") \
21854 _(ip_table_dump, "") \
21855 _(ip_route_dump, "table-id [ip4|ip6]") \
21856 _(ip_mtable_dump, "") \
21857 _(ip_mroute_dump, "table-id [ip4|ip6]") \
21858 _(feature_enable_disable, "arc_name <arc_name> " \
21859 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21860 _(feature_gso_enable_disable, "<intfc> | sw_if_index <nn> " \
21861 "[enable | disable] ") \
21862 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21864 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
21865 "mac <mac-address> [del]") \
21866 _(l2_xconnect_dump, "") \
21867 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
21868 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21869 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21870 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21871 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21872 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21873 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21874 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21875 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21876 _(sock_init_shm, "size <nnn>") \
21877 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21878 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
21879 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
21880 _(session_rules_dump, "") \
21881 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
21882 _(output_acl_set_interface, \
21883 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21884 " [l2-table <nn>] [del]") \
21885 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
21887 /* List of command functions, CLI names map directly to functions */
21888 #define foreach_cli_function \
21889 _(comment, "usage: comment <ignore-rest-of-line>") \
21890 _(dump_interface_table, "usage: dump_interface_table") \
21891 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21892 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21893 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21894 _(dump_macro_table, "usage: dump_macro_table ") \
21895 _(dump_node_table, "usage: dump_node_table") \
21896 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21897 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
21898 _(elog_disable, "usage: elog_disable") \
21899 _(elog_enable, "usage: elog_enable") \
21900 _(elog_save, "usage: elog_save <filename>") \
21901 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21902 _(echo, "usage: echo <message>") \
21903 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21904 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21905 _(help, "usage: help") \
21906 _(q, "usage: quit") \
21907 _(quit, "usage: quit") \
21908 _(search_node_table, "usage: search_node_table <name>...") \
21909 _(set, "usage: set <variable-name> <value>") \
21910 _(script, "usage: script <file-name>") \
21911 _(statseg, "usage: statseg") \
21912 _(unset, "usage: unset <variable-name>")
21915 static void vl_api_##n##_t_handler_uni \
21916 (vl_api_##n##_t * mp) \
21918 vat_main_t * vam = &vat_main; \
21919 if (vam->json_output) { \
21920 vl_api_##n##_t_handler_json(mp); \
21922 vl_api_##n##_t_handler(mp); \
21925 foreach_vpe_api_reply_msg;
21926 #if VPP_API_TEST_BUILTIN == 0
21927 foreach_standalone_reply_msg;
21932 vat_api_hookup (vat_main_t * vam)
21935 vl_msg_api_set_handlers(VL_API_##N, #n, \
21936 vl_api_##n##_t_handler_uni, \
21938 vl_api_##n##_t_endian, \
21939 vl_api_##n##_t_print, \
21940 sizeof(vl_api_##n##_t), 1);
21941 foreach_vpe_api_reply_msg;
21942 #if VPP_API_TEST_BUILTIN == 0
21943 foreach_standalone_reply_msg;
21947 #if (VPP_API_TEST_BUILTIN==0)
21948 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21950 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21952 vam->function_by_name = hash_create_string (0, sizeof (uword));
21954 vam->help_by_name = hash_create_string (0, sizeof (uword));
21957 /* API messages we can send */
21958 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21959 foreach_vpe_api_msg;
21963 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21964 foreach_vpe_api_msg;
21967 /* CLI functions */
21968 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21969 foreach_cli_function;
21973 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21974 foreach_cli_function;
21978 #if VPP_API_TEST_BUILTIN
21979 static clib_error_t *
21980 vat_api_hookup_shim (vlib_main_t * vm)
21982 vat_api_hookup (&vat_main);
21986 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21990 * fd.io coding-style-patch-verification: ON
21993 * eval: (c-set-style "gnu")